commit 7c274da003c9872d75f76a89a125adbb078985e8 Author: Matthias Date: Tue Apr 11 15:47:10 2017 +0200 Initial Commit diff --git a/WFRperfTool.edit/.classpath b/WFRperfTool.edit/.classpath new file mode 100755 index 0000000..121e527 --- /dev/null +++ b/WFRperfTool.edit/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/WFRperfTool.edit/.project b/WFRperfTool.edit/.project new file mode 100755 index 0000000..34cf512 --- /dev/null +++ b/WFRperfTool.edit/.project @@ -0,0 +1,28 @@ + + + WFRperfTool.edit + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + diff --git a/WFRperfTool.edit/META-INF/MANIFEST.MF b/WFRperfTool.edit/META-INF/MANIFEST.MF new file mode 100755 index 0000000..c41b7d7 --- /dev/null +++ b/WFRperfTool.edit/META-INF/MANIFEST.MF @@ -0,0 +1,15 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: WFRperfTool.edit;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-ClassPath: . +Bundle-Activator: at.ac.uibk.wfr.perftool.provider.WFRperfToolModelEditPlugin$Implementation +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Export-Package: at.ac.uibk.wfr.perftool.provider +Require-Bundle: org.eclipse.core.runtime, + WFRperfTool;visibility:=reexport, + org.eclipse.emf.edit;visibility:=reexport +Bundle-ActivationPolicy: lazy diff --git a/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ActivityInstanceItemProvider.class b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ActivityInstanceItemProvider.class new file mode 100755 index 0000000..b893cdf Binary files /dev/null and b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ActivityInstanceItemProvider.class differ diff --git a/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ActivityInstanceStatusEventItemProvider.class b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ActivityInstanceStatusEventItemProvider.class new file mode 100755 index 0000000..b3caf86 Binary files /dev/null and b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ActivityInstanceStatusEventItemProvider.class differ diff --git a/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ActivityItemProvider.class b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ActivityItemProvider.class new file mode 100755 index 0000000..f30e0fd Binary files /dev/null and b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ActivityItemProvider.class differ diff --git a/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ActivityStatusEventItemProvider.class b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ActivityStatusEventItemProvider.class new file mode 100755 index 0000000..4ccd48c Binary files /dev/null and b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ActivityStatusEventItemProvider.class differ diff --git a/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ComponentStatusEventItemProvider.class b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ComponentStatusEventItemProvider.class new file mode 100755 index 0000000..4f47afd Binary files /dev/null and b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/ComponentStatusEventItemProvider.class differ diff --git a/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/DeviceInstanceStatusEventItemProvider.class b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/DeviceInstanceStatusEventItemProvider.class new file mode 100755 index 0000000..4c4bf68 Binary files /dev/null and b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/DeviceInstanceStatusEventItemProvider.class differ diff --git a/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/PerftoolItemProviderAdapterFactory.class b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/PerftoolItemProviderAdapterFactory.class new file mode 100755 index 0000000..7021011 Binary files /dev/null and b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/PerftoolItemProviderAdapterFactory.class differ diff --git a/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/WFRperfToolModelEditPlugin$Implementation.class b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/WFRperfToolModelEditPlugin$Implementation.class new file mode 100755 index 0000000..8edac0e Binary files /dev/null and b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/WFRperfToolModelEditPlugin$Implementation.class differ diff --git a/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/WFRperfToolModelEditPlugin.class b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/WFRperfToolModelEditPlugin.class new file mode 100755 index 0000000..39af7a5 Binary files /dev/null and b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/WFRperfToolModelEditPlugin.class differ diff --git a/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/WorkflowItemProvider.class b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/WorkflowItemProvider.class new file mode 100755 index 0000000..83c349d Binary files /dev/null and b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/WorkflowItemProvider.class differ diff --git a/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/WorkflowStatusEventItemProvider.class b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/WorkflowStatusEventItemProvider.class new file mode 100755 index 0000000..e0f6b31 Binary files /dev/null and b/WFRperfTool.edit/bin/at/ac/uibk/wfr/perftool/provider/WorkflowStatusEventItemProvider.class differ diff --git a/WFRperfTool.edit/build.properties b/WFRperfTool.edit/build.properties new file mode 100755 index 0000000..6e3e902 --- /dev/null +++ b/WFRperfTool.edit/build.properties @@ -0,0 +1,10 @@ +# + +bin.includes = .,\ + icons/,\ + META-INF/,\ + plugin.xml,\ + plugin.properties +jars.compile.order = . +source.. = src/ +output.. = bin/ diff --git a/WFRperfTool.edit/icons/full/ctool16/CreateActivityInstance_statusEvents_ActivityInstanceStatusEvent.gif b/WFRperfTool.edit/icons/full/ctool16/CreateActivityInstance_statusEvents_ActivityInstanceStatusEvent.gif new file mode 100755 index 0000000..c1e8f13 Binary files /dev/null and b/WFRperfTool.edit/icons/full/ctool16/CreateActivityInstance_statusEvents_ActivityInstanceStatusEvent.gif differ diff --git a/WFRperfTool.edit/icons/full/ctool16/CreateActivity_children_Activity.gif b/WFRperfTool.edit/icons/full/ctool16/CreateActivity_children_Activity.gif new file mode 100755 index 0000000..c31e7a2 Binary files /dev/null and b/WFRperfTool.edit/icons/full/ctool16/CreateActivity_children_Activity.gif differ diff --git a/WFRperfTool.edit/icons/full/ctool16/CreateActivity_instances_ActivityInstance.gif b/WFRperfTool.edit/icons/full/ctool16/CreateActivity_instances_ActivityInstance.gif new file mode 100755 index 0000000..5cd8911 Binary files /dev/null and b/WFRperfTool.edit/icons/full/ctool16/CreateActivity_instances_ActivityInstance.gif differ diff --git a/WFRperfTool.edit/icons/full/ctool16/CreateActivity_statusEvents_ActivityStatusEvent.gif b/WFRperfTool.edit/icons/full/ctool16/CreateActivity_statusEvents_ActivityStatusEvent.gif new file mode 100755 index 0000000..159b76b Binary files /dev/null and b/WFRperfTool.edit/icons/full/ctool16/CreateActivity_statusEvents_ActivityStatusEvent.gif differ diff --git a/WFRperfTool.edit/icons/full/ctool16/CreateWorkflow_componentEvents_ComponentStatusEvent.gif b/WFRperfTool.edit/icons/full/ctool16/CreateWorkflow_componentEvents_ComponentStatusEvent.gif new file mode 100755 index 0000000..90d0d79 Binary files /dev/null and b/WFRperfTool.edit/icons/full/ctool16/CreateWorkflow_componentEvents_ComponentStatusEvent.gif differ diff --git a/WFRperfTool.edit/icons/full/ctool16/CreateWorkflow_deviceEvents_DeviceInstanceStatusEvent.gif b/WFRperfTool.edit/icons/full/ctool16/CreateWorkflow_deviceEvents_DeviceInstanceStatusEvent.gif new file mode 100755 index 0000000..238a342 Binary files /dev/null and b/WFRperfTool.edit/icons/full/ctool16/CreateWorkflow_deviceEvents_DeviceInstanceStatusEvent.gif differ diff --git a/WFRperfTool.edit/icons/full/ctool16/CreateWorkflow_statusEvents_WorkflowStatusEvent.gif b/WFRperfTool.edit/icons/full/ctool16/CreateWorkflow_statusEvents_WorkflowStatusEvent.gif new file mode 100755 index 0000000..e16ab2c Binary files /dev/null and b/WFRperfTool.edit/icons/full/ctool16/CreateWorkflow_statusEvents_WorkflowStatusEvent.gif differ diff --git a/WFRperfTool.edit/icons/full/obj16/Activity.gif b/WFRperfTool.edit/icons/full/obj16/Activity.gif new file mode 100755 index 0000000..35ef84e Binary files /dev/null and b/WFRperfTool.edit/icons/full/obj16/Activity.gif differ diff --git a/WFRperfTool.edit/icons/full/obj16/ActivityInstance.gif b/WFRperfTool.edit/icons/full/obj16/ActivityInstance.gif new file mode 100755 index 0000000..c414fe9 Binary files /dev/null and b/WFRperfTool.edit/icons/full/obj16/ActivityInstance.gif differ diff --git a/WFRperfTool.edit/icons/full/obj16/ActivityInstanceStatusEvent.gif b/WFRperfTool.edit/icons/full/obj16/ActivityInstanceStatusEvent.gif new file mode 100755 index 0000000..d92f34c Binary files /dev/null and b/WFRperfTool.edit/icons/full/obj16/ActivityInstanceStatusEvent.gif differ diff --git a/WFRperfTool.edit/icons/full/obj16/ActivityStatusEvent.gif b/WFRperfTool.edit/icons/full/obj16/ActivityStatusEvent.gif new file mode 100755 index 0000000..c4fb30e Binary files /dev/null and b/WFRperfTool.edit/icons/full/obj16/ActivityStatusEvent.gif differ diff --git a/WFRperfTool.edit/icons/full/obj16/ComponentStatusEvent.gif b/WFRperfTool.edit/icons/full/obj16/ComponentStatusEvent.gif new file mode 100755 index 0000000..83afb9b Binary files /dev/null and b/WFRperfTool.edit/icons/full/obj16/ComponentStatusEvent.gif differ diff --git a/WFRperfTool.edit/icons/full/obj16/DeviceInstanceStatusEvent.gif b/WFRperfTool.edit/icons/full/obj16/DeviceInstanceStatusEvent.gif new file mode 100755 index 0000000..f8041d2 Binary files /dev/null and b/WFRperfTool.edit/icons/full/obj16/DeviceInstanceStatusEvent.gif differ diff --git a/WFRperfTool.edit/icons/full/obj16/Workflow.gif b/WFRperfTool.edit/icons/full/obj16/Workflow.gif new file mode 100755 index 0000000..4365960 Binary files /dev/null and b/WFRperfTool.edit/icons/full/obj16/Workflow.gif differ diff --git a/WFRperfTool.edit/icons/full/obj16/WorkflowStatusEvent.gif b/WFRperfTool.edit/icons/full/obj16/WorkflowStatusEvent.gif new file mode 100755 index 0000000..106881e Binary files /dev/null and b/WFRperfTool.edit/icons/full/obj16/WorkflowStatusEvent.gif differ diff --git a/WFRperfTool.edit/plugin.properties b/WFRperfTool.edit/plugin.properties new file mode 100755 index 0000000..fa5f63f --- /dev/null +++ b/WFRperfTool.edit/plugin.properties @@ -0,0 +1,84 @@ +# + +pluginName = WFRperfToolModel Edit Support +providerName = www.example.org + +_UI_CreateChild_text = {0} +_UI_CreateChild_text2 = {1} {0} +_UI_CreateChild_text3 = {1} +_UI_CreateChild_tooltip = Create New {0} Under {1} Feature +_UI_CreateChild_description = Create a new child of type {0} for the {1} feature of the selected {2}. +_UI_CreateSibling_description = Create a new sibling of type {0} for the selected {2}, under the {1} feature of their parent. + +_UI_PropertyDescriptor_description = The {0} of the {1} + +_UI_Workflow_type = Workflow +_UI_Activity_type = Activity +_UI_ActivityInstance_type = Activity Instance +_UI_WorkflowStatusEvent_type = Workflow Status Event +_UI_ActivityStatusEvent_type = Activity Status Event +_UI_ActivityInstanceStatusEvent_type = Activity Instance Status Event +_UI_DeviceInstanceStatusEvent_type = Device Instance Status Event +_UI_ComponentStatusEvent_type = Component Status Event +_UI_Unknown_type = Object + +_UI_Unknown_datatype= Value + +_UI_Workflow_oid_feature = Oid +_UI_Workflow_wfid_feature = Wfid +_UI_Workflow_uuid_feature = Uuid +_UI_Workflow_name_feature = Name +_UI_Workflow_toplevelActivity_feature = Toplevel Activity +_UI_Workflow_statusEvents_feature = Status Events +_UI_Workflow_deviceEvents_feature = Device Events +_UI_Workflow_componentEvents_feature = Component Events +_UI_Activity_oid_feature = Oid +_UI_Activity_actid_feature = Actid +_UI_Activity_name_feature = Name +_UI_Activity_type_feature = Type +_UI_Activity_branchID_feature = Branch ID +_UI_Activity_parentWorkflow_feature = Parent Workflow +_UI_Activity_instances_feature = Instances +_UI_Activity_statusEvents_feature = Status Events +_UI_Activity_parent_feature = Parent +_UI_Activity_children_feature = Children +_UI_ActivityInstance_oid_feature = Oid +_UI_ActivityInstance_instid_feature = Instid +_UI_ActivityInstance_iterationID_feature = Iteration ID +_UI_ActivityInstance_baseActivity_feature = Base Activity +_UI_ActivityInstance_parentWorkflow_feature = Parent Workflow +_UI_ActivityInstance_parentInstance_feature = Parent Instance +_UI_ActivityInstance_statusEvents_feature = Status Events +_UI_WorkflowStatusEvent_oid_feature = Oid +_UI_WorkflowStatusEvent_newStatus_feature = New Status +_UI_WorkflowStatusEvent_oldStatus_feature = Old Status +_UI_WorkflowStatusEvent_timestamp_feature = Timestamp +_UI_WorkflowStatusEvent_parentWorkflow_feature = Parent Workflow +_UI_ActivityStatusEvent_oid_feature = Oid +_UI_ActivityStatusEvent_newStatus_feature = New Status +_UI_ActivityStatusEvent_oldStatus_feature = Old Status +_UI_ActivityStatusEvent_timestamp_feature = Timestamp +_UI_ActivityStatusEvent_parentActivity_feature = Parent Activity +_UI_ActivityInstanceStatusEvent_oid_feature = Oid +_UI_ActivityInstanceStatusEvent_newStatus_feature = New Status +_UI_ActivityInstanceStatusEvent_oldStatus_feature = Old Status +_UI_ActivityInstanceStatusEvent_timestamp_feature = Timestamp +_UI_ActivityInstanceStatusEvent_parentInstance_feature = Parent Instance +_UI_DeviceInstanceStatusEvent_oid_feature = Oid +_UI_DeviceInstanceStatusEvent_deviceType_feature = Device Type +_UI_DeviceInstanceStatusEvent_deviceID_feature = Device ID +_UI_DeviceInstanceStatusEvent_newStatus_feature = New Status +_UI_DeviceInstanceStatusEvent_oldStatus_feature = Old Status +_UI_DeviceInstanceStatusEvent_timestamp_feature = Timestamp +_UI_DeviceInstanceStatusEvent_executedImplID_feature = Executed Impl ID +_UI_DeviceInstanceStatusEvent_deviceSlotCount_feature = Device Slot Count +_UI_DeviceInstanceStatusEvent_parentWorkflow_feature = Parent Workflow +_UI_DeviceInstanceStatusEvent_executedInstance_feature = Executed Instance +_UI_ComponentStatusEvent_oid_feature = Oid +_UI_ComponentStatusEvent_componentType_feature = Component Type +_UI_ComponentStatusEvent_newStatus_feature = New Status +_UI_ComponentStatusEvent_oldStatus_feature = Old Status +_UI_ComponentStatusEvent_timestamp_feature = Timestamp +_UI_ComponentStatusEvent_workflow_feature = Workflow +_UI_Unknown_feature = Unspecified + diff --git a/WFRperfTool.edit/plugin.xml b/WFRperfTool.edit/plugin.xml new file mode 100755 index 0000000..a20d695 --- /dev/null +++ b/WFRperfTool.edit/plugin.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + + diff --git a/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ActivityInstanceItemProvider.java b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ActivityInstanceItemProvider.java new file mode 100755 index 0000000..748c7c7 --- /dev/null +++ b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ActivityInstanceItemProvider.java @@ -0,0 +1,257 @@ +/** + */ +package at.ac.uibk.wfr.perftool.provider; + + +import at.ac.uibk.wfr.perftool.ActivityInstance; +import at.ac.uibk.wfr.perftool.PerftoolFactory; +import at.ac.uibk.wfr.perftool.PerftoolPackage; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.common.util.ResourceLocator; + + +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemProviderAdapter; +import org.eclipse.emf.edit.provider.ViewerNotification; + +/** + * This is the item provider adapter for a {@link at.ac.uibk.wfr.perftool.ActivityInstance} object. + * + * + * @generated + */ +public class ActivityInstanceItemProvider + extends ItemProviderAdapter + implements + IEditingDomainItemProvider, + IStructuredItemContentProvider, + ITreeItemContentProvider, + IItemLabelProvider, + IItemPropertySource { + /** + * This constructs an instance from a factory and a notifier. + * + * + * @generated + */ + public ActivityInstanceItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + addOidPropertyDescriptor(object); + addInstidPropertyDescriptor(object); + addIterationIDPropertyDescriptor(object); + addParentWorkflowPropertyDescriptor(object); + addParentInstancePropertyDescriptor(object); + } + return itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Oid feature. + * + * + * @generated + */ + protected void addOidPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ActivityInstance_oid_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ActivityInstance_oid_feature", "_UI_ActivityInstance_type"), + PerftoolPackage.Literals.ACTIVITY_INSTANCE__OID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Instid feature. + * + * + * @generated + */ + protected void addInstidPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ActivityInstance_instid_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ActivityInstance_instid_feature", "_UI_ActivityInstance_type"), + PerftoolPackage.Literals.ACTIVITY_INSTANCE__INSTID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Iteration ID feature. + * + * + * @generated + */ + protected void addIterationIDPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ActivityInstance_iterationID_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ActivityInstance_iterationID_feature", "_UI_ActivityInstance_type"), + PerftoolPackage.Literals.ACTIVITY_INSTANCE__ITERATION_ID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Parent Workflow feature. + * + * + * @generated + */ + protected void addParentWorkflowPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ActivityInstance_parentWorkflow_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ActivityInstance_parentWorkflow_feature", "_UI_ActivityInstance_type"), + PerftoolPackage.Literals.ACTIVITY_INSTANCE__PARENT_WORKFLOW, + true, + false, + true, + null, + null, + null)); + } + + /** + * This adds a property descriptor for the Parent Instance feature. + * + * + * @generated + */ + protected void addParentInstancePropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ActivityInstance_parentInstance_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ActivityInstance_parentInstance_feature", "_UI_ActivityInstance_type"), + PerftoolPackage.Literals.ACTIVITY_INSTANCE__PARENT_INSTANCE, + true, + false, + true, + null, + null, + null)); + } + + /** + * This returns ActivityInstance.gif. + * + * + * @generated + */ + @Override + public Object getImage(Object object) { + return overlayImage(object, getResourceLocator().getImage("full/obj16/ActivityInstance")); + } + + /** + * This returns the label text for the adapted class. + * + * + * @generated + */ + @Override + public String getText(Object object) { + ActivityInstance activityInstance = (ActivityInstance)object; + return getString("_UI_ActivityInstance_type") + " " + activityInstance.getOid(); + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached + * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + updateChildren(notification); + + switch (notification.getFeatureID(ActivityInstance.class)) { + case PerftoolPackage.ACTIVITY_INSTANCE__OID: + case PerftoolPackage.ACTIVITY_INSTANCE__INSTID: + case PerftoolPackage.ACTIVITY_INSTANCE__ITERATION_ID: + case PerftoolPackage.ACTIVITY_INSTANCE__STATUS_EVENTS: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children + * that can be created under this object. + * + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + + newChildDescriptors.add + (createChildParameter + (PerftoolPackage.Literals.ACTIVITY_INSTANCE__STATUS_EVENTS, + PerftoolFactory.eINSTANCE.createActivityInstanceStatusEvent())); + } + + /** + * Return the resource locator for this item provider's resources. + * + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() { + return WFRperfToolModelEditPlugin.INSTANCE; + } + +} diff --git a/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ActivityInstanceStatusEventItemProvider.java b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ActivityInstanceStatusEventItemProvider.java new file mode 100755 index 0000000..0191f76 --- /dev/null +++ b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ActivityInstanceStatusEventItemProvider.java @@ -0,0 +1,227 @@ +/** + */ +package at.ac.uibk.wfr.perftool.provider; + + +import at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent; +import at.ac.uibk.wfr.perftool.PerftoolPackage; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.common.util.ResourceLocator; + +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemProviderAdapter; +import org.eclipse.emf.edit.provider.ViewerNotification; + +/** + * This is the item provider adapter for a {@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent} object. + * + * + * @generated + */ +public class ActivityInstanceStatusEventItemProvider + extends ItemProviderAdapter + implements + IEditingDomainItemProvider, + IStructuredItemContentProvider, + ITreeItemContentProvider, + IItemLabelProvider, + IItemPropertySource { + /** + * This constructs an instance from a factory and a notifier. + * + * + * @generated + */ + public ActivityInstanceStatusEventItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + addOidPropertyDescriptor(object); + addNewStatusPropertyDescriptor(object); + addOldStatusPropertyDescriptor(object); + addTimestampPropertyDescriptor(object); + } + return itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Oid feature. + * + * + * @generated + */ + protected void addOidPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ActivityInstanceStatusEvent_oid_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ActivityInstanceStatusEvent_oid_feature", "_UI_ActivityInstanceStatusEvent_type"), + PerftoolPackage.Literals.ACTIVITY_INSTANCE_STATUS_EVENT__OID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the New Status feature. + * + * + * @generated + */ + protected void addNewStatusPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ActivityInstanceStatusEvent_newStatus_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ActivityInstanceStatusEvent_newStatus_feature", "_UI_ActivityInstanceStatusEvent_type"), + PerftoolPackage.Literals.ACTIVITY_INSTANCE_STATUS_EVENT__NEW_STATUS, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Old Status feature. + * + * + * @generated + */ + protected void addOldStatusPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ActivityInstanceStatusEvent_oldStatus_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ActivityInstanceStatusEvent_oldStatus_feature", "_UI_ActivityInstanceStatusEvent_type"), + PerftoolPackage.Literals.ACTIVITY_INSTANCE_STATUS_EVENT__OLD_STATUS, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Timestamp feature. + * + * + * @generated + */ + protected void addTimestampPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ActivityInstanceStatusEvent_timestamp_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ActivityInstanceStatusEvent_timestamp_feature", "_UI_ActivityInstanceStatusEvent_type"), + PerftoolPackage.Literals.ACTIVITY_INSTANCE_STATUS_EVENT__TIMESTAMP, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This returns ActivityInstanceStatusEvent.gif. + * + * + * @generated + */ + @Override + public Object getImage(Object object) { + return overlayImage(object, getResourceLocator().getImage("full/obj16/ActivityInstanceStatusEvent")); + } + + /** + * This returns the label text for the adapted class. + * + * + * @generated + */ + @Override + public String getText(Object object) { + ActivityInstanceStatusEvent activityInstanceStatusEvent = (ActivityInstanceStatusEvent)object; + return getString("_UI_ActivityInstanceStatusEvent_type") + " " + activityInstanceStatusEvent.getOid(); + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached + * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + updateChildren(notification); + + switch (notification.getFeatureID(ActivityInstanceStatusEvent.class)) { + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__OID: + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__NEW_STATUS: + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__OLD_STATUS: + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__TIMESTAMP: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children + * that can be created under this object. + * + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + + /** + * Return the resource locator for this item provider's resources. + * + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() { + return WFRperfToolModelEditPlugin.INSTANCE; + } + +} diff --git a/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ActivityItemProvider.java b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ActivityItemProvider.java new file mode 100755 index 0000000..32555e4 --- /dev/null +++ b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ActivityItemProvider.java @@ -0,0 +1,307 @@ +/** + */ +package at.ac.uibk.wfr.perftool.provider; + + +import at.ac.uibk.wfr.perftool.Activity; +import at.ac.uibk.wfr.perftool.PerftoolFactory; +import at.ac.uibk.wfr.perftool.PerftoolPackage; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.common.util.ResourceLocator; + +import org.eclipse.emf.ecore.EStructuralFeature; + +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemProviderAdapter; +import org.eclipse.emf.edit.provider.ViewerNotification; + +/** + * This is the item provider adapter for a {@link at.ac.uibk.wfr.perftool.Activity} object. + * + * + * @generated + */ +public class ActivityItemProvider + extends ItemProviderAdapter + implements + IEditingDomainItemProvider, + IStructuredItemContentProvider, + ITreeItemContentProvider, + IItemLabelProvider, + IItemPropertySource { + /** + * This constructs an instance from a factory and a notifier. + * + * + * @generated + */ + public ActivityItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + addOidPropertyDescriptor(object); + addActidPropertyDescriptor(object); + addNamePropertyDescriptor(object); + addTypePropertyDescriptor(object); + addBranchIDPropertyDescriptor(object); + } + return itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Oid feature. + * + * + * @generated + */ + protected void addOidPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Activity_oid_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_Activity_oid_feature", "_UI_Activity_type"), + PerftoolPackage.Literals.ACTIVITY__OID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Actid feature. + * + * + * @generated + */ + protected void addActidPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Activity_actid_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_Activity_actid_feature", "_UI_Activity_type"), + PerftoolPackage.Literals.ACTIVITY__ACTID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Name feature. + * + * + * @generated + */ + protected void addNamePropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Activity_name_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_Activity_name_feature", "_UI_Activity_type"), + PerftoolPackage.Literals.ACTIVITY__NAME, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Type feature. + * + * + * @generated + */ + protected void addTypePropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Activity_type_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_Activity_type_feature", "_UI_Activity_type"), + PerftoolPackage.Literals.ACTIVITY__TYPE, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Branch ID feature. + * + * + * @generated + */ + protected void addBranchIDPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Activity_branchID_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_Activity_branchID_feature", "_UI_Activity_type"), + PerftoolPackage.Literals.ACTIVITY__BRANCH_ID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an + * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or + * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. + * + * + * @generated + */ + @Override + public Collection getChildrenFeatures(Object object) { + if (childrenFeatures == null) { + super.getChildrenFeatures(object); + childrenFeatures.add(PerftoolPackage.Literals.ACTIVITY__INSTANCES); + childrenFeatures.add(PerftoolPackage.Literals.ACTIVITY__CHILDREN); + } + return childrenFeatures; + } + + /** + * + * + * @generated + */ + @Override + protected EStructuralFeature getChildFeature(Object object, Object child) { + // Check the type of the specified child object and return the proper feature to use for + // adding (see {@link AddCommand}) it as a child. + + return super.getChildFeature(object, child); + } + + /** + * This returns Activity.gif. + * + * + * @generated + */ + @Override + public Object getImage(Object object) { + return overlayImage(object, getResourceLocator().getImage("full/obj16/Activity")); + } + + /** + * This returns the label text for the adapted class. + * + * + * @generated + */ + @Override + public String getText(Object object) { + String label = ((Activity)object).getName(); + return label == null || label.length() == 0 ? + getString("_UI_Activity_type") : + getString("_UI_Activity_type") + " " + label; + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached + * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + updateChildren(notification); + + switch (notification.getFeatureID(Activity.class)) { + case PerftoolPackage.ACTIVITY__OID: + case PerftoolPackage.ACTIVITY__ACTID: + case PerftoolPackage.ACTIVITY__NAME: + case PerftoolPackage.ACTIVITY__TYPE: + case PerftoolPackage.ACTIVITY__BRANCH_ID: + case PerftoolPackage.ACTIVITY__STATUS_EVENTS: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + case PerftoolPackage.ACTIVITY__INSTANCES: + case PerftoolPackage.ACTIVITY__CHILDREN: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children + * that can be created under this object. + * + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + + newChildDescriptors.add + (createChildParameter + (PerftoolPackage.Literals.ACTIVITY__INSTANCES, + PerftoolFactory.eINSTANCE.createActivityInstance())); + + newChildDescriptors.add + (createChildParameter + (PerftoolPackage.Literals.ACTIVITY__STATUS_EVENTS, + PerftoolFactory.eINSTANCE.createActivityStatusEvent())); + + newChildDescriptors.add + (createChildParameter + (PerftoolPackage.Literals.ACTIVITY__CHILDREN, + PerftoolFactory.eINSTANCE.createActivity())); + } + + /** + * Return the resource locator for this item provider's resources. + * + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() { + return WFRperfToolModelEditPlugin.INSTANCE; + } + +} diff --git a/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ActivityStatusEventItemProvider.java b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ActivityStatusEventItemProvider.java new file mode 100755 index 0000000..9905f79 --- /dev/null +++ b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ActivityStatusEventItemProvider.java @@ -0,0 +1,227 @@ +/** + */ +package at.ac.uibk.wfr.perftool.provider; + + +import at.ac.uibk.wfr.perftool.ActivityStatusEvent; +import at.ac.uibk.wfr.perftool.PerftoolPackage; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.common.util.ResourceLocator; + +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemProviderAdapter; +import org.eclipse.emf.edit.provider.ViewerNotification; + +/** + * This is the item provider adapter for a {@link at.ac.uibk.wfr.perftool.ActivityStatusEvent} object. + * + * + * @generated + */ +public class ActivityStatusEventItemProvider + extends ItemProviderAdapter + implements + IEditingDomainItemProvider, + IStructuredItemContentProvider, + ITreeItemContentProvider, + IItemLabelProvider, + IItemPropertySource { + /** + * This constructs an instance from a factory and a notifier. + * + * + * @generated + */ + public ActivityStatusEventItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + addOidPropertyDescriptor(object); + addNewStatusPropertyDescriptor(object); + addOldStatusPropertyDescriptor(object); + addTimestampPropertyDescriptor(object); + } + return itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Oid feature. + * + * + * @generated + */ + protected void addOidPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ActivityStatusEvent_oid_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ActivityStatusEvent_oid_feature", "_UI_ActivityStatusEvent_type"), + PerftoolPackage.Literals.ACTIVITY_STATUS_EVENT__OID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the New Status feature. + * + * + * @generated + */ + protected void addNewStatusPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ActivityStatusEvent_newStatus_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ActivityStatusEvent_newStatus_feature", "_UI_ActivityStatusEvent_type"), + PerftoolPackage.Literals.ACTIVITY_STATUS_EVENT__NEW_STATUS, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Old Status feature. + * + * + * @generated + */ + protected void addOldStatusPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ActivityStatusEvent_oldStatus_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ActivityStatusEvent_oldStatus_feature", "_UI_ActivityStatusEvent_type"), + PerftoolPackage.Literals.ACTIVITY_STATUS_EVENT__OLD_STATUS, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Timestamp feature. + * + * + * @generated + */ + protected void addTimestampPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ActivityStatusEvent_timestamp_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ActivityStatusEvent_timestamp_feature", "_UI_ActivityStatusEvent_type"), + PerftoolPackage.Literals.ACTIVITY_STATUS_EVENT__TIMESTAMP, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This returns ActivityStatusEvent.gif. + * + * + * @generated + */ + @Override + public Object getImage(Object object) { + return overlayImage(object, getResourceLocator().getImage("full/obj16/ActivityStatusEvent")); + } + + /** + * This returns the label text for the adapted class. + * + * + * @generated + */ + @Override + public String getText(Object object) { + ActivityStatusEvent activityStatusEvent = (ActivityStatusEvent)object; + return getString("_UI_ActivityStatusEvent_type") + " " + activityStatusEvent.getOid(); + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached + * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + updateChildren(notification); + + switch (notification.getFeatureID(ActivityStatusEvent.class)) { + case PerftoolPackage.ACTIVITY_STATUS_EVENT__OID: + case PerftoolPackage.ACTIVITY_STATUS_EVENT__NEW_STATUS: + case PerftoolPackage.ACTIVITY_STATUS_EVENT__OLD_STATUS: + case PerftoolPackage.ACTIVITY_STATUS_EVENT__TIMESTAMP: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children + * that can be created under this object. + * + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + + /** + * Return the resource locator for this item provider's resources. + * + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() { + return WFRperfToolModelEditPlugin.INSTANCE; + } + +} diff --git a/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ComponentStatusEventItemProvider.java b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ComponentStatusEventItemProvider.java new file mode 100755 index 0000000..4e43678 --- /dev/null +++ b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/ComponentStatusEventItemProvider.java @@ -0,0 +1,251 @@ +/** + */ +package at.ac.uibk.wfr.perftool.provider; + + +import at.ac.uibk.wfr.perftool.ComponentStatusEvent; +import at.ac.uibk.wfr.perftool.PerftoolPackage; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.common.util.ResourceLocator; + +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemProviderAdapter; +import org.eclipse.emf.edit.provider.ViewerNotification; + +/** + * This is the item provider adapter for a {@link at.ac.uibk.wfr.perftool.ComponentStatusEvent} object. + * + * + * @generated + */ +public class ComponentStatusEventItemProvider + extends ItemProviderAdapter + implements + IEditingDomainItemProvider, + IStructuredItemContentProvider, + ITreeItemContentProvider, + IItemLabelProvider, + IItemPropertySource { + /** + * This constructs an instance from a factory and a notifier. + * + * + * @generated + */ + public ComponentStatusEventItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + addOidPropertyDescriptor(object); + addComponentTypePropertyDescriptor(object); + addNewStatusPropertyDescriptor(object); + addOldStatusPropertyDescriptor(object); + addTimestampPropertyDescriptor(object); + } + return itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Oid feature. + * + * + * @generated + */ + protected void addOidPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ComponentStatusEvent_oid_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ComponentStatusEvent_oid_feature", "_UI_ComponentStatusEvent_type"), + PerftoolPackage.Literals.COMPONENT_STATUS_EVENT__OID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Component Type feature. + * + * + * @generated + */ + protected void addComponentTypePropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ComponentStatusEvent_componentType_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ComponentStatusEvent_componentType_feature", "_UI_ComponentStatusEvent_type"), + PerftoolPackage.Literals.COMPONENT_STATUS_EVENT__COMPONENT_TYPE, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the New Status feature. + * + * + * @generated + */ + protected void addNewStatusPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ComponentStatusEvent_newStatus_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ComponentStatusEvent_newStatus_feature", "_UI_ComponentStatusEvent_type"), + PerftoolPackage.Literals.COMPONENT_STATUS_EVENT__NEW_STATUS, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Old Status feature. + * + * + * @generated + */ + protected void addOldStatusPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ComponentStatusEvent_oldStatus_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ComponentStatusEvent_oldStatus_feature", "_UI_ComponentStatusEvent_type"), + PerftoolPackage.Literals.COMPONENT_STATUS_EVENT__OLD_STATUS, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Timestamp feature. + * + * + * @generated + */ + protected void addTimestampPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_ComponentStatusEvent_timestamp_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_ComponentStatusEvent_timestamp_feature", "_UI_ComponentStatusEvent_type"), + PerftoolPackage.Literals.COMPONENT_STATUS_EVENT__TIMESTAMP, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This returns ComponentStatusEvent.gif. + * + * + * @generated + */ + @Override + public Object getImage(Object object) { + return overlayImage(object, getResourceLocator().getImage("full/obj16/ComponentStatusEvent")); + } + + /** + * This returns the label text for the adapted class. + * + * + * @generated + */ + @Override + public String getText(Object object) { + ComponentStatusEvent componentStatusEvent = (ComponentStatusEvent)object; + return getString("_UI_ComponentStatusEvent_type") + " " + componentStatusEvent.getOid(); + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached + * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + updateChildren(notification); + + switch (notification.getFeatureID(ComponentStatusEvent.class)) { + case PerftoolPackage.COMPONENT_STATUS_EVENT__OID: + case PerftoolPackage.COMPONENT_STATUS_EVENT__COMPONENT_TYPE: + case PerftoolPackage.COMPONENT_STATUS_EVENT__NEW_STATUS: + case PerftoolPackage.COMPONENT_STATUS_EVENT__OLD_STATUS: + case PerftoolPackage.COMPONENT_STATUS_EVENT__TIMESTAMP: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children + * that can be created under this object. + * + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + + /** + * Return the resource locator for this item provider's resources. + * + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() { + return WFRperfToolModelEditPlugin.INSTANCE; + } + +} diff --git a/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/DeviceInstanceStatusEventItemProvider.java b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/DeviceInstanceStatusEventItemProvider.java new file mode 100755 index 0000000..f8a2133 --- /dev/null +++ b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/DeviceInstanceStatusEventItemProvider.java @@ -0,0 +1,346 @@ +/** + */ +package at.ac.uibk.wfr.perftool.provider; + + +import at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent; +import at.ac.uibk.wfr.perftool.PerftoolPackage; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.common.util.ResourceLocator; + +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemProviderAdapter; +import org.eclipse.emf.edit.provider.ViewerNotification; + +/** + * This is the item provider adapter for a {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent} object. + * + * + * @generated + */ +public class DeviceInstanceStatusEventItemProvider + extends ItemProviderAdapter + implements + IEditingDomainItemProvider, + IStructuredItemContentProvider, + ITreeItemContentProvider, + IItemLabelProvider, + IItemPropertySource { + /** + * This constructs an instance from a factory and a notifier. + * + * + * @generated + */ + public DeviceInstanceStatusEventItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + addOidPropertyDescriptor(object); + addDeviceTypePropertyDescriptor(object); + addDeviceIDPropertyDescriptor(object); + addNewStatusPropertyDescriptor(object); + addOldStatusPropertyDescriptor(object); + addTimestampPropertyDescriptor(object); + addExecutedImplIDPropertyDescriptor(object); + addDeviceSlotCountPropertyDescriptor(object); + addExecutedInstancePropertyDescriptor(object); + } + return itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Oid feature. + * + * + * @generated + */ + protected void addOidPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_DeviceInstanceStatusEvent_oid_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_DeviceInstanceStatusEvent_oid_feature", "_UI_DeviceInstanceStatusEvent_type"), + PerftoolPackage.Literals.DEVICE_INSTANCE_STATUS_EVENT__OID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Device Type feature. + * + * + * @generated + */ + protected void addDeviceTypePropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_DeviceInstanceStatusEvent_deviceType_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_DeviceInstanceStatusEvent_deviceType_feature", "_UI_DeviceInstanceStatusEvent_type"), + PerftoolPackage.Literals.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_TYPE, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Device ID feature. + * + * + * @generated + */ + protected void addDeviceIDPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_DeviceInstanceStatusEvent_deviceID_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_DeviceInstanceStatusEvent_deviceID_feature", "_UI_DeviceInstanceStatusEvent_type"), + PerftoolPackage.Literals.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_ID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the New Status feature. + * + * + * @generated + */ + protected void addNewStatusPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_DeviceInstanceStatusEvent_newStatus_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_DeviceInstanceStatusEvent_newStatus_feature", "_UI_DeviceInstanceStatusEvent_type"), + PerftoolPackage.Literals.DEVICE_INSTANCE_STATUS_EVENT__NEW_STATUS, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Old Status feature. + * + * + * @generated + */ + protected void addOldStatusPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_DeviceInstanceStatusEvent_oldStatus_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_DeviceInstanceStatusEvent_oldStatus_feature", "_UI_DeviceInstanceStatusEvent_type"), + PerftoolPackage.Literals.DEVICE_INSTANCE_STATUS_EVENT__OLD_STATUS, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Timestamp feature. + * + * + * @generated + */ + protected void addTimestampPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_DeviceInstanceStatusEvent_timestamp_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_DeviceInstanceStatusEvent_timestamp_feature", "_UI_DeviceInstanceStatusEvent_type"), + PerftoolPackage.Literals.DEVICE_INSTANCE_STATUS_EVENT__TIMESTAMP, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Executed Impl ID feature. + * + * + * @generated + */ + protected void addExecutedImplIDPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_DeviceInstanceStatusEvent_executedImplID_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_DeviceInstanceStatusEvent_executedImplID_feature", "_UI_DeviceInstanceStatusEvent_type"), + PerftoolPackage.Literals.DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_IMPL_ID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Device Slot Count feature. + * + * + * @generated + */ + protected void addDeviceSlotCountPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_DeviceInstanceStatusEvent_deviceSlotCount_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_DeviceInstanceStatusEvent_deviceSlotCount_feature", "_UI_DeviceInstanceStatusEvent_type"), + PerftoolPackage.Literals.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_SLOT_COUNT, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Executed Instance feature. + * + * + * @generated + */ + protected void addExecutedInstancePropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_DeviceInstanceStatusEvent_executedInstance_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_DeviceInstanceStatusEvent_executedInstance_feature", "_UI_DeviceInstanceStatusEvent_type"), + PerftoolPackage.Literals.DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_INSTANCE, + true, + false, + true, + null, + null, + null)); + } + + /** + * This returns DeviceInstanceStatusEvent.gif. + * + * + * @generated + */ + @Override + public Object getImage(Object object) { + return overlayImage(object, getResourceLocator().getImage("full/obj16/DeviceInstanceStatusEvent")); + } + + /** + * This returns the label text for the adapted class. + * + * + * @generated + */ + @Override + public String getText(Object object) { + DeviceInstanceStatusEvent deviceInstanceStatusEvent = (DeviceInstanceStatusEvent)object; + return getString("_UI_DeviceInstanceStatusEvent_type") + " " + deviceInstanceStatusEvent.getOid(); + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached + * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + updateChildren(notification); + + switch (notification.getFeatureID(DeviceInstanceStatusEvent.class)) { + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__OID: + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_TYPE: + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_ID: + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__NEW_STATUS: + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__OLD_STATUS: + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__TIMESTAMP: + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_IMPL_ID: + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_SLOT_COUNT: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children + * that can be created under this object. + * + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + + /** + * Return the resource locator for this item provider's resources. + * + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() { + return WFRperfToolModelEditPlugin.INSTANCE; + } + +} diff --git a/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/PerftoolItemProviderAdapterFactory.java b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/PerftoolItemProviderAdapterFactory.java new file mode 100755 index 0000000..3d2a383 --- /dev/null +++ b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/PerftoolItemProviderAdapterFactory.java @@ -0,0 +1,367 @@ +/** + */ +package at.ac.uibk.wfr.perftool.provider; + +import at.ac.uibk.wfr.perftool.util.PerftoolAdapterFactory; + +import java.util.ArrayList; +import java.util.Collection; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.edit.provider.ChangeNotifier; +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.IChangeNotifier; +import org.eclipse.emf.edit.provider.IDisposable; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.INotifyChangedListener; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; + +/** + * This is the factory that is used to provide the interfaces needed to support Viewers. + * The adapters generated by this factory convert EMF adapter notifications into calls to {@link #fireNotifyChanged fireNotifyChanged}. + * The adapters also support Eclipse property sheets. + * Note that most of the adapters are shared among multiple instances. + * + * + * @generated + */ +public class PerftoolItemProviderAdapterFactory extends PerftoolAdapterFactory implements ComposeableAdapterFactory, IChangeNotifier, IDisposable { + /** + * This keeps track of the root adapter factory that delegates to this adapter factory. + * + * + * @generated + */ + protected ComposedAdapterFactory parentAdapterFactory; + + /** + * This is used to implement {@link org.eclipse.emf.edit.provider.IChangeNotifier}. + * + * + * @generated + */ + protected IChangeNotifier changeNotifier = new ChangeNotifier(); + + /** + * This keeps track of all the supported types checked by {@link #isFactoryForType isFactoryForType}. + * + * + * @generated + */ + protected Collection supportedTypes = new ArrayList(); + + /** + * This constructs an instance. + * + * + * @generated + */ + public PerftoolItemProviderAdapterFactory() { + supportedTypes.add(IEditingDomainItemProvider.class); + supportedTypes.add(IStructuredItemContentProvider.class); + supportedTypes.add(ITreeItemContentProvider.class); + supportedTypes.add(IItemLabelProvider.class); + supportedTypes.add(IItemPropertySource.class); + } + + /** + * This keeps track of the one adapter used for all {@link at.ac.uibk.wfr.perftool.Workflow} instances. + * + * + * @generated + */ + protected WorkflowItemProvider workflowItemProvider; + + /** + * This creates an adapter for a {@link at.ac.uibk.wfr.perftool.Workflow}. + * + * + * @generated + */ + @Override + public Adapter createWorkflowAdapter() { + if (workflowItemProvider == null) { + workflowItemProvider = new WorkflowItemProvider(this); + } + + return workflowItemProvider; + } + + /** + * This keeps track of the one adapter used for all {@link at.ac.uibk.wfr.perftool.Activity} instances. + * + * + * @generated + */ + protected ActivityItemProvider activityItemProvider; + + /** + * This creates an adapter for a {@link at.ac.uibk.wfr.perftool.Activity}. + * + * + * @generated + */ + @Override + public Adapter createActivityAdapter() { + if (activityItemProvider == null) { + activityItemProvider = new ActivityItemProvider(this); + } + + return activityItemProvider; + } + + /** + * This keeps track of the one adapter used for all {@link at.ac.uibk.wfr.perftool.ActivityInstance} instances. + * + * + * @generated + */ + protected ActivityInstanceItemProvider activityInstanceItemProvider; + + /** + * This creates an adapter for a {@link at.ac.uibk.wfr.perftool.ActivityInstance}. + * + * + * @generated + */ + @Override + public Adapter createActivityInstanceAdapter() { + if (activityInstanceItemProvider == null) { + activityInstanceItemProvider = new ActivityInstanceItemProvider(this); + } + + return activityInstanceItemProvider; + } + + /** + * This keeps track of the one adapter used for all {@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent} instances. + * + * + * @generated + */ + protected WorkflowStatusEventItemProvider workflowStatusEventItemProvider; + + /** + * This creates an adapter for a {@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent}. + * + * + * @generated + */ + @Override + public Adapter createWorkflowStatusEventAdapter() { + if (workflowStatusEventItemProvider == null) { + workflowStatusEventItemProvider = new WorkflowStatusEventItemProvider(this); + } + + return workflowStatusEventItemProvider; + } + + /** + * This keeps track of the one adapter used for all {@link at.ac.uibk.wfr.perftool.ActivityStatusEvent} instances. + * + * + * @generated + */ + protected ActivityStatusEventItemProvider activityStatusEventItemProvider; + + /** + * This creates an adapter for a {@link at.ac.uibk.wfr.perftool.ActivityStatusEvent}. + * + * + * @generated + */ + @Override + public Adapter createActivityStatusEventAdapter() { + if (activityStatusEventItemProvider == null) { + activityStatusEventItemProvider = new ActivityStatusEventItemProvider(this); + } + + return activityStatusEventItemProvider; + } + + /** + * This keeps track of the one adapter used for all {@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent} instances. + * + * + * @generated + */ + protected ActivityInstanceStatusEventItemProvider activityInstanceStatusEventItemProvider; + + /** + * This creates an adapter for a {@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent}. + * + * + * @generated + */ + @Override + public Adapter createActivityInstanceStatusEventAdapter() { + if (activityInstanceStatusEventItemProvider == null) { + activityInstanceStatusEventItemProvider = new ActivityInstanceStatusEventItemProvider(this); + } + + return activityInstanceStatusEventItemProvider; + } + + /** + * This keeps track of the one adapter used for all {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent} instances. + * + * + * @generated + */ + protected DeviceInstanceStatusEventItemProvider deviceInstanceStatusEventItemProvider; + + /** + * This creates an adapter for a {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent}. + * + * + * @generated + */ + @Override + public Adapter createDeviceInstanceStatusEventAdapter() { + if (deviceInstanceStatusEventItemProvider == null) { + deviceInstanceStatusEventItemProvider = new DeviceInstanceStatusEventItemProvider(this); + } + + return deviceInstanceStatusEventItemProvider; + } + + /** + * This keeps track of the one adapter used for all {@link at.ac.uibk.wfr.perftool.ComponentStatusEvent} instances. + * + * + * @generated + */ + protected ComponentStatusEventItemProvider componentStatusEventItemProvider; + + /** + * This creates an adapter for a {@link at.ac.uibk.wfr.perftool.ComponentStatusEvent}. + * + * + * @generated + */ + @Override + public Adapter createComponentStatusEventAdapter() { + if (componentStatusEventItemProvider == null) { + componentStatusEventItemProvider = new ComponentStatusEventItemProvider(this); + } + + return componentStatusEventItemProvider; + } + + /** + * This returns the root adapter factory that contains this factory. + * + * + * @generated + */ + public ComposeableAdapterFactory getRootAdapterFactory() { + return parentAdapterFactory == null ? this : parentAdapterFactory.getRootAdapterFactory(); + } + + /** + * This sets the composed adapter factory that contains this factory. + * + * + * @generated + */ + public void setParentAdapterFactory(ComposedAdapterFactory parentAdapterFactory) { + this.parentAdapterFactory = parentAdapterFactory; + } + + /** + * + * + * @generated + */ + @Override + public boolean isFactoryForType(Object type) { + return supportedTypes.contains(type) || super.isFactoryForType(type); + } + + /** + * This implementation substitutes the factory itself as the key for the adapter. + * + * + * @generated + */ + @Override + public Adapter adapt(Notifier notifier, Object type) { + return super.adapt(notifier, this); + } + + /** + * + * + * @generated + */ + @Override + public Object adapt(Object object, Object type) { + if (isFactoryForType(type)) { + Object adapter = super.adapt(object, type); + if (!(type instanceof Class) || (((Class)type).isInstance(adapter))) { + return adapter; + } + } + + return null; + } + + /** + * This adds a listener. + * + * + * @generated + */ + public void addListener(INotifyChangedListener notifyChangedListener) { + changeNotifier.addListener(notifyChangedListener); + } + + /** + * This removes a listener. + * + * + * @generated + */ + public void removeListener(INotifyChangedListener notifyChangedListener) { + changeNotifier.removeListener(notifyChangedListener); + } + + /** + * This delegates to {@link #changeNotifier} and to {@link #parentAdapterFactory}. + * + * + * @generated + */ + public void fireNotifyChanged(Notification notification) { + changeNotifier.fireNotifyChanged(notification); + + if (parentAdapterFactory != null) { + parentAdapterFactory.fireNotifyChanged(notification); + } + } + + /** + * This disposes all of the item providers created by this factory. + * + * + * @generated + */ + public void dispose() { + if (workflowItemProvider != null) workflowItemProvider.dispose(); + if (activityItemProvider != null) activityItemProvider.dispose(); + if (activityInstanceItemProvider != null) activityInstanceItemProvider.dispose(); + if (workflowStatusEventItemProvider != null) workflowStatusEventItemProvider.dispose(); + if (activityStatusEventItemProvider != null) activityStatusEventItemProvider.dispose(); + if (activityInstanceStatusEventItemProvider != null) activityInstanceStatusEventItemProvider.dispose(); + if (deviceInstanceStatusEventItemProvider != null) deviceInstanceStatusEventItemProvider.dispose(); + if (componentStatusEventItemProvider != null) componentStatusEventItemProvider.dispose(); + } + +} diff --git a/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/WFRperfToolModelEditPlugin.java b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/WFRperfToolModelEditPlugin.java new file mode 100755 index 0000000..ec0428d --- /dev/null +++ b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/WFRperfToolModelEditPlugin.java @@ -0,0 +1,89 @@ +/** + */ +package at.ac.uibk.wfr.perftool.provider; + +import org.eclipse.emf.common.EMFPlugin; + +import org.eclipse.emf.common.util.ResourceLocator; + +/** + * This is the central singleton for the WFRperfToolModel edit plugin. + * + * + * @generated + */ +public final class WFRperfToolModelEditPlugin extends EMFPlugin { + /** + * Keep track of the singleton. + * + * + * @generated + */ + public static final WFRperfToolModelEditPlugin INSTANCE = new WFRperfToolModelEditPlugin(); + + /** + * Keep track of the singleton. + * + * + * @generated + */ + private static Implementation plugin; + + /** + * Create the instance. + * + * + * @generated + */ + public WFRperfToolModelEditPlugin() { + super + (new ResourceLocator [] { + }); + } + + /** + * Returns the singleton instance of the Eclipse plugin. + * + * + * @return the singleton instance. + * @generated + */ + @Override + public ResourceLocator getPluginResourceLocator() { + return plugin; + } + + /** + * Returns the singleton instance of the Eclipse plugin. + * + * + * @return the singleton instance. + * @generated + */ + public static Implementation getPlugin() { + return plugin; + } + + /** + * The actual implementation of the Eclipse Plugin. + * + * + * @generated + */ + public static class Implementation extends EclipsePlugin { + /** + * Creates an instance. + * + * + * @generated + */ + public Implementation() { + super(); + + // Remember the static instance. + // + plugin = this; + } + } + +} diff --git a/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/WorkflowItemProvider.java b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/WorkflowItemProvider.java new file mode 100755 index 0000000..bfb5182 --- /dev/null +++ b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/WorkflowItemProvider.java @@ -0,0 +1,303 @@ +/** + */ +package at.ac.uibk.wfr.perftool.provider; + + +import at.ac.uibk.wfr.perftool.PerftoolFactory; +import at.ac.uibk.wfr.perftool.PerftoolPackage; +import at.ac.uibk.wfr.perftool.Workflow; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.common.util.ResourceLocator; + +import org.eclipse.emf.ecore.EStructuralFeature; + +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemProviderAdapter; +import org.eclipse.emf.edit.provider.ViewerNotification; + +/** + * This is the item provider adapter for a {@link at.ac.uibk.wfr.perftool.Workflow} object. + * + * + * @generated + */ +public class WorkflowItemProvider + extends ItemProviderAdapter + implements + IEditingDomainItemProvider, + IStructuredItemContentProvider, + ITreeItemContentProvider, + IItemLabelProvider, + IItemPropertySource { + /** + * This constructs an instance from a factory and a notifier. + * + * + * @generated + */ + public WorkflowItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + addOidPropertyDescriptor(object); + addWfidPropertyDescriptor(object); + addUuidPropertyDescriptor(object); + addNamePropertyDescriptor(object); + addToplevelActivityPropertyDescriptor(object); + } + return itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Oid feature. + * + * + * @generated + */ + protected void addOidPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Workflow_oid_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_Workflow_oid_feature", "_UI_Workflow_type"), + PerftoolPackage.Literals.WORKFLOW__OID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Wfid feature. + * + * + * @generated + */ + protected void addWfidPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Workflow_wfid_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_Workflow_wfid_feature", "_UI_Workflow_type"), + PerftoolPackage.Literals.WORKFLOW__WFID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Uuid feature. + * + * + * @generated + */ + protected void addUuidPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Workflow_uuid_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_Workflow_uuid_feature", "_UI_Workflow_type"), + PerftoolPackage.Literals.WORKFLOW__UUID, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Name feature. + * + * + * @generated + */ + protected void addNamePropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Workflow_name_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_Workflow_name_feature", "_UI_Workflow_type"), + PerftoolPackage.Literals.WORKFLOW__NAME, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Toplevel Activity feature. + * + * + * @generated + */ + protected void addToplevelActivityPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_Workflow_toplevelActivity_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_Workflow_toplevelActivity_feature", "_UI_Workflow_type"), + PerftoolPackage.Literals.WORKFLOW__TOPLEVEL_ACTIVITY, + true, + false, + true, + null, + null, + null)); + } + + /** + * This specifies how to implement {@link #getChildren} and is used to deduce an appropriate feature for an + * {@link org.eclipse.emf.edit.command.AddCommand}, {@link org.eclipse.emf.edit.command.RemoveCommand} or + * {@link org.eclipse.emf.edit.command.MoveCommand} in {@link #createCommand}. + * + * + * @generated + */ + @Override + public Collection getChildrenFeatures(Object object) { + if (childrenFeatures == null) { + super.getChildrenFeatures(object); + childrenFeatures.add(PerftoolPackage.Literals.WORKFLOW__TOPLEVEL_ACTIVITY); + } + return childrenFeatures; + } + + /** + * + * + * @generated + */ + @Override + protected EStructuralFeature getChildFeature(Object object, Object child) { + // Check the type of the specified child object and return the proper feature to use for + // adding (see {@link AddCommand}) it as a child. + + return super.getChildFeature(object, child); + } + + /** + * This returns Workflow.gif. + * + * + * @generated + */ + @Override + public Object getImage(Object object) { + return overlayImage(object, getResourceLocator().getImage("full/obj16/Workflow")); + } + + /** + * This returns the label text for the adapted class. + * + * + * @generated + */ + @Override + public String getText(Object object) { + String label = ((Workflow)object).getName(); + return label == null || label.length() == 0 ? + getString("_UI_Workflow_type") : + getString("_UI_Workflow_type") + " " + label; + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached + * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + updateChildren(notification); + + switch (notification.getFeatureID(Workflow.class)) { + case PerftoolPackage.WORKFLOW__OID: + case PerftoolPackage.WORKFLOW__WFID: + case PerftoolPackage.WORKFLOW__UUID: + case PerftoolPackage.WORKFLOW__NAME: + case PerftoolPackage.WORKFLOW__STATUS_EVENTS: + case PerftoolPackage.WORKFLOW__DEVICE_EVENTS: + case PerftoolPackage.WORKFLOW__COMPONENT_EVENTS: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children + * that can be created under this object. + * + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + + newChildDescriptors.add + (createChildParameter + (PerftoolPackage.Literals.WORKFLOW__STATUS_EVENTS, + PerftoolFactory.eINSTANCE.createWorkflowStatusEvent())); + + newChildDescriptors.add + (createChildParameter + (PerftoolPackage.Literals.WORKFLOW__DEVICE_EVENTS, + PerftoolFactory.eINSTANCE.createDeviceInstanceStatusEvent())); + + newChildDescriptors.add + (createChildParameter + (PerftoolPackage.Literals.WORKFLOW__COMPONENT_EVENTS, + PerftoolFactory.eINSTANCE.createComponentStatusEvent())); + } + + /** + * Return the resource locator for this item provider's resources. + * + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() { + return WFRperfToolModelEditPlugin.INSTANCE; + } + +} diff --git a/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/WorkflowStatusEventItemProvider.java b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/WorkflowStatusEventItemProvider.java new file mode 100755 index 0000000..0a3a78c --- /dev/null +++ b/WFRperfTool.edit/src/at/ac/uibk/wfr/perftool/provider/WorkflowStatusEventItemProvider.java @@ -0,0 +1,239 @@ +/** + */ +package at.ac.uibk.wfr.perftool.provider; + + +import at.ac.uibk.wfr.perftool.PerftoolPackage; +import at.ac.uibk.wfr.perftool.WorkflowStatusEvent; + +import java.util.Collection; +import java.util.List; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.common.util.ResourceLocator; + +import org.eclipse.emf.edit.provider.ComposeableAdapterFactory; +import org.eclipse.emf.edit.provider.IEditingDomainItemProvider; +import org.eclipse.emf.edit.provider.IItemLabelProvider; +import org.eclipse.emf.edit.provider.IItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.IItemPropertySource; +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.emf.edit.provider.ItemPropertyDescriptor; +import org.eclipse.emf.edit.provider.ItemProviderAdapter; +import org.eclipse.emf.edit.provider.ViewerNotification; + +/** + * This is the item provider adapter for a {@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent} object. + * + * + * @generated + */ +public class WorkflowStatusEventItemProvider + extends ItemProviderAdapter + implements + IEditingDomainItemProvider, IStructuredItemContentProvider, ITreeItemContentProvider, IItemLabelProvider, IItemPropertySource { + /** + * This constructs an instance from a factory and a notifier. + * + * + * @generated + */ + public WorkflowStatusEventItemProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * This returns the property descriptors for the adapted class. + * + * + * @generated + */ + @Override + public List getPropertyDescriptors(Object object) { + if (itemPropertyDescriptors == null) { + super.getPropertyDescriptors(object); + + addOidPropertyDescriptor(object); + addNewStatusPropertyDescriptor(object); + addOldStatusPropertyDescriptor(object); + addTimestampPropertyDescriptor(object); + } + return itemPropertyDescriptors; + } + + /** + * This adds a property descriptor for the Oid feature. + * + * + * @generated + */ + protected void addOidPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_WorkflowStatusEvent_oid_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_WorkflowStatusEvent_oid_feature", "_UI_WorkflowStatusEvent_type"), + PerftoolPackage.Literals.WORKFLOW_STATUS_EVENT__OID, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the New Status feature. + * + * + * @generated + */ + protected void addNewStatusPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_WorkflowStatusEvent_newStatus_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_WorkflowStatusEvent_newStatus_feature", "_UI_WorkflowStatusEvent_type"), + PerftoolPackage.Literals.WORKFLOW_STATUS_EVENT__NEW_STATUS, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Old Status feature. + * + * + * @generated + */ + protected void addOldStatusPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_WorkflowStatusEvent_oldStatus_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_WorkflowStatusEvent_oldStatus_feature", "_UI_WorkflowStatusEvent_type"), + PerftoolPackage.Literals.WORKFLOW_STATUS_EVENT__OLD_STATUS, + true, + false, + false, + ItemPropertyDescriptor.GENERIC_VALUE_IMAGE, + null, + null)); + } + + /** + * This adds a property descriptor for the Timestamp feature. + * + * + * @generated + */ + protected void addTimestampPropertyDescriptor(Object object) { + itemPropertyDescriptors.add + (createItemPropertyDescriptor + (((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), + getResourceLocator(), + getString("_UI_WorkflowStatusEvent_timestamp_feature"), + getString("_UI_PropertyDescriptor_description", "_UI_WorkflowStatusEvent_timestamp_feature", "_UI_WorkflowStatusEvent_type"), + PerftoolPackage.Literals.WORKFLOW_STATUS_EVENT__TIMESTAMP, + true, + false, + false, + ItemPropertyDescriptor.INTEGRAL_VALUE_IMAGE, + null, + null)); + } + + /** + * This returns WorkflowStatusEvent.gif. + * + * + * @generated + */ + @Override + public Object getImage(Object object) { + return overlayImage(object, getResourceLocator().getImage("full/obj16/WorkflowStatusEvent")); + } + + /** + * This returns the label text for the adapted class. + * + * + * @generated + */ + @Override + public String getText(Object object) { + WorkflowStatusEvent workflowStatusEvent = (WorkflowStatusEvent)object; + return getString("_UI_WorkflowStatusEvent_type") + " " + workflowStatusEvent.getOid(); + } + + /** + * This handles model notifications by calling {@link #updateChildren} to update any cached + * children and by creating a viewer notification, which it passes to {@link #fireNotifyChanged}. + * + * + * @generated + */ + @Override + public void notifyChanged(Notification notification) { + updateChildren(notification); + + switch (notification.getFeatureID(WorkflowStatusEvent.class)) { + case PerftoolPackage.WORKFLOW_STATUS_EVENT__OID: + case PerftoolPackage.WORKFLOW_STATUS_EVENT__NEW_STATUS: + case PerftoolPackage.WORKFLOW_STATUS_EVENT__OLD_STATUS: + case PerftoolPackage.WORKFLOW_STATUS_EVENT__TIMESTAMP: + fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); + return; + } + super.notifyChanged(notification); + } + + /** + * This adds {@link org.eclipse.emf.edit.command.CommandParameter}s describing the children + * that can be created under this object. + * + * + * @generated + */ + @Override + protected void collectNewChildDescriptors(Collection newChildDescriptors, Object object) { + super.collectNewChildDescriptors(newChildDescriptors, object); + } + + /** + * Return the resource locator for this item provider's resources. + * + * + * @generated + */ + @Override + public ResourceLocator getResourceLocator() { + return WFRperfToolModelEditPlugin.INSTANCE; + } + + @Override + public Object getColumnImage(Object object, int columnIndex) { + if (columnIndex == 0) { + return getImage(object); + } else { + return super.getColumnText(object, columnIndex); + } + } + + @Override + public String getColumnText(Object object, int columnIndex) { + return getText(object); + } + + + +} diff --git a/WFRperfTool.editor/.classpath b/WFRperfTool.editor/.classpath new file mode 100755 index 0000000..2b1b33e --- /dev/null +++ b/WFRperfTool.editor/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/WFRperfTool.editor/.project b/WFRperfTool.editor/.project new file mode 100755 index 0000000..4a79406 --- /dev/null +++ b/WFRperfTool.editor/.project @@ -0,0 +1,28 @@ + + + WFRperfTool.editor + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + diff --git a/WFRperfTool.editor/META-INF/MANIFEST.MF b/WFRperfTool.editor/META-INF/MANIFEST.MF new file mode 100755 index 0000000..67bd1ef --- /dev/null +++ b/WFRperfTool.editor/META-INF/MANIFEST.MF @@ -0,0 +1,34 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: WFRperfTool.editor;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-ClassPath: ., + libs/sqlite-jdbc-3.7.2.jar +Bundle-Activator: at.ac.uibk.wfr.perftool.presentation.WFRperfToolModelEditorPlugin$Implementation +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Export-Package: at.ac.uibk.wfr.perftool.presentation +Require-Bundle: org.eclipse.core.runtime, + WFRperfTool.edit;visibility:=reexport, + org.eclipse.emf.ecore.xmi;visibility:=reexport, + org.eclipse.emf.edit.ui;visibility:=reexport, + org.eclipse.emf.teneo.hibernate;bundle-version="2.0.1", + org.hibernate;bundle-version="4.1.1", + org.eclipse.birt;bundle-version="4.2.2", + org.eclipse.birt.chart.engine;bundle-version="4.2.2", + org.eclipse.birt.chart.device.swt;bundle-version="4.2.2", + org.eclipse.birt.chart.device.extension;bundle-version="4.2.2", + org.eclipse.birt.chart.device.pdf;bundle-version="4.2.2", + org.eclipse.birt.chart.device.svg;bundle-version="4.2.2", + org.eclipse.birt.chart.engine.extension;bundle-version="4.2.2", + org.eclipse.birt.chart.reportitem;bundle-version="4.2.2", + org.eclipse.birt.chart.reportitem.ui;bundle-version="4.2.2", + org.eclipse.birt.chart.ui;bundle-version="4.2.2", + org.eclipse.birt.chart.ui.extension;bundle-version="4.2.2", + org.eclipse.birt.core.script.function;bundle-version="4.2.2", + org.eclipse.birt.core.ui;bundle-version="4.2.2", + org.eclipse.birt.data;bundle-version="4.2.2", + org.eclipse.birt.data.aggregation;bundle-version="4.2.2" +Bundle-ActivationPolicy: lazy diff --git a/WFRperfTool.editor/backup/DeviceEventsTimelineEditorPart.java b/WFRperfTool.editor/backup/DeviceEventsTimelineEditorPart.java new file mode 100755 index 0000000..5e6b611 --- /dev/null +++ b/WFRperfTool.editor/backup/DeviceEventsTimelineEditorPart.java @@ -0,0 +1,411 @@ +package at.ac.uibk.wfr.perftool.deviceeventstimeline; + +import java.util.Date; + +import org.eclipse.birt.chart.extension.datafeed.GanttEntry; +import org.eclipse.birt.chart.model.Chart; +import org.eclipse.birt.chart.model.ChartWithAxes; +import org.eclipse.birt.chart.model.ChartWithoutAxes; +import org.eclipse.birt.chart.model.attribute.ActionType; +import org.eclipse.birt.chart.model.attribute.Anchor; +import org.eclipse.birt.chart.model.attribute.AxisType; +import org.eclipse.birt.chart.model.attribute.ChartDimension; +import org.eclipse.birt.chart.model.attribute.IntersectionType; +import org.eclipse.birt.chart.model.attribute.LegendItemType; +import org.eclipse.birt.chart.model.attribute.LineAttributes; +import org.eclipse.birt.chart.model.attribute.LineStyle; +import org.eclipse.birt.chart.model.attribute.Position; +import org.eclipse.birt.chart.model.attribute.TickStyle; +import org.eclipse.birt.chart.model.attribute.TriggerCondition; +import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl; +import org.eclipse.birt.chart.model.attribute.impl.SeriesValueImpl; +import org.eclipse.birt.chart.model.component.Axis; +import org.eclipse.birt.chart.model.component.Series; +import org.eclipse.birt.chart.model.component.impl.AxisImpl; +import org.eclipse.birt.chart.model.component.impl.SeriesImpl; +import org.eclipse.birt.chart.model.data.BaseSampleData; +import org.eclipse.birt.chart.model.data.DataFactory; +import org.eclipse.birt.chart.model.data.GanttDataSet; +import org.eclipse.birt.chart.model.data.NumberDataSet; +import org.eclipse.birt.chart.model.data.OrthogonalSampleData; +import org.eclipse.birt.chart.model.data.SampleData; +import org.eclipse.birt.chart.model.data.SeriesDefinition; +import org.eclipse.birt.chart.model.data.SeriesGrouping; +import org.eclipse.birt.chart.model.data.TextDataSet; +import org.eclipse.birt.chart.model.data.impl.ActionImpl; +import org.eclipse.birt.chart.model.data.impl.GanttDataSetImpl; +import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl; +import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl; +import org.eclipse.birt.chart.model.data.impl.SeriesGroupingImpl; +import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl; +import org.eclipse.birt.chart.model.data.impl.TriggerImpl; +import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl; +import org.eclipse.birt.chart.model.impl.ChartWithoutAxesImpl; +import org.eclipse.birt.chart.model.layout.Legend; +import org.eclipse.birt.chart.model.type.BarSeries; +import org.eclipse.birt.chart.model.type.GanttSeries; +import org.eclipse.birt.chart.model.type.PieSeries; +import org.eclipse.birt.chart.model.type.impl.BarSeriesImpl; +import org.eclipse.birt.chart.model.type.impl.GanttSeriesImpl; +import org.eclipse.birt.chart.model.type.impl.PieSeriesImpl; +import org.eclipse.birt.chart.util.CDateTime; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.teneo.hibernate.resource.HibernateResource; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.part.EditorPart; + +import at.ac.uibk.wfr.perftool.Activity; +import at.ac.uibk.wfr.perftool.ActivityInstance; +import at.ac.uibk.wfr.perftool.Workflow; +import at.ac.uibk.wfr.perftool.presentation.PerftoolEditor; + +public class DeviceEventsTimelineEditorPart extends EditorPart implements ISelectionChangedListener { + + public static final String ID = "at.ac.uibk.wfr.perftool.perftooleditor.DeviceEventsTimelineEditorPart"; //$NON-NLS-1$ + + private PerftoolEditor mainEditor; + + private HibernateResource hResource; + + private Workflow selectedWorkflow = null; + + private BirtChartCanvas canvas; + + public DeviceEventsTimelineEditorPart(PerftoolEditor mainEditor) { + this.mainEditor = mainEditor; + this.mainEditor.addSelectionChangedListener(this); + hResource = mainEditor.getHibernateResource(); + } + + + @Override + public void init(IEditorSite site, IEditorInput input) throws PartInitException { + setSite(site); + setInput(input); + } + + + /** + * Create contents of the editor part. + * @param parent + */ + @Override + public void createPartControl(Composite parent) { + canvas = new BirtChartCanvas(null, parent, SWT.NONE); + } + + + @Override + public void setFocus() { + + } + + + public static Chart createChart2() { + ChartWithAxes chart = ChartWithAxesImpl.create(); + + chart.setDimension(ChartDimension.TWO_DIMENSIONAL_LITERAL); + chart.setType("Gantt Chart"); + chart.setSubType("Standard Gantt Chart"); + + chart.getBlock().setBackground(ColorDefinitionImpl.WHITE()); + chart.getPlot().setBackground(ColorDefinitionImpl.GREY()); + + chart.setTransposed(true); + + // Title + + chart.getTitle().getLabel().getCaption().setValue("Device Events");//$NON-NLS-1$ + + // Legend + Legend lg = chart.getLegend(); + LineAttributes lia = lg.getOutline(); + lg.getText().getFont().setSize(16); + lia.setStyle(LineStyle.SOLID_LITERAL); + lg.getInsets().set(10, 5, 0, 0); + lg.getOutline().setVisible(true); + lg.setAnchor(Anchor.NORTH_LITERAL); + lg.setItemType(LegendItemType.CATEGORIES_LITERAL); + + // X-Axis + Axis xAxisPrimary = chart.getPrimaryBaseAxes()[0]; + xAxisPrimary.setType(AxisType.TEXT_LITERAL); + xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL); + xAxisPrimary.getOrigin().setType(IntersectionType.MIN_LITERAL); + + // Y-Axis + + Axis yAxisPrimary = chart.getPrimaryOrthogonalAxis(xAxisPrimary); + yAxisPrimary.setType(AxisType.DATE_TIME_LITERAL); + yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL); + //yAxisPrimary.setSideBySide(true); + + // Data Set + TextDataSet categoryValues = TextDataSetImpl.create(new String[] {"PThread(0)", "PThread(1)", "PThread(2)" }); + //NumberDataSet orthoValues1 = NumberDataSetImpl.create(new double[] {12.5, 19.6, 18.3, 13.2, 26.5 }); + //NumberDataSet orthoValues2 = NumberDataSetImpl.create(new double[] {22.7, 23.6, 38.3, 43.2, 40.5 }); + + GanttDataSet phase1 = GanttDataSetImpl.create( new GanttEntry[]{ + new GanttEntry( new CDateTime( 2008, 1, 9 ), + new CDateTime( 2008, 6, 9 ), + "Task A" ), //$NON-NLS-1$ + new GanttEntry( new CDateTime( 2008, 3, 9 ), + new CDateTime( 2008, 8, 9 ), + "Task B" ), //$NON-NLS-1$ + new GanttEntry( new CDateTime( 2008, 5, 24 ), + new CDateTime( 2008, 9, 9 ), + "Task C" ) //$NON-NLS-1$ + } ); + GanttDataSet phase2 = GanttDataSetImpl.create( new GanttEntry[]{ + new GanttEntry( new CDateTime( 2008, 6, 12 ), + new CDateTime( 2008, 9, 23 ), + "Task A" ), //$NON-NLS-1$ + new GanttEntry( new CDateTime( 2008, 8, 9 ), + new CDateTime( 2008, 8, 9 ), + "Task B" ), //$NON-NLS-1$ + new GanttEntry( new CDateTime( 2008, 9, 9 ), + new CDateTime( 2008, 12, 9 ), + "Task C" ) //$NON-NLS-1$ + } ); + + NumberDataSet paletteValues = NumberDataSetImpl.create(new double[] {22.7, 23.6, 38.3, 43.2, 40.5 }); + + // X-Series + Series seCategory = SeriesImpl.create(); + seCategory.setDataSet(categoryValues); + SeriesDefinition sdX = SeriesDefinitionImpl.create(); + xAxisPrimary.getSeriesDefinitions().add(sdX); + sdX.getSeries().add(seCategory); + sdX.getSeriesPalette().shift(0); + + // Y-Series (1) + GanttSeries taskPhase1 = (GanttSeries) GanttSeriesImpl.create( ); + taskPhase1.setDataSet( phase1 ); + taskPhase1.getLabel( ).setVisible( false ); + + GanttSeries taskPhase2 = (GanttSeries) GanttSeriesImpl.create( ); + taskPhase2.setDataSet( phase2 ); + taskPhase2.getLabel( ).setVisible( false ); + + SeriesDefinition sdY1 = SeriesDefinitionImpl.create(); + sdY1.getSeriesPalette().shift(0); + yAxisPrimary.getSeriesDefinitions().add(sdY1); + sdY1.getSeries().add(taskPhase1); + sdY1.getSeries().add(taskPhase2); + + // Y-Series (1) + /*BarSeries bs1 = (BarSeries) BarSeriesImpl.create(); + bs1.setDataSet(orthoValues1); + bs1.getLabel().setVisible(true); + bs1.setLabelPosition(Position.INSIDE_LITERAL); + SeriesDefinition sdY1 = SeriesDefinitionImpl.create(); + sdY1.getSeriesPalette().shift(-2); + yAxisPrimary.getSeriesDefinitions().add(sdY1); + sdY1.getSeries().add(bs1);*/ + + return chart; + } + + + public static Chart createChart() { + ChartWithAxes chart = ChartWithAxesImpl.create(); + + chart.setDimension(ChartDimension.TWO_DIMENSIONAL_LITERAL); + chart.setType("Bar Chart"); + chart.setSubType("Stacked"); + + chart.getBlock().setBackground(ColorDefinitionImpl.WHITE()); + chart.getPlot().setBackground(ColorDefinitionImpl.GREY()); + + chart.setTransposed(true); + + // Title + + chart.getTitle().getLabel().getCaption().setValue("Device Events");//$NON-NLS-1$ + + // Legend + Legend lg = chart.getLegend(); + LineAttributes lia = lg.getOutline(); + lg.getText().getFont().setSize(16); + lia.setStyle(LineStyle.SOLID_LITERAL); + lg.getInsets().set(10, 5, 0, 0); + lg.getOutline().setVisible(true); + lg.setAnchor(Anchor.NORTH_LITERAL); + + // X-Axis + Axis xAxisPrimary = chart.getPrimaryBaseAxes()[0]; + xAxisPrimary.setType(AxisType.TEXT_LITERAL); + xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL); + xAxisPrimary.getOrigin().setType(IntersectionType.MIN_LITERAL); + + // Y-Axis + + Axis yAxisPrimary = chart.getPrimaryOrthogonalAxis(xAxisPrimary); + yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL); + //yAxisPrimary.setSideBySide(true); + + // Data Set + TextDataSet categoryValues = TextDataSetImpl.create(new String[] {"PThread(0)", "PThread(1)", "PThread(2)", "PThread(3)", "PThread(4)" }); + NumberDataSet orthoValues1 = NumberDataSetImpl.create(new double[] {12.5, 19.6, 18.3, 13.2, 26.5 }); + NumberDataSet orthoValues2 = NumberDataSetImpl.create(new double[] {22.7, 23.6, 38.3, 43.2, 40.5 }); + + /*SampleData sd = DataFactory.eINSTANCE.createSampleData(); + BaseSampleData sdBase = DataFactory.eINSTANCE.createBaseSampleData(); + sdBase.setDataSetRepresentation("");//$NON-NLS-1$ + sd.getBaseSampleData().add(sdBase); + + OrthogonalSampleData sdOrthogonal1 = DataFactory.eINSTANCE.createOrthogonalSampleData(); + sdOrthogonal1.setDataSetRepresentation("");//$NON-NLS-1$ + sdOrthogonal1.setSeriesDefinitionIndex(0); + sd.getOrthogonalSampleData().add(sdOrthogonal1); + + chart.setSampleData(sd);*/ + + + // X-Series + Series seCategory = SeriesImpl.create(); + seCategory.setDataSet(categoryValues); + SeriesDefinition sdX = SeriesDefinitionImpl.create(); + xAxisPrimary.getSeriesDefinitions().add(sdX); + sdX.getSeries().add(seCategory); + + // Y-Series (1) + BarSeries bs1 = (BarSeries) BarSeriesImpl.create(); + bs1.setDataSet(orthoValues1); + bs1.setStacked(true); + bs1.getLabel().setVisible(true); + bs1.setLabelPosition(Position.INSIDE_LITERAL); + + BarSeries bs2 = (BarSeries) BarSeriesImpl.create(); + bs2.setDataSet(orthoValues2); + bs2.setStacked(true); + bs2.getLabel().setVisible(true); + bs2.setLabelPosition(Position.INSIDE_LITERAL); + + SeriesDefinition sdY1 = SeriesDefinitionImpl.create(); + sdY1.getSeriesPalette().shift(0); + yAxisPrimary.getSeriesDefinitions().add(sdY1); + sdY1.getSeries().add(bs1); + sdY1.getSeries().add(bs2); + + // Y-Serires (2) + + /*BarSeries bs2 = (BarSeries) BarSeriesImpl.create(); + + bs2.setDataSet(orthoValues2); + bs2.getLabel().setVisible(true); + bs2.setLabelPosition(Position.INSIDE_LITERAL); + SeriesDefinition sdY2 = SeriesDefinitionImpl.create(); + sdY2.getSeriesPalette().shift(-3); + yAxisPrimary.getSeriesDefinitions().add(sdY2); + sdY2.getSeries().add(bs2);*/ + + return chart; + } + + + public static Chart createPie( ) + { + ChartWithoutAxes cwoaPie = ChartWithoutAxesImpl.create( ); + cwoaPie.setDimension( ChartDimension.TWO_DIMENSIONAL_WITH_DEPTH_LITERAL ); + cwoaPie.setType( "Pie Chart" ); //$NON-NLS-1$ + cwoaPie.setSubType( "Standard Pie Chart" ); //$NON-NLS-1$ + + // Plot + cwoaPie.setSeriesThickness( 10 ); + + // Legend + Legend lg = cwoaPie.getLegend( ); + lg.getOutline( ).setVisible( true ); + + // Title + cwoaPie.getTitle( ).getLabel( ).getCaption( ).setValue( "Pie Chart" );//$NON-NLS-1$ + + // Data Set + TextDataSet categoryValues = TextDataSetImpl.create( new String[]{ + "New York", "Boston", "Chicago", "San Francisco", "Dallas"} );//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ + NumberDataSet seriesOneValues = NumberDataSetImpl.create( new double[]{ + 54.65, 21, 75.95, 91.28, 37.43 + } ); + + SampleData sdata = DataFactory.eINSTANCE.createSampleData( ); + BaseSampleData sdBase = DataFactory.eINSTANCE.createBaseSampleData( ); + sdBase.setDataSetRepresentation( "" );//$NON-NLS-1$ + sdata.getBaseSampleData( ).add( sdBase ); + + OrthogonalSampleData sdOrthogonal = DataFactory.eINSTANCE.createOrthogonalSampleData( ); + sdOrthogonal.setDataSetRepresentation( "" );//$NON-NLS-1$ + sdOrthogonal.setSeriesDefinitionIndex( 0 ); + sdata.getOrthogonalSampleData( ).add( sdOrthogonal ); + + cwoaPie.setSampleData( sdata ); + + // Base Series + Series seCategory = SeriesImpl.create( ); + seCategory.setDataSet( categoryValues ); + + SeriesDefinition sd = SeriesDefinitionImpl.create( ); + cwoaPie.getSeriesDefinitions( ).add( sd ); + sd.getSeriesPalette( ).shift( 0 ); + sd.getSeries( ).add( seCategory ); + + // Orthogonal Series + PieSeries sePie = (PieSeries) PieSeriesImpl.create( ); + sePie.setDataSet( seriesOneValues ); + sePie.setSeriesIdentifier( "Cities" );//$NON-NLS-1$ + sePie.setExplosion( 5 ); + + SeriesDefinition sdCity = SeriesDefinitionImpl.create( ); + sd.getSeriesDefinitions( ).add( sdCity ); + sdCity.getSeries( ).add( sePie ); + + return cwoaPie; + } + + + + + @Override + public boolean isDirty() { + return false; + } + @Override + public boolean isSaveAsAllowed() { + return false; + } + @Override + public void doSave(IProgressMonitor monitor) { + } + @Override + public void doSaveAs() { + } + + + @Override + public void selectionChanged(SelectionChangedEvent event) { + System.out.println("DeviceEventsTimelineEditorPart.selectionChanged: " + event.getSelection().toString()); + if (event.getSelection() instanceof TreeSelection) { + TreeSelection sel = (TreeSelection) event.getSelection(); + Object o = sel.getFirstElement(); + if (o instanceof Workflow) { + selectedWorkflow = (Workflow) o; + canvas.setChart(createChart2()); + } else if (o instanceof Activity) { + selectedWorkflow = ((Activity) o).getParentWorkflow(); + canvas.setChart(createChart2()); + } else if (o instanceof ActivityInstance) { + selectedWorkflow = ((ActivityInstance) o).getParentWorkflow(); + canvas.setChart(createChart2()); + } + } + + } + +} diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/deviceeventstimeline/BirtChartCanvas.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/deviceeventstimeline/BirtChartCanvas.class new file mode 100755 index 0000000..cea26e1 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/deviceeventstimeline/BirtChartCanvas.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/deviceeventstimeline/BirtChartCanvasController.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/deviceeventstimeline/BirtChartCanvasController.class new file mode 100755 index 0000000..3a407c3 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/deviceeventstimeline/BirtChartCanvasController.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/deviceeventstimeline/DeviceEventsTimelineEditorPart$1DeviceInstanceEntry.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/deviceeventstimeline/DeviceEventsTimelineEditorPart$1DeviceInstanceEntry.class new file mode 100755 index 0000000..38f5223 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/deviceeventstimeline/DeviceEventsTimelineEditorPart$1DeviceInstanceEntry.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/deviceeventstimeline/DeviceEventsTimelineEditorPart.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/deviceeventstimeline/DeviceEventsTimelineEditorPart.class new file mode 100755 index 0000000..178feea Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/deviceeventstimeline/DeviceEventsTimelineEditorPart.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/perftooleditor/OverviewTreeComparator.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/perftooleditor/OverviewTreeComparator.class new file mode 100755 index 0000000..30fbb5a Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/perftooleditor/OverviewTreeComparator.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor$1.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor$1.class new file mode 100755 index 0000000..060bd7c Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor$1.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor$2.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor$2.class new file mode 100755 index 0000000..d47d78d Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor$2.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor$3.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor$3.class new file mode 100755 index 0000000..807cec4 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor$3.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor$NewAction.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor$NewAction.class new file mode 100755 index 0000000..fdd5e02 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor$NewAction.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor.class new file mode 100755 index 0000000..3bace32 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$1.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$1.class new file mode 100755 index 0000000..0b8c8a5 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$1.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$10.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$10.class new file mode 100755 index 0000000..49de1fd Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$10.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$11.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$11.class new file mode 100755 index 0000000..3af5477 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$11.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$12.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$12.class new file mode 100755 index 0000000..7f44497 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$12.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$1MyContentOutlinePage.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$1MyContentOutlinePage.class new file mode 100755 index 0000000..addfd6b Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$1MyContentOutlinePage.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$2$1.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$2$1.class new file mode 100755 index 0000000..93df622 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$2$1.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$2$2.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$2$2.class new file mode 100755 index 0000000..8daf6ef Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$2$2.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$2.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$2.class new file mode 100755 index 0000000..b4971fe Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$2.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$3$1.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$3$1.class new file mode 100755 index 0000000..5fc9e4f Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$3$1.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$3.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$3.class new file mode 100755 index 0000000..8c0d8c3 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$3.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$4.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$4.class new file mode 100755 index 0000000..89577be Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$4.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$5.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$5.class new file mode 100755 index 0000000..ac564aa Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$5.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$6.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$6.class new file mode 100755 index 0000000..101ac8b Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$6.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$7.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$7.class new file mode 100755 index 0000000..78bdcfb Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$7.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$8.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$8.class new file mode 100755 index 0000000..57c8aa0 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$8.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$9.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$9.class new file mode 100755 index 0000000..56032a1 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$9.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$ReverseAdapterFactoryContentProvider.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$ReverseAdapterFactoryContentProvider.class new file mode 100755 index 0000000..e2649ee Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor$ReverseAdapterFactoryContentProvider.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor.class new file mode 100755 index 0000000..ab7aeae Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard$1.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard$1.class new file mode 100755 index 0000000..fd39e0d Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard$1.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard$PerftoolModelWizardInitialObjectCreationPage$1.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard$PerftoolModelWizardInitialObjectCreationPage$1.class new file mode 100755 index 0000000..8828395 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard$PerftoolModelWizardInitialObjectCreationPage$1.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard$PerftoolModelWizardInitialObjectCreationPage$2.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard$PerftoolModelWizardInitialObjectCreationPage$2.class new file mode 100755 index 0000000..e4d35da Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard$PerftoolModelWizardInitialObjectCreationPage$2.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard$PerftoolModelWizardInitialObjectCreationPage.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard$PerftoolModelWizardInitialObjectCreationPage.class new file mode 100755 index 0000000..0da306b Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard$PerftoolModelWizardInitialObjectCreationPage.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard.class new file mode 100755 index 0000000..4416c9f Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$AboutAction.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$AboutAction.class new file mode 100755 index 0000000..48d0339 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$AboutAction.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$Application.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$Application.class new file mode 100755 index 0000000..0f90cfd Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$Application.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$OpenAction.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$OpenAction.class new file mode 100755 index 0000000..7b23230 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$OpenAction.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$OpenURIAction.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$OpenURIAction.class new file mode 100755 index 0000000..b360e9d Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$OpenURIAction.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$Perspective.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$Perspective.class new file mode 100755 index 0000000..d12af64 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$Perspective.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$WindowActionBarAdvisor.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$WindowActionBarAdvisor.class new file mode 100755 index 0000000..3287270 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$WindowActionBarAdvisor.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$WindowAdvisor.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$WindowAdvisor.class new file mode 100755 index 0000000..709b9a6 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor$WindowAdvisor.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor.class new file mode 100755 index 0000000..118e114 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorPlugin$Implementation.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorPlugin$Implementation.class new file mode 100755 index 0000000..ff79500 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorPlugin$Implementation.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorPlugin.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorPlugin.class new file mode 100755 index 0000000..2774a49 Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorPlugin.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/teneo.properties b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/teneo.properties new file mode 100755 index 0000000..ddfb453 --- /dev/null +++ b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/presentation/teneo.properties @@ -0,0 +1,29 @@ + ## Debug Settings +#hibernate.show_sql=true +#hibernate.format_sql=true +#hibernate.use_sql_comments=true + +hibernate.connection.driver_class=org.sqlite.JDBC + +#hibernate.connection.url=jdbc\:sqlite\:default.sqlite + +## Database Creation Mode (validate | update | create | create-drop) +hibernate.hbm2ddl.auto=validate + +hibernate.dialect=perftoolutils.SQLiteDialect + +teneo.naming.join_column_naming_strategy=simple + +## Teneo Settings +teneo.mapping.disable_econtainer=true +teneo.mapping.always_version=false +teneo.mapping.inheritance=JOINED +teneo.naming.sql_fk_name_prefix=fk_ +teneo.naming.set_foreign_key_name=true +hibernate.jdbc.batch_size=30 + +## Teneo Cache Settings +#hibernate.cache.use_second_level_cache=false +#hibernate.cache.use_query_cache=false +#teneo.mapping.default_cache_strategy=NONE +#hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory \ No newline at end of file diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/view/WFREventView$1.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/view/WFREventView$1.class new file mode 100755 index 0000000..1d12daa Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/view/WFREventView$1.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/view/WFREventView.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/view/WFREventView.class new file mode 100755 index 0000000..410bc7f Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/view/WFREventView.class differ diff --git a/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/wfreventview/WFREventViewResource.class b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/wfreventview/WFREventViewResource.class new file mode 100755 index 0000000..82b6fcb Binary files /dev/null and b/WFRperfTool.editor/bin/at/ac/uibk/wfr/perftool/wfreventview/WFREventViewResource.class differ diff --git a/WFRperfTool.editor/build.properties b/WFRperfTool.editor/build.properties new file mode 100755 index 0000000..c6fe01b --- /dev/null +++ b/WFRperfTool.editor/build.properties @@ -0,0 +1,11 @@ +# + +bin.includes = .,\ + icons/,\ + META-INF/,\ + plugin.xml,\ + plugin.properties,\ + libs/sqlite-jdbc-3.7.2.jar +jars.compile.order = . +source.. = src/ +output.. = bin diff --git a/WFRperfTool.editor/icons/full/obj16/PerftoolModelFile.gif b/WFRperfTool.editor/icons/full/obj16/PerftoolModelFile.gif new file mode 100755 index 0000000..689b728 Binary files /dev/null and b/WFRperfTool.editor/icons/full/obj16/PerftoolModelFile.gif differ diff --git a/WFRperfTool.editor/icons/full/wizban/NewPerftool.gif b/WFRperfTool.editor/icons/full/wizban/NewPerftool.gif new file mode 100755 index 0000000..e976e07 Binary files /dev/null and b/WFRperfTool.editor/icons/full/wizban/NewPerftool.gif differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/ChangeLog b/WFRperfTool.editor/libs/jfreechart-1.0.17/ChangeLog new file mode 100755 index 0000000..f2d0aaa --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/ChangeLog @@ -0,0 +1,11407 @@ +2013-11-23 David Gilbert + + Bug #977: + * org/jfree/chart/axis/DateAxis.java + (DEFAULT_DATE_TICK_UNIT): Deprecated, + (DateAxis): Replace DEFAULT_DATE_TICK_UNIT with new instance. + +2013-11-22 David Gilbert + + * org/jfree/chart/util/PaintAlpha.java + (darker): Remove reflection code no longer required, + (darkerLinearGradientPaint): Likewise, + (darkerRadialGradientPaint): Likewise, + (darkerTexturePaint): Likewise. + +2013-11-21 David Gilbert + + * org/jfree/chart/util/DirectionalGradientPaintTransformer.java: New file. + +2013-11-21 David Gilbert + + * org/jfree/data/time/ohlc/OHLCSeries.java + (add(OHLCItem)): New method. + +2013-11-21 David Gilbert + + * org/jfree/data/general/AbstractDataset.java + (notify): New flag, + (AbstractDataset): Initialise notify to true, + (getNotify): New method, + (setNotify): Likewise, + (fireDatasetChanged): Only fire change if notify flag is true. + +2013-11-21 David Gilbert + + * org/jfree/data/xy/XYSeriesCollection.java + (removeSeries(int)): Ensure VetoableListener is deregistered. + +2013-11-21 David Gilbert + + * org/jfree/data/time/TimeSeriesCollection.java + (getSeriesIndex): New method, + (addSeries): Register VetoableListener, + (removeSeries): Deregister VetoableListener, + (removeAllSeries): Likewise, + (vetoableChange): Check that series key does not clash with existing + names. + +2013-11-21 David Gilbert + + Bug #1084: + * org/jfree/chart/block/BorderArrangement.java + (add): Treat key that is not a RectangleEdge as null. + +2013-11-21 David Gilbert + + Bug #1109: + * org/jfree/chart/renderer/category/WaterfallBarRenderer.java + (drawItem): Use positive bar paint when difference is 0. + +2013-11-21 David Gilbert + + * org/jfree/chart/utils/HMSNumberFormat.java: New class. + +2013-11-20 David Gilbert + + * org/jfree/chart/renderer/xy/XYSplineRenderer.java + (FillType): New enumeration of fill types, + (XYSplineState): New class, + (fillType): New attribute, + (gradientPaintTransformer): Likewise, + (XYSplineRenderer(int, FillType)): New constructor, + (getFillType): New method, + (setFillType): Likewise, + (getGradientPaintTransformer): Likewise, + (setGradientPaintTransformer): Likewise, + (initialise): Use new XYSplineState class, + (drawPrimaryLineAsPath): Add filling options, + (equals): Check new attributes, + (ControlPoint): Removed. + +2013-09-17 David Gilbert + + * org/jfree/chart/renderer/category/GradientBarPainter.java + (paintBar): Fix coordinate bug for gradient paint. + +---------- JFREECHART 1.0.16 RELEASED ------------------------ + +2013-09-12 David Gilbert + + * org/jfree/chart/LocalizationBundle.properties + (FILE_EXISTS_CONFIRM_OVERWRITE): New entry, + (PDF_Files): Likewise, + (SVG_Files): Likewise, + * org/jfree/chart/ChartPanel.java + (SAVE_AS_PNG_COMMAND): New field, + (SAVE_AS_SVG_COMMAND): Likewise, + (SAVE_AS_PDF_COMMAND): Likewise, + (actionPerformed): Handle SVG and PDF options, + (saveAsSVG): New private method, + (generateSVG): New method, + (createSVGGraphics2D): New private method, + (saveAsPDF): Likewise, + (isOrsonPDFAvailable): Likewise, + (writeAsPDF): Likewise, + (createPopupMenu): Add SVG and PDF options when available, + * org/jfree/chart/plot/PiePlot.java + (draw): Check for KEY_SUPPRESS_SHADOW_GENERATION rendering hint, + * org/jfree/chart/plot/CategoryPlot.java + (draw): Likewise, + * org/jfree/chart/plot/XYPlot.java + (draw): Likewise. + +2013-09-12 David Gilbert + + * org/jfree/chart/JFreeChart.java + (KEY_SUPPRESS_SHADOW_GENERATION): new field. + +2013-09-12 David Gilbert + + * org/jfree/chart/axis/DateAxis.java + (zoomRange): Prevent axis range from falling below 1 millisecond. + +2013-08-30 David Gilbert + + * org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java + (drawItem): Set stroke and paint for drawing lines (bugfix). + +2013-08-16 David Gilbert + + * org/jfree/chart/plot/CombinedDomainCategoryPlot.java + (setShadowGenerator): New method override, + * org/jfree/chart/plot/CombinedRangeCategoryPlot.java + (setShadowGenerator): Likewise, + * org/jfree/chart/plot/CombinedDomainXYPlot.java + (setShadowGenerator): Likewise, + * org/jfree/chart/plot/CombinedRangeXYPlot.java + (setShadowGenerator): Likewise. + +2013-08-15 David Gilbert + + * org/jfree/chart/plot/PiePlot.java + (lookupSectionPaint): Replace reflection code with Java 1.6 equivalent. + +2013-08-10 David Gilbert + + * org/jfree/data/general/DatasetUtilities.java + (findYValue): New method, + (findItemIndicesForX): Likewise. + +2013-08-04 David Gilbert + + * org/jfree/chart/ChartFactory.java + (createPieChart): Simplified version (less parameters), + (createPieChart3D): Likewise, + (createBarChart): Likewise, + (createStackedBarChart): Likewise, + (createBarChart3D): Likewise, + (createStackedBarChart3D): Likewise, + (createAreaChart): Likewise, + (createStackedAreaChart): Likewise, + (createLineChart): Likewise, + (createLineChart3D): Likewise, + (createGanttChart): Likewise, + (createScatterPlot): Likewise, + (createXYBarChart): Likewise, + (createXYAreaChart): Likewise, + (createStackedXYAreaChart): Likewise, + (createXYLineChart): Likewise, + (createXYStepChart): Likewise, + (createXYStepAreaChart): Likewise, + (createTimeSeriesChart): Likewise, + (createBubbleChart): Likewise. + +2013-08-01 David Gilbert + + * org/jfree/chart/axis/Axis.java + (labelLocation): New field, + (Axis): Initialise new field, + (getLabelLocation): New method, + (setLabelLocation): Likewise, + (labelLocationX): Likewise, + (labelLocationY): Likewise, + (labelAnchorH): Likewise, + (labelAnchorV): Likewise, + (drawLabel): Take into account position, + (drawAttributedLabel): Likewise, + * org/jfree/chart/axis/AxisLabelLocation.java: New class. + +2013-08-01 David Gilbert + + * org/jfree/chart/axis/Axis.java + (attributedLabel): New field, + (setLabel): Simplified, + (getAttributedLabel): New method, + (setAttributedLabel(String)): Likewise, + (setAttributedLabel(AttributedString)): Likewise, + (createAttributedLabel(String)): New private method, + (getLabelEnclosure): Use attributedLabel if not null,¨ + (drawAttributedLabel): New method, + (equals): Check new attributedLabel field, + (hashCode): Call super, + (writeObject): Write attributedLabel, + (readObject): Read attributedLabel, + * org/jfree/chart/axis/NumberAxis.java + (draw): Use attributedLabel if not null, + * org/jfree/chart/axis/NumberAxis3D.java: Likewise, + * org/jfree/chart/axis/CategoryAxis.java: Likewise, + * org/jfree/chart/axis/CategoryAxis3D.java: Likewise, + * org/jfree/chart/axis/SubCategoryAxis.java: Likewise, + * org/jfree/chart/axis/DateAxis.java: Likewise, + * org/jfree/chart/axis/LogAxis.java: Likewise, + * org/jfree/chart/axis/PeriodAxis.java: Likewise, + * org/jfree/chart/utils/AttrStringUtils.java: New class. + +2013-08-01 David Gilbert + + * org/jfree/experimental/swt/SWTGraphics2D.java + (SWTGraphics2D): Set default stroke, + (setPaint): Do nothing for null, + (setColor): Likewise, + (setBackground): Store color for later, don't update GC now, + (getBackground): Return stored color, + (setComposite): Throw IllegalArgumentException for null, + (setStroke): Likewise, + (clipRect): Fix to apply intersect operation, + (rotate(double)): Reimplemented, + (rotate(double, double, double)): Implemented, + (shear): Reimplemented, + (clearRect): Do nothing if background color is null, + (drawGlyphVector): Implemented, + (drawString(String, int, int)): Delegate, + (drawString(String, float, float)): Check for null string, + (hit): Implemented. + +2013-07-25 David Gilbert + + * org/jfree/chart/axis/CategoryAxis.java + (categoryLabelURLs): New field, + (CategoryAxis): Initialise URL storage, + (addCategoryLabelURL): New method, + (getCategoryLabelURL): Likewise, + (removeCategoryLabelURL): Likewise, + (clearCategoryLabelURLs): Likewise, + (drawCategoryLabels): Add URL info, + (clone): Clone URLs, + (equals): Test URLs. + +2013-07-25 David Gilbert + + Bug 1107: + * org/jfree/chart/axis/PeriodAxis.java + (PeriodAxis): Use timezone when creating default PeriodAxisLabelInfo, + (drawTickLabels): Apply timezone to date formatter. + +2013-07-25 David Gilbert + + * org/jfree/chart/axis/PeriodAxisLabelInfo.java + (PeriodAxisLabelInfo): clone dateFormat, + (getDateFormat): return clone, + * org/jfree/chart/axis/PeriodAxis.java + (drawTickLabels): fetch dateFormat only once. + +2013-07-05 David Gilbert + + * org/jfree/chart/plot/PolarPlot.java + (setRadiusMinorGridlinesVisible): Fire change event. + +---------- JFREECHART 1.0.15 RELEASED ------------------------ + +2013-07-04 David Gilbert + + * org/jfree/chart/renderer/DefaultPolarItemRenderer.java + (drawAngularGridLines): Check for inverted axis, + (drawRadialGridLines): Likewise. + +2013-07-01 David Gilbert + + * org/jfree/chart/annotation/TextAnnotation.java + (setText): Fire change event. + +2012-09-18 David Gilbert + + Bug 3508799: + * org/jfree/chart/renderer/DefaultPolarItemRenderer.java + (getLegendItem): Populate seriesKey. + +2012-09-15 David Gilbert + + * org/jfree/chart/plot/CombinedDomainXYPlot.java + (add(XYPlot, int)): Use ParamChecks class, + (remove): Likewise, + (findSubPlot): Likewise. + +2012-09-04 David Gilbert + + Bug 3555275: + * org/jfree/chart/axis/ValueAxis.java + (reserveSpace): Return correct value for axes with a fixed dimension + specified. + +2012-08-23 David Gilbert + + Bug 3561093: + * org/jfree/chart/renderer/RendererUtilities.java + (findLiveItemsLowerBound): changed while loop expression, + (findLiveItemsUpperBound): likewise. + +2012-07-28 David Gilbert + + * org/jfree/data/general/Series.java + (setKey): Update exception argument and Javadocs, + * org/jfree/data/general/XYSeriesCollection.java + (vetoableChange) : Call getSeriesIndex() rather than getSeries(), + * tests/org/jfree/data/xy/junit/XYSeriesCollectionTests.java + (testSeriesRename): New test method. + +2012-07-17 David Gilbert + + * org/jfree/data/time/Month.java + (getFirstMillisecond): Use getTimeInMillis(); + (getLastMillisecond): Likewise; + * org/jfree/data/time/Year.java + Likewise; + * org/jfree/data/time/Quarter.java + Likewise; + * org/jfree/data/time/Week.java + Likewise; + * org/jfree/data/time/Day.java + Likewise, + * org/jfree/data/time/Hour.java + Likewise, + * org/jfree/data/time/Minute.java + Likewise, + * org/jfree/data/time/Second.java + Likewise; + * org/jfree/data/time/Millisecond.java + Likewise. + +2012-07-17 David Gilbert + + * org/jfree/chart/renderer/AbstractRenderer.java + Remove use of BooleanUtilities throughout; + * org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + Likewise. + +2012-07-12 David Gilbert + + (from Leo Leung) + * org/jfree/chart/LocalisationBundle_ja.properties: + Updated translations. + +2012-07-05 David Gilbert + + * org/jfree/chart/encoders/ImageEncoderFactory.java + (encoders): Change type to Map, + (init) : Remove JDK 1.3 specific code. + +2012-07-05 David Gilbert + + * org/jfree/chart/ChartPanel.java + (setMouseWheelEnabled): Remove reflection only needed for JRE 1.3.1. + +2012-07-02 David Gilbert + + Translations by Leo Leung: + * org/jfree/chart/LocalisationBundle_ja.properties: New translation file; + * org/jfree/chart/editor/LocalisationBundle_ja.properties: Likewise; + * org/jfree/chart/plot/LocalisationBundle_ja.properties: Likewise. + +2012-07-01 David Gilbert + + * org/jfree/chart/plot/PiePlot.java + (drawSimpleLabels): Generate label once only (DG); + +2012-07-01 David Gilbert + + Bug 3521736 (optimisation) + * org/jfree/chart/renderer/xy/DeviationRenderer.java + (drawItem): Provide initial capacity for GeneralPath. + +2012-06-11 David Gilbert + + Patch 3204823 by DaveLaw + * org/jfree/chart/plot/PiePlot3D.java + (drawSide): Use new PaintAlpha class, + * org/jfree/chart/renderer/category/BarRenderer3D.java + (drawItem): Likewise, + * org/jfree/chart/renderer/category/StackedBarRenderer3D.java + (drawStackHorizontal): Likewise, + (drawStackVertical): Likewise, + * org/jfree/chart/util/PaintAlpha.java: New class. + +2012-05-10 David Gilbert + + * org/jfree/chart/renderer/xy/XYBarRenderer.java + (findDomainBounds): call new method in super-class to take account of + non-visible series, + (findRangeBounds): likewise; + * tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java + (testFindDomainBounds2): new test; + (testFindRangeBounds2): Likewise. + +2012-03-11 Martin Hoeller + + Patch 3500621 by Simon Kaczor + * org/jfree/chart/title/LegendTitle + (sortOrder): New field, + (getSortOrder): New method, + (setSortOrder): Likewise, + (fetchLgendItems): Updated to support new sort order, + (equals): Likewise. + * tests/org/jfree/chart/title/LegendTitle + (testEquals): Adapted for new field. + +2012-02-13 Martin Hoeller + + Bug 3425881/Patch 3450234 by Patrick Schlott/Christoph Schroeder, + reviewed by Richard West + * org/jfree/chart/rendered/xy/XYDifferenceRenderer + (drawItemPass0): Fix problems with identical x-values. + +2012-02-08 Martin Hoeller + + Bug 3484403: + * org/jfree/chart/axis/DateAxis + (refreshTicksHorizontal): Fix endless loop, + (refreshTicksVertical): Likewise; + +2012-02-08 Martin Hoeller + + Bug 3484408: + * ant/build.xml: fixed maven-bundle task. + +2012-01-08 David Gilbert + + * source/org/jfree/chart/plot/dial/StandardDialScale.java + (angleToValue): Implemented and removed FIXME. + +2012-01-08 David Gilbert + + Bug 3445507: + * source/org/jfree/data/time/TimeSeriesCollection.java + (getRangeBounds(boolean)): New method, + (getRangeBounds(List, Range, boolean)): Fix combining of ranges. + +2012-01-08 David Gilbert + + * source/org/jfree/data/Range.java + (combineIgnoringNaN): New method. + +2012-01-08 David Gilbert + + Patch 3463807 by Sebastiao Correia + * swt/org/jfree/experimental/chart/swt/ChartComposite.java + (dispose): Dispose the popup if not null. + +2011-12-21 Martin Hoeller + + Patch 3447161 by Ulrich Voigt/Martin Hoeller: + * org/jfree/chart/plot/CombinedDomainXYPlot.java: + (panRangeAxes): new method; + * org/jfree/chart/plot/CombinedRangeXYPlot.java + (panDomainAxes): new method; + +2011-12-16 Martin Hoeller + + Add support to hide minor gridlines for PolarPlot: + * org/jfree/chart/plot/PolarPlot.java + (radiusMinorGridlinesVisible): New field, + (isRadiusMinorGridlinesVisible): New method, + (setRadiusMinorGridlinesVisible): Likewise, + (buildRadialTicks): Likewise, + (drawGridlines): Updated to support new flag; + +2011-11-12 Martin Hoeller + + Improvements to axis and plot editors: + * org/jfree/chart/editor/DefaultValueAxisEditor.java: New file; + * org/jfree/chart/editor/DefaultLogAxisEditor.java: New file; + * org/jfree/chart/editor/DefaultPolarPlotEditor.java: New file; + * org/jfree/chart/editor/DefaultChartEditor.java: + (constructor): added support for DefaultPolarPlotEditor; + * org/jfree/chart/editor/DefaultAxisEditor.java + (constructor): added support for DefaultLogAxisEditor; + * org/jfree/chart/editor/DefaultNumberAxisEditor.java: refactoring; + * org/jfree/chart/editor/DefaultPlotEditor.java + (createPlotPanel): new method, + (createPlotTabs): new method; + * org/jfree/chart/editor/LocalizationBundle_ru.properties: addition + * org/jfree/chart/editor/LocalizationBundle_pt_PT.properties: addition + * org/jfree/chart/editor/LocalizationBundle_de.properties: addition + * org/jfree/chart/editor/LocalizationBundle_zh_CN.properties: addition + * org/jfree/chart/editor/LocalizationBundle_pt_BR.properties: addition + * org/jfree/chart/editor/LocalizationBundle_es.properties: addition + * org/jfree/chart/editor/LocalizationBundle_fr.properties: addition + * org/jfree/chart/editor/LocalizationBundle_nl.properties: addition + * org/jfree/chart/editor/LocalizationBundle_pl.properties: addition + * org/jfree/chart/editor/LocalizationBundle.properties: addition + +2011-12-03 David Gilbert + + Bug 2879650: + * org/jfree/chart/servlet/DisplayChart.java + (service): Don't display file path in exception. + +2011-12-03 David Gilbert + + Bug 3446965: + * org/jfree/data/time/TimeSeries.java + (addOrUpdate): correct update of this.maxY. + +---------- JFREECHART 1.0.14 RELEASED ------------------------ + +2011-11-20 David Gilbert + + Bug 3440237: + * org/jfree/chart/plot/CategoryPlot.java + (CategoryPlot): initialise shadow generator as null; + (PiePlot): likewise; + +2011-11-13 David Gilbert + + Patch 3435734 by Martin Hoeller: + * org/jfree/chart/renderer/category/LineRenderer3D.java + (drawItem): Draw lines in pass 0 and item labels in pass 1; + +2011-11-12 Martin Hoeller + + Bug 3432721: + * org/jfree/chart/plot/PolarPlot.java + (translateToJava2D): Fix calculation to work with any axis, + (translateValueThetaRadiusToJava2D): eliminate duplicate code; + * tests/org/jfree/chart/plot/PolarPlotTests.java + (testTranslateToJava2D_NumberAxis): New method, + (testTranslateToJava2D_NumberAxisAndMargin): New method, + (testTranslateToJava2D_LogAxis): New method; + +2011-11-09 Martin Hoeller + + Translations provided by Petr Kopac: + * org/jfree/chart/LocalizationBundle_cs.properties: New file; + * org/jfree/chart/plot/LocalizationBundle_cs.properties: New file; + * org/jfree/chart/editor/LocalizationBundle_cs.properties: New file; + +2011-11-09 Martin Hoeller + + Bug 3433405: + * org/jfree/chart/renderer/category/LineRenderer3D.java + (drawItem): Fixed eventually wrong item label position; + +2011-11-01 David Gilbert + + Bug 3432020: + * org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (clone): Remove duplicated lines. + +2011-10-30 David Gilbert + + * org/jfree/chart/renderer/category/IntervalBarRenderer.java + (drawInterval): Fix calculation of bar edge; + * org/jfree/chart/renderer/category/StatisticalBarRenderer.java + (drawHorizontalItem): Fix calculation of bar edge; + (drawVerticalItem): Likewise; + +2011-10-30 David Gilbert + + * org/jfree/chart/StandardChartTheme.java + (StandardChartTheme(String, boolean)): New method. + +2011-10-28 Martin Hoeller + + Bug 2810220: + * org/jfree/chart/renderer/category/StatisticalBarRenderer.java + (drawHorizontalItem): Fixed offset problem with maximalBarWidth, + (drawVerticalItem): Likewise; + +2011-10-28 Martin Hoeller + + Bug 3428870: + * org/jfree/chart/annotations/TextAnnotation.java + (setRotationAnchor): Added missing argument check, Bug #3428870; + +2011-10-28 Martin Hoeller + + Bug 3429707: + * org/jfree/chart/axis/LogAxis.java + (refreshTicksHorizontal): Fixed endless loop for 0 TickUnit, + (refreshTicksVertical): Likewise; + +2011-10-19 David Gilbert + + Bug 3072674: + * org/jfree/data/statistics/DefaultStatisticalCategoryDataset.java + (getRangeLowerBound): Check for NaN, + (getRangeUpperBound): Likewise, + (getRangeBounds): Call getRangeLowerBound() and getRangeUpperBound(). + +2011-10-19 David Gilbert + + Bug 3026341: + * org/jfree/chart/renderer/xy/XYShapeRenderer.java + (findDomainBounds): Check for null, + (findRangeBounds): Likewise. + +2011-10-18 David Gilbert + + Bug 3190615: + * org/jfree/data/xy/CategoryTableXYDataset.java + (clear): New method. + +2011-10-16 David Gilbert + + * org/jfree/chart/plot/PiePlot.java + (drawItem): Use new Paint lookup, + (getArcCenter): New protected method, + (lookupSectionPaint): Handle GradientPaint. + +2011-10-16 David Gilbert + + * org/jfree/chart/util/ParamChecks.java: New class; + * org/jfree/data/general/Series.java + (vetoableChangeSupport): New field, + (Series(Comparable, String)): Initialise vetoableChangeSupport, + (setKey): Fire vetoable property change, + (clone): Initialise vetoableChangeSupport, + (addVetoableChangeListener): New method; + * org/jfree/data/xy/XYSeriesCollection.java + (XYSeriesCollection(XYSeries)): Register listener, + (addSeries): Check for duplicate key, register listener, + (removeSeries): Deregister listener, + (removeAllSeries): Likewise, + (getSeriesIndex): New method, + (vetoableChange): New method. + +2011-10-16 Martin Hoeller + + * org/jfree/chart/renderer/DefaultPolarItemRenderer.java + (readObject): Handle fillComposite serialization; + (writeObject): Likewise. + +2011-10-15 David Gilbert + + * org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (getLegendItem): Added early returns to reduce indentation, updated + Javadoc. + +2011-10-13 Martin Hoeller + + * pom.xml added + +2011-10-11 David Gilbert + + * org/jfree/data/time/TimeSeries.java + (update(RegularTimePeriod, double)): new method. + +2011-10-11 Martin Hoeller + + Patch 3421088: + * org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (drawVerticalItem): bugfix for misaligned whiskers. + +2011-10-11 David Gilbert + + Bug 3237879: + * org/jfree/chart/plot/RingPlot.java + (drawItem): Check sectionOutlineVisible flag. + +2011-10-10 Martin Hoeller + + Bug 3165708: + * org/jfree/chart/PolarChartPanel.java: localization fix + +2011-10-10 Martin Hoeller + + Bug 3353913: + * org/jfree/chart/plot/CompassPlot.java: localization fix + * org/jfree/chart/plot/PiePlot3D.java: localization fix + * org/jfree/chart/plot/LocalizationBundle_de.properties: addition + * org/jfree/chart/plot/LocalizationBundle_ru.properties: addition + * org/jfree/chart/plot/LocalizationBundle_nl.properties: addition + * org/jfree/chart/plot/LocalizationBundle_pl.properties: addition + * org/jfree/chart/plot/LocalizationBundle_zh_CN.properties: addition + * org/jfree/chart/plot/LocalizationBundle_es.properties: addition + * org/jfree/chart/plot/LocalizationBundle_pt_PT.properties: addition + * org/jfree/chart/plot/LocalizationBundle_fr.properties: addition + * org/jfree/chart/plot/LocalizationBundle.properties: addition + * org/jfree/chart/ChartPanel.java: localization fix + * org/jfree/chart/LocalizationBundle_de.properties: addition + * org/jfree/chart/LocalizationBundle_zh_TW.properties: addition + * org/jfree/chart/LocalizationBundle_zh_CN.properties: addition + * org/jfree/chart/LocalizationBundle_pt_BR.properties: addition + * org/jfree/chart/LocalizationBundle_es.properties: addition + * org/jfree/chart/LocalizationBundle_ru.properties: addition + * org/jfree/chart/LocalizationBundle_pt_PT.properties: addition + * org/jfree/chart/LocalizationBundle_fr.properties: addition + * org/jfree/chart/LocalizationBundle_nl.properties: addition + * org/jfree/chart/LocalizationBundle_pl.properties: addition + * org/jfree/chart/LocalizationBundle_it.properties: addition + * org/jfree/chart/LocalizationBundle.properties: addition + +2011-10-07 Martin Hoeller + + Bug 3035289/Patch 3035325: + * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java + (drawItem): check if series and item are visible + +2011-10-07 Martin Hoeller + + * source/org/jfree/chart/renderer/PolarItemRenderer.java + (useFillPaint): New field, + (legendLine): Likewise; + (connectFirstAndLastPoint): New method, + (toolTipGeneratorList): Likewise, + (baseToolTipGenerator): Likewise, + (urlGenerator): Likewise, + (legendItemToolTipGenerator): Likewise, + (legendItemURLGenerator): Likewise, + (getConnectFirstAndLastPoint): Likewise, + (setConnectFirstAndLastPoint): Likewise, + (getUseFillPaint): Likewise, + (setUseFillPaint): Likewise, + (getLegendLine): Likewise, + (setLegendLine): Likewise, + (getToolTipGenerator): Likewise, + (getSeriesToolTipGenerator): Likewise, + (setSeriesToolTipGenerator): Likewise, + (getBaseToolTipGenerator): Likewise, + (setBaseToolTipGenerator): Likewise, + (getURLGenerator): Likewise, + (setURLGenerator): Likewise, + (getLegendItemToolTipGenerator): Likewise, + (setLegendItemToolTipGenerator): Likewise, + (getLegendItemURLGenerator): Likewise, + (setLegendItemURLGenerator): Likewise. + * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java + (getToolTipGenerator): New method, + (getSeriesToolTipGenerator): Likewise, + (setSeriesToolTipGenerator): Likewise, + (getBaseToolTipGenerator): Likewise, + (setBaseToolTipGenerator): Likewise, + (getURLGenerator): Likewise, + (setURLGenerator): Likewise. + * source/org/jfree/chart/plot/PolarPlot.java + (angleOffset): New field, + (counterClockwise): Likewise; + (getAxisCount): New method, + (getDatasetCount): Likewise, + (getAngleOffset): Likewise, + (setAngleOffset): Likewise, + (isCounterClockwise): Likewise, + (setCounterClockwise): Likewise, + (getAxisIndex): Likewise, + +2011-10-06 David Gilbert + + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (lineTo): New method; + (moveTo): New method; + * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java + (drawItem): Replace GeneralPath lineTo() and moveTo(); + * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java + (drawItem): Replace GeneralPath lineTo() and moveTo(); + +2011-10-06 David Gilbert + + Bug 3418287 + * tests/org/jfree/chart/util/junit/RelativeDateFormatTests.java + (setUp): New method; + (tearDown): New method. + +2010-03-30 David Gilbert + + Patch 2954302: + * source/org/jfree/chart/annotation/CategoryPointerAnnotation.java + (draw): Modified calculation of pointer line. + +2010-02-16 David Gilbert + + Patch 2952086 by Martin Hoeller: + * source/org/jfree/chart/renderer/xy/XYShapeRenderer.java + (findZBounds): New method, + * source/org/jfree/data/general/DatasetUtilities.java + (findZBounds(XYZDataset): New method, + (findZBounds(XYZDataset, boolean)): Likewise, + (findZBounds(XYZDataset, List, Range, boolean)): Likewise, + * tests/org/jfree/chart/renderer/xy/junit/XYShapeRendererTests.java + (testFindZBounds): New method. + +2010-02-09 David Gilbert + + Bug 2946521: + * source/org/jfree/chart/plot/dial/StandardDialScale.java + (StandardDialScale): Check 'majorTickIncrement' argument. + +2010-02-09 David Gilbert + + Bug 2947660: + * source/org/jfree/chart/renderer/category/AbstractCategoryRenderer.java + (getLegendItems): Fix null check. + +2009-12-09 David Gilbert + + * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java + (getLegendItem): Handle multiple datasets, + * source/org/jfree/chart/plot/PolarPlot.java + (fixedLegendItems): New field, + (getFixedLegendItems): New method, + (setFixedLegendItems): Likewise, + (getIndexOf(PolarItemRenderer)): Likewise, + (getLegendItems): Handle multiple datasets, + (equals): Updated for new fields. + +2009-12-08 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java + (drawVerticalItems): Check for null outliers. + +2009-12-08 David Gilbert + + * source/org/jfree/data/statistics/HistogramDataset.java + (addSeries): Fire dataset change event. + +2009-11-27 David Gilbert + + * source/org/jfree/chart/plot/PolarPlot.java + (axis): Removed, + (dataset): Likewise, + (renderer): Likewise, + (axes): New field, + (axisLocations): Likewise, + (datasets): Likewise, + (renderers): Likewise, + (datasetToAxesMap): Likewise, + (PolarPlot(XYDataset, ValueAxis, PolarItemRenderer)): Initialise new fields, + (getAxis): Delegate to new method, + (ValueAxis getAxis(int)): New method, + (setAxis(ValueAxis)): Delegate to new method, + (setAxis(int, ValueAxis)): New method, + (setAxis(int, ValueAxis, boolean)): Likewise, + (getAxisLocation): New method, + (getAxisLocation(int)): Likewise, + (setAxisLocation(PolarAxisLocation)): Likewise, + (setAxisLocation(PolarAxisLocation, boolean)): Likewise, + (getDataset): Delegate to new method, + (getDataset(int)): New method, + (setDataset(XYDataset)): Delegate to new method, + (setDataset(int, XYDataset)): New method, + (indexOf(XYDataset)): New method, + (getRenderer): Delegate to new method, + (getRenderer(int)): New method, + (setRenderer(PolarItemRenderer)): Delegate to new method, + (setRenderer(int, PolarItemRenderer)): New method, + (setRenderer(int, PolarItemRenderer, boolean)): New method, + (mapDatasetToAxis(int, int)): New method, + (mapDatasetToAxes(int, List)): New method, + (checkAxisIndices(List)): New private method, + (getAxisForDataset(int)): New method, + (draw): Updated to support multiple datasets, axes and renderers, + (drawAxis): Handle alternative axis locations, + (render): Handle multiple datasets, + (drawGridlines): Fetch primary axis, + (zoom): Added FIXME, + (getDataRange): Likewise, + (datasetChanged): Likewise, + (getLegendItems): Likewise, + (getSeriesCount): Deprecated, + (equals): Updated for new fields, + (clone): Likewise, + (readObject): Likewise, + (zoomRangeAxes): Added FIXME, + (translateToJava2D): New method, + (translateValueThetaRadiusToJava2D): Deprecated, + (getMaxRadius): Likewise, + (drawAxis): Likewise, + * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java + (drawSeries): Fetch appropriate axis, + (drawAngularGridLines): Update for deprecated method, + * source/org/jfree/chart/plot/PolarAxisLocation.java: New file. + +2009-11-04 David Gilbert + + * source/org/jfree/chart/MouseWheelHandler.java + (mouseWheelMoved): Handle PiePlot, + * source/org/jfree/chart/demo/PieChartDemo1.java + (createDemoPanel): Enable mouse wheel, + * source/org/jfree/chart/plot/PiePlot.java + (handleMouseWheelRotation): New method. + +2009-11-03 David Gilbert + + * source/org/jfree/chart/renderer/AbstractCategoryItemRenderer.java + (getLegendItems): Check series rendering order in plot, + * source/org/jfree/chart/plot/CategoryPlot.java + (getLegendItems): Use getLegendItems() method in each renderer. + +2009-11-02 David Gilbert + + Bug 2876406: + * source/org/jfree/data/time/TimeTableXYDataset.java + (add): Changed String parameter to Comparable, + (remove): Likewise. + +2009-09-28 David Gilbert + + Patch 2868608 by Peter Becker: + * source/org/jfree/chart/renderer/BoxAndWhiskerRenderer.java + (whiskerWidth): New field, + (BoxAndWhiskerRenderer): Set new field default, + (getWhiskerWidth): New method, + (setWhiskerWidth): Likewise, + (drawHorizontalItem): Use new field, + (drawVerticalItem): Likewise, + (equals): Check new flag. + +2009-09-28 David Gilbert + + Patch 2868585 by Peter Becker: + * source/org/jfree/chart/renderer/BoxAndWhiskerRenderer.java + (useOutlinePaintForWhiskers): New field, + (getUseOutlinePaintForWhiskers): New method, + (setUseOutlinePaintForWhiskers): Likewise, + (drawHorizontalItem): Use new flag, + (drawVerticalItem): Likewise, + (equals): Check new flag. + +2009-09-28 David Gilbert + + Bug 2868557: + * source/org/jfree/chart/renderer/BoxAndWhiskerRenderer.java + (setMedianVisible): Fire change event. + +2009-09-16 David Gilbert + + Bug 2849731: + * source/org/jfree/chart/DatasetUtilities.java + (iterateRangeBounds(XYDataset, boolean)): For IntervalXYDataset, include + regular value and account for nulls / Double.NaN. + +2009-09-10 David Gilbert + + Bug 2849731: + * source/org/jfree/chart/DatasetUtilities.java + (iterateRangeBounds(CategoryDataset, boolean)): For IntervalCategoryDataset + look at regular value, and account for nulls. + +2009-09-10 David Gilbert + + Bug fix by Jim Goodwin: + * source/org/jfree/chart/MouseWheelHandler.java + (handleZoomable): Respect domain/rangeZoomable fields in ChartPanel. + +2009-09-04 David Gilbert + + Patch 2850344 by Martin Hoeller: + * source/org/jfree/chart/plot/PolarPlot.java + (margin): New field, + (PolarPlot): Initialise new field, + (getMargin): New method, + (setMargin): Likewise, + (refreshAngleTicks): Set label anchors according to angle, + (draw): Use margin attribute, + (equals): Updated for margin, + (translateValueThetaRadiusToJava2D): Use new margin attribute, + * source/org/jfree/chart/renderer/DefaultPolarRenderer.java + (drawOutlineWhenFilled): New attribute, + (fillComposite): Likewise, + (shapesVisible): Likewise, + (DefaultPolarItemRenderer): Initialise new fields, + (drawSeries): Use new attributes, + (drawAngularGridlines): Use new tick label anchors, + (getDrawOutlineWhenFilled): New method, + (setDrawOutlineWhenFilled): Likewise, + (getFillComposite): Likewise, + (setFillComposite): Likewise, + (getShapesVisible): Likewise, + (setShapesVisible): Likewise, + (equals): Updated for new fields. + +2009-09-03 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (drawSimpleLabels): Make use of simpleLabelOffset attribute. + +2009-09-01 David Gilbert + + Bug 2840132: + * source/org/jfree/chart/renderer/AbstractXYItemRenderer.java + (drawAnnotations): Set renderer index. + +2009-08-31 David Gilbert + + * source/org/jfree/data/time/TimeSeries.java + (createCopy): Clear cached minY and maxY values. + +2009-08-31 David Gilbert + + * source/org/jfree/chart/plot/Plot.java + (DEFAULT_OUTLINE_STROKE): Changed default cap and join. + +2009-07-13 David Gilbert + + * source/org/jfree/chart/plot/Plot.java + (drawBackgroundImage): Clip to data area. + +2009-07-08 David Gilbert + + * source/org/jfree/chart/axis/NumberAxis.java + (createStandardTickUnits): Added additional units for small tick sizes. + +2009-07-07 David Gilbert + + * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java + (ignoreZeroValues): New flag, + (getIgnoreZeroValues): New method, + (setIgnoreZeroValues): Likewise, + (createStackedValueList): Removed static modifier and check value of new + flag, + (equals): Check value of new flag, + (hashCode): New method override. + +2009-07-06 David Gilbert + + * source/org/jfree/chart/plot/CategoryPlot.java + (clone): Update plot references in cloned renderers, + * source/org/jfree/chart/plot/XYPlot.java + (clone): Likewise. + +2009-07-06 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (paintComponent): Clear off screen buffer to fully transparent. + +2009-06-29 David Gilbert + + * source/org/jfree/chart/JFreeChart.java + (draw): Check the visibility of the main chart title before drawing it. + +2009-06-29 David Gilbert + + * source/org/jfree/chart/axis/CategoryAxis.java + (draw): Add axis entity before drawing labels. + +2009-06-26 David Gilbert + + * source/org/jfree/data/time/TimeSeriesCollection.java + (clone): New method override. + +2009-06-26 David Gilbert + + * source/org/jfree/data/time/ohlc/OHLCSeriesCollection.java + (removeSeries(int)): New method, + (removeSeries(OHLCSeries)): Likewise, + (removeAllSeries): Likewise. + +2009-06-24 David Gilbert + + Patch 2809117 by Peter Kolb: + * source/org/jfree/chart/annotations/AbstractAnnotation.java: New file, + * source/org/jfree/chart/annotations/AbstractXYAnnotation.java: + Now extends AbstractAnnotation, + * source/org/jfree/chart/annotations/Annotation.java: New file, + * source/org/jfree/chart/annotations/CategoryAnnotation.java: + Now extends Annotation, + * source/org/jfree/chart/annotations/CategoryLineAnnotation.java + Now extends AbstractAnnotation, + (setCategory1): Fire change event, + (setValue1): Likewise, + (setCategory2): Likewise, + (setValue2): Likewise, + (setPaint): Likewise, + (setStroke): Likewise, + * source/org/jfree/chart/annotations/CategoryPointerAnnotation.java + (setAngle): Fire change event, + (setTipRadius): Likewise, + (setBaseRadius): Likewise, + (setLabelOffset): Likewise, + (setArrowLength): Likewise, + (setArrowWidth): Likewise, + (setArrowStroke): Likewise, + (setArrowPaint): Likewise, + * source/org/jfree/chart/annotations/CategoryTextAnnotation.java + (setCategory): Fire change event, + (setCategoryAnchor): Likewise, + (setValue): Likewise, + * source/org/jfree/chart/annotations/TextAnnotation.java + (setFont): Fire change event, + (setPaint): Likewise, + (setTextAnchor): Likewise, + (setRotationAnchor): Likewise, + (setRotationAngle): Likewise, + * source/org/jfree/chart/annotations/XYAnnotation.java: + Now extends Annotation, + * source/org/jfree/chart/annotations/XYPointerAnnotation.java + (setAngle): Fire change event, + (setTipRadius): Likewise, + (setBaseRadius): Likewise, + (setLabelOffset): Likewise, + (setArrowLength): Likewise, + (setArrowWidth): Likewise, + (setArrowStroke): Likewise, + (setArrowPaint): Likewise, + * source/org/jfree/chart/annotations/XYTextAnnotation.java + (setFont): Fire change event, + (setPaint): Likewise, + (setTextAnchor): Likewise, + (setRotationAnchor): Likewise, + (setRotationAngle): Likewise, + (setX): Likewise, + (setY): Likewise, + (setBackgroundPaint): Likewise, + (setOutlinePaint): Likewise, + (setOutlineStroke): Likewise, + (setOutlineVisible): Likewise, + * source/org/jfree/chart/annotations/XYTitleAnnotation.java + (setMaxWidth): Fire change event, + (setMaxHeight): Likewise, + * source/org/jfree/chart/event/AnnotationChangeEvent.java: New file, + * source/org/jfree/chart/event/AnnotationChangeListener.java: New file, + * source/org/jfree/chart/plot/CategoryPlot.java + (annotationChanged): New method, + (addAnnotation): Add listener, + (removeAnnotation): Clear listener, + (clearAnnotations): Clear listeners, + * source/org/jfree/chart/plot/Plot.java + (annotationChanged): New method, + * source/org/jfree/chart/plot/XYPlot.java + (annotationChanged): New method, + (addAnnotation): Add listener, + (removeAnnotation): Clear listener, + (clearAnnotations): Clear listeners, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (annotationChanged): New method, + (addAnnotation): Add listener, + (removeAnnotation): Clear listener, + (removeAnnotations): Clear listeners. + +2009-06-17 David Gilbert + + * source/org/jfree/data/time/ohlc/OHLCSeries.java + (remove(int)): New method override. + +2009-06-11 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java + (useFillPaint): New attribute, + (gradientTransformer): Likewise, + (XYAreaRenderer): Initialise new fields, + (getUseFillPaint): New method, + (setUseFillPaint): Likewise, + (getGradientTransformer): Likewise, + (setGradientTransformer): Likewise, + (drawItem): Handle gradient transform, + (equals): Updated for new fields, + (hashCode): New method. + +2009-06-10 David Gilbert + + * source/org/jfree/data/xy/XYDataItem.java + (clone): Rewritten so it doesn't declare CloneNotSupportedException, + * source/org/jfree/data/xy/XYSeries.java + (add(XYDataItem, boolean)): Clone item before adding, + (getDataItem(int)): Return a clone, + (getRawDataItem): New method, + (getX): Call getRawDataItem(), + (getY): Likewise, + (update): Likewise, + (addOrUpdate(Number, Number)): Delegate to new method, + (addOrUpdate(XYDataItem)): New method, + (hashCode): Call getRawDataItem(), + * source/org/jfree/data/XYSeriesCollection.java + (getX): Simplified, + (getY): Likewise, + * source/org/jfree/data/DefaultTableXYDataset.java + (getX): Simplified, + (getY): Likewise. + +2009-06-10 David Gilbert + + * source/org/jfree/data/time/TimeSeries.java + (addOrUpdate(RegularTimePeriod, Number)): Delegate to new method, + (addOrUpdate(TimeSeriesDataItem)): New method. + +2009-06-09 David Gilbert + + * source/org/jfree/data/time/TimeSeries.java + (getDataItem(int)): Return a clone, + (getDataItem(RegularTimePeriod)): Likewise, + (getRawDataItem(int)): New method, + (getRawDataItem(RegularTimePeriod)): Likewise, + (getTimePeriod): Call getRawDataItem(), + (getValue): Likewise, + (add(TimeSeriesDataItem, boolean)): Clone the item, + (addAndOrUpdate): Call getRawDataItem(), + (equals): Tidied up, + (hashCode): Call getRawDataItem(), + * source/org/jfree/data/time/MovingAverage.java + (createMovingAverage): Updates for changes in TimeSeries.java + (createPointMovingAverage): Likewise, + * source/org/jfree/data/time/TimeSeriesCollection.java + (getXValue): Use direct method in TimeSeries, + (getX): Likewise, + (getStartX): Likewise, + (getEndX): Likewise, + (getY): Likewise, + * source/org/jfree/data/time/TimeSeriesDataItem.java + (equals): Cleanup. + +2009-06-09 David Gilbert + + Bug 2802014: + * source/org/jfree/chart/plot/dial/DialValueIndicator.java + (maxTemplateValue): New field, + (DialValueIndicator): Initialise new field, + (getMaxTemplateValue): New method, + (setMaxTemplateValue): Likewise, + (draw): Rewrite for indicator bounds, now supports clipping also, + (fixToRange): New private method, + (equals): Check new field. + +2009-06-08 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (setMouseWheelEnabled): Use correct check for disable branch. + +2009-06-01 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (mousePressed): Return immediately if chart is null. + +2009-06-01 David Gilbert + + * source/org/jfree/chart/plot/MultiplePiePlot.java + (getLegendItems): Set the series key and index for each item, + * source/org/jfree/chart/plot/SpiderWebPlot.java + (getLegendItems): Likewise. + +2009-05-28 David Gilbert + + * source/org/jfree/data/function/PowerFunction2D.java: Implemented + Serializable, + (getA): New method, + (getB): Likewise, + (equals): New method override, + (hashCode): Likewise, + * tests/org/jfree/data/function/junit/PowerFunction2DTests.java: New file. + +2009-05-28 David Gilbert + + * source/org/jfree/data/function/NormalDistributionFunction2D.java: + Implemented Serializable, + (equals): New method override, + (hashCode): Likewise, + * tests/org/jfree/data/function/junit/NormalDistributionFunction2DTests.java: + New file. + +2009-05-28 David Gilbert + + * source/org/jfree/data/function/LineFunction2D.java: Implemented + Serializable, + (getIntercept): New method, + (getSlope): Likewise, + (equals): New method override, + (hashCode): Likewise, + * tests/org/jfree/data/function/junit/LineFunction2DTests.java: New file. + +2009-05-28 David Gilbert + + * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java + (drawItem): Fixed bar alignment for inverted domain axis. + +2009-05-28 David Gilbert + + Patch 2795746 by Peter Kolb: + * source/org/jfree/data/function/PolynomialFunction2D.java: New file, + * source/org/jfree/data/statistics/Regression.java + (getPolynomialRegression): New method, + (calculateSubmatrix): New private method, + * tests/org/jfree/data/function/junit/DataFunctionPackageTests.java: + New test file, + * tests/org/jfree/data/function/junit/PolynomialFunction2DTests.java: + Likewise. + +2009-05-27 David Gilbert + + * source/org/jfree/chart/renderer/category/AreaRenderer.java + (drawItem): Use correct item label anchor for horizontal orientation. + +2009-05-26 David Gilbert + + * source/org/jfree/data/time/TimeTableXYDataset.java + (add): If period is a RegularTimePeriod, peg it to the timezone and locale + specified in the constructor. + +2009-05-26 David Gilbert + + Bug 1937486: + * source/org/jfree/chart/renderer/category/AreaRenderer.java + (drawItem): Handle AreaRendererEndType.LEVEL. + +2009-05-26 David Gilbert + + * source/org/jfree/data/time/TimeSeriesCollection.java: Implemented + XYRangeInfo, + (getRangeBounds): New method. + +2009-05-26 David Gilbert + + * source/org/jfree/data/time/TimeSeries.java + (minY): New field, + (maxY): Likewise, + (TimeSeries(Comparable, String, String)): Initialise new fields, + (getMinY): New method, + (getMaxY): Likewise, + (add(TimeSeriesDataItem, boolean)): Update min/maxY, + (update(RegularTimePeriod, Number)): Delegate, + (update(int, Number)): Update bounds, + (addOrUpdate): Update bounds, + (removeAgedItems): Likewise, + (clear): Clear bounds, + (delete(RegularTimePeriod)): Update bounds, + (delete(int, int)): Delegate to new method, + (delete(int, int, boolean)): New method, + (updateBoundsForAddedItem): New method, + (updateBoundsForRemovedItem): Likewise, + (findBoundsByIteration): Likewise, + (minIgnoreNaN): Likewise, + (maxIgnoreNaN): Likewise, + * tests/org/jfree/data/time/junit/TimeSeriesTests.java + (testDelete3): New test, + (testDelete_RegularTimePeriod): Likewise, + (testSetMaximumItemCount): Updated to check min/maxY, + (testAddOrUpdate2): New method, + (testAddOrUpdate3): Likewise, + (testRemoveAgedItems4): Likewise, + (testRemoveAgedItems5): Likewise, + (testGetMinY): Likewise, + (testGetMaxY): Likewise, + (testClear): Likewise, + (testAdd): Likewise, + (testUpdate_RegularTimePeriod): Likewise. + +2009-05-19 David Gilbert + + * source/org/jfree/data/time/TimeSeriesCollection.java: Implemented + XYDomainInfo, + (getDomainBounds(List, boolean)): New method, + * tests/org/jfree/data/time/junit/TimeSeriesCollectionTests.java + (testFindDomainBounds): New test method. + +2009-05-18 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (drawPrimaryLine): Clip line and only draw if visible. + +2009-05-18 David Gilbert + + * source/org/jfree/chart/annotations/XYPointerAnnotation.java + (hashCode): Return result. + +2009-05-16 David Gilbert + + Patch 2791407 by Peter Kolb: + * source/org/jfree/chart/renderer/category/BarRenderer.java + (findRangeBounds): Call method in super class, not DatasetUtilities, + * source/org/jfree/chart/renderer/category/IntervalBarRenderer.java + (findRangeBounds): Override to include dataset interval, + * source/org/jfree/chart/renderer/category/ScatterRenderer.java + (findRangeBounds): Override to include dataset interval, + * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java + (findRangeBounds): Override to include dataset interval, + * source/org/jfree/data/general/DatasetUtilities.java + (iterateToFindRangeBounds): Handle MultiValueCategoryDataset. + +2009-05-12 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYShapeRenderer.java + (equals): Simplified because paintScale, guideLinePaint and guideLineStroke + are never null. + +2009-05-10 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (equals): Check fixedLegendItems, + (clone): Clone fixedLegendItems, + * tests/org/jfree/chart/plot/junit/XYPlotTests.java + (testEquals): Added test for fixedLegendItems, + (testCloning3): New test. + +2009-05-05 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (doCopy): Account for insets, and pass scaling parameters to + ChartTransferable, + * source/org/jfree/chart/ChartTransferable.java + (minDrawWidth): New field, + (minDrawHeight): Likewise, + (maxDrawWidth): Likewise, + (maxDrawHeight): Likewise, + (ChartTransferable): New constructor, + (getTransferData): Delegate to new utility method, + (createBufferedImage): New method that can apply scaling. + +2009-04-28 David Gilbert + + * source/org/jfree/chart/renderer/xy/SamplingXYLineRenderer.java + (State.startSeriesPass): Reset interval path. + +2009-04-28 David Gilbert + + * source/org/jfree/chart/renderer/AbstractRenderer.java + (legendShape): Renamed legendShapeList, + (treatLegendShapeAsLine): New field, + (AbstractRenderer): Initialise new field, + (getTreatLegendShapeAsLine): New method, + (setTreatLegendShapeAsLine): Likewise, + (equals): Check treatLegendShapeAsLine field, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (getLegendItem): Use different legend item if 'treatLegendShapeAsLine' flag + is set, + * source/org/jfree/chart/LegendItem.java + (setDescription): New method, + (setToolTipText): Likewise, + (setURLText): Likewise, + (setShapeVisible): Likewise, + (setShape): Likewise, + (setOutlineStroke): Likewise, + (setLineVisible): Likewise, + (setLine): Likewise, + * source/org/jfree/chart/renderer/xy/SamplingXYLineRenderer.java + (SamplingXYLineRenderer): Configure renderer for lines in legend item, + (getLegendLine): Deprecated, + (setLegendLine): Likewise. + +2009-04-27 David Gilbert + + * source/org/jfree/chart/util/LogFormat.java + (format(long, StringBuffer, FieldPosition)): Use powerLabel attribute. + +2009-04-27 David Gilbert + + * source/org/jfree/chart/panel/CrosshairOverlay.java + (addDomainCrosshair): Fire change event, + (addRangeCrosshair): Likewise. + +2009-04-27 David Gilbert + + * source/org/jfree/chart/annotation/XYPointerAnnotation.java + (draw): Altered drawing of arrow line. + +---------- JFREECHART 1.0.13 RELEASED ------------------------ + +2009-04-20 David Gilbert + + * source/org/jfree/data/general/DatasetUtilities.java + (iterateToFindRangeBounds): Handle BoxAndWhiskerCategoryDataset. + +2009-04-16 David Gilbert + + * source/org/jfree/chart/title/PaintScaleLegend.java + (draw): Adjusted fill rectangles. + +2009-04-16 David Gilbert + + * source/org/jfree/chart/axis/CategoryAxis.java + (CategoryAxis): Leave tick marks visible by default, + (draw): Call drawTickMarks(), + (drawTickMarks): New method, + * source/org/jfree/chart/axis/CategoryAxis3D.java + (draw): Call drawTickMarks(), + * source/org/jfree/chart/axis/NumberAxis3D.java + (NumberAxis3D): Leave axis line visible by default. + +2009-04-16 David Gilbert + + Patch 2686872 by Peter Kolb: + * source/org/jfree/chart/title/PaintScaleLegend.java: Implemented + AxisChangeListener, + (PaintScaleLegend): Register as axis change listener, + (setAxis): Deregister as change listener on old axis, register as listener + on new axis, + (axisChanged): New method, + (draw): Check isStripOutlineVisible flag. + +2009-04-16 David Gilbert + + * source/org/jfree/chart/StandardChartTheme.java + (baselinePaint): New field, + (createDarknessTheme): Modify baselinePaint, + (StandardChartTheme): Initialise baselinePaint, + (getBaselinePaint): New method, + (setBaselinePaint): Likewise, + (applyToCategoryPlot): Apply baselinePaint, + (applyToXYPlot): Likewise, + (writeObject): Updated for new field, + (readObject): Likewise. + +2009-04-10 David Gilbert + + Bug 2740447: + * source/org/jfree/chart/ChartPanel.java + (paintComponent): Set chartBuffer background to match panel. + +2009-04-09 David Gilbert + + * source/org/jfree/chart/StandardChartTheme.java + (getSmallFont): New method, + (setSmallFont): Likewise. + +2009-04-09 David Gilbert + + * source/org/jfree/chart/ChartPanel.java: Implemented OverlayChangeListener, + (overlays): New field, + (ChartPanel): Initialise new field, + (addOverlay): New method, + (removeOverlay): New method, + (overlayChanged): New method, + (paintComponent): Draw overlays, + * source/org/jfree/chart/event/OverlayChangeEvent.java: New file, + * source/org/jfree/chart/event/OverlayChangeListener.java: New file, + * source/org/jfree/chart/panel/AbstractOverlay.java: New file, + * source/org/jfree/chart/panel/CrosshairOverlay.java: New file, + * source/org/jfree/chart/panel/Overlay.java: New file, + * source/org/jfree/chart/labels/CrosshairLabelGenerator.java: New file, + * source/org/jfree/chart/labels/StandardCrosshairLabelGenerator.java: + New file, + * source/org/jfree/chart/jxlayer/CrosshairLayerUI.java: Refactored class + locations. + +2009-04-08 David Gilbert + + * source/org/jfree/chart/ChartTransferable.java : New file, + * source/org/jfree/chart/ChartPanel.java + (COPY_COMMAND): New field, + ChartPanel(JFreeChart, int, int, int, int, int, int, boolean, boolean, + boolean, boolean, boolean, boolean, boolean)): New constructor, + (actionPerformed): Check for copy action, + (doCopy): Tranfer chart to clipboard, + (createPopupMenu): New method. + +2009-04-01 David Gilbert + + * source/org/jfree/chart/annotation/XYTextAnnotation.java + (draw): Set font before calculating hotspot area. + +2009-04-01 David Gilbert + + * source/org/jfree/data/general/DatasetUtilities.java + (iterateToFindRangeBounds): Handle StatisticalCategoryDataset. + +2009-04-01 David Gilbert + + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (addItemEntity): Check getItemCreateEntity(), + (addEntity): New method, + * source/org/jfree/chart/renderer/AbstractRenderer.java + (defaultEntityRadius): New field, + (AbstractRenderer): Initialise new field, + (getDefaultEntityRadius): New method, + (setDefaultEntityRadius): New method, + (equals): Check new field, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (defaultEntityRadius): Moved to superclass, + (getDefaultEntityRadius): Likewise, + (setDefaultEntityRadius): Likewise, + (equals): Moved check for defaultEntityRadius to superclass, + * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java + (findRangeBounds): New method override, + (drawItem): Use new addEntity() method. + +2009-04-01 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (panMask): New field, + (ChartPanel): Initialise panMask differently on MacOSX, + (mousePressed): Use panMask field, + (mouseDragged): Fixed signs on drag percents. + +2009-03-30 David Gilbert + + * source/org/jfree/chart/axis/LogAxis.java + (pan): New method, + * source/org/jfree/chart/axis/ValueAxis.java + (pan): Likewise, + * source/org/jfree/chart/plot/XYPlot.java + (panDomainAxes): Delegate to axes, + (panRangeAxes): Delegate to axes. + +2009-03-28 David Gilbert + + * source/org/jfree/renderer/LookupPaintScale.java + (PaintItem): Changed to static. + +2009-03-28 David Gilbert + + * source/org/jfree/renderer/xy/AbstractXYItemRenderer.java + (findRangeBounds): Handle case where plot is null. + +2009-03-27 David Gilbert + + * source/org/jfree/renderer/xy/YIntervalRenderer.java + (findRangeBounds): Use new inherited method. + +2009-03-27 David Gilbert + + * source/org/jfree/renderer/RendererUtilities.java + (findLiveItemsLowerBound): Fixed results for unsorted dataset, + (findLiveItemsUpperBound): Likewise, + (findLiveItems): Check case where upper index is less than lower. + +2009-03-27 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (domainPannable): Change default to false, + (rangePannable): Likewise, + (rendererChanged): If series visibility changes, configure the axes, + (panDomainAxes): Reconfigure the range axes, + * source/org/jfree/chart/renderer/AbstractRenderer.java + (dataBoundsIncludesVisibleSeriesOnly): New field, + (setSeriesVisible(Boolean, boolean): Modified generated RendererEvent, + (setSeriesVisible(int, Boolean, boolean): Likewise, + (setBaseSeriesVisible): Likewise, + (getDataBoundsIncludesVisibleSeriesOnly): New method, + (setDataBoundsIncludesVisibleSeriesOnly): Likewise, + (equals): Updated for new field, + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (findRangeBounds(CategoryDataset)): Delegate to new method, + (findRangeBounds(CategoryDataset, boolean)): Handle hidden series, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (findDomainBounds(XYDataset)): Delegate to new method, + (findDomainBounds(XYDataset, boolean)): Handle hidden series, + (findRangeBounds(XYDataset)): Delegate to new method, + (findRangeBounds(XYDataset, boolean)): Handle hidden series, + * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java + (findRangeBounds): Call new inherited method, + * source/org/jfree/chart/renderer/xy/DeviationRenderer.java + (findRangeBounds): Call new inherited method, + * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java + (findRangeBounds): New method override, + * source/org/jfree/data/general/DatasetUtilities.java + (findDomainBounds(XYDataset, List, boolean)): New method, + (findRangeBounds(CategoryDataset, List, boolean)): Likewise, + (findRangeBounds(XYDataset, List, Rangee, boolean)): Likewise, + (iterateToFindRangeBounds(CategoryDataset, List, boolean)): Likewise, + (iterateToFindDomainBounds(XYDataset, List, boolean)): Likewise, + (iterateToFindRangeBounds(XYDataset, List, Range, boolean)): Likewise, + * source/org/jfree/data/category/CategoryRangeInfo.java: New interface, + * source/org/jfree/data/xy/XYDomainInfo.java: Likewise, + * source/org/jfree/data/xy/XYRangeInfo.java: Likewise. + +2009-03-26 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (fillZoomRectangle): Change default to true, + (mousePressed): Don't change cursor for panning unless panning is enabled. + +2009-03-26 David Gilbert + + * source/org/jfree/chart/axis/ValueAxis.java + (equals): Only check range if autoRange is false. + +2009-03-26 David Gilbert + + * source/org/jfree/chart/event/RendererChangeEvent.java + (seriesVisibilityChanged): New field, + (RendererChangeEvent(Object)): Delegate to new constructor, + (RendererChangeEvent(Object, boolean)): New constructor, + (getSeriesVisibilityChanged): New method. + +2009-03-26 David Gilbert + + * source/org/jfree/chart/MouseWheelHandler.java: Implemented Serializable. + +2009-03-26 David Gilbert + + * source/org/jfree/chart/plot/FastScatterPlot.java: Implemented Pannable, + (domainPannable): New field, + (rangePannable): Likewise, + (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): Use new + resizeRange2() method, + (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): Likewise, + plus use correct mouse coordinate, + (isDomainPannable): New method, + (setDomainPannable): Likewise, + (isRangePannable): Likewise, + (setRangePannable): Likewise, + (panDomainAxes): Likewise, + (panRangeAxes): Likewise, + (equals): Updated for new fields. + +2009-03-25 David Gilbert + + * source/org/jfree/chart/imagemap/ImageMapUtilities.java + (javascriptEscape): Reimplemented, + * tests/org/jfree/chart/imagemap/junit/ImageMapPackageTests.java + (suite): Added new test classes, + * tests/org/jfree/chart/imagemap/junit/DynamicDriveToolTipTagFragmentGeneratorTests.java: + New file, + * tests/org/jfree/chart/imagemap/junit/ImageMapUtilitiesTests.java: + New file, + * tests/org/jfree/chart/imagemap/junit/OverLIBToolTipTagFragmentGeneratorTests.java: + New file. + +2009-03-19 David Gilbert + + * source/org/jfree/chart/entity/AxisEntity.java: New class, + * source/org/jfree/chart/entity/JFreeChartEntity.java: New class, + * source/org/jfree/chart/entity/PlotEntity.java: New class, + * source/org/jfree/chart/entity/TitleEntity.java: New class, + * source/org/jfree/chart/axis/Axis.java: + (createAndAddEntity): New method, + * source/org/jfree/chart/axis/CategoryAxis.java: + (draw): Add an entity for the axis, + * source/org/jfree/chart/axis/DateAxis.java: + (draw): Add an entity for the axis, + * source/org/jfree/chart/axis/LogAxis.java: + (draw): Add an entity for the axis, + * source/org/jfree/chart/axis/NumberAxis.java: + (draw): Add an entity for the axis, + * source/org/jfree/chart/plot/CategoryPlot.java: + (draw): Add an entity for the plot, + * source/org/jfree/chart/plot/Plot.java: + (createAndAddEntity): New method, + * source/org/jfree/chart/plot/XYPlot.java: + (draw): Add an entity for the plot, + * source/org/jfree/chart/JFreeChart.java: + (draw): Add an entity for the chart, + * source/org/jfree/chart/title/LegendTitle.java: + (draw): Add an entity for the title, + * source/org/jfree/chart/title/TextTitle.java: + (draw): Likewise. + +2009-03-19 David Gilbert + + Bug 2690293: + * source/org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGenerator.java + (generateToolTipFragment): Use javascriptEscape(), + * source/org/jfree/chart/imagemap/OverLIBToolTipTagFragmentGenerator.java + (generateToolTipFragment): Likewise, + * source/org/jfree/chart/imagemap/ImageMapUtilities.java + (javascriptEscape): New method. + +2009-03-19 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (panW): New field, + (panH): Likewise, + (panLast): Likewise, + (mousePressed): Check for start of panning, + (mouseDragged): Handle panning if it was started in mousePressed(), + (mouseReleased): Reset panning, + * source/org/jfree/chart/plot/CategoryPlot.java: Implemented Pannable, + (rangePannable): New field, + (isDomainPannable): New method, + (isRangePannable): Likewise, + (setRangePannable): Likewise, + (panDomainAxes): Likewise, + (panRangeAxes): Likewise, + * source/org/jfree/chart/plot/Pannable.java: New interface, + * source/org/jfree/chart/plot/XYPlot.java: Implemented Pannable, + (domainPannable): New field, + (rangePannable): Likewise, + (isDomainPannable): New method, + (setDomainPannable): Likewise, + (isRangePannable): Likewise, + (setRangePannable): Likewise, + (panDomainAxes): Likewise, + (panRangeAxes): Likewise. + +2009-03-19 David Gilbert + + * source/org/jfree/chart/renderer/category/BarRenderer3D.java + (drawRangeLine): New method override. + +2009-03-18 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (mouseWheelHandler): New field, + (isMouseWheelEnabled): New method, + (setMouseWheelEnabled): Likewise, + * source/org/jfree/chart/MouseWheelHandler.java: New class, + * source/org/jfree/chart/axis/ValueAxis.java + (resizeRange2): New method, + * source/org/jfree/chart/demo/BarChartDemo1.java + (BarChartDemo1): Enable mouse wheel, + * source/org/jfree/chart/demo/TimeSeriesChartDemo1.java + (createDemoPanel): Enable mouse wheel, + * source/org/jfree/chart/plot/CategoryPlot.java + (zoomRangeAxes): Modify anchored zoom behaviour, + * source/org/jfree/chart/plot/XYPlot.java + (zoomDomainAxes): Likewise, + (zoomRangeAxes): Likewise. + +2009-03-15 David Gilbert + + * source/org/jfree/data/category/SlidingCategoryDataset.java + (getColumnKeys): Fixed loop index. + +2009-03-10 David Gilbert + + * source/org/jfree/chart/annotations/XYAnnotationBoundsInfo.java: + New interface, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (getAnnotations): New method, + * source/org/jfree/chart/annotations/XYDataImageAnnotation.java: + Implemented XYAnnotationBoundsInfo interface, + (includeInDataBounds): New field, + (XYDataImageAnnotation(Image, double, double, double, double, boolean)): + New constructor, + (getIncludeInDataBounds): New method, + (getXRange): Likewise, + (getYRange): Likewise, + (equals): Check new field, + * source/org/jfree/chart/plot/XYPlot.java + (getDataRange): Include annotation bounds. + +2009-03-06 David Gilbert + + * source/org/jfree/chart/renderer/xy/SamplingXYLineRenderer.java: + New class. + +2009-03-06 David Gilbert + + * source/org/jfree/data/xy/IntervalXYDelegate.java + (hashCode): Implemented, + * source/org/jfree/data/xy/XYSeriesCollection.java + (equals): Include interval delegate. + +2009-03-06 David Gilbert + + * source/org/jfree/data/xy/XYSeries.java + (minX): New field, + (maxX): Likewise, + (minY): Likewise, + (maxY): Likewise, + (XYSeries): Initialise new fields, + (getMinX): New method, + (getMaxX): Likewise, + (getMinY): Likewise, + (getMaxY): Likewise, + (updateBoundsForAddedItem): Likewise, + (updateBoundsForRemovedItem): Likewise, + (findBoundsByIteration): Likewise, + (setMaximumItemcount): Refresh mins and maxes, + (add): Likewise, + (delete): Likewise, + (remove): Likewise, + (clear): Reset mins and maxes, + (update): Update minY and maxY, + (minIgnoreNaN): New method, + (maxIgnoreNaN): Likewise, + (update): Delegate to updateByIndex(); + (addOrUpdate): Update mins and maxes, + * source/org/jfree/data/xy/XYSeriesCollection.java: Implemented RangeInfo, + (getDomainLowerBound): Use cached value in underlying series, + (getDomainUpperBound): Likewise, + (getDomainBounds): Likewise, + (getRangeBounds): Implemented, + (getRangeLowerBound): Likewise, + (getRangeUpperBound): Likewise. + +2009-03-02 David Gilbert + + * source/org/jfree/chart/axis/PeriodAxis.java + (draw): Check tickMarksVisible and tickLabelsVisible, + (drawTickMarksHorizontal): Removed unnecessary calendar references, + (drawTickLabels): Likewise, + (valueToJava2D): Likewise, + (java2DtoValue): Likewise, + * source/org/jfree/chart/axis/PeriodAxisLabelInfo.java + (createInstance): Deprecated and added new method with locale argument. + +2009-03-02 David Gilbert + + * source/org/jfree/chart/axis/PeriodAxis.java + (locale): New field, + (PeriodAxis(String, RegularTimePeriod, RegularTimePeriod)): Delegate to + new constructor, + (PeriodAxis(String, RegularTimePeriod, RegularTimePeriod, TimeZone)): + Deprecated, + (PeriodAxis(String, RegularTimePeriod, RegularTimePeriod, TimeZone, Locale)): + New constructor, + (setFirst): Peg the time period, + (setLast): Likewise, + (setTimeZone): Peg first and last, + (getLocale): New method, + (setRange): Use locale, + (drawTickMarksHorizontal): Likewise, + (autoAdjustRange): Likewise, + (equals): Check locale field, + (createInstance): Added locale, + * source/org/jfree/data/time/Day.java + (Day(Date)): Delegate to new constructor, + (Day(Date, TimeZone)): Deprecated, + (Day(Date, TimeZone, Locale)): New constructor, + * source/org/jfree/data/time/Hour.java + (Hour(Date)): Delegate to new constructor, + (Hour(Date, TimeZone)): Deprecated, + (Hour(Date, TimeZone, Locale)): New constructor, + * source/org/jfree/data/time/Millisecond.java + (Millisecond(Date)): Delegate to new constructor, + (Millisecond(Date, TimeZone)): Deprecated, + (Millisecond(Date, TimeZone, Locale)): New constructor, + * source/org/jfree/data/time/Minute.java + (Minute(Date)): Delegate to new constructor, + (Minute(Date, TimeZone)): Deprecated, + (Minute(Date, TimeZone, Locale)): New constructor, + * source/org/jfree/data/time/Second.java + (Second(Date)): Delegate to new constructor, + (Second(Date, TimeZone)): Deprecated, + (Second(Date, TimeZone, Locale)): New constructor. + +2009-02-27 David Gilbert + + * source/org/jfree/data/xy/XYSeriesCollection.java + (getDomainOrder): New method override. + +2009-02-27 David Gilbert + + Bug 2583891: + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + (fillPolygon): Implemented. + +2009-02-27 David Gilbert + + * source/org/jfree/data/general/CombinationDataset.java: Deprecated. + +2009-02-27 David Gilbert + + Bug 2612649: + * source/org/jfree/chart/editor/DefaultPlotEditor.java + (DefaultPlotEditor): Added null Stroke to available options, + (attemptOutlineStrokeSelection): Use current stroke. + +2009-02-27 David Gilbert + + Bug 2617557: + * source/org/jfree/chart/plot/dial/StandardDialScale.java + (draw): Use tickLabelPaint. + +2009-02-27 David Gilbert + + * source/org/jfree/chart/renderer/RendererUtilities.java + (findLiveItemsLowerBound): Added argument checks, + (findLiveItemsUpperBound): Correct calculation of mid. + +2009-02-22 David Gilbert + + * source/org/jfree/chart/renderer/xy/GradientXYBarPainter.java + (paintBar): Use correct outline paint. + +2009-02-13 David Gilbert + + * source/org/jfree/chart/jxlayer/Crosshair.java: New file, + * source/org/jfree/chart/jxlayer/CrosshairLabelGenerator.java: New file, + * source/org/jfree/chart/jxlayer/CrosshairLayerUI.java: New file, + * source/org/jfree/chart/jxlayer/DefaultCrosshairLabelGenerator.java: + New file, + * source/org/jfree/chart/jxlayer/package.html: New file, + * tests/org/jfree/chart/jxlayer/junit/CrosshairTests.java: New tests, + * tests/org/jfree/chart/jxlayer/junit/JXLayerPackageTests.java: Likewise. + +2009-02-12 David Gilbert + + * source/org/jfree/chart/annotations/XYPointerAnnotation.java + (draw): Added support for rotated text, plus background paint and + outline paint/stroke. + +2009-02-12 David Gilbert + + * source/org/jfree/chart/annotations/XYTextAnnotation.java + (backgroundPaint): New field, + (outlineVisible): Likewise, + (outlinePaint): Likewise, + (outlineStroke): Likewise, + (XYTextAnnotation): Initialise new fields, + (getBackgroundPaint): New method, + (setBackgroundPaint): Likewise, + (getOutlinePaint): Likewise, + (setOutlinePaint): Likewise, + (getOutlineStroke): Likewise, + (setOutlineStroke): Likewise, + (isOutlineVisible): Likewuse, + (setOutlineVisible): Likewise, + (draw): Draw background and outline, + (equals): Check new fields, + (writeObject): Handle new fields, + (readObject): Likewise. + +2009-02-12 David Gilbert + + * source/org/jfree/data/general/DatasetUtilities.java + (sampleFunction2D): Delegate to new method, + (sampleFunction2DToSeries): New method, + * source/org/jfree/data/function/NormalDistributionFunction2D.java + (factor): New field, + (denominator): Likewise, + (NormalDistributionFunction2D): Initialise new fields, + (getValue): Use precomputed constants. + +2009-02-10 David Gilbert + + * source/org/jfree/chart/block/LabelBlock.java + (contentAlignmentPoint): New field, + (textAnchor): Likewise, + (LabelBlock): Initialise new fields, + (getContentAlignmentPoint): New method, + (setContentAlignmentPoint): Likewise, + (getTextAnchor): Likewise, + (setTextAnchor): Likewise, + (equals): Check new fields. + +2009-02-05 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (barAlignmentFactor): New field, + (XYBarRenderer): Initialise new field, + (getBarAlignmentFactor): New method, + (setBarAlignmentFactor): Likewise, + (drawItem): Shift bar if alignment factor is set, + (equals): Check new field. + +2009-02-05 David Gilbert + + * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java + (errorIndicatorStroke): New field, + (StatisticalLineAndShapeREnderer): Initialise new field, + (getErrorIndicatorStroke): New method, + (setErrorIndicatorStroke): Likewise, + (drawItem): Use errorIndicatorStroke, + (equals): Check new field, + (readObject): Handle new field, + (writeObject): Likewise. + +2009-02-04 David Gilbert + + * source/org/jfree/data/general/DefaultHeatMapDataset.java: New file, + * source/org/jfree/data/general/HeatMapDataset.java: Likewise, + * source/org/jfree/data/general/HeatMapUtilities.java: Likewise, + * tests/org/jfree/data/general/junit/DefaultHeatMapDatasetTests.java: + Likewise. + +2009-02-04 David Gilbert + + * source/org/jfree/data/general/CombinedDataset.java: Deprecated, + * source/org/jfree/data/general/SubSeriesDataset.java: Likewise. + +2009-02-04 David Gilbert + + Bug 2564636: + * source/org/jfree/data/time/Month.java + (Month(Date, TimeZone, Locale)): Use locale. + +2009-02-04 David Gilbert + + * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java + (createStackedValueList): Deprecated, + (createStackedValueList(CategoryDataset, Comparable, int[], double, + boolean)): New method, + (drawItem): Check for hidden series. + +2009-02-04 David Gilbert + + * source/org/jfree/chart/renderer/category/StackedBarRenderer.java + (drawItem): Check for hidden series. + +2009-02-04 David Gilbert + + * source/org/jfree/chart/renderer/category/CategoryItemRendererState.java + (getVisibleSeriesArray()): New method, + * source/org/jfree/chart/renderer/StackedAreaRenderer.java + (drawItem): Fix handling of renderAsPercentages, + (getStackValues): Likewise, + * source/org/jfree/data/DataUtilities.java + (calculateColumnTotal): New method, + (calculateRowTotal): Likewise. + +2009-02-04 David Gilbert + + * source/org/jfree/chart/renderer/category/StackedAreaRenderer.java + (drawItem): Generate entities only in first pass, and add call for drawing + item labels in second pass. + +2009-02-04 David Gilbert + + * source/org/jfree/chart/renderer/category/WaterfallBarRenderer.java + (findRangeBounds): Handle null dataset, + * tests/org/jfree/chart/renderer/category/junit/WaterfallBarRendererTests.java + (testFindRangeBounds): New tests. + +2009-02-04 David Gilbert + + * source/org/jfree/chart/renderer/category/StackedAreaRenderer.java + (findRangeBounds): Check for null dataset, + (drawItem): Return early if series is not visible, + (getPreviousHeight): Deprecated as it is never used, + * tests/org/jfree/chart/renderer/category/junit/StackedAreaRendererTests.java + (testFindRangeBounds): New tests. + +2009-02-03 David Gilbert + + * source/org/jfree/renderer/category/BarRenderer.java + (defaultShadowsVisible): New field, + (getDefaultShadowsVisible): New method, + (setShadowsVisible): Likewise, + * source/org/jfree/renderer/xy/XYBarRenderer.java + (defaultShadowsVisible): New field, + (getDefaultShadowsVisible): New method, + (setShadowsVisible): Likewise. + +2009-02-03 David Gilbert + + * source/org/jfree/renderer/category/StackedBarRenderer3D.java + (findRangeBounds): Check for null dataset, + * tests/org/jfree/chart/renderer/category/junit/StackedBarRenderer3DTests.java + (testFindRangeBounds): New test. + +2009-02-02 David Gilbert + + * source/org/jfree/chart/renderer/GrayPaintScale.java + (alpha): New field, + (GrayPaintScale(double, double)): Delegate to new constructor, + (GrayPaintScale(double, double, int)): New constructor, + (getAlpha): New method, + (getPaint): Use alpha setting for returned paint, + (equals): Check new field, + (hashCode): New method, + * tests/org/jfree/chart/renderer/junit/GrayPaintScaleTests.java + (testEquals): Check new field. + +2009-01-28 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYErrorRenderer.java + (errorStroke): New field, + (XYErrorRenderer): Initialise new field, + (getErrorStroke): New method, + (setErrorStroke): Likewise, + (drawItem): Updated to use new errorStroke or else item outline stroke, + (equals): Check new field, + (readObject): Handle new field, + (writeObject): Likewise, + * tests/org/jfree/chart/renderer/xy/junit/XYErrorRendererTests.java + (testEquals): Added check for errorStroke field, + (testCloning2): New test, + (testSerialization2): Likewise. + +2009-01-28 David Gilbert + + * source/org/jfree/data/DataUtilities.java + (clone(double[][]): New method, + * tests/org/jfree/data/junit/DataUtilitiesTests.java + (testClone): New method. + +2009-01-28 David Gilbert + + * source/org/jfree/chart/renderer/AbstractRenderer.java + (equals): Fix shape test, + * tests/org/jfree/chart/renderer/junit/AbstractRendererTests.java + (testEquals): Modified to cover Shape.equals() bug. + +2009-01-28 David Gilbert + + * source/org/jfree/data/DataUtilities.java + (equal(double[][], double[][])): New method, + * tests/org/jfree/data/junit/DataUtilitiesTests.java + (testEqual): New method, + (suite): Likewise, + (main): Likewise. + +2009-01-23 David Gilbert + + * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java + (drawItem): Put drawing code in separate passes. + +2009-01-23 David Gilbert + + Patch 2511330 by Peter Kolb, plus hashCode method by DG: + * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java + (drawItem): Check useFillPaint and drawOutlines flags separately, + (hashCode): New method. + +2009-01-23 David Gilbert + + Patch 2511330 by Peter Kolb: + * source/org/jfree/chart/renderer/category/LevelRenderer.java + (calculateItemWidth): Take into account seriesVisible flags, + (calculateBarW0): Likewise, + (drawItem): Likewise. + +2009-01-23 David Gilbert + + * source/org/jfree/chart/renderer/category/LevelRenderer.java + (LevelRenderer): Set default legend shape, + (hashCode): New method. + +2009-01-21 David Gilbert + + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (medianVisible): New field, + (meanVisible): Likewise, + (BoxAndWhiskerRenderer): Initialise new fields, + (isMeanVisible): New method, + (setMeanVisible): Likewise, + (isMedianVisible): New method, + (setMedianVisible): Likewise, + (drawHorizontalItem): Updated to check new flags, + (drawVerticalItem): Likewise, + (equals): Updated to check new fields, + * tests/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java + (testEquals): Check new fields. + +2009-01-21 David Gilbert + + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (drawRangeLine): New method, + * source/org/jfree/chart/plot/CategoryPlot.java + (rangeZeroBaselineVisible): New field, + (rangeZeroBaselineStroke): Likewise, + (rangeZeroBaselinePaint): Likewise, + (rangeMinorGridlinesVisible): Likewise, + (rangeMinorGridlineStroke): Likewise, + (rangeMinorGridlinePaint): Likewise, + (CategoryPlot): Initialise new fields and removed baseline marker, + (isRangeZeroBaselineVisible): New method, + (setRangeZeroBaselineVisible): Likewise, + (getRangeZeroBaselineStroke): Likewise, + (setRangeZeroBaselineStroke): Likewise, + (getRangeZeroBaselinePaint): Likewise, + (setRangeZeroBaselinePaint): Likewise, + (isRangeMinorGridlinesVisible): Likewise, + (setRangeMinorGridlinesVisible): Likewise, + (getRangeMinorGridlineStroke): Likewise, + (setRangeMinorGridlineStroke): Likewise, + (getRangeMinorGridlinePaint): Likewise, + (setRangeMinorGridlinePaint): Likewise, + (draw): Add code to draw new zero range baseline, + (drawRangeGridlines): Account for minor gridlines, + (drawZeroRangeBaseline): New method, + (equals): Updated for new fields, + (writeObject): Likewise, + (readObject): Likewise, + * source/org/jfree/chart/axis/DateAxis.java + (refreshTicksHorizontal): Check tick unit for minor tick count, + (refreshTicksVertical): Likewise, + * source/org/jfree/chart/axis/LogAxis.java + (LogAxis): Remove call to setMinorTickCount(), + * source/org/jfree/chart/axis/NumberAxis.java + (createStandardTickUnits): Initialise minor tick counts, + (createIntegerTickUnits): Likewise, + (refreshTicksHorizontal): Check tick unit for minor tick count, + (refreshTicksVertical): Likewise, + * source/org/jfree/chart/axis/ValueAxis.java + (ValueAxis): Set default minor tick count to zero, + (setMinorTickCount): Remove argument check, + * tests/org/jfree/chart/plot/junit/CategoryPlotTests.java + (testEquals): Check new fields. + +2009-01-16 David Gilbert + + Bug 2490803: + * source/org/jfree/chart/axis/PeriodAxis.java + (getRange): Removed, rely on superclass implementation, + (setRange): Update range with end points of whole periods, + (drawTickMarksHorizontal): Include first and last ticks, + * tests/org/jfree/chart/axis/junit/PeriodAxisTests.java + (test2490803): New test method. + +2009-01-16 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (DEFAULT_BUFFER_USED): Changed default to true, + (zoomOutlinePaint): New field, + (zoomFillPaint): Likewise, + (ChartPanel): Initialise new fields, + (getZoomFillPaint): New method, + (setZoomFillPaint): Likewise, + (getZoomOutlinePaint): Likewise, + (setZoomOutlinePaint): Likewise, + (paintComponent): Update drawing of zoom rectangle, + (mouseDragged): If useBuffer is true, repaint chart rather than using XOR + for zoom rectangle, + (mouseReleased): Likewise, + (drawZoomRectangle): Only use XOR if useBuffer is false, + (writeObject): Handle new fields, + (readObject): Likewise. + +2009-01-14 David Gilbert + + Patch 2497611 by Peter Kolb: + * source/org/jfree/chart/axis/CategoryAxis.java + (getCategorySeriesMiddle): New method, + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (initialise): Record visible series indices, + * source/org/jfree/chart/renderer/category/BarRenderer.java + (calculateBarWidth): Look for visible series count in state, + (calculateBarW0): Likewise, + (drawItem): Use the visible row index, + * source/org/jfree/chart/renderer/category/CategoryItemRendererState.java + (visibleSeries): New field, + (getVisibleSeriesIndex): New method, + (getVisibleSeriesCount): Likewise, + (setVisibleSeriesArray): Likewise, + * source/org/jfree/chart/renderer/category/IntervalBarRenderer.java + (drawInterval): Use the visible row index, + * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/category/ScatterRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java + (drawItem): Likewise, + (drawHorizontalItem): Changed signature, + (drawVerticalItem): Likewise, + * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java + (drawItem): Use the visible row index. + +2009-01-14 David Gilbert + + * source/org/jfree/chart/axis/LogAxis.java + (refreshTicksHorizontal): Read minorTickCount from the tick unit, + (refreshTicksVertical): Likewise, + (createLogTickUnits): Corrected the tick unit sizes and added + minor tick counts, + * source/org/jfree/chart/util/LogFormat.java + (LogFormat): New constructor, + (getExponentFormat): New method, + (setExponentFormat): Likewise, + (equals): Test formatter field, + * tests/org/jfree/chart/util/junit/LogFormatTests.java + (testEquals): Check formatter field. + +2009-01-13 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (zoomInDomain): Change notify flag to ensure plot sends only one event, + (zoomInRange): Likewise, + (zoomOutDomain): Likewise, + (zoomOutRange): Likewise, + (restoreAutoDomainBounds): Likewise, + (restoreAutoRangeBounds): Likewise, + * test/org/jfree/chart/junit/ChartPanelTests.java + (test2502355_zoomInDomain): New test, + (test2502355_zoomInRange): Likewise, + (test2502355_zoomOutDomain): Likewise, + (test2502355_zoomOutRange): Likewise, + (test2502355_restoreAutoDomainBounds): Likewise, + (test2502355_restoreAutoRangeBounds): Likewise. + +2009-01-13 David Gilbert + + Bug 2502355: + * source/org/jfree/chart/ChartPanel.java + (zoomInBoth): Change notify flag to ensure plot sends only one event, + (zoomOutBoth): Likewise, + (zoom): Likewise, + (restoreAutoBounds): Likewise, + * source/org/jfree/chart/plot/Plot.java + (notify): New field, + (Plot): Initialise new field, + (isNotify): New method, + (setNotify): Likewise, + (notifyListeners): Check notify flag, + * tests/org/jfree/chart/junit/ChartPanelTests.java + (chartChangeEvents): New field, + (chartChanged): New method, + (test2502355_zoom): New test, + (test2502355_zoomInBoth): Likewise, + (test2502355_zoomOutBoth): Likewise, + (test2502355_restoreAutoBounds): Likewise. + +2009-01-13 David Gilbert + + * source/org/jfree/data/time/TimeSeries.java + (TimeSeries(Comparable, Class)): Deprecated, + (TimeSeries(Comparable, String, String, Class)): Likewise, + (TimeSeries(Comparable)): Delegate to new constructor, + (TimeSeries(Comparable, String, String)): New constructor, + (add): Update timePeriodClass if necessary, + (addAndOrUpdate): Use new constructor, + (addOrUpdate): Reset timePeriodClass if necessary, + (removeAgedItems): Check for empty series, + (clear): Reset timePeriodClass, + (delete): Reset timePeriodClass if series is empty, + (delete(int, int)): Likewise, + (equals): Reorganised, + * tests/org/jfree/data/time/junit/TimeSeriesTests.java + (testEquals3): New test, + (testRemoveAgedItems3): Likewise. + +2009-01-09 David Gilbert + + * source/org/jfree/chart/plot/MultiplePiePlot.java + (MultiplePiePlot): Set ignoreNullValues to true. + +2009-01-09 David Gilbert + + * source/org/jfree/chart/axis/DateTickUnit.java + (unit): Deprecated, + (unitType): New field, + (rollUnit): Deprecated, + (rollUnitType): New field, + (DateTickUnit): Deprecated existing constructors, replaced with new ones, + (getUnitType): New method, + (getRollUnitType): Likewise, + (getCount): Renamed getMultiple(), + (getRollCount): Renamed getRollMultiple(), + (addToDate): Updated for new fields, + (rollDate): Likewise, + (getCalendarField): Likewise, + (getMillisecondCount): Updated for new type, + (intToUnitType): Utility method for deprecated constants, + (unitTypeToInt): Likewise, + (notNull): Utility method for deprecated constructor, + (equals): Updated for new fields, + (units): Removed, + (YEAR, MONTH, DAY, HOUR, MINUTE, SECOND, MILLISECOND): Deprecated, + (getUnit): Deprecated, + (getRollUnit): Likewise, + * source/org/jfree/chart/axis/DateTickUnitType.java: New file. + +---------- JFREECHART 1.0.12 RELEASED ------------------------ + +2008-12-31 David Gilbert + + Bug 2471906: + * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java + (drawItem): Check for dashed stroke and clip area manually for that case. + +2008-12-30 David Gilbert + + * source/org/jfree/chart/plot/MultiplePiePlot.java + (legendItemShape): New field, + (MultiplePiePlot(CategoryDataset)): Initialise new field, + (getLegendItemShape): New method, + (setLegendItemShape): New method, + (getLegendItems): Use new field, + (equals): Check new field, + (clone): Implemented, + (readObject): Handle new field, + (writeObject): Likewise. + +2008-12-20 David Gilbert + + Bug 2452078: + * source/org/jfree/chart/ChartFactory.java + (createStackedAreaChart): Set category margin to zero. + +2008-12-18 David Gilbert + + Patch 1607918 by Jess Thrysoee (with modifications): + * source/org/jfree/chart/ChartPanel.java + (localizationResources): Use ResourceBundleWrapper, + * source/org/jfree/chart/JFreeChart.java + (JFreeChartInfo()): Likewise, + * source/org/jfree/chart/editor/DefaultAxisEditor.java, + * source/org/jfree/chart/editor/DefaultChartEditor.java, + * source/org/jfree/chart/editor/DefaultColorBarEditor.java, + * source/org/jfree/chart/editor/DefaultNumberAxisEditor.java, + * source/org/jfree/chart/editor/DefaultPlotEditor.java, + * source/org/jfree/chart/editor/DefaultTitleEditor.java + (localizationResources): Use ResourceBundleWrapper, + * source/org/jfree/chart/plot/CategoryPlot.java, + * source/org/jfree/chart/plot/ContourPlot.java, + * source/org/jfree/chart/plot/FastScatterPlot.java, + * source/org/jfree/chart/plot/MeterPlot.java, + * source/org/jfree/chart/plot/PiePlot.java, + * source/org/jfree/chart/plot/PolarPlot.java, + * source/org/jfree/chart/plot/ThermometerPlot.java, + * source/org/jfree/chart/plot/WaferMapPlot.java, + * source/org/jfree/chart/plot/XYPlot.java + (localizationResources): Use ResourceBundleWrapper, + * source/org/jfree/chart/util/ResourceBundleWrapper.java: New class, + * source/org/jfree/data/category/DefaultIntervalCategoryDataset.java + (DefaultIntervalCategoryDataset): Use ResourceBundleWrapper, + * swt/org/jfree/experimental/chart/swt/ChartComposite.java, + * swt/org/jfree/experimental/chart/swt/editor/SWTAxisEditor.java, + * swt/org/jfree/experimental/chart/swt/editor/SWTChartEditor.java, + * swt/org/jfree/experimental/chart/swt/editor/SWTOtherEditor.java, + * swt/org/jfree/experimental/chart/swt/editor/SWTPlotAppearanceEditor.java, + * swt/org/jfree/experimental/chart/swt/editor/SWTPlotEditor.java, + * swt/org/jfree/experimental/chart/swt/editor/SWTTitleEditor.java + (localizationResources): Use ResourceBundleWrapper. + +2008-12-03 David Gilbert + + * source/org/jfree/chart/block/GridArrangement.java + (arrange): Fill in missing constraint combinations, + (arrangeNN): Check for null block, + (arrangeFF): Likewise, + (arrangeRF): New method, + (arrangeRN): Likewise, + (arrangeNR): Likewise, + (arrangeRR): Likewise, + (arrangeFN): Check for null block, + (arrangeNF): New method, + * tests/org/jfree/chart/block/junit/GridArrangementTests.java: + Added various new tests. + +2008-11-25 David Gilbert + + Bug fix 2201869 by Fawad Halim (with modifications): + * source/org/jfree/chart/axis/DateAxis.java + (previousStandardDate): Use new Month constructor, + (correctTickDateForPosition): New private method, + (refreshTicksHorizontal): Moved position correction to top of loop, + (refreshTicksVertical): Likewise, + * source/org/jfree/data/time/Month.java + (Month(Date, TimeZone)): Deprecated, + (Month(Date, TimeZone, Locale)): New constructor, + * source/org/jfree/data/time/Quarter.java + (Quarter(Date, TimeZone)): Deprecated, + (Quarter(Date, TimeZone, Locale)): New constructor, + * source/org/jfree/data/time/Year.java + (Year(Date, TimeZone)): Deprecated, + (Year(Date, TimeZone, Locale)): New constructor. + +2008-11-25 David Gilbert + + Based on patch 1868749 by Andrew Mickish: + * source/org/jfree/chart/plot/CategoryPlot.java + (datasetToDomainAxisMap): Changed from ObjectList to TreeMap, + (datasetToRangeAxisMap): Likewise, + (CategoryPlot): Updated initialization of modified fields, + (mapDatasetToDomainAxis): Delegate to new method, + (mapDatasetToDomainAxes): New method, + (checkAxisIndices): New private method, + (getDomainAxisForDataset): Updated for multiple axis support, + (mapDatasetToRangeAxis): Delegate to new method, + (mapDatasetToRangeAxes): New method, + (getRangeAxisForDataset): Updated for multiple axis support, + (datasetsMappedToDomainAxis): Likewise, + (datasetsMappedToRangeAxis): Likewise, + (equals): Updated for field changes, + (clone): Likewise, + * source/org/jfree/chart/plot/XYPlot.java + (datasetToDomainAxisMap): Renamed, + (datasetToRangeAxisMap): Renamed, + (XYPlot): Updated for renamed fields, + (mapDatasetToDomainAxis): Delegate to new method, + (mapDatasetToDomainAxes): New method, + (mapDatasetToRangeAxis): Delegate to new method, + (mapDatasetToRangeAxes): New method, + (checkAxisIndices): New private method, + (getDomainAxisForDataset): Updated for multiple axis support, + (getRangeAxisForDataset): Likewise, + (getDatasetsMappedToDomainAxis): Likewise, + (getDatasetsMappedToRangeAxis): Likewise, + (equals): Updated for field changes, + (clone): Likewise. + +2008-11-25 David Gilbert + + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (findRangeBounds): Check for null argument, + * source/org/jfree/chart/renderer/category/BarRenderer.java + (findRangeBounds): Likewise, + * source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java + (findRangeBounds): Likewise, + * source/org/jfree/chart/renderer/category/StackedBarRenderer.java + (findRangeBounds): Likewise. + +2008-11-24 David Gilbert + + Bug 1955483: + * source/org/jfree/data/xy/XYSeries.java + (addOrUpdate): Check early for duplicates allowed, + * tests/org/jfree/data/xy/junit/XYSeriesTests.java + (testBug1955483): New test. + +2008-11-18 David Gilbert + + Bug 2216511: + * swt/org/jfree/experimental/chart/demo/SWTBarChartDemo1.java + (createChart): Reset the bar painter to avoid using gradients, + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + (setPaint): Don't fail for GradientPaint. + +2008-11-13 David Gilbert + + Bug 2275695: + * source/org/jfree/chart/axis/SubCategoryAxis.java + (drawSubCategoryLabels): Check for null, + * tests/org/jfree/chart/axis/junit/SubCategoryAxisTests.java + (test2275695): New method. + +2008-11-05 David Gilbert + + Bug 2221495: + * source/org/jfree/chart/annotations/XYLineAnnotation.java + (draw): Clip line before drawing, + * source/org/jfree/chart/util/LineUtilities.java: New file, + * tests/org/jfree/chart/util/junit/LineUtilitiesTests.java: Likewise. + +2008-10-27 David Gilbert + + * source/org/jfree/chart/axis/CategoryAxis.java + (refreshTicks): Set correct for for category label. + +2008-10-23 David Gilbert + + * source/org/jfree/chart/ChartFactory.java + (setChartTheme): Check if theme is "Legacy" and reset default bar painters. + +2008-10-15 David Gilbert + + * source/org/jfree/chart/LegendItem.java + (LegendItem(String, Paint)): New constructor. + +2008-10-08 David Gilbert + + Incorporating patch 2131001: + * source/org/jfree/data/general/DatasetUtilities.java + (iterateDomainBounds(XYDataset, boolean)): Ignore Double.NaN values, + (iterateRangeBounds(CategoryDataset, boolean)): Likewise, + (findStackedRangeBounds(CategoryDataset, KeyToGroupMap)): Cleanup, + (findMinimumStackedRangeValue(CategoryDataset)): Likewise, + (findMaximumStackedRangeValue(CategoryDataset)): Likewise, + (findCumulativeRangeBounds(CategoryDataset)): Likewise. + +2008-10-08 David Gilbert + + * source/org/jfree/chart/labels/IntervalCategoryToolTipGenerator.java + (equals): New method override, + * source/org/jfree/chart/renderer/category/IntervalBarRenderer.java + (equals): New method override. + +2008-10-02 David Gilbert + + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (drawItem): Check item visibility. + +2008-09-26 David Gilbert + + * source/org/jfree/chart/axis/Axis.java + (fireChangeEvent): New method, + also updated various other methods to call fireChangeEvent(). + +2008-09-26 David Gilbert + + * source/org/jfree/chart/renderer/category/WaterfallRenderer.java + (drawItem): Fixed bar misalignment when maxBarWidth is applied. + +2008-09-26 David Gilbert + + * source/org/jfree/chart/renderer/xy/VectorRenderer.java + (drawItem): Add chart entity. + +2008-09-25 David Gilbert + + Patch 1934255 (incorporating 1870189): + * source/org/jfree/chart/axis/Axis.java + (minorTickMarksVisible): New field, + (minorTickMarkInsideLength): New field, + (minorTickMarkOutsideLength): New field, + (Axis(String)): Initialise new fields, + (isMinorTickMarksVisible): New method, + (setMinorTickMarksVisible): Likewise, + (getMinorTickMarkInsideLength): Likewise, + (setMinorTickMarkInsideLength): Likewise, + (getMinorTickMarkOutsideLength): Likewise, + (setMinorTickMarkOutsideLength): Likewise, + * source/org/jfree/chart/axis/DateAxis.java + (refreshTicksHorizontal): Add minor ticks, + (refreshTicksVertical): Likewise, + * source/org/jfree/chart/axis/DateTick.java + (DateTick): New constructor, + (equals): Clean up, + * source/org/jfree/chart/axis/LogAxis.java + (minorTickCount): Removed (now in superclass), + (LogAxis(String)): Updated for removed field, + (getMinorTickCount): Removed (now in superclass), + (setMinorTickCount): Likewise, + (refreshTicksHorizontal): Updated for removed field, + (refreshTicksVertical): Likewise, + (equals): Likewise, + (hashCode): Likewise, + * source/org/jfree/chart/axis/NumberAxis.java + (refreshTicksHorizontal): Add minor ticks, + (refreshTicksVertical): Likewise, + * source/org/jfree/chart/axis/ValueAxis.java + (minorTickCount): New field, + (drawTickMarksAndLabels): Draw minor ticks, + (getMinorTickCount): New method, + (setMinorTickCount): Likewise, + (equals): Updated for new field, + * source/org/jfree/chart/plot/XYPlot.java + (domainMinorGridlinesVisible): New field, + (domainMinorGridlineStroke): Likewise, + (domainMinorGridlinePaint): Likewise, + (rangeMinorGridlinesVisible): Likewise, + (rangeMinorGridlineStroke): Likewise, + (rangeMinorGridlinePaint): Likewise, + (XYPlot): Initialise new fields, + (isDomainMinorGridlinesVisible): New method, + (setDomainMinorGridlinesVisible): Likewise, + (getDomainMinorGridlineStroke): Likewise, + (setDomainMinorGridlineStroke): Likewise, + (getDomainMinorGridlinePaint): Likewise, + (setDomainMinorGridlinePaint): Likewise, + (isRangeMinorGridlinesVisible): Likewise, + (setRangeMinorGridlinesVisible): Likewise, + (getRangeMinorGridlineStroke): Likewise, + (setRangeMinorGridlineStroke): Likewise, + (getRangeMinorGridlinePaint): Likewise, + (setRangeMinorGridlinePaint): Likewise, + (drawDomainGridlines): Draw minor gridlines too, + (drawRangeGridlines): Likewise, + (equals): Updated for new attributes, + (writeObject): Likewise, + (readObject): Likewise, + * tests/org/jfree/chart/axis/junit/AxisTests.java + (testEquals): Updated for new field, + * tests/org/jfree/chart/axis/junit/DateTickTests.java + (testEquals): Updated for new field, + * tests/org/jfree/chart/plot/junit/XYPlotTests.java + (testEquals): Updated for new fields. + +2008-09-25 David Gilbert + + * source/org/jfree/chart/renderer/xy/HighLowRenderer.java + (drawItem): Check for non-null entity collection. + +2008-09-24 David Gilbert + + Bug 2113627 + * source/org/jfree/chart/renderer/xy/XYStepRenderer.java + (drawItem): Draw item labels in second pass only, add chart + entity info in first pass only. + +2008-09-23 David Gilbert + + Bug 2121818 (fix by Christoph Beck): + * source/org/jfree/chart/plot/PiePlot.java + (getLabelLinkDepth): New method, + (drawLeftLabels): Use getLabelLinkDepth(), + (drawRightLabels): Likewise, + * source/org/jfree/chart/plot/RingPlot.java + (getLabelLinkDepth): New method. + +2008-09-23 David Gilbert + + * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java + (drawItem): Check shadow visibility before drawing shadow. + +---------- JFREECHART 1.0.11 RELEASED ------------------------ + +2008-09-19 David Gilbert + + Patch from Greg Darke, slightly modified: + * source/org/jfree/chart/renderer/xy/XYItemRendererState.java + (firstItemIndex): New field, + (lastItemIndex): Likewise, + (getFirstItemIndex): New method, + (getLastItemIndex): New method, + (startSeriesPass): Record first and last item indices, + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (State.startSeriesPass): Reset series state, + (drawItem): Removed code that is handled in State now, + (drawPrimaryLineAsPath): Fix check for last item. + +2008-09-19 David Gilbert + + * source/org/jfree/chart/StandardChartTheme.java + (smallFont): New field, + (crosshairPaint): New field, + (createDarknessTheme): Initialise crosshairPaint, + (StandardChartTheme): Initialise new fields, + (getCrosshairPaint): New method, + (setCrosshairPaint): Likewise, + (applyToXYPlot): Apply crosshair paint and process annotations, + (applyToXYAnnotation): New method, + (equals): Check new fields, + (writeObject): Handle crosshairPaint, + (readObject): Likewise. + +2008-09-19 David Gilbert + + * source/org/jfree/chart/JFreeChart.java + (draw): Check title visibility, + * source/org/jfree/chart/title/Title.java + (visible): New field, + (isVisible): New method, + (setVisible): Likewise, + (equals): Check visible flag. + +2008-08-18 David Gilbert + + * source/org/jfree/chart/axis/DateAxis.java + (locale): New field, + (DateAxis(String, TimeZone, Locale)): New constructor, + (setTimeZone): Updated to use new locale field, + (previousStandardDate): Likewise, + (createStandardDateTickUnits(TimeZone)): Deprecated, + (createStandardDateTickUnits(TimeZone, Locale)): New method. + +2008-09-18 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (paintComponent): Modified chart buffer creation. + +2008-09-18 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYShapeRenderer.java: New class, + * tests/org/jfree/chart/renderer/xy/junit/XYShapeRendererTests.java: + New tests, + * tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java + (suite): Added XYShapeRendererTests. + +2008-09-17 David Gilbert + + * source/org/jfree/chart/annotations/XYDataImageAnnotation.java: + New class. + +2008-09-17 David Gilbert + + * source/org/jfree/chart/title/PaintScaleLegend.java + (PaintScaleLegend(PaintScale, ValueAxis)): Change axis range to reflect + scale bounds. + +2008-09-17 David Gilbert + + * source/org/jfree/data/gantt/XYTaskDataset.java: New class, + * tests/org/jfree/data/gantt/junit/DataGanttPackageTests.java + (suite): Added XYTaskDatasetTests, + * tests/org/jfree/data/gantt/junit/XYTaskDatasetTests.java: New file. + +2008-09-16 David Gilbert + + * source/org/jfree/data/time/Day.java + (Day(Date)): Use TimeZone.getDefault(), + * source/org/jfree/data/time/Hour.java + (Hour(Date)): Likewise, + * source/org/jfree/data/time/Millisecond.java + (Millisecond(Date)): Likewise, + * source/org/jfree/data/time/Minute.java + (Minute(Date)): Likewise, + * source/org/jfree/data/time/Month.java + (Month(Date)): Likewise, + (parseMonth): Updated for changes in Year range, + * source/org/jfree/data/time/Quarter.java + (Quarter(Date)): Use TimeZone.getDefault(), + * source/org/jfree/data/time/RegularTimePeriod.java + (DEFAULT_TIME_ZONE): Deprecated, + * source/org/jfree/data/time/Second.java + (Second(Date)): Use TimeZone.getDefault(), + * source/org/jfree/data/time/Week.java + (Week(Date)): Likewise, + * source/org/jfree/data/time/Year.java + (MINIMUM_YEAR): New field, + (MAXIMUM_YEAR): Likewise, + (Year(int)): Updated range check, + (Year(Date)): Use TimeZone.getDefault(), + (previous): Updated for new range bounds, + (next): Likewise, + (equals): Cleaned up, + * tests/org/jfree/data/time/junit/YearTests.java + (testEquals): Extended, + (test1900Previous): Modified and enamed testMinus9999Previous, + (testParseYear): Updated. + +2008-09-10 David Gilbert + + * source/org/jfree/chart/StandardChartTheme.java + (applyToCategoryAxis): Check for SubCategoryAxis and set sublabel font and + paint. + +2008-09-03 David Gilbert + + * experimental/org/jfree/experimental/chart/annotations/XYTitleAnnotation.java: + Moved to main, + * experimental/org/jfree/experimental/chart/annotations/junit/XYTitleAnnotationTests.java + Likewise, + * experimental/org/jfree/experimental/chart/util/XYCoordinateType.java + Likewise, + * source/org/jfree/chart/annotation/XYTitleAnnotation.java: + Transferred from experimental, + * source/org/jfree/chart/util/XYCoordinateType.java: Likewise, + * tests/org/jfree/chart/annotations/junit/AnnotationsPackageTests.java + (suite): Added tests for XYTitleAnnotation, + * tests/org/jfree/chart/annotations/junit/XYTitleAnnotationTests.java: + New file. + +2008-09-01 David Gilbert + + Bug 2078057: + * source/org/jfree/chart/axis/DateAxis.java + (previousStandardDate): For month option, peg in case of + non-default time zone, + * source/org/jfree/data/time/Month.java + (previous): Added API doc comments, + (next): Likewise. + +2008-09-01 David Gilbert + + * source/org/jfree/chart/axis/DateAxis.java + (valueToJava2D): Use DateRange methods that return millis, + (java2DToValue): Likewise, + * source/org/jfree/data/time/DateRange.java + (getLowerMillis): New method, + (getUpperMillis): Likewise. + +2008-09-01 David Gilbert + + * source/org/jfree/chart/util/RelativeDateFormat.java + (hourFormatter): New field, + (minuteFormatter): New field, + (RelativeDateFormat(long)): Initialise new fields, + (setDayFormatter): New method, + (setHourFormatter): Likewise, + (setMinuteFormatter): Likewise, + (format): Use new fields for formatting, + (equals): Updated for new fields. + +2008-09-01 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYDotRenderer.java + (drawItem): Check for item visibility. + +2008-08-15 David Gilbert + + Bug 2031407: + * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java + (createStackedValueList): Encode series with negative values using -1 + offset, + (drawStackHorizontal): Account for -1 offset, + (drawStackVertical): Likewise. + +2008-08-15 David Gilbert + + Bug 2033721: + * source/org/jfree/chart/renderer/WaferMapRenderer.java + (getLegendCollection): Use lookupSeriesPaint. + +2008-08-15 David Gilbert + + Bug 2051168: + * source/org/jfree/chart/plot/PiePlot.java + (getLegendItems): Populate with series key and index. + +2008-08-15 David Gilbert + + * source/org/jfree/chart/ChartFactory.java: + (currentTheme): New field, + (getChartTheme): New method, + (setChartTheme): Likewise, + ...and applied current theme in all chart creation methods, + * source/org/jfree/chart/ChartTheme.java: New file, + * source/org/jfree/chart/ChartUtilities.java + (applyCurrentTheme): New method, + * source/org/jfree/chart/StandardChartTheme.java: New file. + +2008-08-15 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (DEFAULT_MAXIMUM_DRAW_WIDTH): Increased to 1024, + (DEFAULT_MAXIMUM_DRAW_HEIGHT): Increased to 768. + +2008-08-15 David Gilbert + + * source/org/jfree/chart/renderer/category/GradientBarPainter.java + (paintBar): Use outline paint, + (paintBarShadow): Use shadow paint, + * source/org/jfree/chart/renderer/category/StandardBarPainter.java + (paintBarShadow): Use shadow paint. + +2008-08-15 David Gilbert + + * source/org/jfree/chart/renderer/AbstractRenderer.java + (clearSeriesPaints): New method, + (clearSeriesStrokes): Likewise. + +2008-08-15 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (clearSectionPaints): New method, + (clearSectionOutlinePaints): Likewise, + (clearSectionOutlineStrokes): Likewise. + +2008-08-15 David Gilbert + + * source/org/jfree/chart/axis/SymbolAxis.java + (drawGridBandsHorizontal): Use gridBandAlternatePaint, + (drawGridBandsVertical): Likewise. + +2008-08-15 David Gilbert + + * source/org/jfree/chart/plot/CategoryPlot.java + (getRendererCount): New method, + * source/org/jfree/chart/plot/XYPlot.java + (getRendererCount): Likewise. + +2008-08-15 David Gilbert + + * source/org/jfree/chart/title/LegendTitle.java + (getWrapper): New method. + +2008-08-15 David Gilbert + + * source/org/jfree/chart/plot/Plot.java + (setDrawingSupplier(DrawingSupplier, boolean)): New method. + +2008-08-11 David Gilbert + + * source/org/jfree/chart/renderer/category/BarRenderer.java + (shadowPaint): New field, + (getShadowPaint): New method, + (setShadowPaint): Likewise, + (equals): Updated for new field, + (writeObject): For serialization, + (readObject): Likewise. + +2008-08-11 David Gilbert + + * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java + (totalWeight): Removed, + (CombinedDomainCategoryPlot(CategoryAxis)): Updated for removed field, + (add(CategoryPlot, int)): No longer need to track totalWeight, + (remove): Likewise, + (calculateAxisSpace): Compute totalWeight on-the-fly, + * source/org/jfree/chart/plot/CombinedDomainXYPlot.java + (totalWeight): Removed, + (add(XYPlot, int)): No longer need to track totalWeight, + (remove): Likewise, + (calculateAxisSpace): Compute totalWeight on-the-fly, + * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java + (totalWeight): Removed, + (add(CategoryPlot, int)): No longer need to track totalWeight, + (remove): Likewise, + (calculateAxisSpace): Compute totalWeight on-the-fly, + * source/org/jfree/chart/plot/CombinedRangeXYPlot.java + (totalWeight): Removed, + (add(XYPlot, int)): No longer need to track totalWeight, + (remove): Likewise, + (calculateAxisSpace): Compute totalWeight on-the-fly. + +2008-07-25 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (drawQuadrants): Check for null axes, + (render): Likewise. + +2008-07-11 David Gilbert + + Bug 1994355: + * swt/org/jfree/experimental/swt/ChartComposite.java + (addSWTListener): Changed argument type. + +2008-07-11 David Gilbert + + Synced from trunk change by Henry Proudhon: + * swt/org/jfree/experimental/swt/SWTUtils.java + (toSwtFontData): Simplified font style, + (toAwtFont): Likewise. + +2008-07-10 David Gilbert + + * source/org/jfree/chart/plot/CategoryPlot.java + (draw): Check outline visibility. + +2008-07-10 David Gilbert + + * source/org/jfree/data/time/ohlc/OHLCSeriesCollection.java + (getXPosition): New method, + (setXPosition): Likewise, + (equals): Updated for xPosition attribute. + +2008-07-09 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (render): Call new methods in XYItemRendererState, + * source/org/jfree/chart/renderer/xy/XYItemRendererState.java + (startSeriesPass): New method, + (endSeriesPass): Likewise. + +2008-07-09 David Gilbert + + * source/org/jfree/chart/title/CompositeTitle.java + (backgroundPaint): New field, + (CompositeTitle): Initialise new field, + (getBackgroundPaint): New method, + (setBackgroundPaint): Likewise, + (draw): Fill background if necessary, + (equals): Check backgroundPaint, + (writeObject): Added serialization support for backgroundPaint, + (readObject): Likewise. + +2008-07-02 David Gilbert + + Patch 2006826: + * source/org/jfree/chart/title/CompositeTitle.java + (draw(Graphics2D, Rectangle2D)): Delegate to other draw method, + (draw(Graphics2D, Rectangle2D, Parameters)): Modified implementation to + return result from BlockContainer. + +2008-07-02 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (autoPopulateSectionPaint): New field, + (autoPopulateSectionOutlinePaint): Likewise, + (autoPopulateSectionOutlineStroke): Likewise, + (PiePlot(PieDataset)): Initialise new fields, + (lookupSectionPaint(Comparable)): Use autoPopulateSectionPaint field, + (getAutoPopulateSectionPaint): New method, + (setAutoPopulateSectionPaint): Likewise, + (lookupSectionOutlinePaint(Comparable)): Use autoPopulateSectionOutlinePaint + field, + (getAutoPopulateSectionOutlinePaint): New method, + (setAutoPopulateSectionOutlinePaint): Likewise, + (lookupSectionOutlineStroke(Comparable)): + Use autoPopulateSectionOutlineStroke field, + (getAutoPopulateSectionOutlineStroke): New method, + (setAutoPopulateSectionOutlineStroke): Likewise, + (drawItem): Updated lookup methods, + (getLegendItems): Likewise, + (equals): Updated for new fields, + * source/org/jfree/chart/plot/PiePlot3D.java + (draw): Updated lookup methods, + * source/org/jfree/chart/plot/RingPlot.java + (draw): Likewise. + +2008-06-26 David Gilbert + + * source/org/jfree/chart/axis/CategoryAxis.java + (getCategoryMiddle(Comparable, List, Rectangle2D, RectangleEdge)): + New method, + * source/org/jfree/chart/plot/CategoryCrosshairState.java: New file, + * source/org/jfree/chart/plot/CategoryPlot.java + (crosshairDatasetIndex): New field, + (domainCrosshairVisible): Likewise, + (domainCrosshairRowKey): Likewise, + (domainCrosshairColumnKey): Likewise, + (domainCrosshairStroke): Likewise, + (domainCrosshairPaint): Likewise, + (CategoryPlot): Initialise new fields, + (indexOf): New method, + (isDomainCrosshairVisible): Likewise, + (setDomainCrosshairVisible): Likewise, + (getDomainCrosshairRowKey): Likewise, + (setDomainCrosshairRowKey): Likewise, + (getDomainCrosshairColumnKey): Likewise, + (setDomainCrosshairColumnKey): Likewise, + (getCrosshairDatasetIndex): Likewise, + (setCrosshairDatasetIndex): Likewise, + (getDomainCrosshairPaint): Likewise, + (setDomainCrosshairPaint): Likewise, + (getDomainCrosshairStroke): Likewise, + (setDomainCrosshairStroke): Likewise, + (draw): Handle crosshairs, + (render): Modified method signature to incorporate crosshair state, + (drawDomainCrosshair): New method, + (equals): Updated for new fields, + (writeObject): Likewise, + (readObject): Likewise, + * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java + (draw): Fixed crosshair support, + * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java + (draw): Likewise, + * source/org/jfree/chart/plot/CrosshairState.java + (datasetIndex): New field, + (getDatasetIndex): New method, + (setDatasetIndex): New method, + (getDomainAxisIndex): Deprecated, + (getRangeAxisIndex): Deprecated, + * source/org/jfree/chart/plot/XYCrosshairState.java: New subclass, + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (getItemMiddle): New method, + (updateCrosshairValues): Likewise, + * source/org/jfree/chart/renderer/category/AreaRenderer.java + (drawItem): Update crosshair state, + * source/org/jfree/chart/renderer/category/BarRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/category/CategoryItemRenderer.java + (getItemMiddle): New method, + * source/org/jfree/chart/renderer/category/CategoryItemRendererState.java + (crosshairState): New field, + (getCrosshairState): New method, + (setCrosshairState): Likewise, + * source/org/jfree/chart/renderer/category/GanttRenderer.java + (drawTasks): Update crosshair state, + (drawTask): Likewise, + (getItemMiddle): New method override, + * source/org/jfree/chart/renderer/category/LevelRenderer.java + (drawItem): Update crosshair state, + (getItemMiddle): New method override, + * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java + (drawItem): Update crosshair state, + * tests/org/jfree/chart/plot/junit/CategoryPlotTests.java + (testEquals): Updated for new fields. + +2008-06-24 David Gilbert + + * source/org/jfree/chart/renderer/category/BarPainter.java: New file, + * source/org/jfree/chart/renderer/category/BarRenderer.java: + (defaultBarPainter): New field, + (getDefaultBarPainter): New method, + (setDefaultBarPainter): Likewise, + (barPainter): New field, + (shadowsVisible): Likewise, + (shadowXOffset): Likewise, + (shadowYOffset): Likewise, + (BarRenderer): Initialise new fields, + (getBarPainter): New method, + (setBarPainter): Likewise, + (getShadowsVisible): Likewise, + (setShadowsVisible): Likewise, + (getShadowXOffset): Likewise, + (setShadowXOffset): Likewise, + (getShadowYOffset): Likewise, + (setShadowYOffset): Likewise, + (drawItem): Use new barPainter, + (equals): Check new fields, + * source/org/jfree/chart/renderer/category/GanttRenderer.java + (drawTask): Use new barPainter, + (drawTasks): Likewise, + * source/org/jfree/chart/renderer/category/GradientBarPainter.java: + New file, + * source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java + (drawItem): Use new barPainter, + * source/org/jfree/chart/renderer/category/IntervalBarRenderer.java + (drawItem): Use new barPainter, + * source/org/jfree/chart/renderer/category/StackedBarRenderer.java + (getPassCount): Now returns 3, + (drawItem): Use new barPainter, + * source/org/jfree/chart/renderer/category/StandardBarPainter.java: + New file, + * source/org/jfree/chart/renderer/xy/ClusteredXYBarRenderer.java + (getPassCount): Now returns 2, + (drawItem): Use new barPainter, + * source/org/jfree/chart/renderer/xy/GradientXYBarPainter.java: New file, + * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java + (getPassCount): Now returns 3, + (drawItem): Use new barPainter, + * source/org/jfree/chart/renderer/xy/StandardXYBarPainter.java: New file, + * source/org/jfree/chart/renderer/xy/XYBarPainter.java: New file, + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (defaultBarPainter): New field, + (getDefaultBarPainter): New method, + (setDefaultBarPainter): Likewise, + (barPainter): New field, + (shadowsVisible): Likewise, + (shadowXOffset): Likewise, + (shadowYOffset): Likewise, + (XYBarRenderer(double)): Initialise new fields, + (getBarPainter): New method, + (setBarPainter): Likewise, + (getShadowsVisible): Likewise, + (setShadowsVisible): Likewise, + (getShadowXOffset): Likewise, + (setShadowXOffset): Likewise, + (getShadowYOffset): Likewise, + (setShadowYOffset): Likewise, + (drawItem): Use new barPainter, + (equals): Check new fields, + * tests/org/jfree/chart/renderer/category/junit/BarRendererTests.java + (testEquals): Updated for new fields, + * tests/org/jfree/chart/renderer/category/junit/GradientBarPainterTests.java: + New file, + * tests/org/jfree/chart/renderer/category/junit/RendererCategoryPackageTests.java + (suite): Included new test classes, + * tests/org/jfree/chart/renderer/category/junit/StandardBarPainterTests.java: + New file, + * tests/org/jfree/chart/renderer/xy/junit/GradientXYBarPainterTests.java: + New file, + * tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java + (suite): Included new test classes, + * tests/org/jfree/chart/renderer/xy/junit/StandardXYBarPainterTests.java: + New file, + * tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java + (testEquals): Updated for new fields. + +2008-06-19 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (findRangeBounds): New method override, + * tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java + (testFindRangeBounds): New test method. + +2008-06-18 David Gilbert + + * source/org/jfree/chart/title/PaintScaleLegend.java + (subdivisions): New field, + (PaintScaleLegend): Initialise new field, + (getSubdivisionCount): New method, + (setSubdivisionCount): Likewise, + (SUBDIVISIONS): Removed private field, + (draw): Modified segment calculations, + (equals): Updated for new field. + +2008-06-18 David Gilbert + + * source/org/jfree/chart/annotations/XYDrawableAnnotation.java + (drawScaleFactor): New field, + (width): Renamed displayWidth, + (height): Renamed displayHeight, + (XYDrawableAnnotation(double, double, double, double, double, Drawable)): + New constructor, + (draw): Apply scaling transform, + (equals): Check drawScaleFactor field, + (hashCode): Updated for renamed fields. + +2008-06-17 David Gilbert + + * source/org/jfree/chart/LegendItem.java + (labelFont): New field, + (labelPaint): Likewise, + (getLabelFont): New method, + (setLabelFont): Likewise, + (getLabelPaint): Likewise, + (setLabelPaint): Likewise, + (setFillPaint): Likewise, + (setLinePaint): Likewise, + (setOutlinePaint): Likewise, + (equals): Test new fields, + (writeObject): Handle new field, + (readObject): Likewise, + * source/org/jfree/chart/renderer/AbstractRenderer.java + (legendShape): New field, + (baseLegendShape): Likewise, + (legendTextFont): Likewise, + (baseLegendTextFont): Likewise, + (legendTextPaint): Likewise, + (baseLegendTextPaint): Likewise, + (AbstractRenderer): Initialise new fields, + (lookupLegendShape): New method, + (getLegendShape): Likewise, + (setLegendShape): Likewise, + (getBaseLegendShape): Likewise, + (setBaseLegendShape): Likewise, + (lookupLegendTextFont): Likewise, + (getLegendTextFont): Likewise, + (setLegendTextFont): Likewise, + (getBaseLegendTextFont): Likewise, + (setBaseLegendTextFont): Likewise, + (lookupLegendTextPaint): Likewise, + (getLegendTextPaint): Likewise, + (setLegendTextPaint): Likewise, + (getBaseLegendTextPaint): Likewise, + (setBaseLegendTextPaint): Likewise, + (equals): Handle new fields, + (clone): Likewise, + (writeObject): Likewise, + (readObject): Likewise, + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java, + * source/org/jfree/chart/renderer/category/AreaRenderer.java, + * source/org/jfree/chart/renderer/category/BarRenderer.java, + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java, + * source/org/jfree/chart/renderer/category/CategoryStepRenderer.java, + * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java, + * source/org/jfree/chart/renderer/category/ScatterRenderer.java, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java, + * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java, + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java, + * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java, + * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java, + * source/org/jfree/chart/renderer/xy/XYDotRenderer.java, + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java, + (getLegendItem): Use new legend attributes, + * source/org/jfree/chart/title/LegendTitle.java + (createLegendItemBlock): Pass new attributes to text block. + +2008-06-16 David Gilbert + + * source/org/jfree/chart/renderer/xy/HighLowRenderer.java + (drawItem): Call addEntity() method, + * source/org/jfree/chart/renderer/xy/YIntervalRenderer.java + (drawItem): Likewise. + +---------- JFREECHART 1.0.10 RELEASED ------------------------ + +2008-06-09 David Gilbert + + * source/org/jfree/chart/axis/DateTickUnit.java + (addToDate(Date)): Deprecated. + +2008-06-06 David Gilbert + + * source/org/jfree/data/time/Millisecond.java + (compareTo): Added handling for general RegularTimePeriod. + +2008-06-06 David Gilbert + + * source/org/jfree/chart/axis/Axis.java + (setTickLabelInsets(RectangleInsets)): Delegate to new method, + (setTickLabelInsets(RectangleInsets, boolean)): New method. + +2008-06-02 David Gilbert + + * source/org/jfree/data/time/SimpleTimePeriod.java + (start): Changed from Date to long, + (end): Likewise, + (getStartMillis): New method, + (getEndMillis): Likewise, + (getStart): Returns new date instance, + (getEnd): Likewise. + +2008-06-02 David Gilbert + + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java + (drawItem): Handle PlotOrientation.HORIZONTAL. + +2008-06-02 David Gilbert + + * source/org/jfree/chart/plot/SpiderWebPlot.java + (getLegendItems): Return early if dataset is null. + +2008-06-02 David Gilbert + + * source/org/jfree/chart/plot/SpiderWebPlot.java + (drawRadarPoly): Check dataExtractOrder when generating chart entities. + +2008-06-02 David Gilbert + + Patches by Henry Proudhon: + * swt/org/jfree/experimental/chart/swt/ChartComposite.java + (ChartComposite): Removed duplicate listener registration, + (paintControl): Switched horizontalAxisTrace and verticalAxisTrace, + (dispose): New method, + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + (transformsPool): New field, + (setBackground): Use color pool, + (setTransform): Use transform pool, + (transform): Likewise, + (disposeResourcePool): Clear the fontsPool and transformsPool, + (getSwtTransformFromPool): New method, + (toSwtTransform): Removed. + +2008-06-02 David Gilbert + + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (isPointInRect): New utility method, + * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java + (drawItem): Modified bounds check for inclusion of chart entity, + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (drawSecondaryPass): Modified bounds check for inclusion of chart entity. + +2008-05-28 David Gilbert + + * source/org/jfree/data/time/DateRange.java + (lowerDate): Changed from Date to long, + (upperDate): Likewise, + (DateRange(Date, Date)): Updated for field type change, + (DateRange(long, long)): Likewise, + (getLowerDate): Likewise, + (getUpperDate): Likewise, + (toString): Likewise, + * source/org/jfree/data/time/FixedMillisecond.java + (time): Changed from Date to long. + +2008-05-26 David Gilbert + + * source/org/jfree/chart/labels/AbstractXYItemLabelGenerator.java + (getNullYString): New method, + (equals): Check nullYString, + * source/org/jfree/chart/labels/IntervalXYItemLabelGenerator.java: + New file, + * source/org/jfree/chart/renderer/xy/YIntervalRenderer.java + (additionalItemLabelGenerator): New field, + (YIntervalRenderer): Initialise new field, + (getAdditionalItemLabelGenerator): New method, + (setAdditionalItemLabelGenerator): Likewise, + (drawItem): Added item label support, + (drawAdditionalItemLabel): New method, + (equals): New method override. + +2008-05-22 David Gilbert + + * source/org/jfree/data/statistics/HistogramDataset.java + (clone): Reimplemented. + +2008-05-22 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (calculateAxisSpace): Calculate space for range axes first, adjust the + plotArea then calculate the space for the domain axes. + +2008-05-14 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java + (drawItem): Use addEntity(). + +2008-05-14 David Gilbert + + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (addEntity): If area is null, take into account the plot orientation for + the generated hotspot, + * source/org/jfree/chart/renderer/xy/XYStepRenderer.java + (drawItem): Use addEntity(). + +2008-05-13 David Gilbert + + Bugs 1962467 and 1962472: + * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java + (drawItem): Use hotspot that includes high and low values, and use + addEntity() to add the chart entity. + +2008-05-12 David Gilbert + + * source/org/jfree/data/category/SlidingCategoryDataset.java: New class, + * source/org/jfree/data/gantt/SlidingGanttCategoryDatsaet.java: Likewise, + * tests/org/jfree/data/category/SlidingCategoryDatasetTests.java: + New tests, + * tests/org/jfree/data/gantt/SlidingGanttCategoryDatasetTests.java: + Likewise. + +2008-05-12 David Gilbert + + * source/org/jfree/data/gantt/TaskSeries.java + (clone): New method override, + * source/org/jfree/data/gantt/TaskSeriesCollection.java + (clone): Likewise. + +2008-05-11 David Gilbert + + * source/org/jfree/chart/block/EmptyBlock.java + (arrange): Use constraint. + +2008-05-09 David Gilbert + + * source/org/jfree/data/category/DefaultCategoryDataset.java: + Implemented PublicCloneable. + +2008-05-08 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (chartMouseListeners): Marked this field transient, + (chartBuffer): Likewise, + (writeObject): New method, + (readObject): Likewise. + +2008-05-08 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (zoomPoint): Changed from Point to Point2D, + (getPointInRectangle): Changed return type to Point2D, and no longer round + the coordinates in the returned point, + (mouseReleased): Tidied up for readability, + (restoreAutoDomainBounds): Updated for modified zoomPoint type, + (restoreAutoRangeBounds): Likewise. + +2008-05-07 David Gilbert + + * source/org/jfree/chart/renderer/category/BarRenderer.java + (drawItem): Ensure that minimumBarLength, if used, extends the non-base + end of the bar. + +2008-05-05 David Gilbert + + Patch 1924543 by Richard West: + * experimental/org/jfree/experimental/chart/demo/CombinedCategoryPlotDemo1.java: + New file, + * experimental/org/jfree/experimental/chart/demo/CombinedXYPlotDemo1.java: + Likewise, + * experimental/org/jfree/experimental/chart/plot/CombinedCategoryPlot.java: + Likewise, + * experimental/org/jfree/experimental/chart/plot/CombinedXYPlot.java: + Likewise. + +2008-05-05 David Gilbert + + * source/org/jfree/chart/title/ShortTextTitle.java: New file, + * tests/org/jfree/chart/title/junit/ShortTextTitleTests.java: Likewise. + +2008-05-01 David Gilbert + + Bug 1955483: + * source/org/jfree/data/xy/XYSeries.java + (addOrUpdate(Number, Number)): Add a new item if duplicates are allows, + (addOrUpdate(double, double)): New method. + +2008-04-29 David Gilbert + + * source/org/jfree/chart/renderer/xy/HighLowRenderer.java + (tickLength): New field, + (HighLowRenderer): Initialise new field, + (getTickLength): New method, + (setTickLength): Likewise, + (equals): Added check for new field. + +2008-04-28 David Gilbert + + * source/org/jfree/chart/title/TextTitle.java + (maximumLinesToDisplay): New field, + (getMaximumLinesToDisplay): New method, + (setMaximumLinesToDisplay): Likewise, + (arrangeFN): Pass maximumLinesToDisplay, + (arrangeRR): Likewise, + (equals): Added tests for additional fields. + +2008-04-28 David Gilbert + + Bug 1950037: + * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java + (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): + New method override, + * source/org/jfree/chart/plot/CombinedDomainXYPlot.java + (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): + New method override, + * source/org/jfree/chart/plot/CombinedRangeXYPlot.java + (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): + New method override. + +2008-04-23 David Gilbert + + Bug 1942059: + * source/org/jfree/chart/axis/CategoryAxis.java + (calculateTextBlockWidth): Use correct insets. + +2008-04-23 David Gilbert + + * source/org/jfree/chart/labels/BubbleXYItemLabelGenerator.java, + * source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java: + Implemented PublicCloneable. + +2008-04-23 David Gilbert + + * source/org/jfree/chart/LegendItemCollection.java + (clone): Reimplemented, + * source/org/jfree/chart/plot/CategoryPlot.java + (equals): Check additional fields, + (clone): Clone some internal structures. + +2008-04-23 David Gilbert + + * source/org/jfree/chart/LegendItem.java + (LegendItem(String)): New constructor, + (clone): Implemented. + +2008-04-23 David Gilbert + + * source/org/jfree/chart/annotations/CategoryLineAnnotation.java, + * source/org/jfree/chart/annotations/CategoryTextAnnotation.java: + Implemented PublicCloneable. + +2008-04-23 David Gilbert + + * source/org/jfree/chart/JFreeChart.java: + Added new contributor Diego Pierangeli, + * source/org/jfree/chart/urls/CustomCategoryURLGenerator.java: + New class, + * source/org/jfree/chart/urls/CustomXYURLGenerator.java + (addURLSeries): Copy the incoming list. + +2008-04-22 David Gilbert + + * source/org/jfree/chart/renderer/xy/VectorRenderer.java, + * source/org/jfree/chart/renderer/xy/XYBlockRenderer.java: + Implemented PublicCloneable. + +2008-04-22 David Gilbert + + * source/org/jfree/data/xy/DefaultHighLowDataset.java, + * source/org/jfree/data/xy/DefaultIntervalXYDataset.java, + * source/org/jfree/data/xy/DefaultWindDataset.java, + * source/org/jfree/data/xy/DefaultXYZDataset.java, + * source/org/jfree/data/xy/MatrixSeriesCollection.java, + * source/org/jfree/data/xy/VectorSeriesCollection.java, + * source/org/jfree/data/xy/XIntervalSeriesCollection.java, + * source/org/jfree/data/xy/XYBarDataset.java, + * source/org/jfree/data/xy/XYIntervalSeriesCollection.java, + * source/org/jfree/data/xy/XYSeriesCollection.java, + * source/org/jfree/data/xy/YIntervalSeriesCollection.java: + Implemented PublicCloneable. + +2008-04-22 David Gilbert + + * source/org/jfree/data/xy/DefaultTableXYDataset.java: + Implemented PublicCloneable, plus + (clone): New method override. + +2008-04-22 David Gilbert + + * source/org/jfree/data/xy/DefaultOHLCDataset.java: + Implemented PublicCloneable, plus + (clone): New method override. + +2008-04-22 David Gilbert + + * source/org/jfree/data/xy/CategoryTableXYDataset.java: + Implemented PublicCloneable, plus + (clone): New method override. + +2008-04-21 David Gilbert + + * source/org/jfree/chart/title/ImageTitle.java + (equals): New method override. + +2008-04-18 David Gilbert + + Patch 1943021 (Brian Cabana): + * source/org/jfree/chart/plot/MultiplePiePlot.java + (MultiplePiePlot(CategoryDataset)): Call setDataset() to ensure that + plot registers as a dataset listener, + * tests/org/jfree/chart/plot/junit/MultiplePiePlotTests.java + (testConstructors): New test method. + +2008-04-11 David Gilbert + + * source/org/jfree/chart/title/ImageTitle.java + (arrange): New method override to handle margin, border and padding, + * test/org/jfree/chart/title/junit/ImageTitleTests.java + (testArrangeNN): New test method. + +2008-04-11 David Gilbert + + * source/org/jfree/chart/urls/CustomXYURLGenerator.java + (clone): Implemented, + * tests/org/jfree/chart/urls/junit/CustomPieURLGeneratorTests.java: + New file, + * tests/org/jfree/chart/urls/junit/CustomXYURLGeneratorTests.java + (testEquals): New test method, + (testCloning): Likewise, + * tests/org/jfree/chart/urls/junit/UrlsPackageTests.java + (suite): Added CustomPieURLGeneratorTests. + +2008-04-11 David Gilbert + + * source/org/jfree/chart/renderer/xy/DeviationRenderer.java + (findRangeBounds): New method override, + * source/org/jfree/chart/renderer/xy/YIntervalRenderer.java + (findRangeBounds): Likewise. + +2008-04-10 David Gilbert + + * source/org/jfree/data/xy/XIntervalSeriesCollection.java + (getStartXValue): New method override, + (getEndXValue): Likewise. + +2008-04-10 David Gilbert + + * source/org/jfree/data/xy/XIntervalSeries.java + (getXLowValue): New method, + (getXHighValue): Likewise. + +2008-04-08 David Gilbert + + Bug 1932146: + * source/org/jfree/chart/axis/PeriodAxis.java + (setRange): Notify listeners, + * tests/org/jfree/chart/axis/junit/PeriodAxisTests.java + (lastEvent): New field, + (axisChanged): New method, + (test1932146): New test method. + +2008-04-08 David Gilbert + + * source/org/jfree/chart/renderer/xy/HighLowRenderer.java + (findRangeBounds): New method override. + +2008-04-08 David Gilbert + + * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java + (findRangeBounds): New method override, + * source/org/jfree/data/general/DatasetUtilities.java + (iterateRangeBounds(XYDataset)): Fixed typo for OHLCDataset. + +2008-04-08 David Gilbert + + * source/org/jfree/chart/block/BorderArrangement.java + (arrangeFF): Check for negative width remaining. + +2008-04-08 David Gilbert + + * source/org/jfree/chart/block/ColorBlock.java + (arrange): New method override, + (draw): Add code for margin, border and padding, + * source/org/jfree/chart/block/EmptyBlock.java + (arrange): New method override, + (draw(Graphics2D, Rectangle2D)): Delegate, + (draw(Graphics2D, Rectangle2D, Object)): New method override. + +2008-04-07 David Gilbert + + * source/org/jfree/data/time/TimePeriodValue.java + (toString): New method override, + * source/org/jfree/data/time/TimePeriodValues.java + (updateBounds): Update maxMiddleIndex correctly, + * tests/org/jfree/data/time/junit/TimePeriodValues.java + (testGetMinStartIndex): New test method, + (testGetMaxStartIndex): Likewise, + (testGetMinMiddleIndex): Likewise, + (testGetMaxMiddleIndex): Likewise, + (testGetMinEndIndex): Likewise, + (testGetMaxEndIndex): Likewise. + +2008-04-07 David Gilbert + + * source/org/jfree/chart/plot/CategoryPlot.java + (removeDomainMarker): Check for null collection, + (removeRangeMarker): Likewise, + * source/org/jfree/chart/plot/XYPlot.java + (removeDomainMarker): Check for null collection, + (removeRangeMarker): Likewise. + +2008-04-07 David Gilbert + + * source/org/jfree/data/DefaultKeyedValue.java + (equals): Simplified to reflect that this.key is never null. + +2008-04-07 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBlockRenderer.java + (drawItem): Inserted code to add entities. + +2008-03-31 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (equals): Updated for labelLinkStyle field. + +2008-03-31 David Gilbert + + Patch 1891849 by Martin Hilpert: + * source/org/jfree/chart/plot/PieLabelLinkStyle.java: New file, + * source/org/jfree/chart/plot/PiePlot.java + (labelLinkStyle): New field, + (getLabelLinkStyle): New method, + (setLabelLinkStyle): Likewise, + (drawLeftLabel): Added support for labelLinkStyle field, + (drawRightLabel): Likewise. + +2008-03-31 David Gilbert + + * source/org/jfree/chart/plot/PieLabelDistributor.java + (distributeLabels): Comment out adjustInwards() until it is working, + (adjustDownwards): Fix check for lower bound, + (adjustUpwards): Fix check for upper bound, + (distributeEvenly): Allow overlapping rather than exceeding bounds. + +2008-03-31 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (drawLeftLabels): Adjust label area for interiorGap, + (drawRightLabels): Likewise. + +2008-03-31 David Gilbert + + * source/org/jfree/chart/labels/HighLowItemLabelGenerator.java: + (hashCode): Implemented, + * source/org/jfree/chart/labels/MultipleXYSeriesLabelGenerator.java: + Likewise, + * source/org/jfree/chart/labels/StandardCategorySeriesLabelGenerator.java: + Likewise, + * source/org/jfree/chart/labels/StandardXYSeriesLabelGenerator.java: + Likewise, + * source/org/jfree/chart/labels/SymbolicXYItemLabelGenerator.java: + Likewise. + +2008-03-31 David Gilbert + + * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java + (getSubplots): Return null if this.subplots is null, + * source/org/jfree/chart/plot/CombinedDomainXYPlot.java: Likewise, + * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java: Likewise, + * source/org/jfree/chart/plot/CombinedRangeXYPlot.java: Likewise. + +2008-03-28 David Gilbert + + * source/org/jfree/data/general/DatasetUtilities.java + (iterateRangeBounds(CategoryDataset, boolean)): Modified implementation, + (iterateRangeBounds(XYDataset, boolean)): Likewise, + * tests/org/jfree/data/general/junit/DatasetUtilitiesTests.java + (testFindRangeBounds3): New test, + (testIterateCategoryRangeBounds): Renamed + testIterateRangeBounds_CategoryDataset(), + (testIterateRangeBounds2_CategoryDataset): New method, + (testIterateRangeBounds3_CategoryDataset): Likewise, + (testIterateXYRangeBounds): Renamed testIterateRangeBounds(), + (testIterateXYRangeBounds2): Renamed testIterateRangeBounds2(), + (testIterateRangeBounds3): New method, + (testIterateRangeBounds4): Likewise, + (testCumulativeRange3): Likewise, + (testSampleFunction2D): Likewise. + +2008-03-28 David Gilbert + + * source/org/jfree/data/general/DatasetUtilities.java + (iterateCategoryRangeBounds): Deprecated, + (iterateRangeBounds(CategoryDataset)): New method, + (iterateRangeBounds(CategoryDataset, boolean)): Likewise. + +2008-03-28 David Gilbert + + * source/org/jfree/data/general/DatasetUtilities.java + (findRangeBounds(XYDataset, boolean)): Use boolean argument for call to + iterateRangeBounds(), + (iterateXYRangeBounds): Deprecated, + (iterateRangeBounds(XYDataset)): New method, + (iterateRangeBounds(XYDataset, boolean)): Likewise. + +2008-03-28 David Gilbert + + * source/org/jfree/data/general/DatasetUtilities.java + (sampleFunction2D): Fixed sample count bug. + +2008-03-27 David Gilbert + + Bug 1927239: + * source/org/jfree/chart/renderer/category/WaterfallBarRenderer.java + (findRangeBounds): Reimplemented to account for the special treatment of + the value in the final category, + * source/org/jfree/data/general/DatasetUtilities.java + (findCumulativeRangeBounds): Include final category. + +2008-03-27 David Gilbert + + Bug 1926517: + * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java: + (getDataRange): Override just to document, + * source/org/jfree/chart/plot/CombinedDomainXYPlot.java + (getDataRange): Added javadoc comment, + * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java + (getDataRange): Likewise, + * source/org/jfree/chart/plot/CombinedRangeXYPlot.java + (getDataRange): Likewise. + +2008-03-27 David Gilbert + + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (drawHorizontalItem): Draw box outline using itemOutlinePaint/Stroke, + (drawVerticalItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java + (lookupBoxPaint): New method, + (drawHorizontalItem): Do lookup for box fill paint, + (drawVerticalItem): Likewise. + +2008-03-26 David Gilbert + + Patch 1918209: + * source/org/jfree/chart/axis/LogAxis.java + (createTickLabel): Changed from private to protected. + +2008-03-25 David Gilbert + + * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java + * source/org/jfree/chart/plot/CombinedDomainXYPlot.java + * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java + * source/org/jfree/chart/plot/CombinedRangeXYPlot.java + * source/org/jfree/chart/plot/CompassPlot.java + * source/org/jfree/chart/plot/ContourPlot.java + * source/org/jfree/chart/plot/MeterPlot.java + * source/org/jfree/chart/plot/MultiplePiePlot.java + * source/org/jfree/chart/plot/PiePlot.java + * source/org/jfree/chart/plot/PiePlot3D.java + * source/org/jfree/chart/plot/PolarPlot.java + * source/org/jfree/chart/plot/RingPlot.java + * source/org/jfree/chart/plot/SpiderWebPlot.java + * source/org/jfree/chart/plot/ThermometerPlot.java + * source/org/jfree/chart/plot/WaferMapPlot.java + Use fireChangeEvent() method all over. + +2008-03-25 David Gilbert + + Patch 1914411: + * source/org/jfree/chart/plot/Plot.java + (fireChangeEvent): New method, + * source/org/jfree/chart/plot/CategoryPlot.java + * source/org/jfree/chart/plot/FastScatterPlot.java + * source/org/jfree/chart/plot/XYPlot.java: + Use fireChangeEvent() method all over. + +2008-03-25 David Gilbert + + Patch 1913751: + * source/org/jfree/chart/plot/CategoryPlot.java + (addDomainMarker(int, CategoryMarker, Layer, boolean)): New method, + (removeDomainMarker(int, Marker, Layer, boolean)): Likewise, + (addRangeMarker(int, CategoryMarker, Layer, boolean)): Likewise, + (removeRangeMarker(int, Marker, Layer, boolean)): Likewise, + (addAnnotation(CategoryAnnotation, boolean)): Likewise, + (removeAnnotation(CategoryAnnotation, boolean)): Likewise. + +2008-03-25 David Gilbert + + Patch 1913751: + * source/org/jfree/chart/plot/XYPlot.java + (addDomainMarker(int, Marker, Layer, boolean)): New method, + (removeDomainMarker(int, Marker, Layer, boolean)): Likewise, + (addRangeMarker(int, Marker, Layer, boolean)): Likewise, + (removeRangeMarker(int, Marker, Layer, boolean)): Likewise, + (addAnnotation(XYAnnotation, boolean)): Likewise, + (removeAnnotation(XYAnnotation, boolean)): Likewise. + +2008-03-20 David Gilbert + + Bug 1920854: + * source/org/jfree/chart/plot/PiePlot3D.java + (draw): Move label drawing outside section loop. + +2008-03-19 David Gilbert + + Patch 1902418: + * source/org/jfree/chart/axis/LogAxis.java + (refreshTicksVertical): Change tick type for major tick labels. + +2008-03-19 David Gilbert + + * source/org/jfree/chart/plot/PiePlot3D.java + (getMaximumExplodePercent): Check for null dataset, + (initialise): Likewise, + * tests/org/jfree/chart/plot/junit/PiePlot3DTests.java + (testDrawWithNullDataset): New test method. + +2008-02-26 David Gilbert + + Patch 1901599: + * experimental/org/jfree/chart/annotations/XYTitleAnnotation.java + (draw): Check for null 'info' argument before adding entities, + (hashCode): Reimplemented, + * experimental/org/jfree/chart/annotations/junit/XYTitleAnnotationTests.java + (testDrawWithNullInfo): New test. + +2008-02-26 David Gilbert + + Bug 1897580: + * source/org/jfree/data/DefaultIntervalCategoryDataset.java + (DefaultIntervalCategoryDataset(Comparable[], Comparable[], Number[][], + Number[][]): Initialise seriesKeys and categoryKeys to empty arrays instead + of null for empty dataset, + (setCategoryKeys): Fixed argument check to handle empty dataset. + +2008-02-19 David Gilbert + + * org/jfree/chart/util/LogFormat.java + (powerLabel): New field, + (LogFormat(double, String, boolean)): Delegate to new constructor, + (LogFormat(double, String, String, boolean)): New constructor, + (format): Use new powerLabel, + (equals): New method override, + (clone): Likewise. + +2008-02-18 David Gilbert + + Bug 1880114: + * org/jfree/chart/renderer/xy/VectorRenderer.java + (drawItem): Modify arrow-head for plot orientation. + +2008-02-18 David Gilbert + + Patch 1871902 by Martin Hoeller: + * org/jfree/chart/plot/PolarPlot.java + (DEFAULT_ANGLE_TICK_UNIT_SIZE): New field, + (angleTickUnit): Likewise, + (PolarPlot(XYDataset, ValueAxis, PolarItemRenderer)): Initialise + angleTickUnit, + (getAngleTickUnit): New method, + (setAngleTickUnit): Likewise, + (refreshAngleTicks): Likewise, + (draw): Refresh angle tick list before drawing. + +2008-02-15 David Gilbert + + * org/jfree/data/DefaultKeyedValue.java + (DefaultKeyedValue(Comparable, Number)): Check for null key. + +2008-02-15 David Gilbert + + Patch 1868745: + * source/org/jfree/chart/axis/LogAxis.java + (refreshTicksHorizontal): Adjust label anchor according to axis position, + (refreshTicksVertical): Likewise. + +2008-02-15 David Gilbert + + Patch 1873328: + * source/org/jfree/chart/util/RelativeDateFormat.java + (showZeroHours): New field, + (positivePrefix): Likewise, + (RelativeDateFormat(long)): Initialise new fields, + (getShowZeroHours): New method, + (setShowZeroHours): Likewise, + (getPositivePrefix): Likewise, + (setPositivePrefix): Likewise, + (format): Apply positive prefix, and fix formatting for negative values, + (equals): Handle new fields, + (hashCode): Use positivePrefix. + +2008-02-15 David Gilbert + + Bug 1873160: + * source/org/jfree/chart/plot/DialPlot.java + (draw): Fix clipping issues. + +2008-02-14 David Gilbert + + Bug 1892419: + * source/org/jfree/chart/axis/LogAxis.java + (LogAxis(String)): Change default number of minor ticks. + +2008-02-14 David Gilbert + + Patch 1874890 (Ulrich Voigt with contributions from Martin Hoeller): + * source/org/jfree/chart/renderer/xy/XYStepRenderer.java + (stepPoint): New field, + (getStepPoint): New method, + (setStepPoint): Likewise, + (drawItem): Calculate step point using new field, + (drawLine): New private method, + (equals): New method override, + (hashCode): Likewise. + +2008-02-14 David Gilbert + + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (drawHorizontalItem): Call addEntity() to handle entity generation, + (drawVerticalItem): Likewise. + +2008-02-14 David Gilbert + + Patch 1888422 (Rob Van der Sanden): + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (drawHorizontalItem): Use correct data area dimension for series gap + calculation. + +2008-01-28 David Gilbert + + * source/org/jfree/chart/plot/CombinedDomainXYPlot.java + (draw): Reset fixed range axis space for subplots. + +2008-01-18 David Gilbert + + * source/org/jfree/data/xy/XIntervalSeriesCollection.java + (removeSeries(int)): New method, + (removeSeries(XIntervalSeries)): Likewise, + (removeAllSeries): Likewise, + * source/org/jfree/data/xy/XYIntervalSeriesCollection.java + (removeSeries(int)): New method, + (removeSeries(XYIntervalSeries)): Likewise, + (removeAllSeries): Likewise, + * source/org/jfree/data/xy/YIntervalSeriesCollection.java + (removeSeries(int)): New method, + (removeSeries(YIntervalSeries)): Likewise, + (removeAllSeries): Likewise. + +2008-01-18 David Gilbert + + * source/org/jfree/data/time/TimeSeriesCollection.java + (getSeries): Changed argument from String to Comparable. + +2008-01-15 David Gilbert + + Patch 1866446 (Rob Van der Sanden): + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (maximumBarWidth): New field, + (BoxAndWhiskerRenderer): Initialise new field, + (getMaximumBarWidth): New method, + (setMaximumBarWidth): Likewise, + (equals): Updated for new field, + * tests/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java + (testEquals): Updated to check new field. + +2008-01-10 David Gilbert + + Bug 1864222: + * source/org/jfree/data/time/TimeSeries.java + (createCopy(RegularTimePeriod, RegularTimePeriod)): Handle empty range, + * tests/org/jfree/data/time/junit/TimeSeriesTests.java + (testBug1864222): New test method. + +2008-01-10 David Gilbert + + Bug 1868521: + * source/org/jfree/chart/ChartUtilities.java + (writeChartAsJPEG): Create RGB image rather than ARGB. + +---------- JFREECHART 1.0.9 RELEASED ------------------------ + +2008-01-04 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (drawQuadrants): Fix painting error when quadrant origin is outside plot + area. + +2008-01-03 David Gilbert + + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (drawHorizontalItem): Check visibility of average marker, + (drawVerticalItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java + (drawHorizontalItem): Check visibility of average marker, + (drawVerticalItem): Likewise. + +2007-12-20 David Gilbert + + Fixes bug 1848961: + * source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java + (calculateBarW0): Use correct dataset index. + +2007-12-19 David Gilbert + + * source/org/jfree/data/time/Week.java + (Week(Date, TimeZone)): Hand on the zone, + * tests/org/jfree/data/time/junit/WeekTests.java + (testBug1448828): Control the default locale, + (testBug1498805): Likewise, + (testGetFirstMillisecondWithTimeZone): Control the default locale, and + modify expected result accordingly, + (testGetLastMillisecondWithTimeZone): Likewise. + +2007-12-19 David Gilbert + + * source/org/jfree/chart/title/TextTitle.java + (arrange): Implement additional options, + (arrangeNN): New method, + (arrangeFN): Likewise, + (arrangeRN): Likewise. + +2007-12-18 David Gilbert + + Committing for Sergei Ivanov: + * source/org/jfree/data/Range.java + (intersects(Range)): New method, + (expand): Handle special case for negative margins, + (shift): Added argument check, + (scale): New method, + * tests/org/jfree/data/junit/RangeTests.java + (testConstructor): New test, + (testHashCode): Likewise, + (testExpand): Additional checks, + (testShift): New test, + (testScale): Likewise. + +2007-12-18 David Gilbert + + * source/org/jfree/chart/plot/IntervalMarker.java + (IntervalMarker(double, double, Paint)): New constructor. + +2007-12-05 David Gilbert + + * source/org/jfree/chart/HashUtilities.java + (hashCode(int, BooleanList)): New method, + (hashCode(int, PaintList)): Likewise, + (hashCode(int, StrokeList)): Likewise. + +2007-12-05 David Gilbert + + * source/org/jfree/chart/entity/ChartEntity.java + (getImageMapAreaTag): Don't escape tooltips and urls, delegate that to + the tag generators, + * source/org/jfree/chart/imagemap/StandardURLTagFragmentGenerator.java + (generateURLFragment): Encode the url text, + * tests/org/jfree/chart/imagemap/junit/ImageMapPackageTests.java: New file, + * tests/org/jfree/chart/imagemap/junit/StandardToolTipTagFragmentGeneratorTests.java: + Likewise, + * tests/org/jfree/chart/imagemap/junit/StandardURLTagFragmentGeneratorTests.java: + Likewise. + +2007-12-05 David Gilbert + + * source/org/jfree/chart/JFreeChart.java + (setTitle): Handle listener registration, + * tests/org/jfree/chart/junit/JFreeChartTests.java + (testTitleChangeEvents): New test method. + +2007-12-04 David Gilbert + + * source/org/jfree/chart/imagemap/DynamicDriveToolTipFragmentGenerator.java + (generateToolTipFragment): Escape text, + * source/org/jfree/chart/imagemap/OverLIBToolTipFragmentGenerator.java + (generateToolTipFragment): Likewise, + * source/org/jfree/chart/imagemap/StandardToolTipFragmentGenerator.java + (generateToolTipFragment): Likewise, + * source/org/jfree/chart/imagemap/StandardURLTagFragmentGenerator.java + (generateURLFragment): Likewise. + +2007-12-04 David Gilbert + + * source/org/jfree/chart/renderer/AbstractRenderer.java + (hashCode): Compute using more fields. + +2007-12-04 David Gilbert + + * source/org/jfree/chart/JFreeChart.java + (createBufferedImage(int, int, ChartRenderingInfo)): Change image type, + (createBufferedImage(int, int, double, double, ChartRenderingInfo)): + Likewise. + +2007-12-04 David Gilbert + + Bugs 1363043 and 1840139: + * source/org/jfree/chart/entity/ChartEntity.java + (getImageMapAreaTag): Escape toolTipText and urlText, + * source/org/jfree/chart/imagemap/ImageMapUtilities.java + (getImageMap): Escape name, + (htmlEscape): New method. + +2007-12-04 David Gilbert + + Bug 1460195: + * source/org/jfree/chart/entity/ChartEntity.java + (getImageMapAreaTag): Add 'nohref' attribute when there is no URL. + +2007-12-03 David Gilbert + + * source/org/jfree/data/xy/XYSeriesCollection.java + (getSeries(Comparable)): New method, + * tests/org/jfree/data/xy/junit/XYSeriesCollectionTests.java + (testGetSeriesByKey): New test method. + +2007-11-30 David Gilbert + + * source/org/jfree/data/xy/XYDataItem.java + (getXValue): New method, + (getYValue): Likewise, + (toString): Likewise. + +2007-11-30 David Gilbert + + * source/org/jfree/chart/LocalizationBundle_it.properties: + Fixed errors. + +2007-11-29 David Gilbert + + * source/org/jfree/chart/plot/MeterPlot.java + (writeObject): Handle dialOutlinePaint, + (readObject): Likewise, + * tests/org/jfree/chart/plot/junit/MeterPlotTests.java + (testEquals): Updated to test dialOutlinePaint, + (testSerialization1): Likewise. + +2007-11-27 David Gilbert + + * source/org/jfree/data/ComparableObjectSeries.java + (clear): Changed from protected to public, + * source/org/jfree/data/xy/VectorSeries.java + (clear): Removed, + * tests/org/jfree/data/time/ohlc/junit/OHLCSeriesTests.java + (testClear): New test method, + * tests/org/jfree/data/xy/junit/VectorSeriesTests.java + (testClear): Likewise, + * tests/org/jfree/data/xy/junit/XIntervalSeriesTests.java + (testClear): Likewise, + * tests/org/jfree/data/xy/junit/XYIntervalSeriesTests.java + (testClear): Likewise, + * tests/org/jfree/data/xy/junit/YIntervalSeriesTests.java + (testClear): Likewise. + +2007-11-27 David Gilbert + + * source/org/jfree/chart/plot/CombinedDomainXYPlot.java + (setFixedRangeAxisSpaceForSubplots): Call new method in XYPlot, + * source/org/jfree/chart/plot/CombinedRangeXYPlot.java + (setFixedDomainAxisSpaceForSubplots): Likewise, + * source/org/jfree/chart/plot/XYPlot.java + (setFixedDomainAxisSpace(AxisSpace)): Delegate to new method, + (setFixedDomainAxisSpace(AxisSpace, boolean)): New method, + (setFixedRangeAxisSpace(AxisSpace)): Delegate to new method, + (setFixedRangeAxisSpace(AxisSpace, boolean)): New method. + +2007-11-27 David Gilbert + + * swt/org/jfree/experimental/swt/SWTGraphics2D.java: + (drawImage(BufferedImage, BufferedImageOp, int, int)): Updated for method + moved to SWTUtils, + (drawImage(Image, int, int, ImageObserver)): Implemented, + (drawImage(Image, int, int, int, int, ImageObserver)): Likewise, + (drawImage(Image, int, int, Color, ImageObserver)): Likewise, + (drawImage(Image, int, int, int, int, Color, ImageObserver)): Likewise, + (convertToSWT(BufferedImage)): Moved to SWTUtils.java, + * swt/org/jfree/experimental/swt/SWTUtils.java: + (convertAWTImageToSWT): New method, + (convertToSWT(BufferedImage)): Moved from SWTGraphics2D.java. + +---------- JFREECHART 1.0.8 RELEASED ------------------------ + +2007-11-23 David Gilbert + + * source/org/jfree/chart/plot/dial/DialPointer.java + (Pointer.fillPaint): New attribute, + (Pointer.outlinePaint): Likewise, + (Pointer(int)): Initialize new fields, + (getFillPaint): New method, + (setFillPaint): Likewise, + (getOutlinePaint): Likewise, + (setOutlinePaint): Likewise, + (draw): Use new attributes, + (equals): Check new fields, + (hashCode): Likewise, + (writeObject): Handle serialization for new fields, + (readObject): Likewise, + * tests/org/jfree/chart/plot/dial/junit/DialPointerTests.java + (testEqualsPointer): New test method, + (testSerialization2): Likewise. + +2007-11-22 David Gilbert + + * source/org/jfree/chart/HashUtilities.java + (hashCode(int, int)): New method, + * source/org/jfree/chart/needle/ArrowNeedle.java + * source/org/jfree/chart/needle/LineNeedle.java + * source/org/jfree/chart/needle/LongNeedle.java + * source/org/jfree/chart/needle/MeterNeedle.java + * source/org/jfree/chart/needle/MiddlePinNeedle.java + * source/org/jfree/chart/needle/PinNeedle.java + * source/org/jfree/chart/needle/PlumNeedle.java + * source/org/jfree/chart/needle/PointerNeedle.java + * source/org/jfree/chart/needle/ShipNeedle.java + * source/org/jfree/chart/needle/WindNeedle.java: + Implemented hashCode() method. + +2007-11-22 David Gilbert + + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java + * source/org/jfree/chart/renderer/xy/DeviationRenderer.java + * source/org/jfree/chart/renderer/xy/HighLowRenderer.java + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java + * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java + * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java + * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + * source/org/jfree/chart/renderer/xy/XYBlockRenderer.java + * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java + * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java + * source/org/jfree/chart/renderer/xy/XYDotRenderer.java + * source/org/jfree/chart/renderer/xy/XYErrormRenderer.java + * source/org/jfree/chart/renderer/xy/XYLine3DRenderer.java + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + * source/org/jfree/chart/renderer/xy/XYSplineRenderer.java + * source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java: + Replaced calls to notifyListeners() with fireChangeEvent(). + +2007-11-22 David Gilbert + + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + * source/org/jfree/chart/renderer/category/AreaRenderer.java + * source/org/jfree/chart/renderer/category/BarRenderer.java + * source/org/jfree/chart/renderer/category/BarRenderer3D.java + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + * source/org/jfree/chart/renderer/category/CategoryStepRenderer.java + * source/org/jfree/chart/renderer/category/GanttRenderer.java + * source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java + * source/org/jfree/chart/renderer/category/LevelRenderer.java + * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java + * source/org/jfree/chart/renderer/category/LineRenderer3D.java + * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java + * source/org/jfree/chart/renderer/category/ScatterRenderer.java + * source/org/jfree/chart/renderer/category/StackedAreaRenderer.java + * source/org/jfree/chart/renderer/category/StackedBarRenderer.java + * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java + * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java + * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java: + Replaced calls to notifyListeners() with fireChangeEvent(). + +2007-11-22 David Gilbert + + * source/org/jfree/data/xy/XYSeries.java + (clone): Reimplemented, + * tests/org/jfree/data/xy/junit/XYSeriesTests.java + (testCloning2): New method, + (testCloning3): Likewise. + +2007-11-21 David Gilbert + + * source/org/jfree/data/DefaultKeyedValues.java + (removeValue): Always rebuild index, + * source/org/jfree/data/DefaultKeyedValues2D.java + (removeColumn(Comparable)): Added argument checks, and protect against + rows not containing the specified key, + * tests/org/jfree/data/category/junit/DefaultCategoryDatasetTests.java + (testBug1835955): New method, + * tests/org/jfree/data/junit/DefaultKeyedValues2DTests.java + (testRemoveColumnByKey): New method, + * tests/org/jfree/data/junit/DefaultKeyedValuesTests.java + (testGetIndex2): New method. + +2007-11-21 David Gilbert + + Fix for bug 1832432: + * source/org/jfree/data/time/TimeSeries.java + (clone): Reimplemented. + +2007-11-21 David Gilbert + + * source/org/jfree/chart/plot/DatasetRenderingOrder.java + (hashCode): Implemented, + * source/org/jfree/chart/plot/DialShape.java + (hashCode): Likewise, + * source/org/jfree/chart/plot/PlotOrientation.java + (hashCode): Likewise, + * source/org/jfree/chart/plot/SeriesRenderingOrder.java + (hashCode): Likewise. + +2007-11-21 David Gilbert + + * source/org/jfree/chart/axis/DateAxis.java + (previousStandardDate): Return dates already fetched. + +2007-11-21 David Gilbert + + * source/org/jfree/chart/renderer/CategoryAxis.java + (equalPaintMaps): Use entrySet rather than keySet. + +2007-11-21 David Gilbert + + * source/org/jfree/chart/renderer/PieLabelRecord.java + (equals): Implemented. + +2007-11-21 David Gilbert + + * source/org/jfree/chart/renderer/Outlier.java + (equals): Implemented. + +2007-11-21 David Gilbert + + * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java + (shapesFilled): Deprecated, + (getShapesFilled): Likewise, + (setShapesFilled): Likewise, + (setBaseShapesVisible): Call fireChangeEvent() instead of notifyListeners(), + (setPlotLines): Likewise, + (setGapThresholdType): Likewise, + (setGapThreshold): Likewise, + (setPlotImages): Likewise, + (setLegendLine): Likewise. + +2007-11-21 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (DEFAULT_INTERIOR_GAP): Modified default value, + (maximumLabelWidth): Likewise, + (labelGap): Likewise, + (labelLinkMargin): Likewise, + (DEBUG_DRAW_INTERIOR): New debug flag, + (DEBUG_DRAW_LINK_AREA): Likewise, + (DEBUG_DRAW_PIE_AREA): Likewise, + (PiePlot(PieDataset)): Removed background paint setting, + (drawPie): Modified label position calculations and added debug code, + (drawLabels): Modified label width calculation, + * source/org/jfree/chart/plot/PiePlot3D.java + (depthFactor): Changed default value, + (draw): Modified chart dimension calculations and added debug code, in line + with changes made to the PiePlot class. + +2007-11-19 David Gilbert + + * source/org/jfree/chart/plot/dial/StandardDialScale.java + (getLowerBound): New method, + (setLowerBound): Likewise, + (getUpperBound): Likewise, + (setUpperBound): Likewise, + (getMinorTickStroke): Likewise, + (setMinorTickStroke): Likewise. + +2007-11-14 David Gilbert + + * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java + (errorIndicatorStroke): New field, + (StatisticalBarRenderer): Initialise new field, + (getErrorIndicatorStroke): New method, + (setErrorIndicatorStroke): Likewise, + (drawHorizontalItem): Fix drawBarOutline and gradientPaintTransformer + omissions, and use new errorIndicatorStroke field, + (drawVerticalItem): Likewise, + (equals): Updated for new field, + (writeObject): Likewise, + (readObject): Likewise. + +---------- JFREECHART 1.0.7 RELEASED ------------------------ + +2007-11-14 David Gilbert + + * swt/org/jfree/experimental/chart/swt/ChartComposite.java + (ChartComposite): Create canvas with SWT.DOUBLE_BUFFERED, + (getChartRenderingInfo): New method, + (isDomainZoomable): Likewise, + (setDomainZoomable): Likewise, + (isRangeZoomable): Likewise, + (setRangeZoomable): Likewise. + +2007-11-14 David Gilbert + + * source/org/jfree/chart/plot/CategoryPlot.java + (setWeight): Fire change event, + (setFixedDomainAxisSpace(AxisSpace)): Delegate to new method, + (setFixedDomainAxisSpace(AxisSpace, boolean)): New method, + (setFixedRangeAxisSpace(AxisSpace)): Delegate to new method, + (setFixedRangeAxisSpace(AxisSpace, boolean)): New method, + * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java + (setFixedRangeAxisSpaceForSubplots): Updated, + * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java + (setFixedDomainAxisSpaceForSubplots): Updated. + +2007-11-13 David Gilbert + + * source/org/jfere/chart/HashUtilities.java + (hashCode(int, Comparable)): New method, + * source/org/jfree/chart/entity/CategoryLabelEntity.java + (equals): New method, + (hashCode): Likewise. + +2007-11-13 David Gilbert + + * source/org/jfree/chart/axis/ModuloAxis.java + (equals): Implemented. + +2007-11-13 David Gilbert + + * source/org/jfree/chart/entity/ChartEntity.java + (hashCode): Implemented, + * source/org/jfree/chart/entity/PieSectionEntity.java + (equals): Implemented, + (hashCode): Likewise. + +2007-11-13 David Gilbert + + * source/org/jfree/chart/HashUtilities.java + (hashCode(int, boolean)): New method, + (hashCode(int, double)): Likewise, + (hashCode(int, Paint)): Likewise, + (hashCode(int, Stroke)): Likewise, + (hashCode(int, String)): Likewise. + +2007-11-13 David Gilbert + + * source/org/jfree/chart/plot/dial/AbstractDialLayer.java + (hashCode): Implemented. + +2007-11-12 David Gilbert + + * source/org/jfree/data/statistics/DefaultBoxAndWhiskerXYDataset.java + (add): Fire dataset change event, + (getY): Removed redundant constructor call, + (equals): New method override, + (clone): Likewise. + +2007-11-12 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (equals): Added check for domain/rangeTickBandPaint, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (fillDomainGridBand): Handle plot orientation properly, + (fillRangeGridBand): Likewise. + +2007-11-12 David Gilbert + + Patch 1827829 from Richard West: + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (drawItemLabel): Fixed NPE. + +2007-11-12 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java + (drawItem): Simplified entity generation, + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (drawItem): Likewise. + +2007-11-09 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYDotRenderer.java + (legendShape): New field, + (XYDotRenderer): Initialise new field, + (getLegendShape): New method, + (setLegendShape): Likewise, + (getLegendItem): New method override, + (equals): Updated for new field, + (readObject): New method, + (writeObject): New method. + +2007-11-07 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (paintComponent): Clear refreshBuffer flag before drawing chart. + +2007-11-06 David Gilbert + + * source/org/jfree/data/statistics/DefaultMultiValueCategoryDataset.java + (getValues): Return EMPTY_LIST rather than null. + +2007-11-05 David Gilbert + + * source/org/jfree/data/time/TimeSeries.java + (TimeSeries(String)): Changed first argument to Comparable, + (TimeSeries(String, Class)): Likewise, + (TimeSeries(String, String, String, Class)): Likewise. + +2007-11-05 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (setFixedDomainAxisSpace): Fire change event, + (setFixedRangeAxisSpace): Likewise. + +2007-11-05 David Gilbert + + Patch 1823724 by Richard West: + * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java + (drawItemPass1): Add code to draw item labels. + +2007-11-05 David Gilbert + + Patch 1823697 by Richard West: + * source/org/jfree/chart/plot/XYPlot.java + (removeDomainMarker(Marker)): New method, + (removeDomainMarker(Marker, Layer)): Likewise, + (removeDomainMarker(int, Marker, Layer)): Likewise, + (removeRangeMarker(Marker)): New method, + (removeRangeMarker(Marker, Layer)): Likewise, + (removeRangeMarker(int, Marker, Layer)): Likewise. + +2007-11-05 David Gilbert + + Patch 1823697 by Richard West: + * source/org/jfree/chart/plot/CategoryPlot.java + (removeDomainMarker(Marker)): New method, + (removeDomainMarker(Marker, Layer)): Likewise, + (removeDomainMarker(int, Marker, Layer)): Likewise, + (removeRangeMarker(Marker)): New method, + (removeRangeMarker(Marker, Layer)): Likewise, + (removeRangeMarker(int, Marker, Layer)): Likewise. + +2007-10-31 David Gilbert + + * source/org/jfree/data/DefaultKeyedValues.java + (data): Removed, + (keys): New field, + (values): Likewise, + (indexMap): New field, + (DefaultKeyedValues): Initialise new fields, + (getItemCount): Use new data fields, + (getValue(int)): Likewise, + (getKey(int)): Likewise, + (getIndex(Comparable)): Likewise, + (getKeys): Likewise, + (setValue(Comparable, Number)): Likewise, + (insertValue): Likewise, + (rebuildIndex): Likewise, + (removeValue): Likewise, + (clear): Likewise, + (sortByKeys): Likewise, + (sortByValue): Likewise, + (hashCode): Likewise, + (clone): Likewise. + +2007-10-31 David Gilbert + + * source/org/jfree/data/ComparableObjectSeries.java + (hashCode): Faster implementation, + * source/org/jfree/data/time/TimeSeries.java + (hashCode): Likewise, + * source/org/jfree/data/xy/XYSeriesTests.java + (hashCode): Likewise. + +2007-10-29 David Gilbert + + * source/org/jfree/chart/plot/dial/SimpleDialFrame.java: + Renamed StandardDialFrame.java. + +2007-10-26 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (linesVisible): Deprecated, + (shapesVisible): Likewise, + (shapesFilled): Likewise, + (getLinesVisible): Likewise, + (setLinesVisible): Likewise, + (getShapesVisible): Likewise, + (setShapesVisible): Likewise, + (setShapesFilled): Likewise. + +2007-10-25 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYSplineAndShapeRenderer.java: + Renamed XYSplineRenderer. + +2007-10-25 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYSplineAndShapeRenderer.java + (drawPrimaryLineAsPath): Check for duplicated control points, + (ControlPoint.equals): New method override. + +2007-10-25 David Gilbert + + * source/org/jfree/chart/plot/CategoryPlot.java + (getDomainAxisIndex): Added argument check, + (getRangeAxisIndex): Likewise. + +2007-10-25 David Gilbert + + * source/org/jfree/chart/axis/StandardTickUnitSource.java: + Implemented Serializable, + (StandardTickUnitSource): Added explicit constructor, + (equals): New method override, + (hashCode): Likewise. + +2007-10-25 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (defaultDirectoryForSaveAs): New field, + (ChartPanel(JFreeChart, int, int, int, int, int, int, boolean, boolean, + boolean, boolean, boolean, boolean)): Initialise new field, + (getDefaultDirectoryForSaveAs): New method, + (setDefaultDirectoryForSaveAs): Likewise, + (doSaveAs): Apply default directory. + +2007-10-24 David Gilbert + + * experimenta/org/jfree/experimental/chart/plot/dial/*.java: + Moved this package to org.jfree.chart.plot.dial.*, + * experimenta/org/jfree/experimental/chart/plot/dial/junit/*.java: + Moved this package to org.jfree.chart.plot.dial.junit.*. + +2007-10-24 David Gilbert + + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialFrame.java: + Removed and renamed ArcDialFrame.java, + * experimental/org/jfree/experimental/chart/plot/dial/ArcDialFrame.java: + New file. + +2007-10-24 David Gilbert + + * experimental/org/jfree/experimental/chart/plot/dial/DialPlot.java + (pointers): New field, + (DialPlot): Delegate to new constructor, + (DialPlot(ValueDataset)): New constructor, + (addPointer): New method, + (getPointerIndex): Likewise, + (removePointer(int)): Likewise, + (removePointer(DialPointer)): Likewise, + (getPointerForDataset): Likewise, + (draw): Draw pointers in their own layer, + (equals): Check new pointers field, + * experimental/org/jfree/experimental/chart/plot/dial/DialPointer.java: + Implemented PublicCloneable, + (DialPointer): Changed to protected, + (DialPointer(int)): Likewise, and changed default radius, + (Pin.setPaint): Added argument check, + (Pin.setStroke): Likewise, + (Pointer(int)): Removed radius setting, + * experimental/org/jfree/experimental/chart/plot/dial/DialTextAnnotation.java + (getAnchor): New method, + (setAnchor): Likewise, + * experimental/org/jfree/experimental/chart/plot/dial/DialValueIndicator.java + (DialValueIndicator): New constructor, + (DialValueIndicator(int, String)): Removed string argument, + (setDatasetIndex): Fire change event, + (setTemplateValue): Check for null argument, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialFrame.java + (setInnerRadius): Added argument check, + (setOuterRadius): Likewise, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialRange.java + (scaleIndex): New field, + (StandardDialRange(double, double)): Added field initialisations, + (getScaleIndex): New method, + (setScaleIndex): Likewise, + (draw): Get the correct scale, + (equals): Updated for new field, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialScale.java + (minorTickPaint): New field, + (minorTickStroke): Likewise, + (tickLabelFormatter): Likewise, + (StandardDialScale): Updated for modified constructor signature, + (StandardDialScale(double, double, double, double)): Added two new + arguments to signature, + (setMajorTickLength): Added argument check, + (setMinorTickCount): Likewise, + (setMinorTickLength): Likewise, + (getMinorTickPaint): New method, + (setMinorTickPaint): Likewise, + (getTickLabelFormatter): Likewise, + (setTickLabelFormatter): Likewise, + (draw): Fix major tick length, format labels with new formatter, + (equals): Updated for new fields, + (hashCode): Implemented, + (writeObject): Handle new fields, + (readObject): Likewise. + +2007-10-23 David Gilbert + + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + (drawRoundRect): Implemented, + (fillRoundRect): Likewise, + (clearRect): Implemented. + +2007-10-23 David Gilbert + + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + (drawArc): Implemented, + (fillArc): Likewise. + +2007-10-23 David Gilbert + + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + (drawOval): Implemented, + (fillOval): Likewise. + +2007-10-23 David Gilbert + + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + (drawPolyline): Implemented. + +2007-10-23 David Gilbert + + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + (drawPolygon): Implemented. + +2007-10-23 David Gilbert + + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + (hints): New field, + (SWTGraphics2D): Initialise new field, + (getRenderingHint): Implemented, + (setRenderingHint): Likewise, + (getRenderingHints): Likewise, + (addRenderingHints): Likewise, + (setRenderingHints): Likewise. + +2007-10-23 David Gilbert + + * source/org/jfree/chart/renderer/AbstractRenderer.java + (lookupSeriesPaint): Call accessor methods for per-series paint, + (lookupSeriesFillPaint): Likewise, + (lookupSeriesOutlinePaint): Likewise, + (lookupSeriesStroke): Likewise, + (lookupSeriesOutlineStroke): Likewise, + (lookupSeriesStroke): Likewise. + +2007-10-22 Henry Proudhon + + * source/swt/org/jfree/experimental/chart/swt/ChartComposite.java: + (chart): Made the chart field be private again, + (ChartComposite): Refactored class, now implements PaintListener, + MouseListener and MouseMovedListener, + (zoom): Fixed bug with multiple plots, + (addChartMouseListener): Implemented, + (removeChartMouseListener): Likewise, + (restoreAutoDomainBounds): Fixed NPE, + (restoreAutoRangeBounds): Likewise, + (widgetDefaultSelected): Implemented, + (addSWTListener): New method, + (mouseDoubleClick): Likewise, + (mouseDown): Likewise, + (mouseUp): Likewise, + (mouseMove): Likewise, + (paintControl): Likewise, + * source/swt/org/jfree/experimental/swt/SWTUtils.java + (toAwtMouseEvent): changed method signature. + +2007-10-22 Henry Proudhon + + * source/swt/org/jfree/experimental/swt/SWTUtils.java + (toAwtMouseEvent): Improved mouse event conversion. + +2007-10-22 Henry Proudhon + + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + (composite): New field, + (setComposite): Implemented, + (getComposite): Return from field. + +2007-10-22 Henry Proudhon + + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + (getClip): Implemented. + +2007-10-17 David Gilbert + + * experimental/org/jfree/experimental/chart/plot/dial/AbstractDialLayer.java + (equals): New method override, + (clone): Likewise, + * experimental/org/jfree/experimental/chart/plot/dial/DialBackground.java + (equals): Added call to super.equals(); + * experimental/org/jfree/experimental/chart/plot/dial/DialCap.java + (equals): Added call to super.equals(); + * experimental/org/jfree/experimental/chart/plot/dial/DialPlot.java + (setBackground): Fix listener registration, + (setCap): Likewise, + (setDialFrame): Likewise, + (addLayer): Likewise, + (getLayerIndex(DialLayer)): New method, + (removeLayer(int)): Likewise, + (removeLayer(DialLayer)): Likewise, + (addScale): Fix listener registration, + * experimental/org/jfree/experimental/chart/plot/dial/DialPointer.java + (equals): New method override, + (Pin.equals): Likewise, + (Pin.readObject): New method, + (Pin.writeObject): Likewise, + (Pointer.equals): New method override, + * experimental/org/jfree/experimental/chart/plot/dial/DialScale.java: + Now extends DialLayer, + * experimental/org/jfree/experimental/chart/plot/dial/DialTextAnnotation.java + (equals): Added call to super.equals(); + * experimental/org/jfree/experimental/chart/plot/dial/DialValueIndicator.java + (equals): Added call to super.equals(); + * experimental/org/jfree/experimental/chart/plot/dial/SimpleDialFrame.java + (equals): Added call to super.equals(); + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialFrame.java + (equals): Added call to super.equals(); + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialRange.java + (increment): Removed field, + (setLowerBound): Added argument check, + (setUpperBound): Likewise, + (setBounds): New method, + (equals): Updated, + (hashCode): Likewise, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialScale.java + (setTickRadius): Added argument check, + (setMajorTickIncrement): Likewise, + (setTickLabelPaint): Likewise, + (equals): Updated. + +2007-10-16 David Gilbert + + * source/org/jfree/chart/labels/AbstractXYItemLabelGenerator.java: + (nullXString): Removed, + (createItemArray): Removed check for null x-value. + +2007-10-16 David Gilbert + + * source/org/jfree/chart/renderer/category/BarRenderer3D.java + (drawRangeMarker): Use adjusted data area; + * source/org/jfree/chart/renderer/category/LineRenderer3D.java + (drawRangeMarker): Use adjusted data area, and call super to handle + IntervalMarker (DG); + +2007-10-11 David Gilbert + + * source/org/jfree/chart/renderer/category/MultiValueRenderer.java: + Renamed ScatterRenderer.java; + * tests/org/jfree/chart/renderer/category/junit/MultiValueRendererTests.java: + Renamed ScatterRendererTests.java. + +2007-10-11 David Gilbert + + * source/org/jfree/chart/plot/ThermometerPlot.java + (DEFAULT_GAP_RADIUS): Renamed DEFAULT_GAP, + (gapRadius): Renamed gap, + (getGapRadius): Renamed getGap(), + (setGapRadius): Renamed setGap(), + (getGapDiameter): Removed, + (draw): Updated for method name changes, + (equals): Likewise. + +2007-10-08 David Gilbert + + Based on Patch 1769088: + * source/org/jfree/chart/plot/ThermometerPlot.java + (BULB_RADIUS): Deprecated, + (BULB_DIAMETER): Likewise, + (COLUMN_RADIUS): Likewise, + (COLUMN_DIAMETER): Likewise, + (GAP_RADIUS): Likewise, + (GAP_DIAMETER): Likewise, + (bulbRadius): New field, + (columnRadius): Likewise, + (gapRadius): Likewise, + (getBulbRadius): New method, + (setBulbRadius): Likewise, + (getBulbDiameter): Likewise, + (getColumnRadius): Likewise, + (setColumnRadius): Likewise, + (getColumnDiameter): Likewise, + (getGapRadius): Likewise, + (setGapRadius): Likewise, + (getGapDiameter): Likewise, + (draw): Use attributes rather than constants, + (equals): Updated for new fields, + * tests/org/jfree/chart/plot/junit/ThermometerPlotTests.java + (testEquals): Updated for new fields. + +2007-10-08 David Gilbert + + * source/org/jfree/chart/renderer/category/MultiShapeRenderer.java: + New file, + * source/org/jfree/data/statistics/DefaultMultiValueCategoryDataset.java: + Likewise, + * source/org/jfree/data/statistics/MultiValueCategoryDataset.java: + Likewise, + * tests/org/jfree/chart/renderer/category/junit/MultiShapeRendererTests.java: + Likewise, + * tests/org/jfree/chart/renderer/category/junit/RendererCategoryPackageTests.java + (suite): Added MultiShapeRendererTests, + * tests/org/jfree/data/statistics/junit/DataStatisticsPackageTests.java + (suite): Added DefaultMultiValueCategoryDatasetTests, + * tests/org/jfree/data/statistics/junit/DefaultMultiValueCategoryDatasetTests.java: + New file. + +2007-10-08 David Gilbert + + * source/org/jfree/chart/plot/ValueMarker.java + (ValueMarker(double, Paint, Stroke, Paint, Stroke, float)): Fixed call + to super, + * tests/org/jfree/chart/plot/junit/ValueMarkerTests.java + (test1808376): New test method. + +2007-10-08 David Gilbert + + * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java + (volumePaint): New field, + (CandlestickRenderer(double, boolean, XYToolTipGenerator)): Initialise new + field, + (getVolumePaint): New method, + (setVolumePaint): Likewise, + (drawItem): Use new paint attribute, + (equals): Add check for new field, + (writeObject): Handle serialization for new field, + (readObject): Likewise, + * tests/org/jfree/chart/renderer/xy/junit/CandlestickRendererTests.java + (EPSILON): New field, + (testConstructor): New method, + (testEquals): Added check for new field. + +2007-10-05 David Gilbert + + Based on patch 1805262 by Alex Moots: + * source/org/jfree/chart/plot/PiePlot3D.java + (darkerSides): New field, + (getDarkerSides): New method, + (setDarkerSides): Likewise, + (drawSide): Make side colour darker if necessary, + (equals): Updated for new field, + * tests/org/jfree/chart/plot/junit/PiePlot3DTests.java + (testEquals): Updated for new field. + +2007-10-03 David Gilbert + + * source/org/jfree/data/KeyedObjects2D.java + (getRowIndex): Check for null argument, + (getColumnIndex): Likewise, + (removeObject): Check for unknown keys, + (clear): New method, + * source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java + (rangeBounds): Removed, + (DefaultBoxAndWhiskerCategoryDataset()): Updated for removed field, + (add(BoxAndWhiskerItem, Comparable, Comparable)): Likewise, + (remove(Comparable, Comparable)): New method, + (removeRow(int)): Likewise, + (removeRow(Comparable)): Likewise, + (removeColumn(int)): Likewise, + (removeColumn(Comparable)): Likewise, + (clear): Likewise, + (getRangeBounds): Return new instance every time, + * source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.java + (remove(Comparable, Comparable)): New method, + (removeRow(int)): Likewise, + (removeRow(Comparable)): Likewise, + (removeColumn(int)): Likewise, + (removeColumn(Comparable)): Likewise, + (clear): Likewise, + (getRangeBounds): Return new instance every time, + * tests/org/jfree/data/statistics/junit/DefaultBoxAndWhiskerCategoryDatasetTests.java + (testRemove): New method, + * tests/org/jfree/data/statistics/junit/DefaultStatisticalCategoryDatasetTests.java + (testRemove): New method. + +2007-10-03 David Gilbert + + * source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java + (add(BoxAndWhiskerItem, Comparable, Comparable)): Update cached bounds by + iteration if necessary, + (updateBounds): New private method, + * tests/org/jfree/data/statistics/junit/DefaultBoxAndWhiskerCategoryDatasetTests.java + (testGetRangeBounds): New test method. + +2007-10-03 David Gilbert + + * source/org/jfree/data/KeyedObjects2D.java + (getObject(Comparable, Comparable)): Check arguments for null or + unrecognised keys, + (setObject(Object, Comparable, Comparable): Check for null arguments, + (removeObject): Check if row or column needs removing, + (removeRow(Comparable)): Check for unrecognised key, + (removeColumn(Comparable)): Likewise, + * tests/org/jfree/data/junit/KeyedObjects2DTests.java + (testGetValueByIndex): New test method, + (testGetValueByKey): Likewise, + (testSetObject): Likewise, + (testRemoveRowByIndex): Likewise, + (testRemoveColumnByIndex): Likewise, + (testRemoveRowByKey): Likewise, + (testRemoveColumnByKey): Likewise, + (testRemoveValue): Likewise. + +2007-10-03 David Gilbert + + * source/org/jfree/data/DefaultKeyedValues.java + (removeValue(Comparable)): Throw UnknownKeyException for unrecognised key, + * source/org/jfree/data/KeyedObjects.java + (getObject(int)): Allow IndexOutOfBoundsException to be thrown, + (getKey(int)): Likewise, + (getIndex): Check for null argument, + (getObject): Throw UnknownKeyException for unrecognised key, + (insertValue): New method, + (removeValue): Throw UnknownKeyException for unrecognised key, + (clear): New method, + (hashCode): Likewise, + * source/org/jfree/data/KeyedObjects2D.java + (getObject): Check for missing key in underlying data structure, + * tests/org/jfree/data/junit/DefaultKeyedValuesTests.java + (testRemoveValue): Updated checks for consistency with KeyedObjects, + * tests/org/jfree/data/junit/KeyedObjectsTests.java + (testInsertAndRetrieve): Updated checks, + (testGetObject): New test method, + (testGetKey): Likewise, + (testGetIndex): Likewise, + (testSetObject): Likewise, + (testRemoveValue): Likewise, + (testRemoveValueInt): Likewise. + +2007-10-02 David Gilbert + + * source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.java + (minimumRangeValueRow): New field, + (minimumRangeValueColumn): Likewise, + (minimumRangeValueIncStdDevRow): Likewise, + (minimumRangeValueIncStdDevColumn): Likewise, + (maximumRangeValueRow): Likewise, + (maximumRangeValueColumn): Likewise, + (maximumRangeValueIncStdDevRow): Likewise, + (maximumRangeValueIncStdDevColumn): Likewise, + (DefaultStatisticalCategoryDataset()): Initialise new fields, + (add(Number, Number, Comparable, Comparable)): Fixed calculation of bounds, + (updateBounds): New method, + (getRangeLowerBound): Observe includeInterval flag, + (getRangeUpperBound): Likewise, + * source/org/jfree/data/statistics/MeanAndStandardDeviation.java + (getMeanValue): New method, + (getStandardDeviationValue): Likewise, + (toString): Likewise, + * tests/org/jfree/data/statistics/junit/DefaultStatisticalCategoryDatasetTests.java + (testGetRangeBounds): Fixed broken test, + (EPSILON): New field, + (testAdd): New test method, + (testGetRangeLowerBound): Likewise, + (testGetRangeUpperBound): Likewise, + (testGetRangeBounds2): Likewise. + +2007-10-02 David Gilbert + + * source/org/jfree/data/statistics/BoxAndWhiskerItem.java + (BoxAndWhiskerItem(double, double, double, double, double, double, + double, double, List)): New constructor, + * source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java + (minimumRangeValue): Changed from Number to double, + (minimumRangeValueRow): New field, + (minimumRangeValueColumn): Likewise, + (maximumRangeValue): Changed from Number to double, + (maximumRangeValueRow): New field, + (maximumRangeValueColumn): Likewise, + (DefaultBoxAndWhiskerCategoryDataset): Updated for changed field types, + (add): Fix updating of cached range values, + (getRangeLowerBound): Update for changed field type, + (getRangeUpperBound): Likewise, + * tests/org/jfree/data/statistics/junit/DefaultBoxAndWhiskerCategoryDataset.java + (testAdd): New test method, + (testAddUpdatesCachedRange): Likewise, + (testConstructor): Likewise. + +2007-09-28 David Gilbert + + * source/org/jfree/data/KeyedObjects.java + (equals): Cleaned up, + * source/org/jfree/data/KeyedObjects2D.java + (equals): Likewise, + (clone): Clone data storage, + * source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java + (clone): New method override, + * source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.java + (clone): Likewise, + * tests/org/jfree/data/junit/KeyedObjects2DTests.java + (testEquals): New test, + (testCloning): Check independence, + * tests/org/jfree/data/junit/KeyedObjectsTests.java + (testCloning2): New test, + * tests/org/jfree/data/junit/KeyedObjectTests.java + (testCloning2): New test, + * tests/org/jfree/data/statistics/junit/DefaultBoxAndWhiskerCategoryDatasetTests.java + (testCloning): Check independence, + * tests/org/jfree/data/statistics/junit/DefaultStatisticalCategoryDatasetTests.java + (testCloning): Check independence. + +2007-09-28 David Gilbert + + * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java + (drawItem): Simplified entity generation code. + +2007-09-28 David Gilbert + + * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java + (setGroupStroke): Check for null argument, add event notification, + (equals): New method override, + * tests/org/jfree/chart/renderer/category/junit/MinMaxCategoryRendererTests.java + (testEquals): Extended to cover additional fields. + +2007-09-27 David Gilbert + + * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java + (drawItem): Apply new offset option to x-coordinates. + +2007-09-27 David Gilbert + + * source/org/jfree/chart/axis/CategoryAxis.java + (getCategorySeriesMiddle): New method, + * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java + (useSeriesOffset): New field, + (itemMargin): Likewise, + (LineAndShapeRenderer(boolean, boolean)): Initialise new fields, + (getUseSeriesOffset): New method, + (setUseSeriesOffset): Likewise, + (getItemMargin): Likewise, + (setItemMargin): Likewise, + (drawItem): Apply new offset option to x-coordinates, + (equals): Check new fields, + * tests/org/jfree/chart/renderer/category/junit/LineAndShapeRendererTests.java + (testEquals): Updated for new fields. + +2007-09-26 David Gilbert + + * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java + (drawItem): Simplified entity generation code. + +2007-09-26 David Gilbert + + * source/org/jfree/chart/renderer/GrayPaintScale.java + (getPaint): Use constrained value to calculate gray scale value, + * tests/org/jfree/chart/renderer/junit/GrayPaintScaleTests.java + (testConstructor): New test method, + (testGetPaint): Likewise. + +2007-09-26 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (drawItem): Apply margin in a way that works for inverted axes. + +2007-09-26 David Gilbert + + * source/org/jfree/chart/plot/PlotUtilities.java: New class, + * source/org/jfree/data/general/DatasetUtilities.java + (isEmptyOrNull(XYDataset)): Return early if not empty, + * tests/org/jfree/data/general/junit/DatasetUtilitiesTests.java + (testIsEmptyOrNullXYDataset): New test method. + +2007-09-26 David Gilbert + + * source/org/jfree/data/general/Series.java + (getItemCount): New abstract method, + (isEmpty): New method. + +2007-09-26 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (getQuadrantPaint): Improve exception text, + (setQuadrantPaint): Likewise, + (getDomainAxisForDataset): Likewise, + (getRangeAxisForDataset): Likewise. + +2007-09-26 David Gilbert + + * source/org/jfree/chart/plot/Marker.java + (readObject): Initialise listener list, + * tests/org/jfree/chart/plot/junit/ValueMarkerTests.java + (test1802195): New test method. + +2007-09-24 David Gilbert + + * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java + (linesVisible): Deprecated, + (shapesVisible): Likewise, + (shapesFilled): Likewise, + (getLinesVisible): Likewise, + (setLinesVisible(Boolean)): Likewise, + (setLinesVisible(boolean)): Likewise, + (getShapesVisible): Likewise, + (setShapesVisible(Boolean)): Likewise, + (setShapesVisible(boolean)): Likewise, + (setUseOutlinePaint): Fire change event, + (getShapesFilled): Deprecated, + (setShapesFilled(Boolean)): Likewise, + (setShapesFilled(boolean)): Likewise, + (setSeriesShapesFilled): Fire change event, + (setBaseShapesFilled): Likewise, + (equals): Minor tidy up. + +2007-09-24 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (paintComponent): Clear chart buffer before refreshing. + +2007-09-24 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (zoomAroundAnchor): New field, + (getZoomAroundAnchor): New method, + (setZoomAroundAnchor): Likewise, + (zoomInDomain): Use zoomAroundAnchor flag, + (zoomInRange): Likewise, + (zoomOutDomain): Likewise, + (zoomOutRange): Likewise, + * source/org/jfree/chart/plot/CategoryPlot.java + (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, + (zoomRangeAxes(double, PlotRenderingInfo, Point2D)): Delegate to new method, + (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, + * source/org/jfree/chart/plot/FastScatterPlot.java + (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, + (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): Likewise, + * source/org/jfree/chart/PolarPlot.java + (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, + (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): Likewise, + * source/org/jfree/chart/ThermometerPlot.java + (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, + (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): Likewise, + * source/org/jfree/chart/XYPlot.java + (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, + (zoomDomainAxes(double, PlotRenderingInfo, Point2D)): Delegate to new + method, + (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, + (zoomRangeAxes(double, PlotRenderingInfo, Point2D)): Delegate to new method, + * source/org/jfree/chart/plot/Zoomable.java + (zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean)): New method, + (zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean)): Likewise. + +2007-09-21 David Gilbert + + * source/org/jfree/data/statistics/SimpleHistogramDataset.java: + API doc updates. + +2007-08-28 David Gilbert + + * source/org/jfree/data/time/Week.java + (Week(Date, TimeZone)): Deprecated, + (Week(Date, TimeZone, Locale)): New constructor, + * tests/org/jfree/data/time/junit/WeekTests.java + (testConstructor): New test. + +2007-08-28 David Gilbert + + * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java + (drawHorizontalItem): Check for null data items, + (drawVerticalItem): Likewise, + * tests/org/jfree/chart/renderer/category/junit/StatisticalBarRendererTests.java + (testDrawWithNullMeanVertical): New test method, + (testDrawWithNullMeanHorizontal): Likewise, + (testDrawWithNullDeviationVertical): Likewise, + (testDrawWithNullDeviationHorizontal): Likewise. + +2007-08-03 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYSplineAndShapeRenderer.java + (precision): Initialise in constructor, + (XYSplineAndShapeRenderer()): Change default precision to 5, + (XYSplineAndShapeRenderer(int)): New constructor. + +2007-08-03 David Gilbert + + Fix for bug 1766646: + * source/org/jfree/chart/renderer/xy/XYBlockRenderer.java + (findDomainBounds): Check for null, + (findRangeBounds): Likewise. + +2007-08-03 David Gilbert + + * source/org/jfree/chart/LegendItem.java + (LegendItem): Initialise GradientPaintTransformer. + +2007-08-02 David Gilbert + + * experimental/org/jfree/experimental/chart/axis/LogAxis.java + (LogAxis(String)): Leave tick marks visible, + (autoAdjustRange): Apply margins to log scale, and don't allow auto-range + to go below minimum value, + (refreshTicksHorizontal): Improved handling of ticks and labels, + (refreshTicksVertical): Likewise, + (selectAutoTickUnit): New method, + (selectHorizontalAutoTickUnit): Likewise, + (selectVerticalAutoTickUnit): Likewise, + (exponentLengthToJava2D): Likewise, + (estimateMaximumTickLabelHeight): Likewise, + (estimateMaximumTickLabelWidth): Likewise, + (equals): New method override, + (hashCode): Likewise, + (createLogTickUnits): New method, + and moved to source/org/jfree/chart/axis/, + * source/org/jfree/chart/axis/NumberTick.java + (NumberTick(TickType, double, String, TextAnchor, TextAnchor, double)): + New constructor, + * source/org/jfree/chart/axis/NumberTickUnit.java + (NumberTickUnit(double, NumberFormat, int)): New constructor, + (toString): New method override, + * source/org/jfree/chart/axis/TickType.java: New file, + * source/org/jfree/chart/axis/TickUnit.java + (minorTickCount): New field, + (TickUnit(double, int)): New constructor, + (getMinorTickCount): New method, + (equals): Updated for new field, + * source/org/jfree/chart/axis/TickUnits.java: Reformatting only, + * source/org/jfree/chart/axis/ValueAxis.java + (drawTickMarksAndLabels): Check for major tick before writing label, + * source/org/jfree/chart/axis/ValueTick.java: + (tickType): New field, + (ValueTick(TickType, double, String, TextAnchor, TextAnchor, double)): + New constructor, + (getTickType): New method, + (equals): Updated for new field, + * source/org/jfree/chart/util/LogFormat.java: New file, + * tests/org/jfree/chart/axis/junit/AxisPackageTests.java + (suite): Added LogAxisTests and TickUnitsTests, + * tests/org/jfree/chart/axis/junit/LogAxisTests.java: + New file, + * tests/org/jfree/chart/axis/junit/TickUnitsTests.java: Likewise. + +2007-07-31 David Gilbert + + Bug 1763413: + * source/org/jfree/chart/axis/PeriodAxis.java + (drawTickLabels): Calculate tick label width correctly for inverted axis. + +2007-07-25 David Gilbert + + Patch 1752205: + * source/org/jfree/data/time/TimeTableXYDataset.java + (clear): New method, + * tests/org/jfree/data/time/junit/TimeTableXYDatasetTests.java + (testClear): New method. + +2007-07-25 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYSplineAndShapeRenderer.java: + New file, contributed by Klaus Rheinwald. + +2007-07-25 David Gilbert + + * source/org/jfree/chart/axis/SymbolAxis.java + (DEFAULT_GRID_BAND_ALTERNATE_PAINT): New field, + (gridBandAlternatePaint): New field, + (SymbolAxis): Initialise new field, + (getGridBandAlternatePaint): New method, + (setGridBandAlternatePaint): Likewise, + (equals): Test new field, + (writeObject): Handle new field, + (readObject): Likewise, + * tests/org/jfree/chart/axis/junit/SymbolAxisTests.java + (testEquals): Added check for new field. + +2007-07-18 David Gilbert + + * source/org/jfree/chart/demo/PieChartDemo1.java + (createChart): Modified settings, + * source/org/jfree/chart/plot/PiePlot.java + (DEFAULT_INTERIOR_GAP): Modified default, + (DEFAULT_LABEL_SHADOW_PAINT): Likewise, + (simpleLabels): New field, + (labelPadding): Likewise, + (simpleLabelOffset): Likewise, + (PiePlot(PieDataset)): Initialise new fields, + (getLabelPadding): New method, + (setLabelPadding): Likewise, + (getSimpleLabels): Likewise, + (setSimpleLabels): Likewise, + (getSimpleLabelOffset): Likewise, + (setSimpleLabelOffset): Likewise, + (drawPie): Added simple label handling, + (drawSimpleLabels): New method, + (drawLabels): Reformatting, + (drawLeftLabels): Set label padding, + (drawRightLabels): Likewise, + (equals): Updated for new fields, + * source/org/jfree/chart/plot/PiePlot3D.java + (draw): Updated for simple labels. + +2007-07-18 David Gilbert + + * source/org/jfree/chart/plot/CombinedRangeXYPlot.java + (remove): Actually remove the subplot. + +2007-07-11 David Gilbert + + * experimental/org/jfree/experimental/chart/axis/LogAxis.java + (setSmallestValue): Added event notification, + (zoomRange): New method override. + +2007-07-11 David Gilbert + + * source/org/jfree/chart/axis/SegmentedTimeline.java + (FIRST_MONDAY_AFTER_1900): Deprecated, + (NO_DST_TIME_ZONE): Likewise, + (DEFAULT_TIME_ZONE): Likewise, + (workingCalendarNoDST): Initialise in constructor, + (SegmentedTimeline): Initialise workingCalendarNoDST, + (firstMondayAfter1900): New method, + (newMondayThroughFridayTimeline): Use new method for first monday, + (newFifteenMinuteTimeline): Likewise, + * tests/org/jfree/chart/axis/junit/SegmentedTimelineTests2.java: + Save and restore time zone in all tests. + +2007-07-11 David Gilbert + + * tests/org/jfree/data/time/junit/DayTests.java + (testGetFirstMillisecond): Set/restore time zone, + (testGetFirstMillisecondWithCalendar): Set time zone, + (testGetLastMillisecond): Set/restore time zone, + (testGetLastMillisecondWithCalendar): Set time zone, + * tests/org/jfree/data/time/junit/HourTests.java: Likewise, + * tests/org/jfree/data/time/junit/MillisecondTests.java: Likewise, + * tests/org/jfree/data/time/junit/MinuteTests.java: + (testGetFirstMillisecond): Set/restore time zone, + (testGetFirstMillisecondWithCalendar): Set time zone, + (testGetLastMillisecond): Set/restore time zone, + (testGetLastMillisecondWithCalendar): Set time zone, + (testGetStart): Set/restore time zone, + (testGetEnd): Likewise, + * tests/org/jfree/data/time/junit/MonthTests.java + (testGetFirstMillisecond): Set/restore time zone, + (testGetFirstMillisecondWithCalendar): Set time zone, + (testGetLastMillisecond): Set/restore time zone, + (testGetLastMillisecondWithCalendar): Set time zone, + * tests/org/jfree/data/time/junit/QuarterTests.java: Likewise, + * tests/org/jfree/data/time/junit/SecondTests.java: Likewise, + * tests/org/jfree/data/time/junit/WeekTests.java: Likewise, + * tests/org/jfree/data/time/junit/YearTests.java: Likewise. + +2007-07-10 David Gilbert + + * source/org/jfree/chart/ChartFactory.java + (createPieChart(String, PieDataset, boolean, boolean, Locale)): New method, + (createPieChart(String, PieDataset, PieDataset, int, boolean, boolean, + boolean, Locale, boolean, boolean)) : Likewise, + (createRingChart(String, PieDataset, boolean, boolean, Locale)): Likewise, + (createPieChart3D(String, PieDataset, boolean, boolean, Locale)): Likewise, + * source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java + (StandardPieSectionLabelGenerator(Locale)): New constructor, + (StandardPieSectionLabelGenerator(String labelFormat, Locale)): Likewise, + * source/org/jfree/chart/labels/StandardPieToolTipGenerator.java + (StandardPieToolTipGenerator): Delegate, + (StandardPieToolTipGenerator(Locale)): New constructor, + (StandardPieToolTipGenerator(String)): Delegate, + (StandardPieToolTipGenerator(String labelFormat, Locale)): New constructor. + +2007-07-10 David Gilbert + + * tests/org/jfree/chart/renderer/xy/junit/ClusteredXYBarRendererTests.java + (EPSILON): New field, + (testFindDomainBounds): Fixed compile errors, + * tests/org/jfree/data/time/junit/TimePeriodValuesCollectionTests.java + (EPSILON): New field, + (testGetDomainBoundsWithoutInterval): Fixed compile errors, + (testGetDomainBoundsWithInterval): Likewise. + +2007-07-10 David Gilbert + + * source/org/jfree/data/statistics/SimpleHistogramDataset.java + (SimpleHistogramDataset): Check for null argument. + +2007-07-10 David Gilbert + + * source/org/jfree/chart/plot/CategoryPlot.java + (getRangeAxisIndex): New method. + +---------- JFREECHART 1.0.6 RELEASED ------------------------ + +2007-06-15 David Gilbert + + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + (getSwtColorFromPool): Removed JDK 1.5 specific code. + +2007-06-15 David Gilbert + + * ant/build.xml: Updated version number to 1.0.6, + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (XYBarRenderer): Changed default value for drawBarOutline. + +2007-06-14 David Gilbert + + * source/org/jfree/chart/plot/AbstractPieLabelDistributor.java: + New file, + * source/org/jfree/chart/plot/PieLabelDistributor.java: Now extends + AbstractPieLabelDistributor, + * source/org/jfree/chart/plot/PieLabelRecord: Implemented Serializable, + * source/org/jfree/chart/plot/PiePlot.java + (labelDistributor): New field, + (PiePlot(PieDataset)): Initialise new field, + (getLabelDistributor): New method, + (setLabelDistributor): New method. + +2007-06-14 David Gilbert + + * source/org/jfree/chart/renderer/LookupPaintScale.java + (PaintItem.value): Changed from Number to double, + (PaintItem(Number, Paint)): Changed first parameter to double, + (compareTo): Updated for change in value type, + (equals): Likewise, + (add(Number, Paint)): Deprecated, + (add(double, Paint)): New method, + (getPaint): Updated. + +2007-06-14 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java + (XYBoxAndWhiskerRenderer(double)): Replaced deprecated method call, + (drawHorizontalItem): Call addEntity(), + (drawVerticalDataItem): Likewise. + +2007-06-14 David Gilbert + + * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java + (drawItem): If dataset is not a StatisticalCategoryDataset, revert to + the super class drawing behaviour. + +2007-06-14 David Gilbert + + * experimental/org/jfree/chart/renderer/xy/XYSmoothLineAndShapeRenderer.java: + New class. + +2007-06-14 David Gilbert + + * source/org/jfree/chart/block/LineBorder.java + (draw): Don't draw if area doesn't have positive dimensions, + * source/org/jfree/chart/util/HexNumberFormat.java: New class. + +2007-06-13 David Gilbert + + * source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java + (add): Assign max outlier value to maxValue. + +2007-06-13 David Gilbert + + * source/org/jfree/chart/plot/DefaultDrawingSupplier.java + (DEFAULT_FILL_PAINT_SEQUENCE): New field, + (fillPaintSequence): Likewise, + (fillPaintIndex): Likewise, + (DefaultDrawingSupplier): Constructors updated for new field, + (getNextFillPaint): New method, + * source/org/jfree/chart/plot/DrawingSupplier.kava + (getNextFillPaint): New method, + * source/org/jfree/chart/renderer/AbstractRenderer.java + (autoPopulateSeriesPaint): New field, + (autoPopulateSeriesFillPaint): Likewise, + (autoPopulateSeriesOutlinePaint): Likewise, + (autoPopulateSeriesStroke): Likewise, + (autoPopulateSeriesOutlineStroke): Likewise, + (autoPopulateSeriesShape): Likewise, + (AbstractRenderer): Initialise new fields, + (lookupSeriesPaint): Check autoPopulateField, + (getAutoPopulateSeriesPaint): New method, + (setAutoPopulateSeriesPaint): New method, + (lookupSeriesFillPaint): New method, + (getAutoPopulateSeriesFillPaint): New method, + (setAutoPopulateSeriesFillPaint): New method, + (lookupSeriesOutlinePaint): New method, + (getAutoPopulateSeriesOutlinePaint): New method, + (setAutoPopulateSeriesOutlinePaint): New method, + (lookupSeriesStroke): New method, + (getAutoPopulateSeriesStroke): New method, + (setAutoPopulateSeriesStroke): New method, + (lookupSeriesOutlineStroke): New method, + (getAutoPopulateSeriesOutlineStroke): New method, + (setAutoPopulateSeriesOutlineStroke): New method, + (lookupSeriesShape): New method, + (getAutoPopulateSeriesShape): New method, + (setAutoPopulateSeriesShape): New method. + +2007-06-13 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java + (drawItem): Check item visibility flag, and check that entity hotspot + is contained in dataArea before adding an entity, + (getLegendItem): Reduced indentation. + +2007-06-12 David Gilbert + + * source/org/jfree/chart/renderer/xy/ClusteredXYBarRenderer.java + (findDomainBounds): New method override, + (findDomainBoundsWithOffset): New utility method, + (drawItem): Fixed to handle inverted axes, + * tests/org/jfree/chart/renderer/xy/junit/ClusteredXYBarRendererTests.java + (testFindDomainBounds): New test, + (createSampleDataset1): New helper method. + +2007-06-12 David Gilbert + + * source/org/jfree/chart/renderer/xy/ClusteredXYBarRenderer.java + (drawItem): Simplified chart entity generation, + (equals): Reorganised. + +2007-06-11 David Gilbert + + * source/org/jfree/chart/ChartFactory.java + (createBarChart): Replaced deprecated method calls, + (createWaterfallChart): Likewise, + (createBoxAndWhiskerChart): Likewise. + +2007-06-11 David Gilbert + + * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java + (CandlestickRenderer(double, boolean, XYToolTipGenerator)): Replaced + call to deprecated setToolTipGenerator() method. + +2007-06-11 David Gilbert + + * source/org/jfree/data/time/TimePeriodValuesCollection.java + (TimePeriodValuesCollection(TimePeriodValues)): Changed default value + for this.domainIsPointsInTime, + (getDomainBounds): Use includeInterval parameter correctly, + * tests/org/jfree/data/time/junit/TimePeriodValuesCollectionTests.java + (testGetDomainBoundsWithoutInterval): New method, + (testGetDomainBoundsWithInterval): Likewise. + +2007-06-08 David Gilbert + + * source/org/jfree/chart/axis/QuarterDateFormat.java + (GREEK_QUARTERS): New field, + (quarterFirst): Likewise, + (QuarterFormat(TimeZone, String[], boolean)): New constructor, + (equals): Updated for new field, + * tests/org/jfree/chart/axis/junit/QuarterDateFormatTests.java + (testEquals): Added check for new field. + +2007-06-08 David Gilbert + + * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java + (drawItem): Take orientation into account when passing coordinates to + addEntity(), + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (drawSecondaryPass): Likewise, + * tests/org/jfree/chart/junit/TestUtilities.java: New file, + * tests/org/jfree/chart/renderer/xy/junit/StandardXYItemRendererTests.java + (testNoDisplayedItem): New method. + +2007-06-08 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (drawSecondaryPass): Only add entity if data point is within the + visible data area. + +2007-06-07 David Gilbert + + * source/org/jfree/chart/plot/Plot.java + (fillBackground(Graphics2D, Rectangle2D)): Delegate to new method, + (fillBackground(Graphics2D, Rectangle2D, PlotOrientation)): New method, + * source/org/jfree/chart/plot/CategoryPlot.java + (drawBackground): New method override, + * source/org/jfree/chart/plot/XYPlot.java + (drawBackground): Call new fillBackground() method. + +2007-06-06 Henry Proudhon + + * swt/org/jfree/experimental/chart/swt/ChartComposite.java + (getToolTipText): Fixed minor issues with tooltips. bug reported and fix proposed + by Christoph Beck, bug 1726404 (HP); + +2007-06-06 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (paintComponent): Fixed coordinates for drawing buffer image (DG); + +2007-06-05 David Gilbert + + * source/org/jfree/chart/JFreeChart.java + (JFreeChart(String, Font, Plot, boolean)): Add change listener to + legend, if created, + * tests/org/jfree/chart/junit/JFreeChartTests.java + (testLegendEvents): New test, + (chartChanged): New method, + (lastChartChangeEvent): New field. + +2007-06-01 David Gilbert + + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (addItemEntity): Fixed deprecation warning, + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (drawHorizontalItem): Likewise, + (drawVerticalItem): Likewise, + * source/org/jfree/chart/renderer/category/GanttRenderer.java + (drawTasks): Likewise, + (drawTask): Likewise, + * source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/category/IntervalBarRenderer.java + (drawInterval): Likewise, + * source/org/jfree/chart/renderer/category/LayeredBarRenderer.java + (drawHorizontalItem): Likewise, + (drawVerticalItem): Likewise, + * source/org/jfree/chart/renderer/category/LevelRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java + (drawItem): Likewise. + +2007-06-01 David Gilbert + + * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java + (drawItem): Return early for non-visible items, + (equals): Call super.equals() last. + +2007-05-30 David Gilbert + + * source/org/jfree/chart/axis/SubCategoryAxis.java + (addSubCategory): Added argument check and event notification. + +2007-05-25 David Gilbert + + * experimental/org/jfree/experimental/chart/renderer/xy/VectorRenderer.java: + Moved to source/org/jfree/chart/renderer/xy/VectorRenderer.java + * experimental/org/jfree/experimental/data/xy/Vector.java: + Moved to source/org/jfree/data/xy/Vector.java, + * experimental/org/jfree/experimental/data/xy/VectorDataItem.java: + Moved to source/org/jfree/data/xy/VectorDataItem.java, + * experimental/org/jfree/experimental/data/xy/VectorSeries.java: + Moved to source/org/jfree/data/xy/VectorSeries.java, + * experimental/org/jfree/experimental/data/xy/VectorSeriesCollection.java: + Moved to source/org/jfree/data/xy/VectorSeriesCollection.java, + * experimental/org/jfree/experimental/data/xy/VectorXYDataset.java: + Moved to source/org/jfree/data/xy/VectorXYDataset.java, + * experimental/org/jfree/experimental/data/xy/XYCoordinate.java: + Moved to source/org/jfree/data/xy/XYCoordinate.java. + +2007-05-25 David Gilbert + + * ant/build.xml: Added '-cvs' to version number, removed gjdoc, + * experimental/org/jfree/experimental/data/xy/VectorSeries.java + (remove): New method, + (clear): Likewise. + +2007-05-25 David Gilbert + + Translations provided by Leonardo Alves Machado: + * source/org/jfree/chart/LocalizationBundle_pt_BR.properties: New file, + * source/org/jfree/chart/editor/LocalizationBundle_pt_BR.properties: + Likewise. + +2007-05-24 David Gilbert + + * experimental/org/jfree/experimental/chart/renderer/xy/VectorRenderer.java + (findDomainBounds): Updated for method name changes, + (findRangeBounds): Likewise, + (drawItem): Likewise, + * experimental/org/jfree/experimental/data/xy/Vector.java + (getLength): New method, + (getAngle): Likewise, + * experimental/org/jfree/experimental/data/xy/VectorDataItem.java + (getVector): New method, + (getDeltaX): Renamed getVectorX(), + (getDeltaY): Renamed getVectorY(), + * experimental/org/jfree/experimental/data/xy/VectorSeries.java + (getDeltaXValue): Renamed getVectorXValue(), + (getDeltaYValue): Renamed getVectorYValue(), + * experimental/org/jfree/experimental/data/xy/VectorSeriesCollection.java + (removeSeries): New method, + (removeAllSeries): Likewise, + (indexOf): Likewise, + (getVector): Likewise, + (getDeltaXValue): Renamed getVectorXValue(), + (getDeltaYValue): Renamed getVectorYValue(), + * experimental/org/jfree/experimental/data/xy/VectorXYDataset.java + (getDeltaXValue): Renamed getVectorXValue(), + (getDeltaYValue): Renamed getVectorYValue(), + (getDeltaX): Removed, + (getDeltaY): Removed, + (getVector): New method. + +2007-05-24 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (render): Fixed bug for a series with zero items, + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java + (initialise): Disable visible items optimisation, + * tests/org/jfree/chart/plot/junit/XYPlotTests.java + (testDrawSeriesWithZeroItems): New test. + +2007-05-24 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (updateUI): Update UI for popup menu if there is one. + +2007-05-24 David Gilbert + + * source/org/jfree/chart/ChartMouseEvent.java: API doc updates, + * source/org/jfree/chart/ChartMouseListener.java: Likewise. + +2007-05-19 Henry Proudhon + + * swt/org/jfree/experimental/chart/swt/ChartComposite.java + Integrated a patch by Cédric Chabanois to remove resources leaks. + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + Removed resource leaks by adding a resource pool thanks to a patch + sent by Cédric Chabanois. + +2007-05-21 David Gilbert + + * source/org/jfree/data/statistics/SimpleHistogramDataset.java + (clearObservations): New method, + (removeAllBins): Likewise, + * tests/org/jfree/data/statistics/junit/SimpleHistogramDatasetTests.java + (testClearObservations): New method, + (testRemoveAllBins): Likewise. + +2007-05-19 Henry Proudhon + + * swt/org/jfree/experimental/chart/swt/ChartComposite.java + (paintControl): corrected bug with scaling when the drawing region + is larger than maximum draw width/height. + +2007-05-19 Henry Proudhon + + * swt/org/jfree/experimental/chart/swt/ChartComposite.java + (paintControl): check for null chart + +2007-05-18 David Gilbert + + * source/org/jfree/chart/LegendItem.java + (dataset): New field, + (seriesKey): Likewise, + (getDataset): New method, + (setDataset): Likewise, + (getSeriesKey): Likewise, + (setSeriesKey): Likewise, + * source/org/jfree/chart/entity/CategoryItemEntity.java + (dataset): No longer transient, + (series): Deprecated, + (category): Deprecated, + (categoryIndex): Deprecated, + (rowKey): New field, + (columnKey): Likewise, + (CategoryItemEntity(Shape, String, String, CategoryDataset, int, Object, int)): + Deprecated, + (CategoryItemEntity(Shape, String, String, CategoryDataset, Comparable, Comparable)): + New constructor, + (setDataset): Added argument check, + (getRowKey): New method, + (setRowKey): New method, + (getColumnKey): New method, + (setColumnKey): New method, + (getSeries): Deprecated, + (setSeries): Deprecated, + (getCategory): Deprecated, + (setCategory): Deprecated, + (getCategoryIndex): Likewise, + (setCategoryIndex): Likewise, + (toString): Include new fields, + (equals): Updated for new fields, + * source/org/jfree/chart/entity/LegendItemEntity.java + (dataset): New field, + (seriesKey): New field, + (getDataset): New method, + (setDataset): New method, + (getSeriesKey): New method, + (setSeriesKey): New method, + (getSeriesIndex): Deprecated, + (setSeriesIndex): Deprecated, + (equals): Updated for new fields, + (toString): Likewise, + * source/org/jfree/chart/plot/MeterPlot.java + (getLegendItems): Set dataset for legend item, + * source/org/jfree/chart/plot/MultiplePiePlot.java + (getLegendItems): Likewise, + * source/org/jfree/chart/plot/PiePlot.java + (getLegendItems): Likewise, + * source/org/jfree/chart/plot/SpiderWebPlot.java + (getLegendItems): Likewise, + * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (getLegendItem): Set dataset and series key, + * source/org/jfree/chart/renderer/category/AreaRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/category/BarRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/category/CategoryStepRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/title/LegendItemBlockContainer.java + (dataset): New field, + (seriesKey): Likewise, + (LegendItemBlockContainer(Arrangement, int, int)): Deprecated, + (LegendItemBlockContainer(Arrangement, Dataset, Comparable)): New constructor, + (getDataset): New method, + (getSeriesKey): Likewise, + (draw): Updated for new fields, + * source/org/jfree/chart/title/LegendTitle.java + (createLegendItemBlock): Replaced deprecated constructor, + * tests/org/jfree/chart/entity/junit/CategoryItemEntityTests.java + (testEquals): Updated, + (testCloning): Reformatted, + (testSerialization): Likewise, + * tests/org/jfree/chart/entity/junit/LegendItemEntityTests.java + (testEquals): Added checks for new fields, + (testCloning): Reformatted, + (testSerialization): Likewise. + +2007-05-17 David Gilbert + + * source/org/jfree/chart/plot/MultiplePiePlot.java + (setPieChart(JFreeChart)): Added argument checks. + +2007-05-17 David Gilbert + + * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java + (getLegendItem): Set datasetIndex and seriesIndex, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java + (getLegendItem): Likewise, + * tests/org/jfree/chart/renderer/xy/junit/StandardXYItemRendererTests.java + (testGetLegendItemSeriesIndex): New test, + * tests/org/jfree/chart/renderer/xy/junit/XYAreaRendererTests.java + (testGetLegendItemSeriesIndex): Likewise, + * tests/org/jfree/chart/renderer/xy/junit/XYAreaRenderer2Tests.java + (testGetLegendItemSeriesIndex): Likewise, + * tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java + (testGetLegendItemSeriesIndex): Likewise, + * tests/org/jfree/chart/renderer/xy/junit/XYBubbleRendererTests.java + (testGetLegendItemSeriesIndex): Likewise, + * tests/org/jfree/chart/renderer/xy/junit/XYDifferenceRendererTests.java + (testGetLegendItemSeriesIndex): Likewise, + * tests/org/jfree/chart/renderer/xy/junit/XYDotRendererTests.java + (testGetLegendItemSeriesIndex): Likewise, + * tests/org/jfree/chart/renderer/xy/junit/XYLineAndShapeRendererTests.java + (testGetLegendItemSeriesIndex): Likewise, + * tests/org/jfree/chart/renderer/xy/junit/YIntervalRendererTests.java + (testGetLegendItemSeriesIndex): Likewise. + +2007-05-17 David Gilbert + + * source/org/jfree/chart/renderer/category/AreaRenderer.java + (getLegendItem): Set datasetIndex and seriesIndex, + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (getLegendItem): Likewise, + * tests/org/jfree/chart/renderer/category/junit/AreaRendererTests.java + (testGetLegendItemSeriesIndex): New test, + * tests/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java + (testGetLegendItemSeriesIndex): Likewise, + * tests/org/jfree/chart/renderer/category/junit/LevelRendererTests.java + (testGetLegendItemSeriesIndex): Likewise. + +2007-05-17 David Gilbert + + * source/org/jfree/chart/renderer/category/BarRenderer.java + (getLegendItem): Set datasetIndex and seriesIndex, + * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java + (getLegendItem): Likewise, + * tests/org/jfree/chart/renderer/category/junit/BarRendererTests.java + (testGetLegendItemSeriesIndex): New test, + * tests/org/jfree/chart/renderer/category/junit/LineAndShapeRendererTests.java + (testGetLegendItemSeriesIndex): Likewise. + +2007-05-16 David Gilbert + + * source/org/jfree/chart/JFreeChart.java + (getSubtitles): Copy list, + (setSubtitles): Likewise, + (addSubtitle(int, Title)): New method, + * tests/org/jfree/chart/junit/JFreeChartTests.java + (testAddSubtitle): New test method, + (testGetSubtitles): Likewise. + +2007-05-16 David Gilbert + + * source/org/jfree/chart/JFreeChart.java + (getSubtitle): Fixed argument check, + * tests/org/jfree/chart/junit/JFreeChartTests.java + (testGetSubtitle): New test method. + +2007-05-15 David Gilbert + + * source/org/jfree/chart/plot/Plot.java + (outlineVisible): New field, + (Plot): Initialise new field, + (isOutlineVisible): New method, + (setOutlineVisible): Likewise, + (drawOutline): Check outlineVisible flag, + (equals): Likewise. + +2007-05-11 David Gilbert + + * source/org/jfree/chart/renderer/category/BarRenderer.java + (getLegendItem): Check for visibility, + * tests/org/jfree/chart/renderer/category/junit/BarRendererTests.java + (testGetLegendItem): New test method. + +2007-05-11 David Gilbert + + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (getLegendItem): Check for visibility, + * tests/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java + (testGetLegendItem): New test method. + +2007-05-08 David Gilbert + + * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java + (drawStackHorizontal): Check drawBarOutlines flag, and add shading + to bar sides, + (drawStackVertical): Likewise. + +2007-05-08 David Gilbert + + * source/org/jfree/data/time/TimeSeriesCollection.java + (indexOf): New method, + * source/org/jfree/data/xy/XYSeriesCollection.java + (indexOf): Likewise, + * tests/org/jfree/data/junit/time/TimeSeriesCollectionTests.java + (testIndexOf): New method, + * tests/org/jfree/data/junit/xy/XYSeriesCollectionTests.java + (testIndexOf): Likewise. + +2007-05-04 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (render): Only process visible data items, if possible, + * source/org/jfree/chart/renderer/RendererUtilities.java: New file, + * source/org/jfree/chart/renderer/xy/DeviationRenderer.java: + (initialise): Disable visible items optimisation, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java + (initialise): Likewise, + * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java: + (initialise): Likewise, + * source/org/jfree/chart/renderer/xy/XYItemRendererState.java + (processVisibleItemsOnly): New field, + (XYItemRendererState): Initialise new field, + (getProcessVisibleItemsOnly): New method, + (setProcessVisibleItemsOnly): Likewise, + * source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java + (initialise): Disable visible items optimisation, + * tests/org/jfree/chart/renderer/junit/RendererUtilitiesTests.java: + New file. + +2007-05-04 David Gilbert + + * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java + (drawSeries): Fixed lookup for series paint and stroke, + (getLegendItem): Likewise. + +2007-05-04 David Gilbert + + * source/org/jfree/data/time/TimeSeriesCollection.java + (getDomainOrder): New method override. + +2007-05-03 David Gilbert + + * source/org/jfree/chart/axis/DateAxis.java + (previousStandardDate): Fixed boundary cases for + MILLISECOND, SECOND and MONTH units, + * tests/org/jfree/chart/axis/junit/DateAxisTests.java + (testPreviousStandardDateYear): Removed, + (testPreviousStandardDateMonth): Removed, + (testPreviousStandardDateDay): Removed, + (testPreviousStandardDateHour): Removed, + (testPreviousStandardDateMinute): Removed, + (testPreviousStandardDateSecond): Removed, + (testPreviousStandardDateMillisecond): Removed, + (testPreviousStandardDateYearA): New method, + (testPreviousStandardDateYearB): Likewise, + (testPreviousStandardDateMonthA): Likewise, + (testPreviousStandardDateMonthB): Likewise, + (testPreviousStandardDateDayA): Likewise, + (testPreviousStandardDateDayB): Likewise, + (testPreviousStandardDateHourA): Likewise, + (testPreviousStandardDateHourB): Likewise, + (testPreviousStandardDateMinuteA): Likewise, + (testPreviousStandardDateMinuteB): Likewise, + (testPreviousStandardDateSecondA): Likewise, + (testPreviousStandardDateSecondB): Likewise, + (testPreviousStandardDateMillisecondA): Likewise, + (testPreviousStandardDateMillisecondB): Likewise. + +2007-05-03 David Gilbert + + * source/org/jfree/chart/plot/ThermometerPlot.java + (subrangePaint): Made transient, + (ThermometerPlot(ValueDataset)): Set axis field directly, + (setRangeAxis): Added null argument check, and event + notification, + (setPadding): Added null argument check, + (setUnits(String)): Deprecated, + (setValueFont): Added null argument check, + (setValuePaint): Likewise, + (setValueFormat): Likewise, + (setMercuryPaint): Likewise, + (getShowValueLines): Deprecated, + (setShowValueLines): Likewise, + (datasetChanged): Check for null dataset, + (writeObject): Handle subrange paint, + (readObject): Likewise. + +2007-05-01 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYLine3DRenderer.java + (equals): New method override, + (readObject): New method, + (writeObject): New method. + +2007-04-30 David Gilbert + + * experimental/org/jfree/experimental/chart/annotations/XYTitleAnnotation.java + (equals): Fixed incorrect cast, + * experimental/org/jfree/experimental/chart/annotations/junit/XYTitleAnnotationTests.java: + New file. + +2007-04-30 David Gilbert + + * source/org/jfree/data/general/DefaultPieDataset.java + (insertValue(int, Comparable, double)): New method, + (insertValue(int, Comparable, Double)): Likewise. + +2007-04-30 David Gilbert + + * source/org/jfree/data/DefaultKeyedValues.java + (insertValues(int, Comparable, double)): New method, + (insertValues(int, Comparable, Double)): Likewise, + * tests/org/jfree/data/junit/DefaultKeyedValuesTests.java + (testConstructor): New test method, + (testGetItemCount): Likewise, + (testGetKeys): Likewise, + (testGetValue): Extended, + (testAddValue): New test method, + (testInsertValue): Likewise. + +2007-04-23 David Gilbert + + Patch from Richard West: + * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java + (drawItemPass0): Reimplemented, + (drawItemPass1): Likewise, + (getPositiveArea): Removed, + (getNegativeArea): Removed, + (getIntersection): Removed, + (isEitherSeriesDegenerate): New method, + (areSeriesDisjoint): New method, + (createPolygon): New method. + +2007-04-20 David Gilbert + + * source/org/jfree/chart/renderer/AbstractRenderer.java + (positiveItemLabelPosition): Deprecated, + (negativeItemLabelPosition): Likewise, + (createEntities): Likewise, + (getPositiveItemLabelPosition): Deprecated, + (setPositiveItemLabelPosition(ItemLabelPosition)): Likewise, + (setPositiveItemLabelPosition(ItemLabelPosition, boolean)): Likewise, + (getNegativeItemLabelPosition): Deprecated, + (setNegativeItemLabelPosition(ItemLabelPosition)): Likewise, + (setNegativeItemLabelPosition(ItemLabelPosition, boolean)): Likewise, + (getCreateEntities): Deprecated, + (setCreateEntities(Boolean): Likewise, + (setCreateEntities(Boolean, boolean)): Likewise, + * source/org/jfree/chart/renderer/category/CategoryItemRenderer.java + (getPositiveItemLabelPosition): Deprecated, + (setPositiveItemLabelPosition(ItemLabelPosition)): Likewise, + (setPositiveItemLabelPosition(ItemLabelPosition, boolean)): Likewise, + (getNegativeItemLabelPosition): Deprecated, + (setNegativeItemLabelPosition(ItemLabelPosition)): Likewise, + (setNegativeItemLabelPosition(ItemLabelPosition, boolean)): Likewise, + * source/org/jfree/chart/renderer/xy/XYItemRenderer.java + (getPositiveItemLabelPosition): Deprecated, + (setPositiveItemLabelPosition(ItemLabelPosition)): Likewise, + (setPositiveItemLabelPosition(ItemLabelPosition, boolean)): Likewise, + (getNegativeItemLabelPosition): Deprecated, + (setNegativeItemLabelPosition(ItemLabelPosition)): Likewise, + (setNegativeItemLabelPosition(ItemLabelPosition, boolean)): Likewise. + +2007-04-20 David Gilbert + + * source/org/jfree/chart/renderer/AbstractRenderer.java + (itemLabelsVisible): Deprecated, + (itemLabelFont): Likewise, + (itemLabelPaint): Likewise, + (setItemLabelsVisible(boolean)): Likewise, + (setItemLabelsVisible(Boolean)): Likewise, + (setItemLabelsVisible(Boolean, boolean)): Likewise, + (getItemLabelFont): Likewise, + (setItemLabelFont(Font)): Likewise, + (setItemLabelFont(Font, boolean)): Likewise, + (getItemLabelPaint): Likewise, + (setItemLabelPaint(Paint)): Likewise, + (setItemLabelPaint(Paint, boolean)): Likewise, + * source/org/jfree/chart/renderer/category/CategoryItemRenderer.java + (setItemLabelsVisible(boolean)): Deprecated, + (setItemLabelsVisible(Boolean)): Likewise, + (setItemLabelsVisible(Boolean, boolean)): Likewise, + (getItemLabelFont): Likewise, + (setItemLabelFont(Font)): Likewise, + (getItemLabelPaint): Likewise, + (setItemLabelPaint(Paint)): Likewise, + * source/org/jfree/chart/renderer/xy/XYItemRenderer.java + (setItemLabelsVisible(boolean)): Deprecated, + (setItemLabelsVisible(Boolean)): Likewise, + (setItemLabelsVisible(Boolean, boolean)): Likewise, + (getItemLabelFont): Likewise, + (setItemLabelFont(Font)): Likewise, + (getItemLabelPaint): Likewise, + (setItemLabelPaint(Paint)): Likewise. + +2007-04-20 David Gilbert + + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (itemLabelGenerator): Deprecated, + (toolTipGenerator): Likewise, + (itemURLGenerator): Likewise, + (setItemLabelGenerator): Likewise, + (getToolTipGenerator): Likewise, + (setToolTipGenerator): Likewise, + (setItemURLGenerator): Deprecated and added event notification, + (setSeriesItemURLGenerator): Added event notification, + (setBaseItemURLGenerator): Likewise, + * source/org/jfree/chart/renderer/category/CategoryItemRenderer.java + (setItemLabelGenerator): Deprecated, + (getToolTipGenerator): Likewise, + (setToolTipGenerator): Likewise, + (setItemURLGenerator): Likewise. + +2007-04-20 David Gilbert + + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (itemLabelGenerator): Deprecated, + (toolTipGenerator): Likewise, + (getItemLabelGenerator): Likewise, + (setItemLabelGenerator): Likewise, + (getToolTipGenerator): Likewise, + (setToolTipGenerator): Likewise, + * source/org/jfree/chart/renderer/xy/XYItemRenderer.java + (setItemLabelGenerator): Deprecated, + (setToolTipGenerator): Likewise. + +2007-04-20 David Gilbert + + * source/org/jfree/chart/renderer/AbstractRenderer.java + (paint): Deprecated, + (fillPaint): Likewise, + (outlinePaint): Likewise, + (stroke): Likewise, + (outlineStroke): Likewise, + (shape): Likewise, + (getItemPaint): Call new lookupSeriesPaint() method, + (lookupSeriesPaint): New method, + (setPaint(Paint)): Deprecated, + (setPaint(Paint, boolean)): Likewise, + (getSeriesPaint(int)): Reimplemented to return series + paint only, not a lookup, + (getItemFillPaint): Call new lookupSeriesFillPaint() + method, + (lookupSeriesFillPaint): New method, + (getSeriesFillPaint(int)): Reimplemented to return + series fill paint only, not a lookup, + (setFillPaint(Paint)): Deprecated, + (setFillPaint(Paint, boolean)): Likewise, + (getItemOutlinePaint): Call new lookupSeriesOutlinePaint() + method, + (lookupSeriesOutlinePaint): New method, + (getSeriesOutlinePaint(int)): Reimplemented to return series + outline paint only, not a lookup, + (setOutlinePaint(Paint)): Deprecated, + (setOutlinePaint(Paint, boolean)): Likewise, + (getItemStroke): Call new lookupSeriesOutlineStroke() + method, + (lookupSeriesStroke): New method, + (setStroke(Stroke)): Deprecated, + (setStroke(Stroke, boolean)): Deprecated, + (getSeriesStroke(int)): Reimplemented to return series stroke + only, not a lookup, + (getItemOutlineStroke): Call new lookupSeriesOutlineStroke() + method, + (lookupSeriesOutlineStroke): New method, + (setOutlineStroke(Stroke)): Deprecated, + (setOutlineStroke(Stroke, boolean)): Deprecated, + (getSeriesOutlineStroke(int)): Reimplemented to return series + outline stroke, not a lookup, + (getItemShape): Call new lookupSeriesShape() method, + (lookupSeriesShape): New method, + (setShape(Shape)): Deprecated, + (setShape(Shape, notify)): Deprecated, + (getSeriesShape(int)): Reimplemented to return series shape, + not a lookup, + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (getLegendItem): Updated for renderer changes, + * source/org/jfree/chart/renderer/category/AreaRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/category/BarRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/category/CategoryItemRenderer.java + (setPaint): Deprecated, + (setOutlinePaint): Deprecated, + (setStroke): Deprecated, + (setOutlineStroke): Deprecated, + (setShape): Deprecated, + * source/org/jfree/chart/renderer/category/CategoryStepRenderer.java + (getLegendItem): Updated for renderer changes, + * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java + (getLegendItem): Likewise, + (drawItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java + (getLegendItem): Likewise, + (drawItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYItemRenderer.java + (setPaint): Deprecated, + (setOutlinePaint): Deprecated, + (setStroke): Deprecated, + (setOutlineStroke): Deprecated, + (setShape): Deprecated, + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (getLegendItem): Likewise. + +2007-04-19 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (sectionPaint): Deprecated, + (sectionOutlinePaint): Likewise, + (sectionOutlineStroke): Likewise, + (getSectionPaint): Likewise, + (setSectionPaint(Paint)): Likewise, + (getSectionOutlinePaint): Likewise, + (setSectionOutlinePaint(Paint)): Likewise, + (getSectionOutlineStroke): Likewise, + (setSectionOutlineStroke(Stroke)): Likewise, + (zoom): Removed. + +2007-04-19 David Gilbert + + * source/org/jfree/chart/renderer/AbstractRenderer.java + (seriesVisibleInLegend): Deprecated, + (getSeriesVisibleInLegend): Likewise, + (setSeriesVisibleInLegend(Boolean)): Likewise, + (setSeriesVisibleInLegend(Boolean, boolean)): Likewise, + * source/org/jfree/chart/renderer/category/CategoryItemRenderer.java + (getSeriesVisibleInLegend): Likewise, + (setSeriesVisibleInLegend(Boolean)): Likewise, + (setSeriesVisibleInLegend(Boolean, boolean)): Likewise, + * source/org/jfree/chart/renderer/xy/XYItemRenderer.java + (getSeriesVisibleInLegend): Likewise, + (setSeriesVisibleInLegend(Boolean)): Likewise, + (setSeriesVisibleInLegend(Boolean, boolean)): Likewise. + +2007-04-19 David Gilbert + + * source/org/jfree/chart/renderer/AbstractRenderer.java + (seriesVisible): Deprecated, + (getSeriesVisible): Likewise, + (setSeriesVisible(Boolean)): Likewise, + (setSeriesVisible(Boolean, boolean)): Likewise, + * source/org/jfree/chart/renderer/category/CategoryItemRenderer.java + (getSeriesVisible): Likewise, + (setSeriesVisible(Boolean)): Likewise, + (setSeriesVisible(Boolean, boolean)): Likewise, + * source/org/jfree/chart/renderer/xy/XYItemRenderer.java + (getSeriesVisible): Likewise, + (setSeriesVisible(Boolean)): Likewise, + (setSeriesVisible(Boolean, boolean)): Likewise. + +2007-04-19 David Gilbert + + * source/org/jfree/chart/axis/DateAxis.java + (setMinimumDate): Handle case where new minimum date is on or after + the existing maximum date, + (setMaximumDate): Handle case where new maximum date is on or before + the existing minimum date, + * tests/org/jfree/chart/axis/junit/DateAxisTests.java + (testSetMaximumDate): Added new check, + (testSetMinimumDate): Likewise. + +2007-04-17 David Gilbert + + * source/org/jfree/chart/urls/StandardCategoryURLGenerator.java + (generateURL): Use new URLUtilities class for encoding, + * source/org/jfree/chart/urls/StandardPieURLGenerator.java + (generateURL): Likewise, + * source/org/jfree/chart/urls/TimeSeriesURLGenerator.java + (generateURL): Likewise, + * source/org/jfree/chart/urls/URLUtilities.java: New file, + * tests/org/jfree/chart/urls/junit/StandardPieURLGeneratorTests.java + (testURL): Added new check, + * tests/org/jfree/chart/urls/junit/TimeSeriesURLGeneratorTests.java + (testGenerateURL): New test method. + +2007-04-17 David Gilbert + + * source/org/jfree/chart/urls/TimeSeriesURLGenerator.java + (TimeSeriesURLGenerator(DateFormat, String, String, String)): Added + null argument checks, + (getDateFormat): New method, + (getPrefix): New method, + (getSeriesParameterName): New method, + (getItemParameterName): New method, + (equals): New method, + * tests/org/jfree/chart/urls/junit/TimeSeriesURLGeneratorTests.java: + New file, + * tests/org/jfree/chart/urls/junit/UrlsPackageTests.java + (suite): Added TimeSeriesURLGeneratorTests. + +2007-04-17 David Gilbert + + * source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java + (add): Check for null values, + * tests/org/jfree/data/statistics/junit/DefaultBoxAndWhiskerCategoryDatasetTests.java + (testCloning): New test method, + (test1701822): Likewise. + +2007-04-17 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (actionPerformed): Check for null zoomPoint, + (restoreAutoDomainBounds): Likewise, + (restoreAutoRangeBounds): Likewise, + * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java + (findSubplot): Added null argument checks, + (zoomRangeAxes(double, PlotRenderingInfo, Point2D)): If not in + subplot, zoom for all subplots, + (zoomRangeAxes(double, double, PlotRenderingInfo, Point2D)): Likewise, + * source/org/jfree/chart/plot/CombinedDomainXYPlot.java + (findSubplot): Added null argument checks, + (zoomRangeAxes(double, PlotRenderingInfo, Point2D)): If not in + subplot, zoom for all subplots, + (zoomRangeAxes(double, double, PlotRenderingInfo, Point2D)): Likewise, + * source/org/jfree/chart/plot/CombinedRangeXYPlot.java + (findSubplot): Added null argument checks, + (zoomDomainAxes(double, PlotRenderingInfo, Point2D)): If not in + subplot, zoom for all subplots, + (zoomDomainAxes(double, double, PlotRenderingInfo, Point2D)): Likewise, + * source/org/jfree/chart/plot/PlotRenderingInfo.java + (getSubplotIndex): Added null argument check. + +2007-04-17 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (getLegendItems): Check for null legend item label, + * tests/org/jfree/chart/plot/junit/PiePlotTests.java + (NullLegendLabelGenerator): New support class, + (testDrawWithNullLegendLabels): New test method. + +2007-04-07 Henry Proudhon + + * swt/org/jfree/experimental/chart/swt/ChartComposite.java: + Fixed redraw problem (no need to call forceRedraw() anymore). + * swt/org/jfree/experimental/swt/SWTGraphics2D.java: + Fixed some issues with disposing SWT ressources. Thanks to silent + for pointing this out. + +2007-04-04 Chris Boek + + * source/org/jfree/chart/axis/DateAxis.java + (previousStandardDate): Use time zone for Month, + (refreshTicksHorizontal): Use time zone, + (refreshTicksVertical): Likewise, + * source/org/jfree/chart/axis/DateTickUnit.java + (addToDate(Date, TimeZone)): New method, + (rollDate(Date, TimeZone)): New method, + * source/org/jfree/data/time/Hour.java + (Hour(Date, TimeZone)): Peg to zone, + * source/org/jfree/data/time/Millisecond.java + (Millisecond(Date, TimeZone)): Peg to zone, + * source/org/jfree/data/time/Month.java + (Month(Date, TimeZone)): Peg to zone. + +2007-04-03 David Gilbert + + * source/org/jfree/chart/plot/Plot.java + (drawBackgroundImage): Changed from protected to public. + +2007-04-03 David Gilbert + + * source/org/jfree/chart/renderer/category/BarRenderer3D.java + (drawBackground): Use background alpha, and delegate background + image drawing to the plot, + * source/org/jfree/chart/renderer/category/LineRenderer3D.java + (drawBackground): Likewise. + +2007-03-30 David Gilbert + + * source/org/jfree/data/DefaultKeyedValues2D.java + (removeValue): Remove column values by key not index, + * tests/org/jfree/data/junit/DefaultKeyedValues2DTests.java + (testRemoveValueBug1690654): New test method. + +---------- JFREECHART 1.0.5 RELEASED ------------------------ + +2007-03-23 David Gilbert + + * source/org/jfree/chart/plot/CombinedDomainXYPlot.java + (draw): Draw shared axis last, + * source/org/jfree/chart/plot/CombinedRangeXYPlot.java + (draw): Likewise. + +2007-03-23 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYErrorRenderer.java + (drawItem): Check item visibility. + +2007-03-23 David Gilbert + + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (drawDomainLine): New method, + * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java + (getItemShapeFilled): Do full lookup, + (getShapesFilled): New method, + (setShapesFilled): Fire change event, + (getSeriesShapesFilled): Only look up per-series settings, + (setSeriesShapesFilled): Fire change event, + (getLegendItem): Call getItemShapeFilled for shape fill status. + +2007-03-23 David Gilbert + + * ant/build.xml: Updated library version numbers, + * source/org/jfree/chart/plot/XYPlot.java + (domainZeroBaselineVisible): New field, + (domainZeroBaselineStroke): Likewise, + (domainZeroBaselinePaint): Likewise, + (XYPlot): Initialise new field, + (isDomainZeroBaselineVisible): New method, + (setDomainZeroBaselineVisible): Likewise, + (getDomainZeroBaselineStroke): Likewise, + (setDomainZeroBaselineStroke): Likewise, + (getDomainZeroBaselinePaint): Likewise, + (setDomainZeroBaselinePaint): Likewise, + (draw): Added drawing code for domain zero baseline, + (render): Added check for null renderer, + (drawZeroDomainBaseline): New method, + (equals): Test new fields, + (writeObject): Handle new fields, + (readObject): Likewise. + +2007-03-22 David Gilbert + + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java + (setShapePaint): Fire change event, + (setShapeStroke): Likewise. + +2007-03-22 David Gilbert + + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (getItemLabelGenerator(int, int)): Do lookup, + (getSeriesItemLabelGenerator(int)): Lookup only the series generator, + (getItemLabelGenerator): New method, + (getToolTipGenerator(int, int)): Do lookup, + (getToolTipGenerator): New method, + (getSeriesToolTipGenerator): Lookup only the series generator. + +2007-03-22 David Gilbert + + * source/org/jfree/chart/renderer/AbstractRenderer.java + (fireChangeEvent): Fire new event every time. + +2007-03-22 David Gilbert + + * source/org/jfree/chart/plot/PiePlot3D.java + (setDepthFactor): Fire PlotChangeEvent, + (equals): New method override, + * tests/org/jfree/chart/plot/junit/PiePlot3DTests.java + (testEquals): New test. + +2007-03-22 David Gilbert + + * source/org/jfree/chart/axis/LogarithmicAxis.java + (autoAdjustRange): Use new defaultAutoRange attribute, + * source/org/jfree/chart/axis/NumberAxis.java + (autoAdjustRange): Likewise, + * source/org/jfree/chart/axis/PeriodAxis.java + (autoAdjustRange): Likewise, + * source/org/jfree/chart/axis/ValueAxis.java + (DEFAULT_LOWER_BOUND): Deprecated, + (DEFAULT_UPPER_BOUND): Likewise, + (defaultAutoRange): New field, + (ValueAxis(String, TickUnitSource)): Initialise new field, + (getDefaultAutoRange): New method, + (setDefaultAutoRange): New method, + (equals): Check new defaultAutoRange field. + +2007-03-22 David Gilbert + + * source/org/jfree/chart/axis/AxisLocation.java + (getOpposite): New method. + +2007-03-22 David Gilbert + + * source/org/jfree/chart/JFreeChart.java + (getAntiAlias): Simplified, + (getTextAntiAlias): New method, + (setTextAntiAlias(boolean)): New method, + (setTextAntiAlias(Object)): New method. + +2007-03-22 David Gilbert + + * source/org/jfree/data/time/TimeSeries.java + (getDataItem(RegularTimePeriod)): Simplified. + +2007-03-21 David Gilbert + + * source/org/jfree/chart/axis/ExtendedCategoryAxis.java + (sublabelPaint): Marked as transient, + (setSubLabelFont): Check for null argument, fire change event, + (setSubLabelPaint): Likewise, + (equals): New method override, + (clone): Likewise, + (writeObject): New method, + (readObject): New method, + * tests/org/jfree/chart/axis/junit/AxisPackageTests.java + (suite): Added ExtendedCategoryAxisTests, + * tests/org/jfree/chart/axis/junit/ExtendedCategoryAxisTests.java: + New file. + +2007-03-21 David Gilbert + + * source/org/jfree/chart/plot/PolarPlot.java + (angleLabelPaint): Marked as transient, + (writeObject): Handle angleLabelPaint field, + (readObject): Likewise, + * tests/org/jfree/chart/plot/junit/PolarPlotTests.java + (testSerialization): Added checks for paint fields. + +2007-03-21 David Gilbert + + * source/org/jfree/chart/plot/MeterPlot.java + (tickPaint): Marked as transient, + (tickLabelPaint): Likewise, + (writeObject): Handle new transient fields, + (readObject): Likewise, + * tests/org/jfree/chart/plot/junit/MeterPlotTests.java + (testSerialization): Added checks for paint fields. + +2007-03-21 David Gilbert + + * source/org/jfree/chart/axis/DateTickUnit.java + (units): New private field, + (toString): New method override. + +2007-03-20 David Gilbert + + * source/org/jfree/chart/plot/CompassPlot.java + (roseHighlightPaint): Marked transient, + (rosePaint): Likewise, + (roseCenterPaint): Likewise, + (setDrawBorder): Notify listeners, + (writeObject): New method, + (readObject): New method, + * tests/org/jfree/chart/plot/junit/CompassPlotTests.java + (testSerialization): Check paint fields with GradientPaint. + +2007-03-20 David Gilbert + + * source/org/jfree/chart/renderer/category/GanttRenderer.java + (completePaint): Marked transient, + (incompletePaint): Likewise, + (equals): Implemented, + (writeObject): New method, + (readObject): Likewise, + * tests/org/jfree/chart/renderer/category/junit/GanttRendererTests.java + (testEquals): Extended, + (testSerialization): Updated to check gradient paint. + +2007-03-20 David Gilbert + + * source/org/jfree/chart/JFreeChart.java + (JFreeChart(String, Font, Plot, boolean)): Update for renamed method, + * source/org/jfree/chart/block/AbstractBlock.java + (border): Renamed frame, + (AbstractBlock): Updated for renamed field, + (getBorder): Likewise, + (setBorder(BlockBorder)): Updated for renamed method, + (setBorder(double, double, double, double)): Likewise, + (getBlockFrame): Renamed getFrame(), + (setBlockFrame): Renamed setFrame(), + (getContentXOffset): Updated for renamed field, + (getContentYOffset): Likewise, + (trimToContentWidth): Likewise, + (trimToContentHeight): Likewise, + (calculateTotalWidth): Likewise, + (calculateTotalHeight): Likewise, + (trimBorder): Likewise, + (drawBorder): Likewise, + (equals): Likewise, + (clone): Likewise, + * source/org/jfree/chart/title/LegendTitle.java + (draw): Updated for renamed method. + +2007-03-19 David Gilbert + + * source/org/jfree/chart/ChartUtilities.java + (saveChartAsPNG(File, JFreeChart, int, int, ChartRenderingInfo)): Wrap + writeChartAsPNG in try-finally, + (saveChartAsPNG(File, JFreeChart, int, int, ChartRenderingInfo, + boolean, int)): Likewise, + (saveChartAsJPEG(File, JFreeChart, int, int, ChartRenderingInfo)): + Likewise, + (saveChartAsJPEG(File, float, JFreeChart, int, int, + ChartRenderingInfo)): Likewise. + +2007-03-16 David Gilbert + + * source/org/jfree/chart/JFreeChart.java + (JFreeChart(String, Plot, Font, boolean)): Changed initial legend + border, + * source/org/jfree/chart/block/AbstractBlock.java: implemented + Cloneable, + (border): Changed type to BlockFrame, + (getBorder): Deprecated, + (setBorder): Deprecated, + (getBlockFrame): New method, + (setBlockFrame): New method, + (equals): Check id field, + (clone): Implemented, + * source/org/jfree/chart/block/BlockBorder.java: Implemented BlockFrame + interface, + * source/org/jfree/chart/block/BlockFrame.java: New file, + * source/org/jfree/chart/block/ColorBlock.java + (paint): Marked transient, + (ColorBlock): Added null argument check, + (getPaint): New method, + (equals): New method, + (writeObject): New method, + (readObject): New method, + * source/org/jfree/chart/block/LineBorder.java: New file, + * source/org/jfree/chart/title/LegendTitle.java + (draw): Updated for changes to AbstractBlock border, + * tests/org/jfree/chart/block/junit/AbstractBlockTests.java: New file, + * tests/org/jfree/chart/block/junit/BlockBorderTests.java: Reformatted, + * tests/org/jfree/chart/block/junit/BlockPackageTests.java: Added new + tests, + * tests/org/jfree/chart/block/junit/ColorBlockTests.java: New file, + * tests/org/jfree/chart/block/junit/EmptyBlockTests.java: Reformatted, + * tests/org/jfree/chart/block/junit/LineBorderTests.java: New file. + +2007-03-16 David Gilbert + + * source/org/jfree/chart/block/LabelBlock.java + (paint): Mark as transient, + (equals): Minor simplification, + (readObject): New method, + (writeObject): Likewise, + * tests/org/jfree/chart/block/junit/LabelBlockTests.java + (testSerialization): Test with GradientPaint. + +2007-03-15 David Gilbert + + * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java + (renderAsPercentages): New field, + (StackedXYBarRenderer()): Delegate to another constructor, + (StackedXYBarRenderer(double)): Initialise item label settings, + (getRenderAsPercentages): New method, + (setRenderAsPercetanges): Likewise, + (getPassCount): New method override, + (findRangeBounds): Handle renderAsPercentages, + (drawItem): Divide into two passes, handle renderAsPercentages and + item label drawing, + (equals): Check renderAsPercentages, + (hashCode): New method override, + * source/org/jfree/data/general/DatasetUtilities.java + (calculateStackTotal): New method, + * tests/org/jfree/chart/renderer/xy/junit/StackedXYBarRendererTests.java + (testEquals): Check new field, + (testHashCode): Likewise. + +2007-03-15 David Gilbert + + * source/org/jfree/chart/renderer/xy/DeviationRenderer.java + (drawItem): Removed calls to Java 1.6 methods. + +2007-03-15 David Gilbert + + * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java + (clone): Reimplemented, + * tests/org/jfree/chart/renderer/junit/DefaultPolarItemRendererTests.java + (testCloning): Added independence check. + +2007-03-14 David Gilbert + + * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java + (setPlotDiscontinuous): New method, + (equals): Check additional fields, + (clone): Reimplemented, + * tests/org/jfree/chart/renderer/xy/junit/StandardXYItemRendererTests.java + (testEquals): Check additional fields, + (testCloning): Check independence. + +2007-03-13 David Gilbert + + * source/org/jfree/chart/plot/CategoryPlot.java + (draw): Moved annotation drawing up to point where clipping still + applies. + +2007-03-13 David Gilbert + + * source/org/jfree/chart/plot/CategoryPlot.java + (DEFAULT_CROSSHAIR_VISIBLE): New field, + (DEFAULT_CROSSHAIR_STROKE): Likewise, + (DEFAULT_CROSSHAIR_PAINT): Likewise, + (CategoryPlot(CategoryDataset, CategoryAxis, ValueAxis, CategoryItemRenderer)): + Initialise crosshair fields, + (setRangeCrosshairStroke): Check for null stroke, + (setRangeCrosshairPaint): Check for null paint, + (draw): Call new drawRangeCrosshair() method, + (drawRangeCrosshair): New method, + * source/org/jfree/chart/plot/XYPlot.java + (setRangeCrosshairStroke): Added null argument check, + (setRangeCrosshairPaint): Likewise. + +2007-03-09 David Gilbert + + * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java + (drawItem): Handle horizontal plot orientation. + +2007-03-09 David Gilbert + + * source/org/jfree/chart/renderer/LookupPaintScale.java + (clone): Clone the lookup table, + * source/org/jfree/chart/renderer/xy/XYBlockRenderer.java + (clone): Clone the paint scale, + * tests/org/jfree/chart/renderer/junit/LookupPaintScaleTests.java + (testCloning): Check independence, + * tests/org/jfree/chart/renderer/xy/junit/XYBlockRendererTests.java + (testCloning): Check independence. + +2007-03-09 David Gilbert + + * source/org/jfree/data/category/DefaultIntervalCategoryDataset.java + (getSeriesIndex): Reimplemented, + (getColumnIndex): Reimplemented, + (getRowIndex): Delegate to getSeriesIndex(), + (getColumnCount): Reimplemented, + (getRowCount): Likewise, + (getSeries): Deprecated, + (getCategories): Deprecated, + (getItemCount): Deprecated. + +2007-03-08 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java + (drawItemPass1): Fix entity generation. + +2007-03-08 David Gilbert + + * experimental/org/jfree/experimental/chart/plot/dial/DialPlot.java + (hashCode): Fixed, + * experimental/org/jfree/experimental/chart/plot/dial/DialTextAnnotation.java + (hashCode): Fixed, + * experimental/org/jfree/experimental/chart/plot/dial/SimpleDialFrame.java + (hashCode): Fixed, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialFrame.java + (hashCode): Fixed, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialRange.java + (hashCode): Fixed. + +2007-03-08 David Gilbert + + * source/org/jfree/data/gantt/TaskSeriesCollection.java + (remove): Fix argument check, + * source/org/jfree/data/time/TimePeriodValuesCollection.java + (getSeries): Likewise, + * source/org/jfree/data/xy/DefaultTableXYDataset.java + (getSeries): Likewise, + * source/org/jfree/data/xy/XYSeriesCollection.java + (removeSeries): Likewise, + * tests/org/jfree/data/gantt/junit/TaskSeriesCollectionTests.java + (testRemove): New test method, + * tests/org/jfree/data/time/junit/TimePeriodValuesCollectionTests.java + (testGetSeries): Likewise, + * tests/org/jfree/data/xy/junit/DefaultTableXYDatasetTests.java + (testGetSeries): Likewise, + * tests/org/jfree/data/xy/junit/XYSeriesCollectionTests.java + (testGetSeries): Likewise, + (testRemoveSeries): Likewise. + +2007-03-08 David Gilbert + + * source/org/jfree/data/category/DefaultIntervalCategoryDataset.java + (getValue(Comparable, Comparable)): Check keys, + (getStartValue(Comparable, Comparable)): Likewise, + (getEndValue(Comparable, Comparable)): Likewise, + (setStartValue): Correct index range check, + (setEndValue): Likewise, + (equals): New method override, + (clone): Likewise, + (equal): New private method, + (clone(Number[][])): Likewise, + * tests/org/jfree/data/category/junit/DefaultIntervalCategoryDatasetTests.java: New file, + * tests/org/jfree/data/category/junit/DataCategoryPackageTests.java: + (suite): Added DefaultIntervalCategoryDatasetTests. + +2007-03-08 David Gilbert + + * source/org/jfree/data/category/DefaultCategoryDataset.java + (clone): New method override, + * tests/org/jfree/data/category/junit/DefaultCategoryDatasetTests.java + (testCloning): New method. + +2007-03-07 David Gilbert + + * source/org/jfree/chart/renderer/LookupPaintScale.java + (PaintItem): Implements Comparable, + (PaintItem.compareTo): New method, + (LookupPaintScale(double, double, Paint)): Initialise bounds, + (add): Reimplemented to ensure ordered list, + (getPaint): Check bounds and return default paint if value is outside, + * tests/org/jfree/chart/renderer/junit/LookupPaintScaleTests.java + (EPSILON): New field, + (testConstructor1): New method, + (testConstructor2): Likewise, + (testGeneral): Likewise. + +2007-03-07 David Gilbert + + * source/org/jfree/chart/axis/CategoryAxis.java + (drawCategoryLabels): Fix offset. + +2007-03-06 David Gilbert + + * source/org/jfree/chart/annotations/AbstractXYAnnotation.java + (hashCode): Implemented, + * source/org/jfree/chart/annotations/CategoryLineAnnotation.java + (hashCode): Reimplemented, + * source/org/jfree/chart/annotations/CategoryPointerAnnotation.java + (hashCode): Likewise, + * source/org/jfree/chart/annotations/CategoryTextAnnotation.java + (hashCode): Implemented, + * source/org/jfree/chart/annotations/XYPointerAnnotation.java + (hashCode): Likewise, + * source/org/jfree/chart/annotations/XYShapeAnnotation.java + (hashCode): Likewise. + +2007-03-06 David Gilbert + + * source/org/jfree/chart/HashUtilities.java + (hashCodeForDoubleArray): Accumulate result, + * tests/org/jfree/chart/junit/ChartPackageTests.java + (suite): Add HashUtilitiesTests, + * tests/org/jfree/chart/junit/HashUtilitiesTests.java: New file. + +2007-03-06 David Gilbert + + * source/org/jfree/chart/annotations/XYTextAnnotation.java + (setText): Added null argument check, + (setFont): Likewise, + (setPaint): Likewise, + (setTextAnchor): Likewise, + (setRotationAnchor): Likewise, + (hashCode): Reimplemented. + +2007-03-05 Sergei Ivanov + + * source/org/jfree/chart/ChartPanel.java + (paintComponent): Redraw the zoom rectangle and dispose the Graphics2D + instance, + (mouseDragged): Factor out zoom rectangle drawing, + (mouseReleased): Likewise, + (mouseMoved): Pass Graphics2D to drawAxisTrace methods, + (drawZoomRectangle): New method, + (drawHorizontalAxisTrace): Added Graphics2D parameter, + (drawVerticalAxisTrace): Likewise, + (displayPopupMenu): Fixed logical AND typo. + +2007-03-05 Sergei Ivanov + + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (drawItem): Reworked bar calculation to fix bug when rendering + against LogarithmicAxis. + +2007-03-05 David Gilbert + + * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java + (useOutlinePaint): New field, + (CandlestickRenderer(double, boolean, XYToolTipGenerator)): Initialise + new field, + (drawVolume): Deprecated, + (getDrawVolume): New method, + (getUseOutlinePaint): Likewise, + (setUseOutlinePaint): Likewise, + (drawItem): Use outline paint if flag is set, + (equals): Test useOutlinePaint flag, + * tests/org/jfree/chart/renderer/xy/junit/CandlestickRendererTests.java + (testEquals): Added check for useOutlinePaint flag. + +2007-03-05 David Gilbert + + * source/org/jfree/chart/plot/MeterPlot.java + (draw): Restore clip correctly, + * source/org/jfree/chart/plot/SpiderWebPlot.java + (draw): Likewise. + +2007-03-05 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (drawRangeGridlines): Check for null renderer, + * tests/org/jfree/chart/plot/junit/XYPlotTests.java + (testDrawRangeGridlines): New test method. + +2007-03-02 Sergei Ivanov + + * source/org/jfree/chart/axis/LogarithmicAxis.java + (switchedPow10): New method, + (adjustedLog10): Modified for clarity, + (adjustedPow10): New method, + (autoAdjustRange): Reformatting only, + (valueToJava2D): Likewise, + (java2dToValue): Use new methods, + (zoomRange): New method override, + * tests/org/jfree/chart/axis/junit/LogarithmicAxisTests.java + (MyLogarithmicAxis): New inner class, + (EPSILON): New constant, + (axis): New field, + (setUp): New method, + (testAdjustedLog10): Likewise, + (checkLogPowRoundTrip): Likewise, + (testSwitchedLog10): Likewise, + (checkSwitchedLogPowRoundTrip): Likewise, + (testJava2DToValue): Likewise, + (testValueToJava2D): Likewise, + (checkPointsToJava2D): Likewise, + (checkPointsToValue): Likewise, + (main): Likewise. + +2007-03-02 Sergei Ivanov + + * source/org/jfree/chart/plot/XYPlot.java + (draw): Updated crosshair drawing to take account of orientation + correctly (see bug 1671645). + +2007-03-01 Sergei Ivanov + + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (drawRangeMarker): Fixed drawing of interval markers, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (drawDomainMarker): Likewise, + (drawRangeMarker): Likewise. + +2007-02-28 David Gilbert + + * source/org/jfree/chart/renderer/AbstractRenderer.java + (event): New field, + (setSeriesVisible(Boolean, boolean)): Call fireChangeEvent() to notify, + (setSeriesVisible(int, Boolean, boolean)): Likewise, + (setBaseSeriesVisible(boolean, boolean)): Likewise, + (setSeriesVisibleInLegend(Boolean, boolean)): Likewise, + (setSeriesVisibleInLegend(int, Boolean, boolean)): Likewise, + (setBaseSeriesVisibleInLegend(boolean, boolean)): Likewise, + (setPaint(Paint, boolean)): Likewise, + (setSeriesPaint(int, Paint, boolean)): Likewise, + (setBasePaint(Paint, boolean)): Likewise, + (setFillPaint(Paint, boolean)): Likewise, + (setSeriesFillPaint(int, Paint, boolean)): Likewise, + (setBaseFillPaint(Paint, boolean)): Likewise, + (setOutlinePaint(Paint, boolean)): Likewise, + (setSeriesOutlinePaint(int, Paint, boolean)): Likewise, + (setBaseOutlinePaint(Paint, boolean)): Likewise, + (setStroke(Stroke, boolean)): Likewise, + (setSeriesStroke(int, Stroke, boolean)): Likewise, + (setBaseStroke(Stroke, boolean)): Likewise, + (setOutlineStroke(Stroke, boolean)): Likewise, + (setSeriesOutlineStroke(int, Stroke, boolean)): Likewise, + (setBaseOutlineStroke(Stroke, boolean)): Likewise, + (setShape(Shape, boolean)): Likewise, + (setSeriesShape(int, Shape, boolean)): Likewise, + (setBaseShape(Shape, boolean)): Likewise, + (setItemLabelsVisible(Boolean, boolean)): Likewise, + (setSeriesItemLabelsVisible(int, Boolean, boolean)): Likewise, + (setBaseItemLabelsVisible(Boolean, boolean)): Likewise, + (setItemLabelFont(Font, boolean)): Likewise, + (setSeriesItemLabelFont(int, Font, boolean)): Likewise, + (setBaseItemLabelFont(Font, boolean)): Likewise, + (setItemLabelPaint(Paint, boolean)): Likewise, + (setSeriesItemLabelPaint(int, Paint, boolean)): Likewise, + (setBaseItemLabelPaint(Paint, boolean)): Likewise, + (setPositiveItemLabelPosition(ItemLabelPosition, boolean)): Likewise, + (setSeriesPositiveItemLabelPosition(int, ItemLabelPosition, boolean)): + Likewise, + (setBasePositiveItemLabelPosition(ItemLabelPosition, boolean)): + Likewise, + (setNegativeItemLabelPosition(ItemLabelPosition, boolean)): Likewise, + (setSeriesNegativeItemLabelPosition(int, ItemLabelPosition, boolean)): + Likewise, + (setBaseNegativeItemLabelPosition(ItemLabelPosition, boolean)): + Likewise, + (setItemLabelAnchorOffset): Likewise, + (setCreateEntities(Boolean, boolean)): Likewise, + (setSeriesCreateEntities(int, Boolean, boolean)): Likewise, + (setBaseSeriesCreateEntities(Boolean, boolean)): Likewise, + (fireChangeEvent): New method, + (clone): Initialise event listener list and set event to null. + +2007-02-28 David Gilbert + + * source/org/jfree/chart/axis/SymbolAxis.java + (refreshTicksVertical): Pull check for tickLabelsOverlapping outside + first check. + +2007-02-28 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (setRangeAxisLocation(int, AxisLocation, boolean)): Fixed + copy-and-paste error. + +2007-02-27 David Gilbert + + * source/org/jfree/chart/renderer/xy/DeviationRenderer.java: New file, + * tests/org/jfree/chart/renderer/xy/junit/DeviationRendererTests.java: + New file, + * tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java + (suite): Add new tests. + +2007-02-27 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (setDomainAxisLocation(AxisLocation)): Delegate, + (setDomainAxisLocation(AxisLocation, boolean)): Likewise, + (setDomainAxisLocation(int, AxisLocation)): Likewise, + (setDomainAxisLocation(int, AxisLocation, boolean)): New method, + (setRangeAxisLocation(AxisLocation)): Delegate, + (setRangeAxisLocation(AxisLocation, boolean)): Likewise, + (setRangeAxisLocation(int, AxisLocation)): Likewise, + (setRangeAxisLocation(int, AxisLocation, boolean)): New method. + +2007-02-26 David Gilbert + + * source/org/jfree/chart/plot/CategoryPlot.java + (setDomainAxisLocation(AxisLocation, boolean)): Delegate argument + check, + (setDomainAxisLocation(int, AxisLocation)): Delegate to new method, + (setDomainAxisLocation(int, AxisLocation, boolean)): New method, + (setRangeAxisLocation(int, AxisLocation, boolean)): Added argument + check, + (draw): Removed redundant code. + +2007-02-26 David Gilbert + + * source/org/jfree/data/DefaultKeyedValues2D.java: Updated API docs, + * source/org/jfree/data/category/DefaultCategoryDataset.java: Likewise, + * tests/org/jfree/data/category/junit/DefaultCategoryDatasetTests.java: + (testGetValue2): New method, + (testAddValue): Likewise, + (testRemoveValue): Likewise, + * tests/org/jfree/data/junit/DefaultKeyedValues2DTests.java + (testRowCount): New method, + (testColumnCount): Likewise, + (testGetValue2): Likewise, + (testGetRowKey): Likewise, + (testGetColumnKey): Likewise, + (testRemoveValue): Likewise, + (testRemoveRow): Likewise. + +2007-02-22 David Gilbert + + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (createState): New method, + (initialise): Call createState(), + * source/org/jfree/chart/renderer/category/CategoryStepRenderer.java + (State): New class, + (line): Removed field, + (getLegendItem): New method override, + (createState): Likewise, + (drawLine): Added State parameter, + (drawItem): Updated calls to drawLine(), added entities, + (equals): Minor rearrangement, + * tests/org/jfree/chart/renderer/category/junit/CategoryStepRendererTests.java + (testCloning): Minor updates, + (testSerialization): Likewise. + +2007-02-21 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (clone): Reimplemented, + (equals): Added checks for useFillPaint and drawSeriesLineAsPath, + * tests/org/jfree/chart/renderer/xy/junit/XYLineAndShapeRendererTests.java + (testEquals): Check additional fields, + (testCloning): Check for independence. + +2007-02-20 David Gilbert + + * source/org/jfree/data/xy/YIntervalSeries.java + (getYHighValue): New method, + (getYLowValue): Likewise, + * source/org/jfree/data/xy/YIntervalSeriesCollection.java + (getX): Call method in YIntervalSeries to get result, + (getYValue): New method override, + (getStartYValue): Likewise, + (getEndYValue): Likewise, + (getY): Call method in YIntervalSeries to get result, + (getStartY): Likewise, + (getEndY): Likewise. + +2007-02-20 David Gilbert + + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (clone): Fix cloning of a number of fields, + (equals): Check additional fields, + * tests/org/jfree/chart/renderer/xy/junit/YIntervalRendererTests.java + (testEquals): Extended, + (testCloning): Check independence of clone. + +2007-02-20 David Gilbert + + * source/org/jfree/chart/labels/MultipleXYSeriesLabelGenerator.java + (clone): Reimplemented, + (equals): Likewise, + * tests/org/jfree/chart/labels/junit/LabelsPackageTests.java + (suite): Added MultipleXYSeriesLabelGeneratorTests, + * tests/org/jfree/chart/labels/junit/MultipleXYSeriesLabelGeneratorTests.java: + New file. + +2007-02-19 David Gilbert + + * source/org/jfree/chart/renderer/AbstractRenderer.java + (clone): handle some more fields correctly, + * tests/org/jfree/chart/renderer/junit/AbstractRendererTests.java + (testCloning): New method. + +2007-02-14 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java + (clone): Make a copy of legendArea; + * tests/org/jfree/chart/renderer/xy/junit/XYAreaRendererTests.java + (testCloning): Check independence. + +2007-02-14 David Gilbert + + * source/org/jfree/chart/plot/RingPlot.java + (setSectionDepth): Added event notification. + +2007-02-14 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java + (equals): New method override, + * tests/org/jfree/chart/renderer/xy/junit/XYStepAreaRendererTests.java + (testEquals): Added more checks. + +2007-02-13 David Gilbert + + * source/org/jfree/data/xy/XYIntervalSeriesCollection.java + (clone): Implemented, + * tests/org/jfree/data/xy/junit/XYIntervalSeriesCollectionTests.java + (testCloning): Check independence, + (testSerializable): Likewise, + * tests/org/jfree/data/xy/junit/XYIntervalSeriesTests.java + (testValues): New test. + +2007-02-13 David Gilbert + + * source/org/jfree/data/xy/XYIntervalSeries.java + (getXLowValue): New method, + (getXHighValue): Likewise, + (getYLowValue): Likewise, + (getYHighValue): Likewise, + * source/org/jfree/data/xy/XYIntervalSeriesCollection.java + (getX): Simplified, + (getStartXValue): New method override, + (getEndXValue): Likewise, + (getYValue): Likewise, + (getStartYValue): Likewise, + (getEndYValue): Likewise, + (getY): Simplified, + (getStartX): Likewise, + (getEndX): Likewise, + (getStartY): Likewise, + (getEndY): Likewise. + +---------- JFREECHART 1.0.4 RELEASED ------------------------ + +2007-02-09 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (getLegendItem): Check drawBarOutline flag, + (clone): Make a copy of the legendBar shape, + * tests/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java + (testCloning): Added independence check. + +2007-02-07 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (draw): Check renderer index against dataset count, + (drawDomainMarkers): Likewise, + (drawRangeMarkers): Likewise, + * tests/org/jfree/chart/plot/junit/CategoryPlotTests.java + (test1654215): New test, + * tests/org/jfree/chart/plot/junit/XYPlotTests.java: + (test1654215): New test. + +2007-02-07 David Gilbert + + * swt/org/jfree/experimental/chart/swt/demo/SWTBarChartDemo1.java + (main): Set offscreen buffer flag to true. + +2007-02-07 David Gilbert + + * source/org/jfree/chart/plot/PolarPlot.java + (setAngleLabelPaint): Check for null argument, + (equals): Check cornerTextItems list, + (clone): Clone the cornerTextItems list, + (translateValueThetaRadiusToJava2D): Don't let value go below axis + minimum, + * tests/org/jfree/chart/plot/junit/PolarPlotTests.java + (testEquals): Added check for corner text items, + (testCloning): Added independence checks. + +2007-02-07 David Gilbert + + * swt/org/jfree/experimental/chart/swt/editor/SWTAxisEditor.java + (SWTAxisEditor(Composite, Axis, int)): Check for null axis label. + +2007-02-06 David Gilbert + + * source/org/jfree/chart/plot/CombinedDomainXYPlot.java + (draw): Draw shared axis after subplots, + * source/org/jfree/chart/plot/CombinedRangeXYPlot.java + (draw): Likewise. + +2007-02-06 David Gilbert + + * source/org/jfree/chart/plot/CrosshairState.java + (domainAxisIndex): New field, + (rangeAxisIndex): New fields, + (updateCrosshairPoint(double, double, double, double, + PlotOrientation)): Deprecated, + (updateCrosshairPoint(double, double, int, int, double, double, + PlotOrientation)): New method, + (updateCrosshairX(double)): Deprecated, + (updateCrosshairX(double, int)): New method, + (updateCrosshairY(double)): Deprecated, + (updateCrosshairY(double, int)): New method, + (getDomainAxisIndex): New method, + (getRangeAxisIndex): New method, + * source/org/jfree/chart/plot/XYPlot.java + (draw): Updated to store axis indices in CrosshairState, then draw + crosshairs using new methods, + (drawDomainCrosshair): New method, + (drawRangeCrosshair): New method, + (getDomainAxisIndex): Changed from protected to public, + (getRangeAxisIndex): Likewise, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (updateCrosshairValues(CrosshairState, double, double, double, double, + PlotOrientation): Deprecated, + (updateCrosshairValues(CrosshairState, double, double, int, int, + double, double, PlotOrientation): New method, + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java + (drawItem): Call revised updateCrosshairValues() method, + * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYDotRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYStepRenderer.java + (drawItem): Likewise. + +2007-02-06 David Gilbert + + * source/org/jfree/chart/ChartUtilities.java: API doc updates, + * source/org/jfree/chart/entity/ChartEntity.java: Likewise, + * source/org/jfree/chart/imagemap/ImageMapUtilities.java: Likewise. + +2007-02-06 David Gilbert + + * source/org/jfree/chart/plot/SpiderWebPlot.java + (getPlotValue): Changed to protected. + +2007-02-05 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java + (drawItemPass1): Added extra call to updateCrosshairValues(). + +2007-02-05 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (addRangeMarker): Register plot as a listener with the marker, + * tests/org/jfree/chart/plot/junit/CategoryPlotTests.java + (testAddDomainMarker): New test, + (testAddRangeMarker): Likewise, + * tests/org/jfree/chart/plot/junit/XYPlotTests.java + (testAddDomainMarker): New test, + (testAddRangeMarker): Likewise. + +2007-02-05 David Gilbert + + * source/org/jfree/chart/plot/SpiderWebPlot.java + (draw): Draw axes before first polygon, + (drawRadarPoly): Remove axis drawing code. + +2007-02-05 David Gilbert + + * source/org/jfree/chart/plot/SpiderWebPlot.java + (axisLinePaint): New field, + (axisLineStroke): New field, + (SpiderWebPlot(CategoryDataset, TableOrder)): Initialise new fields, + (getAxisLinePaint): New method, + (setAxisLinePaint): Likewise, + (getAxisLineStroke): Likewise, + (setAxisLineStroke): Likewise, + (drawRadarPoly): Fixed problems with paint and stroke on axis lines, + (equals): Updated for new fields, + (clone): New method override, + (writeObject): Updated for new fields, + (readObject): Likewise, + * tests/org/jfree/chart/plot/junit/SpiderWebPlotTests.java + (testEquals): Added checks for new fields, + (testCloning): Added independence checks. + +2007-02-05 David Gilbert + + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (setArtifactPaint): Check for null, generate event, + (setItemMargin): Generate event, + * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java + (setArtifactPaint): Check for null, generate event, + (drawHorizontalItem): Partially implemented (no outliers yet). + +2007-02-02 David Gilbert + + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java + (drawItem): Fixed crosshair y-value. + +2007-02-02 David Gilbert + + * experiments/org/jfree/experimental/chart/renderer/xy/VectorRenderer.java + (drawItem): Fixed calls to JDK 1.6-only methods; + (equals): Check additional fields. + +2007-02-02 David Gilbert + + * experimental/org/jfree/experimental/chart/annotations/XYTitleAnnotation.java: + New file, + * experimental/org/jfree/experimental/chart/demo/XYTitleAnnotationDemo1.java: + New file, + * experimental/org/jfree/experimental/chart/util/XYCoordinateType.java: + New file. + +2007-02-02 David Gilbert + + * ant/build.xml: Updated version numbers, + * ant/build-swt.xml: Likewise. + +2007-02-02 David Gilbert + + * NEWS: updated, + * source/org/jfree/chart/resources/JFreeChartResources.java + (CONTENTS): Updated version number and date. + +2007-02-02 David Gilbert + + * source/org/jfree/chart/labels/StandardXYItemLabelGenerator.java: + (StandardXYItemLabelGenerator(String, NumberFormat, DateFormat)): Made + public, + * source/org/jfree/chart/labels/StandardXYToolTipGenerator.java: + (StandardXYToolTIpGenerator(String, NumberFormat, DateFormat)): + Likewise. + +2007-02-02 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (setUseYInterval): Only notify if flag changes, + * source/org/jfree/chart/renderer/xy/XYBlockRenderer.java + (getPaintScale): New method. + +2007-01-31 David Gilbert + + * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo1.java: + Removed and added to JFreeChart demo collection, + * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo2.java: + Likewise, + * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo3.java: + Likewise. + +2007-01-31 David Gilbert + + * source/org/jfree/chart/ClipPath.java: Deprecated, + * source/org/jfree/chart/axis/ColorBar.java: Likewise, + * source/org/jfree/chart/editor/PaletteChooserPanel.java: Likewise, + * source/org/jfree/chart/editor/PaletteSample.java: Likewise, + * source/org/jfree/chart/plot/ColorPalette.java: Likewise, + * source/org/jfree/chart/plot/ContourPlot.java: Likewise, + * source/org/jfree/chart/plot/ContourPlotUtilities.java: Likewise, + * source/org/jfree/chart/plot/ContourValuePlot.java: Likewise, + * source/org/jfree/chart/plot/GreyPalette.java: Likewise, + * source/org/jfree/chart/plot/RainbowPalette.java: Likewise, + * source/org/jfree/data/contour/ContourDataset.java: Likewise, + * source/org/jfree/data/contour/DefaultContourDataset.java: Likewise, + * source/org/jfree/data/contour/NonGridContourDataset.java: Likewise, + * source/org/jfree/data/contour/package.html: Updated. + +2007-01-31 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBlockRenderer.java: Moved from + experimental, + * experimental/org/jfree/experimental/chart/renderer/xy/XYBlockRenderer.java: + Moved to main API, + * experimental/org/jfree/experimental/chart/renderer/xy/junit/XYBlockRendererTests.java: + Likewise, + * tests/org/jfree/chart/renderer/junit/RendererPackageTests.java + (suite): Added new tests, + * tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java + (suite): Added XYBlockRendererTests, + * tests/org/jfree/chart/renderer/xy/junit/XYBlockRendererTests.java: + New file, + * tests/org/jfree/chart/title/junit/TitlePackageTests.java + (suite): Added new tests. + +2007-01-31 David Gilbert + + * org/jfree/chart/renderer/GrayPaintScale.java: Moved from + experimental, + * org/jfree/chart/renderer/LookupPaintScale.java: Likewise, + * org/jfree/chart/renderer/PaintScale.java: Likewise, + * org/jfree/chart/title/PaintScaleLegend.java: Likewise, + * experimental/org/jfree/experimental/chart/renderer/GrayPaintScale.java: + Moved to main API, + * experimental/org/jfree/experimental/chart/renderer/LookupPaintScale.java: + Likewise, + * experimental/org/jfree/experimental/chart/renderer/PaintScale.java: + Likewise, + * experimental/org/jfree/experimental/chart/title/PaintScaleLegend.java: + Likewise, + * experimental/org/jfree/experimental/chart/renderer/junit/GrayPaintScaleTests.java: + Likewise, + * experimental/org/jfree/experimental/chart/renderer/junit/LookupPaintScaleTests.java: + Likewise, + * experimental/org/jfree/experimental/chart/title/junit/PaintScaleLegendTests.java: + Likewise, + * tests/org/jfree/chart/renderer/junit/GrayPaintScaleTests.java: + Moved from experimental, + * tests/org/jfree/chart/renderer/junit/LookupPaintScaleTests.java: + Moved from experimental, + * tests/org/jfree/chart/title/junit/PaintScaleLegendTests.java: + Moved from experimental. + +2007-01-31 David Gilbert + + * experimental/org/jfree/experimental/chart/renderer/GrayPaintScale.java: + (min): Renamed lowerBound; + (max): Renamed upperBound; + (GrayPaintScale): Updated for renamed fields, + (getLowerBound): New method, + (getUpperBound): New method, + (getPaint): Updated for renamed fields, + (equals): Likewise, + * experimental/org/jfree/experimental/chart/renderer/LookupPaintScale.java: + (PaintItem): Implemented Serializable, + (PaintItem.paint): Marked transient, + (PaintItem.equals): New method, + (PaintItem.writeObject): Likewise, + (PaintItem.readObject): Likewise, + (lowerBound): New field, + (upperBound): New field, + (defaultPaint): Marked transient, + (LookupPaintScale()): Delegate to other constructor, + (LookupPaintScale(double, double, Paint): New constructor, + (getDefaultPaint): New method, + (getLowerBound): New method, + (getUpperBound): New method, + (equals): Check new fields, + (writeObject): New method, + (readObject): New method, + * experimental/org/jfree/experimental/chart/renderer/PaintScale.java: + (getLowerBound): New method, + (getUpperBound): Likewise, + * experimental/org/jfree/experimental/chart/renderer/junit/LookupPaintScaleTests.java + (testEquals): Check more fields, + (testCloning): Added new check, + (testSerialization): Likewise. + +2007-01-31 David Gilbert + + * experimental/org/jfree/experimental/chart/title/PaintScaleLegend.java + (arrange): Implemented arrangement for no constraints. + +2007-01-31 Henry Proudhon + + * swt/org/jfree/experimental/chart/swt/ChartComposite.java: + Fixed some issues with the trace lines, fixed cross hair not being + drawn, added getter and setter methods for the trace lines. + * swt/org/jfree/experimental/chart/swt/demo/SWTTimeSeries.java: + New class to test the cross hair. + * swt/org/jfree/experimental/swt/SWTGraphics2D.java: + Moved the dummy JPanel to SWTUtils.java, implemented the drawLine + method. + * swt/org/jfree/experimental/swt/SWTUtils.java: Moved the dummy JPanel + from SWTGraphics2D.java, added a new convert method for mouse events. + +2007-01-30 David Gilbert + + * experimental/org/jfree/experimental/chart/demo/VectorPlotDemo1.java: + New file, + * experimental/org/jfree/experimental/chart/renderer/xy/VectorRenderer.java: + New file, + * experimental/org/jfree/experimental/chart/renderer/xy/junit/VectorRendererTests.java: + New file. + +2007-01-30 David Gilbert + + * experimental/org/jfree/experimental/data/xy/Vector.java: + New file, + * experimental/org/jfree/experimental/data/xy/VectorDataItem.java: + New file, + * experimental/org/jfree/experimental/data/xy/VectorSeries.java: + New file, + * experimental/org/jfree/experimental/data/xy/VectorSeriesCollection.java: + New file, + * experimental/org/jfree/experimental/data/xy/VectorXYDataset.java: + New file, + * experimental/org/jfree/experimental/data/xy/XYCoordinate.java: + New file, + * experimental/org/jfree/experimental/data/xy/junit/VectorDataItemTests.java: + New file, + * experimental/org/jfree/experimental/data/xy/junit/VectorSeriesCollectionTests.java: + New file, + * experimental/org/jfree/experimental/data/xy/junit/VectorSeriesTests.java: + New file, + * experimental/org/jfree/experimental/data/xy/junit/VectorTests.java: + New file, + * experimental/org/jfree/experimental/data/xy/junit/XYCoordinateTests.java: + New file. + +2007-01-30 David Gilbert + + * source/org/jfree/data/general/DefaultValueDataset.java + (DefaultValueDataset(Number)): Call super() explicitly, + (equals): Tidied up. + +2007-01-30 David Gilbert + + * source/org/jfree/data/xy/XYBarDataset.java + (getXValue): New method override, + (getYValue): Likewise, + (getStartXValue): Likewise, + (getEndXValue): Likewise, + (getStartYValue): Likewise, + (getEndYValue): Likewise. + +2007-01-30 David Gilbert + + * tests/org/jfree/data/xy/junit/XYSeriesTests.java + (testToArray): Fixed code that won't compile with Java 1.4, + (testToArrayExample): Likewise. + +2007-01-29 Henry Proudhon + + * swt/org/jfree/experimental/swt/SWTGraphics2D.java + (fillRect): switch between foregroung and background colors to correct + bug in FastScatterPlotDemo. + +2007-01-26 David Gilbert + + * tests/org/jfree/chart/JFreeChartTestSuite.java + (suite): Added OHLCPackageTests. + +2007-01-25 David Gilbert + + * source/org/jfree/data/xy/DefaultXYDataset.java: + Implemented PublicCloneable, + * source/org/jfree/data/xy/XYBarDataset.java + (getUnderlyingDataset): New method, + (getBarWidth): Likewise, + (setBarWidth): Likewise, + (equals): New method override, + (clone): Likewise, + * tests/org/jfree/data/xy/junit/DataXYPackageTests.java + (suite): Added new XYBarDatasetTests, + * tests/org/jfree/data/xy/junit/XYBarDatasetTests.java: New class. + +2007-01-25 David Gilbert + + * source/org/jfree/chart/labels/AbstractXYItemLabelGenerator.java + (AbstractXYItemLabelGenerator(String, NumberFormat, DateFormat)): + New constructor, + (clone): Clone date formatters, + * source/org/jfree/chart/labels/StandardXYItemLabelGenerator.java + (StandardXYItemLabelGenerator(String, NumberFormat, DateFormat)): + New constructor, + * source/org/jfree/chart/labels/StandardXYToolTipGenerator.java + (StandardXYToolTipGenerator(String, NumberFormat, DateFormat)): + New constructor, + * tests/org/jfree/chart/labels/junit/StandardXYItemLabelGeneratorTests.java: + (testCloning): Added independence checks. + +2007-01-24 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java + (equals): New method override, + * tests/org/jfree/chart/renderer/xy/junit/XYBubbleRendererTests.java + (testEquals): Strengthened test. + +2007-01-24 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java + (roundXCoordinates): New field, + (XYDifferenceRenderer()): Initialise roundXCoordinates, + (getRoundXCoordinates): New method, + (setRoundXCoordinates): Likewise, + (drawItemPass0): Perform optional rounding of x-coordinates in Java2D + space, + (equals): Check roundXCoordinates field, + (clone): Clone the legendLine shape, + * tests/org/jfree/chart/renderer/xy/junit/XYDifferenceRendererTests.java + (testEquals): Added check for roundXCoordinates field, + (testCloning): Check for clone independence. + +2007-01-23 David Gilbert + + * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo1.java: + (createChart): Tweak settings on chart, + * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo2.java: + (createChart): Likewise, + * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo3.java: + (createChart): Likewise, + * experimental/org/jfree/experimental/chart/title/PaintScaleLegend.java: + (stripOutlineVisible): New field, + (backgroundPaint): Don't initialise here, + (PaintScaleLegend): Update initialisation, + (isStripOutlineVisible): New method, + (setStripOutlineVisible): Likewise, + (getBackgroundPaint): Likewise, + (setBackgroundPaint): Likewise, + (SUBDIVISIONS): New private field, + (draw): Use SUBDIVISIONS, + (equals): Updated for new fields, + * experimental/org/jfree/experimental/chart/title/junit/PaintScaleLegendTests.java: + (testEquals): Test new fields. + +2007-01-22 David Gilbert + + * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo1.java: + (createChart): Added PaintScaleLegend, + * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo2.java: + (createChart): Likewise, + * experimental/org/jfree/experimental/chart/demo/XYBlockChartDemo3.java: + (createChart): Likewise, + * experimental/org/jfree/experimental/chart/title/PaintScaleLegend.java: + New class, + * experimental/org/jfree/experimental/chart/title/junit/PaintScaleLegendTests.java: + New test class. + +2007-01-18 David Gilbert + + * source/org/jfree/chart/axis/DateAxis.java + (nextStandardDate): Use time zone for calendar. + +2007-01-18 David Gilbert + + * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java + (drawStackHorizontal): Handle inverted axis, + (createHorizontalBlock): New method, + (drawStackVertical): Handle inverted axis, + (createVerticalBlock): New method. + +2007-01-18 David Gilbert + + * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java + (createStackedValueList): On null value, continue don't break, + * tests/org/jfree/chart/renderer/category/junit/StackedBarRenderer3DTests.java: + Added new test methods. + +2007-01-18 David Gilbert + + * source/org/jfree/data/DefaultKeyedValues2D.java + (getValue(Comparable, Comparable)): Handle case where row doesn't + explicitly define a value for a valid column key, + * tests/org/jfree/data/junit/DefaultKeyedValues2DTests.java + (testSparsePopulation): New test method. + +2007-01-17 David Gilbert + + * source/org/jfree/chart/ChartFactory.java + (createBoxAndWhiskerChart(String, String, String, + BoxAndWhiskerCategoryDataset, boolean): New method, + * source/org/jfree/chart/JFreeChart.java + (JFreeChartInfo()): Added new contributor. + +2007-01-17 David Gilbert + + * source/org/jfree/data/category/DefaultIntervalCategoryDataset.java: + Removed @author tag and reformatted source code, + * source/org/jfree/data/category/IntervalCategoryDataset.java: Likewise, + * source/org/jfree/data/contour/ContourDataset.java: Likewise, + * source/org/jfree/data/contour/DefaultContourDataset.java: Likewise. + +2007-01-17 David Gilbert + + * source/org/jfree/chart/renderer/category/BarRenderer3D.java + (drawDomainGridline): Use correct value for x2, + * source/org/jfree/chart/renderer/category/LineRenderer3D.java + (setWallPaint): Check for null argument, + (drawDomainGridline): Use correct value for x2. + +2007-01-17 David Gilbert + + * source/org/jfree/chart/plot/ColorPalette.java: Removed @author tag + and reformatted source code, + * source/org/jfree/chart/plot/CompassPlot.java: Likewise, + * source/org/jfree/chart/plot/ContourPlot.java: Likewise, + * source/org/jfree/chart/plot/ContourPlotUtilities.java: Likewise, + * source/org/jfree/chart/plot/ContourValuePlot.java: Likewise, + * source/org/jfree/chart/plot/GreyPalette.java: Likewise, + * source/org/jfree/chart/plot/JThermometer.java: Likewise, + * source/org/jfree/chart/plot/PolarPlot.java: Likewise, + * source/org/jfree/chart/plot/RainbowPalette.java: Likewise, + * source/org/jfree/chart/plot/ThermometerPlot.java: Likewise. + +2007-01-17 David Gilbert + + * source/org/jfree/chart/plot/MultiplePiePlot.java + (prefetchSectionPaints): Check for paint settings in underlying + PiePlot. + +2007-01-17 David Gilbert + + * source/org/jfree/chart/PaintMap.java + (PaintMap()): Use HashMap instead of TreeMap, + (readObject): Likewise, + * tests/org/jfree/chart/junit/PaintMapTests.java + (testKeysOfDifferentClasses): New test method. + +2007-01-16 David Gilbert + + * swt/org/jfree/experimental/swt/SWTUtils.java + (toAwtFont): Call getHeight() rather than accessing height field + directly. + +2007-01-16 David Gilbert + + * source/org/jfree/chart/plot/CompassPlot.java: Updated API docs. + +2007-01-16 David Gilbert + + * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java + (createStackedValueList): New method, + (drawItem): Reimplemented, + (drawStackHorizontal): New method, + (drawStackVertical): New method. + +2007-01-16 David Gilbert + + * source/org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGenerator.java: + Removed @author tag from API docs, + * source/org/jfree/chart/imagemap/ImageMapUtilities: Likewise, + * source/org/jfree/chart/imagemap/OverLIBToolTipTagFragmentGenerator.java: + Likewise, + * source/org/jfree/chart/imagemap/StandardToolTipTagFragmentGenerator.java: + Likewise, + * source/org/jfree/chart/imagemap/StandardURLTagFragmentGenerator.java: + Likewise, + * source/org/jfree/chart/imagemap/ToolTipTagFragmentGenerator.java: + Likewise. + +2007-01-16 David Gilbert + + * source/org/jfree/chart/annotations/TextAnnotation.java + (setText): Added argument check, + (setFont): Likewise, + (setPaint): Likewise, + (setTextAnchor): Likewise, + (hashCode): Reimplemented. + +2007-01-15 David Gilbert + + * source/org/jfree/chart/axis/DateAxis.java + (getTimeZone): New method, + (setTimeZone): Likewise. + +2007-01-15 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (setWeight): Notify listeners, + (setRangeZeroBaselinePaint): Check for null argument, + (drawRangeMarkers): Use axis for dataset/renderer. + +2007-01-15 David Gilbert + + * source/org/jfree/data/xy/XYSeries.java + (toArray): New method, + * tests/org/jfree/data/xy/junit/XYSeriesTests.java + (testToArray): New test, + (testToArrayExample): Likewise. + +2007-01-11 David Gilbert + + * source/org/jfree/chart/plot/Plot.java + (setNoDataMessage): Notify listeners, + (setNoDataMessageFont): Check for null, and notify listeners, + (setNoDataMessagePaint): Likewise, + plus lots of small API doc updates. + +2007-01-10 David Gilbert + + * ant/build.xml + (compile-tests): New target, + (test): Likewise, + * source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java + (equals): Include attributedLabels in the test, + * tests/org/jfree/chart/axis/junit/NumberAxisTests.java + (testSetRangeType): Comment out temporarily. + +2007-01-10 David Gilbert + + * source/org/jfree/data/time/Week.java + (next): Don't go past maximum week in year. + +2007-01-10 David Gilbert + + * tests/org/jfree/chart/annotations/junit/XYImageAnnotationTests.java + (testSerialization): Commented out failing test, + * tests/org/jfree/chart/axis/junit/NumberAxisTests.java + (testCloning): Print stack trace, + (testSerialization): Likewise, + (testSetRangeType): New test, + (testSetLowerBound): New test, + * tests/org/jfree/chart/plot/junit/XYPlotTests.java + (testGetDatasetCount): Commented out failing test. + +2006-12-27 Thomas Morgner + + * source/org/jfree/chart/servlet/ChartDeleter.java: Implemented + Serializable. + +2006-12-19 David Gilbert + + * source/org/jfree/chart/ChartUtilities.java: API doc updates and + source reformatting. + +2006-12-13 David Gilbert + + * source/org/jfree/chart/LegendItem.java + (fillPaintTransformer): New field, + (LegendItem): Initialise fillPaintTransformer field, + (getFillPaintTransformer): New method, + (setFillPaintTransformer): Likewise, + (equals): Check fillPaintTransformer attribute, + * source/org/jfree/chart/renderer/category/BarRenderer.java + (getLegendItem): Use gradientPaintTransformer if available, + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/title/LegendGraphic.java + (fillPaintTransformer): New field, + (LegendGraphic): Initialise fillPaintTransformer, + (getFillPaintTransformer): New method, + (setFillPaintTransformer): Likewise, + (draw): Added support for GradientPaint, + (equals): Check fillPaintTransformer field, + (hashCode): Implemented, + (clone): Clone mutable fields, + * source/org/jfree/chart/title/LegendTitle.java + (createLegendItemBlock): Set gradientPaintTransformer, + * tests/org/jfree/chart/junit/LegendItemTests.java + (testEquals): Extended for new field, + * tests/org/jfree/chart/title/junit/LegendGraphicTests.java + (testEquals): Extended for new field, + (testCloning): Added check for independence, + (testCloning2): New method. + +2006-12-11 David Gilbert + + * source/org/jfree/chart/renderer/xy/ClusteredXYBarRenderer.java + (drawItem): Add support for GradientPaint. + +2006-12-11 David Gilbert + + * source/org/jfree/chart/axis/NumberAxis.java + (estimateMaximumTickLabelWidth): Use format override if set. + +2006-12-11 Henry Proudhon + + * swt/org/jfree/experimental/chart/swt/ChartComposite.java + (MouseUp event) fix popup menu location, patch sent by Fabrizio Giustina. + +2006-12-11 David Gilbert + + * source/org/jfree/data/time/Minute.java + (previous): Fix bug for first minute in hour, + * tests/org/jfree/data/time/junit/MinuteTests.java + (test1611872): New method. + +2006-12-07 David Gilbert + + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (equals): Check additional fields, + * tests/org/jfree/chart/renderer/category/junit/AbstractCategoryItemRendererTests.java + (testEquals): New test. + +2006-12-07 David Gilbert + + * source/org/jfree/chart/renderer/category/BarRenderer3D.java + (equals): New method override, + * tests/org/jfree/chart/renderer/category/junit/BarRenderer3DTests.java + (testEquals): Check all fields. + +2006-12-06 Henry Proudhon + + * swt/org/jfree/experimental/chart/swt/ChartComposite.java + (displayToolTips): New field, + (ChartComposite): modified event listener accordingly, + (setDisplayToolTips): New method, + (getToolTipText): New method (more or less copied from ChartPanel). + +2006-12-06 David Gilbert + + * source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java + (drawItem): Handle GradientPaint, + * tests/org/jfree/chart/renderer/xy/junit/StackedXYBarRendererTests.java + (testSerialization): Check handling of GradientPaint. + +2006-12-04 David Gilbert + + * source/org/jfree/chart/renderer/category/BarRenderer.java + (initialise): Calculate clip bounds from correct axis. + +2006-12-04 David Gilbert + + * source/org/jfree/data/time/ohlc/OHLC.java: New file, + * source/org/jfree/data/time/ohlc/OHLCItem.java: New file, + * source/org/jfree/data/time/ohlc/OHLCSeries.java: New file, + * source/org/jfree/data/time/ohlc/OHLCSeriesCollection.java: New file, + * source/org/jfree/data/time/ohlc/package.html: New file, + * tests/org/jfree/data/time/ohlc/junit/OHLCItemTests.java: New file, + * tests/org/jfree/data/time/ohlc/junit/OHLCPackageTests.java: New file, + * tests/org/jfree/data/time/ohlc/junit/OHLCSeriesCollectionTests.java: + New tests, + * tests/org/jfree/data/time/ohlc/junit/OHLCSeriesTests.java: New file, + * tests/org/jfree/data/time/ohlc/junit/OHLCTests.java: New file. + +2006-12-01 David Gilbert + + * source/org/jfree/chart/renderer/category/LineRenderer3D.java + (equals): New method override, + (writeObject): New method, + (readObject): New method, + * tests/org/jfree/chart/renderer/category/junit/LineRenderer3DTests.java + (suite): Use correct class name, + (testEquals): Extended. + +2006-12-01 David Gilbert + + * source/org/jfree/chart/annotation/XYImageAnnotation.java + (anchor): New field, + (XYImageAnnotation(double, double, Image)): Delegated, + (XYImageAnnotation(double, double, Image, RectangleAnchor)): New + constructor, + (getX): New method, + (getY): New method, + (getImage): New method, + (getImageAnchor): New method, + (draw): Adjust image position, + (equals): Check anchor field, + * tests/org/jfree/chart/annotation/junit/XYImageAnnotationTests.java + (testEquals): Extended, + (testHashCode): Simplified, + (testCloning): Reformatted, + (testSerialization): Likewise. + +2006-12-01 David Gilbert + + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java: + (getLegendItem): Check that series is visible, + * source/org/jfree/chart/renderer/category/AreaRenderer.java + (getLegendItem): Check that series is visible, + (drawItem): Return early if the item is not visible, + * source/org/jfree/chart/renderer/category/CategoryStepRenderer.java + (drawItem): Return early if the item is not visible. + +2006-12-01 David Gilbert + + * source/org/jfree/chart/plot/PlotRenderingInfo.java + (clone): Implemented properly, + * tests/org/jfree/chart/plot/junit/PlotRenderingInfoTests.java + (testEquals): Extended, + (testCloning): Likewise. + +2006-12-01 David Gilbert + + * source/org/jfree/chart/ChartRenderingInfo.java + (equals): Test entities, + (clone): Implemented properly, + * tests/org/jfree/chart/junit/ChartRenderingInfoTests.java + (testEquals): Extended, + (testClone): Check for independence. + +2006-12-01 David Gilbert + + * source/org/jfree/chart/entity/StandardEntityCollection.java + (clone): Implemented properly, + * tests/org/jfree/chart/entity/junit/StandardEntityCollectionTests.java + (testEquals): Extended, + (testCloning): Likewise. + +2006-11-30 Henry Proudhon + + * swt/org/jfree/experimental/chart/swt/ChartComposite.java + (ChartComposite): Modified mouse and paint listener to improve zoom + handling, + (getPointInRectangle, zoom, scale, getScreenDataArea): Signature + methods have been modified (Rectangle2D -> Rectangle). + +2006-11-30 David Gilbert + + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java + (getRoundXCoordinates): New method, + (setRoundXCoordinates): New method, + (equals): New method override, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java + (plotLines): Removed field, + (setOutline): Notify listeners, + (getPlotLines): Deprecated redundant method, + (equals): New method override, + (clone): Clone the legend shape, + * tests/org/jfree/chart/renderer/xy/junit/StackedXYAreaRenderer2Tests.java + (testEquals): Extended, + * tests/org/jfree/chart/renderer/xy/junit/XYAreaRenderer2Tests.java + (testEquals): Extended, + (testCloning): Likewise. + +2006-11-29 David Gilbert + + * source/org/jfree/chart/plot/CategoryPlot.java + (draw): Set clip earlier to stop markers exceeding plot bounds. + +2006-11-29 David Gilbert + + * source/org/jfree/chart/ChartFactory.java + (createXYBarChart): Use time based tool tips if DateAxis is requested. + +2006-11-28 Henry Proudhon + + * swt/org/jfree/experimental/chart/swt/ChartComposite.java + (horizontalAxisTrace): New field, + (verticalAxisTrace): New field, + (verticalTraceLineX): New field, + (horizontalTraceLineY): New field, + (ChartComposite): Implemented trace line painting. + +2006-11-28 David Gilbert + + * source/org/jfree/data/xy/DefaultIntervalXYDataset.java + (hashCode): New method override, + (clone): Likewise, + * source/org/jfree/data/xy/DefaultXYDataset.java + (hashCode): Likewise, + * source/org/jfree/data/xy/DefaultXYZDataset.java + (hashCode): Likewise, + * tests/org/jfree/data/xy/junit/DefaultIntervalXYDatasetTests.java + (testCloning2): New method, + * tests/org/jfree/data/xy/junit/DefaultOHLCDatasetTests.java + (testEquals): Added more checks. + +2006-11-28 David Gilbert + + * source/org/jfree/data/xy/DefaultHighLowDataset.java + (DefaultHighLowDataset): Added argument checks, + (equals): New method override, + * tests/org/jfree/data/xy/junit/DefaultHighLowDatasetTests.java: New + file, + * tests/org/jfree/data/xy/junit/DataXYPackageTests.java + (suite): Added DefaultHighLowDatasetTests. + +2006-11-27 David Gilbert + + * source/org/jfree/data/xy/MatrixSeriesCollection.java + (clone): New method override, + * source/org/jfree/data/xy/XIntervalSeriesCollection.java + (clone): New method override, + * source/org/jfree/data/xy/XYSeriesCollection.java + (clone): New method override, + * source/org/jfree/data/xy/YIntervalSeriesCollection.java + (clone): New method override, + * tests/org/jfree/data/xy/junit/DataXYPackageTests.java + (suite): Added new MatrixSeriesCollectionTests, + * tests/org/jfree/data/xy/junit/MatrixSeriesCollectionTests.java: New + file, + * tests/org/jfree/data/xy/junit/XIntervalSeriesCollectionTests.java + (testCloning): Check independence, + * tests/org/jfree/data/xy/junit/XYSeriesCollectionTests.java + (testCloning): Check independence, + * tests/org/jfree/data/xy/junit/YIntervalSeriesCollectionTests.java + (testCloning): Check independence. + +2006-11-27 David Gilbert + + * source/org/jfree/data/xy/MatrixSeries.java + (equals): Test values, + * tests/org/jfree/data/xy/junit/MatrixSeriesTests.java: + (testEquals): Added more checks. + +2006-11-24 David Gilbert + + * source/org/jfree/chart/labels/StandardXYSeriesLabelGenerator.java + (equals): Fixed, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (setLegendItemLabelGenerator): Notify listeners, + (setLegendItemToolTipGenerator): Likewise, + (setLegendITemURLGenerator): Likewise, + (clone): Clone generators, + * tests/org/jfree/chart/labels/junit/LabelsPackageTests.java + (suite): Added new test, + * tests/org/jfree/chart/labels/junit + /StandardXYSeriesLabelGeneratorTests.java: New file, + * tests/org/jfree/chart/renderer/xy/junit + /AbstractXYItemRendererTests.java + (testCloning_LegendItemLabelGenerator): New test method, + (testCloning_LegendItemToolTipGenerator): New test method, + (testCloning_LegendItemURLGenerator): New test method. + +2006-11-24 David Gilbert + + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (clone): Clone the legend label generators, + (setLegendItemLabelGenerator): Notify listeners, + (setLegendItemToolTipGenerator): Notify listeners, + (setLegendItemURLGenerator): Notify listeners, + * tests/org/jfree/chart/renderer/category/junit/AbstractCategoryITemRendererTests.java + (testCloning_LegendItemLabelGenerator): New test method, + (testCloning_LegendItemToolTipGenerator): New test method, + (testCloning_LegendItemURLGenerator): New test method. + +2006-11-24 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (clone): Fix URL generator cloning, + * source/org/jfree/chart/urls/PieURLGenerator.java: Updated API docs, + * source/org/jfree/chart/urls/StandardPieURLGenerator.java + (StandardPieURLGenerator()): Delegated, + (StandardPieURLGenerator(String)): Likewise, + (StandardPieURLGenerator(String, String)): Likewise, + (StandardPieURLGenerator(String, String, String)): Added argument + checks, + (equals): Reimplemented, + * tests/org/jfree/chart/plot/junit/PiePlotTests.java + (testCloning_URLGenerator): New test method, + (testCloning_LegendLabelURLGenerator): Fixed test, + * tests/org/jfree/chart/urls/junit/StandardPieURLGeneratorTests.java + (testEquals): New test method. + +2006-11-23 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (legendLabelURLGenerator): New field, + (PiePlot(PieDataset)): Initialise new field, + (getLegendLabelURLGenerator): New method, + (setLegendLabelURLGenerator): New method, + (getLegendItems): Populate URL if generator is available, + (equals): Added tests for new/missing fields, + (clone): Added cloning for new/missing fields, + * tests/org/jfree/chart/plot/junit/PiePlotTests.java + (testEquals): Extended for additional fields, + (testCloning_LegendItemShape): New test method, + (testCloning_LegendLabelGenerator): New test method, + (testCloning_LegendLabelToolTipGenerator): New test method, + (testCloning_LegendLabelURLGenerator): New test method. + +2006-11-23 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (setDomainGridlineStroke): Check for null argument, + (setDomainGridlinePaint): Likewise, + (setRangeGridlinePaint): Likewise. + +2006-11-23 David Gilbert + + * source/org/jfree/chart/util/RelativeDateFormat.java + (RelativeDateFormat(long)): Initialise fields needed by equals(), + (setDaySuffix): Check for null argument, + (setHourSuffix): Likewise, + (setMinuteSuffix): Likewise, + (setSecondSuffix): Likewise, + (equals): Check additional fields, + (hashCode): Overridden, + * tests/org/jfree/chart/util/junit/RelativeDateFormatTests.java: + New file, + * tests/org/jfree/chart/util/junit/UtilPackageTests.java: New file. + +2006-11-22 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (equals): Check quadrant fields, + (clone): Clone quadrant field, + * tests/org/jfree/chart/plot/junit/XYPlotTests.java + (testEquals): Added checks for quadrant fields, + (testCloning_QuadrantOrigin): New test method, + (testCloning_QuadrantPaint): New test method. + +2006-11-22 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java: Added API doc cross + references. + +2006-11-22 David Gilbert + + * source/org/jfree/chart/plot/CategoryPlot.java + (setColumnRenderingOrder): Added argument check, event notification, + and updated API docs, + (setRowRenderingOrder): Likewise. + +2006-11-20 David Gilbert + + * ant/build.xml + (initialise): Updated JFreeChart version, restructured iText + definitions, + (fill-distribution): Updated iText reference, simplified copy for + build.xml and added copy for build-swt.xml file. + +---------- JFREECHART 1.0.3 RELEASED ------------------------ + +2006-11-17 David Gilbert + + * experimental/org/jfree/experimental/chart/plot/dial/AbstractDialLayer.java + (visible): New field, + (AbstractDialLayer): Initialise new field, + (isVisible): New method, + (setVisible): New method, + * experimental/org/jfree/experimental/chart/plot/dial/DialLayer.java + (isVisible): New method, + * experimental/org/jfree/experimental/chart/plot/dial/DialPlot.java + (draw): Check layer visibility before drawing, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialFrame.java + (getOuterWindow): Adjust margins, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialScale.java + (tickLabelsVisible): New field, + (firstTickLabelVisible): New field, + (StandardDialScale): Initialise new fields, + (getTickLabelsVisible): New method, + (setTickLabelsVisible): New method, + (getFirstTickLabelVisible): New method, + (setFirstTickLabelVisible): New method, + (draw): Check tick label visibility, + * experimental/org/jfree/experimental/chart/demo/DialDemo1.java + (DialDemo1): Updated JSlider, + * experimental/org/jfree/experimental/chart/demo/DialDemo2.java + (DialDemo2): Updated chart title, + * experimental/org/jfree/experimental/chart/demo/DialDemo3.java: + Reimplemented, + * experimental/org/jfree/experimental/chart/demo/DialDemo4.java: + Reimplemented, + * experimental/org/jfree/experimental/chart/demo/DialDemo5.java: + New file. + +2006-11-17 David Gilbert + + * source/org/jfree/chart/util/RelativeDateFormat.java: New file, + * source/org/jfree/chart/util/package.html: New file. + +2006-11-16 David Gilbert + + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java + (roundXCoordinates): New field, + (drawItem): Add optional rounding of x-coordinates. + +2006-11-16 David Gilbert + + * source/org/jfree/data/statistics/BoxAndWhiskerCalculator.java + (calculateBoxAndWhiskerStatistics(List)): Delegate to new method, + (calculateBoxAndWhiskerStatistics(List, boolean)): New method, + (calculateQ1): Check null argument, + (calculateQ3): Likewise, + * source/org/jfree/data/statistics/BoxAndWhiskerItem.java + (toString): New method override, + * source/org/jfree/data/statistics/Statistics.java + (calculateMean(Number[])): Delegate to new method, + (calculateMean(Number[], boolean)): New method, + (calculateMean(Collection): Delegate to new method, + (calculateMean(Collection, boolean): New method, + (getStdDev): Added null argument checks, + (getLinearFit): Likewise, + (getSlope): Likewise, + * tests/org/jfree/data/statistics/junit/BoxAndWhiskerCalculatorTests.java + (testCalculateBoxAndWhiskerStatistics): New test method, + (testCalculateQ1): Add check for null argument, + (testCalculateQ3): Likewise, + (test1593149): New test method, + * tests/org/jfree/data/statistics/junit/StatisticsTests.java + (testCalculateMean_Array): New test method, + (testCalculateMean_Collection): New test method, + (EPSILON): New constant, + (testCalculateMedian): New test method, + (testGetStdDev): New test method. + +2006-11-14 Henry Proudhon + + * swt/README: New file, + * ant/build-swt.xml: New file. + +2006-11-14 David Gilbert + + * source/org/jfree/chart/plot/ThermometerPlot.java + (draw): Use margin. + +2006-11-14 David Gilbert + + * source/org/jfree/chart/axis/SegmentedTimeline.java + (toTimelineValue): Iterate through exception segments to avoid + potential stack overflow. + +2006-11-10 David Gilbert + + * source/org/jfree/chart/plot/FastScatterPlot.java + (FastScatterPlot()): Use default axes, + (FastScatterPlot(double[][], ValueAxis, ValueAxis)): Throw + IllegalArgumentException if domainAxis or rangeAxis is null, + (setDomainAxis): New method, + (setRangeAxis): New method, + (setDomainGridlineStroke): Don't allow null argument, + (setDomainGridlinePaint): Likewise, + (setRangeGridlineStroke): Likewise, + (setRangeGridlinePaint): Likewise, + (draw): Removed unnecessary null checks, + (drawDomainGridlines): Likewise, + (drawRangeGridlines): Likewise, + * source/org/jfree/chart/plot/FastScatterPlot.java + (testDrawWithNullInfo): New test method. + +2006-11-10 David Gilbert + + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java + (StackedXYAreaRendererState): Initialise line attribute, + * tests/org/jfree/chart/renderer/xy/junit/StackedXYAreaRendererTests.java + (testBug1593156): New test method. + +2006-11-07 David Gilbert + + * experimental/org/jfree/experimental/chart/demo/DialDemo1.java + (DialDemo1): Updated for API change, + * experimental/org/jfree/experimental/chart/demo/DialDemo2.java: + New file replaces old one (which is renamed DialDemo3.java), + * experimental/org/jfree/experimental/chart/demo/DialDemo3.java: + Replaced with former DialDemo2.java, + * experimental/org/jfree/experimental/chart/demo/DialDemo4.java: + Renamed DialDemo3 --> DialDemo4, + * experimental/org/jfree/experimental/chart/plot/dial/DialPlot.java + (datasetToScaleMap): New field, + (DialPlot): Initialise new field, + (addScale): Added index parameter, + (getScale): New method, + (mapDatasetToScale): New method, + (getScaleForDataset): Reimplemented, + * experimental/org/jfree/experimental/chart/plot/dial/DialPointer.java + (DialPointer(int)): New constructor, + (getDatasetIndex): New method, + (setDatasetIndex): New method, + (Pin(int)): New constructor, + (Pointer(int)): New constructor, + * experimental/org/jfree/experimental/chart/plot/dial/DialValueIndicator.java + (datasetIndex): New field, + (paint): Made transient to fix serialization, + (backgroundPaint): Likewise, + (outlineStroke): Likewise, + (outlinePaint): Likewise, + (DialValueIndicator): Modified constructor arguments, + (getDatasetIndex): New method, + (setDatasetIndex): Likewise, + (getAngle): Likewise, + (setAngle): Likewise, + (getFrameAnchor): Likewise, + (setFrameAnchor): Likewise, + (getTemplateValue): Likewise, + (setTemplateValue): Likewise, + (getNumberFormat): Likewise, + (setNumberFormat): Likewise, + (getFont): Likewise, + (setFont): Likewise, + (getPaint): Likewise, + (setPaint): Likewise, + (getBackgroundPaint): Likewise, + (setBackgroundPaint): Likewise, + (getOutlineStroke): Likewise, + (setOutlineStroke): Likewise, + (getOutlinePaint): Likewise, + (setOutlinePaint): Likewise, + (getInsets): Likewise, + (setInsets): Likewise, + (getValueAnchor): Likewise, + (setValueAnchor): Likewise, + (getTextAnchor): Likewise, + (setTextAnchor): Likewise, + (draw): Fetch value from the appropriate dataset, + (equals): Implemented properly, + (hashCode): New method, + (writeObject): New method, + (readObject): New method, + * experimental/org/jfree/experimental/chart/plot/dial/junit/DialValueIndicatorTests.java + (testEquals): Check all fields, + (testHashcode): Updated for new constructor API, + (testCloning): Likewise, + (testSerialization): Likewise. + +2006-11-06 David Gilbert + + * experimental/org/jfree/experimental/chart/plot/dial/AbstractDialLayer.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/DialBackground.java: + Now extends AbstractDialLayer, + (setPaint): Notify listeners, + (setGradientPaintTransformer): Likewise, + * experimental/org/jfree/experimental/chart/plot/dial/DialCap.java: + Now extends AbstractDialLayer, + (setRadius): Notify listeners, + (setFillPaint): Likewise, + (setOutlinePaint): Likewise, + (setOutlineStroke): Likewise, + * experimental/org/jfree/experimental/chart/plot/dial/DialLayer.java: + (addChangeListener): New method, + (removeChangeListener): New method, + (hasListener): New method, + * experimental/org/jfree/experimental/chart/plot/dial/DialLayerChangeEvent.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/DialLayerChangeListener.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/DialPlot.java: + Implemented DialLayerChangeListener, + * experimental/org/jfree/experimental/chart/plot/dial/DialPointer.java: + Now extends AbstractDialLayer, + (setRadius): Notify listeners, + (setPaint): Likewise, + (setStroke): Likewise, + (setWidthRadius): Likewise, + * experimental/org/jfree/experimental/chart/plot/dial/DialTextAnnotation.java: + Now extends AbstractDialLayer, + (setAngle): Notify listeners, + (setRadius): Likewise, + (setFont): Likewise, + (setPaint): Likewise, + (setLabel): Likewise, + * experimental/org/jfree/experimental/chart/plot/dial/DialValueIndicator.java: + Now extends AbstractDialLayer, + (setRadius): Notify listeners, + * experimental/org/jfree/experimental/chart/plot/dial/SimpleDialFrame.java: + (setRadius): Notify listeners, + (setBackgroundPaint): Likewise, + (setForegroundPaint): Likewise, + (setStroke): Likewise, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialFrame.java: + (setBackgroundPaint): Notify listeners, + (setForegroundPaint): Likewise, + (setStroke): Likewise, + (setInnerRadius): Likewise, + (setOuterRadius): Likewise, + (setStartAngle): Likewise, + (setExtent): Likewise, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialRange.java: + (setLowerBound): Notify listeners, + (setUpperBound): Likewise, + (setIncrement): Likewise, + (setPaint): Likewise, + (setInnerRadius): Likewise, + (setOuterRadius): Likewise, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialScale.java: + (setStartAngle): Notify listeners, + (setExtent): Likewise, + (setTickRadius): Likewise, + (setMajorTickIncrement): Likewise, + (setMajorTickLength): Likewise, + (setMajorTickPaint): Likewise, + (setMajorTickStroke): Likewise, + (setMinorTickCount): Likewise, + (setMinorTickLength): Likewise, + (setTickLabelOffset): Likewise, + (setTickLabelFont): Likewise, + (setTickLabelPaint): Likewise. + +2006-11-06 David Gilbert + + * ant/build.xml: Updated for reorganised source directories. + +2006-11-03 David Gilbert + + * experimental/org/jfree/experimental/chart/plot/dial/DialBackground.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/DialCap.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/DialFrame.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/DialLayer.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/DialPlot.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/DialPointer.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/DialScale.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/DialTextAnnotation.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/DialValueIndicator.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/SimpleDialFrame.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialFrame.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialRange.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialScale.java: New file, + * experimental/org/jfree/experimental/chart/plot/dial/StandardDialScale.java: New file, + * tests/org/jfree/experimental/chart/plot/dial/junit/DialBackgroundTests.java: New file, + * tests/org/jfree/experimental/chart/plot/dial/junit/DialCapTests.java: New file, + * tests/org/jfree/experimental/chart/plot/dial/junit/DialPackageTests.java: New file, + * tests/org/jfree/experimental/chart/plot/dial/junit/DialPlotTests.java: New file, + * tests/org/jfree/experimental/chart/plot/dial/junit/DialTextAnnotationTests.java: New file, + * tests/org/jfree/experimental/chart/plot/dial/junit/DialValueIndicatorTests.java: New file, + * tests/org/jfree/experimental/chart/plot/dial/junit/SimpleDialFrameTests.java: New file, + * tests/org/jfree/experimental/chart/plot/dial/junit/StandardDialFrameTests.java: New file, + * tests/org/jfree/experimental/chart/plot/dial/junit/StandardDialRangeTests.java: New file, + * tests/org/jfree/experimental/chart/plot/dial/junit/StandardDialScaleTests.java: New file. + +2006-11-03 David Gilbert + + * source/org/jfree/chart/HashcodeUtilities.java: New file, + * source/org/jfree/chart/annotation/XYPolygonAnnotation.java + (hashCode): Use new utility class, + (hashCodeForPaint): Removed, + (hashCodeForDoubleArray): Likewise. + +2006-11-02 David Gilbert + + * source/org/jfree/data/xy/DefaultIntervalXYDataset.java + (addSeries): Remove old series if there is one with the same key as + the new series, + * source/org/jfree/data/xy/DefaultXYDataset.java + (addSeries): Likewise, + * source/org/jfree/data/xy/DefaultXYZDataset.java + (addSeries): Likewise, + * tests/org/jfree/data/xy/junit/DataXYPackageTests.java + (suite): Added DefaultIntervalXYDatasetTests, + * tests/org/jfree/data/xy/junit/DefaultIntervalXYDatasetTests.java + (testAddSeries): New test, + * tests/org/jfree/data/xy/junit/DefaultXYDatasetTests.java + (testAddSeries): Likewise, + * tests/org/jfree/data/xy/junit/DefaultXYZDatasetTests.java + (testAddSeries): Likewise. + +2006-10-30 David Gilbert + + * source/org/jfree/chart/axis/CategoryAxis.java + (refreshTicks): Fetch categories for all datasets that map to this + axis; + * source/org/jfree/chart/plot/CategoryPlot.java + (getDomainAxisIndex): New method, + (datasetsMappedToDomainIndex): New method, + (getCategoriesForAxis): New method, + * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java + (getCategoriesForAxis): New method. + +2006-10-25 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYErrorRenderer.java: New file, + * tests/org/jfree/chart/renderer/xy/junit/XYErrorRendererTests.java: + New file, + * tests/org/jfree/chart/renderer/xy/junit/RendererXYPackageTests.java + (suite): Added XYErrorRendererTests. + +2006-10-24 David Gilbert + + * source/org/jfree/chart/plot/CategoryMarker.java + (CategoryMarker(Comparable, Paint, Stroke)): Set default alpha to 1.0f, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (drawDomainMarker): Draw marker outlines, + (drawRangeMarker): Likewise. + +2006-10-24 David Gilbert + + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java: + (drawDomainMarker): Use marker alpha setting, + (drawRangeMarker): Likewise, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java: + (drawDomainMarker): Use marker alpha setting, + (drawRangeMarker): Likewise. + +2006-10-24 David Gilbert + + * source/org/jfree/chart/annotations/XYShapeAnnotation.java + (draw): Calculate transform on shape bounds. + +2006-10-23 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java: + (setDomainCrosshairStroke): Check null argument, + (setDomainCrosshairPaint): Likewise, + plus various API doc updates. + +2006-10-23 David Gilbert + + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java: + (drawRangeMarker): Added code to draw outlines. + +2006-10-23 David Gilbert + + * source/org/jfree/chart/resources/JFreeChartResources.java + (CONTENTS): Updated version number to 1.0.3. + +2006-10-23 David Gilbert + + * ant/build.xml: Updated version number to 1.0.3, + * source/org/jfree/data/xy/DefaultIntervalXYDataset.java: New file, + * tests/org/jfree/data/xy/junit/DefaultIntervalXYDatasetTests.java: + New file. + +2006-10-20 David Gilbert + + * source/org/jfree/data/xy/XIntervalSeries.java + (getX): Added cast; + (getYValue): Likewise, + (getDataItem): Changed return value, + * source/org/jfree/data/xy/XIntervalSeriesCollection.java + (getX): Added cast, + (getY): Likewise, + (getStartX): Likewise, + (getEndX): Likewise, + * source/org/jfree/data/xy/XYIntervalSeries.java + (getX): Added cast; + (getYValue): Likewise, + (getDataItem): Changed return value, + * source/org/jfree/data/xy/XYIntervalSeriesCollection.java + (getX): Added cast, + (getY): Likewise, + (getStartX): Likewise, + (getEndX): Likewise, + * source/org/jfree/data/xy/YIntervalSeries.java + (getX): Added cast; + (getYValue): Likewise, + (getDataItem): Changed return value, + * source/org/jfree/data/xy/YIntervalSeriesCollection.java + (getX): Added cast, + (getY): Likewise, + (getStartX): Likewise, + (getEndX): Likewise, + * tests/org/jfree/data/DataPackageTests.java + (suite): Added new tests, + * tests/org/jfree/data/xy/DataXYPackageTests.java + (suite): Added new tests. + +2006-10-20 David Gilbert + + * source/org/jfree/data/ComparableObjectItem.java: New file, + * source/org/jfree/data/ComparableObjectSeries.java: Likewise, + * source/org/jfree/data/xy/XIntervalDataItem.java: Likewise, + * source/org/jfree/data/xy/XIntervalSeries.java: Likewise, + * source/org/jfree/data/xy/XIntervalSeriesCollection.java: Likewise, + * source/org/jfree/data/xy/XYInterval.java: Likewise, + * source/org/jfree/data/xy/XYIntervalDataItem.java: Likewise, + * source/org/jfree/data/xy/XYIntervalSeries.java: Likewise, + * source/org/jfree/data/xy/XYIntervalSeriesCollection.java: Likewise, + * source/org/jfree/data/xy/YInterval.java: Likewise, + * source/org/jfree/data/xy/YIntervalDataItem.java: Likewise, + * source/org/jfree/data/xy/YIntervalSeries.java: Likewise, + * source/org/jfree/data/xy/YIntervalSeriesCollection.java: Likewise, + * source/org/jfree/data/xy/YWithXInterval: Likewise, + * tests/org/jfree/data/junit/ComparableObjectItemTests.java: New file, + * tests/org/jfree/data/junit/ComparableObjectSeriesTests.java: New file, + * tests/org/jfree/data/xy/junit/XIntervalDataItemTests.java: New file, + * tests/org/jfree/data/xy/junit/XIntervalSeriesCollectionTests.java: New file, + * tests/org/jfree/data/xy/junit/XIntervalSeriesTests.java: New file, + * tests/org/jfree/data/xy/junit/XYIntervalDataItemTests.java: New file, + * tests/org/jfree/data/xy/junit/XYIntervalSeriesCollectionTests.java: New file, + * tests/org/jfree/data/xy/junit/XYIntervalSeriesTests.java: New file, + * tests/org/jfree/data/xy/junit/XYIntervalTests.java: New file, + * tests/org/jfree/data/xy/junit/YIntervalDataItemTests.java: New file, + * tests/org/jfree/data/xy/junit/YIntervalSeriesCollectionTests.java: New file, + * tests/org/jfree/data/xy/junit/YIntervalSeriesTests.java: New file, + * tests/org/jfree/data/xy/junit/YIntervalTests.java: New file, + * tests/org/jfree/data/xy/junit/YWithXIntervalTests.java: New file. + +2006-10-17 David Gilbert + + * source/org/jfree/data/jdbc/JDBCXYDataset.java: + (getLegendItemCount): Deprecated, + (getLegendItemLabels): Deprecated. + +2006-10-13 David Gilbert + + * source/org/jfree/chart/plot/CrosshairState.java + (getCrosshairDistance): New method, + (getAnchor): New method, + (getAnchorX): New method, + (setAnchorX): New method, + (getAnchorY): New method, + (setAnchorY): New method, + * source/org/jfree/chart/plot/XYPlot.java + (draw): Initialise the anchor coordinates. + +2006-10-12 David Gilbert + + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java: + (drawHorizontalItem): Check for null box, + (drawVerticalItem): Likewise, + * tests/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java + (testBug1572478Vertical): New method, + (testBug1572478Horizontal): Likewise. + +2006-10-12 David Gilbert + + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java: + Source reformatting and API doc updates. + +2006-10-12 David Gilbert + + * source/org/jfree/chart/plot/RingPlot.java + (sectionDepth): New field, + (RingPlot(PieDataset)): Initialise sectionDepth field, + (getSectionDepth): New method, + (setSectionDepth): Likewise, + (initialise): New method override to specify three passes, + (drawItem): Use sectionDepth, draw separators in pass 3, + (equals): Include sectionDepth in test, + * tests/org/jfree/chart/plot/junit/RingPlotTests.java + (testEquals): Updated, + (testCloning): Likewise, + (testSerialization): Likewise. + +2006-10-12 David Gilbert + + * source/org/jfree/experimental/**: + Removed, files transferred to a new source directory, + * experimental/org/jfree/experimental/**: + Added, see previous item. + +2006-10-11 David Gilbert + + * source/org/jfree/chart/renderer/category/StackedAreaRenderer.java + (renderAsPercentages): New field, + (StackedAreaRenderer(boolean)): New constructor, + (getRenderAsPercentages): New method, + (setRenderAsPercentages): Likewise, + (getPassCount): New method override, + (findRangeBounds): Handle renderAsPercentages, + (drawItem): Add support for renderAsPercentages and item labels, + (getPreviousHeight): Handle renderAsPercentages, + (equals): New method override, + * tests/org/jfree/chart/renderer/category/junit/StackedAreaRendererTests.java + (testEquals): Updated for renderAsPercentages flag. + +2006-10-11 David Gilbert + + * source/org/jfree/chart/renderer/category/AreaRenderer.java + (equals): New method override, + * tests/org/jfree/chart/renderer/category/junit/AreaRendererTests.java + (testEquals): Added new checks. + +2006-10-11 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYStepRenderer.java + (drawItem): Fixed step for horizontal orientation. + +2006-10-06 David Gilbert + + * source/org/jfree/chart/title/LegendItemBlockContainer.java + (toolTipText): New field, + (urlText): Likewise, + (getToolTipText): New method, + (setToolTipText): Likewise, + (getURLText): Likewise, + (setURLText): Likewise, + (draw): Add tool tip text and URL text to the legend item entity, + * source/org/jfree/chart/title/LegendTitle.java + (createLegendItemBlock): Set the tool tip and URL text in the block. + +2006-10-06 David Gilbert + + * source/org/jfree/chart/axis/PeriodAxis.java + (calendar): New field, + (PeriodAxis(String, RegularTimePeriod, RegularTimePeriod, TimeZone)): + Initialize calendar, + (setTimeZone) Reset calendar, + (getRange): Replaced deprecated method calls, + (drawTickMarksHorizontal): Likewise, + (drawTickLabels): Likewise, + (valueToJava2D): Likewise, + (java2DToValue): Likewise, + * source/org/jfree/data/time/Day.java + (firstMillisecond): New field, + (lastMillisecond): New field, + (Day(int, int, int)): Peg milliseconds to default time zone, + (Day(SerialDate)): Likewise, + (Day(Date, TimeZone)): Peg milliseconds to specified milliseconds, + (getFirstMillisecond): New method override, + (getLastMillisecond): Likewise, + (peg): New method, + * source/org/jfree/data/time/FixedMillisecond.java + (peg): New method, + * source/org/jfree/data/time/Hour.java + (hour): Changed type, + (firstMillisecond): New field, + (lastMillisecond): New field, + (Hour(int, Day)): Peg milliseconds to default time zone, + (Hour(Date, TimeZone)): Peg milliseconds to specified time zone, + (getFirstMillisecond): New method override, + (getLastMillisecond): Likewise, + (peg): New method, + * source/org/jfree/data/time/Millisecond.java + (day): New field, + (hour): New field, + (minute): New field, + (second): Changed type, + (firstMillisecond): New field, + (Millisecond(int, Second)): Reimplemented, + (Millisecond(Date, TimeZone)): Likewise, + (getSecond): Likewise, + (getFirstMillisecond): New method override, + (getLastMillisecond): Likewise, + (peg): New method, + (next): Updated for modified fields, + (getSerialIndex): Reimplemented, + (equals): Likewise, + (hashCode): Updated for new fields, + (getFirstMillisecond(Calendar)): Reimplemented, + (getLastMillisecond(Calendar)): Likewise, + * source/org/jfree/data/time/Minute.java + (day): New field, + (hour): Changed type, + (minute): Likewise, + (firstMillisecond): New field, + (lastMillisecond): New field, + (Minute(int, Hour)): Reimplemented, + (Minute(Date, TimeZone)): Likewise, + (getDay): New method, + (getHour): Reimplemented, + (getHourValue): New method, + (getFirstMillisecond): New method override, + (getLastMillisecond): Likewise, + (peg): New method, + (previous): Updated for changed field types, + (next): Likewise, + (getSerialIndex): Reimplemented, + (getFirstMillisecond(Calendar)): Updated for changed field types, + (getLastMillisecond(Calendar)): Likewise, + (equals): Likewise, + (hashCode): Likewise, + * source/org/jfree/data/time/Month.java + (year): Changed type, + (firstMillisecond): New field, + (lastMillisecond): New field, + (Month(int, int)): Reimplemented, + (Month(int, Year)): Likewise, + (Month(Date, TimeZone)): Likewise, + (getYear): Updated for changed field type, + (getYearValue): Likewise, + (getFirstMillisecond): New method override, + (getLastMillisecond): Likewise, + (peg): New method, + (previous): Updated for changed field types, + (next): Likewise, + (getSerialIndex): Likewise, + (equals): Likewise, + (hashCode): Likewise, + (compareTo): Likewise, + (getFirstMillisecond(Calendar)): Reimplemented, + (getLastMillisecond(Calendar)): Likewise, + * source/org/jfree/data/time/Quarter.java + (year): Changed type, + (quarter): Likewise, + (firstMillisecond): New field, + (lastMillisecond): New field, + (Quarter(int, int)): Reimplemented, + (Quarter(int, Year)): Likewise, + (Quarter(Date, TimeZone)): Likewise, + (getYear): Reimplemented, + (getYearValue): New method, + (getFirstMillisecond): New method override, + (getLastMillisecond): Likewise, + (peg): New method, + (previous): Updated for changed field types, + (next): Likewise, + (getSerialIndex): Likewise, + (equals): Likewise, + (hashCode): Likewise, + (compareTo): Likewise, + (getFirstMillisecond(Calendar)): Reimplemented, + (getLastMillisecond(Calendar)): Likewise, + * source/org/jfree/data/time/RegularTimePeriod.java + (WORKING_CALENDAR): Deprecated, + (peg): New method, + (getFirstMillisecond()): Made abstract, + (getFirstMillisecond(TimeZone)): Deprecated, + (getLastMillisecond()): Made abstract, + (getLastMillisecond(TimeZone)): Deprecated, + (getMiddleMillisecond(TimeZone)): Likewise, + * source/org/jfree/data/time/Second.java + (day): New field, + (hour): New field, + (minute): Changed type, + (second): Changed type, + (firstMillisecond): New field, + (Second(int, Minute)): Reimplemented, + (Second(Date, TimeZone)): Reimplemented, + (getMinute): Updated for field type changes, + (getFirstMillisecond): New method override, + (getLastMillisecond): Likewise, + (peg): New method, + (previous): Updated for changed field types, + (next): Likewise, + (getSerialIndex): Likewise, + (getFirstMillisecond(Calendar)): Reimplemented, + (getLastMillisecond(Calendar)): Likewise, + (equals): Likewise, + (hashCode): Likewise, + (compareTo): Updated for field type changes, + * source/org/jfree/data/time/Week.java + (year): Changed type, + (week): Likewise, + (firstMillisecond): New field, + (lastMillisecond): New field, + (Week(int, int)): Reimplemented, + (Week(int, Year)): Likewise, + (Week(Date, TimeZone)): Likewise, + (getYear): Updated for field type changes, + (getYearValue): Likewise, + (getFirstMillisecond): New method override, + (getLastMillisecond): Likewise, + (peg): New method, + (previous): Updated for changed field types, + (next): Likewise, + (getSerialIndex): Likewise, + (getFirstMillisecond(Calendar)): Reimplemented, + (getLastMillisecond(Calendar)): Likewise, + (equals): Likewise, + (hashCode): Likewise, + (compareTo): Updated for field type changes, + * source/org/jfree/data/time/Year.java + (year): Changed field type, + (firstMillisecond): New field, + (lastMillisecond): New field, + (Year(int)): Peg to default time zone, + (Year(Date, TimeZone)): Peg to specified time zone, + (getFirstMillisecond): New method override, + (getLastMillisecond): Likewise, + (peg): New method, + (getFirstMillisecond(Calendar)): Reimplemented, + (getLastMillisecond(Calendar)): Likewise. + +2006-10-06 David Gilbert + + * source/org/jfree/data/xy/DefaultXYZDataset.java: Fixed API doc + warnings. + +2006-10-05 David Gilbert + + * source/org/jfree/data/time/Day.java: API doc updates, + * source/org/jfree/data/time/Hour.java: Likewise, + * source/org/jfree/data/time/Millisecond.java: Likewise, + * source/org/jfree/data/time/Minute.java: Likewise, + * source/org/jfree/data/time/Month.java: Likewise, + * source/org/jfree/data/time/Quarter.java: Likewise, + * source/org/jfree/data/time/Second.java: Likewise, + * source/org/jfree/data/time/Week.java: Likewise, + * source/org/jfree/data/time/Year.java: Likewise. + +2006-10-05 David Gilbert + + * tests/org/jfree/data/time/junit/MillisecondTests.java + (testGetFirstMillisecond): New test, + (testGetFirstMillisecondWithTimeZone): Likewise, + (testGetFirstMillisecondWithCalendar): Likewise, + (testGetLastMillisecond): Likewise, + (testGetLastMillisecondWithTimeZone): Likewise, + (testGetLastMillisecondWithCalendar): Likewise, + (testGetSerialIndex): Likewise, + (testNext): Likewise, + (testGetStart): Likewise, + (testGetEnd): Likewise. + +2006-10-05 David Gilbert + + * tests/org/jfree/data/time/junit/SecondTests.java + (testGetFirstMillisecond): New test, + (testGetFirstMillisecondWithTimeZone): Likewise, + (testGetFirstMillisecondWithCalendar): Likewise, + (testGetLastMillisecond): Likewise, + (testGetLastMillisecondWithTimeZone): Likewise, + (testGetLastMillisecondWithCalendar): Likewise, + (testGetSerialIndex): Likewise, + (testNext): Likewise, + (testGetStart): Likewise, + (testGetEnd): Likewise. + +2006-10-05 David Gilbert + + * tests/org/jfree/data/time/junit/MinuteTests.java + (testGetFirstMillisecond): New test, + (testGetFirstMillisecondWithTimeZone): Likewise, + (testGetFirstMillisecondWithCalendar): Likewise, + (testGetLastMillisecond): Likewise, + (testGetLastMillisecondWithTimeZone): Likewise, + (testGetLastMillisecondWithCalendar): Likewise, + (testGetSerialIndex): Likewise, + (testNext): Likewise, + (testGetStart): Likewise, + (testGetEnd): Likewise. + +2006-10-05 David Gilbert + + * tests/org/jfree/data/time/junit/HourTests.java + (testGetFirstMillisecond): New test, + (testGetFirstMillisecondWithTimeZone): Likewise, + (testGetFirstMillisecondWithCalendar): Likewise, + (testGetLastMillisecond): Likewise, + (testGetLastMillisecondWithTimeZone): Likewise, + (testGetLastMillisecondWithCalendar): Likewise, + (testGetSerialIndex): Likewise, + (testNext): Likewise, + (testGetStart): Likewise, + (testGetEnd): Likewise. + +2006-10-05 David Gilbert + + * tests/org/jfree/data/time/junit/DayTests.java + (testGetFirstMillisecond): New test, + (testGetFirstMillisecondWithTimeZone): Likewise, + (testGetFirstMillisecondWithCalendar): Likewise, + (testGetLastMillisecond): Likewise, + (testGetLastMillisecondWithTimeZone): Likewise, + (testGetLastMillisecondWithCalendar): Likewise, + (testNext): Likewise, + (testGetStart): Likewise, + (testGetEnd): Likewise. + +2006-10-05 David Gilbert + + * tests/org/jfree/data/time/junit/WeekTests.java + (testGetFirstMillisecond): New test, + (testGetFirstMillisecondWithTimeZone): Likewise, + (testGetFirstMillisecondWithCalendar): Likewise, + (testGetLastMillisecond): Likewise, + (testGetLastMillisecondWithTimeZone): Likewise, + (testGetLastMillisecondWithCalendar): Likewise, + (testGetSerialIndex): Likewise, + (testNext): Likewise, + (testGetStart): Likewise, + (testGetEnd): Likewise. + +2006-10-05 David Gilbert + + * tests/org/jfree/data/time/junit/MonthTests.java + (testGetFirstMillisecond): New test, + (testGetFirstMillisecondWithTimeZone): Likewise, + (testGetFirstMillisecondWithCalendar): Likewise, + (testGetLastMillisecond): Likewise, + (testGetLastMillisecondWithTimeZone): Likewise, + (testGetLastMillisecondWithCalendar): Likewise, + (testGetSerialIndex): Likewise, + (testNext): Likewise, + (testGetStart): Likewise, + (testGetEnd): Likewise. + +2006-10-05 David Gilbert + + * tests/org/jfree/data/time/junit/QuarterTests.java + (testGetFirstMillisecond): New test, + (testGetFirstMillisecondWithTimeZone): Likewise, + (testGetFirstMillisecondWithCalendar): Likewise, + (testGetLastMillisecond): Likewise, + (testGetLastMillisecondWithTimeZone): Likewise, + (testGetLastMillisecondWithCalendar): Likewise, + (testGetSerialIndex): Likewise, + (testNext): Likewise, + (testGetStart): Likewise, + (testGetEnd): Likewise. + +2006-10-05 David Gilbert + + * tests/org/jfree/data/time/junit/YearTests.java + (testGetFirstMillisecond): New test, + (testGetFirstMillisecondWithTimeZone): Likewise, + (testGetFirstMillisecondWithCalendar): Likewise, + (testGetLastMillisecond): Likewise, + (testGetLastMillisecondWithTimeZone): Likewise, + (testGetLastMillisecondWithCalendar): Likewise, + (testGetSerialIndex): Likewise, + (testNext): Likewise, + (testGetStart): Likewise, + (testGetEnd): Likewise. + +2006-10-05 David Gilbert + + * source/org/jfree/data/xy/DefaultXYDataset.java: Fixed API doc + warnings. + +2006-10-03 David Gilbert + + * source/org/jfree/chart/annotations/CategoryPointerAnnotation.java: + Fixed Javadoc warnings, + * source/org/jfree/chart/entity/CategoryLabelEntity.java: Likewise, + * source/org/jfree/chart/event/MarkerChangeListener.java: Likewise, + * source/org/jfree/chart/plot/PiePlot.java: Likewise. + +2006-10-03 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (getSectionKey): Replace call to JRE 1.5 method. + +2006-10-03 David Gilbert + + * source/org/jfree/data/time/DayTests.java + (testGetSerialIndex): New method. + +2006-10-03 David Gilbert + + * source/org/jfree/data/time/TimePeriodValue.java + (TimePeriodValue(TimePeriod, Number)): Added null argument check, + (clone): Print stack trace in event of exception, + * source/org/jfree/data/time/TimePeriodValues.java + (add(TimePeriodValue)): Fire series change event, + (equals): Guard against null pointer exceptions, + * source/org/jfree/data/time/TimePeriodValuesCollection.java + (getDomainIsPointsInTime): Deprecated, + (setDomainIsPointsInTime): Likewise, + * source/org/jfree/data/time/junit/TimePeriodValuesCollectionTests.java: + (testEquals): Check for domain and range description fields, + (testAdd): New method, + (MySeriesChangeListener): New test support class. + +2006-10-02 David Gilbert + + * source/org/jfree/chart/annotations/CategoryPointerAnnotation.java: + New file, + * source/org/jfree/chart/annotations/XYPointerAnnotation.java + (setArrowPaint): Check for null argument, + * source/org/jfree/chart/annotations/junit/AnnotationsPackageTests.java + (suite): Added CategoryPointerAnnotationTests, + * source/org/jfree/chart/annotations/junit/CategoryPointerAnnotationTests.java: + New file. + +2006-10-02 David Gilbert + + * source/org/jfree/chart/axis/CategoryAxis.java + (drawCategoryLabels): Updated label entity generation, + * source/org/jfree/chart/entity/CategoryLabelEntity.java: New class. + +2006-09-28 David Gilbert + + * source/org/jfree/chart/axis/CategoryAxis.java + (draw): Replaced call to deprecated method. + +2006-09-28 David Gilbert + + * source/org/jfree/data/general/DefaultPieDataset.java + (sortByKeys): New method, + (sortByValues): New method. + +2006-09-27 David Gilbert + + * source/org/jfree/chart/ChartFactory.java + (createPieChart): Updated for deprecated code, + * source/org/jfree/chart/PaintMap.java: New class, + * source/org/jfree/chart/StrokeMap.java: Likewise, + * source/org/jfree/chart/junit/PaintMapTests.java: Likewise, + * source/org/jfree/chart/junit/StrokeMapTests.java: Likewise, + * source/org/jfree/chart/plot/MultiplePiePlot.java + (draw): Updated for deprecated code, + * source/org/jfree/chart/plot/PiePlot.java + (sectionPaintMap): Changed name and type from PaintList to PaintMap, + (sectionOutlinePaintMap): Likewise, + (sectionOutlineStrokeMap): Likewise, + (explodePercentages): Changed type from ObjectList to Map, + (PiePlot(PieDataset)): Update initialisation for field name changes, + (lookupSectionPaint): Changed argument type, + (getSectionKey): New method, + (getSectionPaint(Comparable)): Likewise, + (setSectionPaint(Comparable, Paint)): Likewise, + (getSectionPaint(int)): Deprecated, + (setSectionPaint(int, Paint)): Likewise, + (lookupSectionOutlinePaint): Changed argument type, + (getSectionOutlinePaint(Comparable)): Likewise, + (setSectionOutlinePaint(Comparable, Paint)): Likewise, + (getSectionOutlinePaint(int)): Deprecated, + (setSectionOutlinePaint(int, Paint)): Likewise, + (lookupSectionOutlineStroke): Changed argument type, + (getSectionOutlineStroke(Comparable)): Likewise, + (setSectionOutlineStroke(Comparable, Stroke)): Likewise, + (getSectionOutlineStroke(int)): Deprecated, + (setSectionOutlineStroke(int, Stroke)): Likewise, + (getExplodePercent(Comparable)): New method, + (setExplodePercent(Comparable, double)): Likewise, + (getExplodePercent(int)): Deprecated, + (setExplodePercent(int, double)): Deprecated, + (getMaximumExplodePercent): Modified to only check visible sections, + (drawItem): Updated for deprecated code, + (getLegendItems): Likewise, + (equals): Updated for renamed fields, + * source/org/jfree/chart/plot/PiePlot3D.java + (draw): Updated for deprecated code, + * source/org/jfree/chart/plot/RingPlot.java + (drawItem): Likewise. + +2006-09-27 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (PiePlot(PieDataset)): Initialise baseSectionPaint to a non-null value, + (lookupSectionPaint(int)): New method, + (lookupSectionPaint(int, boolean)): Likewise, + (getSectionPaint(int)): Reimplemented without lookup, + (lookupSectionOutlinePaint(int)): New method, + (lookupSectionOutlinePaint(int, boolean)): Likewise, + (getSectionOutlinePaint(int)): Reimplemented without lookup, + (lookupSectionOutlineStroke(int)): New method, + (lookupSectionOutlineStroke(int, boolean)): Likewise, + (getSectionOutlineStroke(int)): Reimplemented without lookup, + (drawItem): Use new lookup methods, + (getLegendItems): Likewise, + * source/org/jfree/chart/plot/PiePlot3D.java + (draw): Use new lookup methods, + * source/org/jfree/chart/plot/RingPlot.java + (drawItem): Use new lookup methods, + * source/org/jfree/chart/plot/junit/PiePlotTests.java + (testGetBaseSectionPaint): New method. + +2006-09-25 David Gilbert + + * source/org/jfree/chart/axis/DateAxis.java + (previousStandardDate): Handle tick mark position properly, + * source/org/jfree/chart/axis/junit/DateAxisTests.java + (MyDateAxis): New class, + (testPreviousStandardDateYear): New method, + (testPreviousStandardDateMonth): New method, + (testPreviousStandardDateDay): New method, + (testPreviousStandardDateHour): New method, + (testPreviousStandardDateMinute): New method. + +2006-09-25 David Gilbert + + * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java: + (StatisticalLineAndShapeRenderer(boolean, boolean)): Use arguments, + * source/org/jfree/chart/renderer/category/junit/StatisticalLineAndShapeRendererTests.java: + (test1562759): New method. + +2006-09-21 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java + (drawItem): Don't use hard-coded outline paint and stroke. + +2006-09-13 David Gilbert + + * source/org/jfree/chart/servlet/ServletUtilities.java + (sendTempFile(File, HttpServletResponse, String)): Specify English + locale for response header date format. + +2006-09-13 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (mouseClicked): Return early if chart is null, + (mouseMoved): Check for null chart. + +2006-09-13 David Gilbert + + * source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java: + Updated API docs and reformatted some source code, + * source/org/jfree/chart/plot/CombinedDomainXYPlot.java: Likewise, + * source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java: Likewise, + * source/org/jfree/chart/plot/CombinedRangeXYPlot.java: Likewise, + * source/org/jfree/chart/plot/XYPlot.java: Likewise. + +2006-09-07 David Gilbert + + * source/org/jfree/data/statistics/HistogramDataset.java + (addSeries): Check for binIndex that is too large, + * source/org/jfree/data/statistics/junit/HistogramDatasetTests.java + (test1553088): New method. + +2006-09-05 David Gilbert + + * source/org/jfree/chart/event/MarkerChangeEvent.java: New file, + * source/org/jfree/chart/event/MarkerChangeListener.java: New file, + * source/org/jfree/chart/plot/CategoryMarker.java + (setKey): New method, + (setDrawAsLine): Notify listeners, + * source/org/jfree/chart/plot/CategoryPlot.java + (addDomainMarker): Register plot as a listener with the new marker, + (clearDomainMarkers()): Deregister plot as a listener with each marker, + (clearDomainMarkers(int)): Likewise, + (addRangeMarker): Register plot as a listener with the new marker, + (clearRangeMarkers()): Deregister plot as a listener with each marker, + (clearRangeMarkers(int)): Likewise, + * source/org/jfree/chart/plot/IntervalMarker.java + (setStartValue): New method, + (setEndValue): New method, + (setGradientPaintTransformer): Notify listeners, + * source/org/jfree/chart/plot/Marker.java + (listeners): New field, + (Marker): Initialise listeners field, + (setPaint): Notify listeners, + (setStroke): Likewise, + (setOutlinePaint): Likewise, + (setOutlineStroke): Likewise, + (setAlpha): Likewise, + (setLabel): Likewise, + (setLabelFont): Likewise, + (setLabelPaint): Likewise, + (setLabelAnchor): Likewise, + (setLabelOffset): Likewise, + (setLabelOffsetType): Likewise, + (setLabelTextAnchor): Likewise, + (addChangeListener): New method, + (removeChangeListener): New method, + (notifyListeners): New method, + (getListeners): New method, + * source/org/jfree/chart/plot/Plot.java + (markerChanged): New method, + * source/org/jfree/chart/plot/ValueMarker.java + (setValue): New method, + * source/org/jfree/chart/plot/XYPlot.java + (addDomainMarker): Register plot as a listener with the new marker, + (clearDomainMarkers()): Deregister plot as a listener with each marker, + (clearDomainMarkers(int)): Likewise, + (addRangeMarker): Register plot as a listener with the new marker, + (clearRangeMarkers()): Deregister plot as a listener with each marker, + (clearRangeMarkers(int)): Likewise, + * source/org/jfree/chart/plot/junit/CategoryMarkerTests.java: + (lastEvent): New field, + (markerChanged): New method, + (testGetSetKey): Likewise, + (testGetSetDrawAsLine): Likewise, + * source/org/jfree/chart/plot/junit/IntervalMarkerTests.java: + (lastEvent): New field, + (markerChanged): New method, + (testGetSetStartValue): New method, + (testGetSetEndValue): New method, + * source/org/jfree/chart/plot/junit/MarkerTests.java: New file, + * source/org/jfree/chart/plot/junit/PlotPackageTests.java + (suite): Added MarkerTests.class, + * source/org/jfree/chart/plot/junit/ValueMarkerTests.java: + (lastEvent): New field, + (markerChanged): New method, + (testGetSetValue): Likewise. + +2006-09-04 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (actionPerformed): Updated for method name change, + (attemptEditChartProperties): Renamed doEditChartProperties() and + made public. + +2006-09-04 David Gilbert + + * source/org/jfree/chart/axis/NumberAxis.java + (autoAdjustRange): Check for lower == upper after applying auto range + minimum size and adjust if necessary. + +2006-09-01 David Gilbert + + * source/org/jfree/data/time/TimeSeries.java + (removeAgedItems(boolean)): Check for greater than maxItemAge, + (removeAgedItems(long, boolean): Reimplemented, + * source/org/jfree/data/time/junit/TimeSeriesTests.java + (testRemoveAgedItems): New method, + (testRemoveAgedItems2): New method. + +2006-08-29 Henry Proudhon + + * source/org/jfree/experiment/swt/SWTUtils.java + (Az): New field, + (toSwtFontData): Refined font size calculation, + (toAwtFont): Likewise. + +---------- JFREECHART 1.0.2 RELEASED ------------------------ + +2006-08-25 David Gilbert + + * source/org/jfree/chart/JFreeChart.java + (JFreeChartInfo.getLogo): Load image from jar file in a way that works + for Java Web Start also. + +2006-08-25 David Gilbert + + * README.txt: Provide link to iText, + * ant/build.xml: Restore 'compile-experimental' to 'all', but exclude + SWT classes. + +2006-08-25 David Gilbert + + * NEWS: Updated for release, + * README.txt: Likewise, + * ant/build.xml: Removed 'compile-experimental' from 'all'. + +2006-08-24 David Gilbert + + * source/org/jfree/experimental/chart/axis/LogAxis.java: New file, + * source/org/jfree/experimental/chart/demo/LogAxisDemo1.java: New file. + +2006-08-24 David Gilbert + + * source/org/jfree/experimental/chart/swt/editor/SWTAxisEditor.java: + Made package private, + * source/org/jfree/experimental/chart/swt/editor/SWTNumberAxisEditor.java: + Likewise, + * source/org/jfree/experimental/chart/swt/editor/SWTOtherEditor.java: + Likewise, + * source/org/jfree/experimental/chart/swt/editor/SWTPlotAppearanceEditor.java: + Likewise, + * source/org/jfree/experimental/chart/swt/editor/SWTPlotEditor.java: + Likewise, + * source/org/jfree/experimental/chart/swt/editor/SWTStrokeCanvas.java: + Likewise, + * source/org/jfree/experimental/chart/swt/editor/SWTTitleEditor.java: Likewise. + +2006-08-24 David Gilbert + + * source/org/jfree/experimental/chart/swt/ChartComposite.java + (attemptEditChartProperties): Implemented, + * source/org/jfree/experimental/chart/swt/editor/SWTAxisEditor.java: + New file, + * source/org/jfree/experimental/chart/swt/editor/SWTChartEditor.java: + New file, + * source/org/jfree/experimental/chart/swt/editor/SWTNumberAxisEditor.java: + New file, + * source/org/jfree/experimental/chart/swt/editor/SWTOtherEditor.java: + New file, + * source/org/jfree/experimental/chart/swt/editor/SWTPlotAppearanceEditor.java: + New file, + * source/org/jfree/experimental/chart/swt/editor/SWTPlotEditor.java: + New file, + * source/org/jfree/experimental/chart/swt/editor/SWTStrokeCanvas.java: + New file, + * source/org/jfree/experimental/chart/swt/editor/SWTTitleEditor.java: + New file, + * source/org/jfree/experimental/swt/SWTPaintCanvas.java: New file. + +2006-08-24 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (drawItem): Added crosshair support, and modified dataset calls to + use only double primitives. + +2006-08-24 David Gilbert + + * source/org/jfree/experimental/chart/demo/XYBlockChartDemo2.java + (createDataset): Rewritten to fix compile errors, + * source/org/jfree/experimental/chart/demo/XYBlockChartDemo3.java + (setValue): New method, + (createDataset): Rewritten to fix compile errors. + +2006-08-23 David Gilbert + + * source/org/jfree/experimental/chart/swt/ChartComposite.java: + New file, + * source/org/jfree/experimental/chart/swt/demo/SWTBarChartDemo1.java: + New file, + * source/org/jfree/experimental/chart/swt/demo/SWTMultipleAxisDemo1.java: + New file, + * source/org/jfree/experimental/chart/swt/demo/SWTPieChartDemo1.java: + New file, + * source/org/jfree/experimental/swt/SWTGraphics2D.java: New file, + * source/org/jfree/experimental/swt/SWTUtils.java: New file. + +2006-08-23 David Gilbert + + * ant/build.xml: Added 'compile-experimental' target, + * source/org/jfree/experimental/chart/demo/XYBlockChartDemo1.java: + New file, + * source/org/jfree/experimental/chart/demo/XYBlockChartDemo2.java: + New file, + * source/org/jfree/experimental/chart/demo/XYBlockChartDemo3.java: + New file, + * source/org/jfree/experimental/chart/renderer/GrayPaintScale.java: + New file, + * source/org/jfree/experimental/chart/renderer/LookupPaintScale.java: + New file, + * source/org/jfree/experimental/chart/renderer/PaintScale.java: + New file, + * source/org/jfree/experimental/chart/renderer/junit/GrayPaintScaleTests.java: + New file, + * source/org/jfree/experimental/chart/renderer/junit/LookupPaintScaleTests.java: + New file, + * source/org/jfree/experimental/chart/renderer/xy/XYBlockRenderer.java: + New file, + * source/org/jfree/experimental/chart/renderer/xy/junit/XYBlockRendererTests.java: + New file. + +2006-08-23 David Gilbert + + * source/org/jfree/chart/plot/CombinedDomainXYPlot.java + (setFixedRangeAxisSpace): New method override. + +2006-08-23 David Gilbert + + * source/org/jfree/chart/ChartFactory.java + (createStackedXYAreaChart): Use StackedXYAreaRenderer2 instead of + StackedXYAreaRenderer, for better handling of negative values, + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java: + Updated API docs. + +2006-08-22 David Gilbert + + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java + (findRangeBounds): Handle null and empty datasets correctly, + * source/org/jfree/chart/renderer/xy/junit/StackedXYAreaRenderer2Tests.java: + (testDrawWithEmptyDataset): New test, + (testFindRangeBounds): Added checks for null and empty datasets. + +2006-08-18 David Gilbert + + * source/org/jfree/chart/axis/CategoryAxis.java + (drawCategoryLabels(Graphics2D, Rectangle2D, RectangleEdge, AxisState, + PlotRenderingInfo)): Deprecated, + (drawCategoryLabels(Graphics2D, Rectangle2D, Rectangle2D, + RectangleEdge, AxisState, PlotRenderingInfo)): New method, + * source/org/jfree/chart/axis/CategoryAxis3D.java + (draw): Call new drawCategoryLabels() method, + * source/org/jfree/chart/axis/SubCategoryAxis.java + (draw): Likewise, + * source/org/jfree/chart/plot/CategoryPlot.java + (getDatasetCount): New method. + +2006-08-18 David Gilbert + + * source/org/jfree/chart/renderer/category/LayeredBarRenderer.java + (calculateBarWidth): Respect maximumBarWidth setting. + +2006-08-17 David Gilbert + + * source/org/jfree/chart/renderer/xy/junit/CandlestickRendererTests.java + (testFindRangeBounds): New method, + * source/org/jfree/chart/renderer/xy/junit/HighLowRendererTests.java + (testFindRangeBounds): New method. + +2006-08-17 David Gilbert + + * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java + (equals): Check additional fields, + * source/org/jfree/chart/renderer/xy/junit/CandlestickRendererTests.java + (testEquals): Extended to check all fields. + +2006-08-04 David Gilbert + + * ant/build.xml: Added source="1.3" target="1.3" to compile. + +2006-08-04 David Gilbert + + * source/org/jfree/chart/renderer/category/BarRenderer.java + (calculateBarL0L1}: Changed clipping slightly. + +2006-08-04 David Gilbert + + * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java + (clone): New method, + (equals): Likewise, + * source/org/jfree/chart/renderer/junit/DefaultPolarItemRendererTests.java: + New test class, + * source/org/jfree/chart/renderer/junit/RendererPackageTests.java + (suite): Added DefaultPolarItemRendererTests. + +2006-08-04 David Gilbert + + * source/org/jfree/chart/block/AbstractBlock.java + (getContentXOffset): Added API docs, + (getContentYOffset): Likewise. + +2006-08-04 David Gilbert + + * source/org/jfree/chart/annotation/CategoryLineAnnotation.java + (CategoryLineAnnotation): Fixed API doc warnings. + +2006-08-03 David Gilbert + + * source/org/jfree/data/xy/XYBarDataset.java: API doc updates, + * source/org/jfree/data/xy/XYDataset.java: Likewise, + * source/org/jfree/data/xy/XYSeriesCollection.java: Likewise. + +2006-08-03 David Gilbert + + * source/org/jfree/data/category/junit/CategoryToPieDatasetTests.java + (testGetIndex): New test method. + +2006-08-03 David Gilbert + + * source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.java + (getRangeBounds): Minor fix to previous patch. + +2006-08-03 David Gilbert + + * source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.java + (minimumRangeValueIncStdDev): New field, + (maximumRangeValueIncStdDev): Likewise, + (DefaultStatisticalCategoryDataset): Updated initialization code, + (add): Modified code to update ranges, + (getRangeBounds): Create the range as required, + * source/org/jfree/data/statistics/junit/DefaultStatisticalCategoryDatasetTests.java + (testGetRangeBounds): New test method. + +2006-08-03 David Gilbert + + * source/org/jfree/data/statistics/HistogramDataset.java + (addSeries): Improved precision of bin boundary calculation, + * source/org/jfree/data/statistics/junit/HistogramDatasetTests.java + (testAddSeries): New method, + (testBinBoundaries): New method. + +2006-08-03 David Gilbert + + * source/org/jfree/data/statistics/HistogramDataset.java: + API doc updates. + +2006-08-02 David Gilbert + + * source/org/jfree/chart/annotations/XYBoxAnnotation.java: API doc + correction and source code reformatting. + +2006-08-02 David Gilbert + + * source/org/jfree/chart/needle/ArrowNeedle.java: Minor API doc + updates, + * source/org/jfree/chart/needle/LineNeedle.java: Likewise, + * source/org/jfree/chart/needle/LongNeedle.java: Likewise, + * source/org/jfree/chart/needle/MiddlePinNeedle.java: Likewise, + * source/org/jfree/chart/needle/PinNeedle.java: Likewise, + * source/org/jfree/chart/needle/PlumNeedle.java: Likewise, + * source/org/jfree/chart/needle/PointerNeedle.java: Likewise, + * source/org/jfree/chart/needle/ShipNeedle.java: Likewise, + * source/org/jfree/chart/needle/WindNeedle.java: Likewise. + +2006-08-01 David Gilbert + + * source/org/jfree/chart/plot/SpiderWebPlot.java + (equals): Handle null tool tip and URL generators, + * source/org/jfree/chart/plot/junit/SpiderWebPlot.java + (testEquals): Extended to check tooltip and URL generators. + +2006-08-01 David Gilbert + + * source/org/jfree/chart/DrawableLegendItem.java: Deprecated class. + +2006-08-01 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (restoreAutoRangeBounds): Check for instance of Zoomable rather than + ValueAxisPlot. + +2006-08-01 David Gilbert + + * source/org/jfree/chart/plot/DefaultDrawingSupplier.java: Reformatted + and updated API docs. + +2006-08-01 David Gilbert + + * source/org/jfree/data/DefaultKeyedValues.java + (getIndex): Check for null argument, + * source/org/jfree/data/general/DefaultPieDataset.java + (getKey(int)): Throw IndexOutOfBounds if key exceeds getItemCount() + - 1, + * source/org/jfree/data/general/junit/DefaultPieDatasetTests.java + (testGetKey): New method, + (testGetIndex): New method, + * source/org/jfree/data/junit/DefaultKeyedValuesTests.java + (testGetIndex): Added check for null argument. + +2006-07-31 David Gilbert + + * source/org/jfree/data/DefaultKeyedValues.java + (clear): New method, + * source/org/jfree/data/general/DefaultPieDataset.java + (clear): Likewise, + * source/org/jfree/data/general/junit/DefaultPieDatasetTests.java + (lastEvent): New field, + (datasetChanged): New method, + (testClear): New method, + * source/org/jfree/data/junit/DefaultKeyedValuesTests.java + (testClear): New method. + +2006-07-27 David Gilbert + + * source/org/jfree/data/xy/XYSeries.java + (add(Number, Number, boolean)): Removed redundant argument check. + +2006-07-26 David Gilbert + + * source/org/jfree/chart/axis/junit/NumberAxisTests.java + (testAutoRange4): New method. + +2006-07-26 David Gilbert + + * source/org/jfree/data/category/CategoryToPieDataset.java + (serialVersionUID): New field, + (CategoryToPieDataset): Handle null source, + (getUnderlyingDataset): New method, + (getExtractType): New method, + (getExtractIndex): New method, + (getValue): Check index bounds, + (getKey): Check index bounds, + (getIndex): Handle null source, + (getKeys): Likewise, + (getValue): Handle unrecognised key, + (equals): New method override, + * source/org/jfree/data/category/junit/CategoryToPieDatasetTests.java: + New file, + * source/org/jfree/data/category/junit/DataCategoryPackageTests.java + (suite): Added new test. + +2006-07-25 David Gilbert + + * ant/build.xml: Use JCommon 1.0.5, + * source/org/jfree/chart/axis/DateAxis.java: Fixed API doc warning, + * source/org/jfree/chart/labels/StandardCategoryItemLabelGenerator.java: + Likewise, + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java: Likewise, + * source/org/jfree/data/general/Series.java: Likewise, + * source/org/jfree/data/time/TimeSeries.java: Likewise. + +2006-07-25 David Gilbert + + * source/org/jfree/chart/resources/JFreeChartResources.java + (CONTENTS): Updated version number, + * source/overview.html: Updated link, + * ant/build.xml: Updated version number. + +2006-07-25 David Gilbert + + * source/org/jfree/chart/demo/TimeSeriesDemo1.java + (createDataset): Removed call to deprecated method. + +2006-07-20 David Gilbert + + * source/org/jfree/chart/LegendItem.java + (datasetIndex): New field, + (series): Likewise, + (getDatasetIndex): New method, + (setDatasetIndex): Likewise, + (getSeriesIndex): Likewise, + (setSeriesIndex): Likewise, + (equals): Updated for new fields, + * source/org/jfree/chart/block/BlockContainer.java + (draw): Transform drawing area directly, + * source/org/jfree/chart/block/CenterArrangement.java + (arrangeNN): Set bounds for contained block, + * source/org/jfree/chart/block/LabelBlock.java + (arrange): Removed unused code, + (draw): Correct entity area calculation, + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (getLegendItem): Set dataset and series indices, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/title/LegendItemBlockContainer.java: New file, + * source/org/jfree/chart/title/LegendTitle.java + (createLegendItemBlock): Use new LegendItemBlockContainer class. + +2006-07-20 David Gilbert + + * source/org/jfree/chart/encoders/SunJPEGEncoderAdapter.java + (quality): Changed default to 0.95f, + (setQuality): Added argument check, + (encode(BufferedImage, OutputStream)): Set quality before writing + image to output stream. + +2006-07-12 David Gilbert + + * source/org/jfree/chart/annotations/XYPointerAnnotation.java + (draw): Swap coordinates for PlotOrientation.HORIZONTAL. + +2006-07-12 David Gilbert + + * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java + (drawHorizontalItem): Added item label drawing, + (drawVerticalItem): Likewise. + +2006-07-12 David Gilbert + + * source/org/jfree/data/xy/DefaultWindDataset.java + (DefaultWindDataset(List, Object[][][]): Added argument checks, + (getItemCount): Likewise, + (getSeriesKey): Likewise, + (equals): New method override, + (WindDataItem): Implements Serializable, + (WindDateItem.equals): New method override, + * source/org/jfree/data/xy/WindDataset.java: API doc updates, + * source/org/jfree/data/xy/junit/DataXYPackageTests.java + (suite): Added DefaultWindDatasetTests, + * source/org/jfree/data/xy/junit/DefaultWindDatasetTests.java: + New file. + +2006-07-12 David Gilbert + + * source/org/jfree/data/xy/DefaultXYZDataset.java: New file, + * source/org/jfree/data/xy/junit/DataXYPackageTests.java + (suite): Add new test class, + * source/org/jfree/data/xy/junit/DefaultXYZDatasetTests.java: New file. + +2006-07-10 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYDotRenderer.java + (dotWidth): New field, + (dotHeight): New field, + (XYDotRenderer): Initialize new fields, + (getDotWidth): New method, + (setDotWidth): Likewise, + (getDotHeight): New method, + (setDotHeight): New method, + (drawItem): Use variable dot size, + (equals): Check new field values, + * source/org/jfree/chart/renderer/xy/junit/XYDotRendererTests.java + (testEquals): Extended test to cover new fields, + (testHashCode): Likewise. + +2006-07-10 David Gilbert + + * source/org/jfree/chart/annotations/XYPolygonAnnotation.java + (XYPolygonAnnotation(double[], Stroke, Paint, Paint)): Added argument + checks, and cloned incoming array, + (getPolygonCoordinates): New method, + (getFillPaint): New method, + (getOutlinePaint): New method, + (getOutlineStroke): New method, + (draw): Return if the polygon has less than two vertices, + (equals): Fixed bug with GradientPaint, + (hashCode): Implemented, + (hashCodeForPaint): New utility method, + (hashCodeForDoubleArray): Likewise, + * source/org/jfree/chart/annotations/junit/AnnotationsPackageTests.java: + (suite): Added XYPolygonAnnotationTests, + * source/org/jfree/chart/annotations/junit/XYPolygonAnnotationTest.java: + New file. + +2006-07-10 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java: + Source reformatting. + +2006-07-06 David Gilbert + + * source/org/jfree/data/general/AbstractSeriesDataset.java: API doc + updates, + * source/org/jfree/data/general/SeriesDataset.java: Likewise. + +2006-07-06 David Gilbert + + * source/org/jfree/data/xy/DefaultXYDataset.java: New file, + * source/org/jfree/data/xy/junit/DataXYPackageTests.java: + (suite): Included new class DefaultXYDatasetTests, + * source/org/jfree/data/xy/junit/DefaultXYDatasetTests.java: New file. + +2006-07-06 David Gilbert + + * source/org/jfree/chart/renderer/xy/CyclicXYItemRenderer.java + (drawItem): Swapped all calls to dataset methods returning Number + instances, to corresponding methods that return doubles. + +2006-07-06 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java + (drawItem): Swapped all calls to dataset methods returning Number + instances, to corresponding methods that return doubles. + +2006-07-06 David Gilbert + + * source/org/jfree/chart/renderer/xy/HighLowRenderer.java + (drawItem): Swapped all calls to dataset methods returning Number + instances, to corresponding methods that return doubles. + +2006-07-06 David Gilbert + + * source/org/jfree/chart/urls/TimeSeriesURLGenerator.java: + (generateURL): Swapped getX() --> getXValue() (DG); + +2006-07-06 David Gilbert + + * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java: + Reformatted. + +2006-07-06 David Gilbert + + * source/org/jfree/chart/renderer/xy/CandlestickRenderer.java + (drawItem): Swapped all calls to dataset methods returning Number + instances, to corresponding methods that return doubles. + +2006-07-03 David Gilbert + + * source/org/jfree/chart/plot/Marker.java: Reformatting and API doc + updates. + +2006-06-30 David Gilbert + + * source/org/jfree/chart/plot/Plot.java + (backgroundImageAlpha): New field, + (getBackgroundImageAlpha): New method, + (setBackgroundImageAlpha): New method, + (drawBackgroundImage): Use new alpha field, + * source/org/jfree/chart/plot/junit/PlotTests.java + (testEquals): Added check for new field. + +2006-06-21 David Gilbert + + * source/org/jfree/chart/renderer/xy/ClusteredXYBarRenderer.java + (drawItem): Check orientation when adjusting for margin, call new + drawItemLabel() method in superclass. + +2006-06-21 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (positiveItemLabelPositionFallback): New field, + (negativeItemLabelPositionFallback): Likewise, + (getPositiveItemLabelPositionFallback): New method, + (setPositiveItemLabelPositionFallback): Likewise, + (getNegativeItemLabelPositionFallback): Likewise, + (setNegativeItemLabelPositionFallback): Likewise, + (drawItem): Call new drawItemLabel() method, + (drawItemLabel): New method, + (calculateLabelAnchorPoint): New method, + (isInternalAnchor): New method, + (equals): Updated for new fields, + * source/org/jfree/chart/renderer/xy/junit/XYBarRendererTests.java + (testEquals): Extended to cover new fields, + (testSerialization2): New test. + +2006-06-15 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYStepRenderer.java + (drawItem): Handle item labels. + +2006-06-15 David Gilbert + + * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java + (State.seriesIndex): New field, + (State.getSeriesIndex): New method, + (State.setSeriesIndex): New method, + (initialise): Set seriesIndex field, + (drawItem): Don't return until seriesPath has a chance to be updated + and/or drawn, if it is being used. + +2006-06-01 David Gilbert + + * source/org/jfree/chart/plot/SpiderWebPlot.java + (drawRadarPoly): Check for null info, + * source/org/jfree/chart/plot/junit/SpiderWebPlotTests.java + (testDrawWithNullInfo): New method. + +2006-06-01 David Gilbert + + * source/org/jfree/data/junit/WeekTests.java + (testBug1498805): New method. + +2006-05-25 David Gilbert + + * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java + (drawItem): Check for both line and shape not visible, and do nothing + in that case (fix for bug 1494936). + +2006-05-24 David Gilbert + + * source/org/jfree/data/time/TimeSeries.java: + (delete(RegularTimePeriod)): Do nothing for unknown time period, + (delete(int, int)): Added argument check, + (createCopy(int, int)): Added argument checks, + (createCopy(RegularTimePeriod, RegularTimePeriod)): Added argument + checks, and special handling for range containing no observations, + * source/org/jfree/data/time/junit/TimeSeriesTests.java: + (testDelete2): Added new cases, + (testCreateCopy1): Reformatted, + (testCreateCopy2): New test, + (testGetIndex): Likewise, + (testGetDataItem1): Likewise, + (testGetDataItem2): Likewise. + +2006-05-24 David Gilbert + + * source/org/jfree/data/general/Series.java: Updated API docs. + +2006-05-19 David Gilbert + + * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java + (drawHorizontalItem): Add entity for bar, + (drawVerticalItem): Add entity for bar. + +2006-05-03 David Gilbert + + * source/org/jfree/chart/labels/AbstractCategoryItemLabelGenerator.java + (AbstractCategoryItemLabelGenerator(String, NumberFormat, NumberFormat)): + New constructor, + * source/org/jfree/chart/labels/StandardCategoryItemLabelGenerator.java + (StandardCategoryItemLabelGenerator(String, NumberFormat, NumberFormat)): + New constructor, + (equals): New method, + * source/org/jfree/chart/labels/StandardCategorySeriesLabelGenerator.java + (equals): Added check for formatPattern, + * source/org/jfree/chart/labels/StandardCategoryToolTipGenerator.java + (StandardCategoryToolTipGenerator(String, NumberFormat, NumberFormat)): + New constructor, + (equals): New method, + * source/org/jfree/chart/labels/junit/StandardCategoryItemLabelGeneratorTests.java + (testEquals1481087): New test, + * source/org/jfree/chart/labels/junit/StandardCategorySeriesLabelGeneratorTests.java: + New file, + * source/org/jfree/chart/labels/junit/StandardCategoryToolTipGeneratorTests.java + (testEquals1481087): New test. + +2006-05-03 David Gilbert + + * source/org/jfree/chart/labels/junit/LabelsPackageTests.java + (suite): Updated test class name, + * source/org/jfree/chart/labels/junit/StandardPieItemLabelGeneratorTests.java: + Removed, + * source/org/jfree/chart/labels/junit/StandardPieToolTipGeneratorTests.java: + Added (renamed file). + +2006-05-03 David Gilbert + + * source/org/jfree/chart/labels/AbstractPieItemLabelGenerator.java + (clone): Clone the percentFormat field, fixes bug 1480978, + * source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java + (DEFAULT_SECTION_LABEL_FORMAT): Changed to "{0}", + (StandardPieSectionLabelGenerator()): Use DEFAULT_SECTION_LABEL_FORMAT, + * source/org/jfree/chart/labels/StandardPieToolTipGenerator.java: + Reformatted, + * source/org/jfree/chart/labels/junit/StandardPieItemLabelGeneratorTests.java + (testCloning): Extended test to cover bug 1480978. + +2006-04-19 David Gilbert + + * source/org/jfree/chart/axis/DateAxis.java + (equals): Call super.equals(); + * source/org/jfree/chart/axis/junit/DateAxisTests.java + (testEquals): Added more checks, + (test1472942): New test method. + +2006-04-11 David Gilbert + + * source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java: + (drawItem): Handle horizontal orientation correctly. + +2006-04-06 David Gilbert + + * source/org/jfree/chart/plot/MultiplePiePlot.java + (aggregatedItemsKey): New field, + (aggregatedItemsPaint): Likewise, + (sectionPaints): Likewise, + (MultiplePiePlot(CategoryDataset)): Initialise new fields, + (getAggregatedItemsKey): New method, + (setAggregatedItemsKey): Likewise, + (getAggregatedItemsPaint): Likewise, + (setAggregatedItemsPaint): Likewise, + (draw): Call prefetchSectionPaints(), use new field for + aggregatedItemsKey, and update section colors in pie plot before + drawing, + (prefetchSectionPaints): New utility method, + (getLegendItems): Call prefetchSectionPaints(), and add item for + aggregatedItems if these are being used, + (equals): Added tests for new fields, + (writeObject): Added serialization support for new fields, + (readObject): Likewise, + * source/org/jfree/chart/plot/junit/MultiplePiePlotTests.java + (testEquals): Extended to cover new fields, + (testSerialization): Modified to cover a failing case. + +2006-04-06 David Gilbert + + * source/org/jfree/data/time/Week.java + (Week(Date, TimeZone)): Handle the case where the first few days of the + year are part of the last week of the preceding year - see bug report + 1448828, + * source/org/jfree/data/time/junit/WeekTests.java + (testBug1448828): New test method. + +2006-04-05 David Gilbert + + * source/org/jfree/chart/plot/SpiderWebPlot.java + (toolTipGenerator): New field, + (urlGenerator): Likewise, + (getToolTipGenerator): New method, + (setToolTipGenerator): Likewise, + (getURLGenerator): Likewise, + (setURLGenerator): Likewise, + (drawRadarPoly): Populate entity collection, if not null, + (equals): Updated for new fields. + +2006-04-05 David Gilbert + + * source/org/jfree/chart/plot/SpiderWebPlot.java + (drawRadarPoly): Check for value >= to zero, not > zero (see patch + 1462727). + +2006-04-05 David Gilbert + + Patch 1459313 by Max Herfort: + + * source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java + (renderAsPercentages): New field, + (StackedBarRenderer3D()): Delegate to new constructor, + (StackedBarRenderer3D(boolean)): New constructor, + (StackedBarRenderer3D(double, double, boolean)): Likewise, + (getRenderAsPercentages): New method, + (setRenderAsPercentages): Likewise, + (findRangeBounds): Check renderAsPercentages flag and return an + appropriate range, + (drawItem): Check renderAsPercentages flag and draw items accordingly, + (equals): Overridden to account for renderAsPercentages flag, + * NEWS: Added notes about this patch. + +2006-03-08 David Gilbert + + * source/org/jfree/data/jdbc/JDBCCategoryDataset.java + (executeQuery(Connection, String)): Fixed update loop (bug 1445748). + +2006-03-02 David Gilbert + + * source/org/jfree/chart/renderer/AbstractCategoryItemRenderer.java + (getLegendItems): Check seriesVisibleInLegend flag before creating each + legend item. + +2006-02-28 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (drawRightLabels): Fixed distribution of labels, + * NEWS: Added bug fix entry for 1440415. + +2006-02-28 David Gilbert + + * ant/build.xml + (compile): Remove manifest specification; + * NEWS: Added bug fix entry. + +2006-02-20 David Gilbert + + * source/org/jfree/chart/annotations/XYPointerAnnotation.java + (equals): Reimplemented, + * source/org/jfree/chart/annotations/junit/XYPointerAnnotationTests.java + (testEquals): Updated to cover bug report 1415160. + +2006-02-20 David Gilbert + + * source/org/jfree/chart/axis/NumberAxis.java + (equals): Added check for rangeType field, + * source/org/jfree/chart/axis/junit/NumberAxisTests.java + (testEquals()): Extended to check rangeType field, + * NEWS: Added note of bug fix for 1435461. + +2006-02-10 David Gilbert + + * source/org/jfree/chart/axis/DateAxis.java: Updated API docs, + * source/org/jfree/chart/axis/NumberAxis.java: Likewise. + +---------- JFREECHART 1.0.1 RELEASED ------------------------ + +2006-01-27 David Gilbert + + * NEWS: Updated for 1.0.1 release, + * ant/build.xml: Updated version number, + * source/org/jfree/chart/JFreeChart.java: Reformatted, + * source/org/jfree/chart/resources/JFreeChartResources.java: + (CONTENTS): Updated version number. + +2006-01-27 David Gilbert + + * source/org/jfree/chart/labels/AbstractXYItemLabelGenerator.java + (createItemArray): Updated API docs, + * source/org/jfree/chart/labels/BubbleXYItemLabelGenerator.java: New + file, + * source/org/jfree/chart/labels/StandardXYZItemLabelGenerator.java: + Removed, + * source/org/jfree/chart/labels/XYZItemLabelGenerator.java: Likewise, + * source/org/jfree/chart/labels/junit/BubbleXYItemLabelGeneratorTests.java: + New tests, + * source/org/jfree/chart/labels/junit/LabelsPackageTests.java + (suite): Renamed test, + * source/org/jfree/chart/labels/junit/StandardXYItemLabelGeneratorTests.java: + New file, + * source/org/jfree/chart/labels/junit/StandardXYLabelGeneratorTests.java: + Removed. + +2006-01-27 David Gilbert + + * source/org/jfree/chart/plot/CategoryPlot.java + (getDomainGridlinePosition): Updated API docs, + (setDomainGridlinePosition): Check for null argument, + (getDomainGridlineStroke): Updated API docs, + (setDomainGridlineStroke): Check for null argument, + (getDomainGridlinePaint): Updated API docs, + (setDomainGridlinePaint): Check for null argument, + (getRangeGridlineStroke): Updated API docs, + (setRangeGridlineStroke): Check for null argument, + (getRangeGridlinePaint): Updated API docs, + (setRangeGridlinePaint): Check for null argument. + +2006-01-26 David Gilbert + + * source/org/jfree/chart/plot/XYPlot.java + (getAnnotations): New method, + * source/org/jfree/chart/plot/junit/XYPlotTests.java + (testRemoveAnnotation): New test. + +2006-01-26 David Gilbert + + * source/org/jfree/chart/annotations/XYTextAnnotation.java + (equals): Check x and y attributes (fixes bug 1415480). + +2006-01-26 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java + (drawItem): Check item label visible flag. + +2006-01-26 David Gilbert + + * source/org/jfree/chart/ChartFactory.java + (createScatterPlot): Corrected API documentation. + +2006-01-23 David Gilbert + + * source/org/jfree/chart/renderer/category/LevelRenderer.java + (getMaxItemWidth): Deprecated, + (setMaxItemWidth): Likewise, + (getMaximumItemWidth): New method, + (setMaximumItemWidth): Likewise. + +2006-01-18 David Gilbert + + * source/org/jfree/chart/renderer/category/GanttRenderer.java + (GanttRenderer()): Set includeBaseInRange to false, + * source/org/jfree/data/gantt/TaskSeriesCollection.java + (getSeries(Comparable)): New method, + (getSeries(int)): Likewise, + * source/org/jfree/data/gantt/junit/TaskSeriesCollectionTests.java + (testGetSeries): New tests. + +2006-01-18 David Gilbert + + * source/org/jfree/chart/axis/NumberAxis3D.java + (draw): Check plot is a CategoryPlot before casting (fixes bug + 1408904). + +2006-01-11 David Gilbert + + * source/org/jfree/chart/axis/CategoryAxis.java + (drawCategoryLabels): Fixed null pointer exception (see bug report + 1403043). + +2006-01-11 David Gilbert + + * source/org/jfree/data/xy/XYSeries.java + (update(int, Number)): Deprecated (renamed updateByIndex), + (updateByIndex): New method, + * NEWS: Updated API changes. + +2006-01-11 David Gilbert + + * source/org/jfree/chart/renderer/category/BarRenderer.java + (includeBaseInRange): New flag, + (BarRenderer): Initialise new flag, + (getIncludeBaseInRange): New accessor method, + (setIncludeBaseInRange): Likewise, + (calculateBarL0L1): Simplified code to fix bug 1401856, + (findRangeBounds): New override method, + * source/org/jfree/chart/plot/CategoryPlot.java + (rendererChanged): Call configureRangeAxes(), because the renderer + can affect the axis range, + * source/org/jfree/data/Range.java + (combine): Reformatted, + (expandToInclude): New method, + (expand): Reformatted, + (shift): Likewise, + (shiftWithNoZeroCrossing): Added API docs. + * source/org/jfree/chart/axis/junit/NumberAxisTests.java + (testAutoRange2): Fixed failing test, + (testAutoRange3): Likewise, + * NEWS: Added recent updates. + +2006-01-10 David Gilbert + + * source/org/jfree/chart/servlet/ServletUtilities.java: Updated API + docs and reformatted source code. + +2006-01-09 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (drawLabels): Changed code that checks ignoreNullValues and + ignoreZeroValues flags, + (getLegendItems): Increment section count even when section is ignored. + Fixes bug 1400442. + +2005-12-21 David Gilbert + + * source/org/jfree/chart/plot/SpiderWebPlot.java + (SpiderWebPlot(CategoryDataset)): Delegate to another constructor, + (SpiderWebPlot(CategoryDataset, TableOrder)): Copied code from previous + constructor, + (getPlotType): Updated description, + (setInteriorGap): Reformatted, + (draw): Likewise, + (drawRadarPoly): Likewise, + (drawLabel): Likewise. + +2005-12-20 David Gilbert + + * source/org/jfree/chart/plot/RingPlot.java + (drawItem): fix entity shape (bug 1386328). + +2005-12-13 David Gilbert + + * source/org/jfree/data/time/TimeSeriesCollection.java + (domainIsPointsInTime): Deprecated, no longer required, + (getDomainIsPointsInTime): Likewise, + (setDomainIsPointsInTime): Likewise, + (getSeries): Reformatted, + (removeAllSeries): Likewise, + (getX): Likewise, + (getStartX): Likewise, + (getEndX): Likewise, + (getDomainBounds): Don't use domainIsPointsInTime. + +2005-12-13 David Gilbert + + * source/org/jfree/chart/labels/StandardXYZItemLabelGenerator.java: + New class, + * source/org/jfree/chart/labels/XYZItemLabelGenerator.java: + New interface, + * source/org/jfree/chart/renderer/AbstractRenderer.java: Reformatting, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java: + Likewise, + * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java + (XYBubbleRenderer(int)): Check argument, + (getScaleType): API docs, + (drawItem): Added code to draw item labels, + (getLegendItem): Reformatted. + +2005-12-13 David Gilbert + + * source/org/jfree/chart/title/TextTitle.java + (TextTitle(String)): Reformatted, + (TextTitle(String, Font)): Reformatted, + (arrange): Reformatted, + (arrangeRR): Account for rotated title in left or right positions, + fixes bug 1379331, + (hashCode): Reformatted. + +2005-12-10 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java: + Reformatted. + +2005-12-10 David Gilbert + + * source/org/jfree/chart/LegendItem.java + (attributedLabel): Made transient, + (writeObject): Write out attributedLabel, + (readObject): Read in attributedLabel, + * source/org/jfree/chart/junit/LegendItemTests.java + (testSerialization2): New test, + * NEWS: Noted bug fix. + +2005-12-10 David Gilbert + + * source/org/jfree/data/time/Quarter.java + (Quarter(int, Year)): Fix bug (1377239) in argument checking, + * source/org/jfree/data/time/junit/QuarterTests.java + (testConstructor): New test, + * NEWS: Noted bug fix. + +2005-12-06 David Gilbert + + * NEWS: New file, + * source/org/jfree/chart/renderer/category/BarRenderer.java + (getLegendItem): Changed Color.BLACK to Color.black (fixes bug report + 1374222). + +2005-12-05 David Gilbert + + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java: + Reformatted. + +---------- JFREECHART 1.0.0 RELEASED ------------------------ + +2005-12-02 David Gilbert + + * README.txt: Update for 1.0.0 release, + * source/org/jfree/chart/resources/JFreeChartResources.java + (CONTENTS): Updated version number. + +2005-12-02 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (chartChanged): Don't update domainZoomable and rangeZoomable. + +2005-12-02 David Gilbert + + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java + (drawItem): Access entity collection via convenience method, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java + (drawItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYStepRenderer.java + (drawItem): Likewise. + +2005-12-02 David Gilbert + + * source/org/jfree/chart/plot/PiePlot.java + (drawItem): Access entity collection via convenience method, + * source/org/jfree/chart/plot/RingPlot.java + (drawItem): Likewise. + +2005-12-02 David Gilbert + + * source/org/jfree/chart/renderer/xy/junit/StackedXYAreaRendererTests.java + (drawWithNullInfo): New test, + * source/org/jfree/chart/renderer/xy/junit/XYAreaRendererTests.java + (drawWithNullInfo): New test, + * source/org/jfree/chart/renderer/xy/junit/XYAreaRenderer2Tests.java + (drawWithNullInfo): New test, + * source/org/jfree/chart/renderer/xy/junit/XYStepAreaRendererTests.java + (drawWithNullInfo): New test, + * source/org/jfree/chart/renderer/xy/junit/XYStepRendererTests.java + (drawWithNullInfo): New test. + +2005-12-02 David Gilbert + + * source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java: + Reformatting, + * source/org/jfree/chart/renderer/category/StatisticalLineAndShaperenderer.java + (drawItem): Fixed null pointer exception, + * source/org/jfree/chart/renderer/category/junit/StatisticalBarRendererTests.java + (testDrawWithNullInfo): New test, + * source/org/jfree/chart/renderer/category/junit/StatisticalLineAndShapeRenderer.java + (testDrawWithNullInfo): New test. + +2005-12-02 David Gilbert + + * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java + (drawItem): Fixed null pointer exception. + +2005-12-02 David Gilbert + + * source/org/jfree/chart/renderer/category/LevelRenderer.java + (drawItem): Fixed null pointer exception, + * source/org/jfree/chart/renderer/category/junit/LevelRendererTests.java + (testDrawWithNullInfo): New test. + +2005-12-02 David Gilbert + + * source/org/jfree/chart/renderer/category/LayeredBarRenderer.java + (drawHorizontalItem): Fixed null pointer exception, + (drawVerticalItem): Fixed null pointer exception, + * source/org/jfree/chart/renderer/category/junit/LayeredBarRendererTests.java + (testDrawWithNullInfo): New test. + +2005-12-01 David Gilbert + + * source/org/jfree/data/time/TimeSeries.java + (add(TimeSeriesDataItem)): Delegate to new method, + (add(TimeSeriesDataItem, boolean)): New method, + (add(RegularTimePeriod, double)): Delegate to new method, + (add(RegularTimePeriod, double, boolean)): New method, + (add(RegularTimePeriod, Double)): Delegate to new method, + (add(RegularTimePeriod, Double, boolean)): New method. + +2005-12-01 David Gilbert + + * source/org/jfree/chart/renderer/category/IntervalBarRenderer.java + (drawItem): Call getEntityCollection directly on 'state', + * source/org/jfree/chart/renderer/category/junit/IntervalBarRendererTests.java + (testDrawWithNullInfo): New test. + +2005-12-01 David Gilbert + + * source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java + (drawItem): Call getEntityCollection directly on 'state', + * source/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java + (testDrawWithNullInfo): Construct chart properly, + * source/org/jfree/chart/renderer/category/junit/GroupedStackedBarRendererTests.java + (testDrawWithNullInfo): New test, + * source/org/jfree/data/statistics/BoxAndWhiskerItem.java + (getOutliers): Check for null list. + +2005-12-01 David Gilbert + + * gjdoc/run-gjdoc: Updated version number, + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (drawHorizontalItem): Fixed null pointer exception, + (drawVerticalItem): Likewise, + * source/org/jfree/chart/renderer/category/junit/BoxAndWhiskerRendererTests.java + (testDrawWithNullInfo): New test. + +2005-12-01 David Gilbert + + * source/org/jfree/chart/renderer/category/BarRenderer.java + (getLegendItem): Use drawBarOutline flag for legend graphic, + * source/org/jfree/chart/renderer/category/GanttRenderer.java + (drawTasks): Check drawBarOutline flag, + (drawTask): Likewise. + +2005-12-01 David Gilbert + + * ant/build.xml + (initialise): Updated version number, + * gjdoc/run-gjdoc: Updated package list, + * source/org/jfree/chart/junit/GanttChartTests.java + (testDrawWithNullInfo): Reformatted, + (testDrawWithNullInfo2): New test, + * source/org/jfree/chart/renderer/category/GanttRenderer.java + (drawTasks): Fix NullPointerException, + (drawTask): Likewise. + +2005-11-30 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYItemRenderer.java + (getLegendItemLabelGenerator): Added method to interface, + (setLegendItemLabelGenerator): Likewise. + +2005-11-30 David Gilbert + + * source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java + (getAttributedLabel): Change argument name to 'section', + (setAttributedLabel): Likewise. + +2005-11-30 David Gilbert + + * source/org/jfree/chart/ChartFactory.java + (createSignalChart): Removed, + * source/org/jfree/chart/renderer/xy/SignalRenderer.java: Removed, + * source/org/jfree/chart/renderer/xy/junit/SignalRendererTests.java: + Removed, + * source/org/jfree/data/general/SubSeriesDataset.java + (getType): Removed, + (getLevel): Removed, + * source/org/jfree/data/xy/SignalsDataset.java: Removed. + +2005-11-30 David Gilbert + + * source/org/jfree/chart/ChartRenderingInfo.java + (plotArea): Removed, + (ChartRenderingInfo(EntityCollection)): Updated for removed field, + (getPlotArea): Removed, + (setPlotArea): Removed, + (clear): Updated for removed field, + (equals): Likewise, + (writeObject): Likewise, + (readObject): Likewise, + * source/org/jfree/chart/junit/ChartRenderingInfoTests.java + (testEquals): Updated for removed field, + (testSerialization): Likewise. + +2005-11-28 David Gilbert + + * README.txt: Updated for 1.0.0-rc3 release, + * ant/build.xml: Copy across Maven file. + +2005-11-28 David Gilbert + + * source/org/jfree/chart/editor/ChartEditorFactory.java: New file, + * source/org/jfree/chart/editor/ChartEditorManager.java + (factory): New field, + (getChartEditorFactory): New method, + (setChartEditorFactory): New method, + (getChartEditor): Updated to use factory. + +2005-11-28 David Gilbert + + * source/org/jfree/data/time/TimeSeries.java + (maximumItemAge): Changed type from int to long, + (TimeSeries(String, String, String, Class)): Change initialisation of + maximumItemAge field, + (getMaximumItemAge): Changed return type to long, + (setMaximumItemAge): Changed argument type to long. + +2005-11-28 David Gilbert + + * source/org/jfree/chart/LegendItem.java: + (LegendItem(String, AttributedString, String, String, String, Shape, + Paint)): Removed AttributedString argument, + (LegendItem(String, AttributedString, String, String, String, Shape, + Paint, Stroke, Paint)): Likewise, + (LegendItem(String, AttributedString, String, String, String, Shape, + Stroke, Paint)): Likewise, + (LegendItem(String, AttributedString, String, String, String, boolean, + Shape, boolean, Paint, boolean, Paint, Stroke, boolean, Shape, Stroke, + Paint)): Likewise, + (LegendItem(AttributedString, String, String, String, Shape, Paint)): + New constructor, + (LegendItem(AttributedString, String, String, String, Shape, Paint, + Stroke, Paint)): Likewise, + (LegendItem(AttributedString, String, String, String, Shape, Stroke, + Paint)): Likewise, + (LegendItem(AttributedString, String, String, String, boolean, + Shape, boolean, Paint, boolean, Paint, Stroke, boolean, Shape, Stroke, + Paint)): Likewise, + (characterIteratorToString): New method, + * source/org/jfree/chart/junit/LegendItemCollectionTests.java + (testEquals): Updated for change to LegendItem constructor, + (testSerialization): Likewise, + (testCloning): Likewise, + * source/org/jfree/chart/junit/LegendItemTests.java + (testEquals): Updated for change to LegendItem constructor, + (testSerialization): Likewise, + (testCloning): Likewise, + * source/org/jfree/chart/plot/MeterPlot.java + (getLegendItems): Update for change to LegendItem constructor, + * source/org/jfree/chart/plot/MultiplePiePlot.java + (getLegendItems): Likewise, + * source/org/jfree/chart/plot/PiePlot.java + (getLegendItems): Likewise, + * source/org/jfree/chart/plot/SpiderWebPlot.java + (getLegendItems): Likewise, + * source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/WaferMapRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/category/AreaRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/category/BarRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java + (getLegendItem): Likewise, + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (getLegendItem): Likewise. + +2005-11-28 David Gilbert + + * ant/build.xml + (initialise): Update JFreeChart version number, + (compile): Copy over property files in org.jfree.chart.editor, + * source/org/jfree/chart/resources/JFreeChartResources.java + (CONTENTS): Updated JFreeChart version number. + +2005-11-25 David Gilbert + + * source/org/jfree/chart/ChartMouseListener.java: Now extends EventListener, + * source/org/jfree/chart/ChartPanel.java + (chartMouseListeners): Use EventListenerList, + (ChartPanel(JFreeChart, int, int, int, int, int, int, boolean, boolean, + boolean, boolean, boolean, boolean)): Initialise chartMouseListeners, + (mouseClicked): Use EventListenerList, + (mouseMoved): Likewise, + (addChartMouseListener): Likewise, + (removeChartMouseListener): Likewise, + (getListeners): New override, + * source/org/jfree/chart/junit/ChartPanelTests.java: + (testGetListeners): New test, + (chartMouseClicked): New method, + (chartMouseMoved): New method. + +2005-11-24 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (attemptEditChartProperties): Use ChartEditorManager to get + ChartEditor, + * source/org/jfree/chart/axis/ColorBar.java: Update imports for moved + classes, + * source/org/jfree/chart/axis/junit/ColorBarTests.java: Likewise, + * source/org/jfree/chart/editor/ChartEditor.java: New file, + * source/org/jfree/chart/editor/ChartEditorManager.java: New file, + * source/org/jfree/chart/editor/DefaultAxisEditor.java: New file, + * source/org/jfree/chart/editor/DefaultChartEditor.java: New file, + * source/org/jfree/chart/editor/DefaultColorBarEditor.java: New file, + * source/org/jfree/chart/editor/DefaultNumberAxisEditor.java: New file, + * source/org/jfree/chart/editor/DefaultPlotEditor.java: New file, + * source/org/jfree/chart/editor/DefaultTitleEditor.java: New file, + * source/org/jfree/chart/editor/PaletteChooserPanel.java: New file, + * source/org/jfree/chart/editor/PaletteSample.java: New file, + * source/org/jfree/chart/editor/LocalizationBundle_de.properties: Moved, + * source/org/jfree/chart/editor/LocalizationBundle_es.properties: Moved, + * source/org/jfree/chart/editor/LocalizationBundle_fr.properties: Moved, + * source/org/jfree/chart/editor/LocalizationBundle_nl.properties: Moved, + * source/org/jfree/chart/editor/LocalizationBundle_pl.properties: Moved, + * source/org/jfree/chart/editor/LocalizationBundle_pt_PT.properties: Moved, + * source/org/jfree/chart/editor/LocalizationBundle_ru.properties: Moved, + * source/org/jfree/chart/editor/LocalizationBundle_zh_CN.properties: Moved, + * source/org/jfree/chart/editor/LocalizationBundle.properties: Moved, + * source/org/jfree/chart/editor/package.html: New file, + * source/org/jfree/chart/junit/JFreeChartTestSuite.java: + (suite): Removed ChartUIPackageTests, + * source/org/jfree/chart/plot/ColorPalette.java: Moved, + * source/org/jfree/chart/plot/GreyPalette.java: Moved, + * source/org/jfree/chart/plot/RainbowPalette.java: Moved, + * source/org/jfree/chart/plot/junit/ColorPaletteTests.java: Moved, + * source/org/jfree/chart/plot/junit/PlotPackageTests.java + (suite): Added ColorPaletteTests, + * source/org/jfree/chart/ui/*: Removed package, most classes moved to + org.jfree.chart.editor and renamed, + * source/org/jfree/chart/ui/junit/*: Removed package. + +2005-11-24 David Gilbert + + * source/org/jfree/chart/encoders/KeypointPNGEncoderAdapter.java: + Updated API docs. + +2005-11-24 David Gilbert + + * source/org/jfree/chart/ChartFactory.java + (createHistogram): Set autoRangeIncludesZero to false on domain axis. + +2005-11-24 David Gilbert + + * ant/build.xml: Updated version numbers. + +2005-11-24 David Gilbert + + * source/org/jfree/chart/DefaultOldLegend.java: Removed, + * source/org/jfree/chart/JFreeChart.java + (oldLegend): Removed, + (getOldLegend): Removed, + (setOldLegend): Removed, + (draw(Graphics2D, Rectangle2D, Point2D, ChartRenderingInfo)): Removed + old legend drawing code, + (legendChanged): Removed, + (equals): Removed old legend check, + (readObject): Removed code to add listener to old legend, + (clone): Removed code to clone old legend, + * source/org/jfree/chart/OldLegend.java: Removed, + * source/org/jfree/chart/event/LegendChangeEvent.java: Removed, + * source/org/jfree/chart/event/LegendChangeListener.java: Removed, + * source/org/jfree/chart/junit/JFreeChartTests.java + (testEquals): Removed old legend check, + * source/org/jfree/chart/ui/ChartPropertyEditPanel.java + (legendPropertiesPanel): Removed, + (ChartPropertyEditPanel(JFreeChart)): Removed old legend setup, + (getLegendPropertyEditPanel): Removed, + (updateChartProperties): Removed old legend update, + * source/org/jfree/chart/ui/LegendPropertyEditPanel.java: Removed. + +2005-11-23 David Gilbert + + * source/org/jfree/chart/JFreeChart.java + (JFreeChartInfo): Added Pady Srinivasan to contributors, + * source/org/jfree/chart/axis/CategoryAxis.java: Added Pady Srinivasan + as Contributor. + +2005-11-23 David Gilbert + + These changes are based on patch 1217634 by Pady Srinivasan (with + significant modifications). + + * source/org/jfree/chart/axis/CategoryAxis.java + (tickLabelFontMap): New field, + (tickLabelPaintMap): New field, + (CategoryAxis(String)): Initialise new fields, + (getTickLabelFont(Comparable)): New method, + (setTickLabelFont(Comparable, Font)): New method, + (getTickLabelPaint(Comparable)): New method, + (setTickLabelPaint(Comparable, Paint)): New method, + (getCategoryLabelToolTip): New method, + (drawCategoryLabels): Use new methods to get label font and paint, and + also tooltip, + (refreshTicks): Reformatted, + (createLabel): Use new methods to get label font and paint, + (clone): Handle new fields, + (equals): Likewise, + (readObject): Likewise, + (writeObject): Likewise, + (readPaintMap): New method, + (writePaintMap): New method, + (equalPaintMaps): New method, + * source/org/jfree/chart/axis/junit/CategoryAxisTests.java + (testEquals): Add tests for new fields, + (testCloning2): New test, + (testSerialization): Strengthened test. + +2005-11-22 David Gilbert + + * source/org/jfree/chart/LocalisationBundle_de.properties: + Minor correction (see patch 1315259), + * source/org/jfree/chart/ui/LocalisationBundle_de.properties: + Corrections and additions (see patch 1315258). + +2005-11-22 David Gilbert + + * source/org/jfree/data/statistics/HistogramDataset.java + (getSeriesKey): Cast return value to Comparable. + +2005-11-21 David Gilbert + + * source/org/jfree/chart/renderer/category/LayeredBarRenderer.java + (calculateBarWidth): Remove itemMargin from calculation, + (drawItem): Reformatted, + (drawHorizontalItem): Added support for GradientPaint, + (drawVerticalItem): Likewise. + +2005-11-21 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java + (setDrawSeriesLineAsPath): Send RendererChangeEvent if flag changes. + +2005-11-21 David Gilbert + + * source/org/jfree/data/function/NormalDistributionFunction2D.java + (getMean): New method, + (getStandardDeviation): New method, + (getValue): Reformatted. + +2005-11-17 David Gilbert + + * source/org/jfree/data/time/TimeSeries.java + (historyCount): Renamed maximumItemAge, + (TimeSeries(String, String, String, Class)): Update for renamed field, + (getMaximumItemCount): API doc update, + (setMaximumItemCount): Added argument check, and remove surplus items + in a way that fires a SeriesChangeEvent, + (getHistoryCount): Renamed getMaximumItemAge(), + (setHistoryCount): Renamed setMaximumItemAge() and reimplemented, + (add(TimeSeriesDataItem)): Update for refactored method, + (addOrUpdate(RegularTimePeriod, Number)): Likewise, + (ageHistoryCountItems): Renamed removeAgedItems and amended to generate + change notification if requested, + (ageHistoryCountItems(long)): Likewise, + (equals): Updates for renamed method, + (hashCode): Likewise. + * source/org/jfree/data/time/junit/TimeSeriesTests.java + (testEquals): Updated for renamed field. + +2005-11-17 David Gilbert + + * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java + (minValue): Removed, + (maxValue): Removed, + (isDrawLines): Updated API docs, + (setDrawLines): Send RendererChangeEvent, + (getGroupPaint): Updated API docs, + (setGroupPaint): Check for null argument, send change event, + (setGroupStroke): Likewise, + (getObjectIcon): Updated API docs, + (setObjectIcon): Check for null argument, send change event, + (getMaxIcon): Updated API docs, + (setMaxIcon): Check for null argument, send change event, + (getMinIcon): Updated API docs, + (setMinIcon): Check for null argument, send change event, + (drawItem): Refactored (for removed fields). + +2005-11-16 David Gilbert + + * source/org/jfree/data/statistics/HistogramDataset.java + (addSeries): Handle case where data value is smaller than the lower + bound of the bin range. + +2005-11-15 David Gilbert + + * source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java: + Reformatted and reordered methods. + +2005-11-10 David Gilbert + + * source/org/jfree/chart/plot/MeterPlot.java + (tickSize): New field, + (tickPaint): New field, + (tickLabelPaint): New field, + (MeterPlot(ValueDataset)): Initialise new fields, + (getTickSize): New method, + (setTickSize): New method, + (getTickPaint): New method, + (setTickPaint): New method, + (getTickLabelPaint): New method, + (setTickLabelPaint): New method, + (getLegendItems): Use background color for each interval, + (draw): Call new drawValueLabel() method, + (drawArcForInterval): Updated for refactored methods, + (fillArc): Changed from private to protected, + (drawTicks): Make use of new tickSize field, + (drawTick(Graphics2D, Rectangle2D, double)): Updated for refactored + methods, + (drawTick(Graphics2D, Rectangle2D, double, boolean, Paint, boolean, + String)): Removed special case code for drawing the value label, and + the now redundant parameters, replaced with drawValueLabel(), + (drawValueLabel): New method, + (equals): Updated for new fields. + +2005-11-03 David Gilbert + + * source/org/jfree/chart/ChartColor.java + (createDefaultPaintArray): removed orange color, fix for bug 1328408). + +2005-11-02 David Gilbert + + * source/org/jfree/data/time/Month.java + (Month(int, Year)): changed '&&' to '||' in argument check, fixes + bug 1345383. + +2005-11-02 David Gilbert + + * source/org/jfree/chart/ChartRenderingInfo.java + (equals): updated to include plotArea and plotInfo, + * source/org/jfree/chart/junit/ChartRenderingInfoTests.java + (testEquals): expanded to test all fields, + (testSerialization): changed initialisation of object to be serialized, + (testSerialization2): new test, + * source/org/jfree/chart/plot/PlotRenderingInfo.java + (owner): removed transient keyword. + +2005-11-01 David Gilbert + + * source/org/jfree/chart/title/ImageTitle.java + (height): removed field, + (width): removed field, + (ImageTitle(Image, int, int, RectangleEdge, HorizontalAlignment, + VerticalAlignment, RectangleInsets)): set width and height for block, + (drawHorizontal): use block width and height, + (drawVertical): use block width and height, + * source/org/jfree/chart/title/junit/ImageTitleTests.java + (testWidthAndHeight): new method. + +2005-11-01 David Gilbert + + * ant/build.xml: exclude SunJPEGEncoderAdapter.java from the build if + ImageIO is not present, + * source/org/jfree/chart/encoders/ImageEncoderFactory.java + (init): only add 'jpeg' encoder if JFreeChart was compiled, and is + being run, with JDK 1.4 or later, + * source/org/jfree/chart/encoders/SunJPEGEncoderAdapter.java + (encode): use ImageIO, not com.sun.* classes. + +2005-11-01 David Gilbert + + * source/org/jfree/chart/renderer/xy/HighLowRenderer.java + (openTickPaint): new field, + (closeTickPaint): new field, + (getOpenTickPaint): new method, + (setOpenTickPaint): new method, + (getCloseTickPaint): new method, + (setCloseTickPaint): new method, + (drawItem): use openTickPaint and closeTickPaint if non-null, + (equals): implemented, + (readObject): new method to support serialization, + (writeObject): new method to support serialization, + * source/org/jfree/chart/renderer/xy/junit/HighLowRendererTests.java + (testEquals): add checks for all fields, + (testCloning): updated for new fields, + (testSerialization): updated for new fields. + +2005-11-01 David Gilbert + + * source/org/jfree/chart/renderer/xy/HighLow.java: Removed unused + class. + +2005-10-27 David Gilbert + + * source/org/jfree/data/general/junit/DatasetUtilities.java + (testIterateXYRangeBounds2): added API doc comment. + +2005-10-25 David Gilbert + + * source/org/jfree/data/category/DefaultIntervalCategoryDataset.java + (getCategory): removed, + (getItem): removed, + (getSeries(Object)): changed signature to accept Comparable, + (getSeries(int): removed, + (getValue(Comparable, Comparable)): call getColumnIndex() instead of + getItem(), + (getStartValue(Comparable, Comparable)): likewise, + (getEndValue(Comparable, Comparable)): likewise, + (setStartValue(int, Object, Number)): changed signature to (int, + Comparable, Number), + (setEndValue(int, Object, Number)): likewise, + (getCategoryIndex(Object)): changed signature to (Comparable), + (getColumnKey(int)): changed argument name, + (getRowKey(int)): likewise. + +2005-10-25 David Gilbert + + * source/org/jfree/chart/resources/JFreeChartResources.java + (CONTENTS): updated 'project.version'. + +2005-10-25 David Gilbert + + * source/org/jfree/chart/plot/Marker.java + (Marker(Paint, Stroke, Paint, Stroke, float)): changed from public to + protected. + +2005-10-25 David Gilbert + + * source/org/jfree/chart/plot/PolarPlot.java: now implements Zoomable + interface, + (PolarPlot(XYDataset, ValueAxis, PolarItemRenderer)): reformatted, + (addCornerTextItem): check for null argument, generate PlotChangeEvent, + (removeCornerTextItem): generate PlotChangeEvent if necessary, + (clearCornerTextItem): renamed clearCornerTextItems(), and generates + PlotChangeEvent if necessary, + (setAngleLabelsVisible): only send PlotChangeEvent if flag changes, + (drawCornerTextItems): changed from public to protected, + (render): likewise, + (zoomDomainAxes(double, double, double)): changed signature and now + implementation does nothing, + (zoomDomainAxes(double, double, double, double)): likewise, + (zoomRangeAxes(double, double, double)): changed signature to match + Zoomable interface, + (zoomRangeAxes(double, double, double, double)): likewise, + (isDomainZoomable): now returns false, + (getOrientation): new method, + * source/org/jfree/chart/renderer/PolarItemRenderer.java + (drawRadialGridLines): removed commented out code. + +2005-10-25 David Gilbert + + * source/org/jfree/chart/axis/TickUnits.java + (getCeilingTickUnit): don't pass null to other method. + +2005-10-14 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBarRenderer.java + (drawItem): fixed bar coordinates to work with inverted axes. + +2005-10-14 David Gilbert + + * source/org/jfree/chart/ChartPanel.java + (chartChanged): update plot orientation, it may have changed. + +2005-10-07 David Gilbert + + * source/org/jfree/chart/title/TextTitle.java + (textAlignment): new field, + (TextTitle): initialise new field, + (getTextAlignment): new method, + (setTextAlignment): new method, + (equals): include textAlignment in test, + * source/org/jfree/chart/title/junit/TextTitleTests.java + (testEquals): updated to include textAlignment. + +2005-10-06 David Gilbert + + * source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java + (drawItem): removed setPaint() call. + +2005-10-06 David Gilbert + + * source/org/jfree/data/junit/DefaultKeyedValues2DTests.java + (testEquals): New method, + * source/org/jfree/data/xy/CategoryTableXYDataset.java + (CategoryTableXYDataset): register interval delegate as a listener, + (add(Number, Number, String, boolean)): remove call to itemAdded, + (remove(Number, String, boolean)): remove call to itemRemoved, + (getDomainBounds): only pass to delegate if the interval is included, + (setIntervalWidth): update for renamed method, + (equals): implemented, + * source/org/jfree/data/xy/DefaultTableXYDataset.java + (DefaultTableXYDataset(boolean)): register interval delegate as a + listener, + (removeAllSeries): remove class to seriesRemoved, + (removeSeries(XYSeries)): likewise, + (removeSeries(int)): likewise, + (removeAllValuesForX): likewise, + (getDomainBounds): only pass to delegate if the interval is included, + (setIntervalWidth): update for renamed method, + * source/org/jfree/data/xy/IntervalXYDelegate.java: now implements + DatasetChangeListener, + (intervalWidth): renamed fixedIntervalWidth, + (lowerBound): removed, + (upperBound): removed, + (IntervalXYDelegate(XYDataset, boolean)): added check for null dataset, + updated for renamed field, + (setAutoWidth): if true, recalculate interval width, + (getFixedIntervalWidth): new method, + (setIntervalWidth): renamed setFixedIntervalWidth(), now sets autoWidth + to false, + (getIntervalWidth): updated for renamed field, + (getEndXValue): new method, + (getDomainBounds): reimplemented, + (datasetChanged): new method, recalculates auto interval width, + (itemAdded): removed, + (itemRemoved): removed, + (recalculateIntervalWidth): new implementation, + renamed recalculateInterval(), + (calculateSeries): renamed calculateIntervalForSeries(), new + implementation, + (seriesAdded): removed, + (seriesRemoved): removed, + (equals): updated for renamed field, + * source/org/jfree/data/xy/XYSeriesCollection.java + (XYSeriesCollection(XYSeries)): register interval delegate as a + listener, + (addSeries): removed call to seriesAdded(), + (removeSeries(int)): removed call to seriesRemoved(), + (removeSeries(XYSeries)): likewise, + (removeAllSeries): likewise, + (getDomainBounds): only pass to delegate if the interval is included, + (setIntervalWidth): updated for renamed method, + * source/org/jfree/data/xy/junit/CategoryTableXYDatasetTests.java: new + tests, + * source/org/jfree/data/xy/junit/DataXYPackageTests.java + (suite): added CategoryTableXYDatsaetTests.class), + * source/org/jfree/data/xy/junit/DefaultTableXYDatasetTests.java + (testAddSeries): new test method, + * source/org/jfree/data/xy/junit/IntervalXYDelegateTests.java + (testEquals): updated for method name change. + +2005-10-03 David Gilbert + + * source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java + (drawItem): add an entity to the collection if supplied. + +2005-10-03 David Gilbert + + * source/org/jfree/chart/JFreeChart.java + (drawTitle): check for positive area width and height, otherwise + return null (fixes bug 1306022). + +2005-09-30 David Gilbert + + * source/org/jfree/chart/renderer/category/StackedBarRenderer.java + (drawItem): use item outline stroke, not regular stroke. + +For changes prior to 30-Sep-2005, please refer to the file CHANGELOG.txt. diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/NEWS b/WFRperfTool.editor/libs/jfreechart-1.0.17/NEWS new file mode 100755 index 0000000..3583596 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/NEWS @@ -0,0 +1,855 @@ +JFreeChart 1.0.17 +----------------- +24 November 2013 + +Enhanced XYSplineRenderer with new area fill (contributed by Klaus Rheinwald), +added a notify flag to all datasets that extend AbstractDataset, extended +TimeSeriesCollection to validate TimeSeries keys for uniqueness, added a new +DirectionalGradientPaintTransformer (by Peter Kolb), updated OHLCSeries, added +HMSNumberFormat, updated JCommon to version 1.0.21 (includes rotated text +improvements) and fixed some minor bugs. + +Bug Fixes: + + 977 : Multithreading issue with DateAxis; +1084 : BorderArrangement.add() possible ClassCastException; +1099 : XYSeriesCollection.removeSeries(int) does not deregister listener; +1109 : WaterfallBarRenderer uses wrong color for diff 0. + +And now a word from our sponsors, Object Refinery Limited... + +> ORSON CHARTS 3D +> --------------- +> We are pleased to announce the release of Orson Charts, a 3D chart library +> for the Java(tm) platform. Orson Charts has a similar architecture to +> JFreeChart and provides high-quality 3D chart rendering using just the Java2D +> API. The built-in Swing-based viewer provides zooming and full 360 degree +> rotation of charts in any direction. Export options include PNG, PDF and SVG. +> You can download a free evaluation copy of Orson Charts from: +> +> http://www.object-refinery.com/orsoncharts +> +> We've also added a tab to the JFreeChart demo application so you can see +> Orson Charts in action. Orson Charts is not free, but provides a superb +> complement to the extensive 2D charting capabilities of JFreeChart. + + +JFreeChart 1.0.16 +----------------- +13 September 2013 + +*** THIS RELEASE REQUIRES JDK/JRE 1.6.0 OR LATER. *** + +Provided subscript/superscript support for axis labels (via AttributedString), +new axis label positioning options, simplified ChartFactory methods, +added new methods to DatasetUtilities to interpolate y-values in XYDatasets, +added URLs to labels on CategoryAxis, seamless integration with +JFreeSVG (http://www.jfree.org/jfreesvg/) and OrsonPDF +(http://www.object-refinery.com/pdf/), improved the consistency of the +SWTGraphics2D implementation, and fixed various bugs. All the JUnit tests +have been upgraded to JUnit 4. + +Bug Fixes: +1107 : Fixed TimeZone issue in PeriodAxis. + +Also fixed a line drawing issue with the StackedXYAreaRenderer, and a memory +leak in the SWT ChartComposite class. + +IMPORTANT: Funding is vital to the continued success of the JFreeChart project. +Please ask/persuade/beg your company to support us buy purchasing the +JFreeChart Developer Guide and demo source code (site license options are +available for big companies)...and also please take a look at JFreeSVG and +OrsonPDF, useful products that we are charging money for! + + +JFreeChart 1.0.15 +----------------- +4-July-2013 + +Added support for non-visible series in XYBarRenderer, minor gridlines in +PolarPlot, legend item ordering, chart editor enhancements, updates to +StandardDialScale, localisation files for Japanese and refactored parameter +checks. + +This release also fixes a minor security flaw in the DisplayChart class, +detected and reported by OSI Security: + +http://www.osisecurity.com.au/advisories/jfreechart-path-disclosure + +Patches: + +3500621 : LegendTitle order attribute (by Simon Kaczor); +3463807 : ChartComposite does not dispose popup (by Sebastiao Correia); +3204823 : PaintAlpha for 3D effects (by Dave Law); + +Bug Fixes: + +3561093 : Rendering anomaly for XYPlots; +3555275 : ValueAxis.reserveSpace() problem for axes with fixed dimension; +3521736 : DeviationRenderer optimisation (by Milan Ramaiya); +3514487 : SWTGraphics2D get/setStroke() problem; +3508799 : DefaultPolarItemRenderer does not populate seriesKey in LegendItem; +3482106 : Missing text in SWTGraphics2D (by Kevin Xu); +3484408 : Maven fixes (Martin Hoeller); +3484403 : DateAxis endless loop (by Martin Hoeller); +3446965 : TimeSeries calculates range incorrectly in addOrUpdate(); +3445507 : TimeSeriesCollection.findRangeBounds() regression; +3425881 : XYDifferenceRenderer fix (by Patrick Schlott/Christoph Schroeder); +2963199 : SWT print job (by Jonas Rüttimann); +2879650 : Path disclosure vulnerability in DisplayChart servlet; + +Also fixed a rendering issue for polar charts using an inverted axis. + + +JFreeChart 1.0.14 +----------------- +20 November 2011 + +This release contains support for multiple and logarithmic axes with PolarPlot, +optional drop-shadows in plot rendering, fitting polynomial functions to a data +series, some performance improvements in the TimeSeriesCollection class, mouse +wheel rotation of pie charts, improved Maven support and numerous bug fixes. + +Patches: + +3435734 : Fix lines overlapping item labels (by Martin Hoeller); +3421088 : Bugfix for misalignment in BoxAndWhiskerRenderer; +2952086 : Enhancement for finding bounds in XYZDatasets; +2954302 : CategoryPointerAnnotation line calculation; +2902842 : HistogramDataset.addSeries() fires change change event (by + Thomas A Caswell); +2868608 : Whisker width attribute for BoxAndWhiskerRenderer (by Peter Becker); +2868585 : Added useOutlinePaint flag for BoxAndWhiskerRenderer (by + Peter Becker); +2850344 : PolarPlot enhancements (by Martin Hoeller); +2795746 : Support for polynomial regression; +2791407 : Fixes for findRangeBounds() in various renderers. + +Bug Fixes: + +3440237 : Shadows always visible; +3432721 : PolarPlot doesn't work with logarithmic axis; +3433405 : LineChart3D - Problem with Item Labels; +3429707 : LogAxis endless loop; +3428870 : Missing argument check in TextAnnotation; +3418287 : RelativeDateFormatTest.java is locale dependent; +3353913 : Localisation fixes for ChartPanel, CompassPlot and PiePlot3D; +3237879 : RingPlot should respect getSectionOutlineVisible(); +3190615 : Added missing clear() method in CategoryTableXYDataset; +3165708 : PolarChartPanel localisation fix; +3072674 : Bad handling of NaN in DefaultStatisticalCategoryDataset; +3035289 : StackedXYBarRenderer should respect series/item visible flags; +3026341 : Check for null in getDomain/RangeBounds() for XYShapeRenderer; +2947660 : AbstractCategoryRenderer fix null check in getLegendItems(); +2946521 : StandardDialScale check majorTickIncrement argument; +2876406 : TimeTableXYDataset should support Comparable for series keys; +2868557 : BoxAndWhiskerRenderer should fire change event in setMedianVisible(); +2849731 : For IntervalCategoryDataset and IntervalXYDataset, fix + iterateRangeBounds() in DatasetUtilities; +2840132 : AbstractXYItemRenderer drawAnnotations doesn't set renderer index; +2810220 : Offset problem in StatisticalBarRenderer; +2802014 : Dial value border too small; +2781844 : XYPointerAnnotation arrow drawing; +1937486 : AreaRenderer doesn't respect AreaRendererEndType.LEVEL; + +Also fixed: +- use of simple label offset in PiePlot; +- cached minY and maxY in TimeSeries.createCopy(); +- scaling issues for charts copied to the clipboard; +- use of timezone in TimeTableXYDataset constructor; +- duplicate series names in XYSeriesCollection; +- HistogramDataset fires a change event in addSeries(); +- check visibility of main chart title before drawing it; +- fixed serialization of PowerFunction2D, NormalDistributionFunction2D, + and LineFunction2D; +- item label positioning for the AreaRenderer class when the plot has an + horizontal orientation. + + +JFreeChart 1.0.13 +----------------- +20 April 2009 + +****************************************************************************** +* SPECIAL NOTICE: There will be a birds-of-a-feather session for JFreeChart * +* at this year's JavaOne conference in San Francisco. The session is * +* scheduled for 6.45pm to 7.35pm on Wednesday 3 June. * +****************************************************************************** + +This release contains: + +- updates to the ChartPanel class to support copying charts to the clipboard, + panning and mouse-wheel zooming, and an overlay mechanism that supports + crosshairs; +- enhancements to the auto-range calculation for axes, providing the ability + to use subranges only and also to skip hidden series; +- updates for many of the CategoryItemRenderer implementations to ensure that + they respect the 'seriesVisible' flags; +- an improvement to the TimeSeries class so that it is no longer necessary to + specify the time period type in the constructor; +- a new SamplingXYLineRenderer for improving the performance of time series + charts with large datasets; +- the XYSeries/XYSeriesCollection classes now cache the minimum and maximum + data values to improve the performance of charts with large datasets; +- entities are now created for the chart, data area and axes, allowing mouse + clicks to be detected for these regions; +- added a bar alignment factor to the XYBarRenderer class; +- a new 'errorIndicatorStroke' field for the StatisticalLineAndShapeRenderer + and XYErrorRenderer classes; +- added a new HeatMapDataset interface, DefaultHeatMapDataset implementation, + and a HeatMapUtilities class to make it easier to create heat map charts; +- there is a new flag to allow an XYDataImageAnnotation to be included in the + automatic range calculation for the axes; +- additional attributes in the XYTextAnnotation class; +- added a sampleFunction2DToSeries() method to the DatasetUtilities class; +- some changes to the ChartPanel class that help to work around a regression in + JRE 1.6.0_10 relating to drawing in XOR mode. Regarding this final point: + * the default value for the useBuffer flag has changed to true, which means + that all charts will, by default, be rendered into an off-screen image + before being displayed in the ChartPanel; + * the zoom rectangle is drawn using XOR mode *only* when the useBuffer + flag has been set to false. + For most usage, this should improve performance (but at the cost of using more + memory for each ChartPanel used in your application); + +Bug Fixes: + +2690293 : Problem with Javascript escape characters; +2617557 : StandardDialScale ignored tickLabelPaint; +2612649 : Stroke selection in plot property editor; +2583891 : SWTGraphics2D.fillPolygon() not implemented; +2564636 : Month constructor ignores Locale; +2502355 : ChartPanel sending multiple events; +2490803 : PeriodAxis.setRange() method doesn't take into account that the axis + displays whole periods; + +In addition, a bug in the SlidingCategoryDataset class has been fixed, the +correct outline paint is now used by GradientXYBarPainter, a new method +has been added to the ImageMapUtilities class to escape special characters +in Javascript strings to avoid problems with the OverLIB and DynamicDrive +tooltips, and there are some important fixes in the LogAxis class. + +This release passes 2110 JUnit tests (0 failures) on JRE 1.6.0_12. + + +JFreeChart 1.0.12 +----------------- +31 December 2008 + +This release adds support for minor tick marks, mapping datasets to more than +one axis, an important fix for the XYSeries class (relating to the +addOrUpdate() method) plus numerous other bug fixes. + +This release passes 1996 JUnit test (0 failures) on JRE 1.6.0_10. + +API Adjustments: +- CategoryPlot : added mapDatasetToDomainAxes() and mapDatasetToRangeAxes() + methods; +- Month : added a new constructor Month(Date, TimeZone, Locale) and deprecated + Month(Date, TimeZone); +- Quarter : added a new constructor Quarter(Date, TimeZone, Locale) and + deprecated Quarter(Date, TimeZone); +- XYPlot : added mapDatasetToDomainAxes() and mapDatasetToRangeAxes() methods; +- Year : added a new constructor Year(Date, TimeZone, Locale) and deprecated + Year(Date, TimeZone); + +Bug Fixes: +2471906 : XYAreaRenderer with dashed outline - performance problem; +2452078 : StackedAreaChart has gaps; +2275695 : NullPointerException for SubCategoryAxis on plot with null dataset; +2221495 : XYLineAnnotation with dashed stroke; +2216511 : SWTBarChartDemo1 throws RuntimeException; +2201869 : DateAxis tick label position error; +2121818 : Label link lines for very thin RingPlot; +2113627 : XYStepRenderer item labels; +1955483 : XYSeries.addOrUpdate() problem. + +Also fixed StackedXYBarRenderer which was ignoring the shadowsVisible attribute. + + +JFreeChart 1.0.11 +----------------- +19 September 2008 + +This release features a new chart theming mechanism to allow charts to be +restyled conveniently, a new BarPainter mechanism to enhance the appearance of +bar charts, a new XYShapeRenderer class, a scaling facility for the +XYDrawableAnnotation for drawing images within specific data coordinates, some +new classes (XYTaskDataset, XYDataImageAnnotation and XYTitleAnnotation), a +modification to the Year class to support an extended range, and various bug +fixes and API improvements. There is an important bug fix for the +StackedBarRenderer3D class (see bug 2031407). + +This release passes 1,961 JUnit tests (0 failures) on JRE 1.6.0_07. + +API Adjustments: +- AbstractRenderer - added clearSeriesPaints() and clearSeriesStrokes() + methods; +- BarRenderer - added shadowPaint attribute; +- CategoryAxis - added getCategoryMiddle() method; +- CategoryPlot - added getRendererCount() method; +- ChartFactory - added get/setChartTheme() methods; +- ChartPanel - increased default maximum drawing width and height; +- ChartTheme - new interface; +- ChartUtilities - added applyCurrentTheme() method; +- CompositeTitle - added backgroundPaint attribute; +- GradientBarPainter - new class; +- LegendTitle - added getWrapper() method; +- OHLCSeriesCollection - added xPosition attribute; +- PaintScaleLegend - new subdivisions field; +- PiePlot - added autoPopulate flags, and methods to clear section attributes; +- Plot - added setDrawingSupplier() method; +- RegularTimePeriod - the DEFAULT_TIME_ZONE field has been deprecated in this + release; +- RelativeDateFormat - added methods to control formatting of hours and + minutes - see patch 2033092; +- StandardChartTheme - new class; +- XYItemRendererState - new methods; +- XYPlot - added getRendererCount() method; +- XYShapeRenderer - new class; +- XYTaskDataset - new class. + +Patches: +1997549 : Status calls to XYItemRendererState [Ulrich Voigt]; +2006826 : CompositeTitle drawing fix; +2033092 : Additional formatters for RelativeDateFormat [Cole Markham]; + +Bug Fixes: +1994355 : ChartComposite listener type; +2031407 : Incorrect rendering in StackedBarRenderer3D; +2033721 : WaferMapRenderer; +2051168 : No key in LegendItemEntity for pie charts; + +Also fixed drawing of alternate grid bands in SymbolAxis, the totalWeight +calculation in the CombinedXXXPlot classes, a NullPointerException in the +XYPlot class when drawing quadrants, outline visibility in the +CategoryPlot class, and auto-range calculations with XYBarRenderer. + + +JFreeChart 1.0.10 +----------------- +9 June 2008 + +This release contains various bug fixes and minor enhancements to JFreeChart. +PiePlot labelling has been enhanced (new curve options, and more robust bounds +checking). The BoxAndWhiskerRenderer now has a maximumBarWidth attribute, the +XYStepRenderer has a new stepPoint attribute. The RelativeDateFormat class +has new options. There are new dataset classes (SlidingCategoryDataset and +SlidingGanttDataset) that permit a subset of categories to be plotted, and +allow charts based on these datasets to simulate scrolling. There is a new +ShortTextTitle class. + +This release passes 1,929 JUnit tests (0 failures) on JRE 1.6.0_03. + + +API Adjustments: + +- BoxAndWhiskerRenderer - added maximumBarWidth attribute (see patch 1866446); +- ChartPanel - the zoomPoint attribute has been changed from Point to Point2D; +- DatasetUtilities - iterateCategoryRangeBounds() is deprecated, the method + has been renamed iterateRangeBounds(CategoryDataset) for consistency; +- DefaultKeyedValue - the constructor now prevents a null key; +- LogFormat - now has a 'powerLabel' attribute; +- ShortTextTitle - a new title class; +- SlidingCategoryDataset - new class; +- SlidingGanttDataset - new class; +- TimeSeriesCollection - getSeries(String) changed to getSeries(Comparable); +- XIntervalSeriesCollection - added series removal methods; +- YIntervalSeriesCollection - added series removal methods; +- XYIntervalSeriesCollection - added series removal methods; + +PublicCloneable is now implemented by a number of classes that didn't +previously implement the interface - this should improve the reliability of +chart cloning. + +Patches: + +1943021 : Fix for MultiplePiePlot [Brian Cabana]; +1925366 : Speed improvement for DatasetUtilities [Rafal Skalny]; +1918209 : LogAxis createTickLabel() changed from private to + protected [Andrew Mickish]; +1914411 : Simplification of plot event notification [Richard West]; +1913751 : XYPlot and CategoryPlot addMarker() methods with + optional notification [Richard West]; +1902418 : Bug fix for LogAxis vertical labels [Andrew Mickish]; +1901599 : Fixes for XYTitleAnnotation [Andrew Mickish]; +1891849 : New curve option for pie chart label links [Martin Hilpert]; +1874890 : Added step point to XYStepRenderer [Ulrich Voigt]; +1873328 : Enhancements to RelativeDateFormat [Michael Siemer]; +1871902 : PolarPlot now has angleTickUnit attribute [Martin Hoeller]; +1868745 : Fix label anchor points on LogAxis [Andrew Mickish]; +1866446 : Added maximumBarWidth to BoxAndWhiskerRenderer [Rob Van der Sanden]; + +Bug Fixes: + +1932146 - PeriodAxis.setRange() doesn't notify listeners; +1927239 - Fix calculation of cumulative range; +1926517 - Bugs in data range calculation for combined plots; +1920854 - PiePlot3D labels drawn multiple times; +1897580 - Fix for DefaultIntervalCategoryDataset; +1892419 - Wrong default for minor tick count in LogAxis; +1880114 - VectorRenderer doesn't work for horizontal plot orientation; +1873160 - DialPlot clipping issues; +1868521 - Problem saving charts to JPEG format; +1864222 - Error on TimeSeries createCopy() method; + +The DatasetUtilities.sampleFunction2D() has been changed to sample the correct +number of points - you should check any code that calls this method. The +XYBlockRenderer class now generates entities. Bugs in the removeDomainMarker() +and removeRangeMarker() methods in the CategoryPlot and XYPlot classes have +been fixed. A bug in the TimePeriodValues range calculation has been fixed. +Fixes were applied to the clone() methods in the TaskSeries and +TaskSeriesCollection classes. + +New Experimental Features: + +Two new classes CombinedCategoryPlot and CombinedXYPlot have been added to the +'experimental' source tree - these were contributed by Richard West (see +patch 1924543). + + +JFreeChart 1.0.9 +---------------- +4 January 2008 + +This release contains an important security patch as well as various bug fixes +and minor enhancements. Regarding the security patch, please see the +following advisory: + +http://www.rapid7.com/advisories/R7-0031.jsp + +Note that the fix incorporated in the special JFreeChart 1.0.8a release was +flawed in that it broke the URLs in the HTML image maps generated by +JFreeChart. Further amendments have been made in this release to fix this +problem. + +API Adjustments: + +A number of classes have new methods. Nothing has been removed or deprecated: + +- HashUtilities - added hashCode() methods for BooleanList, PaintList and + StrokeList; +- ImageMapUtilities - added htmlEscape(String); +- IntervalMarker - added new constructor; +- Range - added intersects(Range) and scale(Range, double); +- TextTitle - added protected methods arrangeNN(), arrangeFN() and arrangeRN(); +- XYDataItem - added getXValue() and getYValue() methods; +- XYPlot - added setFixedDomainAxisSpace(AxisSpace, boolean) and + setFixedRangeAxisSpace(AxisSpace, boolean); +- XYSeriesCollection - added getSeries(Comparable) method. + + +Bug Fixes: + +1852525 - CandlestickChart.getCategoryPlot() - ClassCastException; +1851416 - testGetFirstMillisecondWithTimeZone fails in 1.0.8a; +1849333 - 1.0.8a breaks URLs in HTML image maps; +1848961 - GroupedStackedBarRenderer works only for primary dataset; +1846063 - Endless loop in paint of XYPlot; +1840139 - Cross-site scripting vulnerabilities in image map code; +1837979 - Background image not shown with SWT; +1460195 - ChartEntity.getImageMapAreaTag() needs nohref; +1400917 - OverLIBToolTipTagFragmentGenerator not escaping single quote; +1363043 - Escape Image Map Data; +1178601 - AbstractRenderer.hashcode() method returns the same value; + +In addition, a bug in the constructor for the Week class has been fixed. + + +JFreeChart 1.0.8 +---------------- +23 November 2007 + +This release is primarily a bug fix release, correcting a problem with pie +chart labelling, a regression in the DefaultCategoryDataset class (and +underlying KeyedValues2D class), and a cloning bug in the TimeSeries class. +In addition, the StatisticalBarRenderer class has a new 'errorIndicatorStroke' +field and has been updated to support gradients, the StandardDialScale has had +some missing accessor methods implemented, and an override field in the +StandardXYItemRenderer class has been deprecated. Plus some warnings reported +by FindBugs 1.3.0 have been addressed. + + +JFreeChart 1.0.7 +---------------- +14 November 2007 + +This release features new classes DialPlot and LogAxis (previously in +experimental), initial support for minor tick units, a new anchored zooming +option for the ChartPanel class, optional simple labelling on pie charts, +improvements to the "statistical" datasets and underlying data structures, and +numerous bug fixes. + +API Adjustments: + +- CategoryAxis - added getCategorySeriesMiddle() method; +- CategoryPlot - added methods to remove markers; +- ChartPanel - added defaultDirectorForSaveAs attribute; +- DialPlot - new class, an alternative to MeterPlot; +- LogAxis - new class, an alternative to LogarithmicAxis; +- NumberTick - new constructor that allows specification of the tick type; +- NumberTickUnit - new constructor to specify the minor tick count; +- SymbolAxis - new methods get/setGridBandAlternatePaint(); +- TickType - new class; +- TickUnit - added minorTickCount attribute; +- ValueTick - added tickType attribute; +- StandardPieSectionLabelGenerator - new constructors accepting a Locale; +- StandardPieToolTipGenerator - likewise; +- CategoryPlot - added getRangeAxisIndex(), zoomDomainAxes() and zoomRangeAxes() + methods; +- FastScatterPlot - added new zooming methods; +- PiePlot - new attributes to support simple labelling; +- PlotUtilities - new class; +- PolarPlot - added new zooming methods; +- ThermometerPlot - likewise; +- XYPlot - added methods to remove markers (patch 1823697--same as for + CategoryPlot), and added new zooming methods; +- Zoomable - added new zooming methods to this interface; +- LineAndShapeRenderer - added useSeriesOffset and itemMargin attributes; +- MinMaxCategoryRenderer - implemented equals(); +- XYSplineAndShapeRenderer - new class; +- LogFormat - new class; +- ChartFactory - new pie and ring chart creation methods that accept a Locale; +- ChartPanel - added zoomAroundAnchor attribute; +- Series - added isEmpty() method; +- BoxAndWhiskerItem - new convenience constructor; +- DefaultBoxAndWhiskerCategoryDataset - new remove methods; +- DefaultStatisticalCategoryDataset - likewise; +- MeanAndStandardDeviation - added new value accessor methods; +- TimeTableXYDataset - added clear() method; +- Week - added new constructor; +- KeyedObjects - added insertValue() and clear() methods; +- KeyedObjects2D - added clear() method. + +Patches: + +1823724 - updated XYDifferenceRenderer to support item labels; +1827829 - fixed possible NullPointerException in XYBarRenderer; + +Bug Fixes: + +1767315 - GrayPaintScale.getPaint() uses wrong value; +1775452 - Inverted XYBarRenderer does not render margins correctly; +1802195 - Marker.listenerList serializable; +1779941 - StatisticalBarRenderer NPE; +1766646 - XYBlockRenderer can't handle empty datasets; +1763413 - PeriodAxis labels fail to display with setInverted +1737953 - Zoom doesn't work on LogAxis(Demo1) +1749124 - JFreeChart not added as TitleChangeListener + + +JFreeChart 1.0.6 +---------------- +15 June 2007 + +This release features a new VectorRenderer (previously in experimental), a +generalised XYDifferenceRenderer, better support for hotspots on legend items, +improved performance for time series charts displaying subsets of data, support +for GradientPaint in plot backgrounds, plus the usual slew of bug fixes and +minor feature additions. + +API Adjustments: + +- CategoryItemEntity - replaced row and column index attributes with row and + column key attributes; +- CategoryItemRenderer - numerous series override settings have been deprecated; +- DefaultPieDataset - added insertValues() method; +- HexNumberFormat - new class; +- LegendItem - added dataset and seriesKey attributes; +- Plot - added new fillBackground() method to support GradientPaint, and + added is/setOutlineVisible() methods; +- QuarterDateFormat - added GREEK_QUARTERS field plus a new constructor; +- SimpleHistogramDataset - added clearObservations() and removeAllBins() + methods; +- TimeSeriesCollection - added indexOf() method; +- URLUtilities - new class; +- XYItemRenderer - numerous series override settings have been deprecated; +- XYSeriesCollection - added indexOf() method. + +Bug Fixes: + +1735508 - ClusteredXYBarRenderer fails with inverted x-axis; +1726404 - ChartComposite tooltips; +1713474 - StackedBarRenderer3D doesn't fill shadows; +1713401 - StackedBarRenderer3D doesn't check drawBarOutline flag; +1701822 - DefaultBoxAndWhiskerCategoryDataset doesn't follow contracts; +1698965 - NPE in CombinedDomainXYPlot; +1690994 - HideSeriesDemo1 does not work; +1690654 - Bug in removeValue() of DefaultKeyedValues2D; +1562701 - LegendItemEntity needs dataset index; +1486299 - Use URLEncoder.encode() for URL generators; + +Plus the following bugs that didn't have entries in the database: + +- BarRenderer - check for series visibility in getLegendItem(); +- ChartPanel - use correct insets for painting chart buffer to screen, update + UI for popup menu if LookAndFeel changes; +- DateAxis - fixed boundary cases for previousStandardDate() method; +- LineBorder - only draw border if area has positive dimensions; +- JFreeChart - should register as a listener with the default legend; +- StandardXYItemRenderer - fixed a problem where chart entities are created for + non-visible items; +- TimePeriodValuesCollection.getDomainBounds() now computes the bounds + correctly; +- XYLineAndShapeRenderer - fixed a problem where chart entities are created for + non-visible items; +- XYLine3DRenderer - equals() implemented, and serialization fixed; +- XYTitleAnnotation - fixed equals() method; +- various resource usage bugs in the experimental ChartComposite class; + + +JFreeChart 1.0.5 +---------------- +23 March 2007 + +This release features a new DeviationRenderer class, support for item labels +in StackedXYBarRenderer, tooltips and URLs in the CategoryStepRenderer, and +many bug fixes. + +API Adjustments: + +- AbstractCategoryItemRenderer - added createState() method; +- StackedXYBarRenderer - added get/setRenderAsPercentages() methods; +- XYIntervalSeries - added getXLowValue(), getXHighValue(), getYLowValue() and + getYHighValue(); +- YIntervalSeries - added getYLowValue() and getYHighValue() methods; + +Bug Fixes: + +1681777 - DefaultCategoryDataset does not clone data; +1672552 - Zoom rectangle is lost when the chart is repainted; +1671645 - Crosshair incorrectly positioned in horizontal orientation; +1669302 - Tick labels in vertical symbol axis; +1669218 - CategoryPlot.setDomainAxisLocation() ignores parameter; +1667750 - Clip region not restored in Spider and MeterPlot; +1663380 - OutputStream not closed; +1659627 - IntervalMarker with Double.POSITIVE_INFINITY bound; +1647269 - IntervalMarker with Double.MAX_VALUE as upper bound; +1594477 - XYBarRenderer does not render bars on LogarithmicAxis; +1459958 - Log axis zoom function problem; + 880597 - Zooming ChartPanel with log axes; + 764561 - Dynamic chart zoom buggy. + +Also fixed numerous bugs in equals(), cloning and serialization +implementations. + + +JFreeChart 1.0.4 +---------------- +9 February 2007 + +This release features a new XYBlockRenderer class, URLs for pie chart labels +in HTML image maps, a new dataset implementation for open-high-low-close +charts, support for gradient paint in ClusteredXYBarRenderer, +StackedXYBarRenderer and legend graphics, a new anchor attribute for +XYImageAnnotation, improvements to the experimental SWT support, plus a +number of additions to the API for usability, and many bug fixes. + +API Adjustments: + +- DateAxis - added get/setTimeZone() methods; +- DefaultXYDataset - now implements PublicCloneable; +- StackedXYAreaRenderer2 - added get/setRoundXValues() methods; +- StandardXYItemLabelGenerator - added new constructor; +- StandardXYToolTipGenerator - added new constructor; +- XYBarDataset - added getUnderlyingDataset() and get/setBarWidth() methods; +- XYDifferenceRenderer - added roundXCoordinates attribute; +- XYImageAnnotation - added an image anchor attribute, a new constructor, and + several accessor methods; +- XYSeries - added toArray() method; + +Bug Fixes: + +1654215 - XYPlot renderer with no corresponding dataset; +1652640 - RangeMarkers do not update properly; +1649686 - Crosshairs for StackedXYAreaRenderer; +1647749 - IllegalArgumentException in SWTAxisEditor; +1644877 - Replacing series data in DefaultXYDataset; +1644010 - DateAxis.nextStandardDate() ignores timezone; +1638678 - DateAxis code uses the default calendar; +1629382 - Tests fail for jfreechart-1.0.3; +1624067 - StandardXYToolTipGenerator missing constructor; +1616583 - Serialize ChartDeleter; +1612770 - Popup menu in wrong position for SWT ChartComposite; +1611872 - Minute.previous() returns null for minute == 0; +1608371 - Tick labels overlap with custom NumberFormat; +1606205 - Draw shared axis last on combined plots; +1605207 - IntervalMarker exceeds bounds of data area; +1605202 - SpiderWebPlot method access; +1599652 - Inverted StackedBar3D problem; +1598394 - XYBarDataset hiding its proxied object; +1564967 - Crosshairs on XYDifferenceRenderer; +1245305 - NullPointerException in writeImageMap(); +1086307 - Crosshairs on plots with multiple axes. + +Also fixed numerous bugs in equals() and clone() methods throughout the API. + + +JFreeChart 1.0.3: +----------------- +17 November 2006 + +This release features several new IntervalXYDataset implementations, some +significant refactoring of the time period classes (to improve performance +and correctness), modifications to the PiePlot class to support reordering of +dataset items, a new event mechanism to allow updating of markers, plus many +other enhancements, bug fixes and documentation updates. + +A new DialPlot implementation has been added to the 'experimental' sources. +We are looking for people to test this code and provide feedback, so that we +can stabilize the API and add this code to the main JFreeChart API. + +API adjustments: + +The following adjustments have been made to the API: + +- CategoryLabelEntity - new class; +- CategoryPointerAnnotation - new class; +- ChartPanel: added new public method doEditChartProperties(); +- ComparableObjectItem, ComparableObjectSeries - new classes; +- CrosshairState: added several new accessor methods; +- DefaultPieDataset: added sortByKeys() and sortByValues() methods; +- Markers: a change event mechanism has been added to the Marker class and + its subclasses; +- StackedAreaRenderer: added get/setRenderAsPercentages() methods; +- XIntervalDataItem, XIntervalSeries and XIntervalSeriesCollection - new + classes; +- XYErrorRenderer: new class; +- XYInterval, XYIntervalDataItem, XYIntervalSeries and + XYIntervalSeriesCollection - new classes; +- YInterval, YIntervalDataItem, YIntervalSeries, YIntervalSeriesCollection and + YWithXInterval - new classes. + +Bug Fixes: + +1578293 - Unused methods in JDBCXYDataset; +1572478 - BoxAndWhiskerRenderer potential NullPointerException; +1569094 - XYStepRenderer with horizontal orientation; +1565168 - Crosshair position incorrect; +1564977 - DateAxis missing initial tick label; +1562759 - StatisticalLineAndShapeRenderer constructor ignores arguments; +1557141 - Bad locale in ServletUtilities; +1550045 - TimeSeries.removeAgedItems() method problems; +1549218 - Chart not displaying when all data values are the same and large; +1450447 - Marker.setAlpha() ignored; + +Also fixed URL generation for legend items, tick mark positioning on the +DateAxis, the equals() method in the AreaRenderer class, hardcoded outline +attributes in the XYBubbleRenderer, and potential NullPointerExceptions in the +ChartPanel class. + + +JFreeChart 1.0.2: +----------------- +Released on 25 August 2006. + +API adjustments: + +The following adjustments have been made to the API (there should be no +breakage of applications coded to the 1.0.0 or 1.0.1 API): + +- CategoryToPieDataset: added accessor methods for underlying dataset, extract + type and index (feature request 1477915); +- DefaultXYDataset: New dataset implementation that uses double[] arrays; +- DefaultXYZDataset: New dataset implementation that uses double[] arrays; +- LegendItemBlockContainer: New container used in legends (enables + legend item entities again); +- MultiplePiePlot: Added new fields aggregatedItemsKey and + aggregatedItemsPaint, plus accessor methods - see bug 1190647; +- SpiderWebPlot: Added new fields toolTipGenerator and urlGenerator, plus + accessor methods (see patch 1463455); +- StackedBarRenderer3D: Added new flag (renderAsPercentages), plus accessor + methods, that controls whether the data items are displayed as values or + percentages. Two new constructors are also added (see patch 1459313); +- XYPolygonAnnotation: Added new accessor methods. + +Patches: + +1459313 - Add renderAsPercentages option to StackedBarRenderer3D; +1462727 - Modify SpiderWebPlot to support zero values; +1463455 - Modify SpiderWebPlot to support mouse clicks, tool tips and URLs; + +Bug Fixes: + +1514904 - Background image alpha in Plot class; +1499140 - ClusteredXYBarRenderer with margin not drawing correctly; +1494936 - LineAndShapeRenderer generates entity for non-visible item; +1493199 - NPE drawing SpiderWebPlot with null info; +1480978 - AbstractPieItemLabelGenerator.clone() doesn't clone percentFormat; +1472942 - DateAxis.equals() broken; +1468794 - StatisticalLineAndShapeRenderer doesn't draw error bars correctly + when the plot has a horizontal orientation; + - AbstractCategoryItemRenderer doesn't check seriesVisibleInLegend + flag before creating new item; +1440415 - Bad distribution of pie chart section labels; +1440346 - Bad manifest entry for JCommon in JFreeChart jar file; +1435461 - NumberAxis.equals() ignores rangeType field; +1435160 - XYPointerAnnotation.equals() ignores x and y fields; +1398672 - LegendItemEntities not working; +1380480 - StandardXYItemRenderer problems with Double.NaN; +1190647 - Legend and section color mismatch for MultiplePiePlot. + +Miscellaneous Changes: + +- Updated CandlestickRenderer, CyclicXYItemRenderer, HighLowRenderer, + XYStepAreaRenderer and TimeSeriesURLGenerator to call dataset methods that + return double primitive only; +- Updated XYPolygonAnnotation, adding new accessor methods and fixing problems + in the equals()/hashCode() methods; +- ChartFactory.createStackedXYAreaChart() now uses StackedXYAreaRenderer2, for + better handling of negative values; +- Added crosshair support for XYBarRenderer. + +Experimental Code: + +In this release, some new (incomplete) classes have been included in the +org.jfree.experimental.* namespace. These classes are not part of the +standard API, but are included for developers to experiment with and provide +feedback on. Hopefully in the future, refined versions of these classes will +be incorporated into the main library. PLEASE NOTE THAT THE API FOR THESE +CLASSES IS SUBJECT TO CHANGE. + + +JFreeChart 1.0.1: +---------------- +Released 27 January 2006. This is primarily a bug fix release. In addition, +there are some API adjustments (there should be no breakage of applications +coded to the 1.0.0 API). + +API adjustments: +- BarRenderer: added a new flag (includeBaseInRange), plus accessor + methods, that controls whether or not the base value for the bar is + included in the range calculated by the findRangeBounds() method; +- BubbleXYItemLabelGenerator: new class; +- Range: added a new method expandToInclude(Range, double), this is used by + the BarRenderer class; +- TaskSeriesCollection: added two new methods, getSeries(int) and + getSeries(Comparable). +- TimeSeriesCollection: the domainIsPointsInTime flag has been deprecated. + The flag serves no function now that renderers are used to calculate the + domain bounds, so you can safely delete any calls to the + setDomainIsPointsInTime() method; +- XYPlot: added a new getAnnotations() method; +- XYSeries: the update(int, Number) method has been deprecated and a new method + updateByIndex(int, Number) has been added; + +Bug fixes: + +1243050 - XYBarRenderer doesn't show entire range of values for a + TimeSeriesCollection; +1373371 - XYBubbleRenderer doesn't support item labels; +1374222 - BarRenderer contains JDK 1.4 specific code; +1374328 - LegendItem serialization problem; +1377239 - Bad argument checking in Quarter constructor; +1379331 - Incorrect drawing of TextTitle at LEFT or RIGHT position; +1386328 - RingPlot entity incorrect; +1400442 - Inconsistent treatment of null and zero values in PiePlot; +1401856 - Bad rendering for non-zero base values in BarRenderer; +1403043 - NullPointerException in CategoryAxis; +1408904 - NumberAxis3D assumes CategoryPlot; +1415480 - XYTextAnnotation equals() method doesn't check (x, y); + + +JFreeChart 1.0.0: +---------------- +Released on 2 December 2005. diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/README.txt b/WFRperfTool.editor/libs/jfreechart-1.0.17/README.txt new file mode 100755 index 0000000..4e5461f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/README.txt @@ -0,0 +1,817 @@ +******************************** +* JFREECHART: Version 1.0.17 * +******************************** + +24 November 2013 + +(C)opyright 2000-2013, by Object Refinery Limited and Contributors. + +----------------- +1. INTRODUCTION +----------------- +JFreeChart is a free chart library for the Java(tm) platform. It runs +on the Java 2 Platform (JRE 1.6.0 or later) and uses the Java 2D API for +drawing. + +JFreeChart is licensed under the terms of the GNU Lesser General +Public Licence (LGPL). A copy of the licence is included in the +distribution. + +Please note that JFreeChart is distributed WITHOUT ANY WARRANTY; +without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +PARTICULAR PURPOSE. Please refer to the licence for details. + +We are grateful to the many developers that have contributed to JFreeChart. +The contributors are listed below in section 10. + +------------------- +2. LATEST VERSION +------------------- +The latest version of this class library can be obtained from: + + http://www.jfree.org/jfreechart/ + +If you have any comments, suggestions or bugs to report, please post a +message in the JFreeChart forum. + +----------------- +3. DOCUMENTATION +----------------- +You can download installation instructions +(jfreechart-1.0.17-install.pdf) from the JFreeChart home +page or the project page on SourceForge. + +Further documentation for JFreeChart (the JFreeChart Developer Guide) is +available to purchase from by Object Refinery Limited, a company owned and +operated by David Gilbert (the original author of JFreeChart). For more +information, please see: + + http://www.object-refinery.com/jfreechart/guide.html + +Sales of the JFreeChart Developer Guide are an important source of funding for +the project. Please help us to continue developing free software. + +API documentation files in HTML format are available on-line. If you wish +to keep a local copy of the API files, you can regenerate them directly +from the source code. You can do this using the 'javadoc' utility directly, +or with the Ant script (build.xml) included in the distribution. + +----------------- +4. DEPENDENCIES +----------------- +JFreeChart has the following dependencies: + +(a) JRE/JDK 1.6.0 or higher - note that the previous release of JFreeChart +worked with JRE/JDK 1.4.2 or later. With a bit of hacking, it may be possible +to get JFreeChart working on these older versions, but we are no longer +supporting it. + +(b) JCommon - version 1.0.0 or later. The runtime jar file (version 1.0.21) +is included in the JFreeChart distribution. You can obtain the complete +source code for JCommon from: + + http://www.jfree.org/jcommon/ + +JCommon is licensed under the terms of the GNU Lesser General Public Licence. + +(c) servlet.jar - classes in the org.jfree.chart.servlet +package require this file. The JFreeChart distribution includes the +servlet.jar file distributed with Tomcat 4.1.31. Applicable license +terms are published at: + + http://java.sun.com/products/servlet/LICENSE + +(d) JUnit - a unit testing framework (the junit.jar runtime file is +included in the distribution). JUnit is licensed under the terms +of the IBM Common Public License. You can find out more about JUnit +and/or download the latest version from: + + http://www.junit.org + +The JUnit tests included with JFreeChart have been created using JUnit +4.3.1. + +----------- +5. SUPPORT +----------- +Support questions can be posted in the free support forum at + + http://www.jfree.org/forum/viewforum.php?f=3 + +We read all questions posted in the forum, and respond to as many as we can +in the time available. Unfortunately, there are too many questions to answer +them all. + +-------------------- +6. ANT BUILD SCRIPT +-------------------- +An Ant build script (build.xml) is included in the distribution. This +is the same script that is used to create the JFreeChart distribution. + +For more information about Ant: + + http://ant.apache.org/ + +If you want to rebuild the JFreeChart jar file, we highly recommend that you +use this script as it includes certain files (for example, .properties files) +that you MUST have in the jar file for JFreeChart to function correctly. + +------------------------ +7. THE DEMO APPLICATION +------------------------ +A demo application that shows a selection of the charts that can be +generated is included in the JFreeChart distribution. To run the +demo (using JDK 1.6.0 or later), use the following command: + + java -jar jfreechart-1.0.17-demo.jar + +The complete source code for the demo application is available for +download when you purchase the JFreeChart Developer Guide. + +The demo application also links to the JFreeSVG and OrsonPDF libraries, to +provide export facilities to the SVG and PDF formats. These fast, lightweight +libraries are not free, licenses can be purchased from Object Refinery Limited. + +An additional tab added to the demo application in version 1.0.17 showcases +Orson Charts 3D, a new library by Object Refinery Limited. You can find out +more about Orson Charts at: + + http://www.object-refinery.com/orsoncharts/ + +--------------- +8. LIMITATIONS +--------------- +JFreeChart has some known limitations that will hopefully be addressed in +the future: + + - some renderers do not respect the series visibility flags yet; + - the chart property editors (accessible by right-clicking on the chart + panel) are horribly out of date and probably shouldn't be used; + - item labels (if displayed) are not taken into account for the + automatically calculated axis range. As a workaround, you can increase + the axis margins; + - tick labels on a DateAxis that uses a SegmentedTimeline can be + problematic; + +If there are other items that you think should be listed here, +please post a bug report. + +-------------- +9. WHAT's NEW +-------------- +A list of changes in recent versions: + +1.0.17 : (22-Nov-2013) + - see the NEWS and ChangeLog files for details. + +1.0.16 : (13-Sep-2013) + - bumped the required JRE to 1.6, enhanced axis labelling, provided + integration with JFreeSVG and OrsonPDF for vector output, and fixed + bugs. + +1.0.15 : (4-Jul-2013) + - various minor feature enhancements and a range of bug fixes, see the + NEWS and ChangeLog files for details. + +1.0.14 : (20-Nov-2011) + - added support for multiple axes in PolarPlot, performance + improvements in the TimeSeriesCollection class, mouse wheel rotation + in the PiePlot class, improved Maven support, a range of other + minor functional enhancements and numerous bug fixes - see the NEWS + and ChangeLog files for details. + +1.0.13 : (17-Apr-2009) + - there are some significant new features in this release, as well + as performance enhancements and bug fixes - see the NEWS and + ChangeLog files for details. + +1.0.12 : (31-Dec-2008) + - added support for minor tick marks, mapping datasets to more than + one axis, and numerous bug fixes - see the NEWS and ChangeLog files + for details. + +1.0.11 : (18-Sep-2008) + - this release includes a new chart theming mechanism, and numerous + other feature enhancements and bug fixes - see the NEWS and ChangeLog + files for details. + +1.0.10 : (8-Jun-2008) + - another general maintenance release - see the NEWS and ChangeLog + files for more details. + +1.0.9 : (4-Jan-2008) + - this release fixes a security advisory with respect to the HTML + image maps generated by JFreeChart - see the NEWS file for more + information. In addition, a number of bugs have been fixed. + +1.0.8 : (23-Nov-2007) + - primarily a bug fix release. See the NEWS and ChangeLog files for a + more detailed description of the changes in this release. + +1.0.7 : (14-Nov-2007) + - See the NEWS and ChangeLog files for a more detailed description of + the changes in this release. + +1.0.6 : (15-Jun-2007) + - the VectorRenderer and associated dataset classes have been promoted + to the standard API from the 'experimental' source tree. See the + NEWS and ChangeLog files for a more detailed description of the + changes in this release. + +1.0.5 : (23-Mar-2007) + - this release contains a new DeviationRenderer, enhancements to a + number of existing classes and numerous bug fixes, see the NEWS + and ChangeLog files for details. + +1.0.4 : (9-Feb-2007) + - this release contains both new features and bug fixes, see the NEWS + and ChangeLog files for details. + +1.0.3 : (17-Nov-2006) + - this release contains a new DialPlot class (in 'experimental') that + will hopefully replace the MeterPlot class, once the API has been + polished a little, plus many other new features and bug fixes. See + the NEWS and ChangeLog files for details. + +1.0.2 : (25-Aug-2006) + - this release contains both new features and bug fixes, see the NEWS + and ChangeLog files for details. + +1.0.1 : (27-Jan-2006) + - primarily a bug fix release, see the NEWS and ChangeLog files for + details. + +1.0.0 : (2-Dec-2005) + - the first stable release of the JFreeChart class library, all future + releases in the 1.0.x series will aim to maintain backward + compatibility with this release; + - see the ChangeLog file for a detailed list of changes. + +1.0.0-rc3 : (28-Nov-2005) + - the third "release candidate" for version 1.0.0, this release + fixes some issues with the 1.0.0-rc2 release (mainly concerning + packaging of resource bundles for localisation). + - if no significant problems are reported in the next few days, + the 1.0.0 "final" release will be posted on 2-Dec-2005. + +1.0.0-rc2 : (25-Nov-2005) + - the second "release candidate" for version 1.0.0. If no problems + are reported, 1.0.0 "final" will be released on 2-Dec-2005. + - see the ChangeLog file for a detailed list of changes in this + release. + +1.0.0-rc1 : (2-Jun-2005) + - this is a "release candidate" for version 1.0.0. If no + significant API problems are reported, this release will be + re-released as version 1.0.0. + - see CHANGELOG.txt for further details. + +1.0.0-pre2 : (10-Mar-2005) + - see CHANGELOG.txt for further details. + +1.0.0-pre1 : (29-Nov-2004) + - see CHANGELOG.txt for further details. + +0.9.21 : (9-Sep-2004) + - added new axes: PeriodAxis and ModuloAxis. + - split org.jfree.data and org.jfree.chart.renderer into + subpackages for 'category' and 'xy' charts. + - Sun PNG encoder is now used, if available. + - a new demo application makes it easier to preview the + chart types that JFreeChart can create. + - added a new series visibility flag to the AbstractRenderer + class. + - added support for GradientPaint in interval markers. + - see CHANGELOG.txt for further details. + +0.9.20 : (7-Jun-2004) + - primarily bug fixes, see CHANGELOG.txt for further details. + +0.9.19 : (28-May-2004) + - added methods to XYDataset that return double primitives; + - removed distinction between "primary" and "secondary" datasets, + renderers and axes; + - added fixed legend item options to CategoryPlot and XYPlot; + - legend changes by Barek Naveh; + - removed Log4j dependency; + - many, many bug fixes; + - see CHANGELOG.txt for further details. + +0.9.18 : (15-Apr-2004) + - new legend anchor options; + - fixed broken JPEG export; + - fixed title size problems; + - various other bug fixes; + +0.9.17 : (26-Mar-2004) + - pie chart enhancements for labelling, shading and multiple pie + charts (2D or 3D) on a single plot; + - new PolarPlot class added; + - XYSeries can now be sorted or unsorted; + - createBufferedImage() method can now scale charts; + - domain and range markers now support intervals; + - item labels are now supported by some XYItemRenderers; + - tooltip and item label generators now use MessageFormat class; + - added new XYBarDataset class; + - added transparency support to PNG export; + - numerous other small enhancements and bug fixes, see the + CHANGELOG.txt file for more details; + +0.9.16 : (09-Jan-2004) + - this release contains bug fixes and some minor feature + enhancements (title and category label wrapping, legend shape + scaling, enhanced performance for the DefaultTableXYDataset class); + - added Spanish localisation files; + +0.9.15 : (28-Nov-2003) + - the focus of this release is bug fixes - quite a number of issues + have been resolved, please check the bug database for details; + - added a new Wafer Map chart type; + - added a cyclic axis; + - added localisation files for _ru; + +0.9.14 : (17-Nov-2003) + - implemented zooming for the FastScatterPlot class; + - added item label support for stacked bar charts, and new fall back + options for item labels that don't fit within bars; + - modified the CategoryAxis class to allow additional options for the + alignment and rotation of category labels; + - addition of the AxisState class, used in the drawing of axes to + eliminate a bug when multiple threads draw the same axis + simultaneously; + - provided additional attributes in the DateTickUnit class to improve + labelling on a segmented DateAxis; + - added support for GradientPaint in bar charts; + - updated the PNGEncoder; + - fixes for tick label positioning on axes; + - various Javadoc updates; + - numerous bug fixes; + +0.9.13 : (26-Sep-2003) + - various enhancements to the stacked area XY charts; + - added a completion indicator for the Gantt chart; + - range and domain markers can now be placed in the foreground or the + background; + - more fixes for cloning and serialization; + - fixed mouse event bug for combined charts; + - fixed bugs in the PngEncoder class; + - incorporated .properties files that were missing from the 0.9.12 + distribution; + +0.9.12 : (11-Sep-2003) + - extended box-and-whisker plots to work with the CategoryPlot class + as well as the XYPlot class (based on work by David Browning); + - added a new LayeredBarRenderer (by Arnaud Lelievre); + - added support for stacked area charts with the XYPlot class (thanks + to Richard Atkinson); + - improved HTML image map support (thanks to Richard Atkinson); + - added localized resources for the chart property editors (thanks to + Arnaud Lelievre). Current translations include French and Portugese + (thanks to Eduardo Ramalho); + - added facility for setting all rendering hints; + - improved support for cloning and serialization; + - fixed a bug in the XYSeries class that prevented the TableXYDataset + from functioning correctly; + - improved date axis labelling with segmented time lines; + - fixed several bugs in the secondary dataset/axis/renderer code; + - fixed bugs in the JDBCCategoryDataset class; + - numerous other bug fixes; + +0.9.11 : (8-Aug-2003) + - added support for box-and-whisker plots, thanks to David Browning; + - lots of bug fixes; + +API changes in this release are minimal and have been implemented using +deprecation, so code written against 0.9.10 should recompile. + +0.9.10 : (25-Jul-2003) + - added support for multiple secondary axes, datasets and + renderers; + - minor feature enhancements and bug fixes; + +0.9.9 : (10-Jul-2003) PLEASE NOTE THAT MAJOR CHANGES HAVE BEEN MADE IN THIS +RELEASE AND ONE OR TWO FEATURES MAY BE BROKEN. PLEASE REPORT BUGS SO THEY CAN +BE FIXED FOR THE NEXT RELEASE. + + - merged the HorizontalCategoryPlot and VerticalCategoryPlot classes, + into the CategoryPlot class; + - merged the horizontal and vertical axis classes; + - merged the horizontal and vertical renderer classes; + - CategoryPlot and XYPlot now support both horizontal and vertical + orientation via the setOrientation(...) method; + - merged horizontal and vertical methods in the ChartFactory class; + - created new combined plot classes: CombinedDomainCategoryPlot, + CombinedRangeCategoryPlot, CombinedDomainXYPlot and + CombinedRangeXYPlot (these can all be drawn with a horizontal or + vertical orientation); + - Bill Kelemen has enhanced the DateAxis class to handle segmented + timelines. This can be used, for example, to skip weekends for + daily stock price charts; + - Richard Atkinson has updated the ServletUtilities class; + - Bryan Scott has added an XYDatasetTableModel class for presenting + datasets in a JTable; + - modified XYPlot to allow renderers to use multiple passes through + the dataset; + - added new XYDifferenceRenderer; + - added support for colored bands between gridlines in XYPlot; + - added new XYDrawableAnnotation class; + - added a new attribute to control the order of dataset rendering in + a CategoryPlot; + - extended the value label mechanism for the renderers, to allow + better (per series) control over label generation, positioning and + visibility; + - CategoryItemTooltipGenerator has been renamed + CategoryItemLabelGenerator, since it is now being used to generated + item labels as well as tooltips; + - there is now support for horizontal stacked 3D bar charts; + - added support for range markers against secondary axis in a + CategoryPlot; + - added labels to domain and range markers; + - added a new HistogramDataset class (contributed by Jelai Wang) to + make it easier to create histograms with JFreeChart; + - moved the DrawingSupplier into the plot class, renderers now + reference the supplier from the plot (parent plot for combined and + overlaid charts). This means that renderers now share a single + DrawingSupplier by default, which simplifies the creation of + combined charts; + - changed the ColorBarAxis classes that extended the NumberAxis class, + to a single ColorBar class that wraps a ValueAxis (may have broken + one or two things in the process); + - Barak Naveh has contributed new classes MatrixSeries and + MatrixSeriesCollection, along with demos: BubblyBubblesDemo.java + and BubblyBubblesDemo2.java; + - the TextTitle class now has a background paint attribute; + - the StandardLegend class now generates LegendEntity objects if a + ChartRenderingInfo instance is supplied to the draw(...) method; + - extended the CategoryTextAnnotation class to take into account a + category anchor point. See the SurveyResultsDemo.java application + for an example; + - included numerous bug fixes; + +0.9.8 : (24-Apr-2003) + - changed package naming from com.jrefinery.* to org.jfree.*; + - added new TimePeriodValuesCollection class; + - added MIME type code to ServletUtilities class; + - reversed the order of PieDataset and KeyedValuesDataset in + the class hierarchy; + - reversed the order of CategoryDataset and KeyedValues2DDataset + in the class hierarchy; + - minor bug fixes; + +0.9.7 : (11-Apr-2003) + - added a new ValueDataset interface and DefaultValueDataset + class, and changed the CompassPlot class to use this instead + of MeterDataset; + - added DataUtilities class, to support creation of Pareto + charts (new demo included); + - updated writeImageMap method as suggested by Xavier Poinsard + (see Feature Request 688079); + - implemented Serializable for most classes (this is likely to + require further testing); + - incorporated contour plot updates from David M. O'Donnell; + - added new CategoryTextAnnotation and XYLineAnnotation + classes; + - added new HorizontalCategoryAxis3D class contributed by + Klaus Rheinwald; + + Bug fixes: + - added a workaround for JVM crash (a JDK bug) in pie charts + with small sections (see bug report 620031); + - fixed minor bug in HorizontalCategoryPlot constructor (see + bug report 702248); + - added code to ensure HorizontalNumberAxis3D is not drawn if + it is not visible (see bug report 702466); + - added small fix for suppressed chart change events (see bug + report 690865); + - added pieIndex parameter to tooltip and URL generators for + pie charts; + - fixed bug in getLastMillisecond() method for the Second + class and the getFirstMillisecond() method for the Year + class (picked up in JUnit tests); + - in TextTitle, changed width used for relative spacing to fix + bug 703050; + +0.9.6 : (17-Feb-2003) Bug fixes: + - fixed null pointer exception in DefaultCategoryDataset; + - fixed update problem for PaintTable, StrokeTable and + ShapeTable objects; + - added methods to control colors in PiePlot (these were + inadvertantly removed in the changes made for 0.9.5); + - fixed auto-range update problem for secondary axis; + - fixed missing category labels in the overlaid category plot; + - fixed constructors for symbolic axes; + - corrected error in Javadoc generation (Ant script); + +0.9.5 : (6-Feb-2003) PLEASE NOTE THAT MAJOR CHANGES TO THE + JFREECHART API HAVE BEEN MADE IN THIS RELEASE! + + - added support for secondary axes, datasets and renderers; + - added new data interfaces (Value, Values, Values2D, + KeyedValues and KeyedValues2D) and incorporated these into + the existing PieDataset and CategoryDataset interfaces. + - modified the CategoryDataset interface to be more + symmetrical, data is organised in rows and columns (as + before) but can now be accessed by row/column index or + row/column key. + - added support for reading PieDatasets and CategoryDatasets + from XML files. + - created separate packages for the axes + (com.jrefinery.chart.axis), plots (com.jrefinery.chart.plot) + and renderers (com.jrefinery.chart.renderer). + - series attributes (paint, outline paint, stroke and shape) + are now controlled by the renderer classes using lookup + tables. Introduced the DrawingSupplier interface (and + DefaultDrawingSupplier class) which is used to populate the + lookup tables from a common source (necessary to coordinate + complex combined charts). + - the chart legend can now display shapes corresponding to + series. + - moved responsibility for category distribution to the + CategoryAxis class, which tidies up the code in the + CategoryPlot classes. + - gridlines are now controlled by the CategoryPlot and XYPlot + classes, not the axes (included in this change is the + addition of gridlines for the CategoryPlot domain values). + - changed the list of titles in the JFreeChart class to a + title and a list of subtitles. + - added new renderers for XYPlot (XYBubbleRenderer and + YIntervalRenderer). + - modified Gantt chart to display sub-tasks. + - added ContourPlot class (still experimental) by David + M. O'Donnell. + - introduced new MovingAverage class. + - ChartMouseEvent now includes source chart. + - numerous bug fixes. + - lots of Javadoc updates. + +0.9.4 : (18-Oct-2002) Added a new stacked area chart (contributed by Dan + Rivett) and a compass plot (contributed by Bryan Scott). Updated + the ThermometerPlot class. Added a new XYDotRenderer for scatter + plots. Modified combined and overlaid plots to use the series colors + specified in the sub plot rather than the parent plot (this makes it + easier to align the colors in the legend). Added Regression class + for linear and power regressions. BasicTimeSeries can now + automatically drop "old" data. Some clean-up work in the code for + tooltips and the event listener mechanism. Richard Atkinson has + incorporated some useful extensions for servlets/JSP developers. + + Ran Checkstyle and corrected issues reported for most classes. + Checkstyle is a free utility that you can download from: + + http://checkstyle.sourceforge.net + + Fixed bugs and updated documentation. + + API changes include: + - added tickMarkPaint to Axis constructor (also affects + subclasses); + - added getLegendItems() to Plot, and deprecated + getLegendItemLabels(); + - added getLegendItem(int) to XYItemRenderer and + CategoryItemRenderer. + - most 'protected' member variables have been changed to + 'private'. + +0.9.3 : (4-Sep-2002) Added multiple pie charts based on + CategoryDataset. Updated logarithmic axes. Improved URL + support for image map generation. Moved the com.jrefinery.data + package from JCommon to JFreeChart. Added simple framework for + chart annotations. Improved control over renderers. Duplicate + x-values now allowed in XYSeries. Optional category label + skipping in category axes. Added CategoriesPaint attribute to + AbstractCategoryItemRenderer. Added new attributes to + MeterPlot class. Updated 3D pie chart to observe start angle + and direction, and also foreground alpha < 1.0. Improved + Javadoc comments. New demo applications, including: + AnnotationDemo1, EventFrequencyDemo, JDBCCategoryChartDemo, + JDBCPieChartDemo, JDBCXYChartDemo and MinMaxCategoryPlotDemo. + Bug fixes: + - negative percentages on PiePlot. + - added listener notification to setXXXAxis(...) methods. + - fixed DomainInfo method name clash. + - added DomainIsPointsInTime flag to TimeSeriesCollection to + give better control over auto range on axis for time series + charts. + - axis margins for date axes are no longer hard-coded. + - fix for ordering of categories in JdbcCategoryDataset. + - added check for null axis in mouse click handler. + + The CVS repository at SourceForge has also been restructured + to match the distribution directory layout. + +0.9.2 : (28-Jun-2002) PiePlot now has startAngle and direction + attributes. Added support for image map generation. Added a + new Pie3DPlot class. Added label drawing code to bar + renderers. Added optional range markers to horizontal number + axis. Added bar clipping to avoid PRExceptions in bar + charts. JFreeChartDemo has been modified and now includes + examples of the dial and thermometer plots. + Bug fixes: + - auto range for VerticalNumberAxis when zero is forced to be + included in the range. + - fixed null pointer exception in StackedVerticalBarRenderer3D; + - Added get/set methods for min/max chart drawing dimensions + in ChartPanel; + - HorizontalIntervalBarRenderer now handles single category; + - verticalTickLabels now possible in HorizontalNumberAxis3D; + - removed unnecessary imports; + +0.9.1 : (14-Jun-2002) Bug fixes and Javadoc updates. + - fixed auto range calculation for category plots; + - fixed event notification for XYPlot; + - fixed auto axis range for Gantt charts; + - check for null popup menu in ChartPanel.mouseDragged; + - new checks for null info in renderers; + - range markers now drawn only if in visible axis range; + +0.9.0 : (7-Jun-2002) New plots including an area chart, a horizontal + 3D bar chart, a Gantt chart and a thermometer chart. + Combination plots have been reworked to provide a + simpler framework, and extends to allow category plots to be + combined. There is now a facility to add a ChartMouseListener + to the ChartPanel (formerly JFreeChartPanel). An interactive + zooming feature (experimental at this point) is now available + for XYPlots. A new Polish translation has been added. Several + fixes have been applied to the default tool tip generators. A + workaround has been added to fix the alignment between time + series charts and the date axis. There are some improvements + to the VerticalLogarithmicAxis class, and now a corresponding + HorizontalLogarithmicAxis class. Additional demonstration + applications have been added. Fixed the popup menu bug. + +0.8.1 : (5-Apr-2002) Localised resource bundles for French, German and + Spanish languages (thanks to Anthony Boulestreau, Thomas Meier + and Hans-Jurgen Greiner for the translations). An area XY + plot and meter chart contributed by Hari. Symbol charts + contributed by Anthony Boulestreau. An improved + CandleStickRenderer class from Sylvain Vieujot. Updated + servlet code from Bryan Scott. XYItemRenderers now have a + change listener mechanism and therefore do not have to be + immutable. Additional demonstration applications for + individual chart types. Minor bug fixes. + +0.8.0 : (22-Mar-2002) All the category plots are now controlled + through the one class (CategoryPlot) with plug-in renderers. + Added a ResourceBundle for user interface items that require + localisation. Added a logarithmic axis class contributed by + Mike Duffy and some new JDBC and servlet code contributed by + Bryan Scott. Updated the JCommon class library to improve + handling of time periods in different time zones. + +0.7.4 : (6-Mar-2002) Bug fixes in the JCommon Class Library. Various + Javadoc comment updates. Some minor changes to the + code. Added new domain name (http://www.object-refinery.com) + in the source headers. + +0.7.3 : (14-Feb-2002) Bug fixes. + +0.7.2 : (8-Feb-2002) Integrated the WindPlot code from Achilleus + Mantzios. Added an optional background image for the + JFreeChart class, and another optional background image for + the Plot class. Added alpha-transparency for the plot + foreground and background. Added new pie chart label types + that show values. Fixed a bug with the legend that results in + a loop at small chart sizes. Added some tooltip methods that + were missing from the previous version. Changed the Insets + class on chart titles to a new Spacer class that will allow + for relative or absolute insets (the plan is to eventually + replace all Insets in the JFreeChart classes). Fixed a bug in + the setAutoRangeIncludesZero method of the NumberAxis class. + Added the instructions that were missing from the copies of + the GNU Lesser General Public Licence included with JFreeChart. + +0.7.1 : (25-Jan-2002) Added tooltips, crosshairs and zooming + functions, thanks to Jonathan Nash and Hans-Jurgen Greiner + for contributing the code that these features are based on. + Moved the combination charts into the package + com.jrefinery.chart.combination, made a number of other small + API changes and fixed some bugs. Removed the Javadoc HTML + from the download to save space (you can regenerate it from + the source code if you need it). + +0.7.0 : (11-Dec-2001) New combination plots developed by Bill + Kelemen. Added Wolfgang Irler's servlet demo to the standard + download. The About window in the demo application now + includes a list of developers that have contributed to the + project. + +0.6.0 : (27-Nov-2001) New plots including scatter plot, stacked bar + charts and 3D bar charts. Improved pie chart. Data + interfaces and classes moved to the JCommon class library. + New properties to control spacing on bar charts. New + auto-tick mechanism. JFreeChartPanel now incorporates + buffering, and popup menu. Javadocs revised. Fixed numerous + bugs from version 0.5.6. Demo application updated. + +---------------- +10. CONTRIBUTORS +---------------- +JFreeChart wouldn't be half the library that it is today without the +contributions (large and small) that have been made by the developers listed +below: + + - Eric Alexander + - Richard Atkinson + - David Basten + - David Berry + - Chris Boek + - Zoheb Borbora + - Anthony Boulestreau + - Jeremy Bowman + - Nicolas Brodu + - Jody Brownell + - David Browning + - Soren Caspersen + - Thomas A Caswell + - Chuanhao Chiu + - Brian Cole + - Pascal Collet + - Martin Cordova + - Paolo Cova + - Greg Darke + - Mike Duffy + - Don Elliott + - Rune Fauske + - Jonathan Gabbai + - Serge V. Grachov + - Daniel Gredler + - Joao Guilherme Del Valle + - Hans-Jurgen Greiner + - Nick Guenther + - Aiman Han + - Cameron Hayne + - Martin Hoeller (xS+S) + - Jon Iles + - Wolfgang Irler + - Sergei Ivanov + - Nina Jeliazkova + - Adriaan Joubert + - Darren Jung + - Xun Kang + - Bill Kelemen + - Norbert Kiesel + - Petr Kopac + - Gideon Krause + - Dave Law; + - Pierre-Marie Le Biot + - Arnaud Lelievre + - Wolfgang Lenhard + - Leo Leung + - David Li + - Yan Liu + - Tin Luu + - Craig MacFarlane + - Achilleus Mantzios + - Thomas Meier + - Jim Moore + - Jonathan Nash + - Barak Naveh + - David M. O'Donnell + - Krzysztof Paz + - Eric Penfold + - Tomer Peretz + - Xavier Poinsard + - Andrzej Porebski + - Viktor Rajewski + - Eduardo Ramalho + - Michael Rauch + - Cameron Riley + - Klaus Rheinwald + - Dan Rivett + - Scott Sams + - Michel Santos + - Thierry Saura + - Patrick Schlott + - Andreas Schneider + - Christoph Schroeder + - Jean-Luc SCHWAB + - Bryan Scott + - Tobias Selb + - Darshan Shah + - Mofeed Shahin + - Michael Siemer + - Pady Srinivasan + - Greg Steckman + - Roger Studner + - Gerald Struck + - Irv Thomae + - Eric Thomas + - Rich Unger + - Daniel van Enckevort + - Laurence Vanhelsuwe + - Sylvain Vieujot + - Jelai Wang + - Mark Watson + - Alex Weber + - Richard West + - Matthew Wright + - Benoit Xhenseval + - Christian W. Zuckschwerdt + - Hari + - Sam (oldman) + +It is possible that I have missed someone on this list, if that +applies to you, please e-mail me. + +Dave Gilbert (david.gilbert@object-refinery.com) +JFreeChart Project Leader diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/ant/build-swt.xml b/WFRperfTool.editor/libs/jfreechart-1.0.17/ant/build-swt.xml new file mode 100755 index 0000000..22be193 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/ant/build-swt.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/ant/build.xml b/WFRperfTool.editor/libs/jfreechart-1.0.17/ant/build.xml new file mode 100755 index 0000000..4d0b78c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/ant/build.xml @@ -0,0 +1,391 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/javadocs.xml b/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/javadocs.xml new file mode 100755 index 0000000..e740a90 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/javadocs.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/lines.xml b/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/lines.xml new file mode 100755 index 0000000..4230002 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/lines.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/properties.txt b/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/properties.txt new file mode 100755 index 0000000..b3f0ce4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/properties.txt @@ -0,0 +1,6 @@ +checkstyle.allow.tabs no +checkstyle.maxlinelen 100 +checkstyle.maxparameters 20 +checkstyle.rcurly alone +checkstyle.ignore.public.in.interface yes +checkstyle.javadoc.checkUnusedThrows yes diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/style.xml b/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/style.xml new file mode 100755 index 0000000..f8bc160 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/style.xml @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/whitespace.xml b/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/whitespace.xml new file mode 100755 index 0000000..64ffd3a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/checkstyle/whitespace.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/AreaRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/AreaRendererSample.png new file mode 100755 index 0000000..62a7881 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/AreaRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/BarRenderer3DSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/BarRenderer3DSample.png new file mode 100755 index 0000000..5b7dca1 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/BarRenderer3DSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/BarRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/BarRendererSample.png new file mode 100755 index 0000000..deae7b6 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/BarRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/BoxAndWhiskerRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/BoxAndWhiskerRendererSample.png new file mode 100755 index 0000000..e888f0c Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/BoxAndWhiskerRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/CandleStickRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/CandleStickRendererSample.png new file mode 100755 index 0000000..8093d23 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/CandleStickRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/CategoryStepRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/CategoryStepRendererSample.png new file mode 100755 index 0000000..086640e Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/CategoryStepRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/ClusteredXYBarRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/ClusteredXYBarRendererSample.png new file mode 100755 index 0000000..7607236 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/ClusteredXYBarRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/DeviationRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/DeviationRendererSample.png new file mode 100755 index 0000000..2634aad Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/DeviationRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/DialPlotSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/DialPlotSample.png new file mode 100755 index 0000000..4ea8d27 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/DialPlotSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/GanttRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/GanttRendererSample.png new file mode 100755 index 0000000..bac9869 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/GanttRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/GroupedStackedBarRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/GroupedStackedBarRendererSample.png new file mode 100755 index 0000000..9c9b04e Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/GroupedStackedBarRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/HighLowRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/HighLowRendererSample.png new file mode 100755 index 0000000..205f186 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/HighLowRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/IntervalBarRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/IntervalBarRendererSample.png new file mode 100755 index 0000000..a2240c3 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/IntervalBarRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/LayeredBarRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/LayeredBarRendererSample.png new file mode 100755 index 0000000..97ba19e Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/LayeredBarRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/LevelRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/LevelRendererSample.png new file mode 100755 index 0000000..8b17bb2 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/LevelRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/LineAndShapeRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/LineAndShapeRendererSample.png new file mode 100755 index 0000000..fb4eaf5 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/LineAndShapeRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/LineRenderer3DSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/LineRenderer3DSample.png new file mode 100755 index 0000000..c0bdf9a Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/LineRenderer3DSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/MinMaxCategoryRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/MinMaxCategoryRendererSample.png new file mode 100755 index 0000000..be6f536 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/MinMaxCategoryRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/PiePlotSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/PiePlotSample.png new file mode 100755 index 0000000..9d0bd6f Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/PiePlotSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/ScatterRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/ScatterRendererSample.png new file mode 100755 index 0000000..7f87e7b Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/ScatterRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedAreaRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedAreaRendererSample.png new file mode 100755 index 0000000..ff7e420 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedAreaRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedBarRenderer3DSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedBarRenderer3DSample.png new file mode 100755 index 0000000..1ef74c2 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedBarRenderer3DSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedBarRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedBarRendererSample.png new file mode 100755 index 0000000..19b4854 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedBarRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedXYAreaRenderer2Sample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedXYAreaRenderer2Sample.png new file mode 100755 index 0000000..d9d4a95 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedXYAreaRenderer2Sample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedXYAreaRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedXYAreaRendererSample.png new file mode 100755 index 0000000..f302512 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedXYAreaRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedXYBarRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedXYBarRendererSample.png new file mode 100755 index 0000000..3ff0450 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StackedXYBarRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StatisticalBarRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StatisticalBarRendererSample.png new file mode 100755 index 0000000..984ddcb Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StatisticalBarRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StatisticalLineRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StatisticalLineRendererSample.png new file mode 100755 index 0000000..d23bcf6 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/StatisticalLineRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/VectorRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/VectorRendererSample.png new file mode 100755 index 0000000..57191d3 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/VectorRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/WaterfallBarRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/WaterfallBarRendererSample.png new file mode 100755 index 0000000..5aac8f0 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/WaterfallBarRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/WindItemRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/WindItemRendererSample.png new file mode 100755 index 0000000..ae23315 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/WindItemRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYAreaRenderer2Sample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYAreaRenderer2Sample.png new file mode 100755 index 0000000..17f163e Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYAreaRenderer2Sample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYAreaRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYAreaRendererSample.png new file mode 100755 index 0000000..214a487 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYAreaRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYBarRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYBarRendererSample.png new file mode 100755 index 0000000..ba94fae Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYBarRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYBlockRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYBlockRendererSample.png new file mode 100755 index 0000000..a05e061 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYBlockRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYBoxAndWhiskerRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYBoxAndWhiskerRendererSample.png new file mode 100755 index 0000000..fca1377 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYBoxAndWhiskerRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYBubbleRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYBubbleRendererSample.png new file mode 100755 index 0000000..b15810c Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYBubbleRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYDifferenceRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYDifferenceRendererSample.png new file mode 100755 index 0000000..4edcb4c Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYDifferenceRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYDotRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYDotRendererSample.png new file mode 100755 index 0000000..5adcce3 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYDotRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYErrorRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYErrorRendererSample.png new file mode 100755 index 0000000..55862f1 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYErrorRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYLineAndShapeRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYLineAndShapeRendererSample.png new file mode 100755 index 0000000..38cd9ee Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYLineAndShapeRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYShapeRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYShapeRendererSample.png new file mode 100755 index 0000000..598dcb4 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYShapeRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYSplineRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYSplineRendererSample.png new file mode 100755 index 0000000..14f3a4d Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYSplineRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYStepAreaRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYStepAreaRendererSample.png new file mode 100755 index 0000000..ed5cd8e Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYStepAreaRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYStepRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYStepRendererSample.png new file mode 100755 index 0000000..8733f27 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/XYStepRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/YIntervalRendererSample.png b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/YIntervalRendererSample.png new file mode 100755 index 0000000..21938a7 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/docfiles/YIntervalRendererSample.png differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/demo/CombinedCategoryPlotDemo1.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/demo/CombinedCategoryPlotDemo1.java new file mode 100755 index 0000000..3a1a5fd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/demo/CombinedCategoryPlotDemo1.java @@ -0,0 +1,223 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/demo/CombinedXYPlotDemo1.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/demo/CombinedXYPlotDemo1.java new file mode 100755 index 0000000..fdf1fb1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/demo/CombinedXYPlotDemo1.java @@ -0,0 +1,262 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * CombinedXYPlotDemo1.java + * ------------------------ + * (C) Copyright 2008, 2009, 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"); + 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"); + 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/plot/CombinedCategoryPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/plot/CombinedCategoryPlot.java new file mode 100755 index 0000000..ef90a3d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/plot/CombinedCategoryPlot.java @@ -0,0 +1,139 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * 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 1. + * + * @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(); + } +} + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/plot/CombinedXYPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/plot/CombinedXYPlot.java new file mode 100755 index 0000000..00496c5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/plot/CombinedXYPlot.java @@ -0,0 +1,139 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * 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 1. + * + * @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(); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/renderer/xy/XYSmoothLineAndShapeRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/renderer/xy/XYSmoothLineAndShapeRenderer.java new file mode 100755 index 0000000..a313405 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/experimental/org/jfree/experimental/chart/renderer/xy/XYSmoothLineAndShapeRenderer.java @@ -0,0 +1,301 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * 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 entities + * is not null 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); + step += stepSize; + } + res[steps] = point2; + + return res; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/jfreechart-1.0.17-demo.jar b/WFRperfTool.editor/libs/jfreechart-1.0.17/jfreechart-1.0.17-demo.jar new file mode 100755 index 0000000..54db557 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/jfreechart-1.0.17-demo.jar differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/.directory b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/.directory new file mode 100755 index 0000000..815899d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/.directory @@ -0,0 +1,4 @@ +[Dolphin] +Timestamp=2014,5,14,11,57,56 +Version=3 +ViewMode=2 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/hamcrest-core-1.3.jar b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/hamcrest-core-1.3.jar new file mode 100755 index 0000000..9d5fe16 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/hamcrest-core-1.3.jar differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jcommon-1.0.21.jar b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jcommon-1.0.21.jar new file mode 100755 index 0000000..e2f3bc0 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jcommon-1.0.21.jar differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jfreechart-1.0.17-experimental.jar b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jfreechart-1.0.17-experimental.jar new file mode 100755 index 0000000..b861730 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jfreechart-1.0.17-experimental.jar differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jfreechart-1.0.17-swt.jar b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jfreechart-1.0.17-swt.jar new file mode 100755 index 0000000..f564d1c Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jfreechart-1.0.17-swt.jar differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jfreechart-1.0.17.jar b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jfreechart-1.0.17.jar new file mode 100755 index 0000000..2a1ba4d Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jfreechart-1.0.17.jar differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jfreesvg-1.4.jar b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jfreesvg-1.4.jar new file mode 100755 index 0000000..65d78a0 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/jfreesvg-1.4.jar differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/junit-4.11.jar b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/junit-4.11.jar new file mode 100755 index 0000000..aaf7444 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/junit-4.11.jar differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/orsoncharts-1.0-eval.jar b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/orsoncharts-1.0-eval.jar new file mode 100755 index 0000000..dda721f Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/orsoncharts-1.0-eval.jar differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/orsonpdf-1.3-eval.jar b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/orsonpdf-1.3-eval.jar new file mode 100755 index 0000000..ccfe247 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/orsonpdf-1.3-eval.jar differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/servlet.jar b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/servlet.jar new file mode 100755 index 0000000..d368d0f Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/servlet.jar differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/swtgraphics2d.jar b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/swtgraphics2d.jar new file mode 100755 index 0000000..71bdef7 Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/lib/swtgraphics2d.jar differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/licence-LGPL.txt b/WFRperfTool.editor/libs/jfreechart-1.0.17/licence-LGPL.txt new file mode 100755 index 0000000..b1e3f5a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/licence-LGPL.txt @@ -0,0 +1,504 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/pom.xml b/WFRperfTool.editor/libs/jfreechart-1.0.17/pom.xml new file mode 100755 index 0000000..ca2fd2d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/pom.xml @@ -0,0 +1,235 @@ + + + + 4.0.0 + + JFreeChart + + jfreechart + org.jfree + 1.0.17-SNAPSHOT + jar + + + + org.sonatype.oss + oss-parent + 7 + + + + JFree.org + http://www.jfree.org/ + + 2001 + + + JFreeChart is a class library, written in Java, for generating charts. + Utilising the Java2D APIs, it currently supports bar charts, pie charts, + line charts, XY-plots and time series plots. + + + http://www.jfree.org/jfreechart/ + + http://sourceforge.net/tracker/?group_id=15494 + + + scm:svn:https://jfreechart.svn.sourceforge.net/svnroot/jfreechart jfreechart + http://jfreechart.svn.sourceforge.net/viewvc/jfreechart/ + + + + + JFreeChart Developer List + + jfreechart-dev-request@lists.sourceforge.net?subject=subscribe + + + jfreechart-dev-request@lists.sourceforge.net?subject=unsubscribe + + + http://sourceforge.net/mailarchive/forum.php?forum=jfreechart-dev + + + + + + + + + + GNU Lesser General Public Licence + http://www.gnu.org/licenses/lgpl.txt + repo + + + + + + org.jfree + jcommon + 1.0.17 + + + + xml-apis + xml-apis + 1.3.04 + + + + javax.servlet + servlet-api + 2.5 + provided + + + + junit + junit + 4.11 + test + + + + org.hamcrest + hamcrest-core + 1.3 + test + + + + + + source + tests + + + + source + + **/*.properties + **/*.jpg + **/*. + + + + + + + org.codehaus.mojo + animal-sniffer-maven-plugin + 1.7 + + + org.codehaus.mojo.signature + java16 + 1.0 + + + + + + true + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + + attach-javadoc + + jar + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + ${project.source.level} + ${project.target.level} + ${project.build.sourceEncoding} + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.10 + + + **/*Test.java + + + **/JFreeChartTestSuite.java + **/*PackageTests.java + + + + + + org.apache.maven.plugins + maven-resources-plugin + 2.5 + + ${project.build.sourceEncoding} + + + + + org.codehaus.mojo + cobertura-maven-plugin + 2.5.1 + + + + org.apache.maven.plugins + maven-site-plugin + 2.3 + + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + + + org.apache.maven.plugins + maven-surefire-report-plugin + 2.8 + + + + org.apache.maven.plugins + maven-jxr-plugin + 2.3 + + + + org.codehaus.mojo + cobertura-maven-plugin + 2.5.1 + + + + + + UTF-8 + 1.6 + 1.6 + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartColor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartColor.java new file mode 100755 index 0000000..3d3959a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartColor.java @@ -0,0 +1,189 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * ChartColor.java + * --------------- + * (C) Copyright 2003-2011, 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 Paint objects that + * represent the pre-defined colors in the Color and + * ChartColor objects. + * + * @return An array of objects with the Paint 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 + }; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartFactory.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartFactory.java new file mode 100755 index 0000000..9b82439 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartFactory.java @@ -0,0 +1,2561 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * ChartFactory.java + * ----------------- + * (C) Copyright 2001-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Serge V. Grachov; + * Joao Guilherme Del Valle; + * Bill Kelemen; + * Jon Iles; + * Jelai Wang; + * Richard Atkinson; + * David Browning (for Australian Institute of Marine + * Science); + * Benoit Xhenseval; + * + * Changes + * ------- + * 19-Oct-2001 : Version 1, most methods transferred from JFreeChart.java (DG); + * 22-Oct-2001 : Added methods to create stacked bar charts (DG); + * Renamed DataSource.java --> Dataset.java etc. (DG); + * 31-Oct-2001 : Added 3D-effect vertical bar and stacked-bar charts, + * contributed by Serge V. Grachov (DG); + * 07-Nov-2001 : Added a flag to control whether or not a legend is added to + * the chart (DG); + * 17-Nov-2001 : For pie chart, changed dataset from CategoryDataset to + * PieDataset (DG); + * 30-Nov-2001 : Removed try/catch handlers from chart creation, as the + * exception are now RuntimeExceptions, as suggested by Joao + * Guilherme Del Valle (DG); + * 06-Dec-2001 : Added createCombinableXXXXXCharts methods (BK); + * 12-Dec-2001 : Added createCandlestickChart() method (DG); + * 13-Dec-2001 : Updated methods for charts with new renderers (DG); + * 08-Jan-2002 : Added import for + * com.jrefinery.chart.combination.CombinedChart (DG); + * 31-Jan-2002 : Changed the createCombinableVerticalXYBarChart() method to use + * renderer (DG); + * 06-Feb-2002 : Added new method createWindPlot() (DG); + * 23-Apr-2002 : Updates to the chart and plot constructor API (DG); + * 21-May-2002 : Added new method createAreaChart() (JI); + * 06-Jun-2002 : Added new method createGanttChart() (DG); + * 11-Jun-2002 : Renamed createHorizontalStackedBarChart() + * --> createStackedHorizontalBarChart() for consistency (DG); + * 06-Aug-2002 : Updated Javadoc comments (DG); + * 21-Aug-2002 : Added createPieChart(CategoryDataset) method (DG); + * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 09-Oct-2002 : Added methods including tooltips and URL flags (DG); + * 06-Nov-2002 : Moved renderers into a separate package (DG); + * 18-Nov-2002 : Changed CategoryDataset to TableDataset (DG); + * 21-Mar-2003 : Incorporated HorizontalCategoryAxis3D, see bug id 685501 (DG); + * 13-May-2003 : Merged some horizontal and vertical methods (DG); + * 24-May-2003 : Added support for timeline in createHighLowChart (BK); + * 07-Jul-2003 : Added createHistogram() method contributed by Jelai Wang (DG); + * 27-Jul-2003 : Added createStackedAreaXYChart() method (RA); + * 05-Aug-2003 : added new method createBoxAndWhiskerChart (DB); + * 08-Sep-2003 : Changed ValueAxis API (DG); + * 07-Oct-2003 : Added stepped area XY chart contributed by Matthias Rose (DG); + * 06-Nov-2003 : Added createWaterfallChart() method (DG); + * 20-Nov-2003 : Set rendering order for 3D bar charts to fix overlapping + * problems (DG); + * 25-Nov-2003 : Added createWaferMapChart() method (DG); + * 23-Dec-2003 : Renamed createPie3DChart() --> createPieChart3D for + * consistency (DG); + * 20-Jan-2004 : Added createPolarChart() method (DG); + * 28-Jan-2004 : Fixed bug (882890) with axis range in + * createStackedXYAreaChart() method (DG); + * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG); + * 11-Mar-2004 : Updated for pie chart changes (DG); + * 27-Apr-2004 : Added new createPieChart() method contributed by Benoit + * Xhenseval (see RFE 942195) (DG); + * 11-May-2004 : Split StandardCategoryItemLabelGenerator + * --> StandardCategoryToolTipGenerator and + * StandardCategoryLabelGenerator (DG); + * 06-Jan-2005 : Removed deprecated methods (DG); + * 27-Jan-2005 : Added new constructor to LineAndShapeRenderer (DG); + * 28-Feb-2005 : Added docs to createBubbleChart() method (DG); + * 17-Mar-2005 : Added createRingPlot() method (DG); + * 21-Apr-2005 : Replaced Insets with RectangleInsets (DG); + * 29-Nov-2005 : Removed signal chart (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 26-Jan-2006 : Corrected API docs for createScatterPlot() (DG); + * 23-Aug-2006 : Modified createStackedXYAreaChart() to use + * StackedXYAreaRenderer2, because StackedXYAreaRenderer doesn't + * handle negative values (DG); + * 27-Sep-2006 : Update createPieChart() method for deprecated code (DG); + * 29-Nov-2006 : Update createXYBarChart() to use a time based tool tip + * generator is a DateAxis is requested (DG); + * 17-Jan-2007 : Added createBoxAndWhiskerChart() method from patch 1603937 + * submitted by Darren Jung (DG); + * 10-Jul-2007 : Added new methods to create pie charts with locale for + * section label and tool tip formatting (DG); + * 14-Aug-2008 : Added ChartTheme facility (DG); + * 23-Oct-2008 : Check for legacy theme in setChartTheme() and reset default + * bar painters (DG); + * 20-Dec-2008 : In createStackedAreaChart(), set category margin to 0.0 (DG); + * 02-Jul-2013 : Use ParamChecks class (DG); + * + */ + +package org.jfree.chart; + +import java.awt.Color; +import java.awt.Font; +import java.text.DateFormat; +import java.text.NumberFormat; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; + +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.CategoryAxis3D; +import org.jfree.chart.axis.DateAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.NumberAxis3D; +import org.jfree.chart.axis.Timeline; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.labels.BoxAndWhiskerToolTipGenerator; +import org.jfree.chart.labels.HighLowItemLabelGenerator; +import org.jfree.chart.labels.IntervalCategoryToolTipGenerator; +import org.jfree.chart.labels.ItemLabelAnchor; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.labels.PieToolTipGenerator; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +import org.jfree.chart.labels.StandardPieSectionLabelGenerator; +import org.jfree.chart.labels.StandardPieToolTipGenerator; +import org.jfree.chart.labels.StandardXYToolTipGenerator; +import org.jfree.chart.labels.StandardXYZToolTipGenerator; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Marker; +import org.jfree.chart.plot.MultiplePiePlot; +import org.jfree.chart.plot.PiePlot; +import org.jfree.chart.plot.PiePlot3D; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PolarPlot; +import org.jfree.chart.plot.RingPlot; +import org.jfree.chart.plot.ValueMarker; +import org.jfree.chart.plot.WaferMapPlot; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.DefaultPolarItemRenderer; +import org.jfree.chart.renderer.WaferMapRenderer; +import org.jfree.chart.renderer.category.AreaRenderer; +import org.jfree.chart.renderer.category.BarRenderer; +import org.jfree.chart.renderer.category.BarRenderer3D; +import org.jfree.chart.renderer.category.BoxAndWhiskerRenderer; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.renderer.category.GanttRenderer; +import org.jfree.chart.renderer.category.GradientBarPainter; +import org.jfree.chart.renderer.category.LineAndShapeRenderer; +import org.jfree.chart.renderer.category.LineRenderer3D; +import org.jfree.chart.renderer.category.StackedAreaRenderer; +import org.jfree.chart.renderer.category.StackedBarRenderer; +import org.jfree.chart.renderer.category.StackedBarRenderer3D; +import org.jfree.chart.renderer.category.StandardBarPainter; +import org.jfree.chart.renderer.category.WaterfallBarRenderer; +import org.jfree.chart.renderer.xy.CandlestickRenderer; +import org.jfree.chart.renderer.xy.GradientXYBarPainter; +import org.jfree.chart.renderer.xy.HighLowRenderer; +import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2; +import org.jfree.chart.renderer.xy.StandardXYBarPainter; +import org.jfree.chart.renderer.xy.WindItemRenderer; +import org.jfree.chart.renderer.xy.XYAreaRenderer; +import org.jfree.chart.renderer.xy.XYBarRenderer; +import org.jfree.chart.renderer.xy.XYBoxAndWhiskerRenderer; +import org.jfree.chart.renderer.xy.XYBubbleRenderer; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; +import org.jfree.chart.renderer.xy.XYStepAreaRenderer; +import org.jfree.chart.renderer.xy.XYStepRenderer; +import org.jfree.chart.title.TextTitle; +import org.jfree.chart.urls.PieURLGenerator; +import org.jfree.chart.urls.StandardCategoryURLGenerator; +import org.jfree.chart.urls.StandardPieURLGenerator; +import org.jfree.chart.urls.StandardXYURLGenerator; +import org.jfree.chart.urls.StandardXYZURLGenerator; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.IntervalCategoryDataset; +import org.jfree.data.general.DefaultPieDataset; +import org.jfree.data.general.PieDataset; +import org.jfree.data.general.WaferMapDataset; +import org.jfree.data.statistics.BoxAndWhiskerCategoryDataset; +import org.jfree.data.statistics.BoxAndWhiskerXYDataset; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.OHLCDataset; +import org.jfree.data.xy.TableXYDataset; +import org.jfree.data.xy.WindDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYZDataset; +import org.jfree.ui.Layer; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.TextAnchor; +import org.jfree.util.SortOrder; +import org.jfree.util.TableOrder; + +/** + * A collection of utility methods for creating some standard charts with + * JFreeChart. + */ +public abstract class ChartFactory { + + /** The chart theme. */ + private static ChartTheme currentTheme = new StandardChartTheme("JFree"); + + /** + * Returns the current chart theme used by the factory. + * + * @return The chart theme. + * + * @see #setChartTheme(ChartTheme) + * @see ChartUtilities#applyCurrentTheme(JFreeChart) + * + * @since 1.0.11 + */ + public static ChartTheme getChartTheme() { + return currentTheme; + } + + /** + * Sets the current chart theme. This will be applied to all new charts + * created via methods in this class. + * + * @param theme the theme (null not permitted). + * + * @see #getChartTheme() + * @see ChartUtilities#applyCurrentTheme(JFreeChart) + * + * @since 1.0.11 + */ + public static void setChartTheme(ChartTheme theme) { + ParamChecks.nullNotPermitted(theme, "theme"); + currentTheme = theme; + + // here we do a check to see if the user is installing the "Legacy" + // theme, and reset the bar painters in that case... + if (theme instanceof StandardChartTheme) { + StandardChartTheme sct = (StandardChartTheme) theme; + if (sct.getName().equals("Legacy")) { + BarRenderer.setDefaultBarPainter(new StandardBarPainter()); + XYBarRenderer.setDefaultBarPainter(new StandardXYBarPainter()); + } + else { + BarRenderer.setDefaultBarPainter(new GradientBarPainter()); + XYBarRenderer.setDefaultBarPainter(new GradientXYBarPainter()); + } + } + } + + /** + * Creates a pie chart with default settings. + *

+ * The chart object returned by this method uses a {@link PiePlot} instance + * as the plot. + * + * @param title the chart title (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param locale the locale (null not permitted). + * + * @return A pie chart. + * + * @since 1.0.7 + */ + public static JFreeChart createPieChart(String title, PieDataset dataset, + boolean legend, boolean tooltips, Locale locale) { + + PiePlot plot = new PiePlot(dataset); + plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale)); + plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); + if (tooltips) { + plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); + } + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a pie chart with default settings. + *

+ * The chart object returned by this method uses a {@link PiePlot} instance + * as the plot. + * + * @param title the chart title (null permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A pie chart. + * + * @since 1.0.16 + */ + public static JFreeChart createPieChart(String title, PieDataset dataset) { + return createPieChart(title, dataset, true, true, false); + } + + /** + * Creates a pie chart with default settings. + *

+ * The chart object returned by this method uses a {@link PiePlot} instance + * as the plot. + * + * @param title the chart title (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A pie chart. + */ + public static JFreeChart createPieChart(String title, PieDataset dataset, + boolean legend, boolean tooltips, boolean urls) { + + PiePlot plot = new PiePlot(dataset); + plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); + plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); + if (tooltips) { + plot.setToolTipGenerator(new StandardPieToolTipGenerator()); + } + if (urls) { + plot.setURLGenerator(new StandardPieURLGenerator()); + } + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + } + + /** + * Creates a pie chart with default settings that compares 2 datasets. + * The colour of each section will be determined by the move from the value + * for the same key in previousDataset. ie if value1 > value2 + * then the section will be in green (unless greenForIncrease + * is false, in which case it would be red). + * Each section can have a shade of red or green as the difference can be + * tailored between 0% (black) and percentDiffForMaxScale% (bright + * red/green). + *

+ * For instance if percentDiffForMaxScale is 10 (10%), a + * difference of 5% will have a half shade of red/green, a difference of + * 10% or more will have a maximum shade/brightness of red/green. + *

+ * The chart object returned by this method uses a {@link PiePlot} instance + * as the plot. + *

+ * Written by Benoit + * Xhenseval. + * + * @param title the chart title (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param previousDataset the dataset for the last run, this will be used + * to compare each key in the dataset + * @param percentDiffForMaxScale scale goes from bright red/green to black, + * percentDiffForMaxScale indicate the change + * required to reach top scale. + * @param greenForIncrease an increase since previousDataset will be + * displayed in green (decrease red) if true. + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param locale the locale (null not permitted). + * @param subTitle displays a subtitle with colour scheme if true + * @param showDifference create a new dataset that will show the % + * difference between the two datasets. + * + * @return A pie chart. + * + * @since 1.0.7 + */ + public static JFreeChart createPieChart(String title, PieDataset dataset, + PieDataset previousDataset, int percentDiffForMaxScale, + boolean greenForIncrease, boolean legend, boolean tooltips, + Locale locale, boolean subTitle, boolean showDifference) { + + PiePlot plot = new PiePlot(dataset); + plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale)); + plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); + + if (tooltips) { + plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); + } + + List keys = dataset.getKeys(); + DefaultPieDataset series = null; + if (showDifference) { + series = new DefaultPieDataset(); + } + + double colorPerPercent = 255.0 / percentDiffForMaxScale; + for (Iterator it = keys.iterator(); it.hasNext();) { + Comparable key = (Comparable) it.next(); + Number newValue = dataset.getValue(key); + Number oldValue = previousDataset.getValue(key); + + if (oldValue == null) { + if (greenForIncrease) { + plot.setSectionPaint(key, Color.green); + } + else { + plot.setSectionPaint(key, Color.red); + } + if (showDifference) { + assert series != null; // suppresses compiler warning + series.setValue(key + " (+100%)", newValue); + } + } + else { + double percentChange = (newValue.doubleValue() + / oldValue.doubleValue() - 1.0) * 100.0; + double shade + = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 + : Math.abs(percentChange) * colorPerPercent); + if (greenForIncrease + && newValue.doubleValue() > oldValue.doubleValue() + || !greenForIncrease && newValue.doubleValue() + < oldValue.doubleValue()) { + plot.setSectionPaint(key, new Color(0, (int) shade, 0)); + } + else { + plot.setSectionPaint(key, new Color((int) shade, 0, 0)); + } + if (showDifference) { + assert series != null; // suppresses compiler warning + series.setValue(key + " (" + (percentChange >= 0 ? "+" : "") + + NumberFormat.getPercentInstance().format( + percentChange / 100.0) + ")", newValue); + } + } + } + + if (showDifference) { + plot.setDataset(series); + } + + JFreeChart chart = new JFreeChart(title, + JFreeChart.DEFAULT_TITLE_FONT, plot, legend); + + if (subTitle) { + TextTitle subtitle = new TextTitle("Bright " + (greenForIncrease + ? "red" : "green") + "=change >=-" + percentDiffForMaxScale + + "%, Bright " + (!greenForIncrease ? "red" : "green") + + "=change >=+" + percentDiffForMaxScale + "%", + new Font("SansSerif", Font.PLAIN, 10)); + chart.addSubtitle(subtitle); + } + currentTheme.apply(chart); + return chart; + } + + /** + * Creates a pie chart with default settings that compares 2 datasets. + * The colour of each section will be determined by the move from the value + * for the same key in previousDataset. ie if value1 > value2 + * then the section will be in green (unless greenForIncrease + * is false, in which case it would be red). + * Each section can have a shade of red or green as the difference can be + * tailored between 0% (black) and percentDiffForMaxScale% (bright + * red/green). + *

+ * For instance if percentDiffForMaxScale is 10 (10%), a + * difference of 5% will have a half shade of red/green, a difference of + * 10% or more will have a maximum shade/brightness of red/green. + *

+ * The chart object returned by this method uses a {@link PiePlot} instance + * as the plot. + *

+ * Written by Benoit + * Xhenseval. + * + * @param title the chart title (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param previousDataset the dataset for the last run, this will be used + * to compare each key in the dataset + * @param percentDiffForMaxScale scale goes from bright red/green to black, + * percentDiffForMaxScale indicate the change + * required to reach top scale. + * @param greenForIncrease an increase since previousDataset will be + * displayed in green (decrease red) if true. + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * @param subTitle displays a subtitle with colour scheme if true + * @param showDifference create a new dataset that will show the % + * difference between the two datasets. + * + * @return A pie chart. + */ + public static JFreeChart createPieChart(String title, PieDataset dataset, + PieDataset previousDataset, int percentDiffForMaxScale, + boolean greenForIncrease, boolean legend, boolean tooltips, + boolean urls, boolean subTitle, boolean showDifference) { + + PiePlot plot = new PiePlot(dataset); + plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); + plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); + + if (tooltips) { + plot.setToolTipGenerator(new StandardPieToolTipGenerator()); + } + if (urls) { + plot.setURLGenerator(new StandardPieURLGenerator()); + } + + List keys = dataset.getKeys(); + DefaultPieDataset series = null; + if (showDifference) { + series = new DefaultPieDataset(); + } + + double colorPerPercent = 255.0 / percentDiffForMaxScale; + for (Iterator it = keys.iterator(); it.hasNext();) { + Comparable key = (Comparable) it.next(); + Number newValue = dataset.getValue(key); + Number oldValue = previousDataset.getValue(key); + + if (oldValue == null) { + if (greenForIncrease) { + plot.setSectionPaint(key, Color.green); + } + else { + plot.setSectionPaint(key, Color.red); + } + if (showDifference) { + assert series != null; // suppresses compiler warning + series.setValue(key + " (+100%)", newValue); + } + } + else { + double percentChange = (newValue.doubleValue() + / oldValue.doubleValue() - 1.0) * 100.0; + double shade + = (Math.abs(percentChange) >= percentDiffForMaxScale ? 255 + : Math.abs(percentChange) * colorPerPercent); + if (greenForIncrease + && newValue.doubleValue() > oldValue.doubleValue() + || !greenForIncrease && newValue.doubleValue() + < oldValue.doubleValue()) { + plot.setSectionPaint(key, new Color(0, (int) shade, 0)); + } + else { + plot.setSectionPaint(key, new Color((int) shade, 0, 0)); + } + if (showDifference) { + assert series != null; // suppresses compiler warning + series.setValue(key + " (" + (percentChange >= 0 ? "+" : "") + + NumberFormat.getPercentInstance().format( + percentChange / 100.0) + ")", newValue); + } + } + } + + if (showDifference) { + plot.setDataset(series); + } + + JFreeChart chart = new JFreeChart(title, + JFreeChart.DEFAULT_TITLE_FONT, plot, legend); + + if (subTitle) { + TextTitle subtitle = new TextTitle("Bright " + (greenForIncrease + ? "red" : "green") + "=change >=-" + percentDiffForMaxScale + + "%, Bright " + (!greenForIncrease ? "red" : "green") + + "=change >=+" + percentDiffForMaxScale + "%", + new Font("SansSerif", Font.PLAIN, 10)); + chart.addSubtitle(subtitle); + } + currentTheme.apply(chart); + return chart; + } + + /** + * Creates a ring chart with default settings. + *

+ * The chart object returned by this method uses a {@link RingPlot} + * instance as the plot. + * + * @param title the chart title (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param locale the locale (null not permitted). + * + * @return A ring chart. + * + * @since 1.0.7 + */ + public static JFreeChart createRingChart(String title, PieDataset dataset, + boolean legend, boolean tooltips, Locale locale) { + + RingPlot plot = new RingPlot(dataset); + plot.setLabelGenerator(new StandardPieSectionLabelGenerator(locale)); + plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); + if (tooltips) { + plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); + } + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + } + + /** + * Creates a ring chart with default settings. + *

+ * The chart object returned by this method uses a {@link RingPlot} + * instance as the plot. + * + * @param title the chart title (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A ring chart. + */ + public static JFreeChart createRingChart(String title, PieDataset dataset, + boolean legend, boolean tooltips, boolean urls) { + + RingPlot plot = new RingPlot(dataset); + plot.setLabelGenerator(new StandardPieSectionLabelGenerator()); + plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); + if (tooltips) { + plot.setToolTipGenerator(new StandardPieToolTipGenerator()); + } + if (urls) { + plot.setURLGenerator(new StandardPieURLGenerator()); + } + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a chart that displays multiple pie plots. The chart object + * returned by this method uses a {@link MultiplePiePlot} instance as the + * plot. + * + * @param title the chart title (null permitted). + * @param dataset the dataset (null permitted). + * @param order the order that the data is extracted (by row or by column) + * (null not permitted). + * @param legend include a legend? + * @param tooltips generate tooltips? + * @param urls generate URLs? + * + * @return A chart. + */ + public static JFreeChart createMultiplePieChart(String title, + CategoryDataset dataset, TableOrder order, boolean legend, + boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(order, "order"); + MultiplePiePlot plot = new MultiplePiePlot(dataset); + plot.setDataExtractOrder(order); + plot.setBackgroundPaint(null); + plot.setOutlineStroke(null); + + if (tooltips) { + PieToolTipGenerator tooltipGenerator + = new StandardPieToolTipGenerator(); + PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); + pp.setToolTipGenerator(tooltipGenerator); + } + + if (urls) { + PieURLGenerator urlGenerator = new StandardPieURLGenerator(); + PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); + pp.setURLGenerator(urlGenerator); + } + + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a 3D pie chart using the specified dataset. The chart object + * returned by this method uses a {@link PiePlot3D} instance as the + * plot. + * + * @param title the chart title (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param locale the locale (null not permitted). + * + * @return A pie chart. + * + * @since 1.0.7 + */ + public static JFreeChart createPieChart3D(String title, PieDataset dataset, + boolean legend, boolean tooltips, Locale locale) { + + ParamChecks.nullNotPermitted(locale, "locale"); + PiePlot3D plot = new PiePlot3D(dataset); + plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); + if (tooltips) { + plot.setToolTipGenerator(new StandardPieToolTipGenerator(locale)); + } + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a 3D pie chart using the specified dataset. The chart object + * returned by this method uses a {@link PiePlot3D} instance as the + * plot. + * + * @param title the chart title (null permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A pie chart. + * + * @since 1.0.16 + */ + public static JFreeChart createPieChart3D(String title, + PieDataset dataset) { + return createPieChart3D(title, dataset, true, true, false); + } + + /** + * Creates a 3D pie chart using the specified dataset. The chart object + * returned by this method uses a {@link PiePlot3D} instance as the + * plot. + * + * @param title the chart title (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A pie chart. + */ + public static JFreeChart createPieChart3D(String title, PieDataset dataset, + boolean legend, boolean tooltips, boolean urls) { + + PiePlot3D plot = new PiePlot3D(dataset); + plot.setInsets(new RectangleInsets(0.0, 5.0, 5.0, 5.0)); + if (tooltips) { + plot.setToolTipGenerator(new StandardPieToolTipGenerator()); + } + if (urls) { + plot.setURLGenerator(new StandardPieURLGenerator()); + } + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a chart that displays multiple pie plots. The chart object + * returned by this method uses a {@link MultiplePiePlot} instance as the + * plot. + * + * @param title the chart title (null permitted). + * @param dataset the dataset (null permitted). + * @param order the order that the data is extracted (by row or by column) + * (null not permitted). + * @param legend include a legend? + * @param tooltips generate tooltips? + * @param urls generate URLs? + * + * @return A chart. + */ + public static JFreeChart createMultiplePieChart3D(String title, + CategoryDataset dataset, TableOrder order, boolean legend, + boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(order, "order"); + MultiplePiePlot plot = new MultiplePiePlot(dataset); + plot.setDataExtractOrder(order); + plot.setBackgroundPaint(null); + plot.setOutlineStroke(null); + + JFreeChart pieChart = new JFreeChart(new PiePlot3D(null)); + TextTitle seriesTitle = new TextTitle("Series Title", + new Font("SansSerif", Font.BOLD, 12)); + seriesTitle.setPosition(RectangleEdge.BOTTOM); + pieChart.setTitle(seriesTitle); + pieChart.removeLegend(); + pieChart.setBackgroundPaint(null); + plot.setPieChart(pieChart); + + if (tooltips) { + PieToolTipGenerator tooltipGenerator + = new StandardPieToolTipGenerator(); + PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); + pp.setToolTipGenerator(tooltipGenerator); + } + + if (urls) { + PieURLGenerator urlGenerator = new StandardPieURLGenerator(); + PiePlot pp = (PiePlot) plot.getPieChart().getPlot(); + pp.setURLGenerator(urlGenerator); + } + + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a bar chart with a vertical orientation. The chart object + * returned by this method uses a {@link CategoryPlot} instance as the + * plot, with a {@link CategoryAxis} for the domain axis, a + * {@link NumberAxis} as the range axis, and a {@link BarRenderer} as the + * renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis + * (null permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A bar chart. + * + * @since 1.0.16 + */ + public static JFreeChart createBarChart(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset) { + return createBarChart(title, categoryAxisLabel, valueAxisLabel, dataset, + PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates a bar chart. The chart object returned by this method uses a + * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis} + * for the domain axis, a {@link NumberAxis} as the range axis, and a + * {@link BarRenderer} as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis + * (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the plot orientation (horizontal or vertical) + * (null not permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A bar chart. + */ + public static JFreeChart createBarChart(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); + ValueAxis valueAxis = new NumberAxis(valueAxisLabel); + + BarRenderer renderer = new BarRenderer(); + if (orientation == PlotOrientation.HORIZONTAL) { + ItemLabelPosition position1 = new ItemLabelPosition( + ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); + renderer.setBasePositiveItemLabelPosition(position1); + ItemLabelPosition position2 = new ItemLabelPosition( + ItemLabelAnchor.OUTSIDE9, TextAnchor.CENTER_RIGHT); + renderer.setBaseNegativeItemLabelPosition(position2); + } + else if (orientation == PlotOrientation.VERTICAL) { + ItemLabelPosition position1 = new ItemLabelPosition( + ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); + renderer.setBasePositiveItemLabelPosition(position1); + ItemLabelPosition position2 = new ItemLabelPosition( + ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); + renderer.setBaseNegativeItemLabelPosition(position2); + } + if (tooltips) { + renderer.setBaseToolTipGenerator( + new StandardCategoryToolTipGenerator()); + } + if (urls) { + renderer.setBaseItemURLGenerator( + new StandardCategoryURLGenerator()); + } + + CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, + renderer); + plot.setOrientation(orientation); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a stacked bar chart with default settings. The chart object + * returned by this method uses a {@link CategoryPlot} instance as the + * plot, with a {@link CategoryAxis} for the domain axis, a + * {@link NumberAxis} as the range axis, and a {@link StackedBarRenderer} + * as the renderer. + * + * @param title the chart title (null permitted). + * @param domainAxisLabel the label for the category axis + * (null permitted). + * @param rangeAxisLabel the label for the value axis + * (null permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A stacked bar chart. + * + * @since 1.0.16 + */ + public static JFreeChart createStackedBarChart(String title, + String domainAxisLabel, String rangeAxisLabel, + CategoryDataset dataset) { + return createStackedBarChart(title, domainAxisLabel, rangeAxisLabel, + dataset, PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates a stacked bar chart with default settings. The chart object + * returned by this method uses a {@link CategoryPlot} instance as the + * plot, with a {@link CategoryAxis} for the domain axis, a + * {@link NumberAxis} as the range axis, and a {@link StackedBarRenderer} + * as the renderer. + * + * @param title the chart title (null permitted). + * @param domainAxisLabel the label for the category axis + * (null permitted). + * @param rangeAxisLabel the label for the value axis + * (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the orientation of the chart (horizontal or + * vertical) (null not permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A stacked bar chart. + */ + public static JFreeChart createStackedBarChart(String title, + String domainAxisLabel, String rangeAxisLabel, + CategoryDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + + CategoryAxis categoryAxis = new CategoryAxis(domainAxisLabel); + ValueAxis valueAxis = new NumberAxis(rangeAxisLabel); + + StackedBarRenderer renderer = new StackedBarRenderer(); + if (tooltips) { + renderer.setBaseToolTipGenerator( + new StandardCategoryToolTipGenerator()); + } + if (urls) { + renderer.setBaseItemURLGenerator( + new StandardCategoryURLGenerator()); + } + + CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, + renderer); + plot.setOrientation(orientation); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a bar chart with a 3D effect. The chart object returned by this + * method uses a {@link CategoryPlot} instance as the plot, with a + * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as + * the range axis, and a {@link BarRenderer3D} as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A bar chart with a 3D effect. + * + * @since 1.0.16 + */ + public static JFreeChart createBarChart3D(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset) { + return createBarChart3D(title, categoryAxisLabel, valueAxisLabel, + dataset, PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates a bar chart with a 3D effect. The chart object returned by this + * method uses a {@link CategoryPlot} instance as the plot, with a + * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as + * the range axis, and a {@link BarRenderer3D} as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the plot orientation (horizontal or vertical) + * (null not permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A bar chart with a 3D effect. + */ + public static JFreeChart createBarChart3D(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel); + ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel); + + BarRenderer3D renderer = new BarRenderer3D(); + if (tooltips) { + renderer.setBaseToolTipGenerator( + new StandardCategoryToolTipGenerator()); + } + if (urls) { + renderer.setBaseItemURLGenerator( + new StandardCategoryURLGenerator()); + } + + CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, + renderer); + plot.setOrientation(orientation); + if (orientation == PlotOrientation.HORIZONTAL) { + // change rendering order to ensure that bar overlapping is the + // right way around + plot.setRowRenderingOrder(SortOrder.DESCENDING); + plot.setColumnRenderingOrder(SortOrder.DESCENDING); + } + plot.setForegroundAlpha(0.75f); + + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a stacked bar chart with a 3D effect and default settings. The + * chart object returned by this method uses a {@link CategoryPlot} + * instance as the plot, with a {@link CategoryAxis3D} for the domain axis, + * a {@link NumberAxis3D} as the range axis, and a + * {@link StackedBarRenderer3D} as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A stacked bar chart with a 3D effect. + * + * @since 1.0.16 + */ + public static JFreeChart createStackedBarChart3D(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset) { + return createStackedBarChart3D(title, categoryAxisLabel, valueAxisLabel, + dataset, PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates a stacked bar chart with a 3D effect and default settings. The + * chart object returned by this method uses a {@link CategoryPlot} + * instance as the plot, with a {@link CategoryAxis3D} for the domain axis, + * a {@link NumberAxis3D} as the range axis, and a + * {@link StackedBarRenderer3D} as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the orientation (horizontal or vertical) + * (null not permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A stacked bar chart with a 3D effect. + */ + public static JFreeChart createStackedBarChart3D(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel); + ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel); + + // create the renderer... + CategoryItemRenderer renderer = new StackedBarRenderer3D(); + if (tooltips) { + renderer.setBaseToolTipGenerator( + new StandardCategoryToolTipGenerator()); + } + if (urls) { + renderer.setBaseItemURLGenerator( + new StandardCategoryURLGenerator()); + } + + // create the plot... + CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, + renderer); + plot.setOrientation(orientation); + if (orientation == PlotOrientation.HORIZONTAL) { + // change rendering order to ensure that bar overlapping is the + // right way around + plot.setColumnRenderingOrder(SortOrder.DESCENDING); + } + + // create the chart... + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates an area chart with default settings. The chart object returned + * by this method uses a {@link CategoryPlot} instance as the plot, with a + * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the + * range axis, and an {@link AreaRenderer} as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return An area chart. + * + * @since 1.0.16 + */ + public static JFreeChart createAreaChart(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset) { + return createAreaChart(title, categoryAxisLabel, valueAxisLabel, + dataset, PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates an area chart with default settings. The chart object returned + * by this method uses a {@link CategoryPlot} instance as the plot, with a + * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the + * range axis, and an {@link AreaRenderer} as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the plot orientation (null not + * permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return An area chart. + */ + public static JFreeChart createAreaChart(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); + categoryAxis.setCategoryMargin(0.0); + + ValueAxis valueAxis = new NumberAxis(valueAxisLabel); + + AreaRenderer renderer = new AreaRenderer(); + if (tooltips) { + renderer.setBaseToolTipGenerator( + new StandardCategoryToolTipGenerator()); + } + if (urls) { + renderer.setBaseItemURLGenerator( + new StandardCategoryURLGenerator()); + } + + CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, + renderer); + plot.setOrientation(orientation); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a stacked area chart with default settings. The chart object + * returned by this method uses a {@link CategoryPlot} instance as the + * plot, with a {@link CategoryAxis} for the domain axis, a + * {@link NumberAxis} as the range axis, and a {@link StackedAreaRenderer} + * as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A stacked area chart. + * + * @since 1.0.16 + */ + public static JFreeChart createStackedAreaChart(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset) { + return createStackedAreaChart(title, categoryAxisLabel, valueAxisLabel, + dataset, PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates a stacked area chart with default settings. The chart object + * returned by this method uses a {@link CategoryPlot} instance as the + * plot, with a {@link CategoryAxis} for the domain axis, a + * {@link NumberAxis} as the range axis, and a {@link StackedAreaRenderer} + * as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the plot orientation (horizontal or vertical) + * (null not permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A stacked area chart. + */ + public static JFreeChart createStackedAreaChart(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); + categoryAxis.setCategoryMargin(0.0); + ValueAxis valueAxis = new NumberAxis(valueAxisLabel); + + StackedAreaRenderer renderer = new StackedAreaRenderer(); + if (tooltips) { + renderer.setBaseToolTipGenerator( + new StandardCategoryToolTipGenerator()); + } + if (urls) { + renderer.setBaseItemURLGenerator( + new StandardCategoryURLGenerator()); + } + + CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, + renderer); + plot.setOrientation(orientation); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a line chart with default settings. The chart object returned + * by this method uses a {@link CategoryPlot} instance as the plot, with a + * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the + * range axis, and a {@link LineAndShapeRenderer} as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A line chart. + * + * @since 1.0.16 + */ + public static JFreeChart createLineChart(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset) { + return createLineChart(title, categoryAxisLabel, valueAxisLabel, + dataset, PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates a line chart with default settings. The chart object returned + * by this method uses a {@link CategoryPlot} instance as the plot, with a + * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the + * range axis, and a {@link LineAndShapeRenderer} as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the chart orientation (horizontal or vertical) + * (null not permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A line chart. + */ + public static JFreeChart createLineChart(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); + ValueAxis valueAxis = new NumberAxis(valueAxisLabel); + + LineAndShapeRenderer renderer = new LineAndShapeRenderer(true, false); + if (tooltips) { + renderer.setBaseToolTipGenerator( + new StandardCategoryToolTipGenerator()); + } + if (urls) { + renderer.setBaseItemURLGenerator( + new StandardCategoryURLGenerator()); + } + CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, + renderer); + plot.setOrientation(orientation); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a line chart with default settings. The chart object returned by + * this method uses a {@link CategoryPlot} instance as the plot, with a + * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as + * the range axis, and a {@link LineRenderer3D} as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A line chart. + * + * @since 1.0.16 + */ + public static JFreeChart createLineChart3D(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset) { + return createLineChart3D(title, categoryAxisLabel, valueAxisLabel, + dataset, PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates a line chart with default settings. The chart object returned by + * this method uses a {@link CategoryPlot} instance as the plot, with a + * {@link CategoryAxis3D} for the domain axis, a {@link NumberAxis3D} as + * the range axis, and a {@link LineRenderer3D} as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the chart orientation (horizontal or vertical) + * (null not permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A line chart. + */ + public static JFreeChart createLineChart3D(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel); + ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel); + + LineRenderer3D renderer = new LineRenderer3D(); + if (tooltips) { + renderer.setBaseToolTipGenerator( + new StandardCategoryToolTipGenerator()); + } + if (urls) { + renderer.setBaseItemURLGenerator( + new StandardCategoryURLGenerator()); + } + CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, + renderer); + plot.setOrientation(orientation); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a Gantt chart using the supplied attributes plus default values + * where required. The chart object returned by this method uses a + * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis} + * for the domain axis, a {@link DateAxis} as the range axis, and a + * {@link GanttRenderer} as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param dateAxisLabel the label for the date axis + * (null permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A Gantt chart. + * + * @since 1.0.16 + */ + public static JFreeChart createGanttChart(String title, + String categoryAxisLabel, String dateAxisLabel, + IntervalCategoryDataset dataset) { + return createGanttChart(title, categoryAxisLabel, dateAxisLabel, + dataset, true, true, false); + } + + /** + * Creates a Gantt chart using the supplied attributes plus default values + * where required. The chart object returned by this method uses a + * {@link CategoryPlot} instance as the plot, with a {@link CategoryAxis} + * for the domain axis, a {@link DateAxis} as the range axis, and a + * {@link GanttRenderer} as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param dateAxisLabel the label for the date axis + * (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A Gantt chart. + */ + public static JFreeChart createGanttChart(String title, + String categoryAxisLabel, String dateAxisLabel, + IntervalCategoryDataset dataset, boolean legend, boolean tooltips, + boolean urls) { + + CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); + DateAxis dateAxis = new DateAxis(dateAxisLabel); + + CategoryItemRenderer renderer = new GanttRenderer(); + if (tooltips) { + renderer.setBaseToolTipGenerator( + new IntervalCategoryToolTipGenerator( + "{3} - {4}", DateFormat.getDateInstance())); + } + if (urls) { + renderer.setBaseItemURLGenerator( + new StandardCategoryURLGenerator()); + } + + CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, dateAxis, + renderer); + plot.setOrientation(PlotOrientation.HORIZONTAL); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a waterfall chart. The chart object returned by this method + * uses a {@link CategoryPlot} instance as the plot, with a + * {@link CategoryAxis} for the domain axis, a {@link NumberAxis} as the + * range axis, and a {@link WaterfallBarRenderer} as the renderer. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel the label for the category axis + * (null permitted). + * @param valueAxisLabel the label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the plot orientation (horizontal or vertical) + * (null NOT permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A waterfall chart. + */ + public static JFreeChart createWaterfallChart(String title, + String categoryAxisLabel, String valueAxisLabel, + CategoryDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); + categoryAxis.setCategoryMargin(0.0); + + ValueAxis valueAxis = new NumberAxis(valueAxisLabel); + + WaterfallBarRenderer renderer = new WaterfallBarRenderer(); + if (orientation == PlotOrientation.HORIZONTAL) { + ItemLabelPosition position = new ItemLabelPosition( + ItemLabelAnchor.CENTER, TextAnchor.CENTER, + TextAnchor.CENTER, Math.PI / 2.0); + renderer.setBasePositiveItemLabelPosition(position); + renderer.setBaseNegativeItemLabelPosition(position); + } + else if (orientation == PlotOrientation.VERTICAL) { + ItemLabelPosition position = new ItemLabelPosition( + ItemLabelAnchor.CENTER, TextAnchor.CENTER, + TextAnchor.CENTER, 0.0); + renderer.setBasePositiveItemLabelPosition(position); + renderer.setBaseNegativeItemLabelPosition(position); + } + if (tooltips) { + StandardCategoryToolTipGenerator generator + = new StandardCategoryToolTipGenerator(); + renderer.setBaseToolTipGenerator(generator); + } + if (urls) { + renderer.setBaseItemURLGenerator( + new StandardCategoryURLGenerator()); + } + + CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, + renderer); + plot.clearRangeMarkers(); + Marker baseline = new ValueMarker(0.0); + baseline.setPaint(Color.black); + plot.addRangeMarker(baseline, Layer.FOREGROUND); + plot.setOrientation(orientation); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a polar plot for the specified dataset (x-values interpreted as + * angles in degrees). The chart object returned by this method uses a + * {@link PolarPlot} instance as the plot, with a {@link NumberAxis} for + * the radial axis. + * + * @param title the chart title (null permitted). + * @param dataset the dataset (null permitted). + * @param legend legend required? + * @param tooltips tooltips required? + * @param urls URLs required? + * + * @return A chart. + */ + public static JFreeChart createPolarChart(String title, XYDataset dataset, + boolean legend, boolean tooltips, boolean urls) { + + PolarPlot plot = new PolarPlot(); + plot.setDataset(dataset); + NumberAxis rangeAxis = new NumberAxis(); + rangeAxis.setAxisLineVisible(false); + rangeAxis.setTickMarksVisible(false); + rangeAxis.setTickLabelInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); + plot.setAxis(rangeAxis); + plot.setRenderer(new DefaultPolarItemRenderer()); + JFreeChart chart = new JFreeChart( + title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a scatter plot with default settings. The chart object + * returned by this method uses an {@link XYPlot} instance as the plot, + * with a {@link NumberAxis} for the domain axis, a {@link NumberAxis} + * as the range axis, and an {@link XYLineAndShapeRenderer} as the + * renderer. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A scatter plot. + * + * @since 1.0.16 + */ + public static JFreeChart createScatterPlot(String title, String xAxisLabel, + String yAxisLabel, XYDataset dataset) { + return createScatterPlot(title, xAxisLabel, yAxisLabel, dataset, + PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates a scatter plot with default settings. The chart object + * returned by this method uses an {@link XYPlot} instance as the plot, + * with a {@link NumberAxis} for the domain axis, a {@link NumberAxis} + * as the range axis, and an {@link XYLineAndShapeRenderer} as the + * renderer. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the plot orientation (horizontal or vertical) + * (null NOT permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A scatter plot. + */ + public static JFreeChart createScatterPlot(String title, String xAxisLabel, + String yAxisLabel, XYDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + NumberAxis xAxis = new NumberAxis(xAxisLabel); + xAxis.setAutoRangeIncludesZero(false); + NumberAxis yAxis = new NumberAxis(yAxisLabel); + yAxis.setAutoRangeIncludesZero(false); + + XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); + + XYToolTipGenerator toolTipGenerator = null; + if (tooltips) { + toolTipGenerator = new StandardXYToolTipGenerator(); + } + + XYURLGenerator urlGenerator = null; + if (urls) { + urlGenerator = new StandardXYURLGenerator(); + } + XYItemRenderer renderer = new XYLineAndShapeRenderer(false, true); + renderer.setBaseToolTipGenerator(toolTipGenerator); + renderer.setURLGenerator(urlGenerator); + plot.setRenderer(renderer); + plot.setOrientation(orientation); + + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates and returns a default instance of an XY bar chart. + *

+ * The chart object returned by this method uses an {@link XYPlot} instance + * as the plot, with a {@link DateAxis} for the domain axis, a + * {@link NumberAxis} as the range axis, and a {@link XYBarRenderer} as the + * renderer. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param dateAxis make the domain axis display dates? + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return An XY bar chart. + * + * @since 1.0.16 + */ + public static JFreeChart createXYBarChart(String title, String xAxisLabel, + boolean dateAxis, String yAxisLabel, IntervalXYDataset dataset) { + return createXYBarChart(title, xAxisLabel, dateAxis, yAxisLabel, + dataset, PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates and returns a default instance of an XY bar chart. + *

+ * The chart object returned by this method uses an {@link XYPlot} instance + * as the plot, with a {@link DateAxis} for the domain axis, a + * {@link NumberAxis} as the range axis, and a {@link XYBarRenderer} as the + * renderer. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param dateAxis make the domain axis display dates? + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the orientation (horizontal or vertical) + * (null NOT permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return An XY bar chart. + */ + public static JFreeChart createXYBarChart(String title, String xAxisLabel, + boolean dateAxis, String yAxisLabel, IntervalXYDataset dataset, + PlotOrientation orientation, boolean legend, boolean tooltips, + boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + ValueAxis domainAxis; + if (dateAxis) { + domainAxis = new DateAxis(xAxisLabel); + } + else { + NumberAxis axis = new NumberAxis(xAxisLabel); + axis.setAutoRangeIncludesZero(false); + domainAxis = axis; + } + ValueAxis valueAxis = new NumberAxis(yAxisLabel); + + XYBarRenderer renderer = new XYBarRenderer(); + if (tooltips) { + XYToolTipGenerator tt; + if (dateAxis) { + tt = StandardXYToolTipGenerator.getTimeSeriesInstance(); + } + else { + tt = new StandardXYToolTipGenerator(); + } + renderer.setBaseToolTipGenerator(tt); + } + if (urls) { + renderer.setURLGenerator(new StandardXYURLGenerator()); + } + + XYPlot plot = new XYPlot(dataset, domainAxis, valueAxis, renderer); + plot.setOrientation(orientation); + + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates an area chart using an {@link XYDataset}. + *

+ * The chart object returned by this method uses an {@link XYPlot} instance + * as the plot, with a {@link NumberAxis} for the domain axis, a + * {@link NumberAxis} as the range axis, and a {@link XYAreaRenderer} as + * the renderer. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return An XY area chart. + * + * @since 1.0.16 + */ + public static JFreeChart createXYAreaChart(String title,String xAxisLabel, + String yAxisLabel, XYDataset dataset) { + return createXYAreaChart(title, xAxisLabel, yAxisLabel, dataset, + PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates an area chart using an {@link XYDataset}. + *

+ * The chart object returned by this method uses an {@link XYPlot} instance + * as the plot, with a {@link NumberAxis} for the domain axis, a + * {@link NumberAxis} as the range axis, and a {@link XYAreaRenderer} as + * the renderer. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the plot orientation (horizontal or vertical) + * (null NOT permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return An XY area chart. + */ + public static JFreeChart createXYAreaChart(String title, String xAxisLabel, + String yAxisLabel, XYDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + NumberAxis xAxis = new NumberAxis(xAxisLabel); + xAxis.setAutoRangeIncludesZero(false); + NumberAxis yAxis = new NumberAxis(yAxisLabel); + XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); + plot.setOrientation(orientation); + plot.setForegroundAlpha(0.5f); + + XYToolTipGenerator tipGenerator = null; + if (tooltips) { + tipGenerator = new StandardXYToolTipGenerator(); + } + + XYURLGenerator urlGenerator = null; + if (urls) { + urlGenerator = new StandardXYURLGenerator(); + } + + plot.setRenderer(new XYAreaRenderer(XYAreaRenderer.AREA, tipGenerator, + urlGenerator)); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a stacked XY area plot. The chart object returned by this + * method uses an {@link XYPlot} instance as the plot, with a + * {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the + * range axis, and a {@link StackedXYAreaRenderer2} as the renderer. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A stacked XY area chart. + * + * @since 1.0.16 + */ + public static JFreeChart createStackedXYAreaChart(String title, + String xAxisLabel, String yAxisLabel, TableXYDataset dataset) { + return createStackedXYAreaChart(title, xAxisLabel, yAxisLabel, + dataset, PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates a stacked XY area plot. The chart object returned by this + * method uses an {@link XYPlot} instance as the plot, with a + * {@link NumberAxis} for the domain axis, a {@link NumberAxis} as the + * range axis, and a {@link StackedXYAreaRenderer2} as the renderer. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the plot orientation (horizontal or vertical) + * (null NOT permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A stacked XY area chart. + */ + public static JFreeChart createStackedXYAreaChart(String title, + String xAxisLabel, String yAxisLabel, TableXYDataset dataset, + PlotOrientation orientation, boolean legend, boolean tooltips, + boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + NumberAxis xAxis = new NumberAxis(xAxisLabel); + xAxis.setAutoRangeIncludesZero(false); + xAxis.setLowerMargin(0.0); + xAxis.setUpperMargin(0.0); + NumberAxis yAxis = new NumberAxis(yAxisLabel); + XYToolTipGenerator toolTipGenerator = null; + if (tooltips) { + toolTipGenerator = new StandardXYToolTipGenerator(); + } + + XYURLGenerator urlGenerator = null; + if (urls) { + urlGenerator = new StandardXYURLGenerator(); + } + StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2( + toolTipGenerator, urlGenerator); + renderer.setOutline(true); + XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); + plot.setOrientation(orientation); + + plot.setRangeAxis(yAxis); // forces recalculation of the axis range + + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a line chart (based on an {@link XYDataset}) with default + * settings. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return The chart. + */ + public static JFreeChart createXYLineChart(String title, + String xAxisLabel, String yAxisLabel, XYDataset dataset) { + return createXYLineChart(title, xAxisLabel, yAxisLabel, dataset, + PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates a line chart (based on an {@link XYDataset}) with default + * settings. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the plot orientation (horizontal or vertical) + * (null NOT permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return The chart. + */ + public static JFreeChart createXYLineChart(String title, String xAxisLabel, + String yAxisLabel, XYDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + NumberAxis xAxis = new NumberAxis(xAxisLabel); + xAxis.setAutoRangeIncludesZero(false); + NumberAxis yAxis = new NumberAxis(yAxisLabel); + XYItemRenderer renderer = new XYLineAndShapeRenderer(true, false); + XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); + plot.setOrientation(orientation); + if (tooltips) { + renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); + } + if (urls) { + renderer.setURLGenerator(new StandardXYURLGenerator()); + } + + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a stepped XY plot with default settings. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A chart. + * + * @since 1.0.16 + */ + public static JFreeChart createXYStepChart(String title, String xAxisLabel, + String yAxisLabel, XYDataset dataset) { + return createXYStepChart(title, xAxisLabel, yAxisLabel, dataset, + PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates a stepped XY plot with default settings. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the plot orientation (horizontal or vertical) + * (null NOT permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A chart. + */ + public static JFreeChart createXYStepChart(String title, String xAxisLabel, + String yAxisLabel, XYDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + DateAxis xAxis = new DateAxis(xAxisLabel); + NumberAxis yAxis = new NumberAxis(yAxisLabel); + yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + + XYToolTipGenerator toolTipGenerator = null; + if (tooltips) { + toolTipGenerator = new StandardXYToolTipGenerator(); + } + + XYURLGenerator urlGenerator = null; + if (urls) { + urlGenerator = new StandardXYURLGenerator(); + } + XYItemRenderer renderer = new XYStepRenderer(toolTipGenerator, + urlGenerator); + + XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); + plot.setRenderer(renderer); + plot.setOrientation(orientation); + plot.setDomainCrosshairVisible(false); + plot.setRangeCrosshairVisible(false); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a filled stepped XY plot with default settings. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A chart. + * + * @since 1.0.16 + */ + public static JFreeChart createXYStepAreaChart(String title, + String xAxisLabel, String yAxisLabel, XYDataset dataset) { + return createXYStepAreaChart(title, xAxisLabel, yAxisLabel, dataset, + PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates a filled stepped XY plot with default settings. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the plot orientation (horizontal or vertical) + * (null NOT permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A chart. + */ + public static JFreeChart createXYStepAreaChart(String title, + String xAxisLabel, String yAxisLabel, XYDataset dataset, + PlotOrientation orientation, boolean legend, boolean tooltips, + boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + NumberAxis xAxis = new NumberAxis(xAxisLabel); + xAxis.setAutoRangeIncludesZero(false); + NumberAxis yAxis = new NumberAxis(yAxisLabel); + + XYToolTipGenerator toolTipGenerator = null; + if (tooltips) { + toolTipGenerator = new StandardXYToolTipGenerator(); + } + + XYURLGenerator urlGenerator = null; + if (urls) { + urlGenerator = new StandardXYURLGenerator(); + } + XYItemRenderer renderer = new XYStepAreaRenderer( + XYStepAreaRenderer.AREA_AND_SHAPES, toolTipGenerator, + urlGenerator); + + XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); + plot.setRenderer(renderer); + plot.setOrientation(orientation); + plot.setDomainCrosshairVisible(false); + plot.setRangeCrosshairVisible(false); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + } + + /** + * Creates and returns a time series chart. A time series chart is an + * {@link XYPlot} with a {@link DateAxis} for the x-axis and a + * {@link NumberAxis} for the y-axis. The default renderer is an + * {@link XYLineAndShapeRenderer}. + *

+ * A convenient dataset to use with this chart is a + * {@link org.jfree.data.time.TimeSeriesCollection}. + * + * @param title the chart title (null permitted). + * @param timeAxisLabel a label for the time axis (null + * permitted). + * @param valueAxisLabel a label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A time series chart. + * + * @since 1.0.16 + */ + public static JFreeChart createTimeSeriesChart(String title, + String timeAxisLabel, String valueAxisLabel, XYDataset dataset) { + return createTimeSeriesChart(title, timeAxisLabel, valueAxisLabel, + dataset, true, true, false); + } + + /** + * Creates and returns a time series chart. A time series chart is an + * {@link XYPlot} with a {@link DateAxis} for the x-axis and a + * {@link NumberAxis} for the y-axis. The default renderer is an + * {@link XYLineAndShapeRenderer}. + *

+ * A convenient dataset to use with this chart is a + * {@link org.jfree.data.time.TimeSeriesCollection}. + * + * @param title the chart title (null permitted). + * @param timeAxisLabel a label for the time axis (null + * permitted). + * @param valueAxisLabel a label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A time series chart. + */ + public static JFreeChart createTimeSeriesChart(String title, + String timeAxisLabel, String valueAxisLabel, XYDataset dataset, + boolean legend, boolean tooltips, boolean urls) { + + ValueAxis timeAxis = new DateAxis(timeAxisLabel); + timeAxis.setLowerMargin(0.02); // reduce the default margins + timeAxis.setUpperMargin(0.02); + NumberAxis valueAxis = new NumberAxis(valueAxisLabel); + valueAxis.setAutoRangeIncludesZero(false); // override default + XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); + + XYToolTipGenerator toolTipGenerator = null; + if (tooltips) { + toolTipGenerator + = StandardXYToolTipGenerator.getTimeSeriesInstance(); + } + + XYURLGenerator urlGenerator = null; + if (urls) { + urlGenerator = new StandardXYURLGenerator(); + } + + XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, + false); + renderer.setBaseToolTipGenerator(toolTipGenerator); + renderer.setURLGenerator(urlGenerator); + plot.setRenderer(renderer); + + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates and returns a default instance of a candlesticks chart. + * + * @param title the chart title (null permitted). + * @param timeAxisLabel a label for the time axis (null + * permitted). + * @param valueAxisLabel a label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * @param legend a flag specifying whether or not a legend is required. + * + * @return A candlestick chart. + */ + public static JFreeChart createCandlestickChart(String title, + String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, + boolean legend) { + + ValueAxis timeAxis = new DateAxis(timeAxisLabel); + NumberAxis valueAxis = new NumberAxis(valueAxisLabel); + XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); + plot.setRenderer(new CandlestickRenderer()); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates and returns a default instance of a high-low-open-close chart. + * + * @param title the chart title (null permitted). + * @param timeAxisLabel a label for the time axis (null + * permitted). + * @param valueAxisLabel a label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * @param legend a flag specifying whether or not a legend is required. + * + * @return A high-low-open-close chart. + */ + public static JFreeChart createHighLowChart(String title, + String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, + boolean legend) { + + ValueAxis timeAxis = new DateAxis(timeAxisLabel); + NumberAxis valueAxis = new NumberAxis(valueAxisLabel); + HighLowRenderer renderer = new HighLowRenderer(); + renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator()); + XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates and returns a default instance of a high-low-open-close chart + * with a special timeline. This timeline can be a + * {@link org.jfree.chart.axis.SegmentedTimeline} such as the Monday + * through Friday timeline that will remove Saturdays and Sundays from + * the axis. + * + * @param title the chart title (null permitted). + * @param timeAxisLabel a label for the time axis (null + * permitted). + * @param valueAxisLabel a label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * @param timeline the timeline. + * @param legend a flag specifying whether or not a legend is required. + * + * @return A high-low-open-close chart. + */ + public static JFreeChart createHighLowChart(String title, + String timeAxisLabel, String valueAxisLabel, OHLCDataset dataset, + Timeline timeline, boolean legend) { + + DateAxis timeAxis = new DateAxis(timeAxisLabel); + timeAxis.setTimeline(timeline); + NumberAxis valueAxis = new NumberAxis(valueAxisLabel); + HighLowRenderer renderer = new HighLowRenderer(); + renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator()); + XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a bubble chart with default settings. The chart is composed of + * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis, + * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer} + * to draw the data items. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * + * @return A bubble chart. + * + * @since 1.0.16 + */ + public static JFreeChart createBubbleChart(String title, String xAxisLabel, + String yAxisLabel, XYZDataset dataset) { + return createBubbleChart(title, xAxisLabel, yAxisLabel, dataset, + PlotOrientation.VERTICAL, true, true, false); + } + + /** + * Creates a bubble chart with default settings. The chart is composed of + * an {@link XYPlot}, with a {@link NumberAxis} for the domain axis, + * a {@link NumberAxis} for the range axis, and an {@link XYBubbleRenderer} + * to draw the data items. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the X-axis (null permitted). + * @param yAxisLabel a label for the Y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param orientation the orientation (horizontal or vertical) + * (null NOT permitted). + * @param legend a flag specifying whether or not a legend is required. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A bubble chart. + */ + public static JFreeChart createBubbleChart(String title, String xAxisLabel, + String yAxisLabel, XYZDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + NumberAxis xAxis = new NumberAxis(xAxisLabel); + xAxis.setAutoRangeIncludesZero(false); + NumberAxis yAxis = new NumberAxis(yAxisLabel); + yAxis.setAutoRangeIncludesZero(false); + + XYPlot plot = new XYPlot(dataset, xAxis, yAxis, null); + + XYItemRenderer renderer = new XYBubbleRenderer( + XYBubbleRenderer.SCALE_ON_RANGE_AXIS); + if (tooltips) { + renderer.setBaseToolTipGenerator(new StandardXYZToolTipGenerator()); + } + if (urls) { + renderer.setURLGenerator(new StandardXYZURLGenerator()); + } + plot.setRenderer(renderer); + plot.setOrientation(orientation); + + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a histogram chart. This chart is constructed with an + * {@link XYPlot} using an {@link XYBarRenderer}. The domain and range + * axes are {@link NumberAxis} instances. + * + * @param title the chart title (null permitted). + * @param xAxisLabel the x axis label (null permitted). + * @param yAxisLabel the y axis label (null permitted). + * @param dataset the dataset (null permitted). + * @param orientation the orientation (horizontal or vertical) + * (null NOT permitted). + * @param legend create a legend? + * @param tooltips display tooltips? + * @param urls generate URLs? + * + * @return The chart. + */ + public static JFreeChart createHistogram(String title, + String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset, + PlotOrientation orientation, boolean legend, boolean tooltips, + boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + NumberAxis xAxis = new NumberAxis(xAxisLabel); + xAxis.setAutoRangeIncludesZero(false); + ValueAxis yAxis = new NumberAxis(yAxisLabel); + + XYItemRenderer renderer = new XYBarRenderer(); + if (tooltips) { + renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); + } + if (urls) { + renderer.setURLGenerator(new StandardXYURLGenerator()); + } + + XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); + plot.setOrientation(orientation); + plot.setDomainZeroBaselineVisible(true); + plot.setRangeZeroBaselineVisible(true); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates and returns a default instance of a box and whisker chart + * based on data from a {@link BoxAndWhiskerCategoryDataset}. + * + * @param title the chart title (null permitted). + * @param categoryAxisLabel a label for the category axis + * (null permitted). + * @param valueAxisLabel a label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * @param legend a flag specifying whether or not a legend is required. + * + * @return A box and whisker chart. + * + * @since 1.0.4 + */ + public static JFreeChart createBoxAndWhiskerChart(String title, + String categoryAxisLabel, String valueAxisLabel, + BoxAndWhiskerCategoryDataset dataset, boolean legend) { + + CategoryAxis categoryAxis = new CategoryAxis(categoryAxisLabel); + NumberAxis valueAxis = new NumberAxis(valueAxisLabel); + valueAxis.setAutoRangeIncludesZero(false); + + BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); + renderer.setBaseToolTipGenerator(new BoxAndWhiskerToolTipGenerator()); + + CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, + renderer); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + } + + /** + * Creates and returns a default instance of a box and whisker chart. + * + * @param title the chart title (null permitted). + * @param timeAxisLabel a label for the time axis (null + * permitted). + * @param valueAxisLabel a label for the value axis (null + * permitted). + * @param dataset the dataset for the chart (null permitted). + * @param legend a flag specifying whether or not a legend is required. + * + * @return A box and whisker chart. + */ + public static JFreeChart createBoxAndWhiskerChart(String title, + String timeAxisLabel, String valueAxisLabel, + BoxAndWhiskerXYDataset dataset, boolean legend) { + + ValueAxis timeAxis = new DateAxis(timeAxisLabel); + NumberAxis valueAxis = new NumberAxis(valueAxisLabel); + valueAxis.setAutoRangeIncludesZero(false); + XYBoxAndWhiskerRenderer renderer = new XYBoxAndWhiskerRenderer(10.0); + XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, renderer); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a wind plot with default settings. + * + * @param title the chart title (null permitted). + * @param xAxisLabel a label for the x-axis (null permitted). + * @param yAxisLabel a label for the y-axis (null permitted). + * @param dataset the dataset for the chart (null permitted). + * @param legend a flag that controls whether or not a legend is created. + * @param tooltips configure chart to generate tool tips? + * @param urls configure chart to generate URLs? + * + * @return A wind plot. + * + */ + public static JFreeChart createWindPlot(String title, String xAxisLabel, + String yAxisLabel, WindDataset dataset, boolean legend, + boolean tooltips, boolean urls) { + + ValueAxis xAxis = new DateAxis(xAxisLabel); + ValueAxis yAxis = new NumberAxis(yAxisLabel); + yAxis.setRange(-12.0, 12.0); + + WindItemRenderer renderer = new WindItemRenderer(); + if (tooltips) { + renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); + } + if (urls) { + renderer.setURLGenerator(new StandardXYURLGenerator()); + } + XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + + } + + /** + * Creates a wafer map chart. + * + * @param title the chart title (null permitted). + * @param dataset the dataset (null permitted). + * @param orientation the plot orientation (horizontal or vertical) + * (null NOT permitted. + * @param legend display a legend? + * @param tooltips generate tooltips? + * @param urls generate URLs? + * + * @return A wafer map chart. + */ + public static JFreeChart createWaferMapChart(String title, + WaferMapDataset dataset, PlotOrientation orientation, + boolean legend, boolean tooltips, boolean urls) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + WaferMapPlot plot = new WaferMapPlot(dataset); + WaferMapRenderer renderer = new WaferMapRenderer(); + plot.setRenderer(renderer); + + JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, + plot, legend); + currentTheme.apply(chart); + return chart; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartFrame.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartFrame.java new file mode 100755 index 0000000..ac1a4e1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartFrame.java @@ -0,0 +1,96 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * 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 true, 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; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartMouseEvent.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartMouseEvent.java new file mode 100755 index 0000000..87ce172 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartMouseEvent.java @@ -0,0 +1,118 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * 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 (null not permitted). + * @param trigger the mouse event that triggered this event + * (null not permitted). + * @param entity the chart entity (if any) under the mouse point + * (null 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 null). + */ + public JFreeChart getChart() { + return this.chart; + } + + /** + * Returns the mouse event that triggered this event. + * + * @return The event (never null). + */ + public MouseEvent getTrigger() { + return this.trigger; + } + + /** + * Returns the chart entity (if any) under the mouse point. + * + * @return The chart entity (possibly null). + */ + public ChartEntity getEntity() { + return this.entity; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartMouseListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartMouseListener.java new file mode 100755 index 0000000..f62f4cd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartMouseListener.java @@ -0,0 +1,73 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * 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); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartPanel.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartPanel.java new file mode 100755 index 0000000..1a02475 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartPanel.java @@ -0,0 +1,3341 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * ChartPanel.java + * --------------- + * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Andrzej Porebski; + * Soren Caspersen; + * Jonathan Nash; + * Hans-Jurgen Greiner; + * Andreas Schneider; + * Daniel van Enckevort; + * David M O'Donnell; + * Arnaud Lelievre; + * Matthias Rose; + * Onno vd Akker; + * Sergei Ivanov; + * Ulrich Voigt - patch 2686040; + * Alessandro Borges - patch 1460845; + * Martin Hoeller; + * + * Changes (from 28-Jun-2001) + * -------------------------- + * 28-Jun-2001 : Integrated buffering code contributed by S???ren + * Caspersen (DG); + * 18-Sep-2001 : Updated header and fixed DOS encoding problem (DG); + * 22-Nov-2001 : Added scaling to improve display of charts in small sizes (DG); + * 26-Nov-2001 : Added property editing, saving and printing (DG); + * 11-Dec-2001 : Transferred saveChartAsPNG method to new ChartUtilities + * class (DG); + * 13-Dec-2001 : Added tooltips (DG); + * 16-Jan-2002 : Added an optional crosshair, based on the implementation by + * Jonathan Nash. Renamed the tooltips class (DG); + * 23-Jan-2002 : Implemented zooming based on code by Hans-Jurgen Greiner (DG); + * 05-Feb-2002 : Improved tooltips setup. Renamed method attemptSaveAs() + * --> doSaveAs() and made it public rather than private (DG); + * 28-Mar-2002 : Added a new constructor (DG); + * 09-Apr-2002 : Changed initialisation of tooltip generation, as suggested by + * Hans-Jurgen Greiner (DG); + * 27-May-2002 : New interactive zooming methods based on code by Hans-Jurgen + * Greiner. Renamed JFreeChartPanel --> ChartPanel, moved + * constants to ChartPanelConstants interface (DG); + * 31-May-2002 : Fixed a bug with interactive zooming and added a way to + * control if the zoom rectangle is filled in or drawn as an + * outline. A mouse drag gesture towards the top left now causes + * an autoRangeBoth() and is a way to undo zooms (AS); + * 11-Jun-2002 : Reinstated handleClick method call in mouseClicked() to get + * crosshairs working again (DG); + * 13-Jun-2002 : Added check for null popup menu in mouseDragged method (DG); + * 18-Jun-2002 : Added get/set methods for minimum and maximum chart + * dimensions (DG); + * 25-Jun-2002 : Removed redundant code (DG); + * 27-Aug-2002 : Added get/set methods for popup menu (DG); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 22-Oct-2002 : Added translation methods for screen <--> Java2D, contributed + * by Daniel van Enckevort (DG); + * 05-Nov-2002 : Added a chart reference to the ChartMouseEvent class (DG); + * 22-Nov-2002 : Added test in zoom method for inverted axes, supplied by + * David M O'Donnell (DG); + * 14-Jan-2003 : Implemented ChartProgressListener interface (DG); + * 14-Feb-2003 : Removed deprecated setGenerateTooltips method (DG); + * 12-Mar-2003 : Added option to enforce filename extension (see bug id + * 643173) (DG); + * 08-Sep-2003 : Added internationalization via use of properties + * resourceBundle (RFE 690236) (AL); + * 18-Sep-2003 : Added getScaleX() and getScaleY() methods (protected) as + * requested by Irv Thomae (DG); + * 12-Nov-2003 : Added zooming support for the FastScatterPlot class (DG); + * 24-Nov-2003 : Minor Javadoc updates (DG); + * 04-Dec-2003 : Added anchor point for crosshair calculation (DG); + * 17-Jan-2004 : Added new methods to set tooltip delays to be used in this + * chart panel. Refer to patch 877565 (MR); + * 02-Feb-2004 : Fixed bug in zooming trigger and added zoomTriggerDistance + * attribute (DG); + * 08-Apr-2004 : Changed getScaleX() and getScaleY() from protected to + * public (DG); + * 15-Apr-2004 : Added zoomOutFactor and zoomInFactor (DG); + * 21-Apr-2004 : Fixed zooming bug in mouseReleased() method (DG); + * 13-Jul-2004 : Added check for null chart (DG); + * 04-Oct-2004 : Renamed ShapeUtils --> ShapeUtilities (DG); + * 11-Nov-2004 : Moved constants back in from ChartPanelConstants (DG); + * 12-Nov-2004 : Modified zooming mechanism to support zooming within + * subplots (DG); + * 26-Jan-2005 : Fixed mouse zooming for horizontal category plots (DG); + * 11-Apr-2005 : Added getFillZoomRectangle() method, renamed + * setHorizontalZoom() --> setDomainZoomable(), + * setVerticalZoom() --> setRangeZoomable(), added + * isDomainZoomable() and isRangeZoomable(), added + * getHorizontalAxisTrace() and getVerticalAxisTrace(), + * renamed autoRangeBoth() --> restoreAutoBounds(), + * autoRangeHorizontal() --> restoreAutoDomainBounds(), + * autoRangeVertical() --> restoreAutoRangeBounds() (DG); + * 12-Apr-2005 : Removed working areas, added getAnchorPoint() method, + * added protected accessors for tracelines (DG); + * 18-Apr-2005 : Made constants final (DG); + * 26-Apr-2005 : Removed LOGGER (DG); + * 01-Jun-2005 : Fixed zooming for combined plots - see bug report + * 1212039, fix thanks to Onno vd Akker (DG); + * 25-Nov-2005 : Reworked event listener mechanism (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 01-Aug-2006 : Fixed minor bug in restoreAutoRangeBounds() (DG); + * 04-Sep-2006 : Renamed attemptEditChartProperties() --> + * doEditChartProperties() and made public (DG); + * 13-Sep-2006 : Don't generate ChartMouseEvents if the panel's chart is null + * (fixes bug 1556951) (DG); + * 05-Mar-2007 : Applied patch 1672561 by Sergei Ivanov, to fix zoom rectangle + * drawing for dynamic charts (DG); + * 17-Apr-2007 : Fix NullPointerExceptions in zooming for combined plots (DG); + * 24-May-2007 : When the look-and-feel changes, update the popup menu if there + * is one (DG); + * 06-Jun-2007 : Fixed coordinates for drawing buffer image (DG); + * 24-Sep-2007 : Added zoomAroundAnchor flag, and handle clearing of chart + * buffer (DG); + * 25-Oct-2007 : Added default directory attribute (DG); + * 07-Nov-2007 : Fixed (rare) bug in refreshing off-screen image (DG); + * 07-May-2008 : Fixed bug in zooming that triggered zoom for a rectangle + * outside of the data area (DG); + * 08-May-2008 : Fixed serialization bug (DG); + * 15-Aug-2008 : Increased default maxDrawWidth/Height (DG); + * 18-Sep-2008 : Modified creation of chart buffer (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 13-Jan-2009 : Fixed zooming methods to trigger only one plot + * change event (DG); + * 16-Jan-2009 : Use XOR for zoom rectangle only if useBuffer is false (DG); + * 18-Mar-2009 : Added mouse wheel support (DG); + * 19-Mar-2009 : Added panning on mouse drag support - based on Ulrich + * Voigt's patch 2686040 (DG); + * 26-Mar-2009 : Changed fillZoomRectangle default to true, and only change + * cursor for CTRL-mouse-click if panning is enabled (DG); + * 01-Apr-2009 : Fixed panning, and added different mouse event mask for + * MacOSX (DG); + * 08-Apr-2009 : Added copy to clipboard support, based on patch 1460845 + * by Alessandro Borges (DG); + * 09-Apr-2009 : Added overlay support (DG); + * 10-Apr-2009 : Set chartBuffer background to match ChartPanel (DG); + * 05-May-2009 : Match scaling (and insets) in doCopy() (DG); + * 01-Jun-2009 : Check for null chart in mousePressed() method (DG); + * 08-Jun-2009 : Fixed bug in setMouseWheelEnabled() (DG); + * 06-Jul-2009 : Clear off-screen buffer to fully transparent (DG); + * 10-Oct-2011 : localization fix: bug #3353913 (MH); + * 05-Jul-2012 : Remove reflection for MouseWheelListener - only needed for + * JRE 1.3.1 (DG); + * 02-Jul-2013 : Use ParamChecks class (DG); + * 12-Sep-2013 : Provide auto-detection for JFreeSVG and OrsonPDF + * libraries (no compile time dependencies) (DG); + * + */ + +package org.jfree.chart; + +import java.awt.AWTEvent; +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Cursor; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.Image; +import java.awt.Insets; +import java.awt.Paint; +import java.awt.Point; +import java.awt.Rectangle; +import java.awt.Toolkit; +import java.awt.Transparency; +import java.awt.datatransfer.Clipboard; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.awt.event.MouseMotionListener; +import java.awt.geom.AffineTransform; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.print.PageFormat; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.EventListener; +import java.util.Iterator; +import java.util.List; +import java.util.ResourceBundle; + +import javax.swing.JFileChooser; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JPopupMenu; +import javax.swing.SwingUtilities; +import javax.swing.ToolTipManager; +import javax.swing.event.EventListenerList; +import javax.swing.filechooser.FileNameExtensionFilter; + +import org.jfree.chart.editor.ChartEditor; +import org.jfree.chart.editor.ChartEditorManager; +import org.jfree.chart.entity.ChartEntity; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.event.ChartProgressEvent; +import org.jfree.chart.event.ChartProgressListener; +import org.jfree.chart.panel.Overlay; +import org.jfree.chart.event.OverlayChangeEvent; +import org.jfree.chart.event.OverlayChangeListener; +import org.jfree.chart.plot.Pannable; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.Zoomable; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.io.SerialUtilities; + +/** + * A Swing GUI component for displaying a {@link JFreeChart} object. + *

+ * The panel registers with the chart to receive notification of changes to any + * component of the chart. The chart is redrawn automatically whenever this + * notification is received. + */ +public class ChartPanel extends JPanel implements ChartChangeListener, + ChartProgressListener, ActionListener, MouseListener, + MouseMotionListener, OverlayChangeListener, Printable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 6046366297214274674L; + + /** + * Default setting for buffer usage. The default has been changed to + * true from version 1.0.13 onwards, because of a severe + * performance problem with drawing the zoom rectangle using XOR (which + * now happens only when the buffer is NOT used). + */ + public static final boolean DEFAULT_BUFFER_USED = true; + + /** The default panel width. */ + public static final int DEFAULT_WIDTH = 680; + + /** The default panel height. */ + public static final int DEFAULT_HEIGHT = 420; + + /** The default limit below which chart scaling kicks in. */ + public static final int DEFAULT_MINIMUM_DRAW_WIDTH = 300; + + /** The default limit below which chart scaling kicks in. */ + public static final int DEFAULT_MINIMUM_DRAW_HEIGHT = 200; + + /** The default limit above which chart scaling kicks in. */ + public static final int DEFAULT_MAXIMUM_DRAW_WIDTH = 1024; + + /** The default limit above which chart scaling kicks in. */ + public static final int DEFAULT_MAXIMUM_DRAW_HEIGHT = 768; + + /** The minimum size required to perform a zoom on a rectangle */ + public static final int DEFAULT_ZOOM_TRIGGER_DISTANCE = 10; + + /** Properties action command. */ + public static final String PROPERTIES_COMMAND = "PROPERTIES"; + + /** + * Copy action command. + * + * @since 1.0.13 + */ + public static final String COPY_COMMAND = "COPY"; + + /** Save action command. */ + public static final String SAVE_COMMAND = "SAVE"; + + /** Action command to save as PNG. */ + private static final String SAVE_AS_PNG_COMMAND = "SAVE_AS_PNG"; + + /** Action command to save as SVG. */ + private static final String SAVE_AS_SVG_COMMAND = "SAVE_AS_SVG"; + + /** Action command to save as PDF. */ + private static final String SAVE_AS_PDF_COMMAND = "SAVE_AS_PDF"; + + /** Print action command. */ + public static final String PRINT_COMMAND = "PRINT"; + + /** Zoom in (both axes) action command. */ + public static final String ZOOM_IN_BOTH_COMMAND = "ZOOM_IN_BOTH"; + + /** Zoom in (domain axis only) action command. */ + public static final String ZOOM_IN_DOMAIN_COMMAND = "ZOOM_IN_DOMAIN"; + + /** Zoom in (range axis only) action command. */ + public static final String ZOOM_IN_RANGE_COMMAND = "ZOOM_IN_RANGE"; + + /** Zoom out (both axes) action command. */ + public static final String ZOOM_OUT_BOTH_COMMAND = "ZOOM_OUT_BOTH"; + + /** Zoom out (domain axis only) action command. */ + public static final String ZOOM_OUT_DOMAIN_COMMAND = "ZOOM_DOMAIN_BOTH"; + + /** Zoom out (range axis only) action command. */ + public static final String ZOOM_OUT_RANGE_COMMAND = "ZOOM_RANGE_BOTH"; + + /** Zoom reset (both axes) action command. */ + public static final String ZOOM_RESET_BOTH_COMMAND = "ZOOM_RESET_BOTH"; + + /** Zoom reset (domain axis only) action command. */ + public static final String ZOOM_RESET_DOMAIN_COMMAND = "ZOOM_RESET_DOMAIN"; + + /** Zoom reset (range axis only) action command. */ + public static final String ZOOM_RESET_RANGE_COMMAND = "ZOOM_RESET_RANGE"; + + /** The chart that is displayed in the panel. */ + private JFreeChart chart; + + /** Storage for registered (chart) mouse listeners. */ + private transient EventListenerList chartMouseListeners; + + /** A flag that controls whether or not the off-screen buffer is used. */ + private boolean useBuffer; + + /** A flag that indicates that the buffer should be refreshed. */ + private boolean refreshBuffer; + + /** A buffer for the rendered chart. */ + private transient Image chartBuffer; + + /** The height of the chart buffer. */ + private int chartBufferHeight; + + /** The width of the chart buffer. */ + private int chartBufferWidth; + + /** + * The minimum width for drawing a chart (uses scaling for smaller widths). + */ + private int minimumDrawWidth; + + /** + * The minimum height for drawing a chart (uses scaling for smaller + * heights). + */ + private int minimumDrawHeight; + + /** + * The maximum width for drawing a chart (uses scaling for bigger + * widths). + */ + private int maximumDrawWidth; + + /** + * The maximum height for drawing a chart (uses scaling for bigger + * heights). + */ + private int maximumDrawHeight; + + /** The popup menu for the frame. */ + private JPopupMenu popup; + + /** The drawing info collected the last time the chart was drawn. */ + private ChartRenderingInfo info; + + /** The chart anchor point. */ + private Point2D anchor; + + /** The scale factor used to draw the chart. */ + private double scaleX; + + /** The scale factor used to draw the chart. */ + private double scaleY; + + /** The plot orientation. */ + private PlotOrientation orientation = PlotOrientation.VERTICAL; + + /** A flag that controls whether or not domain zooming is enabled. */ + private boolean domainZoomable = false; + + /** A flag that controls whether or not range zooming is enabled. */ + private boolean rangeZoomable = false; + + /** + * The zoom rectangle starting point (selected by the user with a mouse + * click). This is a point on the screen, not the chart (which may have + * been scaled up or down to fit the panel). + */ + private Point2D zoomPoint = null; + + /** The zoom rectangle (selected by the user with the mouse). */ + private transient Rectangle2D zoomRectangle = null; + + /** Controls if the zoom rectangle is drawn as an outline or filled. */ + private boolean fillZoomRectangle = true; + + /** The minimum distance required to drag the mouse to trigger a zoom. */ + private int zoomTriggerDistance; + + /** A flag that controls whether or not horizontal tracing is enabled. */ + private boolean horizontalAxisTrace = false; + + /** A flag that controls whether or not vertical tracing is enabled. */ + private boolean verticalAxisTrace = false; + + /** A vertical trace line. */ + private transient Line2D verticalTraceLine; + + /** A horizontal trace line. */ + private transient Line2D horizontalTraceLine; + + /** Menu item for zooming in on a chart (both axes). */ + private JMenuItem zoomInBothMenuItem; + + /** Menu item for zooming in on a chart (domain axis). */ + private JMenuItem zoomInDomainMenuItem; + + /** Menu item for zooming in on a chart (range axis). */ + private JMenuItem zoomInRangeMenuItem; + + /** Menu item for zooming out on a chart. */ + private JMenuItem zoomOutBothMenuItem; + + /** Menu item for zooming out on a chart (domain axis). */ + private JMenuItem zoomOutDomainMenuItem; + + /** Menu item for zooming out on a chart (range axis). */ + private JMenuItem zoomOutRangeMenuItem; + + /** Menu item for resetting the zoom (both axes). */ + private JMenuItem zoomResetBothMenuItem; + + /** Menu item for resetting the zoom (domain axis only). */ + private JMenuItem zoomResetDomainMenuItem; + + /** Menu item for resetting the zoom (range axis only). */ + private JMenuItem zoomResetRangeMenuItem; + + /** + * The default directory for saving charts to file. + * + * @since 1.0.7 + */ + private File defaultDirectoryForSaveAs; + + /** A flag that controls whether or not file extensions are enforced. */ + private boolean enforceFileExtensions; + + /** A flag that indicates if original tooltip delays are changed. */ + private boolean ownToolTipDelaysActive; + + /** Original initial tooltip delay of ToolTipManager.sharedInstance(). */ + private int originalToolTipInitialDelay; + + /** Original reshow tooltip delay of ToolTipManager.sharedInstance(). */ + private int originalToolTipReshowDelay; + + /** Original dismiss tooltip delay of ToolTipManager.sharedInstance(). */ + private int originalToolTipDismissDelay; + + /** Own initial tooltip delay to be used in this chart panel. */ + private int ownToolTipInitialDelay; + + /** Own reshow tooltip delay to be used in this chart panel. */ + private int ownToolTipReshowDelay; + + /** Own dismiss tooltip delay to be used in this chart panel. */ + private int ownToolTipDismissDelay; + + /** The factor used to zoom in on an axis range. */ + private double zoomInFactor = 0.5; + + /** The factor used to zoom out on an axis range. */ + private double zoomOutFactor = 2.0; + + /** + * A flag that controls whether zoom operations are centred on the + * current anchor point, or the centre point of the relevant axis. + * + * @since 1.0.7 + */ + private boolean zoomAroundAnchor; + + /** + * The paint used to draw the zoom rectangle outline. + * + * @since 1.0.13 + */ + private transient Paint zoomOutlinePaint; + + /** + * The zoom fill paint (should use transparency). + * + * @since 1.0.13 + */ + private transient Paint zoomFillPaint; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.LocalizationBundle"); + + /** + * Temporary storage for the width and height of the chart + * drawing area during panning. + */ + private double panW, panH; + + /** The last mouse position during panning. */ + private Point panLast; + + /** + * The mask for mouse events to trigger panning. + * + * @since 1.0.13 + */ + private int panMask = InputEvent.CTRL_MASK; + + /** + * A list of overlays for the panel. + * + * @since 1.0.13 + */ + private List overlays; + + /** + * Constructs a panel that displays the specified chart. + * + * @param chart the chart. + */ + public ChartPanel(JFreeChart chart) { + + this( + chart, + DEFAULT_WIDTH, + DEFAULT_HEIGHT, + DEFAULT_MINIMUM_DRAW_WIDTH, + DEFAULT_MINIMUM_DRAW_HEIGHT, + DEFAULT_MAXIMUM_DRAW_WIDTH, + DEFAULT_MAXIMUM_DRAW_HEIGHT, + DEFAULT_BUFFER_USED, + true, // properties + true, // save + true, // print + true, // zoom + true // tooltips + ); + + } + + /** + * Constructs a panel containing a chart. The useBuffer flag + * controls whether or not an offscreen BufferedImage is + * maintained for the chart. If the buffer is used, more memory is + * consumed, but panel repaints will be a lot quicker in cases where the + * chart itself hasn't changed (for example, when another frame is moved + * to reveal the panel). WARNING: If you set the useBuffer + * flag to false, note that the mouse zooming rectangle will (in that case) + * be drawn using XOR, and there is a SEVERE performance problem with that + * on JRE6 on Windows. + * + * @param chart the chart. + * @param useBuffer a flag controlling whether or not an off-screen buffer + * is used (read the warning above before setting this + * to false). + */ + public ChartPanel(JFreeChart chart, boolean useBuffer) { + + this(chart, DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_MINIMUM_DRAW_WIDTH, + DEFAULT_MINIMUM_DRAW_HEIGHT, DEFAULT_MAXIMUM_DRAW_WIDTH, + DEFAULT_MAXIMUM_DRAW_HEIGHT, useBuffer, + true, // properties + true, // save + true, // print + true, // zoom + true // tooltips + ); + + } + + /** + * Constructs a JFreeChart panel. + * + * @param chart the chart. + * @param properties a flag indicating whether or not the chart property + * editor should be available via the popup menu. + * @param save a flag indicating whether or not save options should be + * available via the popup menu. + * @param print a flag indicating whether or not the print option + * should be available via the popup menu. + * @param zoom a flag indicating whether or not zoom options should + * be added to the popup menu. + * @param tooltips a flag indicating whether or not tooltips should be + * enabled for the chart. + */ + public ChartPanel(JFreeChart chart, + boolean properties, + boolean save, + boolean print, + boolean zoom, + boolean tooltips) { + + this(chart, + DEFAULT_WIDTH, + DEFAULT_HEIGHT, + DEFAULT_MINIMUM_DRAW_WIDTH, + DEFAULT_MINIMUM_DRAW_HEIGHT, + DEFAULT_MAXIMUM_DRAW_WIDTH, + DEFAULT_MAXIMUM_DRAW_HEIGHT, + DEFAULT_BUFFER_USED, + properties, + save, + print, + zoom, + tooltips + ); + + } + + /** + * Constructs a JFreeChart panel. + * + * @param chart the chart. + * @param width the preferred width of the panel. + * @param height the preferred height of the panel. + * @param minimumDrawWidth the minimum drawing width. + * @param minimumDrawHeight the minimum drawing height. + * @param maximumDrawWidth the maximum drawing width. + * @param maximumDrawHeight the maximum drawing height. + * @param useBuffer a flag that indicates whether to use the off-screen + * buffer to improve performance (at the expense of + * memory). + * @param properties a flag indicating whether or not the chart property + * editor should be available via the popup menu. + * @param save a flag indicating whether or not save options should be + * available via the popup menu. + * @param print a flag indicating whether or not the print option + * should be available via the popup menu. + * @param zoom a flag indicating whether or not zoom options should be + * added to the popup menu. + * @param tooltips a flag indicating whether or not tooltips should be + * enabled for the chart. + */ + public ChartPanel(JFreeChart chart, int width, int height, + int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, + int maximumDrawHeight, boolean useBuffer, boolean properties, + boolean save, boolean print, boolean zoom, boolean tooltips) { + + this(chart, width, height, minimumDrawWidth, minimumDrawHeight, + maximumDrawWidth, maximumDrawHeight, useBuffer, properties, + true, save, print, zoom, tooltips); + } + + /** + * Constructs a JFreeChart panel. + * + * @param chart the chart. + * @param width the preferred width of the panel. + * @param height the preferred height of the panel. + * @param minimumDrawWidth the minimum drawing width. + * @param minimumDrawHeight the minimum drawing height. + * @param maximumDrawWidth the maximum drawing width. + * @param maximumDrawHeight the maximum drawing height. + * @param useBuffer a flag that indicates whether to use the off-screen + * buffer to improve performance (at the expense of + * memory). + * @param properties a flag indicating whether or not the chart property + * editor should be available via the popup menu. + * @param copy a flag indicating whether or not a copy option should be + * available via the popup menu. + * @param save a flag indicating whether or not save options should be + * available via the popup menu. + * @param print a flag indicating whether or not the print option + * should be available via the popup menu. + * @param zoom a flag indicating whether or not zoom options should be + * added to the popup menu. + * @param tooltips a flag indicating whether or not tooltips should be + * enabled for the chart. + * + * @since 1.0.13 + */ + public ChartPanel(JFreeChart chart, int width, int height, + int minimumDrawWidth, int minimumDrawHeight, int maximumDrawWidth, + int maximumDrawHeight, boolean useBuffer, boolean properties, + boolean copy, boolean save, boolean print, boolean zoom, + boolean tooltips) { + + setChart(chart); + this.chartMouseListeners = new EventListenerList(); + this.info = new ChartRenderingInfo(); + setPreferredSize(new Dimension(width, height)); + this.useBuffer = useBuffer; + this.refreshBuffer = false; + this.minimumDrawWidth = minimumDrawWidth; + this.minimumDrawHeight = minimumDrawHeight; + this.maximumDrawWidth = maximumDrawWidth; + this.maximumDrawHeight = maximumDrawHeight; + this.zoomTriggerDistance = DEFAULT_ZOOM_TRIGGER_DISTANCE; + + // set up popup menu... + this.popup = null; + if (properties || copy || save || print || zoom) { + this.popup = createPopupMenu(properties, copy, save, print, zoom); + } + + enableEvents(AWTEvent.MOUSE_EVENT_MASK); + enableEvents(AWTEvent.MOUSE_MOTION_EVENT_MASK); + setDisplayToolTips(tooltips); + addMouseListener(this); + addMouseMotionListener(this); + + this.defaultDirectoryForSaveAs = null; + this.enforceFileExtensions = true; + + // initialize ChartPanel-specific tool tip delays with + // values the from ToolTipManager.sharedInstance() + ToolTipManager ttm = ToolTipManager.sharedInstance(); + this.ownToolTipInitialDelay = ttm.getInitialDelay(); + this.ownToolTipDismissDelay = ttm.getDismissDelay(); + this.ownToolTipReshowDelay = ttm.getReshowDelay(); + + this.zoomAroundAnchor = false; + this.zoomOutlinePaint = Color.blue; + this.zoomFillPaint = new Color(0, 0, 255, 63); + + this.panMask = InputEvent.CTRL_MASK; + // for MacOSX we can't use the CTRL key for mouse drags, see: + // http://developer.apple.com/qa/qa2004/qa1362.html + String osName = System.getProperty("os.name").toLowerCase(); + if (osName.startsWith("mac os x")) { + this.panMask = InputEvent.ALT_MASK; + } + + this.overlays = new java.util.ArrayList(); + } + + /** + * Returns the chart contained in the panel. + * + * @return The chart (possibly null). + */ + public JFreeChart getChart() { + return this.chart; + } + + /** + * Sets the chart that is displayed in the panel. + * + * @param chart the chart (null permitted). + */ + public void setChart(JFreeChart chart) { + + // stop listening for changes to the existing chart + if (this.chart != null) { + this.chart.removeChangeListener(this); + this.chart.removeProgressListener(this); + } + + // add the new chart + this.chart = chart; + if (chart != null) { + this.chart.addChangeListener(this); + this.chart.addProgressListener(this); + Plot plot = chart.getPlot(); + this.domainZoomable = false; + this.rangeZoomable = false; + if (plot instanceof Zoomable) { + Zoomable z = (Zoomable) plot; + this.domainZoomable = z.isDomainZoomable(); + this.rangeZoomable = z.isRangeZoomable(); + this.orientation = z.getOrientation(); + } + } + else { + this.domainZoomable = false; + this.rangeZoomable = false; + } + if (this.useBuffer) { + this.refreshBuffer = true; + } + repaint(); + + } + + /** + * Returns the minimum drawing width for charts. + *

+ * If the width available on the panel is less than this, then the chart is + * drawn at the minimum width then scaled down to fit. + * + * @return The minimum drawing width. + */ + public int getMinimumDrawWidth() { + return this.minimumDrawWidth; + } + + /** + * Sets the minimum drawing width for the chart on this panel. + *

+ * At the time the chart is drawn on the panel, if the available width is + * less than this amount, the chart will be drawn using the minimum width + * then scaled down to fit the available space. + * + * @param width The width. + */ + public void setMinimumDrawWidth(int width) { + this.minimumDrawWidth = width; + } + + /** + * Returns the maximum drawing width for charts. + *

+ * If the width available on the panel is greater than this, then the chart + * is drawn at the maximum width then scaled up to fit. + * + * @return The maximum drawing width. + */ + public int getMaximumDrawWidth() { + return this.maximumDrawWidth; + } + + /** + * Sets the maximum drawing width for the chart on this panel. + *

+ * At the time the chart is drawn on the panel, if the available width is + * greater than this amount, the chart will be drawn using the maximum + * width then scaled up to fit the available space. + * + * @param width The width. + */ + public void setMaximumDrawWidth(int width) { + this.maximumDrawWidth = width; + } + + /** + * Returns the minimum drawing height for charts. + *

+ * If the height available on the panel is less than this, then the chart + * is drawn at the minimum height then scaled down to fit. + * + * @return The minimum drawing height. + */ + public int getMinimumDrawHeight() { + return this.minimumDrawHeight; + } + + /** + * Sets the minimum drawing height for the chart on this panel. + *

+ * At the time the chart is drawn on the panel, if the available height is + * less than this amount, the chart will be drawn using the minimum height + * then scaled down to fit the available space. + * + * @param height The height. + */ + public void setMinimumDrawHeight(int height) { + this.minimumDrawHeight = height; + } + + /** + * Returns the maximum drawing height for charts. + *

+ * If the height available on the panel is greater than this, then the + * chart is drawn at the maximum height then scaled up to fit. + * + * @return The maximum drawing height. + */ + public int getMaximumDrawHeight() { + return this.maximumDrawHeight; + } + + /** + * Sets the maximum drawing height for the chart on this panel. + *

+ * At the time the chart is drawn on the panel, if the available height is + * greater than this amount, the chart will be drawn using the maximum + * height then scaled up to fit the available space. + * + * @param height The height. + */ + public void setMaximumDrawHeight(int height) { + this.maximumDrawHeight = height; + } + + /** + * Returns the X scale factor for the chart. This will be 1.0 if no + * scaling has been used. + * + * @return The scale factor. + */ + public double getScaleX() { + return this.scaleX; + } + + /** + * Returns the Y scale factory for the chart. This will be 1.0 if no + * scaling has been used. + * + * @return The scale factor. + */ + public double getScaleY() { + return this.scaleY; + } + + /** + * Returns the anchor point. + * + * @return The anchor point (possibly null). + */ + public Point2D getAnchor() { + return this.anchor; + } + + /** + * Sets the anchor point. This method is provided for the use of + * subclasses, not end users. + * + * @param anchor the anchor point (null permitted). + */ + protected void setAnchor(Point2D anchor) { + this.anchor = anchor; + } + + /** + * Returns the popup menu. + * + * @return The popup menu. + */ + public JPopupMenu getPopupMenu() { + return this.popup; + } + + /** + * Sets the popup menu for the panel. + * + * @param popup the popup menu (null permitted). + */ + public void setPopupMenu(JPopupMenu popup) { + this.popup = popup; + } + + /** + * Returns the chart rendering info from the most recent chart redraw. + * + * @return The chart rendering info. + */ + public ChartRenderingInfo getChartRenderingInfo() { + return this.info; + } + + /** + * A convenience method that switches on mouse-based zooming. + * + * @param flag true enables zooming and rectangle fill on + * zoom. + */ + public void setMouseZoomable(boolean flag) { + setMouseZoomable(flag, true); + } + + /** + * A convenience method that switches on mouse-based zooming. + * + * @param flag true if zooming enabled + * @param fillRectangle true if zoom rectangle is filled, + * false if rectangle is shown as outline only. + */ + public void setMouseZoomable(boolean flag, boolean fillRectangle) { + setDomainZoomable(flag); + setRangeZoomable(flag); + setFillZoomRectangle(fillRectangle); + } + + /** + * Returns the flag that determines whether or not zooming is enabled for + * the domain axis. + * + * @return A boolean. + */ + public boolean isDomainZoomable() { + return this.domainZoomable; + } + + /** + * Sets the flag that controls whether or not zooming is enable for the + * domain axis. A check is made to ensure that the current plot supports + * zooming for the domain values. + * + * @param flag true enables zooming if possible. + */ + public void setDomainZoomable(boolean flag) { + if (flag) { + Plot plot = this.chart.getPlot(); + if (plot instanceof Zoomable) { + Zoomable z = (Zoomable) plot; + this.domainZoomable = flag && (z.isDomainZoomable()); + } + } + else { + this.domainZoomable = false; + } + } + + /** + * Returns the flag that determines whether or not zooming is enabled for + * the range axis. + * + * @return A boolean. + */ + public boolean isRangeZoomable() { + return this.rangeZoomable; + } + + /** + * A flag that controls mouse-based zooming on the vertical axis. + * + * @param flag true enables zooming. + */ + public void setRangeZoomable(boolean flag) { + if (flag) { + Plot plot = this.chart.getPlot(); + if (plot instanceof Zoomable) { + Zoomable z = (Zoomable) plot; + this.rangeZoomable = flag && (z.isRangeZoomable()); + } + } + else { + this.rangeZoomable = false; + } + } + + /** + * Returns the flag that controls whether or not the zoom rectangle is + * filled when drawn. + * + * @return A boolean. + */ + public boolean getFillZoomRectangle() { + return this.fillZoomRectangle; + } + + /** + * A flag that controls how the zoom rectangle is drawn. + * + * @param flag true instructs to fill the rectangle on + * zoom, otherwise it will be outlined. + */ + public void setFillZoomRectangle(boolean flag) { + this.fillZoomRectangle = flag; + } + + /** + * Returns the zoom trigger distance. This controls how far the mouse must + * move before a zoom action is triggered. + * + * @return The distance (in Java2D units). + */ + public int getZoomTriggerDistance() { + return this.zoomTriggerDistance; + } + + /** + * Sets the zoom trigger distance. This controls how far the mouse must + * move before a zoom action is triggered. + * + * @param distance the distance (in Java2D units). + */ + public void setZoomTriggerDistance(int distance) { + this.zoomTriggerDistance = distance; + } + + /** + * Returns the flag that controls whether or not a horizontal axis trace + * line is drawn over the plot area at the current mouse location. + * + * @return A boolean. + */ + public boolean getHorizontalAxisTrace() { + return this.horizontalAxisTrace; + } + + /** + * A flag that controls trace lines on the horizontal axis. + * + * @param flag true enables trace lines for the mouse + * pointer on the horizontal axis. + */ + public void setHorizontalAxisTrace(boolean flag) { + this.horizontalAxisTrace = flag; + } + + /** + * Returns the horizontal trace line. + * + * @return The horizontal trace line (possibly null). + */ + protected Line2D getHorizontalTraceLine() { + return this.horizontalTraceLine; + } + + /** + * Sets the horizontal trace line. + * + * @param line the line (null permitted). + */ + protected void setHorizontalTraceLine(Line2D line) { + this.horizontalTraceLine = line; + } + + /** + * Returns the flag that controls whether or not a vertical axis trace + * line is drawn over the plot area at the current mouse location. + * + * @return A boolean. + */ + public boolean getVerticalAxisTrace() { + return this.verticalAxisTrace; + } + + /** + * A flag that controls trace lines on the vertical axis. + * + * @param flag true enables trace lines for the mouse + * pointer on the vertical axis. + */ + public void setVerticalAxisTrace(boolean flag) { + this.verticalAxisTrace = flag; + } + + /** + * Returns the vertical trace line. + * + * @return The vertical trace line (possibly null). + */ + protected Line2D getVerticalTraceLine() { + return this.verticalTraceLine; + } + + /** + * Sets the vertical trace line. + * + * @param line the line (null permitted). + */ + protected void setVerticalTraceLine(Line2D line) { + this.verticalTraceLine = line; + } + + /** + * Returns the default directory for the "save as" option. + * + * @return The default directory (possibly null). + * + * @since 1.0.7 + */ + public File getDefaultDirectoryForSaveAs() { + return this.defaultDirectoryForSaveAs; + } + + /** + * Sets the default directory for the "save as" option. If you set this + * to null, the user's default directory will be used. + * + * @param directory the directory (null permitted). + * + * @since 1.0.7 + */ + public void setDefaultDirectoryForSaveAs(File directory) { + if (directory != null) { + if (!directory.isDirectory()) { + throw new IllegalArgumentException( + "The 'directory' argument is not a directory."); + } + } + this.defaultDirectoryForSaveAs = directory; + } + + /** + * Returns true if file extensions should be enforced, and + * false otherwise. + * + * @return The flag. + * + * @see #setEnforceFileExtensions(boolean) + */ + public boolean isEnforceFileExtensions() { + return this.enforceFileExtensions; + } + + /** + * Sets a flag that controls whether or not file extensions are enforced. + * + * @param enforce the new flag value. + * + * @see #isEnforceFileExtensions() + */ + public void setEnforceFileExtensions(boolean enforce) { + this.enforceFileExtensions = enforce; + } + + /** + * Returns the flag that controls whether or not zoom operations are + * centered around the current anchor point. + * + * @return A boolean. + * + * @since 1.0.7 + * + * @see #setZoomAroundAnchor(boolean) + */ + public boolean getZoomAroundAnchor() { + return this.zoomAroundAnchor; + } + + /** + * Sets the flag that controls whether or not zoom operations are + * centered around the current anchor point. + * + * @param zoomAroundAnchor the new flag value. + * + * @since 1.0.7 + * + * @see #getZoomAroundAnchor() + */ + public void setZoomAroundAnchor(boolean zoomAroundAnchor) { + this.zoomAroundAnchor = zoomAroundAnchor; + } + + /** + * Returns the zoom rectangle fill paint. + * + * @return The zoom rectangle fill paint (never null). + * + * @see #setZoomFillPaint(java.awt.Paint) + * @see #setFillZoomRectangle(boolean) + * + * @since 1.0.13 + */ + public Paint getZoomFillPaint() { + return this.zoomFillPaint; + } + + /** + * Sets the zoom rectangle fill paint. + * + * @param paint the paint (null not permitted). + * + * @see #getZoomFillPaint() + * @see #getFillZoomRectangle() + * + * @since 1.0.13 + */ + public void setZoomFillPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.zoomFillPaint = paint; + } + + /** + * Returns the zoom rectangle outline paint. + * + * @return The zoom rectangle outline paint (never null). + * + * @see #setZoomOutlinePaint(java.awt.Paint) + * @see #setFillZoomRectangle(boolean) + * + * @since 1.0.13 + */ + public Paint getZoomOutlinePaint() { + return this.zoomOutlinePaint; + } + + /** + * Sets the zoom rectangle outline paint. + * + * @param paint the paint (null not permitted). + * + * @see #getZoomOutlinePaint() + * @see #getFillZoomRectangle() + * + * @since 1.0.13 + */ + public void setZoomOutlinePaint(Paint paint) { + this.zoomOutlinePaint = paint; + } + + /** + * The mouse wheel handler. + */ + private MouseWheelHandler mouseWheelHandler; + + /** + * Returns true if the mouse wheel handler is enabled, and + * false otherwise. + * + * @return A boolean. + * + * @since 1.0.13 + */ + public boolean isMouseWheelEnabled() { + return this.mouseWheelHandler != null; + } + + /** + * Enables or disables mouse wheel support for the panel. + * + * @param flag a boolean. + * + * @since 1.0.13 + */ + public void setMouseWheelEnabled(boolean flag) { + if (flag && this.mouseWheelHandler == null) { + this.mouseWheelHandler = new MouseWheelHandler(this); + } + else if (!flag && this.mouseWheelHandler != null) { + this.removeMouseWheelListener(this.mouseWheelHandler); + this.mouseWheelHandler = null; + } + } + + /** + * Add an overlay to the panel. + * + * @param overlay the overlay (null not permitted). + * + * @since 1.0.13 + */ + public void addOverlay(Overlay overlay) { + ParamChecks.nullNotPermitted(overlay, "overlay"); + this.overlays.add(overlay); + overlay.addChangeListener(this); + repaint(); + } + + /** + * Removes an overlay from the panel. + * + * @param overlay the overlay to remove (null not permitted). + * + * @since 1.0.13 + */ + public void removeOverlay(Overlay overlay) { + ParamChecks.nullNotPermitted(overlay, "overlay"); + boolean removed = this.overlays.remove(overlay); + if (removed) { + overlay.removeChangeListener(this); + repaint(); + } + } + + /** + * Handles a change to an overlay by repainting the panel. + * + * @param event the event. + * + * @since 1.0.13 + */ + @Override + public void overlayChanged(OverlayChangeEvent event) { + repaint(); + } + + /** + * Switches the display of tooltips for the panel on or off. Note that + * tooltips can only be displayed if the chart has been configured to + * generate tooltip items. + * + * @param flag true to enable tooltips, false to + * disable tooltips. + */ + public void setDisplayToolTips(boolean flag) { + if (flag) { + ToolTipManager.sharedInstance().registerComponent(this); + } + else { + ToolTipManager.sharedInstance().unregisterComponent(this); + } + } + + /** + * Returns a string for the tooltip. + * + * @param e the mouse event. + * + * @return A tool tip or null if no tooltip is available. + */ + @Override + public String getToolTipText(MouseEvent e) { + String result = null; + if (this.info != null) { + EntityCollection entities = this.info.getEntityCollection(); + if (entities != null) { + Insets insets = getInsets(); + ChartEntity entity = entities.getEntity( + (int) ((e.getX() - insets.left) / this.scaleX), + (int) ((e.getY() - insets.top) / this.scaleY)); + if (entity != null) { + result = entity.getToolTipText(); + } + } + } + return result; + } + + /** + * Translates a Java2D point on the chart to a screen location. + * + * @param java2DPoint the Java2D point. + * + * @return The screen location. + */ + public Point translateJava2DToScreen(Point2D java2DPoint) { + Insets insets = getInsets(); + int x = (int) (java2DPoint.getX() * this.scaleX + insets.left); + int y = (int) (java2DPoint.getY() * this.scaleY + insets.top); + return new Point(x, y); + } + + /** + * Translates a panel (component) location to a Java2D point. + * + * @param screenPoint the screen location (null not + * permitted). + * + * @return The Java2D coordinates. + */ + public Point2D translateScreenToJava2D(Point screenPoint) { + Insets insets = getInsets(); + double x = (screenPoint.getX() - insets.left) / this.scaleX; + double y = (screenPoint.getY() - insets.top) / this.scaleY; + return new Point2D.Double(x, y); + } + + /** + * Applies any scaling that is in effect for the chart drawing to the + * given rectangle. + * + * @param rect the rectangle (null not permitted). + * + * @return A new scaled rectangle. + */ + public Rectangle2D scale(Rectangle2D rect) { + Insets insets = getInsets(); + double x = rect.getX() * getScaleX() + insets.left; + double y = rect.getY() * getScaleY() + insets.top; + double w = rect.getWidth() * getScaleX(); + double h = rect.getHeight() * getScaleY(); + return new Rectangle2D.Double(x, y, w, h); + } + + /** + * Returns the chart entity at a given point. + *

+ * This method will return null if there is (a) no entity at the given + * point, or (b) no entity collection has been generated. + * + * @param viewX the x-coordinate. + * @param viewY the y-coordinate. + * + * @return The chart entity (possibly null). + */ + public ChartEntity getEntityForPoint(int viewX, int viewY) { + + ChartEntity result = null; + if (this.info != null) { + Insets insets = getInsets(); + double x = (viewX - insets.left) / this.scaleX; + double y = (viewY - insets.top) / this.scaleY; + EntityCollection entities = this.info.getEntityCollection(); + result = entities != null ? entities.getEntity(x, y) : null; + } + return result; + + } + + /** + * Returns the flag that controls whether or not the offscreen buffer + * needs to be refreshed. + * + * @return A boolean. + */ + public boolean getRefreshBuffer() { + return this.refreshBuffer; + } + + /** + * Sets the refresh buffer flag. This flag is used to avoid unnecessary + * redrawing of the chart when the offscreen image buffer is used. + * + * @param flag true indicates that the buffer should be + * refreshed. + */ + public void setRefreshBuffer(boolean flag) { + this.refreshBuffer = flag; + } + + /** + * Paints the component by drawing the chart to fill the entire component, + * but allowing for the insets (which will be non-zero if a border has been + * set for this component). To increase performance (at the expense of + * memory), an off-screen buffer image can be used. + * + * @param g the graphics device for drawing on. + */ + @Override + public void paintComponent(Graphics g) { + super.paintComponent(g); + if (this.chart == null) { + return; + } + Graphics2D g2 = (Graphics2D) g.create(); + + // first determine the size of the chart rendering area... + Dimension size = getSize(); + Insets insets = getInsets(); + Rectangle2D available = new Rectangle2D.Double(insets.left, insets.top, + size.getWidth() - insets.left - insets.right, + size.getHeight() - insets.top - insets.bottom); + + // work out if scaling is required... + boolean scale = false; + double drawWidth = available.getWidth(); + double drawHeight = available.getHeight(); + this.scaleX = 1.0; + this.scaleY = 1.0; + + if (drawWidth < this.minimumDrawWidth) { + this.scaleX = drawWidth / this.minimumDrawWidth; + drawWidth = this.minimumDrawWidth; + scale = true; + } + else if (drawWidth > this.maximumDrawWidth) { + this.scaleX = drawWidth / this.maximumDrawWidth; + drawWidth = this.maximumDrawWidth; + scale = true; + } + + if (drawHeight < this.minimumDrawHeight) { + this.scaleY = drawHeight / this.minimumDrawHeight; + drawHeight = this.minimumDrawHeight; + scale = true; + } + else if (drawHeight > this.maximumDrawHeight) { + this.scaleY = drawHeight / this.maximumDrawHeight; + drawHeight = this.maximumDrawHeight; + scale = true; + } + + Rectangle2D chartArea = new Rectangle2D.Double(0.0, 0.0, drawWidth, + drawHeight); + + // are we using the chart buffer? + if (this.useBuffer) { + + // do we need to resize the buffer? + if ((this.chartBuffer == null) + || (this.chartBufferWidth != available.getWidth()) + || (this.chartBufferHeight != available.getHeight())) { + this.chartBufferWidth = (int) available.getWidth(); + this.chartBufferHeight = (int) available.getHeight(); + GraphicsConfiguration gc = g2.getDeviceConfiguration(); + this.chartBuffer = gc.createCompatibleImage( + this.chartBufferWidth, this.chartBufferHeight, + Transparency.TRANSLUCENT); + this.refreshBuffer = true; + } + + // do we need to redraw the buffer? + if (this.refreshBuffer) { + + this.refreshBuffer = false; // clear the flag + + Rectangle2D bufferArea = new Rectangle2D.Double( + 0, 0, this.chartBufferWidth, this.chartBufferHeight); + + // make the background of the buffer clear and transparent + Graphics2D bufferG2 = (Graphics2D) + this.chartBuffer.getGraphics(); + Composite savedComposite = bufferG2.getComposite(); + bufferG2.setComposite(AlphaComposite.getInstance( + AlphaComposite.CLEAR, 0.0f)); + Rectangle r = new Rectangle(0, 0, this.chartBufferWidth, + this.chartBufferHeight); + bufferG2.fill(r); + bufferG2.setComposite(savedComposite); + + if (scale) { + AffineTransform saved = bufferG2.getTransform(); + AffineTransform st = AffineTransform.getScaleInstance( + this.scaleX, this.scaleY); + bufferG2.transform(st); + this.chart.draw(bufferG2, chartArea, this.anchor, + this.info); + bufferG2.setTransform(saved); + } + else { + this.chart.draw(bufferG2, bufferArea, this.anchor, + this.info); + } + + } + + // zap the buffer onto the panel... + g2.drawImage(this.chartBuffer, insets.left, insets.top, this); + + } + + // or redrawing the chart every time... + else { + + AffineTransform saved = g2.getTransform(); + g2.translate(insets.left, insets.top); + if (scale) { + AffineTransform st = AffineTransform.getScaleInstance( + this.scaleX, this.scaleY); + g2.transform(st); + } + this.chart.draw(g2, chartArea, this.anchor, this.info); + g2.setTransform(saved); + + } + + Iterator iterator = this.overlays.iterator(); + while (iterator.hasNext()) { + Overlay overlay = (Overlay) iterator.next(); + overlay.paintOverlay(g2, this); + } + + // redraw the zoom rectangle (if present) - if useBuffer is false, + // we use XOR so we can XOR the rectangle away again without redrawing + // the chart + drawZoomRectangle(g2, !this.useBuffer); + + g2.dispose(); + + this.anchor = null; + this.verticalTraceLine = null; + this.horizontalTraceLine = null; + + } + + /** + * Receives notification of changes to the chart, and redraws the chart. + * + * @param event details of the chart change event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.refreshBuffer = true; + Plot plot = this.chart.getPlot(); + if (plot instanceof Zoomable) { + Zoomable z = (Zoomable) plot; + this.orientation = z.getOrientation(); + } + repaint(); + } + + /** + * Receives notification of a chart progress event. + * + * @param event the event. + */ + @Override + public void chartProgress(ChartProgressEvent event) { + // does nothing - override if necessary + } + + /** + * Handles action events generated by the popup menu. + * + * @param event the event. + */ + @Override + public void actionPerformed(ActionEvent event) { + + String command = event.getActionCommand(); + + // many of the zoom methods need a screen location - all we have is + // the zoomPoint, but it might be null. Here we grab the x and y + // coordinates, or use defaults... + double screenX = -1.0; + double screenY = -1.0; + if (this.zoomPoint != null) { + screenX = this.zoomPoint.getX(); + screenY = this.zoomPoint.getY(); + } + + if (command.equals(PROPERTIES_COMMAND)) { + doEditChartProperties(); + } + else if (command.equals(COPY_COMMAND)) { + doCopy(); + } + else if (command.equals(SAVE_AS_PNG_COMMAND)) { + try { + doSaveAs(); + } + catch (IOException e) { + JOptionPane.showMessageDialog(this, "I/O error occurred.", + "Save As PNG", JOptionPane.WARNING_MESSAGE); + } + } + else if (command.equals(SAVE_AS_SVG_COMMAND)) { + try { + saveAsSVG(null); + } catch (IOException e) { + JOptionPane.showMessageDialog(this, "I/O error occurred.", + "Save As SVG", JOptionPane.WARNING_MESSAGE); + } + } + else if (command.equals(SAVE_AS_PDF_COMMAND)) { + saveAsPDF(null); + } + else if (command.equals(PRINT_COMMAND)) { + createChartPrintJob(); + } + else if (command.equals(ZOOM_IN_BOTH_COMMAND)) { + zoomInBoth(screenX, screenY); + } + else if (command.equals(ZOOM_IN_DOMAIN_COMMAND)) { + zoomInDomain(screenX, screenY); + } + else if (command.equals(ZOOM_IN_RANGE_COMMAND)) { + zoomInRange(screenX, screenY); + } + else if (command.equals(ZOOM_OUT_BOTH_COMMAND)) { + zoomOutBoth(screenX, screenY); + } + else if (command.equals(ZOOM_OUT_DOMAIN_COMMAND)) { + zoomOutDomain(screenX, screenY); + } + else if (command.equals(ZOOM_OUT_RANGE_COMMAND)) { + zoomOutRange(screenX, screenY); + } + else if (command.equals(ZOOM_RESET_BOTH_COMMAND)) { + restoreAutoBounds(); + } + else if (command.equals(ZOOM_RESET_DOMAIN_COMMAND)) { + restoreAutoDomainBounds(); + } + else if (command.equals(ZOOM_RESET_RANGE_COMMAND)) { + restoreAutoRangeBounds(); + } + + } + + /** + * Handles a 'mouse entered' event. This method changes the tooltip delays + * of ToolTipManager.sharedInstance() to the possibly different values set + * for this chart panel. + * + * @param e the mouse event. + */ + @Override + public void mouseEntered(MouseEvent e) { + if (!this.ownToolTipDelaysActive) { + ToolTipManager ttm = ToolTipManager.sharedInstance(); + + this.originalToolTipInitialDelay = ttm.getInitialDelay(); + ttm.setInitialDelay(this.ownToolTipInitialDelay); + + this.originalToolTipReshowDelay = ttm.getReshowDelay(); + ttm.setReshowDelay(this.ownToolTipReshowDelay); + + this.originalToolTipDismissDelay = ttm.getDismissDelay(); + ttm.setDismissDelay(this.ownToolTipDismissDelay); + + this.ownToolTipDelaysActive = true; + } + } + + /** + * Handles a 'mouse exited' event. This method resets the tooltip delays of + * ToolTipManager.sharedInstance() to their + * original values in effect before mouseEntered() + * + * @param e the mouse event. + */ + @Override + public void mouseExited(MouseEvent e) { + if (this.ownToolTipDelaysActive) { + // restore original tooltip dealys + ToolTipManager ttm = ToolTipManager.sharedInstance(); + ttm.setInitialDelay(this.originalToolTipInitialDelay); + ttm.setReshowDelay(this.originalToolTipReshowDelay); + ttm.setDismissDelay(this.originalToolTipDismissDelay); + this.ownToolTipDelaysActive = false; + } + } + + /** + * Handles a 'mouse pressed' event. + *

+ * This event is the popup trigger on Unix/Linux. For Windows, the popup + * trigger is the 'mouse released' event. + * + * @param e The mouse event. + */ + @Override + public void mousePressed(MouseEvent e) { + if (this.chart == null) { + return; + } + Plot plot = this.chart.getPlot(); + int mods = e.getModifiers(); + if ((mods & this.panMask) == this.panMask) { + // can we pan this plot? + if (plot instanceof Pannable) { + Pannable pannable = (Pannable) plot; + if (pannable.isDomainPannable() || pannable.isRangePannable()) { + Rectangle2D screenDataArea = getScreenDataArea(e.getX(), + e.getY()); + if (screenDataArea != null && screenDataArea.contains( + e.getPoint())) { + this.panW = screenDataArea.getWidth(); + this.panH = screenDataArea.getHeight(); + this.panLast = e.getPoint(); + setCursor(Cursor.getPredefinedCursor( + Cursor.MOVE_CURSOR)); + } + } + // the actual panning occurs later in the mouseDragged() + // method + } + } + else if (this.zoomRectangle == null) { + Rectangle2D screenDataArea = getScreenDataArea(e.getX(), e.getY()); + if (screenDataArea != null) { + this.zoomPoint = getPointInRectangle(e.getX(), e.getY(), + screenDataArea); + } + else { + this.zoomPoint = null; + } + if (e.isPopupTrigger()) { + if (this.popup != null) { + displayPopupMenu(e.getX(), e.getY()); + } + } + } + } + + /** + * Returns a point based on (x, y) but constrained to be within the bounds + * of the given rectangle. This method could be moved to JCommon. + * + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param area the rectangle (null not permitted). + * + * @return A point within the rectangle. + */ + private Point2D getPointInRectangle(int x, int y, Rectangle2D area) { + double xx = Math.max(area.getMinX(), Math.min(x, area.getMaxX())); + double yy = Math.max(area.getMinY(), Math.min(y, area.getMaxY())); + return new Point2D.Double(xx, yy); + } + + /** + * Handles a 'mouse dragged' event. + * + * @param e the mouse event. + */ + @Override + public void mouseDragged(MouseEvent e) { + + // if the popup menu has already been triggered, then ignore dragging... + if (this.popup != null && this.popup.isShowing()) { + return; + } + + // handle panning if we have a start point + if (this.panLast != null) { + double dx = e.getX() - this.panLast.getX(); + double dy = e.getY() - this.panLast.getY(); + if (dx == 0.0 && dy == 0.0) { + return; + } + double wPercent = -dx / this.panW; + double hPercent = dy / this.panH; + boolean old = this.chart.getPlot().isNotify(); + this.chart.getPlot().setNotify(false); + Pannable p = (Pannable) this.chart.getPlot(); + if (p.getOrientation() == PlotOrientation.VERTICAL) { + p.panDomainAxes(wPercent, this.info.getPlotInfo(), + this.panLast); + p.panRangeAxes(hPercent, this.info.getPlotInfo(), + this.panLast); + } + else { + p.panDomainAxes(hPercent, this.info.getPlotInfo(), + this.panLast); + p.panRangeAxes(wPercent, this.info.getPlotInfo(), + this.panLast); + } + this.panLast = e.getPoint(); + this.chart.getPlot().setNotify(old); + return; + } + + // if no initial zoom point was set, ignore dragging... + if (this.zoomPoint == null) { + return; + } + Graphics2D g2 = (Graphics2D) getGraphics(); + + // erase the previous zoom rectangle (if any). We only need to do + // this is we are using XOR mode, which we do when we're not using + // the buffer (if there is a buffer, then at the end of this method we + // just trigger a repaint) + if (!this.useBuffer) { + drawZoomRectangle(g2, true); + } + + boolean hZoom, vZoom; + if (this.orientation == PlotOrientation.HORIZONTAL) { + hZoom = this.rangeZoomable; + vZoom = this.domainZoomable; + } + else { + hZoom = this.domainZoomable; + vZoom = this.rangeZoomable; + } + Rectangle2D scaledDataArea = getScreenDataArea( + (int) this.zoomPoint.getX(), (int) this.zoomPoint.getY()); + if (hZoom && vZoom) { + // selected rectangle shouldn't extend outside the data area... + double xmax = Math.min(e.getX(), scaledDataArea.getMaxX()); + double ymax = Math.min(e.getY(), scaledDataArea.getMaxY()); + this.zoomRectangle = new Rectangle2D.Double( + this.zoomPoint.getX(), this.zoomPoint.getY(), + xmax - this.zoomPoint.getX(), ymax - this.zoomPoint.getY()); + } + else if (hZoom) { + double xmax = Math.min(e.getX(), scaledDataArea.getMaxX()); + this.zoomRectangle = new Rectangle2D.Double( + this.zoomPoint.getX(), scaledDataArea.getMinY(), + xmax - this.zoomPoint.getX(), scaledDataArea.getHeight()); + } + else if (vZoom) { + double ymax = Math.min(e.getY(), scaledDataArea.getMaxY()); + this.zoomRectangle = new Rectangle2D.Double( + scaledDataArea.getMinX(), this.zoomPoint.getY(), + scaledDataArea.getWidth(), ymax - this.zoomPoint.getY()); + } + + // Draw the new zoom rectangle... + if (this.useBuffer) { + repaint(); + } + else { + // with no buffer, we use XOR to draw the rectangle "over" the + // chart... + drawZoomRectangle(g2, true); + } + g2.dispose(); + + } + + /** + * Handles a 'mouse released' event. On Windows, we need to check if this + * is a popup trigger, but only if we haven't already been tracking a zoom + * rectangle. + * + * @param e information about the event. + */ + @Override + public void mouseReleased(MouseEvent e) { + + // if we've been panning, we need to reset now that the mouse is + // released... + if (this.panLast != null) { + this.panLast = null; + setCursor(Cursor.getDefaultCursor()); + } + + else if (this.zoomRectangle != null) { + boolean hZoom, vZoom; + if (this.orientation == PlotOrientation.HORIZONTAL) { + hZoom = this.rangeZoomable; + vZoom = this.domainZoomable; + } + else { + hZoom = this.domainZoomable; + vZoom = this.rangeZoomable; + } + + boolean zoomTrigger1 = hZoom && Math.abs(e.getX() + - this.zoomPoint.getX()) >= this.zoomTriggerDistance; + boolean zoomTrigger2 = vZoom && Math.abs(e.getY() + - this.zoomPoint.getY()) >= this.zoomTriggerDistance; + if (zoomTrigger1 || zoomTrigger2) { + if ((hZoom && (e.getX() < this.zoomPoint.getX())) + || (vZoom && (e.getY() < this.zoomPoint.getY()))) { + restoreAutoBounds(); + } + else { + double x, y, w, h; + Rectangle2D screenDataArea = getScreenDataArea( + (int) this.zoomPoint.getX(), + (int) this.zoomPoint.getY()); + double maxX = screenDataArea.getMaxX(); + double maxY = screenDataArea.getMaxY(); + // for mouseReleased event, (horizontalZoom || verticalZoom) + // will be true, so we can just test for either being false; + // otherwise both are true + if (!vZoom) { + x = this.zoomPoint.getX(); + y = screenDataArea.getMinY(); + w = Math.min(this.zoomRectangle.getWidth(), + maxX - this.zoomPoint.getX()); + h = screenDataArea.getHeight(); + } + else if (!hZoom) { + x = screenDataArea.getMinX(); + y = this.zoomPoint.getY(); + w = screenDataArea.getWidth(); + h = Math.min(this.zoomRectangle.getHeight(), + maxY - this.zoomPoint.getY()); + } + else { + x = this.zoomPoint.getX(); + y = this.zoomPoint.getY(); + w = Math.min(this.zoomRectangle.getWidth(), + maxX - this.zoomPoint.getX()); + h = Math.min(this.zoomRectangle.getHeight(), + maxY - this.zoomPoint.getY()); + } + Rectangle2D zoomArea = new Rectangle2D.Double(x, y, w, h); + zoom(zoomArea); + } + this.zoomPoint = null; + this.zoomRectangle = null; + } + else { + // erase the zoom rectangle + Graphics2D g2 = (Graphics2D) getGraphics(); + if (this.useBuffer) { + repaint(); + } + else { + drawZoomRectangle(g2, true); + } + g2.dispose(); + this.zoomPoint = null; + this.zoomRectangle = null; + } + + } + + else if (e.isPopupTrigger()) { + if (this.popup != null) { + displayPopupMenu(e.getX(), e.getY()); + } + } + + } + + /** + * Receives notification of mouse clicks on the panel. These are + * translated and passed on to any registered {@link ChartMouseListener}s. + * + * @param event Information about the mouse event. + */ + @Override + public void mouseClicked(MouseEvent event) { + + Insets insets = getInsets(); + int x = (int) ((event.getX() - insets.left) / this.scaleX); + int y = (int) ((event.getY() - insets.top) / this.scaleY); + + this.anchor = new Point2D.Double(x, y); + if (this.chart == null) { + return; + } + this.chart.setNotify(true); // force a redraw + // new entity code... + Object[] listeners = this.chartMouseListeners.getListeners( + ChartMouseListener.class); + if (listeners.length == 0) { + return; + } + + ChartEntity entity = null; + if (this.info != null) { + EntityCollection entities = this.info.getEntityCollection(); + if (entities != null) { + entity = entities.getEntity(x, y); + } + } + ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), event, + entity); + for (int i = listeners.length - 1; i >= 0; i -= 1) { + ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent); + } + + } + + /** + * Implementation of the MouseMotionListener's method. + * + * @param e the event. + */ + @Override + public void mouseMoved(MouseEvent e) { + Graphics2D g2 = (Graphics2D) getGraphics(); + if (this.horizontalAxisTrace) { + drawHorizontalAxisTrace(g2, e.getX()); + } + if (this.verticalAxisTrace) { + drawVerticalAxisTrace(g2, e.getY()); + } + g2.dispose(); + + Object[] listeners = this.chartMouseListeners.getListeners( + ChartMouseListener.class); + if (listeners.length == 0) { + return; + } + Insets insets = getInsets(); + int x = (int) ((e.getX() - insets.left) / this.scaleX); + int y = (int) ((e.getY() - insets.top) / this.scaleY); + + ChartEntity entity = null; + if (this.info != null) { + EntityCollection entities = this.info.getEntityCollection(); + if (entities != null) { + entity = entities.getEntity(x, y); + } + } + + // we can only generate events if the panel's chart is not null + // (see bug report 1556951) + if (this.chart != null) { + ChartMouseEvent event = new ChartMouseEvent(getChart(), e, entity); + for (int i = listeners.length - 1; i >= 0; i -= 1) { + ((ChartMouseListener) listeners[i]).chartMouseMoved(event); + } + } + + } + + /** + * Zooms in on an anchor point (specified in screen coordinate space). + * + * @param x the x value (in screen coordinates). + * @param y the y value (in screen coordinates). + */ + public void zoomInBoth(double x, double y) { + Plot plot = this.chart.getPlot(); + if (plot == null) { + return; + } + // here we tweak the notify flag on the plot so that only + // one notification happens even though we update multiple + // axes... + boolean savedNotify = plot.isNotify(); + plot.setNotify(false); + zoomInDomain(x, y); + zoomInRange(x, y); + plot.setNotify(savedNotify); + } + + /** + * Decreases the length of the domain axis, centered about the given + * coordinate on the screen. The length of the domain axis is reduced + * by the value of {@link #getZoomInFactor()}. + * + * @param x the x coordinate (in screen coordinates). + * @param y the y-coordinate (in screen coordinates). + */ + public void zoomInDomain(double x, double y) { + Plot plot = this.chart.getPlot(); + if (plot instanceof Zoomable) { + // here we tweak the notify flag on the plot so that only + // one notification happens even though we update multiple + // axes... + boolean savedNotify = plot.isNotify(); + plot.setNotify(false); + Zoomable z = (Zoomable) plot; + z.zoomDomainAxes(this.zoomInFactor, this.info.getPlotInfo(), + translateScreenToJava2D(new Point((int) x, (int) y)), + this.zoomAroundAnchor); + plot.setNotify(savedNotify); + } + } + + /** + * Decreases the length of the range axis, centered about the given + * coordinate on the screen. The length of the range axis is reduced by + * the value of {@link #getZoomInFactor()}. + * + * @param x the x-coordinate (in screen coordinates). + * @param y the y coordinate (in screen coordinates). + */ + public void zoomInRange(double x, double y) { + Plot plot = this.chart.getPlot(); + if (plot instanceof Zoomable) { + // here we tweak the notify flag on the plot so that only + // one notification happens even though we update multiple + // axes... + boolean savedNotify = plot.isNotify(); + plot.setNotify(false); + Zoomable z = (Zoomable) plot; + z.zoomRangeAxes(this.zoomInFactor, this.info.getPlotInfo(), + translateScreenToJava2D(new Point((int) x, (int) y)), + this.zoomAroundAnchor); + plot.setNotify(savedNotify); + } + } + + /** + * Zooms out on an anchor point (specified in screen coordinate space). + * + * @param x the x value (in screen coordinates). + * @param y the y value (in screen coordinates). + */ + public void zoomOutBoth(double x, double y) { + Plot plot = this.chart.getPlot(); + if (plot == null) { + return; + } + // here we tweak the notify flag on the plot so that only + // one notification happens even though we update multiple + // axes... + boolean savedNotify = plot.isNotify(); + plot.setNotify(false); + zoomOutDomain(x, y); + zoomOutRange(x, y); + plot.setNotify(savedNotify); + } + + /** + * Increases the length of the domain axis, centered about the given + * coordinate on the screen. The length of the domain axis is increased + * by the value of {@link #getZoomOutFactor()}. + * + * @param x the x coordinate (in screen coordinates). + * @param y the y-coordinate (in screen coordinates). + */ + public void zoomOutDomain(double x, double y) { + Plot plot = this.chart.getPlot(); + if (plot instanceof Zoomable) { + // here we tweak the notify flag on the plot so that only + // one notification happens even though we update multiple + // axes... + boolean savedNotify = plot.isNotify(); + plot.setNotify(false); + Zoomable z = (Zoomable) plot; + z.zoomDomainAxes(this.zoomOutFactor, this.info.getPlotInfo(), + translateScreenToJava2D(new Point((int) x, (int) y)), + this.zoomAroundAnchor); + plot.setNotify(savedNotify); + } + } + + /** + * Increases the length the range axis, centered about the given + * coordinate on the screen. The length of the range axis is increased + * by the value of {@link #getZoomOutFactor()}. + * + * @param x the x coordinate (in screen coordinates). + * @param y the y-coordinate (in screen coordinates). + */ + public void zoomOutRange(double x, double y) { + Plot plot = this.chart.getPlot(); + if (plot instanceof Zoomable) { + // here we tweak the notify flag on the plot so that only + // one notification happens even though we update multiple + // axes... + boolean savedNotify = plot.isNotify(); + plot.setNotify(false); + Zoomable z = (Zoomable) plot; + z.zoomRangeAxes(this.zoomOutFactor, this.info.getPlotInfo(), + translateScreenToJava2D(new Point((int) x, (int) y)), + this.zoomAroundAnchor); + plot.setNotify(savedNotify); + } + } + + /** + * Zooms in on a selected region. + * + * @param selection the selected region. + */ + public void zoom(Rectangle2D selection) { + + // get the origin of the zoom selection in the Java2D space used for + // drawing the chart (that is, before any scaling to fit the panel) + Point2D selectOrigin = translateScreenToJava2D(new Point( + (int) Math.ceil(selection.getX()), + (int) Math.ceil(selection.getY()))); + PlotRenderingInfo plotInfo = this.info.getPlotInfo(); + Rectangle2D scaledDataArea = getScreenDataArea( + (int) selection.getCenterX(), (int) selection.getCenterY()); + if ((selection.getHeight() > 0) && (selection.getWidth() > 0)) { + + double hLower = (selection.getMinX() - scaledDataArea.getMinX()) + / scaledDataArea.getWidth(); + double hUpper = (selection.getMaxX() - scaledDataArea.getMinX()) + / scaledDataArea.getWidth(); + double vLower = (scaledDataArea.getMaxY() - selection.getMaxY()) + / scaledDataArea.getHeight(); + double vUpper = (scaledDataArea.getMaxY() - selection.getMinY()) + / scaledDataArea.getHeight(); + + Plot p = this.chart.getPlot(); + if (p instanceof Zoomable) { + // here we tweak the notify flag on the plot so that only + // one notification happens even though we update multiple + // axes... + boolean savedNotify = p.isNotify(); + p.setNotify(false); + Zoomable z = (Zoomable) p; + if (z.getOrientation() == PlotOrientation.HORIZONTAL) { + z.zoomDomainAxes(vLower, vUpper, plotInfo, selectOrigin); + z.zoomRangeAxes(hLower, hUpper, plotInfo, selectOrigin); + } + else { + z.zoomDomainAxes(hLower, hUpper, plotInfo, selectOrigin); + z.zoomRangeAxes(vLower, vUpper, plotInfo, selectOrigin); + } + p.setNotify(savedNotify); + } + + } + + } + + /** + * Restores the auto-range calculation on both axes. + */ + public void restoreAutoBounds() { + Plot plot = this.chart.getPlot(); + if (plot == null) { + return; + } + // here we tweak the notify flag on the plot so that only + // one notification happens even though we update multiple + // axes... + boolean savedNotify = plot.isNotify(); + plot.setNotify(false); + restoreAutoDomainBounds(); + restoreAutoRangeBounds(); + plot.setNotify(savedNotify); + } + + /** + * Restores the auto-range calculation on the domain axis. + */ + public void restoreAutoDomainBounds() { + Plot plot = this.chart.getPlot(); + if (plot instanceof Zoomable) { + Zoomable z = (Zoomable) plot; + // here we tweak the notify flag on the plot so that only + // one notification happens even though we update multiple + // axes... + boolean savedNotify = plot.isNotify(); + plot.setNotify(false); + // we need to guard against this.zoomPoint being null + Point2D zp = (this.zoomPoint != null + ? this.zoomPoint : new Point()); + z.zoomDomainAxes(0.0, this.info.getPlotInfo(), zp); + plot.setNotify(savedNotify); + } + } + + /** + * Restores the auto-range calculation on the range axis. + */ + public void restoreAutoRangeBounds() { + Plot plot = this.chart.getPlot(); + if (plot instanceof Zoomable) { + Zoomable z = (Zoomable) plot; + // here we tweak the notify flag on the plot so that only + // one notification happens even though we update multiple + // axes... + boolean savedNotify = plot.isNotify(); + plot.setNotify(false); + // we need to guard against this.zoomPoint being null + Point2D zp = (this.zoomPoint != null + ? this.zoomPoint : new Point()); + z.zoomRangeAxes(0.0, this.info.getPlotInfo(), zp); + plot.setNotify(savedNotify); + } + } + + /** + * Returns the data area for the chart (the area inside the axes) with the + * current scaling applied (that is, the area as it appears on screen). + * + * @return The scaled data area. + */ + public Rectangle2D getScreenDataArea() { + Rectangle2D dataArea = this.info.getPlotInfo().getDataArea(); + Insets insets = getInsets(); + double x = dataArea.getX() * this.scaleX + insets.left; + double y = dataArea.getY() * this.scaleY + insets.top; + double w = dataArea.getWidth() * this.scaleX; + double h = dataArea.getHeight() * this.scaleY; + return new Rectangle2D.Double(x, y, w, h); + } + + /** + * Returns the data area (the area inside the axes) for the plot or subplot, + * with the current scaling applied. + * + * @param x the x-coordinate (for subplot selection). + * @param y the y-coordinate (for subplot selection). + * + * @return The scaled data area. + */ + public Rectangle2D getScreenDataArea(int x, int y) { + PlotRenderingInfo plotInfo = this.info.getPlotInfo(); + Rectangle2D result; + if (plotInfo.getSubplotCount() == 0) { + result = getScreenDataArea(); + } + else { + // get the origin of the zoom selection in the Java2D space used for + // drawing the chart (that is, before any scaling to fit the panel) + Point2D selectOrigin = translateScreenToJava2D(new Point(x, y)); + int subplotIndex = plotInfo.getSubplotIndex(selectOrigin); + if (subplotIndex == -1) { + return null; + } + result = scale(plotInfo.getSubplotInfo(subplotIndex).getDataArea()); + } + return result; + } + + /** + * Returns the initial tooltip delay value used inside this chart panel. + * + * @return An integer representing the initial delay value, in milliseconds. + * + * @see javax.swing.ToolTipManager#getInitialDelay() + */ + public int getInitialDelay() { + return this.ownToolTipInitialDelay; + } + + /** + * Returns the reshow tooltip delay value used inside this chart panel. + * + * @return An integer representing the reshow delay value, in milliseconds. + * + * @see javax.swing.ToolTipManager#getReshowDelay() + */ + public int getReshowDelay() { + return this.ownToolTipReshowDelay; + } + + /** + * Returns the dismissal tooltip delay value used inside this chart panel. + * + * @return An integer representing the dismissal delay value, in + * milliseconds. + * + * @see javax.swing.ToolTipManager#getDismissDelay() + */ + public int getDismissDelay() { + return this.ownToolTipDismissDelay; + } + + /** + * Specifies the initial delay value for this chart panel. + * + * @param delay the number of milliseconds to delay (after the cursor has + * paused) before displaying. + * + * @see javax.swing.ToolTipManager#setInitialDelay(int) + */ + public void setInitialDelay(int delay) { + this.ownToolTipInitialDelay = delay; + } + + /** + * Specifies the amount of time before the user has to wait initialDelay + * milliseconds before a tooltip will be shown. + * + * @param delay time in milliseconds + * + * @see javax.swing.ToolTipManager#setReshowDelay(int) + */ + public void setReshowDelay(int delay) { + this.ownToolTipReshowDelay = delay; + } + + /** + * Specifies the dismissal delay value for this chart panel. + * + * @param delay the number of milliseconds to delay before taking away the + * tooltip + * + * @see javax.swing.ToolTipManager#setDismissDelay(int) + */ + public void setDismissDelay(int delay) { + this.ownToolTipDismissDelay = delay; + } + + /** + * Returns the zoom in factor. + * + * @return The zoom in factor. + * + * @see #setZoomInFactor(double) + */ + public double getZoomInFactor() { + return this.zoomInFactor; + } + + /** + * Sets the zoom in factor. + * + * @param factor the factor. + * + * @see #getZoomInFactor() + */ + public void setZoomInFactor(double factor) { + this.zoomInFactor = factor; + } + + /** + * Returns the zoom out factor. + * + * @return The zoom out factor. + * + * @see #setZoomOutFactor(double) + */ + public double getZoomOutFactor() { + return this.zoomOutFactor; + } + + /** + * Sets the zoom out factor. + * + * @param factor the factor. + * + * @see #getZoomOutFactor() + */ + public void setZoomOutFactor(double factor) { + this.zoomOutFactor = factor; + } + + /** + * Draws zoom rectangle (if present). + * The drawing is performed in XOR mode, therefore + * when this method is called twice in a row, + * the second call will completely restore the state + * of the canvas. + * + * @param g2 the graphics device. + * @param xor use XOR for drawing? + */ + private void drawZoomRectangle(Graphics2D g2, boolean xor) { + if (this.zoomRectangle != null) { + if (xor) { + // Set XOR mode to draw the zoom rectangle + g2.setXORMode(Color.gray); + } + if (this.fillZoomRectangle) { + g2.setPaint(this.zoomFillPaint); + g2.fill(this.zoomRectangle); + } + else { + g2.setPaint(this.zoomOutlinePaint); + g2.draw(this.zoomRectangle); + } + if (xor) { + // Reset to the default 'overwrite' mode + g2.setPaintMode(); + } + } + } + + /** + * Draws a vertical line used to trace the mouse position to the horizontal + * axis. + * + * @param g2 the graphics device. + * @param x the x-coordinate of the trace line. + */ + private void drawHorizontalAxisTrace(Graphics2D g2, int x) { + + Rectangle2D dataArea = getScreenDataArea(); + + g2.setXORMode(Color.orange); + if (((int) dataArea.getMinX() < x) && (x < (int) dataArea.getMaxX())) { + + if (this.verticalTraceLine != null) { + g2.draw(this.verticalTraceLine); + this.verticalTraceLine.setLine(x, (int) dataArea.getMinY(), x, + (int) dataArea.getMaxY()); + } + else { + this.verticalTraceLine = new Line2D.Float(x, + (int) dataArea.getMinY(), x, (int) dataArea.getMaxY()); + } + g2.draw(this.verticalTraceLine); + } + + // Reset to the default 'overwrite' mode + g2.setPaintMode(); + } + + /** + * Draws a horizontal line used to trace the mouse position to the vertical + * axis. + * + * @param g2 the graphics device. + * @param y the y-coordinate of the trace line. + */ + private void drawVerticalAxisTrace(Graphics2D g2, int y) { + + Rectangle2D dataArea = getScreenDataArea(); + + g2.setXORMode(Color.orange); + if (((int) dataArea.getMinY() < y) && (y < (int) dataArea.getMaxY())) { + + if (this.horizontalTraceLine != null) { + g2.draw(this.horizontalTraceLine); + this.horizontalTraceLine.setLine((int) dataArea.getMinX(), y, + (int) dataArea.getMaxX(), y); + } + else { + this.horizontalTraceLine = new Line2D.Float( + (int) dataArea.getMinX(), y, (int) dataArea.getMaxX(), + y); + } + g2.draw(this.horizontalTraceLine); + } + + // Reset to the default 'overwrite' mode + g2.setPaintMode(); + } + + /** + * Displays a dialog that allows the user to edit the properties for the + * current chart. + * + * @since 1.0.3 + */ + public void doEditChartProperties() { + + ChartEditor editor = ChartEditorManager.getChartEditor(this.chart); + int result = JOptionPane.showConfirmDialog(this, editor, + localizationResources.getString("Chart_Properties"), + JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); + if (result == JOptionPane.OK_OPTION) { + editor.updateChart(this.chart); + } + + } + + /** + * Copies the current chart to the system clipboard. + * + * @since 1.0.13 + */ + public void doCopy() { + Clipboard systemClipboard + = Toolkit.getDefaultToolkit().getSystemClipboard(); + Insets insets = getInsets(); + int w = getWidth() - insets.left - insets.right; + int h = getHeight() - insets.top - insets.bottom; + ChartTransferable selection = new ChartTransferable(this.chart, w, h, + getMinimumDrawWidth(), getMinimumDrawHeight(), + getMaximumDrawWidth(), getMaximumDrawHeight(), true); + systemClipboard.setContents(selection, null); + } + + /** + * Opens a file chooser and gives the user an opportunity to save the chart + * in PNG format. + * + * @throws IOException if there is an I/O error. + */ + public void doSaveAs() throws IOException { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(this.defaultDirectoryForSaveAs); + FileNameExtensionFilter filter = new FileNameExtensionFilter( + localizationResources.getString("PNG_Image_Files"), "png"); + fileChooser.addChoosableFileFilter(filter); + fileChooser.setFileFilter(filter); + + int option = fileChooser.showSaveDialog(this); + if (option == JFileChooser.APPROVE_OPTION) { + String filename = fileChooser.getSelectedFile().getPath(); + if (isEnforceFileExtensions()) { + if (!filename.endsWith(".png")) { + filename = filename + ".png"; + } + } + ChartUtilities.saveChartAsPNG(new File(filename), this.chart, + getWidth(), getHeight()); + } + } + + /** + * Saves the chart in SVG format (a filechooser will be displayed so that + * the user can specify the filename). Note that this method only works + * if the JFreeSVG library is on the classpath...if this library is not + * present, the method will fail. + */ + private void saveAsSVG(File f) throws IOException { + File file = f; + if (file == null) { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(this.defaultDirectoryForSaveAs); + FileNameExtensionFilter filter = new FileNameExtensionFilter( + localizationResources.getString("SVG_Files"), "svg"); + fileChooser.addChoosableFileFilter(filter); + fileChooser.setFileFilter(filter); + + int option = fileChooser.showSaveDialog(this); + if (option == JFileChooser.APPROVE_OPTION) { + String filename = fileChooser.getSelectedFile().getPath(); + if (isEnforceFileExtensions()) { + if (!filename.endsWith(".svg")) { + filename = filename + ".svg"; + } + } + file = new File(filename); + if (file.exists()) { + String fileExists = localizationResources.getString( + "FILE_EXISTS_CONFIRM_OVERWRITE"); + int response = JOptionPane.showConfirmDialog(this, + fileExists, "Save As SVG", + JOptionPane.OK_CANCEL_OPTION); + if (response == JOptionPane.CANCEL_OPTION) { + file = null; + } + } + } + } + + if (file != null) { + // use reflection to get the SVG string + String svg = generateSVG(getWidth(), getHeight()); + BufferedWriter writer = null; + try { + writer = new BufferedWriter(new FileWriter(file)); + writer.write("\n"); + writer.write(svg + "\n"); + writer.flush(); + } finally { + try { + if (writer != null) { + writer.close(); + } + } catch (IOException ex) { + throw new RuntimeException(ex); + } + } + + } + } + + /** + * Generates a string containing a rendering of the chart in SVG format. + * This feature is only supported if the JFreeSVG library is included on + * the classpath. + * + * @return A string containing an SVG element for the current chart, or + * null if there is a problem with the method invocation + * by reflection. + */ + private String generateSVG(int width, int height) { + Graphics2D g2 = createSVGGraphics2D(width, height); + if (g2 == null) { + throw new IllegalStateException("JFreeSVG library is not present."); + } + // we suppress shadow generation, because SVG is a vector format and + // the shadow effect is applied via bitmap effects... + g2.setRenderingHint(JFreeChart.KEY_SUPPRESS_SHADOW_GENERATION, true); + String svg = null; + Rectangle2D drawArea = new Rectangle2D.Double(0, 0, width, height); + this.chart.draw(g2, drawArea); + try { + Method m = g2.getClass().getMethod("getSVGElement"); + svg = (String) m.invoke(g2); + } catch (NoSuchMethodException e) { + // null will be returned + } catch (SecurityException e) { + // null will be returned + } catch (IllegalAccessException e) { + // null will be returned + } catch (IllegalArgumentException e) { + // null will be returned + } catch (InvocationTargetException e) { + // null will be returned + } + return svg; + } + + private Graphics2D createSVGGraphics2D(int w, int h) { + try { + Class svgGraphics2d = Class.forName("org.jfree.graphics2d.svg.SVGGraphics2D"); + Constructor ctor = svgGraphics2d.getConstructor(int.class, int.class); + return (Graphics2D) ctor.newInstance(w, h); + } catch (ClassNotFoundException ex) { + return null; + } catch (NoSuchMethodException ex) { + return null; + } catch (SecurityException ex) { + return null; + } catch (InstantiationException ex) { + return null; + } catch (IllegalAccessException ex) { + return null; + } catch (IllegalArgumentException ex) { + return null; + } catch (InvocationTargetException ex) { + return null; + } + } + + /** + * Saves the chart in PDF format (a filechooser will be displayed so that + * the user can specify the filename). Note that this method only works + * if the OrsonPDF library is on the classpath...if this library is not + * present, the method will fail. + */ + private void saveAsPDF(File f) { + File file = f; + if (file == null) { + JFileChooser fileChooser = new JFileChooser(); + fileChooser.setCurrentDirectory(this.defaultDirectoryForSaveAs); + FileNameExtensionFilter filter = new FileNameExtensionFilter( + localizationResources.getString("PDF_Files"), "pdf"); + fileChooser.addChoosableFileFilter(filter); + fileChooser.setFileFilter(filter); + + int option = fileChooser.showSaveDialog(this); + if (option == JFileChooser.APPROVE_OPTION) { + String filename = fileChooser.getSelectedFile().getPath(); + if (isEnforceFileExtensions()) { + if (!filename.endsWith(".pdf")) { + filename = filename + ".pdf"; + } + } + file = new File(filename); + if (file.exists()) { + String fileExists = localizationResources.getString( + "FILE_EXISTS_CONFIRM_OVERWRITE"); + int response = JOptionPane.showConfirmDialog(this, + fileExists, "Save As PDF", + JOptionPane.OK_CANCEL_OPTION); + if (response == JOptionPane.CANCEL_OPTION) { + file = null; + } + } + } + } + + if (file != null) { + writeAsPDF(file, getWidth(), getHeight()); + } + } + + /** + * Returns true if OrsonPDF is on the classpath, and + * false otherwise. The OrsonPDF library can be found at + * http://www.object-refinery.com/pdf/ + * + * @return A boolean. + */ + private boolean isOrsonPDFAvailable() { + Class pdfDocumentClass = null; + try { + pdfDocumentClass = Class.forName("com.orsonpdf.PDFDocument"); + } catch (ClassNotFoundException e) { + // pdfDocument class will be null so the function will return false + } + return (pdfDocumentClass != null); + } + + /** + * Writes the current chart to the specified file in PDF format. This + * will only work when the OrsonPDF library is found on the classpath. + * Reflection is used to ensure there is no compile-time dependency on + * OrsonPDF (which is non-free software). + * + * @param file the output file (null not permitted). + * @param w the chart width. + * @param h the chart height. + */ + private void writeAsPDF(File file, int w, int h) { + if (!isOrsonPDFAvailable()) { + throw new IllegalStateException( + "OrsonPDF is not present on the classpath."); + } + ParamChecks.nullNotPermitted(file, "file"); + try { + Class pdfDocClass = Class.forName("com.orsonpdf.PDFDocument"); + Object pdfDoc = pdfDocClass.newInstance(); + Method m = pdfDocClass.getMethod("createPage", Rectangle2D.class); + Rectangle2D rect = new Rectangle(w, h); + Object page = m.invoke(pdfDoc, rect); + Method m2 = page.getClass().getMethod("getGraphics2D"); + Graphics2D g2 = (Graphics2D) m2.invoke(page); + // we suppress shadow generation, because PDF is a vector format and + // the shadow effect is applied via bitmap effects... + g2.setRenderingHint(JFreeChart.KEY_SUPPRESS_SHADOW_GENERATION, true); + Rectangle2D drawArea = new Rectangle2D.Double(0, 0, w, h); + this.chart.draw(g2, drawArea); + Method m3 = pdfDocClass.getMethod("writeToFile", File.class); + m3.invoke(pdfDoc, file); + } catch (ClassNotFoundException ex) { + throw new RuntimeException(ex); + } catch (InstantiationException ex) { + throw new RuntimeException(ex); + } catch (IllegalAccessException ex) { + throw new RuntimeException(ex); + } catch (NoSuchMethodException ex) { + throw new RuntimeException(ex); + } catch (SecurityException ex) { + throw new RuntimeException(ex); + } catch (IllegalArgumentException ex) { + throw new RuntimeException(ex); + } catch (InvocationTargetException ex) { + throw new RuntimeException(ex); + } + } + + /** + * Creates a print job for the chart. + */ + public void createChartPrintJob() { + PrinterJob job = PrinterJob.getPrinterJob(); + PageFormat pf = job.defaultPage(); + PageFormat pf2 = job.pageDialog(pf); + if (pf2 != pf) { + job.setPrintable(this, pf2); + if (job.printDialog()) { + try { + job.print(); + } + catch (PrinterException e) { + JOptionPane.showMessageDialog(this, e); + } + } + } + } + + /** + * Prints the chart on a single page. + * + * @param g the graphics context. + * @param pf the page format to use. + * @param pageIndex the index of the page. If not 0, nothing + * gets print. + * + * @return The result of printing. + */ + @Override + public int print(Graphics g, PageFormat pf, int pageIndex) { + + if (pageIndex != 0) { + return NO_SUCH_PAGE; + } + Graphics2D g2 = (Graphics2D) g; + double x = pf.getImageableX(); + double y = pf.getImageableY(); + double w = pf.getImageableWidth(); + double h = pf.getImageableHeight(); + this.chart.draw(g2, new Rectangle2D.Double(x, y, w, h), this.anchor, + null); + return PAGE_EXISTS; + + } + + /** + * Adds a listener to the list of objects listening for chart mouse events. + * + * @param listener the listener (null not permitted). + */ + public void addChartMouseListener(ChartMouseListener listener) { + ParamChecks.nullNotPermitted(listener, "listener"); + this.chartMouseListeners.add(ChartMouseListener.class, listener); + } + + /** + * Removes a listener from the list of objects listening for chart mouse + * events. + * + * @param listener the listener. + */ + public void removeChartMouseListener(ChartMouseListener listener) { + this.chartMouseListeners.remove(ChartMouseListener.class, listener); + } + + /** + * Returns an array of the listeners of the given type registered with the + * panel. + * + * @param listenerType the listener type. + * + * @return An array of listeners. + */ + @Override + public EventListener[] getListeners(Class listenerType) { + if (listenerType == ChartMouseListener.class) { + // fetch listeners from local storage + return this.chartMouseListeners.getListeners(listenerType); + } + else { + return super.getListeners(listenerType); + } + } + + /** + * 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) { + return createPopupMenu(properties, false, save, print, zoom); + } + + /** + * Creates a popup menu for the panel. + * + * @param properties include a menu item for the chart property editor. + * @param copy include a menu item for copying to the clipboard. + * @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. + * + * @since 1.0.13 + */ + protected JPopupMenu createPopupMenu(boolean properties, + boolean copy, boolean save, boolean print, boolean zoom) { + + JPopupMenu result = new JPopupMenu(localizationResources.getString("Chart") + ":"); + boolean separator = false; + + if (properties) { + JMenuItem propertiesItem = new JMenuItem( + localizationResources.getString("Properties...")); + propertiesItem.setActionCommand(PROPERTIES_COMMAND); + propertiesItem.addActionListener(this); + result.add(propertiesItem); + separator = true; + } + + if (copy) { + if (separator) { + result.addSeparator(); + } + JMenuItem copyItem = new JMenuItem( + localizationResources.getString("Copy")); + copyItem.setActionCommand(COPY_COMMAND); + copyItem.addActionListener(this); + result.add(copyItem); + separator = !save; + } + + if (save) { + if (separator) { + result.addSeparator(); + } + JMenu saveSubMenu = new JMenu("Save as"); + JMenuItem pngItem = new JMenuItem("PNG..."); + pngItem.setActionCommand("SAVE_AS_PNG"); + pngItem.addActionListener(this); + saveSubMenu.add(pngItem); + + if (createSVGGraphics2D(10, 10) != null) { + JMenuItem svgItem = new JMenuItem("SVG..."); + svgItem.setActionCommand("SAVE_AS_SVG"); + svgItem.addActionListener(this); + saveSubMenu.add(svgItem); + } + + if (isOrsonPDFAvailable()) { + JMenuItem pdfItem = new JMenuItem("PDF..."); + pdfItem.setActionCommand("SAVE_AS_PDF"); + pdfItem.addActionListener(this); + saveSubMenu.add(pdfItem); + } + result.add(saveSubMenu); + separator = true; + } + + if (print) { + if (separator) { + result.addSeparator(); + } + JMenuItem printItem = new JMenuItem( + localizationResources.getString("Print...")); + printItem.setActionCommand(PRINT_COMMAND); + printItem.addActionListener(this); + result.add(printItem); + separator = true; + } + + if (zoom) { + if (separator) { + result.addSeparator(); + } + + JMenu zoomInMenu = new JMenu( + localizationResources.getString("Zoom_In")); + + this.zoomInBothMenuItem = new JMenuItem( + localizationResources.getString("All_Axes")); + this.zoomInBothMenuItem.setActionCommand(ZOOM_IN_BOTH_COMMAND); + this.zoomInBothMenuItem.addActionListener(this); + zoomInMenu.add(this.zoomInBothMenuItem); + + zoomInMenu.addSeparator(); + + this.zoomInDomainMenuItem = new JMenuItem( + localizationResources.getString("Domain_Axis")); + this.zoomInDomainMenuItem.setActionCommand(ZOOM_IN_DOMAIN_COMMAND); + this.zoomInDomainMenuItem.addActionListener(this); + zoomInMenu.add(this.zoomInDomainMenuItem); + + this.zoomInRangeMenuItem = new JMenuItem( + localizationResources.getString("Range_Axis")); + this.zoomInRangeMenuItem.setActionCommand(ZOOM_IN_RANGE_COMMAND); + this.zoomInRangeMenuItem.addActionListener(this); + zoomInMenu.add(this.zoomInRangeMenuItem); + + result.add(zoomInMenu); + + JMenu zoomOutMenu = new JMenu( + localizationResources.getString("Zoom_Out")); + + this.zoomOutBothMenuItem = new JMenuItem( + localizationResources.getString("All_Axes")); + this.zoomOutBothMenuItem.setActionCommand(ZOOM_OUT_BOTH_COMMAND); + this.zoomOutBothMenuItem.addActionListener(this); + zoomOutMenu.add(this.zoomOutBothMenuItem); + + zoomOutMenu.addSeparator(); + + this.zoomOutDomainMenuItem = new JMenuItem( + localizationResources.getString("Domain_Axis")); + this.zoomOutDomainMenuItem.setActionCommand( + ZOOM_OUT_DOMAIN_COMMAND); + this.zoomOutDomainMenuItem.addActionListener(this); + zoomOutMenu.add(this.zoomOutDomainMenuItem); + + this.zoomOutRangeMenuItem = new JMenuItem( + localizationResources.getString("Range_Axis")); + this.zoomOutRangeMenuItem.setActionCommand(ZOOM_OUT_RANGE_COMMAND); + this.zoomOutRangeMenuItem.addActionListener(this); + zoomOutMenu.add(this.zoomOutRangeMenuItem); + + result.add(zoomOutMenu); + + JMenu autoRangeMenu = new JMenu( + localizationResources.getString("Auto_Range")); + + this.zoomResetBothMenuItem = new JMenuItem( + localizationResources.getString("All_Axes")); + this.zoomResetBothMenuItem.setActionCommand( + ZOOM_RESET_BOTH_COMMAND); + this.zoomResetBothMenuItem.addActionListener(this); + autoRangeMenu.add(this.zoomResetBothMenuItem); + + autoRangeMenu.addSeparator(); + this.zoomResetDomainMenuItem = new JMenuItem( + localizationResources.getString("Domain_Axis")); + this.zoomResetDomainMenuItem.setActionCommand( + ZOOM_RESET_DOMAIN_COMMAND); + this.zoomResetDomainMenuItem.addActionListener(this); + autoRangeMenu.add(this.zoomResetDomainMenuItem); + + this.zoomResetRangeMenuItem = new JMenuItem( + localizationResources.getString("Range_Axis")); + this.zoomResetRangeMenuItem.setActionCommand( + ZOOM_RESET_RANGE_COMMAND); + this.zoomResetRangeMenuItem.addActionListener(this); + autoRangeMenu.add(this.zoomResetRangeMenuItem); + + result.addSeparator(); + result.add(autoRangeMenu); + + } + + return result; + + } + + /** + * The idea is to modify the zooming options depending on the type of chart + * being displayed by the panel. + * + * @param x horizontal position of the popup. + * @param y vertical position of the popup. + */ + protected void displayPopupMenu(int x, int y) { + + if (this.popup == null) { + return; + } + + // go through each zoom menu item and decide whether or not to + // enable it... + boolean isDomainZoomable = false; + boolean isRangeZoomable = false; + Plot plot = (this.chart != null ? this.chart.getPlot() : null); + if (plot instanceof Zoomable) { + Zoomable z = (Zoomable) plot; + isDomainZoomable = z.isDomainZoomable(); + isRangeZoomable = z.isRangeZoomable(); + } + + if (this.zoomInDomainMenuItem != null) { + this.zoomInDomainMenuItem.setEnabled(isDomainZoomable); + } + if (this.zoomOutDomainMenuItem != null) { + this.zoomOutDomainMenuItem.setEnabled(isDomainZoomable); + } + if (this.zoomResetDomainMenuItem != null) { + this.zoomResetDomainMenuItem.setEnabled(isDomainZoomable); + } + + if (this.zoomInRangeMenuItem != null) { + this.zoomInRangeMenuItem.setEnabled(isRangeZoomable); + } + if (this.zoomOutRangeMenuItem != null) { + this.zoomOutRangeMenuItem.setEnabled(isRangeZoomable); + } + + if (this.zoomResetRangeMenuItem != null) { + this.zoomResetRangeMenuItem.setEnabled(isRangeZoomable); + } + + if (this.zoomInBothMenuItem != null) { + this.zoomInBothMenuItem.setEnabled(isDomainZoomable + && isRangeZoomable); + } + if (this.zoomOutBothMenuItem != null) { + this.zoomOutBothMenuItem.setEnabled(isDomainZoomable + && isRangeZoomable); + } + if (this.zoomResetBothMenuItem != null) { + this.zoomResetBothMenuItem.setEnabled(isDomainZoomable + && isRangeZoomable); + } + + this.popup.show(this, x, y); + + } + + /** + * Updates the UI for a LookAndFeel change. + */ + @Override + public void updateUI() { + // here we need to update the UI for the popup menu, if the panel + // has one... + if (this.popup != null) { + SwingUtilities.updateComponentTreeUI(this.popup); + } + super.updateUI(); + } + + /** + * 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.zoomFillPaint, stream); + SerialUtilities.writePaint(this.zoomOutlinePaint, 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.zoomFillPaint = SerialUtilities.readPaint(stream); + this.zoomOutlinePaint = SerialUtilities.readPaint(stream); + + // we create a new but empty chartMouseListeners list + this.chartMouseListeners = new EventListenerList(); + + // register as a listener with sub-components... + if (this.chart != null) { + this.chart.addChangeListener(this); + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartRenderingInfo.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartRenderingInfo.java new file mode 100755 index 0000000..e50b2df --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartRenderingInfo.java @@ -0,0 +1,257 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * ChartRenderingInfo.java + * ----------------------- + * (C) Copyright 2002-2013, 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. + *

+ * An instance of the {@link JFreeChart} class can draw itself within an + * arbitrary rectangle on any Graphics2D. 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 + * JFreeChart.draw(), by passing an instance of this + * ChartRenderingInfo 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 null 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 + * null, no entity information (including tool tips) will + * be collected. + * + * @param entities an entity collection (null 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 null). + * + * @see #setEntityCollection(EntityCollection) + */ + public EntityCollection getEntityCollection() { + return this.entities; + } + + /** + * Sets the entity collection. + * + * @param entities the entity collection (null 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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. + */ + @Override + 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartTheme.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartTheme.java new file mode 100755 index 0000000..9ff8609 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartTheme.java @@ -0,0 +1,61 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * ChartTheme.java + * --------------- + * (C) Copyright 2008, 2012 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; + +/** + * 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 apply(JFreeChart) 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 (null not permitted). + */ + public void apply(JFreeChart chart); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartTransferable.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartTransferable.java new file mode 100755 index 0000000..414a004 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartTransferable.java @@ -0,0 +1,278 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * ChartTransferable.java + * ---------------------- + * (C) Copyright 2009-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Apr-2009 : Version 1, with inspiration from patch 1460845 (DG); + * 05-May-2009 : Match the scaling options provided by the ChartPanel + * class (DG); + * + */ + +package org.jfree.chart; + +import java.awt.Graphics2D; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.IOException; + +/** + * A class used to represent a chart on the clipboard. + * + * @since 1.0.13 + */ +public class ChartTransferable implements Transferable { + + /** The data flavor. */ + final DataFlavor imageFlavor = new DataFlavor( + "image/x-java-image; class=java.awt.Image", "Image"); + + /** The chart. */ + private JFreeChart chart; + + /** The width of the chart on the clipboard. */ + private int width; + + /** The height of the chart on the clipboard. */ + private int height; + + /** + * The smallest width at which the chart will be drawn (if necessary, the + * chart will then be scaled down to fit the requested width). + * + * @since 1.0.14 + */ + private int minDrawWidth; + + /** + * The smallest height at which the chart will be drawn (if necessary, the + * chart will then be scaled down to fit the requested height). + * + * @since 1.0.14 + */ + private int minDrawHeight; + + /** + * The largest width at which the chart will be drawn (if necessary, the + * chart will then be scaled up to fit the requested width). + * + * @since 1.0.14 + */ + private int maxDrawWidth; + + /** + * The largest height at which the chart will be drawn (if necessary, the + * chart will then be scaled up to fit the requested height). + * + * @since 1.0.14 + */ + private int maxDrawHeight; + + /** + * Creates a new chart selection. + * + * @param chart the chart. + * @param width the chart width. + * @param height the chart height. + */ + public ChartTransferable(JFreeChart chart, int width, int height) { + this(chart, width, height, true); + } + + /** + * Creates a new chart selection. + * + * @param chart the chart. + * @param width the chart width. + * @param height the chart height. + * @param cloneData clone the dataset(s)? + */ + public ChartTransferable(JFreeChart chart, int width, int height, + boolean cloneData) { + this(chart, width, height, 0, 0, Integer.MAX_VALUE, Integer.MAX_VALUE, + true); + } + + /** + * Creates a new chart selection. The minimum and maximum drawing + * dimensions are used to match the scaling behaviour in the + * {@link ChartPanel} class. + * + * @param chart the chart. + * @param width the chart width. + * @param height the chart height. + * @param minDrawW the minimum drawing width. + * @param minDrawH the minimum drawing height. + * @param maxDrawW the maximum drawing width. + * @param maxDrawH the maximum drawing height. + * @param cloneData clone the dataset(s)? + * + * @since 1.0.14 + */ + public ChartTransferable(JFreeChart chart, int width, int height, + int minDrawW, int minDrawH, int maxDrawW, int maxDrawH, + boolean cloneData) { + + // we clone the chart because presumably there can be some delay + // between putting this instance on the system clipboard and + // actually having the getTransferData() method called... + try { + this.chart = (JFreeChart) chart.clone(); + } + catch (CloneNotSupportedException e) { + this.chart = chart; + } + // FIXME: we've cloned the chart, but the dataset(s) aren't cloned + // and we should do that + this.width = width; + this.height = height; + this.minDrawWidth = minDrawW; + this.minDrawHeight = minDrawH; + this.maxDrawWidth = maxDrawW; + this.maxDrawHeight = maxDrawH; + } + + /** + * Returns the data flavors supported. + * + * @return The data flavors supported. + */ + @Override + public DataFlavor[] getTransferDataFlavors() { + return new DataFlavor[] {this.imageFlavor}; + } + + /** + * Returns true if the specified flavor is supported. + * + * @param flavor the flavor. + * + * @return A boolean. + */ + @Override + public boolean isDataFlavorSupported(DataFlavor flavor) { + return this.imageFlavor.equals(flavor); + } + + /** + * Returns the content for the requested flavor, if it is supported. + * + * @param flavor the requested flavor. + * + * @return The content. + * + * @throws java.awt.datatransfer.UnsupportedFlavorException + * @throws java.io.IOException + */ + @Override + public Object getTransferData(DataFlavor flavor) + throws UnsupportedFlavorException, IOException { + + if (this.imageFlavor.equals(flavor)) { + return createBufferedImage(this.chart, this.width, this.height, + this.minDrawWidth, this.minDrawHeight, this.maxDrawWidth, + this.maxDrawHeight); + } + else { + throw new UnsupportedFlavorException(flavor); + } + } + + /** + * A utility method that creates an image of a chart, with scaling. + * + * @param chart the chart. + * @param w the image width. + * @param h the image height. + * @param minDrawW the minimum width for chart drawing. + * @param minDrawH the minimum height for chart drawing. + * @param maxDrawW the maximum width for chart drawing. + * @param maxDrawH the maximum height for chart drawing. + * + * @return A chart image. + * + * @since 1.0.14 + */ + private BufferedImage createBufferedImage(JFreeChart chart, int w, int h, + int minDrawW, int minDrawH, int maxDrawW, int maxDrawH) { + + BufferedImage image = new BufferedImage(w, h, + BufferedImage.TYPE_INT_ARGB); + Graphics2D g2 = image.createGraphics(); + + // work out if scaling is required... + boolean scale = false; + double drawWidth = w; + double drawHeight = h; + double scaleX = 1.0; + double scaleY = 1.0; + if (drawWidth < minDrawW) { + scaleX = drawWidth / minDrawW; + drawWidth = minDrawW; + scale = true; + } + else if (drawWidth > maxDrawW) { + scaleX = drawWidth / maxDrawW; + drawWidth = maxDrawW; + scale = true; + } + if (drawHeight < minDrawH) { + scaleY = drawHeight / minDrawH; + drawHeight = minDrawH; + scale = true; + } + else if (drawHeight > maxDrawH) { + scaleY = drawHeight / maxDrawH; + drawHeight = maxDrawH; + scale = true; + } + + Rectangle2D chartArea = new Rectangle2D.Double(0.0, 0.0, drawWidth, + drawHeight); + if (scale) { + AffineTransform st = AffineTransform.getScaleInstance(scaleX, + scaleY); + g2.transform(st); + } + chart.draw(g2, chartArea, null, null); + g2.dispose(); + return image; + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartUtilities.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartUtilities.java new file mode 100755 index 0000000..752a033 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ChartUtilities.java @@ -0,0 +1,733 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * ChartUtilities.java + * ------------------- + * (C) Copyright 2001-2013, 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); + * 02-Jul-2013 : Use ParamChecks class (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; +import org.jfree.chart.util.ParamChecks; + +/** + * 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 (null 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 (null not permitted). + * @param chart the chart (null 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 (null not permitted). + * @param chart the chart (null 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 (null not permitted). + * @param chart the chart (null not permitted). + * @param width the image width. + * @param height the image height. + * @param info the chart rendering info (null 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 { + + ParamChecks.nullNotPermitted(chart, "chart"); + 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 (null not permitted). + * @param chart the chart (null not permitted). + * @param width the image width. + * @param height the image height. + * @param info carries back chart rendering info (null + * 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 { + + ParamChecks.nullNotPermitted(out, "out"); + ParamChecks.nullNotPermitted(chart, "chart"); + 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 (null not permitted). + * @param chart the chart (null 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 { + + ParamChecks.nullNotPermitted(out, "out"); + ParamChecks.nullNotPermitted(chart, "chart"); + + 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 (null not permitted). + * @param chart the chart (null 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 (null not permitted). + * @param chart the chart (null not permitted). + * @param width the image width. + * @param height the image height. + * @param info the chart rendering info (null 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 { + + ParamChecks.nullNotPermitted(file, "file"); + 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 (null not permitted). + * @param chart the chart (null not permitted). + * @param width the image width. + * @param height the image height. + * @param info the chart rendering info (null 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 { + + ParamChecks.nullNotPermitted(file, "file"); + ParamChecks.nullNotPermitted(chart, "chart"); + 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 (null not permitted). + * @param chart the chart (null 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 (null not permitted). + * @param quality the quality setting. + * @param chart the chart (null 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 (null not permitted). + * @param chart the chart (null not permitted). + * @param width the image width. + * @param height the image height. + * @param info the chart rendering info (null 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 { + + ParamChecks.nullNotPermitted(out, "out"); + ParamChecks.nullNotPermitted(chart, "chart"); + 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 (null not permitted). + * @param quality the output quality (0.0f to 1.0f). + * @param chart the chart (null not permitted). + * @param width the image width. + * @param height the image height. + * @param info the chart rendering info (null 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 { + + ParamChecks.nullNotPermitted(out, "out"); + ParamChecks.nullNotPermitted(chart, "chart"); + 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 (null not permitted). + * @param chart the chart (null 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 (null not permitted). + * @param quality the JPEG quality setting. + * @param chart the chart (null 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 (null not permitted). + * @param chart the chart (null not permitted). + * @param width the image width. + * @param height the image height. + * @param info the chart rendering info (null 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 { + + ParamChecks.nullNotPermitted(file, "file"); + ParamChecks.nullNotPermitted(chart, "chart"); + 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 (null not permitted). + * @param quality the quality setting. + * @param chart the chart (null not permitted). + * @param width the image width. + * @param height the image height. + * @param info the chart rendering info (null 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 { + + ParamChecks.nullNotPermitted(file, "file"); + ParamChecks.nullNotPermitted(chart, "chart"); + 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 (null not permitted). + * @param image the image (null 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 (null not permitted). + * @param quality the image quality (0.0f to 1.0f). + * @param image the image (null 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 (null not permitted). + * @param image the image (null 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 (null not permitted). + * @param image the image (null 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 (null 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 (null 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 (null not permitted). + * @param name the map name (null not permitted). + * @param info the chart rendering info (null 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; + 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 (null not permitted). + * @param name the map name (null not permitted). + * @param info the chart rendering info (null not permitted). + * @param toolTipTagFragmentGenerator a generator for the HTML fragment + * that will contain the tooltip text (null not permitted + * if info contains tooltip information). + * @param urlTagFragmentGenerator a generator for the HTML fragment that + * will contain the URL reference (null not permitted if + * info 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 (null not permitted). + * @param info the chart rendering info (null 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 (null not permitted). + * @param info the chart rendering info (null not permitted). + * @param toolTipTagFragmentGenerator a generator for the HTML fragment + * that will contain the tooltip text (null not permitted + * if info contains tooltip information). + * @param urlTagFragmentGenerator a generator for the HTML fragment that + * will contain the URL reference (null not permitted if + * info 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); + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ClipPath.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ClipPath.java new file mode 100755 index 0000000..0e1a356 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/ClipPath.java @@ -0,0 +1,440 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * ClipPath.java + * ------------- + * (C) Copyright 2003-2013, 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 + * GeneralPath 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. + */ + @Override + public Object clone() throws CloneNotSupportedException { + ClipPath clone = (ClipPath) super.clone(); + clone.xValue = (double[]) this.xValue.clone(); + clone.yValue = (double[]) this.yValue.clone(); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/DrawableLegendItem.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/DrawableLegendItem.java new file mode 100755 index 0000000..fc0e655 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/DrawableLegendItem.java @@ -0,0 +1,253 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * 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; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/Effect3D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/Effect3D.java new file mode 100755 index 0000000..c8fb1e9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/Effect3D.java @@ -0,0 +1,63 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * 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(); +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/HashUtilities.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/HashUtilities.java new file mode 100755 index 0000000..ef8adf8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/HashUtilities.java @@ -0,0 +1,347 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * HashUtilities.java + * ------------------ + * (C) Copyright 2006-2013, 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 Paint instance. If + * p is null, this method returns zero. + * + * @param p the paint (null permitted). + * + * @return The hash code. + */ + public static int hashCodeForPaint(Paint p) { + if (p == null) { + return 0; + } + int result; + // 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 double[] instance. If the array + * is null, this method returns zero. + * + * @param a the array (null 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 (null 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 (null 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 (null 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 Comparable + * instance. + * + * @param pre the seed value. + * @param c the comparable (null 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 Object + * instance. + * + * @param pre the seed value. + * @param obj the object (null 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 (null 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 (null 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 (null 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; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/JFreeChart.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/JFreeChart.java new file mode 100755 index 0000000..4ca65be --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/JFreeChart.java @@ -0,0 +1,1897 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * JFreeChart.java + * --------------- + * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Andrzej Porebski; + * David Li; + * Wolfgang Irler; + * Christian W. Zuckschwerdt; + * Klaus Rheinwald; + * Nicolas Brodu; + * Peter Kolb (patch 2603321); + * + * NOTE: The above list of contributors lists only the people that have + * contributed to this source file (JFreeChart.java) - for a list of ALL + * contributors to the project, please see the README.txt file. + * + * Changes (from 20-Jun-2001) + * -------------------------- + * 20-Jun-2001 : Modifications submitted by Andrzej Porebski for legend + * placement; + * 21-Jun-2001 : Removed JFreeChart parameter from Plot constructors (DG); + * 22-Jun-2001 : Multiple titles added (original code by David Berry, with + * reworkings by DG); + * 18-Sep-2001 : Updated header (DG); + * 15-Oct-2001 : Moved data source classes into new package + * com.jrefinery.data.* (DG); + * 18-Oct-2001 : New factory method for creating VerticalXYBarChart (DG); + * 19-Oct-2001 : Moved series paint and stroke methods to the Plot class (DG); + * Moved static chart creation methods to new ChartFactory + * class (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * Fixed bug where chart isn't registered with the dataset (DG); + * 07-Nov-2001 : Fixed bug where null title in constructor causes + * exception (DG); + * Tidied up event notification code (DG); + * 17-Nov-2001 : Added getLegendItemCount() method (DG); + * 21-Nov-2001 : Set clipping in draw method to ensure that nothing gets drawn + * outside the chart area (DG); + * 11-Dec-2001 : Added the createBufferedImage() method, taken from the + * JFreeChartServletDemo class (DG); + * 13-Dec-2001 : Added tooltips (DG); + * 16-Jan-2002 : Added handleClick() method (DG); + * 22-Jan-2002 : Fixed bug correlating legend labels with pie data (DG); + * 05-Feb-2002 : Removed redundant tooltips code (DG); + * 19-Feb-2002 : Added accessor methods for the backgroundImage and + * backgroundImageAlpha attributes (DG); + * 21-Feb-2002 : Added static fields for INFO, COPYRIGHT, LICENCE, CONTRIBUTORS + * and LIBRARIES. These can be used to display information about + * JFreeChart (DG); + * 06-Mar-2002 : Moved constants to JFreeChartConstants interface (DG); + * 18-Apr-2002 : PieDataset is no longer sorted (oldman); + * 23-Apr-2002 : Moved dataset to the Plot class (DG); + * 13-Jun-2002 : Added an extra draw() method (DG); + * 25-Jun-2002 : Implemented the Drawable interface and removed redundant + * imports (DG); + * 26-Jun-2002 : Added another createBufferedImage() method (DG); + * 18-Sep-2002 : Fixed issues reported by Checkstyle (DG); + * 23-Sep-2002 : Added new contributor (DG); + * 28-Oct-2002 : Created main title and subtitle list to replace existing title + * list (DG); + * 08-Jan-2003 : Added contributor (DG); + * 17-Jan-2003 : Added new constructor (DG); + * 22-Jan-2003 : Added ChartColor class by Cameron Riley, and background image + * alignment code by Christian W. Zuckschwerdt (DG); + * 11-Feb-2003 : Added flag to allow suppression of chart change events, based + * on a suggestion by Klaus Rheinwald (DG); + * 04-Mar-2003 : Added small fix for suppressed chart change events (see bug id + * 690865) (DG); + * 10-Mar-2003 : Added Benoit Xhenseval to contributors (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 15-Jul-2003 : Added an optional border for the chart (DG); + * 11-Sep-2003 : Took care of listeners while cloning (NB); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 22-Sep-2003 : Added nullpointer checks. + * 25-Sep-2003 : Added nullpointer checks too (NB). + * 03-Dec-2003 : Legends are now registered by this class instead of using the + * old constructor way (TM); + * 03-Dec-2003 : Added anchorPoint to draw() method (DG); + * 08-Jan-2004 : Reworked title code, introducing line wrapping (DG); + * 09-Feb-2004 : Created additional createBufferedImage() method (DG); + * 05-Apr-2004 : Added new createBufferedImage() method (DG); + * 27-May-2004 : Moved constants from JFreeChartConstants.java back to this + * class (DG); + * 25-Nov-2004 : Updates for changes to Title class (DG); + * 06-Jan-2005 : Change lookup for default background color (DG); + * 31-Jan-2005 : Added Don Elliott to contributors (DG); + * 02-Feb-2005 : Added clearSubtitles() method (DG); + * 03-Feb-2005 : Added Mofeed Shahin to contributors (DG); + * 08-Feb-2005 : Updated for RectangleConstraint changes (DG); + * 28-Mar-2005 : Renamed Legend --> OldLegend (DG); + * 12-Apr-2005 : Added methods to access legend(s) in subtitle list (DG); + * 13-Apr-2005 : Added removeLegend() and removeSubtitle() methods (DG); + * 20-Apr-2005 : Modified to collect chart entities from titles and + * subtitles (DG); + * 26-Apr-2005 : Removed LOGGER (DG); + * 06-Jun-2005 : Added addLegend() method and padding attribute, fixed equals() + * method (DG); + * 24-Nov-2005 : Removed OldLegend and related code - don't want to support + * this in 1.0.0 final (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 27-Jan-2006 : Updated version number (DG); + * 07-Dec-2006 : Added some missing credits (DG); + * 17-Jan-2007 : Added Darren Jung to contributor list (DG); + * 05-Mar-2007 : Added Sergei Ivanov to the contributor list (DG); + * 16-Mar-2007 : Modified initial legend border (DG); + * 22-Mar-2007 : New methods for text anti-aliasing (DG); + * 16-May-2007 : Fixed argument check in getSubtitle(), copy list in + * get/setSubtitles(), and added new addSubtitle(int, Title) + * method (DG); + * 05-Jun-2007 : Add change listener to default legend (DG); + * 04-Dec-2007 : In createBufferedImage() methods, make the default image type + * BufferedImage.TYPE_INT_ARGB (thanks to Klaus Rheinwald) (DG); + * 05-Dec-2007 : Fixed bug 1749124 (not registering as listener with + * TextTitle) (DG); + * 23-Apr-2008 : Added new contributor (Diego Pierangeli) (DG); + * 16-May-2008 : Added new contributor (Michael Siemer) (DG); + * 19-Sep-2008 : Check for title visibility (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * 29-Jun-2009 : Check visibility flag in main title (DG); + * 02-Jul-2013 : Use ParamChecks class (DG); + * + */ + +package org.jfree.chart; + +import java.awt.AlphaComposite; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Paint; +import java.awt.RenderingHints; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.AffineTransform; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.net.URL; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.ResourceBundle; + +import javax.swing.ImageIcon; +import javax.swing.UIManager; +import javax.swing.event.EventListenerList; + +import org.jfree.JCommon; +import org.jfree.chart.block.BlockParams; +import org.jfree.chart.block.EntityBlockResult; +import org.jfree.chart.block.LengthConstraintType; +import org.jfree.chart.block.LineBorder; +import org.jfree.chart.block.RectangleConstraint; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.entity.JFreeChartEntity; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.event.ChartProgressEvent; +import org.jfree.chart.event.ChartProgressListener; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.event.PlotChangeListener; +import org.jfree.chart.event.TitleChangeEvent; +import org.jfree.chart.event.TitleChangeListener; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.title.LegendTitle; +import org.jfree.chart.title.TextTitle; +import org.jfree.chart.title.Title; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.data.Range; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.Align; +import org.jfree.ui.Drawable; +import org.jfree.ui.HorizontalAlignment; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.Size2D; +import org.jfree.ui.VerticalAlignment; +import org.jfree.ui.about.Contributor; +import org.jfree.ui.about.Licences; +import org.jfree.ui.about.ProjectInfo; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; + +/** + * A chart class implemented using the Java 2D APIs. The current version + * supports bar charts, line charts, pie charts and xy plots (including time + * series data). + *

+ * JFreeChart coordinates several objects to achieve its aim of being able to + * draw a chart on a Java 2D graphics device: a list of {@link Title} objects + * (which often includes the chart's legend), a {@link Plot} and a + * {@link org.jfree.data.general.Dataset} (the plot in turn manages a + * domain axis and a range axis). + *

+ * You should use a {@link ChartPanel} to display a chart in a GUI. + *

+ * The {@link ChartFactory} class contains static methods for creating + * 'ready-made' charts. + * + * @see ChartPanel + * @see ChartFactory + * @see Title + * @see Plot + */ +public class JFreeChart implements Drawable, TitleChangeListener, + PlotChangeListener, Serializable, Cloneable { + + /** For serialization. */ + private static final long serialVersionUID = -3470703747817429120L; + + /** Information about the project. */ + public static final ProjectInfo INFO = new JFreeChartInfo(); + + /** The default font for titles. */ + public static final Font DEFAULT_TITLE_FONT + = new Font("SansSerif", Font.BOLD, 18); + + /** The default background color. */ + public static final Paint DEFAULT_BACKGROUND_PAINT + = UIManager.getColor("Panel.background"); + + /** The default background image. */ + public static final Image DEFAULT_BACKGROUND_IMAGE = null; + + /** The default background image alignment. */ + public static final int DEFAULT_BACKGROUND_IMAGE_ALIGNMENT = Align.FIT; + + /** The default background image alpha. */ + public static final float DEFAULT_BACKGROUND_IMAGE_ALPHA = 0.5f; + + /** + * The key for a rendering hint that can suppress the generation of a + * shadow effect when drawing the chart. The hint value must be a + * Boolean. + * + * @since 1.0.16 + */ + public static final RenderingHints.Key KEY_SUPPRESS_SHADOW_GENERATION + = new RenderingHints.Key(0) { + @Override + public boolean isCompatibleValue(Object val) { + return val instanceof Boolean; + } + }; + + /** + * Rendering hints that will be used for chart drawing. This should never + * be null. + */ + private transient RenderingHints renderingHints; + + /** A flag that controls whether or not the chart border is drawn. */ + private boolean borderVisible; + + /** The stroke used to draw the chart border (if visible). */ + private transient Stroke borderStroke; + + /** The paint used to draw the chart border (if visible). */ + private transient Paint borderPaint; + + /** The padding between the chart border and the chart drawing area. */ + private RectangleInsets padding; + + /** The chart title (optional). */ + private TextTitle title; + + /** + * The chart subtitles (zero, one or many). This field should never be + * null. + */ + private List subtitles; + + /** Draws the visual representation of the data. */ + private Plot plot; + + /** Paint used to draw the background of the chart. */ + private transient Paint backgroundPaint; + + /** An optional background image for the chart. */ + private transient Image backgroundImage; // todo: not serialized yet + + /** The alignment for the background image. */ + private int backgroundImageAlignment = Align.FIT; + + /** The alpha transparency for the background image. */ + private float backgroundImageAlpha = 0.5f; + + /** Storage for registered change listeners. */ + private transient EventListenerList changeListeners; + + /** Storage for registered progress listeners. */ + private transient EventListenerList progressListeners; + + /** + * A flag that can be used to enable/disable notification of chart change + * events. + */ + private boolean notify; + + /** + * Creates a new chart based on the supplied plot. The chart will have + * a legend added automatically, but no title (although you can easily add + * one later). + *

+ * Note that the {@link ChartFactory} class contains a range + * of static methods that will return ready-made charts, and often this + * is a more convenient way to create charts than using this constructor. + * + * @param plot the plot (null not permitted). + */ + public JFreeChart(Plot plot) { + this(null, null, plot, true); + } + + /** + * Creates a new chart with the given title and plot. A default font + * ({@link #DEFAULT_TITLE_FONT}) is used for the title, and the chart will + * have a legend added automatically. + *

+ * Note that the {@link ChartFactory} class contains a range + * of static methods that will return ready-made charts, and often this + * is a more convenient way to create charts than using this constructor. + * + * @param title the chart title (null permitted). + * @param plot the plot (null not permitted). + */ + public JFreeChart(String title, Plot plot) { + this(title, JFreeChart.DEFAULT_TITLE_FONT, plot, true); + } + + /** + * Creates a new chart with the given title and plot. The + * createLegend argument specifies whether or not a legend + * should be added to the chart. + *

+ * Note that the {@link ChartFactory} class contains a range + * of static methods that will return ready-made charts, and often this + * is a more convenient way to create charts than using this constructor. + * + * @param title the chart title (null permitted). + * @param titleFont the font for displaying the chart title + * (null permitted). + * @param plot controller of the visual representation of the data + * (null not permitted). + * @param createLegend a flag indicating whether or not a legend should + * be created for the chart. + */ + public JFreeChart(String title, Font titleFont, Plot plot, + boolean createLegend) { + + ParamChecks.nullNotPermitted(plot, "plot"); + + // create storage for listeners... + this.progressListeners = new EventListenerList(); + this.changeListeners = new EventListenerList(); + this.notify = true; // default is to notify listeners when the + // chart changes + + this.renderingHints = new RenderingHints( + RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + + this.borderVisible = false; + this.borderStroke = new BasicStroke(1.0f); + this.borderPaint = Color.black; + + this.padding = RectangleInsets.ZERO_INSETS; + + this.plot = plot; + plot.addChangeListener(this); + + this.subtitles = new ArrayList(); + + // create a legend, if requested... + if (createLegend) { + LegendTitle legend = new LegendTitle(this.plot); + legend.setMargin(new RectangleInsets(1.0, 1.0, 1.0, 1.0)); + legend.setFrame(new LineBorder()); + legend.setBackgroundPaint(Color.white); + legend.setPosition(RectangleEdge.BOTTOM); + this.subtitles.add(legend); + legend.addChangeListener(this); + } + + // add the chart title, if one has been specified... + if (title != null) { + if (titleFont == null) { + titleFont = DEFAULT_TITLE_FONT; + } + this.title = new TextTitle(title, titleFont); + this.title.addChangeListener(this); + } + + this.backgroundPaint = DEFAULT_BACKGROUND_PAINT; + + this.backgroundImage = DEFAULT_BACKGROUND_IMAGE; + this.backgroundImageAlignment = DEFAULT_BACKGROUND_IMAGE_ALIGNMENT; + this.backgroundImageAlpha = DEFAULT_BACKGROUND_IMAGE_ALPHA; + + } + + /** + * Returns the collection of rendering hints for the chart. + * + * @return The rendering hints for the chart (never null). + * + * @see #setRenderingHints(RenderingHints) + */ + public RenderingHints getRenderingHints() { + return this.renderingHints; + } + + /** + * Sets the rendering hints for the chart. These will be added (using the + * Graphics2D.addRenderingHints() method) near the start of the + * JFreeChart.draw() method. + * + * @param renderingHints the rendering hints (null not + * permitted). + * + * @see #getRenderingHints() + */ + public void setRenderingHints(RenderingHints renderingHints) { + ParamChecks.nullNotPermitted(renderingHints, "renderingHints"); + this.renderingHints = renderingHints; + fireChartChanged(); + } + + /** + * Returns a flag that controls whether or not a border is drawn around the + * outside of the chart. + * + * @return A boolean. + * + * @see #setBorderVisible(boolean) + */ + public boolean isBorderVisible() { + return this.borderVisible; + } + + /** + * Sets a flag that controls whether or not a border is drawn around the + * outside of the chart. + * + * @param visible the flag. + * + * @see #isBorderVisible() + */ + public void setBorderVisible(boolean visible) { + this.borderVisible = visible; + fireChartChanged(); + } + + /** + * Returns the stroke used to draw the chart border (if visible). + * + * @return The border stroke. + * + * @see #setBorderStroke(Stroke) + */ + public Stroke getBorderStroke() { + return this.borderStroke; + } + + /** + * Sets the stroke used to draw the chart border (if visible). + * + * @param stroke the stroke. + * + * @see #getBorderStroke() + */ + public void setBorderStroke(Stroke stroke) { + this.borderStroke = stroke; + fireChartChanged(); + } + + /** + * Returns the paint used to draw the chart border (if visible). + * + * @return The border paint. + * + * @see #setBorderPaint(Paint) + */ + public Paint getBorderPaint() { + return this.borderPaint; + } + + /** + * Sets the paint used to draw the chart border (if visible). + * + * @param paint the paint. + * + * @see #getBorderPaint() + */ + public void setBorderPaint(Paint paint) { + this.borderPaint = paint; + fireChartChanged(); + } + + /** + * Returns the padding between the chart border and the chart drawing area. + * + * @return The padding (never null). + * + * @see #setPadding(RectangleInsets) + */ + public RectangleInsets getPadding() { + return this.padding; + } + + /** + * Sets the padding between the chart border and the chart drawing area, + * and sends a {@link ChartChangeEvent} to all registered listeners. + * + * @param padding the padding (null not permitted). + * + * @see #getPadding() + */ + public void setPadding(RectangleInsets padding) { + ParamChecks.nullNotPermitted(padding, "padding"); + this.padding = padding; + notifyListeners(new ChartChangeEvent(this)); + } + + /** + * Returns the main chart title. Very often a chart will have just one + * title, so we make this case simple by providing accessor methods for + * the main title. However, multiple titles are supported - see the + * {@link #addSubtitle(Title)} method. + * + * @return The chart title (possibly null). + * + * @see #setTitle(TextTitle) + */ + public TextTitle getTitle() { + return this.title; + } + + /** + * Sets the main title for the chart and sends a {@link ChartChangeEvent} + * to all registered listeners. If you do not want a title for the + * chart, set it to null. If you want more than one title on + * a chart, use the {@link #addSubtitle(Title)} method. + * + * @param title the title (null permitted). + * + * @see #getTitle() + */ + public void setTitle(TextTitle title) { + if (this.title != null) { + this.title.removeChangeListener(this); + } + this.title = title; + if (title != null) { + title.addChangeListener(this); + } + fireChartChanged(); + } + + /** + * Sets the chart title and sends a {@link ChartChangeEvent} to all + * registered listeners. This is a convenience method that ends up calling + * the {@link #setTitle(TextTitle)} method. If there is an existing title, + * its text is updated, otherwise a new title using the default font is + * added to the chart. If text is null the chart + * title is set to null. + * + * @param text the title text (null permitted). + * + * @see #getTitle() + */ + public void setTitle(String text) { + if (text != null) { + if (this.title == null) { + setTitle(new TextTitle(text, JFreeChart.DEFAULT_TITLE_FONT)); + } + else { + this.title.setText(text); + } + } + else { + setTitle((TextTitle) null); + } + } + + /** + * Adds a legend to the plot and sends a {@link ChartChangeEvent} to all + * registered listeners. + * + * @param legend the legend (null not permitted). + * + * @see #removeLegend() + */ + public void addLegend(LegendTitle legend) { + addSubtitle(legend); + } + + /** + * Returns the legend for the chart, if there is one. Note that a chart + * can have more than one legend - this method returns the first. + * + * @return The legend (possibly null). + * + * @see #getLegend(int) + */ + public LegendTitle getLegend() { + return getLegend(0); + } + + /** + * Returns the nth legend for a chart, or null. + * + * @param index the legend index (zero-based). + * + * @return The legend (possibly null). + * + * @see #addLegend(LegendTitle) + */ + public LegendTitle getLegend(int index) { + int seen = 0; + Iterator iterator = this.subtitles.iterator(); + while (iterator.hasNext()) { + Title subtitle = (Title) iterator.next(); + if (subtitle instanceof LegendTitle) { + if (seen == index) { + return (LegendTitle) subtitle; + } + else { + seen++; + } + } + } + return null; + } + + /** + * Removes the first legend in the chart and sends a + * {@link ChartChangeEvent} to all registered listeners. + * + * @see #getLegend() + */ + public void removeLegend() { + removeSubtitle(getLegend()); + } + + /** + * Returns the list of subtitles for the chart. + * + * @return The subtitle list (possibly empty, but never null). + * + * @see #setSubtitles(List) + */ + public List getSubtitles() { + return new ArrayList(this.subtitles); + } + + /** + * Sets the title list for the chart (completely replaces any existing + * titles) and sends a {@link ChartChangeEvent} to all registered + * listeners. + * + * @param subtitles the new list of subtitles (null not + * permitted). + * + * @see #getSubtitles() + */ + public void setSubtitles(List subtitles) { + if (subtitles == null) { + throw new NullPointerException("Null 'subtitles' argument."); + } + setNotify(false); + clearSubtitles(); + Iterator iterator = subtitles.iterator(); + while (iterator.hasNext()) { + Title t = (Title) iterator.next(); + if (t != null) { + addSubtitle(t); + } + } + setNotify(true); // this fires a ChartChangeEvent + } + + /** + * Returns the number of titles for the chart. + * + * @return The number of titles for the chart. + * + * @see #getSubtitles() + */ + public int getSubtitleCount() { + return this.subtitles.size(); + } + + /** + * Returns a chart subtitle. + * + * @param index the index of the chart subtitle (zero based). + * + * @return A chart subtitle. + * + * @see #addSubtitle(Title) + */ + public Title getSubtitle(int index) { + if ((index < 0) || (index >= getSubtitleCount())) { + throw new IllegalArgumentException("Index out of range."); + } + return (Title) this.subtitles.get(index); + } + + /** + * Adds a chart subtitle, and notifies registered listeners that the chart + * has been modified. + * + * @param subtitle the subtitle (null not permitted). + * + * @see #getSubtitle(int) + */ + public void addSubtitle(Title subtitle) { + ParamChecks.nullNotPermitted(subtitle, "subtitle"); + this.subtitles.add(subtitle); + subtitle.addChangeListener(this); + fireChartChanged(); + } + + /** + * Adds a subtitle at a particular position in the subtitle list, and sends + * a {@link ChartChangeEvent} to all registered listeners. + * + * @param index the index (in the range 0 to {@link #getSubtitleCount()}). + * @param subtitle the subtitle to add (null not permitted). + * + * @since 1.0.6 + */ + public void addSubtitle(int index, Title subtitle) { + if (index < 0 || index > getSubtitleCount()) { + throw new IllegalArgumentException( + "The 'index' argument is out of range."); + } + ParamChecks.nullNotPermitted(subtitle, "subtitle"); + this.subtitles.add(index, subtitle); + subtitle.addChangeListener(this); + fireChartChanged(); + } + + /** + * Clears all subtitles from the chart and sends a {@link ChartChangeEvent} + * to all registered listeners. + * + * @see #addSubtitle(Title) + */ + public void clearSubtitles() { + Iterator iterator = this.subtitles.iterator(); + while (iterator.hasNext()) { + Title t = (Title) iterator.next(); + t.removeChangeListener(this); + } + this.subtitles.clear(); + fireChartChanged(); + } + + /** + * Removes the specified subtitle and sends a {@link ChartChangeEvent} to + * all registered listeners. + * + * @param title the title. + * + * @see #addSubtitle(Title) + */ + public void removeSubtitle(Title title) { + this.subtitles.remove(title); + fireChartChanged(); + } + + /** + * Returns the plot for the chart. The plot is a class responsible for + * coordinating the visual representation of the data, including the axes + * (if any). + * + * @return The plot. + */ + public Plot getPlot() { + return this.plot; + } + + /** + * Returns the plot cast as a {@link CategoryPlot}. + *

+ * NOTE: if the plot is not an instance of {@link CategoryPlot}, then a + * ClassCastException is thrown. + * + * @return The plot. + * + * @see #getPlot() + */ + public CategoryPlot getCategoryPlot() { + return (CategoryPlot) this.plot; + } + + /** + * Returns the plot cast as an {@link XYPlot}. + *

+ * NOTE: if the plot is not an instance of {@link XYPlot}, then a + * ClassCastException is thrown. + * + * @return The plot. + * + * @see #getPlot() + */ + public XYPlot getXYPlot() { + return (XYPlot) this.plot; + } + + /** + * Returns a flag that indicates whether or not anti-aliasing is used when + * the chart is drawn. + * + * @return The flag. + * + * @see #setAntiAlias(boolean) + */ + public boolean getAntiAlias() { + Object val = this.renderingHints.get(RenderingHints.KEY_ANTIALIASING); + return RenderingHints.VALUE_ANTIALIAS_ON.equals(val); + } + + /** + * Sets a flag that indicates whether or not anti-aliasing is used when the + * chart is drawn. + *

+ * Anti-aliasing usually improves the appearance of charts, but is slower. + * + * @param flag the new value of the flag. + * + * @see #getAntiAlias() + */ + public void setAntiAlias(boolean flag) { + + Object val = this.renderingHints.get(RenderingHints.KEY_ANTIALIASING); + if (val == null) { + val = RenderingHints.VALUE_ANTIALIAS_DEFAULT; + } + if (!flag && RenderingHints.VALUE_ANTIALIAS_OFF.equals(val) + || flag && RenderingHints.VALUE_ANTIALIAS_ON.equals(val)) { + // no change, do nothing + return; + } + if (flag) { + this.renderingHints.put(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + } + else { + this.renderingHints.put(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_OFF); + } + fireChartChanged(); + + } + + /** + * Returns the current value stored in the rendering hints table for + * {@link RenderingHints#KEY_TEXT_ANTIALIASING}. + * + * @return The hint value (possibly null). + * + * @since 1.0.5 + * + * @see #setTextAntiAlias(Object) + */ + public Object getTextAntiAlias() { + return this.renderingHints.get(RenderingHints.KEY_TEXT_ANTIALIASING); + } + + /** + * Sets the value in the rendering hints table for + * {@link RenderingHints#KEY_TEXT_ANTIALIASING} to either + * {@link RenderingHints#VALUE_TEXT_ANTIALIAS_ON} or + * {@link RenderingHints#VALUE_TEXT_ANTIALIAS_OFF}, then sends a + * {@link ChartChangeEvent} to all registered listeners. + * + * @param flag the new value of the flag. + * + * @since 1.0.5 + * + * @see #getTextAntiAlias() + * @see #setTextAntiAlias(Object) + */ + public void setTextAntiAlias(boolean flag) { + if (flag) { + setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + } + else { + setTextAntiAlias(RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); + } + } + + /** + * Sets the value in the rendering hints table for + * {@link RenderingHints#KEY_TEXT_ANTIALIASING} and sends a + * {@link ChartChangeEvent} to all registered listeners. + * + * @param val the new value (null permitted). + * + * @since 1.0.5 + * + * @see #getTextAntiAlias() + * @see #setTextAntiAlias(boolean) + */ + public void setTextAntiAlias(Object val) { + this.renderingHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, val); + notifyListeners(new ChartChangeEvent(this)); + } + + /** + * Returns the paint used for the chart background. + * + * @return The paint (possibly null). + * + * @see #setBackgroundPaint(Paint) + */ + public Paint getBackgroundPaint() { + return this.backgroundPaint; + } + + /** + * Sets the paint used to fill the chart background and sends a + * {@link ChartChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @see #getBackgroundPaint() + */ + public void setBackgroundPaint(Paint paint) { + + if (this.backgroundPaint != null) { + if (!this.backgroundPaint.equals(paint)) { + this.backgroundPaint = paint; + fireChartChanged(); + } + } + else { + if (paint != null) { + this.backgroundPaint = paint; + fireChartChanged(); + } + } + + } + + /** + * Returns the background image for the chart, or null if + * there is no image. + * + * @return The image (possibly null). + * + * @see #setBackgroundImage(Image) + */ + public Image getBackgroundImage() { + return this.backgroundImage; + } + + /** + * Sets the background image for the chart and sends a + * {@link ChartChangeEvent} to all registered listeners. + * + * @param image the image (null permitted). + * + * @see #getBackgroundImage() + */ + public void setBackgroundImage(Image image) { + + if (this.backgroundImage != null) { + if (!this.backgroundImage.equals(image)) { + this.backgroundImage = image; + fireChartChanged(); + } + } + else { + if (image != null) { + this.backgroundImage = image; + fireChartChanged(); + } + } + + } + + /** + * Returns the background image alignment. Alignment constants are defined + * in the org.jfree.ui.Align class in the JCommon class + * library. + * + * @return The alignment. + * + * @see #setBackgroundImageAlignment(int) + */ + public int getBackgroundImageAlignment() { + return this.backgroundImageAlignment; + } + + /** + * Sets the background alignment. Alignment options are defined by the + * {@link org.jfree.ui.Align} class. + * + * @param alignment the alignment. + * + * @see #getBackgroundImageAlignment() + */ + public void setBackgroundImageAlignment(int alignment) { + if (this.backgroundImageAlignment != alignment) { + this.backgroundImageAlignment = alignment; + fireChartChanged(); + } + } + + /** + * Returns the alpha-transparency for the chart's background image. + * + * @return The alpha-transparency. + * + * @see #setBackgroundImageAlpha(float) + */ + public float getBackgroundImageAlpha() { + return this.backgroundImageAlpha; + } + + /** + * Sets the alpha-transparency for the chart's background image. + * Registered listeners are notified that the chart has been changed. + * + * @param alpha the alpha value. + * + * @see #getBackgroundImageAlpha() + */ + public void setBackgroundImageAlpha(float alpha) { + + if (this.backgroundImageAlpha != alpha) { + this.backgroundImageAlpha = alpha; + fireChartChanged(); + } + + } + + /** + * Returns a flag that controls whether or not change events are sent to + * registered listeners. + * + * @return A boolean. + * + * @see #setNotify(boolean) + */ + public boolean isNotify() { + return this.notify; + } + + /** + * Sets a flag that controls whether or not listeners receive + * {@link ChartChangeEvent} notifications. + * + * @param notify a boolean. + * + * @see #isNotify() + */ + public void setNotify(boolean notify) { + this.notify = notify; + // if the flag is being set to true, there may be queued up changes... + if (notify) { + notifyListeners(new ChartChangeEvent(this)); + } + } + + /** + * Draws the chart on a Java 2D graphics device (such as the screen or a + * printer). + *

+ * This method is the focus of the entire JFreeChart library. + * + * @param g2 the graphics device. + * @param area the area within which the chart should be drawn. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + draw(g2, area, null, null); + } + + /** + * Draws the chart on a Java 2D graphics device (such as the screen or a + * printer). This method is the focus of the entire JFreeChart library. + * + * @param g2 the graphics device. + * @param area the area within which the chart should be drawn. + * @param info records info about the drawing (null means collect no info). + */ + public void draw(Graphics2D g2, Rectangle2D area, ChartRenderingInfo info) { + draw(g2, area, null, info); + } + + /** + * Draws the chart on a Java 2D graphics device (such as the screen or a + * printer). + *

+ * This method is the focus of the entire JFreeChart library. + * + * @param g2 the graphics device. + * @param chartArea the area within which the chart should be drawn. + * @param anchor the anchor point (in Java2D space) for the chart + * (null permitted). + * @param info records info about the drawing (null means collect no info). + */ + public void draw(Graphics2D g2, + Rectangle2D chartArea, Point2D anchor, + ChartRenderingInfo info) { + + notifyListeners(new ChartProgressEvent(this, this, + ChartProgressEvent.DRAWING_STARTED, 0)); + + EntityCollection entities = null; + // record the chart area, if info is requested... + if (info != null) { + info.clear(); + info.setChartArea(chartArea); + entities = info.getEntityCollection(); + } + if (entities != null) { + entities.add(new JFreeChartEntity((Rectangle2D) chartArea.clone(), + this)); + } + + // ensure no drawing occurs outside chart area... + Shape savedClip = g2.getClip(); + g2.clip(chartArea); + + g2.addRenderingHints(this.renderingHints); + + // draw the chart background... + if (this.backgroundPaint != null) { + g2.setPaint(this.backgroundPaint); + g2.fill(chartArea); + } + + if (this.backgroundImage != null) { + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + this.backgroundImageAlpha)); + Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0, + this.backgroundImage.getWidth(null), + this.backgroundImage.getHeight(null)); + Align.align(dest, chartArea, this.backgroundImageAlignment); + g2.drawImage(this.backgroundImage, (int) dest.getX(), + (int) dest.getY(), (int) dest.getWidth(), + (int) dest.getHeight(), null); + g2.setComposite(originalComposite); + } + + if (isBorderVisible()) { + Paint paint = getBorderPaint(); + Stroke stroke = getBorderStroke(); + if (paint != null && stroke != null) { + Rectangle2D borderArea = new Rectangle2D.Double( + chartArea.getX(), chartArea.getY(), + chartArea.getWidth() - 1.0, chartArea.getHeight() + - 1.0); + g2.setPaint(paint); + g2.setStroke(stroke); + g2.draw(borderArea); + } + } + + // draw the title and subtitles... + Rectangle2D nonTitleArea = new Rectangle2D.Double(); + nonTitleArea.setRect(chartArea); + this.padding.trim(nonTitleArea); + + if (this.title != null && this.title.isVisible()) { + EntityCollection e = drawTitle(this.title, g2, nonTitleArea, + (entities != null)); + if (e != null && entities != null) { + entities.addAll(e); + } + } + + Iterator iterator = this.subtitles.iterator(); + while (iterator.hasNext()) { + Title currentTitle = (Title) iterator.next(); + if (currentTitle.isVisible()) { + EntityCollection e = drawTitle(currentTitle, g2, nonTitleArea, + (entities != null)); + if (e != null && entities != null) { + entities.addAll(e); + } + } + } + + Rectangle2D plotArea = nonTitleArea; + + // draw the plot (axes and data visualisation) + PlotRenderingInfo plotInfo = null; + if (info != null) { + plotInfo = info.getPlotInfo(); + } + this.plot.draw(g2, plotArea, anchor, null, plotInfo); + + g2.setClip(savedClip); + + notifyListeners(new ChartProgressEvent(this, this, + ChartProgressEvent.DRAWING_FINISHED, 100)); + } + + /** + * Creates a rectangle that is aligned to the frame. + * + * @param dimensions the dimensions for the rectangle. + * @param frame the frame to align to. + * @param hAlign the horizontal alignment. + * @param vAlign the vertical alignment. + * + * @return A rectangle. + */ + private Rectangle2D createAlignedRectangle2D(Size2D dimensions, + Rectangle2D frame, HorizontalAlignment hAlign, + VerticalAlignment vAlign) { + double x = Double.NaN; + double y = Double.NaN; + if (hAlign == HorizontalAlignment.LEFT) { + x = frame.getX(); + } + else if (hAlign == HorizontalAlignment.CENTER) { + x = frame.getCenterX() - (dimensions.width / 2.0); + } + else if (hAlign == HorizontalAlignment.RIGHT) { + x = frame.getMaxX() - dimensions.width; + } + if (vAlign == VerticalAlignment.TOP) { + y = frame.getY(); + } + else if (vAlign == VerticalAlignment.CENTER) { + y = frame.getCenterY() - (dimensions.height / 2.0); + } + else if (vAlign == VerticalAlignment.BOTTOM) { + y = frame.getMaxY() - dimensions.height; + } + + return new Rectangle2D.Double(x, y, dimensions.width, + dimensions.height); + } + + /** + * Draws a title. The title should be drawn at the top, bottom, left or + * right of the specified area, and the area should be updated to reflect + * the amount of space used by the title. + * + * @param t the title (null not permitted). + * @param g2 the graphics device (null not permitted). + * @param area the chart area, excluding any existing titles + * (null not permitted). + * @param entities a flag that controls whether or not an entity + * collection is returned for the title. + * + * @return An entity collection for the title (possibly null). + */ + protected EntityCollection drawTitle(Title t, Graphics2D g2, + Rectangle2D area, boolean entities) { + + ParamChecks.nullNotPermitted(t, "t"); + ParamChecks.nullNotPermitted(area, "area"); + Rectangle2D titleArea; + RectangleEdge position = t.getPosition(); + double ww = area.getWidth(); + if (ww <= 0.0) { + return null; + } + double hh = area.getHeight(); + if (hh <= 0.0) { + return null; + } + RectangleConstraint constraint = new RectangleConstraint(ww, + new Range(0.0, ww), LengthConstraintType.RANGE, hh, + new Range(0.0, hh), LengthConstraintType.RANGE); + Object retValue = null; + BlockParams p = new BlockParams(); + p.setGenerateEntities(entities); + if (position == RectangleEdge.TOP) { + Size2D size = t.arrange(g2, constraint); + titleArea = createAlignedRectangle2D(size, area, + t.getHorizontalAlignment(), VerticalAlignment.TOP); + retValue = t.draw(g2, titleArea, p); + area.setRect(area.getX(), Math.min(area.getY() + size.height, + area.getMaxY()), area.getWidth(), Math.max(area.getHeight() + - size.height, 0)); + } + else if (position == RectangleEdge.BOTTOM) { + Size2D size = t.arrange(g2, constraint); + titleArea = createAlignedRectangle2D(size, area, + t.getHorizontalAlignment(), VerticalAlignment.BOTTOM); + retValue = t.draw(g2, titleArea, p); + area.setRect(area.getX(), area.getY(), area.getWidth(), + area.getHeight() - size.height); + } + else if (position == RectangleEdge.RIGHT) { + Size2D size = t.arrange(g2, constraint); + titleArea = createAlignedRectangle2D(size, area, + HorizontalAlignment.RIGHT, t.getVerticalAlignment()); + retValue = t.draw(g2, titleArea, p); + area.setRect(area.getX(), area.getY(), area.getWidth() + - size.width, area.getHeight()); + } + + else if (position == RectangleEdge.LEFT) { + Size2D size = t.arrange(g2, constraint); + titleArea = createAlignedRectangle2D(size, area, + HorizontalAlignment.LEFT, t.getVerticalAlignment()); + retValue = t.draw(g2, titleArea, p); + area.setRect(area.getX() + size.width, area.getY(), area.getWidth() + - size.width, area.getHeight()); + } + else { + throw new RuntimeException("Unrecognised title position."); + } + EntityCollection result = null; + if (retValue instanceof EntityBlockResult) { + EntityBlockResult ebr = (EntityBlockResult) retValue; + result = ebr.getEntityCollection(); + } + return result; + } + + /** + * Creates and returns a buffered image into which the chart has been drawn. + * + * @param width the width. + * @param height the height. + * + * @return A buffered image. + */ + public BufferedImage createBufferedImage(int width, int height) { + return createBufferedImage(width, height, null); + } + + /** + * Creates and returns a buffered image into which the chart has been drawn. + * + * @param width the width. + * @param height the height. + * @param info carries back chart state information (null + * permitted). + * + * @return A buffered image. + */ + public BufferedImage createBufferedImage(int width, int height, + ChartRenderingInfo info) { + return createBufferedImage(width, height, BufferedImage.TYPE_INT_ARGB, + info); + } + + /** + * Creates and returns a buffered image into which the chart has been drawn. + * + * @param width the width. + * @param height the height. + * @param imageType the image type. + * @param info carries back chart state information (null + * permitted). + * + * @return A buffered image. + */ + public BufferedImage createBufferedImage(int width, int height, + int imageType, + ChartRenderingInfo info) { + BufferedImage image = new BufferedImage(width, height, imageType); + Graphics2D g2 = image.createGraphics(); + draw(g2, new Rectangle2D.Double(0, 0, width, height), null, info); + g2.dispose(); + return image; + } + + /** + * Creates and returns a buffered image into which the chart has been drawn. + * + * @param imageWidth the image width. + * @param imageHeight the image height. + * @param drawWidth the width for drawing the chart (will be scaled to + * fit image). + * @param drawHeight the height for drawing the chart (will be scaled to + * fit image). + * @param info optional object for collection chart dimension and entity + * information. + * + * @return A buffered image. + */ + public BufferedImage createBufferedImage(int imageWidth, + int imageHeight, + double drawWidth, + double drawHeight, + ChartRenderingInfo info) { + + BufferedImage image = new BufferedImage(imageWidth, imageHeight, + BufferedImage.TYPE_INT_ARGB); + Graphics2D g2 = image.createGraphics(); + double scaleX = imageWidth / drawWidth; + double scaleY = imageHeight / drawHeight; + AffineTransform st = AffineTransform.getScaleInstance(scaleX, scaleY); + g2.transform(st); + draw(g2, new Rectangle2D.Double(0, 0, drawWidth, drawHeight), null, + info); + g2.dispose(); + return image; + + } + + /** + * Handles a 'click' on the chart. JFreeChart is not a UI component, so + * some other object (for example, {@link ChartPanel}) needs to capture + * the click event and pass it onto the JFreeChart object. + * If you are not using JFreeChart in a client application, then this + * method is not required. + * + * @param x x-coordinate of the click (in Java2D space). + * @param y y-coordinate of the click (in Java2D space). + * @param info contains chart dimension and entity information + * (null not permitted). + */ + public void handleClick(int x, int y, ChartRenderingInfo info) { + + // pass the click on to the plot... + // rely on the plot to post a plot change event and redraw the chart... + this.plot.handleClick(x, y, info.getPlotInfo()); + + } + + /** + * Registers an object for notification of changes to the chart. + * + * @param listener the listener (null not permitted). + * + * @see #removeChangeListener(ChartChangeListener) + */ + public void addChangeListener(ChartChangeListener listener) { + ParamChecks.nullNotPermitted(listener, "listener"); + this.changeListeners.add(ChartChangeListener.class, listener); + } + + /** + * Deregisters an object for notification of changes to the chart. + * + * @param listener the listener (null not permitted) + * + * @see #addChangeListener(ChartChangeListener) + */ + public void removeChangeListener(ChartChangeListener listener) { + ParamChecks.nullNotPermitted(listener, "listener"); + this.changeListeners.remove(ChartChangeListener.class, listener); + } + + /** + * Sends a default {@link ChartChangeEvent} to all registered listeners. + *

+ * This method is for convenience only. + */ + public void fireChartChanged() { + ChartChangeEvent event = new ChartChangeEvent(this); + notifyListeners(event); + } + + /** + * Sends a {@link ChartChangeEvent} to all registered listeners. + * + * @param event information about the event that triggered the + * notification. + */ + protected void notifyListeners(ChartChangeEvent event) { + if (this.notify) { + Object[] listeners = this.changeListeners.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == ChartChangeListener.class) { + ((ChartChangeListener) listeners[i + 1]).chartChanged( + event); + } + } + } + } + + /** + * Registers an object for notification of progress events relating to the + * chart. + * + * @param listener the object being registered. + * + * @see #removeProgressListener(ChartProgressListener) + */ + public void addProgressListener(ChartProgressListener listener) { + this.progressListeners.add(ChartProgressListener.class, listener); + } + + /** + * Deregisters an object for notification of changes to the chart. + * + * @param listener the object being deregistered. + * + * @see #addProgressListener(ChartProgressListener) + */ + public void removeProgressListener(ChartProgressListener listener) { + this.progressListeners.remove(ChartProgressListener.class, listener); + } + + /** + * Sends a {@link ChartProgressEvent} to all registered listeners. + * + * @param event information about the event that triggered the + * notification. + */ + protected void notifyListeners(ChartProgressEvent event) { + + Object[] listeners = this.progressListeners.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == ChartProgressListener.class) { + ((ChartProgressListener) listeners[i + 1]).chartProgress(event); + } + } + + } + + /** + * Receives notification that a chart title has changed, and passes this + * on to registered listeners. + * + * @param event information about the chart title change. + */ + @Override + public void titleChanged(TitleChangeEvent event) { + event.setChart(this); + notifyListeners(event); + } + + /** + * Receives notification that the plot has changed, and passes this on to + * registered listeners. + * + * @param event information about the plot change. + */ + @Override + public void plotChanged(PlotChangeEvent event) { + event.setChart(this); + notifyListeners(event); + } + + /** + * Tests this chart for equality with another object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof JFreeChart)) { + return false; + } + JFreeChart that = (JFreeChart) obj; + if (!this.renderingHints.equals(that.renderingHints)) { + return false; + } + if (this.borderVisible != that.borderVisible) { + return false; + } + if (!ObjectUtilities.equal(this.borderStroke, that.borderStroke)) { + return false; + } + if (!PaintUtilities.equal(this.borderPaint, that.borderPaint)) { + return false; + } + if (!this.padding.equals(that.padding)) { + return false; + } + if (!ObjectUtilities.equal(this.title, that.title)) { + return false; + } + if (!ObjectUtilities.equal(this.subtitles, that.subtitles)) { + return false; + } + if (!ObjectUtilities.equal(this.plot, that.plot)) { + return false; + } + if (!PaintUtilities.equal( + this.backgroundPaint, that.backgroundPaint + )) { + return false; + } + if (!ObjectUtilities.equal(this.backgroundImage, + that.backgroundImage)) { + return false; + } + if (this.backgroundImageAlignment != that.backgroundImageAlignment) { + return false; + } + if (this.backgroundImageAlpha != that.backgroundImageAlpha) { + return false; + } + if (this.notify != that.notify) { + return false; + } + return true; + } + + /** + * 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.writeStroke(this.borderStroke, stream); + SerialUtilities.writePaint(this.borderPaint, stream); + SerialUtilities.writePaint(this.backgroundPaint, 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.borderStroke = SerialUtilities.readStroke(stream); + this.borderPaint = SerialUtilities.readPaint(stream); + this.backgroundPaint = SerialUtilities.readPaint(stream); + this.progressListeners = new EventListenerList(); + this.changeListeners = new EventListenerList(); + this.renderingHints = new RenderingHints( + RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_ON); + + // register as a listener with sub-components... + if (this.title != null) { + this.title.addChangeListener(this); + } + + for (int i = 0; i < getSubtitleCount(); i++) { + getSubtitle(i).addChangeListener(this); + } + this.plot.addChangeListener(this); + } + + /** + * Prints information about JFreeChart to standard output. + * + * @param args no arguments are honored. + */ + public static void main(String[] args) { + System.out.println(JFreeChart.INFO.toString()); + } + + /** + * Clones the object, and takes care of listeners. + * Note: caller shall register its own listeners on cloned graph. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the chart is not cloneable. + */ + @Override + public Object clone() throws CloneNotSupportedException { + JFreeChart chart = (JFreeChart) super.clone(); + + chart.renderingHints = (RenderingHints) this.renderingHints.clone(); + // private boolean borderVisible; + // private transient Stroke borderStroke; + // private transient Paint borderPaint; + + if (this.title != null) { + chart.title = (TextTitle) this.title.clone(); + chart.title.addChangeListener(chart); + } + + chart.subtitles = new ArrayList(); + for (int i = 0; i < getSubtitleCount(); i++) { + Title subtitle = (Title) getSubtitle(i).clone(); + chart.subtitles.add(subtitle); + subtitle.addChangeListener(chart); + } + + if (this.plot != null) { + chart.plot = (Plot) this.plot.clone(); + chart.plot.addChangeListener(chart); + } + + chart.progressListeners = new EventListenerList(); + chart.changeListeners = new EventListenerList(); + return chart; + } + +} + +/** + * Information about the JFreeChart project. One instance of this class is + * assigned to JFreeChart.INFO. + */ +class JFreeChartInfo extends ProjectInfo { + + /** + * Default constructor. + */ + public JFreeChartInfo() { + + // get a locale-specific resource bundle... + String baseResourceClass + = "org.jfree.chart.resources.JFreeChartResources"; + ResourceBundle resources = ResourceBundleWrapper.getBundle( + baseResourceClass); + + setName(resources.getString("project.name")); + setVersion(resources.getString("project.version")); + setInfo(resources.getString("project.info")); + setCopyright(resources.getString("project.copyright")); + setLogo(null); // load only when required + setLicenceName("LGPL"); + setLicenceText(Licences.getInstance().getLGPL()); + + setContributors(Arrays.asList( + new Contributor[]{ + new Contributor("Eric Alexander", "-"), + new Contributor("Richard Atkinson", + "richard_c_atkinson@ntlworld.com"), + new Contributor("David Basten", "-"), + new Contributor("David Berry", "-"), + new Contributor("Chris Boek", "-"), + new Contributor("Zoheb Borbora", "-"), + new Contributor("Anthony Boulestreau", "-"), + new Contributor("Jeremy Bowman", "-"), + new Contributor("Nicolas Brodu", "-"), + new Contributor("Jody Brownell", "-"), + new Contributor("David Browning", "-"), + new Contributor("Soren Caspersen", "-"), + new Contributor("Chuanhao Chiu", "-"), + new Contributor("Brian Cole", "-"), + new Contributor("Pascal Collet", "-"), + new Contributor("Martin Cordova", "-"), + new Contributor("Paolo Cova", "-"), + new Contributor("Greg Darke", "-"), + new Contributor("Mike Duffy", "-"), + new Contributor("Don Elliott", "-"), + new Contributor("David Forslund", "-"), + new Contributor("Jonathan Gabbai", "-"), + new Contributor("David Gilbert", + "david.gilbert@object-refinery.com"), + new Contributor("Serge V. Grachov", "-"), + new Contributor("Daniel Gredler", "-"), + new Contributor("Hans-Jurgen Greiner", "-"), + new Contributor("Joao Guilherme Del Valle", "-"), + new Contributor("Aiman Han", "-"), + new Contributor("Cameron Hayne", "-"), + new Contributor("Martin Hoeller", "-"), + new Contributor("Jon Iles", "-"), + new Contributor("Wolfgang Irler", "-"), + new Contributor("Sergei Ivanov", "-"), + new Contributor("Adriaan Joubert", "-"), + new Contributor("Darren Jung", "-"), + new Contributor("Xun Kang", "-"), + new Contributor("Bill Kelemen", "-"), + new Contributor("Norbert Kiesel", "-"), + new Contributor("Peter Kolb", "-"), + new Contributor("Gideon Krause", "-"), + new Contributor("Pierre-Marie Le Biot", "-"), + new Contributor("Arnaud Lelievre", "-"), + new Contributor("Wolfgang Lenhard", "-"), + new Contributor("David Li", "-"), + new Contributor("Yan Liu", "-"), + new Contributor("Tin Luu", "-"), + new Contributor("Craig MacFarlane", "-"), + new Contributor("Achilleus Mantzios", "-"), + new Contributor("Thomas Meier", "-"), + new Contributor("Jim Moore", "-"), + new Contributor("Jonathan Nash", "-"), + new Contributor("Barak Naveh", "-"), + new Contributor("David M. O'Donnell", "-"), + new Contributor("Krzysztof Paz", "-"), + new Contributor("Eric Penfold", "-"), + new Contributor("Tomer Peretz", "-"), + new Contributor("Diego Pierangeli", "-"), + new Contributor("Xavier Poinsard", "-"), + new Contributor("Andrzej Porebski", "-"), + new Contributor("Viktor Rajewski", "-"), + new Contributor("Eduardo Ramalho", "-"), + new Contributor("Michael Rauch", "-"), + new Contributor("Cameron Riley", "-"), + new Contributor("Klaus Rheinwald", "-"), + new Contributor("Dan Rivett", "d.rivett@ukonline.co.uk"), + new Contributor("Scott Sams", "-"), + new Contributor("Michel Santos", "-"), + new Contributor("Thierry Saura", "-"), + new Contributor("Andreas Schneider", "-"), + new Contributor("Jean-Luc SCHWAB", "-"), + new Contributor("Bryan Scott", "-"), + new Contributor("Tobias Selb", "-"), + new Contributor("Darshan Shah", "-"), + new Contributor("Mofeed Shahin", "-"), + new Contributor("Michael Siemer", "-"), + new Contributor("Pady Srinivasan", "-"), + new Contributor("Greg Steckman", "-"), + new Contributor("Gerald Struck", "-"), + new Contributor("Roger Studner", "-"), + new Contributor("Irv Thomae", "-"), + new Contributor("Eric Thomas", "-"), + new Contributor("Rich Unger", "-"), + new Contributor("Daniel van Enckevort", "-"), + new Contributor("Laurence Vanhelsuwe", "-"), + new Contributor("Sylvain Vieujot", "-"), + new Contributor("Ulrich Voigt", "-"), + new Contributor("Jelai Wang", "-"), + new Contributor("Mark Watson", "www.markwatson.com"), + new Contributor("Alex Weber", "-"), + new Contributor("Matthew Wright", "-"), + new Contributor("Benoit Xhenseval", "-"), + new Contributor("Christian W. Zuckschwerdt", + "Christian.Zuckschwerdt@Informatik.Uni-Oldenburg.de"), + new Contributor("Hari", "-"), + new Contributor("Sam (oldman)", "-"), + new Contributor("Patrick Schlott", "-"), + new Contributor("Christoph Schroeder", "-") + } + )); + + addLibrary(JCommon.INFO); + + } + + /** + * Returns the JFreeChart logo (a picture of a gorilla). + * + * @return The JFreeChart logo. + */ + @Override + public Image getLogo() { + Image logo = super.getLogo(); + if (logo == null) { + URL imageURL = this.getClass().getClassLoader().getResource( + "org/jfree/chart/gorilla.jpg"); + if (imageURL != null) { + ImageIcon temp = new ImageIcon(imageURL); + // use ImageIcon because it waits for the image to load... + logo = temp.getImage(); + setLogo(logo); + } + } + return logo; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LegendItem.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LegendItem.java new file mode 100755 index 0000000..8e57869 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LegendItem.java @@ -0,0 +1,1147 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * LegendItem.java + * --------------- + * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Andrzej Porebski; + * David Li; + * Wolfgang Irler; + * Luke Quinane; + * + * Changes (from 2-Oct-2002) + * ------------------------- + * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 17-Jan-2003 : Dropped outlineStroke attribute (DG); + * 08-Oct-2003 : Applied patch for displaying series line style, contributed by + * Luke Quinane (DG); + * 21-Jan-2004 : Added the shapeFilled flag (DG); + * 04-Jun-2004 : Added equals() method, implemented Serializable (DG); + * 25-Nov-2004 : Changes required by new LegendTitle implementation (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * 20-Apr-2005 : Added tooltip and URL text (DG); + * 28-Nov-2005 : Separated constructors for AttributedString labels (DG); + * 10-Dec-2005 : Fixed serialization bug (1377239) (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 20-Jul-2006 : Added dataset and series index fields (DG); + * 13-Dec-2006 : Added fillPaintTransformer attribute (DG); + * 18-May-2007 : Added dataset and seriesKey fields (DG); + * 03-Aug-2007 : Fixed null pointer exception (DG); + * 23-Apr-2008 : Added new constructor and implemented Cloneable (DG); + * 17-Jun-2008 : Added optional labelFont and labelPaint attributes (DG); + * 15-Oct-2008 : Added new constructor (DG); + * 28-Apr-2009 : Added various setter methods (DG); + * 01-Jul-2013 : Use ParamChecks class (DG); + * + */ + +package org.jfree.chart; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.Paint; +import java.awt.Shape; +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 java.text.AttributedString; +import java.text.CharacterIterator; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.general.Dataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.StandardGradientPaintTransformer; +import org.jfree.util.AttributedStringUtilities; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A temporary storage object for recording the properties of a legend item, + * without any consideration for layout issues. + */ +public class LegendItem implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -797214582948827144L; + + /** + * The dataset. + * + * @since 1.0.6 + */ + private Dataset dataset; + + /** + * The series key. + * + * @since 1.0.6 + */ + private Comparable seriesKey; + + /** The dataset index. */ + private int datasetIndex; + + /** The series index. */ + private int series; + + /** The label. */ + private String label; + + /** + * The label font (null is permitted). + * + * @since 1.0.11 + */ + private Font labelFont; + + /** + * The label paint (null is permitted). + * + * @since 1.0.11 + */ + private transient Paint labelPaint; + + /** The attributed label (if null, fall back to the regular label). */ + private transient AttributedString attributedLabel; + + /** + * The description (not currently used - could be displayed as a tool tip). + */ + private String description; + + /** The tool tip text. */ + private String toolTipText; + + /** The url text. */ + private String urlText; + + /** A flag that controls whether or not the shape is visible. */ + private boolean shapeVisible; + + /** The shape. */ + private transient Shape shape; + + /** A flag that controls whether or not the shape is filled. */ + private boolean shapeFilled; + + /** The paint. */ + private transient Paint fillPaint; + + /** + * A gradient paint transformer. + * + * @since 1.0.4 + */ + private GradientPaintTransformer fillPaintTransformer; + + /** A flag that controls whether or not the shape outline is visible. */ + private boolean shapeOutlineVisible; + + /** The outline paint. */ + private transient Paint outlinePaint; + + /** The outline stroke. */ + private transient Stroke outlineStroke; + + /** A flag that controls whether or not the line is visible. */ + private boolean lineVisible; + + /** The line. */ + private transient Shape line; + + /** The stroke. */ + private transient Stroke lineStroke; + + /** The line paint. */ + private transient Paint linePaint; + + /** + * The shape must be non-null for a LegendItem - if no shape is required, + * use this. + */ + private static final Shape UNUSED_SHAPE = new Line2D.Float(); + + /** + * The stroke must be non-null for a LegendItem - if no stroke is required, + * use this. + */ + private static final Stroke UNUSED_STROKE = new BasicStroke(0.0f); + + /** + * Creates a legend item with the specified label. The remaining + * attributes take default values. + * + * @param label the label (null not permitted). + * + * @since 1.0.10 + */ + public LegendItem(String label) { + this(label, Color.black); + } + + /** + * Creates a legend item with the specified label and fill paint. The + * remaining attributes take default values. + * + * @param label the label (null not permitted). + * @param paint the paint (null not permitted). + * + * @since 1.0.12 + */ + public LegendItem(String label, Paint paint) { + this(label, null, null, null, new Rectangle2D.Double(-4.0, -4.0, 8.0, + 8.0), paint); + } + + /** + * Creates a legend item with a filled shape. The shape is not outlined, + * and no line is visible. + * + * @param label the label (null not permitted). + * @param description the description (null permitted). + * @param toolTipText the tool tip text (null permitted). + * @param urlText the URL text (null permitted). + * @param shape the shape (null not permitted). + * @param fillPaint the paint used to fill the shape (null + * not permitted). + */ + public LegendItem(String label, String description, + String toolTipText, String urlText, + Shape shape, Paint fillPaint) { + + this(label, description, toolTipText, urlText, + /* shape visible = */ true, shape, + /* shape filled = */ true, fillPaint, + /* shape outlined */ false, Color.black, UNUSED_STROKE, + /* line visible */ false, UNUSED_SHAPE, UNUSED_STROKE, + Color.black); + + } + + /** + * Creates a legend item with a filled and outlined shape. + * + * @param label the label (null not permitted). + * @param description the description (null permitted). + * @param toolTipText the tool tip text (null permitted). + * @param urlText the URL text (null permitted). + * @param shape the shape (null not permitted). + * @param fillPaint the paint used to fill the shape (null + * not permitted). + * @param outlineStroke the outline stroke (null not + * permitted). + * @param outlinePaint the outline paint (null not + * permitted). + */ + public LegendItem(String label, String description, + String toolTipText, String urlText, + Shape shape, Paint fillPaint, + Stroke outlineStroke, Paint outlinePaint) { + + this(label, description, toolTipText, urlText, + /* shape visible = */ true, shape, + /* shape filled = */ true, fillPaint, + /* shape outlined = */ true, outlinePaint, outlineStroke, + /* line visible */ false, UNUSED_SHAPE, UNUSED_STROKE, + Color.black); + + } + + /** + * Creates a legend item using a line. + * + * @param label the label (null not permitted). + * @param description the description (null permitted). + * @param toolTipText the tool tip text (null permitted). + * @param urlText the URL text (null permitted). + * @param line the line (null not permitted). + * @param lineStroke the line stroke (null not permitted). + * @param linePaint the line paint (null not permitted). + */ + public LegendItem(String label, String description, + String toolTipText, String urlText, + Shape line, Stroke lineStroke, Paint linePaint) { + + this(label, description, toolTipText, urlText, + /* shape visible = */ false, UNUSED_SHAPE, + /* shape filled = */ false, Color.black, + /* shape outlined = */ false, Color.black, UNUSED_STROKE, + /* line visible = */ true, line, lineStroke, linePaint); + } + + /** + * Creates a new legend item. + * + * @param label the label (null not permitted). + * @param description the description (not currently used, + * null permitted). + * @param toolTipText the tool tip text (null permitted). + * @param urlText the URL text (null permitted). + * @param shapeVisible a flag that controls whether or not the shape is + * displayed. + * @param shape the shape (null permitted). + * @param shapeFilled a flag that controls whether or not the shape is + * filled. + * @param fillPaint the fill paint (null not permitted). + * @param shapeOutlineVisible a flag that controls whether or not the + * shape is outlined. + * @param outlinePaint the outline paint (null not permitted). + * @param outlineStroke the outline stroke (null not + * permitted). + * @param lineVisible a flag that controls whether or not the line is + * visible. + * @param line the line. + * @param lineStroke the stroke (null not permitted). + * @param linePaint the line paint (null not permitted). + */ + public LegendItem(String label, String description, + String toolTipText, String urlText, + boolean shapeVisible, Shape shape, + boolean shapeFilled, Paint fillPaint, + boolean shapeOutlineVisible, Paint outlinePaint, + Stroke outlineStroke, + boolean lineVisible, Shape line, + Stroke lineStroke, Paint linePaint) { + + ParamChecks.nullNotPermitted(label, "label"); + ParamChecks.nullNotPermitted(fillPaint, "fillPaint"); + ParamChecks.nullNotPermitted(lineStroke, "lineStroke"); + ParamChecks.nullNotPermitted(outlinePaint, "outlinePaint"); + ParamChecks.nullNotPermitted(outlineStroke, "outlineStroke"); + this.label = label; + this.labelPaint = null; + this.attributedLabel = null; + this.description = description; + this.shapeVisible = shapeVisible; + this.shape = shape; + this.shapeFilled = shapeFilled; + this.fillPaint = fillPaint; + this.fillPaintTransformer = new StandardGradientPaintTransformer(); + this.shapeOutlineVisible = shapeOutlineVisible; + this.outlinePaint = outlinePaint; + this.outlineStroke = outlineStroke; + this.lineVisible = lineVisible; + this.line = line; + this.lineStroke = lineStroke; + this.linePaint = linePaint; + this.toolTipText = toolTipText; + this.urlText = urlText; + } + + /** + * Creates a legend item with a filled shape. The shape is not outlined, + * and no line is visible. + * + * @param label the label (null not permitted). + * @param description the description (null permitted). + * @param toolTipText the tool tip text (null permitted). + * @param urlText the URL text (null permitted). + * @param shape the shape (null not permitted). + * @param fillPaint the paint used to fill the shape (null + * not permitted). + */ + public LegendItem(AttributedString label, String description, + String toolTipText, String urlText, + Shape shape, Paint fillPaint) { + + this(label, description, toolTipText, urlText, + /* shape visible = */ true, shape, + /* shape filled = */ true, fillPaint, + /* shape outlined = */ false, Color.black, UNUSED_STROKE, + /* line visible = */ false, UNUSED_SHAPE, UNUSED_STROKE, + Color.black); + + } + + /** + * Creates a legend item with a filled and outlined shape. + * + * @param label the label (null not permitted). + * @param description the description (null permitted). + * @param toolTipText the tool tip text (null permitted). + * @param urlText the URL text (null permitted). + * @param shape the shape (null not permitted). + * @param fillPaint the paint used to fill the shape (null + * not permitted). + * @param outlineStroke the outline stroke (null not + * permitted). + * @param outlinePaint the outline paint (null not + * permitted). + */ + public LegendItem(AttributedString label, String description, + String toolTipText, String urlText, + Shape shape, Paint fillPaint, + Stroke outlineStroke, Paint outlinePaint) { + + this(label, description, toolTipText, urlText, + /* shape visible = */ true, shape, + /* shape filled = */ true, fillPaint, + /* shape outlined = */ true, outlinePaint, outlineStroke, + /* line visible = */ false, UNUSED_SHAPE, UNUSED_STROKE, + Color.black); + } + + /** + * Creates a legend item using a line. + * + * @param label the label (null not permitted). + * @param description the description (null permitted). + * @param toolTipText the tool tip text (null permitted). + * @param urlText the URL text (null permitted). + * @param line the line (null not permitted). + * @param lineStroke the line stroke (null not permitted). + * @param linePaint the line paint (null not permitted). + */ + public LegendItem(AttributedString label, String description, + String toolTipText, String urlText, + Shape line, Stroke lineStroke, Paint linePaint) { + + this(label, description, toolTipText, urlText, + /* shape visible = */ false, UNUSED_SHAPE, + /* shape filled = */ false, Color.black, + /* shape outlined = */ false, Color.black, UNUSED_STROKE, + /* line visible = */ true, line, lineStroke, linePaint); + } + + /** + * Creates a new legend item. + * + * @param label the label (null not permitted). + * @param description the description (not currently used, + * null permitted). + * @param toolTipText the tool tip text (null permitted). + * @param urlText the URL text (null permitted). + * @param shapeVisible a flag that controls whether or not the shape is + * displayed. + * @param shape the shape (null permitted). + * @param shapeFilled a flag that controls whether or not the shape is + * filled. + * @param fillPaint the fill paint (null not permitted). + * @param shapeOutlineVisible a flag that controls whether or not the + * shape is outlined. + * @param outlinePaint the outline paint (null not permitted). + * @param outlineStroke the outline stroke (null not + * permitted). + * @param lineVisible a flag that controls whether or not the line is + * visible. + * @param line the line (null not permitted). + * @param lineStroke the stroke (null not permitted). + * @param linePaint the line paint (null not permitted). + */ + public LegendItem(AttributedString label, String description, + String toolTipText, String urlText, + boolean shapeVisible, Shape shape, + boolean shapeFilled, Paint fillPaint, + boolean shapeOutlineVisible, Paint outlinePaint, + Stroke outlineStroke, + boolean lineVisible, Shape line, Stroke lineStroke, + Paint linePaint) { + + ParamChecks.nullNotPermitted(label, "label"); + ParamChecks.nullNotPermitted(fillPaint, "fillPaint"); + ParamChecks.nullNotPermitted(lineStroke, "lineStroke"); + ParamChecks.nullNotPermitted(line, "line"); + ParamChecks.nullNotPermitted(linePaint, "linePaint"); + ParamChecks.nullNotPermitted(outlinePaint, "outlinePaint"); + ParamChecks.nullNotPermitted(outlineStroke, "outlineStroke"); + this.label = characterIteratorToString(label.getIterator()); + this.attributedLabel = label; + this.description = description; + this.shapeVisible = shapeVisible; + this.shape = shape; + this.shapeFilled = shapeFilled; + this.fillPaint = fillPaint; + this.fillPaintTransformer = new StandardGradientPaintTransformer(); + this.shapeOutlineVisible = shapeOutlineVisible; + this.outlinePaint = outlinePaint; + this.outlineStroke = outlineStroke; + this.lineVisible = lineVisible; + this.line = line; + this.lineStroke = lineStroke; + this.linePaint = linePaint; + this.toolTipText = toolTipText; + this.urlText = urlText; + } + + /** + * Returns a string containing the characters from the given iterator. + * + * @param iterator the iterator (null not permitted). + * + * @return A string. + */ + private String characterIteratorToString(CharacterIterator iterator) { + int endIndex = iterator.getEndIndex(); + int beginIndex = iterator.getBeginIndex(); + int count = endIndex - beginIndex; + if (count <= 0) { + return ""; + } + char[] chars = new char[count]; + int i = 0; + char c = iterator.first(); + while (c != CharacterIterator.DONE) { + chars[i] = c; + i++; + c = iterator.next(); + } + return new String(chars); + } + + /** + * Returns the dataset. + * + * @return The dataset. + * + * @since 1.0.6 + * + * @see #setDatasetIndex(int) + */ + public Dataset getDataset() { + return this.dataset; + } + + /** + * Sets the dataset. + * + * @param dataset the dataset. + * + * @since 1.0.6 + */ + public void setDataset(Dataset dataset) { + this.dataset = dataset; + } + + /** + * Returns the dataset index for this legend item. + * + * @return The dataset index. + * + * @since 1.0.2 + * + * @see #setDatasetIndex(int) + * @see #getDataset() + */ + public int getDatasetIndex() { + return this.datasetIndex; + } + + /** + * Sets the dataset index for this legend item. + * + * @param index the index. + * + * @since 1.0.2 + * + * @see #getDatasetIndex() + */ + public void setDatasetIndex(int index) { + this.datasetIndex = index; + } + + /** + * Returns the series key. + * + * @return The series key. + * + * @since 1.0.6 + * + * @see #setSeriesKey(Comparable) + */ + public Comparable getSeriesKey() { + return this.seriesKey; + } + + /** + * Sets the series key. + * + * @param key the series key. + * + * @since 1.0.6 + */ + public void setSeriesKey(Comparable key) { + this.seriesKey = key; + } + + /** + * Returns the series index for this legend item. + * + * @return The series index. + * + * @since 1.0.2 + */ + public int getSeriesIndex() { + return this.series; + } + + /** + * Sets the series index for this legend item. + * + * @param index the index. + * + * @since 1.0.2 + */ + public void setSeriesIndex(int index) { + this.series = index; + } + + /** + * Returns the label. + * + * @return The label (never null). + */ + public String getLabel() { + return this.label; + } + + /** + * Returns the label font. + * + * @return The label font (possibly null). + * + * @since 1.0.11 + */ + public Font getLabelFont() { + return this.labelFont; + } + + /** + * Sets the label font. + * + * @param font the font (null permitted). + * + * @since 1.0.11 + */ + public void setLabelFont(Font font) { + this.labelFont = font; + } + + /** + * Returns the paint used to draw the label. + * + * @return The paint (possibly null). + * + * @since 1.0.11 + */ + public Paint getLabelPaint() { + return this.labelPaint; + } + + /** + * Sets the paint used to draw the label. + * + * @param paint the paint (null permitted). + * + * @since 1.0.11 + */ + public void setLabelPaint(Paint paint) { + this.labelPaint = paint; + } + + /** + * Returns the attributed label. + * + * @return The attributed label (possibly null). + */ + public AttributedString getAttributedLabel() { + return this.attributedLabel; + } + + /** + * Returns the description for the legend item. + * + * @return The description (possibly null). + * + * @see #setDescription(java.lang.String) + */ + public String getDescription() { + return this.description; + } + + /** + * Sets the description for this legend item. + * + * @param text the description (null permitted). + * + * @see #getDescription() + * @since 1.0.14 + */ + public void setDescription(String text) { + this.description = text; + } + + /** + * Returns the tool tip text. + * + * @return The tool tip text (possibly null). + * + * @see #setToolTipText(java.lang.String) + */ + public String getToolTipText() { + return this.toolTipText; + } + + /** + * Sets the tool tip text for this legend item. + * + * @param text the text (null permitted). + * + * @see #getToolTipText() + * @since 1.0.14 + */ + public void setToolTipText(String text) { + this.toolTipText = text; + } + + /** + * Returns the URL text. + * + * @return The URL text (possibly null). + * + * @see #setURLText(java.lang.String) + */ + public String getURLText() { + return this.urlText; + } + + /** + * Sets the URL text. + * + * @param text the text (null permitted). + * + * @see #getURLText() + * + * @since 1.0.14 + */ + public void setURLText(String text) { + this.urlText = text; + } + + /** + * Returns a flag that indicates whether or not the shape is visible. + * + * @return A boolean. + * + * @see #setShapeVisible(boolean) + */ + public boolean isShapeVisible() { + return this.shapeVisible; + } + + /** + * Sets the flag that controls whether or not the shape is visible. + * + * @param visible the new flag value. + * + * @see #isShapeVisible() + * @see #isLineVisible() + * + * @since 1.0.14 + */ + public void setShapeVisible(boolean visible) { + this.shapeVisible = visible; + } + + /** + * Returns the shape used to label the series represented by this legend + * item. + * + * @return The shape (never null). + * + * @see #setShape(java.awt.Shape) + */ + public Shape getShape() { + return this.shape; + } + + /** + * Sets the shape for the legend item. + * + * @param shape the shape (null not permitted). + * + * @see #getShape() + * @since 1.0.14 + */ + public void setShape(Shape shape) { + ParamChecks.nullNotPermitted(shape, "shape"); + this.shape = shape; + } + + /** + * Returns a flag that controls whether or not the shape is filled. + * + * @return A boolean. + */ + public boolean isShapeFilled() { + return this.shapeFilled; + } + + /** + * Returns the fill paint. + * + * @return The fill paint (never null). + */ + public Paint getFillPaint() { + return this.fillPaint; + } + + /** + * Sets the fill paint. + * + * @param paint the paint (null not permitted). + * + * @since 1.0.11 + */ + public void setFillPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.fillPaint = paint; + } + + /** + * Returns the flag that controls whether or not the shape outline + * is visible. + * + * @return A boolean. + */ + public boolean isShapeOutlineVisible() { + return this.shapeOutlineVisible; + } + + /** + * Returns the line stroke for the series. + * + * @return The stroke (never null). + */ + public Stroke getLineStroke() { + return this.lineStroke; + } + + /** + * Returns the paint used for lines. + * + * @return The paint (never null). + */ + public Paint getLinePaint() { + return this.linePaint; + } + + /** + * Sets the line paint. + * + * @param paint the paint (null not permitted). + * + * @since 1.0.11 + */ + public void setLinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.linePaint = paint; + } + + /** + * Returns the outline paint. + * + * @return The outline paint (never null). + */ + public Paint getOutlinePaint() { + return this.outlinePaint; + } + + /** + * Sets the outline paint. + * + * @param paint the paint (null not permitted). + * + * @since 1.0.11 + */ + public void setOutlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.outlinePaint = paint; + } + + /** + * Returns the outline stroke. + * + * @return The outline stroke (never null). + * + * @see #setOutlineStroke(java.awt.Stroke) + */ + public Stroke getOutlineStroke() { + return this.outlineStroke; + } + + /** + * Sets the outline stroke. + * + * @param stroke the stroke (never null). + * + * @see #getOutlineStroke() + * + * @since 1.0.14 + */ + public void setOutlineStroke(Stroke stroke) { + this.outlineStroke = stroke; + } + + /** + * Returns a flag that indicates whether or not the line is visible. + * + * @return A boolean. + * + * @see #setLineVisible(boolean) + */ + public boolean isLineVisible() { + return this.lineVisible; + } + + /** + * Sets the flag that controls whether or not the line shape is visible for + * this legend item. + * + * @param visible the new flag value. + * + * @see #isLineVisible() + * @since 1.0.14 + */ + public void setLineVisible(boolean visible) { + this.lineVisible = visible; + } + + /** + * Returns the line. + * + * @return The line (never null). + * + * @see #setLine(java.awt.Shape) + * @see #isLineVisible() + */ + public Shape getLine() { + return this.line; + } + + /** + * Sets the line. + * + * @param line the line (null not permitted). + * + * @see #getLine() + * @since 1.0.14 + */ + public void setLine(Shape line) { + ParamChecks.nullNotPermitted(line, "line"); + this.line = line; + } + + /** + * Returns the transformer used when the fill paint is an instance of + * GradientPaint. + * + * @return The transformer (never null). + * + * @since 1.0.4 + * + * @see #setFillPaintTransformer(GradientPaintTransformer) + */ + public GradientPaintTransformer getFillPaintTransformer() { + return this.fillPaintTransformer; + } + + /** + * Sets the transformer used when the fill paint is an instance of + * GradientPaint. + * + * @param transformer the transformer (null not permitted). + * + * @since 1.0.4 + * + * @see #getFillPaintTransformer() + */ + public void setFillPaintTransformer(GradientPaintTransformer transformer) { + ParamChecks.nullNotPermitted(transformer, "transformer"); + this.fillPaintTransformer = transformer; + } + + /** + * Tests this item for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof LegendItem)) { + return false; + } + LegendItem that = (LegendItem) obj; + if (this.datasetIndex != that.datasetIndex) { + return false; + } + if (this.series != that.series) { + return false; + } + if (!this.label.equals(that.label)) { + return false; + } + if (!AttributedStringUtilities.equal(this.attributedLabel, + that.attributedLabel)) { + return false; + } + if (!ObjectUtilities.equal(this.description, that.description)) { + return false; + } + if (this.shapeVisible != that.shapeVisible) { + return false; + } + if (!ShapeUtilities.equal(this.shape, that.shape)) { + return false; + } + if (this.shapeFilled != that.shapeFilled) { + return false; + } + if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.fillPaintTransformer, + that.fillPaintTransformer)) { + return false; + } + if (this.shapeOutlineVisible != that.shapeOutlineVisible) { + return false; + } + if (!this.outlineStroke.equals(that.outlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { + return false; + } + if (!this.lineVisible == that.lineVisible) { + return false; + } + if (!ShapeUtilities.equal(this.line, that.line)) { + return false; + } + if (!this.lineStroke.equals(that.lineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.linePaint, that.linePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.labelFont, that.labelFont)) { + return false; + } + if (!PaintUtilities.equal(this.labelPaint, that.labelPaint)) { + return false; + } + return true; + } + + /** + * Returns an independent copy of this object (except that the clone will + * still reference the same dataset as the original + * LegendItem). + * + * @return A clone. + * + * @throws CloneNotSupportedException if the legend item cannot be cloned. + * + * @since 1.0.10 + */ + @Override + public Object clone() throws CloneNotSupportedException { + LegendItem clone = (LegendItem) super.clone(); + if (this.seriesKey instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.seriesKey; + clone.seriesKey = (Comparable) pc.clone(); + } + // FIXME: Clone the attributed string if it is not null + clone.shape = ShapeUtilities.clone(this.shape); + if (this.fillPaintTransformer instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.fillPaintTransformer; + clone.fillPaintTransformer = (GradientPaintTransformer) pc.clone(); + + } + clone.line = ShapeUtilities.clone(this.line); + return clone; + } + + /** + * Provides serialization support. + * + * @param stream the output stream (null not permitted). + * + * @throws IOException if there is an I/O error. + */ + private void writeObject(ObjectOutputStream stream) throws IOException { + stream.defaultWriteObject(); + SerialUtilities.writeAttributedString(this.attributedLabel, stream); + SerialUtilities.writeShape(this.shape, stream); + SerialUtilities.writePaint(this.fillPaint, stream); + SerialUtilities.writeStroke(this.outlineStroke, stream); + SerialUtilities.writePaint(this.outlinePaint, stream); + SerialUtilities.writeShape(this.line, stream); + SerialUtilities.writeStroke(this.lineStroke, stream); + SerialUtilities.writePaint(this.linePaint, stream); + SerialUtilities.writePaint(this.labelPaint, stream); + } + + /** + * Provides serialization support. + * + * @param stream the input stream (null 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.attributedLabel = SerialUtilities.readAttributedString(stream); + this.shape = SerialUtilities.readShape(stream); + this.fillPaint = SerialUtilities.readPaint(stream); + this.outlineStroke = SerialUtilities.readStroke(stream); + this.outlinePaint = SerialUtilities.readPaint(stream); + this.line = SerialUtilities.readShape(stream); + this.lineStroke = SerialUtilities.readStroke(stream); + this.linePaint = SerialUtilities.readPaint(stream); + this.labelPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LegendItemCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LegendItemCollection.java new file mode 100755 index 0000000..0ecd37a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LegendItemCollection.java @@ -0,0 +1,157 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * LegendItemCollection.java + * ------------------------- + * (C) Copyright 2002-2013, 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 (null not + * permitted). + */ + 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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. + */ + @Override + public Object clone() throws CloneNotSupportedException { + LegendItemCollection clone = (LegendItemCollection) super.clone(); + clone.items = (List) ObjectUtilities.deepClone(this.items); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LegendItemSource.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LegendItemSource.java new file mode 100755 index 0000000..8c184b5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LegendItemSource.java @@ -0,0 +1,57 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * 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 null). + */ + public LegendItemCollection getLegendItems(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LegendRenderingOrder.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LegendRenderingOrder.java new file mode 100755 index 0000000..9b76255 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LegendRenderingOrder.java @@ -0,0 +1,124 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * LegendRenderingOrder.java + * ------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: Angel; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * 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. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + 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; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle.properties new file mode 100755 index 0000000..cb2f3b7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle.properties @@ -0,0 +1,23 @@ +# 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=Chart +Chart_Properties=Chart Properties +Copy=Copy +Domain_Axis=Domain Axis +FILE_EXISTS_CONFIRM_OVERWRITE=The file already exists, are you sure you want to overwrite it? +PNG_Image_Files=PNG Image Files +PDF_Files=PDF Files +Print...=Print... +Properties...=Properties... +Range_Axis=Range Axis +Save_as...=Save as... +SVG_Files=SVG Files +Zoom_In=Zoom In +Zoom_Out=Zoom Out diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_cs.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_cs.properties new file mode 100755 index 0000000..bf93021 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_cs.properties @@ -0,0 +1,21 @@ +# org.jfree.chart.ChartPanel ResourceBundle properties file +# +# Changes (from 31-Aug-2003) +# -------------------------- +# 31-Aug-2003 : Initial version (AL); +# 20-Mar-2010 : Czech translation; +# + +Auto_Range=Auto rozm\u011br +All_Axes=Ob\u011b osy +Chart=Chart +Chart_Properties=Vlastnosti grafu +Copy=Kop\u00edrovat +Domain_Axis=Osa oblasti +PNG_Image_Files=Obr\u00e1zky PNG +Print...=Tisk... +Properties...=Vlastnosti... +Save_as...=Ulo\u017eit jako... +Range_Axis=Osa rozsahu +Zoom_In=P\u0159ibl\u00ed\u017eit +Zoom_Out=Odd\u00e1lit diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_de.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_de.properties new file mode 100755 index 0000000..03c86aa --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_de.properties @@ -0,0 +1,21 @@ +# 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=Diagramm +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 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_es.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_es.properties new file mode 100755 index 0000000..7b4ea41 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_es.properties @@ -0,0 +1,20 @@ +# 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=Chart +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 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_fr.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_fr.properties new file mode 100755 index 0000000..75b4891 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_fr.properties @@ -0,0 +1,20 @@ +# 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=Chart +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 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_it.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_it.properties new file mode 100755 index 0000000..2361f8b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_it.properties @@ -0,0 +1,14 @@ +# org.jfree.chart.ChartPanel ResourceBundle properties file - italian version +Auto_Range=Dimensiona Automaticamente +All_Axes=Entrambi gli Assi +Chart=Chart +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 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_ja.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_ja.properties new file mode 100755 index 0000000..1ac6c68 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_ja.properties @@ -0,0 +1,14 @@ + +All_Axes=\u4e21\u8ef8 +Auto_Range=\u81ea\u52d5\u30b5\u30a4\u30b8\u30f3\u30b0 +Chart=\u30c1\u30e3\u30fc\u30c8 +Chart_Properties=\u30c1\u30e3\u30fc\u30c8 \u30d7\u30ed\u30d1\u30c6\u30a3 +Copy=\u30b3\u30d4\u30fc +Domain_Axis=\u5206\u985e\u8ef8 +PNG_Image_Files=PNG \u30a4\u30e1\u30fc\u30b8\u30d5\u30a1\u30a4\u30eb +Print...=\u5370\u5237... +Properties...=\u30d7\u30ed\u30d1\u30c6\u30a3... +Range_Axis=\u6570\u5024\u8ef8 +Save_as...=\u5225\u540d\u3067\u4fdd\u5b58... +Zoom_In=\u30ba\u30fc\u30e0\u30a4\u30f3 +Zoom_Out=\u30ba\u30fc\u30e0\u30a2\u30a6\u30c8 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_nl.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_nl.properties new file mode 100755 index 0000000..04eb7f5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_nl.properties @@ -0,0 +1,21 @@ +# 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=Chart +Chart_Properties=Eigenschappen +Copy=Kopi\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 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_pl.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_pl.properties new file mode 100755 index 0000000..97c26e1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_pl.properties @@ -0,0 +1,20 @@ +# 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=Chart +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 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_pt_BR.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_pt_BR.properties new file mode 100755 index 0000000..8f33a94 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_pt_BR.properties @@ -0,0 +1,20 @@ +# 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=Chart +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 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_pt_PT.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_pt_PT.properties new file mode 100755 index 0000000..61da66a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_pt_PT.properties @@ -0,0 +1,20 @@ +# 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=Chart +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 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_ru.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_ru.properties new file mode 100755 index 0000000..7d36db0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_ru.properties @@ -0,0 +1,20 @@ +# 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=Chart +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 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_zh_CN.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_zh_CN.properties new file mode 100755 index 0000000..f95a983 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_zh_CN.properties @@ -0,0 +1,20 @@ +# 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=Chart +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 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_zh_TW.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_zh_TW.properties new file mode 100755 index 0000000..61badae --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/LocalizationBundle_zh_TW.properties @@ -0,0 +1,20 @@ +# 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=Chart +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 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/MouseWheelHandler.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/MouseWheelHandler.java new file mode 100755 index 0000000..37f1a98 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/MouseWheelHandler.java @@ -0,0 +1,162 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * MouseWheelHandler.java + * ---------------------- + * (C) Copyright 2009-2013 by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Ulrich Voigt - patch 2686040; + * Jim Goodwin - bug fix; + * + * Changes + * ------- + * 18-Mar-2009 : Version 1, based on ideas by UV in patch 2686040 (DG); + * 26-Mar-2009 : Implemented Serializable (DG); + * 10-Sep-2009 : Bug fix by Jim Goodwin to respect domain/rangeZoomable flags + * in the ChartPanel (DG); + * 04-Nov-2009 : Pass mouse wheel notification to PiePlot (DG); + * + */ + +package org.jfree.chart; + +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; +import java.awt.geom.Point2D; + +import java.io.Serializable; +import org.jfree.chart.plot.PiePlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.Zoomable; + +/** + * A class that handles mouse wheel events for the {@link ChartPanel} class. + * Mouse wheel event support was added in JDK 1.4, so this class will be omitted + * from JFreeChart if you build it using JDK 1.3. + * + * @since 1.0.13 + */ +class MouseWheelHandler implements MouseWheelListener, Serializable { + + /** The chart panel. */ + private ChartPanel chartPanel; + + /** The zoom factor. */ + double zoomFactor; + + /** + * Creates a new instance for the specified chart panel. + * + * @param chartPanel the chart panel (null not permitted). + */ + public MouseWheelHandler(ChartPanel chartPanel) { + this.chartPanel = chartPanel; + this.zoomFactor = 0.10; + this.chartPanel.addMouseWheelListener(this); + } + + /** + * Returns the current zoom factor. The default value is 0.10 (ten + * percent). + * + * @return The zoom factor. + * + * @see #setZoomFactor(double) + */ + public double getZoomFactor() { + return this.zoomFactor; + } + + /** + * Sets the zoom factor. + * + * @param zoomFactor the zoom factor. + * + * @see #getZoomFactor() + */ + public void setZoomFactor(double zoomFactor) { + this.zoomFactor = zoomFactor; + } + + /** + * Handles a mouse wheel event from the underlying chart panel. + * + * @param e the event. + */ + @Override + public void mouseWheelMoved(MouseWheelEvent e) { + JFreeChart chart = this.chartPanel.getChart(); + if (chart == null) { + return; + } + Plot plot = chart.getPlot(); + if (plot instanceof Zoomable) { + Zoomable zoomable = (Zoomable) plot; + handleZoomable(zoomable, e); + } + else if (plot instanceof PiePlot) { + PiePlot pp = (PiePlot) plot; + pp.handleMouseWheelRotation(e.getWheelRotation()); + } + } + + /** + * Handle the case where a plot implements the {@link Zoomable} interface. + * + * @param zoomable the zoomable plot. + * @param e the mouse wheel event. + */ + private void handleZoomable(Zoomable zoomable, MouseWheelEvent e) { + // don't zoom unless the mouse pointer is in the plot's data area + ChartRenderingInfo info = this.chartPanel.getChartRenderingInfo(); + PlotRenderingInfo pinfo = info.getPlotInfo(); + Point2D p = this.chartPanel.translateScreenToJava2D(e.getPoint()); + if (!pinfo.getDataArea().contains(p)) { + return; + } + + Plot plot = (Plot) zoomable; + // do not notify while zooming each axis + boolean notifyState = plot.isNotify(); + plot.setNotify(false); + int clicks = e.getWheelRotation(); + double zf = 1.0 + this.zoomFactor; + if (clicks < 0) { + zf = 1.0 / zf; + } + if (chartPanel.isDomainZoomable()) { + zoomable.zoomDomainAxes(zf, pinfo, p, true); + } + if (chartPanel.isRangeZoomable()) { + zoomable.zoomRangeAxes(zf, pinfo, p, true); + } + plot.setNotify(notifyState); // this generates the change event too + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/PaintMap.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/PaintMap.java new file mode 100755 index 0000000..eec4820 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/PaintMap.java @@ -0,0 +1,222 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * PaintMap.java + * ------------- + * (C) Copyright 2006-2013, 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); + * 02-Jul-2013 : Use ParamChecks class (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.chart.util.ParamChecks; + +import org.jfree.io.SerialUtilities; +import org.jfree.util.PaintUtilities; + +/** + * A storage structure that maps Comparable instances with + * Paint instances. + *

+ * To support cloning and serialization, you should only use keys that are + * cloneable and serializable. Special handling for the Paint + * 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 + * null. + * + * @param key the key (null not permitted). + * + * @return The paint, or null. + * + * @throws IllegalArgumentException if key is + * null. + */ + public Paint getPaint(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + return (Paint) this.store.get(key); + } + + /** + * Returns true if the map contains the specified key, and + * false otherwise. + * + * @param key the key. + * + * @return true if the map contains the specified key, and + * false otherwise. + */ + public boolean containsKey(Comparable key) { + return this.store.containsKey(key); + } + + /** + * Adds a mapping between the specified key and + * paint values. + * + * @param key the key (null not permitted). + * @param paint the paint. + * + * @throws IllegalArgumentException if key is + * null. + */ + public void put(Comparable key, Paint paint) { + ParamChecks.nullNotPermitted(key, "key"); + 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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 PaintMap. + * + * @return A clone of this instance. + * + * @throws CloneNotSupportedException if any key is not cloneable. + */ + @Override + 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); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/PolarChartPanel.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/PolarChartPanel.java new file mode 100755 index 0000000..5e21dc0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/PolarChartPanel.java @@ -0,0 +1,263 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * PolarChartPanel.java + * -------------------- + * (C) Copyright 2004-2013, by Solution Engineering, Inc. and Contributors. + * + * Original Author: Daniel Bridenbecker, Solution Engineering, Inc.; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Martin Hoeller; + * + * 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); + * 10-Oct-2011 : bug #3165708: localization (MH); + * + */ + +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; + +/** + * PolarChartPanel is the top level object for using the + * {@link PolarPlot}. Since this class has a JPanel in the + * inheritance hierarchy, one uses this class to integrate the Polar plot into + * their application. + *

+ * The main modification to ChartPanel is the popup menu. It + * removes ChartPanel's versions of: + *

    + *
  • Zoom In
  • + *
  • Zoom Out
  • + *
  • Auto Range
  • + *
+ * 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. + */ + @Override + 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. + */ + @Override + protected JPopupMenu createPopupMenu(boolean properties, boolean save, + boolean print, boolean zoom) { + + JPopupMenu result = super.createPopupMenu(properties, save, print, zoom); + int zoomInIndex = getPopupMenuItem(result, + localizationResources.getString("Zoom_In")); + int zoomOutIndex = getPopupMenuItem(result, + localizationResources.getString("Zoom_Out")); + int autoIndex = getPopupMenuItem(result, + localizationResources.getString("Auto_Range")); + if (zoom) { + JMenuItem zoomIn = new JMenuItem( + localizationResources.getString("Zoom_In")); + zoomIn.setActionCommand(POLAR_ZOOM_IN_ACTION_COMMAND); + zoomIn.addActionListener(this); + + JMenuItem zoomOut = new JMenuItem( + localizationResources.getString("Zoom_Out")); + zoomOut.setActionCommand(POLAR_ZOOM_OUT_ACTION_COMMAND); + zoomOut.addActionListener(this); + + JMenuItem auto = new JMenuItem( + localizationResources.getString("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. + */ + @Override + 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; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/StandardChartTheme.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/StandardChartTheme.java new file mode 100755 index 0000000..b5d60ba --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/StandardChartTheme.java @@ -0,0 +1,1847 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * StandardChartTheme.java + * ----------------------- + * (C) Copyright 2008-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 14-Aug-2008 : Version 1 (DG); + * 10-Apr-2009 : Added getter/setter for smallFont (DG); + * 10-Jul-2009 : Added shadowGenerator field (DG); + * 29-Oct-2011 : Fixed Eclipse warnings (DG); + * 02-Jul-2013 : Use ParamChecks class (DG); + * + */ + +package org.jfree.chart; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.Paint; +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.List; + +import org.jfree.chart.annotations.XYAnnotation; +import org.jfree.chart.annotations.XYTextAnnotation; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.PeriodAxis; +import org.jfree.chart.axis.PeriodAxisLabelInfo; +import org.jfree.chart.axis.SubCategoryAxis; +import org.jfree.chart.axis.SymbolAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.block.Block; +import org.jfree.chart.block.BlockContainer; +import org.jfree.chart.block.LabelBlock; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.CombinedDomainCategoryPlot; +import org.jfree.chart.plot.CombinedDomainXYPlot; +import org.jfree.chart.plot.CombinedRangeCategoryPlot; +import org.jfree.chart.plot.CombinedRangeXYPlot; +import org.jfree.chart.plot.DefaultDrawingSupplier; +import org.jfree.chart.plot.DrawingSupplier; +import org.jfree.chart.plot.FastScatterPlot; +import org.jfree.chart.plot.MeterPlot; +import org.jfree.chart.plot.MultiplePiePlot; +import org.jfree.chart.plot.PieLabelLinkStyle; +import org.jfree.chart.plot.PiePlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PolarPlot; +import org.jfree.chart.plot.SpiderWebPlot; +import org.jfree.chart.plot.ThermometerPlot; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.AbstractRenderer; +import org.jfree.chart.renderer.category.BarPainter; +import org.jfree.chart.renderer.category.BarRenderer; +import org.jfree.chart.renderer.category.BarRenderer3D; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.renderer.category.GradientBarPainter; +import org.jfree.chart.renderer.category.LineRenderer3D; +import org.jfree.chart.renderer.category.MinMaxCategoryRenderer; +import org.jfree.chart.renderer.category.StatisticalBarRenderer; +import org.jfree.chart.renderer.xy.GradientXYBarPainter; +import org.jfree.chart.renderer.xy.XYBarPainter; +import org.jfree.chart.renderer.xy.XYBarRenderer; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.chart.title.CompositeTitle; +import org.jfree.chart.title.LegendTitle; +import org.jfree.chart.title.PaintScaleLegend; +import org.jfree.chart.title.TextTitle; +import org.jfree.chart.title.Title; +import org.jfree.chart.util.DefaultShadowGenerator; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ShadowGenerator; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A default implementation of the {@link ChartTheme} interface. This + * implementation just collects a whole bunch of chart attributes and mimics + * the manual process of applying each attribute to the right sub-object + * within the JFreeChart instance. It's not elegant code, but it works. + * + * @since 1.0.11 + */ +public class StandardChartTheme implements ChartTheme, Cloneable, + PublicCloneable, Serializable { + + /** The name of this theme. */ + private String name; + + /** + * The largest font size. Use for the main chart title. + */ + private Font extraLargeFont; + + /** + * A large font. Used for subtitles. + */ + private Font largeFont; + + /** + * The regular font size. Used for axis tick labels, legend items etc. + */ + private Font regularFont; + + /** + * The small font size. + */ + private Font smallFont; + + /** The paint used to display the main chart title. */ + private transient Paint titlePaint; + + /** The paint used to display subtitles. */ + private transient Paint subtitlePaint; + + /** The background paint for the chart. */ + private transient Paint chartBackgroundPaint; + + /** The legend background paint. */ + private transient Paint legendBackgroundPaint; + + /** The legend item paint. */ + private transient Paint legendItemPaint; + + /** The drawing supplier. */ + private DrawingSupplier drawingSupplier; + + /** The background paint for the plot. */ + private transient Paint plotBackgroundPaint; + + /** The plot outline paint. */ + private transient Paint plotOutlinePaint; + + /** The label link style for pie charts. */ + private PieLabelLinkStyle labelLinkStyle; + + /** The label link paint for pie charts. */ + private transient Paint labelLinkPaint; + + /** The domain grid line paint. */ + private transient Paint domainGridlinePaint; + + /** The range grid line paint. */ + private transient Paint rangeGridlinePaint; + + /** + * The baseline paint (used for domain and range zero baselines) + * + * @since 1.0.13 + */ + private transient Paint baselinePaint; + + /** The crosshair paint. */ + private transient Paint crosshairPaint; + + /** The axis offsets. */ + private RectangleInsets axisOffset; + + /** The axis label paint. */ + private transient Paint axisLabelPaint; + + /** The tick label paint. */ + private transient Paint tickLabelPaint; + + /** The item label paint. */ + private transient Paint itemLabelPaint; + + /** + * A flag that controls whether or not shadows are visible (for example, + * in a bar renderer). + */ + private boolean shadowVisible; + + /** The shadow paint. */ + private transient Paint shadowPaint; + + /** The bar painter. */ + private BarPainter barPainter; + + /** The XY bar painter. */ + private XYBarPainter xyBarPainter; + + /** The thermometer paint. */ + private transient Paint thermometerPaint; + + /** + * The paint used to fill the interior of the 'walls' in the background + * of a plot with a 3D effect. Applied to BarRenderer3D. + */ + private transient Paint wallPaint; + + /** The error indicator paint for the {@link StatisticalBarRenderer}. */ + private transient Paint errorIndicatorPaint; + + /** The grid band paint for a {@link SymbolAxis}. */ + private transient Paint gridBandPaint = SymbolAxis.DEFAULT_GRID_BAND_PAINT; + + /** The grid band alternate paint for a {@link SymbolAxis}. */ + private transient Paint gridBandAlternatePaint + = SymbolAxis.DEFAULT_GRID_BAND_ALTERNATE_PAINT; + + /** + * The shadow generator (can be null). + * + * @since 1.0.14 + */ + private ShadowGenerator shadowGenerator; + + /** + * Creates and returns the default 'JFree' chart theme. + * + * @return A chart theme. + */ + public static ChartTheme createJFreeTheme() { + return new StandardChartTheme("JFree"); + } + + /** + * Creates and returns a theme called "Darkness". In this theme, the + * charts have a black background. + * + * @return The "Darkness" theme. + */ + public static ChartTheme createDarknessTheme() { + StandardChartTheme theme = new StandardChartTheme("Darkness"); + theme.titlePaint = Color.white; + theme.subtitlePaint = Color.white; + theme.legendBackgroundPaint = Color.black; + theme.legendItemPaint = Color.white; + theme.chartBackgroundPaint = Color.black; + theme.plotBackgroundPaint = Color.black; + theme.plotOutlinePaint = Color.yellow; + theme.baselinePaint = Color.white; + theme.crosshairPaint = Color.red; + theme.labelLinkPaint = Color.lightGray; + theme.tickLabelPaint = Color.white; + theme.axisLabelPaint = Color.white; + theme.shadowPaint = Color.darkGray; + theme.itemLabelPaint = Color.white; + theme.drawingSupplier = new DefaultDrawingSupplier( + new Paint[] {Color.decode("0xFFFF00"), + Color.decode("0x0036CC"), Color.decode("0xFF0000"), + Color.decode("0xFFFF7F"), Color.decode("0x6681CC"), + Color.decode("0xFF7F7F"), Color.decode("0xFFFFBF"), + Color.decode("0x99A6CC"), Color.decode("0xFFBFBF"), + Color.decode("0xA9A938"), Color.decode("0x2D4587")}, + new Paint[] {Color.decode("0xFFFF00"), + Color.decode("0x0036CC")}, + new Stroke[] {new BasicStroke(2.0f)}, + new Stroke[] {new BasicStroke(0.5f)}, + DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE); + theme.wallPaint = Color.darkGray; + theme.errorIndicatorPaint = Color.lightGray; + theme.gridBandPaint = new Color(255, 255, 255, 20); + theme.gridBandAlternatePaint = new Color(255, 255, 255, 40); + theme.shadowGenerator = null; + return theme; + } + + /** + * Creates and returns a {@link ChartTheme} that doesn't apply any changes + * to the JFreeChart defaults. This produces the "legacy" look for + * JFreeChart. + * + * @return A legacy theme. + */ + public static ChartTheme createLegacyTheme() { + StandardChartTheme theme = new StandardChartTheme("Legacy") { + @Override + public void apply(JFreeChart chart) { + // do nothing at all + } + }; + return theme; + } + + /** + * Creates a new default instance. + * + * @param name the name of the theme (null not permitted). + */ + public StandardChartTheme(String name) { + this(name, false); + } + + /** + * Creates a new default instance. + * + * @param name the name of the theme (null not permitted). + * @param shadow a flag that controls whether a shadow generator is + * included. + * + * @since 1.0.14 + */ + public StandardChartTheme(String name, boolean shadow) { + ParamChecks.nullNotPermitted(name, "name"); + this.name = name; + this.extraLargeFont = new Font("Tahoma", Font.BOLD, 20); + this.largeFont = new Font("Tahoma", Font.BOLD, 14); + this.regularFont = new Font("Tahoma", Font.PLAIN, 12); + this.smallFont = new Font("Tahoma", Font.PLAIN, 10); + this.titlePaint = Color.black; + this.subtitlePaint = Color.black; + this.legendBackgroundPaint = Color.white; + this.legendItemPaint = Color.darkGray; + this.chartBackgroundPaint = Color.white; + this.drawingSupplier = new DefaultDrawingSupplier(); + this.plotBackgroundPaint = Color.lightGray; + this.plotOutlinePaint = Color.black; + this.labelLinkPaint = Color.black; + this.labelLinkStyle = PieLabelLinkStyle.CUBIC_CURVE; + this.axisOffset = new RectangleInsets(4, 4, 4, 4); + this.domainGridlinePaint = Color.white; + this.rangeGridlinePaint = Color.white; + this.baselinePaint = Color.black; + this.crosshairPaint = Color.blue; + this.axisLabelPaint = Color.darkGray; + this.tickLabelPaint = Color.darkGray; + this.barPainter = new GradientBarPainter(); + this.xyBarPainter = new GradientXYBarPainter(); + this.shadowVisible = false; + this.shadowPaint = Color.gray; + this.itemLabelPaint = Color.black; + this.thermometerPaint = Color.white; + this.wallPaint = BarRenderer3D.DEFAULT_WALL_PAINT; + this.errorIndicatorPaint = Color.black; + this.shadowGenerator = shadow ? new DefaultShadowGenerator() : null; + } + + /** + * Returns the largest font for this theme. + * + * @return The largest font for this theme. + * + * @see #setExtraLargeFont(Font) + */ + public Font getExtraLargeFont() { + return this.extraLargeFont; + } + + /** + * Sets the largest font for this theme. + * + * @param font the font (null not permitted). + * + * @see #getExtraLargeFont() + */ + public void setExtraLargeFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.extraLargeFont = font; + } + + /** + * Returns the large font for this theme. + * + * @return The large font (never null). + * + * @see #setLargeFont(Font) + */ + public Font getLargeFont() { + return this.largeFont; + } + + /** + * Sets the large font for this theme. + * + * @param font the font (null not permitted). + * + * @see #getLargeFont() + */ + public void setLargeFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.largeFont = font; + } + + /** + * Returns the regular font. + * + * @return The regular font (never null). + * + * @see #setRegularFont(Font) + */ + public Font getRegularFont() { + return this.regularFont; + } + + /** + * Sets the regular font for this theme. + * + * @param font the font (null not permitted). + * + * @see #getRegularFont() + */ + public void setRegularFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.regularFont = font; + } + + /** + * Returns the small font. + * + * @return The small font (never null). + * + * @see #setSmallFont(Font) + * + * @since 1.0.13 + */ + public Font getSmallFont() { + return this.smallFont; + } + + /** + * Sets the small font for this theme. + * + * @param font the font (null not permitted). + * + * @see #getSmallFont() + * + * @since 1.0.13 + */ + public void setSmallFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.smallFont = font; + } + + /** + * Returns the title paint. + * + * @return The title paint (never null). + * + * @see #setTitlePaint(Paint) + */ + public Paint getTitlePaint() { + return this.titlePaint; + } + + /** + * Sets the title paint. + * + * @param paint the paint (null not permitted). + * + * @see #getTitlePaint() + */ + public void setTitlePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.titlePaint = paint; + } + + /** + * Returns the subtitle paint. + * + * @return The subtitle paint (never null). + * + * @see #setSubtitlePaint(Paint) + */ + public Paint getSubtitlePaint() { + return this.subtitlePaint; + } + + /** + * Sets the subtitle paint. + * + * @param paint the paint (null not permitted). + * + * @see #getSubtitlePaint() + */ + public void setSubtitlePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.subtitlePaint = paint; + } + + /** + * Returns the chart background paint. + * + * @return The chart background paint (never null). + * + * @see #setChartBackgroundPaint(Paint) + */ + public Paint getChartBackgroundPaint() { + return this.chartBackgroundPaint; + } + + /** + * Sets the chart background paint. + * + * @param paint the paint (null not permitted). + * + * @see #getChartBackgroundPaint() + */ + public void setChartBackgroundPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.chartBackgroundPaint = paint; + } + + /** + * Returns the legend background paint. + * + * @return The legend background paint (never null). + * + * @see #setLegendBackgroundPaint(Paint) + */ + public Paint getLegendBackgroundPaint() { + return this.legendBackgroundPaint; + } + + /** + * Sets the legend background paint. + * + * @param paint the paint (null not permitted). + * + * @see #getLegendBackgroundPaint() + */ + public void setLegendBackgroundPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.legendBackgroundPaint = paint; + } + + /** + * Returns the legend item paint. + * + * @return The legend item paint (never null). + * + * @see #setLegendItemPaint(Paint) + */ + public Paint getLegendItemPaint() { + return this.legendItemPaint; + } + + /** + * Sets the legend item paint. + * + * @param paint the paint (null not permitted). + * + * @see #getLegendItemPaint() + */ + public void setLegendItemPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.legendItemPaint = paint; + } + + /** + * Returns the plot background paint. + * + * @return The plot background paint (never null). + * + * @see #setPlotBackgroundPaint(Paint) + */ + public Paint getPlotBackgroundPaint() { + return this.plotBackgroundPaint; + } + + /** + * Sets the plot background paint. + * + * @param paint the paint (null not permitted). + * + * @see #getPlotBackgroundPaint() + */ + public void setPlotBackgroundPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.plotBackgroundPaint = paint; + } + + /** + * Returns the plot outline paint. + * + * @return The plot outline paint (never null). + * + * @see #setPlotOutlinePaint(Paint) + */ + public Paint getPlotOutlinePaint() { + return this.plotOutlinePaint; + } + + /** + * Sets the plot outline paint. + * + * @param paint the paint (null not permitted). + * + * @see #getPlotOutlinePaint() + */ + public void setPlotOutlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.plotOutlinePaint = paint; + } + + /** + * Returns the label link style for pie charts. + * + * @return The label link style (never null). + * + * @see #setLabelLinkStyle(PieLabelLinkStyle) + */ + public PieLabelLinkStyle getLabelLinkStyle() { + return this.labelLinkStyle; + } + + /** + * Sets the label link style for pie charts. + * + * @param style the style (null not permitted). + * + * @see #getLabelLinkStyle() + */ + public void setLabelLinkStyle(PieLabelLinkStyle style) { + ParamChecks.nullNotPermitted(style, "style"); + this.labelLinkStyle = style; + } + + /** + * Returns the label link paint for pie charts. + * + * @return The label link paint (never null). + * + * @see #setLabelLinkPaint(Paint) + */ + public Paint getLabelLinkPaint() { + return this.labelLinkPaint; + } + + /** + * Sets the label link paint for pie charts. + * + * @param paint the paint (null not permitted). + * + * @see #getLabelLinkPaint() + */ + public void setLabelLinkPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.labelLinkPaint = paint; + } + + /** + * Returns the domain grid line paint. + * + * @return The domain grid line paint (never null). + * + * @see #setDomainGridlinePaint(Paint) + */ + public Paint getDomainGridlinePaint() { + return this.domainGridlinePaint; + } + + /** + * Sets the domain grid line paint. + * + * @param paint the paint (null not permitted). + * + * @see #getDomainGridlinePaint() + */ + public void setDomainGridlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.domainGridlinePaint = paint; + } + + /** + * Returns the range grid line paint. + * + * @return The range grid line paint (never null). + * + * @see #setRangeGridlinePaint(Paint) + */ + public Paint getRangeGridlinePaint() { + return this.rangeGridlinePaint; + } + + /** + * Sets the range grid line paint. + * + * @param paint the paint (null not permitted). + * + * @see #getRangeGridlinePaint() + */ + public void setRangeGridlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.rangeGridlinePaint = paint; + } + + /** + * Returns the baseline paint. + * + * @return The baseline paint. + * + * @since 1.0.13 + */ + public Paint getBaselinePaint() { + return this.baselinePaint; + } + + /** + * Sets the baseline paint. + * + * @param paint the paint (null not permitted). + * + * @since 1.0.13 + */ + public void setBaselinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.baselinePaint = paint; + } + + /** + * Returns the crosshair paint. + * + * @return The crosshair paint. + */ + public Paint getCrosshairPaint() { + return this.crosshairPaint; + } + + /** + * Sets the crosshair paint. + * + * @param paint the paint (null not permitted). + */ + public void setCrosshairPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.crosshairPaint = paint; + } + + /** + * Returns the axis offsets. + * + * @return The axis offsets (never null). + * + * @see #setAxisOffset(RectangleInsets) + */ + public RectangleInsets getAxisOffset() { + return this.axisOffset; + } + + /** + * Sets the axis offset. + * + * @param offset the offset (null not permitted). + * + * @see #getAxisOffset() + */ + public void setAxisOffset(RectangleInsets offset) { + ParamChecks.nullNotPermitted(offset, "offset"); + this.axisOffset = offset; + } + + /** + * Returns the axis label paint. + * + * @return The axis label paint (never null). + * + * @see #setAxisLabelPaint(Paint) + */ + public Paint getAxisLabelPaint() { + return this.axisLabelPaint; + } + + /** + * Sets the axis label paint. + * + * @param paint the paint (null not permitted). + * + * @see #getAxisLabelPaint() + */ + public void setAxisLabelPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.axisLabelPaint = paint; + } + + /** + * Returns the tick label paint. + * + * @return The tick label paint (never null). + * + * @see #setTickLabelPaint(Paint) + */ + public Paint getTickLabelPaint() { + return this.tickLabelPaint; + } + + /** + * Sets the tick label paint. + * + * @param paint the paint (null not permitted). + * + * @see #getTickLabelPaint() + */ + public void setTickLabelPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.tickLabelPaint = paint; + } + + /** + * Returns the item label paint. + * + * @return The item label paint (never null). + * + * @see #setItemLabelPaint(Paint) + */ + public Paint getItemLabelPaint() { + return this.itemLabelPaint; + } + + /** + * Sets the item label paint. + * + * @param paint the paint (null not permitted). + * + * @see #getItemLabelPaint() + */ + public void setItemLabelPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.itemLabelPaint = paint; + } + + /** + * Returns the shadow visibility flag. + * + * @return The shadow visibility flag. + * + * @see #setShadowVisible(boolean) + */ + public boolean isShadowVisible() { + return this.shadowVisible; + } + + /** + * Sets the shadow visibility flag. + * + * @param visible the flag. + * + * @see #isShadowVisible() + */ + public void setShadowVisible(boolean visible) { + this.shadowVisible = visible; + } + + /** + * Returns the shadow paint. + * + * @return The shadow paint (never null). + * + * @see #setShadowPaint(Paint) + */ + public Paint getShadowPaint() { + return this.shadowPaint; + } + + /** + * Sets the shadow paint. + * + * @param paint the paint (null not permitted). + * + * @see #getShadowPaint() + */ + public void setShadowPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.shadowPaint = paint; + } + + /** + * Returns the bar painter. + * + * @return The bar painter (never null). + * + * @see #setBarPainter(BarPainter) + */ + public BarPainter getBarPainter() { + return this.barPainter; + } + + /** + * Sets the bar painter. + * + * @param painter the painter (null not permitted). + * + * @see #getBarPainter() + */ + public void setBarPainter(BarPainter painter) { + ParamChecks.nullNotPermitted(painter, "painter"); + this.barPainter = painter; + } + + /** + * Returns the XY bar painter. + * + * @return The XY bar painter (never null). + * + * @see #setXYBarPainter(XYBarPainter) + */ + public XYBarPainter getXYBarPainter() { + return this.xyBarPainter; + } + + /** + * Sets the XY bar painter. + * + * @param painter the painter (null not permitted). + * + * @see #getXYBarPainter() + */ + public void setXYBarPainter(XYBarPainter painter) { + ParamChecks.nullNotPermitted(painter, "painter"); + this.xyBarPainter = painter; + } + + /** + * Returns the thermometer paint. + * + * @return The thermometer paint (never null). + * + * @see #setThermometerPaint(Paint) + */ + public Paint getThermometerPaint() { + return this.thermometerPaint; + } + + /** + * Sets the thermometer paint. + * + * @param paint the paint (null not permitted). + * + * @see #getThermometerPaint() + */ + public void setThermometerPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.thermometerPaint = paint; + } + + /** + * Returns the wall paint for charts with a 3D effect. + * + * @return The wall paint (never null). + * + * @see #setWallPaint(Paint) + */ + public Paint getWallPaint() { + return this.wallPaint; + } + + /** + * Sets the wall paint for charts with a 3D effect. + * + * @param paint the paint (null not permitted). + * + * @see #getWallPaint() + */ + public void setWallPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.wallPaint = paint; + } + + /** + * Returns the error indicator paint. + * + * @return The error indicator paint (never null). + * + * @see #setErrorIndicatorPaint(Paint) + */ + public Paint getErrorIndicatorPaint() { + return this.errorIndicatorPaint; + } + + /** + * Sets the error indicator paint. + * + * @param paint the paint (null not permitted). + * + * @see #getErrorIndicatorPaint() + */ + public void setErrorIndicatorPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.errorIndicatorPaint = paint; + } + + /** + * Returns the grid band paint. + * + * @return The grid band paint (never null). + * + * @see #setGridBandPaint(Paint) + */ + public Paint getGridBandPaint() { + return this.gridBandPaint; + } + + /** + * Sets the grid band paint. + * + * @param paint the paint (null not permitted). + * + * @see #getGridBandPaint() + */ + public void setGridBandPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.gridBandPaint = paint; + } + + /** + * Returns the grid band alternate paint (used for a {@link SymbolAxis}). + * + * @return The paint (never null). + * + * @see #setGridBandAlternatePaint(Paint) + */ + public Paint getGridBandAlternatePaint() { + return this.gridBandAlternatePaint; + } + + /** + * Sets the grid band alternate paint (used for a {@link SymbolAxis}). + * + * @param paint the paint (null not permitted). + * + * @see #getGridBandAlternatePaint() + */ + public void setGridBandAlternatePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.gridBandAlternatePaint = paint; + } + + /** + * Returns the name of this theme. + * + * @return The name of this theme. + */ + public String getName() { + return this.name; + } + + /** + * Returns a clone of the drawing supplier for this theme. + * + * @return A clone of the drawing supplier. + */ + public DrawingSupplier getDrawingSupplier() { + DrawingSupplier result = null; + if (this.drawingSupplier instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.drawingSupplier; + try { + result = (DrawingSupplier) pc.clone(); + } + catch (CloneNotSupportedException e) { + throw new RuntimeException(e); + } + } + return result; + } + + /** + * Sets the drawing supplier for this theme. + * + * @param supplier the supplier (null not permitted). + * + * @see #getDrawingSupplier() + */ + public void setDrawingSupplier(DrawingSupplier supplier) { + ParamChecks.nullNotPermitted(supplier, "supplier"); + this.drawingSupplier = supplier; + } + + /** + * Applies this theme to the supplied chart. + * + * @param chart the chart (null not permitted). + */ + @Override + public void apply(JFreeChart chart) { + ParamChecks.nullNotPermitted(chart, "chart"); + TextTitle title = chart.getTitle(); + if (title != null) { + title.setFont(this.extraLargeFont); + title.setPaint(this.titlePaint); + } + + int subtitleCount = chart.getSubtitleCount(); + for (int i = 0; i < subtitleCount; i++) { + applyToTitle(chart.getSubtitle(i)); + } + + chart.setBackgroundPaint(this.chartBackgroundPaint); + + // now process the plot if there is one + Plot plot = chart.getPlot(); + if (plot != null) { + applyToPlot(plot); + } + } + + /** + * Applies the attributes of this theme to the specified title. + * + * @param title the title. + */ + protected void applyToTitle(Title title) { + if (title instanceof TextTitle) { + TextTitle tt = (TextTitle) title; + tt.setFont(this.largeFont); + tt.setPaint(this.subtitlePaint); + } + else if (title instanceof LegendTitle) { + LegendTitle lt = (LegendTitle) title; + if (lt.getBackgroundPaint() != null) { + lt.setBackgroundPaint(this.legendBackgroundPaint); + } + lt.setItemFont(this.regularFont); + lt.setItemPaint(this.legendItemPaint); + if (lt.getWrapper() != null) { + applyToBlockContainer(lt.getWrapper()); + } + } + else if (title instanceof PaintScaleLegend) { + PaintScaleLegend psl = (PaintScaleLegend) title; + psl.setBackgroundPaint(this.legendBackgroundPaint); + ValueAxis axis = psl.getAxis(); + if (axis != null) { + applyToValueAxis(axis); + } + } + else if (title instanceof CompositeTitle) { + CompositeTitle ct = (CompositeTitle) title; + BlockContainer bc = ct.getContainer(); + List blocks = bc.getBlocks(); + Iterator iterator = blocks.iterator(); + while (iterator.hasNext()) { + Block b = (Block) iterator.next(); + if (b instanceof Title) { + applyToTitle((Title) b); + } + } + } + } + + /** + * Applies the attributes of this theme to the specified container. + * + * @param bc a block container (null not permitted). + */ + protected void applyToBlockContainer(BlockContainer bc) { + Iterator iterator = bc.getBlocks().iterator(); + while (iterator.hasNext()) { + Block b = (Block) iterator.next(); + applyToBlock(b); + } + } + + /** + * Applies the attributes of this theme to the specified block. + * + * @param b the block. + */ + protected void applyToBlock(Block b) { + if (b instanceof Title) { + applyToTitle((Title) b); + } + else if (b instanceof LabelBlock) { + LabelBlock lb = (LabelBlock) b; + lb.setFont(this.regularFont); + lb.setPaint(this.legendItemPaint); + } + } + + /** + * Applies the attributes of this theme to a plot. + * + * @param plot the plot (null). + */ + protected void applyToPlot(Plot plot) { + ParamChecks.nullNotPermitted(plot, "plot"); + if (plot.getDrawingSupplier() != null) { + plot.setDrawingSupplier(getDrawingSupplier()); + } + if (plot.getBackgroundPaint() != null) { + plot.setBackgroundPaint(this.plotBackgroundPaint); + } + plot.setOutlinePaint(this.plotOutlinePaint); + + // now handle specific plot types (and yes, I know this is some + // really ugly code that has to be manually updated any time a new + // plot type is added - I should have written something much cooler, + // but I didn't and neither did anyone else). + if (plot instanceof PiePlot) { + applyToPiePlot((PiePlot) plot); + } + else if (plot instanceof MultiplePiePlot) { + applyToMultiplePiePlot((MultiplePiePlot) plot); + } + else if (plot instanceof CategoryPlot) { + applyToCategoryPlot((CategoryPlot) plot); + } + else if (plot instanceof XYPlot) { + applyToXYPlot((XYPlot) plot); + } + else if (plot instanceof FastScatterPlot) { + applyToFastScatterPlot((FastScatterPlot) plot); + } + else if (plot instanceof MeterPlot) { + applyToMeterPlot((MeterPlot) plot); + } + else if (plot instanceof ThermometerPlot) { + applyToThermometerPlot((ThermometerPlot) plot); + } + else if (plot instanceof SpiderWebPlot) { + applyToSpiderWebPlot((SpiderWebPlot) plot); + } + else if (plot instanceof PolarPlot) { + applyToPolarPlot((PolarPlot) plot); + } + } + + /** + * Applies the attributes of this theme to a {@link PiePlot} instance. + * This method also clears any set values for the section paint, outline + * etc, so that the theme's {@link DrawingSupplier} will be used. + * + * @param plot the plot (null not permitted). + */ + protected void applyToPiePlot(PiePlot plot) { + plot.setLabelLinkPaint(this.labelLinkPaint); + plot.setLabelLinkStyle(this.labelLinkStyle); + plot.setLabelFont(this.regularFont); + plot.setShadowGenerator(this.shadowGenerator); + + // clear the section attributes so that the theme's DrawingSupplier + // will be used + if (plot.getAutoPopulateSectionPaint()) { + plot.clearSectionPaints(false); + } + if (plot.getAutoPopulateSectionOutlinePaint()) { + plot.clearSectionOutlinePaints(false); + } + if (plot.getAutoPopulateSectionOutlineStroke()) { + plot.clearSectionOutlineStrokes(false); + } + } + + /** + * Applies the attributes of this theme to a {@link MultiplePiePlot}. + * + * @param plot the plot (null not permitted). + */ + protected void applyToMultiplePiePlot(MultiplePiePlot plot) { + apply(plot.getPieChart()); + } + + /** + * Applies the attributes of this theme to a {@link CategoryPlot}. + * + * @param plot the plot (null not permitted). + */ + protected void applyToCategoryPlot(CategoryPlot plot) { + plot.setAxisOffset(this.axisOffset); + plot.setDomainGridlinePaint(this.domainGridlinePaint); + plot.setRangeGridlinePaint(this.rangeGridlinePaint); + plot.setRangeZeroBaselinePaint(this.baselinePaint); + plot.setShadowGenerator(this.shadowGenerator); + + // process all domain axes + int domainAxisCount = plot.getDomainAxisCount(); + for (int i = 0; i < domainAxisCount; i++) { + CategoryAxis axis = plot.getDomainAxis(i); + if (axis != null) { + applyToCategoryAxis(axis); + } + } + + // process all range axes + int rangeAxisCount = plot.getRangeAxisCount(); + for (int i = 0; i < rangeAxisCount; i++) { + ValueAxis axis = plot.getRangeAxis(i); + if (axis != null) { + applyToValueAxis(axis); + } + } + + // process all renderers + int rendererCount = plot.getRendererCount(); + for (int i = 0; i < rendererCount; i++) { + CategoryItemRenderer r = plot.getRenderer(i); + if (r != null) { + applyToCategoryItemRenderer(r); + } + } + + if (plot instanceof CombinedDomainCategoryPlot) { + CombinedDomainCategoryPlot cp = (CombinedDomainCategoryPlot) plot; + Iterator iterator = cp.getSubplots().iterator(); + while (iterator.hasNext()) { + CategoryPlot subplot = (CategoryPlot) iterator.next(); + if (subplot != null) { + applyToPlot(subplot); + } + } + } + if (plot instanceof CombinedRangeCategoryPlot) { + CombinedRangeCategoryPlot cp = (CombinedRangeCategoryPlot) plot; + Iterator iterator = cp.getSubplots().iterator(); + while (iterator.hasNext()) { + CategoryPlot subplot = (CategoryPlot) iterator.next(); + if (subplot != null) { + applyToPlot(subplot); + } + } + } + } + + /** + * Applies the attributes of this theme to a {@link XYPlot}. + * + * @param plot the plot (null not permitted). + */ + protected void applyToXYPlot(XYPlot plot) { + plot.setAxisOffset(this.axisOffset); + plot.setDomainZeroBaselinePaint(this.baselinePaint); + plot.setRangeZeroBaselinePaint(this.baselinePaint); + plot.setDomainGridlinePaint(this.domainGridlinePaint); + plot.setRangeGridlinePaint(this.rangeGridlinePaint); + plot.setDomainCrosshairPaint(this.crosshairPaint); + plot.setRangeCrosshairPaint(this.crosshairPaint); + plot.setShadowGenerator(this.shadowGenerator); + + // process all domain axes + int domainAxisCount = plot.getDomainAxisCount(); + for (int i = 0; i < domainAxisCount; i++) { + ValueAxis axis = plot.getDomainAxis(i); + if (axis != null) { + applyToValueAxis(axis); + } + } + + // process all range axes + int rangeAxisCount = plot.getRangeAxisCount(); + for (int i = 0; i < rangeAxisCount; i++) { + ValueAxis axis = plot.getRangeAxis(i); + if (axis != null) { + applyToValueAxis(axis); + } + } + + // process all renderers + int rendererCount = plot.getRendererCount(); + for (int i = 0; i < rendererCount; i++) { + XYItemRenderer r = plot.getRenderer(i); + if (r != null) { + applyToXYItemRenderer(r); + } + } + + // process all annotations + Iterator iter = plot.getAnnotations().iterator(); + while (iter.hasNext()) { + XYAnnotation a = (XYAnnotation) iter.next(); + applyToXYAnnotation(a); + } + + if (plot instanceof CombinedDomainXYPlot) { + CombinedDomainXYPlot cp = (CombinedDomainXYPlot) plot; + Iterator iterator = cp.getSubplots().iterator(); + while (iterator.hasNext()) { + XYPlot subplot = (XYPlot) iterator.next(); + if (subplot != null) { + applyToPlot(subplot); + } + } + } + if (plot instanceof CombinedRangeXYPlot) { + CombinedRangeXYPlot cp = (CombinedRangeXYPlot) plot; + Iterator iterator = cp.getSubplots().iterator(); + while (iterator.hasNext()) { + XYPlot subplot = (XYPlot) iterator.next(); + if (subplot != null) { + applyToPlot(subplot); + } + } + } + } + + /** + * Applies the attributes of this theme to a {@link FastScatterPlot}. + * @param plot + */ + protected void applyToFastScatterPlot(FastScatterPlot plot) { + plot.setDomainGridlinePaint(this.domainGridlinePaint); + plot.setRangeGridlinePaint(this.rangeGridlinePaint); + ValueAxis xAxis = plot.getDomainAxis(); + if (xAxis != null) { + applyToValueAxis(xAxis); + } + ValueAxis yAxis = plot.getRangeAxis(); + if (yAxis != null) { + applyToValueAxis(yAxis); + } + + } + + /** + * Applies the attributes of this theme to a {@link PolarPlot}. This + * method is called from the {@link #applyToPlot(Plot)} method. + * + * @param plot the plot (null not permitted). + */ + protected void applyToPolarPlot(PolarPlot plot) { + plot.setAngleLabelFont(this.regularFont); + plot.setAngleLabelPaint(this.tickLabelPaint); + plot.setAngleGridlinePaint(this.domainGridlinePaint); + plot.setRadiusGridlinePaint(this.rangeGridlinePaint); + ValueAxis axis = plot.getAxis(); + if (axis != null) { + applyToValueAxis(axis); + } + } + + /** + * Applies the attributes of this theme to a {@link SpiderWebPlot}. + * + * @param plot the plot (null not permitted). + */ + protected void applyToSpiderWebPlot(SpiderWebPlot plot) { + plot.setLabelFont(this.regularFont); + plot.setLabelPaint(this.axisLabelPaint); + plot.setAxisLinePaint(this.axisLabelPaint); + } + + /** + * Applies the attributes of this theme to a {@link MeterPlot}. + * + * @param plot the plot (null not permitted). + */ + protected void applyToMeterPlot(MeterPlot plot) { + plot.setDialBackgroundPaint(this.plotBackgroundPaint); + plot.setValueFont(this.largeFont); + plot.setValuePaint(this.axisLabelPaint); + plot.setDialOutlinePaint(this.plotOutlinePaint); + plot.setNeedlePaint(this.thermometerPaint); + plot.setTickLabelFont(this.regularFont); + plot.setTickLabelPaint(this.tickLabelPaint); + } + + /** + * Applies the attributes for this theme to a {@link ThermometerPlot}. + * This method is called from the {@link #applyToPlot(Plot)} method. + * + * @param plot the plot. + */ + protected void applyToThermometerPlot(ThermometerPlot plot) { + plot.setValueFont(this.largeFont); + plot.setThermometerPaint(this.thermometerPaint); + ValueAxis axis = plot.getRangeAxis(); + if (axis != null) { + applyToValueAxis(axis); + } + } + + /** + * Applies the attributes for this theme to a {@link CategoryAxis}. + * + * @param axis the axis (null not permitted). + */ + protected void applyToCategoryAxis(CategoryAxis axis) { + axis.setLabelFont(this.largeFont); + axis.setLabelPaint(this.axisLabelPaint); + axis.setTickLabelFont(this.regularFont); + axis.setTickLabelPaint(this.tickLabelPaint); + if (axis instanceof SubCategoryAxis) { + SubCategoryAxis sca = (SubCategoryAxis) axis; + sca.setSubLabelFont(this.regularFont); + sca.setSubLabelPaint(this.tickLabelPaint); + } + } + + /** + * Applies the attributes for this theme to a {@link ValueAxis}. + * + * @param axis the axis (null not permitted). + */ + protected void applyToValueAxis(ValueAxis axis) { + axis.setLabelFont(this.largeFont); + axis.setLabelPaint(this.axisLabelPaint); + axis.setTickLabelFont(this.regularFont); + axis.setTickLabelPaint(this.tickLabelPaint); + if (axis instanceof SymbolAxis) { + applyToSymbolAxis((SymbolAxis) axis); + } + if (axis instanceof PeriodAxis) { + applyToPeriodAxis((PeriodAxis) axis); + } + } + + /** + * Applies the attributes for this theme to a {@link SymbolAxis}. + * + * @param axis the axis (null not permitted). + */ + protected void applyToSymbolAxis(SymbolAxis axis) { + axis.setGridBandPaint(this.gridBandPaint); + axis.setGridBandAlternatePaint(this.gridBandAlternatePaint); + } + + /** + * Applies the attributes for this theme to a {@link PeriodAxis}. + * + * @param axis the axis (null not permitted). + */ + protected void applyToPeriodAxis(PeriodAxis axis) { + PeriodAxisLabelInfo[] info = axis.getLabelInfo(); + for (int i = 0; i < info.length; i++) { + PeriodAxisLabelInfo e = info[i]; + PeriodAxisLabelInfo n = new PeriodAxisLabelInfo(e.getPeriodClass(), + e.getDateFormat(), e.getPadding(), this.regularFont, + this.tickLabelPaint, e.getDrawDividers(), + e.getDividerStroke(), e.getDividerPaint()); + info[i] = n; + } + axis.setLabelInfo(info); + } + + /** + * Applies the attributes for this theme to an {@link AbstractRenderer}. + * + * @param renderer the renderer (null not permitted). + */ + protected void applyToAbstractRenderer(AbstractRenderer renderer) { + if (renderer.getAutoPopulateSeriesPaint()) { + renderer.clearSeriesPaints(false); + } + if (renderer.getAutoPopulateSeriesStroke()) { + renderer.clearSeriesStrokes(false); + } + } + + /** + * Applies the settings of this theme to the specified renderer. + * + * @param renderer the renderer (null not permitted). + */ + protected void applyToCategoryItemRenderer(CategoryItemRenderer renderer) { + ParamChecks.nullNotPermitted(renderer, "renderer"); + + if (renderer instanceof AbstractRenderer) { + applyToAbstractRenderer((AbstractRenderer) renderer); + } + + renderer.setBaseItemLabelFont(this.regularFont); + renderer.setBaseItemLabelPaint(this.itemLabelPaint); + + // now we handle some special cases - yes, UGLY code alert! + + // BarRenderer + if (renderer instanceof BarRenderer) { + BarRenderer br = (BarRenderer) renderer; + br.setBarPainter(this.barPainter); + br.setShadowVisible(this.shadowVisible); + br.setShadowPaint(this.shadowPaint); + } + + // BarRenderer3D + if (renderer instanceof BarRenderer3D) { + BarRenderer3D br3d = (BarRenderer3D) renderer; + br3d.setWallPaint(this.wallPaint); + } + + // LineRenderer3D + if (renderer instanceof LineRenderer3D) { + LineRenderer3D lr3d = (LineRenderer3D) renderer; + lr3d.setWallPaint(this.wallPaint); + } + + // StatisticalBarRenderer + if (renderer instanceof StatisticalBarRenderer) { + StatisticalBarRenderer sbr = (StatisticalBarRenderer) renderer; + sbr.setErrorIndicatorPaint(this.errorIndicatorPaint); + } + + // MinMaxCategoryRenderer + if (renderer instanceof MinMaxCategoryRenderer) { + MinMaxCategoryRenderer mmcr = (MinMaxCategoryRenderer) renderer; + mmcr.setGroupPaint(this.errorIndicatorPaint); + } + } + + /** + * Applies the settings of this theme to the specified renderer. + * + * @param renderer the renderer (null not permitted). + */ + protected void applyToXYItemRenderer(XYItemRenderer renderer) { + ParamChecks.nullNotPermitted(renderer, "renderer"); + if (renderer instanceof AbstractRenderer) { + applyToAbstractRenderer((AbstractRenderer) renderer); + } + renderer.setBaseItemLabelFont(this.regularFont); + renderer.setBaseItemLabelPaint(this.itemLabelPaint); + if (renderer instanceof XYBarRenderer) { + XYBarRenderer br = (XYBarRenderer) renderer; + br.setBarPainter(this.xyBarPainter); + br.setShadowVisible(this.shadowVisible); + } + } + + /** + * Applies the settings of this theme to the specified annotation. + * + * @param annotation the annotation. + */ + protected void applyToXYAnnotation(XYAnnotation annotation) { + ParamChecks.nullNotPermitted(annotation, "annotation"); + if (annotation instanceof XYTextAnnotation) { + XYTextAnnotation xyta = (XYTextAnnotation) annotation; + xyta.setFont(this.smallFont); + xyta.setPaint(this.itemLabelPaint); + } + } + + /** + * Tests this theme for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardChartTheme)) { + return false; + } + StandardChartTheme that = (StandardChartTheme) obj; + if (!this.name.equals(that.name)) { + return false; + } + if (!this.extraLargeFont.equals(that.extraLargeFont)) { + return false; + } + if (!this.largeFont.equals(that.largeFont)) { + return false; + } + if (!this.regularFont.equals(that.regularFont)) { + return false; + } + if (!this.smallFont.equals(that.smallFont)) { + return false; + } + if (!PaintUtilities.equal(this.titlePaint, that.titlePaint)) { + return false; + } + if (!PaintUtilities.equal(this.subtitlePaint, that.subtitlePaint)) { + return false; + } + if (!PaintUtilities.equal(this.chartBackgroundPaint, + that.chartBackgroundPaint)) { + return false; + } + if (!PaintUtilities.equal(this.legendBackgroundPaint, + that.legendBackgroundPaint)) { + return false; + } + if (!PaintUtilities.equal(this.legendItemPaint, that.legendItemPaint)) { + return false; + } + if (!this.drawingSupplier.equals(that.drawingSupplier)) { + return false; + } + if (!PaintUtilities.equal(this.plotBackgroundPaint, + that.plotBackgroundPaint)) { + return false; + } + if (!PaintUtilities.equal(this.plotOutlinePaint, + that.plotOutlinePaint)) { + return false; + } + if (!this.labelLinkStyle.equals(that.labelLinkStyle)) { + return false; + } + if (!PaintUtilities.equal(this.labelLinkPaint, that.labelLinkPaint)) { + return false; + } + if (!PaintUtilities.equal(this.domainGridlinePaint, + that.domainGridlinePaint)) { + return false; + } + if (!PaintUtilities.equal(this.rangeGridlinePaint, + that.rangeGridlinePaint)) { + return false; + } + if (!PaintUtilities.equal(this.crosshairPaint, that.crosshairPaint)) { + return false; + } + if (!this.axisOffset.equals(that.axisOffset)) { + return false; + } + if (!PaintUtilities.equal(this.axisLabelPaint, that.axisLabelPaint)) { + return false; + } + if (!PaintUtilities.equal(this.tickLabelPaint, that.tickLabelPaint)) { + return false; + } + if (!PaintUtilities.equal(this.itemLabelPaint, that.itemLabelPaint)) { + return false; + } + if (this.shadowVisible != that.shadowVisible) { + return false; + } + if (!PaintUtilities.equal(this.shadowPaint, that.shadowPaint)) { + return false; + } + if (!this.barPainter.equals(that.barPainter)) { + return false; + } + if (!this.xyBarPainter.equals(that.xyBarPainter)) { + return false; + } + if (!PaintUtilities.equal(this.thermometerPaint, + that.thermometerPaint)) { + return false; + } + if (!PaintUtilities.equal(this.wallPaint, that.wallPaint)) { + return false; + } + if (!PaintUtilities.equal(this.errorIndicatorPaint, + that.errorIndicatorPaint)) { + return false; + } + if (!PaintUtilities.equal(this.gridBandPaint, that.gridBandPaint)) { + return false; + } + if (!PaintUtilities.equal(this.gridBandAlternatePaint, + that.gridBandAlternatePaint)) { + return false; + } + return true; + } + + /** + * Returns a clone of this theme. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the theme cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Provides serialization support. + * + * @param stream the output stream (null not permitted). + * + * @throws IOException if there is an I/O error. + */ + private void writeObject(ObjectOutputStream stream) throws IOException { + stream.defaultWriteObject(); + SerialUtilities.writePaint(this.titlePaint, stream); + SerialUtilities.writePaint(this.subtitlePaint, stream); + SerialUtilities.writePaint(this.chartBackgroundPaint, stream); + SerialUtilities.writePaint(this.legendBackgroundPaint, stream); + SerialUtilities.writePaint(this.legendItemPaint, stream); + SerialUtilities.writePaint(this.plotBackgroundPaint, stream); + SerialUtilities.writePaint(this.plotOutlinePaint, stream); + SerialUtilities.writePaint(this.labelLinkPaint, stream); + SerialUtilities.writePaint(this.baselinePaint, stream); + SerialUtilities.writePaint(this.domainGridlinePaint, stream); + SerialUtilities.writePaint(this.rangeGridlinePaint, stream); + SerialUtilities.writePaint(this.crosshairPaint, stream); + SerialUtilities.writePaint(this.axisLabelPaint, stream); + SerialUtilities.writePaint(this.tickLabelPaint, stream); + SerialUtilities.writePaint(this.itemLabelPaint, stream); + SerialUtilities.writePaint(this.shadowPaint, stream); + SerialUtilities.writePaint(this.thermometerPaint, stream); + SerialUtilities.writePaint(this.wallPaint, stream); + SerialUtilities.writePaint(this.errorIndicatorPaint, stream); + SerialUtilities.writePaint(this.gridBandPaint, stream); + SerialUtilities.writePaint(this.gridBandAlternatePaint, stream); + } + + /** + * Provides serialization support. + * + * @param stream the input stream (null 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.titlePaint = SerialUtilities.readPaint(stream); + this.subtitlePaint = SerialUtilities.readPaint(stream); + this.chartBackgroundPaint = SerialUtilities.readPaint(stream); + this.legendBackgroundPaint = SerialUtilities.readPaint(stream); + this.legendItemPaint = SerialUtilities.readPaint(stream); + this.plotBackgroundPaint = SerialUtilities.readPaint(stream); + this.plotOutlinePaint = SerialUtilities.readPaint(stream); + this.labelLinkPaint = SerialUtilities.readPaint(stream); + this.baselinePaint = SerialUtilities.readPaint(stream); + this.domainGridlinePaint = SerialUtilities.readPaint(stream); + this.rangeGridlinePaint = SerialUtilities.readPaint(stream); + this.crosshairPaint = SerialUtilities.readPaint(stream); + this.axisLabelPaint = SerialUtilities.readPaint(stream); + this.tickLabelPaint = SerialUtilities.readPaint(stream); + this.itemLabelPaint = SerialUtilities.readPaint(stream); + this.shadowPaint = SerialUtilities.readPaint(stream); + this.thermometerPaint = SerialUtilities.readPaint(stream); + this.wallPaint = SerialUtilities.readPaint(stream); + this.errorIndicatorPaint = SerialUtilities.readPaint(stream); + this.gridBandPaint = SerialUtilities.readPaint(stream); + this.gridBandAlternatePaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/StrokeMap.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/StrokeMap.java new file mode 100755 index 0000000..3fad90e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/StrokeMap.java @@ -0,0 +1,217 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * StrokeMap.java + * -------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 27-Sep-2006 : Version 1 (DG); + * 02-Jul-2013 : Use ParamChecks (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.chart.util.ParamChecks; + +import org.jfree.io.SerialUtilities; +import org.jfree.util.ObjectUtilities; + +/** + * A storage structure that maps Comparable instances with + * Stroke instances. + *

+ * To support cloning and serialization, you should only use keys that are + * cloneable and serializable. Special handling for the Stroke + * 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 + * null. + * + * @param key the key (null not permitted). + * + * @return The stroke, or null. + * + * @throws IllegalArgumentException if key is + * null. + */ + public Stroke getStroke(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + return (Stroke) this.store.get(key); + } + + /** + * Returns true if the map contains the specified key, and + * false otherwise. + * + * @param key the key. + * + * @return true if the map contains the specified key, and + * false otherwise. + */ + public boolean containsKey(Comparable key) { + return this.store.containsKey(key); + } + + /** + * Adds a mapping between the specified key and + * stroke values. + * + * @param key the key (null not permitted). + * @param stroke the stroke. + */ + public void put(Comparable key, Stroke stroke) { + ParamChecks.nullNotPermitted(key, "key"); + 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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 StrokeMap. + * + * @return A clone of this instance. + * + * @throws CloneNotSupportedException if any key is not cloneable. + */ + @Override + 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); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/AbstractAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/AbstractAnnotation.java new file mode 100755 index 0000000..f5ba0fe --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/AbstractAnnotation.java @@ -0,0 +1,225 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * AbstractAnnotation.java + * ----------------------- + * (C) Copyright 2009-2013, by Object Refinery Limited and Contributors. + * + * Original Author: Peter Kolb (see patch 2809117); + * Contributor(s): -; + * + * Changes: + * -------- + * 20-Jun-2009 : Version 1 (PK); + * + */ + +package org.jfree.chart.annotations; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Arrays; +import java.util.EventListener; +import java.util.List; + +import javax.swing.event.EventListenerList; + +import org.jfree.chart.event.AnnotationChangeEvent; +import org.jfree.chart.event.AnnotationChangeListener; + +/** + * An abstract implementation of the {@link Annotation} interface, containing a + * mechanism for registering change listeners. + * + * @since 1.0.14 + */ +public abstract class AbstractAnnotation implements Annotation, Cloneable, + Serializable { + + /** Storage for registered change listeners. */ + private transient EventListenerList listenerList; + + /** + * A flag that indicates whether listeners should be notified + * about changes of the annotation. + */ + private boolean notify = true; + + /** + * Constructs an annotation. + */ + protected AbstractAnnotation() { + this.listenerList = new EventListenerList(); + } + + /** + * Registers an object to receive notification of changes to the + * annotation. + * + * @param listener the object to register. + * + * @see #removeChangeListener(AnnotationChangeListener) + */ + @Override + public void addChangeListener(AnnotationChangeListener listener) { + this.listenerList.add(AnnotationChangeListener.class, listener); + } + + /** + * Deregisters an object so that it no longer receives notification of + * changes to the annotation. + * + * @param listener the object to deregister. + * + * @see #addChangeListener(AnnotationChangeListener) + */ + @Override + public void removeChangeListener(AnnotationChangeListener listener) { + this.listenerList.remove(AnnotationChangeListener.class, listener); + } + + /** + * Returns true if the specified object is registered with + * the annotation as a listener. Most applications won't need to call this + * method, it exists mainly for use by unit testing code. + * + * @param listener the listener. + * + * @return A boolean. + * + * @see #addChangeListener(AnnotationChangeListener) + * @see #removeChangeListener(AnnotationChangeListener) + */ + public boolean hasListener(EventListener listener) { + List list = Arrays.asList(this.listenerList.getListenerList()); + return list.contains(listener); + } + + /** + * Notifies all registered listeners that the annotation has changed. + * + * @see #addChangeListener(AnnotationChangeListener) + */ + protected void fireAnnotationChanged() { + if (notify) { + notifyListeners(new AnnotationChangeEvent(this, this)); + } + } + + /** + * Notifies all registered listeners that the annotation has changed. + * + * @param event contains information about the event that triggered the + * notification. + * + * @see #addChangeListener(AnnotationChangeListener) + * @see #removeChangeListener(AnnotationChangeListener) + */ + protected void notifyListeners(AnnotationChangeEvent event) { + + Object[] listeners = this.listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == AnnotationChangeListener.class) { + ((AnnotationChangeListener) listeners[i + 1]).annotationChanged( + event); + } + } + + } + + /** + * Returns a flag that indicates whether listeners should be + * notified about changes to the annotation. + * + * @return the flag. + * + * @see #setNotify(boolean) + */ + public boolean getNotify(){ + return this.notify; + } + + /** + * Sets a flag that indicates whether listeners should be notified about + * changes of an annotation. + * + * @param flag the flag + * + * @see #getNotify() + */ + public void setNotify(boolean flag){ + this.notify = flag; + if (notify) { + fireAnnotationChanged(); + } + } + + /** + * Returns a clone of the annotation. The cloned annotation will NOT + * include the {@link AnnotationChangeListener} references that have been + * registered with this annotation. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the annotation does not support + * cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + AbstractAnnotation clone = (AbstractAnnotation) super.clone(); + clone.listenerList = new EventListenerList(); + return clone; + } + + /** + * Handles serialization. + * + * @param stream the output stream. + * + * @throws IOException if there is an I/O problem. + */ + private void writeObject(ObjectOutputStream stream) throws IOException { + stream.defaultWriteObject(); + } + + /** + * Restores a serialized object. + * + * @param stream the input stream. + * + * @throws IOException if there is an I/O problem. + * @throws ClassNotFoundException if there is a problem loading a class. + */ + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + this.listenerList = new EventListenerList(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/AbstractXYAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/AbstractXYAnnotation.java new file mode 100755 index 0000000..7770398 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/AbstractXYAnnotation.java @@ -0,0 +1,211 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * AbstractXYAnnotation.java + * ------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (patch 2809117); + * + * Changes: + * -------- + * 29-Sep-2004 : Version 1 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 06-Mar-2007 : Implemented hashCode() (DG); + * 24-Jun-2009 : Now extends AbstractAnnotation (see patch 2809117 by PK) (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 extends AbstractAnnotation + 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() { + super(); + 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 null). + * + * @see #setToolTipText(String) + */ + public String getToolTipText() { + return this.toolTipText; + } + + /** + * Sets the tool tip text for the annotation. + * + * @param text the tool tip text (null 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 null). + * + * @see #setURL(String) + */ + public String getURL() { + return this.url; + } + + /** + * Sets the URL for the annotation. + * + * @param url the URL (null 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. + */ + @Override + 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 (null 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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. + */ + @Override + 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; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/Annotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/Annotation.java new file mode 100755 index 0000000..b908566 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/Annotation.java @@ -0,0 +1,69 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * Annotation.java + * --------------- + * (C) Copyright 2009, 2011 by Object Refinery Limited and Contributors. + * + * Original Author: Peter Kolb (see patch 2809117); + * Contributor(s): ; + * + * Changes: + * -------- + * 20-Jun-2009 : Version 1 (PK); + * + */ + +package org.jfree.chart.annotations; + +import org.jfree.chart.event.AnnotationChangeEvent; +import org.jfree.chart.event.AnnotationChangeListener; + +/** + * The base interface for annotations. All annotations should support the + * {@link AnnotationChangeEvent} mechanism by allowing listeners to register + * and receive notification of any changes to the annotation. + * + * @since 1.0.14 + */ +public interface Annotation { + + /** + * Registers an object for notification of changes to the annotation. + * + * @param listener the object to register. + */ + public void addChangeListener(AnnotationChangeListener listener); + + /** + * Deregisters an object for notification of changes to the annotation. + * + * @param listener the object to deregister. + */ + public void removeChangeListener(AnnotationChangeListener listener); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/CategoryAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/CategoryAnnotation.java new file mode 100755 index 0000000..6c5cdbb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/CategoryAnnotation.java @@ -0,0 +1,72 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * CategoryAnnotation.java + * ----------------------- + * (C) Copyright 2003-2009, 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); + * 24-Jun-2009 : Now extends Annotation (see patch 2809117 by PK) (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 CategoryPlot}. Note that, in JFreeChart 1.0.14, a non-compatible + * change has been made to this interface (it now extends the Annotation + * interface to support change notifications). + */ +public interface CategoryAnnotation extends Annotation { + + /** + * 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); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/CategoryLineAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/CategoryLineAnnotation.java new file mode 100755 index 0000000..944616f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/CategoryLineAnnotation.java @@ -0,0 +1,428 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * CategoryLineAnnotation.java + * --------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (patch 2809117); + * + * 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); + * 24-Jun-2009 : Now extends AbstractAnnotation (see patch 2809117 by PK) (DG); + * 02-Jul-2013 : Use ParamChecks (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.event.AnnotationChangeEvent; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.util.ParamChecks; +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 extends AbstractAnnotation + 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 (null not permitted). + * @param value1 the value. + * @param category2 the category (null not permitted). + * @param value2 the value. + * @param paint the line color (null not permitted). + * @param stroke the line stroke (null not permitted). + */ + public CategoryLineAnnotation(Comparable category1, double value1, + Comparable category2, double value2, + Paint paint, Stroke stroke) { + super(); + ParamChecks.nullNotPermitted(category1, "category1"); + ParamChecks.nullNotPermitted(category2, "category2"); + ParamChecks.nullNotPermitted(paint, "paint"); + ParamChecks.nullNotPermitted(stroke, "stroke"); + 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 null). + * + * @see #setCategory1(Comparable) + */ + public Comparable getCategory1() { + return this.category1; + } + + /** + * Sets the category for the start of the line and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param category the category (null not permitted). + * + * @see #getCategory1() + */ + public void setCategory1(Comparable category) { + ParamChecks.nullNotPermitted(category, "category"); + this.category1 = category; + fireAnnotationChanged(); + } + + /** + * 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 and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param value the value. + * + * @see #getValue1() + */ + public void setValue1(double value) { + this.value1 = value; + fireAnnotationChanged(); + } + + /** + * Returns the category for the end of the line. + * + * @return The category for the end of the line (never null). + * + * @see #setCategory2(Comparable) + */ + public Comparable getCategory2() { + return this.category2; + } + + /** + * Sets the category for the end of the line and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param category the category (null not permitted). + * + * @see #getCategory2() + */ + public void setCategory2(Comparable category) { + ParamChecks.nullNotPermitted(category, "category"); + this.category2 = category; + fireAnnotationChanged(); + } + + /** + * 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 and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param value the value. + * + * @see #getValue2() + */ + public void setValue2(double value) { + this.value2 = value; + fireAnnotationChanged(); + } + + /** + * Returns the paint used to draw the connecting line. + * + * @return The paint (never null). + * + * @see #setPaint(Paint) + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Sets the paint used to draw the connecting line and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getPaint() + */ + public void setPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.paint = paint; + fireAnnotationChanged(); + } + + /** + * Returns the stroke used to draw the connecting line. + * + * @return The stroke (never null). + * + * @see #setStroke(Stroke) + */ + public Stroke getStroke() { + return this.stroke; + } + + /** + * Sets the stroke used to draw the connecting line and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getStroke() + */ + public void setStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.stroke = stroke; + fireAnnotationChanged(); + } + + /** + * 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. + */ + @Override + 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 (null permitted). + * + * @return true or false. + */ + @Override + 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. + */ + @Override + 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. + */ + @Override + 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/CategoryPointerAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/CategoryPointerAnnotation.java new file mode 100755 index 0000000..9dce872 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/CategoryPointerAnnotation.java @@ -0,0 +1,544 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * CategoryPointerAnnotation.java + * ------------------------------ + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (patch 2809117); + * + * Changes: + * -------- + * 02-Oct-2006 : Version 1 (DG); + * 06-Mar-2007 : Implemented hashCode() (DG); + * 24-Jun-2009 : Fire change events (see patch 2809117 by PK) (DG); + * 30-Mar-2010 : Correct calculation of pointer line (see patch 2954302) (DG); + * 02-Jul-2013 : Use ParamChecks (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.event.AnnotationChangeEvent; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.util.ParamChecks; +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. + *

+ * 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 (null 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 and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param angle the angle (in radians). + * + * @see #getAngle() + */ + public void setAngle(double angle) { + this.angle = angle; + fireAnnotationChanged(); + } + + /** + * Returns the tip radius. + * + * @return The tip radius (in Java2D units). + * + * @see #setTipRadius(double) + */ + public double getTipRadius() { + return this.tipRadius; + } + + /** + * Sets the tip radius and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param radius the radius (in Java2D units). + * + * @see #getTipRadius() + */ + public void setTipRadius(double radius) { + this.tipRadius = radius; + fireAnnotationChanged(); + } + + /** + * Returns the base radius. + * + * @return The base radius (in Java2D units). + * + * @see #setBaseRadius(double) + */ + public double getBaseRadius() { + return this.baseRadius; + } + + /** + * Sets the base radius and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param radius the radius (in Java2D units). + * + * @see #getBaseRadius() + */ + public void setBaseRadius(double radius) { + this.baseRadius = radius; + fireAnnotationChanged(); + } + + /** + * 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) and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param offset the offset (in Java2D units). + * + * @see #getLabelOffset() + */ + public void setLabelOffset(double offset) { + this.labelOffset = offset; + fireAnnotationChanged(); + } + + /** + * Returns the arrow length. + * + * @return The arrow length. + * + * @see #setArrowLength(double) + */ + public double getArrowLength() { + return this.arrowLength; + } + + /** + * Sets the arrow length and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param length the length. + * + * @see #getArrowLength() + */ + public void setArrowLength(double length) { + this.arrowLength = length; + fireAnnotationChanged(); + } + + /** + * Returns the arrow width. + * + * @return The arrow width (in Java2D units). + * + * @see #setArrowWidth(double) + */ + public double getArrowWidth() { + return this.arrowWidth; + } + + /** + * Sets the arrow width and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param width the width (in Java2D units). + * + * @see #getArrowWidth() + */ + public void setArrowWidth(double width) { + this.arrowWidth = width; + fireAnnotationChanged(); + } + + /** + * Returns the stroke used to draw the arrow line. + * + * @return The arrow stroke (never null). + * + * @see #setArrowStroke(Stroke) + */ + public Stroke getArrowStroke() { + return this.arrowStroke; + } + + /** + * Sets the stroke used to draw the arrow line and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getArrowStroke() + */ + public void setArrowStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.arrowStroke = stroke; + fireAnnotationChanged(); + } + + /** + * Returns the paint used for the arrow. + * + * @return The arrow paint (never null). + * + * @see #setArrowPaint(Paint) + */ + public Paint getArrowPaint() { + return this.arrowPaint; + } + + /** + * Sets the paint used for the arrow and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param paint the arrow paint (null not permitted). + * + * @see #getArrowPaint() + */ + public void setArrowPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.arrowPaint = paint; + fireAnnotationChanged(); + } + + /** + * 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. + */ + @Override + 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, arrowBaseX, arrowBaseY); + 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 (null permitted). + * + * @return true or false. + */ + @Override + 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. + */ + @Override + 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. + */ + @Override + 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/CategoryTextAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/CategoryTextAnnotation.java new file mode 100755 index 0000000..0817f44 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/CategoryTextAnnotation.java @@ -0,0 +1,285 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * CategoryTextAnnotation.java + * --------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (patch 2809117); + * + * 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); + * 24-Jun-2009 : Fire change events (see patch 2809117 by PK) (DG); + * 02-Jul-2013 : Use ParamChecks (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.event.AnnotationChangeEvent; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.util.ParamChecks; +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 (null not permitted). + * @param category the category (null not permitted). + * @param value the value. + */ + public CategoryTextAnnotation(String text, Comparable category, + double value) { + super(text); + ParamChecks.nullNotPermitted(category, "category"); + this.category = category; + this.value = value; + this.categoryAnchor = CategoryAnchor.MIDDLE; + } + + /** + * Returns the category. + * + * @return The category (never null). + * + * @see #setCategory(Comparable) + */ + public Comparable getCategory() { + return this.category; + } + + /** + * Sets the category that the annotation attaches to and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param category the category (null not permitted). + * + * @see #getCategory() + */ + public void setCategory(Comparable category) { + ParamChecks.nullNotPermitted(category, "category"); + this.category = category; + fireAnnotationChanged(); + } + + /** + * Returns the category anchor point. + * + * @return The category anchor point. + * + * @see #setCategoryAnchor(CategoryAnchor) + */ + public CategoryAnchor getCategoryAnchor() { + return this.categoryAnchor; + } + + /** + * Sets the category anchor point and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param anchor the anchor point (null not permitted). + * + * @see #getCategoryAnchor() + */ + public void setCategoryAnchor(CategoryAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.categoryAnchor = anchor; + fireAnnotationChanged(); + } + + /** + * Returns the value that the annotation attaches to. + * + * @return The value. + * + * @see #setValue(double) + */ + public double getValue() { + return this.value; + } + + /** + * Sets the value and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param value the value. + * + * @see #getValue() + */ + public void setValue(double value) { + this.value = value; + fireAnnotationChanged(); + } + + /** + * 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. + */ + @Override + 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 (null permitted). + * + * @return true or false. + */ + @Override + 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. + */ + @Override + 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. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/TextAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/TextAnnotation.java new file mode 100755 index 0000000..b56a1b4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/TextAnnotation.java @@ -0,0 +1,369 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * TextAnnotation.java + * ------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (patch 2809117); + * Martin Hoeller; + * + * 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); + * 24-Jun-2009 : Fire change events (see patch 2809117 by PK) (DG); + * 28-Oct-2011 : Added missing argument check, Bug #3428870 (MH); + * 01-Jul-2013 : Added missing AnnotationChangeEvent for setText() (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.chart.event.AnnotationChangeEvent; +import org.jfree.chart.util.ParamChecks; +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 extends AbstractAnnotation 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 (null not permitted). + */ + protected TextAnnotation(String text) { + super(); + ParamChecks.nullNotPermitted(text, "text"); + 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 null). + * + * @see #setText(String) + */ + public String getText() { + return this.text; + } + + /** + * Sets the text for the annotation and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param text the text (null not permitted). + * + * @see #getText() + */ + public void setText(String text) { + ParamChecks.nullNotPermitted(text, "text"); + this.text = text; + fireAnnotationChanged(); + } + + /** + * Returns the font for the annotation. + * + * @return The font (never null). + * + * @see #setFont(Font) + */ + public Font getFont() { + return this.font; + } + + /** + * Sets the font for the annotation and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getFont() + */ + public void setFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.font = font; + fireAnnotationChanged(); + } + + /** + * Returns the paint for the annotation. + * + * @return The paint (never null). + * + * @see #setPaint(Paint) + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Sets the paint for the annotation and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getPaint() + */ + public void setPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.paint = paint; + fireAnnotationChanged(); + } + + /** + * 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) and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param anchor the anchor point (null not permitted). + * + * @see #getTextAnchor() + */ + public void setTextAnchor(TextAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.textAnchor = anchor; + fireAnnotationChanged(); + } + + /** + * Returns the rotation anchor. + * + * @return The rotation anchor point (never null). + * + * @see #setRotationAnchor(TextAnchor) + */ + public TextAnchor getRotationAnchor() { + return this.rotationAnchor; + } + + /** + * Sets the rotation anchor point and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param anchor the anchor (null not permitted). + * + * @see #getRotationAnchor() + */ + public void setRotationAnchor(TextAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.rotationAnchor = anchor; + fireAnnotationChanged(); + } + + /** + * Returns the rotation angle in radians. + * + * @return The rotation angle. + * + * @see #setRotationAngle(double) + */ + public double getRotationAngle() { + return this.rotationAngle; + } + + /** + * Sets the rotation angle and sends an {@link AnnotationChangeEvent} to + * all registered listeners. The angle is measured clockwise in radians. + * + * @param angle the angle (in radians). + * + * @see #getRotationAngle() + */ + public void setRotationAngle(double angle) { + this.rotationAngle = angle; + fireAnnotationChanged(); + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + 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. + */ + @Override + 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYAnnotation.java new file mode 100755 index 0000000..d9760fd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYAnnotation.java @@ -0,0 +1,81 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * XYAnnotation.java + * ----------------- + * (C) Copyright 2002-2009, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (patch 2809117); + * + * 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); + * 24-Jun-2009 : Now extends Annotation (see patch 2809117 by PK) (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}. Note that, in JFreeChart 1.0.14, a non-compatible + * change has been made to this interface (it now extends the Annotation + * interface to support change notifications). + */ +public interface XYAnnotation extends Annotation { + + /** + * 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); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYAnnotationBoundsInfo.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYAnnotationBoundsInfo.java new file mode 100755 index 0000000..46c8dbf --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYAnnotationBoundsInfo.java @@ -0,0 +1,77 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * XYAnnotationBoundsInfo.java + * --------------------------- + * (C) Copyright 2009, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 10-Mar-2009 : Version 1 (DG); + * + */ + +package org.jfree.chart.annotations; + +import org.jfree.data.Range; + +/** + * An interface that supplies information about the bounds of the annotation. + * + * @since 1.0.13 + */ +public interface XYAnnotationBoundsInfo { + + /** + * Returns a flag that determines whether or not the annotation's + * bounds should be taken into account for auto-range calculations on + * the axes that the annotation is plotted against. + * + * @return A boolean. + */ + public boolean getIncludeInDataBounds(); + + /** + * Returns the range of x-values (in data space) that the annotation + * uses. + * + * @return The x-range. + */ + public Range getXRange(); + + /** + * Returns the range of y-values (in data space) that the annotation + * uses. + * + * @return The y-range. + */ + public Range getYRange(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYBoxAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYBoxAnnotation.java new file mode 100755 index 0000000..622a592 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYBoxAnnotation.java @@ -0,0 +1,313 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * XYBoxAnnotation.java + * -------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (see patch 2809117); + * + * 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 stroke and outlinePaint. + * + * @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 (null permitted). + * @param outlinePaint the shape color (null 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 (null permitted). + * @param outlinePaint the shape color (null permitted). + * @param fillPaint the paint used to fill the shape (null + * permitted). + */ + public XYBoxAnnotation(double x0, double y0, double x1, double y1, + Stroke stroke, Paint outlinePaint, Paint fillPaint) { + super(); + 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. + */ + @Override + 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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. + */ + @Override + 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. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Provides serialization support. + * + * @param stream the output stream (null 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 (null 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYDataImageAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYDataImageAnnotation.java new file mode 100755 index 0000000..65bb0d6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYDataImageAnnotation.java @@ -0,0 +1,381 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * XYDataImageAnnotation.java + * -------------------------- + * (C) Copyright 2008-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (patch 2809117); + * + * Changes: + * -------- + * 17-Sep-2008 : Version 1, based on XYImageAnnotation (DG); + * 10-Mar-2009 : Implemented XYAnnotationBoundsInfo (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.chart.util.ParamChecks; +import org.jfree.data.Range; +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, XYAnnotationBoundsInfo { + + /** 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; + + /** + * A flag indicating whether or not the annotation should contribute to + * the data range for a plot/renderer. + * + * @since 1.0.13 + */ + private boolean includeInDataBounds; + + /** + * Creates a new annotation to be displayed within the specified rectangle. + * + * @param image the image (null 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) { + this(image, x, y, w, h, false); + } + + /** + * Creates a new annotation to be displayed within the specified rectangle. + * + * @param image the image (null 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. + * @param includeInDataBounds a flag that controls whether or not the + * annotation is included in the data bounds for the axis autoRange. + * + * @since 1.0.13 + */ + public XYDataImageAnnotation(Image image, double x, double y, double w, + double h, boolean includeInDataBounds) { + + super(); + ParamChecks.nullNotPermitted(image, "image"); + this.image = image; + this.x = x; + this.y = y; + this.w = w; + this.h = h; + this.includeInDataBounds = includeInDataBounds; + } + + /** + * 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; + } + + /** + * Returns the flag that controls whether or not the annotation should + * contribute to the autoRange for the axis it is plotted against. + * + * @return A boolean. + * + * @since 1.0.13 + */ + @Override + public boolean getIncludeInDataBounds() { + return this.includeInDataBounds; + } + + /** + * Returns the x-range for the annotation. + * + * @return The range. + * + * @since 1.0.13 + */ + @Override + public Range getXRange() { + return new Range(this.x, this.x + this.w); + } + + /** + * Returns the y-range for the annotation. + * + * @return The range. + * + * @since 1.0.13 + */ + @Override + public Range getYRange() { + return new Range(this.y, this.y + 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. + */ + @Override + 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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 (this.includeInDataBounds != that.includeInDataBounds) { + 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. + */ + @Override + 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. + */ + @Override + 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYDrawableAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYDrawableAnnotation.java new file mode 100755 index 0000000..896ae95 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYDrawableAnnotation.java @@ -0,0 +1,262 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * XYDrawableAnnotation.java + * ------------------------- + * (C) Copyright 2003-2013, 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); + * 02-Jul-2013 : Use ParamChecks (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.chart.util.ParamChecks; +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 (null 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 drawScaleFactor of 2.0, the drawable + * 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 (null not permitted). + * + * @since 1.0.11 + */ + public XYDrawableAnnotation(double x, double y, double displayWidth, + double displayHeight, double drawScaleFactor, Drawable drawable) { + + super(); + ParamChecks.nullNotPermitted(drawable, "drawable"); + 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. + */ + @Override + 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 true or false. + */ + @Override + 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. + */ + @Override + 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. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYImageAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYImageAnnotation.java new file mode 100755 index 0000000..c06b184 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYImageAnnotation.java @@ -0,0 +1,323 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * XYImageAnnotation.java + * ---------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Mike Harris; + * Peter Kolb (patch 2809117); + * + * 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); + * 02-Jul-2013 : Use ParamChecks (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.chart.util.ParamChecks; +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 (null 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 (null not permitted). + * @param anchor the image anchor (null not permitted). + * + * @since 1.0.4 + */ + public XYImageAnnotation(double x, double y, Image image, + RectangleAnchor anchor) { + super(); + ParamChecks.nullNotPermitted(image, "image"); + ParamChecks.nullNotPermitted(anchor, "anchor"); + 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. + */ + @Override + 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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. + */ + @Override + 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. + */ + @Override + 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); + } + + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYLineAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYLineAnnotation.java new file mode 100755 index 0000000..7a56ca3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYLineAnnotation.java @@ -0,0 +1,315 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * XYLineAnnotation.java + * --------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (see patch 2809117); + * + * 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); + * 02-Jul-2013 : Use ParamChecks (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.chart.util.ParamChecks; +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 (null not permitted). + * @param paint the line color (null not permitted). + */ + public XYLineAnnotation(double x1, double y1, double x2, double y2, + Stroke stroke, Paint paint) { + + super(); + ParamChecks.nullNotPermitted(stroke, "stroke"); + ParamChecks.nullNotPermitted(paint, "paint"); + 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. + */ + @Override + 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 (null permitted). + * + * @return true or false. + */ + @Override + 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. + */ + @Override + 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. + */ + @Override + 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYPointerAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYPointerAnnotation.java new file mode 100755 index 0000000..e1de81a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYPointerAnnotation.java @@ -0,0 +1,564 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * XYPointerAnnotation.java + * ------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (patch 2809117); + * + * 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); + * 12-Feb-2009 : Added support for rotated label, plus background and + * outline (DG); + * 18-May-2009 : Fixed typo in hashCode() method (DG); + * 24-Jun-2009 : Fire change events (see patch 2809117 by PK) (DG); + * 02-Jul-2013 : Use ParamChecks (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.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.event.AnnotationChangeEvent; +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.ParamChecks; +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 XYPlot}. The arrow is + * drawn at a user-definable angle so that it points towards the (x, y) + * location for the annotation. + *

+ * 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 (null 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 and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param angle the angle (in radians). + * + * @see #getAngle() + */ + public void setAngle(double angle) { + this.angle = angle; + fireAnnotationChanged(); + } + + /** + * Returns the tip radius. + * + * @return The tip radius (in Java2D units). + * + * @see #setTipRadius(double) + */ + public double getTipRadius() { + return this.tipRadius; + } + + /** + * Sets the tip radius and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param radius the radius (in Java2D units). + * + * @see #getTipRadius() + */ + public void setTipRadius(double radius) { + this.tipRadius = radius; + fireAnnotationChanged(); + } + + /** + * Returns the base radius. + * + * @return The base radius (in Java2D units). + * + * @see #setBaseRadius(double) + */ + public double getBaseRadius() { + return this.baseRadius; + } + + /** + * Sets the base radius and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param radius the radius (in Java2D units). + * + * @see #getBaseRadius() + */ + public void setBaseRadius(double radius) { + this.baseRadius = radius; + fireAnnotationChanged(); + } + + /** + * 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) and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param offset the offset (in Java2D units). + * + * @see #getLabelOffset() + */ + public void setLabelOffset(double offset) { + this.labelOffset = offset; + fireAnnotationChanged(); + } + + /** + * Returns the arrow length. + * + * @return The arrow length. + * + * @see #setArrowLength(double) + */ + public double getArrowLength() { + return this.arrowLength; + } + + /** + * Sets the arrow length and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param length the length. + * + * @see #getArrowLength() + */ + public void setArrowLength(double length) { + this.arrowLength = length; + fireAnnotationChanged(); + } + + /** + * Returns the arrow width. + * + * @return The arrow width (in Java2D units). + * + * @see #setArrowWidth(double) + */ + public double getArrowWidth() { + return this.arrowWidth; + } + + /** + * Sets the arrow width and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param width the width (in Java2D units). + * + * @see #getArrowWidth() + */ + public void setArrowWidth(double width) { + this.arrowWidth = width; + fireAnnotationChanged(); + } + + /** + * Returns the stroke used to draw the arrow line. + * + * @return The arrow stroke (never null). + * + * @see #setArrowStroke(Stroke) + */ + public Stroke getArrowStroke() { + return this.arrowStroke; + } + + /** + * Sets the stroke used to draw the arrow line and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getArrowStroke() + */ + public void setArrowStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.arrowStroke = stroke; + fireAnnotationChanged(); + } + + /** + * Returns the paint used for the arrow. + * + * @return The arrow paint (never null). + * + * @see #setArrowPaint(Paint) + */ + public Paint getArrowPaint() { + return this.arrowPaint; + } + + /** + * Sets the paint used for the arrow and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param paint the arrow paint (null not permitted). + * + * @see #getArrowPaint() + */ + public void setArrowPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.arrowPaint = paint; + fireAnnotationChanged(); + } + + /** + * 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. + */ + @Override + 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, arrowBaseX, arrowBaseY); + g2.draw(line); + g2.fill(arrow); + + // draw the label + double labelX = j2DX + Math.cos(this.angle) * (this.baseRadius + + this.labelOffset); + double labelY = j2DY + Math.sin(this.angle) * (this.baseRadius + + this.labelOffset); + g2.setFont(getFont()); + Shape hotspot = TextUtilities.calculateRotatedStringBounds( + getText(), g2, (float) labelX, (float) labelY, getTextAnchor(), + getRotationAngle(), getRotationAnchor()); + if (getBackgroundPaint() != null) { + g2.setPaint(getBackgroundPaint()); + g2.fill(hotspot); + } + g2.setPaint(getPaint()); + TextUtilities.drawRotatedString(getText(), g2, (float) labelX, + (float) labelY, getTextAnchor(), getRotationAngle(), + getRotationAnchor()); + if (isOutlineVisible()) { + g2.setStroke(getOutlineStroke()); + g2.setPaint(getOutlinePaint()); + g2.draw(hotspot); + } + + 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 (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYPointerAnnotation)) { + 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 super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + 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 result; + } + + /** + * Returns a clone of the annotation. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the annotation can't be cloned. + */ + @Override + 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYPolygonAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYPolygonAnnotation.java new file mode 100755 index 0000000..a9491d5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYPolygonAnnotation.java @@ -0,0 +1,363 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * XYPolygonAnnotation.java + * ------------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (patch 2809117); + * + * Changes: + * -------- + * 09-Feb-2005 : Version 1 (DG); + * 02-Jul-2013 : Use ParamChecks (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.chart.util.ParamChecks; +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 + * (null 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 stroke and outlinePaint. + * 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 + * (null not permitted). + * @param stroke the shape stroke (null permitted). + * @param outlinePaint the shape color (null 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 + * (null not permitted). + * @param stroke the shape stroke (null permitted). + * @param outlinePaint the shape color (null permitted). + * @param fillPaint the paint used to fill the shape (null + * permitted). + */ + public XYPolygonAnnotation(double[] polygon, Stroke stroke, + Paint outlinePaint, Paint fillPaint) { + super(); + ParamChecks.nullNotPermitted(polygon, "polygon"); + 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 null). + * + * @since 1.0.2 + */ + public Paint getFillPaint() { + return this.fillPaint; + } + + /** + * Returns the outline stroke. + * + * @return The outline stroke (possibly null). + * + * @since 1.0.2 + */ + public Stroke getOutlineStroke() { + return this.stroke; + } + + /** + * Returns the outline paint. + * + * @return The outline paint (possibly null). + * + * @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. + */ + @Override + 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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. + */ + @Override + 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. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Provides serialization support. + * + * @param stream the output stream (null 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 (null 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYShapeAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYShapeAnnotation.java new file mode 100755 index 0000000..f57a1f5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYShapeAnnotation.java @@ -0,0 +1,316 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * XYShapeAnnotation.java + * ---------------------- + * (C) Copyright 2003-2013, by Ondax, Inc. and Contributors. + * + * Original Author: Greg Steckman (for Ondax, Inc.); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Peter Kolb (patch 2809117); + * + * 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); + * 02-Jul-2013 : Use ParamChecks (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.chart.util.ParamChecks; +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 Shape 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, null + * 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 stroke and outlinePaint. + * + * @param shape the shape (null not permitted). + * @param stroke the shape stroke (null permitted). + * @param outlinePaint the shape color (null permitted). + */ + public XYShapeAnnotation(Shape shape, Stroke stroke, Paint outlinePaint) { + this(shape, stroke, outlinePaint, null); + } + + /** + * Creates a new annotation. + * + * @param shape the shape (null not permitted). + * @param stroke the shape stroke (null permitted). + * @param outlinePaint the shape color (null permitted). + * @param fillPaint the paint used to fill the shape (null + * permitted. + */ + public XYShapeAnnotation(Shape shape, Stroke stroke, Paint outlinePaint, + Paint fillPaint) { + super(); + ParamChecks.nullNotPermitted(shape, "shape"); + 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. + */ + @Override + 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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. + */ + @Override + 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 ???. + */ + @Override + 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYTextAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYTextAnnotation.java new file mode 100755 index 0000000..6e54d3f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYTextAnnotation.java @@ -0,0 +1,683 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * XYTextAnnotation.java + * --------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (patch 2809117); + * + * 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); + * 12-Feb-2009 : Added background paint and outline paint/stroke (DG); + * 01-Apr-2009 : Fixed bug in hotspot calculation (DG); + * 24-Jun-2009 : Fire change events (see patch 2809117) (DG); + * + */ + +package org.jfree.chart.annotations; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +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.ValueAxis; +import org.jfree.chart.event.AnnotationChangeEvent; +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.ParamChecks; +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; + + /** + * The background paint (possibly null). + * + * @since 1.0.13 + */ + private transient Paint backgroundPaint; + + /** + * The flag that controls the visibility of the outline. + * + * @since 1.0.13 + */ + private boolean outlineVisible; + + /** + * The outline paint (never null). + * + * @since 1.0.13 + */ + private transient Paint outlinePaint; + + /** + * The outline stroke (never null). + * + * @since 1.0.13 + */ + private transient Stroke outlineStroke; + + /** + * 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 (null 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) { + super(); + ParamChecks.nullNotPermitted(text, "text"); + 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; + + // by default the outline and background won't be visible + this.backgroundPaint = null; + this.outlineVisible = false; + this.outlinePaint = Color.black; + this.outlineStroke = new BasicStroke(0.5f); + } + + /** + * Returns the text for the annotation. + * + * @return The text (never null). + * + * @see #setText(String) + */ + public String getText() { + return this.text; + } + + /** + * Sets the text for the annotation. + * + * @param text the text (null not permitted). + * + * @see #getText() + */ + public void setText(String text) { + ParamChecks.nullNotPermitted(text, "text"); + this.text = text; + fireAnnotationChanged(); + } + + /** + * Returns the font for the annotation. + * + * @return The font (never null). + * + * @see #setFont(Font) + */ + public Font getFont() { + return this.font; + } + + /** + * Sets the font for the annotation and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getFont() + */ + public void setFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.font = font; + fireAnnotationChanged(); + } + + /** + * Returns the paint for the annotation. + * + * @return The paint (never null). + * + * @see #setPaint(Paint) + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Sets the paint for the annotation and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getPaint() + */ + public void setPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.paint = paint; + fireAnnotationChanged(); + } + + /** + * Returns the text anchor. + * + * @return The text anchor (never null). + * + * @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) and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param anchor the anchor point (null not permitted). + * + * @see #getTextAnchor() + */ + public void setTextAnchor(TextAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.textAnchor = anchor; + fireAnnotationChanged(); + } + + /** + * Returns the rotation anchor. + * + * @return The rotation anchor point (never null). + * + * @see #setRotationAnchor(TextAnchor) + */ + public TextAnchor getRotationAnchor() { + return this.rotationAnchor; + } + + /** + * Sets the rotation anchor point and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param anchor the anchor (null not permitted). + * + * @see #getRotationAnchor() + */ + public void setRotationAnchor(TextAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.rotationAnchor = anchor; + fireAnnotationChanged(); + } + + /** + * Returns the rotation angle. + * + * @return The rotation angle. + * + * @see #setRotationAngle(double) + */ + public double getRotationAngle() { + return this.rotationAngle; + } + + /** + * Sets the rotation angle and sends an {@link AnnotationChangeEvent} to + * all registered listeners. The angle is measured clockwise in radians. + * + * @param angle the angle (in radians). + * + * @see #getRotationAngle() + */ + public void setRotationAngle(double angle) { + this.rotationAngle = angle; + fireAnnotationChanged(); + } + + /** + * 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) and sends an {@link AnnotationChangeEvent} to all + * registered listeners. + * + * @param x the x coordinate (in data space). + * + * @see #getX() + */ + public void setX(double x) { + this.x = x; + fireAnnotationChanged(); + } + + /** + * 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) and sends an {@link AnnotationChangeEvent} to all registered + * listeners. + * + * @param y the y coordinate. + * + * @see #getY() + */ + public void setY(double y) { + this.y = y; + fireAnnotationChanged(); + } + + /** + * Returns the background paint for the annotation. + * + * @return The background paint (possibly null). + * + * @see #setBackgroundPaint(Paint) + * + * @since 1.0.13 + */ + public Paint getBackgroundPaint() { + return this.backgroundPaint; + } + + /** + * Sets the background paint for the annotation and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @see #getBackgroundPaint() + * + * @since 1.0.13 + */ + public void setBackgroundPaint(Paint paint) { + this.backgroundPaint = paint; + fireAnnotationChanged(); + } + + /** + * Returns the outline paint for the annotation. + * + * @return The outline paint (never null). + * + * @see #setOutlinePaint(Paint) + * + * @since 1.0.13 + */ + public Paint getOutlinePaint() { + return this.outlinePaint; + } + + /** + * Sets the outline paint for the annotation and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getOutlinePaint() + * + * @since 1.0.13 + */ + public void setOutlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.outlinePaint = paint; + fireAnnotationChanged(); + } + + /** + * Returns the outline stroke for the annotation. + * + * @return The outline stroke (never null). + * + * @see #setOutlineStroke(Stroke) + * + * @since 1.0.13 + */ + public Stroke getOutlineStroke() { + return this.outlineStroke; + } + + /** + * Sets the outline stroke for the annotation and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getOutlineStroke() + * + * @since 1.0.13 + */ + public void setOutlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.outlineStroke = stroke; + fireAnnotationChanged(); + } + + /** + * Returns the flag that controls whether or not the outline is drawn. + * + * @return A boolean. + * + * @since 1.0.13 + */ + public boolean isOutlineVisible() { + return this.outlineVisible; + } + + /** + * Sets the flag that controls whether or not the outline is drawn and + * sends an {@link AnnotationChangeEvent} to all registered listeners. + * + * @param visible the new flag value. + * + * @since 1.0.13 + */ + public void setOutlineVisible(boolean visible) { + this.outlineVisible = visible; + fireAnnotationChanged(); + } + + /** + * 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. + */ + @Override + 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()); + Shape hotspot = TextUtilities.calculateRotatedStringBounds( + getText(), g2, anchorX, anchorY, getTextAnchor(), + getRotationAngle(), getRotationAnchor()); + if (this.backgroundPaint != null) { + g2.setPaint(this.backgroundPaint); + g2.fill(hotspot); + } + g2.setPaint(getPaint()); + TextUtilities.drawRotatedString(getText(), g2, anchorX, anchorY, + getTextAnchor(), getRotationAngle(), getRotationAnchor()); + if (this.outlineVisible) { + g2.setStroke(this.outlineStroke); + g2.setPaint(this.outlinePaint); + g2.draw(hotspot); + } + + 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 (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYTextAnnotation)) { + 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; + } + if (this.outlineVisible != that.outlineVisible) { + return false; + } + if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { + return false; + } + if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { + return false; + } + if (!(this.outlineStroke.equals(that.outlineStroke))) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for the object. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 193; + result = 37 * result + this.text.hashCode(); + result = 37 * result + 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. + */ + @Override + 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.writePaint(this.backgroundPaint, stream); + SerialUtilities.writePaint(this.outlinePaint, stream); + SerialUtilities.writeStroke(this.outlineStroke, 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.backgroundPaint = SerialUtilities.readPaint(stream); + this.outlinePaint = SerialUtilities.readPaint(stream); + this.outlineStroke = SerialUtilities.readStroke(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYTitleAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYTitleAnnotation.java new file mode 100755 index 0000000..dc6dd9e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/XYTitleAnnotation.java @@ -0,0 +1,401 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * XYTitleAnnotation.java + * ---------------------- + * (C) Copyright 2007-2011, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Andrew Mickish; + * Peter Kolb (patch 2809117); + * + * 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); + * 24-Jun-2009 : Fire change events (see patch 2809117 by PK) (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.event.AnnotationChangeEvent; +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.ParamChecks; +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 (null 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 (null not permitted). + * @param anchor the title anchor (null not permitted). + */ + public XYTitleAnnotation(double x, double y, Title title, + RectangleAnchor anchor) { + super(); + ParamChecks.nullNotPermitted(title, "title"); + ParamChecks.nullNotPermitted(anchor, "anchor"); + 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 null). + */ + 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 and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param max the maximum width (0.0 or less means no maximum). + */ + public void setMaxWidth(double max) { + this.maxWidth = max; + fireAnnotationChanged(); + } + + /** + * Returns the maximum height. + * + * @return The maximum height. + */ + public double getMaxHeight() { + return this.maxHeight; + } + + /** + * Sets the maximum height and sends an + * {@link AnnotationChangeEvent} to all registered listeners. + * + * @param max the maximum height. + */ + public void setMaxHeight(double max) { + this.maxHeight = max; + fireAnnotationChanged(); + } + + /** + * 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. + */ + @Override + 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, anchorY; + 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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. + */ + @Override + 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. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/package.html new file mode 100755 index 0000000..2b6e2e7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/annotations/package.html @@ -0,0 +1,6 @@ + + + +A framework for addings annotations to charts. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/Axis.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/Axis.java new file mode 100755 index 0000000..0c39f4b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/Axis.java @@ -0,0 +1,1724 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------- + * Axis.java + * --------- + * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Bill Kelemen; + * Nicolas Brodu; + * Peter Kolb (patches 1934255 and 2603321); + * Andrew Mickish (patch 1870189); + * + * Changes + * ------- + * 21-Aug-2001 : Added standard header, fixed DOS encoding problem (DG); + * 18-Sep-2001 : Updated header (DG); + * 07-Nov-2001 : Allow null axis labels (DG); + * : Added default font values (DG); + * 13-Nov-2001 : Modified the setPlot() method to check compatibility between + * the axis and the plot (DG); + * 30-Nov-2001 : Changed default font from "Arial" --> "SansSerif" (DG); + * 06-Dec-2001 : Allow null in setPlot() method (BK); + * 06-Mar-2002 : Added AxisConstants interface (DG); + * 23-Apr-2002 : Added a visible property. Moved drawVerticalString to + * RefineryUtilities. Added fixedDimension property for use in + * combined plots (DG); + * 25-Jun-2002 : Removed unnecessary imports (DG); + * 05-Sep-2002 : Added attribute for tick mark paint (DG); + * 18-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 07-Nov-2002 : Added attributes to control the inside and outside length of + * the tick marks (DG); + * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); + * 18-Nov-2002 : Added axis location to refreshTicks() parameters (DG); + * 15-Jan-2003 : Removed monolithic constructor (DG); + * 17-Jan-2003 : Moved plot classes to separate package (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 03-Jul-2003 : Modified reserveSpace method (DG); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 11-Sep-2003 : Took care of listeners while cloning (NB); + * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); + * 06-Nov-2003 : Modified refreshTicks() signature (DG); + * 06-Jan-2004 : Added axis line attributes (DG); + * 16-Mar-2004 : Added plot state to draw() method (DG); + * 07-Apr-2004 : Modified text bounds calculation (DG); + * 18-May-2004 : Eliminated AxisConstants.java (DG); + * 30-Sep-2004 : Moved drawRotatedString() from RefineryUtilities --> + * TextUtilities (DG); + * 04-Oct-2004 : Modified getLabelEnclosure() method to treat an empty String + * the same way as a null string - see bug 1026521 (DG); + * 21-Apr-2005 : Replaced Insets with RectangleInsets (DG); + * 26-Apr-2005 : Removed LOGGER (DG); + * 01-Jun-2005 : Added hasListener() method for unit testing (DG); + * 08-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 22-Aug-2006 : API doc updates (DG); + * 06-Jun-2008 : Added setTickLabelInsets(RectangleInsets, boolean) (DG); + * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); + * 26-Sep-2008 : Added fireChangeEvent() method (DG); + * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * 01-Aug-2013 : Added attributedLabel override to support superscripts, + * subscripts and more (DG); + */ + +package org.jfree.chart.axis; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.font.TextLayout; +import java.awt.geom.AffineTransform; +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 java.text.AttributedString; +import java.util.Arrays; +import java.util.EventListener; +import java.util.List; + +import javax.swing.event.EventListenerList; + +import org.jfree.chart.entity.AxisEntity; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.AxisChangeEvent; +import org.jfree.chart.event.AxisChangeListener; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.util.AttrStringUtils; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.TextAnchor; +import org.jfree.util.AttributedStringUtilities; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; + +/** + * The base class for all axes in JFreeChart. Subclasses are divided into + * those that display values ({@link ValueAxis}) and those that display + * categories ({@link CategoryAxis}). + */ +public abstract class Axis implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7719289504573298271L; + + /** The default axis visibility. */ + public static final boolean DEFAULT_AXIS_VISIBLE = true; + + /** The default axis label font. */ + public static final Font DEFAULT_AXIS_LABEL_FONT = new Font( + "SansSerif", Font.PLAIN, 12); + + /** The default axis label paint. */ + public static final Paint DEFAULT_AXIS_LABEL_PAINT = Color.black; + + /** The default axis label insets. */ + public static final RectangleInsets DEFAULT_AXIS_LABEL_INSETS + = new RectangleInsets(3.0, 3.0, 3.0, 3.0); + + /** The default axis line paint. */ + public static final Paint DEFAULT_AXIS_LINE_PAINT = Color.gray; + + /** The default axis line stroke. */ + public static final Stroke DEFAULT_AXIS_LINE_STROKE = new BasicStroke(1.0f); + + /** The default tick labels visibility. */ + public static final boolean DEFAULT_TICK_LABELS_VISIBLE = true; + + /** The default tick label font. */ + public static final Font DEFAULT_TICK_LABEL_FONT = new Font("SansSerif", + Font.PLAIN, 10); + + /** The default tick label paint. */ + public static final Paint DEFAULT_TICK_LABEL_PAINT = Color.black; + + /** The default tick label insets. */ + public static final RectangleInsets DEFAULT_TICK_LABEL_INSETS + = new RectangleInsets(2.0, 4.0, 2.0, 4.0); + + /** The default tick marks visible. */ + public static final boolean DEFAULT_TICK_MARKS_VISIBLE = true; + + /** The default tick stroke. */ + public static final Stroke DEFAULT_TICK_MARK_STROKE = new BasicStroke(1); + + /** The default tick paint. */ + public static final Paint DEFAULT_TICK_MARK_PAINT = Color.gray; + + /** The default tick mark inside length. */ + public static final float DEFAULT_TICK_MARK_INSIDE_LENGTH = 0.0f; + + /** The default tick mark outside length. */ + public static final float DEFAULT_TICK_MARK_OUTSIDE_LENGTH = 2.0f; + + /** A flag indicating whether or not the axis is visible. */ + private boolean visible; + + /** The label for the axis. */ + private String label; + + /** + * An attributed label for the axis (overrides label if non-null). + * We have to use this override method to preserve the API compatibility. + */ + private transient AttributedString attributedLabel; + + /** The font for displaying the axis label. */ + private Font labelFont; + + /** The paint for drawing the axis label. */ + private transient Paint labelPaint; + + /** The insets for the axis label. */ + private RectangleInsets labelInsets; + + /** The label angle. */ + private double labelAngle; + + /** The axis label location (new in 1.0.16). */ + private AxisLabelLocation labelLocation; + + /** A flag that controls whether or not the axis line is visible. */ + private boolean axisLineVisible; + + /** The stroke used for the axis line. */ + private transient Stroke axisLineStroke; + + /** The paint used for the axis line. */ + private transient Paint axisLinePaint; + + /** + * A flag that indicates whether or not tick labels are visible for the + * axis. + */ + private boolean tickLabelsVisible; + + /** The font used to display the tick labels. */ + private Font tickLabelFont; + + /** The color used to display the tick labels. */ + private transient Paint tickLabelPaint; + + /** The blank space around each tick label. */ + private RectangleInsets tickLabelInsets; + + /** + * A flag that indicates whether or not major tick marks are visible for + * the axis. + */ + private boolean tickMarksVisible; + + /** + * The length of the major tick mark inside the data area (zero + * permitted). + */ + private float tickMarkInsideLength; + + /** + * The length of the major tick mark outside the data area (zero + * permitted). + */ + private float tickMarkOutsideLength; + + /** + * A flag that indicates whether or not minor tick marks are visible for the + * axis. + * + * @since 1.0.12 + */ + private boolean minorTickMarksVisible; + + /** + * The length of the minor tick mark inside the data area (zero permitted). + * + * @since 1.0.12 + */ + private float minorTickMarkInsideLength; + + /** + * The length of the minor tick mark outside the data area (zero permitted). + * + * @since 1.0.12 + */ + private float minorTickMarkOutsideLength; + + /** The stroke used to draw tick marks. */ + private transient Stroke tickMarkStroke; + + /** The paint used to draw tick marks. */ + private transient Paint tickMarkPaint; + + /** The fixed (horizontal or vertical) dimension for the axis. */ + private double fixedDimension; + + /** + * A reference back to the plot that the axis is assigned to (can be + * null). + */ + private transient Plot plot; + + /** Storage for registered listeners. */ + private transient EventListenerList listenerList; + + /** + * Constructs an axis, using default values where necessary. + * + * @param label the axis label (null permitted). + */ + protected Axis(String label) { + + this.label = label; + this.visible = DEFAULT_AXIS_VISIBLE; + this.labelFont = DEFAULT_AXIS_LABEL_FONT; + this.labelPaint = DEFAULT_AXIS_LABEL_PAINT; + this.labelInsets = DEFAULT_AXIS_LABEL_INSETS; + this.labelAngle = 0.0; + this.labelLocation = AxisLabelLocation.MIDDLE; + + this.axisLineVisible = true; + this.axisLinePaint = DEFAULT_AXIS_LINE_PAINT; + this.axisLineStroke = DEFAULT_AXIS_LINE_STROKE; + + this.tickLabelsVisible = DEFAULT_TICK_LABELS_VISIBLE; + this.tickLabelFont = DEFAULT_TICK_LABEL_FONT; + this.tickLabelPaint = DEFAULT_TICK_LABEL_PAINT; + this.tickLabelInsets = DEFAULT_TICK_LABEL_INSETS; + + this.tickMarksVisible = DEFAULT_TICK_MARKS_VISIBLE; + this.tickMarkStroke = DEFAULT_TICK_MARK_STROKE; + this.tickMarkPaint = DEFAULT_TICK_MARK_PAINT; + this.tickMarkInsideLength = DEFAULT_TICK_MARK_INSIDE_LENGTH; + this.tickMarkOutsideLength = DEFAULT_TICK_MARK_OUTSIDE_LENGTH; + + this.minorTickMarksVisible = false; + this.minorTickMarkInsideLength = 0.0f; + this.minorTickMarkOutsideLength = 2.0f; + + this.plot = null; + + this.listenerList = new EventListenerList(); + } + + /** + * Returns true if the axis is visible, and + * false otherwise. + * + * @return A boolean. + * + * @see #setVisible(boolean) + */ + public boolean isVisible() { + return this.visible; + } + + /** + * Sets a flag that controls whether or not the axis is visible and sends + * an {@link AxisChangeEvent} to all registered listeners. + * + * @param flag the flag. + * + * @see #isVisible() + */ + public void setVisible(boolean flag) { + if (flag != this.visible) { + this.visible = flag; + fireChangeEvent(); + } + } + + /** + * Returns the label for the axis. + * + * @return The label for the axis (null possible). + * + * @see #getLabelFont() + * @see #getLabelPaint() + * @see #setLabel(String) + */ + public String getLabel() { + return this.label; + } + + /** + * Sets the label for the axis and sends an {@link AxisChangeEvent} to all + * registered listeners. + * + * @param label the new label (null permitted). + * + * @see #getLabel() + * @see #setLabelFont(Font) + * @see #setLabelPaint(Paint) + */ + public void setLabel(String label) { + this.label = label; + fireChangeEvent(); + } + + /** + * Returns the attributed label (the returned value is a copy, so + * modifying it will not impact the state of the axis). The default value + * is null. + * + * @return The attributed label (possibly null). + * + * @since 1.0.16 + */ + public AttributedString getAttributedLabel() { + if (this.attributedLabel != null) { + return new AttributedString(this.attributedLabel.getIterator()); + } else { + return null; + } + } + + /** + * Sets the attributed label for the axis and sends an + * {@link AxisChangeEvent} to all registered listeners. This is a + * convenience method that converts the string into an + * AttributedString using the current font attributes. + * + * @param label the label (null permitted). + * + * @since 1.0.16 + */ + public void setAttributedLabel(String label) { + setAttributedLabel(createAttributedLabel(label)); + } + + /** + * Sets the attributed label for the axis and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param label the label (null permitted). + * + * @since 1.0.16 + */ + public void setAttributedLabel(AttributedString label) { + if (label != null) { + this.attributedLabel = new AttributedString(label.getIterator()); + } else { + this.attributedLabel = null; + } + fireChangeEvent(); + } + + /** + * Creates and returns an AttributedString with the specified + * text and the labelFont and labelPaint applied as attributes. + * + * @param label the label (null permitted). + * + * @return An attributed string or null. + * + * @since 1.0.16 + */ + public AttributedString createAttributedLabel(String label) { + if (label == null) { + return null; + } + AttributedString s = new AttributedString(label); + s.addAttributes(this.labelFont.getAttributes(), 0, label.length()); + return s; + } + + /** + * Returns the font for the axis label. + * + * @return The font (never null). + * + * @see #setLabelFont(Font) + */ + public Font getLabelFont() { + return this.labelFont; + } + + /** + * Sets the font for the axis label and sends an {@link AxisChangeEvent} + * to all registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getLabelFont() + */ + public void setLabelFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + if (!this.labelFont.equals(font)) { + this.labelFont = font; + fireChangeEvent(); + } + } + + /** + * Returns the color/shade used to draw the axis label. + * + * @return The paint (never null). + * + * @see #setLabelPaint(Paint) + */ + public Paint getLabelPaint() { + return this.labelPaint; + } + + /** + * Sets the paint used to draw the axis label and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getLabelPaint() + */ + public void setLabelPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.labelPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the insets for the label (that is, the amount of blank space + * that should be left around the label). + * + * @return The label insets (never null). + * + * @see #setLabelInsets(RectangleInsets) + */ + public RectangleInsets getLabelInsets() { + return this.labelInsets; + } + + /** + * Sets the insets for the axis label, and sends an {@link AxisChangeEvent} + * to all registered listeners. + * + * @param insets the insets (null not permitted). + * + * @see #getLabelInsets() + */ + public void setLabelInsets(RectangleInsets insets) { + setLabelInsets(insets, true); + } + + /** + * Sets the insets for the axis label, and sends an {@link AxisChangeEvent} + * to all registered listeners. + * + * @param insets the insets (null not permitted). + * @param notify notify listeners? + * + * @since 1.0.10 + */ + public void setLabelInsets(RectangleInsets insets, boolean notify) { + ParamChecks.nullNotPermitted(insets, "insets"); + if (!insets.equals(this.labelInsets)) { + this.labelInsets = insets; + if (notify) { + fireChangeEvent(); + } + } + } + + /** + * Returns the angle of the axis label. + * + * @return The angle (in radians). + * + * @see #setLabelAngle(double) + */ + public double getLabelAngle() { + return this.labelAngle; + } + + /** + * Sets the angle for the label and sends an {@link AxisChangeEvent} to all + * registered listeners. + * + * @param angle the angle (in radians). + * + * @see #getLabelAngle() + */ + public void setLabelAngle(double angle) { + this.labelAngle = angle; + fireChangeEvent(); + } + + /** + * Returns the location of the axis label. The default is + * {@link AxisLabelLocation#MIDDLE}. + * + * @return The location of the axis label (never null). + * + * @since 1.0.16 + */ + public AxisLabelLocation getLabelLocation() { + return this.labelLocation; + } + + /** + * Sets the axis label location and sends an {@link AxisChangeEvent} to + * all registered listeners. + * + * @param location the new location (null not permitted). + * + * @since 1.0.16 + */ + public void setLabelLocation(AxisLabelLocation location) { + ParamChecks.nullNotPermitted(location, "location"); + this.labelLocation = location; + fireChangeEvent(); + } + + /** + * A flag that controls whether or not the axis line is drawn. + * + * @return A boolean. + * + * @see #getAxisLinePaint() + * @see #getAxisLineStroke() + * @see #setAxisLineVisible(boolean) + */ + public boolean isAxisLineVisible() { + return this.axisLineVisible; + } + + /** + * Sets a flag that controls whether or not the axis line is visible and + * sends an {@link AxisChangeEvent} to all registered listeners. + * + * @param visible the flag. + * + * @see #isAxisLineVisible() + * @see #setAxisLinePaint(Paint) + * @see #setAxisLineStroke(Stroke) + */ + public void setAxisLineVisible(boolean visible) { + this.axisLineVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw the axis line. + * + * @return The paint (never null). + * + * @see #setAxisLinePaint(Paint) + */ + public Paint getAxisLinePaint() { + return this.axisLinePaint; + } + + /** + * Sets the paint used to draw the axis line and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getAxisLinePaint() + */ + public void setAxisLinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.axisLinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the stroke used to draw the axis line. + * + * @return The stroke (never null). + * + * @see #setAxisLineStroke(Stroke) + */ + public Stroke getAxisLineStroke() { + return this.axisLineStroke; + } + + /** + * Sets the stroke used to draw the axis line and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getAxisLineStroke() + */ + public void setAxisLineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.axisLineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns a flag indicating whether or not the tick labels are visible. + * + * @return The flag. + * + * @see #getTickLabelFont() + * @see #getTickLabelPaint() + * @see #setTickLabelsVisible(boolean) + */ + public boolean isTickLabelsVisible() { + return this.tickLabelsVisible; + } + + /** + * Sets the flag that determines whether or not the tick labels are + * visible and sends an {@link AxisChangeEvent} to all registered + * listeners. + * + * @param flag the flag. + * + * @see #isTickLabelsVisible() + * @see #setTickLabelFont(Font) + * @see #setTickLabelPaint(Paint) + */ + public void setTickLabelsVisible(boolean flag) { + + if (flag != this.tickLabelsVisible) { + this.tickLabelsVisible = flag; + fireChangeEvent(); + } + + } + + /** + * Returns the flag that indicates whether or not the minor tick marks are + * showing. + * + * @return The flag that indicates whether or not the minor tick marks are + * showing. + * + * @see #setMinorTickMarksVisible(boolean) + * + * @since 1.0.12 + */ + public boolean isMinorTickMarksVisible() { + return this.minorTickMarksVisible; + } + + /** + * Sets the flag that indicates whether or not the minor tick marks are + * showing and sends an {@link AxisChangeEvent} to all registered + * listeners. + * + * @param flag the flag. + * + * @see #isMinorTickMarksVisible() + * + * @since 1.0.12 + */ + public void setMinorTickMarksVisible(boolean flag) { + if (flag != this.minorTickMarksVisible) { + this.minorTickMarksVisible = flag; + fireChangeEvent(); + } + } + + /** + * Returns the font used for the tick labels (if showing). + * + * @return The font (never null). + * + * @see #setTickLabelFont(Font) + */ + public Font getTickLabelFont() { + return this.tickLabelFont; + } + + /** + * Sets the font for the tick labels and sends an {@link AxisChangeEvent} + * to all registered listeners. + * + * @param font the font (null not allowed). + * + * @see #getTickLabelFont() + */ + public void setTickLabelFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + if (!this.tickLabelFont.equals(font)) { + this.tickLabelFont = font; + fireChangeEvent(); + } + } + + /** + * Returns the color/shade used for the tick labels. + * + * @return The paint used for the tick labels. + * + * @see #setTickLabelPaint(Paint) + */ + public Paint getTickLabelPaint() { + return this.tickLabelPaint; + } + + /** + * Sets the paint used to draw tick labels (if they are showing) and + * sends an {@link AxisChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getTickLabelPaint() + */ + public void setTickLabelPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.tickLabelPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the insets for the tick labels. + * + * @return The insets (never null). + * + * @see #setTickLabelInsets(RectangleInsets) + */ + public RectangleInsets getTickLabelInsets() { + return this.tickLabelInsets; + } + + /** + * Sets the insets for the tick labels and sends an {@link AxisChangeEvent} + * to all registered listeners. + * + * @param insets the insets (null not permitted). + * + * @see #getTickLabelInsets() + */ + public void setTickLabelInsets(RectangleInsets insets) { + ParamChecks.nullNotPermitted(insets, "insets"); + if (!this.tickLabelInsets.equals(insets)) { + this.tickLabelInsets = insets; + fireChangeEvent(); + } + } + + /** + * Returns the flag that indicates whether or not the tick marks are + * showing. + * + * @return The flag that indicates whether or not the tick marks are + * showing. + * + * @see #setTickMarksVisible(boolean) + */ + public boolean isTickMarksVisible() { + return this.tickMarksVisible; + } + + /** + * Sets the flag that indicates whether or not the tick marks are showing + * and sends an {@link AxisChangeEvent} to all registered listeners. + * + * @param flag the flag. + * + * @see #isTickMarksVisible() + */ + public void setTickMarksVisible(boolean flag) { + if (flag != this.tickMarksVisible) { + this.tickMarksVisible = flag; + fireChangeEvent(); + } + } + + /** + * Returns the inside length of the tick marks. + * + * @return The length. + * + * @see #getTickMarkOutsideLength() + * @see #setTickMarkInsideLength(float) + */ + public float getTickMarkInsideLength() { + return this.tickMarkInsideLength; + } + + /** + * Sets the inside length of the tick marks and sends + * an {@link AxisChangeEvent} to all registered listeners. + * + * @param length the new length. + * + * @see #getTickMarkInsideLength() + */ + public void setTickMarkInsideLength(float length) { + this.tickMarkInsideLength = length; + fireChangeEvent(); + } + + /** + * Returns the outside length of the tick marks. + * + * @return The length. + * + * @see #getTickMarkInsideLength() + * @see #setTickMarkOutsideLength(float) + */ + public float getTickMarkOutsideLength() { + return this.tickMarkOutsideLength; + } + + /** + * Sets the outside length of the tick marks and sends + * an {@link AxisChangeEvent} to all registered listeners. + * + * @param length the new length. + * + * @see #getTickMarkInsideLength() + */ + public void setTickMarkOutsideLength(float length) { + this.tickMarkOutsideLength = length; + fireChangeEvent(); + } + + /** + * Returns the stroke used to draw tick marks. + * + * @return The stroke (never null). + * + * @see #setTickMarkStroke(Stroke) + */ + public Stroke getTickMarkStroke() { + return this.tickMarkStroke; + } + + /** + * Sets the stroke used to draw tick marks and sends + * an {@link AxisChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getTickMarkStroke() + */ + public void setTickMarkStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + if (!this.tickMarkStroke.equals(stroke)) { + this.tickMarkStroke = stroke; + fireChangeEvent(); + } + } + + /** + * Returns the paint used to draw tick marks (if they are showing). + * + * @return The paint (never null). + * + * @see #setTickMarkPaint(Paint) + */ + public Paint getTickMarkPaint() { + return this.tickMarkPaint; + } + + /** + * Sets the paint used to draw tick marks and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getTickMarkPaint() + */ + public void setTickMarkPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.tickMarkPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the inside length of the minor tick marks. + * + * @return The length. + * + * @see #getMinorTickMarkOutsideLength() + * @see #setMinorTickMarkInsideLength(float) + * + * @since 1.0.12 + */ + public float getMinorTickMarkInsideLength() { + return this.minorTickMarkInsideLength; + } + + /** + * Sets the inside length of the minor tick marks and sends + * an {@link AxisChangeEvent} to all registered listeners. + * + * @param length the new length. + * + * @see #getMinorTickMarkInsideLength() + * + * @since 1.0.12 + */ + public void setMinorTickMarkInsideLength(float length) { + this.minorTickMarkInsideLength = length; + fireChangeEvent(); + } + + /** + * Returns the outside length of the minor tick marks. + * + * @return The length. + * + * @see #getMinorTickMarkInsideLength() + * @see #setMinorTickMarkOutsideLength(float) + * + * @since 1.0.12 + */ + public float getMinorTickMarkOutsideLength() { + return this.minorTickMarkOutsideLength; + } + + /** + * Sets the outside length of the minor tick marks and sends + * an {@link AxisChangeEvent} to all registered listeners. + * + * @param length the new length. + * + * @see #getMinorTickMarkInsideLength() + * + * @since 1.0.12 + */ + public void setMinorTickMarkOutsideLength(float length) { + this.minorTickMarkOutsideLength = length; + fireChangeEvent(); + } + + /** + * Returns the plot that the axis is assigned to. This method will return + * null if the axis is not currently assigned to a plot. + * + * @return The plot that the axis is assigned to (possibly + * null). + * + * @see #setPlot(Plot) + */ + public Plot getPlot() { + return this.plot; + } + + /** + * Sets a reference to the plot that the axis is assigned to. + *

+ * This method is used internally, you shouldn't need to call it yourself. + * + * @param plot the plot. + * + * @see #getPlot() + */ + public void setPlot(Plot plot) { + this.plot = plot; + configure(); + } + + /** + * Returns the fixed dimension for the axis. + * + * @return The fixed dimension. + * + * @see #setFixedDimension(double) + */ + public double getFixedDimension() { + return this.fixedDimension; + } + + /** + * Sets the fixed dimension for the axis. + *

+ * This is used when combining more than one plot on a chart. In this case, + * there may be several axes that need to have the same height or width so + * that they are aligned. This method is used to fix a dimension for the + * axis (the context determines whether the dimension is horizontal or + * vertical). + * + * @param dimension the fixed dimension. + * + * @see #getFixedDimension() + */ + public void setFixedDimension(double dimension) { + this.fixedDimension = dimension; + } + + /** + * Configures the axis to work with the current plot. Override this method + * to perform any special processing (such as auto-rescaling). + */ + public abstract void configure(); + + /** + * Estimates the space (height or width) required to draw the axis. + * + * @param g2 the graphics device. + * @param plot the plot that the axis belongs to. + * @param plotArea the area within which the plot (including axes) should + * be drawn. + * @param edge the axis location. + * @param space space already reserved. + * + * @return The space required to draw the axis (including pre-reserved + * space). + */ + public abstract AxisSpace reserveSpace(Graphics2D g2, Plot plot, + Rectangle2D plotArea, + RectangleEdge edge, + AxisSpace space); + + /** + * Draws the axis on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device (null 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 (null not permitted). + * @param plotState collects information about the plot + * (null permitted). + * + * @return The axis state (never null). + */ + public abstract AxisState draw(Graphics2D g2, + double cursor, + Rectangle2D plotArea, + Rectangle2D dataArea, + RectangleEdge edge, + PlotRenderingInfo plotState); + + /** + * Calculates the positions of the ticks for the axis, storing the results + * in the tick list (ready for drawing). + * + * @param g2 the graphics device. + * @param state the axis state. + * @param dataArea the area inside the axes. + * @param edge the edge on which the axis is located. + * + * @return The list of ticks. + */ + public abstract List refreshTicks(Graphics2D g2, AxisState state, + Rectangle2D dataArea, RectangleEdge edge); + + /** + * Created an entity for the axis. + * + * @param cursor the initial cursor value. + * @param state the axis state after completion of the drawing with a + * possibly updated cursor position. + * @param dataArea the data area. + * @param edge the edge. + * @param plotState the PlotRenderingInfo from which a reference to the + * entity collection can be obtained. + * + * @since 1.0.13 + */ + protected void createAndAddEntity(double cursor, AxisState state, + Rectangle2D dataArea, RectangleEdge edge, + PlotRenderingInfo plotState) { + + if (plotState == null || plotState.getOwner() == null) { + return; // no need to create entity if we can't save it anyways... + } + Rectangle2D hotspot = null; + if (edge.equals(RectangleEdge.TOP)) { + hotspot = new Rectangle2D.Double(dataArea.getX(), + state.getCursor(), dataArea.getWidth(), + cursor - state.getCursor()); + } + else if (edge.equals(RectangleEdge.BOTTOM)) { + hotspot = new Rectangle2D.Double(dataArea.getX(), cursor, + dataArea.getWidth(), state.getCursor() - cursor); + } + else if (edge.equals(RectangleEdge.LEFT)) { + hotspot = new Rectangle2D.Double(state.getCursor(), + dataArea.getY(), cursor - state.getCursor(), + dataArea.getHeight()); + } + else if (edge.equals(RectangleEdge.RIGHT)) { + hotspot = new Rectangle2D.Double(cursor, dataArea.getY(), + state.getCursor() - cursor, dataArea.getHeight()); + } + EntityCollection e = plotState.getOwner().getEntityCollection(); + if (e != null) { + e.add(new AxisEntity(hotspot, this)); + } + } + + /** + * Registers an object for notification of changes to the axis. + * + * @param listener the object that is being registered. + * + * @see #removeChangeListener(AxisChangeListener) + */ + public void addChangeListener(AxisChangeListener listener) { + this.listenerList.add(AxisChangeListener.class, listener); + } + + /** + * Deregisters an object for notification of changes to the axis. + * + * @param listener the object to deregister. + * + * @see #addChangeListener(AxisChangeListener) + */ + public void removeChangeListener(AxisChangeListener listener) { + this.listenerList.remove(AxisChangeListener.class, listener); + } + + /** + * Returns true if the specified object is registered with + * the dataset as a listener. Most applications won't need to call this + * method, it exists mainly for use by unit testing code. + * + * @param listener the listener. + * + * @return A boolean. + */ + public boolean hasListener(EventListener listener) { + List list = Arrays.asList(this.listenerList.getListenerList()); + return list.contains(listener); + } + + /** + * Notifies all registered listeners that the axis has changed. + * The AxisChangeEvent provides information about the change. + * + * @param event information about the change to the axis. + */ + protected void notifyListeners(AxisChangeEvent event) { + Object[] listeners = this.listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == AxisChangeListener.class) { + ((AxisChangeListener) listeners[i + 1]).axisChanged(event); + } + } + } + + /** + * Sends an {@link AxisChangeEvent} to all registered listeners. + * + * @since 1.0.12 + */ + protected void fireChangeEvent() { + notifyListeners(new AxisChangeEvent(this)); + } + + /** + * Returns a rectangle that encloses the axis label. This is typically + * used for layout purposes (it gives the maximum dimensions of the label). + * + * @param g2 the graphics device. + * @param edge the edge of the plot area along which the axis is measuring. + * + * @return The enclosing rectangle. + */ + protected Rectangle2D getLabelEnclosure(Graphics2D g2, RectangleEdge edge) { + Rectangle2D result = new Rectangle2D.Double(); + Rectangle2D bounds = null; + if (this.attributedLabel != null) { + TextLayout layout = new TextLayout( + this.attributedLabel.getIterator(), + g2.getFontRenderContext()); + bounds = layout.getBounds(); + } else { + String axisLabel = getLabel(); + if (axisLabel != null && !axisLabel.equals("")) { + FontMetrics fm = g2.getFontMetrics(getLabelFont()); + bounds = TextUtilities.getTextBounds(axisLabel, g2, fm); + } + } + if (bounds != null) { + RectangleInsets insets = getLabelInsets(); + bounds = insets.createOutsetRectangle(bounds); + double angle = getLabelAngle(); + if (edge == RectangleEdge.LEFT || edge == RectangleEdge.RIGHT) { + angle = angle - Math.PI / 2.0; + } + double x = bounds.getCenterX(); + double y = bounds.getCenterY(); + AffineTransform transformer + = AffineTransform.getRotateInstance(angle, x, y); + Shape labelBounds = transformer.createTransformedShape(bounds); + result = labelBounds.getBounds2D(); + } + return result; + } + + protected double labelLocationX(AxisLabelLocation location, + Rectangle2D dataArea) { + if (location.equals(AxisLabelLocation.HIGH_END)) { + return dataArea.getMaxX(); + } + if (location.equals(AxisLabelLocation.MIDDLE)) { + return dataArea.getCenterX(); + } + if (location.equals(AxisLabelLocation.LOW_END)) { + return dataArea.getMinX(); + } + throw new RuntimeException("Unexpected AxisLabelLocation: " + location); + } + + protected double labelLocationY(AxisLabelLocation location, + Rectangle2D dataArea) { + if (location.equals(AxisLabelLocation.HIGH_END)) { + return dataArea.getMinY(); + } + if (location.equals(AxisLabelLocation.MIDDLE)) { + return dataArea.getCenterY(); + } + if (location.equals(AxisLabelLocation.LOW_END)) { + return dataArea.getMaxY(); + } + throw new RuntimeException("Unexpected AxisLabelLocation: " + location); + } + + protected TextAnchor labelAnchorH(AxisLabelLocation location) { + if (location.equals(AxisLabelLocation.HIGH_END)) { + return TextAnchor.CENTER_RIGHT; + } + if (location.equals(AxisLabelLocation.MIDDLE)) { + return TextAnchor.CENTER; + } + if (location.equals(AxisLabelLocation.LOW_END)) { + return TextAnchor.CENTER_LEFT; + } + throw new RuntimeException("Unexpected AxisLabelLocation: " + location); + } + + protected TextAnchor labelAnchorV(AxisLabelLocation location) { + if (location.equals(AxisLabelLocation.HIGH_END)) { + return TextAnchor.CENTER_RIGHT; + } + if (location.equals(AxisLabelLocation.MIDDLE)) { + return TextAnchor.CENTER; + } + if (location.equals(AxisLabelLocation.LOW_END)) { + return TextAnchor.CENTER_LEFT; + } + throw new RuntimeException("Unexpected AxisLabelLocation: " + location); + } + + /** + * Draws the axis label. + * + * @param label the label text. + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param dataArea the area inside the axes. + * @param edge the location of the axis. + * @param state the axis state (null not permitted). + * + * @return Information about the axis. + */ + protected AxisState drawLabel(String label, Graphics2D g2, + Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, + AxisState state) { + + // it is unlikely that 'state' will be null, but check anyway... + ParamChecks.nullNotPermitted(state, "state"); + + if ((label == null) || (label.equals(""))) { + return state; + } + + Font font = getLabelFont(); + RectangleInsets insets = getLabelInsets(); + g2.setFont(font); + g2.setPaint(getLabelPaint()); + FontMetrics fm = g2.getFontMetrics(); + Rectangle2D labelBounds = TextUtilities.getTextBounds(label, g2, fm); + + if (edge == RectangleEdge.TOP) { + AffineTransform t = AffineTransform.getRotateInstance( + getLabelAngle(), labelBounds.getCenterX(), + labelBounds.getCenterY()); + Shape rotatedLabelBounds = t.createTransformedShape(labelBounds); + labelBounds = rotatedLabelBounds.getBounds2D(); + double labelx = labelLocationX(this.labelLocation, dataArea); + double labely = state.getCursor() - insets.getBottom() + - labelBounds.getHeight() / 2.0; + TextAnchor anchor = labelAnchorH(this.labelLocation); + TextUtilities.drawRotatedString(label, g2, (float) labelx, + (float) labely, anchor, getLabelAngle(), TextAnchor.CENTER); + state.cursorUp(insets.getTop() + labelBounds.getHeight() + + insets.getBottom()); + } + else if (edge == RectangleEdge.BOTTOM) { + AffineTransform t = AffineTransform.getRotateInstance( + getLabelAngle(), labelBounds.getCenterX(), + labelBounds.getCenterY()); + Shape rotatedLabelBounds = t.createTransformedShape(labelBounds); + labelBounds = rotatedLabelBounds.getBounds2D(); + double labelx = labelLocationX(this.labelLocation, dataArea); + double labely = state.getCursor() + + insets.getTop() + labelBounds.getHeight() / 2.0; + TextAnchor anchor = labelAnchorH(this.labelLocation); + TextUtilities.drawRotatedString(label, g2, (float) labelx, + (float) labely, anchor, getLabelAngle(), TextAnchor.CENTER); + state.cursorDown(insets.getTop() + labelBounds.getHeight() + + insets.getBottom()); + } + else if (edge == RectangleEdge.LEFT) { + AffineTransform t = AffineTransform.getRotateInstance( + getLabelAngle() - Math.PI / 2.0, labelBounds.getCenterX(), + labelBounds.getCenterY()); + Shape rotatedLabelBounds = t.createTransformedShape(labelBounds); + labelBounds = rotatedLabelBounds.getBounds2D(); + double labelx = state.getCursor() + - insets.getRight() - labelBounds.getWidth() / 2.0; + double labely = labelLocationY(this.labelLocation, dataArea); + TextAnchor anchor = labelAnchorV(this.labelLocation); + TextUtilities.drawRotatedString(label, g2, (float) labelx, + (float) labely, anchor, getLabelAngle() - Math.PI / 2.0, + anchor); + state.cursorLeft(insets.getLeft() + labelBounds.getWidth() + + insets.getRight()); + } + else if (edge == RectangleEdge.RIGHT) { + AffineTransform t = AffineTransform.getRotateInstance( + getLabelAngle() + Math.PI / 2.0, + labelBounds.getCenterX(), labelBounds.getCenterY()); + Shape rotatedLabelBounds = t.createTransformedShape(labelBounds); + labelBounds = rotatedLabelBounds.getBounds2D(); + double labelx = state.getCursor() + + insets.getLeft() + labelBounds.getWidth() / 2.0; + double labely = labelLocationY(this.labelLocation, dataArea); + TextAnchor anchor = labelAnchorV(this.labelLocation); + TextUtilities.drawRotatedString(label, g2, (float) labelx, + (float) labely, anchor, getLabelAngle() + Math.PI / 2.0, + anchor); + state.cursorRight(insets.getLeft() + labelBounds.getWidth() + + insets.getRight()); + } + + return state; + + } + + /** + * Draws the axis label. + * + * @param label the label text. + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param dataArea the area inside the axes. + * @param edge the location of the axis. + * @param state the axis state (null not permitted). + * + * @return Information about the axis. + * + * @since 1.0.16 + */ + protected AxisState drawAttributedLabel(AttributedString label, + Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, + RectangleEdge edge, AxisState state) { + + // it is unlikely that 'state' will be null, but check anyway... + ParamChecks.nullNotPermitted(state, "state"); + + if (label == null) { + return state; + } + + RectangleInsets insets = getLabelInsets(); + g2.setFont(getLabelFont()); + g2.setPaint(getLabelPaint()); + TextLayout layout = new TextLayout(this.attributedLabel.getIterator(), + g2.getFontRenderContext()); + Rectangle2D labelBounds = layout.getBounds(); + + if (edge == RectangleEdge.TOP) { + AffineTransform t = AffineTransform.getRotateInstance( + getLabelAngle(), labelBounds.getCenterX(), + labelBounds.getCenterY()); + Shape rotatedLabelBounds = t.createTransformedShape(labelBounds); + labelBounds = rotatedLabelBounds.getBounds2D(); + double labelx = labelLocationX(this.labelLocation, dataArea); + double labely = state.getCursor() - insets.getBottom() + - labelBounds.getHeight() / 2.0; + TextAnchor anchor = labelAnchorH(this.labelLocation); + AttrStringUtils.drawRotatedString(label, g2, (float) labelx, + (float) labely, anchor, getLabelAngle(), TextAnchor.CENTER); + state.cursorUp(insets.getTop() + labelBounds.getHeight() + + insets.getBottom()); + } + else if (edge == RectangleEdge.BOTTOM) { + AffineTransform t = AffineTransform.getRotateInstance( + getLabelAngle(), labelBounds.getCenterX(), + labelBounds.getCenterY()); + Shape rotatedLabelBounds = t.createTransformedShape(labelBounds); + labelBounds = rotatedLabelBounds.getBounds2D(); + double labelx = labelLocationX(this.labelLocation, dataArea); + double labely = state.getCursor() + + insets.getTop() + labelBounds.getHeight() / 2.0; + TextAnchor anchor = labelAnchorH(this.labelLocation); + AttrStringUtils.drawRotatedString(label, g2, (float) labelx, + (float) labely, anchor, getLabelAngle(), TextAnchor.CENTER); + state.cursorDown(insets.getTop() + labelBounds.getHeight() + + insets.getBottom()); + } + else if (edge == RectangleEdge.LEFT) { + AffineTransform t = AffineTransform.getRotateInstance( + getLabelAngle() - Math.PI / 2.0, labelBounds.getCenterX(), + labelBounds.getCenterY()); + Shape rotatedLabelBounds = t.createTransformedShape(labelBounds); + labelBounds = rotatedLabelBounds.getBounds2D(); + double labelx = state.getCursor() + - insets.getRight() - labelBounds.getWidth() / 2.0; + double labely = labelLocationY(this.labelLocation, dataArea); + TextAnchor anchor = labelAnchorV(this.labelLocation); + AttrStringUtils.drawRotatedString(label, g2, (float) labelx, + (float) labely, anchor, getLabelAngle() - Math.PI / 2.0, + anchor); + state.cursorLeft(insets.getLeft() + labelBounds.getWidth() + + insets.getRight()); + } + else if (edge == RectangleEdge.RIGHT) { + AffineTransform t = AffineTransform.getRotateInstance( + getLabelAngle() + Math.PI / 2.0, + labelBounds.getCenterX(), labelBounds.getCenterY()); + Shape rotatedLabelBounds = t.createTransformedShape(labelBounds); + labelBounds = rotatedLabelBounds.getBounds2D(); + double labelx = state.getCursor() + + insets.getLeft() + labelBounds.getWidth() / 2.0; + double labely = labelLocationY(this.labelLocation, dataArea); + TextAnchor anchor = labelAnchorV(this.labelLocation); + AttrStringUtils.drawRotatedString(label, g2, (float) labelx, + (float) labely, anchor, getLabelAngle() + Math.PI / 2.0, + anchor); + state.cursorRight(insets.getLeft() + labelBounds.getWidth() + + insets.getRight()); + } + return state; + } + + /** + * Draws an axis line at the current cursor position and edge. + * + * @param g2 the graphics device. + * @param cursor the cursor position. + * @param dataArea the data area. + * @param edge the edge. + */ + protected void drawAxisLine(Graphics2D g2, double cursor, + Rectangle2D dataArea, RectangleEdge edge) { + + Line2D axisLine = null; + if (edge == RectangleEdge.TOP) { + axisLine = new Line2D.Double(dataArea.getX(), cursor, + dataArea.getMaxX(), cursor); + } + else if (edge == RectangleEdge.BOTTOM) { + axisLine = new Line2D.Double(dataArea.getX(), cursor, + dataArea.getMaxX(), cursor); + } + else if (edge == RectangleEdge.LEFT) { + axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, + dataArea.getMaxY()); + } + else if (edge == RectangleEdge.RIGHT) { + axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, + dataArea.getMaxY()); + } + g2.setPaint(this.axisLinePaint); + g2.setStroke(this.axisLineStroke); + g2.draw(axisLine); + + } + + /** + * Returns a clone of the axis. + * + * @return A clone. + * + * @throws CloneNotSupportedException if some component of the axis does + * not support cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + Axis clone = (Axis) super.clone(); + // It's up to the plot which clones up to restore the correct references + clone.plot = null; + clone.listenerList = new EventListenerList(); + return clone; + } + + /** + * Tests this axis for equality with another object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Axis)) { + return false; + } + Axis that = (Axis) obj; + if (this.visible != that.visible) { + return false; + } + if (!ObjectUtilities.equal(this.label, that.label)) { + return false; + } + if (!AttributedStringUtilities.equal(this.attributedLabel, + that.attributedLabel)) { + return false; + } + if (!ObjectUtilities.equal(this.labelFont, that.labelFont)) { + return false; + } + if (!PaintUtilities.equal(this.labelPaint, that.labelPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.labelInsets, that.labelInsets)) { + return false; + } + if (this.labelAngle != that.labelAngle) { + return false; + } + if (!this.labelLocation.equals(that.labelLocation)) { + return false; + } + if (this.axisLineVisible != that.axisLineVisible) { + return false; + } + if (!ObjectUtilities.equal(this.axisLineStroke, that.axisLineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.axisLinePaint, that.axisLinePaint)) { + return false; + } + if (this.tickLabelsVisible != that.tickLabelsVisible) { + return false; + } + if (!ObjectUtilities.equal(this.tickLabelFont, that.tickLabelFont)) { + return false; + } + if (!PaintUtilities.equal(this.tickLabelPaint, that.tickLabelPaint)) { + return false; + } + if (!ObjectUtilities.equal( + this.tickLabelInsets, that.tickLabelInsets + )) { + return false; + } + if (this.tickMarksVisible != that.tickMarksVisible) { + return false; + } + if (this.tickMarkInsideLength != that.tickMarkInsideLength) { + return false; + } + if (this.tickMarkOutsideLength != that.tickMarkOutsideLength) { + return false; + } + if (!PaintUtilities.equal(this.tickMarkPaint, that.tickMarkPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.tickMarkStroke, that.tickMarkStroke)) { + return false; + } + if (this.minorTickMarksVisible != that.minorTickMarksVisible) { + return false; + } + if (this.minorTickMarkInsideLength != that.minorTickMarkInsideLength) { + return false; + } + if (this.minorTickMarkOutsideLength + != that.minorTickMarkOutsideLength) { + return false; + } + if (this.fixedDimension != that.fixedDimension) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int hash = 3; + if (this.label != null) { + hash = 83 * hash + this.label.hashCode(); + } + return hash; + } + + /** + * 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.writeAttributedString(this.attributedLabel, stream); + SerialUtilities.writePaint(this.labelPaint, stream); + SerialUtilities.writePaint(this.tickLabelPaint, stream); + SerialUtilities.writeStroke(this.axisLineStroke, stream); + SerialUtilities.writePaint(this.axisLinePaint, stream); + SerialUtilities.writeStroke(this.tickMarkStroke, stream); + SerialUtilities.writePaint(this.tickMarkPaint, 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.attributedLabel = SerialUtilities.readAttributedString(stream); + this.labelPaint = SerialUtilities.readPaint(stream); + this.tickLabelPaint = SerialUtilities.readPaint(stream); + this.axisLineStroke = SerialUtilities.readStroke(stream); + this.axisLinePaint = SerialUtilities.readPaint(stream); + this.tickMarkStroke = SerialUtilities.readStroke(stream); + this.tickMarkPaint = SerialUtilities.readPaint(stream); + this.listenerList = new EventListenerList(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisCollection.java new file mode 100755 index 0000000..eb21eeb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisCollection.java @@ -0,0 +1,142 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * AxisCollection.java + * ------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2003 : Added standard header (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.axis; + +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +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 (null not permitted). + * @param edge the edge of the plot that the axis should be drawn on + * (null not permitted). + */ + public void add(Axis axis, RectangleEdge edge) { + ParamChecks.nullNotPermitted(axis, "axis"); + ParamChecks.nullNotPermitted(edge, "edge"); + 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); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisLabelLocation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisLabelLocation.java new file mode 100755 index 0000000..74552a0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisLabelLocation.java @@ -0,0 +1,146 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * AxisLabelLocation.java + * ---------------------- + * (C) Copyright 2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 01-Aug-2013 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Used to indicate the location of an axis label. + * + * @since 1.0.16 + */ +public final class AxisLabelLocation implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 1L; + + /** Axis label at the top. */ + public static final AxisLabelLocation HIGH_END = new AxisLabelLocation( + "HIGH_END"); + + /** Axis label at the middle. */ + public static final AxisLabelLocation MIDDLE = new AxisLabelLocation( + "MIDDLE"); + + /** Axis label at the bottom. */ + public static final AxisLabelLocation LOW_END = new AxisLabelLocation( + "LOW_END"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private AxisLabelLocation(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof AxisLabelLocation)) { + return false; + } + AxisLabelLocation location = (AxisLabelLocation) obj; + if (!this.name.equals(location.toString())) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int hash = 5; + hash = 83 * hash + this.name.hashCode(); + return hash; + } + + /** + * 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(AxisLabelLocation.HIGH_END)) { + return AxisLabelLocation.HIGH_END; + } + if (this.equals(AxisLabelLocation.MIDDLE)) { + return AxisLabelLocation.MIDDLE; + } + if (this.equals(AxisLabelLocation.LOW_END)) { + return AxisLabelLocation.LOW_END; + } + + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisLocation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisLocation.java new file mode 100755 index 0000000..a5b87de --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisLocation.java @@ -0,0 +1,197 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * AxisLocation.java + * ----------------- + * (C) Copyright 2003-2013, 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); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.ObjectStreamException; +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +/** + * 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. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + 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 a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int hash = 5; + hash = 83 * hash + this.name.hashCode(); + return hash; + } + + /** + * Returns the location that is opposite to the supplied location. + * + * @param location the location (null not permitted). + * + * @return The opposite location. + */ + public static AxisLocation getOpposite(AxisLocation location) { + ParamChecks.nullNotPermitted(location, "location"); + 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; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisSpace.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisSpace.java new file mode 100755 index 0000000..82ff0aa --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisSpace.java @@ -0,0 +1,382 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * AxisSpace.java + * -------------- + * (C) Copyright 2003-2013, 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); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.axis; + +import java.awt.geom.Rectangle2D; +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +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 (null not permitted). + */ + public void add(double space, RectangleEdge edge) { + ParamChecks.nullNotPermitted(edge, "edge"); + 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. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Tests this object for equality with another object. + * + * @param obj the object to compare against. + * + * @return true or false. + */ + @Override + 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. + */ + @Override + 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. + */ + @Override + public String toString() { + return super.toString() + "[left=" + this.left + ",right=" + this.right + + ",top=" + this.top + ",bottom=" + this.bottom + "]"; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisState.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisState.java new file mode 100755 index 0000000..d1336e6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/AxisState.java @@ -0,0 +1,193 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * 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; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryAnchor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryAnchor.java new file mode 100755 index 0000000..cb46d4a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryAnchor.java @@ -0,0 +1,132 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * 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: + * START, MIDDLE and END. + */ +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. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + 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; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryAxis.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryAxis.java new file mode 100755 index 0000000..901e2d5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryAxis.java @@ -0,0 +1,1544 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * CategoryAxis.java + * ----------------- + * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert; + * Contributor(s): Pady Srinivasan (patch 1217634); + * Peter Kolb (patches 2497611 and 2603321); + * + * Changes + * ------- + * 21-Aug-2001 : Added standard header. Fixed DOS encoding problem (DG); + * 18-Sep-2001 : Updated header (DG); + * 04-Dec-2001 : Changed constructors to protected, and tidied up default + * values (DG); + * 19-Apr-2002 : Updated import statements (DG); + * 05-Sep-2002 : Updated constructor for changes in Axis class (DG); + * 06-Nov-2002 : Moved margins from the CategoryPlot class (DG); + * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); + * 22-Jan-2002 : Removed monolithic constructor (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 09-May-2003 : Merged HorizontalCategoryAxis and VerticalCategoryAxis into + * this class (DG); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); + * 05-Nov-2003 : Fixed serialization bug (DG); + * 26-Nov-2003 : Added category label offset (DG); + * 06-Jan-2004 : Moved axis line attributes to Axis class, rationalised + * category label position attributes (DG); + * 07-Jan-2004 : Added new implementation for linewrapping of category + * labels (DG); + * 17-Feb-2004 : Moved deprecated code to bottom of source file (DG); + * 10-Mar-2004 : Changed Dimension --> Dimension2D in text classes (DG); + * 16-Mar-2004 : Added support for tooltips on category labels (DG); + * 01-Apr-2004 : Changed java.awt.geom.Dimension2D to org.jfree.ui.Size2D + * because of JDK bug 4976448 which persists on JDK 1.3.1 (DG); + * 03-Sep-2004 : Added 'maxCategoryLabelLines' attribute (DG); + * 04-Oct-2004 : Renamed ShapeUtils --> ShapeUtilities (DG); + * 11-Jan-2005 : Removed deprecated methods in preparation for 1.0.0 + * release (DG); + * 21-Jan-2005 : Modified return type for RectangleAnchor.coordinates() + * method (DG); + * 21-Apr-2005 : Replaced Insets with RectangleInsets (DG); + * 26-Apr-2005 : Removed LOGGER (DG); + * 08-Jun-2005 : Fixed bug in axis layout (DG); + * 22-Nov-2005 : Added a method to access the tool tip text for a category + * label (DG); + * 23-Nov-2005 : Added per-category font and paint options - see patch + * 1217634 (DG); + * ------------- JFreeChart 1.0.x --------------------------------------------- + * 11-Jan-2006 : Fixed null pointer exception in drawCategoryLabels - see bug + * 1403043 (DG); + * 18-Aug-2006 : Fix for bug drawing category labels, thanks to Adriaan + * Joubert (1277726) (DG); + * 02-Oct-2006 : Updated category label entity (DG); + * 30-Oct-2006 : Updated refreshTicks() method to account for possibility of + * multiple domain axes (DG); + * 07-Mar-2007 : Fixed bug in axis label positioning (DG); + * 27-Sep-2007 : Added getCategorySeriesMiddle() method (DG); + * 21-Nov-2007 : Fixed performance bug noted by FindBugs in the + * equalPaintMaps() method (DG); + * 23-Apr-2008 : Fixed bug 1942059, bad use of insets in + * calculateTextBlockWidth() (DG); + * 26-Jun-2008 : Added new getCategoryMiddle() method (DG); + * 27-Oct-2008 : Set font on Graphics2D when creating category labels (DG); + * 14-Jan-2009 : Added new variant of getCategorySeriesMiddle() to make it + * simpler for renderers with hidden series (PK); + * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); + * 16-Apr-2009 : Added tick mark drawing (DG); + * 29-Jun-2009 : Fixed bug where axis entity is hiding label entities (DG); + * 25-Jul-2013 : Added support for URLs on category labels (DG); + * 01-Aug-2013 : Added attributedLabel override to support superscripts, + * subscripts and more (DG); + */ + +package org.jfree.chart.axis; + +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.geom.Line2D; +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 java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.jfree.chart.entity.CategoryLabelEntity; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.AxisChangeEvent; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.category.CategoryDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.text.G2TextMeasurer; +import org.jfree.text.TextBlock; +import org.jfree.text.TextUtilities; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.Size2D; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.ShapeUtilities; + +/** + * An axis that displays categories. + */ +public class CategoryAxis extends Axis implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 5886554608114265863L; + + /** + * The default margin for the axis (used for both lower and upper margins). + */ + public static final double DEFAULT_AXIS_MARGIN = 0.05; + + /** + * The default margin between categories (a percentage of the overall axis + * length). + */ + public static final double DEFAULT_CATEGORY_MARGIN = 0.20; + + /** The amount of space reserved at the start of the axis. */ + private double lowerMargin; + + /** The amount of space reserved at the end of the axis. */ + private double upperMargin; + + /** The amount of space reserved between categories. */ + private double categoryMargin; + + /** The maximum number of lines for category labels. */ + private int maximumCategoryLabelLines; + + /** + * A ratio that is multiplied by the width of one category to determine the + * maximum label width. + */ + private float maximumCategoryLabelWidthRatio; + + /** The category label offset. */ + private int categoryLabelPositionOffset; + + /** + * A structure defining the category label positions for each axis + * location. + */ + private CategoryLabelPositions categoryLabelPositions; + + /** Storage for tick label font overrides (if any). */ + private Map tickLabelFontMap; + + /** Storage for tick label paint overrides (if any). */ + private transient Map tickLabelPaintMap; + + /** Storage for the category label tooltips (if any). */ + private Map categoryLabelToolTips; + + /** Storage for the category label URLs (if any). */ + private Map categoryLabelURLs; + + /** + * Creates a new category axis with no label. + */ + public CategoryAxis() { + this(null); + } + + /** + * Constructs a category axis, using default values where necessary. + * + * @param label the axis label (null permitted). + */ + public CategoryAxis(String label) { + super(label); + + this.lowerMargin = DEFAULT_AXIS_MARGIN; + this.upperMargin = DEFAULT_AXIS_MARGIN; + this.categoryMargin = DEFAULT_CATEGORY_MARGIN; + this.maximumCategoryLabelLines = 1; + this.maximumCategoryLabelWidthRatio = 0.0f; + + this.categoryLabelPositionOffset = 4; + this.categoryLabelPositions = CategoryLabelPositions.STANDARD; + this.tickLabelFontMap = new HashMap(); + this.tickLabelPaintMap = new HashMap(); + this.categoryLabelToolTips = new HashMap(); + this.categoryLabelURLs = new HashMap(); + } + + /** + * Returns the lower margin for the axis. + * + * @return The margin. + * + * @see #getUpperMargin() + * @see #setLowerMargin(double) + */ + public double getLowerMargin() { + return this.lowerMargin; + } + + /** + * Sets the lower margin for the axis and sends an {@link AxisChangeEvent} + * to all registered listeners. + * + * @param margin the margin as a percentage of the axis length (for + * example, 0.05 is five percent). + * + * @see #getLowerMargin() + */ + public void setLowerMargin(double margin) { + this.lowerMargin = margin; + fireChangeEvent(); + } + + /** + * Returns the upper margin for the axis. + * + * @return The margin. + * + * @see #getLowerMargin() + * @see #setUpperMargin(double) + */ + public double getUpperMargin() { + return this.upperMargin; + } + + /** + * Sets the upper margin for the axis and sends an {@link AxisChangeEvent} + * to all registered listeners. + * + * @param margin the margin as a percentage of the axis length (for + * example, 0.05 is five percent). + * + * @see #getUpperMargin() + */ + public void setUpperMargin(double margin) { + this.upperMargin = margin; + fireChangeEvent(); + } + + /** + * Returns the category margin. + * + * @return The margin. + * + * @see #setCategoryMargin(double) + */ + public double getCategoryMargin() { + return this.categoryMargin; + } + + /** + * Sets the category margin and sends an {@link AxisChangeEvent} to all + * registered listeners. The overall category margin is distributed over + * N-1 gaps, where N is the number of categories on the axis. + * + * @param margin the margin as a percentage of the axis length (for + * example, 0.05 is five percent). + * + * @see #getCategoryMargin() + */ + public void setCategoryMargin(double margin) { + this.categoryMargin = margin; + fireChangeEvent(); + } + + /** + * Returns the maximum number of lines to use for each category label. + * + * @return The maximum number of lines. + * + * @see #setMaximumCategoryLabelLines(int) + */ + public int getMaximumCategoryLabelLines() { + return this.maximumCategoryLabelLines; + } + + /** + * Sets the maximum number of lines to use for each category label and + * sends an {@link AxisChangeEvent} to all registered listeners. + * + * @param lines the maximum number of lines. + * + * @see #getMaximumCategoryLabelLines() + */ + public void setMaximumCategoryLabelLines(int lines) { + this.maximumCategoryLabelLines = lines; + fireChangeEvent(); + } + + /** + * Returns the category label width ratio. + * + * @return The ratio. + * + * @see #setMaximumCategoryLabelWidthRatio(float) + */ + public float getMaximumCategoryLabelWidthRatio() { + return this.maximumCategoryLabelWidthRatio; + } + + /** + * Sets the maximum category label width ratio and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param ratio the ratio. + * + * @see #getMaximumCategoryLabelWidthRatio() + */ + public void setMaximumCategoryLabelWidthRatio(float ratio) { + this.maximumCategoryLabelWidthRatio = ratio; + fireChangeEvent(); + } + + /** + * Returns the offset between the axis and the category labels (before + * label positioning is taken into account). + * + * @return The offset (in Java2D units). + * + * @see #setCategoryLabelPositionOffset(int) + */ + public int getCategoryLabelPositionOffset() { + return this.categoryLabelPositionOffset; + } + + /** + * Sets the offset between the axis and the category labels (before label + * positioning is taken into account) and sends a change event to all + * registered listeners. + * + * @param offset the offset (in Java2D units). + * + * @see #getCategoryLabelPositionOffset() + */ + public void setCategoryLabelPositionOffset(int offset) { + this.categoryLabelPositionOffset = offset; + fireChangeEvent(); + } + + /** + * Returns the category label position specification (this contains label + * positioning info for all four possible axis locations). + * + * @return The positions (never null). + * + * @see #setCategoryLabelPositions(CategoryLabelPositions) + */ + public CategoryLabelPositions getCategoryLabelPositions() { + return this.categoryLabelPositions; + } + + /** + * Sets the category label position specification for the axis and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param positions the positions (null not permitted). + * + * @see #getCategoryLabelPositions() + */ + public void setCategoryLabelPositions(CategoryLabelPositions positions) { + ParamChecks.nullNotPermitted(positions, "positions"); + this.categoryLabelPositions = positions; + fireChangeEvent(); + } + + /** + * Returns the font for the tick label for the given category. + * + * @param category the category (null not permitted). + * + * @return The font (never null). + * + * @see #setTickLabelFont(Comparable, Font) + */ + public Font getTickLabelFont(Comparable category) { + ParamChecks.nullNotPermitted(category, "category"); + Font result = (Font) this.tickLabelFontMap.get(category); + // if there is no specific font, use the general one... + if (result == null) { + result = getTickLabelFont(); + } + return result; + } + + /** + * Sets the font for the tick label for the specified category and sends + * an {@link AxisChangeEvent} to all registered listeners. + * + * @param category the category (null not permitted). + * @param font the font (null permitted). + * + * @see #getTickLabelFont(Comparable) + */ + public void setTickLabelFont(Comparable category, Font font) { + ParamChecks.nullNotPermitted(category, "category"); + if (font == null) { + this.tickLabelFontMap.remove(category); + } + else { + this.tickLabelFontMap.put(category, font); + } + fireChangeEvent(); + } + + /** + * Returns the paint for the tick label for the given category. + * + * @param category the category (null not permitted). + * + * @return The paint (never null). + * + * @see #setTickLabelPaint(Paint) + */ + public Paint getTickLabelPaint(Comparable category) { + ParamChecks.nullNotPermitted(category, "category"); + Paint result = (Paint) this.tickLabelPaintMap.get(category); + // if there is no specific paint, use the general one... + if (result == null) { + result = getTickLabelPaint(); + } + return result; + } + + /** + * Sets the paint for the tick label for the specified category and sends + * an {@link AxisChangeEvent} to all registered listeners. + * + * @param category the category (null not permitted). + * @param paint the paint (null permitted). + * + * @see #getTickLabelPaint(Comparable) + */ + public void setTickLabelPaint(Comparable category, Paint paint) { + ParamChecks.nullNotPermitted(category, "category"); + if (paint == null) { + this.tickLabelPaintMap.remove(category); + } + else { + this.tickLabelPaintMap.put(category, paint); + } + fireChangeEvent(); + } + + /** + * Adds a tooltip to the specified category and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param category the category (null not permitted). + * @param tooltip the tooltip text (null permitted). + * + * @see #removeCategoryLabelToolTip(Comparable) + */ + public void addCategoryLabelToolTip(Comparable category, String tooltip) { + ParamChecks.nullNotPermitted(category, "category"); + this.categoryLabelToolTips.put(category, tooltip); + fireChangeEvent(); + } + + /** + * Returns the tool tip text for the label belonging to the specified + * category. + * + * @param category the category (null not permitted). + * + * @return The tool tip text (possibly null). + * + * @see #addCategoryLabelToolTip(Comparable, String) + * @see #removeCategoryLabelToolTip(Comparable) + */ + public String getCategoryLabelToolTip(Comparable category) { + ParamChecks.nullNotPermitted(category, "category"); + return (String) this.categoryLabelToolTips.get(category); + } + + /** + * Removes the tooltip for the specified category and, if there was a value + * associated with that category, sends an {@link AxisChangeEvent} to all + * registered listeners. + * + * @param category the category (null not permitted). + * + * @see #addCategoryLabelToolTip(Comparable, String) + * @see #clearCategoryLabelToolTips() + */ + public void removeCategoryLabelToolTip(Comparable category) { + ParamChecks.nullNotPermitted(category, "category"); + if (this.categoryLabelToolTips.remove(category) != null) { + fireChangeEvent(); + } + } + + /** + * Clears the category label tooltips and sends an {@link AxisChangeEvent} + * to all registered listeners. + * + * @see #addCategoryLabelToolTip(Comparable, String) + * @see #removeCategoryLabelToolTip(Comparable) + */ + public void clearCategoryLabelToolTips() { + this.categoryLabelToolTips.clear(); + fireChangeEvent(); + } + + /** + * Adds a URL (to be used in image maps) to the specified category and + * sends an {@link AxisChangeEvent} to all registered listeners. + * + * @param category the category (null not permitted). + * @param url the URL text (null permitted). + * + * @see #removeCategoryLabelURL(Comparable) + * + * @since 1.0.16 + */ + public void addCategoryLabelURL(Comparable category, String url) { + ParamChecks.nullNotPermitted(category, "category"); + this.categoryLabelURLs.put(category, url); + fireChangeEvent(); + } + + /** + * Returns the URL for the label belonging to the specified category. + * + * @param category the category (null not permitted). + * + * @return The URL text (possibly null). + * + * @see #addCategoryLabelURL(Comparable, String) + * @see #removeCategoryLabelURL(Comparable) + * + * @since 1.0.16 + */ + public String getCategoryLabelURL(Comparable category) { + ParamChecks.nullNotPermitted(category, "category"); + return (String) this.categoryLabelURLs.get(category); + } + + /** + * Removes the URL for the specified category and, if there was a URL + * associated with that category, sends an {@link AxisChangeEvent} to all + * registered listeners. + * + * @param category the category (null not permitted). + * + * @see #addCategoryLabelURL(Comparable, String) + * @see #clearCategoryLabelURLs() + * + * @since 1.0.16 + */ + public void removeCategoryLabelURL(Comparable category) { + ParamChecks.nullNotPermitted(category, "category"); + if (this.categoryLabelURLs.remove(category) != null) { + fireChangeEvent(); + } + } + + /** + * Clears the category label URLs and sends an {@link AxisChangeEvent} + * to all registered listeners. + * + * @see #addCategoryLabelURL(Comparable, String) + * @see #removeCategoryLabelURL(Comparable) + * + * @since 1.0.16 + */ + public void clearCategoryLabelURLs() { + this.categoryLabelURLs.clear(); + fireChangeEvent(); + } + + /** + * 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; + if (anchor == CategoryAnchor.START) { + result = getCategoryStart(category, categoryCount, area, edge); + } + else if (anchor == CategoryAnchor.MIDDLE) { + result = getCategoryMiddle(category, categoryCount, area, edge); + } + else if (anchor == CategoryAnchor.END) { + result = getCategoryEnd(category, categoryCount, area, edge); + } + return result; + + } + + /** + * Returns the starting coordinate for the specified category. + * + * @param category the category. + * @param categoryCount the number of categories. + * @param area the data area. + * @param edge the axis location. + * + * @return The coordinate. + * + * @see #getCategoryMiddle(int, int, Rectangle2D, RectangleEdge) + * @see #getCategoryEnd(int, int, Rectangle2D, RectangleEdge) + */ + public double getCategoryStart(int category, int categoryCount, + Rectangle2D area, RectangleEdge edge) { + + double result = 0.0; + if ((edge == RectangleEdge.TOP) || (edge == RectangleEdge.BOTTOM)) { + result = area.getX() + area.getWidth() * getLowerMargin(); + } + else if ((edge == RectangleEdge.LEFT) + || (edge == RectangleEdge.RIGHT)) { + result = area.getMinY() + area.getHeight() * getLowerMargin(); + } + + double categorySize = calculateCategorySize(categoryCount, area, edge); + double categoryGapWidth = calculateCategoryGapSize(categoryCount, area, + edge); + + result = result + category * (categorySize + categoryGapWidth); + return result; + } + + /** + * Returns the middle coordinate for the specified category. + * + * @param category the category. + * @param categoryCount the number of categories. + * @param area the data area. + * @param edge the axis location. + * + * @return The coordinate. + * + * @see #getCategoryStart(int, int, Rectangle2D, RectangleEdge) + * @see #getCategoryEnd(int, int, Rectangle2D, RectangleEdge) + */ + public double getCategoryMiddle(int category, int categoryCount, + Rectangle2D area, RectangleEdge edge) { + + if (category < 0 || category >= categoryCount) { + throw new IllegalArgumentException("Invalid category index: " + + category); + } + return getCategoryStart(category, categoryCount, area, edge) + + calculateCategorySize(categoryCount, area, edge) / 2; + + } + + /** + * Returns the end coordinate for the specified category. + * + * @param category the category. + * @param categoryCount the number of categories. + * @param area the data area. + * @param edge the axis location. + * + * @return The coordinate. + * + * @see #getCategoryStart(int, int, Rectangle2D, RectangleEdge) + * @see #getCategoryMiddle(int, int, Rectangle2D, RectangleEdge) + */ + public double getCategoryEnd(int category, int categoryCount, + Rectangle2D area, RectangleEdge edge) { + return getCategoryStart(category, categoryCount, area, edge) + + calculateCategorySize(categoryCount, area, edge); + } + + /** + * A convenience method that returns the axis coordinate for the centre of + * a category. + * + * @param category the category key (null not permitted). + * @param categories the categories (null not permitted). + * @param area the data area (null not permitted). + * @param edge the edge along which the axis lies (null not + * permitted). + * + * @return The centre coordinate. + * + * @since 1.0.11 + * + * @see #getCategorySeriesMiddle(Comparable, Comparable, CategoryDataset, + * double, Rectangle2D, RectangleEdge) + */ + public double getCategoryMiddle(Comparable category, + List categories, Rectangle2D area, RectangleEdge edge) { + ParamChecks.nullNotPermitted(categories, "categories"); + int categoryIndex = categories.indexOf(category); + int categoryCount = categories.size(); + return getCategoryMiddle(categoryIndex, categoryCount, area, edge); + } + + /** + * Returns the middle coordinate (in Java2D space) for a series within a + * category. + * + * @param category the category (null not permitted). + * @param seriesKey the series key (null not permitted). + * @param dataset the dataset (null not permitted). + * @param itemMargin the item margin (0.0 <= itemMargin < 1.0); + * @param area the area (null not permitted). + * @param edge the edge (null not permitted). + * + * @return The coordinate in Java2D space. + * + * @since 1.0.7 + */ + public double getCategorySeriesMiddle(Comparable category, + Comparable seriesKey, CategoryDataset dataset, double itemMargin, + Rectangle2D area, RectangleEdge edge) { + + int categoryIndex = dataset.getColumnIndex(category); + int categoryCount = dataset.getColumnCount(); + int seriesIndex = dataset.getRowIndex(seriesKey); + int seriesCount = dataset.getRowCount(); + double start = getCategoryStart(categoryIndex, categoryCount, area, + edge); + double end = getCategoryEnd(categoryIndex, categoryCount, area, edge); + double width = end - start; + if (seriesCount == 1) { + return start + width / 2.0; + } + else { + double gap = (width * itemMargin) / (seriesCount - 1); + double ww = (width * (1 - itemMargin)) / seriesCount; + return start + (seriesIndex * (ww + gap)) + ww / 2.0; + } + } + + /** + * Returns the middle coordinate (in Java2D space) for a series within a + * category. + * + * @param categoryIndex the category index. + * @param categoryCount the category count. + * @param seriesIndex the series index. + * @param seriesCount the series count. + * @param itemMargin the item margin (0.0 <= itemMargin < 1.0); + * @param area the area (null not permitted). + * @param edge the edge (null not permitted). + * + * @return The coordinate in Java2D space. + * + * @since 1.0.13 + */ + public double getCategorySeriesMiddle(int categoryIndex, int categoryCount, + int seriesIndex, int seriesCount, double itemMargin, + Rectangle2D area, RectangleEdge edge) { + + double start = getCategoryStart(categoryIndex, categoryCount, area, + edge); + double end = getCategoryEnd(categoryIndex, categoryCount, area, edge); + double width = end - start; + if (seriesCount == 1) { + return start + width / 2.0; + } + else { + double gap = (width * itemMargin) / (seriesCount - 1); + double ww = (width * (1 - itemMargin)) / seriesCount; + return start + (seriesIndex * (ww + gap)) + ww / 2.0; + } + } + + /** + * Calculates the size (width or height, depending on the location of the + * axis) of a category. + * + * @param categoryCount the number of categories. + * @param area the area within which the categories will be drawn. + * @param edge the axis location. + * + * @return The category size. + */ + protected double calculateCategorySize(int categoryCount, Rectangle2D area, + RectangleEdge edge) { + double result; + double available = 0.0; + + if ((edge == RectangleEdge.TOP) || (edge == RectangleEdge.BOTTOM)) { + available = area.getWidth(); + } + else if ((edge == RectangleEdge.LEFT) + || (edge == RectangleEdge.RIGHT)) { + available = area.getHeight(); + } + if (categoryCount > 1) { + result = available * (1 - getLowerMargin() - getUpperMargin() + - getCategoryMargin()); + result = result / categoryCount; + } + else { + result = available * (1 - getLowerMargin() - getUpperMargin()); + } + return result; + } + + /** + * Calculates the size (width or height, depending on the location of the + * axis) of a category gap. + * + * @param categoryCount the number of categories. + * @param area the area within which the categories will be drawn. + * @param edge the axis location. + * + * @return The category gap width. + */ + protected double calculateCategoryGapSize(int categoryCount, + Rectangle2D area, RectangleEdge edge) { + + double result = 0.0; + double available = 0.0; + + if ((edge == RectangleEdge.TOP) || (edge == RectangleEdge.BOTTOM)) { + available = area.getWidth(); + } + else if ((edge == RectangleEdge.LEFT) + || (edge == RectangleEdge.RIGHT)) { + available = area.getHeight(); + } + + if (categoryCount > 1) { + result = available * getCategoryMargin() / (categoryCount - 1); + } + return result; + } + + /** + * Estimates the space required for the axis, given a specific drawing area. + * + * @param g2 the graphics device (used to obtain font information). + * @param plot the plot that the axis belongs to. + * @param plotArea the area within which the axis should be drawn. + * @param edge the axis location (top or bottom). + * @param space the space already reserved. + * + * @return The space required to draw the axis. + */ + @Override + public AxisSpace reserveSpace(Graphics2D g2, Plot plot, + Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) { + + // create a new space object if one wasn't supplied... + if (space == null) { + space = new AxisSpace(); + } + + // if the axis is not visible, no additional space is required... + if (!isVisible()) { + return space; + } + + // calculate the max size of the tick labels (if visible)... + double tickLabelHeight = 0.0; + double tickLabelWidth = 0.0; + if (isTickLabelsVisible()) { + g2.setFont(getTickLabelFont()); + AxisState state = new AxisState(); + // we call refresh ticks just to get the maximum width or height + refreshTicks(g2, state, plotArea, edge); + if (edge == RectangleEdge.TOP) { + tickLabelHeight = state.getMax(); + } + else if (edge == RectangleEdge.BOTTOM) { + tickLabelHeight = state.getMax(); + } + else if (edge == RectangleEdge.LEFT) { + tickLabelWidth = state.getMax(); + } + else if (edge == RectangleEdge.RIGHT) { + tickLabelWidth = state.getMax(); + } + } + + // get the axis label size and update the space object... + Rectangle2D labelEnclosure = getLabelEnclosure(g2, edge); + double labelHeight, labelWidth; + if (RectangleEdge.isTopOrBottom(edge)) { + labelHeight = labelEnclosure.getHeight(); + space.add(labelHeight + tickLabelHeight + + this.categoryLabelPositionOffset, edge); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + labelWidth = labelEnclosure.getWidth(); + space.add(labelWidth + tickLabelWidth + + this.categoryLabelPositionOffset, edge); + } + return space; + } + + /** + * Configures the axis against the current plot. + */ + @Override + public void configure() { + // nothing required + } + + /** + * Draws the axis on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device (null not permitted). + * @param cursor the cursor location. + * @param plotArea the area within which the axis should be drawn + * (null not permitted). + * @param dataArea the area within which the plot is being drawn + * (null not permitted). + * @param edge the location of the axis (null not permitted). + * @param plotState collects information about the plot + * (null permitted). + * + * @return The axis state (never null). + */ + @Override + 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); + } + + if (isAxisLineVisible()) { + drawAxisLine(g2, cursor, dataArea, edge); + } + AxisState state = new AxisState(cursor); + if (isTickMarksVisible()) { + drawTickMarks(g2, cursor, dataArea, edge, state); + } + + createAndAddEntity(cursor, state, dataArea, edge, plotState); + + // draw the category labels and axis label + state = drawCategoryLabels(g2, plotArea, dataArea, edge, state, + plotState); + if (getAttributedLabel() != null) { + state = drawAttributedLabel(getAttributedLabel(), g2, plotArea, + dataArea, edge, state); + + } else { + state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); + } + return state; + + } + + /** + * Draws the category labels and returns the updated axis state. + * + * @param g2 the graphics device (null not permitted). + * @param plotArea the plot area (null not permitted). + * @param dataArea the area inside the axes (null not + * permitted). + * @param edge the axis location (null not permitted). + * @param state the axis state (null not permitted). + * @param plotState collects information about the plot (null + * permitted). + * + * @return The updated axis state (never null). + */ + protected AxisState drawCategoryLabels(Graphics2D g2, Rectangle2D plotArea, + Rectangle2D dataArea, RectangleEdge edge, AxisState state, + PlotRenderingInfo plotState) { + + ParamChecks.nullNotPermitted(state, "state"); + if (!isTickLabelsVisible()) { + return state; + } + + List ticks = refreshTicks(g2, state, plotArea, edge); + state.setTicks(ticks); + int categoryIndex = 0; + Iterator iterator = ticks.iterator(); + while (iterator.hasNext()) { + CategoryTick tick = (CategoryTick) iterator.next(); + g2.setFont(getTickLabelFont(tick.getCategory())); + g2.setPaint(getTickLabelPaint(tick.getCategory())); + + CategoryLabelPosition position + = this.categoryLabelPositions.getLabelPosition(edge); + double x0 = 0.0; + double x1 = 0.0; + double y0 = 0.0; + double y1 = 0.0; + if (edge == RectangleEdge.TOP) { + x0 = getCategoryStart(categoryIndex, ticks.size(), dataArea, + edge); + x1 = getCategoryEnd(categoryIndex, ticks.size(), dataArea, + edge); + y1 = state.getCursor() - this.categoryLabelPositionOffset; + y0 = y1 - state.getMax(); + } + else if (edge == RectangleEdge.BOTTOM) { + x0 = getCategoryStart(categoryIndex, ticks.size(), dataArea, + edge); + x1 = getCategoryEnd(categoryIndex, ticks.size(), dataArea, + edge); + y0 = state.getCursor() + this.categoryLabelPositionOffset; + y1 = y0 + state.getMax(); + } + else if (edge == RectangleEdge.LEFT) { + y0 = getCategoryStart(categoryIndex, ticks.size(), dataArea, + edge); + y1 = getCategoryEnd(categoryIndex, ticks.size(), dataArea, + edge); + x1 = state.getCursor() - this.categoryLabelPositionOffset; + x0 = x1 - state.getMax(); + } + else if (edge == RectangleEdge.RIGHT) { + y0 = getCategoryStart(categoryIndex, ticks.size(), dataArea, + edge); + y1 = getCategoryEnd(categoryIndex, ticks.size(), dataArea, + edge); + x0 = state.getCursor() + this.categoryLabelPositionOffset; + x1 = x0 - state.getMax(); + } + Rectangle2D area = new Rectangle2D.Double(x0, y0, (x1 - x0), + (y1 - y0)); + Point2D anchorPoint = RectangleAnchor.coordinates(area, + position.getCategoryAnchor()); + TextBlock block = tick.getLabel(); + block.draw(g2, (float) anchorPoint.getX(), + (float) anchorPoint.getY(), position.getLabelAnchor(), + (float) anchorPoint.getX(), (float) anchorPoint.getY(), + position.getAngle()); + Shape bounds = block.calculateBounds(g2, + (float) anchorPoint.getX(), (float) anchorPoint.getY(), + position.getLabelAnchor(), (float) anchorPoint.getX(), + (float) anchorPoint.getY(), position.getAngle()); + if (plotState != null && plotState.getOwner() != null) { + EntityCollection entities = plotState.getOwner() + .getEntityCollection(); + if (entities != null) { + String tooltip = getCategoryLabelToolTip( + tick.getCategory()); + String url = getCategoryLabelURL(tick.getCategory()); + entities.add(new CategoryLabelEntity(tick.getCategory(), + bounds, tooltip, url)); + } + } + categoryIndex++; + } + + if (edge.equals(RectangleEdge.TOP)) { + double h = state.getMax() + this.categoryLabelPositionOffset; + state.cursorUp(h); + } + else if (edge.equals(RectangleEdge.BOTTOM)) { + double h = state.getMax() + this.categoryLabelPositionOffset; + state.cursorDown(h); + } + else if (edge == RectangleEdge.LEFT) { + double w = state.getMax() + this.categoryLabelPositionOffset; + state.cursorLeft(w); + } + else if (edge == RectangleEdge.RIGHT) { + double w = state.getMax() + this.categoryLabelPositionOffset; + state.cursorRight(w); + } + return state; + } + + /** + * Creates a temporary list of ticks that can be used when drawing the axis. + * + * @param g2 the graphics device (used to get font measurements). + * @param state the axis state. + * @param dataArea the area inside the axes. + * @param edge the location of the axis. + * + * @return A list of ticks. + */ + @Override + public List refreshTicks(Graphics2D g2, AxisState state, + Rectangle2D dataArea, RectangleEdge edge) { + + List ticks = new java.util.ArrayList(); + + // sanity check for data area... + if (dataArea.getHeight() <= 0.0 || dataArea.getWidth() < 0.0) { + return ticks; + } + + CategoryPlot plot = (CategoryPlot) getPlot(); + List categories = plot.getCategoriesForAxis(this); + double max = 0.0; + + if (categories != null) { + CategoryLabelPosition position + = this.categoryLabelPositions.getLabelPosition(edge); + float r = this.maximumCategoryLabelWidthRatio; + if (r <= 0.0) { + r = position.getWidthRatio(); + } + + float l; + if (position.getWidthType() == CategoryLabelWidthType.CATEGORY) { + l = (float) calculateCategorySize(categories.size(), dataArea, + edge); + } + else { + if (RectangleEdge.isLeftOrRight(edge)) { + l = (float) dataArea.getWidth(); + } + else { + l = (float) dataArea.getHeight(); + } + } + int categoryIndex = 0; + Iterator iterator = categories.iterator(); + while (iterator.hasNext()) { + Comparable category = (Comparable) iterator.next(); + g2.setFont(getTickLabelFont(category)); + TextBlock label = createLabel(category, l * r, edge, g2); + if (edge == RectangleEdge.TOP || edge == RectangleEdge.BOTTOM) { + max = Math.max(max, calculateTextBlockHeight(label, + position, g2)); + } + else if (edge == RectangleEdge.LEFT + || edge == RectangleEdge.RIGHT) { + max = Math.max(max, calculateTextBlockWidth(label, + position, g2)); + } + Tick tick = new CategoryTick(category, label, + position.getLabelAnchor(), + position.getRotationAnchor(), position.getAngle()); + ticks.add(tick); + categoryIndex = categoryIndex + 1; + } + } + state.setMax(max); + return ticks; + + } + + /** + * Draws the tick marks. + * + * @param g2 the graphics target. + * @param cursor the cursor position (an offset when drawing multiple axes) + * @param dataArea the area for plotting the data. + * @param edge the location of the axis. + * @param state the axis state. + * + * @since 1.0.13 + */ + public void drawTickMarks(Graphics2D g2, double cursor, + Rectangle2D dataArea, RectangleEdge edge, AxisState state) { + + Plot p = getPlot(); + if (p == null) { + return; + } + CategoryPlot plot = (CategoryPlot) p; + double il = getTickMarkInsideLength(); + double ol = getTickMarkOutsideLength(); + Line2D line = new Line2D.Double(); + List categories = plot.getCategoriesForAxis(this); + g2.setPaint(getTickMarkPaint()); + g2.setStroke(getTickMarkStroke()); + if (edge.equals(RectangleEdge.TOP)) { + Iterator iterator = categories.iterator(); + while (iterator.hasNext()) { + Comparable key = (Comparable) iterator.next(); + double x = getCategoryMiddle(key, categories, dataArea, edge); + line.setLine(x, cursor, x, cursor + il); + g2.draw(line); + line.setLine(x, cursor, x, cursor - ol); + g2.draw(line); + } + state.cursorUp(ol); + } + else if (edge.equals(RectangleEdge.BOTTOM)) { + Iterator iterator = categories.iterator(); + while (iterator.hasNext()) { + Comparable key = (Comparable) iterator.next(); + double x = getCategoryMiddle(key, categories, dataArea, edge); + line.setLine(x, cursor, x, cursor - il); + g2.draw(line); + line.setLine(x, cursor, x, cursor + ol); + g2.draw(line); + } + state.cursorDown(ol); + } + else if (edge.equals(RectangleEdge.LEFT)) { + Iterator iterator = categories.iterator(); + while (iterator.hasNext()) { + Comparable key = (Comparable) iterator.next(); + double y = getCategoryMiddle(key, categories, dataArea, edge); + line.setLine(cursor, y, cursor + il, y); + g2.draw(line); + line.setLine(cursor, y, cursor - ol, y); + g2.draw(line); + } + state.cursorLeft(ol); + } + else if (edge.equals(RectangleEdge.RIGHT)) { + Iterator iterator = categories.iterator(); + while (iterator.hasNext()) { + Comparable key = (Comparable) iterator.next(); + double y = getCategoryMiddle(key, categories, dataArea, edge); + line.setLine(cursor, y, cursor - il, y); + g2.draw(line); + line.setLine(cursor, y, cursor + ol, y); + g2.draw(line); + } + state.cursorRight(ol); + } + } + + /** + * Creates a label. + * + * @param category the category. + * @param width the available width. + * @param edge the edge on which the axis appears. + * @param g2 the graphics device. + * + * @return A label. + */ + protected TextBlock createLabel(Comparable category, float width, + RectangleEdge edge, Graphics2D g2) { + TextBlock label = TextUtilities.createTextBlock(category.toString(), + getTickLabelFont(category), getTickLabelPaint(category), width, + this.maximumCategoryLabelLines, new G2TextMeasurer(g2)); + return label; + } + + /** + * A utility method for determining the width of a text block. + * + * @param block the text block. + * @param position the position. + * @param g2 the graphics device. + * + * @return The width. + */ + protected double calculateTextBlockWidth(TextBlock block, + CategoryLabelPosition position, Graphics2D g2) { + RectangleInsets insets = getTickLabelInsets(); + Size2D size = block.calculateDimensions(g2); + Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(), + size.getHeight()); + Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(), + 0.0f, 0.0f); + double w = rotatedBox.getBounds2D().getWidth() + insets.getLeft() + + insets.getRight(); + return w; + } + + /** + * A utility method for determining the height of a text block. + * + * @param block the text block. + * @param position the label position. + * @param g2 the graphics device. + * + * @return The height. + */ + protected double calculateTextBlockHeight(TextBlock block, + CategoryLabelPosition position, Graphics2D g2) { + RectangleInsets insets = getTickLabelInsets(); + Size2D size = block.calculateDimensions(g2); + Rectangle2D box = new Rectangle2D.Double(0.0, 0.0, size.getWidth(), + size.getHeight()); + Shape rotatedBox = ShapeUtilities.rotateShape(box, position.getAngle(), + 0.0f, 0.0f); + double h = rotatedBox.getBounds2D().getHeight() + + insets.getTop() + insets.getBottom(); + return h; + } + + /** + * Creates a clone of the axis. + * + * @return A clone. + * + * @throws CloneNotSupportedException if some component of the axis does + * not support cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + CategoryAxis clone = (CategoryAxis) super.clone(); + clone.tickLabelFontMap = new HashMap(this.tickLabelFontMap); + clone.tickLabelPaintMap = new HashMap(this.tickLabelPaintMap); + clone.categoryLabelToolTips = new HashMap(this.categoryLabelToolTips); + clone.categoryLabelURLs = new HashMap(this.categoryLabelToolTips); + return clone; + } + + /** + * Tests this axis for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CategoryAxis)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + CategoryAxis that = (CategoryAxis) obj; + if (that.lowerMargin != this.lowerMargin) { + return false; + } + if (that.upperMargin != this.upperMargin) { + return false; + } + if (that.categoryMargin != this.categoryMargin) { + return false; + } + if (that.maximumCategoryLabelWidthRatio + != this.maximumCategoryLabelWidthRatio) { + return false; + } + if (that.categoryLabelPositionOffset + != this.categoryLabelPositionOffset) { + return false; + } + if (!ObjectUtilities.equal(that.categoryLabelPositions, + this.categoryLabelPositions)) { + return false; + } + if (!ObjectUtilities.equal(that.categoryLabelToolTips, + this.categoryLabelToolTips)) { + return false; + } + if (!ObjectUtilities.equal(this.categoryLabelURLs, + that.categoryLabelURLs)) { + return false; + } + if (!ObjectUtilities.equal(this.tickLabelFontMap, + that.tickLabelFontMap)) { + return false; + } + if (!equalPaintMaps(this.tickLabelPaintMap, that.tickLabelPaintMap)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this object. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return super.hashCode(); + } + + /** + * 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(); + writePaintMap(this.tickLabelPaintMap, 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.tickLabelPaintMap = readPaintMap(stream); + } + + /** + * Reads a Map of (Comparable, Paint) + * elements from a stream. + * + * @param in the input stream. + * + * @return The map. + * + * @throws IOException + * @throws ClassNotFoundException + * + * @see #writePaintMap(Map, ObjectOutputStream) + */ + private Map readPaintMap(ObjectInputStream in) + throws IOException, ClassNotFoundException { + boolean isNull = in.readBoolean(); + if (isNull) { + return null; + } + Map result = new HashMap(); + int count = in.readInt(); + for (int i = 0; i < count; i++) { + Comparable category = (Comparable) in.readObject(); + Paint paint = SerialUtilities.readPaint(in); + result.put(category, paint); + } + return result; + } + + /** + * Writes a map of (Comparable, Paint) + * elements to a stream. + * + * @param map the map (null permitted). + * + * @param out + * @throws IOException + * + * @see #readPaintMap(ObjectInputStream) + */ + private void writePaintMap(Map map, ObjectOutputStream out) + throws IOException { + if (map == null) { + out.writeBoolean(true); + } + else { + out.writeBoolean(false); + Set keys = map.keySet(); + int count = keys.size(); + out.writeInt(count); + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Comparable key = (Comparable) iterator.next(); + out.writeObject(key); + SerialUtilities.writePaint((Paint) map.get(key), out); + } + } + } + + /** + * Tests two maps containing (Comparable, Paint) + * elements for equality. + * + * @param map1 the first map (null not permitted). + * @param map2 the second map (null not permitted). + * + * @return A boolean. + */ + private boolean equalPaintMaps(Map map1, Map map2) { + if (map1.size() != map2.size()) { + return false; + } + Set entries = map1.entrySet(); + Iterator iterator = entries.iterator(); + while (iterator.hasNext()) { + Map.Entry entry = (Map.Entry) iterator.next(); + Paint p1 = (Paint) entry.getValue(); + Paint p2 = (Paint) map2.get(entry.getKey()); + if (!PaintUtilities.equal(p1, p2)) { + return false; + } + } + return true; + } + + /** + * Draws the category labels and returns the updated axis state. + * + * @param g2 the graphics device (null not permitted). + * @param dataArea the area inside the axes (null not + * permitted). + * @param edge the axis location (null not permitted). + * @param state the axis state (null not permitted). + * @param plotState collects information about the plot (null + * permitted). + * + * @return The updated axis state (never null). + * + * @deprecated Use {@link #drawCategoryLabels(Graphics2D, Rectangle2D, + * Rectangle2D, RectangleEdge, AxisState, PlotRenderingInfo)}. + */ + protected AxisState drawCategoryLabels(Graphics2D g2, Rectangle2D dataArea, + RectangleEdge edge, AxisState state, PlotRenderingInfo plotState) { + // this method is deprecated because we really need the plotArea + // when drawing the labels - see bug 1277726 + return drawCategoryLabels(g2, dataArea, dataArea, edge, state, + plotState); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryAxis3D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryAxis3D.java new file mode 100755 index 0000000..bd45f90 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryAxis3D.java @@ -0,0 +1,234 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * CategoryAxis3D.java + * ------------------- + * (C) Copyright 2003-2013, 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); + * 16-Apr-2009 : Draw axis line and tick marks (DG); + * 01-Aug-2013 : Added attributedLabel override to support superscripts, + * subscripts and more (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 (null 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 (null not permitted). + * @param cursor the cursor location. + * @param plotArea the area within which the axis should be drawn + * (null not permitted). + * @param dataArea the area within which the plot is being drawn + * (null not permitted). + * @param edge the location of the axis (null not permitted). + * @param plotState collects information about the plot (null + * permitted). + * + * @return The axis state (never null). + */ + @Override + 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); + } + + if (isAxisLineVisible()) { + drawAxisLine(g2, cursor, adjustedDataArea, edge); + } + // draw the category labels and axis label + AxisState state = new AxisState(cursor); + if (isTickMarksVisible()) { + drawTickMarks(g2, cursor, adjustedDataArea, edge, state); + } + state = drawCategoryLabels(g2, plotArea, adjustedDataArea, edge, + state, plotState); + if (getAttributedLabel() != null) { + state = drawAttributedLabel(getAttributedLabel(), g2, plotArea, + dataArea, edge, state); + + } else { + 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. + */ + @Override + 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. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryLabelPosition.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryLabelPosition.java new file mode 100755 index 0000000..00e4cce --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryLabelPosition.java @@ -0,0 +1,266 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * CategoryLabelPosition.java + * -------------------------- + * (C) Copyright 2003-2013, 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); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +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 (null not + * permitted). + * @param labelAnchor the label anchor (null 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 (null not + * permitted). + * @param labelAnchor the label anchor (null not permitted). + * @param widthType the width type (null 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 (null not + * permitted). + * @param labelAnchor the label anchor (null not permitted). + * @param rotationAnchor the rotation anchor (null not + * permitted). + * @param angle the rotation angle (null not permitted). + * @param widthType the width type (null 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) { + + ParamChecks.nullNotPermitted(categoryAnchor, "categoryAnchor"); + ParamChecks.nullNotPermitted(labelAnchor, "labelAnchor"); + ParamChecks.nullNotPermitted(rotationAnchor, "rotationAnchor"); + ParamChecks.nullNotPermitted(widthType, "widthType"); + + 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 null). + */ + public RectangleAnchor getCategoryAnchor() { + return this.categoryAnchor; + } + + /** + * Returns the text block anchor. + * + * @return The text block anchor (never null). + */ + public TextBlockAnchor getLabelAnchor() { + return this.labelAnchor; + } + + /** + * Returns the rotation anchor point. + * + * @return The rotation anchor point (never null). + */ + 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 null). + */ + 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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. + */ + @Override + 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; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryLabelPositions.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryLabelPositions.java new file mode 100755 index 0000000..a07391d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryLabelPositions.java @@ -0,0 +1,408 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * CategoryLabelPositions.java + * --------------------------- + * (C) Copyright 2004-2013, 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); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +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 + * (null not permitted). + * @param bottom the label position info used when an axis is at the + * bottom (null not permitted). + * @param left the label position info used when an axis is at the left + * (null not permitted). + * @param right the label position info used when an axis is at the right + * (null not permitted). + */ + public CategoryLabelPositions(CategoryLabelPosition top, + CategoryLabelPosition bottom, CategoryLabelPosition left, + CategoryLabelPosition right) { + + ParamChecks.nullNotPermitted(top, "top"); + ParamChecks.nullNotPermitted(bottom, "bottom"); + ParamChecks.nullNotPermitted(left, "left"); + ParamChecks.nullNotPermitted(right, "right"); + + 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 (null not permitted). + * @param top the top position (null not permitted). + * + * @return A new instance (never null). + */ + public static CategoryLabelPositions replaceTopPosition( + CategoryLabelPositions base, CategoryLabelPosition top) { + + ParamChecks.nullNotPermitted(base, "base"); + ParamChecks.nullNotPermitted(top, "top"); + + 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 (null not permitted). + * @param bottom the bottom position (null not permitted). + * + * @return A new instance (never null). + */ + public static CategoryLabelPositions replaceBottomPosition( + CategoryLabelPositions base, CategoryLabelPosition bottom) { + + ParamChecks.nullNotPermitted(base, "base"); + ParamChecks.nullNotPermitted(bottom, "bottom"); + + 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 (null not permitted). + * @param left the left position (null not permitted). + * + * @return A new instance (never null). + */ + public static CategoryLabelPositions replaceLeftPosition( + CategoryLabelPositions base, CategoryLabelPosition left) { + + ParamChecks.nullNotPermitted(base, "base"); + ParamChecks.nullNotPermitted(left, "left"); + + 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 (null not permitted). + * @param right the right position (null not permitted). + * + * @return A new instance (never null). + */ + public static CategoryLabelPositions replaceRightPosition( + CategoryLabelPositions base, CategoryLabelPosition right) { + + ParamChecks.nullNotPermitted(base, "base"); + ParamChecks.nullNotPermitted(right, "right"); + return new CategoryLabelPositions( + base.getLabelPosition(RectangleEdge.TOP), + base.getLabelPosition(RectangleEdge.BOTTOM), + base.getLabelPosition(RectangleEdge.LEFT), + right); + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + 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. + */ + @Override + 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; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryLabelWidthType.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryLabelWidthType.java new file mode 100755 index 0000000..3f0a491 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryLabelWidthType.java @@ -0,0 +1,127 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * CategoryLabelWidthType.java + * --------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 24-Mar-2004 : Version 1 (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.ObjectStreamException; +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +/** + * 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 (null not permitted). + */ + private CategoryLabelWidthType(String name) { + ParamChecks.nullNotPermitted(name, "name"); + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string (never null). + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + 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; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryTick.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryTick.java new file mode 100755 index 0000000..8ce13e5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CategoryTick.java @@ -0,0 +1,153 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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. + */ + @Override + 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; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ColorBar.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ColorBar.java new file mode 100755 index 0000000..a272521 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ColorBar.java @@ -0,0 +1,471 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * 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; + 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; + assert colorBarArea != null; // suppresses compiler warnings + 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); + } + assert state != null; // suppresses compiler warning + 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; + 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. + */ + @Override + 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. + */ + @Override + 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. + */ + @Override + public int hashCode() { + return this.axis.hashCode(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CompassFormat.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CompassFormat.java new file mode 100755 index 0000000..f27b1a0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CompassFormat.java @@ -0,0 +1,139 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * 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. + */ + @Override + 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. + */ + @Override + public StringBuffer format(long number, StringBuffer toAppendTo, + FieldPosition pos) { + return toAppendTo.append(getDirectionCode(number)); + } + + /** + * This method returns null for all inputs. This class cannot + * be used for parsing. + * + * @param source the source string. + * @param parsePosition the parse position. + * + * @return null. + */ + @Override + public Number parse(String source, ParsePosition parsePosition) { + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CyclicNumberAxis.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CyclicNumberAxis.java new file mode 100755 index 0000000..d880613 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/CyclicNumberAxis.java @@ -0,0 +1,1189 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * CyclicNumberAxis.java + * --------------------- + * (C) Copyright 2003-2013, by Nicolas Brodu and Contributors. + * + * Original Author: Nicolas Brodu; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 19-Nov-2003 : Initial import to JFreeChart from the JSynoptic project (NB); + * 16-Mar-2004 : Added plotState to draw() method (DG); + * 07-Apr-2004 : Modifed text bounds calculation (DG); + * 21-Apr-2005 : Replaced Insets with RectangleInsets, removed redundant + * argument in selectAutoTickUnit() (DG); + * 22-Apr-2005 : Renamed refreshHorizontalTicks() --> refreshTicksHorizontal + * (for consistency with other classes) and removed unused + * parameters (DG); + * 08-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.axis; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +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.text.NumberFormat; +import java.util.List; + +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.TextAnchor; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; + +/** +This class extends NumberAxis and handles cycling. + +Traditional representation of data in the range x0..x1 +

+|-------------------------|
+x0                       x1
+
+ +Here, the range bounds are at the axis extremities. +With cyclic axis, however, the time is split in +"cycles", or "time frames", or the same duration : the period. + +A cycle axis cannot by definition handle a larger interval +than the period :
x1 - x0 >= period
. Thus, at most a full +period can be represented with such an axis. + +The cycle bound is the number between x0 and x1 which marks +the beginning of new time frame: +
+|---------------------|----------------------------|
+x0                   cb                           x1
+<---previous cycle---><-------current cycle-------->
+
+ +It is actually a multiple of the period, plus optionally +a start offset:
cb = n * period + offset
+ +Thus, by definition, two consecutive cycle bounds +period apart, which is precisely why it is called a +period. + +The visual representation of a cyclic axis is like that: +
+|----------------------------|---------------------|
+cb                         x1|x0                  cb
+<-------current cycle--------><---previous cycle--->
+
+ +The cycle bound is at the axis ends, then current +cycle is shown, then the last cycle. When using +dynamic data, the visual effect is the current cycle +erases the last cycle as x grows. Then, the next cycle +bound is reached, and the process starts over, erasing +the previous cycle. + +A Cyclic item renderer is provided to do exactly this. + + */ +public class CyclicNumberAxis extends NumberAxis { + + /** For serialization. */ + static final long serialVersionUID = -7514160997164582554L; + + /** The default axis line stroke. */ + public static Stroke DEFAULT_ADVANCE_LINE_STROKE = new BasicStroke(1.0f); + + /** The default axis line paint. */ + public static final Paint DEFAULT_ADVANCE_LINE_PAINT = Color.gray; + + /** The offset. */ + protected double offset; + + /** The period.*/ + protected double period; + + /** ??. */ + protected boolean boundMappedToLastCycle; + + /** A flag that controls whether or not the advance line is visible. */ + protected boolean advanceLineVisible; + + /** The advance line stroke. */ + protected transient Stroke advanceLineStroke = DEFAULT_ADVANCE_LINE_STROKE; + + /** The advance line paint. */ + protected transient Paint advanceLinePaint; + + private transient boolean internalMarkerWhenTicksOverlap; + private transient Tick internalMarkerCycleBoundTick; + + /** + * Creates a CycleNumberAxis with the given period. + * + * @param period the period. + */ + public CyclicNumberAxis(double period) { + this(period, 0.0); + } + + /** + * Creates a CycleNumberAxis with the given period and offset. + * + * @param period the period. + * @param offset the offset. + */ + public CyclicNumberAxis(double period, double offset) { + this(period, offset, null); + } + + /** + * Creates a named CycleNumberAxis with the given period. + * + * @param period the period. + * @param label the label. + */ + public CyclicNumberAxis(double period, String label) { + this(0, period, label); + } + + /** + * Creates a named CycleNumberAxis with the given period and offset. + * + * @param period the period. + * @param offset the offset. + * @param label the label. + */ + public CyclicNumberAxis(double period, double offset, String label) { + super(label); + this.period = period; + this.offset = offset; + setFixedAutoRange(period); + this.advanceLineVisible = true; + this.advanceLinePaint = DEFAULT_ADVANCE_LINE_PAINT; + } + + /** + * The advance line is the line drawn at the limit of the current cycle, + * when erasing the previous cycle. + * + * @return A boolean. + */ + public boolean isAdvanceLineVisible() { + return this.advanceLineVisible; + } + + /** + * The advance line is the line drawn at the limit of the current cycle, + * when erasing the previous cycle. + * + * @param visible the flag. + */ + public void setAdvanceLineVisible(boolean visible) { + this.advanceLineVisible = visible; + } + + /** + * The advance line is the line drawn at the limit of the current cycle, + * when erasing the previous cycle. + * + * @return The paint (never null). + */ + public Paint getAdvanceLinePaint() { + return this.advanceLinePaint; + } + + /** + * The advance line is the line drawn at the limit of the current cycle, + * when erasing the previous cycle. + * + * @param paint the paint (null not permitted). + */ + public void setAdvanceLinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.advanceLinePaint = paint; + } + + /** + * The advance line is the line drawn at the limit of the current cycle, + * when erasing the previous cycle. + * + * @return The stroke (never null). + */ + public Stroke getAdvanceLineStroke() { + return this.advanceLineStroke; + } + /** + * The advance line is the line drawn at the limit of the current cycle, + * when erasing the previous cycle. + * + * @param stroke the stroke (null not permitted). + */ + public void setAdvanceLineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.advanceLineStroke = stroke; + } + + /** + * The cycle bound can be associated either with the current or with the + * last cycle. It's up to the user's choice to decide which, as this is + * just a convention. By default, the cycle bound is mapped to the current + * cycle. + *
+ * Note that this has no effect on visual appearance, as the cycle bound is + * mapped successively for both axis ends. Use this function for correct + * results in translateValueToJava2D. + * + * @return true if the cycle bound is mapped to the last + * cycle, false if it is bound to the current cycle + * (default) + */ + public boolean isBoundMappedToLastCycle() { + return this.boundMappedToLastCycle; + } + + /** + * The cycle bound can be associated either with the current or with the + * last cycle. It's up to the user's choice to decide which, as this is + * just a convention. By default, the cycle bound is mapped to the current + * cycle. + *
+ * Note that this has no effect on visual appearance, as the cycle bound is + * mapped successively for both axis ends. Use this function for correct + * results in valueToJava2D. + * + * @param boundMappedToLastCycle Set it to true to map the cycle bound to + * the last cycle. + */ + public void setBoundMappedToLastCycle(boolean boundMappedToLastCycle) { + this.boundMappedToLastCycle = boundMappedToLastCycle; + } + + /** + * Selects a tick unit when the axis is displayed horizontally. + * + * @param g2 the graphics device. + * @param drawArea the drawing area. + * @param dataArea the data area. + * @param edge the side of the rectangle on which the axis is displayed. + */ + protected void selectHorizontalAutoTickUnit(Graphics2D g2, + Rectangle2D drawArea, Rectangle2D dataArea, RectangleEdge edge) { + + double tickLabelWidth + = estimateMaximumTickLabelWidth(g2, getTickUnit()); + + // Compute number of labels + double n = getRange().getLength() + * tickLabelWidth / dataArea.getWidth(); + + setTickUnit( + (NumberTickUnit) getStandardTickUnits().getCeilingTickUnit(n), + false, false); + + } + + /** + * Selects a tick unit when the axis is displayed vertically. + * + * @param g2 the graphics device. + * @param drawArea the drawing area. + * @param dataArea the data area. + * @param edge the side of the rectangle on which the axis is displayed. + */ + protected void selectVerticalAutoTickUnit(Graphics2D g2, + Rectangle2D drawArea, Rectangle2D dataArea, RectangleEdge edge) { + + double tickLabelWidth + = estimateMaximumTickLabelWidth(g2, getTickUnit()); + + // Compute number of labels + double n = getRange().getLength() + * tickLabelWidth / dataArea.getHeight(); + + setTickUnit( + (NumberTickUnit) getStandardTickUnits().getCeilingTickUnit(n), + false, false); + } + + /** + * A special Number tick that also hold information about the cycle bound + * mapping for this tick. This is especially useful for having a tick at + * each axis end with the cycle bound value. See also + * isBoundMappedToLastCycle() + */ + protected static class CycleBoundTick extends NumberTick { + + /** Map to last cycle. */ + public boolean mapToLastCycle; + + /** + * Creates a new tick. + * + * @param mapToLastCycle map to last cycle? + * @param number the number. + * @param label the label. + * @param textAnchor the text anchor. + * @param rotationAnchor the rotation anchor. + * @param angle the rotation angle. + */ + public CycleBoundTick(boolean mapToLastCycle, Number number, + String label, TextAnchor textAnchor, + TextAnchor rotationAnchor, double angle) { + super(number, label, textAnchor, rotationAnchor, angle); + this.mapToLastCycle = mapToLastCycle; + } + } + + /** + * Calculates the anchor point for a tick. + * + * @param tick the tick. + * @param cursor the cursor. + * @param dataArea the data area. + * @param edge the side on which the axis is displayed. + * + * @return The anchor point. + */ + @Override + protected float[] calculateAnchorPoint(ValueTick tick, double cursor, + Rectangle2D dataArea, RectangleEdge edge) { + if (tick instanceof CycleBoundTick) { + boolean mapsav = this.boundMappedToLastCycle; + this.boundMappedToLastCycle + = ((CycleBoundTick) tick).mapToLastCycle; + float[] ret = super.calculateAnchorPoint( + tick, cursor, dataArea, edge + ); + this.boundMappedToLastCycle = mapsav; + return ret; + } + return super.calculateAnchorPoint(tick, cursor, dataArea, edge); + } + + + + /** + * Builds a list of ticks for the axis. This method is called when the + * axis is at the top or bottom of the chart (so the axis is "horizontal"). + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param edge the edge. + * + * @return A list of ticks. + */ + @Override + protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, + RectangleEdge edge) { + + List result = new java.util.ArrayList(); + + Font tickLabelFont = getTickLabelFont(); + g2.setFont(tickLabelFont); + + if (isAutoTickUnitSelection()) { + selectAutoTickUnit(g2, dataArea, edge); + } + + double unit = getTickUnit().getSize(); + double cycleBound = getCycleBound(); + double currentTickValue = Math.ceil(cycleBound / unit) * unit; + double upperValue = getRange().getUpperBound(); + boolean cycled = false; + + boolean boundMapping = this.boundMappedToLastCycle; + this.boundMappedToLastCycle = false; + + CycleBoundTick lastTick = null; + float lastX = 0.0f; + + if (upperValue == cycleBound) { + currentTickValue = calculateLowestVisibleTickValue(); + cycled = true; + this.boundMappedToLastCycle = true; + } + + while (currentTickValue <= upperValue) { + + // Cycle when necessary + boolean cyclenow = false; + if ((currentTickValue + unit > upperValue) && !cycled) { + cyclenow = true; + } + + double xx = valueToJava2D(currentTickValue, dataArea, edge); + String tickLabel; + NumberFormat formatter = getNumberFormatOverride(); + if (formatter != null) { + tickLabel = formatter.format(currentTickValue); + } + else { + tickLabel = getTickUnit().valueToString(currentTickValue); + } + float x = (float) xx; + TextAnchor anchor; + TextAnchor rotationAnchor; + double angle = 0.0; + if (isVerticalTickLabels()) { + if (edge == RectangleEdge.TOP) { + angle = Math.PI / 2.0; + } + else { + angle = -Math.PI / 2.0; + } + anchor = TextAnchor.CENTER_RIGHT; + // If tick overlap when cycling, update last tick too + if ((lastTick != null) && (lastX == x) + && (currentTickValue != cycleBound)) { + anchor = isInverted() + ? TextAnchor.TOP_RIGHT : TextAnchor.BOTTOM_RIGHT; + result.remove(result.size() - 1); + result.add(new CycleBoundTick( + this.boundMappedToLastCycle, lastTick.getNumber(), + lastTick.getText(), anchor, anchor, + lastTick.getAngle()) + ); + this.internalMarkerWhenTicksOverlap = true; + anchor = isInverted() + ? TextAnchor.BOTTOM_RIGHT : TextAnchor.TOP_RIGHT; + } + rotationAnchor = anchor; + } + else { + if (edge == RectangleEdge.TOP) { + anchor = TextAnchor.BOTTOM_CENTER; + if ((lastTick != null) && (lastX == x) + && (currentTickValue != cycleBound)) { + anchor = isInverted() + ? TextAnchor.BOTTOM_LEFT : TextAnchor.BOTTOM_RIGHT; + result.remove(result.size() - 1); + result.add(new CycleBoundTick( + this.boundMappedToLastCycle, lastTick.getNumber(), + lastTick.getText(), anchor, anchor, + lastTick.getAngle()) + ); + this.internalMarkerWhenTicksOverlap = true; + anchor = isInverted() + ? TextAnchor.BOTTOM_RIGHT : TextAnchor.BOTTOM_LEFT; + } + rotationAnchor = anchor; + } + else { + anchor = TextAnchor.TOP_CENTER; + if ((lastTick != null) && (lastX == x) + && (currentTickValue != cycleBound)) { + anchor = isInverted() + ? TextAnchor.TOP_LEFT : TextAnchor.TOP_RIGHT; + result.remove(result.size() - 1); + result.add(new CycleBoundTick( + this.boundMappedToLastCycle, lastTick.getNumber(), + lastTick.getText(), anchor, anchor, + lastTick.getAngle()) + ); + this.internalMarkerWhenTicksOverlap = true; + anchor = isInverted() + ? TextAnchor.TOP_RIGHT : TextAnchor.TOP_LEFT; + } + rotationAnchor = anchor; + } + } + + CycleBoundTick tick = new CycleBoundTick( + this.boundMappedToLastCycle, + new Double(currentTickValue), tickLabel, anchor, + rotationAnchor, angle + ); + if (currentTickValue == cycleBound) { + this.internalMarkerCycleBoundTick = tick; + } + result.add(tick); + lastTick = tick; + lastX = x; + + currentTickValue += unit; + + if (cyclenow) { + currentTickValue = calculateLowestVisibleTickValue(); + upperValue = cycleBound; + cycled = true; + this.boundMappedToLastCycle = true; + } + + } + this.boundMappedToLastCycle = boundMapping; + return result; + + } + + /** + * Builds a list of ticks for the axis. This method is called when the + * axis is at the left or right of the chart (so the axis is "vertical"). + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param edge the edge. + * + * @return A list of ticks. + */ + protected List refreshVerticalTicks(Graphics2D g2, Rectangle2D dataArea, + RectangleEdge edge) { + + List result = new java.util.ArrayList(); + result.clear(); + + Font tickLabelFont = getTickLabelFont(); + g2.setFont(tickLabelFont); + if (isAutoTickUnitSelection()) { + selectAutoTickUnit(g2, dataArea, edge); + } + + double unit = getTickUnit().getSize(); + double cycleBound = getCycleBound(); + double currentTickValue = Math.ceil(cycleBound / unit) * unit; + double upperValue = getRange().getUpperBound(); + boolean cycled = false; + + boolean boundMapping = this.boundMappedToLastCycle; + this.boundMappedToLastCycle = true; + + NumberTick lastTick = null; + float lastY = 0.0f; + + if (upperValue == cycleBound) { + currentTickValue = calculateLowestVisibleTickValue(); + cycled = true; + this.boundMappedToLastCycle = true; + } + + while (currentTickValue <= upperValue) { + + // Cycle when necessary + boolean cyclenow = false; + if ((currentTickValue + unit > upperValue) && !cycled) { + cyclenow = true; + } + + double yy = valueToJava2D(currentTickValue, dataArea, edge); + String tickLabel; + NumberFormat formatter = getNumberFormatOverride(); + if (formatter != null) { + tickLabel = formatter.format(currentTickValue); + } + else { + tickLabel = getTickUnit().valueToString(currentTickValue); + } + + float y = (float) yy; + TextAnchor anchor; + TextAnchor rotationAnchor; + double angle = 0.0; + if (isVerticalTickLabels()) { + + if (edge == RectangleEdge.LEFT) { + anchor = TextAnchor.BOTTOM_CENTER; + if ((lastTick != null) && (lastY == y) + && (currentTickValue != cycleBound)) { + anchor = isInverted() + ? TextAnchor.BOTTOM_LEFT : TextAnchor.BOTTOM_RIGHT; + result.remove(result.size() - 1); + result.add(new CycleBoundTick( + this.boundMappedToLastCycle, lastTick.getNumber(), + lastTick.getText(), anchor, anchor, + lastTick.getAngle()) + ); + this.internalMarkerWhenTicksOverlap = true; + anchor = isInverted() + ? TextAnchor.BOTTOM_RIGHT : TextAnchor.BOTTOM_LEFT; + } + rotationAnchor = anchor; + angle = -Math.PI / 2.0; + } + else { + anchor = TextAnchor.BOTTOM_CENTER; + if ((lastTick != null) && (lastY == y) + && (currentTickValue != cycleBound)) { + anchor = isInverted() + ? TextAnchor.BOTTOM_RIGHT : TextAnchor.BOTTOM_LEFT; + result.remove(result.size() - 1); + result.add(new CycleBoundTick( + this.boundMappedToLastCycle, lastTick.getNumber(), + lastTick.getText(), anchor, anchor, + lastTick.getAngle()) + ); + this.internalMarkerWhenTicksOverlap = true; + anchor = isInverted() + ? TextAnchor.BOTTOM_LEFT : TextAnchor.BOTTOM_RIGHT; + } + rotationAnchor = anchor; + angle = Math.PI / 2.0; + } + } + else { + if (edge == RectangleEdge.LEFT) { + anchor = TextAnchor.CENTER_RIGHT; + if ((lastTick != null) && (lastY == y) + && (currentTickValue != cycleBound)) { + anchor = isInverted() + ? TextAnchor.BOTTOM_RIGHT : TextAnchor.TOP_RIGHT; + result.remove(result.size() - 1); + result.add(new CycleBoundTick( + this.boundMappedToLastCycle, lastTick.getNumber(), + lastTick.getText(), anchor, anchor, + lastTick.getAngle()) + ); + this.internalMarkerWhenTicksOverlap = true; + anchor = isInverted() + ? TextAnchor.TOP_RIGHT : TextAnchor.BOTTOM_RIGHT; + } + rotationAnchor = anchor; + } + else { + anchor = TextAnchor.CENTER_LEFT; + if ((lastTick != null) && (lastY == y) + && (currentTickValue != cycleBound)) { + anchor = isInverted() + ? TextAnchor.BOTTOM_LEFT : TextAnchor.TOP_LEFT; + result.remove(result.size() - 1); + result.add(new CycleBoundTick( + this.boundMappedToLastCycle, lastTick.getNumber(), + lastTick.getText(), anchor, anchor, + lastTick.getAngle()) + ); + this.internalMarkerWhenTicksOverlap = true; + anchor = isInverted() + ? TextAnchor.TOP_LEFT : TextAnchor.BOTTOM_LEFT; + } + rotationAnchor = anchor; + } + } + + CycleBoundTick tick = new CycleBoundTick( + this.boundMappedToLastCycle, new Double(currentTickValue), + tickLabel, anchor, rotationAnchor, angle); + if (currentTickValue == cycleBound) { + this.internalMarkerCycleBoundTick = tick; + } + result.add(tick); + lastTick = tick; + lastY = y; + + if (currentTickValue == cycleBound) { + this.internalMarkerCycleBoundTick = tick; + } + + currentTickValue += unit; + + if (cyclenow) { + currentTickValue = calculateLowestVisibleTickValue(); + upperValue = cycleBound; + cycled = true; + this.boundMappedToLastCycle = false; + } + + } + this.boundMappedToLastCycle = boundMapping; + return result; + } + + /** + * Converts a coordinate from Java 2D space to data space. + * + * @param java2DValue the coordinate in Java2D space. + * @param dataArea the data area. + * @param edge the edge. + * + * @return The data value. + */ + @Override + public double java2DToValue(double java2DValue, Rectangle2D dataArea, + RectangleEdge edge) { + Range range = getRange(); + + double vmax = range.getUpperBound(); + double vp = getCycleBound(); + + double jmin = 0.0; + double jmax = 0.0; + if (RectangleEdge.isTopOrBottom(edge)) { + jmin = dataArea.getMinX(); + jmax = dataArea.getMaxX(); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + jmin = dataArea.getMaxY(); + jmax = dataArea.getMinY(); + } + + if (isInverted()) { + double jbreak = jmax - (vmax - vp) * (jmax - jmin) / this.period; + if (java2DValue >= jbreak) { + return vp + (jmax - java2DValue) * this.period / (jmax - jmin); + } + else { + return vp - (java2DValue - jmin) * this.period / (jmax - jmin); + } + } + else { + double jbreak = (vmax - vp) * (jmax - jmin) / this.period + jmin; + if (java2DValue <= jbreak) { + return vp + (java2DValue - jmin) * this.period / (jmax - jmin); + } + else { + return vp - (jmax - java2DValue) * this.period / (jmax - jmin); + } + } + } + + /** + * Translates a value from data space to Java 2D space. + * + * @param value the data value. + * @param dataArea the data area. + * @param edge the edge. + * + * @return The Java 2D value. + */ + @Override + public double valueToJava2D(double value, Rectangle2D dataArea, + RectangleEdge edge) { + Range range = getRange(); + + double vmin = range.getLowerBound(); + double vmax = range.getUpperBound(); + double vp = getCycleBound(); + + if ((value < vmin) || (value > vmax)) { + return Double.NaN; + } + + + double jmin = 0.0; + double jmax = 0.0; + if (RectangleEdge.isTopOrBottom(edge)) { + jmin = dataArea.getMinX(); + jmax = dataArea.getMaxX(); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + jmax = dataArea.getMinY(); + jmin = dataArea.getMaxY(); + } + + if (isInverted()) { + if (value == vp) { + return this.boundMappedToLastCycle ? jmin : jmax; + } + else if (value > vp) { + return jmax - (value - vp) * (jmax - jmin) / this.period; + } + else { + return jmin + (vp - value) * (jmax - jmin) / this.period; + } + } + else { + if (value == vp) { + return this.boundMappedToLastCycle ? jmax : jmin; + } + else if (value >= vp) { + return jmin + (value - vp) * (jmax - jmin) / this.period; + } + else { + return jmax - (vp - value) * (jmax - jmin) / this.period; + } + } + } + + /** + * Centers the range about the given value. + * + * @param value the data value. + */ + @Override + public void centerRange(double value) { + setRange(value - this.period / 2.0, value + this.period / 2.0); + } + + /** + * This function is nearly useless since the auto range is fixed for this + * class to the period. The period is extended if necessary to fit the + * minimum size. + * + * @param size the size. + * @param notify notify? + * + * @see org.jfree.chart.axis.ValueAxis#setAutoRangeMinimumSize(double, + * boolean) + */ + @Override + public void setAutoRangeMinimumSize(double size, boolean notify) { + if (size > this.period) { + this.period = size; + } + super.setAutoRangeMinimumSize(size, notify); + } + + /** + * The auto range is fixed for this class to the period by default. + * This function will thus set a new period. + * + * @param length the length. + * + * @see org.jfree.chart.axis.ValueAxis#setFixedAutoRange(double) + */ + @Override + public void setFixedAutoRange(double length) { + this.period = length; + super.setFixedAutoRange(length); + } + + /** + * Sets a new axis range. The period is extended to fit the range size, if + * necessary. + * + * @param range the range. + * @param turnOffAutoRange switch off the auto range. + * @param notify notify? + * + * @see org.jfree.chart.axis.ValueAxis#setRange(Range, boolean, boolean) + */ + @Override + public void setRange(Range range, boolean turnOffAutoRange, + boolean notify) { + double size = range.getUpperBound() - range.getLowerBound(); + if (size > this.period) { + this.period = size; + } + super.setRange(range, turnOffAutoRange, notify); + } + + /** + * The cycle bound is defined as the higest value x such that + * "offset + period * i = x", with i and integer and x < + * range.getUpperBound() This is the value which is at both ends of the + * axis : x...up|low...x + * The values from x to up are the valued in the current cycle. + * The values from low to x are the valued in the previous cycle. + * + * @return The cycle bound. + */ + public double getCycleBound() { + return Math.floor( + (getRange().getUpperBound() - this.offset) / this.period + ) * this.period + this.offset; + } + + /** + * The cycle bound is a multiple of the period, plus optionally a start + * offset. + *

+ *

cb = n * period + offset

+ * + * @return The current offset. + * + * @see #getCycleBound() + */ + public double getOffset() { + return this.offset; + } + + /** + * The cycle bound is a multiple of the period, plus optionally a start + * offset. + *

+ *

cb = n * period + offset

+ * + * @param offset The offset to set. + * + * @see #getCycleBound() + */ + public void setOffset(double offset) { + this.offset = offset; + } + + /** + * The cycle bound is a multiple of the period, plus optionally a start + * offset. + *

+ *

cb = n * period + offset

+ * + * @return The current period. + * + * @see #getCycleBound() + */ + public double getPeriod() { + return this.period; + } + + /** + * The cycle bound is a multiple of the period, plus optionally a start + * offset. + *

+ *

cb = n * period + offset

+ * + * @param period The period to set. + * + * @see #getCycleBound() + */ + public void setPeriod(double period) { + this.period = period; + } + + /** + * Draws the tick marks and labels. + * + * @param g2 the graphics device. + * @param cursor the cursor. + * @param plotArea the plot area. + * @param dataArea the area inside the axes. + * @param edge the side on which the axis is displayed. + * + * @return The axis state. + */ + @Override + protected AxisState drawTickMarksAndLabels(Graphics2D g2, double cursor, + Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge) { + this.internalMarkerWhenTicksOverlap = false; + AxisState ret = super.drawTickMarksAndLabels(g2, cursor, plotArea, + dataArea, edge); + + // continue and separate the labels only if necessary + if (!this.internalMarkerWhenTicksOverlap) { + return ret; + } + + double ol; + FontMetrics fm = g2.getFontMetrics(getTickLabelFont()); + if (isVerticalTickLabels()) { + ol = fm.getMaxAdvance(); + } + else { + ol = fm.getHeight(); + } + + double il = 0; + if (isTickMarksVisible()) { + float xx = (float) valueToJava2D(getRange().getUpperBound(), + dataArea, edge); + Line2D mark = null; + g2.setStroke(getTickMarkStroke()); + g2.setPaint(getTickMarkPaint()); + if (edge == RectangleEdge.LEFT) { + mark = new Line2D.Double(cursor - ol, xx, cursor + il, xx); + } + else if (edge == RectangleEdge.RIGHT) { + mark = new Line2D.Double(cursor + ol, xx, cursor - il, xx); + } + else if (edge == RectangleEdge.TOP) { + mark = new Line2D.Double(xx, cursor - ol, xx, cursor + il); + } + else if (edge == RectangleEdge.BOTTOM) { + mark = new Line2D.Double(xx, cursor + ol, xx, cursor - il); + } + g2.draw(mark); + } + return ret; + } + + /** + * Draws the axis. + * + * @param g2 the graphics device (null not permitted). + * @param cursor the cursor position. + * @param plotArea the plot area (null not permitted). + * @param dataArea the data area (null not permitted). + * @param edge the edge (null not permitted). + * @param plotState collects information about the plot + * (null permitted). + * + * @return The axis state (never null). + */ + @Override + public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, + Rectangle2D dataArea, RectangleEdge edge, PlotRenderingInfo plotState) { + + AxisState ret = super.draw(g2, cursor, plotArea, dataArea, edge, + plotState); + if (isAdvanceLineVisible()) { + double xx = valueToJava2D(getRange().getUpperBound(), dataArea, + edge); + Line2D mark = null; + g2.setStroke(getAdvanceLineStroke()); + g2.setPaint(getAdvanceLinePaint()); + if (edge == RectangleEdge.LEFT) { + mark = new Line2D.Double(cursor, xx, cursor + + dataArea.getWidth(), xx); + } + else if (edge == RectangleEdge.RIGHT) { + mark = new Line2D.Double(cursor - dataArea.getWidth(), xx, + cursor, xx); + } + else if (edge == RectangleEdge.TOP) { + mark = new Line2D.Double(xx, cursor + dataArea.getHeight(), xx, + cursor); + } + else if (edge == RectangleEdge.BOTTOM) { + mark = new Line2D.Double(xx, cursor, xx, + cursor - dataArea.getHeight()); + } + g2.draw(mark); + } + return ret; + } + + /** + * Reserve some space on each axis side because we draw a centered label at + * each extremity. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param plotArea the plot area. + * @param edge the edge. + * @param space the space already reserved. + * + * @return The reserved space. + */ + @Override + public AxisSpace reserveSpace(Graphics2D g2, Plot plot, + Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) { + + this.internalMarkerCycleBoundTick = null; + AxisSpace ret = super.reserveSpace(g2, plot, plotArea, edge, space); + if (this.internalMarkerCycleBoundTick == null) { + return ret; + } + + FontMetrics fm = g2.getFontMetrics(getTickLabelFont()); + Rectangle2D r = TextUtilities.getTextBounds( + this.internalMarkerCycleBoundTick.getText(), g2, fm + ); + + if (RectangleEdge.isTopOrBottom(edge)) { + if (isVerticalTickLabels()) { + space.add(r.getHeight() / 2, RectangleEdge.RIGHT); + } + else { + space.add(r.getWidth() / 2, RectangleEdge.RIGHT); + } + } + else if (RectangleEdge.isLeftOrRight(edge)) { + if (isVerticalTickLabels()) { + space.add(r.getWidth() / 2, RectangleEdge.TOP); + } + else { + space.add(r.getHeight() / 2, RectangleEdge.TOP); + } + } + + return ret; + + } + + /** + * 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.advanceLinePaint, stream); + SerialUtilities.writeStroke(this.advanceLineStroke, 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.advanceLinePaint = SerialUtilities.readPaint(stream); + this.advanceLineStroke = SerialUtilities.readStroke(stream); + } + + + /** + * Tests the axis for equality with another object. + * + * @param obj the object to test against. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CyclicNumberAxis)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + CyclicNumberAxis that = (CyclicNumberAxis) obj; + if (this.period != that.period) { + return false; + } + if (this.offset != that.offset) { + return false; + } + if (!PaintUtilities.equal(this.advanceLinePaint, + that.advanceLinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.advanceLineStroke, + that.advanceLineStroke)) { + return false; + } + if (this.advanceLineVisible != that.advanceLineVisible) { + return false; + } + if (this.boundMappedToLastCycle != that.boundMappedToLastCycle) { + return false; + } + return true; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateAxis.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateAxis.java new file mode 100755 index 0000000..bded2e4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateAxis.java @@ -0,0 +1,1976 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * DateAxis.java + * ------------- + * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert; + * Contributor(s): Jonathan Nash; + * David Li; + * Michael Rauch; + * Bill Kelemen; + * Pawel Pabis; + * Chris Boek; + * Peter Kolb (patches 1934255 and 2603321); + * Andrew Mickish (patch 1870189); + * Fawad Halim (bug 2201869); + * + * Changes (from 23-Jun-2001) + * -------------------------- + * 23-Jun-2001 : Modified to work with null data source (DG); + * 18-Sep-2001 : Updated header (DG); + * 27-Nov-2001 : Changed constructors from public to protected, updated Javadoc + * comments (DG); + * 16-Jan-2002 : Added an optional crosshair, based on the implementation by + * Jonathan Nash (DG); + * 26-Feb-2002 : Updated import statements (DG); + * 22-Apr-2002 : Added a setRange() method (DG); + * 25-Jun-2002 : Removed redundant local variable (DG); + * 25-Jul-2002 : Changed order of parameters in ValueAxis constructor (DG); + * 21-Aug-2002 : The setTickUnit() method now turns off auto-tick unit + * selection (fix for bug id 528885) (DG); + * 05-Sep-2002 : Updated the constructors to reflect changes in the Axis + * class (DG); + * 18-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 25-Sep-2002 : Added new setRange() methods, and deprecated + * setAxisRange() (DG); + * 04-Oct-2002 : Changed auto tick selection to parallel number axis + * classes (DG); + * 24-Oct-2002 : Added a date format override (DG); + * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); + * 14-Jan-2003 : Changed autoRangeMinimumSize from Number --> double, moved + * crosshair settings to the plot (DG); + * 15-Jan-2003 : Removed anchor date (DG); + * 20-Jan-2003 : Removed unnecessary constructors (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 02-May-2003 : Added additional units to createStandardDateTickUnits() + * method, as suggested by mhilpert in bug report 723187 (DG); + * 13-May-2003 : Merged HorizontalDateAxis and VerticalDateAxis (DG); + * 24-May-2003 : Added support for underlying timeline for + * SegmentedTimeline (BK); + * 16-Jul-2003 : Applied patch from Pawel Pabis to fix overlapping dates (DG); + * 22-Jul-2003 : Applied patch from Pawel Pabis for monthly ticks (DG); + * 25-Jul-2003 : Fixed bug 777561 and 777586 (DG); + * 13-Aug-2003 : Implemented Cloneable and added equals() method (DG); + * 02-Sep-2003 : Fixes for bug report 790506 (DG); + * 04-Sep-2003 : Fixed tick label alignment when axis appears at the top (DG); + * 10-Sep-2003 : Fixes for segmented timeline (DG); + * 17-Sep-2003 : Fixed a layout bug when multiple domain axes are used (DG); + * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); + * 07-Nov-2003 : Modified to use new tick classes (DG); + * 12-Nov-2003 : Modified tick labelling to use roll unit from DateTickUnit + * when a calculated tick value is hidden (which can occur in + * segmented date axes) (DG); + * 24-Nov-2003 : Fixed some problems with the auto tick unit selection, and + * fixed bug 846277 (labels missing for inverted axis) (DG); + * 30-Dec-2003 : Fixed bug in refreshTicksHorizontal() when start of time unit + * (ex. 1st of month) was hidden, causing infinite loop (BK); + * 13-Jan-2004 : Fixed bug in previousStandardDate() method (fix by Richard + * Wardle) (DG); + * 21-Jan-2004 : Renamed translateJava2DToValue --> java2DToValue, and + * translateValueToJava2D --> valueToJava2D (DG); + * 12-Mar-2004 : Fixed bug where date format override is ignored for vertical + * axis (DG); + * 16-Mar-2004 : Added plotState to draw() method (DG); + * 07-Apr-2004 : Changed string width calculation (DG); + * 21-Apr-2004 : Fixed bug in estimateMaximumTickLabelWidth() method (bug id + * 939148) (DG); + * 11-Jan-2005 : Removed deprecated methods in preparation for 1.0.0 + * release (DG); + * 13-Jan-2005 : Fixed bug (see + * http://www.jfree.org/forum/viewtopic.php?t=11330) (DG); + * 21-Apr-2005 : Replaced Insets with RectangleInsets, removed redundant + * argument from selectAutoTickUnit() (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 10-Feb-2006 : Added some API doc comments in respect of bug 821046 (DG); + * 19-Apr-2006 : Fixed bug 1472942 in equals() method (DG); + * 25-Sep-2006 : Fixed bug 1564977 missing tick labels (DG); + * 15-Jan-2007 : Added get/setTimeZone() suggested by 'skunk' (DG); + * 18-Jan-2007 : Fixed bug 1638678, time zone for calendar in + * previousStandardDate() (DG); + * 04-Apr-2007 : Use time zone in date calculations (CB); + * 19-Apr-2007 : Fix exceptions in setMinimum/MaximumDate() (DG); + * 03-May-2007 : Fixed minor bugs in previousStandardDate(), with new JUnit + * tests (DG); + * 21-Nov-2007 : Fixed warnings from FindBugs (DG); + * 01-Sep-2008 : Use new methods from DateRange, added fix for bug + * 2078057 (DG); + * 18-Sep-2008 : Added locale to go with timezone (DG); + * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); + * 25-Nov-2008 : Added bug fix 2201869 by Fawad Halim (DG); + * 21-Jan-2009 : Check tickUnit for minor tick count (DG); + * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); + * 08-Feb-2012 : Bugfix for endless-loop, bug 3484403 by rbrabe (MH); + * 25-Jul-2013 : Update event notification to use fireChangeEvent() (DG); + * 01-Aug-2013 : Added attributedLabel override to support superscripts, + * subscripts and more (DG); + * 12-Sep-2013 : Prevent exception when zooming in below 1 millisecond (DG); + * 23-Nov-2013 : Deprecated DEFAULT_DATE_TICK_UNIT to fix bug #977 (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.io.Serializable; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.TimeZone; + +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.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.time.DateRange; +import org.jfree.data.time.Month; +import org.jfree.data.time.RegularTimePeriod; +import org.jfree.data.time.Year; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.TextAnchor; +import org.jfree.util.ObjectUtilities; + +/** + * The base class for axes that display dates. You will find it easier to + * understand how this axis works if you bear in mind that it really + * displays/measures integer (or long) data, where the integers are + * milliseconds since midnight, 1-Jan-1970. When displaying tick labels, the + * millisecond values are converted back to dates using a + * DateFormat instance. + *

+ * You can also create a {@link org.jfree.chart.axis.Timeline} and supply in + * the constructor to create an axis that only contains certain domain values. + * For example, this allows you to create a date axis that only contains + * working days. + */ +public class DateAxis extends ValueAxis implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -1013460999649007604L; + + /** The default axis range. */ + public static final DateRange DEFAULT_DATE_RANGE = new DateRange(); + + /** The default minimum auto range size. */ + public static final double + DEFAULT_AUTO_RANGE_MINIMUM_SIZE_IN_MILLISECONDS = 2.0; + + /** + * The default date tick unit. + * + * @deprecated As pointed out in bug #977, the SimpleDateFormat in this + * object uses Calendar which is not thread safe...so you should + * avoid reusing this instance and create a new instance as required. + */ + public static final DateTickUnit DEFAULT_DATE_TICK_UNIT + = new DateTickUnit(DateTickUnitType.DAY, 1, new SimpleDateFormat()); + + /** The default anchor date. */ + public static final Date DEFAULT_ANCHOR_DATE = new Date(); + + /** The current tick unit. */ + private DateTickUnit tickUnit; + + /** The override date format. */ + private DateFormat dateFormatOverride; + + /** + * Tick marks can be displayed at the start or the middle of the time + * period. + */ + private DateTickMarkPosition tickMarkPosition = DateTickMarkPosition.START; + + /** + * A timeline that includes all milliseconds (as defined by + * java.util.Date) in the real time line. + */ + private static class DefaultTimeline implements Timeline, Serializable { + + /** + * Converts a millisecond into a timeline value. + * + * @param millisecond the millisecond. + * + * @return The timeline value. + */ + @Override + public long toTimelineValue(long millisecond) { + return millisecond; + } + + /** + * Converts a date into a timeline value. + * + * @param date the domain value. + * + * @return The timeline value. + */ + @Override + public long toTimelineValue(Date date) { + return date.getTime(); + } + + /** + * Converts a timeline value into a millisecond (as encoded by + * java.util.Date). + * + * @param value the value. + * + * @return The millisecond. + */ + @Override + public long toMillisecond(long value) { + return value; + } + + /** + * Returns true if the timeline includes the specified + * domain value. + * + * @param millisecond the millisecond. + * + * @return true. + */ + @Override + public boolean containsDomainValue(long millisecond) { + return true; + } + + /** + * Returns true if the timeline includes the specified + * domain value. + * + * @param date the date. + * + * @return true. + */ + @Override + public boolean containsDomainValue(Date date) { + return true; + } + + /** + * Returns true if the timeline includes the specified + * domain value range. + * + * @param from the start value. + * @param to the end value. + * + * @return true. + */ + @Override + public boolean containsDomainRange(long from, long to) { + return true; + } + + /** + * Returns true if the timeline includes the specified + * domain value range. + * + * @param from the start date. + * @param to the end date. + * + * @return true. + */ + @Override + public boolean containsDomainRange(Date from, Date to) { + return true; + } + + /** + * Tests an object for equality with this instance. + * + * @param object the object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object object) { + if (object == null) { + return false; + } + if (object == this) { + return true; + } + if (object instanceof DefaultTimeline) { + return true; + } + return false; + } + } + + /** A static default timeline shared by all standard DateAxis */ + private static final Timeline DEFAULT_TIMELINE = new DefaultTimeline(); + + /** The time zone for the axis. */ + private TimeZone timeZone; + + /** + * The locale for the axis (null is not permitted). + * + * @since 1.0.11 + */ + private Locale locale; + + /** Our underlying timeline. */ + private Timeline timeline; + + /** + * Creates a date axis with no label. + */ + public DateAxis() { + this(null); + } + + /** + * Creates a date axis with the specified label. + * + * @param label the axis label (null permitted). + */ + public DateAxis(String label) { + this(label, TimeZone.getDefault()); + } + + /** + * Creates a date axis. A timeline is specified for the axis. This allows + * special transformations to occur between a domain of values and the + * values included in the axis. + * + * @see org.jfree.chart.axis.SegmentedTimeline + * + * @param label the axis label (null permitted). + * @param zone the time zone. + * + * @deprecated From 1.0.11 onwards, use {@link #DateAxis(String, TimeZone, + * Locale)} instead, to explicitly set the locale. + */ + public DateAxis(String label, TimeZone zone) { + this(label, zone, Locale.getDefault()); + } + + /** + * Creates a date axis. A timeline is specified for the axis. This allows + * special transformations to occur between a domain of values and the + * values included in the axis. + * + * @see org.jfree.chart.axis.SegmentedTimeline + * + * @param label the axis label (null permitted). + * @param zone the time zone. + * @param locale the locale (null not permitted). + * + * @since 1.0.11 + */ + public DateAxis(String label, TimeZone zone, Locale locale) { + super(label, DateAxis.createStandardDateTickUnits(zone, locale)); + this.tickUnit = new DateTickUnit(DateTickUnitType.DAY, 1, + new SimpleDateFormat()); + setAutoRangeMinimumSize( + DEFAULT_AUTO_RANGE_MINIMUM_SIZE_IN_MILLISECONDS); + setRange(DEFAULT_DATE_RANGE, false, false); + this.dateFormatOverride = null; + this.timeZone = zone; + this.locale = locale; + this.timeline = DEFAULT_TIMELINE; + } + + /** + * Returns the time zone for the axis. + * + * @return The time zone (never null). + * + * @since 1.0.4 + * + * @see #setTimeZone(TimeZone) + */ + public TimeZone getTimeZone() { + return this.timeZone; + } + + /** + * Sets the time zone for the axis and sends an {@link AxisChangeEvent} to + * all registered listeners. + * + * @param zone the time zone (null not permitted). + * + * @since 1.0.4 + * + * @see #getTimeZone() + */ + public void setTimeZone(TimeZone zone) { + ParamChecks.nullNotPermitted(zone, "zone"); + if (!this.timeZone.equals(zone)) { + this.timeZone = zone; + setStandardTickUnits(createStandardDateTickUnits(zone, + this.locale)); + fireChangeEvent(); + } + } + + /** + * Returns the underlying timeline used by this axis. + * + * @return The timeline. + */ + public Timeline getTimeline() { + return this.timeline; + } + + /** + * Sets the underlying timeline to use for this axis. If the timeline is + * changed, an {@link AxisChangeEvent} is sent to all registered listeners. + * + * @param timeline the timeline. + */ + public void setTimeline(Timeline timeline) { + if (this.timeline != timeline) { + this.timeline = timeline; + fireChangeEvent(); + } + } + + /** + * Returns the tick unit for the axis. + *

+ * Note: if the autoTickUnitSelection flag is + * true the tick unit may be changed while the axis is being + * drawn, so in that case the return value from this method may be + * irrelevant if the method is called before the axis has been drawn. + * + * @return The tick unit (possibly null). + * + * @see #setTickUnit(DateTickUnit) + * @see ValueAxis#isAutoTickUnitSelection() + */ + public DateTickUnit getTickUnit() { + return this.tickUnit; + } + + /** + * Sets the tick unit for the axis. The auto-tick-unit-selection flag is + * set to false, and registered listeners are notified that + * the axis has been changed. + * + * @param unit the tick unit. + * + * @see #getTickUnit() + * @see #setTickUnit(DateTickUnit, boolean, boolean) + */ + public void setTickUnit(DateTickUnit unit) { + setTickUnit(unit, true, true); + } + + /** + * Sets the tick unit attribute and, if requested, sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param unit the new tick unit. + * @param notify notify registered listeners? + * @param turnOffAutoSelection turn off auto selection? + * + * @see #getTickUnit() + */ + public void setTickUnit(DateTickUnit unit, boolean notify, + boolean turnOffAutoSelection) { + + this.tickUnit = unit; + if (turnOffAutoSelection) { + setAutoTickUnitSelection(false, false); + } + if (notify) { + fireChangeEvent(); + } + + } + + /** + * Returns the date format override. If this is non-null, then it will be + * used to format the dates on the axis. + * + * @return The formatter (possibly null). + */ + public DateFormat getDateFormatOverride() { + return this.dateFormatOverride; + } + + /** + * Sets the date format override and sends an {@link AxisChangeEvent} to + * all registered listeners. If this is non-null, then it will be + * used to format the dates on the axis. + * + * @param formatter the date formatter (null permitted). + */ + public void setDateFormatOverride(DateFormat formatter) { + this.dateFormatOverride = formatter; + fireChangeEvent(); + } + + /** + * Sets the upper and lower bounds for the axis and sends an + * {@link AxisChangeEvent} to all registered listeners. As a side-effect, + * the auto-range flag is set to false. + * + * @param range the new range (null not permitted). + */ + @Override + public void setRange(Range range) { + setRange(range, true, true); + } + + /** + * Sets the range for the axis, if requested, sends an + * {@link AxisChangeEvent} to all registered listeners. As a side-effect, + * the auto-range flag is set to false (optional). + * + * @param range the range (null not permitted). + * @param turnOffAutoRange a flag that controls whether or not the auto + * range is turned off. + * @param notify a flag that controls whether or not listeners are + * notified. + */ + @Override + public void setRange(Range range, boolean turnOffAutoRange, + boolean notify) { + ParamChecks.nullNotPermitted(range, "range"); + // usually the range will be a DateRange, but if it isn't do a + // conversion... + if (!(range instanceof DateRange)) { + range = new DateRange(range); + } + super.setRange(range, turnOffAutoRange, notify); + } + + /** + * Sets the axis range and sends an {@link AxisChangeEvent} to all + * registered listeners. + * + * @param lower the lower bound for the axis. + * @param upper the upper bound for the axis. + */ + public void setRange(Date lower, Date upper) { + if (lower.getTime() >= upper.getTime()) { + throw new IllegalArgumentException("Requires 'lower' < 'upper'."); + } + setRange(new DateRange(lower, upper)); + } + + /** + * Sets the axis range and sends an {@link AxisChangeEvent} to all + * registered listeners. + * + * @param lower the lower bound for the axis. + * @param upper the upper bound for the axis. + */ + @Override + public void setRange(double lower, double upper) { + if (lower >= upper) { + throw new IllegalArgumentException("Requires 'lower' < 'upper'."); + } + setRange(new DateRange(lower, upper)); + } + + /** + * Returns the earliest date visible on the axis. + * + * @return The date. + * + * @see #setMinimumDate(Date) + * @see #getMaximumDate() + */ + public Date getMinimumDate() { + Date result; + Range range = getRange(); + if (range instanceof DateRange) { + DateRange r = (DateRange) range; + result = r.getLowerDate(); + } + else { + result = new Date((long) range.getLowerBound()); + } + return result; + } + + /** + * Sets the minimum date visible on the axis and sends an + * {@link AxisChangeEvent} to all registered listeners. If + * date is on or after the current maximum date for + * the axis, the maximum date will be shifted to preserve the current + * length of the axis. + * + * @param date the date (null not permitted). + * + * @see #getMinimumDate() + * @see #setMaximumDate(Date) + */ + public void setMinimumDate(Date date) { + ParamChecks.nullNotPermitted(date, "date"); + // check the new minimum date relative to the current maximum date + Date maxDate = getMaximumDate(); + long maxMillis = maxDate.getTime(); + long newMinMillis = date.getTime(); + if (maxMillis <= newMinMillis) { + Date oldMin = getMinimumDate(); + long length = maxMillis - oldMin.getTime(); + maxDate = new Date(newMinMillis + length); + } + setRange(new DateRange(date, maxDate), true, false); + fireChangeEvent(); + } + + /** + * Returns the latest date visible on the axis. + * + * @return The date. + * + * @see #setMaximumDate(Date) + * @see #getMinimumDate() + */ + public Date getMaximumDate() { + Date result; + Range range = getRange(); + if (range instanceof DateRange) { + DateRange r = (DateRange) range; + result = r.getUpperDate(); + } + else { + result = new Date((long) range.getUpperBound()); + } + return result; + } + + /** + * Sets the maximum date visible on the axis and sends an + * {@link AxisChangeEvent} to all registered listeners. If + * maximumDate is on or before the current minimum date for + * the axis, the minimum date will be shifted to preserve the current + * length of the axis. + * + * @param maximumDate the date (null not permitted). + * + * @see #getMinimumDate() + * @see #setMinimumDate(Date) + */ + public void setMaximumDate(Date maximumDate) { + ParamChecks.nullNotPermitted(maximumDate, "maximumDate"); + // check the new maximum date relative to the current minimum date + Date minDate = getMinimumDate(); + long minMillis = minDate.getTime(); + long newMaxMillis = maximumDate.getTime(); + if (minMillis >= newMaxMillis) { + Date oldMax = getMaximumDate(); + long length = oldMax.getTime() - minMillis; + minDate = new Date(newMaxMillis - length); + } + setRange(new DateRange(minDate, maximumDate), true, false); + fireChangeEvent(); + } + + /** + * Returns the tick mark position (start, middle or end of the time period). + * + * @return The position (never null). + */ + public DateTickMarkPosition getTickMarkPosition() { + return this.tickMarkPosition; + } + + /** + * Sets the tick mark position (start, middle or end of the time period) + * and sends an {@link AxisChangeEvent} to all registered listeners. + * + * @param position the position (null not permitted). + */ + public void setTickMarkPosition(DateTickMarkPosition position) { + ParamChecks.nullNotPermitted(position, "position"); + this.tickMarkPosition = position; + fireChangeEvent(); + } + + /** + * Configures the axis to work with the specified plot. If the axis has + * auto-scaling, then sets the maximum and minimum values. + */ + @Override + public void configure() { + if (isAutoRange()) { + autoAdjustRange(); + } + } + + /** + * Returns true if the axis hides this value, and + * false otherwise. + * + * @param millis the data value. + * + * @return A value. + */ + public boolean isHiddenValue(long millis) { + return (!this.timeline.containsDomainValue(new Date(millis))); + } + + /** + * Translates the data value to the display coordinates (Java 2D User Space) + * of the chart. + * + * @param value the date to be plotted. + * @param area the rectangle (in Java2D space) where the data is to be + * plotted. + * @param edge the axis location. + * + * @return The coordinate corresponding to the supplied data value. + */ + @Override + public double valueToJava2D(double value, Rectangle2D area, + RectangleEdge edge) { + + value = this.timeline.toTimelineValue((long) value); + + DateRange range = (DateRange) getRange(); + double axisMin = this.timeline.toTimelineValue(range.getLowerMillis()); + double axisMax = this.timeline.toTimelineValue(range.getUpperMillis()); + double result = 0.0; + if (RectangleEdge.isTopOrBottom(edge)) { + double minX = area.getX(); + double maxX = area.getMaxX(); + if (isInverted()) { + result = maxX + ((value - axisMin) / (axisMax - axisMin)) + * (minX - maxX); + } + else { + result = minX + ((value - axisMin) / (axisMax - axisMin)) + * (maxX - minX); + } + } + else if (RectangleEdge.isLeftOrRight(edge)) { + double minY = area.getMinY(); + double maxY = area.getMaxY(); + if (isInverted()) { + result = minY + (((value - axisMin) / (axisMax - axisMin)) + * (maxY - minY)); + } + else { + result = maxY - (((value - axisMin) / (axisMax - axisMin)) + * (maxY - minY)); + } + } + return result; + } + + /** + * Translates a date to Java2D coordinates, based on the range displayed by + * this axis for the specified data area. + * + * @param date the date. + * @param area the rectangle (in Java2D space) where the data is to be + * plotted. + * @param edge the axis location. + * + * @return The coordinate corresponding to the supplied date. + */ + public double dateToJava2D(Date date, Rectangle2D area, + RectangleEdge edge) { + double value = date.getTime(); + return valueToJava2D(value, area, edge); + } + + /** + * Translates a Java2D coordinate into the corresponding data value. To + * perform this translation, you need to know the area used for plotting + * data, and which edge the axis is located on. + * + * @param java2DValue the coordinate in Java2D space. + * @param area the rectangle (in Java2D space) where the data is to be + * plotted. + * @param edge the axis location. + * + * @return A data value. + */ + @Override + public double java2DToValue(double java2DValue, Rectangle2D area, + RectangleEdge edge) { + + DateRange range = (DateRange) getRange(); + double axisMin = this.timeline.toTimelineValue(range.getLowerMillis()); + double axisMax = this.timeline.toTimelineValue(range.getUpperMillis()); + + 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 result; + if (isInverted()) { + result = axisMax - ((java2DValue - min) / (max - min) + * (axisMax - axisMin)); + } + else { + result = axisMin + ((java2DValue - min) / (max - min) + * (axisMax - axisMin)); + } + + return this.timeline.toMillisecond((long) result); + } + + /** + * Calculates the value of the lowest visible tick on the axis. + * + * @param unit date unit to use. + * + * @return The value of the lowest visible tick on the axis. + */ + public Date calculateLowestVisibleTickValue(DateTickUnit unit) { + return nextStandardDate(getMinimumDate(), unit); + } + + /** + * Calculates the value of the highest visible tick on the axis. + * + * @param unit date unit to use. + * + * @return The value of the highest visible tick on the axis. + */ + public Date calculateHighestVisibleTickValue(DateTickUnit unit) { + return previousStandardDate(getMaximumDate(), unit); + } + + /** + * Returns the previous "standard" date, for a given date and tick unit. + * + * @param date the reference date. + * @param unit the tick unit. + * + * @return The previous "standard" date. + */ + protected Date previousStandardDate(Date date, DateTickUnit unit) { + + int milliseconds; + int seconds; + int minutes; + int hours; + int days; + int months; + int years; + + Calendar calendar = Calendar.getInstance(this.timeZone, this.locale); + calendar.setTime(date); + int count = unit.getCount(); + int current = calendar.get(unit.getCalendarField()); + int value = count * (current / count); + + switch (unit.getUnit()) { + + case DateTickUnit.MILLISECOND : + years = calendar.get(Calendar.YEAR); + months = calendar.get(Calendar.MONTH); + days = calendar.get(Calendar.DATE); + hours = calendar.get(Calendar.HOUR_OF_DAY); + minutes = calendar.get(Calendar.MINUTE); + seconds = calendar.get(Calendar.SECOND); + calendar.set(years, months, days, hours, minutes, seconds); + calendar.set(Calendar.MILLISECOND, value); + Date mm = calendar.getTime(); + if (mm.getTime() >= date.getTime()) { + calendar.set(Calendar.MILLISECOND, value - 1); + mm = calendar.getTime(); + } + return mm; + + case DateTickUnit.SECOND : + years = calendar.get(Calendar.YEAR); + months = calendar.get(Calendar.MONTH); + days = calendar.get(Calendar.DATE); + hours = calendar.get(Calendar.HOUR_OF_DAY); + minutes = calendar.get(Calendar.MINUTE); + if (this.tickMarkPosition == DateTickMarkPosition.START) { + milliseconds = 0; + } + else if (this.tickMarkPosition == DateTickMarkPosition.MIDDLE) { + milliseconds = 500; + } + else { + milliseconds = 999; + } + calendar.set(Calendar.MILLISECOND, milliseconds); + calendar.set(years, months, days, hours, minutes, value); + Date dd = calendar.getTime(); + if (dd.getTime() >= date.getTime()) { + calendar.set(Calendar.SECOND, value - 1); + dd = calendar.getTime(); + } + return dd; + + case DateTickUnit.MINUTE : + years = calendar.get(Calendar.YEAR); + months = calendar.get(Calendar.MONTH); + days = calendar.get(Calendar.DATE); + hours = calendar.get(Calendar.HOUR_OF_DAY); + if (this.tickMarkPosition == DateTickMarkPosition.START) { + seconds = 0; + } + else if (this.tickMarkPosition == DateTickMarkPosition.MIDDLE) { + seconds = 30; + } + else { + seconds = 59; + } + calendar.clear(Calendar.MILLISECOND); + calendar.set(years, months, days, hours, value, seconds); + Date d0 = calendar.getTime(); + if (d0.getTime() >= date.getTime()) { + calendar.set(Calendar.MINUTE, value - 1); + d0 = calendar.getTime(); + } + return d0; + + case DateTickUnit.HOUR : + years = calendar.get(Calendar.YEAR); + months = calendar.get(Calendar.MONTH); + days = calendar.get(Calendar.DATE); + if (this.tickMarkPosition == DateTickMarkPosition.START) { + minutes = 0; + seconds = 0; + } + else if (this.tickMarkPosition == DateTickMarkPosition.MIDDLE) { + minutes = 30; + seconds = 0; + } + else { + minutes = 59; + seconds = 59; + } + calendar.clear(Calendar.MILLISECOND); + calendar.set(years, months, days, value, minutes, seconds); + Date d1 = calendar.getTime(); + if (d1.getTime() >= date.getTime()) { + calendar.set(Calendar.HOUR_OF_DAY, value - 1); + d1 = calendar.getTime(); + } + return d1; + + case DateTickUnit.DAY : + years = calendar.get(Calendar.YEAR); + months = calendar.get(Calendar.MONTH); + if (this.tickMarkPosition == DateTickMarkPosition.START) { + hours = 0; + } + else if (this.tickMarkPosition == DateTickMarkPosition.MIDDLE) { + hours = 12; + } + else { + hours = 23; + } + calendar.clear(Calendar.MILLISECOND); + calendar.set(years, months, value, hours, 0, 0); + // long result = calendar.getTimeInMillis(); + // won't work with JDK 1.3 + Date d2 = calendar.getTime(); + if (d2.getTime() >= date.getTime()) { + calendar.set(Calendar.DATE, value - 1); + d2 = calendar.getTime(); + } + return d2; + + case DateTickUnit.MONTH : + years = calendar.get(Calendar.YEAR); + calendar.clear(Calendar.MILLISECOND); + calendar.set(years, value, 1, 0, 0, 0); + Month month = new Month(calendar.getTime(), this.timeZone, + this.locale); + Date standardDate = calculateDateForPosition( + month, this.tickMarkPosition); + long millis = standardDate.getTime(); + if (millis >= date.getTime()) { + month = (Month) month.previous(); + // need to peg the month in case the time zone isn't the + // default - see bug 2078057 + month.peg(Calendar.getInstance(this.timeZone)); + standardDate = calculateDateForPosition( + month, this.tickMarkPosition); + } + return standardDate; + + case DateTickUnit.YEAR : + if (this.tickMarkPosition == DateTickMarkPosition.START) { + months = 0; + days = 1; + } + else if (this.tickMarkPosition == DateTickMarkPosition.MIDDLE) { + months = 6; + days = 1; + } + else { + months = 11; + days = 31; + } + calendar.clear(Calendar.MILLISECOND); + calendar.set(value, months, days, 0, 0, 0); + Date d3 = calendar.getTime(); + if (d3.getTime() >= date.getTime()) { + calendar.set(Calendar.YEAR, value - 1); + d3 = calendar.getTime(); + } + return d3; + + default: return null; + + } + + } + + /** + * Returns a {@link java.util.Date} corresponding to the specified position + * within a {@link RegularTimePeriod}. + * + * @param period the period. + * @param position the position (null not permitted). + * + * @return A date. + */ + private Date calculateDateForPosition(RegularTimePeriod period, + DateTickMarkPosition position) { + ParamChecks.nullNotPermitted(period, "period"); + Date result = null; + if (position == DateTickMarkPosition.START) { + result = new Date(period.getFirstMillisecond()); + } + else if (position == DateTickMarkPosition.MIDDLE) { + result = new Date(period.getMiddleMillisecond()); + } + else if (position == DateTickMarkPosition.END) { + result = new Date(period.getLastMillisecond()); + } + return result; + + } + + /** + * Returns the first "standard" date (based on the specified field and + * units). + * + * @param date the reference date. + * @param unit the date tick unit. + * + * @return The next "standard" date. + */ + protected Date nextStandardDate(Date date, DateTickUnit unit) { + Date previous = previousStandardDate(date, unit); + Calendar calendar = Calendar.getInstance(this.timeZone, this.locale); + calendar.setTime(previous); + calendar.add(unit.getCalendarField(), unit.getMultiple()); + return calendar.getTime(); + } + + /** + * Returns a collection of standard date tick units that uses the default + * time zone. This collection will be used by default, but you are free + * to create your own collection if you want to (see the + * {@link ValueAxis#setStandardTickUnits(TickUnitSource)} method inherited + * from the {@link ValueAxis} class). + * + * @return A collection of standard date tick units. + */ + public static TickUnitSource createStandardDateTickUnits() { + return createStandardDateTickUnits(TimeZone.getDefault(), + Locale.getDefault()); + } + + /** + * Returns a collection of standard date tick units. This collection will + * be used by default, but you are free to create your own collection if + * you want to (see the + * {@link ValueAxis#setStandardTickUnits(TickUnitSource)} method inherited + * from the {@link ValueAxis} class). + * + * @param zone the time zone (null not permitted). + * @param locale the locale (null not permitted). + * + * @return A collection of standard date tick units. + * + * @since 1.0.11 + */ + public static TickUnitSource createStandardDateTickUnits(TimeZone zone, + Locale locale) { + + ParamChecks.nullNotPermitted(zone, "zone"); + ParamChecks.nullNotPermitted(locale, "locale"); + TickUnits units = new TickUnits(); + + // date formatters + DateFormat f1 = new SimpleDateFormat("HH:mm:ss.SSS", locale); + DateFormat f2 = new SimpleDateFormat("HH:mm:ss", locale); + DateFormat f3 = new SimpleDateFormat("HH:mm", locale); + DateFormat f4 = new SimpleDateFormat("d-MMM, HH:mm", locale); + DateFormat f5 = new SimpleDateFormat("d-MMM", locale); + DateFormat f6 = new SimpleDateFormat("MMM-yyyy", locale); + DateFormat f7 = new SimpleDateFormat("yyyy", locale); + + f1.setTimeZone(zone); + f2.setTimeZone(zone); + f3.setTimeZone(zone); + f4.setTimeZone(zone); + f5.setTimeZone(zone); + f6.setTimeZone(zone); + f7.setTimeZone(zone); + + // milliseconds + units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 1, f1)); + units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 5, + DateTickUnitType.MILLISECOND, 1, f1)); + units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 10, + DateTickUnitType.MILLISECOND, 1, f1)); + units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 25, + DateTickUnitType.MILLISECOND, 5, f1)); + units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 50, + DateTickUnitType.MILLISECOND, 10, f1)); + units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 100, + DateTickUnitType.MILLISECOND, 10, f1)); + units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 250, + DateTickUnitType.MILLISECOND, 10, f1)); + units.add(new DateTickUnit(DateTickUnitType.MILLISECOND, 500, + DateTickUnitType.MILLISECOND, 50, f1)); + + // seconds + units.add(new DateTickUnit(DateTickUnitType.SECOND, 1, + DateTickUnitType.MILLISECOND, 50, f2)); + units.add(new DateTickUnit(DateTickUnitType.SECOND, 5, + DateTickUnitType.SECOND, 1, f2)); + units.add(new DateTickUnit(DateTickUnitType.SECOND, 10, + DateTickUnitType.SECOND, 1, f2)); + units.add(new DateTickUnit(DateTickUnitType.SECOND, 30, + DateTickUnitType.SECOND, 5, f2)); + + // minutes + units.add(new DateTickUnit(DateTickUnitType.MINUTE, 1, + DateTickUnitType.SECOND, 5, f3)); + units.add(new DateTickUnit(DateTickUnitType.MINUTE, 2, + DateTickUnitType.SECOND, 10, f3)); + units.add(new DateTickUnit(DateTickUnitType.MINUTE, 5, + DateTickUnitType.MINUTE, 1, f3)); + units.add(new DateTickUnit(DateTickUnitType.MINUTE, 10, + DateTickUnitType.MINUTE, 1, f3)); + units.add(new DateTickUnit(DateTickUnitType.MINUTE, 15, + DateTickUnitType.MINUTE, 5, f3)); + units.add(new DateTickUnit(DateTickUnitType.MINUTE, 20, + DateTickUnitType.MINUTE, 5, f3)); + units.add(new DateTickUnit(DateTickUnitType.MINUTE, 30, + DateTickUnitType.MINUTE, 5, f3)); + + // hours + units.add(new DateTickUnit(DateTickUnitType.HOUR, 1, + DateTickUnitType.MINUTE, 5, f3)); + units.add(new DateTickUnit(DateTickUnitType.HOUR, 2, + DateTickUnitType.MINUTE, 10, f3)); + units.add(new DateTickUnit(DateTickUnitType.HOUR, 4, + DateTickUnitType.MINUTE, 30, f3)); + units.add(new DateTickUnit(DateTickUnitType.HOUR, 6, + DateTickUnitType.HOUR, 1, f3)); + units.add(new DateTickUnit(DateTickUnitType.HOUR, 12, + DateTickUnitType.HOUR, 1, f4)); + + // days + units.add(new DateTickUnit(DateTickUnitType.DAY, 1, + DateTickUnitType.HOUR, 1, f5)); + units.add(new DateTickUnit(DateTickUnitType.DAY, 2, + DateTickUnitType.HOUR, 1, f5)); + units.add(new DateTickUnit(DateTickUnitType.DAY, 7, + DateTickUnitType.DAY, 1, f5)); + units.add(new DateTickUnit(DateTickUnitType.DAY, 15, + DateTickUnitType.DAY, 1, f5)); + + // months + units.add(new DateTickUnit(DateTickUnitType.MONTH, 1, + DateTickUnitType.DAY, 1, f6)); + units.add(new DateTickUnit(DateTickUnitType.MONTH, 2, + DateTickUnitType.DAY, 1, f6)); + units.add(new DateTickUnit(DateTickUnitType.MONTH, 3, + DateTickUnitType.MONTH, 1, f6)); + units.add(new DateTickUnit(DateTickUnitType.MONTH, 4, + DateTickUnitType.MONTH, 1, f6)); + units.add(new DateTickUnit(DateTickUnitType.MONTH, 6, + DateTickUnitType.MONTH, 1, f6)); + + // years + units.add(new DateTickUnit(DateTickUnitType.YEAR, 1, + DateTickUnitType.MONTH, 1, f7)); + units.add(new DateTickUnit(DateTickUnitType.YEAR, 2, + DateTickUnitType.MONTH, 3, f7)); + units.add(new DateTickUnit(DateTickUnitType.YEAR, 5, + DateTickUnitType.YEAR, 1, f7)); + units.add(new DateTickUnit(DateTickUnitType.YEAR, 10, + DateTickUnitType.YEAR, 1, f7)); + units.add(new DateTickUnit(DateTickUnitType.YEAR, 25, + DateTickUnitType.YEAR, 5, f7)); + units.add(new DateTickUnit(DateTickUnitType.YEAR, 50, + DateTickUnitType.YEAR, 10, f7)); + units.add(new DateTickUnit(DateTickUnitType.YEAR, 100, + DateTickUnitType.YEAR, 20, f7)); + + return units; + + } + + /** + * Rescales the axis to ensure that all data is visible. + */ + @Override + 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) { + if (this.timeline instanceof SegmentedTimeline) { + //Timeline hasn't method getStartTime() + r = new DateRange(( + (SegmentedTimeline) this.timeline).getStartTime(), + ((SegmentedTimeline) this.timeline).getStartTime() + + 1); + } + else { + r = new DateRange(); + } + } + + long upper = this.timeline.toTimelineValue( + (long) r.getUpperBound()); + long lower; + long fixedAutoRange = (long) getFixedAutoRange(); + if (fixedAutoRange > 0.0) { + lower = upper - fixedAutoRange; + } + else { + lower = this.timeline.toTimelineValue((long) r.getLowerBound()); + double range = upper - lower; + long minRange = (long) getAutoRangeMinimumSize(); + if (range < minRange) { + long expand = (long) (minRange - range) / 2; + upper = upper + expand; + lower = lower - expand; + } + upper = upper + (long) (range * getUpperMargin()); + lower = lower - (long) (range * getLowerMargin()); + } + + upper = this.timeline.toMillisecond(upper); + lower = this.timeline.toMillisecond(lower); + DateRange dr = new DateRange(new Date(lower), new Date(upper)); + setRange(dr, false, false); + } + + } + + /** + * 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. + */ + 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 size for the axis. The strategy is to + * display as many ticks as possible (selected from a collection 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. + */ + protected void selectHorizontalAutoTickUnit(Graphics2D g2, + Rectangle2D dataArea, RectangleEdge edge) { + + long shift = 0; + if (this.timeline instanceof SegmentedTimeline) { + shift = ((SegmentedTimeline) this.timeline).getStartTime(); + } + double zero = valueToJava2D(shift + 0.0, dataArea, edge); + double tickLabelWidth = estimateMaximumTickLabelWidth(g2, + getTickUnit()); + + // start with the current tick unit... + TickUnitSource tickUnits = getStandardTickUnits(); + TickUnit unit1 = tickUnits.getCeilingTickUnit(getTickUnit()); + double x1 = valueToJava2D(shift + unit1.getSize(), dataArea, edge); + double unit1Width = Math.abs(x1 - zero); + + // then extrapolate... + double guess = (tickLabelWidth / unit1Width) * unit1.getSize(); + DateTickUnit unit2 = (DateTickUnit) tickUnits.getCeilingTickUnit(guess); + double x2 = valueToJava2D(shift + unit2.getSize(), dataArea, edge); + double unit2Width = Math.abs(x2 - zero); + tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2); + if (tickLabelWidth > unit2Width) { + unit2 = (DateTickUnit) tickUnits.getLargerTickUnit(unit2); + } + setTickUnit(unit2, false, false); + } + + /** + * Selects an appropriate tick size for the axis. The strategy is to + * display as many ticks as possible (selected from a collection 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. + */ + protected void selectVerticalAutoTickUnit(Graphics2D g2, + Rectangle2D dataArea, RectangleEdge edge) { + + // start with the current tick unit... + TickUnitSource tickUnits = getStandardTickUnits(); + double zero = valueToJava2D(0.0, dataArea, edge); + + // start with a unit that is at least 1/10th of the axis length + double estimate1 = getRange().getLength() / 10.0; + DateTickUnit candidate1 + = (DateTickUnit) tickUnits.getCeilingTickUnit(estimate1); + double labelHeight1 = estimateMaximumTickLabelHeight(g2, candidate1); + double y1 = valueToJava2D(candidate1.getSize(), dataArea, edge); + double candidate1UnitHeight = Math.abs(y1 - zero); + + // now extrapolate based on label height and unit height... + double estimate2 + = (labelHeight1 / candidate1UnitHeight) * candidate1.getSize(); + DateTickUnit candidate2 + = (DateTickUnit) tickUnits.getCeilingTickUnit(estimate2); + double labelHeight2 = estimateMaximumTickLabelHeight(g2, candidate2); + double y2 = valueToJava2D(candidate2.getSize(), dataArea, edge); + double unit2Height = Math.abs(y2 - zero); + + // make final selection... + DateTickUnit finalUnit; + if (labelHeight2 < unit2Height) { + finalUnit = candidate2; + } + else { + finalUnit = (DateTickUnit) tickUnits.getLargerTickUnit(candidate2); + } + setTickUnit(finalUnit, false, false); + + } + + /** + * Estimates the maximum width of the tick labels, assuming the specified + * tick unit is used. + *

+ * 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. + */ + private double estimateMaximumTickLabelWidth(Graphics2D g2, + DateTickUnit unit) { + + RectangleInsets tickLabelInsets = getTickLabelInsets(); + double result = tickLabelInsets.getLeft() + tickLabelInsets.getRight(); + + Font tickLabelFont = getTickLabelFont(); + FontRenderContext frc = g2.getFontRenderContext(); + LineMetrics lm = tickLabelFont.getLineMetrics("ABCxyz", frc); + if (isVerticalTickLabels()) { + // all tick labels have the same width (equal to the height of + // the font)... + result += lm.getHeight(); + } + else { + // look at lower and upper bounds... + DateRange range = (DateRange) getRange(); + Date lower = range.getLowerDate(); + Date upper = range.getUpperDate(); + String lowerStr, upperStr; + DateFormat formatter = getDateFormatOverride(); + if (formatter != null) { + lowerStr = formatter.format(lower); + upperStr = formatter.format(upper); + } + else { + lowerStr = unit.dateToString(lower); + upperStr = unit.dateToString(upper); + } + FontMetrics fm = g2.getFontMetrics(tickLabelFont); + double w1 = fm.stringWidth(lowerStr); + double w2 = fm.stringWidth(upperStr); + result += Math.max(w1, w2); + } + + return result; + + } + + /** + * Estimates the maximum width of the tick labels, assuming the specified + * tick unit is used. + *

+ * 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. + */ + private double estimateMaximumTickLabelHeight(Graphics2D g2, + DateTickUnit unit) { + + RectangleInsets tickLabelInsets = getTickLabelInsets(); + double result = tickLabelInsets.getTop() + tickLabelInsets.getBottom(); + + Font tickLabelFont = getTickLabelFont(); + FontRenderContext frc = g2.getFontRenderContext(); + LineMetrics lm = tickLabelFont.getLineMetrics("ABCxyz", frc); + if (!isVerticalTickLabels()) { + // all tick labels have the same width (equal to the height of + // the font)... + result += lm.getHeight(); + } + else { + // look at lower and upper bounds... + DateRange range = (DateRange) getRange(); + Date lower = range.getLowerDate(); + Date upper = range.getUpperDate(); + String lowerStr, upperStr; + DateFormat formatter = getDateFormatOverride(); + if (formatter != null) { + lowerStr = formatter.format(lower); + upperStr = formatter.format(upper); + } + else { + lowerStr = unit.dateToString(lower); + upperStr = unit.dateToString(upper); + } + FontMetrics fm = g2.getFontMetrics(tickLabelFont); + double w1 = fm.stringWidth(lowerStr); + double w2 = fm.stringWidth(upperStr); + result += Math.max(w1, w2); + } + + return result; + + } + + /** + * 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. + */ + @Override + public List refreshTicks(Graphics2D g2, AxisState state, + Rectangle2D dataArea, RectangleEdge edge) { + + List result = null; + if (RectangleEdge.isTopOrBottom(edge)) { + result = refreshTicksHorizontal(g2, dataArea, edge); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + result = refreshTicksVertical(g2, dataArea, edge); + } + return result; + + } + + /** + * Corrects the given tick date for the position setting. + * + * @param time the tick date/time. + * @param unit the tick unit. + * @param position the tick position. + * + * @return The adjusted time. + */ + private Date correctTickDateForPosition(Date time, DateTickUnit unit, + DateTickMarkPosition position) { + Date result = time; + switch (unit.getUnit()) { + case DateTickUnit.MILLISECOND : + case DateTickUnit.SECOND : + case DateTickUnit.MINUTE : + case DateTickUnit.HOUR : + case DateTickUnit.DAY : + break; + case DateTickUnit.MONTH : + result = calculateDateForPosition(new Month(time, + this.timeZone, this.locale), position); + break; + case DateTickUnit.YEAR : + result = calculateDateForPosition(new Year(time, + this.timeZone, this.locale), position); + break; + + default: break; + } + return result; + } + + /** + * Recalculates the ticks for the date axis. + * + * @param g2 the graphics device. + * @param dataArea the area in which the data is to be drawn. + * @param edge the location of the axis. + * + * @return A list of ticks. + */ + protected List refreshTicksHorizontal(Graphics2D g2, + Rectangle2D dataArea, RectangleEdge edge) { + + List result = new java.util.ArrayList(); + + Font tickLabelFont = getTickLabelFont(); + g2.setFont(tickLabelFont); + + if (isAutoTickUnitSelection()) { + selectAutoTickUnit(g2, dataArea, edge); + } + + DateTickUnit unit = getTickUnit(); + Date tickDate = calculateLowestVisibleTickValue(unit); + Date upperDate = getMaximumDate(); + + boolean hasRolled = false; + while (tickDate.before(upperDate)) { + // could add a flag to make the following correction optional... + if (!hasRolled) { + tickDate = correctTickDateForPosition(tickDate, unit, + this.tickMarkPosition); + } + + long lowestTickTime = tickDate.getTime(); + long distance = unit.addToDate(tickDate, this.timeZone).getTime() + - lowestTickTime; + int minorTickSpaces = getMinorTickCount(); + if (minorTickSpaces <= 0) { + minorTickSpaces = unit.getMinorTickCount(); + } + for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) { + long minorTickTime = lowestTickTime - distance + * minorTick / minorTickSpaces; + if (minorTickTime > 0 && getRange().contains(minorTickTime) + && (!isHiddenValue(minorTickTime))) { + result.add(new DateTick(TickType.MINOR, + new Date(minorTickTime), "", TextAnchor.TOP_CENTER, + TextAnchor.CENTER, 0.0)); + } + } + + if (!isHiddenValue(tickDate.getTime())) { + // work out the value, label and position + String tickLabel; + DateFormat formatter = getDateFormatOverride(); + if (formatter != null) { + tickLabel = formatter.format(tickDate); + } + else { + tickLabel = this.tickUnit.dateToString(tickDate); + } + TextAnchor anchor, rotationAnchor; + double angle = 0.0; + if (isVerticalTickLabels()) { + anchor = TextAnchor.CENTER_RIGHT; + rotationAnchor = TextAnchor.CENTER_RIGHT; + if (edge == RectangleEdge.TOP) { + angle = Math.PI / 2.0; + } + else { + angle = -Math.PI / 2.0; + } + } + else { + if (edge == RectangleEdge.TOP) { + anchor = TextAnchor.BOTTOM_CENTER; + rotationAnchor = TextAnchor.BOTTOM_CENTER; + } + else { + anchor = TextAnchor.TOP_CENTER; + rotationAnchor = TextAnchor.TOP_CENTER; + } + } + + Tick tick = new DateTick(tickDate, tickLabel, anchor, + rotationAnchor, angle); + result.add(tick); + hasRolled = false; + + long currentTickTime = tickDate.getTime(); + tickDate = unit.addToDate(tickDate, this.timeZone); + long nextTickTime = tickDate.getTime(); + for (int minorTick = 1; minorTick < minorTickSpaces; + minorTick++) { + long minorTickTime = currentTickTime + + (nextTickTime - currentTickTime) + * minorTick / minorTickSpaces; + if (getRange().contains(minorTickTime) + && (!isHiddenValue(minorTickTime))) { + result.add(new DateTick(TickType.MINOR, + new Date(minorTickTime), "", + TextAnchor.TOP_CENTER, TextAnchor.CENTER, + 0.0)); + } + } + + } + else { + tickDate = unit.rollDate(tickDate, this.timeZone); + hasRolled = true; + continue; + } + + } + return result; + + } + + /** + * Recalculates the ticks for the date axis. + * + * @param g2 the graphics device. + * @param dataArea the area in which the plot should be drawn. + * @param edge the location of the axis. + * + * @return A list of ticks. + */ + protected List refreshTicksVertical(Graphics2D g2, + Rectangle2D dataArea, RectangleEdge edge) { + + List result = new java.util.ArrayList(); + + Font tickLabelFont = getTickLabelFont(); + g2.setFont(tickLabelFont); + + if (isAutoTickUnitSelection()) { + selectAutoTickUnit(g2, dataArea, edge); + } + DateTickUnit unit = getTickUnit(); + Date tickDate = calculateLowestVisibleTickValue(unit); + Date upperDate = getMaximumDate(); + + boolean hasRolled = false; + while (tickDate.before(upperDate)) { + + // could add a flag to make the following correction optional... + if (!hasRolled) { + tickDate = correctTickDateForPosition(tickDate, unit, + this.tickMarkPosition); + } + + long lowestTickTime = tickDate.getTime(); + long distance = unit.addToDate(tickDate, this.timeZone).getTime() + - lowestTickTime; + int minorTickSpaces = getMinorTickCount(); + if (minorTickSpaces <= 0) { + minorTickSpaces = unit.getMinorTickCount(); + } + for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) { + long minorTickTime = lowestTickTime - distance + * minorTick / minorTickSpaces; + if (minorTickTime > 0 && getRange().contains(minorTickTime) + && (!isHiddenValue(minorTickTime))) { + result.add(new DateTick(TickType.MINOR, + new Date(minorTickTime), "", TextAnchor.TOP_CENTER, + TextAnchor.CENTER, 0.0)); + } + } + if (!isHiddenValue(tickDate.getTime())) { + // work out the value, label and position + String tickLabel; + DateFormat formatter = getDateFormatOverride(); + if (formatter != null) { + tickLabel = formatter.format(tickDate); + } + else { + tickLabel = this.tickUnit.dateToString(tickDate); + } + TextAnchor anchor, rotationAnchor; + double angle = 0.0; + if (isVerticalTickLabels()) { + anchor = TextAnchor.BOTTOM_CENTER; + rotationAnchor = TextAnchor.BOTTOM_CENTER; + if (edge == RectangleEdge.LEFT) { + angle = -Math.PI / 2.0; + } + else { + angle = Math.PI / 2.0; + } + } + else { + if (edge == RectangleEdge.LEFT) { + anchor = TextAnchor.CENTER_RIGHT; + rotationAnchor = TextAnchor.CENTER_RIGHT; + } + else { + anchor = TextAnchor.CENTER_LEFT; + rotationAnchor = TextAnchor.CENTER_LEFT; + } + } + + Tick tick = new DateTick(tickDate, tickLabel, anchor, + rotationAnchor, angle); + result.add(tick); + hasRolled = false; + + long currentTickTime = tickDate.getTime(); + tickDate = unit.addToDate(tickDate, this.timeZone); + long nextTickTime = tickDate.getTime(); + for (int minorTick = 1; minorTick < minorTickSpaces; + minorTick++) { + long minorTickTime = currentTickTime + + (nextTickTime - currentTickTime) + * minorTick / minorTickSpaces; + if (getRange().contains(minorTickTime) + && (!isHiddenValue(minorTickTime))) { + result.add(new DateTick(TickType.MINOR, + new Date(minorTickTime), "", + TextAnchor.TOP_CENTER, TextAnchor.CENTER, + 0.0)); + } + } + } + else { + tickDate = unit.rollDate(tickDate, this.timeZone); + hasRolled = true; + } + } + return result; + } + + /** + * Draws the axis on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device (null not permitted). + * @param cursor the cursor location. + * @param plotArea the area within which the axes and data should be + * drawn (null not permitted). + * @param dataArea the area within which the data should be drawn + * (null not permitted). + * @param edge the location of the axis (null not permitted). + * @param plotState collects information about the plot + * (null permitted). + * + * @return The axis state (never null). + */ + @Override + 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()) { + AxisState state = new AxisState(cursor); + // even though the axis is not visible, we need to refresh ticks in + // case the grid is being drawn... + List ticks = refreshTicks(g2, state, dataArea, edge); + state.setTicks(ticks); + return state; + } + + // draw the tick marks and labels... + AxisState state = drawTickMarksAndLabels(g2, cursor, plotArea, + dataArea, edge); + + // draw the axis label (note that 'state' is passed in *and* + // returned)... + if (getAttributedLabel() != null) { + state = drawAttributedLabel(getAttributedLabel(), g2, plotArea, + dataArea, edge, state); + + } else { + state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); + } + createAndAddEntity(cursor, state, dataArea, edge, plotState); + return state; + + } + + /** + * Zooms in on the current range (zoom-in stops once the axis length + * reaches the equivalent of one millisecond). + * + * @param lowerPercent the new lower bound. + * @param upperPercent the new upper bound. + */ + @Override + public void zoomRange(double lowerPercent, double upperPercent) { + double start = this.timeline.toTimelineValue( + (long) getRange().getLowerBound()); + double end = this.timeline.toTimelineValue( + (long) getRange().getUpperBound()); + double length = end - start; + Range adjusted; + long adjStart, adjEnd; + if (isInverted()) { + adjStart = (long) (start + (length * (1 - upperPercent))); + adjEnd = (long) (start + (length * (1 - lowerPercent))); + } + else { + adjStart = (long) (start + length * lowerPercent); + adjEnd = (long) (start + length * upperPercent); + } + // when zooming to sub-millisecond ranges, it can be the case that + // adjEnd == adjStart...and we can't have an axis with zero length + // so we apply this instead: + if (adjEnd <= adjStart) { + adjEnd = adjStart + 1L; + } + adjusted = new DateRange(this.timeline.toMillisecond(adjStart), + this.timeline.toMillisecond(adjEnd)); + setRange(adjusted); + } + + /** + * Tests this axis for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DateAxis)) { + return false; + } + DateAxis that = (DateAxis) obj; + if (!ObjectUtilities.equal(this.tickUnit, that.tickUnit)) { + return false; + } + if (!ObjectUtilities.equal(this.dateFormatOverride, + that.dateFormatOverride)) { + return false; + } + if (!ObjectUtilities.equal(this.tickMarkPosition, + that.tickMarkPosition)) { + return false; + } + if (!ObjectUtilities.equal(this.timeline, that.timeline)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this object. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return super.hashCode(); + } + + /** + * Returns a clone of the object. + * + * @return A clone. + * + * @throws CloneNotSupportedException if some component of the axis does + * not support cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DateAxis clone = (DateAxis) super.clone(); + // 'dateTickUnit' is immutable : no need to clone + if (this.dateFormatOverride != null) { + clone.dateFormatOverride + = (DateFormat) this.dateFormatOverride.clone(); + } + // 'tickMarkPosition' is immutable : no need to clone + return clone; + } + + /** + * Returns a collection of standard date tick units. This collection will + * be used by default, but you are free to create your own collection if + * you want to (see the + * {@link ValueAxis#setStandardTickUnits(TickUnitSource)} method inherited + * from the {@link ValueAxis} class). + * + * @param zone the time zone (null not permitted). + * + * @return A collection of standard date tick units. + * + * @deprecated Since 1.0.11, use {@link #createStandardDateTickUnits( + * TimeZone, Locale)} to explicitly set the locale as well as the + * time zone. + */ + public static TickUnitSource createStandardDateTickUnits(TimeZone zone) { + return createStandardDateTickUnits(zone, Locale.getDefault()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateTick.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateTick.java new file mode 100755 index 0000000..cfb7138 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateTick.java @@ -0,0 +1,141 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * DateTick.java + * ------------- + * (C) Copyright 2003-2009, 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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. + */ + @Override + public int hashCode() { + return this.date.hashCode(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateTickMarkPosition.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateTickMarkPosition.java new file mode 100755 index 0000000..9ccaa9c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateTickMarkPosition.java @@ -0,0 +1,135 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * 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. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + 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; + } + + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateTickUnit.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateTickUnit.java new file mode 100755 index 0000000..82c9b5f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateTickUnit.java @@ -0,0 +1,652 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * DateTickUnit.java + * ----------------- + * (C) Copyright 2000-2013, 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); + * 09-Jan-2009 : Replaced the unit and rollUnit fields with an enumerated + * type (DG); + * 02-Jul-2013 : Use ParamChecks (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.chart.util.ParamChecks; + +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; + + /** + * The units. + * + * @since 1.0.13 + */ + private DateTickUnitType unitType; + + /** The unit count. */ + private int count; + + /** + * The roll unit type. + * + * @since 1.0.13 + */ + private DateTickUnitType rollUnitType; + + /** The roll count. */ + private int rollCount; + + /** The date formatter. */ + private DateFormat formatter; + + /** + * Creates a new date tick unit. + * + * @param unitType the unit type (null not permitted). + * @param multiple the multiple (of the unit type, must be > 0). + * + * @since 1.0.13 + */ + public DateTickUnit(DateTickUnitType unitType, int multiple) { + this(unitType, multiple, DateFormat.getDateInstance(DateFormat.SHORT)); + } + + /** + * Creates a new date tick unit. + * + * @param unitType the unit type (null not permitted). + * @param multiple the multiple (of the unit type, must be > 0). + * @param formatter the date formatter (null not permitted). + * + * @since 1.0.13 + */ + public DateTickUnit(DateTickUnitType unitType, int multiple, + DateFormat formatter) { + this(unitType, multiple, unitType, multiple, formatter); + } + + /** + * Creates a new unit. + * + * @param unitType the unit. + * @param multiple the multiple. + * @param rollUnitType the roll unit. + * @param rollMultiple the roll multiple. + * @param formatter the date formatter (null not permitted). + * + * @since 1.0.13 + */ + public DateTickUnit(DateTickUnitType unitType, int multiple, + DateTickUnitType rollUnitType, int rollMultiple, + DateFormat formatter) { + super(DateTickUnit.getMillisecondCount(unitType, multiple)); + ParamChecks.nullNotPermitted(formatter, "formatter"); + if (multiple <= 0) { + throw new IllegalArgumentException("Requires 'multiple' > 0."); + } + if (rollMultiple <= 0) { + throw new IllegalArgumentException("Requires 'rollMultiple' > 0."); + } + this.unitType = unitType; + this.count = multiple; + this.rollUnitType = rollUnitType; + this.rollCount = rollMultiple; + this.formatter = formatter; + + // populate deprecated fields + this.unit = unitTypeToInt(unitType); + this.rollUnit = unitTypeToInt(rollUnitType); + } + + /** + * Returns the unit type. + * + * @return The unit type (never null). + * + * @since 1.0.13 + */ + public DateTickUnitType getUnitType() { + return this.unitType; + } + + /** + * Returns the unit multiple. + * + * @return The unit multiple (always > 0). + */ + public int getMultiple() { + return this.count; + } + + /** + * Returns the roll unit type. + * + * @return The roll unit type (never null). + * + * @since 1.0.13 + */ + public DateTickUnitType getRollUnitType() { + return this.rollUnitType; + } + + /** + * Returns the roll unit multiple. + * + * @return The roll unit multiple. + * + * @since 1.0.13 + */ + public int getRollMultiple() { + return this.rollCount; + } + + /** + * Formats a value. + * + * @param milliseconds date in milliseconds since 01-01-1970. + * + * @return The formatted date. + */ + @Override + 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. + * + * @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(this.unitType.getCalendarField(), 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(this.rollUnitType.getCalendarField(), this.rollCount); + return calendar.getTime(); + } + + /** + * Returns a field code that can be used with the Calendar + * class. + * + * @return The field code. + */ + public int getCalendarField() { + return this.unitType.getCalendarField(); + } + + /** + * Returns the (approximate) number of milliseconds for the given unit and + * unit count. + *

+ * 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. + * + * @since 1.0.13 + */ + private static long getMillisecondCount(DateTickUnitType unit, int count) { + + if (unit.equals(DateTickUnitType.YEAR)) { + return (365L * 24L * 60L * 60L * 1000L) * count; + } + else if (unit.equals(DateTickUnitType.MONTH)) { + return (31L * 24L * 60L * 60L * 1000L) * count; + } + else if (unit.equals(DateTickUnitType.DAY)) { + return (24L * 60L * 60L * 1000L) * count; + } + else if (unit.equals(DateTickUnitType.HOUR)) { + return (60L * 60L * 1000L) * count; + } + else if (unit.equals(DateTickUnitType.MINUTE)) { + return (60L * 1000L) * count; + } + else if (unit.equals(DateTickUnitType.SECOND)) { + return 1000L * count; + } + else if (unit.equals(DateTickUnitType.MILLISECOND)) { + return count; + } + else { + throw new IllegalArgumentException("The 'unit' argument has a " + + "value that is not recognised."); + } + + } + + /** + * A utility method that is used internally to convert the old unit + * constants into the corresponding enumerated value. + * + * @param unit the unit specified using the deprecated integer codes. + * + * @return The unit type. + * + * @since 1.0.13 + */ + private static DateTickUnitType intToUnitType(int unit) { + switch (unit) { + case YEAR: return DateTickUnitType.YEAR; + case MONTH: return DateTickUnitType.MONTH; + case DAY: return DateTickUnitType.DAY; + case HOUR: return DateTickUnitType.HOUR; + case MINUTE: return DateTickUnitType.MINUTE; + case SECOND: return DateTickUnitType.SECOND; + case MILLISECOND: return DateTickUnitType.MILLISECOND; + default: throw new IllegalArgumentException( + "Unrecognised 'unit' value " + unit + "."); + } + } + + /** + * Converts a unit type to the corresponding deprecated integer constant. + * + * @param unitType the unit type (null not permitted). + * + * @return The int code. + * + * @since 1.0.13 + */ + private static int unitTypeToInt(DateTickUnitType unitType) { + ParamChecks.nullNotPermitted(unitType, "unitType"); + if (unitType.equals(DateTickUnitType.YEAR)) { + return YEAR; + } + else if (unitType.equals(DateTickUnitType.MONTH)) { + return MONTH; + } + else if (unitType.equals(DateTickUnitType.DAY)) { + return DAY; + } + else if (unitType.equals(DateTickUnitType.HOUR)) { + return HOUR; + } + else if (unitType.equals(DateTickUnitType.MINUTE)) { + return MINUTE; + } + else if (unitType.equals(DateTickUnitType.SECOND)) { + return SECOND; + } + else if (unitType.equals(DateTickUnitType.MILLISECOND)) { + return MILLISECOND; + } + else { + throw new IllegalArgumentException( + "The 'unitType' is not recognised"); + } + } + + /** + * A utility method to put a default in place if a null formatter is + * supplied. + * + * @param formatter the formatter (null permitted). + * + * @return The formatter if it is not null, otherwise a default. + */ + private static DateFormat notNull(DateFormat formatter) { + if (formatter == null) { + return DateFormat.getDateInstance(DateFormat.SHORT); + } + else { + return formatter; + } + } + + /** + * Tests this unit for equality with another object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + 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.unitType.equals(that.unitType))) { + 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. + */ + @Override + public int hashCode() { + int result = 19; + result = 37 * result + this.unitType.hashCode(); + result = 37 * result + this.count; + result = 37 * result + this.formatter.hashCode(); + return result; + } + + /** + * Returns a string representation of this instance, primarily used for + * debugging purposes. + * + * @return A string representation of this instance. + */ + @Override + public String toString() { + return "DateTickUnit[" + this.unitType.toString() + ", " + + this.count + "]"; + } + + /** + * A constant for years. + * + * @deprecated As of version 1.0.13, use {@link DateTickUnitType} instead. + */ + public static final int YEAR = 0; + + /** + * A constant for months. + * + * @deprecated As of version 1.0.13, use {@link DateTickUnitType} instead. + */ + public static final int MONTH = 1; + + /** + * A constant for days. + * + * @deprecated As of version 1.0.13, use {@link DateTickUnitType} instead. + */ + public static final int DAY = 2; + + /** + * A constant for hours. + * + * @deprecated As of version 1.0.13, use {@link DateTickUnitType} instead. + */ + public static final int HOUR = 3; + + /** + * A constant for minutes. + * + * @deprecated As of version 1.0.13, use {@link DateTickUnitType} instead. + */ + public static final int MINUTE = 4; + + /** + * A constant for seconds. + * + * @deprecated As of version 1.0.13, use {@link DateTickUnitType} instead. + */ + public static final int SECOND = 5; + + /** + * A constant for milliseconds. + * + * @deprecated As of version 1.0.13, use {@link DateTickUnitType} instead. + */ + public static final int MILLISECOND = 6; + + /** + * The unit. + * + * @deprecated As of version 1.0.13, use the unitType field. + */ + private int unit; + + /** + * The roll unit. + * + * @deprecated As of version 1.0.13, use the rollUnitType field. + */ + private int rollUnit; + + /** + * 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). + * + * @deprecated As of version 1.0.13, use {@link #DateTickUnit( + * DateTickUnitType, int, DateFormat)}. + */ + public DateTickUnit(int unit, int count, DateFormat formatter) { + this(unit, count, unit, count, 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. + * + * @deprecated As of version 1.0.13, use {@link #DateTickUnit( + * DateTickUnitType, int)}. + */ + public DateTickUnit(int unit, int count) { + this(unit, count, null); + } + + /** + * 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). + * + * @deprecated As of version 1.0.13, use {@link #DateTickUnit( + * DateTickUnitType, int, DateTickUnitType, int, DateFormat)}. + */ + public DateTickUnit(int unit, int count, int rollUnit, int rollCount, + DateFormat formatter) { + this(intToUnitType(unit), count, intToUnitType(rollUnit), rollCount, + notNull(formatter)); + } + + /** + * Returns the date unit. This will be one of the constants + * YEAR, MONTH, DAY, + * HOUR, MINUTE, SECOND or + * MILLISECOND, defined by this class. Note that these + * constants do NOT correspond to those defined in Java's + * Calendar class. + * + * @return The date unit. + * + * @deprecated As of 1.0.13, use the getUnitType() method. + */ + public int getUnit() { + return this.unit; + } + + /** + * Returns the unit count. + * + * @return The unit count. + * + * @deprecated As of version 1.0.13, use {@link #getMultiple()}. + */ + 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. + * + * @deprecated As of version 1.0.13, use {@link #getRollUnitType()}. + */ + public int getRollUnit() { + return this.rollUnit; + } + + /** + * Returns the roll count. + * + * @return The roll count. + * + * @deprecated As of version 1.0.13, use the {@link #getRollMultiple()} + * + */ + public int getRollCount() { + return this.rollCount; + } + + /** + * 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()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateTickUnitType.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateTickUnitType.java new file mode 100755 index 0000000..3d8b477 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/DateTickUnitType.java @@ -0,0 +1,176 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * DateTickUnitType.java + * --------------------- + * (C) Copyright 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 09-Jan-2009 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.ObjectStreamException; +import java.io.Serializable; +import java.util.Calendar; + +/** + * An enumeration of the unit types for a {@link DateTickUnit} instance. + * + * @since 1.0.13 + */ +public class DateTickUnitType implements Serializable { + + /** Year. */ + public static final DateTickUnitType YEAR + = new DateTickUnitType("DateTickUnitType.YEAR", Calendar.YEAR); + + /** Month. */ + public static final DateTickUnitType MONTH + = new DateTickUnitType("DateTickUnitType.MONTH", Calendar.MONTH); + + /** Day. */ + public static final DateTickUnitType DAY + = new DateTickUnitType("DateTickUnitType.DAY", Calendar.DATE); + + + /** Hour. */ + public static final DateTickUnitType HOUR + = new DateTickUnitType("DateTickUnitType.HOUR", + Calendar.HOUR_OF_DAY); + + /** Minute. */ + public static final DateTickUnitType MINUTE + = new DateTickUnitType("DateTickUnitType.MINUTE", Calendar.MINUTE); + + /** Second. */ + public static final DateTickUnitType SECOND + = new DateTickUnitType("DateTickUnitType.SECOND", Calendar.SECOND); + + /** Millisecond. */ + public static final DateTickUnitType MILLISECOND + = new DateTickUnitType("DateTickUnitType.MILLISECOND", + Calendar.MILLISECOND); + + /** The name. */ + private String name; + + /** The corresponding field value in Java's Calendar class. */ + private int calendarField; + + /** + * Private constructor. + * + * @param name the name. + * @param calendarField the calendar field. + */ + private DateTickUnitType(String name, int calendarField) { + this.name = name; + this.calendarField = calendarField; + } + + /** + * Returns the calendar field. + * + * @return The calendar field. + */ + public int getCalendarField() { + return this.calendarField; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof DateTickUnitType)) { + return false; + } + DateTickUnitType t = (DateTickUnitType) 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(DateTickUnitType.YEAR)) { + return DateTickUnitType.YEAR; + } + else if (this.equals(DateTickUnitType.MONTH)) { + return DateTickUnitType.MONTH; + } + else if (this.equals(DateTickUnitType.DAY)) { + return DateTickUnitType.DAY; + } + else if (this.equals(DateTickUnitType.HOUR)) { + return DateTickUnitType.HOUR; + } + else if (this.equals(DateTickUnitType.MINUTE)) { + return DateTickUnitType.MINUTE; + } + else if (this.equals(DateTickUnitType.SECOND)) { + return DateTickUnitType.SECOND; + } + else if (this.equals(DateTickUnitType.MILLISECOND)) { + return DateTickUnitType.MILLISECOND; + } + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ExtendedCategoryAxis.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ExtendedCategoryAxis.java new file mode 100755 index 0000000..30bf41c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ExtendedCategoryAxis.java @@ -0,0 +1,259 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * ExtendedCategoryAxis.java + * ------------------------- + * (C) Copyright 2003-2013, 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); + * 02-Jul-2013 : Use ParamChecks (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.chart.util.ParamChecks; +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 null). + * + * @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 (null not permitted). + * + * @see #getSubLabelFont() + */ + public void setSubLabelFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.sublabelFont = font; + notifyListeners(new AxisChangeEvent(this)); + } + + /** + * Returns the paint for the sublabels. + * + * @return The paint (never null). + * + * @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 (null not permitted). + * + * @see #getSubLabelPaint() + */ + public void setSubLabelPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + 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. + */ + @Override + 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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. + */ + @Override + 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/LogAxis.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/LogAxis.java new file mode 100755 index 0000000..679d7ff --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/LogAxis.java @@ -0,0 +1,944 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------ + * LogAxis.java + * ------------ + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Andrew Mickish (patch 1868745); + * Peter Kolb (patches 1934255 and 2603321); + * + * 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); + * 14-Jan-2009 : Fetch minor ticks from TickUnit, and corrected + * createLogTickUnits() (DG); + * 21-Jan-2009 : No need to call setMinorTickCount() in constructor (DG); + * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); + * 30-Mar-2009 : Added pan(double) method (DG); + * 28-Oct-2011 : Fixed endless loop for 0 TickUnit, # 3429707 (MH); + * 02-Jul-2013 : Use ParamChecks (DG); + * 01-Aug-2013 : Added attributedLabel override to support superscripts, + * subscripts and more (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.chart.util.LogFormat; +import org.jfree.chart.util.ParamChecks; +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 LogAxis with no label. + */ + public LogAxis() { + this(null); + } + + /** + * Creates a new LogAxis with the given label. + * + * @param label the axis label (null 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.#"), 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); + fireChangeEvent(); + } + + /** + * 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; + fireChangeEvent(); + } + + /** + * 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 (null 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 (null 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) { + + ParamChecks.nullNotPermitted(unit, "unit"); + this.tickUnit = unit; + if (turnOffAutoSelect) { + setAutoTickUnitSelection(false, false); + } + if (notify) { + fireChangeEvent(); + } + + } + + /** + * 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 null). + * + * @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 (null permitted). + * + * @see #getNumberFormatOverride() + */ + public void setNumberFormatOverride(NumberFormat formatter) { + this.numberFormatOverride = formatter; + fireChangeEvent(); + } + + /** + * 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 edge of the area. + * + * @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. + */ + @Override + 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; + 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 area, based on the axis running along the + * specified edge. + * + * @param value the data value. + * @param area the area. + * @param edge the edge. + * + * @return The Java2D coordinate corresponding to value. + */ + @Override + 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. + */ + @Override + public void configure() { + if (isAutoRange()) { + autoAdjustRange(); + } + } + + /** + * Adjusts the axis range to match the data range that the axis is + * required to display. + */ + @Override + 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 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 (null 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 (null not permitted). + * @param plotState collects information about the plot + * (null permitted). + * + * @return The axis state (never null). + */ + @Override + public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, + Rectangle2D dataArea, RectangleEdge edge, + PlotRenderingInfo plotState) { + + AxisState state; + // 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); + if (getAttributedLabel() != null) { + state = drawAttributedLabel(getAttributedLabel(), g2, plotArea, + dataArea, edge, state); + + } else { + state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); + } + createAndAddEntity(cursor, state, dataArea, edge, plotState); + 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. + * + */ + @Override + 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); + } + int minorTickCount = this.tickUnit.getMinorTickCount(); + double start = Math.floor(calculateLog(getLowerBound())); + double end = Math.ceil(calculateLog(getUpperBound())); + double current = start; + boolean hasTicks = (this.tickUnit.getSize() > 0.0) + && !Double.isInfinite(start); + while (hasTicks && 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 < minorTickCount; i++) { + double minorV = v + i * ((next - v) / minorTickCount); + 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); + } + int minorTickCount = this.tickUnit.getMinorTickCount(); + double start = Math.floor(calculateLog(getLowerBound())); + double end = Math.ceil(calculateLog(getUpperBound())); + double current = start; + boolean hasTicks = (this.tickUnit.getSize() > 0.0) + && !Double.isInfinite(start); + while (hasTicks && 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 < minorTickCount; i++) { + double minorV = v + i * ((next - v) / minorTickCount); + 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. + *

+ * 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, 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. + */ + @Override + 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; + 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); + } + + /** + * Slides the axis range by the specified percentage. + * + * @param percent the percentage. + * + * @since 1.0.13 + */ + @Override + public void pan(double percent) { + Range range = getRange(); + double lower = range.getLowerBound(); + double upper = range.getUpperBound(); + double log1 = calculateLog(lower); + double log2 = calculateLog(upper); + double length = log2 - log1; + double adj = length * percent; + log1 = log1 + adj; + log2 = log2 + adj; + setRange(calculateValue(log1), calculateValue(log2)); + } + + /** + * 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 (null permitted). + * + * @return A boolean. + */ + @Override + 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. + */ + @Override + 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 = new LogFormat(); + units.add(new NumberTickUnit(0.05, numberFormat, 2)); + units.add(new NumberTickUnit(0.1, numberFormat, 10)); + units.add(new NumberTickUnit(0.2, numberFormat, 2)); + units.add(new NumberTickUnit(0.5, numberFormat, 5)); + units.add(new NumberTickUnit(1, numberFormat, 10)); + units.add(new NumberTickUnit(2, numberFormat, 10)); + units.add(new NumberTickUnit(3, numberFormat, 15)); + units.add(new NumberTickUnit(4, numberFormat, 20)); + units.add(new NumberTickUnit(5, numberFormat, 25)); + units.add(new NumberTickUnit(6, numberFormat)); + units.add(new NumberTickUnit(7, numberFormat)); + units.add(new NumberTickUnit(8, numberFormat)); + units.add(new NumberTickUnit(9, numberFormat)); + units.add(new NumberTickUnit(10, numberFormat)); + return units; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/LogarithmicAxis.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/LogarithmicAxis.java new file mode 100755 index 0000000..85fcb26 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/LogarithmicAxis.java @@ -0,0 +1,1091 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * LogarithmicAxis.java + * -------------------- + * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. + * + * Original Author: Michael Duffy / Eric Thomas; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * David M. O'Donnell; + * Scott Sams; + * Sergei Ivanov; + * + * Changes + * ------- + * 14-Mar-2002 : Version 1 contributed by Michael Duffy (DG); + * 19-Apr-2002 : drawVerticalString() is now drawRotatedString() in + * RefineryUtilities (DG); + * 23-Apr-2002 : Added a range property (DG); + * 15-May-2002 : Modified to be able to deal with negative and zero values (via + * new 'adjustedLog10()' method); occurrences of "Math.log(10)" + * changed to "LOG10_VALUE"; changed 'intValue()' to + * 'longValue()' in 'refreshTicks()' to fix label-text value + * out-of-range problem; removed 'draw()' method; added + * 'autoRangeMinimumSize' check; added 'log10TickLabelsFlag' + * parameter flag and implementation (ET); + * 25-Jun-2002 : Removed redundant import (DG); + * 25-Jul-2002 : Changed order of parameters in ValueAxis constructor (DG); + * 16-Jul-2002 : Implemented support for plotting positive values arbitrarily + * close to zero (added 'allowNegativesFlag' flag) (ET). + * 05-Sep-2002 : Updated constructor reflecting changes in the Axis class (DG); + * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); + * 22-Nov-2002 : Bug fixes from David M. O'Donnell (DG); + * 14-Jan-2003 : Changed autoRangeMinimumSize from Number --> double (DG); + * 20-Jan-2003 : Removed unnecessary constructors (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 08-May-2003 : Fixed plotting of datasets with lower==upper bounds when + * 'minAutoRange' is very small; added 'strictValuesFlag' + * and default functionality of throwing a runtime exception + * if 'allowNegativesFlag' is false and any values are less + * than or equal to zero; added 'expTickLabelsFlag' and + * changed to use "1e#"-style tick labels by default + * ("10^n"-style tick labels still supported via 'set' + * method); improved generation of tick labels when range of + * values is small; changed to use 'NumberFormat.getInstance()' + * to create 'numberFormatterObj' (ET); + * 14-May-2003 : Merged HorizontalLogarithmicAxis and + * VerticalLogarithmicAxis (DG); + * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); + * 07-Nov-2003 : Modified to use new NumberTick class (DG); + * 08-Apr-2004 : Use numberFormatOverride if set - see patch 930139 (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); + * 21-Apr-2005 : Added support for upper and lower margins; added + * get/setAutoRangeNextLogFlag() methods and changed + * default to 'autoRangeNextLogFlag'==false (ET); + * 22-Apr-2005 : Removed refreshTicks() and fixed names and parameters for + * refreshHorizontalTicks() & refreshVerticalTicks(); + * changed javadoc on setExpTickLabelsFlag() to specify + * proper default (ET); + * 22-Apr-2005 : Renamed refreshHorizontalTicks --> refreshTicksHorizontal + * (and likewise the vertical version) for consistency with + * other axis classes (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 02-Mar-2007 : Applied patch 1671069 to fix zooming (DG); + * 22-Mar-2007 : Use new defaultAutoRange attribute (DG); + * + */ + +package org.jfree.chart.axis; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.List; + +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.ValueAxisPlot; +import org.jfree.data.Range; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.TextAnchor; + +/** + * A numerical axis that uses a logarithmic scale. + */ +public class LogarithmicAxis extends NumberAxis { + + /** For serialization. */ + private static final long serialVersionUID = 2502918599004103054L; + + /** Useful constant for log(10). */ + public static final double LOG10_VALUE = Math.log(10.0); + + /** Smallest arbitrarily-close-to-zero value allowed. */ + public static final double SMALL_LOG_VALUE = 1e-100; + + /** Flag set true to allow negative values in data. */ + protected boolean allowNegativesFlag = false; + + /** + * Flag set true make axis throw exception if any values are + * <= 0 and 'allowNegativesFlag' is false. + */ + protected boolean strictValuesFlag = true; + + /** Number formatter for generating numeric strings. */ + protected final NumberFormat numberFormatterObj + = NumberFormat.getInstance(); + + /** Flag set true for "1e#"-style tick labels. */ + protected boolean expTickLabelsFlag = false; + + /** Flag set true for "10^n"-style tick labels. */ + protected boolean log10TickLabelsFlag = false; + + /** True to make 'autoAdjustRange()' select "10^n" values. */ + protected boolean autoRangeNextLogFlag = false; + + /** Helper flag for log axis processing. */ + protected boolean smallLogFlag = false; + + /** + * Creates a new axis. + * + * @param label the axis label. + */ + public LogarithmicAxis(String label) { + super(label); + setupNumberFmtObj(); //setup number formatter obj + } + + /** + * Sets the 'allowNegativesFlag' flag; true to allow negative values + * in data, false to be able to plot positive values arbitrarily close to + * zero. + * + * @param flgVal the new value of the flag. + */ + public void setAllowNegativesFlag(boolean flgVal) { + this.allowNegativesFlag = flgVal; + } + + /** + * Returns the 'allowNegativesFlag' flag; true to allow negative values + * in data, false to be able to plot positive values arbitrarily close + * to zero. + * + * @return The flag. + */ + public boolean getAllowNegativesFlag() { + return this.allowNegativesFlag; + } + + /** + * Sets the 'strictValuesFlag' flag; if true and 'allowNegativesFlag' + * is false then this axis will throw a runtime exception if any of its + * values are less than or equal to zero; if false then the axis will + * adjust for values less than or equal to zero as needed. + * + * @param flgVal true for strict enforcement. + */ + public void setStrictValuesFlag(boolean flgVal) { + this.strictValuesFlag = flgVal; + } + + /** + * Returns the 'strictValuesFlag' flag; if true and 'allowNegativesFlag' + * is false then this axis will throw a runtime exception if any of its + * values are less than or equal to zero; if false then the axis will + * adjust for values less than or equal to zero as needed. + * + * @return true if strict enforcement is enabled. + */ + public boolean getStrictValuesFlag() { + return this.strictValuesFlag; + } + + /** + * Sets the 'expTickLabelsFlag' flag. If the 'log10TickLabelsFlag' + * is false then this will set whether or not "1e#"-style tick labels + * are used. The default is to use regular numeric tick labels. + * + * @param flgVal true for "1e#"-style tick labels, false for + * log10 or regular numeric tick labels. + */ + public void setExpTickLabelsFlag(boolean flgVal) { + this.expTickLabelsFlag = flgVal; + setupNumberFmtObj(); //setup number formatter obj + } + + /** + * Returns the 'expTickLabelsFlag' flag. + * + * @return true for "1e#"-style tick labels, + * false for log10 or regular numeric tick labels. + */ + public boolean getExpTickLabelsFlag() { + return this.expTickLabelsFlag; + } + + /** + * Sets the 'log10TickLabelsFlag' flag. The default value is false. + * + * @param flag true for "10^n"-style tick labels, false for "1e#"-style + * or regular numeric tick labels. + */ + public void setLog10TickLabelsFlag(boolean flag) { + this.log10TickLabelsFlag = flag; + } + + /** + * Returns the 'log10TickLabelsFlag' flag. + * + * @return true for "10^n"-style tick labels, + * false for "1e#"-style or regular numeric tick + * labels. + */ + public boolean getLog10TickLabelsFlag() { + return this.log10TickLabelsFlag; + } + + /** + * Sets the 'autoRangeNextLogFlag' flag. This determines whether or + * not the 'autoAdjustRange()' method will select the next "10^n" + * values when determining the upper and lower bounds. The default + * value is false. + * + * @param flag true to make the 'autoAdjustRange()' + * method select the next "10^n" values, false to not. + */ + public void setAutoRangeNextLogFlag(boolean flag) { + this.autoRangeNextLogFlag = flag; + } + + /** + * Returns the 'autoRangeNextLogFlag' flag. + * + * @return true if the 'autoAdjustRange()' method will + * select the next "10^n" values, false if not. + */ + public boolean getAutoRangeNextLogFlag() { + return this.autoRangeNextLogFlag; + } + + /** + * Overridden version that calls original and then sets up flag for + * log axis processing. + * + * @param range the new range. + */ + @Override + public void setRange(Range range) { + super.setRange(range); // call parent method + setupSmallLogFlag(); // setup flag based on bounds values + } + + /** + * Sets up flag for log axis processing. Set true if negative values + * not allowed and the lower bound is between 0 and 10. + */ + protected void setupSmallLogFlag() { + // set flag true if negative values not allowed and the + // lower bound is between 0 and 10: + double lowerVal = getRange().getLowerBound(); + this.smallLogFlag = (!this.allowNegativesFlag && lowerVal < 10.0 + && lowerVal > 0.0); + } + + /** + * Sets up the number formatter object according to the + * 'expTickLabelsFlag' flag. + */ + protected void setupNumberFmtObj() { + if (this.numberFormatterObj instanceof DecimalFormat) { + //setup for "1e#"-style tick labels or regular + // numeric tick labels, depending on flag: + ((DecimalFormat) this.numberFormatterObj).applyPattern( + this.expTickLabelsFlag ? "0E0" : "0.###"); + } + } + + /** + * Returns the log10 value, depending on if values between 0 and + * 1 are being plotted. If negative values are not allowed and + * the lower bound is between 0 and 10 then a normal log is + * returned; otherwise the returned value is adjusted if the + * given value is less than 10. + * + * @param val the value. + * + * @return log10(val). + * + * @see #switchedPow10(double) + */ + protected double switchedLog10(double val) { + return this.smallLogFlag ? Math.log(val) + / LOG10_VALUE : adjustedLog10(val); + } + + /** + * Returns a power of 10, depending on if values between 0 and + * 1 are being plotted. If negative values are not allowed and + * the lower bound is between 0 and 10 then a normal power is + * returned; otherwise the returned value is adjusted if the + * given value is less than 1. + * + * @param val the value. + * + * @return 10val. + * + * @since 1.0.5 + * @see #switchedLog10(double) + */ + public double switchedPow10(double val) { + return this.smallLogFlag ? Math.pow(10.0, val) : adjustedPow10(val); + } + + /** + * Returns an adjusted log10 value for graphing purposes. The first + * adjustment is that negative values are changed to positive during + * the calculations, and then the answer is negated at the end. The + * second is that, for values less than 10, an increasingly large + * (0 to 1) scaling factor is added such that at 0 the value is + * adjusted to 1, resulting in a returned result of 0. + * + * @param val value for which log10 should be calculated. + * + * @return An adjusted log10(val). + * + * @see #adjustedPow10(double) + */ + public double adjustedLog10(double val) { + boolean negFlag = (val < 0.0); + if (negFlag) { + val = -val; // if negative then set flag and make positive + } + if (val < 10.0) { // if < 10 then + val += (10.0 - val) / 10.0; //increase so 0 translates to 0 + } + //return value; negate if original value was negative: + double res = Math.log(val) / LOG10_VALUE; + return negFlag ? (-res) : res; + } + + /** + * Returns an adjusted power of 10 value for graphing purposes. The first + * adjustment is that negative values are changed to positive during + * the calculations, and then the answer is negated at the end. The + * second is that, for values less than 1, a progressive logarithmic + * offset is subtracted such that at 0 the returned result is also 0. + * + * @param val value for which power of 10 should be calculated. + * + * @return An adjusted 10val. + * + * @since 1.0.5 + * @see #adjustedLog10(double) + */ + public double adjustedPow10(double val) { + boolean negFlag = (val < 0.0); + if (negFlag) { + val = -val; // if negative then set flag and make positive + } + double res; + if (val < 1.0) { + res = (Math.pow(10, val + 1.0) - 10.0) / 9.0; //invert adjustLog10 + } + else { + res = Math.pow(10, val); + } + return negFlag ? (-res) : res; + } + + /** + * Returns the largest (closest to positive infinity) double value that is + * not greater than the argument, is equal to a mathematical integer and + * satisfying the condition that log base 10 of the value is an integer + * (i.e., the value returned will be a power of 10: 1, 10, 100, 1000, etc.). + * + * @param lower a double value below which a floor will be calcualted. + * + * @return 10N with N .. { 1 ... } + */ + protected double computeLogFloor(double lower) { + + double logFloor; + if (this.allowNegativesFlag) { + //negative values are allowed + if (lower > 10.0) { //parameter value is > 10 + // The Math.log() function is based on e not 10. + logFloor = Math.log(lower) / LOG10_VALUE; + logFloor = Math.floor(logFloor); + logFloor = Math.pow(10, logFloor); + } + else if (lower < -10.0) { //parameter value is < -10 + //calculate log using positive value: + logFloor = Math.log(-lower) / LOG10_VALUE; + //calculate floor using negative value: + logFloor = Math.floor(-logFloor); + //calculate power using positive value; then negate + logFloor = -Math.pow(10, -logFloor); + } + else { + //parameter value is -10 > val < 10 + logFloor = Math.floor(lower); //use as-is + } + } + else { + //negative values not allowed + if (lower > 0.0) { //parameter value is > 0 + // The Math.log() function is based on e not 10. + logFloor = Math.log(lower) / LOG10_VALUE; + logFloor = Math.floor(logFloor); + logFloor = Math.pow(10, logFloor); + } + else { + //parameter value is <= 0 + logFloor = Math.floor(lower); //use as-is + } + } + return logFloor; + } + + /** + * Returns the smallest (closest to negative infinity) double value that is + * not less than the argument, is equal to a mathematical integer and + * satisfying the condition that log base 10 of the value is an integer + * (i.e., the value returned will be a power of 10: 1, 10, 100, 1000, etc.). + * + * @param upper a double value above which a ceiling will be calcualted. + * + * @return 10N with N .. { 1 ... } + */ + protected double computeLogCeil(double upper) { + + double logCeil; + if (this.allowNegativesFlag) { + //negative values are allowed + if (upper > 10.0) { + //parameter value is > 10 + // The Math.log() function is based on e not 10. + logCeil = Math.log(upper) / LOG10_VALUE; + logCeil = Math.ceil(logCeil); + logCeil = Math.pow(10, logCeil); + } + else if (upper < -10.0) { + //parameter value is < -10 + //calculate log using positive value: + logCeil = Math.log(-upper) / LOG10_VALUE; + //calculate ceil using negative value: + logCeil = Math.ceil(-logCeil); + //calculate power using positive value; then negate + logCeil = -Math.pow(10, -logCeil); + } + else { + //parameter value is -10 > val < 10 + logCeil = Math.ceil(upper); //use as-is + } + } + else { + //negative values not allowed + if (upper > 0.0) { + //parameter value is > 0 + // The Math.log() function is based on e not 10. + logCeil = Math.log(upper) / LOG10_VALUE; + logCeil = Math.ceil(logCeil); + logCeil = Math.pow(10, logCeil); + } + else { + //parameter value is <= 0 + logCeil = Math.ceil(upper); //use as-is + } + } + return logCeil; + } + + /** + * Rescales the axis to ensure that all data is visible. + */ + @Override + public void autoAdjustRange() { + + Plot plot = getPlot(); + if (plot == null) { + return; // no plot, no data. + } + + if (plot instanceof ValueAxisPlot) { + ValueAxisPlot vap = (ValueAxisPlot) plot; + + double lower; + Range r = vap.getDataRange(this); + if (r == null) { + //no real data present + r = getDefaultAutoRange(); + lower = r.getLowerBound(); //get lower bound value + } + else { + //actual data is present + lower = r.getLowerBound(); //get lower bound value + if (this.strictValuesFlag + && !this.allowNegativesFlag && lower <= 0.0) { + //strict flag set, allow-negatives not set and values <= 0 + throw new RuntimeException("Values less than or equal to " + + "zero not allowed with logarithmic axis"); + } + } + + //apply lower margin by decreasing lower bound: + final double lowerMargin; + if (lower > 0.0 && (lowerMargin = getLowerMargin()) > 0.0) { + //lower bound and margin OK; get log10 of lower bound + final double logLower = (Math.log(lower) / LOG10_VALUE); + double logAbs; //get absolute value of log10 value + if ((logAbs = Math.abs(logLower)) < 1.0) { + logAbs = 1.0; //if less than 1.0 then make it 1.0 + } //subtract out margin and get exponential value: + lower = Math.pow(10, (logLower - (logAbs * lowerMargin))); + } + + //if flag then change to log version of lowest value + // to make range begin at a 10^n value: + if (this.autoRangeNextLogFlag) { + lower = computeLogFloor(lower); + } + + if (!this.allowNegativesFlag && lower >= 0.0 + && lower < SMALL_LOG_VALUE) { + //negatives not allowed and lower range bound is zero + lower = r.getLowerBound(); //use data range bound instead + } + + double upper = r.getUpperBound(); + + //apply upper margin by increasing upper bound: + final double upperMargin; + if (upper > 0.0 && (upperMargin = getUpperMargin()) > 0.0) { + //upper bound and margin OK; get log10 of upper bound + final double logUpper = (Math.log(upper) / LOG10_VALUE); + double logAbs; //get absolute value of log10 value + if ((logAbs = Math.abs(logUpper)) < 1.0) { + logAbs = 1.0; //if less than 1.0 then make it 1.0 + } //add in margin and get exponential value: + upper = Math.pow(10, (logUpper + (logAbs * upperMargin))); + } + + if (!this.allowNegativesFlag && upper < 1.0 && upper > 0.0 + && lower > 0.0) { + //negatives not allowed and upper bound between 0 & 1 + //round up to nearest significant digit for bound: + //get negative exponent: + double expVal = Math.log(upper) / LOG10_VALUE; + expVal = Math.ceil(-expVal + 0.001); //get positive exponent + expVal = Math.pow(10, expVal); //create multiplier value + //multiply, round up, and divide for bound value: + upper = (expVal > 0.0) ? Math.ceil(upper * expVal) / expVal + : Math.ceil(upper); + } + else { + //negatives allowed or upper bound not between 0 & 1 + //if flag then change to log version of highest value to + // make range begin at a 10^n value; else use nearest int + upper = (this.autoRangeNextLogFlag) ? computeLogCeil(upper) + : Math.ceil(upper); + } + // ensure the autorange is at least in size... + double minRange = getAutoRangeMinimumSize(); + if (upper - lower < minRange) { + upper = (upper + lower + minRange) / 2; + lower = (upper + lower - minRange) / 2; + //if autorange still below minimum then adjust by 1% + // (can be needed when minRange is very small): + if (upper - lower < minRange) { + double absUpper = Math.abs(upper); + //need to account for case where upper==0.0 + double adjVal = (absUpper > SMALL_LOG_VALUE) ? absUpper + / 100.0 : 0.01; + upper = (upper + lower + adjVal) / 2; + lower = (upper + lower - adjVal) / 2; + } + } + + setRange(new Range(lower, upper), false, false); + setupSmallLogFlag(); //setup flag based on bounds values + } + } + + /** + * Converts a data value to a coordinate in Java2D space, assuming that + * the axis runs along one edge of the specified plotArea. + * Note that it is possible for the coordinate to fall outside the + * plotArea. + * + * @param value the data value. + * @param plotArea the area for plotting the data. + * @param edge the axis location. + * + * @return The Java2D coordinate. + */ + @Override + public double valueToJava2D(double value, Rectangle2D plotArea, + RectangleEdge edge) { + + Range range = getRange(); + double axisMin = switchedLog10(range.getLowerBound()); + double axisMax = switchedLog10(range.getUpperBound()); + + double min = 0.0; + double max = 0.0; + if (RectangleEdge.isTopOrBottom(edge)) { + min = plotArea.getMinX(); + max = plotArea.getMaxX(); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + min = plotArea.getMaxY(); + max = plotArea.getMinY(); + } + + value = switchedLog10(value); + + if (isInverted()) { + return max - (((value - axisMin) / (axisMax - axisMin)) + * (max - min)); + } + else { + return min + (((value - axisMin) / (axisMax - axisMin)) + * (max - min)); + } + + } + + /** + * Converts a coordinate in Java2D space to the corresponding data + * value, assuming that the axis runs along one edge of the specified + * plotArea. + * + * @param java2DValue the coordinate in Java2D space. + * @param plotArea the area in which the data is plotted. + * @param edge the axis location. + * + * @return The data value. + */ + @Override + public double java2DToValue(double java2DValue, Rectangle2D plotArea, + RectangleEdge edge) { + + Range range = getRange(); + double axisMin = switchedLog10(range.getLowerBound()); + double axisMax = switchedLog10(range.getUpperBound()); + + double plotMin = 0.0; + double plotMax = 0.0; + if (RectangleEdge.isTopOrBottom(edge)) { + plotMin = plotArea.getX(); + plotMax = plotArea.getMaxX(); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + plotMin = plotArea.getMaxY(); + plotMax = plotArea.getMinY(); + } + + if (isInverted()) { + return switchedPow10(axisMax - ((java2DValue - plotMin) + / (plotMax - plotMin)) * (axisMax - axisMin)); + } + else { + return switchedPow10(axisMin + ((java2DValue - plotMin) + / (plotMax - plotMin)) * (axisMax - axisMin)); + } + } + + /** + * Zooms in on the current range. + * + * @param lowerPercent the new lower bound. + * @param upperPercent the new upper bound. + */ + @Override + public void zoomRange(double lowerPercent, double upperPercent) { + double startLog = switchedLog10(getRange().getLowerBound()); + double lengthLog = switchedLog10(getRange().getUpperBound()) - startLog; + Range adjusted; + + if (isInverted()) { + adjusted = new Range( + switchedPow10(startLog + (lengthLog * (1 - upperPercent))), + switchedPow10(startLog + (lengthLog * (1 - lowerPercent)))); + } + else { + adjusted = new Range( + switchedPow10(startLog + (lengthLog * lowerPercent)), + switchedPow10(startLog + (lengthLog * upperPercent))); + } + + setRange(adjusted); + } + + /** + * 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 dataArea the area in which the plot should be drawn. + * @param edge the location of the axis. + * + * @return A list of ticks. + */ + @Override + protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, + RectangleEdge edge) { + + List ticks = new java.util.ArrayList(); + Range range = getRange(); + + //get lower bound value: + double lowerBoundVal = range.getLowerBound(); + //if small log values and lower bound value too small + // then set to a small value (don't allow <= 0): + if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) { + lowerBoundVal = SMALL_LOG_VALUE; + } + + //get upper bound value + double upperBoundVal = range.getUpperBound(); + + //get log10 version of lower bound and round to integer: + int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal)); + //get log10 version of upper bound and round to integer: + int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal)); + + if (iBegCount == iEndCount && iBegCount > 0 + && Math.pow(10, iBegCount) > lowerBoundVal) { + //only 1 power of 10 value, it's > 0 and its resulting + // tick value will be larger than lower bound of data + --iBegCount; //decrement to generate more ticks + } + + double currentTickValue; + String tickLabel; + boolean zeroTickFlag = false; + for (int i = iBegCount; i <= iEndCount; i++) { + //for each power of 10 value; create ten ticks + for (int j = 0; j < 10; ++j) { + //for each tick to be displayed + if (this.smallLogFlag) { + //small log values in use; create numeric value for tick + currentTickValue = Math.pow(10, i) + (Math.pow(10, i) * j); + if (this.expTickLabelsFlag + || (i < 0 && currentTickValue > 0.0 + && currentTickValue < 1.0)) { + //showing "1e#"-style ticks or negative exponent + // generating tick value between 0 & 1; show fewer + if (j == 0 || (i > -4 && j < 2) + || currentTickValue >= upperBoundVal) { + //first tick of series, or not too small a value and + // one of first 3 ticks, or last tick to be displayed + // set exact number of fractional digits to be shown + // (no effect if showing "1e#"-style ticks): + this.numberFormatterObj + .setMaximumFractionDigits(-i); + //create tick label (force use of fmt obj): + tickLabel = makeTickLabel(currentTickValue, true); + } + else { //no tick label to be shown + tickLabel = ""; + } + } + else { //tick value not between 0 & 1 + //show tick label if it's the first or last in + // the set, or if it's 1-5; beyond that show + // fewer as the values get larger: + tickLabel = (j < 1 || (i < 1 && j < 5) || (j < 4 - i) + || currentTickValue >= upperBoundVal) + ? makeTickLabel(currentTickValue) : ""; + } + } + else { //not small log values in use; allow for values <= 0 + if (zeroTickFlag) { //if did zero tick last iter then + --j; //decrement to do 1.0 tick now + } //calculate power-of-ten value for tick: + currentTickValue = (i >= 0) + ? Math.pow(10, i) + (Math.pow(10, i) * j) + : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j)); + if (!zeroTickFlag) { // did not do zero tick last iteration + if (Math.abs(currentTickValue - 1.0) < 0.0001 + && lowerBoundVal <= 0.0 && upperBoundVal >= 0.0) { + //tick value is 1.0 and 0.0 is within data range + currentTickValue = 0.0; //set tick value to zero + zeroTickFlag = true; //indicate zero tick + } + } + else { //did zero tick last iteration + zeroTickFlag = false; //clear flag + } //create tick label string: + //show tick label if "1e#"-style and it's one + // of the first two, if it's the first or last + // in the set, or if it's 1-5; beyond that + // show fewer as the values get larger: + tickLabel = ((this.expTickLabelsFlag && j < 2) + || j < 1 + || (i < 1 && j < 5) || (j < 4 - i) + || currentTickValue >= upperBoundVal) + ? makeTickLabel(currentTickValue) : ""; + } + + if (currentTickValue > upperBoundVal) { + return ticks; // if past highest data value then exit + // method + } + + if (currentTickValue >= lowerBoundVal - SMALL_LOG_VALUE) { + //tick value not below lowest data value + TextAnchor anchor; + TextAnchor rotationAnchor; + double angle = 0.0; + if (isVerticalTickLabels()) { + anchor = TextAnchor.CENTER_RIGHT; + rotationAnchor = TextAnchor.CENTER_RIGHT; + if (edge == RectangleEdge.TOP) { + angle = Math.PI / 2.0; + } + else { + angle = -Math.PI / 2.0; + } + } + else { + if (edge == RectangleEdge.TOP) { + anchor = TextAnchor.BOTTOM_CENTER; + rotationAnchor = TextAnchor.BOTTOM_CENTER; + } + else { + anchor = TextAnchor.TOP_CENTER; + rotationAnchor = TextAnchor.TOP_CENTER; + } + } + + Tick tick = new NumberTick(new Double(currentTickValue), + tickLabel, anchor, rotationAnchor, angle); + ticks.add(tick); + } + } + } + return ticks; + + } + + /** + * 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 dataArea the area in which the plot should be drawn. + * @param edge the location of the axis. + * + * @return A list of ticks. + */ + @Override + protected List refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, + RectangleEdge edge) { + + List ticks = new java.util.ArrayList(); + + //get lower bound value: + double lowerBoundVal = getRange().getLowerBound(); + //if small log values and lower bound value too small + // then set to a small value (don't allow <= 0): + if (this.smallLogFlag && lowerBoundVal < SMALL_LOG_VALUE) { + lowerBoundVal = SMALL_LOG_VALUE; + } + //get upper bound value + double upperBoundVal = getRange().getUpperBound(); + + //get log10 version of lower bound and round to integer: + int iBegCount = (int) Math.rint(switchedLog10(lowerBoundVal)); + //get log10 version of upper bound and round to integer: + int iEndCount = (int) Math.rint(switchedLog10(upperBoundVal)); + + if (iBegCount == iEndCount && iBegCount > 0 + && Math.pow(10, iBegCount) > lowerBoundVal) { + //only 1 power of 10 value, it's > 0 and its resulting + // tick value will be larger than lower bound of data + --iBegCount; //decrement to generate more ticks + } + + double tickVal; + String tickLabel; + boolean zeroTickFlag = false; + for (int i = iBegCount; i <= iEndCount; i++) { + //for each tick with a label to be displayed + int jEndCount = 10; + if (i == iEndCount) { + jEndCount = 1; + } + + for (int j = 0; j < jEndCount; j++) { + //for each tick to be displayed + if (this.smallLogFlag) { + //small log values in use + tickVal = Math.pow(10, i) + (Math.pow(10, i) * j); + if (j == 0) { + //first tick of group; create label text + if (this.log10TickLabelsFlag) { + //if flag then + tickLabel = "10^" + i; //create "log10"-type label + } + else { //not "log10"-type label + if (this.expTickLabelsFlag) { + //if flag then + tickLabel = "1e" + i; //create "1e#"-type label + } + else { //not "1e#"-type label + if (i >= 0) { // if positive exponent then + // make integer + NumberFormat format + = getNumberFormatOverride(); + if (format != null) { + tickLabel = format.format(tickVal); + } + else { + tickLabel = Long.toString((long) + Math.rint(tickVal)); + } + } + else { + //negative exponent; create fractional value + //set exact number of fractional digits to + // be shown: + this.numberFormatterObj + .setMaximumFractionDigits(-i); + //create tick label: + tickLabel = this.numberFormatterObj.format( + tickVal); + } + } + } + } + else { //not first tick to be displayed + tickLabel = ""; //no tick label + } + } + else { //not small log values in use; allow for values <= 0 + if (zeroTickFlag) { //if did zero tick last iter then + --j; + } //decrement to do 1.0 tick now + tickVal = (i >= 0) ? Math.pow(10, i) + (Math.pow(10, i) * j) + : -(Math.pow(10, -i) - (Math.pow(10, -i - 1) * j)); + if (j == 0) { //first tick of group + if (!zeroTickFlag) { // did not do zero tick last + // iteration + if (i > iBegCount && i < iEndCount + && Math.abs(tickVal - 1.0) < 0.0001) { + // not first or last tick on graph and value + // is 1.0 + tickVal = 0.0; //change value to 0.0 + zeroTickFlag = true; //indicate zero tick + tickLabel = "0"; //create label for tick + } + else { + //first or last tick on graph or value is 1.0 + //create label for tick: + if (this.log10TickLabelsFlag) { + //create "log10"-type label + tickLabel = (((i < 0) ? "-" : "") + + "10^" + Math.abs(i)); + } + else { + if (this.expTickLabelsFlag) { + //create "1e#"-type label + tickLabel = (((i < 0) ? "-" : "") + + "1e" + Math.abs(i)); + } + else { + NumberFormat format + = getNumberFormatOverride(); + if (format != null) { + tickLabel = format.format(tickVal); + } + else { + tickLabel = Long.toString( + (long) Math.rint(tickVal)); + } + } + } + } + } + else { // did zero tick last iteration + tickLabel = ""; //no label + zeroTickFlag = false; //clear flag + } + } + else { // not first tick of group + tickLabel = ""; //no label + zeroTickFlag = false; //make sure flag cleared + } + } + + if (tickVal > upperBoundVal) { + return ticks; //if past highest data value then exit method + } + + if (tickVal >= lowerBoundVal - SMALL_LOG_VALUE) { + //tick value not below lowest data value + TextAnchor anchor; + TextAnchor rotationAnchor; + double angle = 0.0; + if (isVerticalTickLabels()) { + if (edge == RectangleEdge.LEFT) { + anchor = TextAnchor.BOTTOM_CENTER; + rotationAnchor = TextAnchor.BOTTOM_CENTER; + angle = -Math.PI / 2.0; + } + else { + anchor = TextAnchor.BOTTOM_CENTER; + rotationAnchor = TextAnchor.BOTTOM_CENTER; + angle = Math.PI / 2.0; + } + } + else { + if (edge == RectangleEdge.LEFT) { + anchor = TextAnchor.CENTER_RIGHT; + rotationAnchor = TextAnchor.CENTER_RIGHT; + } + else { + anchor = TextAnchor.CENTER_LEFT; + rotationAnchor = TextAnchor.CENTER_LEFT; + } + } + //create tick object and add to list: + ticks.add(new NumberTick(new Double(tickVal), tickLabel, + anchor, rotationAnchor, angle)); + } + } + } + return ticks; + } + + /** + * Converts the given value to a tick label string. + * + * @param val the value to convert. + * @param forceFmtFlag true to force the number-formatter object + * to be used. + * + * @return The tick label string. + */ + protected String makeTickLabel(double val, boolean forceFmtFlag) { + if (this.expTickLabelsFlag || forceFmtFlag) { + //using exponents or force-formatter flag is set + // (convert 'E' to lower-case 'e'): + return this.numberFormatterObj.format(val).toLowerCase(); + } + return getTickUnit().valueToString(val); + } + + /** + * Converts the given value to a tick label string. + * @param val the value to convert. + * + * @return The tick label string. + */ + protected String makeTickLabel(double val) { + return makeTickLabel(val, false); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/MarkerAxisBand.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/MarkerAxisBand.java new file mode 100755 index 0000000..629a82f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/MarkerAxisBand.java @@ -0,0 +1,276 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * MarkerAxisBand.java + * ------------------- + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Sep-2002 : Updated Javadoc comments (DG); + * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 13-May-2003 : Renamed HorizontalMarkerAxisBand --> MarkerAxisBand (DG); + * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); + * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); + * 07-Apr-2004 : Changed text bounds calculation (DG); + * + */ + +package org.jfree.chart.axis; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.font.LineMetrics; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.plot.IntervalMarker; +import org.jfree.text.TextUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.ObjectUtilities; + +/** + * A band that can be added to a number axis to display regions. + */ +public class MarkerAxisBand implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -1729482413886398919L; + + /** The axis that the band belongs to. */ + private NumberAxis axis; + + /** The top outer gap. */ + private double topOuterGap; + + /** The top inner gap. */ + private double topInnerGap; + + /** The bottom outer gap. */ + private double bottomOuterGap; + + /** The bottom inner gap. */ + private double bottomInnerGap; + + /** The font. */ + private Font font; + + /** Storage for the markers. */ + private List markers; + + /** + * Constructs a new axis band. + * + * @param axis the owner. + * @param topOuterGap the top outer gap. + * @param topInnerGap the top inner gap. + * @param bottomOuterGap the bottom outer gap. + * @param bottomInnerGap the bottom inner gap. + * @param font the font. + */ + public MarkerAxisBand(NumberAxis axis, + double topOuterGap, double topInnerGap, + double bottomOuterGap, double bottomInnerGap, + Font font) { + this.axis = axis; + this.topOuterGap = topOuterGap; + this.topInnerGap = topInnerGap; + this.bottomOuterGap = bottomOuterGap; + this.bottomInnerGap = bottomInnerGap; + this.font = font; + this.markers = new java.util.ArrayList(); + } + + /** + * Adds a marker to the band. + * + * @param marker the marker. + */ + public void addMarker(IntervalMarker marker) { + this.markers.add(marker); + } + + /** + * Returns the height of the band. + * + * @param g2 the graphics device. + * + * @return The height of the band. + */ + public double getHeight(Graphics2D g2) { + + double result = 0.0; + if (this.markers.size() > 0) { + LineMetrics metrics = this.font.getLineMetrics( + "123g", g2.getFontRenderContext() + ); + result = this.topOuterGap + this.topInnerGap + metrics.getHeight() + + this.bottomInnerGap + this.bottomOuterGap; + } + return result; + + } + + /** + * A utility method that draws a string inside a rectangle. + * + * @param g2 the graphics device. + * @param bounds the rectangle. + * @param font the font. + * @param text the text. + */ + private void drawStringInRect(Graphics2D g2, Rectangle2D bounds, Font font, + String text) { + + g2.setFont(font); + FontMetrics fm = g2.getFontMetrics(font); + Rectangle2D r = TextUtilities.getTextBounds(text, g2, fm); + double x = bounds.getX(); + if (r.getWidth() < bounds.getWidth()) { + x = x + (bounds.getWidth() - r.getWidth()) / 2; + } + LineMetrics metrics = font.getLineMetrics( + text, g2.getFontRenderContext() + ); + g2.drawString( + text, (float) x, (float) (bounds.getMaxY() + - this.bottomInnerGap - metrics.getDescent()) + ); + } + + /** + * Draws the band. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param dataArea the data area. + * @param x the x-coordinate. + * @param y the y-coordinate. + */ + public void draw(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, + double x, double y) { + + double h = getHeight(g2); + Iterator iterator = this.markers.iterator(); + while (iterator.hasNext()) { + IntervalMarker marker = (IntervalMarker) iterator.next(); + double start = Math.max( + marker.getStartValue(), this.axis.getRange().getLowerBound() + ); + double end = Math.min( + marker.getEndValue(), this.axis.getRange().getUpperBound() + ); + double s = this.axis.valueToJava2D( + start, dataArea, RectangleEdge.BOTTOM + ); + double e = this.axis.valueToJava2D( + end, dataArea, RectangleEdge.BOTTOM + ); + Rectangle2D r = new Rectangle2D.Double( + s, y + this.topOuterGap, e - s, + h - this.topOuterGap - this.bottomOuterGap + ); + + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance( + AlphaComposite.SRC_OVER, marker.getAlpha()) + ); + g2.setPaint(marker.getPaint()); + g2.fill(r); + g2.setPaint(marker.getOutlinePaint()); + g2.draw(r); + g2.setComposite(originalComposite); + + g2.setPaint(Color.black); + drawStringInRect(g2, r, this.font, marker.getLabel()); + } + + } + + /** + * Tests this axis for equality with another object. Note that the axis + * that the band belongs to is ignored in the test. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof MarkerAxisBand)) { + return false; + } + MarkerAxisBand that = (MarkerAxisBand) obj; + if (this.topOuterGap != that.topOuterGap) { + return false; + } + if (this.topInnerGap != that.topInnerGap) { + return false; + } + if (this.bottomInnerGap != that.bottomInnerGap) { + return false; + } + if (this.bottomOuterGap != that.bottomOuterGap) { + return false; + } + if (!ObjectUtilities.equal(this.font, that.font)) { + return false; + } + if (!ObjectUtilities.equal(this.markers, that.markers)) { + return false; + } + return true; + } + + /** + * Returns a hash code for the object. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 37; + result = 19 * result + this.font.hashCode(); + result = 19 * result + this.markers.hashCode(); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ModuloAxis.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ModuloAxis.java new file mode 100755 index 0000000..a76dfcd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ModuloAxis.java @@ -0,0 +1,437 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * ModuloAxis.java + * --------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Aug-2004 : Version 1 (DG); + * 13-Nov-2007 : Implemented equals() (DG); + * + */ + +package org.jfree.chart.axis; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.event.AxisChangeEvent; +import org.jfree.data.Range; +import org.jfree.ui.RectangleEdge; + +/** + * An axis that displays numerical values within a fixed range using a modulo + * calculation. + */ +public class ModuloAxis extends NumberAxis { + + /** + * The fixed range for the axis - all data values will be mapped to this + * range using a modulo calculation. + */ + private Range fixedRange; + + /** + * The display start value (this will sometimes be > displayEnd, in which + * case the axis wraps around at some point in the middle of the axis). + */ + private double displayStart; + + /** + * The display end value. + */ + private double displayEnd; + + /** + * Creates a new axis. + * + * @param label the axis label (null permitted). + * @param fixedRange the fixed range (null not permitted). + */ + public ModuloAxis(String label, Range fixedRange) { + super(label); + this.fixedRange = fixedRange; + this.displayStart = 270.0; + this.displayEnd = 90.0; + } + + /** + * Returns the display start value. + * + * @return The display start value. + */ + public double getDisplayStart() { + return this.displayStart; + } + + /** + * Returns the display end value. + * + * @return The display end value. + */ + public double getDisplayEnd() { + return this.displayEnd; + } + + /** + * Sets the display range. The values will be mapped to the fixed range if + * necessary. + * + * @param start the start value. + * @param end the end value. + */ + public void setDisplayRange(double start, double end) { + this.displayStart = mapValueToFixedRange(start); + this.displayEnd = mapValueToFixedRange(end); + if (this.displayStart < this.displayEnd) { + setRange(this.displayStart, this.displayEnd); + } + else { + setRange(this.displayStart, this.fixedRange.getUpperBound() + + (this.displayEnd - this.fixedRange.getLowerBound())); + } + notifyListeners(new AxisChangeEvent(this)); + } + + /** + * This method should calculate a range that will show all the data values. + * For now, it just sets the axis range to the fixedRange. + */ + @Override + protected void autoAdjustRange() { + setRange(this.fixedRange, false, false); + } + + /** + * Translates a data value to a Java2D coordinate. + * + * @param value the value. + * @param area the area. + * @param edge the edge. + * + * @return A Java2D coordinate. + */ + @Override + public double valueToJava2D(double value, Rectangle2D area, + RectangleEdge edge) { + double result; + double v = mapValueToFixedRange(value); + if (this.displayStart < this.displayEnd) { // regular number axis + result = trans(v, area, edge); + } + else { // displayStart > displayEnd, need to handle split + double cutoff = (this.displayStart + this.displayEnd) / 2.0; + double length1 = this.fixedRange.getUpperBound() + - this.displayStart; + double length2 = this.displayEnd - this.fixedRange.getLowerBound(); + if (v > cutoff) { + result = transStart(v, area, edge, length1, length2); + } + else { + result = transEnd(v, area, edge, length1, length2); + } + } + return result; + } + + /** + * A regular translation from a data value to a Java2D value. + * + * @param value the value. + * @param area the data area. + * @param edge the edge along which the axis lies. + * + * @return The Java2D coordinate. + */ + private double trans(double value, Rectangle2D area, RectangleEdge edge) { + double min = 0.0; + double max = 0.0; + if (RectangleEdge.isTopOrBottom(edge)) { + min = area.getX(); + max = area.getX() + area.getWidth(); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + min = area.getMaxY(); + max = area.getMaxY() - area.getHeight(); + } + if (isInverted()) { + return max - ((value - this.displayStart) + / (this.displayEnd - this.displayStart)) * (max - min); + } + else { + return min + ((value - this.displayStart) + / (this.displayEnd - this.displayStart)) * (max - min); + } + + } + + /** + * Translates a data value to a Java2D value for the first section of the + * axis. + * + * @param value the value. + * @param area the data area. + * @param edge the edge along which the axis lies. + * @param length1 the length of the first section. + * @param length2 the length of the second section. + * + * @return The Java2D coordinate. + */ + private double transStart(double value, Rectangle2D area, + RectangleEdge edge, + double length1, double length2) { + double min = 0.0; + double max = 0.0; + if (RectangleEdge.isTopOrBottom(edge)) { + min = area.getX(); + max = area.getX() + area.getWidth() * length1 / (length1 + length2); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + min = area.getMaxY(); + max = area.getMaxY() - area.getHeight() * length1 + / (length1 + length2); + } + if (isInverted()) { + return max - ((value - this.displayStart) + / (this.fixedRange.getUpperBound() - this.displayStart)) + * (max - min); + } + else { + return min + ((value - this.displayStart) + / (this.fixedRange.getUpperBound() - this.displayStart)) + * (max - min); + } + + } + + /** + * Translates a data value to a Java2D value for the second section of the + * axis. + * + * @param value the value. + * @param area the data area. + * @param edge the edge along which the axis lies. + * @param length1 the length of the first section. + * @param length2 the length of the second section. + * + * @return The Java2D coordinate. + */ + private double transEnd(double value, Rectangle2D area, RectangleEdge edge, + double length1, double length2) { + double min = 0.0; + double max = 0.0; + if (RectangleEdge.isTopOrBottom(edge)) { + max = area.getMaxX(); + min = area.getMaxX() - area.getWidth() * length2 + / (length1 + length2); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + max = area.getMinY(); + min = area.getMinY() + area.getHeight() * length2 + / (length1 + length2); + } + if (isInverted()) { + return max - ((value - this.fixedRange.getLowerBound()) + / (this.displayEnd - this.fixedRange.getLowerBound())) + * (max - min); + } + else { + return min + ((value - this.fixedRange.getLowerBound()) + / (this.displayEnd - this.fixedRange.getLowerBound())) + * (max - min); + } + + } + + /** + * Maps a data value into the fixed range. + * + * @param value the value. + * + * @return The mapped value. + */ + private double mapValueToFixedRange(double value) { + double lower = this.fixedRange.getLowerBound(); + double length = this.fixedRange.getLength(); + if (value < lower) { + return lower + length + ((value - lower) % length); + } + else { + return lower + ((value - lower) % length); + } + } + + /** + * Translates a Java2D coordinate into a data value. + * + * @param java2DValue the Java2D coordinate. + * @param area the area. + * @param edge the edge. + * + * @return The Java2D coordinate. + */ + @Override + public double java2DToValue(double java2DValue, Rectangle2D area, + RectangleEdge edge) { + double result = 0.0; + if (this.displayStart < this.displayEnd) { // regular number axis + result = super.java2DToValue(java2DValue, area, edge); + } + else { // displayStart > displayEnd, need to handle split + + } + return result; + } + + /** + * Returns the display length for the axis. + * + * @return The display length. + */ + private double getDisplayLength() { + if (this.displayStart < this.displayEnd) { + return (this.displayEnd - this.displayStart); + } + else { + return (this.fixedRange.getUpperBound() - this.displayStart) + + (this.displayEnd - this.fixedRange.getLowerBound()); + } + } + + /** + * Returns the central value of the current display range. + * + * @return The central value. + */ + private double getDisplayCentralValue() { + return mapValueToFixedRange(this.displayStart + + (getDisplayLength() / 2)); + } + + /** + * Increases or decreases the axis range by the specified percentage about + * the central value and sends an {@link AxisChangeEvent} to all registered + * listeners. + *

+ * To double the length of the axis range, use 200% (2.0). + * To halve the length of the axis range, use 50% (0.5). + * + * @param percent the resize factor. + */ + @Override + public void resizeRange(double percent) { + resizeRange(percent, getDisplayCentralValue()); + } + + /** + * Increases or decreases the axis range by the specified percentage about + * the specified anchor value and sends an {@link AxisChangeEvent} to all + * registered listeners. + *

+ * To double the length of the axis range, use 200% (2.0). + * To halve the length of the axis range, use 50% (0.5). + * + * @param percent the resize factor. + * @param anchorValue the new central value after the resize. + */ + @Override + public void resizeRange(double percent, double anchorValue) { + + if (percent > 0.0) { + double halfLength = getDisplayLength() * percent / 2; + setDisplayRange(anchorValue - halfLength, anchorValue + halfLength); + } + else { + setAutoRange(true); + } + + } + + /** + * 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. + */ + @Override + public double lengthToJava2D(double length, Rectangle2D area, + RectangleEdge edge) { + double axisLength = 0.0; + if (this.displayEnd > this.displayStart) { + axisLength = this.displayEnd - this.displayStart; + } + else { + axisLength = (this.fixedRange.getUpperBound() - this.displayStart) + + (this.displayEnd - this.fixedRange.getLowerBound()); + } + double areaLength; + if (RectangleEdge.isLeftOrRight(edge)) { + areaLength = area.getHeight(); + } + else { + areaLength = area.getWidth(); + } + return (length / axisLength) * areaLength; + } + + /** + * Tests this axis for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ModuloAxis)) { + return false; + } + ModuloAxis that = (ModuloAxis) obj; + if (this.displayStart != that.displayStart) { + return false; + } + if (this.displayEnd != that.displayEnd) { + return false; + } + if (!this.fixedRange.equals(that.fixedRange)) { + return false; + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/MonthDateFormat.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/MonthDateFormat.java new file mode 100755 index 0000000..bdb0967 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/MonthDateFormat.java @@ -0,0 +1,312 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * MonthDateFormat.java + * -------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 10-May-2005 : Version 1 (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.axis; + +import java.text.DateFormat; +import java.text.DateFormatSymbols; +import java.text.FieldPosition; +import java.text.NumberFormat; +import java.text.ParsePosition; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.time.Month; + +/** + * A formatter that formats dates to show the initial letter(s) of the month + * name and, as an option, the year for the first or last month of each year. + */ +public class MonthDateFormat extends DateFormat { + + /** The symbols used for the months. */ + private String[] months; + + /** Flags that control which months will have the year appended. */ + private boolean[] showYear; + + /** The year formatter. */ + private DateFormat yearFormatter; + + /** + * Creates a new instance for the default time zone. + */ + public MonthDateFormat() { + this(TimeZone.getDefault()); + } + + /** + * Creates a new instance for the specified time zone. + * + * @param zone the time zone (null not permitted). + */ + public MonthDateFormat(TimeZone zone) { + this(zone, Locale.getDefault(), 1, true, false); + } + + /** + * Creates a new instance for the specified time zone. + * + * @param locale the locale used to obtain the month + * names (null not permitted). + */ + public MonthDateFormat(Locale locale) { + this(TimeZone.getDefault(), locale, 1, true, false); + } + + /** + * Creates a new instance for the specified time zone. + * + * @param zone the time zone (null not permitted). + * @param chars the maximum number of characters to use from the month + * names (that are obtained from the date symbols of the + * default locale). If this value is <= 0, the entire + * month name is used in each case. + */ + public MonthDateFormat(TimeZone zone, int chars) { + this(zone, Locale.getDefault(), chars, true, false); + } + + /** + * Creates a new instance for the specified time zone. + * + * @param locale the locale (null not permitted). + * @param chars the maximum number of characters to use from the month + * names (that are obtained from the date symbols of the + * default locale). If this value is <= 0, the entire + * month name is used in each case. + */ + public MonthDateFormat(Locale locale, int chars) { + this(TimeZone.getDefault(), locale, chars, true, false); + } + + /** + * Creates a new formatter. + * + * @param zone the time zone used to extract the month and year from dates + * passed to this formatter (null not permitted). + * @param locale the locale used to determine the month names + * (null not permitted). + * @param chars the maximum number of characters to use from the month + * names, or zero to indicate that the entire month name + * should be used. + * @param showYearForJan a flag that controls whether or not the year is + * appended to the symbol for the first month of + * each year. + * @param showYearForDec a flag that controls whether or not the year is + * appended to the symbol for the last month of + * each year. + */ + public MonthDateFormat(TimeZone zone, Locale locale, int chars, + boolean showYearForJan, boolean showYearForDec) { + this(zone, locale, chars, new boolean[] {showYearForJan, false, false, + false, false, false, false, false, false, false, false, false, + showYearForDec}, new SimpleDateFormat("yy")); + } + + /** + * Creates a new formatter. + * + * @param zone the time zone used to extract the month and year from dates + * passed to this formatter (null not permitted). + * @param locale the locale used to determine the month names + * (null not permitted). + * @param chars the maximum number of characters to use from the month + * names, or zero to indicate that the entire month name + * should be used. + * @param showYear an array of flags that control whether or not the + * year is displayed for a particular month. + * @param yearFormatter the year formatter. + */ + public MonthDateFormat(TimeZone zone, Locale locale, int chars, + boolean[] showYear, DateFormat yearFormatter) { + ParamChecks.nullNotPermitted(locale, "locale"); + DateFormatSymbols dfs = new DateFormatSymbols(locale); + String[] monthsFromLocale = dfs.getMonths(); + this.months = new String[12]; + for (int i = 0; i < 12; i++) { + if (chars > 0) { + this.months[i] = monthsFromLocale[i].substring(0, + Math.min(chars, monthsFromLocale[i].length())); + } + else { + this.months[i] = monthsFromLocale[i]; + } + } + this.calendar = new GregorianCalendar(zone); + this.showYear = showYear; + this.yearFormatter = yearFormatter; + + // the following is never used, but it seems that DateFormat requires + // it to be non-null. It isn't well covered in the spec, refer to + // bug parade 5061189 for more info. + this.numberFormat = NumberFormat.getNumberInstance(); + } + + /** + * Formats the given date. + * + * @param date the date. + * @param toAppendTo the string buffer. + * @param fieldPosition the field position. + * + * @return The formatted date. + */ + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, + FieldPosition fieldPosition) { + this.calendar.setTime(date); + int month = this.calendar.get(Calendar.MONTH); + toAppendTo.append(this.months[month]); + if (this.showYear[month]) { + toAppendTo.append(this.yearFormatter.format(date)); + } + return toAppendTo; + } + + /** + * Parses the given string (not implemented). + * + * @param source the date string. + * @param pos the parse position. + * + * @return null, as this method has not been implemented. + */ + @Override + public Date parse(String source, ParsePosition pos) { + return null; + } + + /** + * Tests this formatter for equality with an arbitrary object. + * + * @param obj the object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof MonthDateFormat)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + MonthDateFormat that = (MonthDateFormat) obj; + if (!Arrays.equals(this.months, that.months)) { + return false; + } + if (!Arrays.equals(this.showYear, that.showYear)) { + return false; + } + if (!this.yearFormatter.equals(that.yearFormatter)) { + return false; + } + return true; + } + + /** + * Some test code. + * + * @param args ignored. + */ + public static void main(String[] args) { + MonthDateFormat mdf = new MonthDateFormat(Locale.UK, 2); + System.out.println("UK:"); + System.out.println(mdf.format(new Month(1, 2005).getStart())); + System.out.println(mdf.format(new Month(2, 2005).getStart())); + System.out.println(mdf.format(new Month(3, 2005).getStart())); + System.out.println(mdf.format(new Month(4, 2005).getStart())); + System.out.println(mdf.format(new Month(5, 2005).getStart())); + System.out.println(mdf.format(new Month(6, 2005).getStart())); + System.out.println(mdf.format(new Month(7, 2005).getStart())); + System.out.println(mdf.format(new Month(8, 2005).getStart())); + System.out.println(mdf.format(new Month(9, 2005).getStart())); + System.out.println(mdf.format(new Month(10, 2005).getStart())); + System.out.println(mdf.format(new Month(11, 2005).getStart())); + System.out.println(mdf.format(new Month(12, 2005).getStart())); + System.out.println(); + + mdf = new MonthDateFormat(Locale.GERMANY, 2); + System.out.println("GERMANY:"); + System.out.println(mdf.format(new Month(1, 2005).getStart())); + System.out.println(mdf.format(new Month(2, 2005).getStart())); + System.out.println(mdf.format(new Month(3, 2005).getStart())); + System.out.println(mdf.format(new Month(4, 2005).getStart())); + System.out.println(mdf.format(new Month(5, 2005).getStart())); + System.out.println(mdf.format(new Month(6, 2005).getStart())); + System.out.println(mdf.format(new Month(7, 2005).getStart())); + System.out.println(mdf.format(new Month(8, 2005).getStart())); + System.out.println(mdf.format(new Month(9, 2005).getStart())); + System.out.println(mdf.format(new Month(10, 2005).getStart())); + System.out.println(mdf.format(new Month(11, 2005).getStart())); + System.out.println(mdf.format(new Month(12, 2005).getStart())); + System.out.println(); + + mdf = new MonthDateFormat(Locale.FRANCE, 2); + System.out.println("FRANCE:"); + System.out.println(mdf.format(new Month(1, 2005).getStart())); + System.out.println(mdf.format(new Month(2, 2005).getStart())); + System.out.println(mdf.format(new Month(3, 2005).getStart())); + System.out.println(mdf.format(new Month(4, 2005).getStart())); + System.out.println(mdf.format(new Month(5, 2005).getStart())); + System.out.println(mdf.format(new Month(6, 2005).getStart())); + System.out.println(mdf.format(new Month(7, 2005).getStart())); + System.out.println(mdf.format(new Month(8, 2005).getStart())); + System.out.println(mdf.format(new Month(9, 2005).getStart())); + System.out.println(mdf.format(new Month(10, 2005).getStart())); + System.out.println(mdf.format(new Month(11, 2005).getStart())); + System.out.println(mdf.format(new Month(12, 2005).getStart())); + System.out.println(); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy"); + sdf.setNumberFormat(null); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/NumberAxis.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/NumberAxis.java new file mode 100755 index 0000000..299bebf --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/NumberAxis.java @@ -0,0 +1,1401 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * NumberAxis.java + * --------------- + * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Laurence Vanhelsuwe; + * Peter Kolb (patches 1934255 and 2603321); + * + * Changes + * ------- + * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); + * 22-Sep-2001 : Changed setMinimumAxisValue() and setMaximumAxisValue() so + * that they clear the autoRange flag (DG); + * 27-Nov-2001 : Removed old, redundant code (DG); + * 30-Nov-2001 : Added accessor methods for the standard tick units (DG); + * 08-Jan-2002 : Added setAxisRange() method (since renamed setRange()) (DG); + * 16-Jan-2002 : Added setTickUnit() method. Extended ValueAxis to support an + * optional cross-hair (DG); + * 08-Feb-2002 : Fixes bug to ensure the autorange is recalculated if the + * setAutoRangeIncludesZero flag is changed (DG); + * 25-Feb-2002 : Added a new flag autoRangeStickyZero to provide further + * control over margins in the auto-range mechanism. Updated + * constructors. Updated import statements. Moved the + * createStandardTickUnits() method to the TickUnits class (DG); + * 19-Apr-2002 : Updated Javadoc comments (DG); + * 01-May-2002 : Updated for changes to TickUnit class, removed valueToString() + * method (DG); + * 25-Jul-2002 : Moved the lower and upper margin attributes, and the + * auto-range minimum size, up one level to the ValueAxis + * class (DG); + * 05-Sep-2002 : Updated constructor to match changes in Axis class (DG); + * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 04-Oct-2002 : Moved standardTickUnits from NumberAxis --> ValueAxis (DG); + * 24-Oct-2002 : Added a number format override (DG); + * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); + * 19-Nov-2002 : Removed grid settings (now controlled by the plot) (DG); + * 14-Jan-2003 : Changed autoRangeMinimumSize from Number --> double, and moved + * crosshair settings to the plot classes (DG); + * 20-Jan-2003 : Removed the monolithic constructor (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 16-Jul-2003 : Reworked to allow for multiple secondary axes (DG); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 07-Oct-2003 : Fixed bug (815028) in the auto range calculation (DG); + * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); + * 07-Nov-2003 : Modified to use NumberTick class (DG); + * 21-Jan-2004 : Renamed translateJava2DToValue --> java2DToValue, and + * translateValueToJava2D --> valueToJava2D (DG); + * 03-Mar-2004 : Added plotState to draw() method (DG); + * 07-Apr-2004 : Changed string width calculation (DG); + * 11-Jan-2005 : Removed deprecated methods in preparation for 1.0.0 + * release (DG); + * 28-Mar-2005 : Renamed autoRangeIncludesZero() --> getAutoRangeIncludesZero() + * and autoRangeStickyZero() --> getAutoRangeStickyZero() (DG); + * 21-Apr-2005 : Removed redundant argument from selectAutoTickUnit() (DG); + * 22-Apr-2005 : Renamed refreshHorizontalTicks --> refreshTicksHorizontal + * (and likewise the vertical version) for consistency with + * other axis classes (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 10-Feb-2006 : Added some API doc comments in respect of bug 821046 (DG); + * 20-Feb-2006 : Modified equals() method to check rangeType field (fixes bug + * 1435461) (DG); + * 04-Sep-2006 : Fix auto range calculation for the case where all data values + * are constant and large (see bug report 1549218) (DG); + * 11-Dec-2006 : Fix bug in auto-tick unit selection with tick format override, + * see bug 1608371 (DG); + * 22-Mar-2007 : Use new defaultAutoRange attribute (DG); + * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); + * 21-Jan-2009 : Default minor tick counts will now come from the tick unit + * collection (DG); + * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * 01-Aug-2013 : Added attributedLabel override to support superscripts, + * subscripts and more (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.io.Serializable; +import java.text.DecimalFormat; +import java.text.NumberFormat; +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.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.RangeType; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.TextAnchor; +import org.jfree.util.ObjectUtilities; + +/** + * An axis for displaying numerical data. + *

+ * If the axis is set up to automatically determine its range to fit the data, + * you can ensure that the range includes zero (statisticians usually prefer + * this) by setting the autoRangeIncludesZero flag to + * true. + *

+ * The NumberAxis class has a mechanism for automatically + * selecting a tick unit that is appropriate for the current axis range. This + * mechanism is an adaptation of code suggested by Laurence Vanhelsuwe. + */ +public class NumberAxis extends ValueAxis implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 2805933088476185789L; + + /** The default value for the autoRangeIncludesZero flag. */ + public static final boolean DEFAULT_AUTO_RANGE_INCLUDES_ZERO = true; + + /** The default value for the autoRangeStickyZero flag. */ + public static final boolean DEFAULT_AUTO_RANGE_STICKY_ZERO = true; + + /** The default tick unit. */ + public static final NumberTickUnit DEFAULT_TICK_UNIT = new NumberTickUnit( + 1.0, new DecimalFormat("0")); + + /** The default setting for the vertical tick labels flag. */ + public static final boolean DEFAULT_VERTICAL_TICK_LABELS = false; + + /** + * The range type (can be used to force the axis to display only positive + * values or only negative values). + */ + private RangeType rangeType; + + /** + * A flag that affects the axis range when the range is determined + * automatically. If the auto range does NOT include zero and this flag + * is TRUE, then the range is changed to include zero. + */ + private boolean autoRangeIncludesZero; + + /** + * A flag that affects the size of the margins added to the axis range when + * the range is determined automatically. If the value 0 falls within the + * margin and this flag is TRUE, then the margin is truncated at zero. + */ + private boolean autoRangeStickyZero; + + /** The tick unit for the axis. */ + private NumberTickUnit tickUnit; + + /** The override number format. */ + private NumberFormat numberFormatOverride; + + /** An optional band for marking regions on the axis. */ + private MarkerAxisBand markerBand; + + /** + * Default constructor. + */ + public NumberAxis() { + this(null); + } + + /** + * Constructs a number axis, using default values where necessary. + * + * @param label the axis label (null permitted). + */ + public NumberAxis(String label) { + super(label, NumberAxis.createStandardTickUnits()); + this.rangeType = RangeType.FULL; + this.autoRangeIncludesZero = DEFAULT_AUTO_RANGE_INCLUDES_ZERO; + this.autoRangeStickyZero = DEFAULT_AUTO_RANGE_STICKY_ZERO; + this.tickUnit = DEFAULT_TICK_UNIT; + this.numberFormatOverride = null; + this.markerBand = null; + } + + /** + * Returns the axis range type. + * + * @return The axis range type (never null). + * + * @see #setRangeType(RangeType) + */ + public RangeType getRangeType() { + return this.rangeType; + } + + /** + * Sets the axis range type. + * + * @param rangeType the range type (null not permitted). + * + * @see #getRangeType() + */ + public void setRangeType(RangeType rangeType) { + ParamChecks.nullNotPermitted(rangeType, "rangeType"); + this.rangeType = rangeType; + notifyListeners(new AxisChangeEvent(this)); + } + + /** + * Returns the flag that indicates whether or not the automatic axis range + * (if indeed it is determined automatically) is forced to include zero. + * + * @return The flag. + */ + public boolean getAutoRangeIncludesZero() { + return this.autoRangeIncludesZero; + } + + /** + * Sets the flag that indicates whether or not the axis range, if + * automatically calculated, is forced to include zero. + *

+ * If the flag is changed to true, the axis range is + * recalculated. + *

+ * Any change to the flag will trigger an {@link AxisChangeEvent}. + * + * @param flag the new value of the flag. + * + * @see #getAutoRangeIncludesZero() + */ + public void setAutoRangeIncludesZero(boolean flag) { + if (this.autoRangeIncludesZero != flag) { + this.autoRangeIncludesZero = flag; + if (isAutoRange()) { + autoAdjustRange(); + } + notifyListeners(new AxisChangeEvent(this)); + } + } + + /** + * Returns a flag that affects the auto-range when zero falls outside the + * data range but inside the margins defined for the axis. + * + * @return The flag. + * + * @see #setAutoRangeStickyZero(boolean) + */ + public boolean getAutoRangeStickyZero() { + return this.autoRangeStickyZero; + } + + /** + * Sets a flag that affects the auto-range when zero falls outside the data + * range but inside the margins defined for the axis. + * + * @param flag the new flag. + * + * @see #getAutoRangeStickyZero() + */ + public void setAutoRangeStickyZero(boolean flag) { + if (this.autoRangeStickyZero != flag) { + this.autoRangeStickyZero = flag; + if (isAutoRange()) { + autoAdjustRange(); + } + notifyListeners(new AxisChangeEvent(this)); + } + } + + /** + * Returns the tick unit for the axis. + *

+ * Note: if the autoTickUnitSelection flag is + * true the tick unit may be changed while the axis is being + * drawn, so in that case the return value from this method may be + * irrelevant if the method is called before the axis has been drawn. + * + * @return The tick unit for the axis. + * + * @see #setTickUnit(NumberTickUnit) + * @see ValueAxis#isAutoTickUnitSelection() + */ + 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 (null not permitted). + * + * @see #getTickUnit() + * @see #setTickUnit(NumberTickUnit, boolean, boolean) + */ + 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 (null not permitted). + * @param notify notify listeners? + * @param turnOffAutoSelect turn off the auto-tick selection? + */ + public void setTickUnit(NumberTickUnit unit, boolean notify, + boolean turnOffAutoSelect) { + + ParamChecks.nullNotPermitted(unit, "unit"); + 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 null). + * + * @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 (null permitted). + * + * @see #getNumberFormatOverride() + */ + public void setNumberFormatOverride(NumberFormat formatter) { + this.numberFormatOverride = formatter; + notifyListeners(new AxisChangeEvent(this)); + } + + /** + * Returns the (optional) marker band for the axis. + * + * @return The marker band (possibly null). + * + * @see #setMarkerBand(MarkerAxisBand) + */ + public MarkerAxisBand getMarkerBand() { + return this.markerBand; + } + + /** + * Sets the marker band for the axis. + *

+ * The marker band is optional, leave it set to null if you + * don't require it. + * + * @param band the new band (null permitted). + * + * @see #getMarkerBand() + */ + public void setMarkerBand(MarkerAxisBand band) { + this.markerBand = band; + notifyListeners(new AxisChangeEvent(this)); + } + + /** + * Configures the axis to work with the specified plot. If the axis has + * auto-scaling, then sets the maximum and minimum values. + */ + @Override + public void configure() { + if (isAutoRange()) { + autoAdjustRange(); + } + } + + /** + * Rescales the axis to ensure that all data is visible. + */ + @Override + 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 = r.getLowerBound(); + if (this.rangeType == RangeType.POSITIVE) { + lower = Math.max(0.0, lower); + upper = Math.max(0.0, upper); + } + else if (this.rangeType == RangeType.NEGATIVE) { + lower = Math.min(0.0, lower); + upper = Math.min(0.0, upper); + } + + if (getAutoRangeIncludesZero()) { + lower = Math.min(lower, 0.0); + upper = Math.max(upper, 0.0); + } + double range = upper - lower; + + // if fixed auto range, then derive lower bound... + double fixedAutoRange = getFixedAutoRange(); + if (fixedAutoRange > 0.0) { + lower = upper - fixedAutoRange; + } + else { + // ensure the autorange is at least in size... + double minRange = getAutoRangeMinimumSize(); + if (range < minRange) { + double expand = (minRange - range) / 2; + upper = upper + expand; + lower = lower - expand; + if (lower == upper) { // see bug report 1549218 + double adjust = Math.abs(lower) / 10.0; + lower = lower - adjust; + upper = upper + adjust; + } + if (this.rangeType == RangeType.POSITIVE) { + if (lower < 0.0) { + upper = upper - lower; + lower = 0.0; + } + } + else if (this.rangeType == RangeType.NEGATIVE) { + if (upper > 0.0) { + lower = lower - upper; + upper = 0.0; + } + } + } + + if (getAutoRangeStickyZero()) { + if (upper <= 0.0) { + upper = Math.min(0.0, upper + getUpperMargin() * range); + } + else { + upper = upper + getUpperMargin() * range; + } + if (lower >= 0.0) { + lower = Math.max(0.0, lower - getLowerMargin() * range); + } + else { + lower = lower - getLowerMargin() * range; + } + } + else { + upper = upper + getUpperMargin() * range; + lower = lower - getLowerMargin() * range; + } + } + + setRange(new Range(lower, upper), false, false); + } + + } + + /** + * Converts a data value to a coordinate in Java2D space, assuming that the + * axis runs along one edge of the specified dataArea. + *

+ * Note that it is possible for the coordinate to fall outside the plotArea. + * + * @param value the data value. + * @param area the area for plotting the data. + * @param edge the axis location. + * + * @return The Java2D coordinate. + * + * @see #java2DToValue(double, Rectangle2D, RectangleEdge) + */ + @Override + public double valueToJava2D(double value, Rectangle2D area, + RectangleEdge edge) { + + Range range = getRange(); + double axisMin = range.getLowerBound(); + double axisMax = 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)) { + 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); + } + + } + + /** + * Converts a coordinate in Java2D space to the corresponding data value, + * assuming that the axis runs along one edge of the specified dataArea. + * + * @param java2DValue the coordinate in Java2D space. + * @param area the area in which the data is plotted. + * @param edge the location. + * + * @return The data value. + * + * @see #valueToJava2D(double, Rectangle2D, RectangleEdge) + */ + @Override + public double java2DToValue(double java2DValue, Rectangle2D area, + RectangleEdge edge) { + + Range range = getRange(); + double axisMin = range.getLowerBound(); + double axisMax = 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(); + } + if (isInverted()) { + return axisMax + - (java2DValue - min) / (max - min) * (axisMax - axisMin); + } + else { + return axisMin + + (java2DValue - min) / (max - min) * (axisMax - axisMin); + } + + } + + /** + * Calculates the value of the lowest visible tick on the axis. + * + * @return The value of the lowest visible tick on the axis. + * + * @see #calculateHighestVisibleTickValue() + */ + protected double calculateLowestVisibleTickValue() { + double unit = getTickUnit().getSize(); + double index = Math.ceil(getRange().getLowerBound() / unit); + return index * unit; + } + + /** + * Calculates the value of the highest visible tick on the axis. + * + * @return The value of the highest visible tick on the axis. + * + * @see #calculateLowestVisibleTickValue() + */ + protected double calculateHighestVisibleTickValue() { + double unit = getTickUnit().getSize(); + double index = Math.floor(getRange().getUpperBound() / unit); + return index * unit; + } + + /** + * Calculates the number of visible ticks. + * + * @return The number of visible ticks on the axis. + */ + protected int calculateVisibleTickCount() { + double unit = getTickUnit().getSize(); + Range range = getRange(); + return (int) (Math.floor(range.getUpperBound() / unit) + - Math.ceil(range.getLowerBound() / unit) + 1); + } + + /** + * Draws the axis on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device (null not permitted). + * @param cursor the cursor location. + * @param plotArea the area within which the axes and data should be drawn + * (null not permitted). + * @param dataArea the area within which the data should be drawn + * (null not permitted). + * @param edge the location of the axis (null not permitted). + * @param plotState collects information about the plot + * (null permitted). + * + * @return The axis state (never null). + */ + @Override + public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, + Rectangle2D dataArea, RectangleEdge edge, + PlotRenderingInfo plotState) { + + AxisState state; + // 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; + } + + // draw the tick marks and labels... + state = drawTickMarksAndLabels(g2, cursor, plotArea, dataArea, edge); + + if (getAttributedLabel() != null) { + state = drawAttributedLabel(getAttributedLabel(), g2, plotArea, + dataArea, edge, state); + + } else { + state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); + } + createAndAddEntity(cursor, state, dataArea, edge, plotState); + return state; + + } + + /** + * Creates the standard tick units. + *

+ * If you don't like these defaults, create your own instance of TickUnits + * and then pass it to the setStandardTickUnits() method in the + * NumberAxis class. + * + * @return The standard tick units. + * + * @see #setStandardTickUnits(TickUnitSource) + * @see #createIntegerTickUnits() + */ + public static TickUnitSource createStandardTickUnits() { + + TickUnits units = new TickUnits(); + DecimalFormat df000 = new DecimalFormat("0.0000000000"); + DecimalFormat df00 = new DecimalFormat("0.000000000"); + DecimalFormat df0 = new DecimalFormat("0.00000000"); + DecimalFormat df1 = new DecimalFormat("0.0000000"); + DecimalFormat df2 = new DecimalFormat("0.000000"); + DecimalFormat df3 = new DecimalFormat("0.00000"); + DecimalFormat df4 = new DecimalFormat("0.0000"); + DecimalFormat df5 = new DecimalFormat("0.000"); + DecimalFormat df6 = new DecimalFormat("0.00"); + DecimalFormat df7 = new DecimalFormat("0.0"); + DecimalFormat df8 = new DecimalFormat("#,##0"); + DecimalFormat df9 = new DecimalFormat("#,###,##0"); + DecimalFormat df10 = new DecimalFormat("#,###,###,##0"); + + // we can add the units in any order, the TickUnits collection will + // sort them... + units.add(new NumberTickUnit(0.000000001, df00, 2)); + units.add(new NumberTickUnit(0.00000001, df0, 2)); + units.add(new NumberTickUnit(0.0000001, df1, 2)); + units.add(new NumberTickUnit(0.000001, df2, 2)); + units.add(new NumberTickUnit(0.00001, df3, 2)); + units.add(new NumberTickUnit(0.0001, df4, 2)); + units.add(new NumberTickUnit(0.001, df5, 2)); + units.add(new NumberTickUnit(0.01, df6, 2)); + units.add(new NumberTickUnit(0.1, df7, 2)); + units.add(new NumberTickUnit(1, df8, 2)); + units.add(new NumberTickUnit(10, df8, 2)); + units.add(new NumberTickUnit(100, df8, 2)); + units.add(new NumberTickUnit(1000, df8, 2)); + units.add(new NumberTickUnit(10000, df8, 2)); + units.add(new NumberTickUnit(100000, df8, 2)); + units.add(new NumberTickUnit(1000000, df9, 2)); + units.add(new NumberTickUnit(10000000, df9, 2)); + units.add(new NumberTickUnit(100000000, df9, 2)); + units.add(new NumberTickUnit(1000000000, df10, 2)); + units.add(new NumberTickUnit(10000000000.0, df10, 2)); + units.add(new NumberTickUnit(100000000000.0, df10, 2)); + + units.add(new NumberTickUnit(0.0000000025, df000, 5)); + units.add(new NumberTickUnit(0.000000025, df00, 5)); + units.add(new NumberTickUnit(0.00000025, df0, 5)); + units.add(new NumberTickUnit(0.0000025, df1, 5)); + units.add(new NumberTickUnit(0.000025, df2, 5)); + units.add(new NumberTickUnit(0.00025, df3, 5)); + units.add(new NumberTickUnit(0.0025, df4, 5)); + units.add(new NumberTickUnit(0.025, df5, 5)); + units.add(new NumberTickUnit(0.25, df6, 5)); + units.add(new NumberTickUnit(2.5, df7, 5)); + units.add(new NumberTickUnit(25, df8, 5)); + units.add(new NumberTickUnit(250, df8, 5)); + units.add(new NumberTickUnit(2500, df8, 5)); + units.add(new NumberTickUnit(25000, df8, 5)); + units.add(new NumberTickUnit(250000, df8, 5)); + units.add(new NumberTickUnit(2500000, df9, 5)); + units.add(new NumberTickUnit(25000000, df9, 5)); + units.add(new NumberTickUnit(250000000, df9, 5)); + units.add(new NumberTickUnit(2500000000.0, df10, 5)); + units.add(new NumberTickUnit(25000000000.0, df10, 5)); + units.add(new NumberTickUnit(250000000000.0, df10, 5)); + + units.add(new NumberTickUnit(0.000000005, df00, 5)); + units.add(new NumberTickUnit(0.00000005, df0, 5)); + units.add(new NumberTickUnit(0.0000005, df1, 5)); + units.add(new NumberTickUnit(0.000005, df2, 5)); + units.add(new NumberTickUnit(0.00005, df3, 5)); + units.add(new NumberTickUnit(0.0005, df4, 5)); + units.add(new NumberTickUnit(0.005, df5, 5)); + units.add(new NumberTickUnit(0.05, df6, 5)); + units.add(new NumberTickUnit(0.5, df7, 5)); + units.add(new NumberTickUnit(5L, df8, 5)); + units.add(new NumberTickUnit(50L, df8, 5)); + units.add(new NumberTickUnit(500L, df8, 5)); + units.add(new NumberTickUnit(5000L, df8, 5)); + units.add(new NumberTickUnit(50000L, df8, 5)); + units.add(new NumberTickUnit(500000L, df8, 5)); + units.add(new NumberTickUnit(5000000L, df9, 5)); + units.add(new NumberTickUnit(50000000L, df9, 5)); + units.add(new NumberTickUnit(500000000L, df9, 5)); + units.add(new NumberTickUnit(5000000000L, df10, 5)); + units.add(new NumberTickUnit(50000000000L, df10, 5)); + units.add(new NumberTickUnit(500000000000L, df10, 5)); + + return units; + + } + + /** + * Returns a collection of tick units for integer values. + * + * @return A collection of tick units for integer values. + * + * @see #setStandardTickUnits(TickUnitSource) + * @see #createStandardTickUnits() + */ + public static TickUnitSource createIntegerTickUnits() { + TickUnits units = new TickUnits(); + DecimalFormat df0 = new DecimalFormat("0"); + DecimalFormat df1 = new DecimalFormat("#,##0"); + units.add(new NumberTickUnit(1, df0, 2)); + units.add(new NumberTickUnit(2, df0, 2)); + units.add(new NumberTickUnit(5, df0, 5)); + units.add(new NumberTickUnit(10, df0, 2)); + units.add(new NumberTickUnit(20, df0, 2)); + units.add(new NumberTickUnit(50, df0, 5)); + units.add(new NumberTickUnit(100, df0, 2)); + units.add(new NumberTickUnit(200, df0, 2)); + units.add(new NumberTickUnit(500, df0, 5)); + units.add(new NumberTickUnit(1000, df1, 2)); + units.add(new NumberTickUnit(2000, df1, 2)); + units.add(new NumberTickUnit(5000, df1, 5)); + units.add(new NumberTickUnit(10000, df1, 2)); + units.add(new NumberTickUnit(20000, df1, 2)); + units.add(new NumberTickUnit(50000, df1, 5)); + units.add(new NumberTickUnit(100000, df1, 2)); + units.add(new NumberTickUnit(200000, df1, 2)); + units.add(new NumberTickUnit(500000, df1, 5)); + units.add(new NumberTickUnit(1000000, df1, 2)); + units.add(new NumberTickUnit(2000000, df1, 2)); + units.add(new NumberTickUnit(5000000, df1, 5)); + units.add(new NumberTickUnit(10000000, df1, 2)); + units.add(new NumberTickUnit(20000000, df1, 2)); + units.add(new NumberTickUnit(50000000, df1, 5)); + units.add(new NumberTickUnit(100000000, df1, 2)); + units.add(new NumberTickUnit(200000000, df1, 2)); + units.add(new NumberTickUnit(500000000, df1, 5)); + units.add(new NumberTickUnit(1000000000, df1, 2)); + units.add(new NumberTickUnit(2000000000, df1, 2)); + units.add(new NumberTickUnit(5000000000.0, df1, 5)); + units.add(new NumberTickUnit(10000000000.0, df1, 2)); + return units; + } + + /** + * Creates a collection of standard tick units. The supplied locale is + * used to create the number formatter (a localised instance of + * NumberFormat). + *

+ * If you don't like these defaults, create your own instance of + * {@link TickUnits} and then pass it to the + * setStandardTickUnits() method. + * + * @param locale the locale. + * + * @return A tick unit collection. + * + * @see #setStandardTickUnits(TickUnitSource) + */ + public static TickUnitSource createStandardTickUnits(Locale locale) { + + TickUnits units = new TickUnits(); + NumberFormat numberFormat = NumberFormat.getNumberInstance(locale); + // we can add the units in any order, the TickUnits collection will + // sort them... + units.add(new NumberTickUnit(0.0000001, numberFormat, 2)); + units.add(new NumberTickUnit(0.000001, numberFormat, 2)); + units.add(new NumberTickUnit(0.00001, numberFormat, 2)); + units.add(new NumberTickUnit(0.0001, numberFormat, 2)); + units.add(new NumberTickUnit(0.001, numberFormat, 2)); + units.add(new NumberTickUnit(0.01, numberFormat, 2)); + units.add(new NumberTickUnit(0.1, numberFormat, 2)); + units.add(new NumberTickUnit(1, numberFormat, 2)); + units.add(new NumberTickUnit(10, numberFormat, 2)); + units.add(new NumberTickUnit(100, numberFormat, 2)); + units.add(new NumberTickUnit(1000, numberFormat, 2)); + units.add(new NumberTickUnit(10000, numberFormat, 2)); + units.add(new NumberTickUnit(100000, numberFormat, 2)); + units.add(new NumberTickUnit(1000000, numberFormat, 2)); + units.add(new NumberTickUnit(10000000, numberFormat, 2)); + units.add(new NumberTickUnit(100000000, numberFormat, 2)); + units.add(new NumberTickUnit(1000000000, numberFormat, 2)); + units.add(new NumberTickUnit(10000000000.0, numberFormat, 2)); + + units.add(new NumberTickUnit(0.00000025, numberFormat, 5)); + units.add(new NumberTickUnit(0.0000025, numberFormat, 5)); + units.add(new NumberTickUnit(0.000025, numberFormat, 5)); + units.add(new NumberTickUnit(0.00025, numberFormat, 5)); + units.add(new NumberTickUnit(0.0025, numberFormat, 5)); + units.add(new NumberTickUnit(0.025, numberFormat, 5)); + units.add(new NumberTickUnit(0.25, numberFormat, 5)); + units.add(new NumberTickUnit(2.5, numberFormat, 5)); + units.add(new NumberTickUnit(25, numberFormat, 5)); + units.add(new NumberTickUnit(250, numberFormat, 5)); + units.add(new NumberTickUnit(2500, numberFormat, 5)); + units.add(new NumberTickUnit(25000, numberFormat, 5)); + units.add(new NumberTickUnit(250000, numberFormat, 5)); + units.add(new NumberTickUnit(2500000, numberFormat, 5)); + units.add(new NumberTickUnit(25000000, numberFormat, 5)); + units.add(new NumberTickUnit(250000000, numberFormat, 5)); + units.add(new NumberTickUnit(2500000000.0, numberFormat, 5)); + units.add(new NumberTickUnit(25000000000.0, numberFormat, 5)); + + units.add(new NumberTickUnit(0.0000005, numberFormat, 5)); + units.add(new NumberTickUnit(0.000005, numberFormat, 5)); + units.add(new NumberTickUnit(0.00005, numberFormat, 5)); + units.add(new NumberTickUnit(0.0005, numberFormat, 5)); + units.add(new NumberTickUnit(0.005, numberFormat, 5)); + units.add(new NumberTickUnit(0.05, numberFormat, 5)); + units.add(new NumberTickUnit(0.5, numberFormat, 5)); + units.add(new NumberTickUnit(5L, numberFormat, 5)); + units.add(new NumberTickUnit(50L, numberFormat, 5)); + units.add(new NumberTickUnit(500L, numberFormat, 5)); + units.add(new NumberTickUnit(5000L, numberFormat, 5)); + units.add(new NumberTickUnit(50000L, numberFormat, 5)); + units.add(new NumberTickUnit(500000L, numberFormat, 5)); + units.add(new NumberTickUnit(5000000L, numberFormat, 5)); + units.add(new NumberTickUnit(50000000L, numberFormat, 5)); + units.add(new NumberTickUnit(500000000L, numberFormat, 5)); + units.add(new NumberTickUnit(5000000000L, numberFormat, 5)); + units.add(new NumberTickUnit(50000000000L, numberFormat, 5)); + + return units; + + } + + /** + * Returns a collection of tick units for integer 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. + * + * @see #setStandardTickUnits(TickUnitSource) + */ + public static TickUnitSource createIntegerTickUnits(Locale locale) { + TickUnits units = new TickUnits(); + NumberFormat numberFormat = NumberFormat.getNumberInstance(locale); + units.add(new NumberTickUnit(1, numberFormat, 2)); + units.add(new NumberTickUnit(2, numberFormat, 2)); + units.add(new NumberTickUnit(5, numberFormat, 5)); + units.add(new NumberTickUnit(10, numberFormat, 2)); + units.add(new NumberTickUnit(20, numberFormat, 2)); + units.add(new NumberTickUnit(50, numberFormat, 5)); + units.add(new NumberTickUnit(100, numberFormat, 2)); + units.add(new NumberTickUnit(200, numberFormat, 2)); + units.add(new NumberTickUnit(500, numberFormat, 5)); + units.add(new NumberTickUnit(1000, numberFormat, 2)); + units.add(new NumberTickUnit(2000, numberFormat, 2)); + units.add(new NumberTickUnit(5000, numberFormat, 5)); + units.add(new NumberTickUnit(10000, numberFormat, 2)); + units.add(new NumberTickUnit(20000, numberFormat, 2)); + units.add(new NumberTickUnit(50000, numberFormat, 5)); + units.add(new NumberTickUnit(100000, numberFormat, 2)); + units.add(new NumberTickUnit(200000, numberFormat, 2)); + units.add(new NumberTickUnit(500000, numberFormat, 5)); + units.add(new NumberTickUnit(1000000, numberFormat, 2)); + units.add(new NumberTickUnit(2000000, numberFormat, 2)); + units.add(new NumberTickUnit(5000000, numberFormat, 5)); + units.add(new NumberTickUnit(10000000, numberFormat, 2)); + units.add(new NumberTickUnit(20000000, numberFormat, 2)); + units.add(new NumberTickUnit(50000000, numberFormat, 5)); + units.add(new NumberTickUnit(100000000, numberFormat, 2)); + units.add(new NumberTickUnit(200000000, numberFormat, 2)); + units.add(new NumberTickUnit(500000000, numberFormat, 5)); + units.add(new NumberTickUnit(1000000000, numberFormat, 2)); + units.add(new NumberTickUnit(2000000000, numberFormat, 2)); + units.add(new NumberTickUnit(5000000000.0, numberFormat, 5)); + units.add(new NumberTickUnit(10000000000.0, numberFormat, 2)); + return units; + } + + /** + * Estimates the maximum tick label height. + * + * @param g2 the graphics device. + * + * @return The maximum height. + */ + 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. + *

+ * 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. + */ + 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, 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; + + } + + /** + * 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. + */ + 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. + */ + 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 = lengthToJava2D(unit1.getSize(), dataArea, edge); + + // then extrapolate... + double guess = (tickLabelWidth / unit1Width) * unit1.getSize(); + + NumberTickUnit unit2 = (NumberTickUnit) tickUnits.getCeilingTickUnit( + guess); + double unit2Width = lengthToJava2D(unit2.getSize(), dataArea, edge); + + tickLabelWidth = estimateMaximumTickLabelWidth(g2, unit2); + if (tickLabelWidth > unit2Width) { + unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2); + } + + setTickUnit(unit2, false, false); + + } + + /** + * 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. + */ + 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 = lengthToJava2D(unit1.getSize(), dataArea, edge); + + // then extrapolate... + double guess = (tickLabelHeight / unitHeight) * unit1.getSize(); + + NumberTickUnit unit2 + = (NumberTickUnit) tickUnits.getCeilingTickUnit(guess); + double unit2Height = lengthToJava2D(unit2.getSize(), dataArea, edge); + + tickLabelHeight = estimateMaximumTickLabelHeight(g2); + if (tickLabelHeight > unit2Height) { + unit2 = (NumberTickUnit) tickUnits.getLargerTickUnit(unit2); + } + + setTickUnit(unit2, false, false); + + } + + /** + * 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. + */ + @Override + 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; + + } + + /** + * 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 dataArea the area in which the data should be drawn. + * @param edge the location of the axis. + * + * @return A list of ticks. + */ + protected List refreshTicksHorizontal(Graphics2D g2, + Rectangle2D dataArea, RectangleEdge edge) { + + List result = new java.util.ArrayList(); + + Font tickLabelFont = getTickLabelFont(); + g2.setFont(tickLabelFont); + + if (isAutoTickUnitSelection()) { + selectAutoTickUnit(g2, dataArea, edge); + } + + TickUnit tu = getTickUnit(); + double size = tu.getSize(); + int count = calculateVisibleTickCount(); + double lowestTickValue = calculateLowestVisibleTickValue(); + + if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { + int minorTickSpaces = getMinorTickCount(); + if (minorTickSpaces <= 0) { + minorTickSpaces = tu.getMinorTickCount(); + } + for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) { + double minorTickValue = lowestTickValue + - size * minorTick / minorTickSpaces; + if (getRange().contains(minorTickValue)) { + result.add(new NumberTick(TickType.MINOR, minorTickValue, + "", TextAnchor.TOP_CENTER, TextAnchor.CENTER, + 0.0)); + } + } + for (int i = 0; i < count; i++) { + double currentTickValue = lowestTickValue + (i * size); + String tickLabel; + NumberFormat formatter = getNumberFormatOverride(); + if (formatter != null) { + tickLabel = formatter.format(currentTickValue); + } + else { + tickLabel = getTickUnit().valueToString(currentTickValue); + } + TextAnchor anchor, rotationAnchor; + double angle = 0.0; + if (isVerticalTickLabels()) { + anchor = TextAnchor.CENTER_RIGHT; + rotationAnchor = TextAnchor.CENTER_RIGHT; + if (edge == RectangleEdge.TOP) { + angle = Math.PI / 2.0; + } + else { + angle = -Math.PI / 2.0; + } + } + else { + if (edge == RectangleEdge.TOP) { + anchor = TextAnchor.BOTTOM_CENTER; + rotationAnchor = TextAnchor.BOTTOM_CENTER; + } + else { + anchor = TextAnchor.TOP_CENTER; + rotationAnchor = TextAnchor.TOP_CENTER; + } + } + + Tick tick = new NumberTick(new Double(currentTickValue), + tickLabel, anchor, rotationAnchor, angle); + result.add(tick); + double nextTickValue = lowestTickValue + ((i + 1) * size); + for (int minorTick = 1; minorTick < minorTickSpaces; + minorTick++) { + double minorTickValue = currentTickValue + + (nextTickValue - currentTickValue) + * minorTick / minorTickSpaces; + if (getRange().contains(minorTickValue)) { + result.add(new NumberTick(TickType.MINOR, + minorTickValue, "", TextAnchor.TOP_CENTER, + TextAnchor.CENTER, 0.0)); + } + } + } + } + return result; + + } + + /** + * 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 dataArea the area in which the plot should be drawn. + * @param edge the location of the axis. + * + * @return A list of ticks. + */ + protected List refreshTicksVertical(Graphics2D g2, + Rectangle2D dataArea, RectangleEdge edge) { + + List result = new java.util.ArrayList(); + result.clear(); + + Font tickLabelFont = getTickLabelFont(); + g2.setFont(tickLabelFont); + if (isAutoTickUnitSelection()) { + selectAutoTickUnit(g2, dataArea, edge); + } + + TickUnit tu = getTickUnit(); + double size = tu.getSize(); + int count = calculateVisibleTickCount(); + double lowestTickValue = calculateLowestVisibleTickValue(); + + if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { + int minorTickSpaces = getMinorTickCount(); + if (minorTickSpaces <= 0) { + minorTickSpaces = tu.getMinorTickCount(); + } + for (int minorTick = 1; minorTick < minorTickSpaces; minorTick++) { + double minorTickValue = lowestTickValue + - size * minorTick / minorTickSpaces; + if (getRange().contains(minorTickValue)) { + result.add(new NumberTick(TickType.MINOR, minorTickValue, + "", TextAnchor.TOP_CENTER, TextAnchor.CENTER, + 0.0)); + } + } + + for (int i = 0; i < count; i++) { + double currentTickValue = lowestTickValue + (i * size); + String tickLabel; + NumberFormat formatter = getNumberFormatOverride(); + if (formatter != null) { + tickLabel = formatter.format(currentTickValue); + } + else { + tickLabel = getTickUnit().valueToString(currentTickValue); + } + + TextAnchor anchor; + TextAnchor rotationAnchor; + double angle = 0.0; + if (isVerticalTickLabels()) { + if (edge == RectangleEdge.LEFT) { + anchor = TextAnchor.BOTTOM_CENTER; + rotationAnchor = TextAnchor.BOTTOM_CENTER; + angle = -Math.PI / 2.0; + } + else { + anchor = TextAnchor.BOTTOM_CENTER; + rotationAnchor = TextAnchor.BOTTOM_CENTER; + angle = Math.PI / 2.0; + } + } + else { + if (edge == RectangleEdge.LEFT) { + anchor = TextAnchor.CENTER_RIGHT; + rotationAnchor = TextAnchor.CENTER_RIGHT; + } + else { + anchor = TextAnchor.CENTER_LEFT; + rotationAnchor = TextAnchor.CENTER_LEFT; + } + } + + Tick tick = new NumberTick(new Double(currentTickValue), + tickLabel, anchor, rotationAnchor, angle); + result.add(tick); + + double nextTickValue = lowestTickValue + ((i + 1) * size); + for (int minorTick = 1; minorTick < minorTickSpaces; + minorTick++) { + double minorTickValue = currentTickValue + + (nextTickValue - currentTickValue) + * minorTick / minorTickSpaces; + if (getRange().contains(minorTickValue)) { + result.add(new NumberTick(TickType.MINOR, + minorTickValue, "", TextAnchor.TOP_CENTER, + TextAnchor.CENTER, 0.0)); + } + } + } + } + return result; + + } + + /** + * Returns a clone of the axis. + * + * @return A clone + * + * @throws CloneNotSupportedException if some component of the axis does + * not support cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + NumberAxis clone = (NumberAxis) super.clone(); + if (this.numberFormatOverride != null) { + clone.numberFormatOverride + = (NumberFormat) this.numberFormatOverride.clone(); + } + return clone; + } + + /** + * Tests the axis for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof NumberAxis)) { + return false; + } + NumberAxis that = (NumberAxis) obj; + if (this.autoRangeIncludesZero != that.autoRangeIncludesZero) { + return false; + } + if (this.autoRangeStickyZero != that.autoRangeStickyZero) { + return false; + } + if (!ObjectUtilities.equal(this.tickUnit, that.tickUnit)) { + return false; + } + if (!ObjectUtilities.equal(this.numberFormatOverride, + that.numberFormatOverride)) { + return false; + } + if (!this.rangeType.equals(that.rangeType)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this object. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return super.hashCode(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/NumberAxis3D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/NumberAxis3D.java new file mode 100755 index 0000000..797522f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/NumberAxis3D.java @@ -0,0 +1,182 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * NumberAxis3D.java + * ----------------- + * (C) Copyright 2001-2009, by Serge V. Grachov and Contributors. + * + * Original Author: Serge V. Grachov; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Jonathan Nash; + * Richard Atkinson; + * Tin Luu; + * + * Changes + * ------- + * 31-Oct-2001 : Version 1 contributed by Serge V. Grachov (DG); + * 23-Nov-2001 : Overhauled auto tick unit code for all axes (DG); + * 12-Dec-2001 : Minor change due to grid lines bug fix (DG); + * 08-Jan-2002 : Added flag allowing the axis to be 'inverted'. That is, run + * from positive to negative. Added default values to + * constructors (DG); + * 16-Jan-2002 : Added an optional crosshair, based on the implementation by + * Jonathan Nash (DG); + * 25-Feb-2002 : Updated constructors for new autoRangeStickyZero flag (DG); + * 19-Apr-2002 : drawVerticalString() is now drawRotatedString() in + * RefineryUtilities (DG); + * 25-Jun-2002 : Removed redundant import (DG); + * 25-Jul-2002 : Changed order of parameters in ValueAxis constructor (DG); + * 06-Aug-2002 : Modified draw method to not draw axis label if label is empty + * String (RA); + * 05-Sep-2002 : Updated constructor for changes in the Axis class, and changed + * draw method to observe tickMarkPaint (DG); + * 22-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); + * 20-Jan-2003 : Removed unnecessary constructors (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 13-May-2003 : Merged HorizontalNumberAxis3D and VerticalNumberAxis3D (DG); + * 21-Aug-2003 : Updated draw() method signature (DG); + * 07-Nov-2003 : Modified refreshTicks method signature (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 18-Jan-2006 : Fixed bug 1408904 (axis assumes CategoryPlot) (DG): + * 16-Apr-2009 : Changed axis line visibility default (DG); + * 01-Aug-2013 : Added attributedLabel override to support superscripts, + * subscripts and more (DG); * + */ + +package org.jfree.chart.axis; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; +import java.util.List; + +import org.jfree.chart.Effect3D; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.ui.RectangleEdge; + +/** + * A standard linear value axis with a 3D effect corresponding to the + * offset specified by some renderers. + */ +public class NumberAxis3D extends NumberAxis implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -1790205852569123512L; + + /** + * Default constructor. + */ + public NumberAxis3D() { + this(null); + } + + /** + * Constructs a new axis. + * + * @param label the axis label (null permitted). + */ + public NumberAxis3D(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. + * @param cursor the cursor. + * @param plotArea the area for drawing the axes and data. + * @param dataArea the area for drawing the data (a subset of the + * plotArea). + * @param edge the axis location. + * @param plotState collects information about the plot (null + * permitted). + * + * @return The updated cursor value. + */ + @Override + 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()) { + AxisState 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; + } + + // calculate the adjusted data area taking into account the 3D effect... + double xOffset = 0.0; + double yOffset = 0.0; + Plot plot = getPlot(); + if (plot instanceof CategoryPlot) { + CategoryPlot cp = (CategoryPlot) plot; + CategoryItemRenderer r = cp.getRenderer(); + if (r instanceof Effect3D) { + Effect3D e3D = (Effect3D) r; + xOffset = e3D.getXOffset(); + yOffset = e3D.getYOffset(); + } + } + + double adjustedX = dataArea.getMinX(); + double adjustedY = dataArea.getMinY(); + double adjustedW = dataArea.getWidth() - xOffset; + double adjustedH = dataArea.getHeight() - yOffset; + + if (edge == RectangleEdge.LEFT || edge == RectangleEdge.BOTTOM) { + adjustedY += yOffset; + } + else if (edge == RectangleEdge.RIGHT || edge == RectangleEdge.TOP) { + adjustedX += xOffset; + } + Rectangle2D adjustedDataArea = new Rectangle2D.Double(adjustedX, + adjustedY, adjustedW, adjustedH); + + // draw the tick marks and labels... + AxisState info = drawTickMarksAndLabels(g2, cursor, plotArea, + adjustedDataArea, edge); + + if (getAttributedLabel() != null) { + info = drawAttributedLabel(getAttributedLabel(), g2, plotArea, + dataArea, edge, info); + } else { + info = drawLabel(getLabel(), g2, plotArea, dataArea, edge, info); + } + return info; + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/NumberTick.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/NumberTick.java new file mode 100755 index 0000000..e5afcfe --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/NumberTick.java @@ -0,0 +1,104 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * NumberTick.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); + * 02-Aug-2007 : Added new constructor with tick type (DG); + * + */ + +package org.jfree.chart.axis; + +import org.jfree.ui.TextAnchor; + +/** + * A numerical tick. + */ +public class NumberTick extends ValueTick { + + /** The number. */ + private Number number; + + /** + * Creates a new tick. + * + * @param number the number (null not permitted). + * @param label the label. + * @param textAnchor the part of the label that is aligned with the anchor + * point. + * @param rotationAnchor defines the rotation point relative to the text. + * @param angle the rotation angle (in radians). + */ + public NumberTick(Number number, String label, + TextAnchor textAnchor, + TextAnchor rotationAnchor, double angle) { + + super(number.doubleValue(), label, textAnchor, rotationAnchor, angle); + this.number = number; + + } + + /** + * Creates a new tick. + * + * @param tickType the tick type. + * @param value the value. + * @param label the label. + * @param textAnchor the part of the label that is aligned with the anchor + * point. + * @param rotationAnchor defines the rotation point relative to the text. + * @param angle the rotation angle (in radians). + * + * @since 1.0.7 + */ + public NumberTick(TickType tickType, double value, String label, + TextAnchor textAnchor, + TextAnchor rotationAnchor, double angle) { + + super(tickType, value, label, textAnchor, rotationAnchor, angle); + this.number = new Double(value); + + } + + /** + * Returns the number. + * + * @return The number. + */ + public Number getNumber() { + return this.number; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/NumberTickUnit.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/NumberTickUnit.java new file mode 100755 index 0000000..70b8fd1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/NumberTickUnit.java @@ -0,0 +1,166 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * NumberTickUnit.java + * ------------------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Dec-2001 : Added standard header (DG); + * 01-May-2002 : Updated for changed to TickUnit class (DG); + * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); + * 09-Jan-2002 : Added a new constructor (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 05-Jul-2005 : Added equals() implementation (DG); + * 05-Sep-2005 : Implemented hashCode(), thanks to Thomas Morgner (DG); + * 02-Aug-2007 : Added new constructor with minorTickCount (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.Serializable; +import java.text.NumberFormat; +import org.jfree.chart.util.ParamChecks; + +/** + * A numerical tick unit. + */ +public class NumberTickUnit extends TickUnit implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 3849459506627654442L; + + /** A formatter for the tick unit. */ + private NumberFormat formatter; + + /** + * Creates a new number tick unit. + * + * @param size the size of the tick unit. + */ + public NumberTickUnit(double size) { + this(size, NumberFormat.getNumberInstance()); + } + + /** + * Creates a new number tick unit. + * + * @param size the size of the tick unit. + * @param formatter a number formatter for the tick unit (null + * not permitted). + */ + public NumberTickUnit(double size, NumberFormat formatter) { + super(size); + ParamChecks.nullNotPermitted(formatter, "formatter"); + this.formatter = formatter; + } + + /** + * Creates a new number tick unit. + * + * @param size the size of the tick unit. + * @param formatter a number formatter for the tick unit (null + * not permitted). + * @param minorTickCount the number of minor ticks. + * + * @since 1.0.7 + */ + public NumberTickUnit(double size, NumberFormat formatter, + int minorTickCount) { + super(size, minorTickCount); + ParamChecks.nullNotPermitted(formatter, "formatter"); + this.formatter = formatter; + } + + /** + * Converts a value to a string. + * + * @param value the value. + * + * @return The formatted string. + */ + @Override + public String valueToString(double value) { + return this.formatter.format(value); + } + + /** + * Tests this formatter for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof NumberTickUnit)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + NumberTickUnit that = (NumberTickUnit) obj; + if (!this.formatter.equals(that.formatter)) { + return false; + } + return true; + } + + /** + * Returns a string representing this unit. + * + * @return A string. + */ + @Override + public String toString() { + return "[size=" + this.valueToString(this.getSize()) + "]"; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = super.hashCode(); + result = 29 * result + (this.formatter != null + ? this.formatter.hashCode() : 0); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/PeriodAxis.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/PeriodAxis.java new file mode 100755 index 0000000..2226d54 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/PeriodAxis.java @@ -0,0 +1,1230 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * PeriodAxis.java + * --------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 01-Jun-2004 : Version 1 (DG); + * 16-Sep-2004 : Fixed bug in equals() method, added clone() method and + * PublicCloneable interface (DG); + * 25-Nov-2004 : Updates to support major and minor tick marks (DG); + * 25-Feb-2005 : Fixed some tick mark bugs (DG); + * 15-Apr-2005 : Fixed some more tick mark bugs (DG); + * 26-Apr-2005 : Removed LOGGER (DG); + * 16-Jun-2005 : Fixed zooming (DG); + * 15-Sep-2005 : Changed configure() method to check autoRange flag, + * and added ticks to state (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 06-Oct-2006 : Updated for deprecations in RegularTimePeriod and + * subclasses (DG); + * 22-Mar-2007 : Use new defaultAutoRange attribute (DG); + * 31-Jul-2007 : Fix for inverted axis labelling (see bug 1763413) (DG); + * 08-Apr-2008 : Notify listeners in setRange(Range, boolean, boolean) - fixes + * bug 1932146 (DG); + * 16-Jan-2009 : Fixed bug 2490803, a problem in the setRange() method (DG); + * 02-Mar-2009 : Added locale - see patch 2569670 by Benjamin Bignell (DG); + * 02-Mar-2009 : Fixed draw() method to check tickMarksVisible and + * tickLabelsVisible (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * 25-Jul-2013 : Fix for axis timezone and label formatting, bug 1107 (DG); + * 01-Aug-2013 : Added attributedLabel override to support superscripts, + * subscripts and more (DG); + * + */ + +package org.jfree.chart.axis; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.FontMetrics; +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 java.lang.reflect.Constructor; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import java.util.Locale; +import java.util.TimeZone; + +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.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.time.Day; +import org.jfree.data.time.Month; +import org.jfree.data.time.RegularTimePeriod; +import org.jfree.data.time.Year; +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.TextAnchor; +import org.jfree.util.PublicCloneable; + +/** + * An axis that displays a date scale based on a + * {@link org.jfree.data.time.RegularTimePeriod}. This axis works when + * displayed across the bottom or top of a plot, but is broken for display at + * the left or right of charts. + */ +public class PeriodAxis extends ValueAxis + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 8353295532075872069L; + + /** The first time period in the overall range. */ + private RegularTimePeriod first; + + /** The last time period in the overall range. */ + private RegularTimePeriod last; + + /** + * The time zone used to convert 'first' and 'last' to absolute + * milliseconds. + */ + private TimeZone timeZone; + + /** + * The locale (never null). + * + * @since 1.0.13 + */ + private Locale locale; + + /** + * A calendar used for date manipulations in the current time zone and + * locale. + */ + private Calendar calendar; + + /** + * The {@link RegularTimePeriod} subclass used to automatically determine + * the axis range. + */ + private Class autoRangeTimePeriodClass; + + /** + * Indicates the {@link RegularTimePeriod} subclass that is used to + * determine the spacing of the major tick marks. + */ + private Class majorTickTimePeriodClass; + + /** + * A flag that indicates whether or not tick marks are visible for the + * axis. + */ + private boolean minorTickMarksVisible; + + /** + * Indicates the {@link RegularTimePeriod} subclass that is used to + * determine the spacing of the minor tick marks. + */ + private Class minorTickTimePeriodClass; + + /** The length of the tick mark inside the data area (zero permitted). */ + private float minorTickMarkInsideLength = 0.0f; + + /** The length of the tick mark outside the data area (zero permitted). */ + private float minorTickMarkOutsideLength = 2.0f; + + /** The stroke used to draw tick marks. */ + private transient Stroke minorTickMarkStroke = new BasicStroke(0.5f); + + /** The paint used to draw tick marks. */ + private transient Paint minorTickMarkPaint = Color.black; + + /** Info for each labeling band. */ + private PeriodAxisLabelInfo[] labelInfo; + + /** + * Creates a new axis. + * + * @param label the axis label. + */ + public PeriodAxis(String label) { + this(label, new Day(), new Day()); + } + + /** + * Creates a new axis. + * + * @param label the axis label (null permitted). + * @param first the first time period in the axis range + * (null not permitted). + * @param last the last time period in the axis range + * (null not permitted). + */ + public PeriodAxis(String label, + RegularTimePeriod first, RegularTimePeriod last) { + this(label, first, last, TimeZone.getDefault(), Locale.getDefault()); + } + + /** + * Creates a new axis. + * + * @param label the axis label (null permitted). + * @param first the first time period in the axis range + * (null not permitted). + * @param last the last time period in the axis range + * (null not permitted). + * @param timeZone the time zone (null not permitted). + * + * @deprecated As of version 1.0.13, you should use the constructor that + * specifies a Locale also. + */ + public PeriodAxis(String label, RegularTimePeriod first, + RegularTimePeriod last, TimeZone timeZone) { + this(label, first, last, timeZone, Locale.getDefault()); + } + + /** + * Creates a new axis. + * + * @param label the axis label (null permitted). + * @param first the first time period in the axis range + * (null not permitted). + * @param last the last time period in the axis range + * (null not permitted). + * @param timeZone the time zone (null not permitted). + * @param locale the locale (null not permitted). + * + * @since 1.0.13 + */ + public PeriodAxis(String label, RegularTimePeriod first, + RegularTimePeriod last, TimeZone timeZone, Locale locale) { + super(label, null); + ParamChecks.nullNotPermitted(timeZone, "timeZone"); + ParamChecks.nullNotPermitted(locale, "locale"); + this.first = first; + this.last = last; + this.timeZone = timeZone; + this.locale = locale; + this.calendar = Calendar.getInstance(timeZone, locale); + this.first.peg(this.calendar); + this.last.peg(this.calendar); + this.autoRangeTimePeriodClass = first.getClass(); + this.majorTickTimePeriodClass = first.getClass(); + this.minorTickMarksVisible = false; + this.minorTickTimePeriodClass = RegularTimePeriod.downsize( + this.majorTickTimePeriodClass); + setAutoRange(true); + this.labelInfo = new PeriodAxisLabelInfo[2]; + SimpleDateFormat df0 = new SimpleDateFormat("MMM", locale); + df0.setTimeZone(timeZone); + this.labelInfo[0] = new PeriodAxisLabelInfo(Month.class, df0); + SimpleDateFormat df1 = new SimpleDateFormat("yyyy", locale); + df1.setTimeZone(timeZone); + this.labelInfo[1] = new PeriodAxisLabelInfo(Year.class, df1); + } + + /** + * Returns the first time period in the axis range. + * + * @return The first time period (never null). + */ + public RegularTimePeriod getFirst() { + return this.first; + } + + /** + * Sets the first time period in the axis range and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param first the time period (null not permitted). + */ + public void setFirst(RegularTimePeriod first) { + ParamChecks.nullNotPermitted(first, "first"); + this.first = first; + this.first.peg(this.calendar); + fireChangeEvent(); + } + + /** + * Returns the last time period in the axis range. + * + * @return The last time period (never null). + */ + public RegularTimePeriod getLast() { + return this.last; + } + + /** + * Sets the last time period in the axis range and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param last the time period (null not permitted). + */ + public void setLast(RegularTimePeriod last) { + ParamChecks.nullNotPermitted(last, "last"); + this.last = last; + this.last.peg(this.calendar); + fireChangeEvent(); + } + + /** + * Returns the time zone used to convert the periods defining the axis + * range into absolute milliseconds. + * + * @return The time zone (never null). + */ + public TimeZone getTimeZone() { + return this.timeZone; + } + + /** + * Sets the time zone that is used to convert the time periods into + * absolute milliseconds. + * + * @param zone the time zone (null not permitted). + */ + public void setTimeZone(TimeZone zone) { + ParamChecks.nullNotPermitted(zone, "zone"); + this.timeZone = zone; + this.calendar = Calendar.getInstance(zone, this.locale); + this.first.peg(this.calendar); + this.last.peg(this.calendar); + fireChangeEvent(); + } + + /** + * Returns the locale for this axis. + * + * @return The locale (never (null). + * + * @since 1.0.13 + */ + public Locale getLocale() { + return this.locale; + } + + /** + * Returns the class used to create the first and last time periods for + * the axis range when the auto-range flag is set to true. + * + * @return The class (never null). + */ + public Class getAutoRangeTimePeriodClass() { + return this.autoRangeTimePeriodClass; + } + + /** + * Sets the class used to create the first and last time periods for the + * axis range when the auto-range flag is set to true and + * sends an {@link AxisChangeEvent} to all registered listeners. + * + * @param c the class (null not permitted). + */ + public void setAutoRangeTimePeriodClass(Class c) { + ParamChecks.nullNotPermitted(c, "c"); + this.autoRangeTimePeriodClass = c; + fireChangeEvent(); + } + + /** + * Returns the class that controls the spacing of the major tick marks. + * + * @return The class (never null). + */ + public Class getMajorTickTimePeriodClass() { + return this.majorTickTimePeriodClass; + } + + /** + * Sets the class that controls the spacing of the major tick marks, and + * sends an {@link AxisChangeEvent} to all registered listeners. + * + * @param c the class (a subclass of {@link RegularTimePeriod} is + * expected). + */ + public void setMajorTickTimePeriodClass(Class c) { + ParamChecks.nullNotPermitted(c, "c"); + this.majorTickTimePeriodClass = c; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not minor tick marks + * are displayed for the axis. + * + * @return A boolean. + */ + @Override + public boolean isMinorTickMarksVisible() { + return this.minorTickMarksVisible; + } + + /** + * Sets the flag that controls whether or not minor tick marks + * are displayed for the axis, and sends a {@link AxisChangeEvent} + * to all registered listeners. + * + * @param visible the flag. + */ + @Override + public void setMinorTickMarksVisible(boolean visible) { + this.minorTickMarksVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the class that controls the spacing of the minor tick marks. + * + * @return The class (never null). + */ + public Class getMinorTickTimePeriodClass() { + return this.minorTickTimePeriodClass; + } + + /** + * Sets the class that controls the spacing of the minor tick marks, and + * sends an {@link AxisChangeEvent} to all registered listeners. + * + * @param c the class (a subclass of {@link RegularTimePeriod} is + * expected). + */ + public void setMinorTickTimePeriodClass(Class c) { + ParamChecks.nullNotPermitted(c, "c"); + this.minorTickTimePeriodClass = c; + fireChangeEvent(); + } + + /** + * Returns the stroke used to display minor tick marks, if they are + * visible. + * + * @return A stroke (never null). + */ + public Stroke getMinorTickMarkStroke() { + return this.minorTickMarkStroke; + } + + /** + * Sets the stroke used to display minor tick marks, if they are + * visible, and sends a {@link AxisChangeEvent} to all registered + * listeners. + * + * @param stroke the stroke (null not permitted). + */ + public void setMinorTickMarkStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.minorTickMarkStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint used to display minor tick marks, if they are + * visible. + * + * @return A paint (never null). + */ + public Paint getMinorTickMarkPaint() { + return this.minorTickMarkPaint; + } + + /** + * Sets the paint used to display minor tick marks, if they are + * visible, and sends a {@link AxisChangeEvent} to all registered + * listeners. + * + * @param paint the paint (null not permitted). + */ + public void setMinorTickMarkPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.minorTickMarkPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the inside length for the minor tick marks. + * + * @return The length. + */ + @Override + public float getMinorTickMarkInsideLength() { + return this.minorTickMarkInsideLength; + } + + /** + * Sets the inside length of the minor tick marks and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param length the length. + */ + @Override + public void setMinorTickMarkInsideLength(float length) { + this.minorTickMarkInsideLength = length; + fireChangeEvent(); + } + + /** + * Returns the outside length for the minor tick marks. + * + * @return The length. + */ + @Override + public float getMinorTickMarkOutsideLength() { + return this.minorTickMarkOutsideLength; + } + + /** + * Sets the outside length of the minor tick marks and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param length the length. + */ + @Override + public void setMinorTickMarkOutsideLength(float length) { + this.minorTickMarkOutsideLength = length; + fireChangeEvent(); + } + + /** + * Returns an array of label info records. + * + * @return An array. + */ + public PeriodAxisLabelInfo[] getLabelInfo() { + return this.labelInfo; + } + + /** + * Sets the array of label info records and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param info the info. + */ + public void setLabelInfo(PeriodAxisLabelInfo[] info) { + this.labelInfo = info; + fireChangeEvent(); + } + + /** + * Sets the range for the axis, if requested, sends an + * {@link AxisChangeEvent} to all registered listeners. As a side-effect, + * the auto-range flag is set to false (optional). + * + * @param range the range (null not permitted). + * @param turnOffAutoRange a flag that controls whether or not the auto + * range is turned off. + * @param notify a flag that controls whether or not listeners are + * notified. + */ + @Override + public void setRange(Range range, boolean turnOffAutoRange, + boolean notify) { + long upper = Math.round(range.getUpperBound()); + long lower = Math.round(range.getLowerBound()); + this.first = createInstance(this.autoRangeTimePeriodClass, + new Date(lower), this.timeZone, this.locale); + this.last = createInstance(this.autoRangeTimePeriodClass, + new Date(upper), this.timeZone, this.locale); + super.setRange(new Range(this.first.getFirstMillisecond(), + this.last.getLastMillisecond() + 1.0), turnOffAutoRange, + notify); + } + + /** + * Configures the axis to work with the current plot. Override this method + * to perform any special processing (such as auto-rescaling). + */ + @Override + public void configure() { + if (this.isAutoRange()) { + autoAdjustRange(); + } + } + + /** + * Estimates the space (height or width) required to draw the axis. + * + * @param g2 the graphics device. + * @param plot the plot that the axis belongs to. + * @param plotArea the area within which the plot (including axes) should + * be drawn. + * @param edge the axis location. + * @param space space already reserved. + * + * @return The space required to draw the axis (including pre-reserved + * space). + */ + @Override + public AxisSpace reserveSpace(Graphics2D g2, Plot plot, + Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) { + // create a new space object if one wasn't supplied... + if (space == null) { + space = new AxisSpace(); + } + + // if the axis is not visible, no additional space is required... + if (!isVisible()) { + return space; + } + + // if the axis has a fixed dimension, return it... + double dimension = getFixedDimension(); + if (dimension > 0.0) { + space.ensureAtLeast(dimension, edge); + } + + // get the axis label size and update the space object... + Rectangle2D labelEnclosure = getLabelEnclosure(g2, edge); + double labelHeight, labelWidth; + double tickLabelBandsDimension = 0.0; + + for (int i = 0; i < this.labelInfo.length; i++) { + PeriodAxisLabelInfo info = this.labelInfo[i]; + FontMetrics fm = g2.getFontMetrics(info.getLabelFont()); + tickLabelBandsDimension + += info.getPadding().extendHeight(fm.getHeight()); + } + + if (RectangleEdge.isTopOrBottom(edge)) { + labelHeight = labelEnclosure.getHeight(); + space.add(labelHeight + tickLabelBandsDimension, edge); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + labelWidth = labelEnclosure.getWidth(); + space.add(labelWidth + tickLabelBandsDimension, edge); + } + + // add space for the outer tick labels, if any... + double tickMarkSpace = 0.0; + if (isTickMarksVisible()) { + tickMarkSpace = getTickMarkOutsideLength(); + } + if (this.minorTickMarksVisible) { + tickMarkSpace = Math.max(tickMarkSpace, + this.minorTickMarkOutsideLength); + } + space.add(tickMarkSpace, edge); + return space; + } + + /** + * Draws the axis on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device (null 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 (null not permitted). + * @param plotState collects information about the plot + * (null permitted). + * + * @return The axis state (never null). + */ + @Override + public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, + Rectangle2D dataArea, RectangleEdge edge, + PlotRenderingInfo plotState) { + + AxisState axisState = new AxisState(cursor); + if (isAxisLineVisible()) { + drawAxisLine(g2, cursor, dataArea, edge); + } + if (isTickMarksVisible()) { + drawTickMarks(g2, axisState, dataArea, edge); + } + if (isTickLabelsVisible()) { + for (int band = 0; band < this.labelInfo.length; band++) { + axisState = drawTickLabels(band, g2, axisState, dataArea, edge); + } + } + + if (getAttributedLabel() != null) { + axisState = drawAttributedLabel(getAttributedLabel(), g2, plotArea, + dataArea, edge, axisState); + } else { + axisState = drawLabel(getLabel(), g2, plotArea, dataArea, edge, + axisState); + } + return axisState; + + } + + /** + * Draws the tick marks for the axis. + * + * @param g2 the graphics device. + * @param state the axis state. + * @param dataArea the data area. + * @param edge the edge. + */ + protected void drawTickMarks(Graphics2D g2, AxisState state, + Rectangle2D dataArea, RectangleEdge edge) { + if (RectangleEdge.isTopOrBottom(edge)) { + drawTickMarksHorizontal(g2, state, dataArea, edge); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + drawTickMarksVertical(g2, state, dataArea, edge); + } + } + + /** + * Draws the major and minor tick marks for an axis that lies at the top or + * bottom of the plot. + * + * @param g2 the graphics device. + * @param state the axis state. + * @param dataArea the data area. + * @param edge the edge. + */ + protected void drawTickMarksHorizontal(Graphics2D g2, AxisState state, + Rectangle2D dataArea, RectangleEdge edge) { + List ticks = new ArrayList(); + double x0; + double y0 = state.getCursor(); + double insideLength = getTickMarkInsideLength(); + double outsideLength = getTickMarkOutsideLength(); + RegularTimePeriod t = createInstance(this.majorTickTimePeriodClass, + this.first.getStart(), getTimeZone(), this.locale); + long t0 = t.getFirstMillisecond(); + Line2D inside = null; + Line2D outside = null; + long firstOnAxis = getFirst().getFirstMillisecond(); + long lastOnAxis = getLast().getLastMillisecond() + 1; + while (t0 <= lastOnAxis) { + ticks.add(new NumberTick(Double.valueOf(t0), "", TextAnchor.CENTER, + TextAnchor.CENTER, 0.0)); + x0 = valueToJava2D(t0, dataArea, edge); + if (edge == RectangleEdge.TOP) { + inside = new Line2D.Double(x0, y0, x0, y0 + insideLength); + outside = new Line2D.Double(x0, y0, x0, y0 - outsideLength); + } + else if (edge == RectangleEdge.BOTTOM) { + inside = new Line2D.Double(x0, y0, x0, y0 - insideLength); + outside = new Line2D.Double(x0, y0, x0, y0 + outsideLength); + } + if (t0 >= firstOnAxis) { + g2.setPaint(getTickMarkPaint()); + g2.setStroke(getTickMarkStroke()); + g2.draw(inside); + g2.draw(outside); + } + // draw minor tick marks + if (this.minorTickMarksVisible) { + RegularTimePeriod tminor = createInstance( + this.minorTickTimePeriodClass, new Date(t0), + getTimeZone(), this.locale); + long tt0 = tminor.getFirstMillisecond(); + while (tt0 < t.getLastMillisecond() + && tt0 < lastOnAxis) { + double xx0 = valueToJava2D(tt0, dataArea, edge); + if (edge == RectangleEdge.TOP) { + inside = new Line2D.Double(xx0, y0, xx0, + y0 + this.minorTickMarkInsideLength); + outside = new Line2D.Double(xx0, y0, xx0, + y0 - this.minorTickMarkOutsideLength); + } + else if (edge == RectangleEdge.BOTTOM) { + inside = new Line2D.Double(xx0, y0, xx0, + y0 - this.minorTickMarkInsideLength); + outside = new Line2D.Double(xx0, y0, xx0, + y0 + this.minorTickMarkOutsideLength); + } + if (tt0 >= firstOnAxis) { + g2.setPaint(this.minorTickMarkPaint); + g2.setStroke(this.minorTickMarkStroke); + g2.draw(inside); + g2.draw(outside); + } + tminor = tminor.next(); + tminor.peg(this.calendar); + tt0 = tminor.getFirstMillisecond(); + } + } + t = t.next(); + t.peg(this.calendar); + t0 = t.getFirstMillisecond(); + } + if (edge == RectangleEdge.TOP) { + state.cursorUp(Math.max(outsideLength, + this.minorTickMarkOutsideLength)); + } + else if (edge == RectangleEdge.BOTTOM) { + state.cursorDown(Math.max(outsideLength, + this.minorTickMarkOutsideLength)); + } + state.setTicks(ticks); + } + + /** + * Draws the tick marks for a vertical axis. + * + * @param g2 the graphics device. + * @param state the axis state. + * @param dataArea the data area. + * @param edge the edge. + */ + protected void drawTickMarksVertical(Graphics2D g2, AxisState state, + Rectangle2D dataArea, RectangleEdge edge) { + // FIXME: implement this... + } + + /** + * Draws the tick labels for one "band" of time periods. + * + * @param band the band index (zero-based). + * @param g2 the graphics device. + * @param state the axis state. + * @param dataArea the data area. + * @param edge the edge where the axis is located. + * + * @return The updated axis state. + */ + protected AxisState drawTickLabels(int band, Graphics2D g2, AxisState state, + Rectangle2D dataArea, RectangleEdge edge) { + + // work out the initial gap + double delta1 = 0.0; + FontMetrics fm = g2.getFontMetrics(this.labelInfo[band].getLabelFont()); + if (edge == RectangleEdge.BOTTOM) { + delta1 = this.labelInfo[band].getPadding().calculateTopOutset( + fm.getHeight()); + } + else if (edge == RectangleEdge.TOP) { + delta1 = this.labelInfo[band].getPadding().calculateBottomOutset( + fm.getHeight()); + } + state.moveCursor(delta1, edge); + long axisMin = this.first.getFirstMillisecond(); + long axisMax = this.last.getLastMillisecond(); + g2.setFont(this.labelInfo[band].getLabelFont()); + g2.setPaint(this.labelInfo[band].getLabelPaint()); + + // work out the number of periods to skip for labelling + RegularTimePeriod p1 = this.labelInfo[band].createInstance( + new Date(axisMin), this.timeZone, this.locale); + RegularTimePeriod p2 = this.labelInfo[band].createInstance( + new Date(axisMax), this.timeZone, this.locale); + DateFormat df = this.labelInfo[band].getDateFormat(); + df.setTimeZone(this.timeZone); + String label1 = df.format(new Date(p1.getMiddleMillisecond())); + String label2 = df.format(new Date(p2.getMiddleMillisecond())); + Rectangle2D b1 = TextUtilities.getTextBounds(label1, g2, + g2.getFontMetrics()); + Rectangle2D b2 = TextUtilities.getTextBounds(label2, g2, + g2.getFontMetrics()); + double w = Math.max(b1.getWidth(), b2.getWidth()); + long ww = Math.round(java2DToValue(dataArea.getX() + w + 5.0, + dataArea, edge)); + if (isInverted()) { + ww = axisMax - ww; + } + else { + ww = ww - axisMin; + } + long length = p1.getLastMillisecond() + - p1.getFirstMillisecond(); + int periods = (int) (ww / length) + 1; + + RegularTimePeriod p = this.labelInfo[band].createInstance( + new Date(axisMin), this.timeZone, this.locale); + Rectangle2D b = null; + long lastXX = 0L; + float y = (float) (state.getCursor()); + TextAnchor anchor = TextAnchor.TOP_CENTER; + float yDelta = (float) b1.getHeight(); + if (edge == RectangleEdge.TOP) { + anchor = TextAnchor.BOTTOM_CENTER; + yDelta = -yDelta; + } + while (p.getFirstMillisecond() <= axisMax) { + float x = (float) valueToJava2D(p.getMiddleMillisecond(), dataArea, + edge); + String label = df.format(new Date(p.getMiddleMillisecond())); + long first = p.getFirstMillisecond(); + long last = p.getLastMillisecond(); + if (last > axisMax) { + // this is the last period, but it is only partially visible + // so check that the label will fit before displaying it... + Rectangle2D bb = TextUtilities.getTextBounds(label, g2, + g2.getFontMetrics()); + if ((x + bb.getWidth() / 2) > dataArea.getMaxX()) { + float xstart = (float) valueToJava2D(Math.max(first, + axisMin), dataArea, edge); + if (bb.getWidth() < (dataArea.getMaxX() - xstart)) { + x = ((float) dataArea.getMaxX() + xstart) / 2.0f; + } + else { + label = null; + } + } + } + if (first < axisMin) { + // this is the first period, but it is only partially visible + // so check that the label will fit before displaying it... + Rectangle2D bb = TextUtilities.getTextBounds(label, g2, + g2.getFontMetrics()); + if ((x - bb.getWidth() / 2) < dataArea.getX()) { + float xlast = (float) valueToJava2D(Math.min(last, + axisMax), dataArea, edge); + if (bb.getWidth() < (xlast - dataArea.getX())) { + x = (xlast + (float) dataArea.getX()) / 2.0f; + } + else { + label = null; + } + } + + } + if (label != null) { + g2.setPaint(this.labelInfo[band].getLabelPaint()); + b = TextUtilities.drawAlignedString(label, g2, x, y, anchor); + } + if (lastXX > 0L) { + if (this.labelInfo[band].getDrawDividers()) { + long nextXX = p.getFirstMillisecond(); + long mid = (lastXX + nextXX) / 2; + float mid2d = (float) valueToJava2D(mid, dataArea, edge); + g2.setStroke(this.labelInfo[band].getDividerStroke()); + g2.setPaint(this.labelInfo[band].getDividerPaint()); + g2.draw(new Line2D.Float(mid2d, y, mid2d, y + yDelta)); + } + } + lastXX = last; + for (int i = 0; i < periods; i++) { + p = p.next(); + } + p.peg(this.calendar); + } + double used = 0.0; + if (b != null) { + used = b.getHeight(); + // work out the trailing gap + if (edge == RectangleEdge.BOTTOM) { + used += this.labelInfo[band].getPadding().calculateBottomOutset( + fm.getHeight()); + } + else if (edge == RectangleEdge.TOP) { + used += this.labelInfo[band].getPadding().calculateTopOutset( + fm.getHeight()); + } + } + state.moveCursor(used, edge); + return state; + } + + /** + * Calculates the positions of the ticks for the axis, storing the results + * in the tick list (ready for drawing). + * + * @param g2 the graphics device. + * @param state the axis state. + * @param dataArea the area inside the axes. + * @param edge the edge on which the axis is located. + * + * @return The list of ticks. + */ + @Override + public List refreshTicks(Graphics2D g2, AxisState state, + Rectangle2D dataArea, RectangleEdge edge) { + return Collections.EMPTY_LIST; + } + + /** + * Converts a data value to a coordinate in Java2D space, assuming that the + * axis runs along one edge of the specified dataArea. + *

+ * Note that it is possible for the coordinate to fall outside the area. + * + * @param value the data value. + * @param area the area for plotting the data. + * @param edge the edge along which the axis lies. + * + * @return The Java2D coordinate. + */ + @Override + public double valueToJava2D(double value, Rectangle2D area, + RectangleEdge edge) { + + double result = Double.NaN; + double axisMin = this.first.getFirstMillisecond(); + double axisMax = this.last.getLastMillisecond(); + if (RectangleEdge.isTopOrBottom(edge)) { + double minX = area.getX(); + double maxX = area.getMaxX(); + if (isInverted()) { + result = maxX + ((value - axisMin) / (axisMax - axisMin)) + * (minX - maxX); + } + else { + result = minX + ((value - axisMin) / (axisMax - axisMin)) + * (maxX - minX); + } + } + else if (RectangleEdge.isLeftOrRight(edge)) { + double minY = area.getMinY(); + double maxY = area.getMaxY(); + if (isInverted()) { + result = minY + (((value - axisMin) / (axisMax - axisMin)) + * (maxY - minY)); + } + else { + result = maxY - (((value - axisMin) / (axisMax - axisMin)) + * (maxY - minY)); + } + } + return result; + + } + + /** + * Converts a coordinate in Java2D space to the corresponding data value, + * assuming that the axis runs along one edge of the specified dataArea. + * + * @param java2DValue the coordinate in Java2D space. + * @param area the area in which the data is plotted. + * @param edge the edge along which the axis lies. + * + * @return The data value. + */ + @Override + public double java2DToValue(double java2DValue, Rectangle2D area, + RectangleEdge edge) { + + double result; + double min = 0.0; + double max = 0.0; + double axisMin = this.first.getFirstMillisecond(); + double axisMax = this.last.getLastMillisecond(); + if (RectangleEdge.isTopOrBottom(edge)) { + min = area.getX(); + max = area.getMaxX(); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + min = area.getMaxY(); + max = area.getY(); + } + if (isInverted()) { + result = axisMax - ((java2DValue - min) / (max - min) + * (axisMax - axisMin)); + } + else { + result = axisMin + ((java2DValue - min) / (max - min) + * (axisMax - axisMin)); + } + return result; + } + + /** + * Rescales the axis to ensure that all data is visible. + */ + @Override + 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(); + } + + long upper = Math.round(r.getUpperBound()); + long lower = Math.round(r.getLowerBound()); + this.first = createInstance(this.autoRangeTimePeriodClass, + new Date(lower), this.timeZone, this.locale); + this.last = createInstance(this.autoRangeTimePeriodClass, + new Date(upper), this.timeZone, this.locale); + setRange(r, false, false); + } + + } + + /** + * Tests the axis for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PeriodAxis)) { + return false; + } + PeriodAxis that = (PeriodAxis) obj; + if (!this.first.equals(that.first)) { + return false; + } + if (!this.last.equals(that.last)) { + return false; + } + if (!this.timeZone.equals(that.timeZone)) { + return false; + } + if (!this.locale.equals(that.locale)) { + return false; + } + if (!this.autoRangeTimePeriodClass.equals( + that.autoRangeTimePeriodClass)) { + return false; + } + if (!(isMinorTickMarksVisible() == that.isMinorTickMarksVisible())) { + return false; + } + if (!this.majorTickTimePeriodClass.equals( + that.majorTickTimePeriodClass)) { + return false; + } + if (!this.minorTickTimePeriodClass.equals( + that.minorTickTimePeriodClass)) { + return false; + } + if (!this.minorTickMarkPaint.equals(that.minorTickMarkPaint)) { + return false; + } + if (!this.minorTickMarkStroke.equals(that.minorTickMarkStroke)) { + return false; + } + if (!Arrays.equals(this.labelInfo, that.labelInfo)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this object. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return super.hashCode(); + } + + /** + * Returns a clone of the axis. + * + * @return A clone. + * + * @throws CloneNotSupportedException this class is cloneable, but + * subclasses may not be. + */ + @Override + public Object clone() throws CloneNotSupportedException { + PeriodAxis clone = (PeriodAxis) super.clone(); + clone.timeZone = (TimeZone) this.timeZone.clone(); + clone.labelInfo = (PeriodAxisLabelInfo[]) this.labelInfo.clone(); + return clone; + } + + /** + * A utility method used to create a particular subclass of the + * {@link RegularTimePeriod} class that includes the specified millisecond, + * assuming the specified time zone. + * + * @param periodClass the class. + * @param millisecond the time. + * @param zone the time zone. + * @param locale the locale. + * + * @return The time period. + */ + private RegularTimePeriod createInstance(Class periodClass, + Date millisecond, TimeZone zone, Locale locale) { + RegularTimePeriod result = null; + try { + Constructor c = periodClass.getDeclaredConstructor(new Class[] { + Date.class, TimeZone.class, Locale.class}); + result = (RegularTimePeriod) c.newInstance(new Object[] { + millisecond, zone, locale}); + } + catch (Exception e) { + try { + Constructor c = periodClass.getDeclaredConstructor(new Class[] { + Date.class}); + result = (RegularTimePeriod) c.newInstance(new Object[] { + millisecond}); + } + catch (Exception e2) { + // do nothing + } + } + 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.writeStroke(this.minorTickMarkStroke, stream); + SerialUtilities.writePaint(this.minorTickMarkPaint, 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.minorTickMarkStroke = SerialUtilities.readStroke(stream); + this.minorTickMarkPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/PeriodAxisLabelInfo.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/PeriodAxisLabelInfo.java new file mode 100755 index 0000000..e725037 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/PeriodAxisLabelInfo.java @@ -0,0 +1,382 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * PeriodAxisLabelInfo.java + * ------------------------ + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 01-Jun-2004 : Version 1 (DG); + * 23-Feb-2005 : Replaced Spacer with RectangleInsets (DG); + * 01-Mar-2005 : Modified constructors to accept DateFormat (DG); + * 20-May-2005 : Added default constants and null argument checks in the + * constructor (DG); + * 02-Mar-2009 : Updated createInstance to use locale (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.axis; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.Paint; +import java.awt.Stroke; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.lang.reflect.Constructor; +import java.text.DateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.time.RegularTimePeriod; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleInsets; + +/** + * A record that contains information for one "band" of date labels in + * a {@link PeriodAxis}. + */ +public class PeriodAxisLabelInfo implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 5710451740920277357L; + + /** The default insets. */ + public static final RectangleInsets DEFAULT_INSETS + = new RectangleInsets(2, 2, 2, 2); + + /** The default font. */ + public static final Font DEFAULT_FONT + = new Font("SansSerif", Font.PLAIN, 10); + + /** The default label paint. */ + public static final Paint DEFAULT_LABEL_PAINT = Color.black; + + /** The default divider stroke. */ + public static final Stroke DEFAULT_DIVIDER_STROKE = new BasicStroke(0.5f); + + /** The default divider paint. */ + public static final Paint DEFAULT_DIVIDER_PAINT = Color.gray; + + /** The subclass of {@link RegularTimePeriod} to use for this band. */ + private Class periodClass; + + /** Controls the gaps around the band. */ + private RectangleInsets padding; + + /** The date formatter. */ + private DateFormat dateFormat; + + /** The label font. */ + private Font labelFont; + + /** The label paint. */ + private transient Paint labelPaint; + + /** A flag that controls whether or not dividers are visible. */ + private boolean drawDividers; + + /** The stroke used to draw the dividers. */ + private transient Stroke dividerStroke; + + /** The paint used to draw the dividers. */ + private transient Paint dividerPaint; + + /** + * Creates a new instance. + * + * @param periodClass the subclass of {@link RegularTimePeriod} to use + * (null not permitted). + * @param dateFormat the date format (null not permitted). + */ + public PeriodAxisLabelInfo(Class periodClass, DateFormat dateFormat) { + this(periodClass, dateFormat, DEFAULT_INSETS, DEFAULT_FONT, + DEFAULT_LABEL_PAINT, true, DEFAULT_DIVIDER_STROKE, + DEFAULT_DIVIDER_PAINT); + } + + /** + * Creates a new instance. + * + * @param periodClass the subclass of {@link RegularTimePeriod} to use + * (null not permitted). + * @param dateFormat the date format (null not permitted). + * @param padding controls the space around the band (null + * not permitted). + * @param labelFont the label font (null not permitted). + * @param labelPaint the label paint (null not permitted). + * @param drawDividers a flag that controls whether dividers are drawn. + * @param dividerStroke the stroke used to draw the dividers + * (null not permitted). + * @param dividerPaint the paint used to draw the dividers + * (null not permitted). + */ + public PeriodAxisLabelInfo(Class periodClass, DateFormat dateFormat, + RectangleInsets padding, Font labelFont, Paint labelPaint, + boolean drawDividers, Stroke dividerStroke, Paint dividerPaint) { + ParamChecks.nullNotPermitted(periodClass, "periodClass"); + ParamChecks.nullNotPermitted(dateFormat, "dateFormat"); + ParamChecks.nullNotPermitted(padding, "padding"); + ParamChecks.nullNotPermitted(labelFont, "labelFont"); + ParamChecks.nullNotPermitted(labelPaint, "labelPaint"); + ParamChecks.nullNotPermitted(dividerStroke, "dividerStroke"); + ParamChecks.nullNotPermitted(dividerPaint, "dividerPaint"); + this.periodClass = periodClass; + this.dateFormat = (DateFormat) dateFormat.clone(); + this.padding = padding; + this.labelFont = labelFont; + this.labelPaint = labelPaint; + this.drawDividers = drawDividers; + this.dividerStroke = dividerStroke; + this.dividerPaint = dividerPaint; + } + + /** + * Returns the subclass of {@link RegularTimePeriod} that should be used + * to generate the date labels. + * + * @return The class. + */ + public Class getPeriodClass() { + return this.periodClass; + } + + /** + * Returns a copy of the date formatter. + * + * @return A copy of the date formatter (never null). + */ + public DateFormat getDateFormat() { + return (DateFormat) this.dateFormat.clone(); + } + + /** + * Returns the padding for the band. + * + * @return The padding. + */ + public RectangleInsets getPadding() { + return this.padding; + } + + /** + * Returns the label font. + * + * @return The label font (never null). + */ + public Font getLabelFont() { + return this.labelFont; + } + + /** + * Returns the label paint. + * + * @return The label paint. + */ + public Paint getLabelPaint() { + return this.labelPaint; + } + + /** + * Returns a flag that controls whether or not dividers are drawn. + * + * @return A flag. + */ + public boolean getDrawDividers() { + return this.drawDividers; + } + + /** + * Returns the stroke used to draw the dividers. + * + * @return The stroke. + */ + public Stroke getDividerStroke() { + return this.dividerStroke; + } + + /** + * Returns the paint used to draw the dividers. + * + * @return The paint. + */ + public Paint getDividerPaint() { + return this.dividerPaint; + } + + /** + * Creates a time period that includes the specified millisecond, assuming + * the given time zone. + * + * @param millisecond the time. + * @param zone the time zone. + * + * @return The time period. + * + * @deprecated As of 1.0.13, use the method that specifies the locale also. + */ + public RegularTimePeriod createInstance(Date millisecond, TimeZone zone) { + return createInstance(millisecond, zone, Locale.getDefault()); + } + + /** + * Creates a time period that includes the specified millisecond, assuming + * the given time zone. + * + * @param millisecond the time. + * @param zone the time zone. + * @param locale the locale. + * + * @return The time period. + * + * @since 1.0.13. + */ + public RegularTimePeriod createInstance(Date millisecond, TimeZone zone, + Locale locale) { + RegularTimePeriod result = null; + try { + Constructor c = this.periodClass.getDeclaredConstructor( + new Class[] {Date.class, TimeZone.class, Locale.class}); + result = (RegularTimePeriod) c.newInstance(new Object[] { + millisecond, zone, locale}); + } + catch (Exception e) { + // do nothing + } + return result; + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof PeriodAxisLabelInfo) { + PeriodAxisLabelInfo info = (PeriodAxisLabelInfo) obj; + if (!info.periodClass.equals(this.periodClass)) { + return false; + } + if (!info.dateFormat.equals(this.dateFormat)) { + return false; + } + if (!info.padding.equals(this.padding)) { + return false; + } + if (!info.labelFont.equals(this.labelFont)) { + return false; + } + if (!info.labelPaint.equals(this.labelPaint)) { + return false; + } + if (info.drawDividers != this.drawDividers) { + return false; + } + if (!info.dividerStroke.equals(this.dividerStroke)) { + return false; + } + if (!info.dividerPaint.equals(this.dividerPaint)) { + return false; + } + return true; + } + return false; + } + + /** + * Returns a hash code for this object. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 41; + result = result + 37 * this.periodClass.hashCode(); + result = result + 37 * this.dateFormat.hashCode(); + return result; + } + + /** + * Returns a clone of the object. + * + * @return A clone. + * + * @throws CloneNotSupportedException if cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + PeriodAxisLabelInfo clone = (PeriodAxisLabelInfo) super.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.writePaint(this.labelPaint, stream); + SerialUtilities.writeStroke(this.dividerStroke, stream); + SerialUtilities.writePaint(this.dividerPaint, 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.labelPaint = SerialUtilities.readPaint(stream); + this.dividerStroke = SerialUtilities.readStroke(stream); + this.dividerPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/QuarterDateFormat.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/QuarterDateFormat.java new file mode 100755 index 0000000..3bc2c7d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/QuarterDateFormat.java @@ -0,0 +1,210 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * QuarterDateFormat.java + * ---------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 01-Mar-2005 : Version 1 (DG); + * 10-May-2005 : Added equals() method, and implemented Cloneable and + * Serializable (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 08-Jun-2007 : Added Greek symbols, and support for reversing the date - see + * patch 1577221 (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.FieldPosition; +import java.text.NumberFormat; +import java.text.ParsePosition; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.TimeZone; +import org.jfree.chart.util.ParamChecks; + +/** + * A formatter that formats dates to show the year and quarter (for example, + * '2004 IV' for the last quarter of 2004. + */ +public class QuarterDateFormat extends DateFormat + implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -6738465248529797176L; + + /** Symbols for regular quarters. */ + public static final String[] REGULAR_QUARTERS = new String[] {"1", "2", + "3", "4"}; + + /** Symbols for roman numbered quarters. */ + public static final String[] ROMAN_QUARTERS = new String[] {"I", "II", + "III", "IV"}; + + /** + * Symbols for greek numbered quarters. + * + * @since 1.0.6 + */ + public static final String[] GREEK_QUARTERS = new String[] {"\u0391", + "\u0392", "\u0393", "\u0394"}; + + /** The strings. */ + private String[] quarters = REGULAR_QUARTERS; + + /** A flag that controls whether the quarter or the year goes first. */ + private boolean quarterFirst; + + /** + * Creates a new instance for the default time zone. + */ + public QuarterDateFormat() { + this(TimeZone.getDefault()); + } + + /** + * Creates a new instance for the specified time zone. + * + * @param zone the time zone (null not permitted). + */ + public QuarterDateFormat(TimeZone zone) { + this(zone, REGULAR_QUARTERS); + } + + /** + * Creates a new instance for the specified time zone. + * + * @param zone the time zone (null not permitted). + * @param quarterSymbols the quarter symbols. + */ + public QuarterDateFormat(TimeZone zone, String[] quarterSymbols) { + this(zone, quarterSymbols, false); + } + + /** + * Creates a new instance for the specified time zone. + * + * @param zone the time zone (null not permitted). + * @param quarterSymbols the quarter symbols. + * @param quarterFirst a flag that controls whether the quarter or the + * year is displayed first. + * + * @since 1.0.6 + */ + public QuarterDateFormat(TimeZone zone, String[] quarterSymbols, + boolean quarterFirst) { + ParamChecks.nullNotPermitted(zone, "zone"); + this.calendar = new GregorianCalendar(zone); + this.quarters = quarterSymbols; + this.quarterFirst = quarterFirst; + + // the following is never used, but it seems that DateFormat requires + // it to be non-null. It isn't well covered in the spec, refer to + // bug parade 5061189 for more info. + this.numberFormat = NumberFormat.getNumberInstance(); + + } + + /** + * Formats the given date. + * + * @param date the date. + * @param toAppendTo the string buffer. + * @param fieldPosition the field position. + * + * @return The formatted date. + */ + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, + FieldPosition fieldPosition) { + this.calendar.setTime(date); + int year = this.calendar.get(Calendar.YEAR); + int month = this.calendar.get(Calendar.MONTH); + int quarter = month / 3; + if (this.quarterFirst) { + toAppendTo.append(this.quarters[quarter]); + toAppendTo.append(" "); + toAppendTo.append(year); + } + else { + toAppendTo.append(year); + toAppendTo.append(" "); + toAppendTo.append(this.quarters[quarter]); + } + return toAppendTo; + } + + /** + * Parses the given string (not implemented). + * + * @param source the date string. + * @param pos the parse position. + * + * @return null, as this method has not been implemented. + */ + @Override + public Date parse(String source, ParsePosition pos) { + return null; + } + + /** + * Tests this formatter for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof QuarterDateFormat)) { + return false; + } + QuarterDateFormat that = (QuarterDateFormat) obj; + if (!Arrays.equals(this.quarters, that.quarters)) { + return false; + } + if (this.quarterFirst != that.quarterFirst) { + return false; + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/SegmentedTimeline.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/SegmentedTimeline.java new file mode 100755 index 0000000..e09aa1e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/SegmentedTimeline.java @@ -0,0 +1,1768 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * SegmentedTimeline.java + * ----------------------- + * (C) Copyright 2003-2008, by Bill Kelemen and Contributors. + * + * Original Author: Bill Kelemen; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 23-May-2003 : Version 1 (BK); + * 15-Aug-2003 : Implemented Cloneable (DG); + * 01-Jun-2004 : Modified to compile with JDK 1.2.2 (DG); + * 30-Sep-2004 : Replaced getTime().getTime() with getTimeInMillis() (DG); + * 04-Nov-2004 : Reverted change of 30-Sep-2004, won't work with JDK 1.3 (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 14-Nov-2006 : Fix in toTimelineValue(long) to avoid stack overflow (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 11-Jul-2007 : Fixed time zone bugs (DG); + * 06-Jun-2008 : Performance enhancement posted in forum (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.SimpleTimeZone; +import java.util.TimeZone; + +/** + * A {@link Timeline} that implements a "segmented" timeline with included, + * excluded and exception segments. + *

+ * A Timeline will present a series of values to be used for an axis. Each + * Timeline must provide transformation methods between domain values and + * timeline values. + *

+ * A timeline can be used as parameter to a + * {@link org.jfree.chart.axis.DateAxis} to define the values that this axis + * supports. This class implements a timeline formed by segments of equal + * length (ex. days, hours, minutes) where some segments can be included in the + * timeline and others excluded. Therefore timelines like "working days" or + * "working hours" can be created where non-working days or non-working hours + * respectively can be removed from the timeline, and therefore from the axis. + * This creates a smooth plot with equal separation between all included + * segments. + *

+ * Because Timelines were created mainly for Date related axis, values are + * represented as longs instead of doubles. In this case, the domain value is + * just the number of milliseconds since January 1, 1970, 00:00:00 GMT as + * defined by the getTime() method of {@link java.util.Date}. + *

+ * In this class, a segment is defined as a unit of time of fixed length. + * Examples of segments are: days, hours, minutes, etc. The size of a segment + * is defined as the number of milliseconds in the segment. Some useful segment + * sizes are defined as constants in this class: DAY_SEGMENT_SIZE, + * HOUR_SEGMENT_SIZE, FIFTEEN_MINUTE_SEGMENT_SIZE and MINUTE_SEGMENT_SIZE. + *

+ * Segments are group together to form a Segment Group. Each Segment Group will + * contain a number of Segments included and a number of Segments excluded. This + * Segment Group structure will repeat for the whole timeline. + *

+ * For example, a working days SegmentedTimeline would be formed by a group of + * 7 daily segments, where there are 5 included (Monday through Friday) and 2 + * excluded (Saturday and Sunday) segments. + *

+ * Following is a diagram that explains the major attributes that define a + * segment. Each box is one segment and must be of fixed length (ms, second, + * hour, day, etc). + *

+ *

+ * start time
+ *   |
+ *   v
+ *   0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 ...
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+...
+ * |  |  |  |  |  |EE|EE|  |  |  |  |  |EE|EE|  |  |  |  |  |EE|EE|
+ * +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+...
+ *  \____________/ \___/            \_/
+ *        \/         |               |
+ *     included   excluded        segment
+ *     segments   segments         size
+ *  \_________  _______/
+ *            \/
+ *       segment group
+ * 
+ * Legend:
+ * <space> = Included segment
+ * EE = Excluded segments in the base timeline
+ *

+ * In the example, the following segment attributes are presented: + *

    + *
  • segment size: the size of each segment in ms. + *
  • start time: the start of the first segment of the first segment group to + * consider. + *
  • included segments: the number of segments to include in the group. + *
  • excluded segments: the number of segments to exclude in the group. + *
+ *

+ * Exception Segments are allowed. These exception segments are defined as + * segments that would have been in the included segments of the Segment Group, + * but should be excluded for special reasons. In the previous working days + * SegmentedTimeline example, holidays would be considered exceptions. + *

+ * Additionally the startTime, or start of the first Segment of + * the smallest segment group needs to be defined. This startTime could be + * relative to January 1, 1970, 00:00:00 GMT or any other date. This creates a + * point of reference to start counting Segment Groups. For example, for the + * working days SegmentedTimeline, the startTime could be + * 00:00:00 GMT of the first Monday after January 1, 1970. In this class, the + * constant FIRST_MONDAY_AFTER_1900 refers to a reference point of the first + * Monday of the last century. + *

+ * A SegmentedTimeline can include a baseTimeline. This combination of + * timelines allows the creation of more complex timelines. For example, in + * order to implement a SegmentedTimeline for an intraday stock trading + * application, where the trading period is defined as 9:00 AM through 4:00 PM + * Monday through Friday, two SegmentedTimelines are used. The first one (the + * baseTimeline) would be a working day SegmentedTimeline (daily timeline + * Monday through Friday). On top of this baseTimeline, a second one is defined + * that maps the 9:00 AM to 4:00 PM period. Because the baseTimeline defines a + * timeline of Monday through Friday, the resulting (combined) timeline will + * expose the period 9:00 AM through 4:00 PM only on Monday through Friday, + * and will remove all other intermediate intervals. + *

+ * Two factory methods newMondayThroughFridayTimeline() and + * newFifteenMinuteTimeline() are provided as examples to create special + * SegmentedTimelines. + * + * @see org.jfree.chart.axis.DateAxis + */ +public class SegmentedTimeline implements Timeline, Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 1093779862539903110L; + + //////////////////////////////////////////////////////////////////////////// + // predetermined segments sizes + //////////////////////////////////////////////////////////////////////////// + + /** Defines a day segment size in ms. */ + public static final long DAY_SEGMENT_SIZE = 24 * 60 * 60 * 1000; + + /** Defines a one hour segment size in ms. */ + public static final long HOUR_SEGMENT_SIZE = 60 * 60 * 1000; + + /** Defines a 15-minute segment size in ms. */ + public static final long FIFTEEN_MINUTE_SEGMENT_SIZE = 15 * 60 * 1000; + + /** Defines a one-minute segment size in ms. */ + public static final long MINUTE_SEGMENT_SIZE = 60 * 1000; + + //////////////////////////////////////////////////////////////////////////// + // other constants + //////////////////////////////////////////////////////////////////////////// + + /** + * Utility constant that defines the startTime as the first monday after + * 1/1/1970. This should be used when creating a SegmentedTimeline for + * Monday through Friday. See static block below for calculation of this + * constant. + * + * @deprecated As of 1.0.7. This field doesn't take into account changes + * to the default time zone. + */ + public static long FIRST_MONDAY_AFTER_1900; + + /** + * Utility TimeZone object that has no DST and an offset equal to the + * default TimeZone. This allows easy arithmetic between days as each one + * will have equal size. + * + * @deprecated As of 1.0.7. This field is initialised based on the + * default time zone, and doesn't take into account subsequent + * changes to the default. + */ + public static TimeZone NO_DST_TIME_ZONE; + + /** + * This is the default time zone where the application is running. See + * getTime() below where we make use of certain transformations between + * times in the default time zone and the no-dst time zone used for our + * calculations. + * + * @deprecated As of 1.0.7. When the default time zone is required, + * just call TimeZone.getDefault(). + */ + public static TimeZone DEFAULT_TIME_ZONE = TimeZone.getDefault(); + + /** + * This will be a utility calendar that has no DST but is shifted relative + * to the default time zone's offset. + */ + private Calendar workingCalendarNoDST; + + /** + * This will be a utility calendar that used the default time zone. + */ + private Calendar workingCalendar = Calendar.getInstance(); + + //////////////////////////////////////////////////////////////////////////// + // private attributes + //////////////////////////////////////////////////////////////////////////// + + /** Segment size in ms. */ + private long segmentSize; + + /** Number of consecutive segments to include in a segment group. */ + private int segmentsIncluded; + + /** Number of consecutive segments to exclude in a segment group. */ + private int segmentsExcluded; + + /** Number of segments in a group (segmentsIncluded + segmentsExcluded). */ + private int groupSegmentCount; + + /** + * Start of time reference from time zero (1/1/1970). + * This is the start of segment #0. + */ + private long startTime; + + /** Consecutive ms in segmentsIncluded (segmentsIncluded * segmentSize). */ + private long segmentsIncludedSize; + + /** Consecutive ms in segmentsExcluded (segmentsExcluded * segmentSize). */ + private long segmentsExcludedSize; + + /** ms in a segment group (segmentsIncludedSize + segmentsExcludedSize). */ + private long segmentsGroupSize; + + /** + * List of exception segments (exceptions segments that would otherwise be + * included based on the periodic (included, excluded) grouping). + */ + private List exceptionSegments = new ArrayList(); + + /** + * This base timeline is used to specify exceptions at a higher level. For + * example, if we are a intraday timeline and want to exclude holidays, + * instead of having to exclude all intraday segments for the holiday, + * segments from this base timeline can be excluded. This baseTimeline is + * always optional and is only a convenience method. + *

+ * Additionally, all excluded segments from this baseTimeline will be + * considered exceptions at this level. + */ + private SegmentedTimeline baseTimeline; + + /** A flag that controls whether or not to adjust for daylight saving. */ + private boolean adjustForDaylightSaving = false; + + //////////////////////////////////////////////////////////////////////////// + // static block + //////////////////////////////////////////////////////////////////////////// + + static { + // make a time zone with no DST for our Calendar calculations + int offset = TimeZone.getDefault().getRawOffset(); + NO_DST_TIME_ZONE = new SimpleTimeZone(offset, "UTC-" + offset); + + // calculate midnight of first monday after 1/1/1900 relative to + // current locale + Calendar cal = new GregorianCalendar(NO_DST_TIME_ZONE); + cal.set(1900, 0, 1, 0, 0, 0); + cal.set(Calendar.MILLISECOND, 0); + while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { + cal.add(Calendar.DATE, 1); + } + // FIRST_MONDAY_AFTER_1900 = cal.getTime().getTime(); + // preceding code won't work with JDK 1.3 + FIRST_MONDAY_AFTER_1900 = cal.getTime().getTime(); + } + + //////////////////////////////////////////////////////////////////////////// + // constructors and factory methods + //////////////////////////////////////////////////////////////////////////// + + /** + * Constructs a new segmented timeline, optionaly using another segmented + * timeline as its base. This chaining of SegmentedTimelines allows further + * segmentation into smaller timelines. + * + * If a base + * + * @param segmentSize the size of a segment in ms. This time unit will be + * used to compute the included and excluded segments of the + * timeline. + * @param segmentsIncluded Number of consecutive segments to include. + * @param segmentsExcluded Number of consecutive segments to exclude. + */ + public SegmentedTimeline(long segmentSize, + int segmentsIncluded, + int segmentsExcluded) { + + this.segmentSize = segmentSize; + this.segmentsIncluded = segmentsIncluded; + this.segmentsExcluded = segmentsExcluded; + + this.groupSegmentCount = this.segmentsIncluded + this.segmentsExcluded; + this.segmentsIncludedSize = this.segmentsIncluded * this.segmentSize; + this.segmentsExcludedSize = this.segmentsExcluded * this.segmentSize; + this.segmentsGroupSize = this.segmentsIncludedSize + + this.segmentsExcludedSize; + int offset = TimeZone.getDefault().getRawOffset(); + TimeZone z = new SimpleTimeZone(offset, "UTC-" + offset); + this.workingCalendarNoDST = new GregorianCalendar(z, + Locale.getDefault()); + } + + /** + * Returns the milliseconds for midnight of the first Monday after + * 1-Jan-1900, ignoring daylight savings. + * + * @return The milliseconds. + * + * @since 1.0.7 + */ + public static long firstMondayAfter1900() { + int offset = TimeZone.getDefault().getRawOffset(); + TimeZone z = new SimpleTimeZone(offset, "UTC-" + offset); + + // calculate midnight of first monday after 1/1/1900 relative to + // current locale + Calendar cal = new GregorianCalendar(z); + cal.set(1900, 0, 1, 0, 0, 0); + cal.set(Calendar.MILLISECOND, 0); + while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { + cal.add(Calendar.DATE, 1); + } + //return cal.getTimeInMillis(); + // preceding code won't work with JDK 1.3 + return cal.getTime().getTime(); + } + + /** + * Factory method to create a Monday through Friday SegmentedTimeline. + *

+ * The startTime of the resulting timeline will be midnight + * of the first Monday after 1/1/1900. + * + * @return A fully initialized SegmentedTimeline. + */ + public static SegmentedTimeline newMondayThroughFridayTimeline() { + SegmentedTimeline timeline + = new SegmentedTimeline(DAY_SEGMENT_SIZE, 5, 2); + timeline.setStartTime(firstMondayAfter1900()); + return timeline; + } + + /** + * Factory method to create a 15-min, 9:00 AM thought 4:00 PM, Monday + * through Friday SegmentedTimeline. + *

+ * This timeline uses a segmentSize of FIFTEEN_MIN_SEGMENT_SIZE. The + * segment group is defined as 28 included segments (9:00 AM through + * 4:00 PM) and 68 excluded segments (4:00 PM through 9:00 AM the next day). + *

+ * In order to exclude Saturdays and Sundays it uses a baseTimeline that + * only includes Monday through Friday days. + *

+ * The startTime of the resulting timeline will be 9:00 AM + * after the startTime of the baseTimeline. This will correspond to 9:00 AM + * of the first Monday after 1/1/1900. + * + * @return A fully initialized SegmentedTimeline. + */ + public static SegmentedTimeline newFifteenMinuteTimeline() { + SegmentedTimeline timeline = new SegmentedTimeline( + FIFTEEN_MINUTE_SEGMENT_SIZE, 28, 68); + timeline.setStartTime(firstMondayAfter1900() + 36 + * timeline.getSegmentSize()); + timeline.setBaseTimeline(newMondayThroughFridayTimeline()); + return timeline; + } + + /** + * Returns the flag that controls whether or not the daylight saving + * adjustment is applied. + * + * @return A boolean. + */ + public boolean getAdjustForDaylightSaving() { + return this.adjustForDaylightSaving; + } + + /** + * Sets the flag that controls whether or not the daylight saving adjustment + * is applied. + * + * @param adjust the flag. + */ + public void setAdjustForDaylightSaving(boolean adjust) { + this.adjustForDaylightSaving = adjust; + } + + //////////////////////////////////////////////////////////////////////////// + // operations + //////////////////////////////////////////////////////////////////////////// + + /** + * Sets the start time for the timeline. This is the beginning of segment + * zero. + * + * @param millisecond the start time (encoded as in java.util.Date). + */ + public void setStartTime(long millisecond) { + this.startTime = millisecond; + } + + /** + * Returns the start time for the timeline. This is the beginning of + * segment zero. + * + * @return The start time. + */ + public long getStartTime() { + return this.startTime; + } + + /** + * Returns the number of segments excluded per segment group. + * + * @return The number of segments excluded. + */ + public int getSegmentsExcluded() { + return this.segmentsExcluded; + } + + /** + * Returns the size in milliseconds of the segments excluded per segment + * group. + * + * @return The size in milliseconds. + */ + public long getSegmentsExcludedSize() { + return this.segmentsExcludedSize; + } + + /** + * Returns the number of segments in a segment group. This will be equal to + * segments included plus segments excluded. + * + * @return The number of segments. + */ + public int getGroupSegmentCount() { + return this.groupSegmentCount; + } + + /** + * Returns the size in milliseconds of a segment group. This will be equal + * to size of the segments included plus the size of the segments excluded. + * + * @return The segment group size in milliseconds. + */ + public long getSegmentsGroupSize() { + return this.segmentsGroupSize; + } + + /** + * Returns the number of segments included per segment group. + * + * @return The number of segments. + */ + public int getSegmentsIncluded() { + return this.segmentsIncluded; + } + + /** + * Returns the size in ms of the segments included per segment group. + * + * @return The segment size in milliseconds. + */ + public long getSegmentsIncludedSize() { + return this.segmentsIncludedSize; + } + + /** + * Returns the size of one segment in ms. + * + * @return The segment size in milliseconds. + */ + public long getSegmentSize() { + return this.segmentSize; + } + + /** + * Returns a list of all the exception segments. This list is not + * modifiable. + * + * @return The exception segments. + */ + public List getExceptionSegments() { + return Collections.unmodifiableList(this.exceptionSegments); + } + + /** + * Sets the exception segments list. + * + * @param exceptionSegments the exception segments. + */ + public void setExceptionSegments(List exceptionSegments) { + this.exceptionSegments = exceptionSegments; + } + + /** + * Returns our baseTimeline, or null if none. + * + * @return The base timeline. + */ + public SegmentedTimeline getBaseTimeline() { + return this.baseTimeline; + } + + /** + * Sets the base timeline. + * + * @param baseTimeline the timeline. + */ + public void setBaseTimeline(SegmentedTimeline baseTimeline) { + + // verify that baseTimeline is compatible with us + if (baseTimeline != null) { + if (baseTimeline.getSegmentSize() < this.segmentSize) { + throw new IllegalArgumentException( + "baseTimeline.getSegmentSize() " + + "is smaller than segmentSize"); + } + else if (baseTimeline.getStartTime() > this.startTime) { + throw new IllegalArgumentException( + "baseTimeline.getStartTime() is after startTime"); + } + else if ((baseTimeline.getSegmentSize() % this.segmentSize) != 0) { + throw new IllegalArgumentException( + "baseTimeline.getSegmentSize() is not multiple of " + + "segmentSize"); + } + else if (((this.startTime + - baseTimeline.getStartTime()) % this.segmentSize) != 0) { + throw new IllegalArgumentException( + "baseTimeline is not aligned"); + } + } + + this.baseTimeline = baseTimeline; + } + + /** + * Translates a value relative to the domain value (all Dates) into a value + * relative to the segmented timeline. The values relative to the segmented + * timeline are all consecutives starting at zero at the startTime. + * + * @param millisecond the millisecond (as encoded by java.util.Date). + * + * @return The timeline value. + */ + @Override + public long toTimelineValue(long millisecond) { + + long result; + long rawMilliseconds = millisecond - this.startTime; + long groupMilliseconds = rawMilliseconds % this.segmentsGroupSize; + long groupIndex = rawMilliseconds / this.segmentsGroupSize; + + if (groupMilliseconds >= this.segmentsIncludedSize) { + result = toTimelineValue(this.startTime + this.segmentsGroupSize + * (groupIndex + 1)); + } + else { + Segment segment = getSegment(millisecond); + if (segment.inExceptionSegments()) { + int p; + while ((p = binarySearchExceptionSegments(segment)) >= 0) { + segment = getSegment(millisecond = ((Segment) + this.exceptionSegments.get(p)).getSegmentEnd() + 1); + } + result = toTimelineValue(millisecond); + } + else { + long shiftedSegmentedValue = millisecond - this.startTime; + long x = shiftedSegmentedValue % this.segmentsGroupSize; + long y = shiftedSegmentedValue / this.segmentsGroupSize; + + long wholeExceptionsBeforeDomainValue = + getExceptionSegmentCount(this.startTime, millisecond - 1); + +// long partialTimeInException = 0; +// Segment ss = getSegment(millisecond); +// if (ss.inExceptionSegments()) { +// partialTimeInException = millisecond + // - ss.getSegmentStart(); +// } + + if (x < this.segmentsIncludedSize) { + result = this.segmentsIncludedSize * y + + x - wholeExceptionsBeforeDomainValue + * this.segmentSize; + // - partialTimeInException; + } + else { + result = this.segmentsIncludedSize * (y + 1) + - wholeExceptionsBeforeDomainValue + * this.segmentSize; + // - partialTimeInException; + } + } + } + + return result; + } + + /** + * Translates a date into a value relative to the segmented timeline. The + * values relative to the segmented timeline are all consecutives starting + * at zero at the startTime. + * + * @param date date relative to the domain. + * + * @return The timeline value (in milliseconds). + */ + @Override + public long toTimelineValue(Date date) { + return toTimelineValue(getTime(date)); + //return toTimelineValue(dateDomainValue.getTime()); + } + + /** + * Translates a value relative to the timeline into a millisecond. + * + * @param timelineValue the timeline value (in milliseconds). + * + * @return The domain value (in milliseconds). + */ + @Override + public long toMillisecond(long timelineValue) { + + // calculate the result as if no exceptions + Segment result = new Segment(this.startTime + timelineValue + + (timelineValue / this.segmentsIncludedSize) + * this.segmentsExcludedSize); + + long lastIndex = this.startTime; + + // adjust result for any exceptions in the result calculated + while (lastIndex <= result.segmentStart) { + + // skip all whole exception segments in the range + long exceptionSegmentCount; + while ((exceptionSegmentCount = getExceptionSegmentCount( + lastIndex, (result.millisecond / this.segmentSize) + * this.segmentSize - 1)) > 0 + ) { + lastIndex = result.segmentStart; + // move forward exceptionSegmentCount segments skipping + // excluded segments + for (int i = 0; i < exceptionSegmentCount; i++) { + do { + result.inc(); + } + while (result.inExcludeSegments()); + } + } + lastIndex = result.segmentStart; + + // skip exception or excluded segments we may fall on + while (result.inExceptionSegments() || result.inExcludeSegments()) { + result.inc(); + lastIndex += this.segmentSize; + } + + lastIndex++; + } + + return getTimeFromLong(result.millisecond); + } + + /** + * Converts a date/time value to take account of daylight savings time. + * + * @param date the milliseconds. + * + * @return The milliseconds. + */ + public long getTimeFromLong(long date) { + long result = date; + if (this.adjustForDaylightSaving) { + this.workingCalendarNoDST.setTime(new Date(date)); + this.workingCalendar.set( + this.workingCalendarNoDST.get(Calendar.YEAR), + this.workingCalendarNoDST.get(Calendar.MONTH), + this.workingCalendarNoDST.get(Calendar.DATE), + this.workingCalendarNoDST.get(Calendar.HOUR_OF_DAY), + this.workingCalendarNoDST.get(Calendar.MINUTE), + this.workingCalendarNoDST.get(Calendar.SECOND) + ); + this.workingCalendar.set(Calendar.MILLISECOND, + this.workingCalendarNoDST.get(Calendar.MILLISECOND)); + // result = this.workingCalendar.getTimeInMillis(); + // preceding code won't work with JDK 1.3 + result = this.workingCalendar.getTime().getTime(); + } + return result; + } + + /** + * Returns true if a value is contained in the timeline. + * + * @param millisecond the value to verify. + * + * @return true if value is contained in the timeline. + */ + @Override + public boolean containsDomainValue(long millisecond) { + Segment segment = getSegment(millisecond); + return segment.inIncludeSegments(); + } + + /** + * Returns true if a value is contained in the timeline. + * + * @param date date to verify + * + * @return true if value is contained in the timeline + */ + @Override + public boolean containsDomainValue(Date date) { + return containsDomainValue(getTime(date)); + } + + /** + * Returns true if a range of values are contained in the + * timeline. This is implemented verifying that all segments are in the + * range. + * + * @param domainValueStart start of the range to verify + * @param domainValueEnd end of the range to verify + * + * @return true if the range is contained in the timeline + */ + @Override + public boolean containsDomainRange(long domainValueStart, + long domainValueEnd) { + if (domainValueEnd < domainValueStart) { + throw new IllegalArgumentException( + "domainValueEnd (" + domainValueEnd + + ") < domainValueStart (" + domainValueStart + ")"); + } + Segment segment = getSegment(domainValueStart); + boolean contains = true; + do { + contains = (segment.inIncludeSegments()); + if (segment.contains(domainValueEnd)) { + break; + } + else { + segment.inc(); + } + } + while (contains); + return (contains); + } + + /** + * Returns true if a range of values are contained in the + * timeline. This is implemented verifying that all segments are in the + * range. + * + * @param dateDomainValueStart start of the range to verify + * @param dateDomainValueEnd end of the range to verify + * + * @return true if the range is contained in the timeline + */ + @Override + public boolean containsDomainRange(Date dateDomainValueStart, + Date dateDomainValueEnd) { + return containsDomainRange(getTime(dateDomainValueStart), + getTime(dateDomainValueEnd)); + } + + /** + * Adds a segment as an exception. An exception segment is defined as a + * segment to exclude from what would otherwise be considered a valid + * segment of the timeline. An exception segment can not be contained + * inside an already excluded segment. If so, no action will occur (the + * proposed exception segment will be discarded). + *

+ * The segment is identified by a domainValue into any part of the segment. + * Therefore the segmentStart <= domainValue <= segmentEnd. + * + * @param millisecond domain value to treat as an exception + */ + public void addException(long millisecond) { + addException(new Segment(millisecond)); + } + + /** + * Adds a segment range as an exception. An exception segment is defined as + * a segment to exclude from what would otherwise be considered a valid + * segment of the timeline. An exception segment can not be contained + * inside an already excluded segment. If so, no action will occur (the + * proposed exception segment will be discarded). + *

+ * The segment range is identified by a domainValue that begins a valid + * segment and ends with a domainValue that ends a valid segment. + * Therefore the range will contain all segments whose segmentStart + * <= domainValue and segmentEnd <= toDomainValue. + * + * @param fromDomainValue start of domain range to treat as an exception + * @param toDomainValue end of domain range to treat as an exception + */ + public void addException(long fromDomainValue, long toDomainValue) { + addException(new SegmentRange(fromDomainValue, toDomainValue)); + } + + /** + * Adds a segment as an exception. An exception segment is defined as a + * segment to exclude from what would otherwise be considered a valid + * segment of the timeline. An exception segment can not be contained + * inside an already excluded segment. If so, no action will occur (the + * proposed exception segment will be discarded). + *

+ * The segment is identified by a Date into any part of the segment. + * + * @param exceptionDate Date into the segment to exclude. + */ + public void addException(Date exceptionDate) { + addException(getTime(exceptionDate)); + //addException(exceptionDate.getTime()); + } + + /** + * Adds a list of dates as segment exceptions. Each exception segment is + * defined as a segment to exclude from what would otherwise be considered + * a valid segment of the timeline. An exception segment can not be + * contained inside an already excluded segment. If so, no action will + * occur (the proposed exception segment will be discarded). + *

+ * The segment is identified by a Date into any part of the segment. + * + * @param exceptionList List of Date objects that identify the segments to + * exclude. + */ + public void addExceptions(List exceptionList) { + for (Iterator iter = exceptionList.iterator(); iter.hasNext();) { + addException((Date) iter.next()); + } + } + + /** + * Adds a segment as an exception. An exception segment is defined as a + * segment to exclude from what would otherwise be considered a valid + * segment of the timeline. An exception segment can not be contained + * inside an already excluded segment. This is verified inside this + * method, and if so, no action will occur (the proposed exception segment + * will be discarded). + * + * @param segment the segment to exclude. + */ + private void addException(Segment segment) { + if (segment.inIncludeSegments()) { + int p = binarySearchExceptionSegments(segment); + this.exceptionSegments.add(-(p + 1), segment); + } + } + + /** + * Adds a segment relative to the baseTimeline as an exception. Because a + * base segment is normally larger than our segments, this may add one or + * more segment ranges to the exception list. + *

+ * An exception segment is defined as a segment + * to exclude from what would otherwise be considered a valid segment of + * the timeline. An exception segment can not be contained inside an + * already excluded segment. If so, no action will occur (the proposed + * exception segment will be discarded). + *

+ * The segment is identified by a domainValue into any part of the + * baseTimeline segment. + * + * @param domainValue domain value to teat as a baseTimeline exception. + */ + public void addBaseTimelineException(long domainValue) { + + Segment baseSegment = this.baseTimeline.getSegment(domainValue); + if (baseSegment.inIncludeSegments()) { + + // cycle through all the segments contained in the BaseTimeline + // exception segment + Segment segment = getSegment(baseSegment.getSegmentStart()); + while (segment.getSegmentStart() <= baseSegment.getSegmentEnd()) { + if (segment.inIncludeSegments()) { + + // find all consecutive included segments + long fromDomainValue = segment.getSegmentStart(); + long toDomainValue; + do { + toDomainValue = segment.getSegmentEnd(); + segment.inc(); + } + while (segment.inIncludeSegments()); + + // add the interval as an exception + addException(fromDomainValue, toDomainValue); + + } + else { + // this is not one of our included segment, skip it + segment.inc(); + } + } + } + } + + /** + * Adds a segment relative to the baseTimeline as an exception. An + * exception segment is defined as a segment to exclude from what would + * otherwise be considered a valid segment of the timeline. An exception + * segment can not be contained inside an already excluded segment. If so, + * no action will occure (the proposed exception segment will be discarded). + *

+ * The segment is identified by a domainValue into any part of the segment. + * Therefore the segmentStart <= domainValue <= segmentEnd. + * + * @param date date domain value to treat as a baseTimeline exception + */ + public void addBaseTimelineException(Date date) { + addBaseTimelineException(getTime(date)); + } + + /** + * Adds all excluded segments from the BaseTimeline as exceptions to our + * timeline. This allows us to combine two timelines for more complex + * calculations. + * + * @param fromBaseDomainValue Start of the range where exclusions will be + * extracted. + * @param toBaseDomainValue End of the range to process. + */ + public void addBaseTimelineExclusions(long fromBaseDomainValue, + long toBaseDomainValue) { + + // find first excluded base segment starting fromDomainValue + Segment baseSegment = this.baseTimeline.getSegment(fromBaseDomainValue); + while (baseSegment.getSegmentStart() <= toBaseDomainValue + && !baseSegment.inExcludeSegments()) { + + baseSegment.inc(); + + } + + // cycle over all the base segments groups in the range + while (baseSegment.getSegmentStart() <= toBaseDomainValue) { + + long baseExclusionRangeEnd = baseSegment.getSegmentStart() + + this.baseTimeline.getSegmentsExcluded() + * this.baseTimeline.getSegmentSize() - 1; + + // cycle through all the segments contained in the base exclusion + // area + Segment segment = getSegment(baseSegment.getSegmentStart()); + while (segment.getSegmentStart() <= baseExclusionRangeEnd) { + if (segment.inIncludeSegments()) { + + // find all consecutive included segments + long fromDomainValue = segment.getSegmentStart(); + long toDomainValue; + do { + toDomainValue = segment.getSegmentEnd(); + segment.inc(); + } + while (segment.inIncludeSegments()); + + // add the interval as an exception + addException(new BaseTimelineSegmentRange( + fromDomainValue, toDomainValue)); + } + else { + // this is not one of our included segment, skip it + segment.inc(); + } + } + + // go to next base segment group + baseSegment.inc(this.baseTimeline.getGroupSegmentCount()); + } + } + + /** + * Returns the number of exception segments wholly contained in the + * (fromDomainValue, toDomainValue) interval. + * + * @param fromMillisecond the beginning of the interval. + * @param toMillisecond the end of the interval. + * + * @return Number of exception segments contained in the interval. + */ + public long getExceptionSegmentCount(long fromMillisecond, + long toMillisecond) { + if (toMillisecond < fromMillisecond) { + return (0); + } + + int n = 0; + for (Iterator iter = this.exceptionSegments.iterator(); + iter.hasNext();) { + Segment segment = (Segment) iter.next(); + Segment intersection = segment.intersect(fromMillisecond, + toMillisecond); + if (intersection != null) { + n += intersection.getSegmentCount(); + } + } + + return (n); + } + + /** + * Returns a segment that contains a domainValue. If the domainValue is + * not contained in the timeline (because it is not contained in the + * baseTimeline), a Segment that contains + * index + segmentSize*m will be returned for the smallest + * m possible. + * + * @param millisecond index into the segment + * + * @return A Segment that contains index, or the next possible Segment. + */ + public Segment getSegment(long millisecond) { + return new Segment(millisecond); + } + + /** + * Returns a segment that contains a date. For accurate calculations, + * the calendar should use TIME_ZONE for its calculation (or any other + * similar time zone). + * + * If the date is not contained in the timeline (because it is not + * contained in the baseTimeline), a Segment that contains + * date + segmentSize*m will be returned for the smallest + * m possible. + * + * @param date date into the segment + * + * @return A Segment that contains date, or the next possible Segment. + */ + public Segment getSegment(Date date) { + return (getSegment(getTime(date))); + } + + /** + * Convenient method to test equality in two objects, taking into account + * nulls. + * + * @param o first object to compare + * @param p second object to compare + * + * @return true if both objects are equal or both + * null, false otherwise. + */ + private boolean equals(Object o, Object p) { + return (o == p || ((o != null) && o.equals(p))); + } + + /** + * Returns true if we are equal to the parameter + * + * @param o Object to verify with us + * + * @return true or false + */ + @Override + public boolean equals(Object o) { + if (o instanceof SegmentedTimeline) { + SegmentedTimeline other = (SegmentedTimeline) o; + + boolean b0 = (this.segmentSize == other.getSegmentSize()); + boolean b1 = (this.segmentsIncluded == other.getSegmentsIncluded()); + boolean b2 = (this.segmentsExcluded == other.getSegmentsExcluded()); + boolean b3 = (this.startTime == other.getStartTime()); + boolean b4 = equals(this.exceptionSegments, + other.getExceptionSegments()); + return b0 && b1 && b2 && b3 && b4; + } + else { + return (false); + } + } + + /** + * Returns a hash code for this object. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 19; + result = 37 * result + + (int) (this.segmentSize ^ (this.segmentSize >>> 32)); + result = 37 * result + (int) (this.startTime ^ (this.startTime >>> 32)); + return result; + } + + /** + * Preforms a binary serach in the exceptionSegments sorted array. This + * array can contain Segments or SegmentRange objects. + * + * @param segment the key to be searched for. + * + * @return index of the search segment, if it is contained in the list; + * otherwise, (-(insertion point) - 1). The + * insertion point is defined as the point at which the + * segment would be inserted into the list: the index of the first + * element greater than the key, or list.size(), if all + * elements in the list are less than the specified segment. Note + * that this guarantees that the return value will be >= 0 if + * and only if the key is found. + */ + private int binarySearchExceptionSegments(Segment segment) { + int low = 0; + int high = this.exceptionSegments.size() - 1; + + while (low <= high) { + int mid = (low + high) / 2; + Segment midSegment = (Segment) this.exceptionSegments.get(mid); + + // first test for equality (contains or contained) + if (segment.contains(midSegment) || midSegment.contains(segment)) { + return mid; + } + + if (midSegment.before(segment)) { + low = mid + 1; + } + else if (midSegment.after(segment)) { + high = mid - 1; + } + else { + throw new IllegalStateException("Invalid condition."); + } + } + return -(low + 1); // key not found + } + + /** + * Special method that handles conversion between the Default Time Zone and + * a UTC time zone with no DST. This is needed so all days have the same + * size. This method is the prefered way of converting a Data into + * milliseconds for usage in this class. + * + * @param date Date to convert to long. + * + * @return The milliseconds. + */ + public long getTime(Date date) { + long result = date.getTime(); + if (this.adjustForDaylightSaving) { + this.workingCalendar.setTime(date); + this.workingCalendarNoDST.set( + this.workingCalendar.get(Calendar.YEAR), + this.workingCalendar.get(Calendar.MONTH), + this.workingCalendar.get(Calendar.DATE), + this.workingCalendar.get(Calendar.HOUR_OF_DAY), + this.workingCalendar.get(Calendar.MINUTE), + this.workingCalendar.get(Calendar.SECOND)); + this.workingCalendarNoDST.set(Calendar.MILLISECOND, + this.workingCalendar.get(Calendar.MILLISECOND)); + Date revisedDate = this.workingCalendarNoDST.getTime(); + result = revisedDate.getTime(); + } + + return result; + } + + /** + * Converts a millisecond value into a {@link Date} object. + * + * @param value the millisecond value. + * + * @return The date. + */ + public Date getDate(long value) { + this.workingCalendarNoDST.setTime(new Date(value)); + return (this.workingCalendarNoDST.getTime()); + } + + /** + * Returns a clone of the timeline. + * + * @return A clone. + * + * @throws CloneNotSupportedException ??. + */ + @Override + public Object clone() throws CloneNotSupportedException { + SegmentedTimeline clone = (SegmentedTimeline) super.clone(); + return clone; + } + + /** + * Internal class to represent a valid segment for this timeline. A segment + * is valid on a timeline if it is part of its included, excluded or + * exception segments. + *

+ * Each segment will know its segment number, segmentStart, segmentEnd and + * index inside the segment. + */ + public class Segment implements Comparable, Cloneable, Serializable { + + /** The segment number. */ + protected long segmentNumber; + + /** The segment start. */ + protected long segmentStart; + + /** The segment end. */ + protected long segmentEnd; + + /** A reference point within the segment. */ + protected long millisecond; + + /** + * Protected constructor only used by sub-classes. + */ + protected Segment() { + // empty + } + + /** + * Creates a segment for a given point in time. + * + * @param millisecond the millisecond (as encoded by java.util.Date). + */ + protected Segment(long millisecond) { + this.segmentNumber = calculateSegmentNumber(millisecond); + this.segmentStart = SegmentedTimeline.this.startTime + + this.segmentNumber * SegmentedTimeline.this.segmentSize; + this.segmentEnd + = this.segmentStart + SegmentedTimeline.this.segmentSize - 1; + this.millisecond = millisecond; + } + + /** + * Calculates the segment number for a given millisecond. + * + * @param millis the millisecond (as encoded by java.util.Date). + * + * @return The segment number. + */ + public long calculateSegmentNumber(long millis) { + if (millis >= SegmentedTimeline.this.startTime) { + return (millis - SegmentedTimeline.this.startTime) + / SegmentedTimeline.this.segmentSize; + } + else { + return ((millis - SegmentedTimeline.this.startTime) + / SegmentedTimeline.this.segmentSize) - 1; + } + } + + /** + * Returns the segment number of this segment. Segments start at 0. + * + * @return The segment number. + */ + public long getSegmentNumber() { + return this.segmentNumber; + } + + /** + * Returns always one (the number of segments contained in this + * segment). + * + * @return The segment count (always 1 for this class). + */ + public long getSegmentCount() { + return 1; + } + + /** + * Gets the start of this segment in ms. + * + * @return The segment start. + */ + public long getSegmentStart() { + return this.segmentStart; + } + + /** + * Gets the end of this segment in ms. + * + * @return The segment end. + */ + public long getSegmentEnd() { + return this.segmentEnd; + } + + /** + * Returns the millisecond used to reference this segment (always + * between the segmentStart and segmentEnd). + * + * @return The millisecond. + */ + public long getMillisecond() { + return this.millisecond; + } + + /** + * Returns a {@link java.util.Date} that represents the reference point + * for this segment. + * + * @return The date. + */ + public Date getDate() { + return SegmentedTimeline.this.getDate(this.millisecond); + } + + /** + * Returns true if a particular millisecond is contained in this + * segment. + * + * @param millis the millisecond to verify. + * + * @return true if the millisecond is contained in the + * segment. + */ + public boolean contains(long millis) { + return (this.segmentStart <= millis && millis <= this.segmentEnd); + } + + /** + * Returns true if an interval is contained in this + * segment. + * + * @param from the start of the interval. + * @param to the end of the interval. + * + * @return true if the interval is contained in the + * segment. + */ + public boolean contains(long from, long to) { + return (this.segmentStart <= from && to <= this.segmentEnd); + } + + /** + * Returns true if a segment is contained in this segment. + * + * @param segment the segment to test for inclusion + * + * @return true if the segment is contained in this + * segment. + */ + public boolean contains(Segment segment) { + return contains(segment.getSegmentStart(), segment.getSegmentEnd()); + } + + /** + * Returns true if this segment is contained in an + * interval. + * + * @param from the start of the interval. + * @param to the end of the interval. + * + * @return true if this segment is contained in the + * interval. + */ + public boolean contained(long from, long to) { + return (from <= this.segmentStart && this.segmentEnd <= to); + } + + /** + * Returns a segment that is the intersection of this segment and the + * interval. + * + * @param from the start of the interval. + * @param to the end of the interval. + * + * @return A segment. + */ + public Segment intersect(long from, long to) { + if (from <= this.segmentStart && this.segmentEnd <= to) { + return this; + } + else { + return null; + } + } + + /** + * Returns true if this segment is wholly before another + * segment. + * + * @param other the other segment. + * + * @return A boolean. + */ + public boolean before(Segment other) { + return (this.segmentEnd < other.getSegmentStart()); + } + + /** + * Returns true if this segment is wholly after another + * segment. + * + * @param other the other segment. + * + * @return A boolean. + */ + public boolean after(Segment other) { + return (this.segmentStart > other.getSegmentEnd()); + } + + /** + * Tests an object (usually another Segment) for equality + * with this segment. + * + * @param object The other segment to compare with us + * + * @return true if we are the same segment + */ + @Override + public boolean equals(Object object) { + if (object instanceof Segment) { + Segment other = (Segment) object; + return (this.segmentNumber == other.getSegmentNumber() + && this.segmentStart == other.getSegmentStart() + && this.segmentEnd == other.getSegmentEnd() + && this.millisecond == other.getMillisecond()); + } + else { + return false; + } + } + + /** + * Returns a copy of ourselves or null if there was an + * exception during cloning. + * + * @return A copy of this segment. + */ + public Segment copy() { + try { + return (Segment) this.clone(); + } + catch (CloneNotSupportedException e) { + return null; + } + } + + /** + * Will compare this Segment with another Segment (from Comparable + * interface). + * + * @param object The other Segment to compare with + * + * @return -1: this < object, 0: this.equal(object) and + * +1: this > object + */ + @Override + public int compareTo(Object object) { + Segment other = (Segment) object; + if (this.before(other)) { + return -1; + } + else if (this.after(other)) { + return +1; + } + else { + return 0; + } + } + + /** + * Returns true if we are an included segment and we are not an + * exception. + * + * @return true or false. + */ + public boolean inIncludeSegments() { + if (getSegmentNumberRelativeToGroup() + < SegmentedTimeline.this.segmentsIncluded) { + return !inExceptionSegments(); + } + else { + return false; + } + } + + /** + * Returns true if we are an excluded segment. + * + * @return true or false. + */ + public boolean inExcludeSegments() { + return getSegmentNumberRelativeToGroup() + >= SegmentedTimeline.this.segmentsIncluded; + } + + /** + * Calculate the segment number relative to the segment group. This + * will be a number between 0 and segmentsGroup-1. This value is + * calculated from the segmentNumber. Special care is taken for + * negative segmentNumbers. + * + * @return The segment number. + */ + private long getSegmentNumberRelativeToGroup() { + long p = (this.segmentNumber + % SegmentedTimeline.this.groupSegmentCount); + if (p < 0) { + p += SegmentedTimeline.this.groupSegmentCount; + } + return p; + } + + /** + * Returns true if we are an exception segment. This is implemented via + * a binary search on the exceptionSegments sorted list. + * + * If the segment is not listed as an exception in our list and we have + * a baseTimeline, a check is performed to see if the segment is inside + * an excluded segment from our base. If so, it is also considered an + * exception. + * + * @return true if we are an exception segment. + */ + public boolean inExceptionSegments() { + return binarySearchExceptionSegments(this) >= 0; + } + + /** + * Increments the internal attributes of this segment by a number of + * segments. + * + * @param n Number of segments to increment. + */ + public void inc(long n) { + this.segmentNumber += n; + long m = n * SegmentedTimeline.this.segmentSize; + this.segmentStart += m; + this.segmentEnd += m; + this.millisecond += m; + } + + /** + * Increments the internal attributes of this segment by one segment. + * The exact time incremented is segmentSize. + */ + public void inc() { + inc(1); + } + + /** + * Decrements the internal attributes of this segment by a number of + * segments. + * + * @param n Number of segments to decrement. + */ + public void dec(long n) { + this.segmentNumber -= n; + long m = n * SegmentedTimeline.this.segmentSize; + this.segmentStart -= m; + this.segmentEnd -= m; + this.millisecond -= m; + } + + /** + * Decrements the internal attributes of this segment by one segment. + * The exact time decremented is segmentSize. + */ + public void dec() { + dec(1); + } + + /** + * Moves the index of this segment to the beginning if the segment. + */ + public void moveIndexToStart() { + this.millisecond = this.segmentStart; + } + + /** + * Moves the index of this segment to the end of the segment. + */ + public void moveIndexToEnd() { + this.millisecond = this.segmentEnd; + } + + } + + /** + * Private internal class to represent a range of segments. This class is + * mainly used to store in one object a range of exception segments. This + * optimizes certain timelines that use a small segment size (like an + * intraday timeline) allowing them to express a day exception as one + * SegmentRange instead of multi Segments. + */ + protected class SegmentRange extends Segment { + + /** The number of segments in the range. */ + private long segmentCount; + + /** + * Creates a SegmentRange between a start and end domain values. + * + * @param fromMillisecond start of the range + * @param toMillisecond end of the range + */ + public SegmentRange(long fromMillisecond, long toMillisecond) { + + Segment start = getSegment(fromMillisecond); + Segment end = getSegment(toMillisecond); +// if (start.getSegmentStart() != fromMillisecond +// || end.getSegmentEnd() != toMillisecond) { +// throw new IllegalArgumentException("Invalid Segment Range [" +// + fromMillisecond + "," + toMillisecond + "]"); +// } + + this.millisecond = fromMillisecond; + this.segmentNumber = calculateSegmentNumber(fromMillisecond); + this.segmentStart = start.segmentStart; + this.segmentEnd = end.segmentEnd; + this.segmentCount + = (end.getSegmentNumber() - start.getSegmentNumber() + 1); + } + + /** + * Returns the number of segments contained in this range. + * + * @return The segment count. + */ + @Override + public long getSegmentCount() { + return this.segmentCount; + } + + /** + * Returns a segment that is the intersection of this segment and the + * interval. + * + * @param from the start of the interval. + * @param to the end of the interval. + * + * @return The intersection. + */ + @Override + public Segment intersect(long from, long to) { + + // Segment fromSegment = getSegment(from); + // fromSegment.inc(); + // Segment toSegment = getSegment(to); + // toSegment.dec(); + long start = Math.max(from, this.segmentStart); + long end = Math.min(to, this.segmentEnd); + // long start = Math.max( + // fromSegment.getSegmentStart(), this.segmentStart + // ); + // long end = Math.min(toSegment.getSegmentEnd(), this.segmentEnd); + if (start <= end) { + return new SegmentRange(start, end); + } + else { + return null; + } + } + + /** + * Returns true if all Segments of this SegmentRenge are an included + * segment and are not an exception. + * + * @return true or false. + */ + @Override + public boolean inIncludeSegments() { + for (Segment segment = getSegment(this.segmentStart); + segment.getSegmentStart() < this.segmentEnd; + segment.inc()) { + if (!segment.inIncludeSegments()) { + return (false); + } + } + return true; + } + + /** + * Returns true if we are an excluded segment. + * + * @return true or false. + */ + @Override + public boolean inExcludeSegments() { + for (Segment segment = getSegment(this.segmentStart); + segment.getSegmentStart() < this.segmentEnd; + segment.inc()) { + if (!segment.inExceptionSegments()) { + return (false); + } + } + return true; + } + + /** + * Not implemented for SegmentRange. Always throws + * IllegalArgumentException. + * + * @param n Number of segments to increment. + */ + @Override + public void inc(long n) { + throw new IllegalArgumentException( + "Not implemented in SegmentRange"); + } + + } + + /** + * Special SegmentRange that came from the BaseTimeline. + */ + protected class BaseTimelineSegmentRange extends SegmentRange { + + /** + * Constructor. + * + * @param fromDomainValue the start value. + * @param toDomainValue the end value. + */ + public BaseTimelineSegmentRange(long fromDomainValue, + long toDomainValue) { + super(fromDomainValue, toDomainValue); + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/StandardTickUnitSource.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/StandardTickUnitSource.java new file mode 100755 index 0000000..a6c33fb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/StandardTickUnitSource.java @@ -0,0 +1,135 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * StandardTickUnitSource.java + * --------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Sep-2003 : Version 1 (DG); + * 25-Oct-2007 : Implemented Serializable and equals() method (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.Serializable; +import java.text.DecimalFormat; + +/** + * A source that can used by the {@link NumberAxis} class to obtain a + * suitable {@link TickUnit}. Instances of this class are {@link Serializable} + * from version 1.0.7 onwards. Cloning is not supported, because instances + * are immutable. + */ +public class StandardTickUnitSource implements TickUnitSource, Serializable { + + /** Constant for log(10.0). */ + private static final double LOG_10_VALUE = Math.log(10.0); + + /** + * Default constructor. + */ + public StandardTickUnitSource() { + super(); + } + + /** + * Returns a tick unit that is larger than the supplied unit. + * + * @param unit the unit (null not permitted). + * + * @return A tick unit that is larger than the supplied unit. + */ + @Override + public TickUnit getLargerTickUnit(TickUnit unit) { + double x = unit.getSize(); + double log = Math.log(x) / LOG_10_VALUE; + double higher = Math.ceil(log); + return new NumberTickUnit(Math.pow(10, higher), + new DecimalFormat("0.0E0")); + } + + /** + * Returns the tick unit in the collection that is greater than or equal + * to (in size) the specified unit. + * + * @param unit the unit (null not permitted). + * + * @return A unit from the collection. + */ + @Override + public TickUnit getCeilingTickUnit(TickUnit unit) { + return getLargerTickUnit(unit); + } + + /** + * Returns the tick unit in the collection that is greater than or equal + * to the specified size. + * + * @param size the size. + * + * @return A unit from the collection. + */ + @Override + public TickUnit getCeilingTickUnit(double size) { + double log = Math.log(size) / LOG_10_VALUE; + double higher = Math.ceil(log); + return new NumberTickUnit(Math.pow(10, higher), + new DecimalFormat("0.0E0")); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + return (obj instanceof StandardTickUnitSource); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return 0; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/SubCategoryAxis.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/SubCategoryAxis.java new file mode 100755 index 0000000..8cc454d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/SubCategoryAxis.java @@ -0,0 +1,454 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * SubCategoryAxis.java + * -------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert; + * Contributor(s): Adriaan Joubert; + * + * Changes + * ------- + * 12-May-2004 : Version 1 (DG); + * 30-Sep-2004 : Moved drawRotatedString() from RefineryUtilities + * --> TextUtilities (DG); + * 26-Apr-2005 : Removed logger (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 18-Aug-2006 : Fix for bug drawing category labels, thanks to Adriaan + * Joubert (1277726) (DG); + * 30-May-2007 : Added argument check and event notification to + * addSubCategory() (DG); + * 13-Nov-2008 : Fix NullPointerException when dataset is null - see bug + * report 2275695 (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * 01-Aug-2013 : Added attributedLabel override to support superscripts, + * subscripts and more (DG); + */ + +package org.jfree.chart.axis; + +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.event.AxisChangeEvent; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.category.CategoryDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.TextAnchor; + +/** + * A specialised category axis that can display sub-categories. + */ +public class SubCategoryAxis extends CategoryAxis + implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -1279463299793228344L; + + /** Storage for the sub-categories (these need to be set manually). */ + private List subCategories; + + /** The font for the sub-category labels. */ + private Font subLabelFont = new Font("SansSerif", Font.PLAIN, 10); + + /** The paint for the sub-category labels. */ + private transient Paint subLabelPaint = Color.black; + + /** + * Creates a new axis. + * + * @param label the axis label. + */ + public SubCategoryAxis(String label) { + super(label); + this.subCategories = new java.util.ArrayList(); + } + + /** + * Adds a sub-category to the axis and sends an {@link AxisChangeEvent} to + * all registered listeners. + * + * @param subCategory the sub-category (null not permitted). + */ + public void addSubCategory(Comparable subCategory) { + ParamChecks.nullNotPermitted(subCategory, "subCategory"); + this.subCategories.add(subCategory); + notifyListeners(new AxisChangeEvent(this)); + } + + /** + * Returns the font used to display the sub-category labels. + * + * @return The font (never null). + * + * @see #setSubLabelFont(Font) + */ + public Font getSubLabelFont() { + return this.subLabelFont; + } + + /** + * Sets the font used to display the sub-category labels and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getSubLabelFont() + */ + public void setSubLabelFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.subLabelFont = font; + notifyListeners(new AxisChangeEvent(this)); + } + + /** + * Returns the paint used to display the sub-category labels. + * + * @return The paint (never null). + * + * @see #setSubLabelPaint(Paint) + */ + public Paint getSubLabelPaint() { + return this.subLabelPaint; + } + + /** + * Sets the paint used to display the sub-category labels and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getSubLabelPaint() + */ + public void setSubLabelPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.subLabelPaint = paint; + notifyListeners(new AxisChangeEvent(this)); + } + + /** + * Estimates the space required for the axis, given a specific drawing area. + * + * @param g2 the graphics device (used to obtain font information). + * @param plot the plot that the axis belongs to. + * @param plotArea the area within which the axis should be drawn. + * @param edge the axis location (top or bottom). + * @param space the space already reserved. + * + * @return The space required to draw the axis. + */ + @Override + public AxisSpace reserveSpace(Graphics2D g2, Plot plot, + Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) { + + // create a new space object if one wasn't supplied... + if (space == null) { + space = new AxisSpace(); + } + + // if the axis is not visible, no additional space is required... + if (!isVisible()) { + return space; + } + + space = super.reserveSpace(g2, plot, plotArea, edge, space); + double maxdim = getMaxDim(g2, edge); + if (RectangleEdge.isTopOrBottom(edge)) { + space.add(maxdim, edge); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + space.add(maxdim, edge); + } + return space; + } + + /** + * Returns the maximum of the relevant dimension (height or width) of the + * subcategory labels. + * + * @param g2 the graphics device. + * @param edge the edge. + * + * @return The maximum dimension. + */ + private double getMaxDim(Graphics2D g2, RectangleEdge edge) { + double result = 0.0; + g2.setFont(this.subLabelFont); + FontMetrics fm = g2.getFontMetrics(); + Iterator iterator = this.subCategories.iterator(); + while (iterator.hasNext()) { + Comparable subcategory = (Comparable) iterator.next(); + String label = subcategory.toString(); + Rectangle2D bounds = TextUtilities.getTextBounds(label, g2, fm); + double dim; + if (RectangleEdge.isLeftOrRight(edge)) { + dim = bounds.getWidth(); + } + else { // must be top or bottom + dim = bounds.getHeight(); + } + result = Math.max(result, dim); + } + return result; + } + + /** + * Draws the axis on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device (null not permitted). + * @param cursor the cursor location. + * @param plotArea the area within which the axis should be drawn + * (null not permitted). + * @param dataArea the area within which the plot is being drawn + * (null not permitted). + * @param edge the location of the axis (null not permitted). + * @param plotState collects information about the plot + * (null permitted). + * + * @return The axis state (never null). + */ + @Override + 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); + } + + if (isAxisLineVisible()) { + drawAxisLine(g2, cursor, dataArea, edge); + } + + // draw the category labels and axis label + AxisState state = new AxisState(cursor); + state = drawSubCategoryLabels(g2, plotArea, dataArea, edge, state, + plotState); + state = drawCategoryLabels(g2, plotArea, dataArea, edge, state, + plotState); + if (getAttributedLabel() != null) { + state = drawAttributedLabel(getAttributedLabel(), g2, plotArea, + dataArea, edge, state); + } else { + state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); + } + return state; + + } + + /** + * Draws the category labels and returns the updated axis state. + * + * @param g2 the graphics device (null not permitted). + * @param plotArea the plot area (null not permitted). + * @param dataArea the area inside the axes (null not + * permitted). + * @param edge the axis location (null not permitted). + * @param state the axis state (null not permitted). + * @param plotState collects information about the plot (null + * permitted). + * + * @return The updated axis state (never null). + */ + protected AxisState drawSubCategoryLabels(Graphics2D g2, + Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, + AxisState state, PlotRenderingInfo plotState) { + + ParamChecks.nullNotPermitted(state, "state"); + + g2.setFont(this.subLabelFont); + g2.setPaint(this.subLabelPaint); + CategoryPlot plot = (CategoryPlot) getPlot(); + int categoryCount = 0; + CategoryDataset dataset = plot.getDataset(); + if (dataset != null) { + categoryCount = dataset.getColumnCount(); + } + + double maxdim = getMaxDim(g2, edge); + for (int categoryIndex = 0; categoryIndex < categoryCount; + categoryIndex++) { + + double x0 = 0.0; + double x1 = 0.0; + double y0 = 0.0; + double y1 = 0.0; + if (edge == RectangleEdge.TOP) { + x0 = getCategoryStart(categoryIndex, categoryCount, dataArea, + edge); + x1 = getCategoryEnd(categoryIndex, categoryCount, dataArea, + edge); + y1 = state.getCursor(); + y0 = y1 - maxdim; + } + else if (edge == RectangleEdge.BOTTOM) { + x0 = getCategoryStart(categoryIndex, categoryCount, dataArea, + edge); + x1 = getCategoryEnd(categoryIndex, categoryCount, dataArea, + edge); + y0 = state.getCursor(); + y1 = y0 + maxdim; + } + else if (edge == RectangleEdge.LEFT) { + y0 = getCategoryStart(categoryIndex, categoryCount, dataArea, + edge); + y1 = getCategoryEnd(categoryIndex, categoryCount, dataArea, + edge); + x1 = state.getCursor(); + x0 = x1 - maxdim; + } + else if (edge == RectangleEdge.RIGHT) { + y0 = getCategoryStart(categoryIndex, categoryCount, dataArea, + edge); + y1 = getCategoryEnd(categoryIndex, categoryCount, dataArea, + edge); + x0 = state.getCursor(); + x1 = x0 + maxdim; + } + Rectangle2D area = new Rectangle2D.Double(x0, y0, (x1 - x0), + (y1 - y0)); + int subCategoryCount = this.subCategories.size(); + float width = (float) ((x1 - x0) / subCategoryCount); + float height = (float) ((y1 - y0) / subCategoryCount); + float xx, yy; + for (int i = 0; i < subCategoryCount; i++) { + if (RectangleEdge.isTopOrBottom(edge)) { + xx = (float) (x0 + (i + 0.5) * width); + yy = (float) area.getCenterY(); + } + else { + xx = (float) area.getCenterX(); + yy = (float) (y0 + (i + 0.5) * height); + } + String label = this.subCategories.get(i).toString(); + TextUtilities.drawRotatedString(label, g2, xx, yy, + TextAnchor.CENTER, 0.0, TextAnchor.CENTER); + } + } + + if (edge.equals(RectangleEdge.TOP)) { + double h = maxdim; + state.cursorUp(h); + } + else if (edge.equals(RectangleEdge.BOTTOM)) { + double h = maxdim; + state.cursorDown(h); + } + else if (edge == RectangleEdge.LEFT) { + double w = maxdim; + state.cursorLeft(w); + } + else if (edge == RectangleEdge.RIGHT) { + double w = maxdim; + state.cursorRight(w); + } + return state; + } + + /** + * Tests the axis for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof SubCategoryAxis && super.equals(obj)) { + SubCategoryAxis axis = (SubCategoryAxis) obj; + if (!this.subCategories.equals(axis.subCategories)) { + return false; + } + if (!this.subLabelFont.equals(axis.subLabelFont)) { + return false; + } + if (!this.subLabelPaint.equals(axis.subLabelPaint)) { + return false; + } + return true; + } + return false; + } + + /** + * Returns a hashcode for this instance. + * + * @return A hashcode for this instance. + */ + @Override + public int hashCode() { + return super.hashCode(); + } + + /** + * 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/SymbolAxis.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/SymbolAxis.java new file mode 100755 index 0000000..d4900c9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/SymbolAxis.java @@ -0,0 +1,811 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * SymbolAxis.java + * --------------- + * (C) Copyright 2002-2013, by Anthony Boulestreau and Contributors. + * + * Original Author: Anthony Boulestreau; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * + * Changes + * ------- + * 29-Mar-2002 : First version (AB); + * 19-Apr-2002 : Updated formatting and import statements (DG); + * 21-Jun-2002 : Make change to use the class TickUnit - remove valueToString() + * method and add SymbolicTickUnit (AB); + * 25-Jun-2002 : Removed redundant code (DG); + * 25-Jul-2002 : Changed order of parameters in ValueAxis constructor (DG); + * 05-Sep-2002 : Updated constructor to reflect changes in the Axis class (DG); + * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); + * 14-Feb-2003 : Added back missing constructor code (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 14-May-2003 : Renamed HorizontalSymbolicAxis --> SymbolicAxis and merged in + * VerticalSymbolicAxis (DG); + * 12-Aug-2003 : Fixed bug where refreshTicks() method has different signature + * to super class (DG); + * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); + * 02-Nov-2003 : Added code to avoid overlapping labels (MR); + * 07-Nov-2003 : Modified to use new tick classes (DG); + * 18-Nov-2003 : Fixed bug where symbols are not being displayed on the + * axis (DG); + * 24-Nov-2003 : Added fix for gridlines on zooming (bug id 834643) (DG); + * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); + * 11-Mar-2004 : Modified the way the background grid color is being drawn, see + * this thread: + * http://www.jfree.org/phpBB2/viewtopic.php?p=22973 (DG); + * 16-Mar-2004 : Added plotState to draw() method (DG); + * 07-Apr-2004 : Modified string bounds calculation (DG); + * 28-Mar-2005 : Renamed autoRangeIncludesZero() --> getAutoRangeIncludesZero() + * and autoRangeStickyZero() --> getAutoRangeStickyZero() (DG); + * 05-Jul-2005 : Fixed signature on refreshTicks() method - see bug report + * 1232264 (DG); + * 06-Jul-2005 : Renamed SymbolicAxis --> SymbolAxis, added equals() method, + * renamed getSymbolicValue() --> getSymbols(), renamed + * symbolicGridPaint --> gridBandPaint, fixed serialization of + * gridBandPaint, renamed symbolicGridLinesVisible --> + * gridBandsVisible, eliminated symbolicGridLineList (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 28-Feb-2007 : Fixed bug 1669302 (tick label overlap) (DG); + * 25-Jul-2007 : Added new field for alternate grid band paint (DG); + * 15-Aug-2008 : Use alternate grid band paint when drawing (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.axis; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +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 java.text.NumberFormat; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; + +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.chart.util.ParamChecks; +import org.jfree.data.Range; +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; + +/** + * A standard linear value axis that replaces integer values with symbols. + */ +public class SymbolAxis extends NumberAxis implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7216330468770619716L; + + /** The default grid band paint. */ + public static final Paint DEFAULT_GRID_BAND_PAINT + = new Color(232, 234, 232, 128); + + /** + * The default paint for alternate grid bands. + * + * @since 1.0.7 + */ + public static final Paint DEFAULT_GRID_BAND_ALTERNATE_PAINT + = new Color(0, 0, 0, 0); // transparent + + /** The list of symbols to display instead of the numeric values. */ + private List symbols; + + /** Flag that indicates whether or not grid bands are visible. */ + private boolean gridBandsVisible; + + /** The paint used to color the grid bands (if the bands are visible). */ + private transient Paint gridBandPaint; + + /** + * The paint used to fill the alternate grid bands. + * + * @since 1.0.7 + */ + private transient Paint gridBandAlternatePaint; + + /** + * Constructs a symbol axis, using default attribute values where + * necessary. + * + * @param label the axis label (null permitted). + * @param sv the list of symbols to display instead of the numeric + * values. + */ + public SymbolAxis(String label, String[] sv) { + super(label); + this.symbols = Arrays.asList(sv); + this.gridBandsVisible = true; + this.gridBandPaint = DEFAULT_GRID_BAND_PAINT; + this.gridBandAlternatePaint = DEFAULT_GRID_BAND_ALTERNATE_PAINT; + setAutoTickUnitSelection(false, false); + setAutoRangeStickyZero(false); + + } + + /** + * Returns an array of the symbols for the axis. + * + * @return The symbols. + */ + public String[] getSymbols() { + String[] result = new String[this.symbols.size()]; + result = (String[]) this.symbols.toArray(result); + return result; + } + + /** + * Returns true if the grid bands are showing, and + * false otherwise. + * + * @return true if the grid bands are showing, and + * false otherwise. + * + * @see #setGridBandsVisible(boolean) + */ + public boolean isGridBandsVisible() { + return this.gridBandsVisible; + } + + /** + * Sets the visibility of the grid bands and notifies registered + * listeners that the axis has been modified. + * + * @param flag the new setting. + * + * @see #isGridBandsVisible() + */ + public void setGridBandsVisible(boolean flag) { + if (this.gridBandsVisible != flag) { + this.gridBandsVisible = flag; + fireChangeEvent(); + } + } + + /** + * Returns the paint used to color the grid bands. + * + * @return The grid band paint (never null). + * + * @see #setGridBandPaint(Paint) + * @see #isGridBandsVisible() + */ + public Paint getGridBandPaint() { + return this.gridBandPaint; + } + + /** + * Sets the grid band paint and sends an {@link AxisChangeEvent} to + * all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getGridBandPaint() + */ + public void setGridBandPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.gridBandPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint used for alternate grid bands. + * + * @return The paint (never null). + * + * @see #setGridBandAlternatePaint(Paint) + * @see #getGridBandPaint() + * + * @since 1.0.7 + */ + public Paint getGridBandAlternatePaint() { + return this.gridBandAlternatePaint; + } + + /** + * Sets the paint used for alternate grid bands and sends a + * {@link AxisChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getGridBandAlternatePaint() + * @see #setGridBandPaint(Paint) + * + * @since 1.0.7 + */ + public void setGridBandAlternatePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.gridBandAlternatePaint = paint; + fireChangeEvent(); + } + + /** + * This operation is not supported by this axis. + * + * @param g2 the graphics device. + * @param dataArea the area in which the plot and axes should be drawn. + * @param edge the edge along which the axis is drawn. + */ + @Override + protected void selectAutoTickUnit(Graphics2D g2, Rectangle2D dataArea, + RectangleEdge edge) { + throw new UnsupportedOperationException(); + } + + /** + * Draws the axis on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device (null not permitted). + * @param cursor the cursor location. + * @param plotArea the area within which the plot and axes should be drawn + * (null not permitted). + * @param dataArea the area within which the data should be drawn + * (null not permitted). + * @param edge the axis location (null not permitted). + * @param plotState collects information about the plot + * (null permitted). + * + * @return The axis state (never null). + */ + @Override + public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, + Rectangle2D dataArea, RectangleEdge edge, + PlotRenderingInfo plotState) { + + AxisState info = new AxisState(cursor); + if (isVisible()) { + info = super.draw(g2, cursor, plotArea, dataArea, edge, plotState); + } + if (this.gridBandsVisible) { + drawGridBands(g2, plotArea, dataArea, edge, info.getTicks()); + } + return info; + + } + + /** + * Draws the grid bands. Alternate bands are colored using + * gridBandPaint (DEFAULT_GRID_BAND_PAINT by + * default). + * + * @param g2 the graphics device. + * @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 edge the axis location. + * @param ticks the ticks. + */ + protected void drawGridBands(Graphics2D g2, Rectangle2D plotArea, + Rectangle2D dataArea, RectangleEdge edge, List ticks) { + + Shape savedClip = g2.getClip(); + g2.clip(dataArea); + if (RectangleEdge.isTopOrBottom(edge)) { + drawGridBandsHorizontal(g2, plotArea, dataArea, true, ticks); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + drawGridBandsVertical(g2, plotArea, dataArea, true, ticks); + } + g2.setClip(savedClip); + + } + + /** + * Draws the grid bands for the axis when it is at the top or bottom of + * the plot. + * + * @param g2 the graphics device. + * @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 firstGridBandIsDark True: the first grid band takes the + * color of gridBandPaint. + * False: the second grid band takes the + * color of gridBandPaint. + * @param ticks the ticks. + */ + protected void drawGridBandsHorizontal(Graphics2D g2, + Rectangle2D plotArea, Rectangle2D dataArea, + boolean firstGridBandIsDark, List ticks) { + + boolean currentGridBandIsDark = firstGridBandIsDark; + double yy = dataArea.getY(); + double xx1, xx2; + + //gets the outline stroke width of the plot + double outlineStrokeWidth; + if (getPlot().getOutlineStroke() != null) { + outlineStrokeWidth + = ((BasicStroke) getPlot().getOutlineStroke()).getLineWidth(); + } + else { + outlineStrokeWidth = 1d; + } + + Iterator iterator = ticks.iterator(); + ValueTick tick; + Rectangle2D band; + while (iterator.hasNext()) { + tick = (ValueTick) iterator.next(); + xx1 = valueToJava2D(tick.getValue() - 0.5d, dataArea, + RectangleEdge.BOTTOM); + xx2 = valueToJava2D(tick.getValue() + 0.5d, dataArea, + RectangleEdge.BOTTOM); + if (currentGridBandIsDark) { + g2.setPaint(this.gridBandPaint); + } + else { + g2.setPaint(this.gridBandAlternatePaint); + } + band = new Rectangle2D.Double(xx1, yy + outlineStrokeWidth, + xx2 - xx1, dataArea.getMaxY() - yy - outlineStrokeWidth); + g2.fill(band); + currentGridBandIsDark = !currentGridBandIsDark; + } + g2.setPaintMode(); + } + + /** + * Draws the grid bands for the axis when it is at the top or bottom of + * the plot. + * + * @param g2 the graphics device. + * @param drawArea the area within which the chart should be drawn. + * @param plotArea the area within which the plot should be drawn (a + * subset of the drawArea). + * @param firstGridBandIsDark True: the first grid band takes the + * color of gridBandPaint. + * False: the second grid band takes the + * color of gridBandPaint. + * @param ticks a list of ticks. + */ + protected void drawGridBandsVertical(Graphics2D g2, Rectangle2D drawArea, + Rectangle2D plotArea, boolean firstGridBandIsDark, List ticks) { + + boolean currentGridBandIsDark = firstGridBandIsDark; + double xx = plotArea.getX(); + double yy1, yy2; + + //gets the outline stroke width of the plot + double outlineStrokeWidth; + Stroke outlineStroke = getPlot().getOutlineStroke(); + if (outlineStroke != null && outlineStroke instanceof BasicStroke) { + outlineStrokeWidth = ((BasicStroke) outlineStroke).getLineWidth(); + } + else { + outlineStrokeWidth = 1d; + } + + Iterator iterator = ticks.iterator(); + ValueTick tick; + Rectangle2D band; + while (iterator.hasNext()) { + tick = (ValueTick) iterator.next(); + yy1 = valueToJava2D(tick.getValue() + 0.5d, plotArea, + RectangleEdge.LEFT); + yy2 = valueToJava2D(tick.getValue() - 0.5d, plotArea, + RectangleEdge.LEFT); + if (currentGridBandIsDark) { + g2.setPaint(this.gridBandPaint); + } + else { + g2.setPaint(this.gridBandAlternatePaint); + } + band = new Rectangle2D.Double(xx + outlineStrokeWidth, yy1, + plotArea.getMaxX() - xx - outlineStrokeWidth, yy2 - yy1); + g2.fill(band); + currentGridBandIsDark = !currentGridBandIsDark; + } + g2.setPaintMode(); + } + + /** + * Rescales the axis to ensure that all data is visible. + */ + @Override + protected void autoAdjustRange() { + + Plot plot = getPlot(); + if (plot == null) { + return; // no plot, no data + } + + if (plot instanceof ValueAxisPlot) { + + // ensure that all the symbols are displayed + double upper = this.symbols.size() - 1; + double lower = 0; + double range = upper - lower; + + // ensure the autorange is at least in size... + double minRange = getAutoRangeMinimumSize(); + if (range < minRange) { + upper = (upper + lower + minRange) / 2; + lower = (upper + lower - minRange) / 2; + } + + // this ensure that the grid bands will be displayed correctly. + double upperMargin = 0.5; + double lowerMargin = 0.5; + + if (getAutoRangeIncludesZero()) { + if (getAutoRangeStickyZero()) { + if (upper <= 0.0) { + upper = 0.0; + } + else { + upper = upper + upperMargin; + } + if (lower >= 0.0) { + lower = 0.0; + } + else { + lower = lower - lowerMargin; + } + } + else { + upper = Math.max(0.0, upper + upperMargin); + lower = Math.min(0.0, lower - lowerMargin); + } + } + else { + if (getAutoRangeStickyZero()) { + if (upper <= 0.0) { + upper = Math.min(0.0, upper + upperMargin); + } + else { + upper = upper + upperMargin * range; + } + if (lower >= 0.0) { + lower = Math.max(0.0, lower - lowerMargin); + } + else { + lower = lower - lowerMargin; + } + } + else { + upper = upper + upperMargin; + lower = lower - lowerMargin; + } + } + + setRange(new Range(lower, upper), false, false); + + } + + } + + /** + * 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 data should be drawn. + * @param edge the location of the axis. + * + * @return A list of ticks. + */ + @Override + public List refreshTicks(Graphics2D g2, AxisState state, + Rectangle2D dataArea, RectangleEdge edge) { + List ticks = null; + if (RectangleEdge.isTopOrBottom(edge)) { + ticks = refreshTicksHorizontal(g2, dataArea, edge); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + ticks = refreshTicksVertical(g2, dataArea, edge); + } + return ticks; + } + + /** + * 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 dataArea the area in which the data should be drawn. + * @param edge the location of the axis. + * + * @return The ticks. + */ + @Override + protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, + RectangleEdge edge) { + + List ticks = new java.util.ArrayList(); + + Font tickLabelFont = getTickLabelFont(); + g2.setFont(tickLabelFont); + + double size = getTickUnit().getSize(); + int count = calculateVisibleTickCount(); + double lowestTickValue = calculateLowestVisibleTickValue(); + + double previousDrawnTickLabelPos = 0.0; + double previousDrawnTickLabelLength = 0.0; + + if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { + for (int i = 0; i < count; i++) { + double currentTickValue = lowestTickValue + (i * size); + double xx = valueToJava2D(currentTickValue, dataArea, edge); + String tickLabel; + NumberFormat formatter = getNumberFormatOverride(); + if (formatter != null) { + tickLabel = formatter.format(currentTickValue); + } + else { + tickLabel = valueToString(currentTickValue); + } + + // avoid to draw overlapping tick labels + Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, + g2.getFontMetrics()); + double tickLabelLength = isVerticalTickLabels() + ? bounds.getHeight() : bounds.getWidth(); + boolean tickLabelsOverlapping = false; + if (i > 0) { + double avgTickLabelLength = (previousDrawnTickLabelLength + + tickLabelLength) / 2.0; + if (Math.abs(xx - previousDrawnTickLabelPos) + < avgTickLabelLength) { + tickLabelsOverlapping = true; + } + } + if (tickLabelsOverlapping) { + tickLabel = ""; // don't draw this tick label + } + else { + // remember these values for next comparison + previousDrawnTickLabelPos = xx; + previousDrawnTickLabelLength = tickLabelLength; + } + + TextAnchor anchor; + TextAnchor rotationAnchor; + double angle = 0.0; + if (isVerticalTickLabels()) { + anchor = TextAnchor.CENTER_RIGHT; + rotationAnchor = TextAnchor.CENTER_RIGHT; + if (edge == RectangleEdge.TOP) { + angle = Math.PI / 2.0; + } + else { + angle = -Math.PI / 2.0; + } + } + else { + if (edge == RectangleEdge.TOP) { + anchor = TextAnchor.BOTTOM_CENTER; + rotationAnchor = TextAnchor.BOTTOM_CENTER; + } + else { + anchor = TextAnchor.TOP_CENTER; + rotationAnchor = TextAnchor.TOP_CENTER; + } + } + Tick tick = new NumberTick(new Double(currentTickValue), + tickLabel, anchor, rotationAnchor, angle); + ticks.add(tick); + } + } + return ticks; + + } + + /** + * 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 dataArea the area in which the plot should be drawn. + * @param edge the location of the axis. + * + * @return The ticks. + */ + @Override + protected List refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, + RectangleEdge edge) { + + List ticks = new java.util.ArrayList(); + + Font tickLabelFont = getTickLabelFont(); + g2.setFont(tickLabelFont); + + double size = getTickUnit().getSize(); + int count = calculateVisibleTickCount(); + double lowestTickValue = calculateLowestVisibleTickValue(); + + double previousDrawnTickLabelPos = 0.0; + double previousDrawnTickLabelLength = 0.0; + + if (count <= ValueAxis.MAXIMUM_TICK_COUNT) { + for (int i = 0; i < count; i++) { + double currentTickValue = lowestTickValue + (i * size); + double yy = valueToJava2D(currentTickValue, dataArea, edge); + String tickLabel; + NumberFormat formatter = getNumberFormatOverride(); + if (formatter != null) { + tickLabel = formatter.format(currentTickValue); + } + else { + tickLabel = valueToString(currentTickValue); + } + + // avoid to draw overlapping tick labels + Rectangle2D bounds = TextUtilities.getTextBounds(tickLabel, g2, + g2.getFontMetrics()); + double tickLabelLength = isVerticalTickLabels() + ? bounds.getWidth() : bounds.getHeight(); + boolean tickLabelsOverlapping = false; + if (i > 0) { + double avgTickLabelLength = (previousDrawnTickLabelLength + + tickLabelLength) / 2.0; + if (Math.abs(yy - previousDrawnTickLabelPos) + < avgTickLabelLength) { + tickLabelsOverlapping = true; + } + } + if (tickLabelsOverlapping) { + tickLabel = ""; // don't draw this tick label + } + else { + // remember these values for next comparison + previousDrawnTickLabelPos = yy; + previousDrawnTickLabelLength = tickLabelLength; + } + + TextAnchor anchor; + TextAnchor rotationAnchor; + double angle = 0.0; + if (isVerticalTickLabels()) { + anchor = TextAnchor.BOTTOM_CENTER; + rotationAnchor = TextAnchor.BOTTOM_CENTER; + if (edge == RectangleEdge.LEFT) { + angle = -Math.PI / 2.0; + } + else { + angle = Math.PI / 2.0; + } + } + else { + if (edge == RectangleEdge.LEFT) { + anchor = TextAnchor.CENTER_RIGHT; + rotationAnchor = TextAnchor.CENTER_RIGHT; + } + else { + anchor = TextAnchor.CENTER_LEFT; + rotationAnchor = TextAnchor.CENTER_LEFT; + } + } + Tick tick = new NumberTick(new Double(currentTickValue), + tickLabel, anchor, rotationAnchor, angle); + ticks.add(tick); + } + } + return ticks; + + } + + /** + * Converts a value to a string, using the list of symbols. + * + * @param value value to convert. + * + * @return The symbol. + */ + public String valueToString(double value) { + String strToReturn; + try { + strToReturn = (String) this.symbols.get((int) value); + } + catch (IndexOutOfBoundsException ex) { + strToReturn = ""; + } + return strToReturn; + } + + /** + * Tests this axis for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SymbolAxis)) { + return false; + } + SymbolAxis that = (SymbolAxis) obj; + if (!this.symbols.equals(that.symbols)) { + return false; + } + if (this.gridBandsVisible != that.gridBandsVisible) { + return false; + } + if (!PaintUtilities.equal(this.gridBandPaint, that.gridBandPaint)) { + return false; + } + if (!PaintUtilities.equal(this.gridBandAlternatePaint, + that.gridBandAlternatePaint)) { + return false; + } + return super.equals(obj); + } + + /** + * 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.gridBandPaint, stream); + SerialUtilities.writePaint(this.gridBandAlternatePaint, 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.gridBandPaint = SerialUtilities.readPaint(stream); + this.gridBandAlternatePaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/Tick.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/Tick.java new file mode 100755 index 0000000..b427c6f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/Tick.java @@ -0,0 +1,184 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------- + * Tick.java + * --------- + * (C) Copyright 2000-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Nicolas Brodu; + * + * Changes + * ------- + * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 12-Sep-2003 : Implemented Cloneable (NB); + * 07-Nov-2003 : Added subclasses for particular types of ticks (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.ui.TextAnchor; +import org.jfree.util.ObjectUtilities; + +/** + * The base class used to represent labeled ticks along an axis. + */ +public abstract class Tick implements Serializable, Cloneable { + + /** For serialization. */ + private static final long serialVersionUID = 6668230383875149773L; + + /** A text version of the tick value. */ + private String text; + + /** The text anchor for the tick label. */ + private TextAnchor textAnchor; + + /** The rotation anchor for the tick label. */ + private TextAnchor rotationAnchor; + + /** The rotation angle. */ + private double angle; + + /** + * Creates a new tick. + * + * @param text the formatted version of the tick value. + * @param textAnchor the text anchor (null not permitted). + * @param rotationAnchor the rotation anchor (null not + * permitted). + * @param angle the angle. + */ + public Tick(String text, TextAnchor textAnchor, TextAnchor rotationAnchor, + double angle) { + ParamChecks.nullNotPermitted(textAnchor, "textAnchor"); + ParamChecks.nullNotPermitted(rotationAnchor, "rotationAnchor"); + this.text = text; + this.textAnchor = textAnchor; + this.rotationAnchor = rotationAnchor; + this.angle = angle; + } + + /** + * Returns the text version of the tick value. + * + * @return A string (possibly null; + */ + public String getText() { + return this.text; + } + + /** + * Returns the text anchor. + * + * @return The text anchor (never null). + */ + public TextAnchor getTextAnchor() { + return this.textAnchor; + } + + /** + * Returns the text anchor that defines the point around which the label is + * rotated. + * + * @return A text anchor (never null). + */ + public TextAnchor getRotationAnchor() { + return this.rotationAnchor; + } + + /** + * Returns the angle. + * + * @return The angle. + */ + public double getAngle() { + return this.angle; + } + + /** + * Tests this tick for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj instanceof Tick) { + Tick t = (Tick) obj; + if (!ObjectUtilities.equal(this.text, t.text)) { + return false; + } + if (!ObjectUtilities.equal(this.textAnchor, t.textAnchor)) { + return false; + } + if (!ObjectUtilities.equal(this.rotationAnchor, t.rotationAnchor)) { + return false; + } + if (!(this.angle == t.angle)) { + return false; + } + return true; + } + return false; + } + + /** + * Returns a clone of the tick. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + Tick clone = (Tick) super.clone(); + return clone; + } + + /** + * Returns a string representation of the tick. + * + * @return A string. + */ + @Override + public String toString() { + return this.text; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/TickType.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/TickType.java new file mode 100755 index 0000000..dba4091 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/TickType.java @@ -0,0 +1,123 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * TickType.java + * ------------- + * (C) Copyright 2007, 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 02-Aug-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Used to indicate the tick type (MAJOR or MINOR). + * + * @since 1.0.7 + */ +public final class TickType implements Serializable { + + /** Major tick. */ + public static final TickType MAJOR = new TickType("MAJOR"); + + /** Minor tick. */ + public static final TickType MINOR = new TickType("MINOR"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private TickType(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof TickType)) { + return false; + } + + TickType that = (TickType) obj; + if (!this.name.equals(that.name)) { + 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 { + Object result = null; + if (this.equals(TickType.MAJOR)) { + result = TickType.MAJOR; + } + else if (this.equals(TickType.MINOR)) { + result = TickType.MINOR; + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/TickUnit.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/TickUnit.java new file mode 100755 index 0000000..dbdf0ab --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/TickUnit.java @@ -0,0 +1,200 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * TickUnit.java + * ------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Dec-2001 : Added standard header (DG); + * 01-May-2002 : Changed the unit size from Number to double (DG); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 05-Sep-2005 : Implemented hashCode(), thanks to Thomas Morgner (DG); + * 02-Aug-2007 : Added minorTickCount attribute (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.Serializable; + +/** + * Base class representing a tick unit. This determines the spacing of the + * tick marks on an axis. + *

+ * This class (and any subclasses) should be immutable, the reason being that + * ORDERED collections of tick units are maintained and if one instance can be + * changed, it may destroy the order of the collection that it belongs to. + * In addition, if the implementations are immutable, they can belong to + * multiple collections. + * + * @see ValueAxis + */ +public abstract class TickUnit implements Comparable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 510179855057013974L; + + /** The size of the tick unit. */ + private double size; + + /** + * The number of minor ticks. + * + * @since 1.0.7 + */ + private int minorTickCount; + + /** + * Constructs a new tick unit. + * + * @param size the tick unit size. + */ + public TickUnit(double size) { + this.size = size; + } + + /** + * Constructs a new tick unit. + * + * @param size the tick unit size. + * @param minorTickCount the minor tick count. + * + * @since 1.0.7 + */ + public TickUnit(double size, int minorTickCount) { + this.size = size; + this.minorTickCount = minorTickCount; + } + + /** + * Returns the size of the tick unit. + * + * @return The size of the tick unit. + */ + public double getSize() { + return this.size; + } + + /** + * Returns the minor tick count. + * + * @return The minor tick count. + * + * @since 1.0.7 + */ + public int getMinorTickCount() { + return this.minorTickCount; + } + + /** + * Converts the supplied value to a string. + *

+ * Subclasses may implement special formatting by overriding this method. + * + * @param value the data value. + * + * @return Value as string. + */ + public String valueToString(double value) { + return String.valueOf(value); + } + + /** + * Compares this tick unit to an arbitrary object. + * + * @param object the object to compare against. + * + * @return 1 if the size of the other object is less than this, + * 0 if both have the same size and -1 this + * size is less than the others. + */ + @Override + public int compareTo(Object object) { + + if (object instanceof TickUnit) { + TickUnit other = (TickUnit) object; + if (this.size > other.getSize()) { + return 1; + } + else if (this.size < other.getSize()) { + return -1; + } + else { + return 0; + } + } + else { + return -1; + } + + } + + /** + * Tests this unit for equality with another object. + * + * @param obj the object. + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TickUnit)) { + return false; + } + TickUnit that = (TickUnit) obj; + if (this.size != that.size) { + return false; + } + if (this.minorTickCount != that.minorTickCount) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + long temp = this.size != +0.0d ? Double.doubleToLongBits(this.size) + : 0L; + return (int) (temp ^ (temp >>> 32)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/TickUnitSource.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/TickUnitSource.java new file mode 100755 index 0000000..f41ff34 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/TickUnitSource.java @@ -0,0 +1,78 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * TickUnitSource.java + * ------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Sep-2003 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +/** + * An interface used by the {@link DateAxis} and {@link NumberAxis} classes to + * obtain a suitable {@link TickUnit}. + */ +public interface TickUnitSource { + + /** + * Returns a tick unit that is larger than the supplied unit. + * + * @param unit the unit. + * + * @return A tick unit that is larger than the supplied unit. + */ + public TickUnit getLargerTickUnit(TickUnit unit); + + /** + * Returns the tick unit in the collection that is greater than or equal + * to (in size) the specified unit. + * + * @param unit the unit. + * + * @return A unit from the collection. + */ + public TickUnit getCeilingTickUnit(TickUnit unit); + + /** + * Returns the tick unit in the collection that is greater than or equal + * to the specified size. + * + * @param size the size. + * + * @return A unit from the collection. + */ + public TickUnit getCeilingTickUnit(double size); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/TickUnits.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/TickUnits.java new file mode 100755 index 0000000..a219ede --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/TickUnits.java @@ -0,0 +1,211 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * TickUnits.java + * -------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Nov-2001 : Version 1 (DG); + * 18-Feb-2002 : Fixed bug in getNearestTickUnit (thanks to Mario Inchiosa for + * reporting this, SourceForge bug id 518073) (DG); + * 25-Feb-2002 : Moved createStandardTickUnits() method from NumberAxis, and + * added createIntegerTickUnits() method (DG); + * 01-May-2002 : Updated for changes to the TickUnit class (DG); + * 18-Sep-2002 : Added standardTickUnit methods which take a Locale + * instance (AS); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 23-Sep-2003 : Implemented TickUnitSource interface (DG); + * 03-Dec-2003 : Adding null values now throws exceptions (TM); + * 11-Jan-2005 : Removed deprecated methods in preparation for 1.0.0 + * release (DG); + * + */ + +package org.jfree.chart.axis; + +import java.io.Serializable; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * A collection of tick units, used by the {@link DateAxis} and + * {@link NumberAxis} classes. + */ +public class TickUnits implements TickUnitSource, Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 1134174035901467545L; + + /** Storage for the tick units. */ + private List tickUnits; + + /** + * Constructs a new collection of tick units. + */ + public TickUnits() { + this.tickUnits = new ArrayList(); + } + + /** + * Adds a tick unit to the collection. The tick units are maintained in + * ascending order. + * + * @param unit the tick unit to add (null not permitted). + */ + public void add(TickUnit unit) { + if (unit == null) { + throw new NullPointerException("Null 'unit' argument."); + } + this.tickUnits.add(unit); + Collections.sort(this.tickUnits); + } + + /** + * Returns the number of tick units in this collection. + *

+ * This method is required for the XML writer. + * + * @return The number of units in this collection. + */ + public int size() { + return this.tickUnits.size(); + } + + /** + * Returns the tickunit on the given position. + *

+ * This method is required for the XML writer. + * + * @param pos the position in the list. + * + * @return The tickunit. + */ + public TickUnit get(int pos) { + return (TickUnit) this.tickUnits.get(pos); + } + + /** + * Returns a tick unit that is larger than the supplied unit. + * + * @param unit the unit. + * + * @return A tick unit that is larger than the supplied unit. + */ + @Override + public TickUnit getLargerTickUnit(TickUnit unit) { + int index = Collections.binarySearch(this.tickUnits, unit); + if (index >= 0) { + index = index + 1; + } + else { + index = -index; + } + + return (TickUnit) this.tickUnits.get(Math.min(index, + this.tickUnits.size() - 1)); + } + + /** + * Returns the tick unit in the collection that is greater than or equal + * to (in size) the specified unit. + * + * @param unit the unit. + * + * @return A unit from the collection. + */ + @Override + public TickUnit getCeilingTickUnit(TickUnit unit) { + int index = Collections.binarySearch(this.tickUnits, unit); + if (index >= 0) { + return (TickUnit) this.tickUnits.get(index); + } + else { + index = -(index + 1); + return (TickUnit) this.tickUnits.get(Math.min(index, + this.tickUnits.size() - 1)); + } + } + + /** + * Returns the tick unit in the collection that is greater than or equal + * to the specified size. + * + * @param size the size. + * + * @return A unit from the collection. + */ + @Override + public TickUnit getCeilingTickUnit(double size) { + return getCeilingTickUnit(new NumberTickUnit(size, + NumberFormat.getInstance())); + } + + /** + * Returns a clone of the collection. + * + * @return A clone. + * + * @throws CloneNotSupportedException if an item in the collection does not + * support cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + TickUnits clone = (TickUnits) super.clone(); + clone.tickUnits = new java.util.ArrayList(this.tickUnits); + return clone; + } + + /** + * Tests an object for equality with this instance. + * + * @param obj the object to test (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TickUnits)) { + return false; + } + TickUnits that = (TickUnits) obj; + return that.tickUnits.equals(this.tickUnits); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/Timeline.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/Timeline.java new file mode 100755 index 0000000..7af7bd4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/Timeline.java @@ -0,0 +1,155 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * Timeline.java + * ------------- + * (C) Copyright 2000-2008, by Object Refinery Limited and Contributors. + * + * Original Author: Bill Kelemen; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 23-May-2003 : Version 1 (BK); + * 09-Sep-2003 : Changed some method and parameter names (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.axis; + +import java.util.Date; + +/** + * An interface that defines the contract for a Timeline. + *

+ * A Timeline will present a series of values to be used for an axis. Each + * Timeline must provide transformation methods between domain values and + * timeline values. In theory many transformations are possible. This interface + * has been implemented completely in + * {@link org.jfree.chart.axis.SegmentedTimeline}. + *

+ * A timeline can be used as parameter to a + * {@link org.jfree.chart.axis.DateAxis} to define the values that this axis + * supports. As an example, the {@link org.jfree.chart.axis.SegmentedTimeline} + * implements a timeline formed by segments of equal length (ex. days, hours, + * minutes) where some segments can be included in the timeline and others + * excluded. Therefore timelines like "working days" or "working hours" can be + * created where non-working days or non-working hours respectively can be + * removed from the timeline, and therefore from the axis. This creates a smooth + * plot with equal separation between all included segments. + *

+ * Because Timelines were created mainly for Date related axis, values are + * represented as longs instead of doubles. In this case, the domain value is + * just the number of milliseconds since January 1, 1970, 00:00:00 GMT as + * defined by the getTime() method of {@link java.util.Date}. + * + * @see org.jfree.chart.axis.SegmentedTimeline + * @see org.jfree.chart.axis.DateAxis + */ +public interface Timeline { + + /** + * Translates a millisecond (as defined by java.util.Date) into an index + * along this timeline. + * + * @param millisecond the millisecond. + * + * @return A timeline value. + */ + long toTimelineValue(long millisecond); + + /** + * Translates a date into a value on this timeline. + * + * @param date the date. + * + * @return A timeline value + */ + long toTimelineValue(Date date); + + /** + * Translates a value relative to this timeline into a domain value. The + * domain value obtained by this method is not always the same domain value + * that could have been supplied to + * translateDomainValueToTimelineValue(domainValue). + * This is because the original transformation may not be complete + * reversable. + * + * @see org.jfree.chart.axis.SegmentedTimeline + * + * @param timelineValue a timeline value. + * + * @return A domain value. + */ + long toMillisecond(long timelineValue); + + /** + * Returns true if a value is contained in the timeline values. + * + * @param millisecond the millisecond. + * + * @return true if value is contained in the timeline and + * false otherwise. + */ + boolean containsDomainValue(long millisecond); + + /** + * Returns true if a date is contained in the timeline values. + * + * @param date the date to verify. + * + * @return true if value is contained in the timeline and + * false otherwise. + */ + boolean containsDomainValue(Date date); + + /** + * Returns true if a range of values are contained in the + * timeline. + * + * @param fromMillisecond the start of the range to verify. + * @param toMillisecond the end of the range to verify. + * + * @return true if the range is contained in the timeline or + * false otherwise + */ + boolean containsDomainRange(long fromMillisecond, long toMillisecond); + + /** + * Returns true if a range of dates are contained in the + * timeline. + * + * @param fromDate the start of the range to verify. + * @param toDate the end of the range to verify. + * + * @return true if the range is contained in the timeline or + * false otherwise + */ + boolean containsDomainRange(Date fromDate, Date toDate); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ValueAxis.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ValueAxis.java new file mode 100755 index 0000000..a24cacb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ValueAxis.java @@ -0,0 +1,1744 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * ValueAxis.java + * -------------- + * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Jonathan Nash; + * Nicolas Brodu (for Astrium and EADS Corporate Research + * Center); + * Peter Kolb (patch 1934255); + * Andrew Mickish (patch 1870189); + * + * Changes + * ------- + * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); + * 23-Nov-2001 : Overhauled standard tick unit code (DG); + * 04-Dec-2001 : Changed constructors to protected, and tidied up default + * values (DG); + * 12-Dec-2001 : Fixed vertical gridlines bug (DG); + * 16-Jan-2002 : Added an optional crosshair, based on the implementation by + * Jonathan Nash (DG); + * 23-Jan-2002 : Moved the minimum and maximum values to here from NumberAxis, + * and changed the type from Number to double (DG); + * 25-Feb-2002 : Added default value for autoRange. Changed autoAdjustRange + * from public to protected. Updated import statements (DG); + * 23-Apr-2002 : Added setRange() method (DG); + * 29-Apr-2002 : Added range adjustment methods (DG); + * 13-Jun-2002 : Modified setCrosshairValue() to notify listeners only when the + * crosshairs are visible, to avoid unnecessary repaints, as + * suggested by Kees Kuip (DG); + * 25-Jul-2002 : Moved lower and upper margin attributes from the NumberAxis + * class (DG); + * 05-Sep-2002 : Updated constructor for changes in Axis class (DG); + * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 04-Oct-2002 : Moved standardTickUnits from NumberAxis --> ValueAxis (DG); + * 08-Nov-2002 : Moved to new package com.jrefinery.chart.axis (DG); + * 19-Nov-2002 : Removed grid settings (now controlled by the plot) (DG); + * 27-Nov-2002 : Moved the 'inverted' attribute from NumberAxis to + * ValueAxis (DG); + * 03-Jan-2003 : Small fix to ensure auto-range minimum is observed + * immediately (DG); + * 14-Jan-2003 : Changed autoRangeMinimumSize from Number --> double (DG); + * 20-Jan-2003 : Replaced monolithic constructor (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 09-May-2003 : Added AxisLocation parameter to translation methods (DG); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 01-Sep-2003 : Fixed bug 793167 (setMaximumAxisValue exception) (DG); + * 02-Sep-2003 : Fixed bug 795366 (zooming on inverted axes) (DG); + * 08-Sep-2003 : Completed Serialization support (NB); + * 08-Sep-2003 : Renamed get/setMinimumValue --> get/setLowerBound, + * and get/setMaximumValue --> get/setUpperBound (DG); + * 27-Oct-2003 : Changed DEFAULT_AUTO_RANGE_MINIMUM_SIZE value - see bug ID + * 829606 (DG); + * 07-Nov-2003 : Changes to tick mechanism (DG); + * 06-Jan-2004 : Moved axis line attributes to Axis class (DG); + * 21-Jan-2004 : Removed redundant axisLineVisible attribute. Renamed + * translateJava2DToValue --> java2DToValue, and + * translateValueToJava2D --> valueToJava2D (DG); + * 23-Jan-2004 : Fixed setAxisLinePaint() and setAxisLineStroke() which had no + * effect (andreas.gawecki@coremedia.com); + * 07-Apr-2004 : Changed text bounds calculation (DG); + * 26-Apr-2004 : Added getter/setter methods for arrow shapes (DG); + * 18-May-2004 : Added methods to set axis range *including* current + * margins (DG); + * 02-Jun-2004 : Fixed bug in setRangeWithMargins() method (DG); + * 30-Sep-2004 : Moved drawRotatedString() from RefineryUtilities + * --> TextUtilities (DG); + * 11-Jan-2005 : Removed deprecated methods in preparation for 1.0.0 + * release (DG); + * 21-Apr-2005 : Replaced Insets with RectangleInsets (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 10-Oct-2006 : Source reformatting (DG); + * 22-Mar-2007 : Added new defaultAutoRange attribute (DG); + * 02-Aug-2007 : Check for major tick when drawing label (DG); + * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); + * 21-Jan-2009 : Updated default behaviour of minor ticks (DG); + * 18-Mar-2008 : Added resizeRange2() method which provides more natural + * anchored zooming for mouse wheel support (DG); + * 26-Mar-2009 : In equals(), only check current range if autoRange is + * false (DG); + * 30-Mar-2009 : Added pan(double) method (DG); + * 03-Sep-2012 : Fix reserveSpace() method, bug 3555275 (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.axis; + +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Polygon; +import java.awt.Shape; +import java.awt.font.LineMetrics; +import java.awt.geom.AffineTransform; +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 java.util.Iterator; +import java.util.List; + +import org.jfree.chart.event.AxisChangeEvent; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * The base class for axes that display value data, where values are measured + * using the double primitive. The two key subclasses are + * {@link DateAxis} and {@link NumberAxis}. + */ +public abstract class ValueAxis extends Axis + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 3698345477322391456L; + + /** The default axis range. */ + public static final Range DEFAULT_RANGE = new Range(0.0, 1.0); + + /** The default auto-range value. */ + public static final boolean DEFAULT_AUTO_RANGE = true; + + /** The default inverted flag setting. */ + public static final boolean DEFAULT_INVERTED = false; + + /** The default minimum auto range. */ + public static final double DEFAULT_AUTO_RANGE_MINIMUM_SIZE = 0.00000001; + + /** The default value for the lower margin (0.05 = 5%). */ + public static final double DEFAULT_LOWER_MARGIN = 0.05; + + /** The default value for the upper margin (0.05 = 5%). */ + public static final double DEFAULT_UPPER_MARGIN = 0.05; + + /** + * The default lower bound for the axis. + * + * @deprecated From 1.0.5 onwards, the axis defines a defaultRange + * attribute (see {@link #getDefaultAutoRange()}). + */ + public static final double DEFAULT_LOWER_BOUND = 0.0; + + /** + * The default upper bound for the axis. + * + * @deprecated From 1.0.5 onwards, the axis defines a defaultRange + * attribute (see {@link #getDefaultAutoRange()}). + */ + public static final double DEFAULT_UPPER_BOUND = 1.0; + + /** The default auto-tick-unit-selection value. */ + public static final boolean DEFAULT_AUTO_TICK_UNIT_SELECTION = true; + + /** The maximum tick count. */ + public static final int MAXIMUM_TICK_COUNT = 500; + + /** + * A flag that controls whether an arrow is drawn at the positive end of + * the axis line. + */ + private boolean positiveArrowVisible; + + /** + * A flag that controls whether an arrow is drawn at the negative end of + * the axis line. + */ + private boolean negativeArrowVisible; + + /** The shape used for an up arrow. */ + private transient Shape upArrow; + + /** The shape used for a down arrow. */ + private transient Shape downArrow; + + /** The shape used for a left arrow. */ + private transient Shape leftArrow; + + /** The shape used for a right arrow. */ + private transient Shape rightArrow; + + /** A flag that affects the orientation of the values on the axis. */ + private boolean inverted; + + /** The axis range. */ + private Range range; + + /** + * Flag that indicates whether the axis automatically scales to fit the + * chart data. + */ + private boolean autoRange; + + /** The minimum size for the 'auto' axis range (excluding margins). */ + private double autoRangeMinimumSize; + + /** + * The default range is used when the dataset is empty and the axis needs + * to determine the auto range. + * + * @since 1.0.5 + */ + private Range defaultAutoRange; + + /** + * The upper margin percentage. This indicates the amount by which the + * maximum axis value exceeds the maximum data value (as a percentage of + * the range on the axis) when the axis range is determined automatically. + */ + private double upperMargin; + + /** + * The lower margin. This is a percentage that indicates the amount by + * which the minimum axis value is "less than" the minimum data value when + * the axis range is determined automatically. + */ + private double lowerMargin; + + /** + * If this value is positive, the amount is subtracted from the maximum + * data value to determine the lower axis range. This can be used to + * provide a fixed "window" on dynamic data. + */ + private double fixedAutoRange; + + /** + * Flag that indicates whether or not the tick unit is selected + * automatically. + */ + private boolean autoTickUnitSelection; + + /** The standard tick units for the axis. */ + private TickUnitSource standardTickUnits; + + /** An index into an array of standard tick values. */ + private int autoTickIndex; + + /** + * The number of minor ticks per major tick unit. This is an override + * field, if the value is > 0 it is used, otherwise the axis refers to the + * minorTickCount in the current tickUnit. + */ + private int minorTickCount; + + /** A flag indicating whether or not tick labels are rotated to vertical. */ + private boolean verticalTickLabels; + + /** + * Constructs a value axis. + * + * @param label the axis label (null permitted). + * @param standardTickUnits the source for standard tick units + * (null permitted). + */ + protected ValueAxis(String label, TickUnitSource standardTickUnits) { + + super(label); + + this.positiveArrowVisible = false; + this.negativeArrowVisible = false; + + this.range = DEFAULT_RANGE; + this.autoRange = DEFAULT_AUTO_RANGE; + this.defaultAutoRange = DEFAULT_RANGE; + + this.inverted = DEFAULT_INVERTED; + this.autoRangeMinimumSize = DEFAULT_AUTO_RANGE_MINIMUM_SIZE; + + this.lowerMargin = DEFAULT_LOWER_MARGIN; + this.upperMargin = DEFAULT_UPPER_MARGIN; + + this.fixedAutoRange = 0.0; + + this.autoTickUnitSelection = DEFAULT_AUTO_TICK_UNIT_SELECTION; + this.standardTickUnits = standardTickUnits; + + Polygon p1 = new Polygon(); + p1.addPoint(0, 0); + p1.addPoint(-2, 2); + p1.addPoint(2, 2); + + this.upArrow = p1; + + Polygon p2 = new Polygon(); + p2.addPoint(0, 0); + p2.addPoint(-2, -2); + p2.addPoint(2, -2); + + this.downArrow = p2; + + Polygon p3 = new Polygon(); + p3.addPoint(0, 0); + p3.addPoint(-2, -2); + p3.addPoint(-2, 2); + + this.rightArrow = p3; + + Polygon p4 = new Polygon(); + p4.addPoint(0, 0); + p4.addPoint(2, -2); + p4.addPoint(2, 2); + + this.leftArrow = p4; + + this.verticalTickLabels = false; + this.minorTickCount = 0; + + } + + /** + * Returns true if the tick labels should be rotated (to + * vertical), and false otherwise. + * + * @return true or false. + * + * @see #setVerticalTickLabels(boolean) + */ + public boolean isVerticalTickLabels() { + return this.verticalTickLabels; + } + + /** + * Sets the flag that controls whether the tick labels are displayed + * vertically (that is, rotated 90 degrees from horizontal). If the flag + * is changed, an {@link AxisChangeEvent} is sent to all registered + * listeners. + * + * @param flag the flag. + * + * @see #isVerticalTickLabels() + */ + public void setVerticalTickLabels(boolean flag) { + if (this.verticalTickLabels != flag) { + this.verticalTickLabels = flag; + fireChangeEvent(); + } + } + + /** + * Returns a flag that controls whether or not the axis line has an arrow + * drawn that points in the positive direction for the axis. + * + * @return A boolean. + * + * @see #setPositiveArrowVisible(boolean) + */ + public boolean isPositiveArrowVisible() { + return this.positiveArrowVisible; + } + + /** + * Sets a flag that controls whether or not the axis lines has an arrow + * drawn that points in the positive direction for the axis, and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param visible the flag. + * + * @see #isPositiveArrowVisible() + */ + public void setPositiveArrowVisible(boolean visible) { + this.positiveArrowVisible = visible; + fireChangeEvent(); + } + + /** + * Returns a flag that controls whether or not the axis line has an arrow + * drawn that points in the negative direction for the axis. + * + * @return A boolean. + * + * @see #setNegativeArrowVisible(boolean) + */ + public boolean isNegativeArrowVisible() { + return this.negativeArrowVisible; + } + + /** + * Sets a flag that controls whether or not the axis lines has an arrow + * drawn that points in the negative direction for the axis, and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param visible the flag. + * + * @see #setNegativeArrowVisible(boolean) + */ + public void setNegativeArrowVisible(boolean visible) { + this.negativeArrowVisible = visible; + fireChangeEvent(); + } + + /** + * Returns a shape that can be displayed as an arrow pointing upwards at + * the end of an axis line. + * + * @return A shape (never null). + * + * @see #setUpArrow(Shape) + */ + public Shape getUpArrow() { + return this.upArrow; + } + + /** + * Sets the shape that can be displayed as an arrow pointing upwards at + * the end of an axis line and sends an {@link AxisChangeEvent} to all + * registered listeners. + * + * @param arrow the arrow shape (null not permitted). + * + * @see #getUpArrow() + */ + public void setUpArrow(Shape arrow) { + ParamChecks.nullNotPermitted(arrow, "arrow"); + this.upArrow = arrow; + fireChangeEvent(); + } + + /** + * Returns a shape that can be displayed as an arrow pointing downwards at + * the end of an axis line. + * + * @return A shape (never null). + * + * @see #setDownArrow(Shape) + */ + public Shape getDownArrow() { + return this.downArrow; + } + + /** + * Sets the shape that can be displayed as an arrow pointing downwards at + * the end of an axis line and sends an {@link AxisChangeEvent} to all + * registered listeners. + * + * @param arrow the arrow shape (null not permitted). + * + * @see #getDownArrow() + */ + public void setDownArrow(Shape arrow) { + ParamChecks.nullNotPermitted(arrow, "arrow"); + this.downArrow = arrow; + fireChangeEvent(); + } + + /** + * Returns a shape that can be displayed as an arrow pointing left at the + * end of an axis line. + * + * @return A shape (never null). + * + * @see #setLeftArrow(Shape) + */ + public Shape getLeftArrow() { + return this.leftArrow; + } + + /** + * Sets the shape that can be displayed as an arrow pointing left at the + * end of an axis line and sends an {@link AxisChangeEvent} to all + * registered listeners. + * + * @param arrow the arrow shape (null not permitted). + * + * @see #getLeftArrow() + */ + public void setLeftArrow(Shape arrow) { + ParamChecks.nullNotPermitted(arrow, "arrow"); + this.leftArrow = arrow; + fireChangeEvent(); + } + + /** + * Returns a shape that can be displayed as an arrow pointing right at the + * end of an axis line. + * + * @return A shape (never null). + * + * @see #setRightArrow(Shape) + */ + public Shape getRightArrow() { + return this.rightArrow; + } + + /** + * Sets the shape that can be displayed as an arrow pointing rightwards at + * the end of an axis line and sends an {@link AxisChangeEvent} to all + * registered listeners. + * + * @param arrow the arrow shape (null not permitted). + * + * @see #getRightArrow() + */ + public void setRightArrow(Shape arrow) { + ParamChecks.nullNotPermitted(arrow, "arrow"); + this.rightArrow = arrow; + fireChangeEvent(); + } + + /** + * Draws an axis line at the current cursor position and edge. + * + * @param g2 the graphics device. + * @param cursor the cursor position. + * @param dataArea the data area. + * @param edge the edge. + */ + @Override + protected void drawAxisLine(Graphics2D g2, double cursor, + Rectangle2D dataArea, RectangleEdge edge) { + Line2D axisLine = null; + if (edge == RectangleEdge.TOP) { + axisLine = new Line2D.Double(dataArea.getX(), cursor, + dataArea.getMaxX(), cursor); + } + else if (edge == RectangleEdge.BOTTOM) { + axisLine = new Line2D.Double(dataArea.getX(), cursor, + dataArea.getMaxX(), cursor); + } + else if (edge == RectangleEdge.LEFT) { + axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, + dataArea.getMaxY()); + } + else if (edge == RectangleEdge.RIGHT) { + axisLine = new Line2D.Double(cursor, dataArea.getY(), cursor, + dataArea.getMaxY()); + } + g2.setPaint(getAxisLinePaint()); + g2.setStroke(getAxisLineStroke()); + g2.draw(axisLine); + + boolean drawUpOrRight = false; + boolean drawDownOrLeft = false; + if (this.positiveArrowVisible) { + if (this.inverted) { + drawDownOrLeft = true; + } + else { + drawUpOrRight = true; + } + } + if (this.negativeArrowVisible) { + if (this.inverted) { + drawUpOrRight = true; + } + else { + drawDownOrLeft = true; + } + } + if (drawUpOrRight) { + double x = 0.0; + double y = 0.0; + Shape arrow = null; + if (edge == RectangleEdge.TOP || edge == RectangleEdge.BOTTOM) { + x = dataArea.getMaxX(); + y = cursor; + arrow = this.rightArrow; + } + else if (edge == RectangleEdge.LEFT + || edge == RectangleEdge.RIGHT) { + x = cursor; + y = dataArea.getMinY(); + arrow = this.upArrow; + } + + // draw the arrow... + AffineTransform transformer = new AffineTransform(); + transformer.setToTranslation(x, y); + Shape shape = transformer.createTransformedShape(arrow); + g2.fill(shape); + g2.draw(shape); + } + + if (drawDownOrLeft) { + double x = 0.0; + double y = 0.0; + Shape arrow = null; + if (edge == RectangleEdge.TOP || edge == RectangleEdge.BOTTOM) { + x = dataArea.getMinX(); + y = cursor; + arrow = this.leftArrow; + } + else if (edge == RectangleEdge.LEFT + || edge == RectangleEdge.RIGHT) { + x = cursor; + y = dataArea.getMaxY(); + arrow = this.downArrow; + } + + // draw the arrow... + AffineTransform transformer = new AffineTransform(); + transformer.setToTranslation(x, y); + Shape shape = transformer.createTransformedShape(arrow); + g2.fill(shape); + g2.draw(shape); + } + + } + + /** + * Calculates the anchor point for a tick label. + * + * @param tick the tick. + * @param cursor the cursor. + * @param dataArea the data area. + * @param edge the edge on which the axis is drawn. + * + * @return The x and y coordinates of the anchor point. + */ + protected float[] calculateAnchorPoint(ValueTick tick, double cursor, + Rectangle2D dataArea, RectangleEdge edge) { + + RectangleInsets insets = getTickLabelInsets(); + float[] result = new float[2]; + if (edge == RectangleEdge.TOP) { + result[0] = (float) valueToJava2D(tick.getValue(), dataArea, edge); + result[1] = (float) (cursor - insets.getBottom() - 2.0); + } + else if (edge == RectangleEdge.BOTTOM) { + result[0] = (float) valueToJava2D(tick.getValue(), dataArea, edge); + result[1] = (float) (cursor + insets.getTop() + 2.0); + } + else if (edge == RectangleEdge.LEFT) { + result[0] = (float) (cursor - insets.getLeft() - 2.0); + result[1] = (float) valueToJava2D(tick.getValue(), dataArea, edge); + } + else if (edge == RectangleEdge.RIGHT) { + result[0] = (float) (cursor + insets.getRight() + 2.0); + result[1] = (float) valueToJava2D(tick.getValue(), dataArea, edge); + } + return result; + } + + /** + * Draws the axis line, tick marks and tick mark labels. + * + * @param g2 the graphics device. + * @param cursor the cursor. + * @param plotArea the plot area. + * @param dataArea the data area. + * @param edge the edge that the axis is aligned with. + * + * @return The width or height used to draw the axis. + */ + protected AxisState drawTickMarksAndLabels(Graphics2D g2, + double cursor, Rectangle2D plotArea, Rectangle2D dataArea, + RectangleEdge edge) { + + AxisState state = new AxisState(cursor); + + if (isAxisLineVisible()) { + drawAxisLine(g2, cursor, dataArea, edge); + } + + List ticks = refreshTicks(g2, state, dataArea, edge); + state.setTicks(ticks); + g2.setFont(getTickLabelFont()); + Iterator iterator = ticks.iterator(); + while (iterator.hasNext()) { + ValueTick tick = (ValueTick) iterator.next(); + if (isTickLabelsVisible()) { + g2.setPaint(getTickLabelPaint()); + float[] anchorPoint = calculateAnchorPoint(tick, cursor, + dataArea, edge); + TextUtilities.drawRotatedString(tick.getText(), g2, + anchorPoint[0], anchorPoint[1], tick.getTextAnchor(), + tick.getAngle(), tick.getRotationAnchor()); + } + + if ((isTickMarksVisible() && tick.getTickType().equals( + TickType.MAJOR)) || (isMinorTickMarksVisible() + && tick.getTickType().equals(TickType.MINOR))) { + + double ol = (tick.getTickType().equals(TickType.MINOR)) + ? getMinorTickMarkOutsideLength() + : getTickMarkOutsideLength(); + + double il = (tick.getTickType().equals(TickType.MINOR)) + ? getMinorTickMarkInsideLength() + : getTickMarkInsideLength(); + + float xx = (float) valueToJava2D(tick.getValue(), dataArea, + edge); + Line2D mark = null; + g2.setStroke(getTickMarkStroke()); + g2.setPaint(getTickMarkPaint()); + if (edge == RectangleEdge.LEFT) { + mark = new Line2D.Double(cursor - ol, xx, cursor + il, xx); + } + else if (edge == RectangleEdge.RIGHT) { + mark = new Line2D.Double(cursor + ol, xx, cursor - il, xx); + } + else if (edge == RectangleEdge.TOP) { + mark = new Line2D.Double(xx, cursor - ol, xx, cursor + il); + } + else if (edge == RectangleEdge.BOTTOM) { + mark = new Line2D.Double(xx, cursor + ol, xx, cursor - il); + } + g2.draw(mark); + } + } + + // need to work out the space used by the tick labels... + // so we can update the cursor... + double used = 0.0; + if (isTickLabelsVisible()) { + if (edge == RectangleEdge.LEFT) { + used += findMaximumTickLabelWidth(ticks, g2, plotArea, + isVerticalTickLabels()); + state.cursorLeft(used); + } + else if (edge == RectangleEdge.RIGHT) { + used = findMaximumTickLabelWidth(ticks, g2, plotArea, + isVerticalTickLabels()); + state.cursorRight(used); + } + else if (edge == RectangleEdge.TOP) { + used = findMaximumTickLabelHeight(ticks, g2, plotArea, + isVerticalTickLabels()); + state.cursorUp(used); + } + else if (edge == RectangleEdge.BOTTOM) { + used = findMaximumTickLabelHeight(ticks, g2, plotArea, + isVerticalTickLabels()); + state.cursorDown(used); + } + } + + return state; + } + + /** + * Returns the space required to draw the axis. + * + * @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 edge the axis location. + * @param space the space already reserved (for other axes). + * + * @return The space required to draw the axis (including pre-reserved + * space). + */ + @Override + public AxisSpace reserveSpace(Graphics2D g2, Plot plot, + Rectangle2D plotArea, RectangleEdge edge, AxisSpace space) { + + // create a new space object if one wasn't supplied... + if (space == null) { + space = new AxisSpace(); + } + + // if the axis is not visible, no additional space is required... + if (!isVisible()) { + return space; + } + + // if the axis has a fixed dimension, return it... + double dimension = getFixedDimension(); + if (dimension > 0.0) { + space.add(dimension, edge); + return space; + } + + // calculate the max size of the tick labels (if visible)... + double tickLabelHeight = 0.0; + double tickLabelWidth = 0.0; + if (isTickLabelsVisible()) { + g2.setFont(getTickLabelFont()); + List ticks = refreshTicks(g2, new AxisState(), plotArea, edge); + if (RectangleEdge.isTopOrBottom(edge)) { + tickLabelHeight = findMaximumTickLabelHeight(ticks, g2, + plotArea, isVerticalTickLabels()); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + tickLabelWidth = findMaximumTickLabelWidth(ticks, g2, plotArea, + isVerticalTickLabels()); + } + } + + // get the axis label size and update the space object... + Rectangle2D labelEnclosure = getLabelEnclosure(g2, edge); + if (RectangleEdge.isTopOrBottom(edge)) { + double labelHeight = labelEnclosure.getHeight(); + space.add(labelHeight + tickLabelHeight, edge); + } + else if (RectangleEdge.isLeftOrRight(edge)) { + double labelWidth = labelEnclosure.getWidth(); + space.add(labelWidth + tickLabelWidth, edge); + } + + return space; + + } + + /** + * A utility method for determining the height of the tallest tick label. + * + * @param ticks the ticks. + * @param g2 the graphics device. + * @param drawArea the area within which the plot and axes should be drawn. + * @param vertical a flag that indicates whether or not the tick labels + * are 'vertical'. + * + * @return The height of the tallest tick label. + */ + protected double findMaximumTickLabelHeight(List ticks, Graphics2D g2, + Rectangle2D drawArea, boolean vertical) { + + RectangleInsets insets = getTickLabelInsets(); + Font font = getTickLabelFont(); + double maxHeight = 0.0; + if (vertical) { + FontMetrics fm = g2.getFontMetrics(font); + Iterator iterator = ticks.iterator(); + while (iterator.hasNext()) { + Tick tick = (Tick) iterator.next(); + Rectangle2D labelBounds = TextUtilities.getTextBounds( + tick.getText(), g2, fm); + if (labelBounds.getWidth() + insets.getTop() + + insets.getBottom() > maxHeight) { + maxHeight = labelBounds.getWidth() + + insets.getTop() + insets.getBottom(); + } + } + } + else { + LineMetrics metrics = font.getLineMetrics("ABCxyz", + g2.getFontRenderContext()); + maxHeight = metrics.getHeight() + + insets.getTop() + insets.getBottom(); + } + return maxHeight; + + } + + /** + * A utility method for determining the width of the widest tick label. + * + * @param ticks the ticks. + * @param g2 the graphics device. + * @param drawArea the area within which the plot and axes should be drawn. + * @param vertical a flag that indicates whether or not the tick labels + * are 'vertical'. + * + * @return The width of the tallest tick label. + */ + protected double findMaximumTickLabelWidth(List ticks, Graphics2D g2, + Rectangle2D drawArea, boolean vertical) { + + RectangleInsets insets = getTickLabelInsets(); + Font font = getTickLabelFont(); + double maxWidth = 0.0; + if (!vertical) { + FontMetrics fm = g2.getFontMetrics(font); + Iterator iterator = ticks.iterator(); + while (iterator.hasNext()) { + Tick tick = (Tick) iterator.next(); + Rectangle2D labelBounds = TextUtilities.getTextBounds( + tick.getText(), g2, fm); + if (labelBounds.getWidth() + insets.getLeft() + + insets.getRight() > maxWidth) { + maxWidth = labelBounds.getWidth() + + insets.getLeft() + insets.getRight(); + } + } + } + else { + LineMetrics metrics = font.getLineMetrics("ABCxyz", + g2.getFontRenderContext()); + maxWidth = metrics.getHeight() + + insets.getTop() + insets.getBottom(); + } + return maxWidth; + + } + + /** + * Returns a flag that controls the direction of values on the axis. + *

+ * For a regular axis, values increase from left to right (for a horizontal + * axis) and bottom to top (for a vertical axis). When the axis is + * 'inverted', the values increase in the opposite direction. + * + * @return The flag. + * + * @see #setInverted(boolean) + */ + public boolean isInverted() { + return this.inverted; + } + + /** + * Sets a flag that controls the direction of values on the axis, and + * notifies registered listeners that the axis has changed. + * + * @param flag the flag. + * + * @see #isInverted() + */ + public void setInverted(boolean flag) { + if (this.inverted != flag) { + this.inverted = flag; + fireChangeEvent(); + } + } + + /** + * Returns the flag that controls whether or not the axis range is + * automatically adjusted to fit the data values. + * + * @return The flag. + * + * @see #setAutoRange(boolean) + */ + public boolean isAutoRange() { + return this.autoRange; + } + + /** + * Sets a flag that determines whether or not the axis range is + * automatically adjusted to fit the data, and notifies registered + * listeners that the axis has been modified. + * + * @param auto the new value of the flag. + * + * @see #isAutoRange() + */ + public void setAutoRange(boolean auto) { + setAutoRange(auto, true); + } + + /** + * Sets the auto range attribute. If the notify flag is set, + * an {@link AxisChangeEvent} is sent to registered listeners. + * + * @param auto the flag. + * @param notify notify listeners? + * + * @see #isAutoRange() + */ + protected void setAutoRange(boolean auto, boolean notify) { + if (this.autoRange != auto) { + this.autoRange = auto; + if (this.autoRange) { + autoAdjustRange(); + } + if (notify) { + fireChangeEvent(); + } + } + } + + /** + * Returns the minimum size allowed for the axis range when it is + * automatically calculated. + * + * @return The minimum range. + * + * @see #setAutoRangeMinimumSize(double) + */ + public double getAutoRangeMinimumSize() { + return this.autoRangeMinimumSize; + } + + /** + * Sets the auto range minimum size and sends an {@link AxisChangeEvent} + * to all registered listeners. + * + * @param size the size. + * + * @see #getAutoRangeMinimumSize() + */ + public void setAutoRangeMinimumSize(double size) { + setAutoRangeMinimumSize(size, true); + } + + /** + * Sets the minimum size allowed for the axis range when it is + * automatically calculated. + *

+ * If requested, an {@link AxisChangeEvent} is forwarded to all registered + * listeners. + * + * @param size the new minimum. + * @param notify notify listeners? + */ + public void setAutoRangeMinimumSize(double size, boolean notify) { + if (size <= 0.0) { + throw new IllegalArgumentException( + "NumberAxis.setAutoRangeMinimumSize(double): must be > 0.0."); + } + if (this.autoRangeMinimumSize != size) { + this.autoRangeMinimumSize = size; + if (this.autoRange) { + autoAdjustRange(); + } + if (notify) { + fireChangeEvent(); + } + } + + } + + /** + * Returns the default auto range. + * + * @return The default auto range (never null). + * + * @see #setDefaultAutoRange(Range) + * + * @since 1.0.5 + */ + public Range getDefaultAutoRange() { + return this.defaultAutoRange; + } + + /** + * Sets the default auto range and sends an {@link AxisChangeEvent} to all + * registered listeners. + * + * @param range the range (null not permitted). + * + * @see #getDefaultAutoRange() + * + * @since 1.0.5 + */ + public void setDefaultAutoRange(Range range) { + ParamChecks.nullNotPermitted(range, "range"); + this.defaultAutoRange = range; + fireChangeEvent(); + } + + /** + * Returns the lower margin for the axis, expressed as a percentage of the + * axis range. This controls the space added to the lower end of the axis + * when the axis range is automatically calculated (it is ignored when the + * axis range is set explicitly). The default value is 0.05 (five percent). + * + * @return The lower margin. + * + * @see #setLowerMargin(double) + */ + public double getLowerMargin() { + return this.lowerMargin; + } + + /** + * Sets the lower margin for the axis (as a percentage of the axis range) + * and sends an {@link AxisChangeEvent} to all registered listeners. This + * margin is added only when the axis range is auto-calculated - if you set + * the axis range manually, the margin is ignored. + * + * @param margin the margin percentage (for example, 0.05 is five percent). + * + * @see #getLowerMargin() + * @see #setUpperMargin(double) + */ + public void setLowerMargin(double margin) { + this.lowerMargin = margin; + if (isAutoRange()) { + autoAdjustRange(); + } + fireChangeEvent(); + } + + /** + * Returns the upper margin for the axis, expressed as a percentage of the + * axis range. This controls the space added to the lower end of the axis + * when the axis range is automatically calculated (it is ignored when the + * axis range is set explicitly). The default value is 0.05 (five percent). + * + * @return The upper margin. + * + * @see #setUpperMargin(double) + */ + public double getUpperMargin() { + return this.upperMargin; + } + + /** + * Sets the upper margin for the axis (as a percentage of the axis range) + * and sends an {@link AxisChangeEvent} to all registered listeners. This + * margin is added only when the axis range is auto-calculated - if you set + * the axis range manually, the margin is ignored. + * + * @param margin the margin percentage (for example, 0.05 is five percent). + * + * @see #getLowerMargin() + * @see #setLowerMargin(double) + */ + public void setUpperMargin(double margin) { + this.upperMargin = margin; + if (isAutoRange()) { + autoAdjustRange(); + } + fireChangeEvent(); + } + + /** + * Returns the fixed auto range. + * + * @return The length. + * + * @see #setFixedAutoRange(double) + */ + public double getFixedAutoRange() { + return this.fixedAutoRange; + } + + /** + * Sets the fixed auto range for the axis. + * + * @param length the range length. + * + * @see #getFixedAutoRange() + */ + public void setFixedAutoRange(double length) { + this.fixedAutoRange = length; + if (isAutoRange()) { + autoAdjustRange(); + } + fireChangeEvent(); + } + + /** + * Returns the lower bound of the axis range. + * + * @return The lower bound. + * + * @see #setLowerBound(double) + */ + public double getLowerBound() { + return this.range.getLowerBound(); + } + + /** + * Sets the lower bound for the axis range. An {@link AxisChangeEvent} is + * sent to all registered listeners. + * + * @param min the new minimum. + * + * @see #getLowerBound() + */ + public void setLowerBound(double min) { + if (this.range.getUpperBound() > min) { + setRange(new Range(min, this.range.getUpperBound())); + } + else { + setRange(new Range(min, min + 1.0)); + } + } + + /** + * Returns the upper bound for the axis range. + * + * @return The upper bound. + * + * @see #setUpperBound(double) + */ + public double getUpperBound() { + return this.range.getUpperBound(); + } + + /** + * Sets the upper bound for the axis range, and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param max the new maximum. + * + * @see #getUpperBound() + */ + public void setUpperBound(double max) { + if (this.range.getLowerBound() < max) { + setRange(new Range(this.range.getLowerBound(), max)); + } + else { + setRange(max - 1.0, max); + } + } + + /** + * Returns the range for the axis. + * + * @return The axis range (never null). + * + * @see #setRange(Range) + */ + public Range getRange() { + return this.range; + } + + /** + * Sets the range attribute and sends an {@link AxisChangeEvent} to all + * registered listeners. As a side-effect, the auto-range flag is set to + * false. + * + * @param range the range (null not permitted). + * + * @see #getRange() + */ + public void setRange(Range range) { + // defer argument checking + setRange(range, true, true); + } + + /** + * Sets the range for the axis, if requested, sends an + * {@link AxisChangeEvent} to all registered listeners. As a side-effect, + * the auto-range flag is set to false (optional). + * + * @param range the range (null not permitted). + * @param turnOffAutoRange a flag that controls whether or not the auto + * range is turned off. + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @see #getRange() + */ + public void setRange(Range range, boolean turnOffAutoRange, + boolean notify) { + ParamChecks.nullNotPermitted(range, "range"); + if (turnOffAutoRange) { + this.autoRange = false; + } + this.range = range; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Sets the axis range and sends an {@link AxisChangeEvent} to all + * registered listeners. As a side-effect, the auto-range flag is set to + * false. + * + * @param lower the lower axis limit. + * @param upper the upper axis limit. + * + * @see #getRange() + * @see #setRange(Range) + */ + public void setRange(double lower, double upper) { + setRange(new Range(lower, upper)); + } + + /** + * Sets the range for the axis (after first adding the current margins to + * the specified range) and sends an {@link AxisChangeEvent} to all + * registered listeners. + * + * @param range the range (null not permitted). + */ + public void setRangeWithMargins(Range range) { + setRangeWithMargins(range, true, true); + } + + /** + * Sets the range for the axis after first adding the current margins to + * the range and, if requested, sends an {@link AxisChangeEvent} to all + * registered listeners. As a side-effect, the auto-range flag is set to + * false (optional). + * + * @param range the range (excluding margins, null not + * permitted). + * @param turnOffAutoRange a flag that controls whether or not the auto + * range is turned off. + * @param notify a flag that controls whether or not listeners are + * notified. + */ + public void setRangeWithMargins(Range range, boolean turnOffAutoRange, + boolean notify) { + ParamChecks.nullNotPermitted(range, "range"); + setRange(Range.expand(range, getLowerMargin(), getUpperMargin()), + turnOffAutoRange, notify); + } + + /** + * Sets the axis range (after first adding the current margins to the + * range) and sends an {@link AxisChangeEvent} to all registered listeners. + * As a side-effect, the auto-range flag is set to false. + * + * @param lower the lower axis limit. + * @param upper the upper axis limit. + */ + public void setRangeWithMargins(double lower, double upper) { + setRangeWithMargins(new Range(lower, upper)); + } + + /** + * Sets the axis range, where the new range is 'size' in length, and + * centered on 'value'. + * + * @param value the central value. + * @param length the range length. + */ + public void setRangeAboutValue(double value, double length) { + setRange(new Range(value - length / 2, value + length / 2)); + } + + /** + * Returns a flag indicating whether or not the tick unit is automatically + * selected from a range of standard tick units. + * + * @return A flag indicating whether or not the tick unit is automatically + * selected. + * + * @see #setAutoTickUnitSelection(boolean) + */ + public boolean isAutoTickUnitSelection() { + return this.autoTickUnitSelection; + } + + /** + * Sets a flag indicating whether or not the tick unit is automatically + * selected from a range of standard tick units. If the flag is changed, + * registered listeners are notified that the chart has changed. + * + * @param flag the new value of the flag. + * + * @see #isAutoTickUnitSelection() + */ + public void setAutoTickUnitSelection(boolean flag) { + setAutoTickUnitSelection(flag, true); + } + + /** + * Sets a flag indicating whether or not the tick unit is automatically + * selected from a range of standard tick units. + * + * @param flag the new value of the flag. + * @param notify notify listeners? + * + * @see #isAutoTickUnitSelection() + */ + public void setAutoTickUnitSelection(boolean flag, boolean notify) { + + if (this.autoTickUnitSelection != flag) { + this.autoTickUnitSelection = flag; + if (notify) { + fireChangeEvent(); + } + } + } + + /** + * Returns the source for obtaining standard tick units for the axis. + * + * @return The source (possibly null). + * + * @see #setStandardTickUnits(TickUnitSource) + */ + public TickUnitSource getStandardTickUnits() { + return this.standardTickUnits; + } + + /** + * Sets the source for obtaining standard tick units for the axis and sends + * an {@link AxisChangeEvent} to all registered listeners. The axis will + * try to select the smallest tick unit from the source that does not cause + * the tick labels to overlap (see also the + * {@link #setAutoTickUnitSelection(boolean)} method. + * + * @param source the source for standard tick units (null + * permitted). + * + * @see #getStandardTickUnits() + */ + public void setStandardTickUnits(TickUnitSource source) { + this.standardTickUnits = source; + fireChangeEvent(); + } + + /** + * Returns the number of minor tick marks to display. + * + * @return The number of minor tick marks to display. + * + * @see #setMinorTickCount(int) + * + * @since 1.0.12 + */ + public int getMinorTickCount() { + return this.minorTickCount; + } + + /** + * Sets the number of minor tick marks to display, and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param count the count. + * + * @see #getMinorTickCount() + * + * @since 1.0.12 + */ + public void setMinorTickCount(int count) { + this.minorTickCount = count; + fireChangeEvent(); + } + + /** + * Converts a data value to a coordinate in Java2D space, assuming that the + * axis runs along one edge of the specified dataArea. + *

+ * Note that it is possible for the coordinate to fall outside the area. + * + * @param value the data value. + * @param area the area for plotting the data. + * @param edge the edge along which the axis lies. + * + * @return The Java2D coordinate. + * + * @see #java2DToValue(double, Rectangle2D, RectangleEdge) + */ + public abstract double valueToJava2D(double value, Rectangle2D area, + RectangleEdge edge); + + /** + * 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. + */ + public double lengthToJava2D(double length, Rectangle2D area, + RectangleEdge edge) { + double zero = valueToJava2D(0.0, area, edge); + double l = valueToJava2D(length, area, edge); + return Math.abs(l - zero); + } + + /** + * Converts a coordinate in Java2D space to the corresponding data value, + * assuming that the axis runs along one edge of the specified dataArea. + * + * @param java2DValue the coordinate in Java2D space. + * @param area the area in which the data is plotted. + * @param edge the edge along which the axis lies. + * + * @return The data value. + * + * @see #valueToJava2D(double, Rectangle2D, RectangleEdge) + */ + public abstract double java2DToValue(double java2DValue, Rectangle2D area, + RectangleEdge edge); + + /** + * Automatically sets the axis range to fit the range of values in the + * dataset. Sometimes this can depend on the renderer used as well (for + * example, the renderer may "stack" values, requiring an axis range + * greater than otherwise necessary). + */ + protected abstract void autoAdjustRange(); + + /** + * Centers the axis range about the specified value and sends an + * {@link AxisChangeEvent} to all registered listeners. + * + * @param value the center value. + */ + public void centerRange(double value) { + double central = this.range.getCentralValue(); + Range adjusted = new Range(this.range.getLowerBound() + value - central, + this.range.getUpperBound() + value - central); + setRange(adjusted); + } + + /** + * Increases or decreases the axis range by the specified percentage about + * the central value and sends an {@link AxisChangeEvent} to all registered + * listeners. + *

+ * To double the length of the axis range, use 200% (2.0). + * To halve the length of the axis range, use 50% (0.5). + * + * @param percent the resize factor. + * + * @see #resizeRange(double, double) + */ + public void resizeRange(double percent) { + resizeRange(percent, this.range.getCentralValue()); + } + + /** + * Increases or decreases the axis range by the specified percentage about + * the specified anchor value and sends an {@link AxisChangeEvent} to all + * registered listeners. + *

+ * To double the length of the axis range, use 200% (2.0). + * To halve the length of the axis range, use 50% (0.5). + * + * @param percent the resize factor. + * @param anchorValue the new central value after the resize. + * + * @see #resizeRange(double) + */ + public void resizeRange(double percent, double anchorValue) { + if (percent > 0.0) { + double halfLength = this.range.getLength() * percent / 2; + Range adjusted = new Range(anchorValue - halfLength, + anchorValue + halfLength); + setRange(adjusted); + } + else { + setAutoRange(true); + } + } + + /** + * Increases or decreases the axis range by the specified percentage about + * the specified anchor value and sends an {@link AxisChangeEvent} to all + * registered listeners. + *

+ * To double the length of the axis range, use 200% (2.0). + * To halve the length of the axis range, use 50% (0.5). + * + * @param percent the resize factor. + * @param anchorValue the new central value after the resize. + * + * @see #resizeRange(double) + * + * @since 1.0.13 + */ + public void resizeRange2(double percent, double anchorValue) { + if (percent > 0.0) { + double left = anchorValue - getLowerBound(); + double right = getUpperBound() - anchorValue; + Range adjusted = new Range(anchorValue - left * percent, + anchorValue + right * percent); + setRange(adjusted); + } + else { + setAutoRange(true); + } + } + + /** + * 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) { + double start = this.range.getLowerBound(); + double length = this.range.getLength(); + Range adjusted; + if (isInverted()) { + adjusted = new Range(start + (length * (1 - upperPercent)), + start + (length * (1 - lowerPercent))); + } + else { + adjusted = new Range(start + length * lowerPercent, + start + length * upperPercent); + } + setRange(adjusted); + } + + /** + * Slides the axis range by the specified percentage. + * + * @param percent the percentage. + * + * @since 1.0.13 + */ + public void pan(double percent) { + Range r = getRange(); + double length = range.getLength(); + double adj = length * percent; + double lower = r.getLowerBound() + adj; + double upper = r.getUpperBound() + adj; + setRange(lower, upper); + } + + /** + * Returns the auto tick index. + * + * @return The auto tick index. + * + * @see #setAutoTickIndex(int) + */ + protected int getAutoTickIndex() { + return this.autoTickIndex; + } + + /** + * Sets the auto tick index. + * + * @param index the new value. + * + * @see #getAutoTickIndex() + */ + protected void setAutoTickIndex(int index) { + this.autoTickIndex = index; + } + + /** + * Tests the axis for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ValueAxis)) { + return false; + } + ValueAxis that = (ValueAxis) obj; + if (this.positiveArrowVisible != that.positiveArrowVisible) { + return false; + } + if (this.negativeArrowVisible != that.negativeArrowVisible) { + return false; + } + if (this.inverted != that.inverted) { + return false; + } + // if autoRange is true, then the current range is irrelevant + if (!this.autoRange && !ObjectUtilities.equal(this.range, that.range)) { + return false; + } + if (this.autoRange != that.autoRange) { + return false; + } + if (this.autoRangeMinimumSize != that.autoRangeMinimumSize) { + return false; + } + if (!this.defaultAutoRange.equals(that.defaultAutoRange)) { + return false; + } + if (this.upperMargin != that.upperMargin) { + return false; + } + if (this.lowerMargin != that.lowerMargin) { + return false; + } + if (this.fixedAutoRange != that.fixedAutoRange) { + return false; + } + if (this.autoTickUnitSelection != that.autoTickUnitSelection) { + return false; + } + if (!ObjectUtilities.equal(this.standardTickUnits, + that.standardTickUnits)) { + return false; + } + if (this.verticalTickLabels != that.verticalTickLabels) { + return false; + } + if (this.minorTickCount != that.minorTickCount) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the object. + * + * @return A clone. + * + * @throws CloneNotSupportedException if some component of the axis does + * not support cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + ValueAxis clone = (ValueAxis) super.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.upArrow, stream); + SerialUtilities.writeShape(this.downArrow, stream); + SerialUtilities.writeShape(this.leftArrow, stream); + SerialUtilities.writeShape(this.rightArrow, 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.upArrow = SerialUtilities.readShape(stream); + this.downArrow = SerialUtilities.readShape(stream); + this.leftArrow = SerialUtilities.readShape(stream); + this.rightArrow = SerialUtilities.readShape(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ValueTick.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ValueTick.java new file mode 100755 index 0000000..d54056b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/ValueTick.java @@ -0,0 +1,147 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * ValueTick.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); + * 02-Aug-2007 : Added tick type attribute (DG); + * + */ + +package org.jfree.chart.axis; + +import org.jfree.ui.TextAnchor; + +/** + * A value tick. + */ +public abstract class ValueTick extends Tick { + + /** The value. */ + private double value; + + /** + * The tick type (major or minor). + * + * @since 1.0.7 + */ + private TickType tickType; + + /** + * Creates a new value tick. + * + * @param value the value. + * @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 label. + * @param angle the rotation angle (in radians). + */ + public ValueTick(double value, String label, + TextAnchor textAnchor, TextAnchor rotationAnchor, + double angle) { + + this(TickType.MAJOR, value, label, textAnchor, rotationAnchor, angle); + this.value = value; + + } + + /** + * Creates a new value tick. + * + * @param tickType the tick type (major or minor). + * @param value the value. + * @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 label. + * @param angle the rotation angle (in radians). + * + * @since 1.0.7 + */ + public ValueTick(TickType tickType, double value, String label, + TextAnchor textAnchor, TextAnchor rotationAnchor, + double angle) { + + super(label, textAnchor, rotationAnchor, angle); + this.value = value; + this.tickType = tickType; + } + + /** + * Returns the value. + * + * @return The value. + */ + public double getValue() { + return this.value; + } + + /** + * Returns the tick type (major or minor). + * + * @return The tick type. + * + * @since 1.0.7 + */ + public TickType getTickType() { + return this.tickType; + } + + /** + * Tests this tick for equality with an arbitrary object. + * + * @param obj the object to test (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ValueTick)) { + return false; + } + ValueTick that = (ValueTick) obj; + if (this.value != that.value) { + return false; + } + if (!this.tickType.equals(that.tickType)) { + return false; + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/package.html new file mode 100755 index 0000000..30075ac --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/axis/package.html @@ -0,0 +1,6 @@ + + + +Axis classes and interfaces. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/AbstractBlock.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/AbstractBlock.java new file mode 100755 index 0000000..03887e7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/AbstractBlock.java @@ -0,0 +1,664 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * AbstractBlock.java + * ------------------ + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 22-Oct-2004 : Version 1 (DG); + * 02-Feb-2005 : Added accessor methods for margin (DG); + * 04-Feb-2005 : Added equals() method and implemented Serializable (DG); + * 03-May-2005 : Added null argument checks (DG); + * 06-May-2005 : Added convenience methods for setting margin, border and + * padding (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 16-Mar-2007 : Changed border from BlockBorder to BlockFrame, updated + * equals(), and implemented Cloneable (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.block; + +import java.awt.Graphics2D; +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.util.ParamChecks; + +import org.jfree.data.Range; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.Size2D; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A convenience class for creating new classes that implement + * the {@link Block} interface. + */ +public class AbstractBlock implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7689852412141274563L; + + /** The id for the block. */ + private String id; + + /** The margin around the outside of the block. */ + private RectangleInsets margin; + + /** The frame (or border) for the block. */ + private BlockFrame frame; + + /** The padding between the block content and the border. */ + private RectangleInsets padding; + + /** + * The natural width of the block (may be overridden if there are + * constraints in sizing). + */ + private double width; + + /** + * The natural height of the block (may be overridden if there are + * constraints in sizing). + */ + private double height; + + /** + * The current bounds for the block (position of the block in Java2D space). + */ + private transient Rectangle2D bounds; + + /** + * Creates a new block. + */ + protected AbstractBlock() { + this.id = null; + this.width = 0.0; + this.height = 0.0; + this.bounds = new Rectangle2D.Float(); + this.margin = RectangleInsets.ZERO_INSETS; + this.frame = BlockBorder.NONE; + this.padding = RectangleInsets.ZERO_INSETS; + } + + /** + * Returns the id. + * + * @return The id (possibly null). + * + * @see #setID(String) + */ + public String getID() { + return this.id; + } + + /** + * Sets the id for the block. + * + * @param id the id (null permitted). + * + * @see #getID() + */ + public void setID(String id) { + this.id = id; + } + + /** + * Returns the natural width of the block, if this is known in advance. + * The actual width of the block may be overridden if layout constraints + * make this necessary. + * + * @return The width. + * + * @see #setWidth(double) + */ + public double getWidth() { + return this.width; + } + + /** + * Sets the natural width of the block, if this is known in advance. + * + * @param width the width (in Java2D units) + * + * @see #getWidth() + */ + public void setWidth(double width) { + this.width = width; + } + + /** + * Returns the natural height of the block, if this is known in advance. + * The actual height of the block may be overridden if layout constraints + * make this necessary. + * + * @return The height. + * + * @see #setHeight(double) + */ + public double getHeight() { + return this.height; + } + + /** + * Sets the natural width of the block, if this is known in advance. + * + * @param height the width (in Java2D units) + * + * @see #getHeight() + */ + public void setHeight(double height) { + this.height = height; + } + + /** + * Returns the margin. + * + * @return The margin (never null). + * + * @see #getMargin() + */ + public RectangleInsets getMargin() { + return this.margin; + } + + /** + * Sets the margin (use {@link RectangleInsets#ZERO_INSETS} for no + * padding). + * + * @param margin the margin (null not permitted). + * + * @see #getMargin() + */ + public void setMargin(RectangleInsets margin) { + ParamChecks.nullNotPermitted(margin, "margin"); + this.margin = margin; + } + + /** + * Sets the margin. + * + * @param top the top margin. + * @param left the left margin. + * @param bottom the bottom margin. + * @param right the right margin. + * + * @see #getMargin() + */ + public void setMargin(double top, double left, double bottom, + double right) { + setMargin(new RectangleInsets(top, left, bottom, right)); + } + + /** + * Returns the border. + * + * @return The border (never null). + * + * @deprecated Use {@link #getFrame()} instead. + */ + public BlockBorder getBorder() { + if (this.frame instanceof BlockBorder) { + return (BlockBorder) this.frame; + } + else { + return null; + } + } + + /** + * Sets the border for the block (use {@link BlockBorder#NONE} for + * no border). + * + * @param border the border (null not permitted). + * + * @see #getBorder() + * + * @deprecated Use {@link #setFrame(BlockFrame)} instead. + */ + public void setBorder(BlockBorder border) { + setFrame(border); + } + + /** + * Sets a black border with the specified line widths. + * + * @param top the top border line width. + * @param left the left border line width. + * @param bottom the bottom border line width. + * @param right the right border line width. + */ + public void setBorder(double top, double left, double bottom, + double right) { + setFrame(new BlockBorder(top, left, bottom, right)); + } + + /** + * Returns the current frame (border). + * + * @return The frame. + * + * @since 1.0.5 + * @see #setFrame(BlockFrame) + */ + public BlockFrame getFrame() { + return this.frame; + } + + /** + * Sets the frame (or border). + * + * @param frame the frame (null not permitted). + * + * @since 1.0.5 + * @see #getFrame() + */ + public void setFrame(BlockFrame frame) { + ParamChecks.nullNotPermitted(frame, "frame"); + this.frame = frame; + } + + /** + * Returns the padding. + * + * @return The padding (never null). + * + * @see #setPadding(RectangleInsets) + */ + public RectangleInsets getPadding() { + return this.padding; + } + + /** + * Sets the padding (use {@link RectangleInsets#ZERO_INSETS} for no + * padding). + * + * @param padding the padding (null not permitted). + * + * @see #getPadding() + */ + public void setPadding(RectangleInsets padding) { + ParamChecks.nullNotPermitted(padding, "padding"); + this.padding = padding; + } + + /** + * Sets the padding. + * + * @param top the top padding. + * @param left the left padding. + * @param bottom the bottom padding. + * @param right the right padding. + */ + public void setPadding(double top, double left, double bottom, + double right) { + setPadding(new RectangleInsets(top, left, bottom, right)); + } + + /** + * Returns the x-offset for the content within the block. + * + * @return The x-offset. + * + * @see #getContentYOffset() + */ + public double getContentXOffset() { + return this.margin.getLeft() + this.frame.getInsets().getLeft() + + this.padding.getLeft(); + } + + /** + * Returns the y-offset for the content within the block. + * + * @return The y-offset. + * + * @see #getContentXOffset() + */ + public double getContentYOffset() { + return this.margin.getTop() + this.frame.getInsets().getTop() + + this.padding.getTop(); + } + + /** + * Arranges the contents of the block, with no constraints, and returns + * the block size. + * + * @param g2 the graphics device. + * + * @return The block size (in Java2D units, never null). + */ + public Size2D arrange(Graphics2D g2) { + return arrange(g2, RectangleConstraint.NONE); + } + + /** + * Arranges the contents of the block, within the given constraints, and + * returns the block size. + * + * @param g2 the graphics device. + * @param constraint the constraint (null not permitted). + * + * @return The block size (in Java2D units, never null). + */ + public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { + Size2D base = new Size2D(getWidth(), getHeight()); + return constraint.calculateConstrainedSize(base); + } + + /** + * Returns the current bounds of the block. + * + * @return The bounds. + * + * @see #setBounds(Rectangle2D) + */ + public Rectangle2D getBounds() { + return this.bounds; + } + + /** + * Sets the bounds of the block. + * + * @param bounds the bounds (null not permitted). + * + * @see #getBounds() + */ + public void setBounds(Rectangle2D bounds) { + ParamChecks.nullNotPermitted(bounds, "bounds"); + this.bounds = bounds; + } + + /** + * Calculate the width available for content after subtracting + * the margin, border and padding space from the specified fixed + * width. + * + * @param fixedWidth the fixed width. + * + * @return The available space. + * + * @see #trimToContentHeight(double) + */ + protected double trimToContentWidth(double fixedWidth) { + double result = this.margin.trimWidth(fixedWidth); + result = this.frame.getInsets().trimWidth(result); + result = this.padding.trimWidth(result); + return Math.max(result, 0.0); + } + + /** + * Calculate the height available for content after subtracting + * the margin, border and padding space from the specified fixed + * height. + * + * @param fixedHeight the fixed height. + * + * @return The available space. + * + * @see #trimToContentWidth(double) + */ + protected double trimToContentHeight(double fixedHeight) { + double result = this.margin.trimHeight(fixedHeight); + result = this.frame.getInsets().trimHeight(result); + result = this.padding.trimHeight(result); + return Math.max(result, 0.0); + } + + /** + * Returns a constraint for the content of this block that will result in + * the bounds of the block matching the specified constraint. + * + * @param c the outer constraint (null not permitted). + * + * @return The content constraint. + */ + protected RectangleConstraint toContentConstraint(RectangleConstraint c) { + ParamChecks.nullNotPermitted(c, "c"); + if (c.equals(RectangleConstraint.NONE)) { + return c; + } + double w = c.getWidth(); + Range wr = c.getWidthRange(); + double h = c.getHeight(); + Range hr = c.getHeightRange(); + double ww = trimToContentWidth(w); + double hh = trimToContentHeight(h); + Range wwr = trimToContentWidth(wr); + Range hhr = trimToContentHeight(hr); + return new RectangleConstraint(ww, wwr, c.getWidthConstraintType(), + hh, hhr, c.getHeightConstraintType()); + } + + private Range trimToContentWidth(Range r) { + if (r == null) { + return null; + } + double lowerBound = 0.0; + double upperBound = Double.POSITIVE_INFINITY; + if (r.getLowerBound() > 0.0) { + lowerBound = trimToContentWidth(r.getLowerBound()); + } + if (r.getUpperBound() < Double.POSITIVE_INFINITY) { + upperBound = trimToContentWidth(r.getUpperBound()); + } + return new Range(lowerBound, upperBound); + } + + private Range trimToContentHeight(Range r) { + if (r == null) { + return null; + } + double lowerBound = 0.0; + double upperBound = Double.POSITIVE_INFINITY; + if (r.getLowerBound() > 0.0) { + lowerBound = trimToContentHeight(r.getLowerBound()); + } + if (r.getUpperBound() < Double.POSITIVE_INFINITY) { + upperBound = trimToContentHeight(r.getUpperBound()); + } + return new Range(lowerBound, upperBound); + } + + /** + * Adds the margin, border and padding to the specified content width. + * + * @param contentWidth the content width. + * + * @return The adjusted width. + */ + protected double calculateTotalWidth(double contentWidth) { + double result = contentWidth; + result = this.padding.extendWidth(result); + result = this.frame.getInsets().extendWidth(result); + result = this.margin.extendWidth(result); + return result; + } + + /** + * Adds the margin, border and padding to the specified content height. + * + * @param contentHeight the content height. + * + * @return The adjusted height. + */ + protected double calculateTotalHeight(double contentHeight) { + double result = contentHeight; + result = this.padding.extendHeight(result); + result = this.frame.getInsets().extendHeight(result); + result = this.margin.extendHeight(result); + return result; + } + + /** + * Reduces the specified area by the amount of space consumed + * by the margin. + * + * @param area the area (null not permitted). + * + * @return The trimmed area. + */ + protected Rectangle2D trimMargin(Rectangle2D area) { + // defer argument checking... + this.margin.trim(area); + return area; + } + + /** + * Reduces the specified area by the amount of space consumed + * by the border. + * + * @param area the area (null not permitted). + * + * @return The trimmed area. + */ + protected Rectangle2D trimBorder(Rectangle2D area) { + // defer argument checking... + this.frame.getInsets().trim(area); + return area; + } + + /** + * Reduces the specified area by the amount of space consumed + * by the padding. + * + * @param area the area (null not permitted). + * + * @return The trimmed area. + */ + protected Rectangle2D trimPadding(Rectangle2D area) { + // defer argument checking... + this.padding.trim(area); + return area; + } + + /** + * Draws the border around the perimeter of the specified area. + * + * @param g2 the graphics device. + * @param area the area. + */ + protected void drawBorder(Graphics2D g2, Rectangle2D area) { + this.frame.draw(g2, area); + } + + /** + * Tests this block for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof AbstractBlock)) { + return false; + } + AbstractBlock that = (AbstractBlock) obj; + if (!ObjectUtilities.equal(this.id, that.id)) { + return false; + } + if (!this.frame.equals(that.frame)) { + return false; + } + if (!this.bounds.equals(that.bounds)) { + return false; + } + if (!this.margin.equals(that.margin)) { + return false; + } + if (!this.padding.equals(that.padding)) { + return false; + } + if (this.height != that.height) { + return false; + } + if (this.width != that.width) { + return false; + } + return true; + } + + /** + * Returns a clone of this block. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem creating the + * clone. + */ + @Override + public Object clone() throws CloneNotSupportedException { + AbstractBlock clone = (AbstractBlock) super.clone(); + clone.bounds = (Rectangle2D) ShapeUtilities.clone(this.bounds); + if (this.frame instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.frame; + clone.frame = (BlockFrame) 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.bounds, 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.bounds = (Rectangle2D) SerialUtilities.readShape(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/Arrangement.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/Arrangement.java new file mode 100755 index 0000000..0556d86 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/Arrangement.java @@ -0,0 +1,85 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * Arrangement.java + * ---------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 22-Oct-2004 : Version 1 (DG); + * 11-Feb-2005 : Modified arrange() method to return Size2D (DG); + * 22-Apr-2005 : Reordered arguments in arrange() method (DG); + * + */ + +package org.jfree.chart.block; + +import java.awt.Graphics2D; + +import org.jfree.ui.Size2D; + +/** + * An object that is responsible for arranging a collection of {@link Block}s + * within a {@link BlockContainer}. + */ +public interface Arrangement { + + /** + * Adds a block and a key which can be used to determine the position of + * the block in the arrangement. This method is called by the container + * (you don't need to call this method directly) and gives the arrangement + * an opportunity to record the details if they are required. + * + * @param block the block. + * @param key the key (null permitted). + */ + public void add(Block block, Object key); + + /** + * Arranges the blocks within the specified container, subject to the given + * constraint. + * + * @param container the container (null not permitted). + * @param g2 the graphics device. + * @param constraint the constraint. + * + * @return The container size after the arrangement. + */ + public Size2D arrange(BlockContainer container, + Graphics2D g2, + RectangleConstraint constraint); + + /** + * Clears any cached layout information retained by the arrangement. + */ + public void clear(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/Block.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/Block.java new file mode 100755 index 0000000..0634a68 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/Block.java @@ -0,0 +1,121 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------- + * Block.java + * ---------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 22-Oct-2004 : Version 1 (DG); + * 08-Feb-2005 : Added ID (DG); + * 20-Apr-2005 : Added a new draw() method that can accept params + * and return results (DG); + * + */ + +package org.jfree.chart.block; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; + +import org.jfree.ui.Drawable; +import org.jfree.ui.Size2D; + +/** + * A block is an arbitrary item that can be drawn (in Java2D space) within a + * rectangular area, has a preferred size, and can be arranged by an + * {@link Arrangement} manager. + */ +public interface Block extends Drawable { + + /** + * Returns an ID for the block. + * + * @return An ID. + */ + public String getID(); + + /** + * Sets the ID for the block. + * + * @param id the ID. + */ + public void setID(String id); + + /** + * Arranges the contents of the block, with no constraints, and returns + * the block size. + * + * @param g2 the graphics device. + * + * @return The size of the block. + */ + public Size2D arrange(Graphics2D g2); + + /** + * Arranges the contents of the block, within the given constraints, and + * returns the block size. + * + * @param g2 the graphics device. + * @param constraint the constraint (null not permitted). + * + * @return The block size (in Java2D units, never null). + */ + public Size2D arrange(Graphics2D g2, RectangleConstraint constraint); + + /** + * Returns the current bounds of the block. + * + * @return The bounds. + */ + public Rectangle2D getBounds(); + + /** + * Sets the bounds of the block. + * + * @param bounds the bounds. + */ + public void setBounds(Rectangle2D bounds); + + /** + * Draws the block within the specified area. Refer to the documentation + * for the implementing class for information about the params + * and return value supported. + * + * @param g2 the graphics device. + * @param area the area. + * @param params optional parameters (null permitted). + * + * @return An optional return value (possibly null). + */ + public Object draw(Graphics2D g2, Rectangle2D area, Object params); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockBorder.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockBorder.java new file mode 100755 index 0000000..bc3d136 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockBorder.java @@ -0,0 +1,244 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * BlockBorder.java + * ---------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 22-Oct-2004 : Version 1 (DG); + * 04-Feb-2005 : Added equals() and implemented Serializable (DG); + * 23-Feb-2005 : Added attribute for border color (DG); + * 06-May-2005 : Added new convenience constructors (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 16-Mar-2007 : Implemented BlockFrame (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.block; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Paint; +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.util.ParamChecks; + +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.PaintUtilities; + +/** + * A border for a block. This class is immutable. + */ +public class BlockBorder implements BlockFrame, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 4961579220410228283L; + + /** An empty border. */ + public static final BlockBorder NONE = new BlockBorder( + RectangleInsets.ZERO_INSETS, Color.white); + + /** The space reserved for the border. */ + private RectangleInsets insets; + + /** The border color. */ + private transient Paint paint; + + /** + * Creates a default border. + */ + public BlockBorder() { + this(Color.black); + } + + /** + * Creates a new border with the specified color. + * + * @param paint the color (null not permitted). + */ + public BlockBorder(Paint paint) { + this(new RectangleInsets(1, 1, 1, 1), paint); + } + + /** + * Creates a new border with the specified line widths (in black). + * + * @param top the width of the top border. + * @param left the width of the left border. + * @param bottom the width of the bottom border. + * @param right the width of the right border. + */ + public BlockBorder(double top, double left, double bottom, double right) { + this(new RectangleInsets(top, left, bottom, right), Color.black); + } + + /** + * Creates a new border with the specified line widths (in black). + * + * @param top the width of the top border. + * @param left the width of the left border. + * @param bottom the width of the bottom border. + * @param right the width of the right border. + * @param paint the border paint (null not permitted). + */ + public BlockBorder(double top, double left, double bottom, double right, + Paint paint) { + this(new RectangleInsets(top, left, bottom, right), paint); + } + + /** + * Creates a new border. + * + * @param insets the border insets (null not permitted). + * @param paint the paint (null not permitted). + */ + public BlockBorder(RectangleInsets insets, Paint paint) { + ParamChecks.nullNotPermitted(insets, "insets"); + ParamChecks.nullNotPermitted(paint, "paint"); + this.insets = insets; + this.paint = paint; + } + + /** + * Returns the space reserved for the border. + * + * @return The space (never null). + */ + @Override + public RectangleInsets getInsets() { + return this.insets; + } + + /** + * Returns the paint used to draw the border. + * + * @return The paint (never null). + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Draws the border by filling in the reserved space. + * + * @param g2 the graphics device. + * @param area the area. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + // this default implementation will just fill the available + // border space with a single color + double t = this.insets.calculateTopInset(area.getHeight()); + double b = this.insets.calculateBottomInset(area.getHeight()); + double l = this.insets.calculateLeftInset(area.getWidth()); + double r = this.insets.calculateRightInset(area.getWidth()); + double x = area.getX(); + double y = area.getY(); + double w = area.getWidth(); + double h = area.getHeight(); + g2.setPaint(this.paint); + Rectangle2D rect = new Rectangle2D.Double(); + if (t > 0.0) { + rect.setRect(x, y, w, t); + g2.fill(rect); + } + if (b > 0.0) { + rect.setRect(x, y + h - b, w, b); + g2.fill(rect); + } + if (l > 0.0) { + rect.setRect(x, y, l, h); + g2.fill(rect); + } + if (r > 0.0) { + rect.setRect(x + w - r, y, r, h); + g2.fill(rect); + } + } + + /** + * Tests this border for equality with an arbitrary instance. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof BlockBorder)) { + return false; + } + BlockBorder that = (BlockBorder) obj; + if (!this.insets.equals(that.insets)) { + return false; + } + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + return true; + } + + /** + * 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockContainer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockContainer.java new file mode 100755 index 0000000..1b2d2f4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockContainer.java @@ -0,0 +1,284 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * BlockContainer.java + * ------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 22-Oct-2004 : Version 1 (DG); + * 02-Feb-2005 : Added isEmpty() method (DG); + * 04-Feb-2005 : Added equals(), clone() and implemented Serializable (DG); + * 08-Feb-2005 : Updated for changes in RectangleConstraint (DG); + * 20-Apr-2005 : Added new draw() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 20-Jul-2006 : Perform translation directly on drawing area, not via + * Graphics2D (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.block; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.entity.StandardEntityCollection; +import org.jfree.chart.util.ParamChecks; +import org.jfree.ui.Size2D; +import org.jfree.util.PublicCloneable; + +/** + * A container for a collection of {@link Block} objects. The container uses + * an {@link Arrangement} object to handle the position of each block. + */ +public class BlockContainer extends AbstractBlock + implements Block, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 8199508075695195293L; + + /** The blocks within the container. */ + private List blocks; + + /** The object responsible for laying out the blocks. */ + private Arrangement arrangement; + + /** + * Creates a new instance with default settings. + */ + public BlockContainer() { + this(new BorderArrangement()); + } + + /** + * Creates a new instance with the specified arrangement. + * + * @param arrangement the arrangement manager (null not + * permitted). + */ + public BlockContainer(Arrangement arrangement) { + ParamChecks.nullNotPermitted(arrangement, "arrangement"); + this.arrangement = arrangement; + this.blocks = new ArrayList(); + } + + /** + * Returns the arrangement (layout) manager for the container. + * + * @return The arrangement manager (never null). + */ + public Arrangement getArrangement() { + return this.arrangement; + } + + /** + * Sets the arrangement (layout) manager. + * + * @param arrangement the arrangement (null not permitted). + */ + public void setArrangement(Arrangement arrangement) { + ParamChecks.nullNotPermitted(arrangement, "arrangement"); + this.arrangement = arrangement; + } + + /** + * Returns true if there are no blocks in the container, and + * false otherwise. + * + * @return A boolean. + */ + public boolean isEmpty() { + return this.blocks.isEmpty(); + } + + /** + * Returns an unmodifiable list of the {@link Block} objects managed by + * this arrangement. + * + * @return A list of blocks. + */ + public List getBlocks() { + return Collections.unmodifiableList(this.blocks); + } + + /** + * Adds a block to the container. + * + * @param block the block (null permitted). + */ + public void add(Block block) { + add(block, null); + } + + /** + * Adds a block to the container. + * + * @param block the block (null permitted). + * @param key the key (null permitted). + */ + public void add(Block block, Object key) { + this.blocks.add(block); + this.arrangement.add(block, key); + } + + /** + * Clears all the blocks from the container. + */ + public void clear() { + this.blocks.clear(); + this.arrangement.clear(); + } + + /** + * Arranges the contents of the block, within the given constraints, and + * returns the block size. + * + * @param g2 the graphics device. + * @param constraint the constraint (null not permitted). + * + * @return The block size (in Java2D units, never null). + */ + @Override + public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { + return this.arrangement.arrange(this, g2, constraint); + } + + /** + * Draws the container and all the blocks within it. + * + * @param g2 the graphics device. + * @param area the area. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + draw(g2, area, null); + } + + /** + * Draws the block within the specified area. + * + * @param g2 the graphics device. + * @param area the area. + * @param params passed on to blocks within the container + * (null permitted). + * + * @return An instance of {@link EntityBlockResult}, or null. + */ + @Override + public Object draw(Graphics2D g2, Rectangle2D area, Object params) { + // check if we need to collect chart entities from the container + EntityBlockParams ebp; + StandardEntityCollection sec = null; + if (params instanceof EntityBlockParams) { + ebp = (EntityBlockParams) params; + if (ebp.getGenerateEntities()) { + sec = new StandardEntityCollection(); + } + } + Rectangle2D contentArea = (Rectangle2D) area.clone(); + contentArea = trimMargin(contentArea); + drawBorder(g2, contentArea); + contentArea = trimBorder(contentArea); + contentArea = trimPadding(contentArea); + Iterator iterator = this.blocks.iterator(); + while (iterator.hasNext()) { + Block block = (Block) iterator.next(); + Rectangle2D bounds = block.getBounds(); + Rectangle2D drawArea = new Rectangle2D.Double(bounds.getX() + + area.getX(), bounds.getY() + area.getY(), + bounds.getWidth(), bounds.getHeight()); + Object r = block.draw(g2, drawArea, params); + if (sec != null) { + if (r instanceof EntityBlockResult) { + EntityBlockResult ebr = (EntityBlockResult) r; + EntityCollection ec = ebr.getEntityCollection(); + sec.addAll(ec); + } + } + } + BlockResult result = null; + if (sec != null) { + result = new BlockResult(); + result.setEntityCollection(sec); + } + return result; + } + + /** + * Tests this container for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof BlockContainer)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + BlockContainer that = (BlockContainer) obj; + if (!this.arrangement.equals(that.arrangement)) { + return false; + } + if (!this.blocks.equals(that.blocks)) { + return false; + } + return true; + } + + /** + * Returns a clone of the container. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + BlockContainer clone = (BlockContainer) super.clone(); + // TODO : complete this + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockFrame.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockFrame.java new file mode 100755 index 0000000..0f69e29 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockFrame.java @@ -0,0 +1,73 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * BlockFrame.java + * --------------- + * (C) Copyright 2007, 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 16-Mar-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; + +import org.jfree.ui.RectangleInsets; +import org.jfree.util.PublicCloneable; + +/** + * A block frame is a type of border that can be drawn around the outside of + * any {@link AbstractBlock}. Classes that implement this interface should + * implement {@link PublicCloneable} OR be immutable. + * + * @since 1.0.5 + */ +public interface BlockFrame { + + /** + * Returns the space reserved for the border. + * + * @return The space (never null). + */ + public RectangleInsets getInsets(); + + /** + * Draws the border by filling in the reserved space (in black). + * + * @param g2 the graphics device. + * @param area the area. + */ + public void draw(Graphics2D g2, Rectangle2D area); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockParams.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockParams.java new file mode 100755 index 0000000..9f2bf1f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockParams.java @@ -0,0 +1,138 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * BlockParams.java + * ---------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 19-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +/** + * A standard parameter object that can be passed to the draw() method defined + * by the {@link Block} class. + */ +public class BlockParams implements EntityBlockParams { + + /** + * A flag that controls whether or not the block should generate and + * return chart entities for the items it draws. + */ + private boolean generateEntities; + + /** + * The x-translation (used to enable chart entities to use global + * coordinates rather than coordinates that are local to the container + * they are within). + */ + private double translateX; + + /** + * The y-translation (used to enable chart entities to use global + * coordinates rather than coordinates that are local to the container + * they are within). + */ + private double translateY; + + /** + * Creates a new instance. + */ + public BlockParams() { + this.translateX = 0.0; + this.translateY = 0.0; + this.generateEntities = false; + } + + /** + * Returns the flag that controls whether or not chart entities are + * generated. + * + * @return A boolean. + */ + @Override + public boolean getGenerateEntities() { + return this.generateEntities; + } + + /** + * Sets the flag that controls whether or not chart entities are generated. + * + * @param generate the flag. + */ + public void setGenerateEntities(boolean generate) { + this.generateEntities = generate; + } + + /** + * Returns the translation required to convert local x-coordinates back to + * the coordinate space of the container. + * + * @return The x-translation amount. + */ + public double getTranslateX() { + return this.translateX; + } + + /** + * Sets the translation required to convert local x-coordinates into the + * coordinate space of the container. + * + * @param x the x-translation amount. + */ + public void setTranslateX(double x) { + this.translateX = x; + } + + /** + * Returns the translation required to convert local y-coordinates back to + * the coordinate space of the container. + * + * @return The y-translation amount. + */ + public double getTranslateY() { + return this.translateY; + } + + /** + * Sets the translation required to convert local y-coordinates into the + * coordinate space of the container. + * + * @param y the y-translation amount. + */ + public void setTranslateY(double y) { + this.translateY = y; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockResult.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockResult.java new file mode 100755 index 0000000..9bbefc0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BlockResult.java @@ -0,0 +1,80 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * BlockResult.java + * ---------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 19-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +import org.jfree.chart.entity.EntityCollection; + +/** + * Used to return results from the draw() method in the {@link Block} + * class. + */ +public class BlockResult implements EntityBlockResult { + + /** The entities from the block. */ + private EntityCollection entities; + + /** + * Creates a new result instance. + */ + public BlockResult() { + this.entities = null; + } + + /** + * Returns the collection of entities from the block. + * + * @return The entities. + */ + @Override + public EntityCollection getEntityCollection() { + return this.entities; + } + + /** + * Sets the entities for the block. + * + * @param entities the entities. + */ + public void setEntityCollection(EntityCollection entities) { + this.entities = entities; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BorderArrangement.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BorderArrangement.java new file mode 100755 index 0000000..d65b8ce --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/BorderArrangement.java @@ -0,0 +1,537 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * BorderArrangement.java + * ---------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 22-Oct-2004 : Version 1 (DG); + * 08-Feb-2005 : Updated for changes in RectangleConstraint (DG); + * 24-Feb-2005 : Improved arrangeRR() method (DG); + * 03-May-2005 : Implemented Serializable and added equals() method (DG); + * 13-May-2005 : Fixed bugs in the arrange() method (DG); + * 08-Apr-2008 : Fixed bug in arrangeFF() method where width is too small for + * left and right blocks (DG); + * 21-Nov-2013 : Fixed bug #1084 (DG); + * + */ + +package org.jfree.chart.block; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.data.Range; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.Size2D; +import org.jfree.util.ObjectUtilities; + +/** + * An arrangement manager that lays out blocks in a similar way to + * Swing's BorderLayout class. + */ +public class BorderArrangement implements Arrangement, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 506071142274883745L; + + /** The block (if any) at the center of the layout. */ + private Block centerBlock; + + /** The block (if any) at the top of the layout. */ + private Block topBlock; + + /** The block (if any) at the bottom of the layout. */ + private Block bottomBlock; + + /** The block (if any) at the left of the layout. */ + private Block leftBlock; + + /** The block (if any) at the right of the layout. */ + private Block rightBlock; + + /** + * Creates a new instance. + */ + public BorderArrangement() { + } + + /** + * Adds a block to the arrangement manager at the specified edge. + * If the key is not an instance of {@link RectangleEdge} the block will + * be added in the center. + * + * @param block the block (null permitted). + * @param key the edge (an instance of {@link RectangleEdge}) or + * null for the center block. + */ + @Override + public void add(Block block, Object key) { + + if (!(key instanceof RectangleEdge)) { // catches null also + this.centerBlock = block; + } + else { + RectangleEdge edge = (RectangleEdge) key; + if (edge == RectangleEdge.TOP) { + this.topBlock = block; + } + else if (edge == RectangleEdge.BOTTOM) { + this.bottomBlock = block; + } + else if (edge == RectangleEdge.LEFT) { + this.leftBlock = block; + } + else if (edge == RectangleEdge.RIGHT) { + this.rightBlock = block; + } + } + } + + /** + * Arranges the items in the specified container, subject to the given + * constraint. + * + * @param container the container. + * @param g2 the graphics device. + * @param constraint the constraint. + * + * @return The block size. + */ + @Override + public Size2D arrange(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + RectangleConstraint contentConstraint + = container.toContentConstraint(constraint); + Size2D contentSize = null; + LengthConstraintType w = contentConstraint.getWidthConstraintType(); + LengthConstraintType h = contentConstraint.getHeightConstraintType(); + if (w == LengthConstraintType.NONE) { + if (h == LengthConstraintType.NONE) { + contentSize = arrangeNN(container, g2); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not implemented."); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not implemented."); + } + } + else if (w == LengthConstraintType.FIXED) { + if (h == LengthConstraintType.NONE) { + contentSize = arrangeFN(container, g2, constraint.getWidth()); + } + else if (h == LengthConstraintType.FIXED) { + contentSize = arrangeFF(container, g2, constraint); + } + else if (h == LengthConstraintType.RANGE) { + contentSize = arrangeFR(container, g2, constraint); + } + } + else if (w == LengthConstraintType.RANGE) { + if (h == LengthConstraintType.NONE) { + throw new RuntimeException("Not implemented."); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not implemented."); + } + else if (h == LengthConstraintType.RANGE) { + contentSize = arrangeRR(container, constraint.getWidthRange(), + constraint.getHeightRange(), g2); + } + } + assert contentSize != null; + return new Size2D(container.calculateTotalWidth(contentSize.getWidth()), + container.calculateTotalHeight(contentSize.getHeight())); + } + + /** + * Performs an arrangement without constraints. + * + * @param container the container. + * @param g2 the graphics device. + * + * @return The container size after the arrangement. + */ + protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) { + double[] w = new double[5]; + double[] h = new double[5]; + if (this.topBlock != null) { + Size2D size = this.topBlock.arrange(g2, RectangleConstraint.NONE); + w[0] = size.width; + h[0] = size.height; + } + if (this.bottomBlock != null) { + Size2D size = this.bottomBlock.arrange(g2, + RectangleConstraint.NONE); + w[1] = size.width; + h[1] = size.height; + } + if (this.leftBlock != null) { + Size2D size = this.leftBlock.arrange(g2, RectangleConstraint.NONE); + w[2] = size.width; + h[2] = size.height; + } + if (this.rightBlock != null) { + Size2D size = this.rightBlock.arrange(g2, RectangleConstraint.NONE); + w[3] = size.width; + h[3] = size.height; + } + + h[2] = Math.max(h[2], h[3]); + h[3] = h[2]; + + if (this.centerBlock != null) { + Size2D size = this.centerBlock.arrange(g2, + RectangleConstraint.NONE); + w[4] = size.width; + h[4] = size.height; + } + double width = Math.max(w[0], Math.max(w[1], w[2] + w[4] + w[3])); + double centerHeight = Math.max(h[2], Math.max(h[3], h[4])); + double height = h[0] + h[1] + centerHeight; + if (this.topBlock != null) { + this.topBlock.setBounds(new Rectangle2D.Double(0.0, 0.0, width, + h[0])); + } + if (this.bottomBlock != null) { + this.bottomBlock.setBounds(new Rectangle2D.Double(0.0, + height - h[1], width, h[1])); + } + if (this.leftBlock != null) { + this.leftBlock.setBounds(new Rectangle2D.Double(0.0, h[0], w[2], + centerHeight)); + } + if (this.rightBlock != null) { + this.rightBlock.setBounds(new Rectangle2D.Double(width - w[3], + h[0], w[3], centerHeight)); + } + + if (this.centerBlock != null) { + this.centerBlock.setBounds(new Rectangle2D.Double(w[2], h[0], + width - w[2] - w[3], centerHeight)); + } + return new Size2D(width, height); + } + + /** + * Performs an arrangement with a fixed width and a range for the height. + * + * @param container the container. + * @param g2 the graphics device. + * @param constraint the constraint. + * + * @return The container size after the arrangement. + */ + protected Size2D arrangeFR(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + Size2D size1 = arrangeFN(container, g2, constraint.getWidth()); + if (constraint.getHeightRange().contains(size1.getHeight())) { + return size1; + } + else { + double h = constraint.getHeightRange().constrain(size1.getHeight()); + RectangleConstraint c2 = constraint.toFixedHeight(h); + return arrange(container, g2, c2); + } + } + + /** + * Arranges the container width a fixed width and no constraint on the + * height. + * + * @param container the container. + * @param g2 the graphics device. + * @param width the fixed width. + * + * @return The container size after arranging the contents. + */ + protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, + double width) { + double[] w = new double[5]; + double[] h = new double[5]; + RectangleConstraint c1 = new RectangleConstraint(width, null, + LengthConstraintType.FIXED, 0.0, null, + LengthConstraintType.NONE); + if (this.topBlock != null) { + Size2D size = this.topBlock.arrange(g2, c1); + w[0] = size.width; + h[0] = size.height; + } + if (this.bottomBlock != null) { + Size2D size = this.bottomBlock.arrange(g2, c1); + w[1] = size.width; + h[1] = size.height; + } + RectangleConstraint c2 = new RectangleConstraint(0.0, + new Range(0.0, width), LengthConstraintType.RANGE, + 0.0, null, LengthConstraintType.NONE); + if (this.leftBlock != null) { + Size2D size = this.leftBlock.arrange(g2, c2); + w[2] = size.width; + h[2] = size.height; + } + if (this.rightBlock != null) { + double maxW = Math.max(width - w[2], 0.0); + RectangleConstraint c3 = new RectangleConstraint(0.0, + new Range(Math.min(w[2], maxW), maxW), + LengthConstraintType.RANGE, 0.0, null, + LengthConstraintType.NONE); + Size2D size = this.rightBlock.arrange(g2, c3); + w[3] = size.width; + h[3] = size.height; + } + + h[2] = Math.max(h[2], h[3]); + h[3] = h[2]; + + if (this.centerBlock != null) { + RectangleConstraint c4 = new RectangleConstraint(width - w[2] + - w[3], null, LengthConstraintType.FIXED, 0.0, null, + LengthConstraintType.NONE); + Size2D size = this.centerBlock.arrange(g2, c4); + w[4] = size.width; + h[4] = size.height; + } + double height = h[0] + h[1] + Math.max(h[2], Math.max(h[3], h[4])); + return arrange(container, g2, new RectangleConstraint(width, height)); + } + + /** + * Performs an arrangement with range constraints on both the vertical + * and horizontal sides. + * + * @param container the container. + * @param widthRange the allowable range for the container width. + * @param heightRange the allowable range for the container height. + * @param g2 the graphics device. + * + * @return The container size. + */ + protected Size2D arrangeRR(BlockContainer container, + Range widthRange, Range heightRange, + Graphics2D g2) { + double[] w = new double[5]; + double[] h = new double[5]; + if (this.topBlock != null) { + RectangleConstraint c1 = new RectangleConstraint(widthRange, + heightRange); + Size2D size = this.topBlock.arrange(g2, c1); + w[0] = size.width; + h[0] = size.height; + } + if (this.bottomBlock != null) { + Range heightRange2 = Range.shift(heightRange, -h[0], false); + RectangleConstraint c2 = new RectangleConstraint(widthRange, + heightRange2); + Size2D size = this.bottomBlock.arrange(g2, c2); + w[1] = size.width; + h[1] = size.height; + } + Range heightRange3 = Range.shift(heightRange, -(h[0] + h[1])); + if (this.leftBlock != null) { + RectangleConstraint c3 = new RectangleConstraint(widthRange, + heightRange3); + Size2D size = this.leftBlock.arrange(g2, c3); + w[2] = size.width; + h[2] = size.height; + } + Range widthRange2 = Range.shift(widthRange, -w[2], false); + if (this.rightBlock != null) { + RectangleConstraint c4 = new RectangleConstraint(widthRange2, + heightRange3); + Size2D size = this.rightBlock.arrange(g2, c4); + w[3] = size.width; + h[3] = size.height; + } + + h[2] = Math.max(h[2], h[3]); + h[3] = h[2]; + Range widthRange3 = Range.shift(widthRange, -(w[2] + w[3]), false); + if (this.centerBlock != null) { + RectangleConstraint c5 = new RectangleConstraint(widthRange3, + heightRange3); + Size2D size = this.centerBlock.arrange(g2, c5); + w[4] = size.width; + h[4] = size.height; + } + double width = Math.max(w[0], Math.max(w[1], w[2] + w[4] + w[3])); + double height = h[0] + h[1] + Math.max(h[2], Math.max(h[3], h[4])); + if (this.topBlock != null) { + this.topBlock.setBounds(new Rectangle2D.Double(0.0, 0.0, width, + h[0])); + } + if (this.bottomBlock != null) { + this.bottomBlock.setBounds(new Rectangle2D.Double(0.0, + height - h[1], width, h[1])); + } + if (this.leftBlock != null) { + this.leftBlock.setBounds(new Rectangle2D.Double(0.0, h[0], w[2], + h[2])); + } + if (this.rightBlock != null) { + this.rightBlock.setBounds(new Rectangle2D.Double(width - w[3], + h[0], w[3], h[3])); + } + + if (this.centerBlock != null) { + this.centerBlock.setBounds(new Rectangle2D.Double(w[2], h[0], + width - w[2] - w[3], height - h[0] - h[1])); + } + return new Size2D(width, height); + } + + /** + * Arranges the items within a container. + * + * @param container the container. + * @param constraint the constraint. + * @param g2 the graphics device. + * + * @return The container size after the arrangement. + */ + protected Size2D arrangeFF(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + double[] w = new double[5]; + double[] h = new double[5]; + w[0] = constraint.getWidth(); + if (this.topBlock != null) { + RectangleConstraint c1 = new RectangleConstraint(w[0], null, + LengthConstraintType.FIXED, 0.0, + new Range(0.0, constraint.getHeight()), + LengthConstraintType.RANGE); + Size2D size = this.topBlock.arrange(g2, c1); + h[0] = size.height; + } + w[1] = w[0]; + if (this.bottomBlock != null) { + RectangleConstraint c2 = new RectangleConstraint(w[0], null, + LengthConstraintType.FIXED, 0.0, new Range(0.0, + constraint.getHeight() - h[0]), LengthConstraintType.RANGE); + Size2D size = this.bottomBlock.arrange(g2, c2); + h[1] = size.height; + } + h[2] = constraint.getHeight() - h[1] - h[0]; + if (this.leftBlock != null) { + RectangleConstraint c3 = new RectangleConstraint(0.0, + new Range(0.0, constraint.getWidth()), + LengthConstraintType.RANGE, h[2], null, + LengthConstraintType.FIXED); + Size2D size = this.leftBlock.arrange(g2, c3); + w[2] = size.width; + } + h[3] = h[2]; + if (this.rightBlock != null) { + RectangleConstraint c4 = new RectangleConstraint(0.0, + new Range(0.0, Math.max(constraint.getWidth() - w[2], 0.0)), + LengthConstraintType.RANGE, h[2], null, + LengthConstraintType.FIXED); + Size2D size = this.rightBlock.arrange(g2, c4); + w[3] = size.width; + } + h[4] = h[2]; + w[4] = constraint.getWidth() - w[3] - w[2]; + RectangleConstraint c5 = new RectangleConstraint(w[4], h[4]); + if (this.centerBlock != null) { + this.centerBlock.arrange(g2, c5); + } + + if (this.topBlock != null) { + this.topBlock.setBounds(new Rectangle2D.Double(0.0, 0.0, w[0], + h[0])); + } + if (this.bottomBlock != null) { + this.bottomBlock.setBounds(new Rectangle2D.Double(0.0, h[0] + h[2], + w[1], h[1])); + } + if (this.leftBlock != null) { + this.leftBlock.setBounds(new Rectangle2D.Double(0.0, h[0], w[2], + h[2])); + } + if (this.rightBlock != null) { + this.rightBlock.setBounds(new Rectangle2D.Double(w[2] + w[4], h[0], + w[3], h[3])); + } + if (this.centerBlock != null) { + this.centerBlock.setBounds(new Rectangle2D.Double(w[2], h[0], w[4], + h[4])); + } + return new Size2D(constraint.getWidth(), constraint.getHeight()); + } + + /** + * Clears the layout. + */ + @Override + public void clear() { + this.centerBlock = null; + this.topBlock = null; + this.bottomBlock = null; + this.leftBlock = null; + this.rightBlock = null; + } + + /** + * Tests this arrangement for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof BorderArrangement)) { + return false; + } + BorderArrangement that = (BorderArrangement) obj; + if (!ObjectUtilities.equal(this.topBlock, that.topBlock)) { + return false; + } + if (!ObjectUtilities.equal(this.bottomBlock, that.bottomBlock)) { + return false; + } + if (!ObjectUtilities.equal(this.leftBlock, that.leftBlock)) { + return false; + } + if (!ObjectUtilities.equal(this.rightBlock, that.rightBlock)) { + return false; + } + if (!ObjectUtilities.equal(this.centerBlock, that.centerBlock)) { + return false; + } + return true; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/CenterArrangement.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/CenterArrangement.java new file mode 100755 index 0000000..7584146 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/CenterArrangement.java @@ -0,0 +1,333 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * CenterArrangement.java + * ---------------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 08-Mar-2005 : Version 1 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 20-Jul-2006 : Set bounds of contained block when arranging (DG); + * + */ + +package org.jfree.chart.block; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; +import java.util.List; + +import org.jfree.ui.Size2D; + +/** + * Arranges a block in the center of its container. This class is immutable. + */ +public class CenterArrangement implements Arrangement, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -353308149220382047L; + + /** + * Creates a new instance. + */ + public CenterArrangement() { + } + + /** + * Adds a block to be managed by this instance. This method is usually + * called by the {@link BlockContainer}, you shouldn't need to call it + * directly. + * + * @param block the block. + * @param key a key that controls the position of the block. + */ + @Override + public void add(Block block, Object key) { + // since the flow layout is relatively straightforward, + // no information needs to be recorded here + } + + /** + * Calculates and sets the bounds of all the items in the specified + * container, subject to the given constraint. The Graphics2D + * can be used by some items (particularly items containing text) to + * calculate sizing parameters. + * + * @param container the container whose items are being arranged. + * @param g2 the graphics device. + * @param constraint the size constraint. + * + * @return The size of the container after arrangement of the contents. + */ + @Override + public Size2D arrange(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + LengthConstraintType w = constraint.getWidthConstraintType(); + LengthConstraintType h = constraint.getHeightConstraintType(); + if (w == LengthConstraintType.NONE) { + if (h == LengthConstraintType.NONE) { + return arrangeNN(container, g2); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not implemented."); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not implemented."); + } + } + else if (w == LengthConstraintType.FIXED) { + if (h == LengthConstraintType.NONE) { + return arrangeFN(container, g2, constraint); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not implemented."); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not implemented."); + } + } + else if (w == LengthConstraintType.RANGE) { + if (h == LengthConstraintType.NONE) { + return arrangeRN(container, g2, constraint); + } + else if (h == LengthConstraintType.FIXED) { + return arrangeRF(container, g2, constraint); + } + else if (h == LengthConstraintType.RANGE) { + return arrangeRR(container, g2, constraint); + } + } + throw new IllegalArgumentException("Unknown LengthConstraintType."); + + } + + /** + * Arranges the blocks in the container with a fixed width and no height + * constraint. + * + * @param container the container. + * @param g2 the graphics device. + * @param constraint the constraint. + * + * @return The size. + */ + protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + List blocks = container.getBlocks(); + Block b = (Block) blocks.get(0); + Size2D s = b.arrange(g2, RectangleConstraint.NONE); + double width = constraint.getWidth(); + Rectangle2D bounds = new Rectangle2D.Double((width - s.width) / 2.0, + 0.0, s.width, s.height); + b.setBounds(bounds); + return new Size2D((width - s.width) / 2.0, s.height); + } + + /** + * Arranges the blocks in the container with a fixed with and a range + * constraint on the height. + * + * @param container the container. + * @param g2 the graphics device. + * @param constraint the constraint. + * + * @return The size following the arrangement. + */ + protected Size2D arrangeFR(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + Size2D s = arrangeFN(container, g2, constraint); + if (constraint.getHeightRange().contains(s.height)) { + return s; + } + else { + RectangleConstraint c = constraint.toFixedHeight( + constraint.getHeightRange().constrain(s.getHeight())); + return arrangeFF(container, g2, c); + } + } + + /** + * Arranges the blocks in the container with the overall height and width + * specified as fixed constraints. + * + * @param container the container. + * @param g2 the graphics device. + * @param constraint the constraint. + * + * @return The size following the arrangement. + */ + protected Size2D arrangeFF(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + // TODO: implement this properly + return arrangeFN(container, g2, constraint); + } + + /** + * Arranges the blocks with the overall width and height to fit within + * specified ranges. + * + * @param container the container. + * @param g2 the graphics device. + * @param constraint the constraint. + * + * @return The size after the arrangement. + */ + protected Size2D arrangeRR(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + // first arrange without constraints, and see if this fits within + // the required ranges... + Size2D s1 = arrangeNN(container, g2); + if (constraint.getWidthRange().contains(s1.width)) { + return s1; // TODO: we didn't check the height yet + } + else { + RectangleConstraint c = constraint.toFixedWidth( + constraint.getWidthRange().getUpperBound()); + return arrangeFR(container, g2, c); + } + } + + /** + * Arranges the blocks in the container with a range constraint on the + * width and a fixed height. + * + * @param container the container. + * @param g2 the graphics device. + * @param constraint the constraint. + * + * @return The size following the arrangement. + */ + protected Size2D arrangeRF(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + Size2D s = arrangeNF(container, g2, constraint); + if (constraint.getWidthRange().contains(s.width)) { + return s; + } + else { + RectangleConstraint c = constraint.toFixedWidth( + constraint.getWidthRange().constrain(s.getWidth())); + return arrangeFF(container, g2, c); + } + } + + /** + * Arranges the block with a range constraint on the width, and no + * constraint on the height. + * + * @param container the container. + * @param g2 the graphics device. + * @param constraint the constraint. + * + * @return The size following the arrangement. + */ + protected Size2D arrangeRN(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + // first arrange without constraints, then see if the width fits + // within the required range...if not, call arrangeFN() at max width + Size2D s1 = arrangeNN(container, g2); + if (constraint.getWidthRange().contains(s1.width)) { + return s1; + } + else { + RectangleConstraint c = constraint.toFixedWidth( + constraint.getWidthRange().getUpperBound()); + return arrangeFN(container, g2, c); + } + } + + /** + * Arranges the blocks without any constraints. This puts all blocks + * into a single row. + * + * @param container the container. + * @param g2 the graphics device. + * + * @return The size after the arrangement. + */ + protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) { + List blocks = container.getBlocks(); + Block b = (Block) blocks.get(0); + Size2D s = b.arrange(g2, RectangleConstraint.NONE); + b.setBounds(new Rectangle2D.Double(0.0, 0.0, s.width, s.height)); + return new Size2D(s.width, s.height); + } + + /** + * Arranges the blocks with no width constraint and a fixed height + * constraint. This puts all blocks into a single row. + * + * @param container the container. + * @param g2 the graphics device. + * @param constraint the constraint. + * + * @return The size after the arrangement. + */ + protected Size2D arrangeNF(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + // TODO: for now we are ignoring the height constraint + return arrangeNN(container, g2); + } + + /** + * Clears any cached information. + */ + @Override + public void clear() { + // no action required. + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CenterArrangement)) { + return false; + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/ColorBlock.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/ColorBlock.java new file mode 100755 index 0000000..93fbb7d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/ColorBlock.java @@ -0,0 +1,191 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * ColorBlock.java + * --------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 22-Oct-2004 : Version 1 (DG); + * 20-Apr-2005 : Added new draw() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 16-Mar-2007 : Implemented equals() and fixed serialization (DG); + * 08-Apr-2008 : Added code for margin, border and padding in draw() + * method (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.block; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.io.SerialUtilities; +import org.jfree.ui.Size2D; +import org.jfree.util.PaintUtilities; + +/** + * A block that is filled with a single color. + */ +public class ColorBlock extends AbstractBlock implements Block { + + /** For serialization. */ + static final long serialVersionUID = 3383866145634010865L; + + /** The paint. */ + private transient Paint paint; + + /** + * Creates a new block. + * + * @param paint the paint (null not permitted). + * @param width the width. + * @param height the height. + */ + public ColorBlock(Paint paint, double width, double height) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.paint = paint; + setWidth(width); + setHeight(height); + } + + /** + * Returns the paint. + * + * @return The paint (never null). + * + * @since 1.0.5 + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Arranges the contents of the block, within the given constraints, and + * returns the block size. + * + * @param g2 the graphics device. + * @param constraint the constraint (null not permitted). + * + * @return The block size (in Java2D units, never null). + */ + @Override + public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { + return new Size2D(calculateTotalWidth(getWidth()), + calculateTotalHeight(getHeight())); + } + + /** + * Draws the block. + * + * @param g2 the graphics device. + * @param area the area. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + area = trimMargin(area); + drawBorder(g2, area); + area = trimBorder(area); + area = trimPadding(area); + g2.setPaint(this.paint); + g2.fill(area); + } + + /** + * Draws the block within the specified area. + * + * @param g2 the graphics device. + * @param area the area. + * @param params ignored (null permitted). + * + * @return Always null. + */ + @Override + public Object draw(Graphics2D g2, Rectangle2D area, Object params) { + draw(g2, area); + return null; + } + + /** + * Tests this block for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ColorBlock)) { + return false; + } + ColorBlock that = (ColorBlock) obj; + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + return super.equals(obj); + } + + /** + * 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/ColumnArrangement.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/ColumnArrangement.java new file mode 100755 index 0000000..dc64bc9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/ColumnArrangement.java @@ -0,0 +1,392 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * ColumnArrangement.java + * ---------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 22-Oct-2004 : Version 1 (DG); + * 04-Feb-2005 : Added equals() and implemented Serializable (DG); + * + */ + +package org.jfree.chart.block; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.jfree.ui.HorizontalAlignment; +import org.jfree.ui.Size2D; +import org.jfree.ui.VerticalAlignment; + +/** + * Arranges blocks in a column layout. This class is immutable. + */ +public class ColumnArrangement implements Arrangement, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -5315388482898581555L; + + /** The horizontal alignment of blocks. */ + private HorizontalAlignment horizontalAlignment; + + /** The vertical alignment of blocks within each row. */ + private VerticalAlignment verticalAlignment; + + /** The horizontal gap between columns. */ + private double horizontalGap; + + /** The vertical gap between items in a column. */ + private double verticalGap; + + /** + * Creates a new instance. + */ + public ColumnArrangement() { + } + + /** + * Creates a new instance. + * + * @param hAlign the horizontal alignment (currently ignored). + * @param vAlign the vertical alignment (currently ignored). + * @param hGap the horizontal gap. + * @param vGap the vertical gap. + */ + public ColumnArrangement(HorizontalAlignment hAlign, + VerticalAlignment vAlign, + double hGap, double vGap) { + this.horizontalAlignment = hAlign; + this.verticalAlignment = vAlign; + this.horizontalGap = hGap; + this.verticalGap = vGap; + } + + /** + * Adds a block to be managed by this instance. This method is usually + * called by the {@link BlockContainer}, you shouldn't need to call it + * directly. + * + * @param block the block. + * @param key a key that controls the position of the block. + */ + @Override + public void add(Block block, Object key) { + // since the flow layout is relatively straightforward, no information + // needs to be recorded here + } + + /** + * Calculates and sets the bounds of all the items in the specified + * container, subject to the given constraint. The Graphics2D + * can be used by some items (particularly items containing text) to + * calculate sizing parameters. + * + * @param container the container whose items are being arranged. + * @param g2 the graphics device. + * @param constraint the size constraint. + * + * @return The size of the container after arrangement of the contents. + */ + @Override + public Size2D arrange(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + LengthConstraintType w = constraint.getWidthConstraintType(); + LengthConstraintType h = constraint.getHeightConstraintType(); + if (w == LengthConstraintType.NONE) { + if (h == LengthConstraintType.NONE) { + return arrangeNN(container, g2); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not implemented."); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not implemented."); + } + } + else if (w == LengthConstraintType.FIXED) { + if (h == LengthConstraintType.NONE) { + throw new RuntimeException("Not implemented."); + } + else if (h == LengthConstraintType.FIXED) { + return arrangeFF(container, g2, constraint); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not implemented."); + } + } + else if (w == LengthConstraintType.RANGE) { + if (h == LengthConstraintType.NONE) { + throw new RuntimeException("Not implemented."); + } + else if (h == LengthConstraintType.FIXED) { + return arrangeRF(container, g2, constraint); + } + else if (h == LengthConstraintType.RANGE) { + return arrangeRR(container, g2, constraint); + } + } + return new Size2D(); // TODO: complete this + + } + + /** + * Calculates and sets the bounds of all the items in the specified + * container, subject to the given constraint. The Graphics2D + * can be used by some items (particularly items containing text) to + * calculate sizing parameters. + * + * @param container the container whose items are being arranged. + * @param g2 the graphics device. + * @param constraint the size constraint. + * + * @return The container size after the arrangement. + */ + protected Size2D arrangeFF(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + // TODO: implement properly + return arrangeNF(container, g2, constraint); + } + + /** + * Calculates and sets the bounds of all the items in the specified + * container, subject to the given constraint. The Graphics2D + * can be used by some items (particularly items containing text) to + * calculate sizing parameters. + * + * @param container the container whose items are being arranged. + * @param constraint the size constraint. + * @param g2 the graphics device. + * + * @return The container size after the arrangement. + */ + protected Size2D arrangeNF(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + List blocks = container.getBlocks(); + + double height = constraint.getHeight(); + if (height <= 0.0) { + height = Double.POSITIVE_INFINITY; + } + + double x = 0.0; + double y = 0.0; + double maxWidth = 0.0; + List itemsInColumn = new ArrayList(); + for (int i = 0; i < blocks.size(); i++) { + Block block = (Block) blocks.get(i); + Size2D size = block.arrange(g2, RectangleConstraint.NONE); + if (y + size.height <= height) { + itemsInColumn.add(block); + block.setBounds( + new Rectangle2D.Double(x, y, size.width, size.height) + ); + y = y + size.height + this.verticalGap; + maxWidth = Math.max(maxWidth, size.width); + } + else { + if (itemsInColumn.isEmpty()) { + // place in this column (truncated) anyway + block.setBounds( + new Rectangle2D.Double( + x, y, size.width, Math.min(size.height, height - y) + ) + ); + y = 0.0; + x = x + size.width + this.horizontalGap; + } + else { + // start new column + itemsInColumn.clear(); + x = x + maxWidth + this.horizontalGap; + y = 0.0; + maxWidth = size.width; + block.setBounds( + new Rectangle2D.Double( + x, y, size.width, Math.min(size.height, height) + ) + ); + y = size.height + this.verticalGap; + itemsInColumn.add(block); + } + } + } + return new Size2D(x + maxWidth, constraint.getHeight()); + } + + /** + * Arranges a container with range constraints for both the horizontal + * and vertical. + * + * @param container the container. + * @param g2 the graphics device. + * @param constraint the constraint. + * + * @return The size of the container. + */ + protected Size2D arrangeRR(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + // first arrange without constraints, and see if this fits within + // the required ranges... + Size2D s1 = arrangeNN(container, g2); + if (constraint.getHeightRange().contains(s1.height)) { + return s1; // TODO: we didn't check the width yet + } + else { + RectangleConstraint c = constraint.toFixedHeight( + constraint.getHeightRange().getUpperBound() + ); + return arrangeRF(container, g2, c); + } + } + + /** + * Arranges the blocks in the container using a fixed height and a + * range for the width. + * + * @param container the container. + * @param g2 the graphics device. + * @param constraint the constraint. + * + * @return The size of the container after arrangement. + */ + protected Size2D arrangeRF(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + Size2D s = arrangeNF(container, g2, constraint); + if (constraint.getWidthRange().contains(s.width)) { + return s; + } + else { + RectangleConstraint c = constraint.toFixedWidth( + constraint.getWidthRange().constrain(s.getWidth()) + ); + return arrangeFF(container, g2, c); + } + } + + /** + * Arranges the blocks without any constraints. This puts all blocks + * into a single column. + * + * @param container the container. + * @param g2 the graphics device. + * + * @return The size after the arrangement. + */ + protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) { + double y = 0.0; + double height = 0.0; + double maxWidth = 0.0; + List blocks = container.getBlocks(); + int blockCount = blocks.size(); + if (blockCount > 0) { + Size2D[] sizes = new Size2D[blocks.size()]; + for (int i = 0; i < blocks.size(); i++) { + Block block = (Block) blocks.get(i); + sizes[i] = block.arrange(g2, RectangleConstraint.NONE); + height = height + sizes[i].getHeight(); + maxWidth = Math.max(sizes[i].width, maxWidth); + block.setBounds( + new Rectangle2D.Double( + 0.0, y, sizes[i].width, sizes[i].height + ) + ); + y = y + sizes[i].height + this.verticalGap; + } + if (blockCount > 1) { + height = height + this.verticalGap * (blockCount - 1); + } + if (this.horizontalAlignment != HorizontalAlignment.LEFT) { + for (int i = 0; i < blocks.size(); i++) { + //Block b = (Block) blocks.get(i); + if (this.horizontalAlignment + == HorizontalAlignment.CENTER) { + //TODO: shift block right by half + } + else if (this.horizontalAlignment + == HorizontalAlignment.RIGHT) { + //TODO: shift block over to right + } + } + } + } + return new Size2D(maxWidth, height); + } + + /** + * Clears any cached information. + */ + @Override + public void clear() { + // no action required. + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ColumnArrangement)) { + return false; + } + ColumnArrangement that = (ColumnArrangement) obj; + if (this.horizontalAlignment != that.horizontalAlignment) { + return false; + } + if (this.verticalAlignment != that.verticalAlignment) { + return false; + } + if (this.horizontalGap != that.horizontalGap) { + return false; + } + if (this.verticalGap != that.verticalGap) { + return false; + } + return true; + } + + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/EmptyBlock.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/EmptyBlock.java new file mode 100755 index 0000000..a660af0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/EmptyBlock.java @@ -0,0 +1,132 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * EmptyBlock.java + * --------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 22-Oct-2004 : Version 1 (DG); + * 04-Feb-2005 : Now cloneable and serializable (DG); + * 20-Apr-2005 : Added new draw() method (DG); + * 08-Apr-2008 : Added support for margin and border (DG); + * 08-May-2008 : Updated arrange() method to recognise + * incoming constraint (DG); + * + */ + +package org.jfree.chart.block; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.ui.Size2D; +import org.jfree.util.PublicCloneable; + +/** + * An empty block with a fixed size. + */ +public class EmptyBlock extends AbstractBlock + implements Block, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -4083197869412648579L; + + /** + * Creates a new block with the specified width and height. + * + * @param width the width. + * @param height the height. + */ + public EmptyBlock(double width, double height) { + setWidth(width); + setHeight(height); + } + + /** + * Arranges the contents of the block, within the given constraints, and + * returns the block size. + * + * @param g2 the graphics device. + * @param constraint the constraint (null not permitted). + * + * @return The block size (in Java2D units, never null). + */ + @Override + public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { + Size2D base = new Size2D(calculateTotalWidth(getWidth()), + calculateTotalHeight(getHeight())); + return constraint.calculateConstrainedSize(base); + } + + /** + * Draws the block. Since the block is empty, there is nothing to draw + * except the optional border. + * + * @param g2 the graphics device. + * @param area the area. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + draw(g2, area, null); + } + + /** + * Draws the block within the specified area. Since the block is empty, + * there is nothing to draw except the optional border. + * + * @param g2 the graphics device. + * @param area the area. + * @param params ignored (null permitted). + * + * @return Always null. + */ + @Override + public Object draw(Graphics2D g2, Rectangle2D area, Object params) { + area = trimMargin(area); + drawBorder(g2, area); + return null; + } + + /** + * Returns a clone of the block. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/EntityBlockParams.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/EntityBlockParams.java new file mode 100755 index 0000000..b41fcc1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/EntityBlockParams.java @@ -0,0 +1,58 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * EntityBlockParams.java + * ---------------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 19-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +/** + * An interface that is used by the draw() method of some {@link Block} + * implementations to determine whether or not to generate entities for the + * items within the block. + */ +public interface EntityBlockParams { + + /** + * Returns a flag that controls whether or not the block should return + * entities for the items it draws. + * + * @return A boolean. + */ + public boolean getGenerateEntities(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/EntityBlockResult.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/EntityBlockResult.java new file mode 100755 index 0000000..a548416 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/EntityBlockResult.java @@ -0,0 +1,58 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * EntityBlockResult.java + * ---------------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 19-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +import org.jfree.chart.entity.EntityCollection; + +/** + * Provides access to the {@link EntityCollection} generated when a block is + * drawn. + */ +public interface EntityBlockResult { + + /** + * Returns the entity collection. + * + * @return An entity collection (possibly null). + */ + public EntityCollection getEntityCollection(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/FlowArrangement.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/FlowArrangement.java new file mode 100755 index 0000000..759b980 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/FlowArrangement.java @@ -0,0 +1,451 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * FlowArrangement.java + * -------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 22-Oct-2004 : Version 1 (DG); + * 04-Feb-2005 : Implemented equals() and made serializable (DG); + * 08-Feb-2005 : Updated for changes in RectangleConstraint (DG); + * + */ + +package org.jfree.chart.block; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.jfree.ui.HorizontalAlignment; +import org.jfree.ui.Size2D; +import org.jfree.ui.VerticalAlignment; + +/** + * Arranges blocks in a flow layout. This class is immutable. + */ +public class FlowArrangement implements Arrangement, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 4543632485478613800L; + + /** The horizontal alignment of blocks. */ + private HorizontalAlignment horizontalAlignment; + + /** The vertical alignment of blocks within each row. */ + private VerticalAlignment verticalAlignment; + + /** The horizontal gap between items within rows. */ + private double horizontalGap; + + /** The vertical gap between rows. */ + private double verticalGap; + + /** + * Creates a new instance. + */ + public FlowArrangement() { + this(HorizontalAlignment.CENTER, VerticalAlignment.CENTER, 2.0, 2.0); + } + + /** + * Creates a new instance. + * + * @param hAlign the horizontal alignment (currently ignored). + * @param vAlign the vertical alignment (currently ignored). + * @param hGap the horizontal gap. + * @param vGap the vertical gap. + */ + public FlowArrangement(HorizontalAlignment hAlign, VerticalAlignment vAlign, + double hGap, double vGap) { + this.horizontalAlignment = hAlign; + this.verticalAlignment = vAlign; + this.horizontalGap = hGap; + this.verticalGap = vGap; + } + + /** + * Adds a block to be managed by this instance. This method is usually + * called by the {@link BlockContainer}, you shouldn't need to call it + * directly. + * + * @param block the block. + * @param key a key that controls the position of the block. + */ + @Override + public void add(Block block, Object key) { + // since the flow layout is relatively straightforward, + // no information needs to be recorded here + } + + /** + * Calculates and sets the bounds of all the items in the specified + * container, subject to the given constraint. The Graphics2D + * can be used by some items (particularly items containing text) to + * calculate sizing parameters. + * + * @param container the container whose items are being arranged. + * @param constraint the size constraint. + * @param g2 the graphics device. + * + * @return The size of the container after arrangement of the contents. + */ + @Override + public Size2D arrange(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + LengthConstraintType w = constraint.getWidthConstraintType(); + LengthConstraintType h = constraint.getHeightConstraintType(); + if (w == LengthConstraintType.NONE) { + if (h == LengthConstraintType.NONE) { + return arrangeNN(container, g2); + } + else if (h == LengthConstraintType.FIXED) { + return arrangeNF(container, g2, constraint); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not implemented."); + } + } + else if (w == LengthConstraintType.FIXED) { + if (h == LengthConstraintType.NONE) { + return arrangeFN(container, g2, constraint); + } + else if (h == LengthConstraintType.FIXED) { + return arrangeFF(container, g2, constraint); + } + else if (h == LengthConstraintType.RANGE) { + return arrangeFR(container, g2, constraint); + } + } + else if (w == LengthConstraintType.RANGE) { + if (h == LengthConstraintType.NONE) { + return arrangeRN(container, g2, constraint); + } + else if (h == LengthConstraintType.FIXED) { + return arrangeRF(container, g2, constraint); + } + else if (h == LengthConstraintType.RANGE) { + return arrangeRR(container, g2, constraint); + } + } + throw new RuntimeException("Unrecognised constraint type."); + + } + + /** + * Arranges the blocks in the container with a fixed width and no height + * constraint. + * + * @param container the container. + * @param constraint the constraint. + * @param g2 the graphics device. + * + * @return The size. + */ + protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + List blocks = container.getBlocks(); + double width = constraint.getWidth(); + + double x = 0.0; + double y = 0.0; + double maxHeight = 0.0; + List itemsInRow = new ArrayList(); + for (int i = 0; i < blocks.size(); i++) { + Block block = (Block) blocks.get(i); + Size2D size = block.arrange(g2, RectangleConstraint.NONE); + if (x + size.width <= width) { + itemsInRow.add(block); + block.setBounds( + new Rectangle2D.Double(x, y, size.width, size.height) + ); + x = x + size.width + this.horizontalGap; + maxHeight = Math.max(maxHeight, size.height); + } + else { + if (itemsInRow.isEmpty()) { + // place in this row (truncated) anyway + block.setBounds( + new Rectangle2D.Double( + x, y, Math.min(size.width, width - x), size.height + ) + ); + x = 0.0; + y = y + size.height + this.verticalGap; + } + else { + // start new row + itemsInRow.clear(); + x = 0.0; + y = y + maxHeight + this.verticalGap; + maxHeight = size.height; + block.setBounds( + new Rectangle2D.Double( + x, y, Math.min(size.width, width), size.height + ) + ); + x = size.width + this.horizontalGap; + itemsInRow.add(block); + } + } + } + return new Size2D(constraint.getWidth(), y + maxHeight); + } + + /** + * Arranges the blocks in the container with a fixed width and a range + * constraint on the height. + * + * @param container the container. + * @param constraint the constraint. + * @param g2 the graphics device. + * + * @return The size following the arrangement. + */ + protected Size2D arrangeFR(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + Size2D s = arrangeFN(container, g2, constraint); + if (constraint.getHeightRange().contains(s.height)) { + return s; + } + else { + RectangleConstraint c = constraint.toFixedHeight( + constraint.getHeightRange().constrain(s.getHeight()) + ); + return arrangeFF(container, g2, c); + } + } + + /** + * Arranges the blocks in the container with the overall height and width + * specified as fixed constraints. + * + * @param container the container. + * @param constraint the constraint. + * @param g2 the graphics device. + * + * @return The size following the arrangement. + */ + protected Size2D arrangeFF(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + // TODO: implement this properly + return arrangeFN(container, g2, constraint); + } + + /** + * Arranges the blocks with the overall width and height to fit within + * specified ranges. + * + * @param container the container. + * @param constraint the constraint. + * @param g2 the graphics device. + * + * @return The size after the arrangement. + */ + protected Size2D arrangeRR(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + // first arrange without constraints, and see if this fits within + // the required ranges... + Size2D s1 = arrangeNN(container, g2); + if (constraint.getWidthRange().contains(s1.width)) { + return s1; // TODO: we didn't check the height yet + } + else { + RectangleConstraint c = constraint.toFixedWidth( + constraint.getWidthRange().getUpperBound() + ); + return arrangeFR(container, g2, c); + } + } + + /** + * Arranges the blocks in the container with a range constraint on the + * width and a fixed height. + * + * @param container the container. + * @param constraint the constraint. + * @param g2 the graphics device. + * + * @return The size following the arrangement. + */ + protected Size2D arrangeRF(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + Size2D s = arrangeNF(container, g2, constraint); + if (constraint.getWidthRange().contains(s.width)) { + return s; + } + else { + RectangleConstraint c = constraint.toFixedWidth( + constraint.getWidthRange().constrain(s.getWidth()) + ); + return arrangeFF(container, g2, c); + } + } + + /** + * Arranges the block with a range constraint on the width, and no + * constraint on the height. + * + * @param container the container. + * @param constraint the constraint. + * @param g2 the graphics device. + * + * @return The size following the arrangement. + */ + protected Size2D arrangeRN(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + // first arrange without constraints, then see if the width fits + // within the required range...if not, call arrangeFN() at max width + Size2D s1 = arrangeNN(container, g2); + if (constraint.getWidthRange().contains(s1.width)) { + return s1; + } + else { + RectangleConstraint c = constraint.toFixedWidth( + constraint.getWidthRange().getUpperBound() + ); + return arrangeFN(container, g2, c); + } + } + + /** + * Arranges the blocks without any constraints. This puts all blocks + * into a single row. + * + * @param container the container. + * @param g2 the graphics device. + * + * @return The size after the arrangement. + */ + protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) { + double x = 0.0; + double width = 0.0; + double maxHeight = 0.0; + List blocks = container.getBlocks(); + int blockCount = blocks.size(); + if (blockCount > 0) { + Size2D[] sizes = new Size2D[blocks.size()]; + for (int i = 0; i < blocks.size(); i++) { + Block block = (Block) blocks.get(i); + sizes[i] = block.arrange(g2, RectangleConstraint.NONE); + width = width + sizes[i].getWidth(); + maxHeight = Math.max(sizes[i].height, maxHeight); + block.setBounds( + new Rectangle2D.Double( + x, 0.0, sizes[i].width, sizes[i].height + ) + ); + x = x + sizes[i].width + this.horizontalGap; + } + if (blockCount > 1) { + width = width + this.horizontalGap * (blockCount - 1); + } + if (this.verticalAlignment != VerticalAlignment.TOP) { + for (int i = 0; i < blocks.size(); i++) { + //Block b = (Block) blocks.get(i); + if (this.verticalAlignment == VerticalAlignment.CENTER) { + //TODO: shift block down by half + } + else if (this.verticalAlignment + == VerticalAlignment.BOTTOM) { + //TODO: shift block down to bottom + } + } + } + } + return new Size2D(width, maxHeight); + } + + /** + * Arranges the blocks with no width constraint and a fixed height + * constraint. This puts all blocks into a single row. + * + * @param container the container. + * @param constraint the constraint. + * @param g2 the graphics device. + * + * @return The size after the arrangement. + */ + protected Size2D arrangeNF(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + // TODO: for now we are ignoring the height constraint + return arrangeNN(container, g2); + } + + /** + * Clears any cached information. + */ + @Override + public void clear() { + // no action required. + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof FlowArrangement)) { + return false; + } + FlowArrangement that = (FlowArrangement) obj; + if (this.horizontalAlignment != that.horizontalAlignment) { + return false; + } + if (this.verticalAlignment != that.verticalAlignment) { + return false; + } + if (this.horizontalGap != that.horizontalGap) { + return false; + } + if (this.verticalGap != that.verticalGap) { + return false; + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/GridArrangement.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/GridArrangement.java new file mode 100755 index 0000000..a6fd8d1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/GridArrangement.java @@ -0,0 +1,453 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * GridArrangement.java + * -------------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 08-Feb-2005 : Version 1 (DG); + * 03-Dec-2008 : Implemented missing methods, and fixed bugs reported in + * patch 2370487 (DG); + * + */ + +package org.jfree.chart.block; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import org.jfree.ui.Size2D; + +/** + * Arranges blocks in a grid within their container. + */ +public class GridArrangement implements Arrangement, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -2563758090144655938L; + + /** The rows. */ + private int rows; + + /** The columns. */ + private int columns; + + /** + * Creates a new grid arrangement. + * + * @param rows the row count. + * @param columns the column count. + */ + public GridArrangement(int rows, int columns) { + this.rows = rows; + this.columns = columns; + } + + /** + * Adds a block and a key which can be used to determine the position of + * the block in the arrangement. This method is called by the container + * (you don't need to call this method directly) and gives the arrangement + * an opportunity to record the details if they are required. + * + * @param block the block. + * @param key the key (null permitted). + */ + @Override + public void add(Block block, Object key) { + // can safely ignore + } + + /** + * Arranges the blocks within the specified container, subject to the given + * constraint. + * + * @param container the container (null not permitted). + * @param constraint the constraint. + * @param g2 the graphics device. + * + * @return The size following the arrangement. + */ + @Override + public Size2D arrange(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + LengthConstraintType w = constraint.getWidthConstraintType(); + LengthConstraintType h = constraint.getHeightConstraintType(); + if (w == LengthConstraintType.NONE) { + if (h == LengthConstraintType.NONE) { + return arrangeNN(container, g2); + } + else if (h == LengthConstraintType.FIXED) { + return arrangeNF(container, g2, constraint); + } + else if (h == LengthConstraintType.RANGE) { + // find optimum height, then map to range + return arrangeNR(container, g2, constraint); + } + } + else if (w == LengthConstraintType.FIXED) { + if (h == LengthConstraintType.NONE) { + // find optimum height + return arrangeFN(container, g2, constraint); + } + else if (h == LengthConstraintType.FIXED) { + return arrangeFF(container, g2, constraint); + } + else if (h == LengthConstraintType.RANGE) { + // find optimum height and map to range + return arrangeFR(container, g2, constraint); + } + } + else if (w == LengthConstraintType.RANGE) { + // find optimum width and map to range + if (h == LengthConstraintType.NONE) { + // find optimum height + return arrangeRN(container, g2, constraint); + } + else if (h == LengthConstraintType.FIXED) { + // fixed width + return arrangeRF(container, g2, constraint); + } + else if (h == LengthConstraintType.RANGE) { + return arrangeRR(container, g2, constraint); + } + } + throw new RuntimeException("Should never get to here!"); + } + + /** + * Arranges the container with no constraint on the width or height. + * + * @param container the container (null not permitted). + * @param g2 the graphics device. + * + * @return The size. + */ + protected Size2D arrangeNN(BlockContainer container, Graphics2D g2) { + double maxW = 0.0; + double maxH = 0.0; + List blocks = container.getBlocks(); + Iterator iterator = blocks.iterator(); + while (iterator.hasNext()) { + Block b = (Block) iterator.next(); + if (b != null) { + Size2D s = b.arrange(g2, RectangleConstraint.NONE); + maxW = Math.max(maxW, s.width); + maxH = Math.max(maxH, s.height); + } + } + double width = this.columns * maxW; + double height = this.rows * maxH; + RectangleConstraint c = new RectangleConstraint(width, height); + return arrangeFF(container, g2, c); + } + + /** + * Arranges the container with a fixed overall width and height. + * + * @param container the container (null not permitted). + * @param g2 the graphics device. + * @param constraint the constraint (null not permitted). + * + * @return The size following the arrangement. + */ + protected Size2D arrangeFF(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + double width = constraint.getWidth() / this.columns; + double height = constraint.getHeight() / this.rows; + List blocks = container.getBlocks(); + for (int c = 0; c < this.columns; c++) { + for (int r = 0; r < this.rows; r++) { + int index = r * this.columns + c; + if (index >= blocks.size()) { + break; + } + Block b = (Block) blocks.get(index); + if (b != null) { + b.setBounds(new Rectangle2D.Double(c * width, r * height, + width, height)); + } + } + } + return new Size2D(this.columns * width, this.rows * height); + } + + /** + * Arrange with a fixed width and a height within a given range. + * + * @param container the container. + * @param constraint the constraint. + * @param g2 the graphics device. + * + * @return The size of the arrangement. + */ + protected Size2D arrangeFR(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + RectangleConstraint c1 = constraint.toUnconstrainedHeight(); + Size2D size1 = arrange(container, g2, c1); + + if (constraint.getHeightRange().contains(size1.getHeight())) { + return size1; + } + else { + double h = constraint.getHeightRange().constrain(size1.getHeight()); + RectangleConstraint c2 = constraint.toFixedHeight(h); + return arrange(container, g2, c2); + } + } + + /** + * Arrange with a fixed height and a width within a given range. + * + * @param container the container. + * @param constraint the constraint. + * @param g2 the graphics device. + * + * @return The size of the arrangement. + */ + protected Size2D arrangeRF(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + RectangleConstraint c1 = constraint.toUnconstrainedWidth(); + Size2D size1 = arrange(container, g2, c1); + + if (constraint.getWidthRange().contains(size1.getWidth())) { + return size1; + } + else { + double w = constraint.getWidthRange().constrain(size1.getWidth()); + RectangleConstraint c2 = constraint.toFixedWidth(w); + return arrange(container, g2, c2); + } + } + + /** + * Arrange with a fixed width and no height constraint. + * + * @param container the container. + * @param constraint the constraint. + * @param g2 the graphics device. + * + * @return The size of the arrangement. + */ + protected Size2D arrangeRN(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + RectangleConstraint c1 = constraint.toUnconstrainedWidth(); + Size2D size1 = arrange(container, g2, c1); + + if (constraint.getWidthRange().contains(size1.getWidth())) { + return size1; + } + else { + double w = constraint.getWidthRange().constrain(size1.getWidth()); + RectangleConstraint c2 = constraint.toFixedWidth(w); + return arrange(container, g2, c2); + } + } + + /** + * Arrange with a fixed height and no width constraint. + * + * @param container the container. + * @param constraint the constraint. + * @param g2 the graphics device. + * + * @return The size of the arrangement. + */ + protected Size2D arrangeNR(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + RectangleConstraint c1 = constraint.toUnconstrainedHeight(); + Size2D size1 = arrange(container, g2, c1); + + if (constraint.getHeightRange().contains(size1.getHeight())) { + return size1; + } + else { + double h = constraint.getHeightRange().constrain(size1.getHeight()); + RectangleConstraint c2 = constraint.toFixedHeight(h); + return arrange(container, g2, c2); + } + } + + /** + * Arrange with ranges for both the width and height constraints. + * + * @param container the container. + * @param constraint the constraint. + * @param g2 the graphics device. + * + * @return The size of the arrangement. + */ + protected Size2D arrangeRR(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + Size2D size1 = arrange(container, g2, RectangleConstraint.NONE); + + if (constraint.getWidthRange().contains(size1.getWidth())) { + if (constraint.getHeightRange().contains(size1.getHeight())) { + return size1; + } + else { + // width is OK, but height must be constrained + double h = constraint.getHeightRange().constrain( + size1.getHeight()); + RectangleConstraint cc = new RectangleConstraint( + size1.getWidth(), h); + return arrangeFF(container, g2, cc); + } + } + else { + if (constraint.getHeightRange().contains(size1.getHeight())) { + // height is OK, but width must be constrained + double w = constraint.getWidthRange().constrain( + size1.getWidth()); + RectangleConstraint cc = new RectangleConstraint(w, + size1.getHeight()); + return arrangeFF(container, g2, cc); + + } + else { + double w = constraint.getWidthRange().constrain( + size1.getWidth()); + double h = constraint.getHeightRange().constrain( + size1.getHeight()); + RectangleConstraint cc = new RectangleConstraint(w, h); + return arrangeFF(container, g2, cc); + } + } + } + + /** + * Arrange with a fixed width and a height within a given range. + * + * @param container the container. + * @param g2 the graphics device. + * @param constraint the constraint. + * + * @return The size of the arrangement. + */ + protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + double width = constraint.getWidth() / this.columns; + RectangleConstraint bc = constraint.toFixedWidth(width); + List blocks = container.getBlocks(); + double maxH = 0.0; + for (int r = 0; r < this.rows; r++) { + for (int c = 0; c < this.columns; c++) { + int index = r * this.columns + c; + if (index >= blocks.size()) { + break; + } + Block b = (Block) blocks.get(index); + if (b != null) { + Size2D s = b.arrange(g2, bc); + maxH = Math.max(maxH, s.getHeight()); + } + } + } + RectangleConstraint cc = constraint.toFixedHeight(maxH * this.rows); + return arrange(container, g2, cc); + } + + /** + * Arrange with a fixed height and no constraint for the width. + * + * @param container the container. + * @param g2 the graphics device. + * @param constraint the constraint. + * + * @return The size of the arrangement. + */ + protected Size2D arrangeNF(BlockContainer container, Graphics2D g2, + RectangleConstraint constraint) { + + double height = constraint.getHeight() / this.rows; + RectangleConstraint bc = constraint.toFixedHeight(height); + List blocks = container.getBlocks(); + double maxW = 0.0; + for (int r = 0; r < this.rows; r++) { + for (int c = 0; c < this.columns; c++) { + int index = r * this.columns + c; + if (index >= blocks.size()) { + break; + } + Block b = (Block) blocks.get(index); + if (b != null) { + Size2D s = b.arrange(g2, bc); + maxW = Math.max(maxW, s.getWidth()); + } + } + } + RectangleConstraint cc = constraint.toFixedWidth(maxW * this.columns); + return arrange(container, g2, cc); + } + + /** + * Clears any cached layout information retained by the arrangement. + */ + @Override + public void clear() { + // nothing to clear + } + + /** + * Compares this layout manager for equality with an arbitrary object. + * + * @param obj the object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof GridArrangement)) { + return false; + } + GridArrangement that = (GridArrangement) obj; + if (this.columns != that.columns) { + return false; + } + if (this.rows != that.rows) { + return false; + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/LabelBlock.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/LabelBlock.java new file mode 100755 index 0000000..c7b1fd2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/LabelBlock.java @@ -0,0 +1,450 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * LabelBlock.java + * --------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Pierre-Marie Le Biot; + * + * Changes: + * -------- + * 22-Oct-2004 : Version 1 (DG); + * 19-Apr-2005 : Added optional tooltip and URL text items, + * draw() method now returns entities if + * requested (DG); + * 13-May-2005 : Added methods to set the font (DG); + * 01-Sep-2005 : Added paint management (PMLB); + * Implemented equals() and clone() (PublicCloneable) (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 20-Jul-2006 : Fixed entity area in draw() method (DG); + * 16-Mar-2007 : Fixed serialization when using GradientPaint (DG); + * 10-Feb-2009 : Added alignment fields (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.block; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import org.jfree.chart.entity.ChartEntity; +import org.jfree.chart.entity.StandardEntityCollection; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextBlock; +import org.jfree.text.TextBlockAnchor; +import org.jfree.text.TextUtilities; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.Size2D; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A block containing a label. + */ +public class LabelBlock extends AbstractBlock + implements Block, PublicCloneable { + + /** For serialization. */ + static final long serialVersionUID = 249626098864178017L; + + /** + * The text for the label - retained in case the label needs + * regenerating (for example, to change the font). + */ + private String text; + + /** The label. */ + private TextBlock label; + + /** The font. */ + private Font font; + + /** The tool tip text (can be null). */ + private String toolTipText; + + /** The URL text (can be null). */ + private String urlText; + + /** The default color. */ + public static final Paint DEFAULT_PAINT = Color.black; + + /** The paint. */ + private transient Paint paint; + + /** + * The content alignment point. + * + * @since 1.0.13 + */ + private TextBlockAnchor contentAlignmentPoint; + + /** + * The anchor point for the text. + * + * @since 1.0.13 + */ + private RectangleAnchor textAnchor; + + /** + * Creates a new label block. + * + * @param label the label (null not permitted). + */ + public LabelBlock(String label) { + this(label, new Font("SansSerif", Font.PLAIN, 10), DEFAULT_PAINT); + } + + /** + * Creates a new label block. + * + * @param text the text for the label (null not permitted). + * @param font the font (null not permitted). + */ + public LabelBlock(String text, Font font) { + this(text, font, DEFAULT_PAINT); + } + + /** + * Creates a new label block. + * + * @param text the text for the label (null not permitted). + * @param font the font (null not permitted). + * @param paint the paint (null not permitted). + */ + public LabelBlock(String text, Font font, Paint paint) { + this.text = text; + this.paint = paint; + this.label = TextUtilities.createTextBlock(text, font, this.paint); + this.font = font; + this.toolTipText = null; + this.urlText = null; + this.contentAlignmentPoint = TextBlockAnchor.CENTER; + this.textAnchor = RectangleAnchor.CENTER; + } + + /** + * Returns the font. + * + * @return The font (never null). + * + * @see #setFont(Font) + */ + public Font getFont() { + return this.font; + } + + /** + * Sets the font and regenerates the label. + * + * @param font the font (null not permitted). + * + * @see #getFont() + */ + public void setFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.font = font; + this.label = TextUtilities.createTextBlock(this.text, font, this.paint); + } + + /** + * Returns the paint. + * + * @return The paint (never null). + * + * @see #setPaint(Paint) + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Sets the paint and regenerates the label. + * + * @param paint the paint (null not permitted). + * + * @see #getPaint() + */ + public void setPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.paint = paint; + this.label = TextUtilities.createTextBlock(this.text, this.font, + this.paint); + } + + /** + * Returns the tool tip text. + * + * @return The tool tip text (possibly null). + * + * @see #setToolTipText(String) + */ + public String getToolTipText() { + return this.toolTipText; + } + + /** + * Sets the tool tip text. + * + * @param text the text (null permitted). + * + * @see #getToolTipText() + */ + public void setToolTipText(String text) { + this.toolTipText = text; + } + + /** + * Returns the URL text. + * + * @return The URL text (possibly null). + * + * @see #setURLText(String) + */ + public String getURLText() { + return this.urlText; + } + + /** + * Sets the URL text. + * + * @param text the text (null permitted). + * + * @see #getURLText() + */ + public void setURLText(String text) { + this.urlText = text; + } + + /** + * Returns the content alignment point. + * + * @return The content alignment point (never null). + * + * @since 1.0.13 + */ + public TextBlockAnchor getContentAlignmentPoint() { + return this.contentAlignmentPoint; + } + + /** + * Sets the content alignment point. + * + * @param anchor the anchor used to determine the alignment point (never + * null). + * + * @since 1.0.13 + */ + public void setContentAlignmentPoint(TextBlockAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.contentAlignmentPoint = anchor; + } + + /** + * Returns the text anchor (never null). + * + * @return The text anchor. + * + * @since 1.0.13 + */ + public RectangleAnchor getTextAnchor() { + return this.textAnchor; + } + + /** + * Sets the text anchor. + * + * @param anchor the anchor (null not permitted). + * + * @since 1.0.13 + */ + public void setTextAnchor(RectangleAnchor anchor) { + this.textAnchor = anchor; + } + + /** + * Arranges the contents of the block, within the given constraints, and + * returns the block size. + * + * @param g2 the graphics device. + * @param constraint the constraint (null not permitted). + * + * @return The block size (in Java2D units, never null). + */ + @Override + public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { + g2.setFont(this.font); + Size2D s = this.label.calculateDimensions(g2); + return new Size2D(calculateTotalWidth(s.getWidth()), + calculateTotalHeight(s.getHeight())); + } + + /** + * Draws the block. + * + * @param g2 the graphics device. + * @param area the area. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + draw(g2, area, null); + } + + /** + * Draws the block within the specified area. + * + * @param g2 the graphics device. + * @param area the area. + * @param params ignored (null permitted). + * + * @return Always null. + */ + @Override + public Object draw(Graphics2D g2, Rectangle2D area, Object params) { + area = trimMargin(area); + drawBorder(g2, area); + area = trimBorder(area); + area = trimPadding(area); + + // check if we need to collect chart entities from the container + EntityBlockParams ebp = null; + StandardEntityCollection sec = null; + Shape entityArea = null; + if (params instanceof EntityBlockParams) { + ebp = (EntityBlockParams) params; + if (ebp.getGenerateEntities()) { + sec = new StandardEntityCollection(); + entityArea = (Shape) area.clone(); + } + } + g2.setPaint(this.paint); + g2.setFont(this.font); + Point2D pt = RectangleAnchor.coordinates(area, this.textAnchor); + this.label.draw(g2, (float) pt.getX(), (float) pt.getY(), + this.contentAlignmentPoint); + BlockResult result = null; + if (ebp != null && sec != null) { + if (this.toolTipText != null || this.urlText != null) { + ChartEntity entity = new ChartEntity(entityArea, + this.toolTipText, this.urlText); + sec.add(entity); + result = new BlockResult(); + result.setEntityCollection(sec); + } + } + return result; + } + + /** + * Tests this LabelBlock for equality with an arbitrary + * object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (!(obj instanceof LabelBlock)) { + return false; + } + LabelBlock that = (LabelBlock) obj; + if (!this.text.equals(that.text)) { + return false; + } + if (!this.font.equals(that.font)) { + return false; + } + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + if (!ObjectUtilities.equal(this.toolTipText, that.toolTipText)) { + return false; + } + if (!ObjectUtilities.equal(this.urlText, that.urlText)) { + return false; + } + if (!this.contentAlignmentPoint.equals(that.contentAlignmentPoint)) { + return false; + } + if (!this.textAnchor.equals(that.textAnchor)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of this LabelBlock instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning. + */ + @Override + 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/LengthConstraintType.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/LengthConstraintType.java new file mode 100755 index 0000000..6113eca --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/LengthConstraintType.java @@ -0,0 +1,141 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * LengthConstraintType.java + * ------------------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 08-Feb-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Defines tokens used to indicate a length constraint type. + */ +public final class LengthConstraintType implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -1156658804028142978L; + + /** NONE. */ + public static final LengthConstraintType NONE + = new LengthConstraintType("LengthConstraintType.NONE"); + + /** Range. */ + public static final LengthConstraintType RANGE + = new LengthConstraintType("RectangleConstraintType.RANGE"); + + /** FIXED. */ + public static final LengthConstraintType FIXED + = new LengthConstraintType("LengthConstraintType.FIXED"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private LengthConstraintType(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof LengthConstraintType)) { + return false; + } + LengthConstraintType that = (LengthConstraintType) obj; + if (!this.name.equals(that.toString())) { + return false; + } + return true; + } + + /** + * Returns a hash code value for the object. + * + * @return The hashcode + */ + @Override + public int hashCode() { + return this.name.hashCode(); + } + + /** + * 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(LengthConstraintType.NONE)) { + return LengthConstraintType.NONE; + } + else if (this.equals(LengthConstraintType.RANGE)) { + return LengthConstraintType.RANGE; + } + else if (this.equals(LengthConstraintType.FIXED)) { + return LengthConstraintType.FIXED; + } + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/LineBorder.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/LineBorder.java new file mode 100755 index 0000000..ef03fd0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/LineBorder.java @@ -0,0 +1,237 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * LineBorder.java + * --------------- + * (C) Copyright 2007-2013, by Christo Zietsman and Contributors. + * + * Original Author: Christo Zietsman; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 16-Mar-2007 : Version 1, contributed by Christo Zietsman with + * modifications by DG (DG); + * 13-Jun-2007 : Don't draw if area doesn't have positive dimensions (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.block; + +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.util.ParamChecks; + +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; + +/** + * A line border for any {@link AbstractBlock}. + * + * @since 1.0.5 + */ +public class LineBorder implements BlockFrame, Serializable { + + /** For serialization. */ + static final long serialVersionUID = 4630356736707233924L; + + /** The line color. */ + private transient Paint paint; + + /** The line stroke. */ + private transient Stroke stroke; + + /** The insets. */ + private RectangleInsets insets; + + /** + * Creates a default border. + */ + public LineBorder() { + this(Color.black, new BasicStroke(1.0f), new RectangleInsets(1.0, 1.0, + 1.0, 1.0)); + } + + /** + * Creates a new border with the specified color. + * + * @param paint the color (null not permitted). + * @param stroke the border stroke (null not permitted). + * @param insets the insets (null not permitted). + */ + public LineBorder(Paint paint, Stroke stroke, RectangleInsets insets) { + ParamChecks.nullNotPermitted(paint, "paint"); + ParamChecks.nullNotPermitted(stroke, "stroke"); + ParamChecks.nullNotPermitted(insets, "insets"); + this.paint = paint; + this.stroke = stroke; + this.insets = insets; + } + + /** + * Returns the paint. + * + * @return The paint (never null). + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Returns the insets. + * + * @return The insets (never null). + */ + @Override + public RectangleInsets getInsets() { + return this.insets; + } + + /** + * Returns the stroke. + * + * @return The stroke (never null). + */ + public Stroke getStroke() { + return this.stroke; + } + + /** + * Draws the border by filling in the reserved space (in black). + * + * @param g2 the graphics device. + * @param area the area. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + double w = area.getWidth(); + double h = area.getHeight(); + // if the area has zero height or width, we shouldn't draw anything + if (w <= 0.0 || h <= 0.0) { + return; + } + double t = this.insets.calculateTopInset(h); + double b = this.insets.calculateBottomInset(h); + double l = this.insets.calculateLeftInset(w); + double r = this.insets.calculateRightInset(w); + double x = area.getX(); + double y = area.getY(); + double x0 = x + l / 2.0; + double x1 = x + w - r / 2.0; + double y0 = y + h - b / 2.0; + double y1 = y + t / 2.0; + g2.setPaint(getPaint()); + g2.setStroke(getStroke()); + Line2D line = new Line2D.Double(); + if (t > 0.0) { + line.setLine(x0, y1, x1, y1); + g2.draw(line); + } + if (b > 0.0) { + line.setLine(x0, y0, x1, y0); + g2.draw(line); + } + if (l > 0.0) { + line.setLine(x0, y0, x0, y1); + g2.draw(line); + } + if (r > 0.0) { + line.setLine(x1, y0, x1, y1); + g2.draw(line); + } + } + + /** + * Tests this border for equality with an arbitrary instance. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof LineBorder)) { + return false; + } + LineBorder that = (LineBorder) obj; + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + if (!ObjectUtilities.equal(this.stroke, that.stroke)) { + return false; + } + if (!this.insets.equals(that.insets)) { + return false; + } + return true; + } + + /** + * 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); + } +} + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/RectangleConstraint.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/RectangleConstraint.java new file mode 100755 index 0000000..60b5163 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/RectangleConstraint.java @@ -0,0 +1,359 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * RectangleConstraint.java + * ------------------------ + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 22-Oct-2004 : Version 1 (DG); + * 02-Feb-2005 : Added toString() method (DG); + * 08-Feb-2005 : Separated height and width constraints (DG); + * 13-May-2005 : Added convenience constructor and new methods for + * transforming constraints (DG); + * + */ + +package org.jfree.chart.block; + +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.ui.Size2D; + +/** + * A description of a constraint for resizing a rectangle. Constraints are + * immutable. + */ +public class RectangleConstraint { + + /** + * An instance representing no constraint. + */ + public static final RectangleConstraint NONE = new RectangleConstraint( + 0.0, null, LengthConstraintType.NONE, + 0.0, null, LengthConstraintType.NONE); + + /** The width. */ + private double width; + + /** The width range. */ + private Range widthRange; + + /** The width constraint type. */ + private LengthConstraintType widthConstraintType; + + /** The fixed or maximum height. */ + private double height; + + private Range heightRange; + + /** The constraint type. */ + private LengthConstraintType heightConstraintType; + + /** + * Creates a new "fixed width and height" instance. + * + * @param w the fixed width. + * @param h the fixed height. + */ + public RectangleConstraint(double w, double h) { + this(w, null, LengthConstraintType.FIXED, + h, null, LengthConstraintType.FIXED); + } + + /** + * Creates a new "range width and height" instance. + * + * @param w the width range. + * @param h the height range. + */ + public RectangleConstraint(Range w, Range h) { + this(0.0, w, LengthConstraintType.RANGE, + 0.0, h, LengthConstraintType.RANGE); + } + + /** + * Creates a new constraint with a range for the width and a + * fixed height. + * + * @param w the width range. + * @param h the fixed height. + */ + public RectangleConstraint(Range w, double h) { + this(0.0, w, LengthConstraintType.RANGE, + h, null, LengthConstraintType.FIXED); + } + + /** + * Creates a new constraint with a fixed width and a range for + * the height. + * + * @param w the fixed width. + * @param h the height range. + */ + public RectangleConstraint(double w, Range h) { + this(w, null, LengthConstraintType.FIXED, + 0.0, h, LengthConstraintType.RANGE); + } + + /** + * Creates a new constraint. + * + * @param w the fixed or maximum width. + * @param widthRange the width range. + * @param widthConstraintType the width type. + * @param h the fixed or maximum height. + * @param heightRange the height range. + * @param heightConstraintType the height type. + */ + public RectangleConstraint(double w, Range widthRange, + LengthConstraintType widthConstraintType, + double h, Range heightRange, + LengthConstraintType heightConstraintType) { + ParamChecks.nullNotPermitted(widthConstraintType, "widthConstraintType"); + ParamChecks.nullNotPermitted(heightConstraintType, "heightConstraintType"); + this.width = w; + this.widthRange = widthRange; + this.widthConstraintType = widthConstraintType; + this.height = h; + this.heightRange = heightRange; + this.heightConstraintType = heightConstraintType; + } + + /** + * Returns the fixed width. + * + * @return The width. + */ + public double getWidth() { + return this.width; + } + + /** + * Returns the width range. + * + * @return The range (possibly null). + */ + public Range getWidthRange() { + return this.widthRange; + } + + /** + * Returns the constraint type. + * + * @return The constraint type (never null). + */ + public LengthConstraintType getWidthConstraintType() { + return this.widthConstraintType; + } + + /** + * Returns the fixed height. + * + * @return The height. + */ + public double getHeight() { + return this.height; + } + + /** + * Returns the width range. + * + * @return The range (possibly null). + */ + public Range getHeightRange() { + return this.heightRange; + } + + /** + * Returns the constraint type. + * + * @return The constraint type (never null). + */ + public LengthConstraintType getHeightConstraintType() { + return this.heightConstraintType; + } + + /** + * Returns a constraint that matches this one on the height attributes, + * but has no width constraint. + * + * @return A new constraint. + */ + public RectangleConstraint toUnconstrainedWidth() { + if (this.widthConstraintType == LengthConstraintType.NONE) { + return this; + } + else { + return new RectangleConstraint(this.width, this.widthRange, + LengthConstraintType.NONE, this.height, this.heightRange, + this.heightConstraintType); + } + } + + /** + * Returns a constraint that matches this one on the width attributes, + * but has no height constraint. + * + * @return A new constraint. + */ + public RectangleConstraint toUnconstrainedHeight() { + if (this.heightConstraintType == LengthConstraintType.NONE) { + return this; + } + else { + return new RectangleConstraint(this.width, this.widthRange, + this.widthConstraintType, 0.0, this.heightRange, + LengthConstraintType.NONE); + } + } + + /** + * Returns a constraint that matches this one on the height attributes, + * but has a fixed width constraint. + * + * @param width the fixed width. + * + * @return A new constraint. + */ + public RectangleConstraint toFixedWidth(double width) { + return new RectangleConstraint(width, this.widthRange, + LengthConstraintType.FIXED, this.height, this.heightRange, + this.heightConstraintType); + } + + /** + * Returns a constraint that matches this one on the width attributes, + * but has a fixed height constraint. + * + * @param height the fixed height. + * + * @return A new constraint. + */ + public RectangleConstraint toFixedHeight(double height) { + return new RectangleConstraint(this.width, this.widthRange, + this.widthConstraintType, height, this.heightRange, + LengthConstraintType.FIXED); + } + + /** + * Returns a constraint that matches this one on the height attributes, + * but has a range width constraint. + * + * @param range the width range (null not permitted). + * + * @return A new constraint. + */ + public RectangleConstraint toRangeWidth(Range range) { + ParamChecks.nullNotPermitted(range, "range"); + return new RectangleConstraint(range.getUpperBound(), range, + LengthConstraintType.RANGE, this.height, this.heightRange, + this.heightConstraintType); + } + + /** + * Returns a constraint that matches this one on the width attributes, + * but has a range height constraint. + * + * @param range the height range (null not permitted). + * + * @return A new constraint. + */ + public RectangleConstraint toRangeHeight(Range range) { + ParamChecks.nullNotPermitted(range, "range"); + return new RectangleConstraint(this.width, this.widthRange, + this.widthConstraintType, range.getUpperBound(), range, + LengthConstraintType.RANGE); + } + + /** + * Returns a string representation of this instance, mostly used for + * debugging purposes. + * + * @return A string. + */ + @Override + public String toString() { + return "RectangleConstraint[" + + this.widthConstraintType.toString() + ": width=" + + this.width + ", height=" + this.height + "]"; + } + + /** + * Returns the new size that reflects the constraints defined by this + * instance. + * + * @param base the base size. + * + * @return The constrained size. + */ + public Size2D calculateConstrainedSize(Size2D base) { + Size2D result = new Size2D(); + if (this.widthConstraintType == LengthConstraintType.NONE) { + result.width = base.width; + if (this.heightConstraintType == LengthConstraintType.NONE) { + result.height = base.height; + } + else if (this.heightConstraintType == LengthConstraintType.RANGE) { + result.height = this.heightRange.constrain(base.height); + } + else if (this.heightConstraintType == LengthConstraintType.FIXED) { + result.height = this.height; + } + } + else if (this.widthConstraintType == LengthConstraintType.RANGE) { + result.width = this.widthRange.constrain(base.width); + if (this.heightConstraintType == LengthConstraintType.NONE) { + result.height = base.height; + } + else if (this.heightConstraintType == LengthConstraintType.RANGE) { + result.height = this.heightRange.constrain(base.height); + } + else if (this.heightConstraintType == LengthConstraintType.FIXED) { + result.height = this.height; + } + } + else if (this.widthConstraintType == LengthConstraintType.FIXED) { + result.width = this.width; + if (this.heightConstraintType == LengthConstraintType.NONE) { + result.height = base.height; + } + else if (this.heightConstraintType == LengthConstraintType.RANGE) { + result.height = this.heightRange.constrain(base.height); + } + else if (this.heightConstraintType == LengthConstraintType.FIXED) { + result.height = this.height; + } + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/package.html new file mode 100755 index 0000000..d65a8e4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/block/package.html @@ -0,0 +1,6 @@ + + + +Blocks and layout classes used extensively by the {@link org.jfree.chart.title.LegendTitle} class. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/demo/BarChartDemo1.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/demo/BarChartDemo1.java new file mode 100755 index 0000000..5150bed --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/demo/BarChartDemo1.java @@ -0,0 +1,214 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * BarChartDemo1.java + * ------------------ + * (C) Copyright 2003-2011, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): ; + * + * Changes + * ------- + * 09-Mar-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.demo; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.GradientPaint; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.StandardChartTheme; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.CategoryLabelPositions; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.renderer.category.BarRenderer; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.ui.ApplicationFrame; +import org.jfree.ui.RefineryUtilities; + +/** + * A simple demonstration application showing how to create a bar chart. + */ +public class BarChartDemo1 extends ApplicationFrame { + + private static final long serialVersionUID = 1L; + + { + // set a theme using the new shadow generator feature available in + // 1.0.14 - for backwards compatibility it is not enabled by default + ChartFactory.setChartTheme(new StandardChartTheme("JFree/Shadow", + true)); + } + + /** + * Creates a new demo instance. + * + * @param title the frame title. + */ + public BarChartDemo1(String title) { + super(title); + CategoryDataset dataset = createDataset(); + JFreeChart chart = createChart(dataset); + ChartPanel chartPanel = new ChartPanel(chart); + chartPanel.setFillZoomRectangle(true); + chartPanel.setMouseWheelEnabled(true); + chartPanel.setPreferredSize(new Dimension(500, 270)); + setContentPane(chartPanel); + } + + /** + * Returns a sample dataset. + * + * @return The dataset. + */ + private static CategoryDataset createDataset() { + + // row keys... + String series1 = "First"; + String series2 = "Second"; + String series3 = "Third"; + + // column keys... + String category1 = "Category 1"; + String category2 = "Category 2"; + String category3 = "Category 3"; + String category4 = "Category 4"; + String category5 = "Category 5"; + + // create the dataset... + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + + dataset.addValue(1.0, series1, category1); + dataset.addValue(4.0, series1, category2); + dataset.addValue(3.0, series1, category3); + dataset.addValue(5.0, series1, category4); + dataset.addValue(5.0, series1, category5); + + dataset.addValue(5.0, series2, category1); + dataset.addValue(7.0, series2, category2); + dataset.addValue(6.0, series2, category3); + dataset.addValue(8.0, series2, category4); + dataset.addValue(4.0, series2, category5); + + dataset.addValue(4.0, series3, category1); + dataset.addValue(3.0, series3, category2); + dataset.addValue(2.0, series3, category3); + dataset.addValue(3.0, series3, category4); + dataset.addValue(6.0, series3, category5); + + return dataset; + + } + + /** + * Creates a sample chart. + * + * @param dataset the dataset. + * + * @return The chart. + */ + private static JFreeChart createChart(CategoryDataset dataset) { + + // create the chart... + JFreeChart chart = ChartFactory.createBarChart( + "Bar Chart Demo 1", // chart title + "Category", // domain axis label + "Value", // range axis label + dataset, // data + PlotOrientation.VERTICAL, // orientation + true, // include legend + true, // tooltips? + false // URLs? + ); + + // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... + + // set the background color for the chart... + chart.setBackgroundPaint(Color.white); + + // get a reference to the plot for further customisation... + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + + // ****************************************************************** + // More than 150 demo applications are included with the JFreeChart + // Developer Guide...for more information, see: + // + // > http://www.object-refinery.com/jfreechart/guide.html + // + // ****************************************************************** + + // set the range axis to display integers only... + NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + + // disable bar outlines... + BarRenderer renderer = (BarRenderer) plot.getRenderer(); + renderer.setDrawBarOutline(false); + + // set up gradient paints for series... + GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, + 0.0f, 0.0f, new Color(0, 0, 64)); + GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, + 0.0f, 0.0f, new Color(0, 64, 0)); + GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, + 0.0f, 0.0f, new Color(64, 0, 0)); + renderer.setSeriesPaint(0, gp0); + renderer.setSeriesPaint(1, gp1); + renderer.setSeriesPaint(2, gp2); + + CategoryAxis domainAxis = plot.getDomainAxis(); + domainAxis.setCategoryLabelPositions( + CategoryLabelPositions.createUpRotationLabelPositions( + Math.PI / 6.0)); + // OPTIONAL CUSTOMISATION COMPLETED. + + return chart; + + } + + /** + * Starting point for the demonstration application. + * + * @param args ignored. + */ + public static void main(String[] args) { + BarChartDemo1 demo = new BarChartDemo1("Bar Chart Demo 1"); + demo.pack(); + RefineryUtilities.centerFrameOnScreen(demo); + demo.setVisible(true); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/demo/PieChartDemo1.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/demo/PieChartDemo1.java new file mode 100755 index 0000000..a56bf66 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/demo/PieChartDemo1.java @@ -0,0 +1,221 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * PieChartDemo1.java + * ------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): ; + * + * Changes + * ------- + * 09-Mar-2005 : Version 1, copied from the demo collection that ships with + * the JFreeChart Developer Guide (DG); + * + */ + +package org.jfree.chart.demo; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.Point; +import java.awt.RadialGradientPaint; +import java.awt.geom.Point2D; +import javax.swing.JPanel; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.StandardChartTheme; +import org.jfree.chart.plot.PiePlot; +import org.jfree.chart.title.TextTitle; +import org.jfree.data.general.DefaultPieDataset; +import org.jfree.data.general.PieDataset; +import org.jfree.ui.ApplicationFrame; +import org.jfree.ui.HorizontalAlignment; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.RefineryUtilities; + +/** + * A simple demonstration application showing how to create a pie chart using + * data from a {@link DefaultPieDataset}. + */ +public class PieChartDemo1 extends ApplicationFrame { + + private static final long serialVersionUID = 1L; + + { + // set a theme using the new shadow generator feature available in + // 1.0.14 - for backwards compatibility it is not enabled by default + ChartFactory.setChartTheme(new StandardChartTheme("JFree/Shadow", + true)); + } + + /** + * Default constructor. + * + * @param title the frame title. + */ + public PieChartDemo1(String title) { + super(title); + setContentPane(createDemoPanel()); + } + + /** + * Creates a sample dataset. + * + * Source: http://www.bbc.co.uk/news/business-15489523 + * + * @return A sample dataset. + */ + private static PieDataset createDataset() { + DefaultPieDataset dataset = new DefaultPieDataset(); + dataset.setValue("Samsung", new Double(27.8)); + dataset.setValue("Others", new Double(55.3)); + dataset.setValue("Nokia", new Double(16.8)); + dataset.setValue("Apple", new Double(17.1)); + return dataset; + } + + /** + * Creates a chart. + * + * @param dataset the dataset. + * + * @return A chart. + */ + private static JFreeChart createChart(PieDataset dataset) { + + JFreeChart chart = ChartFactory.createPieChart( + "Smart Phones Manufactured / Q3 2011", // chart title + dataset, // data + false, // no legend + true, // tooltips + false // no URL generation + ); + + // set a custom background for the chart + chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), + new Color(20, 20, 20), new Point(400, 200), Color.DARK_GRAY)); + + // customise the title position and font + TextTitle t = chart.getTitle(); + t.setHorizontalAlignment(HorizontalAlignment.LEFT); + t.setPaint(new Color(240, 240, 240)); + t.setFont(new Font("Arial", Font.BOLD, 26)); + + PiePlot plot = (PiePlot) chart.getPlot(); + plot.setBackgroundPaint(null); + plot.setInteriorGap(0.04); + plot.setOutlineVisible(false); + + // use gradients and white borders for the section colours + plot.setSectionPaint("Others", createGradientPaint(new Color(200, 200, 255), Color.BLUE)); + plot.setSectionPaint("Samsung", createGradientPaint(new Color(255, 200, 200), Color.RED)); + plot.setSectionPaint("Apple", createGradientPaint(new Color(200, 255, 200), Color.GREEN)); + plot.setSectionPaint("Nokia", createGradientPaint(new Color(200, 255, 200), Color.YELLOW)); + plot.setBaseSectionOutlinePaint(Color.WHITE); + plot.setSectionOutlinesVisible(true); + plot.setBaseSectionOutlineStroke(new BasicStroke(2.0f)); + + // customise the section label appearance + plot.setLabelFont(new Font("Courier New", Font.BOLD, 20)); + plot.setLabelLinkPaint(Color.WHITE); + plot.setLabelLinkStroke(new BasicStroke(2.0f)); + plot.setLabelOutlineStroke(null); + plot.setLabelPaint(Color.WHITE); + plot.setLabelBackgroundPaint(null); + + // add a subtitle giving the data source + TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", + new Font("Courier New", Font.PLAIN, 12)); + source.setPaint(Color.WHITE); + source.setPosition(RectangleEdge.BOTTOM); + source.setHorizontalAlignment(HorizontalAlignment.RIGHT); + chart.addSubtitle(source); + return chart; + + } + + /** + * A utility method for creating gradient paints. + * + * @param c1 color 1. + * @param c2 color 2. + * + * @return A radial gradient paint. + */ + private static RadialGradientPaint createGradientPaint(Color c1, Color c2) { + Point2D center = new Point2D.Float(0, 0); + float radius = 200; + float[] dist = {0.0f, 1.0f}; + return new RadialGradientPaint(center, radius, dist, + new Color[] {c1, c2}); + } + + /** + * Creates a panel for the demo (used by SuperDemo.java). + * + * @return A panel. + */ + public static JPanel createDemoPanel() { + JFreeChart chart = createChart(createDataset()); + chart.setPadding(new RectangleInsets(4, 8, 2, 2)); + ChartPanel panel = new ChartPanel(chart); + panel.setMouseWheelEnabled(true); + panel.setPreferredSize(new Dimension(600, 300)); + return panel; + } + + /** + * Starting point for the demonstration application. + * + * @param args ignored. + */ + public static void main(String[] args) { + + // ****************************************************************** + // More than 150 demo applications are included with the JFreeChart + // Developer Guide...for more information, see: + // + // > http://www.object-refinery.com/jfreechart/guide.html + // + // ****************************************************************** + + PieChartDemo1 demo = new PieChartDemo1("JFreeChart: Pie Chart Demo 1"); + demo.pack(); + RefineryUtilities.centerFrameOnScreen(demo); + demo.setVisible(true); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/demo/TimeSeriesChartDemo1.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/demo/TimeSeriesChartDemo1.java new file mode 100755 index 0000000..cb74d1c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/demo/TimeSeriesChartDemo1.java @@ -0,0 +1,229 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * TimeSeriesChartDemo1.java + * ------------------------- + * (C) Copyright 2003-2011, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): ; + * + * Changes + * ------- + * 09-Mar-2005 : Version 1, copied from the demo collection that ships with + * the JFreeChart Developer Guide (DG); + * + */ + +package org.jfree.chart.demo; + +import java.awt.Color; +import java.text.SimpleDateFormat; + +import javax.swing.JPanel; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.StandardChartTheme; +import org.jfree.chart.axis.DateAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; +import org.jfree.data.time.Month; +import org.jfree.data.time.TimeSeries; +import org.jfree.data.time.TimeSeriesCollection; +import org.jfree.data.xy.XYDataset; +import org.jfree.ui.ApplicationFrame; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.RefineryUtilities; + +/** + * An example of a time series chart. For the most part, default settings are + * used, except that the renderer is modified to show filled shapes (as well as + * lines) at each data point. + */ +public class TimeSeriesChartDemo1 extends ApplicationFrame { + + private static final long serialVersionUID = 1L; + + { + // set a theme using the new shadow generator feature available in + // 1.0.14 - for backwards compatibility it is not enabled by default + ChartFactory.setChartTheme(new StandardChartTheme("JFree/Shadow", + true)); + } + + /** + * A demonstration application showing how to create a simple time series + * chart. This example uses monthly data. + * + * @param title the frame title. + */ + public TimeSeriesChartDemo1(String title) { + super(title); + ChartPanel chartPanel = (ChartPanel) createDemoPanel(); + chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); + setContentPane(chartPanel); + } + + /** + * Creates a chart. + * + * @param dataset a dataset. + * + * @return A chart. + */ + private static JFreeChart createChart(XYDataset dataset) { + + JFreeChart chart = ChartFactory.createTimeSeriesChart( + "Legal & General Unit Trust Prices", // title + "Date", // x-axis label + "Price Per Unit", // y-axis label + dataset, // data + true, // create legend? + true, // generate tooltips? + false // generate URLs? + ); + + chart.setBackgroundPaint(Color.white); + + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setBackgroundPaint(Color.lightGray); + plot.setDomainGridlinePaint(Color.white); + plot.setRangeGridlinePaint(Color.white); + plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); + plot.setDomainCrosshairVisible(true); + plot.setRangeCrosshairVisible(true); + + XYItemRenderer r = plot.getRenderer(); + if (r instanceof XYLineAndShapeRenderer) { + XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; + renderer.setBaseShapesVisible(true); + renderer.setBaseShapesFilled(true); + renderer.setDrawSeriesLineAsPath(true); + } + + DateAxis axis = (DateAxis) plot.getDomainAxis(); + axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); + + return chart; + + } + + /** + * Creates a dataset, consisting of two series of monthly data. + * + * @return The dataset. + */ + private static XYDataset createDataset() { + + TimeSeries s1 = new TimeSeries("L&G European Index Trust"); + s1.add(new Month(2, 2001), 181.8); + s1.add(new Month(3, 2001), 167.3); + s1.add(new Month(4, 2001), 153.8); + s1.add(new Month(5, 2001), 167.6); + s1.add(new Month(6, 2001), 158.8); + s1.add(new Month(7, 2001), 148.3); + s1.add(new Month(8, 2001), 153.9); + s1.add(new Month(9, 2001), 142.7); + s1.add(new Month(10, 2001), 123.2); + s1.add(new Month(11, 2001), 131.8); + s1.add(new Month(12, 2001), 139.6); + s1.add(new Month(1, 2002), 142.9); + s1.add(new Month(2, 2002), 138.7); + s1.add(new Month(3, 2002), 137.3); + s1.add(new Month(4, 2002), 143.9); + s1.add(new Month(5, 2002), 139.8); + s1.add(new Month(6, 2002), 137.0); + s1.add(new Month(7, 2002), 132.8); + + TimeSeries s2 = new TimeSeries("L&G UK Index Trust"); + s2.add(new Month(2, 2001), 129.6); + s2.add(new Month(3, 2001), 123.2); + s2.add(new Month(4, 2001), 117.2); + s2.add(new Month(5, 2001), 124.1); + s2.add(new Month(6, 2001), 122.6); + s2.add(new Month(7, 2001), 119.2); + s2.add(new Month(8, 2001), 116.5); + s2.add(new Month(9, 2001), 112.7); + s2.add(new Month(10, 2001), 101.5); + s2.add(new Month(11, 2001), 106.1); + s2.add(new Month(12, 2001), 110.3); + s2.add(new Month(1, 2002), 111.7); + s2.add(new Month(2, 2002), 111.0); + s2.add(new Month(3, 2002), 109.6); + s2.add(new Month(4, 2002), 113.2); + s2.add(new Month(5, 2002), 111.6); + s2.add(new Month(6, 2002), 108.8); + s2.add(new Month(7, 2002), 101.6); + + // ****************************************************************** + // More than 150 demo applications are included with the JFreeChart + // Developer Guide...for more information, see: + // + // > http://www.object-refinery.com/jfreechart/guide.html + // + // ****************************************************************** + + TimeSeriesCollection dataset = new TimeSeriesCollection(); + dataset.addSeries(s1); + dataset.addSeries(s2); + + return dataset; + + } + + /** + * Creates a panel for the demo (used by SuperDemo.java). + * + * @return A panel. + */ + public static JPanel createDemoPanel() { + JFreeChart chart = createChart(createDataset()); + ChartPanel panel = new ChartPanel(chart); + panel.setFillZoomRectangle(true); + panel.setMouseWheelEnabled(true); + return panel; + } + + /** + * Starting point for the demonstration application. + * + * @param args ignored. + */ + public static void main(String[] args) { + + TimeSeriesChartDemo1 demo = new TimeSeriesChartDemo1( + "Time Series Chart Demo 1"); + demo.pack(); + RefineryUtilities.centerFrameOnScreen(demo); + demo.setVisible(true); + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/demo/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/demo/package.html new file mode 100755 index 0000000..f751f53 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/demo/package.html @@ -0,0 +1,12 @@ + + + +Some basic demos to get you started. A large range of demo applications is +available for download (including source code) with the JFreeChart Developer +Guide. For more information, see: +

+ + http://www.object-refinery.com/jfreechart/guide.html + + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/ChartEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/ChartEditor.java new file mode 100755 index 0000000..a9a72e3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/ChartEditor.java @@ -0,0 +1,62 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * ChartEditor.java + * ---------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): ; + * + * Changes + * ------- + * 24-Nov-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.editor; + +import javax.swing.JComponent; + +import org.jfree.chart.JFreeChart; + +/** + * A chart editor is typically a {@link JComponent} containing a user interface + * for modifying the properties of a chart. + * + * @see ChartEditorManager#getChartEditor(JFreeChart) + */ +public interface ChartEditor { + + /** + * Applies the changes to the specified chart. + * + * @param chart the chart. + */ + public void updateChart(JFreeChart chart); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/ChartEditorFactory.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/ChartEditorFactory.java new file mode 100755 index 0000000..c0fc50d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/ChartEditorFactory.java @@ -0,0 +1,59 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * ChartEditorFactory.java + * ----------------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): ; + * + * Changes + * ------- + * 28-Nov-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.editor; + +import org.jfree.chart.JFreeChart; + +/** + * A factory for creating new {@link ChartEditor} instances. + */ +public interface ChartEditorFactory { + + /** + * Creates an editor for the given chart. + * + * @param chart the chart. + * + * @return A chart editor. + */ + public ChartEditor createEditor(JFreeChart chart); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/ChartEditorManager.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/ChartEditorManager.java new file mode 100755 index 0000000..22ffb95 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/ChartEditorManager.java @@ -0,0 +1,94 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * ChartEditorManager.java + * ----------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): ; + * + * Changes + * ------- + * 24-Nov-2005 : Version 1 (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.editor; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.util.ParamChecks; + +/** + * The central point for obtaining {@link ChartEditor} instances for editing + * charts. Right now, the API is minimal - the plan is to extend this class + * to provide customisation options for chart editors (for example, make some + * editor items read-only). + */ +public class ChartEditorManager { + + /** This factory creates new {@link ChartEditor} instances as required. */ + static ChartEditorFactory factory = new DefaultChartEditorFactory(); + + /** + * Private constructor prevents instantiation. + */ + private ChartEditorManager() { + // nothing to do + } + + /** + * Returns the current factory. + * + * @return The current factory (never null). + */ + public static ChartEditorFactory getChartEditorFactory() { + return factory; + } + + /** + * Sets the chart editor factory. + * + * @param f the new factory (null not permitted). + */ + public static void setChartEditorFactory(ChartEditorFactory f) { + ParamChecks.nullNotPermitted(f, "f"); + factory = f; + } + + /** + * Returns a component that can be used to edit the given chart. + * + * @param chart the chart. + * + * @return The chart editor. + */ + public static ChartEditor getChartEditor(JFreeChart chart) { + return factory.createEditor(chart); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultAxisEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultAxisEditor.java new file mode 100755 index 0000000..dfc7403 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultAxisEditor.java @@ -0,0 +1,525 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * DefaultAxisEditor.java + * ---------------------- + * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert; + * Contributor(s): Andrzej Porebski; + * Arnaud Lelievre; + * + * Changes + * ------- + * 24-Nov-2005 : Version 1, based on AxisPropertyEditPanel.java (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * + */ + +package org.jfree.chart.editor; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Font; +import java.awt.Paint; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ResourceBundle; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JColorChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; +import javax.swing.JTextField; + +import org.jfree.chart.axis.Axis; +import org.jfree.chart.axis.LogAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.layout.LCBLayout; +import org.jfree.ui.FontChooserPanel; +import org.jfree.ui.FontDisplayField; +import org.jfree.ui.PaintSample; +import org.jfree.ui.RectangleInsets; + +/** + * A panel for editing the properties of an axis. + */ +class DefaultAxisEditor extends JPanel implements ActionListener { + + /** The axis label. */ + private JTextField label; + + /** The label font. */ + private Font labelFont; + + /** The label paint. */ + private PaintSample labelPaintSample; + + /** A field showing a description of the label font. */ + private JTextField labelFontField; + + /** The font for displaying tick labels on the axis. */ + private Font tickLabelFont; + + /** + * A field containing a description of the font for displaying tick labels + * on the axis. + */ + private JTextField tickLabelFontField; + + /** The paint (color) for the tick labels. */ + private PaintSample tickLabelPaintSample; + + /** + * An empty sub-panel for extending the user interface to handle more + * complex axes. + */ + private JPanel slot1; + + /** + * An empty sub-panel for extending the user interface to handle more + * complex axes. + */ + private JPanel slot2; + + /** A flag that indicates whether or not the tick labels are visible. */ + private JCheckBox showTickLabelsCheckBox; + + /** A flag that indicates whether or not the tick marks are visible. */ + private JCheckBox showTickMarksCheckBox; + +// /** Insets text field. */ +// private InsetsTextField tickLabelInsetsTextField; +// +// /** Label insets text field. */ +// private InsetsTextField labelInsetsTextField; + + /** The tick label insets. */ + private RectangleInsets tickLabelInsets; + + /** The label insets. */ + private RectangleInsets labelInsets; + + /** A tabbed pane for... */ + private JTabbedPane otherTabs; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.editor.LocalizationBundle"); + + /** + * A static method that returns a panel that is appropriate for the axis + * type. + * + * @param axis the axis whose properties are to be displayed/edited in + * the panel. + * + * @return A panel or nullnull. + */ + public static DefaultAxisEditor getInstance(Axis axis) { + + if (axis != null) { + // figure out what type of axis we have and instantiate the + // appropriate panel + if (axis instanceof NumberAxis) { + return new DefaultNumberAxisEditor((NumberAxis) axis); + } + if (axis instanceof LogAxis) { + return new DefaultLogAxisEditor((LogAxis) axis); + } + else { + return new DefaultAxisEditor(axis); + } + } + else { + return null; + } + + } + + /** + * Standard constructor: builds a panel for displaying/editing the + * properties of the specified axis. + * + * @param axis the axis whose properties are to be displayed/edited in + * the panel. + */ + public DefaultAxisEditor(Axis axis) { + + this.labelFont = axis.getLabelFont(); + this.labelPaintSample = new PaintSample(axis.getLabelPaint()); + this.tickLabelFont = axis.getTickLabelFont(); + this.tickLabelPaintSample = new PaintSample(axis.getTickLabelPaint()); + + // Insets values + this.tickLabelInsets = axis.getTickLabelInsets(); + this.labelInsets = axis.getLabelInsets(); + + setLayout(new BorderLayout()); + + JPanel general = new JPanel(new BorderLayout()); + general.setBorder( + BorderFactory.createTitledBorder( + BorderFactory.createEtchedBorder(), + localizationResources.getString("General") + ) + ); + + JPanel interior = new JPanel(new LCBLayout(5)); + interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); + interior.add(new JLabel(localizationResources.getString("Label"))); + this.label = new JTextField(axis.getLabel()); + interior.add(this.label); + interior.add(new JPanel()); + + interior.add(new JLabel(localizationResources.getString("Font"))); + this.labelFontField = new FontDisplayField(this.labelFont); + interior.add(this.labelFontField); + JButton b = new JButton(localizationResources.getString("Select...")); + b.setActionCommand("SelectLabelFont"); + b.addActionListener(this); + interior.add(b); + + interior.add(new JLabel(localizationResources.getString("Paint"))); + interior.add(this.labelPaintSample); + b = new JButton(localizationResources.getString("Select...")); + b.setActionCommand("SelectLabelPaint"); + b.addActionListener(this); + interior.add(b); + +// interior.add( +// new JLabel(localizationResources.getString("Label_Insets")) +// ); +// b = new JButton(localizationResources.getString("Edit...")); +// b.setActionCommand("LabelInsets"); +// b.addActionListener(this); +// this.labelInsetsTextField = new InsetsTextField(this.labelInsets); +// interior.add(this.labelInsetsTextField); +// interior.add(b); +// +// interior.add( +// new JLabel(localizationResources.getString("Tick_Label_Insets")) +// ); +// b = new JButton(localizationResources.getString("Edit...")); +// b.setActionCommand("TickLabelInsets"); +// b.addActionListener(this); +// this.tickLabelInsetsTextField +// = new InsetsTextField(this.tickLabelInsets); +// interior.add(this.tickLabelInsetsTextField); +// interior.add(b); + + general.add(interior); + + add(general, BorderLayout.NORTH); + + this.slot1 = new JPanel(new BorderLayout()); + + JPanel other = new JPanel(new BorderLayout()); + other.setBorder(BorderFactory.createTitledBorder( + BorderFactory.createEtchedBorder(), + localizationResources.getString("Other"))); + + this.otherTabs = new JTabbedPane(); + this.otherTabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); + + JPanel ticks = new JPanel(new LCBLayout(3)); + ticks.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); + + this.showTickLabelsCheckBox = new JCheckBox( + localizationResources.getString("Show_tick_labels"), + axis.isTickLabelsVisible() + ); + ticks.add(this.showTickLabelsCheckBox); + ticks.add(new JPanel()); + ticks.add(new JPanel()); + + ticks.add( + new JLabel(localizationResources.getString("Tick_label_font")) + ); + this.tickLabelFontField = new FontDisplayField(this.tickLabelFont); + ticks.add(this.tickLabelFontField); + b = new JButton(localizationResources.getString("Select...")); + b.setActionCommand("SelectTickLabelFont"); + b.addActionListener(this); + ticks.add(b); + + this.showTickMarksCheckBox = new JCheckBox( + localizationResources.getString("Show_tick_marks"), + axis.isTickMarksVisible() + ); + ticks.add(this.showTickMarksCheckBox); + ticks.add(new JPanel()); + ticks.add(new JPanel()); + + this.otherTabs.add(localizationResources.getString("Ticks"), ticks); + + other.add(this.otherTabs); + + this.slot1.add(other); + + this.slot2 = new JPanel(new BorderLayout()); + this.slot2.add(this.slot1, BorderLayout.NORTH); + add(this.slot2); + + } + + /** + * Returns the current axis label. + * + * @return The current axis label. + */ + public String getLabel() { + return this.label.getText(); + } + + /** + * Returns the current label font. + * + * @return The current label font. + */ + public Font getLabelFont() { + return this.labelFont; + } + + /** + * Returns the current label paint. + * + * @return The current label paint. + */ + public Paint getLabelPaint() { + return this.labelPaintSample.getPaint(); + } + + /** + * Returns a flag that indicates whether or not the tick labels are visible. + * + * @return true if ick mark labels are visible. + */ + public boolean isTickLabelsVisible() { + return this.showTickLabelsCheckBox.isSelected(); + } + + /** + * Returns the font used to draw the tick labels (if they are showing). + * + * @return The font used to draw the tick labels. + */ + public Font getTickLabelFont() { + return this.tickLabelFont; + } + + /** + * Returns the current tick label paint. + * + * @return The current tick label paint. + */ + public Paint getTickLabelPaint() { + return this.tickLabelPaintSample.getPaint(); + } + + /** + * Returns the current value of the flag that determines whether or not + * tick marks are visible. + * + * @return true if tick marks are visible. + */ + public boolean isTickMarksVisible() { + return this.showTickMarksCheckBox.isSelected(); + } + + /** + * Returns the current tick label insets value + * + * @return The current tick label insets value. + */ + public RectangleInsets getTickLabelInsets() { + return (this.tickLabelInsets == null) + ? new RectangleInsets(0, 0, 0, 0) + : this.tickLabelInsets; + } + + /** + * Returns the current label insets value + * + * @return The current label insets value. + */ + public RectangleInsets getLabelInsets() { + return (this.labelInsets == null) + ? new RectangleInsets(0, 0, 0, 0) : this.labelInsets; + } + + /** + * Returns a reference to the tabbed pane. + * + * @return A reference to the tabbed pane. + */ + public JTabbedPane getOtherTabs() { + return this.otherTabs; + } + + /** + * Handles user interaction with the property panel. + * + * @param event information about the event that triggered the call to + * this method. + */ + @Override + public void actionPerformed(ActionEvent event) { + String command = event.getActionCommand(); + if (command.equals("SelectLabelFont")) { + attemptLabelFontSelection(); + } + else if (command.equals("SelectLabelPaint")) { + attemptModifyLabelPaint(); + } + else if (command.equals("SelectTickLabelFont")) { + attemptTickLabelFontSelection(); + } +// else if (command.equals("LabelInsets")) { +// editLabelInsets(); +// } +// else if (command.equals("TickLabelInsets")) { +// editTickLabelInsets(); +// } + } + + /** + * Presents a font selection dialog to the user. + */ + private void attemptLabelFontSelection() { + + FontChooserPanel panel = new FontChooserPanel(this.labelFont); + int result = JOptionPane.showConfirmDialog(this, panel, + localizationResources.getString("Font_Selection"), + JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); + + if (result == JOptionPane.OK_OPTION) { + this.labelFont = panel.getSelectedFont(); + this.labelFontField.setText( + this.labelFont.getFontName() + " " + this.labelFont.getSize() + ); + } + + } + + /** + * Allows the user the opportunity to change the outline paint. + */ + private void attemptModifyLabelPaint() { + Color c; + c = JColorChooser.showDialog( + this, localizationResources.getString("Label_Color"), Color.blue + ); + if (c != null) { + this.labelPaintSample.setPaint(c); + } + } + + /** + * Presents a tick label font selection dialog to the user. + */ + public void attemptTickLabelFontSelection() { + + FontChooserPanel panel = new FontChooserPanel(this.tickLabelFont); + int result = JOptionPane.showConfirmDialog(this, panel, + localizationResources.getString("Font_Selection"), + JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); + + if (result == JOptionPane.OK_OPTION) { + this.tickLabelFont = panel.getSelectedFont(); + this.tickLabelFontField.setText( + this.tickLabelFont.getFontName() + " " + + this.tickLabelFont.getSize() + ); + } + + } + +// /** +// * Presents insets chooser panel allowing user to modify tick label's +// * individual insets values. Updates the current insets text field if +// * edit is accepted. +// */ +// private void editTickLabelInsets() { +// InsetsChooserPanel panel = new InsetsChooserPanel( +// this.tickLabelInsets); +// int result = JOptionPane.showConfirmDialog( +// this, panel, localizationResources.getString("Edit_Insets"), +// JOptionPane.PLAIN_MESSAGE +// ); +// +// if (result == JOptionPane.OK_OPTION) { +// this.tickLabelInsets = panel.getInsets(); +// this.tickLabelInsetsTextField.setInsets(this.tickLabelInsets); +// } +// } +// +// /** +// * Presents insets chooser panel allowing user to modify label's +// * individual insets values. Updates the current insets text field if edit +// * is accepted. +// */ +// private void editLabelInsets() { +// InsetsChooserPanel panel = new InsetsChooserPanel(this.labelInsets); +// int result = JOptionPane.showConfirmDialog( +// this, panel, localizationResources.getString("Edit_Insets"), +// JOptionPane.PLAIN_MESSAGE +// ); +// +// if (result == JOptionPane.OK_OPTION) { +// this.labelInsets = panel.getInsets(); +// this.labelInsetsTextField.setInsets(this.labelInsets); +// } +// } + + /** + * Sets the properties of the specified axis to match the properties + * defined on this panel. + * + * @param axis the axis. + */ + public void setAxisProperties(Axis axis) { + axis.setLabel(getLabel()); + axis.setLabelFont(getLabelFont()); + axis.setLabelPaint(getLabelPaint()); + axis.setTickMarksVisible(isTickMarksVisible()); + // axis.setTickMarkStroke(getTickMarkStroke()); + axis.setTickLabelsVisible(isTickLabelsVisible()); + axis.setTickLabelFont(getTickLabelFont()); + axis.setTickLabelPaint(getTickLabelPaint()); + axis.setTickLabelInsets(getTickLabelInsets()); + axis.setLabelInsets(getLabelInsets()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultChartEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultChartEditor.java new file mode 100755 index 0000000..65fa7f7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultChartEditor.java @@ -0,0 +1,277 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * DefaultChartEditor.java + * ----------------------- + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Arnaud Lelievre; + * Daniel Gredler; + * + * Changes + * ------- + * 24-Nov-2005 : New class, based on ChartPropertyEditPanel.java (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * + */ + +package org.jfree.chart.editor; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Paint; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ResourceBundle; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JColorChooser; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; +import javax.swing.JTextField; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PolarPlot; +import org.jfree.chart.title.Title; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.layout.LCBLayout; +import org.jfree.ui.PaintSample; + +/** + * A panel for editing chart properties (includes subpanels for the title, + * legend and plot). + */ +class DefaultChartEditor extends JPanel implements ActionListener, ChartEditor { + + /** A panel for displaying/editing the properties of the title. */ + private DefaultTitleEditor titleEditor; + + /** A panel for displaying/editing the properties of the plot. */ + private DefaultPlotEditor plotEditor; + + /** + * A checkbox indicating whether or not the chart is drawn with + * anti-aliasing. + */ + private JCheckBox antialias; + + /** The chart background color. */ + private PaintSample background; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.editor.LocalizationBundle"); + + /** + * Standard constructor - the property panel is made up of a number of + * sub-panels that are displayed in the tabbed pane. + * + * @param chart the chart, whichs properties should be changed. + */ + public DefaultChartEditor(JFreeChart chart) { + setLayout(new BorderLayout()); + + JPanel other = new JPanel(new BorderLayout()); + other.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); + + JPanel general = new JPanel(new BorderLayout()); + general.setBorder(BorderFactory.createTitledBorder( + BorderFactory.createEtchedBorder(), + localizationResources.getString("General"))); + + JPanel interior = new JPanel(new LCBLayout(6)); + interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); + + this.antialias = new JCheckBox(localizationResources.getString( + "Draw_anti-aliased")); + this.antialias.setSelected(chart.getAntiAlias()); + interior.add(this.antialias); + interior.add(new JLabel("")); + interior.add(new JLabel("")); + interior.add(new JLabel(localizationResources.getString( + "Background_paint"))); + this.background = new PaintSample(chart.getBackgroundPaint()); + interior.add(this.background); + JButton button = new JButton(localizationResources.getString( + "Select...")); + button.setActionCommand("BackgroundPaint"); + button.addActionListener(this); + interior.add(button); + + interior.add(new JLabel(localizationResources.getString( + "Series_Paint"))); + JTextField info = new JTextField(localizationResources.getString( + "No_editor_implemented")); + info.setEnabled(false); + interior.add(info); + button = new JButton(localizationResources.getString("Edit...")); + button.setEnabled(false); + interior.add(button); + + interior.add(new JLabel(localizationResources.getString( + "Series_Stroke"))); + info = new JTextField(localizationResources.getString( + "No_editor_implemented")); + info.setEnabled(false); + interior.add(info); + button = new JButton(localizationResources.getString("Edit...")); + button.setEnabled(false); + interior.add(button); + + interior.add(new JLabel(localizationResources.getString( + "Series_Outline_Paint"))); + info = new JTextField(localizationResources.getString( + "No_editor_implemented")); + info.setEnabled(false); + interior.add(info); + button = new JButton(localizationResources.getString("Edit...")); + button.setEnabled(false); + interior.add(button); + + interior.add(new JLabel(localizationResources.getString( + "Series_Outline_Stroke"))); + info = new JTextField(localizationResources.getString( + "No_editor_implemented")); + info.setEnabled(false); + interior.add(info); + button = new JButton(localizationResources.getString("Edit...")); + button.setEnabled(false); + interior.add(button); + + general.add(interior, BorderLayout.NORTH); + other.add(general, BorderLayout.NORTH); + + JPanel parts = new JPanel(new BorderLayout()); + + Title title = chart.getTitle(); + Plot plot = chart.getPlot(); + + JTabbedPane tabs = new JTabbedPane(); + + this.titleEditor = new DefaultTitleEditor(title); + this.titleEditor.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); + tabs.addTab(localizationResources.getString("Title"), this.titleEditor); + + if (plot instanceof PolarPlot) { + this.plotEditor = new DefaultPolarPlotEditor((PolarPlot) plot); + } + else { + this.plotEditor = new DefaultPlotEditor(plot); + } + this.plotEditor.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); + tabs.addTab(localizationResources.getString("Plot"), this.plotEditor); + + tabs.add(localizationResources.getString("Other"), other); + parts.add(tabs, BorderLayout.NORTH); + add(parts); + } + + /** + * Returns a reference to the title editor. + * + * @return A panel for editing the title. + */ + public DefaultTitleEditor getTitleEditor() { + return this.titleEditor; + } + + /** + * Returns a reference to the plot property sub-panel. + * + * @return A panel for editing the plot properties. + */ + public DefaultPlotEditor getPlotEditor() { + return this.plotEditor; + } + + /** + * Returns the current setting of the anti-alias flag. + * + * @return true if anti-aliasing is enabled. + */ + public boolean getAntiAlias() { + return this.antialias.isSelected(); + } + + /** + * Returns the current background paint. + * + * @return The current background paint. + */ + public Paint getBackgroundPaint() { + return this.background.getPaint(); + } + + /** + * Handles user interactions with the panel. + * + * @param event a BackgroundPaint action. + */ + @Override + public void actionPerformed(ActionEvent event) { + String command = event.getActionCommand(); + if (command.equals("BackgroundPaint")) { + attemptModifyBackgroundPaint(); + } + } + + /** + * Allows the user the opportunity to select a new background paint. Uses + * JColorChooser, so we are only allowing a subset of all Paint objects to + * be selected (fix later). + */ + private void attemptModifyBackgroundPaint() { + Color c; + c = JColorChooser.showDialog(this, localizationResources.getString( + "Background_Color"), Color.blue); + if (c != null) { + this.background.setPaint(c); + } + } + + /** + * Updates the properties of a chart to match the properties defined on the + * panel. + * + * @param chart the chart. + */ + @Override + public void updateChart(JFreeChart chart) { + this.titleEditor.setTitleProperties(chart); + this.plotEditor.updatePlotProperties(chart.getPlot()); + chart.setAntiAlias(getAntiAlias()); + chart.setBackgroundPaint(getBackgroundPaint()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultChartEditorFactory.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultChartEditorFactory.java new file mode 100755 index 0000000..be50a7f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultChartEditorFactory.java @@ -0,0 +1,68 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * DefaultChartEditorFactory.java + * ------------------------------ + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): ; + * + * Changes + * ------- + * 28-Nov-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.editor; + +import org.jfree.chart.JFreeChart; + +/** + * A default implementation of the {@link ChartEditorFactory} interface. + */ +public class DefaultChartEditorFactory implements ChartEditorFactory { + + /** + * Creates a new instance. + */ + public DefaultChartEditorFactory() { + } + + /** + * Returns a new instance of a {@link ChartEditor}. + * + * @param chart the chart. + * + * @return A chart editor for the given chart. + */ + @Override + public ChartEditor createEditor(JFreeChart chart) { + return new DefaultChartEditor(chart); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultColorBarEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultColorBarEditor.java new file mode 100755 index 0000000..665a2d9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultColorBarEditor.java @@ -0,0 +1,230 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * DefaultColorBarEditor.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); + * Arnaud Lelievre; + * + * Changes + * ------- + * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG); + * 08-Sep-2003 : Added internationalization via use of properties + * resourceBundle (RFE 690236) (AL); + * 24-Nov-2005 : Moved and renamed: org.jfree.chart.ui.ColorBarPropertyEditPanel + * --> DefaultColorBarEditor (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * + */ + +package org.jfree.chart.editor; + +import java.awt.event.ActionEvent; +import java.util.ResourceBundle; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; + +import org.jfree.chart.axis.ColorBar; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.GreyPalette; +import org.jfree.chart.plot.RainbowPalette; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.layout.LCBLayout; + +/** + * A DefaultColorBarEditor. Extends DefaultNumberAxisEditor to allow + * change general axis type parameters. + */ +class DefaultColorBarEditor extends DefaultNumberAxisEditor { + + /** + * A checkbox that indicates whether or not the color indices should run + * high to low. + */ + private JCheckBox invertPaletteCheckBox; + + /** Flag set by invertPaletteCheckBox. */ + private boolean invertPalette = false; + + /** A checkbox that indicates whether the palette is stepped. */ + private JCheckBox stepPaletteCheckBox; + + /** Flag set by stepPaletteCheckBox. */ + private boolean stepPalette = false; + + /** The Palette Sample displaying the current Palette. */ + private PaletteSample currentPalette; + + /** An array of availiable sample palettes. */ + private PaletteSample[] availablePaletteSamples; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.editor.LocalizationBundle"); + + /** + * Creates a new edit panel for a color bar. + * + * @param colorBar the color bar. + */ + public DefaultColorBarEditor(ColorBar colorBar) { + super((NumberAxis) colorBar.getAxis()); + this.invertPalette = colorBar.getColorPalette().isInverse(); + this.stepPalette = colorBar.getColorPalette().isStepped(); + this.currentPalette = new PaletteSample(colorBar.getColorPalette()); + this.availablePaletteSamples = new PaletteSample[2]; + this.availablePaletteSamples[0] + = new PaletteSample(new RainbowPalette()); + this.availablePaletteSamples[1] + = new PaletteSample(new GreyPalette()); + + JTabbedPane other = getOtherTabs(); + + JPanel palettePanel = new JPanel(new LCBLayout(4)); + palettePanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); + + palettePanel.add(new JPanel()); + this.invertPaletteCheckBox = new JCheckBox( + localizationResources.getString("Invert_Palette"), + this.invertPalette + ); + this.invertPaletteCheckBox.setActionCommand("invertPalette"); + this.invertPaletteCheckBox.addActionListener(this); + palettePanel.add(this.invertPaletteCheckBox); + palettePanel.add(new JPanel()); + + palettePanel.add(new JPanel()); + this.stepPaletteCheckBox = new JCheckBox( + localizationResources.getString("Step_Palette"), + this.stepPalette + ); + this.stepPaletteCheckBox.setActionCommand("stepPalette"); + this.stepPaletteCheckBox.addActionListener(this); + palettePanel.add(this.stepPaletteCheckBox); + palettePanel.add(new JPanel()); + + palettePanel.add( + new JLabel(localizationResources.getString("Palette")) + ); + JButton button + = new JButton(localizationResources.getString("Set_palette...")); + button.setActionCommand("PaletteChoice"); + button.addActionListener(this); + palettePanel.add(this.currentPalette); + palettePanel.add(button); + + other.add(localizationResources.getString("Palette"), palettePanel); + + } + + /** + * Handles actions from within the property panel. + * + * @param event the event. + */ + @Override + public void actionPerformed(ActionEvent event) { + String command = event.getActionCommand(); + if (command.equals("PaletteChoice")) { + attemptPaletteSelection(); + } + else if (command.equals("invertPalette")) { + this.invertPalette = this.invertPaletteCheckBox.isSelected(); + } + else if (command.equals("stepPalette")) { + this.stepPalette = this.stepPaletteCheckBox.isSelected(); + } + else { + super.actionPerformed(event); // pass to super-class for handling + } + } + + /** + * Handle a palette selection. + */ + private void attemptPaletteSelection() { + PaletteChooserPanel panel + = new PaletteChooserPanel(null, this.availablePaletteSamples); + int result = JOptionPane.showConfirmDialog( + this, panel, localizationResources.getString("Palette_Selection"), + JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE + ); + + if (result == JOptionPane.OK_OPTION) { + double zmin = this.currentPalette.getPalette().getMinZ(); + double zmax = this.currentPalette.getPalette().getMaxZ(); + this.currentPalette.setPalette(panel.getSelectedPalette()); + this.currentPalette.getPalette().setMinZ(zmin); + this.currentPalette.getPalette().setMaxZ(zmax); + } + } + + /** + * Sets the properties of the specified axis to match the properties + * defined on this panel. + * + * @param colorBar the color bar. + */ + public void setAxisProperties(ColorBar colorBar) { + super.setAxisProperties(colorBar.getAxis()); + colorBar.setColorPalette(this.currentPalette.getPalette()); + colorBar.getColorPalette().setInverse(this.invertPalette); //dmo added + colorBar.getColorPalette().setStepped(this.stepPalette); //dmo added + } + + /** + * A static method that returns a panel that is appropriate for the axis + * type. + * + * @param colorBar the color bar. + * + * @return A panel or nullnull. + */ + public static DefaultColorBarEditor getInstance(ColorBar colorBar) { + + if (colorBar != null) { + return new DefaultColorBarEditor(colorBar); + } + else { + return null; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultLogAxisEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultLogAxisEditor.java new file mode 100755 index 0000000..595b5dc --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultLogAxisEditor.java @@ -0,0 +1,169 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * DefaultLogAxisEditor.java + * ------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: Martin Hoeller; + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2011 : Version 1 (MH); + * + */ + +package org.jfree.chart.editor; + +import java.awt.event.ActionEvent; +import java.awt.event.FocusEvent; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.jfree.chart.axis.Axis; +import org.jfree.chart.axis.LogAxis; +import org.jfree.chart.axis.NumberTickUnit; + +/** + * A panel for editing properties of a {@link LogAxis}. + */ +public class DefaultLogAxisEditor extends DefaultValueAxisEditor { + + private double manualTickUnitValue; + + private JTextField manualTickUnit; + + /** + * Standard constructor: builds a property panel for the specified axis. + * + * @param axis the axis, which should be changed. + */ + public DefaultLogAxisEditor(LogAxis axis) { + super(axis); + this.manualTickUnitValue = axis.getTickUnit().getSize(); + manualTickUnit.setText(Double.toString(this.manualTickUnitValue)); + } + + /** + * Creates a panel for editing the tick unit. + * + * @return A panel. + */ + @Override + protected JPanel createTickUnitPanel() { + JPanel tickUnitPanel = super.createTickUnitPanel(); + + tickUnitPanel.add(new JLabel(localizationResources.getString( + "Manual_TickUnit_value"))); + this.manualTickUnit = new JTextField(Double.toString( + this.manualTickUnitValue)); + this.manualTickUnit.setEnabled(!isAutoTickUnitSelection()); + this.manualTickUnit.setActionCommand("TickUnitValue"); + this.manualTickUnit.addActionListener(this); + this.manualTickUnit.addFocusListener(this); + tickUnitPanel.add(this.manualTickUnit); + tickUnitPanel.add(new JPanel()); + + return tickUnitPanel; + } + + /** + * Handles actions from within the property panel. + * + * @param event an event. + */ + @Override + public void actionPerformed(ActionEvent event) { + String command = event.getActionCommand(); + if (command.equals("TickUnitValue")) { + validateTickUnit(); + } + else { + // pass to the super-class for handling + super.actionPerformed(event); + } + } + + @Override + public void focusLost(FocusEvent event) { + super.focusLost(event); + if (event.getSource() == this.manualTickUnit) { + validateTickUnit(); + } + } + + /** + * Toggles the auto-tick-unit setting. + */ + @Override + public void toggleAutoTick() { + super.toggleAutoTick(); + if (isAutoTickUnitSelection()) { + this.manualTickUnit.setText(Double.toString(this.manualTickUnitValue)); + this.manualTickUnit.setEnabled(false); + } + else { + this.manualTickUnit.setEnabled(true); + } + } + + /** + * Validates the tick unit entered. + */ + public void validateTickUnit() { + double newTickUnit; + try { + newTickUnit = Double.parseDouble(this.manualTickUnit.getText()); + } + catch (NumberFormatException e) { + newTickUnit = this.manualTickUnitValue; + } + + if (newTickUnit > 0.0) { + this.manualTickUnitValue = newTickUnit; + } + this.manualTickUnit.setText(Double.toString(this.manualTickUnitValue)); + } + + /** + * Sets the properties of the specified axis to match the properties + * defined on this panel. + * + * @param axis the axis. + */ + @Override + public void setAxisProperties(Axis axis) { + super.setAxisProperties(axis); + LogAxis logAxis = (LogAxis) axis; + if (!isAutoTickUnitSelection()) { + logAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue)); + } + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultNumberAxisEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultNumberAxisEditor.java new file mode 100755 index 0000000..33f9616 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultNumberAxisEditor.java @@ -0,0 +1,180 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * DefaultNumberAxisEditor.java + * ---------------------------- + * (C) Copyright 2005-2009, Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Arnaud Lelievre; + * + * Changes: + * -------- + * 24-Nov-2005 : Version 1, based on NumberAxisPropertyEditor (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 27-Feb-2009 : Fixed bug 2612649, NullPointerException (DG); + * 03-Nov-2011 : Refactoring to use new DefaultValueAxisEditor (MH); + */ + +package org.jfree.chart.editor; + +import java.awt.event.ActionEvent; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; + +import javax.swing.BorderFactory; +import javax.swing.JCheckBox; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.jfree.chart.axis.Axis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.NumberTickUnit; +import org.jfree.layout.LCBLayout; + +/** + * A panel for editing the properties of a value axis. + */ +class DefaultNumberAxisEditor extends DefaultValueAxisEditor + implements FocusListener { + + private double manualTickUnitValue; + + private JTextField manualTickUnit; + + + /** + * Standard constructor: builds a property panel for the specified axis. + * + * @param axis the axis, which should be changed. + */ + public DefaultNumberAxisEditor(NumberAxis axis) { + + super(axis); + + this.manualTickUnitValue = axis.getTickUnit().getSize(); + validateTickUnit(); + } + + @Override + protected JPanel createTickUnitPanel() + { + JPanel tickUnitPanel = new JPanel(new LCBLayout(3)); + tickUnitPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); + + tickUnitPanel.add(new JPanel()); + JCheckBox autoTickUnitSelectionCheckBox = new JCheckBox( + localizationResources.getString("Auto-TickUnit_Selection"), + isAutoTickUnitSelection()); + autoTickUnitSelectionCheckBox.setActionCommand("AutoTickOnOff"); + autoTickUnitSelectionCheckBox.addActionListener(this); + setAutoTickUnitSelectionCheckBox(autoTickUnitSelectionCheckBox); + tickUnitPanel.add(getAutoTickUnitSelectionCheckBox()); + tickUnitPanel.add(new JPanel()); + + tickUnitPanel.add(new JLabel(localizationResources.getString( + "Manual_TickUnit_value"))); + this.manualTickUnit = new JTextField(Double.toString( + this.manualTickUnitValue)); + this.manualTickUnit.setEnabled(!isAutoTickUnitSelection()); + this.manualTickUnit.setActionCommand("TickUnitValue"); + this.manualTickUnit.addActionListener(this); + this.manualTickUnit.addFocusListener(this); + tickUnitPanel.add(this.manualTickUnit); + tickUnitPanel.add(new JPanel()); + + return tickUnitPanel; + } + + /** + * Handles actions from within the property panel. + * @param event an event. + */ + @Override + public void actionPerformed(ActionEvent event) { + String command = event.getActionCommand(); + if (command.equals("TickUnitValue")) { + validateTickUnit(); + } + else { + // pass to the super-class for handling + super.actionPerformed(event); + } + } + + @Override + public void focusLost(FocusEvent event) { + super.focusLost(event); + if (event.getSource() == this.manualTickUnit) { + validateTickUnit(); + } + } + + @Override + public void toggleAutoTick() { + super.toggleAutoTick(); + if (isAutoTickUnitSelection()) { + this.manualTickUnit.setText(Double.toString(this.manualTickUnitValue)); + this.manualTickUnit.setEnabled(false); + } + else { + this.manualTickUnit.setEnabled(true); + } + } + + public void validateTickUnit() { + double newTickUnit; + try { + newTickUnit = Double.parseDouble(this.manualTickUnit.getText()); + } + catch (NumberFormatException e) { + newTickUnit = this.manualTickUnitValue; + } + + if (newTickUnit > 0.0) { + this.manualTickUnitValue = newTickUnit; + } + this.manualTickUnit.setText(Double.toString(this.manualTickUnitValue)); + } + + /** + * Sets the properties of the specified axis to match the properties + * defined on this panel. + * + * @param axis the axis. + */ + @Override + public void setAxisProperties(Axis axis) { + super.setAxisProperties(axis); + NumberAxis numberAxis = (NumberAxis) axis; + if (!isAutoTickUnitSelection()) { + numberAxis.setTickUnit(new NumberTickUnit(manualTickUnitValue)); + } + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultPlotEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultPlotEditor.java new file mode 100755 index 0000000..9a2554e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultPlotEditor.java @@ -0,0 +1,676 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * DefaultPlotEditor.java + * ---------------------- + * (C) Copyright 2005-2009, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Andrzej Porebski; + * Arnaud Lelievre; + * Daniel Gredler; + * + * Changes: + * -------- + * 24-Nov-2005 : Version 1, based on PlotPropertyEditPanel.java (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 27-Feb-2009 : Fixed bug 2612649, NullPointerException (DG); + * 03-Nov-2011 : Added support for DefaultPolarPlotEditor (MH); + * + */ + +package org.jfree.chart.editor; + +import java.awt.BasicStroke; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Paint; +import java.awt.Stroke; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ResourceBundle; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JColorChooser; +import javax.swing.JComboBox; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; + +import org.jfree.chart.axis.Axis; +import org.jfree.chart.axis.ColorBar; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.ContourPlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PolarPlot; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.renderer.category.LineAndShapeRenderer; +import org.jfree.chart.renderer.xy.StandardXYItemRenderer; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.layout.LCBLayout; +import org.jfree.ui.PaintSample; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.StrokeChooserPanel; +import org.jfree.ui.StrokeSample; +import org.jfree.util.BooleanUtilities; + +/** + * A panel for editing the properties of a {@link Plot}. + */ +class DefaultPlotEditor extends JPanel implements ActionListener { + + /** Orientation constants. */ + private final static String[] orientationNames = {"Vertical", "Horizontal"}; + private final static int ORIENTATION_VERTICAL = 0; + private final static int ORIENTATION_HORIZONTAL = 1; + + /** The paint (color) used to fill the background of the plot. */ + private PaintSample backgroundPaintSample; + + /** The stroke used to draw the outline of the plot. */ + private StrokeSample outlineStrokeSample; + + /** The paint (color) used to draw the outline of the plot. */ + private PaintSample outlinePaintSample; + + /** + * A panel used to display/edit the properties of the domain axis (if any). + */ + private DefaultAxisEditor domainAxisPropertyPanel; + + /** + * A panel used to display/edit the properties of the range axis (if any). + */ + private DefaultAxisEditor rangeAxisPropertyPanel; + + /** + * A panel used to display/edit the properties of the colorbar axis (if + * any). + */ + private DefaultColorBarEditor colorBarAxisPropertyPanel; + + /** An array of stroke samples to choose from. */ + private StrokeSample[] availableStrokeSamples; + + /** The insets for the plot. */ + private RectangleInsets plotInsets; + + /** + * The orientation for the plot (for CategoryPlots and + * XYPlots). + */ + private PlotOrientation plotOrientation; + + /** + * The orientation combo box (for CategoryPlots and + * XYPlots). + */ + private JComboBox orientationCombo; + + /** Whether or not to draw lines between each data point (for + * LineAndShapeRenderers and StandardXYItemRenderers). + */ + private Boolean drawLines; + + /** + * The checkbox for whether or not to draw lines between each data point. + */ + private JCheckBox drawLinesCheckBox; + + /** Whether or not to draw shapes at each data point (for + * LineAndShapeRenderers and StandardXYItemRenderers). + */ + private Boolean drawShapes; + + /** + * The checkbox for whether or not to draw shapes at each data point. + */ + private JCheckBox drawShapesCheckBox; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.editor.LocalizationBundle"); + + /** + * Standard constructor - constructs a panel for editing the properties of + * the specified plot. + *

+ * In designing the panel, we need to be aware that subclasses of Plot will + * need to implement subclasses of PlotPropertyEditPanel - so we need to + * leave one or two 'slots' where the subclasses can extend the user + * interface. + * + * @param plot the plot, which should be changed. + */ + public DefaultPlotEditor(Plot plot) { + JPanel panel = createPlotPanel(plot); + add(panel); + } + + protected JPanel createPlotPanel(Plot plot) { + this.plotInsets = plot.getInsets(); + this.backgroundPaintSample = new PaintSample(plot.getBackgroundPaint()); + this.outlineStrokeSample = new StrokeSample(plot.getOutlineStroke()); + this.outlinePaintSample = new PaintSample(plot.getOutlinePaint()); + if (plot instanceof CategoryPlot) { + this.plotOrientation = ((CategoryPlot) plot).getOrientation(); + } + else if (plot instanceof XYPlot) { + this.plotOrientation = ((XYPlot) plot).getOrientation(); + } + if (plot instanceof CategoryPlot) { + CategoryItemRenderer renderer = ((CategoryPlot) plot).getRenderer(); + if (renderer instanceof LineAndShapeRenderer) { + LineAndShapeRenderer r = (LineAndShapeRenderer) renderer; + this.drawLines = BooleanUtilities.valueOf( + r.getBaseLinesVisible()); + this.drawShapes = BooleanUtilities.valueOf( + r.getBaseShapesVisible()); + } + } + else if (plot instanceof XYPlot) { + XYItemRenderer renderer = ((XYPlot) plot).getRenderer(); + if (renderer instanceof StandardXYItemRenderer) { + StandardXYItemRenderer r = (StandardXYItemRenderer) renderer; + this.drawLines = BooleanUtilities.valueOf(r.getPlotLines()); + this.drawShapes = BooleanUtilities.valueOf( + r.getBaseShapesVisible()); + } + } + + setLayout(new BorderLayout()); + + this.availableStrokeSamples = new StrokeSample[4]; + this.availableStrokeSamples[0] = new StrokeSample(null); + this.availableStrokeSamples[1] = new StrokeSample( + new BasicStroke(1.0f)); + this.availableStrokeSamples[2] = new StrokeSample( + new BasicStroke(2.0f)); + this.availableStrokeSamples[3] = new StrokeSample( + new BasicStroke(3.0f)); + + // create a panel for the settings... + JPanel panel = new JPanel(new BorderLayout()); + panel.setBorder(BorderFactory.createTitledBorder( + BorderFactory.createEtchedBorder(), plot.getPlotType() + + localizationResources.getString(":"))); + + JPanel general = new JPanel(new BorderLayout()); + general.setBorder(BorderFactory.createTitledBorder( + localizationResources.getString("General"))); + + JPanel interior = new JPanel(new LCBLayout(7)); + interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); + +// interior.add(new JLabel(localizationResources.getString("Insets"))); +// JButton button = new JButton( +// localizationResources.getString("Edit...") +// ); +// button.setActionCommand("Insets"); +// button.addActionListener(this); +// +// this.insetsTextField = new InsetsTextField(this.plotInsets); +// this.insetsTextField.setEnabled(false); +// interior.add(this.insetsTextField); +// interior.add(button); + + interior.add(new JLabel(localizationResources.getString( + "Outline_stroke"))); + JButton button = new JButton(localizationResources.getString( + "Select...")); + button.setActionCommand("OutlineStroke"); + button.addActionListener(this); + interior.add(this.outlineStrokeSample); + interior.add(button); + + interior.add(new JLabel(localizationResources.getString( + "Outline_Paint"))); + button = new JButton(localizationResources.getString("Select...")); + button.setActionCommand("OutlinePaint"); + button.addActionListener(this); + interior.add(this.outlinePaintSample); + interior.add(button); + + interior.add(new JLabel(localizationResources.getString( + "Background_paint"))); + button = new JButton(localizationResources.getString("Select...")); + button.setActionCommand("BackgroundPaint"); + button.addActionListener(this); + interior.add(this.backgroundPaintSample); + interior.add(button); + + if (this.plotOrientation != null) { + boolean isVertical = this.plotOrientation.equals( + PlotOrientation.VERTICAL); + int index = isVertical ? ORIENTATION_VERTICAL + : ORIENTATION_HORIZONTAL; + interior.add(new JLabel(localizationResources.getString( + "Orientation"))); + this.orientationCombo = new JComboBox(orientationNames); + this.orientationCombo.setSelectedIndex(index); + this.orientationCombo.setActionCommand("Orientation"); + this.orientationCombo.addActionListener(this); + interior.add(new JPanel()); + interior.add(this.orientationCombo); + } + + if (this.drawLines != null) { + interior.add(new JLabel(localizationResources.getString( + "Draw_lines"))); + this.drawLinesCheckBox = new JCheckBox(); + this.drawLinesCheckBox.setSelected(this.drawLines.booleanValue()); + this.drawLinesCheckBox.setActionCommand("DrawLines"); + this.drawLinesCheckBox.addActionListener(this); + interior.add(new JPanel()); + interior.add(this.drawLinesCheckBox); + } + + if (this.drawShapes != null) { + interior.add(new JLabel(localizationResources.getString( + "Draw_shapes"))); + this.drawShapesCheckBox = new JCheckBox(); + this.drawShapesCheckBox.setSelected(this.drawShapes.booleanValue()); + this.drawShapesCheckBox.setActionCommand("DrawShapes"); + this.drawShapesCheckBox.addActionListener(this); + interior.add(new JPanel()); + interior.add(this.drawShapesCheckBox); + } + + general.add(interior, BorderLayout.NORTH); + + JPanel appearance = new JPanel(new BorderLayout()); + appearance.setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2)); + appearance.add(general, BorderLayout.NORTH); + + JTabbedPane tabs = createPlotTabs(plot); + tabs.add(localizationResources.getString("Appearance"), appearance); + panel.add(tabs); + + return panel; + } + + protected JTabbedPane createPlotTabs(Plot plot) + { + JTabbedPane tabs = new JTabbedPane(); + tabs.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); + + Axis domainAxis = null; + if (plot instanceof CategoryPlot) { + domainAxis = ((CategoryPlot) plot).getDomainAxis(); + } + else if (plot instanceof XYPlot) { + domainAxis = ((XYPlot) plot).getDomainAxis(); + } + this.domainAxisPropertyPanel = DefaultAxisEditor.getInstance( + domainAxis); + if (this.domainAxisPropertyPanel != null) { + this.domainAxisPropertyPanel.setBorder( + BorderFactory.createEmptyBorder(2, 2, 2, 2)); + tabs.add(localizationResources.getString("Domain_Axis"), + this.domainAxisPropertyPanel); + } + + Axis rangeAxis = null; + if (plot instanceof CategoryPlot) { + rangeAxis = ((CategoryPlot) plot).getRangeAxis(); + } + else if (plot instanceof XYPlot) { + rangeAxis = ((XYPlot) plot).getRangeAxis(); + } + else if (plot instanceof PolarPlot) { + rangeAxis = ((PolarPlot) plot).getAxis(); + } + + this.rangeAxisPropertyPanel = DefaultAxisEditor.getInstance(rangeAxis); + if (this.rangeAxisPropertyPanel != null) { + this.rangeAxisPropertyPanel.setBorder( + BorderFactory.createEmptyBorder(2, 2, 2, 2)); + tabs.add(localizationResources.getString("Range_Axis"), + this.rangeAxisPropertyPanel); + } + +//dmo: added this panel for colorbar control. (start dmo additions) + ColorBar colorBar = null; + if (plot instanceof ContourPlot) { + colorBar = ((ContourPlot) plot).getColorBar(); + } + + this.colorBarAxisPropertyPanel = DefaultColorBarEditor.getInstance( + colorBar); + if (this.colorBarAxisPropertyPanel != null) { + this.colorBarAxisPropertyPanel.setBorder( + BorderFactory.createEmptyBorder(2, 2, 2, 2)); + tabs.add(localizationResources.getString("Color_Bar"), + this.colorBarAxisPropertyPanel); + } +//dmo: (end dmo additions) + + return tabs; + } + + /** + * Returns the current plot insets. + * + * @return The current plot insets. + */ + public RectangleInsets getPlotInsets() { + if (this.plotInsets == null) { + this.plotInsets = new RectangleInsets(0.0, 0.0, 0.0, 0.0); + } + return this.plotInsets; + } + + /** + * Returns the current background paint. + * + * @return The current background paint. + */ + public Paint getBackgroundPaint() { + return this.backgroundPaintSample.getPaint(); + } + + /** + * Returns the current outline stroke. + * + * @return The current outline stroke (possibly null). + */ + public Stroke getOutlineStroke() { + return this.outlineStrokeSample.getStroke(); + } + + /** + * Returns the current outline paint. + * + * @return The current outline paint. + */ + public Paint getOutlinePaint() { + return this.outlinePaintSample.getPaint(); + } + + /** + * Returns a reference to the panel for editing the properties of the + * domain axis. + * + * @return A reference to a panel. + */ + public DefaultAxisEditor getDomainAxisPropertyEditPanel() { + return this.domainAxisPropertyPanel; + } + + /** + * Returns a reference to the panel for editing the properties of the + * range axis. + * + * @return A reference to a panel. + */ + public DefaultAxisEditor getRangeAxisPropertyEditPanel() { + return this.rangeAxisPropertyPanel; + } + + /** + * Handles user actions generated within the panel. + * @param event the event + */ + @Override + public void actionPerformed(ActionEvent event) { + String command = event.getActionCommand(); + if (command.equals("BackgroundPaint")) { + attemptBackgroundPaintSelection(); + } + else if (command.equals("OutlineStroke")) { + attemptOutlineStrokeSelection(); + } + else if (command.equals("OutlinePaint")) { + attemptOutlinePaintSelection(); + } +// else if (command.equals("Insets")) { +// editInsets(); +// } + else if (command.equals("Orientation")) { + attemptOrientationSelection(); + } + else if (command.equals("DrawLines")) { + attemptDrawLinesSelection(); + } + else if (command.equals("DrawShapes")) { + attemptDrawShapesSelection(); + } + } + + /** + * Allow the user to change the background paint. + */ + private void attemptBackgroundPaintSelection() { + Color c; + c = JColorChooser.showDialog(this, localizationResources.getString( + "Background_Color"), Color.blue); + if (c != null) { + this.backgroundPaintSample.setPaint(c); + } + } + + /** + * Allow the user to change the outline stroke. + */ + private void attemptOutlineStrokeSelection() { + StrokeChooserPanel panel = new StrokeChooserPanel( + this.outlineStrokeSample, this.availableStrokeSamples); + int result = JOptionPane.showConfirmDialog(this, panel, + localizationResources.getString("Stroke_Selection"), + JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); + + if (result == JOptionPane.OK_OPTION) { + this.outlineStrokeSample.setStroke(panel.getSelectedStroke()); + } + } + + /** + * Allow the user to change the outline paint. We use JColorChooser, so + * the user can only choose colors (a subset of all possible paints). + */ + private void attemptOutlinePaintSelection() { + Color c; + c = JColorChooser.showDialog(this, localizationResources.getString( + "Outline_Color"), Color.blue); + if (c != null) { + this.outlinePaintSample.setPaint(c); + } + } + +// /** +// * Allow the user to edit the individual insets' values. +// */ +// private void editInsets() { +// InsetsChooserPanel panel = new InsetsChooserPanel(this.plotInsets); +// int result = JOptionPane.showConfirmDialog( +// this, panel, localizationResources.getString("Edit_Insets"), +// JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE +// ); +// +// if (result == JOptionPane.OK_OPTION) { +// this.plotInsets = panel.getInsets(); +// this.insetsTextField.setInsets(this.plotInsets); +// } +// +// } +// + /** + * Allow the user to modify the plot orientation if this is an editor for a + * CategoryPlot or a XYPlot. + */ + private void attemptOrientationSelection() { + + int index = this.orientationCombo.getSelectedIndex(); + + if (index == ORIENTATION_VERTICAL) { + this.plotOrientation = PlotOrientation.VERTICAL; + } + else { + this.plotOrientation = PlotOrientation.HORIZONTAL; + } + } + + /** + * Allow the user to modify whether or not lines are drawn between data + * points by LineAndShapeRenderers and + * StandardXYItemRenderers. + */ + private void attemptDrawLinesSelection() { + this.drawLines = BooleanUtilities.valueOf( + this.drawLinesCheckBox.isSelected()); + } + + /** + * Allow the user to modify whether or not shapes are drawn at data points + * by LineAndShapeRenderers and StandardXYItemRenderers. + */ + private void attemptDrawShapesSelection() { + this.drawShapes = BooleanUtilities.valueOf( + this.drawShapesCheckBox.isSelected()); + } + + /** + * Updates the plot properties to match the properties defined on the panel. + * + * @param plot The plot. + */ + public void updatePlotProperties(Plot plot) { + + // set the plot properties... + plot.setOutlinePaint(getOutlinePaint()); + plot.setOutlineStroke(getOutlineStroke()); + plot.setBackgroundPaint(getBackgroundPaint()); + plot.setInsets(getPlotInsets()); + + // then the axis properties... + if (this.domainAxisPropertyPanel != null) { + Axis domainAxis = null; + if (plot instanceof CategoryPlot) { + CategoryPlot p = (CategoryPlot) plot; + domainAxis = p.getDomainAxis(); + } + else if (plot instanceof XYPlot) { + XYPlot p = (XYPlot) plot; + domainAxis = p.getDomainAxis(); + } + if (domainAxis != null) { + this.domainAxisPropertyPanel.setAxisProperties(domainAxis); + } + } + + if (this.rangeAxisPropertyPanel != null) { + Axis rangeAxis = null; + if (plot instanceof CategoryPlot) { + CategoryPlot p = (CategoryPlot) plot; + rangeAxis = p.getRangeAxis(); + } + else if (plot instanceof XYPlot) { + XYPlot p = (XYPlot) plot; + rangeAxis = p.getRangeAxis(); + } + else if (plot instanceof PolarPlot) { + PolarPlot p = (PolarPlot) plot; + rangeAxis = p.getAxis(); + } + if (rangeAxis != null) { + this.rangeAxisPropertyPanel.setAxisProperties(rangeAxis); + } + } + + if (this.plotOrientation != null) { + if (plot instanceof CategoryPlot) { + CategoryPlot p = (CategoryPlot) plot; + p.setOrientation(this.plotOrientation); + } + else if (plot instanceof XYPlot) { + XYPlot p = (XYPlot) plot; + p.setOrientation(this.plotOrientation); + } + } + + if (this.drawLines != null) { + if (plot instanceof CategoryPlot) { + CategoryPlot p = (CategoryPlot) plot; + CategoryItemRenderer r = p.getRenderer(); + if (r instanceof LineAndShapeRenderer) { + ((LineAndShapeRenderer) r).setLinesVisible( + this.drawLines.booleanValue()); + } + } + else if (plot instanceof XYPlot) { + XYPlot p = (XYPlot) plot; + XYItemRenderer r = p.getRenderer(); + if (r instanceof StandardXYItemRenderer) { + ((StandardXYItemRenderer) r).setPlotLines( + this.drawLines.booleanValue()); + } + } + } + + if (this.drawShapes != null) { + if (plot instanceof CategoryPlot) { + CategoryPlot p = (CategoryPlot) plot; + CategoryItemRenderer r = p.getRenderer(); + if (r instanceof LineAndShapeRenderer) { + ((LineAndShapeRenderer) r).setShapesVisible( + this.drawShapes.booleanValue()); + } + } + else if (plot instanceof XYPlot) { + XYPlot p = (XYPlot) plot; + XYItemRenderer r = p.getRenderer(); + if (r instanceof StandardXYItemRenderer) { + ((StandardXYItemRenderer) r).setBaseShapesVisible( + this.drawShapes.booleanValue()); + } + } + } + +//dmo: added this panel for colorbar control. (start dmo additions) + if (this.colorBarAxisPropertyPanel != null) { + ColorBar colorBar = null; + if (plot instanceof ContourPlot) { + ContourPlot p = (ContourPlot) plot; + colorBar = p.getColorBar(); + } + if (colorBar != null) { + this.colorBarAxisPropertyPanel.setAxisProperties(colorBar); + } + } +//dmo: (end dmo additions) + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultPolarPlotEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultPolarPlotEditor.java new file mode 100755 index 0000000..fb1decc --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultPolarPlotEditor.java @@ -0,0 +1,216 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * DefaultPolarPlotEditor.java + * ---------------------- + * (C) Copyright 2005-2011, by Object Refinery Limited and Contributors. + * + * Original Author: Martin Hoeller; + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2011 : Version 1 (MH); + * + */ + + +package org.jfree.chart.editor; + +import java.awt.event.ActionEvent; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; + +import javax.swing.BorderFactory; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; +import javax.swing.JTextField; + +import org.jfree.chart.axis.NumberTickUnit; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PolarPlot; +import org.jfree.layout.LCBLayout; + +/** + * A panel for editing the properties of a {@link PolarPlot}. + */ +public class DefaultPolarPlotEditor extends DefaultPlotEditor + implements FocusListener { + + /** A text field to enter a manual TickUnit. */ + private JTextField manualTickUnit; + + /** A text field to enter the angleOffset. */ + private JTextField angleOffset; + + /** The size for the manual TickUnit. */ + private double manualTickUnitValue; + + /** The value for the plot's angle offset. */ + private double angleOffsetValue; + + + /** + * Standard constructor - constructs a panel for editing the properties of + * the specified plot. + * + * @param plot the plot, which should be changed. + */ + public DefaultPolarPlotEditor(PolarPlot plot) { + super(plot); + this.angleOffsetValue = plot.getAngleOffset(); + this.angleOffset.setText(Double.toString(this.angleOffsetValue)); + this.manualTickUnitValue = plot.getAngleTickUnit().getSize(); + this.manualTickUnit.setText(Double.toString(this.manualTickUnitValue)); + } + + /** + * Creates a tabbed pane for editing the plot attributes. + * + * @param plot the plot. + * + * @return A tabbed pane. + */ + @Override + protected JTabbedPane createPlotTabs(Plot plot) { + JTabbedPane tabs = super.createPlotTabs(plot); + // TODO find a better localization key + tabs.insertTab(localizationResources.getString("General1"), null, + createPlotPanel(), null, 0); + tabs.setSelectedIndex(0); + return tabs; + } + + private JPanel createPlotPanel() { + JPanel plotPanel = new JPanel(new LCBLayout(3)); + plotPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); + + plotPanel.add(new JLabel(localizationResources.getString( + "AngleOffset"))); + this.angleOffset = new JTextField(Double.toString( + this.angleOffsetValue)); + this.angleOffset.setActionCommand("AngleOffsetValue"); + this.angleOffset.addActionListener(this); + this.angleOffset.addFocusListener(this); + plotPanel.add(this.angleOffset); + plotPanel.add(new JPanel()); + + plotPanel.add(new JLabel(localizationResources.getString( + "Manual_TickUnit_value"))); + this.manualTickUnit = new JTextField(Double.toString( + this.manualTickUnitValue)); + this.manualTickUnit.setActionCommand("TickUnitValue"); + this.manualTickUnit.addActionListener(this); + this.manualTickUnit.addFocusListener(this); + plotPanel.add(this.manualTickUnit); + plotPanel.add(new JPanel()); + + return plotPanel; + } + + /** + * Does nothing. + * + * @param event the event. + */ + @Override + public void focusGained(FocusEvent event) { + // don't need to do anything + } + + /** + * Revalidates minimum/maximum range. + * + * @param event the event. + */ + @Override + public void focusLost(FocusEvent event) { + if (event.getSource() == this.angleOffset) { + validateAngleOffset(); + } + else if (event.getSource() == this.manualTickUnit) { + validateTickUnit(); + } + } + + /** + * Handles actions from within the property panel. + * @param event an event. + */ + @Override + public void actionPerformed(ActionEvent event) { + String command = event.getActionCommand(); + if (command.equals("AngleOffsetValue")) { + validateAngleOffset(); + } + else if (command.equals("TickUnitValue")) { + validateTickUnit(); + } + } + + /** + * Validates the angle offset entered by the user. + */ + public void validateAngleOffset() { + double newOffset; + try { + newOffset = Double.parseDouble(this.angleOffset.getText()); + } + catch (NumberFormatException e) { + newOffset = this.angleOffsetValue; + } + this.angleOffsetValue = newOffset; + this.angleOffset.setText(Double.toString(this.angleOffsetValue)); + } + + /** + * Validates the tick unit entered by the user. + */ + public void validateTickUnit() { + double newTickUnit; + try { + newTickUnit = Double.parseDouble(this.manualTickUnit.getText()); + } + catch (NumberFormatException e) { + newTickUnit = this.manualTickUnitValue; + } + + if (newTickUnit > 0.0 && newTickUnit < 360.0) { + this.manualTickUnitValue = newTickUnit; + } + this.manualTickUnit.setText(Double.toString(this.manualTickUnitValue)); + } + + @Override + public void updatePlotProperties(Plot plot) { + super.updatePlotProperties(plot); + PolarPlot pp = (PolarPlot) plot; + pp.setAngleTickUnit(new NumberTickUnit(this.manualTickUnitValue)); + pp.setAngleOffset(this.angleOffsetValue); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultTitleEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultTitleEditor.java new file mode 100755 index 0000000..d97bcf6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultTitleEditor.java @@ -0,0 +1,304 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * DefaultTitleEditor.java + * ----------------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Arnaud Lelievre; + * Daniel Gredler; + * + * Changes + * ------- + * 24-Nov-2005 : Version 1, based on TitlePropertyEditPanel.java (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * + */ + +package org.jfree.chart.editor; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Font; +import java.awt.Paint; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ResourceBundle; + +import javax.swing.BorderFactory; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JColorChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTextField; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.title.TextTitle; +import org.jfree.chart.title.Title; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.layout.LCBLayout; +import org.jfree.ui.FontChooserPanel; +import org.jfree.ui.FontDisplayField; +import org.jfree.ui.PaintSample; + +/** + * A panel for editing the properties of a chart title. + */ +class DefaultTitleEditor extends JPanel implements ActionListener { + + /** Whether or not to display the title on the chart. */ + private boolean showTitle; + + /** The checkbox to indicate whether or not to display the title. */ + private JCheckBox showTitleCheckBox; + + /** A field for displaying/editing the title text. */ + private JTextField titleField; + + /** The font used to draw the title. */ + private Font titleFont; + + /** A field for displaying a description of the title font. */ + private JTextField fontfield; + + /** The button to use to select a new title font. */ + private JButton selectFontButton; + + /** The paint (color) used to draw the title. */ + private PaintSample titlePaint; + + /** The button to use to select a new paint (color) to draw the title. */ + private JButton selectPaintButton; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.editor.LocalizationBundle"); + + /** + * Standard constructor: builds a panel for displaying/editing the + * properties of the specified title. + * + * @param title the title, which should be changed. + */ + public DefaultTitleEditor(Title title) { + + TextTitle t = (title != null ? (TextTitle) title + : new TextTitle(localizationResources.getString("Title"))); + this.showTitle = (title != null); + this.titleFont = t.getFont(); + this.titleField = new JTextField(t.getText()); + this.titlePaint = new PaintSample(t.getPaint()); + + setLayout(new BorderLayout()); + + JPanel general = new JPanel(new BorderLayout()); + general.setBorder( + BorderFactory.createTitledBorder( + BorderFactory.createEtchedBorder(), + localizationResources.getString("General") + ) + ); + + JPanel interior = new JPanel(new LCBLayout(4)); + interior.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5)); + + interior.add(new JLabel(localizationResources.getString("Show_Title"))); + this.showTitleCheckBox = new JCheckBox(); + this.showTitleCheckBox.setSelected(this.showTitle); + this.showTitleCheckBox.setActionCommand("ShowTitle"); + this.showTitleCheckBox.addActionListener(this); + interior.add(new JPanel()); + interior.add(this.showTitleCheckBox); + + JLabel titleLabel = new JLabel(localizationResources.getString("Text")); + interior.add(titleLabel); + interior.add(this.titleField); + interior.add(new JPanel()); + + JLabel fontLabel = new JLabel(localizationResources.getString("Font")); + this.fontfield = new FontDisplayField(this.titleFont); + this.selectFontButton = new JButton( + localizationResources.getString("Select...") + ); + this.selectFontButton.setActionCommand("SelectFont"); + this.selectFontButton.addActionListener(this); + interior.add(fontLabel); + interior.add(this.fontfield); + interior.add(this.selectFontButton); + + JLabel colorLabel = new JLabel( + localizationResources.getString("Color") + ); + this.selectPaintButton = new JButton( + localizationResources.getString("Select...") + ); + this.selectPaintButton.setActionCommand("SelectPaint"); + this.selectPaintButton.addActionListener(this); + interior.add(colorLabel); + interior.add(this.titlePaint); + interior.add(this.selectPaintButton); + + this.enableOrDisableControls(); + + general.add(interior); + add(general, BorderLayout.NORTH); + } + + /** + * Returns the title text entered in the panel. + * + * @return The title text entered in the panel. + */ + public String getTitleText() { + return this.titleField.getText(); + } + + /** + * Returns the font selected in the panel. + * + * @return The font selected in the panel. + */ + public Font getTitleFont() { + return this.titleFont; + } + + /** + * Returns the paint selected in the panel. + * + * @return The paint selected in the panel. + */ + public Paint getTitlePaint() { + return this.titlePaint.getPaint(); + } + + /** + * Handles button clicks by passing control to an appropriate handler + * method. + * + * @param event the event + */ + @Override + public void actionPerformed(ActionEvent event) { + + String command = event.getActionCommand(); + + if (command.equals("SelectFont")) { + attemptFontSelection(); + } + else if (command.equals("SelectPaint")) { + attemptPaintSelection(); + } + else if (command.equals("ShowTitle")) { + attemptModifyShowTitle(); + } + } + + /** + * Presents a font selection dialog to the user. + */ + public void attemptFontSelection() { + + FontChooserPanel panel = new FontChooserPanel(this.titleFont); + int result = + JOptionPane.showConfirmDialog( + this, panel, localizationResources.getString("Font_Selection"), + JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE + ); + + if (result == JOptionPane.OK_OPTION) { + this.titleFont = panel.getSelectedFont(); + this.fontfield.setText( + this.titleFont.getFontName() + " " + this.titleFont.getSize() + ); + } + } + + /** + * Allow the user the opportunity to select a Paint object. For now, we + * just use the standard color chooser - all colors are Paint objects, but + * not all Paint objects are colors (later we can implement a more general + * Paint chooser). + */ + public void attemptPaintSelection() { + Paint p = this.titlePaint.getPaint(); + Color defaultColor = (p instanceof Color ? (Color) p : Color.blue); + Color c = JColorChooser.showDialog( + this, localizationResources.getString("Title_Color"), defaultColor + ); + if (c != null) { + this.titlePaint.setPaint(c); + } + } + + /** + * Allow the user the opportunity to change whether the title is + * displayed on the chart or not. + */ + private void attemptModifyShowTitle() { + this.showTitle = this.showTitleCheckBox.isSelected(); + this.enableOrDisableControls(); + } + + /** + * If we are supposed to show the title, the controls are enabled. + * If we are not supposed to show the title, the controls are disabled. + */ + private void enableOrDisableControls() { + boolean enabled = (this.showTitle == true); + this.titleField.setEnabled(enabled); + this.selectFontButton.setEnabled(enabled); + this.selectPaintButton.setEnabled(enabled); + } + + /** + * Sets the properties of the specified title to match the properties + * defined on this panel. + * + * @param chart the chart whose title is to be modified. + */ + public void setTitleProperties(JFreeChart chart) { + if (this.showTitle) { + TextTitle title = chart.getTitle(); + if (title == null) { + title = new TextTitle(); + chart.setTitle(title); + } + title.setText(getTitleText()); + title.setFont(getTitleFont()); + title.setPaint(getTitlePaint()); + } + else { + chart.setTitle((TextTitle) null); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultValueAxisEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultValueAxisEditor.java new file mode 100755 index 0000000..cf3b106 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/DefaultValueAxisEditor.java @@ -0,0 +1,421 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * DefaultValueAxisEditor.java + * ---------------------- + * (C) Copyright 2005-2011, by Object Refinery Limited and Contributors. + * + * Original Author: Martin Hoeller (base on DefaultNumberAxisEditor + * by David Gilbert); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2011 : Version 1, based on DefaultNumberAxisEditor.java (MH); + * + */ + +package org.jfree.chart.editor; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.util.ResourceBundle; + +import javax.swing.BorderFactory; +import javax.swing.JCheckBox; +import javax.swing.JColorChooser; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import javax.swing.JTabbedPane; +import javax.swing.JTextField; + +import org.jfree.chart.axis.Axis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.layout.LCBLayout; +import org.jfree.ui.PaintSample; +import org.jfree.ui.StrokeChooserPanel; +import org.jfree.ui.StrokeSample; + +/** + * A panel for editing properties of a {@link ValueAxis}. + */ +class DefaultValueAxisEditor extends DefaultAxisEditor + implements FocusListener { + + /** A flag that indicates whether or not the axis range is determined + * automatically. + */ + private boolean autoRange; + + /** Flag if auto-tickunit-selection is enabled. */ + private boolean autoTickUnitSelection; + + /** The lowest value in the axis range. */ + private double minimumValue; + + /** The highest value in the axis range. */ + private double maximumValue; + + /** A checkbox that indicates whether or not the axis range is determined + * automatically. + */ + private JCheckBox autoRangeCheckBox; + + /** A check-box enabling/disabling auto-tickunit-selection. */ + private JCheckBox autoTickUnitSelectionCheckBox; + + /** A text field for entering the minimum value in the axis range. */ + private JTextField minimumRangeValue; + + /** A text field for entering the maximum value in the axis range. */ + private JTextField maximumRangeValue; + + /** The paint selected for drawing the gridlines. */ + private PaintSample gridPaintSample; + + /** The stroke selected for drawing the gridlines. */ + private StrokeSample gridStrokeSample; + + /** An array of stroke samples to choose from (since I haven't written a + * decent StrokeChooser component yet). + */ + private StrokeSample[] availableStrokeSamples; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.editor.LocalizationBundle"); + + /** + * Standard constructor: builds a property panel for the specified axis. + * + * @param axis the axis, which should be changed. + */ + public DefaultValueAxisEditor(ValueAxis axis) { + + super(axis); + + this.autoRange = axis.isAutoRange(); + this.minimumValue = axis.getLowerBound(); + this.maximumValue = axis.getUpperBound(); + this.autoTickUnitSelection = axis.isAutoTickUnitSelection(); + + this.gridPaintSample = new PaintSample(Color.blue); + this.gridStrokeSample = new StrokeSample(new BasicStroke(1.0f)); + + this.availableStrokeSamples = new StrokeSample[3]; + this.availableStrokeSamples[0] = new StrokeSample( + new BasicStroke(1.0f)); + this.availableStrokeSamples[1] = new StrokeSample( + new BasicStroke(2.0f)); + this.availableStrokeSamples[2] = new StrokeSample( + new BasicStroke(3.0f)); + + JTabbedPane other = getOtherTabs(); + + JPanel range = new JPanel(new LCBLayout(3)); + range.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); + + range.add(new JPanel()); + this.autoRangeCheckBox = new JCheckBox(localizationResources.getString( + "Auto-adjust_range"), this.autoRange); + this.autoRangeCheckBox.setActionCommand("AutoRangeOnOff"); + this.autoRangeCheckBox.addActionListener(this); + range.add(this.autoRangeCheckBox); + range.add(new JPanel()); + + range.add(new JLabel(localizationResources.getString( + "Minimum_range_value"))); + this.minimumRangeValue = new JTextField(Double.toString( + this.minimumValue)); + this.minimumRangeValue.setEnabled(!this.autoRange); + this.minimumRangeValue.setActionCommand("MinimumRange"); + this.minimumRangeValue.addActionListener(this); + this.minimumRangeValue.addFocusListener(this); + range.add(this.minimumRangeValue); + range.add(new JPanel()); + + range.add(new JLabel(localizationResources.getString( + "Maximum_range_value"))); + this.maximumRangeValue = new JTextField(Double.toString( + this.maximumValue)); + this.maximumRangeValue.setEnabled(!this.autoRange); + this.maximumRangeValue.setActionCommand("MaximumRange"); + this.maximumRangeValue.addActionListener(this); + this.maximumRangeValue.addFocusListener(this); + range.add(this.maximumRangeValue); + range.add(new JPanel()); + + other.add(localizationResources.getString("Range"), range); + + other.add(localizationResources.getString("TickUnit"), + createTickUnitPanel()); + } + + protected JPanel createTickUnitPanel() { + JPanel tickUnitPanel = new JPanel(new LCBLayout(3)); + tickUnitPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); + + tickUnitPanel.add(new JPanel()); + this.autoTickUnitSelectionCheckBox = new JCheckBox( + localizationResources.getString("Auto-TickUnit_Selection"), + this.autoTickUnitSelection); + this.autoTickUnitSelectionCheckBox.setActionCommand("AutoTickOnOff"); + this.autoTickUnitSelectionCheckBox.addActionListener(this); + tickUnitPanel.add(this.autoTickUnitSelectionCheckBox); + tickUnitPanel.add(new JPanel()); + + return tickUnitPanel; + } + + /** + * Getter for the {@link #autoTickUnitSelection} flag. + * + * @return The value of the flag for enabling auto-tickunit-selection. + */ + protected boolean isAutoTickUnitSelection() { + return autoTickUnitSelection; + } + + /** + * Setter for the {@link #autoTickUnitSelection} flag. + * @param autoTickUnitSelection The new value for auto-tickunit-selection. + */ + protected void setAutoTickUnitSelection(boolean autoTickUnitSelection) { + this.autoTickUnitSelection = autoTickUnitSelection; + } + + /** + * Get the checkbox that enables/disables auto-tickunit-selection. + * + * @return The checkbox. + */ + protected JCheckBox getAutoTickUnitSelectionCheckBox() { + return autoTickUnitSelectionCheckBox; + } + + /** + * Set the checkbox that enables/disables auto-tickunit-selection. + * + * @param autoTickUnitSelectionCheckBox The checkbox. + */ + protected void setAutoTickUnitSelectionCheckBox( + JCheckBox autoTickUnitSelectionCheckBox) { + this.autoTickUnitSelectionCheckBox = autoTickUnitSelectionCheckBox; + } + + /** + * Returns the current setting of the auto-range property. + * + * @return true if auto range is enabled. + */ + public boolean isAutoRange() { + return this.autoRange; + } + + /** + * Returns the current setting of the minimum value in the axis range. + * + * @return The current setting of the minimum value in the axis range. + */ + public double getMinimumValue() { + return this.minimumValue; + } + + /** + * Returns the current setting of the maximum value in the axis range. + * + * @return The current setting of the maximum value in the axis range. + */ + public double getMaximumValue() { + return this.maximumValue; + } + + /** + * Handles actions from within the property panel. + * @param event an event. + */ + @Override + public void actionPerformed(ActionEvent event) { + String command = event.getActionCommand(); + if (command.equals("GridStroke")) { + attemptGridStrokeSelection(); + } + else if (command.equals("GridPaint")) { + attemptGridPaintSelection(); + } + else if (command.equals("AutoRangeOnOff")) { + toggleAutoRange(); + } + else if (command.equals("MinimumRange")) { + validateMinimum(); + } + else if (command.equals("MaximumRange")) { + validateMaximum(); + } + else if (command.equals("AutoTickOnOff")) { + toggleAutoTick(); + } + else { + // pass to the super-class for handling + super.actionPerformed(event); + } + } + + /** + * Handle a grid stroke selection. + */ + protected void attemptGridStrokeSelection() { + StrokeChooserPanel panel = new StrokeChooserPanel(this.gridStrokeSample, + this.availableStrokeSamples); + int result = JOptionPane.showConfirmDialog(this, panel, + localizationResources.getString("Stroke_Selection"), + JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); + + if (result == JOptionPane.OK_OPTION) { + this.gridStrokeSample.setStroke(panel.getSelectedStroke()); + } + } + + /** + * Handle a grid paint selection. + */ + protected void attemptGridPaintSelection() { + Color c; + c = JColorChooser.showDialog(this, localizationResources.getString( + "Grid_Color"), Color.blue); + if (c != null) { + this.gridPaintSample.setPaint(c); + } + } + + /** + * Does nothing. + * + * @param event the event. + */ + @Override + public void focusGained(FocusEvent event) { + // don't need to do anything + } + + /** + * Revalidates minimum/maximum range. + * + * @param event the event. + */ + @Override + public void focusLost(FocusEvent event) { + if (event.getSource() == this.minimumRangeValue) { + validateMinimum(); + } + else if (event.getSource() == this.maximumRangeValue) { + validateMaximum(); + } + } + + /** + * Toggle the auto range setting. + */ + public void toggleAutoRange() { + this.autoRange = this.autoRangeCheckBox.isSelected(); + if (this.autoRange) { + this.minimumRangeValue.setText(Double.toString(this.minimumValue)); + this.minimumRangeValue.setEnabled(false); + this.maximumRangeValue.setText(Double.toString(this.maximumValue)); + this.maximumRangeValue.setEnabled(false); + } + else { + this.minimumRangeValue.setEnabled(true); + this.maximumRangeValue.setEnabled(true); + } + } + + public void toggleAutoTick() { + this.autoTickUnitSelection = this.autoTickUnitSelectionCheckBox.isSelected(); + } + + /** + * Revalidate the range minimum. + */ + public void validateMinimum() { + double newMin; + try { + newMin = Double.parseDouble(this.minimumRangeValue.getText()); + if (newMin >= this.maximumValue) { + newMin = this.minimumValue; + } + } + catch (NumberFormatException e) { + newMin = this.minimumValue; + } + + this.minimumValue = newMin; + this.minimumRangeValue.setText(Double.toString(this.minimumValue)); + } + + /** + * Revalidate the range maximum. + */ + public void validateMaximum() { + double newMax; + try { + newMax = Double.parseDouble(this.maximumRangeValue.getText()); + if (newMax <= this.minimumValue) { + newMax = this.maximumValue; + } + } + catch (NumberFormatException e) { + newMax = this.maximumValue; + } + + this.maximumValue = newMax; + this.maximumRangeValue.setText(Double.toString(this.maximumValue)); + } + + /** + * Sets the properties of the specified axis to match the properties + * defined on this panel. + * + * @param axis the axis. + */ + @Override + public void setAxisProperties(Axis axis) { + super.setAxisProperties(axis); + ValueAxis valueAxis = (ValueAxis) axis; + valueAxis.setAutoRange(this.autoRange); + if (!this.autoRange) { + valueAxis.setRange(this.minimumValue, this.maximumValue); + } + valueAxis.setAutoTickUnitSelection(this.autoTickUnitSelection); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle.properties new file mode 100755 index 0000000..bf35fbf --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle.properties @@ -0,0 +1,73 @@ +# org.jfree.chart.ui.ui ResourceBundle properties file +# +# Changes (from 31-Aug-2003) +# -------------------------- +# 31-Aug-2003 : Initial version (AL); +# + +\:=: +AngleOffset=Angle Offset +Appearance=Appearance +Auto-adjust_range=Auto-adjust range: +Auto-TickUnit_Selection=Auto-Selection of TickUnit +Background=Background: +Background_Color=Background Color +Background_paint=Background paint: +Color=Color: +Color_Bar=Color Bar +Domain_Axis=Domain Axis +Draw_anti-aliased=Draw anti-aliased +Draw_lines=Draw Lines: +Draw_shapes=Draw Shapes: +Edit...=Edit... +Edit_Insets=Edit Insets +Font=Font: +Font_Selection=Font Selection +General=General: +General1=General +Grid_Color=Grid Color +Insets=Insets: +Invert_Palette=Invert Palette: +Label=Label: +Label_Color=Label Color +Label_Insets=Label Insets: +Legend=Legend +Manual_TickUnit_value=TickUnit value +Maximum_range_value=Maximum range value: +Minimum_range_value=Minimum range value: +No_editor_implemented=No editor implemented +Orientation=Orientation: +Other=Other +Outline=Outline: +Outline_Color=Outline Color +Outline_stroke=Outline stroke: +Outline_Paint=Outline paint: +Paint=Paint: +Palette_Selection=Palette Selection +Palette=Palette: +Pen_Stroke_Selection=Pen/Stroke Selection +Plot=Plot +Range=Range +Range_Axis=Range Axis +Select...=Select... +Series_Label_Color=Series Label Color +Series_label_font=Series label font: +Series_label_paint=Series label paint: +Series_Outline_Paint=Series Outline Paint: +Series_Outline_Stroke=Series Outline Stroke: +Series_Paint=Series Paint: +Series_Stroke=Series Stroke: +Show_Legend=Show Legend: +Show_tick_labels=Show tick labels +Show_tick_marks=Show tick marks +Show_Title=Show Title: +Set_palette...=Set palette... +Step_Palette=Step Palette: +Stroke_Selection=Stroke Selection +Text=Text: +Ticks=Ticks +Tick_label_font=Tick label font: +Tick_Label_Insets=Tick Label Insets: +TickUnit=TickUnit +Title=Title +Title_Color=Title Color diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_cs.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_cs.properties new file mode 100755 index 0000000..f3df87d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_cs.properties @@ -0,0 +1,69 @@ +# org.jfree.chart.ui.ui ResourceBundle properties file +# +# Changes (from 31-Aug-2003) +# -------------------------- +# 31-Aug-2003 : Initial version (AL); +# 20-Mar-2010 : Czech translation; +# + +\:=: +Appearance=Vzhled +Auto-adjust_range=Automatick\u00fd rozsah: +Background=Pozad\u00ed: +Background_Color=Barva pozad\u00ed +Background_paint=V\u00fdpl\u0148 pozad\u00ed: +Color=Barva: +Color_Bar=Barevn\u00fd pruh +Domain_Axis=Osa oblasti +Draw_anti-aliased=Pou\u017e\u00edt vyhlazov\u00e1n\u00ed +Draw_lines=Kreslit \u010d\u00e1ry: +Draw_shapes=Kreslit tvary: +Edit...=Upravit... +Edit_Insets=Upravit okraje +Font=P\u00edsmo: +Font_Selection=V\u00fdb\u011br p\u00edsma +General=Obecn\u00e9: +Grid_Color=Barva m\u0159\u00ed\u017eky +Insets=Okraje: +Invert_Palette=Invertovat paletu: +Label=Popisek: +Label_Color=Barva popisku +Label_Insets=Okraje popisku: +Legend=Legenda +Maximum_range_value=Maximum rozsahu: +Minimum_range_value=Minimum rozsahu: +No_editor_implemented=Editor nen\u00ed implementovan\u00fd +Orientation=Orientatace: +Other=Ostatn\u00ed +Outline=R\u00e1me\u010dek: +Outline_Color=Barva r\u00e1me\u010dku +Outline_stroke=Tlou\u0161\u0165ka \u010d\u00e1ry: +Outline_Paint=V\u00fdpl\u0148 r\u00e1me\u010dku: +Paint=V\u00fdpl\u0148: +Palette_Selection=V\u00fdb\u011br z palety +Palette=Paleta: +Pen_Stroke_Selection=V\u00fdb\u011br pera/\u010d\u00e1ry +Plot=Graf +Range=Rozsah +Range_Axis=Osa rozsahu +Select...=V\u00fdb\u011br... +Series_Label_Color=Barva popisku dat +Series_label_font=P\u00edsmo popisku dat: +Series_label_paint=V\u00fdpl\u0148 popisku dat: +Series_Outline_Paint=V\u00fdpl\u0148 r\u00e1me\u010dku dat: +Series_Outline_Stroke=V\u00fdpl\u0148 r\u00e1me\u010dku dat: +Series_Paint=V\u00fdpl\u0148 dat: +Series_Stroke=\u010c\u00e1ra dat: +Show_Legend=Zobrazit legendu: +Show_tick_labels=Zobrazit popisky \u010dasu +Show_tick_marks=Zobrazit zna\u010dky \u010dasu +Show_Title=Zobrazit nadpis: +Set_palette...=Nastavit paletu... +Step_Palette=Krok palety: +Stroke_Selection=V\u00fdber \u010d\u00e1ry +Text=Text: +Ticks=\u010cas +Tick_label_font=P\u00edsmo popisk\u016f \u010dasu: +Tick_Label_Insets=Okraje popisk\u016f \u010dasu: +Title=Nadpis +Title_Color=Barva nadpisu diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_de.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_de.properties new file mode 100755 index 0000000..29386f4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_de.properties @@ -0,0 +1,74 @@ +# org.jfree.chart.ui.ui ResourceBundle properties file - german version +# +# Changes (from 31-Aug-2003) +# -------------------------- +# 31-Aug-2003 : Initial version (AL); +# 15-Mar-2004 : Revised version (Christian W. Zuckschwerdt); +# + +\:=: +AngleOffset=Winkel Offset +Appearance=Darstellung +Auto-adjust_range=Autojustage des Wertebereichs: +Auto-TickUnit_Selection=Automatische Auswahl der Schrittweite +Background=Hintergrund: +Background_Color=Hintergrundfarbe +Background_paint=Hintergrundfarbe: +Color=Farbe: +Color_Bar=Farbleiste +Domain_Axis=Rubrikenachse +Draw_anti-aliased=Zeichnung gl\u00e4tten +Draw_lines=Zeichne Linien: +Draw_shapes=Zeichne Formen: +Edit...=Bearbeiten... +Edit_Insets=Seitenr\u00e4nder bearbeiten +Font=Schrift: +Font_Selection=Schriftwahl +General=Allgemein: +General1=Allgemein +Grid_Color=Gitterfarbe +Insets=R\u00e4nder: +Invert_Palette=Palette invertieren: +Label=Beschriftung: +Label_Color=Beschriftungsfarbe +Label_Insets=Beschriftungsr\u00e4nder: +Legend=Legende +Manual_TickUnit_value=manuelle Schrittweite +Maximum_range_value=Maximalwert: +Minimum_range_value=Minimalwert: +No_editor_implemented=Kein Editor verf\u00fcgbar +Orientation=Orientierung: +Other=Sonstiges +Outline=Rahmenlinien: +Outline_Color=Rahmenfarbe +Outline_stroke=Rahmenart: +Outline_Paint=Rahmenfarbe: +Paint=Farbe: +Palette_Selection=Farbauswahl +Palette=Palette: +Pen_Stroke_Selection=Linienst\u00e4rke w\u00e4hlen +Plot=Diagramm +Range=Wertebereich +Range_Axis=Werteachse +Select...=Ausw\u00e4hlen... +Series_Label_Color=Farbe der Datenreihenbeschriftung +Series_label_font=Schrift der Datenreihenbeschriftung: +Series_label_paint=Farbe der Datenreihenbeschriftung: +Series_Outline_Paint=Farbe der Datenreihenrahmen: +Series_Outline_Stroke=Art der Datenreihenrahmen: +Series_Paint=Datenreihenfarbe: +Series_Stroke=Datenreihenrahmen: +Show_Legend=Legende anzeigen: +Show_tick_labels=Beschriftungen zeichnen +Show_tick_marks=Markierungen zeichnen +Show_Title=\u00dcberschrift anzeigen: +Set_palette...=Palette w\u00e4hlen... +Step_Palette=Step Palette: +Stroke_Selection=Linienauswahl +Text=Text: +Ticks=Markierungen +TickUnit=Schrittweite +Tick_label_font=Markierungsschift: +Tick_Label_Insets=Markierungsr\u00e4nder: +Title=\u00dcberschrift +Title_Color=Titelfarbe diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_es.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_es.properties new file mode 100755 index 0000000..bdfa7c5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_es.properties @@ -0,0 +1,74 @@ +# org.jfree.chart.ui.ui ResourceBundle properties file - spanish version +# +# Changes (from 16-Dec-2003) +# -------------------------- +# 16-Dec-2003 : Initial Version: Complejo Hospitalario Universitario Juan Canalejo +# 14-Oct-2004 : Revised by: Leopoldo Federico P\u00ef\u00bf\u00bdrtile (Grupo de Procesamiento Digital de Im\u00ef\u00bf\u00bdgenes) +# Universidad Tecnol\u00ef\u00bf\u00bdgica Nacional - Facultad Regional Resistencia, Argentina + +\:=\ : +AngleOffset=Angle Offset +Appearance=Apariencia +Auto-adjust_range=Ejes auto-ajustables : +Auto-TickUnit_Selection=Auto-Selection of TickUnit +Background=Fondo : +Background_Color=Color de fondo +Background_paint=Color de fondo : +Color=Color : +Color_Bar=Color de la barra +Domain_Axis=Eje de las abcisas +Draw_anti-aliased=Anti-aliasing +Draw_lines=Dibujar l\u00edneas: +Draw_shapes=Draw figuras: +Edit...=Editar... +Edit_Insets=Regular la posici\u00f3n +Font=Fuente : +Font_Selection=Selecci\u00f3n de fuente +General=General : +General1=General +Grid_Color=Color de la rejilla +Insets=Posici\u00f3n : +Invert_Palette=Invertir la paleta : +Label=Etiqueta : +Label_Color=Color de la etiqueta +Label_Insets=Posici\u00f3n de la etiqueta : +Legend=Leyenda +Manual_TickUnit_value=TickUnit value +Maximum_range_value=Valor m\u00e3ximo del eje : +Minimum_range_value=Valor m\u00ednimo del eje : +No_editor_implemented=Editor no disponble +Orientation=Orientaci\u00f3n: +Other=Otro +Outline=Borde : +Outline_Paint=Color del borde : +Outline_Color=Color del borde +Outline_stroke=Estilo del trazo del borde : +Paint=Color : +Palette=Paleta : +Palette_Selection=Selecci\u00f3n de la paleta +Pen_Stroke_Selection=Selecci\u00f3n del trazo +Plot=Trazo +Range=Intervalo +Range_Axis=Eje de ordenadas +Select...=Seleccionar... +Series_Label_Color=Color de la etiqueta de las series +Series_label_font=Fuente de la etiqueta de las series : +Series_label_paint=Color de la etiqueta de las series : +Series_Outline_Paint=Color del borde de las series : +Series_Outline_Stroke=Estilo del trazo del borde : +Series_Paint=Color de las series : +Series_Stroke=Estilo del trazo de las series : +Show_Legend=Mostrar leyenda: +Show_tick_labels=Visualizar etiquetas de graduaci\u00f3n de escala +Show_tick_marks=Visualizar marcas de graduaci\u00f3n de escala +Show_Title=Mostrar t\u00edtulo +Set_palette...=Escoja la paleta... +Step_Palette=Paso de paleta : +Stroke_Selection=Selecci\u00f3n del trazo +Text=Texto : +Tick_label_font=Fuente de las etiquetas de graduaci\u00f3n de escala : +Tick_Label_Insets=Posici\u00f3n de las etiquetas de graduaci\u00f3n de escala : +Ticks=Etiquetas de graduaci\u00f3n de escala +TickUnit=TickUnit +Title=T\u00edtulo +Title_Color=Color del t\u00edtulo diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_fr.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_fr.properties new file mode 100755 index 0000000..8942781 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_fr.properties @@ -0,0 +1,67 @@ +# org.jfree.chart.ui.ui ResourceBundle properties file - french version +# +# Changes (from 31-Aug-2003) +# -------------------------- +# 31-Aug-2003 : Initial version (AL); +# + +\:=\ : +AngleOffset=Angle Offset +Appearance=G\u00E9n\u00E9ral +Auto-adjust_range=R\u00E9glage automatique de l'\u00E9chelle : +Auto-TickUnit_Selection=Auto-Selection of TickUnit +Background=Fond : +Background_Color=Couleur du fond +Background_paint=Couleur du fond : +Color=Couleur : +Color_Bar=Couleur de la barre +Domain_Axis=Axe des abcisses +Draw_anti-aliased=Anti-aliasing +Edit...=Edition... +Edit_Insets=R\u00E9gler la position +Font=Police : +Font_Selection=S\u00E9lection de la police +General=G\u00E9n\u00E9ral : +General=G\u00E9n\u00E9ral +Grid_Color=Couleur de la grille +Insets=Position : +Invert_Palette=Inversion de la palette : +Label=Etiquette : +Label_Color=Couleur de l'\u00E9tiquette +Label_Insets=Position de l'\u00E9tiquette : +Legend=L\u00E9gende +Manual_TickUnit_value=TickUnit value +Maximum_range_value=Valeur maximum de l'axe : +Minimum_range_value=Valeur minimum de l'axe : +No_editor_implemented=Aucun \u00E9diteur disponible +Other=Autre +Outline=Bordure : +Outline_Paint=Couleur de la bordure : +Outline_Color=Outline Color +Outline_stroke=Bordure : +Paint=Couleur : +Palette=Palette : +Palette_Selection=Selection de la palette +Pen_Stroke_Selection=S\u00E9lection du style de trait +Plot=Trac\u00E9 +Range=Echelle +Range_Axis=Axe des ordonn\u00E9es +Select...=S\u00E9lectionner... +Series_Label_Color=S\u00E9lection de la couleur de l'\u00E9tiquette +Series_label_font=Police de l'\u00E9tiquette de s\u00E9rie : +Series_label_paint=Couleur de l'\u00E9tiquette de s\u00E9rie : +Series_Outline_Paint=Couleur de bordure de la s\u00E9rie : +Series_Outline_Stroke=Style du trait de bordure de la s\u00E9rie : +Series_Paint=Couleur de la s\u00E9rie : +Series_Stroke=Style du trait de la s\u00E9rie : +Show_tick_labels=Afficher les \u00E9tiquettes de graduation +Show_tick_marks=Afficher les rep\u00E8res de graduation +Set_palette...=Choix de palette... +Step_Palette=Changement de palette : +Stroke_Selection=S\u00E9lection du style de trait +Text=Texte : +Tick_label_font=Police des \u00E9tiquettes de graduation : +Tick_Label_Insets=Position des \u00E9tiquettes de graduation : +Ticks=Etiquettes de graduation +TickUnit=TickUnit +Title_Color=Couleur du titre diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_ja.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_ja.properties new file mode 100755 index 0000000..87b2274 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_ja.properties @@ -0,0 +1,62 @@ + +\:=: +Appearance=\u5916\u89b3 +Auto-adjust_range=\u81ea\u52d5\u8abf\u6574\u7bc4\u56f2: +Background=\u80cc\u666f: +Background_Color=\u80cc\u666f\u8272 +Background_paint=\u80cc\u666f\u306e\u5857\u88c5: +Color=\u8272: +Color_Bar=\u30ab\u30e9\u30fc\u30d0\u30fc +Domain_Axis=\u5206\u985e\u8ef8 +Draw_anti-aliased=\u30c9\u30ed\u30fc\u30a2\u30f3\u30c1\u30a8\u30a4\u30ea\u30a2\u30b9 +Draw_lines=\u30c9\u30ed\u30fc\u30e9\u30a4\u30f3: +Draw_shapes=\u63cf\u753b\u56f3\u5f62: +Edit...=\u7de8\u96c6... +Edit_Insets=\u30a4\u30f3\u30bb\u30c3\u30c8\u306e\u7de8\u96c6 +Font=\u30d5\u30a9\u30f3\u30c8: +Font_Selection=\u30d5\u30a9\u30f3\u30c8\u306e\u9078\u629e +General=\u4e00\u822c: +Grid_Color=\u30b0\u30ea\u30c3\u30c9\u306e\u8272 +Insets=\u633f\u5165 +Invert_Palette=\u30d1\u30ec\u30c3\u30c8\u3092\u53cd\u8ee2: +Label=\u30e9\u30d9\u30eb: +Label_Color=\u30e9\u30d9\u30eb\u306e\u8272 +Label_Insets=\u30e9\u30d9\u30eb\u306e\u30a4\u30f3\u30bb\u30c3\u30c8: +Legend=\u51e1\u4f8b +Maximum_range_value=\u7bc4\u56f2\u306e\u6700\u5927\u5024: +Minimum_range_value=\u7bc4\u56f2\u306e\u6700\u5c0f\u5024: +No_editor_implemented=\u30a8\u30c7\u30a3\u30bf\u304c\u5b9f\u88c5\u3055\u308c\u3066\u3044\u307e\u305b\u3093 +Orientation=\u65b9\u5411: +Other=\u305d\u306e\u4ed6 +Outline=\u6982\u8981: +Outline_Color=\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3\u306e\u8272 +Outline_Paint=\u30da\u30a4\u30f3\u30c8\u306e\u30a2\u30a6\u30c8\u30e9\u30a4\u30f3: +Outline_stroke=\u5de5\u7a0b\u306e\u6982\u8981: +Paint=\u30da\u30a4\u30f3\u30c8: +Palette=\u30d1\u30ec\u30c3\u30c8: +Palette_Selection=\u30d1\u30ec\u30c3\u30c8\u306e\u9078\u629e +Pen_Stroke_Selection=\u30da\u30f3/\u5de5\u7a0b\u306e\u9078\u629e +Plot=\u4f5c\u56f3 +Range=\u7bc4\u56f2 +Range_Axis=\u6570\u5024\u8ef8 +Select...=\u9078\u629e... +Series_Label_Color=\u30b7\u30ea\u30fc\u30ba\u306e\u30e9\u30d9\u30eb\u8272 +Series_Outline_Paint=\u30b7\u30ea\u30fc\u30ba\u306e\u6982\u8981\u30da\u30a4\u30f3\u30c8: +Series_Outline_Stroke=\u30b7\u30ea\u30fc\u30ba\u306e\u6982\u8981\u5de5\u7a0b: +Series_Paint=\u8a69\u30ea\u30fc\u30b9\u30da\u30a4\u30f3\u30c8: +Series_Stroke=\u30b7\u30ea\u30fc\u30ba\u306e\u5de5\u7a0b: +Series_label_font=\u30b7\u30ea\u30fc\u30ba\u306e\u30e9\u30d9\u30eb\u30d5\u30a9\u30f3\u30c8: +Series_label_paint=\u30b7\u30ea\u30fc\u30ba\u306e\u30e9\u30d9\u30eb\u30da\u30a4\u30f3\u30c8: +Set_palette...=\u30d1\u30ec\u30c3\u30c8\u306e\u8a2d\u5b9a... +Show_Legend=\u51e1\u4f8b: +Show_Title=\u30bf\u30a4\u30c8\u30eb\u306e\u8868\u793a: +Show_tick_labels=\u76ee\u76db\u30e9\u30d9\u30eb\u3092\u8868\u793a +Show_tick_marks=\u76ee\u76db\u3092\u8868\u793a +Step_Palette=\u30d1\u30ec\u30c3\u30c8\u306e\u30b9\u30c6\u30c3\u30d7: +Stroke_Selection=\u6982\u8981\u306e\u9078\u629e +Text=\u30c6\u30ad\u30b9\u30c8: +Tick_Label_Insets=\u30e9\u30d9\u30eb\u306e\u30a4\u30f3\u30bb\u30c3\u30c8\u3092\u30c1\u30a7\u30c3\u30af: +Tick_label_font=\u30e9\u30d9\u30eb\u306e\u30d5\u30a9\u30f3\u30c8\u3092\u30c1\u30a7\u30c3\u30af: +Ticks=\u523b\u307f +Title=\u30bf\u30a4\u30c8\u30eb +Title_Color=\u30bf\u30a4\u30c8\u30eb\u306e\u8272 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_nl.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_nl.properties new file mode 100755 index 0000000..442fac9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_nl.properties @@ -0,0 +1,72 @@ +# org.jfree.chart.ui.ui ResourceBundle properties file +# +# Changes (from 31-Aug-2003) +# -------------------------- +# 24-Mar-2003 : Translated into Dutch +# 31-Aug-2003 : Initial version (AL); +# + +\:=: +AngleOffset=Angle Offset +Appearance=Uiterlijk +Auto-adjust_range=Bereik automatisch bepalen +Auto-TickUnit_Selection=Auto-Selection of TickUnit +Background=Achtergrond +Background_Color=Achtergrondkleur + +# "Paint" translated sounds a bit silly IMHO. Since at present only single, +# opaque colors are selectable anyway, lets just call it that -- color. +Background_paint=Achtergrondkleur: + +Color=Kleur: +Color_Bar=Kleurbalk +Domain_Axis=Domein as +Draw_anti-aliased=Kartelrandjes maskeren (anti-aliasing) +Edit...=Wijzig... +Edit_Insets=Wijzig marges +Font=Lettertype: +Font_Selection=Lettertype keuze +General=Algemeen: +General1=Algemeen +Grid_Color=Rasterkleur +Insets=Marges: +Invert_Palette=Palet inverteren: +Label=Label: +Label_Color=Labelkleur +Label_Insets=Labelmarges: +Legend=Legenda +Manual_TickUnit_value=TickUnit value +Maximum_range_value=Hoogste waarde: +Minimum_range_value=Laagste waarde: +No_editor_implemented=Geen editor beschikbaar +Other=Overig +Outline=Rand: +Outline_Color=Randkleur +Outline_stroke=Rand stijl: +Outline_Paint=Randkleur: +Paint=Kleur: +Palette_Selection=Paletkleuze +Palette=Palet: +Pen_Stroke_Selection=Pen/Stijl Keuze +Plot=Diagram +Range=Bereik +Range_Axis=Gegevens as +Select...=Selecteer... +Series_Label_Color=Kleur serienaam +Series_label_font=Lettertype serienaam: +Series_label_paint=Kleur serienaam: +Series_Outline_Paint=Kleur serie-rand: +Series_Outline_Stroke=Stijl serie-rand: +Series_Paint=Kleur v.d. serie: +Series_Stroke=Stijl v.d. serie: +Show_tick_labels=Toon waarde-labels +Show_tick_marks=Toon waarde-streepjes +Set_palette...=Kies palet... +Step_Palette=Stap palet: +Stroke_Selection=Stijlkeuze +Text=Tekst: +Ticks=Waarde-streepjes +TickUnit=TickUnit +Tick_label_font=Lettertype waarde-labes: +Tick_Label_Insets=Waarde-label marges: +Title_Color=Kleur titel diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_pl.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_pl.properties new file mode 100755 index 0000000..23e4a75 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_pl.properties @@ -0,0 +1,66 @@ +# org.jfree.chart.ui.ui ResourceBundle properties file +# +# Changes (from 15-Mar-2004) +# -------------------------- +# 15-Mar-2004 : Initial version (Kuba Duda); +# + +\:=: +AngleOffset=Angle Offset +Appearance=Wygl\u0105d +Auto-adjust_range=Automatycznie dostosuj zakres: +Auto-TickUnit_Selection=Auto-Selection of TickUnit +Background=T\u0142o: +Background_Color=Kolor t\u0142a +Background_paint=Wype\u0142nienie t\u0142a: +Color=Kolor: +Color_Bar=Pasek kolor\u00f3w +Domain_Axis=O\u015b domeny +Draw_anti-aliased=Wyg\u0142adzaj kraw\u0119dzie +Edit...=Edytuj... +Edit_Insets=Edytuj wstawki +Font=Czcionka: +Font_Selection=Wyb\u00f3r czcionki +General=Og\u00f3lne: +Grid_Color=Kolor siatki +Insets=Wstawki: +Invert_Palette=Odwr\u00f3\u0107 palet\u0119: +Label=Etykieta: +Label_Color=Kolor etykiet +Label_Insets=Wstawki etykiet: +Legend=Legenda +Manual_TickUnit_value=TickUnit value +Maximum_range_value=Maksymalna warto\u015b\u0107 zakresu: +Minimum_range_value=Minimalna warto\u015b\u0107 zakresu: +No_editor_implemented=Edytor nie zaimplementowany +Other=Inne +Outline=Obrys: +Outline_Color=Kolor konturu +Outline_stroke=Obrys konturu: +Outline_Paint=wype\u0142nienie konturu: +Paint=Wype\u0142nienie: +Palette_Selection=Wyb\u00f3r palety +Palette=Paleta: +Pen_Stroke_Selection=Wyb\u00f3r pi\u00f3ra/obrysu +Plot=Wykres +Range=Zakres +Range_Axis=O\u015b zakresu +Select...=Wybierz... +Series_Label_Color=Kolor etykiety serii +Series_label_font=Czcionka etykiety serii: +Series_label_paint=Wype\u0142nienie etykiety serii: +Series_Outline_Paint=Wype\u0142nienie obrysu serii: +Series_Outline_Stroke=Kolor obrysu serii: +Series_Paint=Wype\u0142nienie serii: +Series_Stroke=Kolor serii: +Show_tick_labels=Pokazuj etykiety skali +Show_tick_marks=Pokazuj znaczniki skali +Set_palette...=Wybierz palet\u0119... +Step_Palette=Paleta krokowa: +Stroke_Selection=Wyb\u00f3r obrysu +Text=Tekst: +Ticks=Podzia\u0142ka +TickUnit=TickUnit +Tick_label_font=Czcionka etykiet podzia\u0142ki: +Tick_Label_Insets=Wstawki etykiet podzia\u0142ki: +Title_Color=Kolor tytu\u0142u diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_pt_BR.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_pt_BR.properties new file mode 100755 index 0000000..3266a30 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_pt_BR.properties @@ -0,0 +1,67 @@ +# org.jfree.chart.ChartPanel ResourceBundle properties file - portuguese version +# +# Changes (from 24-May-2007) +# -------------------------- +# 24-May-2007 : Initial version (Leonardo Alves Machado) +# + +\:=\ : +AngleOffset=Angle Offset +Appearance=Geral +Auto-adjust_range=Eixos auto-ajust\u00E1veis : +Auto-TickUnit_Selection=Auto-Selection of TickUnit +Background=Fundo : +Background_Color=Cor de fundo +Background_paint=Cor de fundo : +Color=Cor : +Color_Bar=Cor da barra +Domain_Axis=Eixo das abcissas +Draw_anti-aliased=Anti-aliasing +Edit...=Editar... +Edit_Insets=Regular a posi\u00E7\u00E3o +Font=Fonte : +Font_Selection=Sele\u00E7\u00E3o da fonte +General=Geral : +General1=Geral +Grid_Color=Cor da grade +Insets=Posi\u00E7\u00E3o : +Invert_Palette=Inverter o palete : +Label=R\u00F3tulo : +Label_Color=Cor do r\u00F3tulo +Label_Insets=Posi\u00E7\u00E3o do r\u00F3tulo : +Legend=Legenda +Manual_TickUnit_value=TickUnit value +Maximum_range_value=Valor m\u00E1ximo do eixo : +Minimum_range_value=Valor m\u00EDnimo do eixo : +No_editor_implemented=Editor n\u00E3o dispon\u00EDvel +Other=Outro +Outline=Borda : +Outline_Paint=Cor da borda : +Outline_Color=Cor da borda +Outline_stroke=Estilo do tra\u00E7o da borda : +Paint=Cor : +Palette=Palete : +Palette_Selection=Sele\u00E7\u00E3o do palete +Pen_Stroke_Selection=Sele\u00E7\u00E3o de tra\u00E7o +Plot=Tra\u00E7o +Range=Intervalo +Range_Axis=Eixo das ordenadas +Select...=Selecionar... +Series_Label_Color=Cor do r\u00F3tulo das s\u00E9ries +Series_label_font=Fonte do r\u00F3tulo das s\u00E9ries : +Series_label_paint=Cor do r\u00F3tulo das s\u00E9ries : +Series_Outline_Paint=Cor da borda das s\u00E9ries : +Series_Outline_Stroke=Estilo do tra\u00E7o da borda : +Series_Paint=Cor da s\u00E9ries : +Series_Stroke=Estilo do tra\u00E7o das s\u00E9ries : +Show_tick_labels=Visualizar r\u00F3tulos de gradua\u00E7\u00E3o de escala +Show_tick_marks=Visualizar marcas de gradua\u00E7\u00E3o de escala +Set_palette...=Escolha do palete... +Step_Palette=Espaçamento do palete : +Stroke_Selection=Sele\u00E7\u00E3o do tra\u00E7o +Text=Texto : +Tick_label_font=Fonte dos r\u00F3tulos de gradua\u00E7\u00E3o de escala : +Tick_Label_Insets=Posi\u00E7\u00E3o dos r\u00F3tulos de gradua\u00E7\u00E3o de escala : +Ticks=R\u00F3tulos de gradua\u00E7\u00E3o de escala +TickUnit=TickUnit +Title_Color=Cor do t\u00EDtulo diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_pt_PT.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_pt_PT.properties new file mode 100755 index 0000000..bbcf4ec --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_pt_PT.properties @@ -0,0 +1,67 @@ +# org.jfree.chart.ChartPanel ResourceBundle properties file - portuguese version +# +# Changes (from 09-Set-2003) +# -------------------------- +# 09-Set-2003 : Initial version (Eduardo Ramalho); +# + +\:=\ : +Appearance=Geral +AngleOffset=Angle Offset +Auto-adjust_range=Eixos auto-ajust\u00E1veis : +Auto-TickUnit_Selection=Auto-Selection of TickUnit +Background=Fundo : +Background_Color=Cor de fundo +Background_paint=Cor de fundo : +Color=Cor : +Color_Bar=Cor da barra +Domain_Axis=Eixo das abcissas +Draw_anti-aliased=Anti-aliasing +Edit...=Editar... +Edit_Insets=Regular a posi\u00E7\u00E3o +Font=Fonte : +Font_Selection=Selec\u00E7\u00E3o da fonte +General=Geral : +General1=Geral +Grid_Color=Cor da grelha +Insets=Posi\u00E7\u00E3o : +Invert_Palette=Inverter a paleta : +Label=Etiqueta : +Label_Color=Cor da etiqueta +Label_Insets=Posi\u00E7\u00E3o da etiqueta : +Legend=Legenda +Manual_TickUnit_value=TickUnit value +Maximum_range_value=Valor m\u00E1ximo do eixo : +Minimum_range_value=Valor m\u00EDnimo do eixo : +No_editor_implemented=Editor n\u00E3o dispon\u00EDvel +Other=Outro +Outline=Borda : +Outline_Paint=Cor da borda : +Outline_Color=Cor da borda +Outline_stroke=Estilo do tra\u00E7o da borda : +Paint=Cor : +Palette=Palete : +Palette_Selection=Selec\u00E7\u00E3o da palete +Pen_Stroke_Selection=Selec\u00E7\u00E3o de tra\u00E7o +Plot=Tra\u00E7o +Range=Intervalo +Range_Axis=Eixo das ordenadas +Select...=Seleccionar... +Series_Label_Color=Cor da etiqueta das s\u00E9ries +Series_label_font=Fonte da etiqueta das s\u00E9ries : +Series_label_paint=Cor da etiqueta das s\u00E9ries : +Series_Outline_Paint=Cor da borda das s\u00E9ries : +Series_Outline_Stroke=Estilo do tra\u00E7o da borda : +Series_Paint=Cor da s\u00E9ries : +Series_Stroke=Estilo do tra\u00E7o das s\u00E9ries : +Show_tick_labels=Visualizar etiquetas de gradua\u00E7\u00E3o de escala +Show_tick_marks=Visualizar marcas de gradua\u00E7\u00E3o de escala +Set_palette...=Escolha de palete... +Step_Palette=Changement de palette : +Stroke_Selection=Selec\u00E7\u00E3o do tra\u00E7o +Text=Texto : +Tick_label_font=Fonte das etiquetas de gradua\u00E7\u00E3o de escala : +Tick_Label_Insets=Posi\u00E7\u00E3o das etiquetas de gradua\u00E7\u00E3o de escala : +Ticks=Etiquetas de gradua\u00E7\u00E3o de escala +TickUnit=TickUnit +Title_Color=Cor do t\u00EDtulo diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_ru.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_ru.properties new file mode 100755 index 0000000..df6bef1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_ru.properties @@ -0,0 +1,67 @@ +# org.jfree.chart.ui.ui ResourceBundle properties file +# +# Changes (from 10-Nov-2003) +# -------------------------- +# 10-Nov-2003 : Initial version (AL); +# + +\:=: +Appearance=\u0412\u0438\u0434 +AngleOffset=Angle Offset +Auto-adjust_range=\u0410\u0432\u0442\u0440\u043e\u0440\u0435\u0433\u0443\u043b\u0438\u0440\u043e\u0432\u043a\u0430: +Auto-TickUnit_Selection=Auto-Selection of TickUnit +Background=\u0424\u043e\u043d: +Background_Color=\u0426\u0432\u0435\u0442 \u0444\u043e\u043d\u0430 +Background_paint=\u0424\u043e\u043d\u043e\u0432\u044b\u0439 \u0440\u0438\u0441\u0443\u043d\u043e\u043a: +Color=\u0426\u0432\u0435\u0442: +Color_Bar=\u0426\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u0433\u0440\u0443\u0433 +Domain_Axis=\u041e\u0441\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 +Draw_anti-aliased=\u0410\u043d\u0442\u0438-\u0430\u043b\u0438\u0430\u0441\u0438\u043d\u0433 +Edit...=\u0420\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c... +Edit_Insets=\u041d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 \u043e\u0442\u0441\u0442\u0443\u043f\u043e\u0432 +Font=\u0428\u0440\u0438\u0444\u0442: +Font_Selection=\u0412\u044b\u0431\u043e\u0440 \u0448\u0440\u0438\u0444\u0442\u0430 +General=\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435: +General1=\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 +Grid_Color=\u0426\u0432\u0435\u0442 \u0441\u0435\u0442\u043a\u0438 +Insets=\u041e\u0442\u0441\u0442\u0443\u043f\u044b: +Invert_Palette=\u0418\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043b\u0438\u0442\u0440\u0443: +Label=\u041c\u0435\u0442\u043a\u0430: +Label_Color=\u0426\u0432\u0435\u0442 \u043c\u0435\u0442\u043a\u0438 +Label_Insets=\u041e\u0442\u0441\u0442\u0443\u043f\u044b \u043c\u0435\u0442\u043a\u0438: +Legend=\u041b\u0435\u0433\u0435\u043d\u0434\u0430 +Manual_TickUnit_value=TickUnit value +Maximum_range_value=\u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435: +Minimum_range_value=\u041c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435: +No_editor_implemented=\u041d\u0435 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440 +Other=\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e +Outline=\u0420\u0430\u043c\u043a\u0430: +Outline_Color=\u0426\u0432\u0435\u0442 \u0440\u0430\u043c\u043a\u0438 +Outline_stroke=\u0421\u0442\u0438\u043b\u044c \u0440\u0430\u043c\u043a\u0438: +Outline_Paint=\u041e\u043a\u0440\u0430\u0441\u043a\u0430 \u0440\u0430\u043c\u043a\u0438: +Paint=\u041e\u043a\u0440\u0430\u0441\u043a\u0430: +Palette_Selection=\u0412\u044b\u0431\u043e\u0440 \u043f\u0430\u043b\u0438\u0442\u0440\u044b +Palette=\u041f\u0430\u043b\u0438\u0442\u0440\u0430: +Pen_Stroke_Selection=\u0412\u044b\u0431\u043e\u0440 \u041a\u0430\u0440\u0430\u043d\u0434\u0430\u0448/\u0428\u0442\u0440\u0438\u0445 +Plot=\u0413\u0440\u0430\u0444\u0438\u043a +Range=\u041e\u0431\u043b\u0430\u0441\u0442\u044c +Range_Axis=\u041e\u0441\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 +Select...=\u0412\u044b\u0431\u043e\u0440... +Series_Label_Color=\u0426\u0432\u0435\u0442 \u043c\u0435\u0442\u043a\u0438 \u0441\u0435\u0440\u0438\u0438 +Series_label_font=\u0428\u0440\u0438\u0444\u0442 \u043c\u0435\u0442\u043a\u0438 \u0441\u0435\u0440\u0438\u0438: +Series_label_paint=\u041e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043a\u0438 \u0441\u0435\u0440\u0438\u0438: +Series_Outline_Paint=\u041e\u043a\u0440\u0430\u0441\u043a\u0430 \u0440\u0430\u043c\u043a\u0438 \u0441\u0435\u0440\u0438\u0438: +Series_Outline_Stroke=\u0428\u0442\u0440\u0438\u0445\u043e\u0432\u0430\u044f \u0440\u0430\u043c\u043a\u0430 \u0441\u0435\u0440\u0438\u0438: +Series_Paint=\u041e\u043a\u0440\u0430\u0441\u043a\u0430 \u0441\u0435\u0440\u0438\u0438: +Series_Stroke=\u0428\u0442\u0440\u0438\u0445\u0438 \u0441\u0435\u0440\u0438\u0438: +Show_tick_labels=\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u0441\u0435\u0432\u044b\u0435 \u043e\u0442\u043c\u0435\u0442\u043a\u0438 +Show_tick_marks=\u041f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c \u043e\u0441\u0435\u0432\u044b\u0435 \u0448\u0442\u0440\u0438\u0445\u0438 +Set_palette...=\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0430\u043b\u0438\u0442\u0440\u0443... +Step_Palette=\u0428\u0430\u0433 \u043f\u0430\u043b\u0438\u0442\u0440\u044b: +Stroke_Selection=\u0412\u044b\u0431\u043e\u0440 \u0448\u0442\u0440\u0438\u0445\u0430 +Text=\u0422\u0435\u043a\u0441\u0442: +Ticks=\u041e\u0442\u043c\u0435\u0442\u043a\u0438 +TickUnit=TickUnit +Tick_label_font=\u0428\u0440\u0438\u0444\u0442 \u043e\u0442\u043c\u0435\u0442\u043a\u0438: +Tick_Label_Insets=\u041e\u0442\u0441\u0442\u0443\u043f\u044b \u043e\u0442\u043c\u0435\u0442\u043e\u043a: +Title_Color=\u0426\u0432\u0435\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_zh_CN.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_zh_CN.properties new file mode 100755 index 0000000..00fc210 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/LocalizationBundle_zh_CN.properties @@ -0,0 +1,73 @@ +# org.jfree.chart.ui.ui ResourceBundle properties file +# +# Changes +# ------- +# 29-Jun-2005 : Initial version, see: http://www.jfree.org/phpBB2/viewtopic.php?t=13495; +# + +\:=: +Appearance=\u5916\u89c2 +AngleOffset=Angle Offset +Auto-adjust_range=\u81ea\u52a8\u8c03\u8282\u8303\u56f4: +Auto-TickUnit_Selection=Auto-Selection of TickUnit +Background=\u80cc\u666f: +Background_Color=\u80cc\u666f\u8272 +Background_paint=\u80cc\u666f\u586b\u5145: +Color=\u989c\u8272: +Color_Bar=\u8272\u5f69\u6761 +Domain_Axis=\u9879\u76ee\u8f74 +Draw_anti-aliased=\u7ed8\u5236\u53cd\u6df7\u6dc6 +Draw_lines=\u753b\u7ebf: +Draw_shapes=\u753b\u5f62\u72b6: +Edit...=\u7f16\u8f91... +Edit_Insets=\u7f16\u8f91\u5d4c\u5165 +Font=\u5b57\u4f53: +Font_Selection=\u5b57\u4f53\u9009\u62e9 +General=\u7efc\u5408: +General1=\u7efc\u5408 +Grid_Color=\u7f51\u683c\u989c\u8272 +Insets=\u63d2\u56fe: +Invert_Palette=\u53cd\u8f6c\u8c03\u8272\u677f: +Label=\u6807\u7b7e: +Label_Color=\u6807\u7b7e\u989c\u8272 +Label_Insets=\u6807\u7b7e\u63d2\u56fe: +Legend=\u56fe\u4f8b +Maximum_range_value=\u6700\u5927\u503c: +Manual_TickUnit_value=TickUnit value +Minimum_range_value=\u6700\u5c0f\u503c: +No_editor_implemented=\u6ca1\u6709\u53ef\u6267\u884c\u7684\u7f16\u8f91\u5668 +Orientation=\u65b9\u5411: +Other=\u5176\u4ed6 +Outline=\u8f6e\u5ed3: +Outline_Color=\u8f6e\u5ed3\u989c\u8272 +Outline_stroke=\u8f6e\u5ed3\u7ebf\u6761: +Outline_Paint=\u8f6e\u5ed3\u586b\u5145: +Paint=\u586b\u5145: +Palette_Selection=\u8c03\u8272\u677f\u9009\u62e9 +Palette=\u8c03\u8272\u677f: +Pen_Stroke_Selection=\u753b\u7b14/\u7ebf\u578b \u9009\u62e9 +Plot=\u56fe +Range=\u8303\u56f4 +Range_Axis=\u8303\u56f4\u8f74 +Select...=\u9009\u62e9... +Series_Label_Color=\u5e8f\u5217\u6807\u7b7e\u8272 +Series_label_font=\u5e8f\u5217\u6807\u7b7e\u5b57\u4f53: +Series_label_paint=\u5e8f\u5217\u6807\u7b7e\u586b\u5145: +Series_Outline_Paint=\u5e8f\u5217\u8f6e\u5ed3\u586b\u5145: +Series_Outline_Stroke=\u5e8f\u5217\u8f6e\u5ed3\u7ebf\u578b: +Series_Paint=\u5e8f\u5217\u586b\u5145: +Series_Stroke=\u5e8f\u5217\u7ebf\u578b: +Show_Legend=\u663e\u793a\u56fe\u4f8b: +Show_tick_labels=\u663e\u793a\u523b\u5ea6\u6807\u7b7e +Show_tick_marks=\u663e\u793a\u6807\u7b7e\u8bb0\u53f7 +Show_Title=\u663e\u793a\u6807\u9898: +Set_palette...=\u8bbe\u7f6e\u8c03\u8272\u677f... +Step_Palette=Step \u8c03\u8272\u677f: +Stroke_Selection=\u7ebf\u578b\u9009\u62e9 +Text=\u6b63\u6587: +Ticks=\u523b\u5ea6\u7ebf +TickUnit=TickUnit +Tick_label_font=\u523b\u5ea6\u6807\u7b7e\u5b57\u4f53: +Tick_Label_Insets=\u523b\u5ea6\u6807\u7b7e\u63d2\u56fe: +Title=\u6807\u9898 +Title_Color=\u6807\u9898\u989c\u8272 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/PaletteChooserPanel.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/PaletteChooserPanel.java new file mode 100755 index 0000000..00892e7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/PaletteChooserPanel.java @@ -0,0 +1,90 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * PaletteChooserPanel.java + * ------------------------ + * (C) Copyright 2002-2008, by David M. O'Donnell. + * + * Original Author: David M. O'Donnell; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 27-Jan-2003 : Added standard header (DG); + * 31-Jan-2007 : Deprecated (DG); + * + */ + +package org.jfree.chart.editor; + +import java.awt.BorderLayout; + +import javax.swing.JComboBox; +import javax.swing.JPanel; + +import org.jfree.chart.plot.ColorPalette; +import org.jfree.chart.plot.RainbowPalette; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYBlockRenderer; + +/** + * A component for choosing a palette from a list of available palettes. + * + * @deprecated This class is no longer supported. If you are creating + * contour plots, please try to use {@link XYPlot} and + * {@link XYBlockRenderer}. + */ +class PaletteChooserPanel extends JPanel { + + /** A combo for selecting the stroke. */ + private JComboBox selector; + + /** + * Constructor. + * + * @param current the current palette sample. + * @param available an array of 'available' palette samples. + */ + public PaletteChooserPanel(PaletteSample current, + PaletteSample[] available) { + setLayout(new BorderLayout()); + this.selector = new JComboBox(available); + this.selector.setSelectedItem(current); + this.selector.setRenderer(new PaletteSample(new RainbowPalette())); + add(this.selector); + } + + /** + * Returns the selected palette. + * + * @return The selected palette. + */ + public ColorPalette getSelectedPalette() { + PaletteSample sample = (PaletteSample) this.selector.getSelectedItem(); + return sample.getPalette(); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/PaletteSample.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/PaletteSample.java new file mode 100755 index 0000000..42156e6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/PaletteSample.java @@ -0,0 +1,173 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * PaletteSample.java + * ------------------ + * (C) Copyright 2002-2008, by David M. O'Donnell. + * + * Original Author: David M. O'Donnell; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 21-Jan-2003 : Added standard header (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 31-Jan-2007 : Deprecated (DG); + * + */ + +package org.jfree.chart.editor; + +import java.awt.BasicStroke; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Insets; +import java.awt.RenderingHints; +import java.awt.geom.Line2D; + +import javax.swing.JComponent; +import javax.swing.JList; +import javax.swing.ListCellRenderer; + +import org.jfree.chart.plot.ColorPalette; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYBlockRenderer; + + +/** + * A panel that displays a palette sample. + * + * @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 PaletteSample extends JComponent implements ListCellRenderer { + + /** The palette being displayed. */ + private ColorPalette palette; + + /** The preferred size of the component; */ + private Dimension preferredSize; + + /** + * Creates a new sample. + * + * @param palette the palette. + */ + public PaletteSample(ColorPalette palette) { + this.palette = palette; + this.preferredSize = new Dimension(80, 18); + } + + /** + * Returns a list cell renderer for the stroke, so the sample can be + * displayed in a list or combo. + * + * @param list the list component. + * @param value the value. + * @param index the index. + * @param isSelected a flag that indicates whether or not the item is + * selected. + * @param cellHasFocus a flag that indicates whether or not the cell has + * the focus. + * + * @return The renderer. + */ + @Override + public Component getListCellRendererComponent(JList list, Object value, + int index, boolean isSelected, boolean cellHasFocus) { + if (value instanceof PaletteSample) { + PaletteSample in = (PaletteSample) value; + setPalette(in.getPalette()); + } + return this; + } + + /** + * Returns the current palette object being displayed. + * + * @return The palette. + */ + public ColorPalette getPalette() { + return this.palette; + } + + /** + * Returns the preferred size of the component. + * + * @return The preferred size. + */ + @Override + public Dimension getPreferredSize() { + return this.preferredSize; + } + + /** + * Draws the sample. + * + * @param g the graphics device. + */ + @Override + public void paintComponent(Graphics g) { + + Graphics2D g2 = (Graphics2D) g; + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_OFF); + Dimension size = getSize(); + Insets insets = getInsets(); + double ww = size.getWidth() - insets.left - insets.right; + double hh = size.getHeight() - insets.top - insets.bottom; + + g2.setStroke(new BasicStroke(1.0f)); + + double y1 = insets.top; + double y2 = y1 + hh; + double xx = insets.left; + Line2D line = new Line2D.Double(); + int count = 0; + while (xx <= insets.left + ww) { + count++; + line.setLine(xx, y1, xx, y2); + g2.setPaint(this.palette.getColor(count)); + g2.draw(line); + xx += 1; + } + } + + /** + * Sets the palette object being displayed. + * + * @param palette the palette. + */ + public void setPalette(ColorPalette palette) { + this.palette = palette; + this.repaint(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/package.html new file mode 100755 index 0000000..974d71e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/editor/package.html @@ -0,0 +1,7 @@ + + + +Provides a simple (but so far incomplete) framework for editing chart +properties. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/EncoderUtil.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/EncoderUtil.java new file mode 100755 index 0000000..45d2c11 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/EncoderUtil.java @@ -0,0 +1,191 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * EncoderUtil.java + * ---------------- + * (C) Copyright 2004-2008, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): -; + * + * Changes + * ------- + * 01-Aug-2004 : Initial version (RA); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.encoders; + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.OutputStream; + +/** + * A collection of utility methods for encoding images and returning them as a + * byte[] or writing them directly to an OutputStream. + */ +public class EncoderUtil { + + /** + * Encode the image in a specific format. + * + * @param image The image to be encoded. + * @param format The {@link ImageFormat} to use. + * + * @return The byte[] that is the encoded image. + * @throws IOException + */ + public static byte[] encode(BufferedImage image, String format) + throws IOException { + ImageEncoder imageEncoder = ImageEncoderFactory.newInstance(format); + return imageEncoder.encode(image); + } + + /** + * Encode the image in a specific format. + * + * @param image The image to be encoded. + * @param format The {@link ImageFormat} to use. + * @param encodeAlpha Whether to encode alpha transparency (not supported + * by all ImageEncoders). + * @return The byte[] that is the encoded image. + * @throws IOException + */ + public static byte[] encode(BufferedImage image, String format, + boolean encodeAlpha) throws IOException { + ImageEncoder imageEncoder + = ImageEncoderFactory.newInstance(format, encodeAlpha); + return imageEncoder.encode(image); + } + + /** + * Encode the image in a specific format. + * + * @param image The image to be encoded. + * @param format The {@link ImageFormat} to use. + * @param quality The quality to use for the image encoding (not supported + * by all ImageEncoders). + * @return The byte[] that is the encoded image. + * @throws IOException + */ + public static byte[] encode(BufferedImage image, String format, + float quality) throws IOException { + ImageEncoder imageEncoder + = ImageEncoderFactory.newInstance(format, quality); + return imageEncoder.encode(image); + } + + /** + * Encode the image in a specific format. + * + * @param image The image to be encoded. + * @param format The {@link ImageFormat} to use. + * @param quality The quality to use for the image encoding (not supported + * by all ImageEncoders). + * @param encodeAlpha Whether to encode alpha transparency (not supported + * by all ImageEncoders). + * @return The byte[] that is the encoded image. + * @throws IOException + */ + public static byte[] encode(BufferedImage image, String format, + float quality, boolean encodeAlpha) + throws IOException { + ImageEncoder imageEncoder + = ImageEncoderFactory.newInstance(format, quality, encodeAlpha); + return imageEncoder.encode(image); + } + + /** + * Encode the image in a specific format and write it to an OutputStream. + * + * @param image The image to be encoded. + * @param format The {@link ImageFormat} to use. + * @param outputStream The OutputStream to write the encoded image to. + * @throws IOException + */ + public static void writeBufferedImage(BufferedImage image, String format, + OutputStream outputStream) throws IOException { + ImageEncoder imageEncoder = ImageEncoderFactory.newInstance(format); + imageEncoder.encode(image, outputStream); + } + + /** + * Encode the image in a specific format and write it to an OutputStream. + * + * @param image The image to be encoded. + * @param format The {@link ImageFormat} to use. + * @param outputStream The OutputStream to write the encoded image to. + * @param quality The quality to use for the image encoding (not + * supported by all ImageEncoders). + * @throws IOException + */ + public static void writeBufferedImage(BufferedImage image, String format, + OutputStream outputStream, float quality) throws IOException { + ImageEncoder imageEncoder + = ImageEncoderFactory.newInstance(format, quality); + imageEncoder.encode(image, outputStream); + } + + /** + * Encode the image in a specific format and write it to an OutputStream. + * + * @param image The image to be encoded. + * @param format The {@link ImageFormat} to use. + * @param outputStream The OutputStream to write the encoded image to. + * @param encodeAlpha Whether to encode alpha transparency (not + * supported by all ImageEncoders). + * @throws IOException + */ + public static void writeBufferedImage(BufferedImage image, String format, + OutputStream outputStream, boolean encodeAlpha) throws IOException { + ImageEncoder imageEncoder + = ImageEncoderFactory.newInstance(format, encodeAlpha); + imageEncoder.encode(image, outputStream); + } + + /** + * Encode the image in a specific format and write it to an OutputStream. + * + * @param image The image to be encoded. + * @param format The {@link ImageFormat} to use. + * @param outputStream The OutputStream to write the encoded image to. + * @param quality The quality to use for the image encoding (not + * supported by all ImageEncoders). + * @param encodeAlpha Whether to encode alpha transparency (not supported + * by all ImageEncoders). + * @throws IOException + */ + public static void writeBufferedImage(BufferedImage image, String format, + OutputStream outputStream, float quality, boolean encodeAlpha) + throws IOException { + ImageEncoder imageEncoder + = ImageEncoderFactory.newInstance(format, quality, encodeAlpha); + imageEncoder.encode(image, outputStream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/ImageEncoder.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/ImageEncoder.java new file mode 100755 index 0000000..20d02c9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/ImageEncoder.java @@ -0,0 +1,106 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * ImageEncoder.java + * ----------------- + * (C) Copyright 2004-2008, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): -; + * + * Changes + * ------- + * 01-Aug-2004 : Initial version (RA); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.encoders; + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.OutputStream; + +/** + * Interface for abstracting different types of image encoders. + */ +public interface ImageEncoder { + + /** + * Encodes an image in a particular format. + * + * @param bufferedImage The image to be encoded. + * + * @return The byte[] that is the encoded image. + * + * @throws IOException + */ + public byte[] encode(BufferedImage bufferedImage) throws IOException; + + + /** + * Encodes an image in a particular format and writes it to an OutputStream. + * + * @param bufferedImage The image to be encoded. + * @param outputStream The OutputStream to write the encoded image to. + * @throws IOException + */ + public void encode(BufferedImage bufferedImage, OutputStream outputStream) + throws IOException; + + /** + * Get the quality of the image encoding. + * + * @return A float representing the quality. + */ + public float getQuality(); + + /** + * Set the quality of the image encoding (not supported by all + * ImageEncoders). + * + * @param quality A float representing the quality. + */ + public void setQuality(float quality); + + /** + * Get whether the encoder should encode alpha transparency. + * + * @return Whether the encoder is encoding alpha transparency. + */ + public boolean isEncodingAlpha(); + + /** + * Set whether the encoder should encode alpha transparency (not + * supported by all ImageEncoders). + * + * @param encodingAlpha Whether the encoder should encode alpha + * transparency. + */ + public void setEncodingAlpha(boolean encodingAlpha); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/ImageEncoderFactory.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/ImageEncoderFactory.java new file mode 100755 index 0000000..2c42a32 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/ImageEncoderFactory.java @@ -0,0 +1,155 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * ImageEncoderFactory.java + * ------------------------ + * (C) Copyright 2004-2012, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 01-Aug-2004 : Initial version (RA); + * 01-Nov-2005 : Now using ImageIO for JPEG encoding, so we no longer have a + * dependency on com.sun.* which isn't available on all + * implementations (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 06-Jul-2008 : Remove encoder only used in JDK 1.3 (DG); + * + */ + +package org.jfree.chart.encoders; + +import java.util.HashMap; +import java.util.Map; + +/** + * Factory class for returning {@link ImageEncoder}s for different + * {@link ImageFormat}s. + */ +public class ImageEncoderFactory { + + /** Storage for the encoders. */ + private static Map encoders = null; + + static { + init(); + } + + /** + * Sets up default encoders (uses Sun PNG Encoder if JDK 1.4+ and the + * SunPNGEncoderAdapter class is available). + */ + private static void init() { + encoders = new HashMap(); + encoders.put("jpeg", "org.jfree.chart.encoders.SunJPEGEncoderAdapter"); + encoders.put("png", "org.jfree.chart.encoders.SunPNGEncoderAdapter"); + } + + /** + * Used to set additional encoders or replace default ones. + * + * @param format The image format name. + * @param imageEncoderClassName The name of the ImageEncoder class. + */ + public static void setImageEncoder(String format, + String imageEncoderClassName) { + encoders.put(format, imageEncoderClassName); + } + + /** + * Used to retrieve an ImageEncoder for a specific image format. + * + * @param format The image format required. + * + * @return The ImageEncoder or null if none available. + */ + public static ImageEncoder newInstance(String format) { + ImageEncoder imageEncoder = null; + String className = (String) encoders.get(format); + if (className == null) { + throw new IllegalArgumentException("Unsupported image format - " + + format); + } + try { + Class imageEncoderClass = Class.forName(className); + imageEncoder = (ImageEncoder) imageEncoderClass.newInstance(); + } + catch (Exception e) { + throw new IllegalArgumentException(e.toString()); + } + return imageEncoder; + } + + /** + * Used to retrieve an ImageEncoder for a specific image format. + * + * @param format The image format required. + * @param quality The quality to be set before returning. + * + * @return The ImageEncoder or null if none available. + */ + public static ImageEncoder newInstance(String format, float quality) { + ImageEncoder imageEncoder = newInstance(format); + imageEncoder.setQuality(quality); + return imageEncoder; + } + + /** + * Used to retrieve an ImageEncoder for a specific image format. + * + * @param format The image format required. + * @param encodingAlpha Sets whether alpha transparency should be encoded. + * + * @return The ImageEncoder or null if none available. + */ + public static ImageEncoder newInstance(String format, + boolean encodingAlpha) { + ImageEncoder imageEncoder = newInstance(format); + imageEncoder.setEncodingAlpha(encodingAlpha); + return imageEncoder; + } + + /** + * Used to retrieve an ImageEncoder for a specific image format. + * + * @param format The image format required. + * @param quality The quality to be set before returning. + * @param encodingAlpha Sets whether alpha transparency should be encoded. + * + * @return The ImageEncoder or null if none available. + */ + public static ImageEncoder newInstance(String format, float quality, + boolean encodingAlpha) { + ImageEncoder imageEncoder = newInstance(format); + imageEncoder.setQuality(quality); + imageEncoder.setEncodingAlpha(encodingAlpha); + return imageEncoder; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/ImageFormat.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/ImageFormat.java new file mode 100755 index 0000000..76716ee --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/ImageFormat.java @@ -0,0 +1,58 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * ImageFormat.java + * ---------------- + * (C) Copyright 2004-2008, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): -; + * + * Changes + * ------- + * 01-Aug-2004 : Initial version (RA); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.encoders; + +/** + * Interface used for referencing different image formats. + */ +public interface ImageFormat { + + /** Portable Network Graphics - lossless */ + public static String PNG = "png"; + + /** Joint Photographic Experts Group format - lossy */ + public static String JPEG = "jpeg"; + + /** Graphics Interchange Format - lossless, but 256 colour restriction */ + public static String GIF = "gif"; + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/KeypointPNGEncoderAdapter.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/KeypointPNGEncoderAdapter.java new file mode 100755 index 0000000..0a3b7e6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/KeypointPNGEncoderAdapter.java @@ -0,0 +1,144 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * KeypointPNGEncoderAdapter.java + * ------------------------------ + * (C) Copyright 2004-2013, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): -; + * + * Changes + * ------- + * 01-Aug-2004 : Initial version (RA); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.encoders; + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.OutputStream; + +import com.keypoint.PngEncoder; +import org.jfree.chart.util.ParamChecks; + +/** + * Adapter class for the Keypoint PNG Encoder. The ImageEncoderFactory will + * only return a reference to this class by default if the library has been + * compiled under a JDK < 1.4 or is being run using a JDK < 1.4. + */ +public class KeypointPNGEncoderAdapter implements ImageEncoder { + + /** The quality setting. */ + private int quality = 9; + + /** Encode alpha? */ + private boolean encodingAlpha = false; + + /** + * Get the quality of the image encoding. The underlying encoder uses int + * values: 0 for no compression, and values 1 through 9 for various levels + * of compression (1 is best speed, 9 is best compression). + * + * @return A float representing the quality. + */ + @Override + public float getQuality() { + return this.quality; + } + + /** + * Set the quality of the image encoding (supported). The underlying + * encoder uses int values: 0 for no compression, and values 1 through 9 + * for various levels of compression (1 is best speed, 9 is best + * compression). + * + * @param quality A float representing the quality. + */ + @Override + public void setQuality(float quality) { + this.quality = (int) quality; + } + + /** + * Get whether the encoder should encode alpha transparency. + * + * @return Whether the encoder is encoding alpha transparency. + */ + @Override + public boolean isEncodingAlpha() { + return this.encodingAlpha; + } + + /** + * Set whether the encoder should encode alpha transparency (supported). + * + * @param encodingAlpha Whether the encoder should encode alpha + * transparency. + */ + @Override + public void setEncodingAlpha(boolean encodingAlpha) { + this.encodingAlpha = encodingAlpha; + } + + /** + * Encodes an image in PNG format. + * + * @param bufferedImage The image to be encoded. + * @return The byte[] that is the encoded image. + * @throws IOException + */ + @Override + public byte[] encode(BufferedImage bufferedImage) throws IOException { + ParamChecks.nullNotPermitted(bufferedImage, "bufferedImage"); + PngEncoder encoder = new PngEncoder(bufferedImage, this.encodingAlpha, + 0, this.quality); + return encoder.pngEncode(); + } + + /** + * Encodes an image in PNG format and writes it to an + * OutputStream. + * + * @param bufferedImage The image to be encoded. + * @param outputStream The OutputStream to write the encoded image to. + * @throws IOException + */ + @Override + public void encode(BufferedImage bufferedImage, OutputStream outputStream) + throws IOException { + ParamChecks.nullNotPermitted(bufferedImage, "bufferedImage"); + ParamChecks.nullNotPermitted(outputStream, "outputStream"); + PngEncoder encoder = new PngEncoder(bufferedImage, this.encodingAlpha, + 0, this.quality); + outputStream.write(encoder.pngEncode()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/SunJPEGEncoderAdapter.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/SunJPEGEncoderAdapter.java new file mode 100755 index 0000000..37db826 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/SunJPEGEncoderAdapter.java @@ -0,0 +1,181 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * SunJPEGEncoderAdapter.java + * -------------------------- + * (C) Copyright 2004-2013, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 01-Aug-2004 : Initial version (RA); + * 01-Nov-2005 : To remove the dependency on non-supported APIs, use ImageIO + * instead of com.sun.image.codec.jpeg.JPEGImageEncoder - this + * adapter will only be available on JDK 1.4 or later (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 20-Jul-2006 : Pass quality setting to ImageIO. Also increased default + * value to 0.95 (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.encoders; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Iterator; + +import javax.imageio.IIOImage; +import javax.imageio.ImageIO; +import javax.imageio.ImageWriteParam; +import javax.imageio.ImageWriter; +import javax.imageio.stream.ImageOutputStream; +import org.jfree.chart.util.ParamChecks; + +/** + * Adapter class for the Sun JPEG Encoder. The {@link ImageEncoderFactory} + * will only return a reference to this class by default if the library has + * been compiled under a JDK 1.4+ and is being run using a JRE 1.4+. + */ +public class SunJPEGEncoderAdapter implements ImageEncoder { + + /** The quality setting (in the range 0.0f to 1.0f). */ + private float quality = 0.95f; + + /** + * Creates a new SunJPEGEncoderAdapter instance. + */ + public SunJPEGEncoderAdapter() { + } + + /** + * Returns the quality of the image encoding, which is a number in the + * range 0.0f to 1.0f (higher values give better quality output, but larger + * file sizes). The default value is 0.95f. + * + * @return A float representing the quality, in the range 0.0f to 1.0f. + * + * @see #setQuality(float) + */ + @Override + public float getQuality() { + return this.quality; + } + + /** + * Set the quality of the image encoding. + * + * @param quality A float representing the quality (in the range 0.0f to + * 1.0f). + * + * @see #getQuality() + */ + @Override + public void setQuality(float quality) { + if (quality < 0.0f || quality > 1.0f) { + throw new IllegalArgumentException( + "The 'quality' must be in the range 0.0f to 1.0f"); + } + this.quality = quality; + } + + /** + * Returns false always, indicating that this encoder does not + * encode alpha transparency. + * + * @return false. + */ + @Override + public boolean isEncodingAlpha() { + return false; + } + + /** + * Set whether the encoder should encode alpha transparency (this is not + * supported for JPEG, so this method does nothing). + * + * @param encodingAlpha ignored. + */ + @Override + public void setEncodingAlpha(boolean encodingAlpha) { + // No op + } + + /** + * Encodes an image in JPEG format. + * + * @param bufferedImage the image to be encoded (null not + * permitted). + * + * @return The byte[] that is the encoded image. + * + * @throws IOException if there is an I/O problem. + * @throws NullPointerException if bufferedImage is + * null. + */ + @Override + public byte[] encode(BufferedImage bufferedImage) throws IOException { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + encode(bufferedImage, outputStream); + return outputStream.toByteArray(); + } + + /** + * Encodes an image in JPEG format and writes it to an output stream. + * + * @param bufferedImage the image to be encoded (null not + * permitted). + * @param outputStream the OutputStream to write the encoded image to + * (null not permitted). + * + * @throws IOException if there is an I/O problem. + * @throws NullPointerException if bufferedImage is + * null. + */ + @Override + public void encode(BufferedImage bufferedImage, OutputStream outputStream) + throws IOException { + ParamChecks.nullNotPermitted(bufferedImage, "bufferedImage"); + ParamChecks.nullNotPermitted(outputStream, "outputStream"); + Iterator iterator = ImageIO.getImageWritersByFormatName("jpeg"); + ImageWriter writer = (ImageWriter) iterator.next(); + ImageWriteParam p = writer.getDefaultWriteParam(); + p.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); + p.setCompressionQuality(this.quality); + ImageOutputStream ios = ImageIO.createImageOutputStream(outputStream); + writer.setOutput(ios); + writer.write(null, new IIOImage(bufferedImage, null, null), p); + ios.flush(); + writer.dispose(); + ios.close(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/SunPNGEncoderAdapter.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/SunPNGEncoderAdapter.java new file mode 100755 index 0000000..b606874 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/SunPNGEncoderAdapter.java @@ -0,0 +1,134 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * SunPNGEncoderAdapter.java + * ------------------------- + * (C) Copyright 2004-2013, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): -; + * + * Changes + * ------- + * 01-Aug-2004 : Initial version (RA); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.encoders; + +import java.awt.image.BufferedImage; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; + +import javax.imageio.ImageIO; +import org.jfree.chart.util.ParamChecks; + +/** + * Adapter class for the Sun PNG Encoder. The ImageEncoderFactory will only + * return a reference to this class by default if the library has been compiled + * under a JDK 1.4+ and is being run using a JDK 1.4+. + */ +public class SunPNGEncoderAdapter implements ImageEncoder { + + /** + * Get the quality of the image encoding (always 0.0). + * + * @return A float representing the quality. + */ + @Override + public float getQuality() { + return 0.0f; + } + + /** + * Set the quality of the image encoding (not supported in this + * ImageEncoder). + * + * @param quality A float representing the quality. + */ + @Override + public void setQuality(float quality) { + // No op + } + + /** + * Get whether the encoder should encode alpha transparency (always false). + * + * @return Whether the encoder is encoding alpha transparency. + */ + @Override + public boolean isEncodingAlpha() { + return false; + } + + /** + * Set whether the encoder should encode alpha transparency (not + * supported in this ImageEncoder). + * + * @param encodingAlpha Whether the encoder should encode alpha + * transparency. + */ + @Override + public void setEncodingAlpha(boolean encodingAlpha) { + // No op + } + + /** + * Encodes an image in PNG format. + * + * @param bufferedImage The image to be encoded. + * + * @return The byte[] that is the encoded image. + * + * @throws IOException + */ + @Override + public byte[] encode(BufferedImage bufferedImage) throws IOException { + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + encode(bufferedImage, outputStream); + return outputStream.toByteArray(); + } + + /** + * Encodes an image in PNG format and writes it to an OutputStream. + * + * @param bufferedImage The image to be encoded. + * @param outputStream The OutputStream to write the encoded image to. + * @throws IOException + */ + @Override + public void encode(BufferedImage bufferedImage, OutputStream outputStream) + throws IOException { + ParamChecks.nullNotPermitted(bufferedImage, "bufferedImage"); + ParamChecks.nullNotPermitted(outputStream, "outputStream"); + ImageIO.write(bufferedImage, ImageFormat.PNG, outputStream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/package.html new file mode 100755 index 0000000..fb5bd62 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/encoders/package.html @@ -0,0 +1,6 @@ + + + +Classes related to the encoding of charts to different image formats. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/AxisEntity.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/AxisEntity.java new file mode 100755 index 0000000..ae6f68b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/AxisEntity.java @@ -0,0 +1,215 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * AxisEntity.java + * ---------------- + * (C) Copyright 2009-2013, by Object Refinery Limited and Contributors. + * + * Original Author: Peter Kolb; + * Contributor(s): ; + * + * Changes: + * -------- + * 15-Feb-2009 : Version 1 (PK); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.entity; + +import java.awt.Shape; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.axis.Axis; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.util.ObjectUtilities; + +/** + * A class that captures information about an {@link Axis} belonging to a + * chart. + * + * @since 1.0.13 + */ +public class AxisEntity extends ChartEntity { + + /** For serialization. */ + private static final long serialVersionUID = -4445994133561919083L; + //same as for ChartEntity! + + /** The axis for the entity. */ + private Axis axis; + + /** + * Creates a new axis entity. + * + * @param area the area (null not permitted). + * @param axis the axis (null not permitted). + */ + public AxisEntity(Shape area, Axis axis) { + // defer argument checks... + this(area, axis, null); + } + + /** + * Creates a new axis entity. + * + * @param area the area (null not permitted). + * @param axis the axis (null not permitted). + * @param toolTipText the tool tip text (null permitted). + */ + public AxisEntity(Shape area, Axis axis, String toolTipText) { + // defer argument checks... + this(area, axis, toolTipText, null); + } + + /** + * Creates a new axis entity. + * + * @param area the area (null not permitted). + * @param axis the axis (null not permitted). + * @param toolTipText the tool tip text (null permitted). + * @param urlText the URL text for HTML image maps (null + * permitted). + */ + public AxisEntity(Shape area, Axis axis, String toolTipText, + String urlText) { + super(area, toolTipText, urlText); + ParamChecks.nullNotPermitted(axis, "axis"); + this.axis = axis; + } + + /** + * Returns the axis that occupies the entity area. + * + * @return The axis (never null). + */ + public Axis getAxis() { + return this.axis; + } + + /** + * Returns a string representation of the chart entity, useful for + * debugging. + * + * @return A string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder("AxisEntity: "); + sb.append("tooltip = "); + sb.append(getToolTipText()); + return sb.toString(); + } + + /** + * Tests the entity for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof AxisEntity)) { + return false; + } + AxisEntity that = (AxisEntity) obj; + if (!getArea().equals(that.getArea())) { + return false; + } + if (!ObjectUtilities.equal(getToolTipText(), that.getToolTipText())) { + return false; + } + if (!ObjectUtilities.equal(getURLText(), that.getURLText())) { + return false; + } + if (!(this.axis.equals(that.axis))) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 39; + result = HashUtilities.hashCode(result, getToolTipText()); + result = HashUtilities.hashCode(result, getURLText()); + return result; + } + + /** + * Returns a clone of the entity. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning the + * entity. + */ + @Override + 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(getArea(), 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(); + setArea(SerialUtilities.readShape(stream)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/CategoryItemEntity.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/CategoryItemEntity.java new file mode 100755 index 0000000..2f5d8fe --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/CategoryItemEntity.java @@ -0,0 +1,384 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * CategoryItemEntity.java + * ----------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Richard Atkinson; + * Christian W. Zuckschwerdt; + * + * Changes: + * -------- + * 23-May-2002 : Version 1 (DG); + * 12-Jun-2002 : Added Javadoc comments (DG); + * 26-Jun-2002 : Added getImageMapAreaTag() method (DG); + * 05-Aug-2002 : Added new constructor to populate URLText + * Moved getImageMapAreaTag() to ChartEntity (superclass) (RA); + * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 30-Jul-2003 : Added CategoryDataset reference (CZ); + * 20-May-2004 : Added equals() and clone() methods, and implemented + * Serializable (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 18-May-2007 : Updated to use row and column keys to identify item (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.entity; + +import java.awt.Shape; +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.category.CategoryDataset; +import org.jfree.util.ObjectUtilities; + +/** + * A chart entity that represents one item within a category plot. + */ +public class CategoryItemEntity extends ChartEntity + implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -8657249457902337349L; + + /** The dataset. */ + private CategoryDataset dataset; + + /** + * The series (zero-based index). + * + * @deprecated As of 1.0.6, this field is redundant as you can derive the + * index from the rowKey field. + */ + private int series; + + /** + * The category. + * + * @deprecated As of 1.0.6, this field is deprecated in favour of the + * columnKey field. + */ + private Object category; + + /** + * The category index. + * + * @deprecated As of 1.0.6, this field is redundant as you can derive the + * index from the columnKey field. + */ + private int categoryIndex; + + /** + * The row key. + * + * @since 1.0.6 + */ + private Comparable rowKey; + + /** + * The column key. + * + * @since 1.0.6 + */ + private Comparable columnKey; + + /** + * Creates a new category item entity. + * + * @param area the area (null not permitted). + * @param toolTipText the tool tip text. + * @param urlText the URL text for HTML image maps. + * @param dataset the dataset. + * @param series the series (zero-based index). + * @param category the category. + * @param categoryIndex the category index. + * + * @deprecated As of 1.0.6, use {@link #CategoryItemEntity(Shape, String, + * String, CategoryDataset, Comparable, Comparable)}. + */ + public CategoryItemEntity(Shape area, String toolTipText, String urlText, + CategoryDataset dataset, + int series, Object category, int categoryIndex) { + + super(area, toolTipText, urlText); + ParamChecks.nullNotPermitted(dataset, "dataset"); + this.dataset = dataset; + this.series = series; + this.category = category; + this.categoryIndex = categoryIndex; + this.rowKey = dataset.getRowKey(series); + this.columnKey = dataset.getColumnKey(categoryIndex); + } + + /** + * Creates a new entity instance for an item in the specified dataset. + * + * @param area the 'hotspot' area (null not permitted). + * @param toolTipText the tool tip text. + * @param urlText the URL text. + * @param dataset the dataset (null not permitted). + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @since 1.0.6 + */ + public CategoryItemEntity(Shape area, String toolTipText, String urlText, + CategoryDataset dataset, Comparable rowKey, Comparable columnKey) { + super(area, toolTipText, urlText); + ParamChecks.nullNotPermitted(dataset, "dataset"); + this.dataset = dataset; + this.rowKey = rowKey; + this.columnKey = columnKey; + + // populate the deprecated fields + this.series = dataset.getRowIndex(rowKey); + this.category = columnKey; + this.categoryIndex = dataset.getColumnIndex(columnKey); + } + + /** + * Returns the dataset this entity refers to. This can be used to + * differentiate between items in a chart that displays more than one + * dataset. + * + * @return The dataset (never null). + * + * @see #setDataset(CategoryDataset) + */ + public CategoryDataset getDataset() { + return this.dataset; + } + + /** + * Sets the dataset this entity refers to. + * + * @param dataset the dataset (null not permitted). + * + * @see #getDataset() + */ + public void setDataset(CategoryDataset dataset) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + this.dataset = dataset; + } + + /** + * Returns the row key. + * + * @return The row key (never null). + * + * @since 1.0.6 + * + * @see #setRowKey(Comparable) + */ + public Comparable getRowKey() { + return this.rowKey; + } + + /** + * Sets the row key. + * + * @param rowKey the row key (null not permitted). + * + * @since 1.0.6 + * + * @see #getRowKey() + */ + public void setRowKey(Comparable rowKey) { + this.rowKey = rowKey; + // update the deprecated field + this.series = this.dataset.getRowIndex(rowKey); + } + + /** + * Returns the column key. + * + * @return The column key (never null). + * + * @since 1.0.6 + * + * @see #setColumnKey(Comparable) + */ + public Comparable getColumnKey() { + return this.columnKey; + } + + /** + * Sets the column key. + * + * @param columnKey the column key (null not permitted). + * + * @since 1.0.6 + * + * @see #getColumnKey() + */ + public void setColumnKey(Comparable columnKey) { + this.columnKey = columnKey; + // update the deprecated fields + this.category = columnKey; + this.categoryIndex = this.dataset.getColumnIndex(columnKey); + } + + /** + * Returns the series index. + * + * @return The series index. + * + * @see #setSeries(int) + * + * @deprecated As of 1.0.6, you can derive this information from the + * {@link #getRowKey()} method. + */ + public int getSeries() { + return this.series; + } + + /** + * Sets the series index. + * + * @param series the series index (zero-based). + * + * @see #getSeries() + * + * @deprecated As of 1.0.6, you should use {@link #setRowKey(Comparable)} + * to designate the series. + */ + public void setSeries(int series) { + this.series = series; + } + + /** + * Returns the category. + * + * @return The category (possibly null). + * + * @see #setCategory(Object) + * + * @deprecated The return type for this method should be + * Comparable, so it has been deprecated as of + * version 1.0.6 and replaced by {@link #getColumnKey()}. + */ + public Object getCategory() { + return this.category; + } + + /** + * Sets the category. + * + * @param category the category (null permitted). + * + * @see #getCategory() + * + * @deprecated As of version 1.0.6, use {@link #setColumnKey(Comparable)}. + */ + public void setCategory(Object category) { + this.category = category; + } + + /** + * Returns the category index. + * + * @return The index. + * + * @see #setCategoryIndex(int) + * + * @deprecated As of 1.0.6, you can derive this information from the + * {@link #getColumnKey()} method. + */ + public int getCategoryIndex() { + return this.categoryIndex; + } + + /** + * Sets the category index. + * + * @param index the category index. + * + * @see #getCategoryIndex() + * + * @deprecated As of 1.0.6, use {@link #setColumnKey(Comparable)} to + * designate the category. + */ + public void setCategoryIndex(int index) { + this.categoryIndex = index; + } + + /** + * Returns a string representing this object (useful for debugging + * purposes). + * + * @return A string (never null). + */ + @Override + public String toString() { + return "CategoryItemEntity: rowKey=" + this.rowKey + + ", columnKey=" + this.columnKey + ", dataset=" + this.dataset; + } + + /** + * Tests the entity for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CategoryItemEntity)) { + return false; + } + CategoryItemEntity that = (CategoryItemEntity) obj; + if (!this.rowKey.equals(that.rowKey)) { + return false; + } + if (!this.columnKey.equals(that.columnKey)) { + return false; + } + if (!ObjectUtilities.equal(this.dataset, that.dataset)) { + return false; + } + + // check the deprecated fields + if (this.categoryIndex != that.categoryIndex) { + return false; + } + if (this.series != that.series) { + return false; + } + if (!ObjectUtilities.equal(this.category, that.category)) { + return false; + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/CategoryLabelEntity.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/CategoryLabelEntity.java new file mode 100755 index 0000000..7d4706d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/CategoryLabelEntity.java @@ -0,0 +1,132 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * CategoryLabelEntity.java + * ------------------------ + * (C) Copyright 2006-2011, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 02-Oct-2006 : Version 1 (DG); + * 13-Nov-2007 : Added equals() and hashCode() methods (DG); + * + */ + +package org.jfree.chart.entity; + +import java.awt.Shape; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.util.ObjectUtilities; + +/** + * An entity to represent the labels on a {@link CategoryAxis}. + * + * @since 1.0.3 + */ +public class CategoryLabelEntity extends TickLabelEntity { + + /** The category key. */ + private Comparable key; + + /** + * Creates a new entity. + * + * @param key the category key. + * @param area the hotspot. + * @param toolTipText the tool tip text. + * @param urlText the URL text. + */ + public CategoryLabelEntity(Comparable key, Shape area, + String toolTipText, String urlText) { + super(area, toolTipText, urlText); + this.key = key; + } + + /** + * Returns the category key. + * + * @return The category key. + */ + public Comparable getKey() { + return this.key; + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CategoryLabelEntity)) { + return false; + } + CategoryLabelEntity that = (CategoryLabelEntity) obj; + if (!ObjectUtilities.equal(this.key, that.key)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = super.hashCode(); + result = HashUtilities.hashCode(result, this.key); + return result; + } + + /** + * Returns a string representation of this entity. This is primarily + * useful for debugging. + * + * @return A string representation of this entity. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder("CategoryLabelEntity: "); + sb.append("category="); + sb.append(this.key); + sb.append(", tooltip=").append(getToolTipText()); + sb.append(", url=").append(getURLText()); + return sb.toString(); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/ChartEntity.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/ChartEntity.java new file mode 100755 index 0000000..afdc38e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/ChartEntity.java @@ -0,0 +1,436 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * ChartEntity.java + * ---------------- + * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Richard Atkinson; + * Xavier Poinsard; + * Robert Fuller; + * + * Changes: + * -------- + * 23-May-2002 : Version 1 (DG); + * 12-Jun-2002 : Added Javadoc comments (DG); + * 26-Jun-2002 : Added methods for image maps (DG); + * 05-Aug-2002 : Added constructor and accessors for URL support in image maps + * Added getImageMapAreaTag() - previously in subclasses (RA); + * 05-Sep-2002 : Added getImageMapAreaTag(boolean) to support OverLIB for + * tooltips http://www.bosrup.com/web/overlib (RA); + * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 08-Oct-2002 : Changed getImageMapAreaTag to use title instead of alt + * attribute so HTML image maps now work in Mozilla and Opera as + * well as Internet Explorer (RA); + * 13-Mar-2003 : Change getImageMapAreaTag to only return a tag when there is a + * tooltip or URL, 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 : Incorporated fix (791901) submitted by Robert Fuller (DG); + * 19-May-2004 : Added equals() method and implemented Cloneable and + * Serializable (DG); + * 29-Sep-2004 : Implemented PublicCloneable (DG); + * 13-Jan-2005 : Fixed for compliance with XHTML 1.0 (DG); + * 18-Apr-2005 : Use StringBuffer (DG); + * 20-Apr-2005 : Added toString() implementation (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 06-Feb-2007 : API doc update (DG); + * 13-Nov-2007 : Reorganised equals(), implemented hashCode (DG); + * 04-Dec-2007 : Added 'nohref' attribute in getImageMapAreaTag() method, to + * fix bug 1460195 (DG); + * 04-Dec-2007 : Escape the toolTipText and urlText in getImageMapAreaTag() to + * prevent special characters corrupting the HTML (DG); + * 05-Dec-2007 : Previous change reverted - let the tool tip and url tag + * generators handle filtering / escaping (DG); + * + */ + +package org.jfree.chart.entity; + +import java.awt.Shape; +import java.awt.geom.PathIterator; +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.imagemap.ToolTipTagFragmentGenerator; +import org.jfree.chart.imagemap.URLTagFragmentGenerator; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A class that captures information about some component of a chart (a bar, + * line etc). + */ +public class ChartEntity implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -4445994133561919083L; + + /** The area occupied by the entity (in Java 2D space). */ + private transient Shape area; + + /** The tool tip text for the entity. */ + private String toolTipText; + + /** The URL text for the entity. */ + private String urlText; + + /** + * Creates a new chart entity. + * + * @param area the area (null not permitted). + */ + public ChartEntity(Shape area) { + // defer argument checks... + this(area, null); + } + + /** + * Creates a new chart entity. + * + * @param area the area (null not permitted). + * @param toolTipText the tool tip text (null permitted). + */ + public ChartEntity(Shape area, String toolTipText) { + // defer argument checks... + this(area, toolTipText, null); + } + + /** + * Creates a new entity. + * + * @param area the area (null not permitted). + * @param toolTipText the tool tip text (null permitted). + * @param urlText the URL text for HTML image maps (null + * permitted). + */ + public ChartEntity(Shape area, String toolTipText, String urlText) { + ParamChecks.nullNotPermitted(area, "area"); + this.area = area; + this.toolTipText = toolTipText; + this.urlText = urlText; + } + + /** + * Returns the area occupied by the entity (in Java 2D space). + * + * @return The area (never null). + */ + public Shape getArea() { + return this.area; + } + + /** + * Sets the area for the entity. + *

+ * This class conveys information about chart entities back to a client. + * Setting this area doesn't change the entity (which has already been + * drawn). + * + * @param area the area (null not permitted). + */ + public void setArea(Shape area) { + ParamChecks.nullNotPermitted(area, "area"); + this.area = area; + } + + /** + * Returns the tool tip text for the entity. Be aware that this text + * may have been generated from user supplied data, so for security + * reasons some form of filtering should be applied before incorporating + * this text into any HTML output. + * + * @return The tool tip text (possibly null). + */ + public String getToolTipText() { + return this.toolTipText; + } + + /** + * Sets the tool tip text. + * + * @param text the text (null permitted). + */ + public void setToolTipText(String text) { + this.toolTipText = text; + } + + /** + * Returns the URL text for the entity. Be aware that this text + * may have been generated from user supplied data, so some form of + * filtering should be applied before this "URL" is used in any output. + * + * @return The URL text (possibly null). + */ + public String getURLText() { + return this.urlText; + } + + /** + * Sets the URL text. + * + * @param text the text (null permitted). + */ + public void setURLText(String text) { + this.urlText = text; + } + + /** + * Returns a string describing the entity area. This string is intended + * for use in an AREA tag when generating an image map. + * + * @return The shape type (never null). + */ + public String getShapeType() { + if (this.area instanceof Rectangle2D) { + return "rect"; + } + else { + return "poly"; + } + } + + /** + * Returns the shape coordinates as a string. + * + * @return The shape coordinates (never null). + */ + public String getShapeCoords() { + if (this.area instanceof Rectangle2D) { + return getRectCoords((Rectangle2D) this.area); + } + else { + return getPolyCoords(this.area); + } + } + + /** + * Returns a string containing the coordinates (x1, y1, x2, y2) for a given + * rectangle. This string is intended for use in an image map. + * + * @param rectangle the rectangle (null not permitted). + * + * @return Upper left and lower right corner of a rectangle. + */ + private String getRectCoords(Rectangle2D rectangle) { + ParamChecks.nullNotPermitted(rectangle, "rectangle"); + int x1 = (int) rectangle.getX(); + int y1 = (int) rectangle.getY(); + int x2 = x1 + (int) rectangle.getWidth(); + int y2 = y1 + (int) rectangle.getHeight(); + // fix by rfuller + if (x2 == x1) { + x2++; + } + if (y2 == y1) { + y2++; + } + // end fix by rfuller + return x1 + "," + y1 + "," + x2 + "," + y2; + } + + /** + * Returns a string containing the coordinates for a given shape. This + * string is intended for use in an image map. + * + * @param shape the shape (null not permitted). + * + * @return The coordinates for a given shape as string. + */ + private String getPolyCoords(Shape shape) { + ParamChecks.nullNotPermitted(shape, "shape"); + StringBuilder result = new StringBuilder(); + boolean first = true; + float[] coords = new float[6]; + PathIterator pi = shape.getPathIterator(null, 1.0); + while (!pi.isDone()) { + pi.currentSegment(coords); + if (first) { + first = false; + result.append((int) coords[0]); + result.append(",").append((int) coords[1]); + } + else { + result.append(","); + result.append((int) coords[0]); + result.append(","); + result.append((int) coords[1]); + } + pi.next(); + } + return result.toString(); + } + + /** + * Returns an HTML image map tag for this entity. The returned fragment + * should be XHTML 1.0 compliant. + * + * @param toolTipTagFragmentGenerator a generator for the HTML fragment + * that will contain the tooltip text (null not permitted + * if this entity contains tooltip information). + * @param urlTagFragmentGenerator a generator for the HTML fragment that + * will contain the URL reference (null not permitted if + * this entity has a URL). + * + * @return The HTML tag. + */ + public String getImageMapAreaTag( + ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, + URLTagFragmentGenerator urlTagFragmentGenerator) { + + StringBuilder tag = new StringBuilder(); + boolean hasURL = (this.urlText == null ? false + : !this.urlText.equals("")); + boolean hasToolTip = (this.toolTipText == null ? false + : !this.toolTipText.equals("")); + if (hasURL || hasToolTip) { + tag.append(""); + } + return tag.toString(); + } + + /** + * Returns a string representation of the chart entity, useful for + * debugging. + * + * @return A string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder("ChartEntity: "); + sb.append("tooltip = "); + sb.append(this.toolTipText); + return sb.toString(); + } + + /** + * Tests the entity for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ChartEntity)) { + return false; + } + ChartEntity that = (ChartEntity) obj; + if (!this.area.equals(that.area)) { + return false; + } + if (!ObjectUtilities.equal(this.toolTipText, that.toolTipText)) { + return false; + } + if (!ObjectUtilities.equal(this.urlText, that.urlText)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 37; + result = HashUtilities.hashCode(result, this.toolTipText); + result = HashUtilities.hashCode(result, this.urlText); + return result; + } + + /** + * Returns a clone of the entity. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning the + * entity. + */ + @Override + 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.area, 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.area = SerialUtilities.readShape(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/ContourEntity.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/ContourEntity.java new file mode 100755 index 0000000..9ecad1a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/ContourEntity.java @@ -0,0 +1,142 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * ContourEntity.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); + * 20-May-2004 : Added equals() and clone() methods and implemented + * Serializable (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.entity; + +import java.awt.Shape; +import java.io.Serializable; + +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYBlockRenderer; + +/** + * Represents an item on a contour chart. + * + * @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 ContourEntity extends ChartEntity + implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 1249570520505992847L; + + /** Holds the index into the dataset for this entity. */ + private int index = -1; + + /** + * Constructor for ContourEntity. + * + * @param area the area. + * @param toolTipText the tooltip text. + */ + public ContourEntity(Shape area, String toolTipText) { + super(area, toolTipText); + } + + /** + * Constructor for ContourEntity. + * + * @param area the area. + * @param toolTipText the tooltip text. + * @param urlText the URL text. + */ + public ContourEntity(Shape area, String toolTipText, String urlText) { + super(area, toolTipText, urlText); + } + + /** + * Returns the index. + * + * @return The index. + */ + public int getIndex() { + return this.index; + } + + /** + * Sets the index. + * + * @param index the index. + */ + public void setIndex(int index) { + this.index = index; + } + + /** + * Tests the entity for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof ContourEntity && super.equals(obj)) { + ContourEntity ce = (ContourEntity) obj; + if (this.index != ce.index) { + return false; + } + return true; + } + return false; + } + + /** + * Returns a clone of the entity. + * + * @return A clone. + * + * @throws CloneNotSupportedException if cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/EntityCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/EntityCollection.java new file mode 100755 index 0000000..8bbb8a9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/EntityCollection.java @@ -0,0 +1,118 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * EntityCollection.java + * --------------------- + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-May-2002 : Version 1 (DG); + * 25-Jun-2002 : Removed unnecessary import (DG); + * 26-Jun-2002 : Added iterator() method (DG); + * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 30-Jan-2004 : Added a method to add a collection of entities. + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * 18-Jan-2005 : Added getEntity() and getEntityCount() methods (DG); + * + */ + +package org.jfree.chart.entity; + +import java.util.Collection; +import java.util.Iterator; + +/** + * This interface defines the methods used to access an ordered list of + * {@link ChartEntity} objects. + */ +public interface EntityCollection { + + /** + * Clears all entities. + */ + public void clear(); + + /** + * Adds an entity to the collection. + * + * @param entity the entity (null not permitted). + */ + public void add(ChartEntity entity); + + /** + * Adds the entities from another collection to this collection. + * + * @param collection the other collection. + */ + public void addAll(EntityCollection collection); + + /** + * Returns an entity whose area contains the specified point. + * + * @param x the x coordinate. + * @param y the y coordinate. + * + * @return The entity. + */ + public ChartEntity getEntity(double x, double y); + + /** + * Returns an entity from the collection. + * + * @param index the index (zero-based). + * + * @return An entity. + */ + public ChartEntity getEntity(int index); + + /** + * Returns the entity count. + * + * @return The entity count. + */ + public int getEntityCount(); + + /** + * Returns the entities in an unmodifiable collection. + * + * @return The entities. + */ + public Collection getEntities(); + + /** + * Returns an iterator for the entities in the collection. + * + * @return An iterator. + */ + public Iterator iterator(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/JFreeChartEntity.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/JFreeChartEntity.java new file mode 100755 index 0000000..e3c348b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/JFreeChartEntity.java @@ -0,0 +1,214 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * JFreeChartEntity.java + * -------------------- + * (C) Copyright 2009-2013, by Object Refinery Limited and Contributors. + * + * Original Author: Peter Kolb; + * Contributor(s): ; + * + * Changes: + * -------- + * 15-Feb-2009 : Version 1 (PK); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.entity; + +import java.awt.Shape; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.util.ObjectUtilities; + +/** + * A class that captures information about an entire chart. + * + * @since 1.0.13 + */ +public class JFreeChartEntity extends ChartEntity { + + /** For serialization. */ + private static final long serialVersionUID = -4445994133561919083L; + //same as for ChartEntity! + + /** The chart. */ + private JFreeChart chart; + + /** + * Creates a new chart entity. + * + * @param area the area (null not permitted). + * @param chart the chart (null not permitted). + */ + public JFreeChartEntity(Shape area, JFreeChart chart) { + // defer argument checks... + this(area, chart, null); + } + + /** + * Creates a new chart entity. + * + * @param area the area (null not permitted). + * @param chart the chart (null not permitted). + * @param toolTipText the tool tip text (null permitted). + */ + public JFreeChartEntity(Shape area, JFreeChart chart, String toolTipText) { + // defer argument checks... + this(area, chart, toolTipText, null); + } + + /** + * Creates a new chart entity. + * + * @param area the area (null not permitted). + * @param chart the chart (null not permitted). + * @param toolTipText the tool tip text (null permitted). + * @param urlText the URL text for HTML image maps (null + * permitted). + */ + public JFreeChartEntity(Shape area, JFreeChart chart, String toolTipText, + String urlText) { + super(area, toolTipText, urlText); + ParamChecks.nullNotPermitted(chart, "chart"); + this.chart = chart; + } + + /** + * Returns the chart that occupies the entity area. + * + * @return The chart (never null). + */ + public JFreeChart getChart() { + return this.chart; + } + + /** + * Returns a string representation of the chart entity, useful for + * debugging. + * + * @return A string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder("JFreeChartEntity: "); + sb.append("tooltip = "); + sb.append(getToolTipText()); + return sb.toString(); + } + + /** + * Tests the entity for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof JFreeChartEntity)) { + return false; + } + JFreeChartEntity that = (JFreeChartEntity) obj; + if (!getArea().equals(that.getArea())) { + return false; + } + if (!ObjectUtilities.equal(getToolTipText(), that.getToolTipText())) { + return false; + } + if (!ObjectUtilities.equal(getURLText(), that.getURLText())) { + return false; + } + if (!(this.chart.equals(that.chart))) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 39; + result = HashUtilities.hashCode(result, getToolTipText()); + result = HashUtilities.hashCode(result, getURLText()); + return result; + } + + /** + * Returns a clone of the entity. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning the + * entity. + */ + @Override + 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(getArea(), 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(); + setArea(SerialUtilities.readShape(stream)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/LegendItemEntity.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/LegendItemEntity.java new file mode 100755 index 0000000..c4bfff2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/LegendItemEntity.java @@ -0,0 +1,219 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * LegendItemEntity.java + * --------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 05-Jun-2003 : Version 1 (DG); + * 20-May-2004 : Added equals() method and implemented Cloneable and + * Serializable (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 18-May-2007 : Added dataset and seriesKey fields (DG); + * + */ + +package org.jfree.chart.entity; + +import java.awt.Shape; +import java.io.Serializable; + +import org.jfree.data.general.Dataset; +import org.jfree.util.ObjectUtilities; + +/** + * An entity that represents an item within a legend. + */ +public class LegendItemEntity extends ChartEntity + implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -7435683933545666702L; + + /** + * The dataset. + * + * @since 1.0.6 + */ + private Dataset dataset; + + /** + * The series key. + * + * @since 1.0.6 + */ + private Comparable seriesKey; + + /** The series index. */ + private int seriesIndex; + + /** + * Creates a legend item entity. + * + * @param area the area. + */ + public LegendItemEntity(Shape area) { + super(area); + } + + /** + * Returns a reference to the dataset that this legend item is derived + * from. + * + * @return The dataset. + * + * @since 1.0.6 + * + * @see #setDataset(Dataset) + */ + public Dataset getDataset() { + return this.dataset; + } + + /** + * Sets a reference to the dataset that this legend item is derived from. + * + * @param dataset the dataset. + * + * @since 1.0.6 + */ + public void setDataset(Dataset dataset) { + this.dataset = dataset; + } + + /** + * Returns the series key that identifies the legend item. + * + * @return The series key. + * + * @since 1.0.6 + * + * @see #setSeriesKey(Comparable) + */ + public Comparable getSeriesKey() { + return this.seriesKey; + } + + /** + * Sets the key for the series. + * + * @param key the key. + * + * @since 1.0.6 + * + * @see #getSeriesKey() + */ + public void setSeriesKey(Comparable key) { + this.seriesKey = key; + } + + /** + * Returns the series index. + * + * @return The series index. + * + * @see #setSeriesIndex(int) + * + * @deprecated As of 1.0.6, use the {@link #getSeriesKey()} method. + */ + public int getSeriesIndex() { + return this.seriesIndex; + } + + /** + * Sets the series index. + * + * @param index the series index. + * + * @see #getSeriesIndex() + * + * @deprecated As of 1.0.6, use the {@link #setSeriesKey(Comparable)} + * method. + */ + public void setSeriesIndex(int index) { + this.seriesIndex = index; + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof LegendItemEntity)) { + return false; + } + LegendItemEntity that = (LegendItemEntity) obj; + if (!ObjectUtilities.equal(this.seriesKey, that.seriesKey)) { + return false; + } + if (this.seriesIndex != that.seriesIndex) { + return false; + } + if (!ObjectUtilities.equal(this.dataset, that.dataset)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the entity. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning the + * object. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Returns a string representing this object (useful for debugging + * purposes). + * + * @return A string (never null). + */ + @Override + public String toString() { + return "LegendItemEntity: seriesKey=" + this.seriesKey + + ", dataset=" + this.dataset; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/PieSectionEntity.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/PieSectionEntity.java new file mode 100755 index 0000000..d41307f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/PieSectionEntity.java @@ -0,0 +1,255 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * PieSectionEntity.java + * --------------------- + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Richard Atkinson; + * Christian W. Zuckschwerdt; + * + * Changes: + * -------- + * 23-May-2002 : Version 1 (DG); + * 12-Jun-2002 : Added Javadoc comments (DG); + * 26-Jun-2002 : Added method to generate AREA tag for image map + * generation (DG); + * 05-Aug-2002 : Added new constructor to populate URLText + * Moved getImageMapAreaTag() to ChartEntity (superclass) (RA); + * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 07-Mar-2003 : Added pie index attribute, since the PiePlot class can create + * multiple pie plots within one chart. Also renamed 'category' + * --> 'sectionKey' and changed the class from Object --> + * Comparable (DG); + * 30-Jul-2003 : Added PieDataset reference (CZ); + * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); + * 13-Nov-2007 : Implemented equals() and hashCode() (DG); + * + */ + +package org.jfree.chart.entity; + +import java.awt.Shape; +import java.io.Serializable; + +import org.jfree.chart.HashUtilities; +import org.jfree.data.general.PieDataset; +import org.jfree.util.ObjectUtilities; + +/** + * A chart entity that represents one section within a pie plot. + */ +public class PieSectionEntity extends ChartEntity + implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 9199892576531984162L; + + /** The dataset. */ + private PieDataset dataset; + + /** The pie index. */ + private int pieIndex; + + /** The section index. */ + private int sectionIndex; + + /** The section key. */ + private Comparable sectionKey; + + /** + * Creates a new pie section entity. + * + * @param area the area. + * @param dataset the pie dataset. + * @param pieIndex the pie index (zero-based). + * @param sectionIndex the section index (zero-based). + * @param sectionKey the section key. + * @param toolTipText the tool tip text. + * @param urlText the URL text for HTML image maps. + */ + public PieSectionEntity(Shape area, + PieDataset dataset, + int pieIndex, int sectionIndex, + Comparable sectionKey, + String toolTipText, String urlText) { + + super(area, toolTipText, urlText); + this.dataset = dataset; + this.pieIndex = pieIndex; + this.sectionIndex = sectionIndex; + this.sectionKey = sectionKey; + + } + + /** + * Returns the dataset this entity refers to. + * + * @return The dataset. + * + * @see #setDataset(PieDataset) + */ + public PieDataset getDataset() { + return this.dataset; + } + + /** + * Sets the dataset this entity refers to. + * + * @param dataset the dataset. + * + * @see #getDataset() + */ + public void setDataset(PieDataset dataset) { + this.dataset = dataset; + } + + /** + * Returns the pie index. For a regular pie chart, the section index is 0. + * For a pie chart containing multiple pie plots, the pie index is the row + * or column index from which the pie data is extracted. + * + * @return The pie index. + * + * @see #setPieIndex(int) + */ + public int getPieIndex() { + return this.pieIndex; + } + + /** + * Sets the pie index. + * + * @param index the new index value. + * + * @see #getPieIndex() + */ + public void setPieIndex(int index) { + this.pieIndex = index; + } + + /** + * Returns the section index. + * + * @return The section index. + * + * @see #setSectionIndex(int) + */ + public int getSectionIndex() { + return this.sectionIndex; + } + + /** + * Sets the section index. + * + * @param index the section index. + * + * @see #getSectionIndex() + */ + public void setSectionIndex(int index) { + this.sectionIndex = index; + } + + /** + * Returns the section key. + * + * @return The section key. + * + * @see #setSectionKey(Comparable) + */ + public Comparable getSectionKey() { + return this.sectionKey; + } + + /** + * Sets the section key. + * + * @param key the section key. + * + * @see #getSectionKey() + */ + public void setSectionKey(Comparable key) { + this.sectionKey = key; + } + + /** + * Tests this entity for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PieSectionEntity)) { + return false; + } + PieSectionEntity that = (PieSectionEntity) obj; + if (!ObjectUtilities.equal(this.dataset, that.dataset)) { + return false; + } + if (this.pieIndex != that.pieIndex) { + return false; + } + if (this.sectionIndex != that.sectionIndex) { + return false; + } + if (!ObjectUtilities.equal(this.sectionKey, that.sectionKey)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = super.hashCode(); + result = HashUtilities.hashCode(result, this.pieIndex); + result = HashUtilities.hashCode(result, this.sectionIndex); + return result; + } + + /** + * Returns a string representing the entity. + * + * @return A string representing the entity. + */ + @Override + public String toString() { + return "PieSection: " + this.pieIndex + ", " + this.sectionIndex + "(" + + this.sectionKey.toString() + ")"; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/PlotEntity.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/PlotEntity.java new file mode 100755 index 0000000..eec2b87 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/PlotEntity.java @@ -0,0 +1,214 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * PlotEntity.java + * --------------- + * (C) Copyright 2009-2013, by Object Refinery Limited and Contributors. + * + * Original Author: Peter Kolb; + * Contributor(s): ; + * + * Changes: + * -------- + * 15-Feb-2009 : Version 1 (PK); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.entity; + +import java.awt.Shape; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import org.jfree.chart.plot.Plot; +import org.jfree.chart.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.util.ObjectUtilities; + +/** + * A class that captures information about a plot. + * + * @since 1.0.13 + */ +public class PlotEntity extends ChartEntity { + + /** For serialization. */ + private static final long serialVersionUID = -4445994133561919083L; + //same as for ChartEntity! + + /** The plot. */ + private Plot plot; + + /** + * Creates a new plot entity. + * + * @param area the area (null not permitted). + * @param plot the plot (null not permitted). + */ + public PlotEntity(Shape area, Plot plot) { + // defer argument checks... + this(area, plot, null); + } + + /** + * Creates a new plot entity. + * + * @param area the area (null not permitted). + * @param plot the plot (null not permitted). + * @param toolTipText the tool tip text (null permitted). + */ + public PlotEntity(Shape area, Plot plot, String toolTipText) { + // defer argument checks... + this(area, plot, toolTipText, null); + } + + /** + * Creates a new plot entity. + * + * @param area the area (null not permitted). + * @param plot the plot (null not permitted). + * @param toolTipText the tool tip text (null permitted). + * @param urlText the URL text for HTML image maps (null + * permitted). + */ + public PlotEntity(Shape area, Plot plot, String toolTipText, + String urlText) { + super(area, toolTipText, urlText); + ParamChecks.nullNotPermitted(plot, "plot"); + this.plot = plot; + } + + /** + * Returns the plot that occupies the entity area. + * + * @return The plot (never null). + */ + public Plot getPlot() { + return this.plot; + } + + /** + * Returns a string representation of the plot entity, useful for + * debugging. + * + * @return A string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder("PlotEntity: "); + sb.append("tooltip = "); + sb.append(getToolTipText()); + return sb.toString(); + } + + /** + * Tests the entity for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PlotEntity)) { + return false; + } + PlotEntity that = (PlotEntity) obj; + if (!getArea().equals(that.getArea())) { + return false; + } + if (!ObjectUtilities.equal(getToolTipText(), that.getToolTipText())) { + return false; + } + if (!ObjectUtilities.equal(getURLText(), that.getURLText())) { + return false; + } + if (!(this.plot.equals(that.plot))) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 39; + result = HashUtilities.hashCode(result, getToolTipText()); + result = HashUtilities.hashCode(result, getURLText()); + return result; + } + + /** + * Returns a clone of the entity. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning the + * entity. + */ + @Override + 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(getArea(), 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(); + setArea(SerialUtilities.readShape(stream)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/StandardEntityCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/StandardEntityCollection.java new file mode 100755 index 0000000..01d1c2d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/StandardEntityCollection.java @@ -0,0 +1,215 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * StandardEntityCollection.java + * ----------------------------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-May-2002 : Version 1 (DG); + * 26-Jun-2002 : Added iterator() method (DG); + * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 19-May-2004 : Implemented Serializable (DG); + * 29-Sep-2004 : Renamed addEntity() --> add() and addEntities() + * --> addAll() (DG); + * 19-Jan-2005 : Changed storage from Collection --> List (DG); + * 20-May-2005 : Fixed bug 1113521 - inefficiency in getEntity() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 01-Dec-2006 : Implemented PublicCloneable and fixed clone() method (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.entity; + +import java.io.Serializable; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A standard implementation of the {@link EntityCollection} interface. + */ +public class StandardEntityCollection implements EntityCollection, + Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 5384773031184897047L; + + /** Storage for the entities. */ + private List entities; + + /** + * Constructs a new entity collection (initially empty). + */ + public StandardEntityCollection() { + this.entities = new java.util.ArrayList(); + } + + /** + * Returns the number of entities in the collection. + * + * @return The entity count. + */ + @Override + public int getEntityCount() { + return this.entities.size(); + } + + /** + * Returns a chart entity from the collection. + * + * @param index the entity index. + * + * @return The entity. + * + * @see #add(ChartEntity) + */ + @Override + public ChartEntity getEntity(int index) { + return (ChartEntity) this.entities.get(index); + } + + /** + * Clears all the entities from the collection. + */ + @Override + public void clear() { + this.entities.clear(); + } + + /** + * Adds an entity to the collection. + * + * @param entity the entity (null not permitted). + */ + @Override + public void add(ChartEntity entity) { + ParamChecks.nullNotPermitted(entity, "entity"); + this.entities.add(entity); + } + + /** + * Adds all the entities from the specified collection. + * + * @param collection the collection of entities (null not + * permitted). + */ + @Override + public void addAll(EntityCollection collection) { + this.entities.addAll(collection.getEntities()); + } + + /** + * Returns the last entity in the list with an area that encloses the + * specified coordinates, or null if there is no such entity. + * + * @param x the x coordinate. + * @param y the y coordinate. + * + * @return The entity (possibly null). + */ + @Override + public ChartEntity getEntity(double x, double y) { + int entityCount = this.entities.size(); + for (int i = entityCount - 1; i >= 0; i--) { + ChartEntity entity = (ChartEntity) this.entities.get(i); + if (entity.getArea().contains(x, y)) { + return entity; + } + } + return null; + } + + /** + * Returns the entities in an unmodifiable collection. + * + * @return The entities. + */ + @Override + public Collection getEntities() { + return Collections.unmodifiableCollection(this.entities); + } + + /** + * Returns an iterator for the entities in the collection. + * + * @return An iterator. + */ + @Override + public Iterator iterator() { + return this.entities.iterator(); + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof StandardEntityCollection) { + StandardEntityCollection that = (StandardEntityCollection) obj; + return ObjectUtilities.equal(this.entities, that.entities); + } + return false; + } + + /** + * Returns a clone of this entity collection. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the object cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + StandardEntityCollection clone + = (StandardEntityCollection) super.clone(); + clone.entities = new java.util.ArrayList(this.entities.size()); + for (int i = 0; i < this.entities.size(); i++) { + ChartEntity entity = (ChartEntity) this.entities.get(i); + clone.entities.add(entity.clone()); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/TickLabelEntity.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/TickLabelEntity.java new file mode 100755 index 0000000..cb3365c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/TickLabelEntity.java @@ -0,0 +1,67 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * TickLabelEntity.java + * -------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 16-Mar-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.entity; + +import java.awt.Shape; +import java.io.Serializable; + +/** + * A chart entity representing a tick label. + */ +public class TickLabelEntity extends ChartEntity implements Cloneable, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 681583956588092095L; + + /** + * Creates a new entity. + * + * @param area the area (null not permitted). + * @param toolTipText the tool tip text (null permitted). + * @param urlText the URL text for HTML image maps (null + * permitted). + */ + public TickLabelEntity(Shape area, String toolTipText, String urlText) { + super(area, toolTipText, urlText); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/TitleEntity.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/TitleEntity.java new file mode 100755 index 0000000..dfc37c3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/TitleEntity.java @@ -0,0 +1,214 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * TitleEntity.java + * ---------------- + * (C) Copyright 2009-2013, by Object Refinery Limited and Contributors. + * + * Original Author: Peter Kolb; + * Contributor(s): ; + * + * Changes: + * -------- + * 15-Feb-2009 : Version 1 (PK); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.entity; + +import java.awt.Shape; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.title.Title; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.util.ObjectUtilities; + +/** + * A class that captures information about a Title of a chart. + * + * @since 1.0.13 + */ +public class TitleEntity extends ChartEntity { + + /** For serialization. */ + private static final long serialVersionUID = -4445994133561919083L; + //same as for ChartEntity! + + /** The Title for the entity. */ + private Title title; + + /** + * Creates a new chart entity. + * + * @param area the area (null not permitted). + * @param title the title (null not permitted). + */ + public TitleEntity(Shape area, Title title) { + // defer argument checks... + this(area, title, null); + } + + /** + * Creates a new chart entity. + * + * @param area the area (null not permitted). + * @param title the title (null not permitted). + * @param toolTipText the tool tip text (null permitted). + */ + public TitleEntity(Shape area, Title title, String toolTipText) { + // defer argument checks... + this(area, title, toolTipText, null); + } + + /** + * Creates a new entity. + * + * @param area the area (null not permitted). + * @param title the title (null not permitted). + * @param toolTipText the tool tip text (null permitted). + * @param urlText the URL text for HTML image maps (null + * permitted). + */ + public TitleEntity(Shape area, Title title, String toolTipText, + String urlText) { + super(area, toolTipText, urlText); + ParamChecks.nullNotPermitted(title, "title"); + this.title = title; + } + + /** + * Returns the title that occupies the entity area. + * + * @return The title (never null). + */ + public Title getTitle() { + return this.title; + } + + /** + * Returns a string representation of the chart entity, useful for + * debugging. + * + * @return A string. + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder("TitleEntity: "); + sb.append("tooltip = "); + sb.append(getToolTipText()); + return sb.toString(); + } + + /** + * Tests the entity for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TitleEntity)) { + return false; + } + TitleEntity that = (TitleEntity) obj; + if (!getArea().equals(that.getArea())) { + return false; + } + if (!ObjectUtilities.equal(getToolTipText(), that.getToolTipText())) { + return false; + } + if (!ObjectUtilities.equal(getURLText(), that.getURLText())) { + return false; + } + if (!(this.title.equals(that.title))) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 41; + result = HashUtilities.hashCode(result, getToolTipText()); + result = HashUtilities.hashCode(result, getURLText()); + return result; + } + + /** + * Returns a clone of the entity. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning the + * entity. + */ + @Override + 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(getArea(), 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(); + setArea(SerialUtilities.readShape(stream)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/XYAnnotationEntity.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/XYAnnotationEntity.java new file mode 100755 index 0000000..e1535d2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/XYAnnotationEntity.java @@ -0,0 +1,116 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * XYAnnotationEntity.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); + * + */ + +package org.jfree.chart.entity; + +import java.awt.Shape; +import java.io.Serializable; + +/** + * A chart entity that represents an annotation on an + * {@link org.jfree.chart.plot.XYPlot}. + */ +public class XYAnnotationEntity extends ChartEntity + implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 2340334068383660799L; + + /** The renderer index. */ + private int rendererIndex; + + /** + * Creates a new entity. + * + * @param hotspot the area. + * @param rendererIndex the rendererIndex (zero-based index). + * @param toolTipText the tool tip text. + * @param urlText the URL text for HTML image maps. + */ + public XYAnnotationEntity(Shape hotspot, int rendererIndex, + String toolTipText, String urlText) { + super(hotspot, toolTipText, urlText); + this.rendererIndex = rendererIndex; + } + + /** + * Returns the renderer index. + * + * @return The renderer index. + */ + public int getRendererIndex() { + return this.rendererIndex; + } + + /** + * Sets the renderer index. + * + * @param index the item index (zero-based). + */ + public void setRendererIndex(int index) { + this.rendererIndex = index; + } + + /** + * Tests the entity for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof XYAnnotationEntity)) { + return false; + } + XYAnnotationEntity that = (XYAnnotationEntity) obj; + if (this.rendererIndex != that.rendererIndex) { + return false; + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/XYItemEntity.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/XYItemEntity.java new file mode 100755 index 0000000..b8a5abe --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/XYItemEntity.java @@ -0,0 +1,185 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * XYItemEntity.java + * ----------------- + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Richard Atkinson; + * Christian W. Zuckschwerdt; + * + * Changes: + * -------- + * 23-May-2002 : Version 1 (DG); + * 12-Jun-2002 : Added accessor methods and Javadoc comments (DG); + * 26-Jun-2002 : Added getImageMapAreaTag() method (DG); + * 05-Aug-2002 : Added new constructor to populate URLText + * Moved getImageMapAreaTag() to ChartEntity (superclass) (RA); + * 03-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 30-Jun-2003 : Added XYDataset reference (CZ); + * 20-May-2004 : Added equals() and clone() methods and implemented + * Serializable (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); + * + */ + +package org.jfree.chart.entity; + +import java.awt.Shape; + +import org.jfree.data.xy.XYDataset; + +/** + * A chart entity that represents one item within an + * {@link org.jfree.chart.plot.XYPlot}. + */ +public class XYItemEntity extends ChartEntity { + + /** For serialization. */ + private static final long serialVersionUID = -3870862224880283771L; + + /** The dataset. */ + private transient XYDataset dataset; + + /** The series. */ + private int series; + + /** The item. */ + private int item; + + /** + * Creates a new entity. + * + * @param area the area. + * @param dataset the dataset. + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * @param toolTipText the tool tip text. + * @param urlText the URL text for HTML image maps. + */ + public XYItemEntity(Shape area, + XYDataset dataset, int series, int item, + String toolTipText, String urlText) { + super(area, toolTipText, urlText); + this.dataset = dataset; + this.series = series; + this.item = item; + } + + /** + * Returns the dataset this entity refers to. + * + * @return The dataset. + */ + public XYDataset getDataset() { + return this.dataset; + } + + /** + * Sets the dataset this entity refers to. + * + * @param dataset the dataset. + */ + public void setDataset(XYDataset dataset) { + this.dataset = dataset; + } + + /** + * Returns the series index. + * + * @return The series index. + */ + public int getSeriesIndex() { + return this.series; + } + + /** + * Sets the series index. + * + * @param series the series index (zero-based). + */ + public void setSeriesIndex(int series) { + this.series = series; + } + + /** + * Returns the item index. + * + * @return The item index. + */ + public int getItem() { + return this.item; + } + + /** + * Sets the item index. + * + * @param item the item index (zero-based). + */ + public void setItem(int item) { + this.item = item; + } + + /** + * Tests the entity for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof XYItemEntity && super.equals(obj)) { + XYItemEntity ie = (XYItemEntity) obj; + if (this.series != ie.series) { + return false; + } + if (this.item != ie.item) { + return false; + } + return true; + } + return false; + } + + /** + * Returns a string representation of this instance, useful for debugging + * purposes. + * + * @return A string. + */ + @Override + public String toString() { + return "XYItemEntity: series = " + getSeriesIndex() + ", item = " + + getItem() + ", dataset = " + getDataset(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/package.html new file mode 100755 index 0000000..b0e3398 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/entity/package.html @@ -0,0 +1,6 @@ + + + +Classes representing components of (or entities in) a chart. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/AnnotationChangeEvent.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/AnnotationChangeEvent.java new file mode 100755 index 0000000..3237f1e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/AnnotationChangeEvent.java @@ -0,0 +1,83 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * AnnotationChangeEvent.java + * -------------------------- + * (C) Copyright 2009, by Object Refinery Limited and Contributors. + * + * Original Author: Peter Kolb (patch 2809117); + * Contributor(s): ; + * + * Changes: + * -------- + * 20-Jun-2009 : Version 1 (PK); + * + */ + +package org.jfree.chart.event; + +import org.jfree.chart.annotations.Annotation; +import org.jfree.chart.util.ParamChecks; + +/** + * An event that can be forwarded to any {@link AnnotationChangeListener} to + * signal a change to an {@link Annotation}. + * + * @since 1.0.14 + */ +public class AnnotationChangeEvent extends ChartChangeEvent { + + /** The annotation that generated the event. */ + private Annotation annotation; + + /** + * Creates a new AnnotationChangeEvent instance. + * + * @param source the event source. + * @param annotation the annotation that triggered the event + * (null not permitted). + * + * @since 1.0.14 + */ + public AnnotationChangeEvent(Object source, Annotation annotation) { + super(source); + ParamChecks.nullNotPermitted(annotation, "annotation"); + this.annotation = annotation; + } + + /** + * Returns the annotation that triggered the event. + * + * @return The annotation that triggered the event (never null). + * + * @since 1.0.14 + */ + public Annotation getAnnotation() { + return this.annotation; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/AnnotationChangeListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/AnnotationChangeListener.java new file mode 100755 index 0000000..db16f8b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/AnnotationChangeListener.java @@ -0,0 +1,64 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * AnnotationChangeListener.java + * ------------------------- + * (C) Copyright 2009, by Object Refinery Limited and Contributors. + * + * Original Author: Peter Kolb (patch 2809117); + * Contributor(s): ; + * + * Changes: + * -------- + * 20-Jun-2009 : Version 1 (PK); + * + */ + +package org.jfree.chart.event; + +import java.util.EventListener; + +import org.jfree.chart.annotations.Annotation; + +/** + * The interface that must be supported by classes that wish to receive + * notification of changes to an {@link Annotation}. + * + * @since 1.0.14 + */ +public interface AnnotationChangeListener extends EventListener { + + /** + * Receives notification of an annotation change event. + * + * @param event the event. + * + * @since 1.0.14 + */ + public void annotationChanged(AnnotationChangeEvent event); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/AxisChangeEvent.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/AxisChangeEvent.java new file mode 100755 index 0000000..f1dad69 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/AxisChangeEvent.java @@ -0,0 +1,73 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * AxisChangeEvent.java + * -------------------- + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 24-Aug-2001) + * -------------------------- + * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * + */ + +package org.jfree.chart.event; + +import org.jfree.chart.axis.Axis; + +/** + * A change event that encapsulates information about a change to an axis. + */ +public class AxisChangeEvent extends ChartChangeEvent { + + /** The axis that generated the change event. */ + private Axis axis; + + /** + * Creates a new AxisChangeEvent. + * + * @param axis the axis that generated the event. + */ + public AxisChangeEvent(Axis axis) { + super(axis); + this.axis = axis; + } + + /** + * Returns the axis that generated the event. + * + * @return The axis that generated the event. + */ + public Axis getAxis() { + return this.axis; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/AxisChangeListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/AxisChangeListener.java new file mode 100755 index 0000000..d82eaeb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/AxisChangeListener.java @@ -0,0 +1,66 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * AxisChangeEvent.java + * -------------------- + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 24-Aug-2001) + * -------------------------- + * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); + * 07-Nov-2001 : Updated header (DG); + * 14-Oct-2002 : Now extends EventListener (DG); + * + */ + +package org.jfree.chart.event; + +import java.util.EventListener; + +/** + * The interface that must be supported by classes that wish to receive + * notification of changes to an axis. + *

+ * The Plot class implements this interface, and automatically registers with + * its axes (if any). Any axis changes are passed on by the plot as a plot + * change event. This is part of the notification mechanism that ensures that + * charts are redrawn whenever changes are made to any chart component. + * + */ +public interface AxisChangeListener extends EventListener { + + /** + * Receives notification of an axis change event. + * + * @param event the event. + */ + public void axisChanged(AxisChangeEvent event); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartChangeEvent.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartChangeEvent.java new file mode 100755 index 0000000..2e09779 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartChangeEvent.java @@ -0,0 +1,134 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * ChartChangeEvent.java + * --------------------- + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 24-Aug-2001) + * -------------------------- + * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); + * 07-Nov-2001 : Updated header (DG); + * Change event type names (DG); + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 18-Feb-2005 : Changed the type from int to ChartChangeEventType (DG); + * + */ + +package org.jfree.chart.event; + +import java.util.EventObject; + +import org.jfree.chart.JFreeChart; + +/** + * A change event that encapsulates information about a change to a chart. + */ +public class ChartChangeEvent extends EventObject { + + /** The type of event. */ + private ChartChangeEventType type; + + /** The chart that generated the event. */ + private JFreeChart chart; + + /** + * Creates a new chart change event. + * + * @param source the source of the event (could be the chart, a title, + * an axis etc.) + */ + public ChartChangeEvent(Object source) { + this(source, null, ChartChangeEventType.GENERAL); + } + + /** + * Creates a new chart change event. + * + * @param source the source of the event (could be the chart, a title, an + * axis etc.) + * @param chart the chart that generated the event. + */ + public ChartChangeEvent(Object source, JFreeChart chart) { + this(source, chart, ChartChangeEventType.GENERAL); + } + + /** + * Creates a new chart change event. + * + * @param source the source of the event (could be the chart, a title, an + axis etc.) + * @param chart the chart that generated the event. + * @param type the type of event. + */ + public ChartChangeEvent(Object source, JFreeChart chart, + ChartChangeEventType type) { + super(source); + this.chart = chart; + this.type = type; + } + + /** + * Returns the chart that generated the change event. + * + * @return The chart that generated the change event. + */ + public JFreeChart getChart() { + return this.chart; + } + + /** + * Sets the chart that generated the change event. + * + * @param chart the chart that generated the event. + */ + public void setChart(JFreeChart chart) { + this.chart = chart; + } + + /** + * Returns the event type. + * + * @return The event type. + */ + public ChartChangeEventType getType() { + return this.type; + } + + /** + * Sets the event type. + * + * @param type the event type. + */ + public void setType(ChartChangeEventType type) { + this.type = type; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartChangeEventType.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartChangeEventType.java new file mode 100755 index 0000000..d1e55b2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartChangeEventType.java @@ -0,0 +1,141 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * ChartChangeEventType.java + * ------------------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 18-Feb-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.event; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Defines tokens used to indicate an event type. + */ +public final class ChartChangeEventType implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 5481917022435735602L; + + /** GENERAL. */ + public static final ChartChangeEventType GENERAL + = new ChartChangeEventType("ChartChangeEventType.GENERAL"); + + /** NEW_DATASET. */ + public static final ChartChangeEventType NEW_DATASET + = new ChartChangeEventType("ChartChangeEventType.NEW_DATASET"); + + /** DATASET_UPDATED. */ + public static final ChartChangeEventType DATASET_UPDATED + = new ChartChangeEventType("ChartChangeEventType.DATASET_UPDATED"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private ChartChangeEventType(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof ChartChangeEventType)) { + return false; + } + ChartChangeEventType that = (ChartChangeEventType) obj; + if (!this.name.equals(that.toString())) { + return false; + } + return true; + } + + /** + * Returns a hash code value for the object. + * + * @return The hashcode + */ + @Override + public int hashCode() { + return this.name.hashCode(); + } + + /** + * 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(ChartChangeEventType.GENERAL)) { + return ChartChangeEventType.GENERAL; + } + else if (this.equals(ChartChangeEventType.NEW_DATASET)) { + return ChartChangeEventType.NEW_DATASET; + } + else if (this.equals(ChartChangeEventType.DATASET_UPDATED)) { + return ChartChangeEventType.DATASET_UPDATED; + } + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartChangeListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartChangeListener.java new file mode 100755 index 0000000..8624a6b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartChangeListener.java @@ -0,0 +1,65 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * ChartChangeListener.java + * ------------------------ + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 24-Aug-2001) + * -------------------------- + * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); + * 07-Nov-2001 : Updated header (DG); + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 14-Oct-2002 : Now extends java.util.EventListener (DG); + * + */ + +package org.jfree.chart.event; + +import java.util.EventListener; + +/** + * The interface that must be supported by classes that wish to receive + * notification of chart events. + *

+ * The {@link org.jfree.chart.ChartPanel} class registers itself with the + * chart it displays, and whenever the chart changes, the panel redraws itself. + * + */ +public interface ChartChangeListener extends EventListener { + + /** + * Receives notification of a chart change event. + * + * @param event the event. + */ + public void chartChanged(ChartChangeEvent event); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartProgressEvent.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartProgressEvent.java new file mode 100755 index 0000000..fa51ec3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartProgressEvent.java @@ -0,0 +1,137 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * ChartProgressEvent.java + * ----------------------- + * (C) Copyright 2003-2010, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 14-Jan-2003 : Version 1 (DG); + * 20-Jan-2010 : Fixed bug in constructor (DG); + * + */ + +package org.jfree.chart.event; + +import org.jfree.chart.JFreeChart; + +/** + * An event that contains information about the drawing progress of a chart. + */ +public class ChartProgressEvent extends java.util.EventObject { + + /** Indicates drawing has started. */ + public static final int DRAWING_STARTED = 1; + + /** Indicates drawing has finished. */ + public static final int DRAWING_FINISHED = 2; + + /** The type of event. */ + private int type; + + /** The percentage of completion. */ + private int percent; + + /** The chart that generated the event. */ + private JFreeChart chart; + + /** + * Creates a new chart change event. + * + * @param source the source of the event (could be the chart, a title, an + * axis etc.) + * @param chart the chart that generated the event. + * @param type the type of event. + * @param percent the percentage of completion. + */ + public ChartProgressEvent(Object source, JFreeChart chart, int type, + int percent) { + super(source); + this.chart = chart; + this.type = type; + this.percent = percent; + } + + /** + * Returns the chart that generated the change event. + * + * @return The chart that generated the change event. + */ + public JFreeChart getChart() { + return this.chart; + } + + /** + * Sets the chart that generated the change event. + * + * @param chart the chart that generated the event. + */ + public void setChart(JFreeChart chart) { + this.chart = chart; + } + + /** + * Returns the event type. + * + * @return The event type. + */ + public int getType() { + return this.type; + } + + /** + * Sets the event type. + * + * @param type the event type. + */ + public void setType(int type) { + this.type = type; + } + + /** + * Returns the percentage complete. + * + * @return The percentage complete. + */ + public int getPercent() { + return this.percent; + } + + /** + * Sets the percentage complete. + * + * @param percent the percentage. + */ + public void setPercent(int percent) { + this.percent = percent; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartProgressListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartProgressListener.java new file mode 100755 index 0000000..e5a6d6a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/ChartProgressListener.java @@ -0,0 +1,58 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * ChartProgressListener.java + * -------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 24-Aug-2001) + * -------------------------- + * 14-Jan-2003 : Version 1 (DG); + * + */ + +package org.jfree.chart.event; + +import java.util.EventListener; + +/** + * The interface that must be supported by classes that wish to receive + * notification of chart progress events. + */ +public interface ChartProgressListener extends EventListener { + + /** + * Receives notification of a chart progress event. + * + * @param event the event. + */ + public void chartProgress(ChartProgressEvent event); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/MarkerChangeEvent.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/MarkerChangeEvent.java new file mode 100755 index 0000000..8f572ac --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/MarkerChangeEvent.java @@ -0,0 +1,80 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * MarkerChangeEvent.java + * ---------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Sep-2006 : Version 1 (DG); + * + */ + +package org.jfree.chart.event; + +import org.jfree.chart.plot.Marker; + +/** + * An event that can be forwarded to any {@link MarkerChangeListener} to + * signal a change to a {@link Marker}. + * + * @since 1.0.3 + */ +public class MarkerChangeEvent extends ChartChangeEvent { + + /** The plot that generated the event. */ + private Marker marker; + + /** + * Creates a new MarkerChangeEvent instance. + * + * @param marker the marker that triggered the event (null + * not permitted). + * + * @since 1.0.3 + */ + public MarkerChangeEvent(Marker marker) { + super(marker); + this.marker = marker; + } + + /** + * Returns the marker that triggered the event. + * + * @return The marker that triggered the event (never null). + * + * @since 1.0.3 + */ + public Marker getMarker() { + return this.marker; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/MarkerChangeListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/MarkerChangeListener.java new file mode 100755 index 0000000..bb8e48d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/MarkerChangeListener.java @@ -0,0 +1,64 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * MarkerChangeListener.java + * ------------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Sep-2006 : Version 1 (DG); + * + */ + +package org.jfree.chart.event; + +import java.util.EventListener; + +import org.jfree.chart.plot.Marker; + +/** + * The interface that must be supported by classes that wish to receive + * notification of changes to a {@link Marker}. + * + * @since 1.0.3 + */ +public interface MarkerChangeListener extends EventListener { + + /** + * Receives notification of a marker change event. + * + * @param event the event. + * + * @since 1.0.3 + */ + public void markerChanged(MarkerChangeEvent event); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/OverlayChangeEvent.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/OverlayChangeEvent.java new file mode 100755 index 0000000..7cc1a5b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/OverlayChangeEvent.java @@ -0,0 +1,62 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * OverlayChangeEvent.java + * ----------------------- + * (C) Copyright 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 09-Apr-2009 : Version 1 (DG); + * + */ + +package org.jfree.chart.event; + +import java.util.EventObject; +import org.jfree.chart.panel.Overlay; + +/** + * A change event for an {@link Overlay}. + * + * @since 1.0.13 + */ +public class OverlayChangeEvent extends EventObject { + + /** + * Creates a new change event. + * + * @param source the event source. + */ + public OverlayChangeEvent(Object source) { + super(source); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/OverlayChangeListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/OverlayChangeListener.java new file mode 100755 index 0000000..2d150cb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/OverlayChangeListener.java @@ -0,0 +1,60 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * OverlayChangeListener.java + * -------------------------- + * (C) Copyright 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 09-Apr-2009 : Version 1 (DG); + * + */ + +package org.jfree.chart.event; + +import java.util.EventListener; +import org.jfree.chart.panel.Overlay; + +/** + * A listener for changes to an {@link Overlay}. + * + * @since 1.0.13 + */ +public interface OverlayChangeListener extends EventListener { + + /** + * This method is called to notify a listener of a change event. + * + * @param event the event. + */ + public void overlayChanged(OverlayChangeEvent event); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/PlotChangeEvent.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/PlotChangeEvent.java new file mode 100755 index 0000000..2801c56 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/PlotChangeEvent.java @@ -0,0 +1,77 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * PlotChangeEvent.java + * -------------------- + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 24-Aug-2001) + * -------------------------- + * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); + * 07-Nov-2001 : Updated header (DG); + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 17-Jan-2003 : Moved plot classes to a separate package (DG); + * + */ + +package org.jfree.chart.event; + +import org.jfree.chart.plot.Plot; + +/** + * An event that can be forwarded to any + * {@link org.jfree.chart.event.PlotChangeListener} to signal a change to a + * plot. + */ +public class PlotChangeEvent extends ChartChangeEvent { + + /** The plot that generated the event. */ + private Plot plot; + + /** + * Creates a new PlotChangeEvent. + * + * @param plot the plot that generated the event. + */ + public PlotChangeEvent(Plot plot) { + super(plot); + this.plot = plot; + } + + /** + * Returns the plot that generated the event. + * + * @return The plot that generated the event. + */ + public Plot getPlot() { + return this.plot; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/PlotChangeListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/PlotChangeListener.java new file mode 100755 index 0000000..f937bae --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/PlotChangeListener.java @@ -0,0 +1,62 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * PlotChangeListener.java + * ----------------------- + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 24-Aug-2001) + * -------------------------- + * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); + * 07-Nov-2001 : Updated header (DG); + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 14-Oct-2002 : Now extends EventListener (DG); + * + */ + +package org.jfree.chart.event; + +import java.util.EventListener; + +/** + * The interface that must be supported by classes that wish to receive + * notification of changes to a plot. + * + */ +public interface PlotChangeListener extends EventListener { + + /** + * Receives notification of a plot change event. + * + * @param event the event. + */ + public void plotChanged(PlotChangeEvent event); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/RendererChangeEvent.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/RendererChangeEvent.java new file mode 100755 index 0000000..c7288d2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/RendererChangeEvent.java @@ -0,0 +1,108 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * RendererChangeEvent.java + * ------------------------ + * (C) Copyright 2003-2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Oct-2003 : Version 1 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 04-Apr-2007 : Fixed typo in API docs (DG); + * 26-Mar-2009 : Added flag to signal visible series change (DG); + * + */ + +package org.jfree.chart.event; + +/** + * An event that can be forwarded to any {@link RendererChangeListener} to + * signal a change to a renderer. + */ +public class RendererChangeEvent extends ChartChangeEvent { + + /** The renderer that generated the event. */ + private Object renderer; + + /** + * A flag that indicates whether this event relates to a change in the + * series visibility. If so, the receiver (if it is a plot) may want to + * update the axis bounds. + * + * @since 1.0.13 + */ + private boolean seriesVisibilityChanged; + + /** + * Creates a new event. + * + * @param renderer the renderer that generated the event. + */ + public RendererChangeEvent(Object renderer) { + this(renderer, false); + } + + /** + * Creates a new event. + * + * @param renderer the renderer that generated the event. + * @param seriesVisibilityChanged a flag that indicates whether or not + * the event relates to a change in the series visibility flags. + */ + public RendererChangeEvent(Object renderer, + boolean seriesVisibilityChanged) { + super(renderer); + this.renderer = renderer; + this.seriesVisibilityChanged = seriesVisibilityChanged; + } + + /** + * Returns the renderer that generated the event. + * + * @return The renderer that generated the event. + */ + public Object getRenderer() { + return this.renderer; + } + + /** + * Returns the flag that indicates whether or not the event relates to + * a change in series visibility. + * + * @return A boolean. + * + * @since 1.0.13 + */ + public boolean getSeriesVisibilityChanged() { + return this.seriesVisibilityChanged; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/RendererChangeListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/RendererChangeListener.java new file mode 100755 index 0000000..eab4385 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/RendererChangeListener.java @@ -0,0 +1,59 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * RendererChangeListener.java + * --------------------------- + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Oct-2003 : Added standard source header. Fixed DOS encoding problem (DG); + * + */ + +package org.jfree.chart.event; + +import java.util.EventListener; + +/** + * The interface that must be supported by classes that wish to receive + * notification of changes to a renderer. + * + */ +public interface RendererChangeListener extends EventListener { + + /** + * Receives notification of a renderer change event. + * + * @param event the event. + */ + public void rendererChanged(RendererChangeEvent event); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/TitleChangeEvent.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/TitleChangeEvent.java new file mode 100755 index 0000000..3b6a073 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/TitleChangeEvent.java @@ -0,0 +1,77 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * TitleChangeEvent.java + * --------------------- + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 22-Jun-2001) + * -------------------------- + * 22-Jun-2001 : Changed Title to AbstractTitle while incorporating + * David Berry's changes (DG); + * 24-Aug-2001 : Fixed DOS encoding problem (DG); + * 07-Nov-2001 : Updated header (DG); + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 08-Jan-2004 : Renamed AbstractTitle --> Title and moved to new package (DG); + * + */ + +package org.jfree.chart.event; + +import org.jfree.chart.title.Title; + +/** + * A change event that encapsulates information about a change to a chart title. + */ +public class TitleChangeEvent extends ChartChangeEvent { + + /** The chart title that generated the event. */ + private Title title; + + /** + * Default constructor. + * + * @param title the chart title that generated the event. + */ + public TitleChangeEvent(Title title) { + super(title); + this.title = title; + } + + /** + * Returns the title that generated the event. + * + * @return The title that generated the event. + */ + public Title getTitle() { + return this.title; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/TitleChangeListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/TitleChangeListener.java new file mode 100755 index 0000000..211d2e3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/TitleChangeListener.java @@ -0,0 +1,62 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * TitleChangeListener.java + * ------------------------ + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 24-Aug-2001) + * -------------------------- + * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); + * 07-Nov-2001 : Updated header (DG); + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 14-Oct-2002 : Now extends EventListener (DG); + * + */ + +package org.jfree.chart.event; + +import java.util.EventListener; + +/** + * The interface that must be supported by classes that wish to receive + * notification of changes to a chart title. + * + */ +public interface TitleChangeListener extends EventListener { + + /** + * Receives notification of a chart title change event. + * + * @param event the event. + */ + public void titleChanged(TitleChangeEvent event); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/package.html new file mode 100755 index 0000000..fd708bc --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/event/package.html @@ -0,0 +1,8 @@ + + + +Event classes and listener interfaces, used to provide a change +notification mechanism so that charts are automatically redrawn +whenever changes are made to any chart component. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/gorilla.jpg b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/gorilla.jpg new file mode 100755 index 0000000..c0c2d6d Binary files /dev/null and b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/gorilla.jpg differ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGenerator.java new file mode 100755 index 0000000..e95fb06 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGenerator.java @@ -0,0 +1,94 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------------------- + * DynamicDriveToolTipTagFragmentGenerator.java + * -------------------------------------------- + * (C) Copyright 2003-2013, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributors: David Gilbert (for Object Refinery Limited); + * Fawad Halim - bug 2690293; + * + * Changes + * ------- + * 12-Aug-2003 : Version 1 (RA); + * 04-Dec-2007 : Escape tool tip text to fix bug 1400917 (DG); + * 19-Mar-2009 : Escape apostrophes - see bug 2690293 with fix by FH (DG); + * + */ + +package org.jfree.chart.imagemap; + +/** + * Generates tooltips using the Dynamic Drive DHTML Tip Message + * library (http://www.dynamicdrive.com). + */ +public class DynamicDriveToolTipTagFragmentGenerator + implements ToolTipTagFragmentGenerator { + + /** The title, empty string not to display */ + protected String title = ""; + + /** The style number */ + protected int style = 1; + + /** + * Blank constructor. + */ + public DynamicDriveToolTipTagFragmentGenerator() { + super(); + } + + /** + * Creates a new generator with specific title and style settings. + * + * @param title title for use in all tooltips, use empty String not to + * display a title. + * @param style style number, see http://www.dynamicdrive.com for more + * information. + */ + public DynamicDriveToolTipTagFragmentGenerator(String title, int style) { + this.title = title; + this.style = style; + } + + /** + * Generates a tooltip string to go in an HTML image map. + * + * @param toolTipText the tooltip. + * + * @return The formatted HTML area tag attribute(s). + */ + @Override + public String generateToolTipFragment(String toolTipText) { + return " onMouseOver=\"return stm(['" + + ImageMapUtilities.javascriptEscape(this.title) + "','" + + ImageMapUtilities.javascriptEscape(toolTipText) + "'],Style[" + + this.style + "]);\"" + " onMouseOut=\"return htm();\""; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/ImageMapUtilities.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/ImageMapUtilities.java new file mode 100755 index 0000000..c26751f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/ImageMapUtilities.java @@ -0,0 +1,275 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * ImageMapUtilities.java + * ---------------------- + * (C) Copyright 2004-2013, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Fawad Halim - bug 2690293; + * + * Changes + * ------- + * 02-Aug-2004 : Initial version (RA); + * 13-Jan-2005 : Renamed ImageMapUtilities (DG); + * 19-Jan-2005 : Reversed order of tags for chart entities to get correct + * layering (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 06-Feb-2006 : API doc updates (DG); + * 04-Dec-2007 : Added htmlEscape() method, and escape 'name' in + * getImageMap() (DG); + * 19-Mar-2009 : Added javascriptEscape() method - see bug 2690293 by FH (DG); + * 25-Mar-2009 : Reimplemented javascriptEscape() (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.imagemap; + +import java.io.IOException; +import java.io.PrintWriter; + +import org.jfree.chart.ChartRenderingInfo; +import org.jfree.chart.entity.ChartEntity; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.util.ParamChecks; +import org.jfree.util.StringUtils; + +/** + * Collection of utility methods related to producing image maps. + * Functionality was originally in {@link org.jfree.chart.ChartUtilities}. + */ +public class ImageMapUtilities { + + /** + * Writes an image map to an output stream. + * + * @param writer the writer (null not permitted). + * @param name the map name (null not permitted). + * @param info the chart rendering info (null not permitted). + * + * @throws java.io.IOException if there are any I/O errors. + */ + public static void writeImageMap(PrintWriter writer, String name, + ChartRenderingInfo info) throws IOException { + + // defer argument checking... + ImageMapUtilities.writeImageMap(writer, name, info, + new StandardToolTipTagFragmentGenerator(), + new StandardURLTagFragmentGenerator()); + + } + + /** + * Writes an image map to an output stream. + * + * @param writer the writer (null not permitted). + * @param name the map name (null not permitted). + * @param info the chart rendering info (null not permitted). + * @param useOverLibForToolTips whether to use OverLIB for tooltips + * (http://www.bosrup.com/web/overlib/). + * + * @throws java.io.IOException if there are any I/O errors. + */ + public static void writeImageMap(PrintWriter writer, + String name, ChartRenderingInfo info, + boolean useOverLibForToolTips) throws IOException { + + ToolTipTagFragmentGenerator toolTipTagFragmentGenerator; + if (useOverLibForToolTips) { + toolTipTagFragmentGenerator + = new OverLIBToolTipTagFragmentGenerator(); + } + else { + toolTipTagFragmentGenerator + = new StandardToolTipTagFragmentGenerator(); + } + ImageMapUtilities.writeImageMap(writer, name, info, + toolTipTagFragmentGenerator, + new StandardURLTagFragmentGenerator()); + + } + + /** + * Writes an image map to an output stream. + * + * @param writer the writer (null not permitted). + * @param name the map name (null not permitted). + * @param info the chart rendering info (null not permitted). + * @param toolTipTagFragmentGenerator a generator for the HTML fragment + * that will contain the tooltip text (null not permitted + * if info contains tooltip information). + * @param urlTagFragmentGenerator a generator for the HTML fragment that + * will contain the URL reference (null not permitted if + * info contains URLs). + * + * @throws java.io.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 image map element that complies with the XHTML 1.0 + * specification. + * + * @param name the map name (null not permitted). + * @param info the chart rendering info (null not permitted). + * + * @return The map element. + */ + public static String getImageMap(String name, ChartRenderingInfo info) { + return ImageMapUtilities.getImageMap(name, info, + new StandardToolTipTagFragmentGenerator(), + new StandardURLTagFragmentGenerator()); + } + + /** + * Creates an image map element that complies with the XHTML 1.0 + * specification. + * + * @param name the map name (null not permitted). + * @param info the chart rendering info (null not permitted). + * @param toolTipTagFragmentGenerator a generator for the HTML fragment + * that will contain the tooltip text (null not permitted + * if info contains tooltip information). + * @param urlTagFragmentGenerator a generator for the HTML fragment that + * will contain the URL reference (null not permitted if + * info contains URLs). + * + * @return The map tag. + */ + public static String getImageMap(String name, ChartRenderingInfo info, + ToolTipTagFragmentGenerator toolTipTagFragmentGenerator, + URLTagFragmentGenerator urlTagFragmentGenerator) { + + StringBuilder sb = new StringBuilder(); + sb.append(""); + sb.append(StringUtils.getLineSeparator()); + EntityCollection entities = info.getEntityCollection(); + if (entities != null) { + int count = entities.getEntityCount(); + for (int i = count - 1; i >= 0; i--) { + ChartEntity entity = entities.getEntity(i); + if (entity.getToolTipText() != null + || entity.getURLText() != null) { + String area = entity.getImageMapAreaTag( + toolTipTagFragmentGenerator, + urlTagFragmentGenerator); + if (area.length() > 0) { + sb.append(area); + sb.append(StringUtils.getLineSeparator()); + } + } + } + } + sb.append(""); + return sb.toString(); + + } + + /** + * Returns a string that is equivalent to the input string, but with + * special characters converted to HTML escape sequences. + * + * @param input the string to escape (null not permitted). + * + * @return A string with characters escaped. + * + * @since 1.0.9 + */ + public static String htmlEscape(String input) { + ParamChecks.nullNotPermitted(input, "input"); + StringBuilder result = new StringBuilder(); + int length = input.length(); + for (int i = 0; i < length; i++) { + char c = input.charAt(i); + if (c == '&') { + result.append("&"); + } + else if (c == '\"') { + result.append("""); + } + else if (c == '<') { + result.append("<"); + } + else if (c == '>') { + result.append(">"); + } + else if (c == '\'') { + result.append("'"); + } + else if (c == '\\') { + result.append("\"); + } + else { + result.append(c); + } + } + return result.toString(); + } + + /** + * Returns a string that is equivalent to the input string, but with + * special characters converted to JavaScript escape sequences. + * + * @param input the string to escape (null not permitted). + * + * @return A string with characters escaped. + * + * @since 1.0.13 + */ + public static String javascriptEscape(String input) { + ParamChecks.nullNotPermitted(input, "input"); + StringBuilder result = new StringBuilder(); + int length = input.length(); + for (int i = 0; i < length; i++) { + char c = input.charAt(i); + if (c == '\"') { + result.append("\\\""); + } + else if (c == '\'') { + result.append("\\'"); + } + else if (c == '\\') { + result.append("\\\\"); + } + else { + result.append(c); + } + } + return result.toString(); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/OverLIBToolTipTagFragmentGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/OverLIBToolTipTagFragmentGenerator.java new file mode 100755 index 0000000..ecb7871 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/OverLIBToolTipTagFragmentGenerator.java @@ -0,0 +1,74 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------------- + * OverLibToolTipTagFragmentGenerator.java + * --------------------------------------- + * (C) Copyright 2003-2009, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributors: David Gilbert (for Object Refinery Limited); + * Fawad Halim - bug 2690293; + * + * Changes + * ------- + * 12-Aug-2003 : Version 1 (RA); + * 04-Dec-2007 : Escape tool tip text to fix bug 1400917 (DG); + * 19-Mar-2009 : Escape apostrophes - see bug 2690293 with fix by FH (DG); + * + */ + +package org.jfree.chart.imagemap; + +/** + * Generates tooltips using the OverLIB library + * (http://www.bosrup.com/web/overlib/). + */ +public class OverLIBToolTipTagFragmentGenerator + implements ToolTipTagFragmentGenerator { + + /** + * Creates a new instance. + */ + public OverLIBToolTipTagFragmentGenerator() { + super(); + } + + /** + * Generates a tooltip string to go in an HTML image map. + * + * @param toolTipText the tooltip text. + * + * @return The formatted HTML area tag attribute(s). + */ + @Override + public String generateToolTipFragment(String toolTipText) { + return " onMouseOver=\"return overlib('" + + ImageMapUtilities.javascriptEscape(toolTipText) + + "');\" onMouseOut=\"return nd();\""; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/StandardToolTipTagFragmentGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/StandardToolTipTagFragmentGenerator.java new file mode 100755 index 0000000..2dc2050 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/StandardToolTipTagFragmentGenerator.java @@ -0,0 +1,70 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------------- + * StandardToolTipTagFragmentGenerator.java + * ---------------------------------------- + * (C) Copyright 2003-2008, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributors: David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 12-Aug-2003 : Version 1 (RA); + * 04-Dec-2007 : Escape tool tip text to fix bug 1400917 (DG); + * + */ + +package org.jfree.chart.imagemap; + +/** + * Generates tooltips using the HTML title attribute for image map area tags. + */ +public class StandardToolTipTagFragmentGenerator + implements ToolTipTagFragmentGenerator { + + /** + * Creates a new instance. + */ + public StandardToolTipTagFragmentGenerator() { + super(); + } + + /** + * Generates a tooltip string to go in an HTML image map. + * + * @param toolTipText the tooltip. + * + * @return The formatted HTML area tag attribute(s). + */ + @Override + public String generateToolTipFragment(String toolTipText) { + return " title=\"" + ImageMapUtilities.htmlEscape(toolTipText) + + "\" alt=\"\""; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/StandardURLTagFragmentGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/StandardURLTagFragmentGenerator.java new file mode 100755 index 0000000..cb0de28 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/StandardURLTagFragmentGenerator.java @@ -0,0 +1,71 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------ + * StandardURLTagFragmentGenerator.java + * ------------------------------------ + * (C) Copyright 2003-2008, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributors: David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 12-Aug-2003 : Version 1 (RA); + * 04-Dec-2007 : Encode URL text to fix bug 1400917 (DG); + * 13-Dec-2007 : Revert change from 04-Dec-2007 (DG); + * + */ + +package org.jfree.chart.imagemap; + +/** + * Generates URLs using the HTML href attribute for image map area tags. + */ +public class StandardURLTagFragmentGenerator + implements URLTagFragmentGenerator { + + /** + * Creates a new instance. + */ + public StandardURLTagFragmentGenerator() { + super(); + } + + /** + * Generates a URL string to go in an HTML image map. + * + * @param urlText the URL text (fully escaped). + * + * @return The formatted text + */ + @Override + public String generateURLFragment(String urlText) { + // the URL text should already have been escaped by the URL generator + return " href=\"" + urlText + "\""; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/ToolTipTagFragmentGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/ToolTipTagFragmentGenerator.java new file mode 100755 index 0000000..4869110 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/ToolTipTagFragmentGenerator.java @@ -0,0 +1,65 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------- + * ToolTipTagFragmentGenerator.java + * -------------------------------- + * (C) Copyright 2003-2008, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * + * Changes + * ------- + * 12-Aug-2003 : Version 1 (RA); + * 05-Dec-2007 : Updated API docs (DG); + * + */ + +package org.jfree.chart.imagemap; + +/** + * Interface for generating the tooltip fragment of an HTML image map area tag. + * The fragment should be XHTML 1.0 compliant. + */ +public interface ToolTipTagFragmentGenerator { + + /** + * Generates a tooltip string to go in an HTML image map. To allow for + * varying standards compliance among browsers, this method is expected + * to return an 'alt' attribute IN ADDITION TO whatever it does to create + * the tooltip (often a 'title' attribute). + *

+ * Note that the toolTipText may have been generated from + * user-defined data, so care should be taken to filter/escape any + * characters that may corrupt the HTML tag. + * + * @param toolTipText the tooltip. + * + * @return The formatted HTML area tag attribute(s). + */ + public String generateToolTipFragment(String toolTipText); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/URLTagFragmentGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/URLTagFragmentGenerator.java new file mode 100755 index 0000000..bde4ff7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/URLTagFragmentGenerator.java @@ -0,0 +1,67 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * URLTagFragmentGenerator.java + * ---------------------------- + * (C) Copyright 2003-2008, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * + * Changes + * ------- + * 12-Aug-2003 : Version 1 (RA); + * 13-Dec-2007 : Updated API docs (DG); + * + */ + +package org.jfree.chart.imagemap; + +import org.jfree.chart.urls.CategoryURLGenerator; +import org.jfree.chart.urls.PieURLGenerator; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.chart.urls.XYZURLGenerator; + +/** + * Interface for generating the URL fragment of an HTML image map area tag. + */ +public interface URLTagFragmentGenerator { + + /** + * Generates a URL string to go in an HTML image map. + *

+ * Note that the urlText will be created by a URL generator + * (such as {@link CategoryURLGenerator}, {@link PieURLGenerator}, + * {@link XYURLGenerator} or {@link XYZURLGenerator}) and that generator is + * responsible for ensuring that the URL text is correctly escaped. + * + * @param urlText the URL text (fully escaped). + * + * @return The formatted HTML area tag attribute(s). + */ + public String generateURLFragment(String urlText); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/package.html new file mode 100755 index 0000000..a0d87b7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/imagemap/package.html @@ -0,0 +1,6 @@ + + + +Classes, including {@link org.jfree.chart.imagemap.ImageMapUtilities}, for creating HTML image maps. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/AbstractCategoryItemLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/AbstractCategoryItemLabelGenerator.java new file mode 100755 index 0000000..655bf00 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/AbstractCategoryItemLabelGenerator.java @@ -0,0 +1,325 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------------- + * AbstractCategoryItemLabelGenerator.java + * --------------------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-May-2004 : Version 1, distilled from StandardCategoryLabelGenerator (DG); + * 31-Jan-2005 : Added methods to return row and column labels (DG); + * 17-May-2005 : Added percentage to item array (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 03-May-2006 : Added new constructor (DG); + * 23-Nov-2007 : Implemented hashCode() (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.MessageFormat; +import java.text.NumberFormat; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.DataUtilities; +import org.jfree.data.category.CategoryDataset; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A base class that can be used to create a label or tooltip generator that + * can be assigned to a + * {@link org.jfree.chart.renderer.category.CategoryItemRenderer}. + */ +public abstract class AbstractCategoryItemLabelGenerator + implements PublicCloneable, Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -7108591260223293197L; + + /** + * The label format string used by a MessageFormat object to + * combine the standard items: {0} = series name, {1} = category, + * {2} = value, {3} = value as a percentage of the column total. + */ + private String labelFormat; + + /** The string used to represent a null value. */ + private String nullValueString; + + /** + * A number formatter used to preformat the value before it is passed to + * the MessageFormat object. + */ + private NumberFormat numberFormat; + + /** + * A date formatter used to preformat the value before it is passed to the + * MessageFormat object. + */ + private DateFormat dateFormat; + + /** + * A number formatter used to preformat the percentage value before it is + * passed to the MessageFormat object. + */ + private NumberFormat percentFormat; + + /** + * Creates a label generator with the specified number formatter. + * + * @param labelFormat the label format string (null not + * permitted). + * @param formatter the number formatter (null not permitted). + */ + protected AbstractCategoryItemLabelGenerator(String labelFormat, + NumberFormat formatter) { + this(labelFormat, formatter, NumberFormat.getPercentInstance()); + } + + /** + * Creates a label generator with the specified number formatter. + * + * @param labelFormat the label format string (null not + * permitted). + * @param formatter the number formatter (null not permitted). + * @param percentFormatter the percent formatter (null not + * permitted). + * + * @since 1.0.2 + */ + protected AbstractCategoryItemLabelGenerator(String labelFormat, + NumberFormat formatter, NumberFormat percentFormatter) { + ParamChecks.nullNotPermitted(labelFormat, "labelFormat"); + ParamChecks.nullNotPermitted(formatter, "formatter"); + ParamChecks.nullNotPermitted(percentFormatter, "percentFormatter"); + this.labelFormat = labelFormat; + this.numberFormat = formatter; + this.percentFormat = percentFormatter; + this.dateFormat = null; + this.nullValueString = "-"; + } + + /** + * Creates a label generator with the specified date formatter. + * + * @param labelFormat the label format string (null not + * permitted). + * @param formatter the date formatter (null not permitted). + */ + protected AbstractCategoryItemLabelGenerator(String labelFormat, + DateFormat formatter) { + ParamChecks.nullNotPermitted(labelFormat, "labelFormat"); + ParamChecks.nullNotPermitted(formatter, "formatter"); + this.labelFormat = labelFormat; + this.numberFormat = null; + this.percentFormat = NumberFormat.getPercentInstance(); + this.dateFormat = formatter; + this.nullValueString = "-"; + } + + /** + * Generates a label for the specified row. + * + * @param dataset the dataset (null not permitted). + * @param row the row index (zero-based). + * + * @return The label. + */ + public String generateRowLabel(CategoryDataset dataset, int row) { + return dataset.getRowKey(row).toString(); + } + + /** + * Generates a label for the specified row. + * + * @param dataset the dataset (null not permitted). + * @param column the column index (zero-based). + * + * @return The label. + */ + public String generateColumnLabel(CategoryDataset dataset, int column) { + return dataset.getColumnKey(column).toString(); + } + + /** + * Returns the label format string. + * + * @return The label format string (never null). + */ + public String getLabelFormat() { + return this.labelFormat; + } + + /** + * Returns the number formatter. + * + * @return The number formatter (possibly null). + */ + public NumberFormat getNumberFormat() { + return this.numberFormat; + } + + /** + * Returns the date formatter. + * + * @return The date formatter (possibly null). + */ + public DateFormat getDateFormat() { + return this.dateFormat; + } + + /** + * Generates a for the specified item. + * + * @param dataset the dataset (null not permitted). + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The label (possibly null). + */ + protected String generateLabelString(CategoryDataset dataset, + int row, int column) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + String result; + Object[] items = createItemArray(dataset, row, column); + result = MessageFormat.format(this.labelFormat, items); + return result; + + } + + /** + * Creates the array of items that can be passed to the + * {@link MessageFormat} class for creating labels. + * + * @param dataset the dataset (null not permitted). + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The items (never null). + */ + protected Object[] createItemArray(CategoryDataset dataset, + int row, int column) { + Object[] result = new Object[4]; + result[0] = dataset.getRowKey(row).toString(); + result[1] = dataset.getColumnKey(column).toString(); + Number value = dataset.getValue(row, column); + if (value != null) { + if (this.numberFormat != null) { + result[2] = this.numberFormat.format(value); + } + else if (this.dateFormat != null) { + result[2] = this.dateFormat.format(value); + } + } + else { + result[2] = this.nullValueString; + } + if (value != null) { + double total = DataUtilities.calculateColumnTotal(dataset, column); + double percent = value.doubleValue() / total; + result[3] = this.percentFormat.format(percent); + } + + return result; + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof AbstractCategoryItemLabelGenerator)) { + return false; + } + + AbstractCategoryItemLabelGenerator that + = (AbstractCategoryItemLabelGenerator) obj; + if (!this.labelFormat.equals(that.labelFormat)) { + return false; + } + if (!ObjectUtilities.equal(this.dateFormat, that.dateFormat)) { + return false; + } + if (!ObjectUtilities.equal(this.numberFormat, that.numberFormat)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 127; + result = HashUtilities.hashCode(result, this.labelFormat); + result = HashUtilities.hashCode(result, this.nullValueString); + result = HashUtilities.hashCode(result, this.dateFormat); + result = HashUtilities.hashCode(result, this.numberFormat); + result = HashUtilities.hashCode(result, this.percentFormat); + return result; + } + + /** + * Returns an independent copy of the generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException should not happen. + */ + @Override + public Object clone() throws CloneNotSupportedException { + AbstractCategoryItemLabelGenerator clone + = (AbstractCategoryItemLabelGenerator) super.clone(); + if (this.numberFormat != null) { + clone.numberFormat = (NumberFormat) this.numberFormat.clone(); + } + if (this.dateFormat != null) { + clone.dateFormat = (DateFormat) this.dateFormat.clone(); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/AbstractPieItemLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/AbstractPieItemLabelGenerator.java new file mode 100755 index 0000000..7518de8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/AbstractPieItemLabelGenerator.java @@ -0,0 +1,242 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------- + * AbstractPieItemLabelGenerator.java + * ---------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 09-Nov-2004 : Version 1, draws out code from StandardPieItemLabelGenerator + * and StandardPieToolTipGenerator (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 03-May-2006 : Fixed bug 1480978, a problem in the clone() method (DG); + * 23-Nov-2007 : Implemented hashCode() (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.MessageFormat; +import java.text.NumberFormat; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.general.PieDataset; + +/** + * A base class used for generating pie chart item labels. + */ +public class AbstractPieItemLabelGenerator implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7347703325267846275L; + + /** The label format string. */ + private String labelFormat; + + /** A number formatter for the value. */ + private NumberFormat numberFormat; + + /** A number formatter for the percentage. */ + private NumberFormat percentFormat; + + /** + * Creates an item label generator using the specified number formatters. + * + * @param labelFormat the label format string (null not + * permitted). + * @param numberFormat the format object for the values (null + * not permitted). + * @param percentFormat the format object for the percentages + * (null not permitted). + */ + protected AbstractPieItemLabelGenerator(String labelFormat, + NumberFormat numberFormat, NumberFormat percentFormat) { + ParamChecks.nullNotPermitted(labelFormat, "labelFormat"); + ParamChecks.nullNotPermitted(numberFormat, "numberFormat"); + ParamChecks.nullNotPermitted(percentFormat, "percentFormat"); + this.labelFormat = labelFormat; + this.numberFormat = numberFormat; + this.percentFormat = percentFormat; + } + + /** + * Returns the label format string. + * + * @return The label format string (never null). + */ + public String getLabelFormat() { + return this.labelFormat; + } + + /** + * Returns the number formatter. + * + * @return The formatter (never null). + */ + public NumberFormat getNumberFormat() { + return this.numberFormat; + } + + /** + * Returns the percent formatter. + * + * @return The formatter (never null). + */ + public NumberFormat getPercentFormat() { + return this.percentFormat; + } + + /** + * Creates the array of items that can be passed to the + * {@link MessageFormat} class for creating labels. The returned array + * contains four values: + *

    + *
  • result[0] = the section key converted to a String;
  • + *
  • result[1] = the formatted data value;
  • + *
  • result[2] = the formatted percentage (of the total);
  • + *
  • result[3] = the formatted total value.
  • + *
+ * + * @param dataset the dataset (null not permitted). + * @param key the key (null not permitted). + * + * @return The items (never null). + */ + protected Object[] createItemArray(PieDataset dataset, Comparable key) { + Object[] result = new Object[4]; + double total = DatasetUtilities.calculatePieDatasetTotal(dataset); + result[0] = key.toString(); + Number value = dataset.getValue(key); + if (value != null) { + result[1] = this.numberFormat.format(value); + } + else { + result[1] = "null"; + } + double percent = 0.0; + if (value != null) { + double v = value.doubleValue(); + if (v > 0.0) { + percent = v / total; + } + } + result[2] = this.percentFormat.format(percent); + result[3] = this.numberFormat.format(total); + return result; + } + + /** + * Generates a label for a pie section. + * + * @param dataset the dataset (null not permitted). + * @param key the section key (null not permitted). + * + * @return The label (possibly null). + */ + protected String generateSectionLabel(PieDataset dataset, Comparable key) { + String result = null; + if (dataset != null) { + Object[] items = createItemArray(dataset, key); + result = MessageFormat.format(this.labelFormat, items); + } + return result; + } + + /** + * Tests the generator for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof AbstractPieItemLabelGenerator)) { + return false; + } + + AbstractPieItemLabelGenerator that + = (AbstractPieItemLabelGenerator) obj; + if (!this.labelFormat.equals(that.labelFormat)) { + return false; + } + if (!this.numberFormat.equals(that.numberFormat)) { + return false; + } + if (!this.percentFormat.equals(that.percentFormat)) { + return false; + } + return true; + + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 127; + result = HashUtilities.hashCode(result, this.labelFormat); + result = HashUtilities.hashCode(result, this.numberFormat); + result = HashUtilities.hashCode(result, this.percentFormat); + return result; + } + + /** + * Returns an independent copy of the generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException should not happen. + */ + @Override + public Object clone() throws CloneNotSupportedException { + AbstractPieItemLabelGenerator clone + = (AbstractPieItemLabelGenerator) super.clone(); + if (this.numberFormat != null) { + clone.numberFormat = (NumberFormat) this.numberFormat.clone(); + } + if (this.percentFormat != null) { + clone.percentFormat = (NumberFormat) this.percentFormat.clone(); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/AbstractXYItemLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/AbstractXYItemLabelGenerator.java new file mode 100755 index 0000000..2578496 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/AbstractXYItemLabelGenerator.java @@ -0,0 +1,372 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * AbstractXYItemLabelGenerator.java + * --------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Feb-2004 : Version 1 (DG); + * 12-May-2004 : Moved default tool tip format to + * StandardXYToolTipGenerator (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 08-Oct-2004 : Modified createItemArray() method to handle null values (DG); + * 10-Jan-2005 : Updated createItemArray() to use x, y primitives if + * possible (DG); + * ------------- JFREECHART 1.0.x -------------------------------------------- + * 26-Jan-2006 : Minor API doc update (DG); + * 25-Jan-2007 : Added new constructor and fixed bug in clone() method (DG); + * 16-Oct-2007 : Removed redundant code (DG); + * 23-Nov-2007 : Implemented hashCode() (DG); + * 26-May-2008 : Added accessor methods for nullYString and updated equals() + * method (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.MessageFormat; +import java.text.NumberFormat; +import java.util.Date; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.util.ObjectUtilities; + +/** + * A base class for creating item label generators. + */ +public class AbstractXYItemLabelGenerator implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 5869744396278660636L; + + /** The item label format string. */ + private String formatString; + + /** A number formatter for the x value. */ + private NumberFormat xFormat; + + /** A date formatter for the x value. */ + private DateFormat xDateFormat; + + /** A formatter for the y value. */ + private NumberFormat yFormat; + + /** A date formatter for the y value. */ + private DateFormat yDateFormat; + + /** The string used to represent 'null' for the y-value. */ + private String nullYString = "null"; + + /** + * Creates an item label generator using default number formatters. + */ + protected AbstractXYItemLabelGenerator() { + this("{2}", NumberFormat.getNumberInstance(), + NumberFormat.getNumberInstance()); + } + + /** + * Creates an item label generator using the specified number formatters. + * + * @param formatString the item label format string (null + * not permitted). + * @param xFormat the format object for the x values (null + * not permitted). + * @param yFormat the format object for the y values (null + * not permitted). + */ + protected AbstractXYItemLabelGenerator(String formatString, + NumberFormat xFormat, NumberFormat yFormat) { + + ParamChecks.nullNotPermitted(formatString, "formatString"); + ParamChecks.nullNotPermitted(xFormat, "xFormat"); + ParamChecks.nullNotPermitted(yFormat, "yFormat"); + this.formatString = formatString; + this.xFormat = xFormat; + this.yFormat = yFormat; + } + + /** + * Creates an item label generator using the specified number formatters. + * + * @param formatString the item label format string (null + * not permitted). + * @param xFormat the format object for the x values (null + * permitted). + * @param yFormat the format object for the y values (null + * not permitted). + */ + protected AbstractXYItemLabelGenerator(String formatString, + DateFormat xFormat, NumberFormat yFormat) { + + this(formatString, NumberFormat.getInstance(), yFormat); + this.xDateFormat = xFormat; + } + + /** + * Creates an item label generator using the specified formatters (a + * number formatter for the x-values and a date formatter for the + * y-values). + * + * @param formatString the item label format string (null + * not permitted). + * @param xFormat the format object for the x values (null + * permitted). + * @param yFormat the format object for the y values (null + * not permitted). + * + * @since 1.0.4 + */ + protected AbstractXYItemLabelGenerator(String formatString, + NumberFormat xFormat, DateFormat yFormat) { + + this(formatString, xFormat, NumberFormat.getInstance()); + this.yDateFormat = yFormat; + } + + /** + * Creates an item label generator using the specified number formatters. + * + * @param formatString the item label format string (null + * not permitted). + * @param xFormat the format object for the x values (null + * permitted). + * @param yFormat the format object for the y values (null + * not permitted). + */ + protected AbstractXYItemLabelGenerator(String formatString, + DateFormat xFormat, DateFormat yFormat) { + + this(formatString, NumberFormat.getInstance(), + NumberFormat.getInstance()); + this.xDateFormat = xFormat; + this.yDateFormat = yFormat; + } + + /** + * Returns the format string (this controls the overall structure of the + * label). + * + * @return The format string (never null). + */ + public String getFormatString() { + return this.formatString; + } + + /** + * Returns the number formatter for the x-values. + * + * @return The number formatter (possibly null). + */ + public NumberFormat getXFormat() { + return this.xFormat; + } + + /** + * Returns the date formatter for the x-values. + * + * @return The date formatter (possibly null). + */ + public DateFormat getXDateFormat() { + return this.xDateFormat; + } + + /** + * Returns the number formatter for the y-values. + * + * @return The number formatter (possibly null). + */ + public NumberFormat getYFormat() { + return this.yFormat; + } + + /** + * Returns the date formatter for the y-values. + * + * @return The date formatter (possibly null). + */ + public DateFormat getYDateFormat() { + return this.yDateFormat; + } + + /** + * Generates a label string for an item in the dataset. + * + * @param dataset the dataset (null not permitted). + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The label (possibly null). + */ + public String generateLabelString(XYDataset dataset, int series, int item) { + String result; + Object[] items = createItemArray(dataset, series, item); + result = MessageFormat.format(this.formatString, items); + return result; + } + + /** + * Returns the string representing a null value. + * + * @return The string representing a null value. + * + * @since 1.0.10 + */ + public String getNullYString() { + return this.nullYString; + } + + /** + * Creates the array of items that can be passed to the + * {@link MessageFormat} class for creating labels. + * + * @param dataset the dataset (null not permitted). + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return An array of three items from the dataset formatted as + * String objects (never null). + */ + protected Object[] createItemArray(XYDataset dataset, int series, + int item) { + Object[] result = new Object[3]; + result[0] = dataset.getSeriesKey(series).toString(); + + double x = dataset.getXValue(series, item); + if (this.xDateFormat != null) { + result[1] = this.xDateFormat.format(new Date((long) x)); + } + else { + result[1] = this.xFormat.format(x); + } + + double y = dataset.getYValue(series, item); + if (Double.isNaN(y) && dataset.getY(series, item) == null) { + result[2] = this.nullYString; + } + else { + if (this.yDateFormat != null) { + result[2] = this.yDateFormat.format(new Date((long) y)); + } + else { + result[2] = this.yFormat.format(y); + } + } + return result; + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof AbstractXYItemLabelGenerator)) { + return false; + } + AbstractXYItemLabelGenerator that = (AbstractXYItemLabelGenerator) obj; + if (!this.formatString.equals(that.formatString)) { + return false; + } + if (!ObjectUtilities.equal(this.xFormat, that.xFormat)) { + return false; + } + if (!ObjectUtilities.equal(this.xDateFormat, that.xDateFormat)) { + return false; + } + if (!ObjectUtilities.equal(this.yFormat, that.yFormat)) { + return false; + } + if (!ObjectUtilities.equal(this.yDateFormat, that.yDateFormat)) { + return false; + } + if (!this.nullYString.equals(that.nullYString)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 127; + result = HashUtilities.hashCode(result, this.formatString); + result = HashUtilities.hashCode(result, this.xFormat); + result = HashUtilities.hashCode(result, this.xDateFormat); + result = HashUtilities.hashCode(result, this.yFormat); + result = HashUtilities.hashCode(result, this.yDateFormat); + return result; + } + + /** + * Returns an independent copy of the generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException if cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + AbstractXYItemLabelGenerator clone + = (AbstractXYItemLabelGenerator) super.clone(); + if (this.xFormat != null) { + clone.xFormat = (NumberFormat) this.xFormat.clone(); + } + if (this.yFormat != null) { + clone.yFormat = (NumberFormat) this.yFormat.clone(); + } + if (this.xDateFormat != null) { + clone.xDateFormat = (DateFormat) this.xDateFormat.clone(); + } + if (this.yDateFormat != null) { + clone.yDateFormat = (DateFormat) this.yDateFormat.clone(); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/BoxAndWhiskerToolTipGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/BoxAndWhiskerToolTipGenerator.java new file mode 100755 index 0000000..2650adb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/BoxAndWhiskerToolTipGenerator.java @@ -0,0 +1,149 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------ + * BoxAndWhiskerToolTipGenerator.java + * ------------------------------------ + * (C) Copyright 2004-2008, by David Browning and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 02-Jun-2004 : Version 1 (DG); + * 23-Mar-2005 : Implemented PublicCloneable (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.MessageFormat; +import java.text.NumberFormat; + +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.statistics.BoxAndWhiskerCategoryDataset; +import org.jfree.util.PublicCloneable; + +/** + * An item label generator for plots that use data from a + * {@link BoxAndWhiskerCategoryDataset}. + *

+ * The tooltip text and item label text are composed using a + * {@link java.text.MessageFormat} object, that can aggregate some or all of + * the following string values into a message. + * + * + * + * + * + * + * + * + * + *
0Series Name
1X (value or date)
2Mean
3Median
4Minimum
5Maximum
6Quartile 1
7Quartile 3
+ */ +public class BoxAndWhiskerToolTipGenerator + extends StandardCategoryToolTipGenerator + implements CategoryToolTipGenerator, Cloneable, PublicCloneable, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -6076837753823076334L; + + /** The default tooltip format string. */ + public static final String DEFAULT_TOOL_TIP_FORMAT + = "X: {1} Mean: {2} Median: {3} Min: {4} Max: {5} Q1: {6} Q3: {7} "; + + /** + * Creates a default tool tip generator. + */ + public BoxAndWhiskerToolTipGenerator() { + super(DEFAULT_TOOL_TIP_FORMAT, NumberFormat.getInstance()); + } + + /** + * Creates a tool tip formatter. + * + * @param format the tool tip format string. + * @param formatter the formatter. + */ + public BoxAndWhiskerToolTipGenerator(String format, + NumberFormat formatter) { + super(format, formatter); + } + + /** + * Creates the array of items that can be passed to the + * {@link MessageFormat} class for creating labels. + * + * @param dataset the dataset (null not permitted). + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The items (never null). + */ + @Override + protected Object[] createItemArray(CategoryDataset dataset, int series, + int item) { + Object[] result = new Object[8]; + result[0] = dataset.getRowKey(series); + Number y = dataset.getValue(series, item); + NumberFormat formatter = getNumberFormat(); + result[1] = formatter.format(y); + if (dataset instanceof BoxAndWhiskerCategoryDataset) { + BoxAndWhiskerCategoryDataset d + = (BoxAndWhiskerCategoryDataset) dataset; + result[2] = formatter.format(d.getMeanValue(series, item)); + result[3] = formatter.format(d.getMedianValue(series, item)); + result[4] = formatter.format(d.getMinRegularValue(series, item)); + result[5] = formatter.format(d.getMaxRegularValue(series, item)); + result[6] = formatter.format(d.getQ1Value(series, item)); + result[7] = formatter.format(d.getQ3Value(series, item)); + } + return result; + } + + /** + * Tests if this object is equal to another. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof BoxAndWhiskerToolTipGenerator) { + return super.equals(obj); + } + return false; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/BoxAndWhiskerXYToolTipGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/BoxAndWhiskerXYToolTipGenerator.java new file mode 100755 index 0000000..48524c7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/BoxAndWhiskerXYToolTipGenerator.java @@ -0,0 +1,169 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------ + * BoxAndWhiskerXYToolTipGenerator.java + * ------------------------------------ + * (C) Copyright 2003-2008, by David Browning and Contributors. + * + * Original Author: David Browning; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 05-Aug-2003 : Version 1, contributed by David Browning (DG); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 28-Aug-2003 : Updated for changes in dataset API (DG); + * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG); + * 27-Feb-2004 : Renamed BoxAndWhiskerItemLabelGenerator --> + * BoxAndWhiskerXYItemLabelGenerator, and modified to use + * MessageFormat (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.MessageFormat; +import java.text.NumberFormat; +import java.util.Date; + +import org.jfree.data.statistics.BoxAndWhiskerXYDataset; +import org.jfree.data.xy.XYDataset; + +/** + * An item label generator for plots that use data from a + * {@link BoxAndWhiskerXYDataset}. + *

+ * The tooltip text and item label text are composed using a + * {@link java.text.MessageFormat} object, that can aggregate some or all of + * the following string values into a message. + * + * + * + * + * + * + * + * + * + *
0Series Name
1X (value or date)
2Mean
3Median
4Minimum
5Maximum
6Quartile 1
7Quartile 3
+ */ +public class BoxAndWhiskerXYToolTipGenerator extends StandardXYToolTipGenerator + implements XYToolTipGenerator, Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -2648775791161459710L; + + /** The default tooltip format string. */ + public static final String DEFAULT_TOOL_TIP_FORMAT + = "X: {1} Mean: {2} Median: {3} Min: {4} Max: {5} Q1: {6} Q3: {7} "; + + /** + * Creates a default item label generator. + */ + public BoxAndWhiskerXYToolTipGenerator() { + super(DEFAULT_TOOL_TIP_FORMAT, NumberFormat.getInstance(), + NumberFormat.getInstance()); + } + + /** + * Creates a new item label generator. If the date formatter is not + * null, the x-values will be formatted as dates. + * + * @param toolTipFormat the tool tip format string (null not + * permitted). + * @param numberFormat the number formatter (null not + * permitted). + * @param dateFormat the date formatter (null permitted). + */ + public BoxAndWhiskerXYToolTipGenerator(String toolTipFormat, + DateFormat dateFormat, + NumberFormat numberFormat) { + + super(toolTipFormat, dateFormat, numberFormat); + + } + + /** + * Creates the array of items that can be passed to the + * {@link MessageFormat} class for creating labels. + * + * @param dataset the dataset (null not permitted). + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The items (never null). + */ + @Override + protected Object[] createItemArray(XYDataset dataset, int series, + int item) { + Object[] result = new Object[8]; + result[0] = dataset.getSeriesKey(series).toString(); + Number x = dataset.getX(series, item); + if (getXDateFormat() != null) { + result[1] = getXDateFormat().format(new Date(x.longValue())); + } + else { + result[1] = getXFormat().format(x); + } + NumberFormat formatter = getYFormat(); + + if (dataset instanceof BoxAndWhiskerXYDataset) { + BoxAndWhiskerXYDataset d = (BoxAndWhiskerXYDataset) dataset; + result[2] = formatter.format(d.getMeanValue(series, item)); + result[3] = formatter.format(d.getMedianValue(series, item)); + result[4] = formatter.format(d.getMinRegularValue(series, item)); + result[5] = formatter.format(d.getMaxRegularValue(series, item)); + result[6] = formatter.format(d.getQ1Value(series, item)); + result[7] = formatter.format(d.getQ3Value(series, item)); + } + return result; + } + + /** + * Tests if this object is equal to another. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof BoxAndWhiskerXYToolTipGenerator)) { + return false; + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/BubbleXYItemLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/BubbleXYItemLabelGenerator.java new file mode 100755 index 0000000..c2132c7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/BubbleXYItemLabelGenerator.java @@ -0,0 +1,278 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * BubbleXYItemLabelGenerator.java + * ------------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Dec-2005 : Version 1, based on StandardXYZToolTipGenerator (DG); + * 26-Jan-2006 : Renamed StandardXYZItemLabelGenerator + * --> BubbleXYItemLabelGenerator (DG); + * 23-Nov-2007 : Implemented hashCode() (DG); + * 23-Apr-2008 : Implemented PublicCloneable (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.MessageFormat; +import java.text.NumberFormat; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.renderer.xy.XYBubbleRenderer; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYZDataset; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * An item label generator defined for use with the {@link XYBubbleRenderer} + * class, or any other class that uses an {@link XYZDataset}. + * + * @since 1.0.1 + */ +public class BubbleXYItemLabelGenerator extends AbstractXYItemLabelGenerator + implements XYItemLabelGenerator, PublicCloneable, Serializable { + + /** For serialization. */ + static final long serialVersionUID = -8458568928021240922L; + + /** The default item label format. */ + public static final String DEFAULT_FORMAT_STRING = "{3}"; + + /** + * A number formatter for the z value - if this is null, then + * zDateFormat must be non-null. + */ + private NumberFormat zFormat; + + /** + * A date formatter for the z-value - if this is null, then zFormat must be + * non-null. + */ + private DateFormat zDateFormat; + + /** + * Creates a new tool tip generator using default number formatters for the + * x, y and z-values. + */ + public BubbleXYItemLabelGenerator() { + this(DEFAULT_FORMAT_STRING, NumberFormat.getNumberInstance(), + NumberFormat.getNumberInstance(), + NumberFormat.getNumberInstance()); + } + + /** + * Constructs a new tool tip generator using the specified number + * formatters. + * + * @param formatString the format string. + * @param xFormat the format object for the x values (null + * not permitted). + * @param yFormat the format object for the y values (null + * not permitted). + * @param zFormat the format object for the z values (null + * not permitted). + */ + public BubbleXYItemLabelGenerator(String formatString, + NumberFormat xFormat, NumberFormat yFormat, NumberFormat zFormat) { + super(formatString, xFormat, yFormat); + ParamChecks.nullNotPermitted(zFormat, "zFormat"); + this.zFormat = zFormat; + } + + /** + * Constructs a new item label generator using the specified date + * formatters. + * + * @param formatString the format string. + * @param xFormat the format object for the x values (null + * not permitted). + * @param yFormat the format object for the y values (null + * not permitted). + * @param zFormat the format object for the z values (null + * not permitted). + */ + public BubbleXYItemLabelGenerator(String formatString, + DateFormat xFormat, DateFormat yFormat, DateFormat zFormat) { + super(formatString, xFormat, yFormat); + ParamChecks.nullNotPermitted(zFormat, "zFormat"); + this.zDateFormat = zFormat; + } + + /** + * Returns the number formatter for the z-values. + * + * @return The number formatter (possibly null). + */ + public NumberFormat getZFormat() { + return this.zFormat; + } + + /** + * Returns the date formatter for the z-values. + * + * @return The date formatter (possibly null). + */ + public DateFormat getZDateFormat() { + return this.zDateFormat; + } + + /** + * Generates an item label for a particular item within a series. + * + * @param dataset the dataset (null not permitted). + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The item label (possibly null). + */ + @Override + public String generateLabel(XYDataset dataset, int series, int item) { + return generateLabelString(dataset, series, item); + } + + /** + * Generates a label string for an item in the dataset. + * + * @param dataset the dataset (null not permitted). + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The label (possibly null). + */ + @Override + public String generateLabelString(XYDataset dataset, int series, int item) { + String result; + Object[] items; + if (dataset instanceof XYZDataset) { + items = createItemArray((XYZDataset) dataset, series, item); + } + else { + items = createItemArray(dataset, series, item); + } + result = MessageFormat.format(getFormatString(), items); + return result; + } + + /** + * Creates the array of items that can be passed to the + * {@link MessageFormat} class for creating labels. + * + * @param dataset the dataset (null not permitted). + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The items (never null). + */ + protected Object[] createItemArray(XYZDataset dataset, + int series, int item) { + + Object[] result = new Object[4]; + result[0] = dataset.getSeriesKey(series).toString(); + + Number x = dataset.getX(series, item); + DateFormat xf = getXDateFormat(); + if (xf != null) { + result[1] = xf.format(x); + } + else { + result[1] = getXFormat().format(x); + } + + Number y = dataset.getY(series, item); + DateFormat yf = getYDateFormat(); + if (yf != null) { + result[2] = yf.format(y); + } + else { + result[2] = getYFormat().format(y); + } + + Number z = dataset.getZ(series, item); + if (this.zDateFormat != null) { + result[3] = this.zDateFormat.format(z); + } + else { + result[3] = this.zFormat.format(z); + } + + return result; + + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof BubbleXYItemLabelGenerator)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + BubbleXYItemLabelGenerator that = (BubbleXYItemLabelGenerator) obj; + if (!ObjectUtilities.equal(this.zFormat, that.zFormat)) { + return false; + } + if (!ObjectUtilities.equal(this.zDateFormat, that.zDateFormat)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int h = super.hashCode(); + h = HashUtilities.hashCode(h, this.zFormat); + h = HashUtilities.hashCode(h, this.zDateFormat); + return h; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CategoryItemLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CategoryItemLabelGenerator.java new file mode 100755 index 0000000..0f6de71 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CategoryItemLabelGenerator.java @@ -0,0 +1,107 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * CategoryItemLabelGenerator.java + * ------------------------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Dec-2001 : Version 1 (DG); + * 16-Jan-2002 : Completed Javadocs (DG); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 24-Oct-2002 : Method now specifies category index (DG); + * 05-Nov-2002 : Replaced reference to CategoryDataset with TableDataset (DG); + * 21-Jan-2003 : TableDataset merged with CategoryDataset (DG); + * 10-Apr-2003 : Changed CategoryDataset --> KeyedValues2DDataset (DG); + * 01-May-2003 : Added generateValueLabel() method (with a plan to renaming + * this interface to reflect its more general use) (DG); + * 09-Jun-2003 : Renamed CategoryToolTipGenerator + * --> CategoryItemLabelGenerator (DG); + * 13-Aug-2003 : Added clone() method (DG); + * 12-Feb-2004 : Removed clone() method (DG); + * 15-Apr-2004 : Moved generateToolTip() method into CategoryToolTipGenerator + * interface (DG); + * 11-May-2004 : Renamed CategoryItemLabelGenerator + * --> CategoryLabelGenerator (DG); + * 31-Jan-2005 : Added generateRowLabel() and generateColumnLabel() + * methods (DG); + * 20-Apr-2005 : Reverted name change of 11-May-2004 (DG); + * + */ + +package org.jfree.chart.labels; + +import org.jfree.data.category.CategoryDataset; + +/** + * A category item label generator is an object that can be assigned to a + * {@link org.jfree.chart.renderer.category.CategoryItemRenderer} and that + * assumes responsibility for creating text items to be used as labels for the + * items in a {@link org.jfree.chart.plot.CategoryPlot}. + *

+ * To assist with cloning charts, classes that implement this interface should + * also implement the {@link org.jfree.util.PublicCloneable} interface. + */ +public interface CategoryItemLabelGenerator { + + /** + * Generates a label for the specified row. + * + * @param dataset the dataset (null not permitted). + * @param row the row index (zero-based). + * + * @return The label. + */ + public String generateRowLabel(CategoryDataset dataset, int row); + + /** + * Generates a label for the specified row. + * + * @param dataset the dataset (null not permitted). + * @param column the column index (zero-based). + * + * @return The label. + */ + public String generateColumnLabel(CategoryDataset dataset, int column); + + /** + * Generates a label for the specified item. The label is typically a + * formatted version of the data value, but any text can be used. + * + * @param dataset the dataset (null not permitted). + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The label (possibly null). + */ + public String generateLabel(CategoryDataset dataset, int row, int column); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CategorySeriesLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CategorySeriesLabelGenerator.java new file mode 100755 index 0000000..469866f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CategorySeriesLabelGenerator.java @@ -0,0 +1,67 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * CategorySeriesLabelGenerator.java + * --------------------------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Apr-2005 : Version 1 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 24-Nov-2006 : Updated API docs (DG); + * + */ + +package org.jfree.chart.labels; + +import org.jfree.data.category.CategoryDataset; + +/** + * A generator that creates labels for the series in a {@link CategoryDataset}. + *

+ * Classes that implement this interface should be either (a) immutable, or + * (b) cloneable via the PublicCloneable interface (defined in + * the JCommon class library). This provides a mechanism for the referring + * renderer to clone the generator if necessary. + */ +public interface CategorySeriesLabelGenerator { + + /** + * Generates a label for the specified series. + * + * @param dataset the dataset (null not permitted). + * @param series the series index. + * + * @return A series label. + */ + public String generateLabel(CategoryDataset dataset, int series); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CategoryToolTipGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CategoryToolTipGenerator.java new file mode 100755 index 0000000..1c1b5f8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CategoryToolTipGenerator.java @@ -0,0 +1,71 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * CategoryToolTipGenerator.java + * ----------------------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 15-Apr-2004 : Separated tool tip method from CategoryItemLabelGenerator + * interface (DG); + * + */ + +package org.jfree.chart.labels; + +import org.jfree.data.category.CategoryDataset; + +/** + * A category tool tip generator is an object that can be assigned to a + * {@link org.jfree.chart.renderer.category.CategoryItemRenderer} and that + * assumes responsibility for creating text items to be used as tooltips for the + * items in a {@link org.jfree.chart.plot.CategoryPlot}. + *

+ * To assist with cloning charts, classes that implement this interface should + * also implement the org.jfree.util.PublicCloneable interface (in + * JCommon). + */ +public interface CategoryToolTipGenerator { + + /** + * Generates the tool tip text for an item in a dataset. Note: in the + * current dataset implementation, each row is a series, and each column + * contains values for a particular category. + * + * @param dataset the dataset (null not permitted). + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The tooltip text (possibly null). + */ + public String generateToolTip(CategoryDataset dataset, int row, int column); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/ContourToolTipGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/ContourToolTipGenerator.java new file mode 100755 index 0000000..16a8632 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/ContourToolTipGenerator.java @@ -0,0 +1,69 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * ContourToolTipGenerator.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 + * ------- + * 23-Jan-2003 : Added standard header (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Deprecated (DG); + * + */ + +package org.jfree.chart.labels; + +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYBlockRenderer; +import org.jfree.data.contour.ContourDataset; + +/** + * Interface for a tooltip generator for plots that use data from a + * {@link ContourDataset}. + * + * @deprecated This interface 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 interface ContourToolTipGenerator { + + /** + * Generates a tooltip text item for a particular item within a series. + * + * @param dataset the dataset. + * @param item the item index (zero-based). + * + * @return The tooltip text. + */ + public String generateToolTip(ContourDataset dataset, int item); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CrosshairLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CrosshairLabelGenerator.java new file mode 100755 index 0000000..2c6baf6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CrosshairLabelGenerator.java @@ -0,0 +1,61 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * CrosshairLabelGenerator.java + * ---------------------------- + * (C) Copyright 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 13-Feb-2009 : Version 1 (DG); + * + */ + +package org.jfree.chart.labels; + +import org.jfree.chart.plot.Crosshair; + +/** + * A label generator for crosshairs. + * + * @since 1.0.13 + */ +public interface CrosshairLabelGenerator { + + /** + * Returns a string that can be used as the label for a crosshair. + * + * @param crosshair the crosshair (null not permitted). + * + * @return The label (possibly null). + */ + public String generateLabel(Crosshair crosshair); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CustomXYToolTipGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CustomXYToolTipGenerator.java new file mode 100755 index 0000000..c9230d9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/CustomXYToolTipGenerator.java @@ -0,0 +1,197 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * CustomXYItemLabelGenerator.java + * ------------------------------- + * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 05-Aug-2002 : Version 1, contributed by Richard Atkinson (RA); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 21-Mar-2003 : Implemented Serializable (DG); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 17-Nov-2003 : Implemented PublicCloneable (DG); + * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.util.List; + +import org.jfree.data.xy.XYDataset; +import org.jfree.util.PublicCloneable; + +/** + * A tool tip generator that stores custom tooltips. The dataset passed into + * the generateToolTip method is ignored. + */ +public class CustomXYToolTipGenerator implements XYToolTipGenerator, + Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 8636030004670141362L; + + /** Storage for the tooltip lists. */ + private List toolTipSeries = new java.util.ArrayList(); + + /** + * Default constructor. + */ + public CustomXYToolTipGenerator() { + super(); + } + + /** + * Returns the number of tool tip lists stored by the renderer. + * + * @return The list count. + */ + public int getListCount() { + return this.toolTipSeries.size(); + } + + /** + * Returns the number of tool tips in a given list. + * + * @param list the list index (zero based). + * + * @return The tooltip count. + */ + public int getToolTipCount(int list) { + + int result = 0; + List tooltips = (List) this.toolTipSeries.get(list); + if (tooltips != null) { + result = tooltips.size(); + } + return result; + } + + /** + * Returns the tool tip text for an item. + * + * @param series the series index. + * @param item the item index. + * + * @return The tool tip text. + */ + public String getToolTipText(int series, int item) { + + String result = null; + + if (series < getListCount()) { + List tooltips = (List) this.toolTipSeries.get(series); + if (tooltips != null) { + if (item < tooltips.size()) { + result = (String) tooltips.get(item); + } + } + } + + return result; + } + + /** + * Adds a list of tooltips for a series. + * + * @param toolTips the list of tool tips. + */ + public void addToolTipSeries(List toolTips) { + this.toolTipSeries.add(toolTips); + } + + /** + * Generates a tool tip text item for a particular item within a series. + * + * @param data the dataset (ignored in this implementation). + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The tooltip text. + */ + @Override + public String generateToolTip(XYDataset data, int series, int item) { + return getToolTipText(series, item); + } + + /** + * Returns an independent copy of the generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException if cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + CustomXYToolTipGenerator clone + = (CustomXYToolTipGenerator) super.clone(); + if (this.toolTipSeries != null) { + clone.toolTipSeries = new java.util.ArrayList(this.toolTipSeries); + } + return clone; + } + + /** + * Tests if this object is equal to another. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof CustomXYToolTipGenerator) { + CustomXYToolTipGenerator generator = (CustomXYToolTipGenerator) obj; + boolean result = true; + for (int series = 0; series < getListCount(); series++) { + for (int item = 0; item < getToolTipCount(series); item++) { + String t1 = getToolTipText(series, item); + String t2 = generator.getToolTipText(series, item); + if (t1 != null) { + result = result && t1.equals(t2); + } + else { + result = result && (t2 == null); + } + } + } + return result; + } + return false; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/HighLowItemLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/HighLowItemLabelGenerator.java new file mode 100755 index 0000000..0cb1cb3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/HighLowItemLabelGenerator.java @@ -0,0 +1,229 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * HighLowItemLabelGenerator.java + * ------------------------------ + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): David Basten; + * + * Changes + * ------- + * 13-Dec-2001 : Version 1 (DG); + * 16-Jan-2002 : Completed Javadocs (DG); + * 23-Apr-2002 : Added date to the tooltip string (DG); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 21-Mar-2003 : Implemented Serializable (DG); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 17-Nov-2003 : Implemented PublicCloneable (DG); + * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG); + * 25-May-2004 : Added number formatter (see patch 890496) (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 20-Apr-2005 : Renamed XYLabelGenerator --> XYItemLabelGenerator (DG); + * 31-Mar-2008 : Added hashCode() method to appease FindBugs (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.NumberFormat; +import java.util.Date; + +import org.jfree.chart.HashUtilities; +import org.jfree.data.xy.OHLCDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.util.PublicCloneable; + +/** + * A standard item label generator for plots that use data from a + * {@link OHLCDataset}. + */ +public class HighLowItemLabelGenerator implements XYItemLabelGenerator, + XYToolTipGenerator, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 5617111754832211830L; + + /** The date formatter. */ + private DateFormat dateFormatter; + + /** The number formatter. */ + private NumberFormat numberFormatter; + + /** + * Creates an item label generator using the default date and number + * formats. + */ + public HighLowItemLabelGenerator() { + this(DateFormat.getInstance(), NumberFormat.getInstance()); + } + + /** + * Creates a tool tip generator using the supplied date formatter. + * + * @param dateFormatter the date formatter (null not + * permitted). + * @param numberFormatter the number formatter (null not + * permitted). + */ + public HighLowItemLabelGenerator(DateFormat dateFormatter, + NumberFormat numberFormatter) { + if (dateFormatter == null) { + throw new IllegalArgumentException( + "Null 'dateFormatter' argument."); + } + if (numberFormatter == null) { + throw new IllegalArgumentException( + "Null 'numberFormatter' argument."); + } + this.dateFormatter = dateFormatter; + this.numberFormatter = numberFormatter; + } + + /** + * Generates a tooltip text item for a particular item within a series. + * + * @param dataset the dataset. + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The tooltip text. + */ + @Override + public String generateToolTip(XYDataset dataset, int series, int item) { + if (!(dataset instanceof OHLCDataset)) { + return null; + } + StringBuilder sb = new StringBuilder(); + OHLCDataset d = (OHLCDataset) dataset; + Number high = d.getHigh(series, item); + Number low = d.getLow(series, item); + Number open = d.getOpen(series, item); + Number close = d.getClose(series, item); + Number x = d.getX(series, item); + sb.append(d.getSeriesKey(series).toString()); + if (x != null) { + Date date = new Date(x.longValue()); + sb.append("--> Date=").append(this.dateFormatter.format(date)); + if (high != null) { + sb.append(" High="); + sb.append(this.numberFormatter.format(high.doubleValue())); + } + if (low != null) { + sb.append(" Low="); + sb.append(this.numberFormatter.format(low.doubleValue())); + } + if (open != null) { + sb.append(" Open="); + sb.append(this.numberFormatter.format(open.doubleValue())); + } + if (close != null) { + sb.append(" Close="); + sb.append(this.numberFormatter.format(close.doubleValue())); + } + } + return sb.toString(); + } + + /** + * Generates a label for the specified item. The label is typically a + * formatted version of the data value, but any text can be used. + * + * @param dataset the dataset (null not permitted). + * @param series the series index (zero-based). + * @param category the category index (zero-based). + * + * @return The label (possibly null). + */ + @Override + public String generateLabel(XYDataset dataset, int series, int category) { + return null; //TODO: implement this method properly + } + + /** + * Returns an independent copy of the generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException if cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + HighLowItemLabelGenerator clone + = (HighLowItemLabelGenerator) super.clone(); + if (this.dateFormatter != null) { + clone.dateFormatter = (DateFormat) this.dateFormatter.clone(); + } + if (this.numberFormatter != null) { + clone.numberFormatter = (NumberFormat) this.numberFormatter.clone(); + } + return clone; + } + + /** + * Tests if this object is equal to another. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof HighLowItemLabelGenerator)) { + return false; + } + HighLowItemLabelGenerator generator = (HighLowItemLabelGenerator) obj; + if (!this.dateFormatter.equals(generator.dateFormatter)) { + return false; + } + if (!this.numberFormatter.equals(generator.numberFormatter)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 127; + result = HashUtilities.hashCode(result, this.dateFormatter); + result = HashUtilities.hashCode(result, this.numberFormatter); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/IntervalCategoryItemLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/IntervalCategoryItemLabelGenerator.java new file mode 100755 index 0000000..a814e88 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/IntervalCategoryItemLabelGenerator.java @@ -0,0 +1,138 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------------- + * IntervalCategoryItemLabelGenerator.java + * --------------------------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-May-2004 : Version 1, split from IntervalCategoryItemLabelGenerator (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.NumberFormat; + +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.IntervalCategoryDataset; +import org.jfree.util.PublicCloneable; + +/** + * A label generator for plots that use data from an + * {@link IntervalCategoryDataset}. + */ +public class IntervalCategoryItemLabelGenerator + extends StandardCategoryItemLabelGenerator + implements CategoryItemLabelGenerator, PublicCloneable, Cloneable, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 5056909225610630529L; + + /** The default format string. */ + public static final String DEFAULT_LABEL_FORMAT_STRING + = "({0}, {1}) = {3} - {4}"; + + /** + * Creates a new generator with a default number formatter. + */ + public IntervalCategoryItemLabelGenerator() { + super(DEFAULT_LABEL_FORMAT_STRING, NumberFormat.getInstance()); + } + + /** + * Creates a new generator with the specified number formatter. + * + * @param labelFormat the label format string (null not + * permitted). + * @param formatter the number formatter (null not permitted). + */ + public IntervalCategoryItemLabelGenerator(String labelFormat, + NumberFormat formatter) { + super(labelFormat, formatter); + } + + /** + * Creates a new generator with the specified date formatter. + * + * @param labelFormat the label format string (null not + * permitted). + * @param formatter the date formatter (null not permitted). + */ + public IntervalCategoryItemLabelGenerator(String labelFormat, + DateFormat formatter) { + super(labelFormat, formatter); + } + + /** + * Creates the array of items that can be passed to the + * MessageFormat class for creating labels. + * + * @param dataset the dataset (null not permitted). + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The items (never null). + */ + @Override + protected Object[] createItemArray(CategoryDataset dataset, + int row, int column) { + Object[] result = new Object[5]; + result[0] = dataset.getRowKey(row).toString(); + result[1] = dataset.getColumnKey(column).toString(); + Number value = dataset.getValue(row, column); + if (getNumberFormat() != null) { + result[2] = getNumberFormat().format(value); + } + else if (getDateFormat() != null) { + result[2] = getDateFormat().format(value); + } + + if (dataset instanceof IntervalCategoryDataset) { + IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; + Number start = icd.getStartValue(row, column); + Number end = icd.getEndValue(row, column); + if (getNumberFormat() != null) { + result[3] = getNumberFormat().format(start); + result[4] = getNumberFormat().format(end); + } + else if (getDateFormat() != null) { + result[3] = getDateFormat().format(start); + result[4] = getDateFormat().format(end); + } + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/IntervalCategoryToolTipGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/IntervalCategoryToolTipGenerator.java new file mode 100755 index 0000000..6a98cdc --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/IntervalCategoryToolTipGenerator.java @@ -0,0 +1,155 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------- + * IntervalCategoryToolTipGenerator.java + * ------------------------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-May-2004 : Version 1, split from IntervalCategoryItemLabelGenerator (DG); + * 08-Oct-2008 : Override equals() method (DG); + * + */ + +package org.jfree.chart.labels; + +import java.text.DateFormat; +import java.text.NumberFormat; + +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.IntervalCategoryDataset; + +/** + * A tooltip generator for plots that use data from an + * {@link IntervalCategoryDataset}. + */ +public class IntervalCategoryToolTipGenerator + extends StandardCategoryToolTipGenerator { + + /** For serialization. */ + private static final long serialVersionUID = -3853824986520333437L; + + /** The default format string. */ + public static final String DEFAULT_TOOL_TIP_FORMAT_STRING + = "({0}, {1}) = {3} - {4}"; + + /** + * Creates a new generator with a default number formatter. + */ + public IntervalCategoryToolTipGenerator() { + super(DEFAULT_TOOL_TIP_FORMAT_STRING, NumberFormat.getInstance()); + } + + /** + * Creates a new generator with the specified number formatter. + * + * @param labelFormat the label format string (null not + * permitted). + * @param formatter the number formatter (null not permitted). + */ + public IntervalCategoryToolTipGenerator(String labelFormat, + NumberFormat formatter) { + super(labelFormat, formatter); + } + + /** + * Creates a new generator with the specified date formatter. + * + * @param labelFormat the label format string (null not + * permitted). + * @param formatter the date formatter (null not permitted). + */ + public IntervalCategoryToolTipGenerator(String labelFormat, + DateFormat formatter) { + super(labelFormat, formatter); + } + + /** + * Creates the array of items that can be passed to the + * MessageFormat class for creating labels. + * + * @param dataset the dataset (null not permitted). + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The items (never null). + */ + @Override + protected Object[] createItemArray(CategoryDataset dataset, + int row, int column) { + Object[] result = new Object[5]; + result[0] = dataset.getRowKey(row).toString(); + result[1] = dataset.getColumnKey(column).toString(); + Number value = dataset.getValue(row, column); + if (getNumberFormat() != null) { + result[2] = getNumberFormat().format(value); + } + else if (getDateFormat() != null) { + result[2] = getDateFormat().format(value); + } + + if (dataset instanceof IntervalCategoryDataset) { + IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; + Number start = icd.getStartValue(row, column); + Number end = icd.getEndValue(row, column); + if (getNumberFormat() != null) { + result[3] = getNumberFormat().format(start); + result[4] = getNumberFormat().format(end); + } + else if (getDateFormat() != null) { + result[3] = getDateFormat().format(start); + result[4] = getDateFormat().format(end); + } + } + return result; + } + + /** + * Tests this tool tip generator for equality with an arbitrary + * object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof IntervalCategoryToolTipGenerator)) { + return false; + } + // no fields to test + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/IntervalXYItemLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/IntervalXYItemLabelGenerator.java new file mode 100755 index 0000000..62eb387 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/IntervalXYItemLabelGenerator.java @@ -0,0 +1,272 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * IntervalXYItemLabelGenerator.java + * --------------------------------- + * (C) Copyright 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-May-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.MessageFormat; +import java.text.NumberFormat; +import java.util.Date; + +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.util.PublicCloneable; + +/** + * An item label generator for datasets that implement the + * {@link IntervalXYDataset} interface. + * + * @since 1.0.10 + */ +public class IntervalXYItemLabelGenerator extends AbstractXYItemLabelGenerator + implements XYItemLabelGenerator, Cloneable, PublicCloneable, + Serializable { + + /** The default item label format. */ + public static final String DEFAULT_ITEM_LABEL_FORMAT = "{5} - {6}"; + + /** + * Creates an item label generator using default number formatters. + */ + public IntervalXYItemLabelGenerator() { + this(DEFAULT_ITEM_LABEL_FORMAT, NumberFormat.getNumberInstance(), + NumberFormat.getNumberInstance()); + } + + /** + * Creates an item label generator using the specified number formatters. + * + * @param formatString the item label format string (null not + * permitted). + * @param xFormat the format object for the x values (null + * not permitted). + * @param yFormat the format object for the y values (null + * not permitted). + */ + public IntervalXYItemLabelGenerator(String formatString, + NumberFormat xFormat, NumberFormat yFormat) { + + super(formatString, xFormat, yFormat); + } + + /** + * Creates an item label generator using the specified formatters. + * + * @param formatString the item label format string (null + * not permitted). + * @param xFormat the format object for the x values (null + * not permitted). + * @param yFormat the format object for the y values (null + * not permitted). + */ + public IntervalXYItemLabelGenerator(String formatString, + DateFormat xFormat, NumberFormat yFormat) { + + super(formatString, xFormat, yFormat); + } + + /** + * Creates an item label generator using the specified formatters (a + * number formatter for the x-values and a date formatter for the + * y-values). + * + * @param formatString the item label format string (null + * not permitted). + * @param xFormat the format object for the x values (null + * permitted). + * @param yFormat the format object for the y values (null + * not permitted). + */ + public IntervalXYItemLabelGenerator(String formatString, + NumberFormat xFormat, DateFormat yFormat) { + + super(formatString, xFormat, yFormat); + } + + /** + * Creates a label generator using the specified date formatters. + * + * @param formatString the label format string (null not + * permitted). + * @param xFormat the format object for the x values (null + * not permitted). + * @param yFormat the format object for the y values (null + * not permitted). + */ + public IntervalXYItemLabelGenerator(String formatString, + DateFormat xFormat, DateFormat yFormat) { + + super(formatString, xFormat, yFormat); + } + + /** + * Creates the array of items that can be passed to the + * {@link MessageFormat} class for creating labels. + * + * @param dataset the dataset (null not permitted). + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return An array of seven items from the dataset formatted as + * String objects (never null). + */ + @Override + protected Object[] createItemArray(XYDataset dataset, int series, + int item) { + + IntervalXYDataset intervalDataset = null; + if (dataset instanceof IntervalXYDataset) { + intervalDataset = (IntervalXYDataset) dataset; + } + Object[] result = new Object[7]; + result[0] = dataset.getSeriesKey(series).toString(); + + double x = dataset.getXValue(series, item); + double xs = x; + double xe = x; + double y = dataset.getYValue(series, item); + double ys = y; + double ye = y; + if (intervalDataset != null) { + xs = intervalDataset.getStartXValue(series, item); + xe = intervalDataset.getEndXValue(series, item); + ys = intervalDataset.getStartYValue(series, item); + ye = intervalDataset.getEndYValue(series, item); + } + + DateFormat xdf = getXDateFormat(); + if (xdf != null) { + result[1] = xdf.format(new Date((long) x)); + result[2] = xdf.format(new Date((long) xs)); + result[3] = xdf.format(new Date((long) xe)); + } + else { + NumberFormat xnf = getXFormat(); + result[1] = xnf.format(x); + result[2] = xnf.format(xs); + result[3] = xnf.format(xe); + } + + NumberFormat ynf = getYFormat(); + DateFormat ydf = getYDateFormat(); + if (Double.isNaN(y) && dataset.getY(series, item) == null) { + result[4] = getNullYString(); + } + else { + if (ydf != null) { + result[4] = ydf.format(new Date((long) y)); + } + else { + result[4] = ynf.format(y); + } + } + if (Double.isNaN(ys) && intervalDataset != null + && intervalDataset.getStartY(series, item) == null) { + result[5] = getNullYString(); + } + else { + if (ydf != null) { + result[5] = ydf.format(new Date((long) ys)); + } + else { + result[5] = ynf.format(ys); + } + } + if (Double.isNaN(ye) && intervalDataset != null + && intervalDataset.getEndY(series, item) == null) { + result[6] = getNullYString(); + } + else { + if (ydf != null) { + result[6] = ydf.format(new Date((long) ye)); + } + else { + result[6] = ynf.format(ye); + } + } + return result; + } + + /** + * Generates the item label text for an item in a dataset. + * + * @param dataset the dataset (null not permitted). + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The label text (possibly null). + */ + @Override + public String generateLabel(XYDataset dataset, int series, int item) { + return generateLabelString(dataset, series, item); + } + + /** + * Returns an independent copy of the generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException if cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof IntervalXYItemLabelGenerator)) { + return false; + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/ItemLabelAnchor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/ItemLabelAnchor.java new file mode 100755 index 0000000..fe3b94c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/ItemLabelAnchor.java @@ -0,0 +1,291 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * ItemLabelAnchor.java + * -------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Apr-2003 : Version 1 (DG); + * 19-Feb-2004 : Moved to org.jfree.chart.labels package, added readResolve() + * method (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * An enumeration of the positions that a value label can take, relative to an + * item in a {@link org.jfree.chart.plot.CategoryPlot}. + */ +public final class ItemLabelAnchor implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -1233101616128695658L; + + /** CENTER. */ + public static final ItemLabelAnchor CENTER + = new ItemLabelAnchor("ItemLabelAnchor.CENTER"); + + /** INSIDE1. */ + public static final ItemLabelAnchor INSIDE1 + = new ItemLabelAnchor("ItemLabelAnchor.INSIDE1"); + + /** INSIDE2. */ + public static final ItemLabelAnchor INSIDE2 + = new ItemLabelAnchor("ItemLabelAnchor.INSIDE2"); + + /** INSIDE3. */ + public static final ItemLabelAnchor INSIDE3 + = new ItemLabelAnchor("ItemLabelAnchor.INSIDE3"); + + /** INSIDE4. */ + public static final ItemLabelAnchor INSIDE4 + = new ItemLabelAnchor("ItemLabelAnchor.INSIDE4"); + + /** INSIDE5. */ + public static final ItemLabelAnchor INSIDE5 + = new ItemLabelAnchor("ItemLabelAnchor.INSIDE5"); + + /** INSIDE6. */ + public static final ItemLabelAnchor INSIDE6 + = new ItemLabelAnchor("ItemLabelAnchor.INSIDE6"); + + /** INSIDE7. */ + public static final ItemLabelAnchor INSIDE7 + = new ItemLabelAnchor("ItemLabelAnchor.INSIDE7"); + + /** INSIDE8. */ + public static final ItemLabelAnchor INSIDE8 + = new ItemLabelAnchor("ItemLabelAnchor.INSIDE8"); + + /** INSIDE9. */ + public static final ItemLabelAnchor INSIDE9 + = new ItemLabelAnchor("ItemLabelAnchor.INSIDE9"); + + /** INSIDE10. */ + public static final ItemLabelAnchor INSIDE10 + = new ItemLabelAnchor("ItemLabelAnchor.INSIDE10"); + + /** INSIDE11. */ + public static final ItemLabelAnchor INSIDE11 + = new ItemLabelAnchor("ItemLabelAnchor.INSIDE11"); + + /** INSIDE12. */ + public static final ItemLabelAnchor INSIDE12 + = new ItemLabelAnchor("ItemLabelAnchor.INSIDE12"); + + /** OUTSIDE1. */ + public static final ItemLabelAnchor OUTSIDE1 + = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE1"); + + /** OUTSIDE2. */ + public static final ItemLabelAnchor OUTSIDE2 + = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE2"); + + /** OUTSIDE3. */ + public static final ItemLabelAnchor OUTSIDE3 + = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE3"); + + /** OUTSIDE4. */ + public static final ItemLabelAnchor OUTSIDE4 + = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE4"); + + /** OUTSIDE5. */ + public static final ItemLabelAnchor OUTSIDE5 + = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE5"); + + /** OUTSIDE6. */ + public static final ItemLabelAnchor OUTSIDE6 + = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE6"); + + /** OUTSIDE7. */ + public static final ItemLabelAnchor OUTSIDE7 + = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE7"); + + /** OUTSIDE8. */ + public static final ItemLabelAnchor OUTSIDE8 + = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE8"); + + /** OUTSIDE9. */ + public static final ItemLabelAnchor OUTSIDE9 + = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE9"); + + /** OUTSIDE10. */ + public static final ItemLabelAnchor OUTSIDE10 + = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE10"); + + /** OUTSIDE11. */ + public static final ItemLabelAnchor OUTSIDE11 + = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE11"); + + /** OUTSIDE12. */ + public static final ItemLabelAnchor OUTSIDE12 + = new ItemLabelAnchor("ItemLabelAnchor.OUTSIDE12"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private ItemLabelAnchor(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof ItemLabelAnchor)) { + return false; + } + ItemLabelAnchor that = (ItemLabelAnchor) obj; + if (!this.name.equals(that.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 { + ItemLabelAnchor result = null; + if (this.equals(ItemLabelAnchor.CENTER)) { + result = ItemLabelAnchor.CENTER; + } + else if (this.equals(ItemLabelAnchor.INSIDE1)) { + result = ItemLabelAnchor.INSIDE1; + } + else if (this.equals(ItemLabelAnchor.INSIDE2)) { + result = ItemLabelAnchor.INSIDE2; + } + else if (this.equals(ItemLabelAnchor.INSIDE3)) { + result = ItemLabelAnchor.INSIDE3; + } + else if (this.equals(ItemLabelAnchor.INSIDE4)) { + result = ItemLabelAnchor.INSIDE4; + } + else if (this.equals(ItemLabelAnchor.INSIDE5)) { + result = ItemLabelAnchor.INSIDE5; + } + else if (this.equals(ItemLabelAnchor.INSIDE6)) { + result = ItemLabelAnchor.INSIDE6; + } + else if (this.equals(ItemLabelAnchor.INSIDE7)) { + result = ItemLabelAnchor.INSIDE7; + } + else if (this.equals(ItemLabelAnchor.INSIDE8)) { + result = ItemLabelAnchor.INSIDE8; + } + else if (this.equals(ItemLabelAnchor.INSIDE9)) { + result = ItemLabelAnchor.INSIDE9; + } + else if (this.equals(ItemLabelAnchor.INSIDE10)) { + result = ItemLabelAnchor.INSIDE10; + } + else if (this.equals(ItemLabelAnchor.INSIDE11)) { + result = ItemLabelAnchor.INSIDE11; + } + else if (this.equals(ItemLabelAnchor.INSIDE12)) { + result = ItemLabelAnchor.INSIDE12; + } + else if (this.equals(ItemLabelAnchor.OUTSIDE1)) { + result = ItemLabelAnchor.OUTSIDE1; + } + else if (this.equals(ItemLabelAnchor.OUTSIDE2)) { + result = ItemLabelAnchor.OUTSIDE2; + } + else if (this.equals(ItemLabelAnchor.OUTSIDE3)) { + result = ItemLabelAnchor.OUTSIDE3; + } + else if (this.equals(ItemLabelAnchor.OUTSIDE4)) { + result = ItemLabelAnchor.OUTSIDE4; + } + else if (this.equals(ItemLabelAnchor.OUTSIDE5)) { + result = ItemLabelAnchor.OUTSIDE5; + } + else if (this.equals(ItemLabelAnchor.OUTSIDE6)) { + result = ItemLabelAnchor.OUTSIDE6; + } + else if (this.equals(ItemLabelAnchor.OUTSIDE7)) { + result = ItemLabelAnchor.OUTSIDE7; + } + else if (this.equals(ItemLabelAnchor.OUTSIDE8)) { + result = ItemLabelAnchor.OUTSIDE8; + } + else if (this.equals(ItemLabelAnchor.OUTSIDE9)) { + result = ItemLabelAnchor.OUTSIDE9; + } + else if (this.equals(ItemLabelAnchor.OUTSIDE10)) { + result = ItemLabelAnchor.OUTSIDE10; + } + else if (this.equals(ItemLabelAnchor.OUTSIDE11)) { + result = ItemLabelAnchor.OUTSIDE11; + } + else if (this.equals(ItemLabelAnchor.OUTSIDE12)) { + result = ItemLabelAnchor.OUTSIDE12; + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/ItemLabelPosition.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/ItemLabelPosition.java new file mode 100755 index 0000000..ffc7713 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/ItemLabelPosition.java @@ -0,0 +1,185 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * ItemLabelPosition.java + * ---------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Oct-2003 : Version 1 (DG); + * 19-Feb-2004 : Moved to org.jfree.chart.labels, updated Javadocs and argument + * checking (DG); + * 26-Feb-2004 : Added new constructor (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.ui.TextAnchor; + +/** + * The attributes that control the position of the label for each data item on + * a chart. Instances of this class are immutable. + */ +public class ItemLabelPosition implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 5845390630157034499L; + + /** The item label anchor point. */ + private ItemLabelAnchor itemLabelAnchor; + + /** The text anchor. */ + private TextAnchor textAnchor; + + /** The rotation anchor. */ + private TextAnchor rotationAnchor; + + /** The rotation angle. */ + private double angle; + + /** + * Creates a new position record with default settings. + */ + public ItemLabelPosition() { + this(ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER, + TextAnchor.CENTER, 0.0); + } + + /** + * Creates a new position record (with zero rotation). + * + * @param itemLabelAnchor the item label anchor (null not + * permitted). + * @param textAnchor the text anchor (null not permitted). + */ + public ItemLabelPosition(ItemLabelAnchor itemLabelAnchor, + TextAnchor textAnchor) { + this(itemLabelAnchor, textAnchor, TextAnchor.CENTER, 0.0); + } + + /** + * 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 itemLabelAnchor the item label anchor (null not + * permitted). + * @param textAnchor the text anchor (null not permitted). + * @param rotationAnchor the rotation anchor (null not + * permitted). + * @param angle the rotation angle (in radians). + */ + public ItemLabelPosition(ItemLabelAnchor itemLabelAnchor, + TextAnchor textAnchor, TextAnchor rotationAnchor, double angle) { + + ParamChecks.nullNotPermitted(itemLabelAnchor, "itemLabelAnchor"); + ParamChecks.nullNotPermitted(textAnchor, "textAnchor"); + ParamChecks.nullNotPermitted(rotationAnchor, "rotationAnchor"); + this.itemLabelAnchor = itemLabelAnchor; + this.textAnchor = textAnchor; + this.rotationAnchor = rotationAnchor; + this.angle = angle; + } + + /** + * Returns the item label anchor. + * + * @return The item label anchor (never null). + */ + public ItemLabelAnchor getItemLabelAnchor() { + return this.itemLabelAnchor; + } + + /** + * Returns the text anchor. + * + * @return The text anchor (never null). + */ + public TextAnchor getTextAnchor() { + return this.textAnchor; + } + + /** + * Returns the rotation anchor point. + * + * @return The rotation anchor point (never null). + */ + 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; + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ItemLabelPosition)) { + return false; + } + ItemLabelPosition that = (ItemLabelPosition) obj; + if (!this.itemLabelAnchor.equals(that.itemLabelAnchor)) { + return false; + } + if (!this.textAnchor.equals(that.textAnchor)) { + return false; + } + if (!this.rotationAnchor.equals(that.rotationAnchor)) { + return false; + } + if (this.angle != that.angle) { + return false; + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/MultipleXYSeriesLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/MultipleXYSeriesLabelGenerator.java new file mode 100755 index 0000000..0e64fb0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/MultipleXYSeriesLabelGenerator.java @@ -0,0 +1,242 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------- + * MultipleXYSeriesLabelGenerator.java + * ----------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Nov-2004 : Version 1 (DG); + * 18-Apr-2005 : Use StringBuffer (DG); + * 20-Feb-2007 : Fixed for equals() and cloning() (DG); + * 31-Mar-2008 : Added hashCode() method to appease FindBugs (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.MessageFormat; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.util.PublicCloneable; + +/** + * A series label generator for plots that use data from + * an {@link org.jfree.data.xy.XYDataset}. + */ +public class MultipleXYSeriesLabelGenerator implements XYSeriesLabelGenerator, + Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 138976236941898560L; + + /** The default item label format. */ + public static final String DEFAULT_LABEL_FORMAT = "{0}"; + + /** The format pattern for the initial part of the label. */ + private String formatPattern; + + /** The format pattern for additional labels. */ + private String additionalFormatPattern; + + /** Storage for the additional series labels. */ + private Map seriesLabelLists; + + /** + * Creates an item label generator using default number formatters. + */ + public MultipleXYSeriesLabelGenerator() { + this(DEFAULT_LABEL_FORMAT); + } + + /** + * Creates a new series label generator. + * + * @param format the format pattern (null not permitted). + */ + public MultipleXYSeriesLabelGenerator(String format) { + ParamChecks.nullNotPermitted(format, "format"); + this.formatPattern = format; + this.additionalFormatPattern = "\n{0}"; + this.seriesLabelLists = new HashMap(); + } + + /** + * Adds an extra label for the specified series. + * + * @param series the series index. + * @param label the label. + */ + public void addSeriesLabel(int series, String label) { + Integer key = new Integer(series); + List labelList = (List) this.seriesLabelLists.get(key); + if (labelList == null) { + labelList = new java.util.ArrayList(); + this.seriesLabelLists.put(key, labelList); + } + labelList.add(label); + } + + /** + * Clears the extra labels for the specified series. + * + * @param series the series index. + */ + public void clearSeriesLabels(int series) { + Integer key = new Integer(series); + this.seriesLabelLists.put(key, null); + } + + /** + * Generates a label for the specified series. This label will be + * used for the chart legend. + * + * @param dataset the dataset (null not permitted). + * @param series the series. + * + * @return A series label. + */ + @Override + public String generateLabel(XYDataset dataset, int series) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + StringBuilder label = new StringBuilder(); + label.append(MessageFormat.format(this.formatPattern, + createItemArray(dataset, series))); + Integer key = new Integer(series); + List extraLabels = (List) this.seriesLabelLists.get(key); + if (extraLabels != null) { + Object[] temp = new Object[1]; + for (int i = 0; i < extraLabels.size(); i++) { + temp[0] = extraLabels.get(i); + String labelAddition = MessageFormat.format( + this.additionalFormatPattern, temp); + label.append(labelAddition); + } + } + return label.toString(); + } + + /** + * Creates the array of items that can be passed to the + * {@link MessageFormat} class for creating labels. + * + * @param dataset the dataset (null not permitted). + * @param series the series (zero-based index). + * + * @return The items (never null). + */ + protected Object[] createItemArray(XYDataset dataset, int series) { + Object[] result = new Object[1]; + result[0] = dataset.getSeriesKey(series).toString(); + return result; + } + + /** + * Returns an independent copy of the generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException if cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + MultipleXYSeriesLabelGenerator clone + = (MultipleXYSeriesLabelGenerator) super.clone(); + clone.seriesLabelLists = new HashMap(); + Set keys = this.seriesLabelLists.keySet(); + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Object key = iterator.next(); + Object entry = this.seriesLabelLists.get(key); + Object toAdd = entry; + if (entry instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) entry; + toAdd = pc.clone(); + } + clone.seriesLabelLists.put(key, toAdd); + } + return clone; + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof MultipleXYSeriesLabelGenerator)) { + return false; + } + MultipleXYSeriesLabelGenerator that + = (MultipleXYSeriesLabelGenerator) obj; + if (!this.formatPattern.equals(that.formatPattern)) { + return false; + } + if (!this.additionalFormatPattern.equals( + that.additionalFormatPattern)) { + return false; + } + if (!this.seriesLabelLists.equals(that.seriesLabelLists)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 127; + result = HashUtilities.hashCode(result, this.formatPattern); + result = HashUtilities.hashCode(result, this.additionalFormatPattern); + result = HashUtilities.hashCode(result, this.seriesLabelLists); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/PieSectionLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/PieSectionLabelGenerator.java new file mode 100755 index 0000000..79316c9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/PieSectionLabelGenerator.java @@ -0,0 +1,109 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * PieSectionLabelGenerator.java + * ----------------------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Dec-2001 : Version 1 (DG); + * 16-Jan-2002 : Completed Javadocs (DG); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 30-Oct-2002 : Category is now a Comparable instance (DG); + * 07-Mar-2003 : Changed to KeyedValuesDataset and added pieIndex + * parameter (DG); + * 21-Mar-2003 : Updated Javadocs (DG); + * 24-Apr-2003 : Switched around PieDataset and KeyedValuesDataset (DG); + * 13-Aug-2003 : Added clone() method (DG); + * 19-Aug-2003 : Renamed PieToolTipGenerator --> PieItemLabelGenerator (DG); + * 11-Nov-2003 : Removed clone() method (DG); + * 30-Jan-2004 : Added generateSectionLabel() method (DG); + * 15-Apr-2004 : Moved generateToolTip() method into separate interface and + * renamed this interface PieSectionLabelGenerator (DG); + * + */ + +package org.jfree.chart.labels; + +import java.awt.Font; +import java.awt.Paint; +import java.awt.font.TextAttribute; +import java.text.AttributedString; + +import org.jfree.data.general.PieDataset; + +/** + * Interface for a label generator for plots that use data from + * a {@link PieDataset}. + */ +public interface PieSectionLabelGenerator { + + /** + * Generates a label for a pie section. + * + * @param dataset the dataset (null not permitted). + * @param key the section key (null not permitted). + * + * @return The label (possibly null). + */ + public String generateSectionLabel(PieDataset dataset, Comparable key); + + /** + * Generates an attributed label for the specified series, or + * null if no attributed label is available (in which case, + * the string returned by + * {@link #generateSectionLabel(PieDataset, Comparable)} will + * provide the fallback). Only certain attributes are recognised by the + * code that ultimately displays the labels: + *

    + *
  • {@link TextAttribute#FONT}: will set the font;
  • + *
  • {@link TextAttribute#POSTURE}: a value of + * {@link TextAttribute#POSTURE_OBLIQUE} will add {@link Font#ITALIC} to + * the current font;
  • + *
  • {@link TextAttribute#WEIGHT}: a value of + * {@link TextAttribute#WEIGHT_BOLD} will add {@link Font#BOLD} to the + * current font;
  • + *
  • {@link TextAttribute#FOREGROUND}: this will set the {@link Paint} + * for the current
  • + *
  • {@link TextAttribute#SUPERSCRIPT}: the values + * {@link TextAttribute#SUPERSCRIPT_SUB} and + * {@link TextAttribute#SUPERSCRIPT_SUPER} are recognised.
  • + *
+ * + * @param dataset the dataset. + * @param key the key. + * + * @return An attributed label (possibly null). + */ + public AttributedString generateAttributedSectionLabel(PieDataset dataset, + Comparable key); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/PieToolTipGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/PieToolTipGenerator.java new file mode 100755 index 0000000..26d3df5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/PieToolTipGenerator.java @@ -0,0 +1,63 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * PieToolTipGenerator.java + * ------------------------ + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 15-Apr-2004 : Version 1, split from PieItemLabelGenerator (DG); + * + */ + +package org.jfree.chart.labels; + +import org.jfree.data.general.PieDataset; + +/** + * A tool tip generator that is used by the + * {@link org.jfree.chart.plot.PiePlot} class. + */ +public interface PieToolTipGenerator { + + /** + * Generates a tool tip text item for the specified item in the dataset. + * This method can return null to indicate that no tool tip + * should be displayed for an item. + * + * @param dataset the dataset (null not permitted). + * @param key the section key (null not permitted). + * + * @return The tool tip text (possibly null). + */ + public String generateToolTip(PieDataset dataset, Comparable key); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardCategoryItemLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardCategoryItemLabelGenerator.java new file mode 100755 index 0000000..8f6a0bd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardCategoryItemLabelGenerator.java @@ -0,0 +1,149 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------------- + * StandardCategoryItemLabelGenerator.java + * --------------------------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-May-2004 : Version 1 (DG); + * 20-Apr-2005 : Renamed StandardCategoryLabelGenerator + * --> StandardCategoryItemLabelGenerator (DG); + * ------------- JFREECHART 1.0.0 --------------------------------------------- + * 03-May-2005 : Added equals() implementation, to fix bug 1481087 (DG); + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.NumberFormat; + +import org.jfree.data.category.CategoryDataset; +import org.jfree.util.PublicCloneable; + +/** + * A standard label generator that can be used with a + * {@link org.jfree.chart.renderer.category.CategoryItemRenderer}. + */ +public class StandardCategoryItemLabelGenerator + extends AbstractCategoryItemLabelGenerator + implements CategoryItemLabelGenerator, Cloneable, PublicCloneable, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 3499701401211412882L; + + /** The default format string. */ + public static final String DEFAULT_LABEL_FORMAT_STRING = "{2}"; + + /** + * Creates a new generator with a default number formatter. + */ + public StandardCategoryItemLabelGenerator() { + super(DEFAULT_LABEL_FORMAT_STRING, NumberFormat.getInstance()); + } + + /** + * Creates a new generator with the specified number formatter. + * + * @param labelFormat the label format string (null not + * permitted). + * @param formatter the number formatter (null not permitted). + */ + public StandardCategoryItemLabelGenerator(String labelFormat, + NumberFormat formatter) { + super(labelFormat, formatter); + } + + /** + * Creates a new generator with the specified number formatter. + * + * @param labelFormat the label format string (null not + * permitted). + * @param formatter the number formatter (null not permitted). + * @param percentFormatter the percent formatter (null not + * permitted). + * + * @since 1.0.2 + */ + public StandardCategoryItemLabelGenerator(String labelFormat, + NumberFormat formatter, NumberFormat percentFormatter) { + super(labelFormat, formatter, percentFormatter); + } + + /** + * Creates a new generator with the specified date formatter. + * + * @param labelFormat the label format string (null not + * permitted). + * @param formatter the date formatter (null not permitted). + */ + public StandardCategoryItemLabelGenerator(String labelFormat, + DateFormat formatter) { + super(labelFormat, formatter); + } + + /** + * Generates the label for an item in a dataset. Note: in the current + * dataset implementation, each row is a series, and each column contains + * values for a particular category. + * + * @param dataset the dataset (null not permitted). + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The label (possibly null). + */ + @Override + public String generateLabel(CategoryDataset dataset, int row, int column) { + return generateLabelString(dataset, row, column); + } + + /** + * Tests this generator for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return true if this generator is equal to + * obj, and false otherwise. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardCategoryItemLabelGenerator)) { + return false; + } + return super.equals(obj); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardCategorySeriesLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardCategorySeriesLabelGenerator.java new file mode 100755 index 0000000..87a74e3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardCategorySeriesLabelGenerator.java @@ -0,0 +1,167 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------------- + * StandardCategorySeriesLabelGenerator.java + * ----------------------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Apr-2005 : Version 1 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 03-May-2006 : Fixed equals() method (bug 1481102) (DG); + * 31-Mar-2008 : Added hashCode() method to appease FindBugs (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.MessageFormat; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.category.CategoryDataset; +import org.jfree.util.PublicCloneable; + +/** + * A standard series label generator for plots that use data from + * a {@link org.jfree.data.category.CategoryDataset}. + */ +public class StandardCategorySeriesLabelGenerator implements + CategorySeriesLabelGenerator, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 4630760091523940820L; + + /** The default item label format. */ + public static final String DEFAULT_LABEL_FORMAT = "{0}"; + + /** The format pattern. */ + private String formatPattern; + + /** + * Creates a default series label generator (uses + * {@link #DEFAULT_LABEL_FORMAT}). + */ + public StandardCategorySeriesLabelGenerator() { + this(DEFAULT_LABEL_FORMAT); + } + + /** + * Creates a new series label generator. + * + * @param format the format pattern (null not permitted). + */ + public StandardCategorySeriesLabelGenerator(String format) { + ParamChecks.nullNotPermitted(format, "format"); + this.formatPattern = format; + } + + /** + * Generates a label for the specified series. + * + * @param dataset the dataset (null not permitted). + * @param series the series. + * + * @return A series label. + */ + @Override + public String generateLabel(CategoryDataset dataset, int series) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + String label = MessageFormat.format(this.formatPattern, + createItemArray(dataset, series)); + return label; + } + + /** + * Creates the array of items that can be passed to the + * {@link MessageFormat} class for creating labels. + * + * @param dataset the dataset (null not permitted). + * @param series the series (zero-based index). + * + * @return The items (never null). + */ + protected Object[] createItemArray(CategoryDataset dataset, int series) { + Object[] result = new Object[1]; + result[0] = dataset.getRowKey(series).toString(); + return result; + } + + /** + * Returns an independent copy of the generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException if cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardCategorySeriesLabelGenerator)) { + return false; + } + StandardCategorySeriesLabelGenerator that + = (StandardCategorySeriesLabelGenerator) obj; + if (!this.formatPattern.equals(that.formatPattern)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 127; + result = HashUtilities.hashCode(result, this.formatPattern); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardCategoryToolTipGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardCategoryToolTipGenerator.java new file mode 100755 index 0000000..5894a80 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardCategoryToolTipGenerator.java @@ -0,0 +1,132 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------- + * StandardCategoryToolTipGenerator.java + * ------------------------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-May-2004 : Version 1 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 03-May-2006 : Added equals() method to fix bug 1481087 (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.NumberFormat; + +import org.jfree.data.category.CategoryDataset; + +/** + * A standard tool tip generator that can be used with a + * {@link org.jfree.chart.renderer.category.CategoryItemRenderer}. + */ +public class StandardCategoryToolTipGenerator + extends AbstractCategoryItemLabelGenerator + implements CategoryToolTipGenerator, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -6768806592218710764L; + + /** The default format string. */ + public static final String DEFAULT_TOOL_TIP_FORMAT_STRING + = "({0}, {1}) = {2}"; + + /** + * Creates a new generator with a default number formatter. + */ + public StandardCategoryToolTipGenerator() { + super(DEFAULT_TOOL_TIP_FORMAT_STRING, NumberFormat.getInstance()); + } + + /** + * Creates a new generator with the specified number formatter. + * + * @param labelFormat the label format string (null not + * permitted). + * @param formatter the number formatter (null not permitted). + */ + public StandardCategoryToolTipGenerator(String labelFormat, + NumberFormat formatter) { + super(labelFormat, formatter); + } + + /** + * Creates a new generator with the specified date formatter. + * + * @param labelFormat the label format string (null not + * permitted). + * @param formatter the date formatter (null not permitted). + */ + public StandardCategoryToolTipGenerator(String labelFormat, + DateFormat formatter) { + super(labelFormat, formatter); + } + + /** + * Generates the tool tip text for an item in a dataset. Note: in the + * current dataset implementation, each row is a series, and each column + * contains values for a particular category. + * + * @param dataset the dataset (null not permitted). + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The tooltip text (possibly null). + */ + @Override + public String generateToolTip(CategoryDataset dataset, + int row, int column) { + return generateLabelString(dataset, row, column); + } + + /** + * Tests this generator for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardCategoryToolTipGenerator)) { + return false; + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardContourToolTipGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardContourToolTipGenerator.java new file mode 100755 index 0000000..57e6d76 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardContourToolTipGenerator.java @@ -0,0 +1,136 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------ + * StandardContourToolTipGenerator.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 + * ------- + * 23-Jan-2003 : Added standard header (DG); + * 21-Mar-2003 : Implemented Serializable (DG); + * 15-Jul-2004 : Switched the getZ() and getZValue() methods (DG); + * 19-Jan-2005 : Now accesses primitives only from dataset (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.Date; + +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYBlockRenderer; +import org.jfree.data.contour.ContourDataset; + +/** + * A standard tooltip generator for plots that use data from an + * {@link ContourDataset}. + * + * @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 StandardContourToolTipGenerator implements ContourToolTipGenerator, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -1881659351247502711L; + + /** The number formatter. */ + private DecimalFormat valueForm = new DecimalFormat("##.###"); + + /** + * Generates a tooltip text item for a particular item within a series. + * + * @param data the dataset. + * @param item the item index (zero-based). + * + * @return The tooltip text. + */ + @Override + public String generateToolTip(ContourDataset data, int item) { + + double x = data.getXValue(0, item); + double y = data.getYValue(0, item); + double z = data.getZValue(0, item); + String xString; + + if (data.isDateAxis(0)) { + SimpleDateFormat formatter + = new java.text.SimpleDateFormat("MM/dd/yyyy hh:mm:ss"); + StringBuffer strbuf = new StringBuffer(); + strbuf = formatter.format( + new Date((long) x), strbuf, new java.text.FieldPosition(0) + ); + xString = strbuf.toString(); + } + else { + xString = this.valueForm.format(x); + } + if (!Double.isNaN(z)) { + return "X: " + xString + + ", Y: " + this.valueForm.format(y) + + ", Z: " + this.valueForm.format(z); + } + else { + return "X: " + xString + + ", Y: " + this.valueForm.format(y) + + ", Z: no data"; + } + + } + + /** + * Tests if this object is equal to another. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardContourToolTipGenerator)) { + return false; + } + StandardContourToolTipGenerator that + = (StandardContourToolTipGenerator) obj; + if (this.valueForm != null) { + return this.valueForm.equals(that.valueForm); + } + return false; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardCrosshairLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardCrosshairLabelGenerator.java new file mode 100755 index 0000000..f7e9f2f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardCrosshairLabelGenerator.java @@ -0,0 +1,161 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------ + * StandardCrosshairLabelGenerator.java + * ------------------------------------ + * (C) Copyright 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 13-Feb-2009 : Version 1 (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.MessageFormat; +import java.text.NumberFormat; +import org.jfree.chart.plot.Crosshair; + +/** + * A default label generator. + * + * @since 1.0.13 + */ +public class StandardCrosshairLabelGenerator implements CrosshairLabelGenerator, + Serializable { + + /** The label format string. */ + private String labelTemplate; + + /** A number formatter for the value. */ + private NumberFormat numberFormat; + + /** + * Creates a new instance with default attributes. + */ + public StandardCrosshairLabelGenerator() { + this("{0}", NumberFormat.getNumberInstance()); + } + + /** + * Creates a new instance with the specified attributes. + * + * @param labelTemplate the label template (null not + * permitted). + * @param numberFormat the number formatter (null not + * permitted). + */ + public StandardCrosshairLabelGenerator(String labelTemplate, + NumberFormat numberFormat) { + super(); + if (labelTemplate == null) { + throw new IllegalArgumentException( + "Null 'labelTemplate' argument."); + } + if (numberFormat == null) { + throw new IllegalArgumentException( + "Null 'numberFormat' argument."); + } + this.labelTemplate = labelTemplate; + this.numberFormat = numberFormat; + } + + /** + * Returns the label template string. + * + * @return The label template string (never null). + */ + public String getLabelTemplate() { + return this.labelTemplate; + } + + /** + * Returns the number formatter. + * + * @return The formatter (never null). + */ + public NumberFormat getNumberFormat() { + return this.numberFormat; + } + + /** + * Returns a string that can be used as the label for a crosshair. + * + * @param crosshair the crosshair (null not permitted). + * + * @return The label (possibly null). + */ + @Override + public String generateLabel(Crosshair crosshair) { + Object[] v = new Object[] {this.numberFormat.format( + crosshair.getValue())}; + String result = MessageFormat.format(this.labelTemplate, v); + return result; + } + + /** + * Tests this generator for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardCrosshairLabelGenerator)) { + return false; + } + StandardCrosshairLabelGenerator that + = (StandardCrosshairLabelGenerator) obj; + if (!this.labelTemplate.equals(that.labelTemplate)) { + return false; + } + if (!this.numberFormat.equals(that.numberFormat)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code for this instance. + */ + @Override + public int hashCode() { + return this.labelTemplate.hashCode(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java new file mode 100755 index 0000000..6625f50 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardPieSectionLabelGenerator.java @@ -0,0 +1,253 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------- + * StandardPieSectionLabelGenerator.java + * ------------------------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 09-Nov-2004 : Version 1, derived from StandardPieItemLabelGenerator (DG); + * 29-Jul-2005 : Removed unused generateToolTip() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 03-May-2006 : Modified DEFAULT_SECTION_LABEL_FORMAT (DG); + * 10-Jan-2007 : Include attributedLabels in equals() test (DG); + * 10-Jul-2007 : Added constructors with locale parameter (DG); + * 23-Apr-2008 : Implemented PublicCloneable (DG); + * + */ + +package org.jfree.chart.labels; + +import java.awt.Font; +import java.awt.Paint; +import java.awt.font.TextAttribute; +import java.io.Serializable; +import java.text.AttributedString; +import java.text.NumberFormat; +import java.util.Locale; + +import org.jfree.data.general.PieDataset; +import org.jfree.util.ObjectList; +import org.jfree.util.PublicCloneable; + +/** + * A standard item label generator for plots that use data from a + * {@link PieDataset}. + *

+ * For the label format, use {0} where the pie section key should be inserted, + * {1} for the absolute section value and {2} for the percent amount of the pie + * section, e.g. "{0} = {1} ({2})" will display as + * apple = 120 (5%). + */ +public class StandardPieSectionLabelGenerator + extends AbstractPieItemLabelGenerator + implements PieSectionLabelGenerator, Cloneable, PublicCloneable, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 3064190563760203668L; + + /** The default section label format. */ + public static final String DEFAULT_SECTION_LABEL_FORMAT = "{0}"; + + /** + * An optional list of attributed labels (instances of AttributedString). + */ + private ObjectList attributedLabels; + + /** + * Creates a new section label generator using + * {@link #DEFAULT_SECTION_LABEL_FORMAT} as the label format string, and + * platform default number and percentage formatters. + */ + public StandardPieSectionLabelGenerator() { + this(DEFAULT_SECTION_LABEL_FORMAT, NumberFormat.getNumberInstance(), + NumberFormat.getPercentInstance()); + } + + /** + * Creates a new instance for the specified locale. + * + * @param locale the local (null not permitted). + * + * @since 1.0.7 + */ + public StandardPieSectionLabelGenerator(Locale locale) { + this(DEFAULT_SECTION_LABEL_FORMAT, locale); + } + + /** + * Creates a new section label generator using the specified label format + * string, and platform default number and percentage formatters. + * + * @param labelFormat the label format (null not permitted). + */ + public StandardPieSectionLabelGenerator(String labelFormat) { + this(labelFormat, NumberFormat.getNumberInstance(), + NumberFormat.getPercentInstance()); + } + + /** + * Creates a new instance for the specified locale. + * + * @param labelFormat the label format (null not permitted). + * @param locale the local (null not permitted). + * + * @since 1.0.7 + */ + public StandardPieSectionLabelGenerator(String labelFormat, Locale locale) { + this(labelFormat, NumberFormat.getNumberInstance(locale), + NumberFormat.getPercentInstance(locale)); + } + + /** + * Creates an item label generator using the specified number formatters. + * + * @param labelFormat the label format string (null not + * permitted). + * @param numberFormat the format object for the values (null + * not permitted). + * @param percentFormat the format object for the percentages + * (null not permitted). + */ + public StandardPieSectionLabelGenerator(String labelFormat, + NumberFormat numberFormat, NumberFormat percentFormat) { + super(labelFormat, numberFormat, percentFormat); + this.attributedLabels = new ObjectList(); + } + + /** + * Returns the attributed label for a section, or null if none + * is defined. + * + * @param section the section index. + * + * @return The attributed label. + */ + public AttributedString getAttributedLabel(int section) { + return (AttributedString) this.attributedLabels.get(section); + } + + /** + * Sets the attributed label for a section. + * + * @param section the section index. + * @param label the label (null permitted). + */ + public void setAttributedLabel(int section, AttributedString label) { + this.attributedLabels.set(section, label); + } + + /** + * Generates a label for a pie section. + * + * @param dataset the dataset (null not permitted). + * @param key the section key (null not permitted). + * + * @return The label (possibly null). + */ + @Override + public String generateSectionLabel(PieDataset dataset, Comparable key) { + return super.generateSectionLabel(dataset, key); + } + + /** + * Generates an attributed label for the specified series, or + * null if no attributed label is available (in which case, + * the string returned by + * {@link #generateSectionLabel(PieDataset, Comparable)} will + * provide the fallback). Only certain attributes are recognised by the + * code that ultimately displays the labels: + *

    + *
  • {@link TextAttribute#FONT}: will set the font;
  • + *
  • {@link TextAttribute#POSTURE}: a value of + * {@link TextAttribute#POSTURE_OBLIQUE} will add {@link Font#ITALIC} to + * the current font;
  • + *
  • {@link TextAttribute#WEIGHT}: a value of + * {@link TextAttribute#WEIGHT_BOLD} will add {@link Font#BOLD} to the + * current font;
  • + *
  • {@link TextAttribute#FOREGROUND}: this will set the {@link Paint} + * for the current
  • + *
  • {@link TextAttribute#SUPERSCRIPT}: the values + * {@link TextAttribute#SUPERSCRIPT_SUB} and + * {@link TextAttribute#SUPERSCRIPT_SUPER} are recognised.
  • + *
+ * + * @param dataset the dataset (null not permitted). + * @param key the key. + * + * @return An attributed label (possibly null). + */ + @Override + public AttributedString generateAttributedSectionLabel(PieDataset dataset, + Comparable key) { + return getAttributedLabel(dataset.getIndex(key)); + } + + /** + * Tests the generator for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardPieSectionLabelGenerator)) { + return false; + } + StandardPieSectionLabelGenerator that + = (StandardPieSectionLabelGenerator) obj; + if (!this.attributedLabels.equals(that.attributedLabels)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + return true; + } + + /** + * Returns an independent copy of the generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException should not happen. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardPieToolTipGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardPieToolTipGenerator.java new file mode 100755 index 0000000..84898cd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardPieToolTipGenerator.java @@ -0,0 +1,174 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------- + * StandardPieToolTipGenerator.java + * -------------------------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Richard Atkinson; + * Andreas Schroeder; + * + * Changes + * ------- + * 13-Dec-2001 : Version 1 (DG); + * 16-Jan-2002 : Completed Javadocs (DG); + * 29-Aug-2002 : Changed to format numbers using default locale (RA); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 30-Oct-2002 : Changed PieToolTipGenerator interface (DG); + * 21-Mar-2003 : Implemented Serializable (DG); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 19-Aug-2003 : Renamed StandardPieToolTipGenerator --> + * StandardPieItemLabelGenerator (DG); + * 10-Mar-2004 : Modified to use MessageFormat class (DG); + * 31-Mar-2004 : Added javadocs for the MessageFormat usage (AS); + * 15-Apr-2004 : Split PieItemLabelGenerator interface into + * PieSectionLabelGenerator and PieToolTipGenerator (DG); + * 25-Nov-2004 : Moved some code into abstract super class (DG); + * 29-Jul-2005 : Removed implementation of PieSectionLabelGenerator + * interface (DG); + * 10-Jul-2007 : Added constructors with locale argument (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.NumberFormat; +import java.util.Locale; + +import org.jfree.data.general.PieDataset; +import org.jfree.util.PublicCloneable; + +/** + * A standard item label generator for plots that use data from a + * {@link PieDataset}. + *

+ * For the label format, use {0} where the pie section key should be inserted, + * {1} for the absolute section value and {2} for the percent amount of the pie + * section, e.g. "{0} = {1} ({2})" will display as + * apple = 120 (5%). + */ +public class StandardPieToolTipGenerator extends AbstractPieItemLabelGenerator + implements PieToolTipGenerator, Cloneable, PublicCloneable, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 2995304200445733779L; + + /** The default tooltip format. */ + public static final String DEFAULT_TOOLTIP_FORMAT = "{0}: ({1}, {2})"; + + /** + * The default section label format. + * + * @deprecated As of 1.0.7, use {@link #DEFAULT_TOOLTIP_FORMAT} instead. + */ + public static final String DEFAULT_SECTION_LABEL_FORMAT = "{0} = {1}"; + + /** + * Creates an item label generator using default number formatters. + */ + public StandardPieToolTipGenerator() { + this(DEFAULT_TOOLTIP_FORMAT); + } + + /** + * Creates a pie tool tip generator for the specified locale, using the + * default format string. + * + * @param locale the locale (null not permitted). + * + * @since 1.0.7 + */ + public StandardPieToolTipGenerator(Locale locale) { + this(DEFAULT_TOOLTIP_FORMAT, locale); + } + + /** + * Creates a pie tool tip generator for the default locale. + * + * @param labelFormat the label format (null not permitted). + */ + public StandardPieToolTipGenerator(String labelFormat) { + this(labelFormat, Locale.getDefault()); + } + + /** + * Creates a pie tool tip generator for the specified locale. + * + * @param labelFormat the label format (null not permitted). + * @param locale the locale (null not permitted). + * + * @since 1.0.7 + */ + public StandardPieToolTipGenerator(String labelFormat, Locale locale) { + this(labelFormat, NumberFormat.getNumberInstance(locale), + NumberFormat.getPercentInstance(locale)); + } + + /** + * Creates an item label generator using the specified number formatters. + * + * @param labelFormat the label format string (null not + * permitted). + * @param numberFormat the format object for the values (null + * not permitted). + * @param percentFormat the format object for the percentages + * (null not permitted). + */ + public StandardPieToolTipGenerator(String labelFormat, + NumberFormat numberFormat, NumberFormat percentFormat) { + super(labelFormat, numberFormat, percentFormat); + } + + /** + * Generates a tool tip text item for one section in a pie chart. + * + * @param dataset the dataset (null not permitted). + * @param key the section key (null not permitted). + * + * @return The tool tip text (possibly null). + */ + @Override + public String generateToolTip(PieDataset dataset, Comparable key) { + return generateSectionLabel(dataset, key); + } + + /** + * Returns an independent copy of the generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException should not happen. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardXYItemLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardXYItemLabelGenerator.java new file mode 100755 index 0000000..84dd9ed --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardXYItemLabelGenerator.java @@ -0,0 +1,217 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * StandardXYItemLabelGenerator.java + * --------------------------------- + * (C) Copyright 2001-2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Dec-2001 : Version 1 (DG); + * 16-Jan-2002 : Completed Javadocs (DG); + * 02-Apr-2002 : Modified to handle null y-values (DG); + * 09-Apr-2002 : Added formatting objects for the x and y values (DG); + * 30-May-2002 : Added series name to standard tool tip (DG); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 23-Mar-2003 : Implemented Serializable (DG); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 17-Nov-2003 : Implemented PublicCloneable (DG); + * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator and + * StandardXYToolTipGenerator --> + * StandardXYItemLabelGenerator (DG); + * 26-Feb-2004 : Modified to use MessageFormat (DG); + * 27-Feb-2004 : Added abstract superclass (DG); + * 11-May-2004 : Split into StandardXYToolTipGenerator and + * StandardXYLabelGenerator (DG); + * 20-Apr-2005 : Renamed StandardXYLabelGenerator + * --> StandardXYItemLabelGenerator (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 25-Jan-2007 : Added new constructor - see bug 1624067 (DG); + * 24-Jun-2009 : Added new constructor (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.NumberFormat; + +import org.jfree.data.xy.XYDataset; +import org.jfree.util.PublicCloneable; + +/** + * A standard item label generator for plots that use data from an + * {@link org.jfree.data.xy.XYDataset}. + */ +public class StandardXYItemLabelGenerator extends AbstractXYItemLabelGenerator + implements XYItemLabelGenerator, Cloneable, PublicCloneable, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7807668053171837925L; + + /** The default item label format. */ + public static final String DEFAULT_ITEM_LABEL_FORMAT = "{2}"; + + /** + * Creates an item label generator using default number formatters. + */ + public StandardXYItemLabelGenerator() { + this(DEFAULT_ITEM_LABEL_FORMAT, NumberFormat.getNumberInstance(), + NumberFormat.getNumberInstance()); + } + + /** + * Creates an item label generator using the specified number formatters. + * + * @param formatString the item label format string (null not + * permitted). + * + * @since 1.0.14 + */ + public StandardXYItemLabelGenerator(String formatString) { + this(formatString, NumberFormat.getNumberInstance(), + NumberFormat.getNumberInstance()); + } + + /** + * Creates an item label generator using the specified number formatters. + * + * @param formatString the item label format string (null not + * permitted). + * @param xFormat the format object for the x values (null + * not permitted). + * @param yFormat the format object for the y values (null + * not permitted). + */ + public StandardXYItemLabelGenerator(String formatString, + NumberFormat xFormat, NumberFormat yFormat) { + + super(formatString, xFormat, yFormat); + } + + /** + * Creates an item label generator using the specified formatters. + * + * @param formatString the item label format string (null + * not permitted). + * @param xFormat the format object for the x values (null + * not permitted). + * @param yFormat the format object for the y values (null + * not permitted). + */ + public StandardXYItemLabelGenerator(String formatString, + DateFormat xFormat, NumberFormat yFormat) { + + super(formatString, xFormat, yFormat); + } + + /** + * Creates an item label generator using the specified formatters (a + * number formatter for the x-values and a date formatter for the + * y-values). + * + * @param formatString the item label format string (null + * not permitted). + * @param xFormat the format object for the x values (null + * permitted). + * @param yFormat the format object for the y values (null + * not permitted). + * + * @since 1.0.4 + */ + public StandardXYItemLabelGenerator(String formatString, + NumberFormat xFormat, DateFormat yFormat) { + + super(formatString, xFormat, yFormat); + } + + /** + * Creates a label generator using the specified date formatters. + * + * @param formatString the label format string (null not + * permitted). + * @param xFormat the format object for the x values (null + * not permitted). + * @param yFormat the format object for the y values (null + * not permitted). + */ + public StandardXYItemLabelGenerator(String formatString, + DateFormat xFormat, DateFormat yFormat) { + + super(formatString, xFormat, yFormat); + } + + /** + * Generates the item label text for an item in a dataset. + * + * @param dataset the dataset (null not permitted). + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The label text (possibly null). + */ + @Override + public String generateLabel(XYDataset dataset, int series, int item) { + return generateLabelString(dataset, series, item); + } + + /** + * Returns an independent copy of the generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException if cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardXYItemLabelGenerator)) { + return false; + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardXYSeriesLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardXYSeriesLabelGenerator.java new file mode 100755 index 0000000..2396828 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardXYSeriesLabelGenerator.java @@ -0,0 +1,174 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------- + * StandardXYSeriesLabelGenerator.java + * ----------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Nov-2004 : Version 1 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 24-Nov-2006 : Fixed equals() method and updated API docs (DG); + * 31-Mar-2008 : Added hashCode() method to appease FindBugs (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.MessageFormat; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.util.PublicCloneable; + +/** + * A standard series label generator for plots that use data from + * an {@link org.jfree.data.xy.XYDataset}. + *

+ * This class implements PublicCloneable by mistake but we retain + * this for the sake of backward compatibility. + */ +public class StandardXYSeriesLabelGenerator implements XYSeriesLabelGenerator, + Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 1916017081848400024L; + + /** The default item label format. */ + public static final String DEFAULT_LABEL_FORMAT = "{0}"; + + /** The format pattern. */ + private String formatPattern; + + /** + * Creates a default series label generator (uses + * {@link #DEFAULT_LABEL_FORMAT}). + */ + public StandardXYSeriesLabelGenerator() { + this(DEFAULT_LABEL_FORMAT); + } + + /** + * Creates a new series label generator. + * + * @param format the format pattern (null not permitted). + */ + public StandardXYSeriesLabelGenerator(String format) { + ParamChecks.nullNotPermitted(format, "format"); + this.formatPattern = format; + } + + /** + * Generates a label for the specified series. This label will be + * used for the chart legend. + * + * @param dataset the dataset (null not permitted). + * @param series the series. + * + * @return A series label. + */ + @Override + public String generateLabel(XYDataset dataset, int series) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + String label = MessageFormat.format( + this.formatPattern, createItemArray(dataset, series) + ); + return label; + } + + /** + * Creates the array of items that can be passed to the + * {@link MessageFormat} class for creating labels. + * + * @param dataset the dataset (null not permitted). + * @param series the series (zero-based index). + * + * @return The items (never null). + */ + protected Object[] createItemArray(XYDataset dataset, int series) { + Object[] result = new Object[1]; + result[0] = dataset.getSeriesKey(series).toString(); + return result; + } + + /** + * Returns an independent copy of the generator. This is unnecessary, + * because instances are immutable anyway, but we retain this + * behaviour for backwards compatibility. + * + * @return A clone. + * + * @throws CloneNotSupportedException if cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardXYSeriesLabelGenerator)) { + return false; + } + StandardXYSeriesLabelGenerator that + = (StandardXYSeriesLabelGenerator) obj; + if (!this.formatPattern.equals(that.formatPattern)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 127; + result = HashUtilities.hashCode(result, this.formatPattern); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardXYToolTipGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardXYToolTipGenerator.java new file mode 100755 index 0000000..c5fcd91 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardXYToolTipGenerator.java @@ -0,0 +1,199 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * StandardXYToolTipGenerator.java + * ------------------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 12-May-2004 : Version 1 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 25-Jan-2007 : Added new constructor - see bug 1624067 (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.NumberFormat; + +import org.jfree.data.xy.XYDataset; +import org.jfree.util.PublicCloneable; + +/** + * A standard tool tip generator for use with an + * {@link org.jfree.chart.renderer.xy.XYItemRenderer}. + */ +public class StandardXYToolTipGenerator extends AbstractXYItemLabelGenerator + implements XYToolTipGenerator, Cloneable, PublicCloneable, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -3564164459039540784L; + + /** The default tooltip format. */ + public static final String DEFAULT_TOOL_TIP_FORMAT = "{0}: ({1}, {2})"; + + /** + * Returns a tool tip generator that formats the x-values as dates and the + * y-values as numbers. + * + * @return A tool tip generator (never null). + */ + public static StandardXYToolTipGenerator getTimeSeriesInstance() { + return new StandardXYToolTipGenerator(DEFAULT_TOOL_TIP_FORMAT, + DateFormat.getInstance(), NumberFormat.getInstance()); + } + + /** + * Creates a tool tip generator using default number formatters. + */ + public StandardXYToolTipGenerator() { + this(DEFAULT_TOOL_TIP_FORMAT, NumberFormat.getNumberInstance(), + NumberFormat.getNumberInstance()); + } + + /** + * Creates a tool tip generator using the specified number formatters. + * + * @param formatString the item label format string (null not + * permitted). + * @param xFormat the format object for the x values (null + * not permitted). + * @param yFormat the format object for the y values (null + * not permitted). + */ + public StandardXYToolTipGenerator(String formatString, + NumberFormat xFormat, NumberFormat yFormat) { + + super(formatString, xFormat, yFormat); + + } + + /** + * Creates a tool tip generator using the specified number formatters. + * + * @param formatString the label format string (null not + * permitted). + * @param xFormat the format object for the x values (null + * not permitted). + * @param yFormat the format object for the y values (null + * not permitted). + */ + public StandardXYToolTipGenerator(String formatString, DateFormat xFormat, + NumberFormat yFormat) { + + super(formatString, xFormat, yFormat); + + } + + /** + * Creates a tool tip generator using the specified formatters (a + * number formatter for the x-values and a date formatter for the + * y-values). + * + * @param formatString the item label format string (null + * not permitted). + * @param xFormat the format object for the x values (null + * permitted). + * @param yFormat the format object for the y values (null + * not permitted). + * + * @since 1.0.4 + */ + public StandardXYToolTipGenerator(String formatString, + NumberFormat xFormat, DateFormat yFormat) { + + super(formatString, xFormat, yFormat); + } + /** + * Creates a tool tip generator using the specified date formatters. + * + * @param formatString the label format string (null not + * permitted). + * @param xFormat the format object for the x values (null + * not permitted). + * @param yFormat the format object for the y values (null + * not permitted). + */ + public StandardXYToolTipGenerator(String formatString, + DateFormat xFormat, DateFormat yFormat) { + + super(formatString, xFormat, yFormat); + + } + + /** + * Generates the tool tip text for an item in a dataset. + * + * @param dataset the dataset (null not permitted). + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The tooltip text (possibly null). + */ + @Override + public String generateToolTip(XYDataset dataset, int series, int item) { + return generateLabelString(dataset, series, item); + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardXYToolTipGenerator)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns an independent copy of the generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException if cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardXYZToolTipGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardXYZToolTipGenerator.java new file mode 100755 index 0000000..f22087e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/StandardXYZToolTipGenerator.java @@ -0,0 +1,256 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------- + * StandardXYZToolTipGenerator.java + * -------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-May-2003 : Version 1, split from StandardXYZItemLabelGenerator (DG); + * 15-Jul-2004 : Switched getZ() and getZValue() methods (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.MessageFormat; +import java.text.NumberFormat; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYZDataset; +import org.jfree.util.ObjectUtilities; + +/** + * A standard item label generator for use with {@link XYZDataset} data. Each + * value can be formatted as a number or as a date. + */ +public class StandardXYZToolTipGenerator extends StandardXYToolTipGenerator + implements XYZToolTipGenerator, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -2961577421889473503L; + + /** The default tooltip format. */ + public static final String DEFAULT_TOOL_TIP_FORMAT = "{0}: ({1}, {2}, {3})"; + + /** + * A number formatter for the z value - if this is null, then zDateFormat + * must be non-null. + */ + private NumberFormat zFormat; + + /** + * A date formatter for the z-value - if this is null, then zFormat must be + * non-null. + */ + private DateFormat zDateFormat; + + /** + * Creates a new tool tip generator using default number formatters for the + * x, y and z-values. + */ + public StandardXYZToolTipGenerator() { + this( + DEFAULT_TOOL_TIP_FORMAT, + NumberFormat.getNumberInstance(), + NumberFormat.getNumberInstance(), + NumberFormat.getNumberInstance() + ); + } + + /** + * Constructs a new tool tip generator using the specified number + * formatters. + * + * @param formatString the format string. + * @param xFormat the format object for the x values (null + * not permitted). + * @param yFormat the format object for the y values (null + * not permitted). + * @param zFormat the format object for the z values (null + * not permitted). + */ + public StandardXYZToolTipGenerator(String formatString, + NumberFormat xFormat, NumberFormat yFormat, NumberFormat zFormat) { + super(formatString, xFormat, yFormat); + ParamChecks.nullNotPermitted(zFormat, "zFormat"); + this.zFormat = zFormat; + } + + /** + * Constructs a new tool tip generator using the specified date formatters. + * + * @param formatString the format string. + * @param xFormat the format object for the x values (null + * not permitted). + * @param yFormat the format object for the y values (null + * not permitted). + * @param zFormat the format object for the z values (null + * not permitted). + */ + public StandardXYZToolTipGenerator(String formatString, DateFormat xFormat, + DateFormat yFormat, DateFormat zFormat) { + super(formatString, xFormat, yFormat); + ParamChecks.nullNotPermitted(zFormat, "zFormat"); + this.zDateFormat = zFormat; + } + + // TODO: add constructors for combinations of number and date formatters. + + /** + * Returns the number formatter for the z-values. + * + * @return The number formatter (possibly null). + */ + public NumberFormat getZFormat() { + return this.zFormat; + } + + /** + * Returns the date formatter for the z-values. + * + * @return The date formatter (possibly null). + */ + public DateFormat getZDateFormat() { + return this.zDateFormat; + } + + /** + * Generates a tool tip text item for a particular item within a series. + * + * @param dataset the dataset (null not permitted). + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The tooltip text (possibly null). + */ + @Override + public String generateToolTip(XYZDataset dataset, int series, int item) { + return generateLabelString(dataset, series, item); + } + + /** + * Generates a label string for an item in the dataset. + * + * @param dataset the dataset (null not permitted). + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The label (possibly null). + */ + @Override + public String generateLabelString(XYDataset dataset, int series, int item) { + String result; + Object[] items = createItemArray((XYZDataset) dataset, series, item); + result = MessageFormat.format(getFormatString(), items); + return result; + } + + /** + * Creates the array of items that can be passed to the + * {@link MessageFormat} class for creating labels. + * + * @param dataset the dataset (null not permitted). + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The items (never null). + */ + protected Object[] createItemArray(XYZDataset dataset, + int series, int item) { + + Object[] result = new Object[4]; + result[0] = dataset.getSeriesKey(series).toString(); + + Number x = dataset.getX(series, item); + DateFormat xf = getXDateFormat(); + if (xf != null) { + result[1] = xf.format(x); + } + else { + result[1] = getXFormat().format(x); + } + + Number y = dataset.getY(series, item); + DateFormat yf = getYDateFormat(); + if (yf != null) { + result[2] = yf.format(y); + } + else { + result[2] = getYFormat().format(y); + } + + Number z = dataset.getZ(series, item); + if (this.zDateFormat != null) { + result[3] = this.zDateFormat.format(z); + } + else { + result[3] = this.zFormat.format(z); + } + + return result; + + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardXYZToolTipGenerator)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + StandardXYZToolTipGenerator that = (StandardXYZToolTipGenerator) obj; + if (!ObjectUtilities.equal(this.zFormat, that.zFormat)) { + return false; + } + if (!ObjectUtilities.equal(this.zDateFormat, that.zDateFormat)) { + return false; + } + return true; + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/SymbolicXYItemLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/SymbolicXYItemLabelGenerator.java new file mode 100755 index 0000000..6d91e9f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/SymbolicXYItemLabelGenerator.java @@ -0,0 +1,180 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * SymbolicXYItemLabelGenerator.java + * --------------------------------- + * (C) Copyright 2001-2008, by Anthony Boulestreau and Contributors. + * + * Original Author: Anthony Boulestreau; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 29-Mar-2002 : Version 1, contributed by Anthony Boulestreau (DG); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 23-Mar-2003 : Implemented Serializable (DG); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 17-Nov-2003 : Implemented PublicCloneable (DG); + * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG); + * 19-Jan-2005 : Now accesses primitives only from dataset (DG); + * 20-Apr-2005 : Renamed XYLabelGenerator --> XYItemLabelGenerator (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 31-Mar-2008 : Added hashCode() method to appease FindBugs (DG); + * + */ + +package org.jfree.chart.labels; + +import java.io.Serializable; + +import org.jfree.data.time.RegularTimePeriod; +import org.jfree.data.time.TimeSeriesCollection; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XisSymbolic; +import org.jfree.data.xy.YisSymbolic; +import org.jfree.util.PublicCloneable; + +/** + * A standard item label generator for plots that use data from an + * {@link XYDataset}. + */ +public class SymbolicXYItemLabelGenerator implements XYItemLabelGenerator, + XYToolTipGenerator, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 3963400354475494395L; + + /** + * Generates a tool tip text item for a particular item within a series. + * + * @param data the dataset. + * @param series the series number (zero-based index). + * @param item the item number (zero-based index). + * + * @return The tool tip text (possibly null). + */ + @Override + public String generateToolTip(XYDataset data, int series, int item) { + + String xStr, yStr; + if (data instanceof YisSymbolic) { + yStr = ((YisSymbolic) data).getYSymbolicValue(series, item); + } + else { + double y = data.getYValue(series, item); + yStr = Double.toString(round(y, 2)); + } + if (data instanceof XisSymbolic) { + xStr = ((XisSymbolic) data).getXSymbolicValue(series, item); + } + else if (data instanceof TimeSeriesCollection) { + RegularTimePeriod p + = ((TimeSeriesCollection) data).getSeries(series) + .getTimePeriod(item); + xStr = p.toString(); + } + else { + double x = data.getXValue(series, item); + xStr = Double.toString(round(x, 2)); + } + return "X: " + xStr + ", Y: " + yStr; + } + + /** + * Generates a label for the specified item. The label is typically a + * formatted version of the data value, but any text can be used. + * + * @param dataset the dataset (null not permitted). + * @param series the series index (zero-based). + * @param category the category index (zero-based). + * + * @return The label (possibly null). + */ + @Override + public String generateLabel(XYDataset dataset, int series, int category) { + return null; //TODO: implement this method properly + } + + /** + * Round a double value. + * + * @param value the value. + * @param nb the exponent. + * + * @return The rounded value. + */ + private static double round(double value, int nb) { + if (nb <= 0) { + return Math.floor(value + 0.5d); + } + double p = Math.pow(10, nb); + double tempval = Math.floor(value * p + 0.5d); + return tempval / p; + } + + /** + * Returns an independent copy of the generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException if cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Tests if this object is equal to another. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof SymbolicXYItemLabelGenerator) { + return true; + } + return false; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 127; + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/XYItemLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/XYItemLabelGenerator.java new file mode 100755 index 0000000..6ea1b11 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/XYItemLabelGenerator.java @@ -0,0 +1,71 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * XYItemLabelGenerator.java + * ------------------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Dec-2001 : Version 1 (DG); + * 16-Jan-2002 : Completed Javadocs (DG); + * 13-Jun-2002 : Correction to Javadoc comments (DG); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 25-Feb-2004 : Renamed XYToolTipGenerator --> XYItemLabelGenerator (DG); + * 15-Apr-2004 : Moved the generateToolTip() method to a separate + * interface (DG); + * 11-May-2004 : Renamed XYItemLabelGenerator --> XYLabelGenerator (DG); + * 20-Apr-2005 : Reverted name change of 11-May-2004 (DG); + * + */ + +package org.jfree.chart.labels; + +import org.jfree.data.xy.XYDataset; + +/** + * Interface for a label generator for plots that use data from an + * {@link XYDataset}. + */ +public interface XYItemLabelGenerator { + + /** + * Generates a label for the specified item. The label is typically a + * formatted version of the data value, but any text can be used. + * + * @param dataset the dataset (null not permitted). + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The label (possibly null). + */ + public String generateLabel(XYDataset dataset, int series, int item); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/XYSeriesLabelGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/XYSeriesLabelGenerator.java new file mode 100755 index 0000000..8f2d390 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/XYSeriesLabelGenerator.java @@ -0,0 +1,68 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * XYSeriesLabelGenerator.java + * --------------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Nov-2004 : Version 1 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 24-Nov-2006 : Updated API docs (DG); + * + */ + +package org.jfree.chart.labels; + +import org.jfree.data.xy.XYDataset; + +/** + * A generator that creates labels for the series in an {@link XYDataset}. + *

+ * Classes that implement this interface should be either (a) immutable, or + * (b) cloneable via the PublicCloneable interface (defined in + * the JCommon class library). This provides a mechanism for the referring + * renderer to clone the generator if necessary. + */ +public interface XYSeriesLabelGenerator { + + /** + * Generates a label for the specified series. This label will be + * used for the chart legend. + * + * @param dataset the dataset (null not permitted). + * @param series the series. + * + * @return A series label. + */ + public String generateLabel(XYDataset dataset, int series); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/XYToolTipGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/XYToolTipGenerator.java new file mode 100755 index 0000000..259ca5d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/XYToolTipGenerator.java @@ -0,0 +1,64 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * XYToolTipGenerator.java + * ----------------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 15-Apr-2004 : Extracted the generateToolTip() method from the + * XYItemLabelGenerator interface and put it into this new + * interface (DG); + * + */ + +package org.jfree.chart.labels; + +import org.jfree.data.xy.XYDataset; + +/** + * Interface for a tooltip generator for plots that use data from an + * {@link XYDataset}. + */ +public interface XYToolTipGenerator { + + /** + * Generates the tooltip text for the specified item. + * + * @param dataset the dataset (null not permitted). + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The tooltip text (possibly null). + */ + public String generateToolTip(XYDataset dataset, int series, int item); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/XYZToolTipGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/XYZToolTipGenerator.java new file mode 100755 index 0000000..ba307e9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/XYZToolTipGenerator.java @@ -0,0 +1,64 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * XYZToolTipGenerator.java + * ------------------------ + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Feb-2003 : Version 1 (DG); + * 25-Feb-2004 : Renamed XYZToolTipGenerator --> XYZItemLabelGenerator (DG); + * 11-May-2004 : Reverted to XYZToolTipGenerator (DG); + * + */ + +package org.jfree.chart.labels; + +import org.jfree.data.xy.XYZDataset; + +/** + * Interface for a tooltip generator for plots that use data from an + * {@link XYZDataset}. + */ +public interface XYZToolTipGenerator extends XYToolTipGenerator { + + /** + * Generates a tool tip text item for a particular item within a series. + * + * @param dataset the dataset (null not permitted). + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The tooltip text (possibly null). + */ + public String generateToolTip(XYZDataset dataset, int series, int item); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/package.html new file mode 100755 index 0000000..c2a769d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/labels/package.html @@ -0,0 +1,6 @@ + + + +Generators and other classes used for the display of item labels and tooltips. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/ArrowNeedle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/ArrowNeedle.java new file mode 100755 index 0000000..b0d2be8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/ArrowNeedle.java @@ -0,0 +1,185 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * ArrowNeedle.java + * ---------------- + * (C) Copyright 2002-2008, by the Australian Antarctic Division and + * Contributors. + * + * Original Author: Bryan Scott (for the Australian Antarctic Division); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); + * 27-Mar-2003 : Implemented Serializable (DG); + * 09-Sep-2003 : Added equals() method (DG); + * 08-Jun-2005 : Implemented Cloneable (DG); + * 22-Nov-2007 : Added hashCode() implementation (DG); + * + */ + +package org.jfree.chart.needle; + +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.HashUtilities; + +/** + * A needle in the shape of an arrow. + */ +public class ArrowNeedle extends MeterNeedle + implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -5334056511213782357L; + + /** + * A flag controlling whether or not there is an arrow at the top of the + * needle. + */ + private boolean isArrowAtTop = true; + + /** + * Constructs a new arrow needle. + * + * @param isArrowAtTop a flag that controls whether or not there is an + * arrow at the top of the needle. + */ + public ArrowNeedle(boolean isArrowAtTop) { + this.isArrowAtTop = isArrowAtTop; + } + + /** + * Draws the needle. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param rotate the rotation point. + * @param angle the angle. + */ + @Override + protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, + Point2D rotate, double angle) { + + Line2D shape = new Line2D.Float(); + Shape d; + + float x = (float) (plotArea.getMinX() + (plotArea.getWidth() / 2)); + float minY = (float) plotArea.getMinY(); + float maxY = (float) plotArea.getMaxY(); + shape.setLine(x, minY, x, maxY); + + GeneralPath shape1 = new GeneralPath(); + if (this.isArrowAtTop) { + shape1.moveTo(x, minY); + minY += 4 * getSize(); + } + else { + shape1.moveTo(x, maxY); + minY = maxY - 4 * getSize(); + } + shape1.lineTo(x + getSize(), minY); + shape1.lineTo(x - getSize(), minY); + shape1.closePath(); + + if ((rotate != null) && (angle != 0)) { + getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); + d = getTransform().createTransformedShape(shape); + } + else { + d = shape; + } + defaultDisplay(g2, d); + + if ((rotate != null) && (angle != 0)) { + d = getTransform().createTransformedShape(shape1); + } + else { + d = shape1; + } + defaultDisplay(g2, d); + + } + + /** + * Tests another object for equality with this object. + * + * @param obj the object to test (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ArrowNeedle)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + ArrowNeedle that = (ArrowNeedle) obj; + if (this.isArrowAtTop != that.isArrowAtTop) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = super.hashCode(); + result = HashUtilities.hashCode(result, this.isArrowAtTop); + return result; + } + + /** + * Returns a clone of this needle. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the ArrowNeedle + * cannot be cloned (in theory, this should not happen). + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/LineNeedle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/LineNeedle.java new file mode 100755 index 0000000..a9d0aa6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/LineNeedle.java @@ -0,0 +1,135 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * LineNeedle.java + * --------------- + * (C) Copyright 2002-2008, by the Australian Antarctic Division and + * Contributors. + * + * Original Author: Bryan Scott (for the Australian Antarctic Division); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); + * 27-Mar-2003 : Implemented Serializable (DG); + * 09-Sep-2003 : Added equals() method (DG); + * 08-Jun-2005 : Implemented Cloneable (DG); + * 22-Nov-2007 : Added hashCode() implementation (DG); + * + */ + +package org.jfree.chart.needle; + +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +/** + * A needle that is represented by a line. + */ +public class LineNeedle extends MeterNeedle + implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 6215321387896748945L; + + /** + * Draws the needle. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param rotate the rotation point. + * @param angle the angle. + */ + @Override + protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, + Point2D rotate, double angle) { + + Line2D shape = new Line2D.Double(); + + double x = plotArea.getMinX() + (plotArea.getWidth() / 2); + shape.setLine(x, plotArea.getMinY(), x, plotArea.getMaxY()); + + Shape s = shape; + + if ((rotate != null) && (angle != 0)) { + /// we have rotation + getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); + s = getTransform().createTransformedShape(s); + } + + defaultDisplay(g2, s); + + } + + /** + * Tests another object for equality with this object. + * + * @param obj the object to test (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof LineNeedle)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return super.hashCode(); + } + + /** + * Returns a clone of this needle. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the LineNeedle + * cannot be cloned (in theory, this should not happen). + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/LongNeedle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/LongNeedle.java new file mode 100755 index 0000000..ded750a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/LongNeedle.java @@ -0,0 +1,191 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * LongNeedle.java + * --------------- + * (C) Copyright 2002-2008, by the Australian Antarctic Division and + * Contributors. + * + * Original Author: Bryan Scott (for the Australian Antarctic Division); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); + * 27-Mar-2003 : Implemented Serializable (DG); + * 09-Sep-2003 : Added equals() method (DG); + * 16-Mar-2004 : Implemented Rotation; + * 22-Nov-2007 : Implemented hashCode() (DG); + * + */ + +package org.jfree.chart.needle; + +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.geom.GeneralPath; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +/** + * A needle that is represented by a long line. + */ +public class LongNeedle extends MeterNeedle + implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -4319985779783688159L; + + /** + * Default constructor. + */ + public LongNeedle() { + super(); + setRotateY(0.8); + } + + /** + * Draws the needle. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param rotate the rotation point. + * @param angle the angle. + */ + @Override + protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, + Point2D rotate, double angle) { + + GeneralPath shape1 = new GeneralPath(); + GeneralPath shape2 = new GeneralPath(); + GeneralPath shape3 = new GeneralPath(); + + float minX = (float) plotArea.getMinX(); + float minY = (float) plotArea.getMinY(); + float maxX = (float) plotArea.getMaxX(); + float maxY = (float) plotArea.getMaxY(); + //float midX = (float) (minX + (plotArea.getWidth() * getRotateX())); + //float midY = (float) (minY + (plotArea.getHeight() * getRotateY())); + float midX = (float) (minX + (plotArea.getWidth() * 0.5)); + float midY = (float) (minY + (plotArea.getHeight() * 0.8)); + float y = maxY - (2 * (maxY - midY)); + if (y < minY) { + y = minY; + } + shape1.moveTo(minX, midY); + shape1.lineTo(midX, minY); + shape1.lineTo(midX, y); + shape1.closePath(); + + shape2.moveTo(maxX, midY); + shape2.lineTo(midX, minY); + shape2.lineTo(midX, y); + shape2.closePath(); + + shape3.moveTo(minX, midY); + shape3.lineTo(midX, maxY); + shape3.lineTo(maxX, midY); + shape3.lineTo(midX, y); + shape3.closePath(); + + Shape s1 = shape1; + Shape s2 = shape2; + Shape s3 = shape3; + + if ((rotate != null) && (angle != 0)) { + /// we have rotation huston, please spin me + getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); + s1 = shape1.createTransformedShape(transform); + s2 = shape2.createTransformedShape(transform); + s3 = shape3.createTransformedShape(transform); + } + + + if (getHighlightPaint() != null) { + g2.setPaint(getHighlightPaint()); + g2.fill(s3); + } + + if (getFillPaint() != null) { + g2.setPaint(getFillPaint()); + g2.fill(s1); + g2.fill(s2); + } + + + if (getOutlinePaint() != null) { + g2.setStroke(getOutlineStroke()); + g2.setPaint(getOutlinePaint()); + g2.draw(s1); + g2.draw(s2); + g2.draw(s3); + } + } + + /** + * Tests another object for equality with this object. + * + * @param obj the object to test (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof LongNeedle)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return super.hashCode(); + } + + /** + * Returns a clone of this needle. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the LongNeedle + * cannot be cloned (in theory, this should not happen). + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/MeterNeedle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/MeterNeedle.java new file mode 100755 index 0000000..44f317a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/MeterNeedle.java @@ -0,0 +1,437 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * MeterNeedle.java + * ---------------- + * (C) Copyright 2002-2008, by the Australian Antarctic Division and + * Contributors. + * + * Original Author: Bryan Scott (for the Australian Antarctic Division); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Nicolas Brodu (for Astrium and EADS Corporate Research + * Center); + * + * Changes: + * -------- + * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); + * 07-Nov-2002 : Fixed errors reported by Checkstyle (DG); + * 01-Sep-2003 : Implemented Serialization (NB); + * 16-Mar-2004 : Changed transform from private to protected (BRS); + * 08-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); + * 22-Nov-2007 : Implemented hashCode() (DG); + * + */ + +package org.jfree.chart.needle; + +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.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.HashUtilities; +import org.jfree.io.SerialUtilities; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; + +/** + * The base class used to represent the needle on a + * {@link org.jfree.chart.plot.CompassPlot}. + */ +public abstract class MeterNeedle implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 5203064851510951052L; + + /** The outline paint. */ + private transient Paint outlinePaint = Color.black; + + /** The outline stroke. */ + private transient Stroke outlineStroke = new BasicStroke(2); + + /** The fill paint. */ + private transient Paint fillPaint = null; + + /** The highlight paint. */ + private transient Paint highlightPaint = null; + + /** The size. */ + private int size = 5; + + /** Scalar to aply to locate the rotation x point. */ + private double rotateX = 0.5; + + /** Scalar to aply to locate the rotation y point. */ + private double rotateY = 0.5; + + /** A transform. */ + protected static AffineTransform transform = new AffineTransform(); + + /** + * Creates a new needle. + */ + public MeterNeedle() { + this(null, null, null); + } + + /** + * Creates a new needle. + * + * @param outline the outline paint (null permitted). + * @param fill the fill paint (null permitted). + * @param highlight the highlight paint (null permitted). + */ + public MeterNeedle(Paint outline, Paint fill, Paint highlight) { + this.fillPaint = fill; + this.highlightPaint = highlight; + this.outlinePaint = outline; + } + + /** + * Returns the outline paint. + * + * @return The outline paint. + */ + public Paint getOutlinePaint() { + return this.outlinePaint; + } + + /** + * Sets the outline paint. + * + * @param p the new paint. + */ + public void setOutlinePaint(Paint p) { + if (p != null) { + this.outlinePaint = p; + } + } + + /** + * Returns the outline stroke. + * + * @return The outline stroke. + */ + public Stroke getOutlineStroke() { + return this.outlineStroke; + } + + /** + * Sets the outline stroke. + * + * @param s the new stroke. + */ + public void setOutlineStroke(Stroke s) { + if (s != null) { + this.outlineStroke = s; + } + } + + /** + * Returns the fill paint. + * + * @return The fill paint. + */ + public Paint getFillPaint() { + return this.fillPaint; + } + + /** + * Sets the fill paint. + * + * @param p the fill paint. + */ + public void setFillPaint(Paint p) { + if (p != null) { + this.fillPaint = p; + } + } + + /** + * Returns the highlight paint. + * + * @return The highlight paint. + */ + public Paint getHighlightPaint() { + return this.highlightPaint; + } + + /** + * Sets the highlight paint. + * + * @param p the highlight paint. + */ + public void setHighlightPaint(Paint p) { + if (p != null) { + this.highlightPaint = p; + } + } + + /** + * Returns the scalar used for determining the rotation x value. + * + * @return The x rotate scalar. + */ + public double getRotateX() { + return this.rotateX; + } + + /** + * Sets the rotateX value. + * + * @param x the new value. + */ + public void setRotateX(double x) { + this.rotateX = x; + } + + /** + * Sets the rotateY value. + * + * @param y the new value. + */ + public void setRotateY(double y) { + this.rotateY = y; + } + + /** + * Returns the scalar used for determining the rotation y value. + * + * @return The y rotate scalar. + */ + public double getRotateY() { + return this.rotateY; + } + + /** + * Draws the needle. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + */ + public void draw(Graphics2D g2, Rectangle2D plotArea) { + draw(g2, plotArea, 0); + } + + /** + * Draws the needle. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param angle the angle. + */ + public void draw(Graphics2D g2, Rectangle2D plotArea, double angle) { + + Point2D.Double pt = new Point2D.Double(); + pt.setLocation( + plotArea.getMinX() + this.rotateX * plotArea.getWidth(), + plotArea.getMinY() + this.rotateY * plotArea.getHeight() + ); + draw(g2, plotArea, pt, angle); + + } + + /** + * Draws the needle. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param rotate the rotation point. + * @param angle the angle. + */ + public void draw(Graphics2D g2, Rectangle2D plotArea, Point2D rotate, + double angle) { + + Paint savePaint = g2.getColor(); + Stroke saveStroke = g2.getStroke(); + + drawNeedle(g2, plotArea, rotate, Math.toRadians(angle)); + + g2.setStroke(saveStroke); + g2.setPaint(savePaint); + + } + + /** + * Draws the needle. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param rotate the rotation point. + * @param angle the angle. + */ + protected abstract void drawNeedle(Graphics2D g2, + Rectangle2D plotArea, Point2D rotate, + double angle); + + /** + * Displays a shape. + * + * @param g2 the graphics device. + * @param shape the shape. + */ + protected void defaultDisplay(Graphics2D g2, Shape shape) { + + if (this.fillPaint != null) { + g2.setPaint(this.fillPaint); + g2.fill(shape); + } + + if (this.outlinePaint != null) { + g2.setStroke(this.outlineStroke); + g2.setPaint(this.outlinePaint); + g2.draw(shape); + } + + } + + /** + * Returns the size. + * + * @return The size. + */ + public int getSize() { + return this.size; + } + + /** + * Sets the size. + * + * @param pixels the new size. + */ + public void setSize(int pixels) { + this.size = pixels; + } + + /** + * Returns the transform. + * + * @return The transform. + */ + public AffineTransform getTransform() { + return MeterNeedle.transform; + } + + /** + * Tests another object for equality with this object. + * + * @param obj the object to test (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof MeterNeedle)) { + return false; + } + MeterNeedle that = (MeterNeedle) obj; + if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { + return false; + } + if (!PaintUtilities.equal(this.highlightPaint, that.highlightPaint)) { + return false; + } + if (this.size != that.size) { + return false; + } + if (this.rotateX != that.rotateX) { + return false; + } + if (this.rotateY != that.rotateY) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = HashUtilities.hashCode(193, this.fillPaint); + result = HashUtilities.hashCode(result, this.highlightPaint); + result = HashUtilities.hashCode(result, this.outlinePaint); + result = HashUtilities.hashCode(result, this.outlineStroke); + result = HashUtilities.hashCode(result, this.rotateX); + result = HashUtilities.hashCode(result, this.rotateY); + result = HashUtilities.hashCode(result, this.size); + 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.writeStroke(this.outlineStroke, stream); + SerialUtilities.writePaint(this.outlinePaint, stream); + SerialUtilities.writePaint(this.fillPaint, stream); + SerialUtilities.writePaint(this.highlightPaint, 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.outlineStroke = SerialUtilities.readStroke(stream); + this.outlinePaint = SerialUtilities.readPaint(stream); + this.fillPaint = SerialUtilities.readPaint(stream); + this.highlightPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/MiddlePinNeedle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/MiddlePinNeedle.java new file mode 100755 index 0000000..004df71 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/MiddlePinNeedle.java @@ -0,0 +1,157 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * MiddlePinNeedle.java + * -------------------- + * (C) Copyright 2002-2008, by the Australian Antarctic Division and + * Contributors. + * + * Original Author: Bryan Scott (for the Australian Antarctic Division); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); + * 27-Mar-2003 : Implemented Serializable (DG); + * 09-Sep-2003 : Added equals() method (DG); + * 08-Jun-2005 : Implemented Cloneable (DG); + * 22-Nov-2007 : Implemented hashCode() (DG); + * + */ + +package org.jfree.chart.needle; + +import java.awt.Graphics2D; +import java.awt.geom.Area; +import java.awt.geom.Ellipse2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +/** + * A needle that is drawn as a pin shape. + */ +public class MiddlePinNeedle extends MeterNeedle + implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 6237073996403125310L; + + /** + * Draws the needle. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param rotate the rotation point. + * @param angle the angle. + */ + @Override + protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, + Point2D rotate, double angle) { + + Area shape; + GeneralPath pointer = new GeneralPath(); + + int minY = (int) (plotArea.getMinY()); + //int maxX = (int) (plotArea.getMaxX()); + int maxY = (int) (plotArea.getMaxY()); + int midY = ((maxY - minY) / 2) + minY; + + int midX = (int) (plotArea.getMinX() + (plotArea.getWidth() / 2)); + //int midY = (int) (plotArea.getMinY() + (plotArea.getHeight() / 2)); + int lenX = (int) (plotArea.getWidth() / 10); + if (lenX < 2) { + lenX = 2; + } + + pointer.moveTo(midX - lenX, midY - lenX); + pointer.lineTo(midX + lenX, midY - lenX); + pointer.lineTo(midX, minY); + pointer.closePath(); + + lenX = 4 * lenX; + Ellipse2D circle = new Ellipse2D.Double(midX - lenX / 2, + midY - lenX, lenX, lenX); + + shape = new Area(circle); + shape.add(new Area(pointer)); + if ((rotate != null) && (angle != 0)) { + /// we have rotation + getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); + shape.transform(getTransform()); + } + + defaultDisplay(g2, shape); + + } + + /** + * Tests another object for equality with this object. + * + * @param object the object to test. + * + * @return A boolean. + */ + @Override + public boolean equals(Object object) { + if (object == null) { + return false; + } + if (object == this) { + return true; + } + if (super.equals(object) && object instanceof MiddlePinNeedle) { + return true; + } + return false; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return super.hashCode(); + } + + /** + * Returns a clone of this needle. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the MiddlePinNeedle + * cannot be cloned (in theory, this should not happen). + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/PinNeedle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/PinNeedle.java new file mode 100755 index 0000000..7f52e68 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/PinNeedle.java @@ -0,0 +1,155 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * PinNeedle.java + * -------------- + * (C) Copyright 2002-2008, by the Australian Antarctic Division and + * Contributors. + * + * Original Author: Bryan Scott (for the Australian Antarctic Division); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); + * 27-Mar-2003 : Implemented Serializable (DG); + * 09-Sep-2003 : Added equals() method (DG); + * 08-Jun-2005 : Implemented Cloneable (DG); + * 22-Nov-2007 : Implemented hashCode() (DG); + * + */ + +package org.jfree.chart.needle; + +import java.awt.Graphics2D; +import java.awt.geom.Area; +import java.awt.geom.Ellipse2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +/** + * A needle that is drawn as a pin shape. + */ +public class PinNeedle extends MeterNeedle + implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -3787089953079863373L; + + /** + * Draws the needle. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param rotate the rotation point. + * @param angle the angle. + */ + @Override + protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, + Point2D rotate, double angle) { + + Area shape; + GeneralPath pointer = new GeneralPath(); + + int minY = (int) (plotArea.getMinY()); + //int maxX = (int) (plotArea.getMaxX()); + int maxY = (int) (plotArea.getMaxY()); + int midX = (int) (plotArea.getMinX() + (plotArea.getWidth() / 2)); + //int midY = (int) (plotArea.getMinY() + (plotArea.getHeight() / 2)); + int lenX = (int) (plotArea.getWidth() / 10); + if (lenX < 2) { + lenX = 2; + } + + pointer.moveTo(midX - lenX, maxY - lenX); + pointer.lineTo(midX + lenX, maxY - lenX); + pointer.lineTo(midX, minY + lenX); + pointer.closePath(); + + lenX = 4 * lenX; + Ellipse2D circle = new Ellipse2D.Double(midX - lenX / 2, + plotArea.getMaxY() - lenX, lenX, lenX); + + shape = new Area(circle); + shape.add(new Area(pointer)); + if ((rotate != null) && (angle != 0)) { + /// we have rotation + getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); + shape.transform(getTransform()); + } + + defaultDisplay(g2, shape); + + } + + /** + * Tests another object for equality with this object. + * + * @param obj the object to test (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PinNeedle)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return super.hashCode(); + } + + /** + * Returns a clone of this needle. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the PinNeedle + * cannot be cloned (in theory, this should not happen). + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/PlumNeedle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/PlumNeedle.java new file mode 100755 index 0000000..9e86f2a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/PlumNeedle.java @@ -0,0 +1,143 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * PlumNeedle.java + * --------------- + * (C) Copyright 2002-2008, by the Australian Antarctic Division and + * Contributors. + * + * Original Author: Bryan Scott (for the Australian Antarctic Division); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); + * 27-Mar-2003 : Implemented Serializable (DG); + * 09-Sep-2003 : Added equals() method (DG); + * 08-Jun-2005 : Implemented Cloneable (DG); + * 22-Nov-2007 : Implemented hashCode() (DG); + * + */ + +package org.jfree.chart.needle; + +import java.awt.Graphics2D; +import java.awt.geom.Arc2D; +import java.awt.geom.Area; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +/** + * A needle for use with the {@link org.jfree.chart.plot.CompassPlot} class. + */ +public class PlumNeedle extends MeterNeedle + implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -3082660488660600718L; + + /** + * Draws the needle. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param rotate the rotation point. + * @param angle the angle. + */ + @Override + protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, + Point2D rotate, double angle) { + + Arc2D shape = new Arc2D.Double(Arc2D.PIE); + double radius = plotArea.getHeight(); + double halfX = plotArea.getWidth() / 2; + double diameter = 2 * radius; + + shape.setFrame(plotArea.getMinX() + halfX - radius , + plotArea.getMinY() - radius, + diameter, diameter); + radius = Math.toDegrees(Math.asin(halfX / radius)); + shape.setAngleStart(270 - radius); + shape.setAngleExtent(2 * radius); + + Area s = new Area(shape); + + if ((rotate != null) && (angle != 0)) { + /// we have rotation houston, please spin me + getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); + s.transform(getTransform()); + } + + defaultDisplay(g2, s); + } + + /** + * Tests another object for equality with this object. + * + * @param obj the object to test (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PlumNeedle)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return super.hashCode(); + } + + /** + * Returns a clone of this needle. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the PlumNeedle + * cannot be cloned (in theory, this should not happen). + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/PointerNeedle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/PointerNeedle.java new file mode 100755 index 0000000..579df4e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/PointerNeedle.java @@ -0,0 +1,164 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * PointerNeedle.java + * ------------------ + * (C) Copyright 2002-2008, by the Australian Antarctic Division and + * Contributors. + * + * Original Author: Bryan Scott (for the Australian Antarctic Division); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 09-Sep-2003 : Added equals() method (DG); + * 08-Jun-2005 : Implemented Cloneable (DG); + * 22-Nov-2007 : Implemented hashCode() (DG); + * + */ + +package org.jfree.chart.needle; + +import java.awt.Graphics2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +/** + * A needle in the shape of a pointer, for use with the + * {@link org.jfree.chart.plot.CompassPlot} class. + */ +public class PointerNeedle extends MeterNeedle + implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -4744677345334729606L; + + /** + * Draws the needle. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param rotate the rotation point. + * @param angle the angle. + */ + @Override + protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, + Point2D rotate, double angle) { + + GeneralPath shape1 = new GeneralPath(); + GeneralPath shape2 = new GeneralPath(); + float minX = (float) plotArea.getMinX(); + float minY = (float) plotArea.getMinY(); + float maxX = (float) plotArea.getMaxX(); + float maxY = (float) plotArea.getMaxY(); + float midX = (float) (minX + (plotArea.getWidth() / 2)); + float midY = (float) (minY + (plotArea.getHeight() / 2)); + + shape1.moveTo(minX, midY); + shape1.lineTo(midX, minY); + shape1.lineTo(maxX, midY); + shape1.closePath(); + + shape2.moveTo(minX, midY); + shape2.lineTo(midX, maxY); + shape2.lineTo(maxX, midY); + shape2.closePath(); + + if ((rotate != null) && (angle != 0)) { + /// we have rotation huston, please spin me + getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); + shape1.transform(getTransform()); + shape2.transform(getTransform()); + } + + if (getFillPaint() != null) { + g2.setPaint(getFillPaint()); + g2.fill(shape1); + } + + if (getHighlightPaint() != null) { + g2.setPaint(getHighlightPaint()); + g2.fill(shape2); + } + + if (getOutlinePaint() != null) { + g2.setStroke(getOutlineStroke()); + g2.setPaint(getOutlinePaint()); + g2.draw(shape1); + g2.draw(shape2); + } + } + + /** + * Tests another object for equality with this object. + * + * @param obj the object to test (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PointerNeedle)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return super.hashCode(); + } + + /** + * Returns a clone of this needle. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the PointerNeedle + * cannot be cloned (in theory, this should not happen). + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/ShipNeedle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/ShipNeedle.java new file mode 100755 index 0000000..057d6ea --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/ShipNeedle.java @@ -0,0 +1,141 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * ShipNeedle.java + * --------------- + * (C) Copyright 2002-2008, by the Australian Antarctic Division and + * Contributors. + * + * Original Author: Bryan Scott (for the Australian Antarctic Division); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); + * 27-Mar-2003 : Implemented Serializable (DG); + * 09-Sep-2003 : Added equals() method (DG); + * 08-Jun-2005 : Implemented Cloneable (DG); + * 22-Nov-2007 : Implemented hashCode() (DG); + * + */ + +package org.jfree.chart.needle; + +import java.awt.Graphics2D; +import java.awt.geom.Arc2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +/** + * A needle in the shape of a ship, for use with the + * {@link org.jfree.chart.plot.CompassPlot} class. + */ +public class ShipNeedle extends MeterNeedle + implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 149554868169435612L; + + /** + * Draws the needle. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param rotate the rotation point. + * @param angle the angle. + */ + @Override + protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, + Point2D rotate, double angle) { + + GeneralPath shape = new GeneralPath(); + shape.append(new Arc2D.Double(-9.0, -7.0, 10, 14, 0.0, 25.5, + Arc2D.OPEN), true); + shape.append(new Arc2D.Double(0.0, -7.0, 10, 14, 154.5, 25.5, + Arc2D.OPEN), true); + shape.closePath(); + getTransform().setToTranslation(plotArea.getMinX(), plotArea.getMaxY()); + getTransform().scale(plotArea.getWidth(), plotArea.getHeight() / 3); + shape.transform(getTransform()); + + if ((rotate != null) && (angle != 0)) { + /// we have rotation + getTransform().setToRotation(angle, rotate.getX(), rotate.getY()); + shape.transform(getTransform()); + } + + defaultDisplay(g2, shape); + } + + /** + * Tests another object for equality with this object. + * + * @param object the object to test. + * + * @return A boolean. + */ + @Override + public boolean equals(Object object) { + if (object == null) { + return false; + } + if (object == this) { + return true; + } + if (super.equals(object) && object instanceof ShipNeedle) { + return true; + } + return false; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return super.hashCode(); + } + + /** + * Returns a clone of this needle. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the ShipNeedle + * cannot be cloned (in theory, this should not happen). + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/WindNeedle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/WindNeedle.java new file mode 100755 index 0000000..b7d6ec6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/WindNeedle.java @@ -0,0 +1,131 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * WindNeedle.java + * --------------- + * (C) Copyright 2002-2008, by the Australian Antarctic Division and + * Contributors. + * + * Original Author: Bryan Scott (for the Australian Antarctic Division); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); + * 09-Sep-2003 : Added equals() method (DG); + * 22-Nov-2007 : Implemented hashCode() (DG) + * + */ + +package org.jfree.chart.needle; + +import java.awt.Graphics2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +/** + * A needle that indicates wind direction, for use with the + * {@link org.jfree.chart.plot.CompassPlot} class. + */ +public class WindNeedle extends ArrowNeedle + implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -2861061368907167834L; + + /** + * Default constructor. + */ + public WindNeedle() { + super(false); // isArrowAtTop + } + + /** + * Draws the needle. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param rotate the rotation point. + * @param angle the angle. + */ + @Override + protected void drawNeedle(Graphics2D g2, Rectangle2D plotArea, + Point2D rotate, double angle) { + + super.drawNeedle(g2, plotArea, rotate, angle); + if ((rotate != null) && (plotArea != null)) { + + int spacing = getSize() * 3; + Rectangle2D newArea = new Rectangle2D.Double(); + + Point2D newRotate = rotate; + newArea.setRect(plotArea.getMinX() - spacing, plotArea.getMinY(), + plotArea.getWidth(), plotArea.getHeight()); + super.drawNeedle(g2, newArea, newRotate, angle); + + newArea.setRect(plotArea.getMinX() + spacing, + plotArea.getMinY(), plotArea.getWidth(), + plotArea.getHeight()); + super.drawNeedle(g2, newArea, newRotate, angle); + + } + } + + /** + * Tests another object for equality with this object. + * + * @param object the object to test. + * + * @return A boolean. + */ + @Override + public boolean equals(Object object) { + if (object == null) { + return false; + } + if (object == this) { + return true; + } + if (super.equals(object) && object instanceof WindNeedle) { + return true; + } + return false; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return super.hashCode(); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/package.html new file mode 100755 index 0000000..1f2a468 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/needle/package.html @@ -0,0 +1,7 @@ + + + +A range of objects that can be used to represent the needle on a +{@link org.jfree.chart.plot.CompassPlot}. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/package.html new file mode 100755 index 0000000..f8929bd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/package.html @@ -0,0 +1,7 @@ + + + +Core classes, including {@link org.jfree.chart.JFreeChart} and +{@link org.jfree.chart.ChartPanel}. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/panel/AbstractOverlay.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/panel/AbstractOverlay.java new file mode 100755 index 0000000..75e1746 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/panel/AbstractOverlay.java @@ -0,0 +1,119 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * AbstractOverlay.java + * -------------------- + * (C) Copyright 2009-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 09-Apr-2009 : Version 1 (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.panel; + +import javax.swing.event.EventListenerList; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.OverlayChangeEvent; +import org.jfree.chart.event.OverlayChangeListener; +import org.jfree.chart.util.ParamChecks; + +/** + * A base class for implementing overlays for a {@link ChartPanel}. + * + * @since 1.0.13 + */ +public class AbstractOverlay { + + /** Storage for registered change listeners. */ + private transient EventListenerList changeListeners; + + /** + * Default constructor. + */ + public AbstractOverlay() { + this.changeListeners = new EventListenerList(); + } + + /** + * Registers an object for notification of changes to the overlay. + * + * @param listener the listener (null not permitted). + * + * @see #removeChangeListener(OverlayChangeListener) + */ + public void addChangeListener(OverlayChangeListener listener) { + ParamChecks.nullNotPermitted(listener, "listener"); + this.changeListeners.add(OverlayChangeListener.class, listener); + } + + /** + * Deregisters an object for notification of changes to the overlay. + * + * @param listener the listener (null not permitted) + * + * @see #addChangeListener(OverlayChangeListener) + */ + public void removeChangeListener(OverlayChangeListener listener) { + ParamChecks.nullNotPermitted(listener, "listener"); + this.changeListeners.remove(OverlayChangeListener.class, listener); + } + + /** + * Sends a default {@link ChartChangeEvent} to all registered listeners. + *

+ * This method is for convenience only. + */ + public void fireOverlayChanged() { + OverlayChangeEvent event = new OverlayChangeEvent(this); + notifyListeners(event); + } + + /** + * Sends a {@link ChartChangeEvent} to all registered listeners. + * + * @param event information about the event that triggered the + * notification. + */ + protected void notifyListeners(OverlayChangeEvent event) { + Object[] listeners = this.changeListeners.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == OverlayChangeListener.class) { + ((OverlayChangeListener) listeners[i + 1]).overlayChanged( + event); + } + } + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/panel/CrosshairOverlay.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/panel/CrosshairOverlay.java new file mode 100755 index 0000000..41ca113 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/panel/CrosshairOverlay.java @@ -0,0 +1,592 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * CrosshairOverlay.java + * --------------------- + * (C) Copyright 2011-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 09-Apr-2009 : Version 1 (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.panel; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.OverlayChangeEvent; +import org.jfree.chart.plot.Crosshair; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.util.ParamChecks; +import org.jfree.text.TextUtilities; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.TextAnchor; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * An overlay for a {@link ChartPanel} that draws crosshairs on a plot. + * + * @since 1.0.13 + */ +public class CrosshairOverlay extends AbstractOverlay implements Overlay, + PropertyChangeListener, PublicCloneable, Cloneable, Serializable { + + /** Storage for the crosshairs along the x-axis. */ + private List xCrosshairs; + + /** Storage for the crosshairs along the y-axis. */ + private List yCrosshairs; + + /** + * Default constructor. + */ + public CrosshairOverlay() { + super(); + this.xCrosshairs = new java.util.ArrayList(); + this.yCrosshairs = new java.util.ArrayList(); + } + + /** + * Adds a crosshair against the domain axis and sends an + * {@link OverlayChangeEvent} to all registered listeners. + * + * @param crosshair the crosshair (null not permitted). + * + * @see #removeDomainCrosshair(org.jfree.chart.plot.Crosshair) + * @see #addRangeCrosshair(org.jfree.chart.plot.Crosshair) + */ + public void addDomainCrosshair(Crosshair crosshair) { + ParamChecks.nullNotPermitted(crosshair, "crosshair"); + this.xCrosshairs.add(crosshair); + crosshair.addPropertyChangeListener(this); + fireOverlayChanged(); + } + + /** + * Removes a domain axis crosshair and sends an {@link OverlayChangeEvent} + * to all registered listeners. + * + * @param crosshair the crosshair (null not permitted). + * + * @see #addDomainCrosshair(org.jfree.chart.plot.Crosshair) + */ + public void removeDomainCrosshair(Crosshair crosshair) { + ParamChecks.nullNotPermitted(crosshair, "crosshair"); + if (this.xCrosshairs.remove(crosshair)) { + crosshair.removePropertyChangeListener(this); + fireOverlayChanged(); + } + } + + /** + * Clears all the domain crosshairs from the overlay and sends an + * {@link OverlayChangeEvent} to all registered listeners. + */ + public void clearDomainCrosshairs() { + if (this.xCrosshairs.isEmpty()) { + return; // nothing to do + } + List crosshairs = getDomainCrosshairs(); + for (int i = 0; i < crosshairs.size(); i++) { + Crosshair c = (Crosshair) crosshairs.get(i); + this.xCrosshairs.remove(c); + c.removePropertyChangeListener(this); + } + fireOverlayChanged(); + } + + /** + * Returns a new list containing the domain crosshairs for this overlay. + * + * @return A list of crosshairs. + */ + public List getDomainCrosshairs() { + return new ArrayList(this.xCrosshairs); + } + + /** + * Adds a crosshair against the range axis and sends an + * {@link OverlayChangeEvent} to all registered listeners. + * + * @param crosshair the crosshair (null not permitted). + */ + public void addRangeCrosshair(Crosshair crosshair) { + ParamChecks.nullNotPermitted(crosshair, "crosshair"); + this.yCrosshairs.add(crosshair); + crosshair.addPropertyChangeListener(this); + fireOverlayChanged(); + } + + /** + * Removes a range axis crosshair and sends an {@link OverlayChangeEvent} + * to all registered listeners. + * + * @param crosshair the crosshair (null not permitted). + * + * @see #addRangeCrosshair(org.jfree.chart.plot.Crosshair) + */ + public void removeRangeCrosshair(Crosshair crosshair) { + ParamChecks.nullNotPermitted(crosshair, "crosshair"); + if (this.yCrosshairs.remove(crosshair)) { + crosshair.removePropertyChangeListener(this); + fireOverlayChanged(); + } + } + + /** + * Clears all the range crosshairs from the overlay and sends an + * {@link OverlayChangeEvent} to all registered listeners. + */ + public void clearRangeCrosshairs() { + if (this.yCrosshairs.isEmpty()) { + return; // nothing to do + } + List crosshairs = getRangeCrosshairs(); + for (int i = 0; i < crosshairs.size(); i++) { + Crosshair c = (Crosshair) crosshairs.get(i); + this.yCrosshairs.remove(c); + c.removePropertyChangeListener(this); + } + fireOverlayChanged(); + } + + /** + * Returns a new list containing the range crosshairs for this overlay. + * + * @return A list of crosshairs. + */ + public List getRangeCrosshairs() { + return new ArrayList(this.yCrosshairs); + } + + /** + * Receives a property change event (typically a change in one of the + * crosshairs). + * + * @param e the event. + */ + @Override + public void propertyChange(PropertyChangeEvent e) { + fireOverlayChanged(); + } + + /** + * Paints the crosshairs in the layer. + * + * @param g2 the graphics target. + * @param chartPanel the chart panel. + */ + @Override + public void paintOverlay(Graphics2D g2, ChartPanel chartPanel) { + Shape savedClip = g2.getClip(); + Rectangle2D dataArea = chartPanel.getScreenDataArea(); + g2.clip(dataArea); + JFreeChart chart = chartPanel.getChart(); + XYPlot plot = (XYPlot) chart.getPlot(); + ValueAxis xAxis = plot.getDomainAxis(); + RectangleEdge xAxisEdge = plot.getDomainAxisEdge(); + Iterator iterator = this.xCrosshairs.iterator(); + while (iterator.hasNext()) { + Crosshair ch = (Crosshair) iterator.next(); + if (ch.isVisible()) { + double x = ch.getValue(); + double xx = xAxis.valueToJava2D(x, dataArea, xAxisEdge); + if (plot.getOrientation() == PlotOrientation.VERTICAL) { + drawVerticalCrosshair(g2, dataArea, xx, ch); + } + else { + drawHorizontalCrosshair(g2, dataArea, xx, ch); + } + } + } + ValueAxis yAxis = plot.getRangeAxis(); + RectangleEdge yAxisEdge = plot.getRangeAxisEdge(); + iterator = this.yCrosshairs.iterator(); + while (iterator.hasNext()) { + Crosshair ch = (Crosshair) iterator.next(); + if (ch.isVisible()) { + double y = ch.getValue(); + double yy = yAxis.valueToJava2D(y, dataArea, yAxisEdge); + if (plot.getOrientation() == PlotOrientation.VERTICAL) { + drawHorizontalCrosshair(g2, dataArea, yy, ch); + } + else { + drawVerticalCrosshair(g2, dataArea, yy, ch); + } + } + } + g2.setClip(savedClip); + } + + /** + * Draws a crosshair horizontally across the plot. + * + * @param g2 the graphics target. + * @param dataArea the data area. + * @param y the y-value in Java2D space. + * @param crosshair the crosshair. + */ + protected void drawHorizontalCrosshair(Graphics2D g2, Rectangle2D dataArea, + double y, Crosshair crosshair) { + + if (y >= dataArea.getMinY() && y <= dataArea.getMaxY()) { + Line2D line = new Line2D.Double(dataArea.getMinX(), y, + dataArea.getMaxX(), y); + Paint savedPaint = g2.getPaint(); + Stroke savedStroke = g2.getStroke(); + g2.setPaint(crosshair.getPaint()); + g2.setStroke(crosshair.getStroke()); + g2.draw(line); + if (crosshair.isLabelVisible()) { + String label = crosshair.getLabelGenerator().generateLabel( + crosshair); + RectangleAnchor anchor = crosshair.getLabelAnchor(); + Point2D pt = calculateLabelPoint(line, anchor, 5, 5); + float xx = (float) pt.getX(); + float yy = (float) pt.getY(); + TextAnchor alignPt = textAlignPtForLabelAnchorH(anchor); + Shape hotspot = TextUtilities.calculateRotatedStringBounds( + label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER); + if (!dataArea.contains(hotspot.getBounds2D())) { + anchor = flipAnchorV(anchor); + pt = calculateLabelPoint(line, anchor, 5, 5); + xx = (float) pt.getX(); + yy = (float) pt.getY(); + alignPt = textAlignPtForLabelAnchorH(anchor); + hotspot = TextUtilities.calculateRotatedStringBounds( + label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER); + } + + g2.setPaint(crosshair.getLabelBackgroundPaint()); + g2.fill(hotspot); + g2.setPaint(crosshair.getLabelOutlinePaint()); + g2.draw(hotspot); + TextUtilities.drawAlignedString(label, g2, xx, yy, alignPt); + } + g2.setPaint(savedPaint); + g2.setStroke(savedStroke); + } + } + + /** + * Draws a crosshair vertically on the plot. + * + * @param g2 the graphics target. + * @param dataArea the data area. + * @param x the x-value in Java2D space. + * @param crosshair the crosshair. + */ + protected void drawVerticalCrosshair(Graphics2D g2, Rectangle2D dataArea, + double x, Crosshair crosshair) { + + if (x >= dataArea.getMinX() && x <= dataArea.getMaxX()) { + Line2D line = new Line2D.Double(x, dataArea.getMinY(), x, + dataArea.getMaxY()); + Paint savedPaint = g2.getPaint(); + Stroke savedStroke = g2.getStroke(); + g2.setPaint(crosshair.getPaint()); + g2.setStroke(crosshair.getStroke()); + g2.draw(line); + if (crosshair.isLabelVisible()) { + String label = crosshair.getLabelGenerator().generateLabel( + crosshair); + RectangleAnchor anchor = crosshair.getLabelAnchor(); + Point2D pt = calculateLabelPoint(line, anchor, 5, 5); + float xx = (float) pt.getX(); + float yy = (float) pt.getY(); + TextAnchor alignPt = textAlignPtForLabelAnchorV(anchor); + Shape hotspot = TextUtilities.calculateRotatedStringBounds( + label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER); + if (!dataArea.contains(hotspot.getBounds2D())) { + anchor = flipAnchorH(anchor); + pt = calculateLabelPoint(line, anchor, 5, 5); + xx = (float) pt.getX(); + yy = (float) pt.getY(); + alignPt = textAlignPtForLabelAnchorV(anchor); + hotspot = TextUtilities.calculateRotatedStringBounds( + label, g2, xx, yy, alignPt, 0.0, TextAnchor.CENTER); + } + g2.setPaint(crosshair.getLabelBackgroundPaint()); + g2.fill(hotspot); + g2.setPaint(crosshair.getLabelOutlinePaint()); + g2.draw(hotspot); + TextUtilities.drawAlignedString(label, g2, xx, yy, alignPt); + } + g2.setPaint(savedPaint); + g2.setStroke(savedStroke); + } + } + + /** + * Calculates the anchor point for a label. + * + * @param line the line for the crosshair. + * @param anchor the anchor point. + * @param deltaX the x-offset. + * @param deltaY the y-offset. + * + * @return The anchor point. + */ + private Point2D calculateLabelPoint(Line2D line, RectangleAnchor anchor, + double deltaX, double deltaY) { + double x, y; + boolean left = (anchor == RectangleAnchor.BOTTOM_LEFT + || anchor == RectangleAnchor.LEFT + || anchor == RectangleAnchor.TOP_LEFT); + boolean right = (anchor == RectangleAnchor.BOTTOM_RIGHT + || anchor == RectangleAnchor.RIGHT + || anchor == RectangleAnchor.TOP_RIGHT); + boolean top = (anchor == RectangleAnchor.TOP_LEFT + || anchor == RectangleAnchor.TOP + || anchor == RectangleAnchor.TOP_RIGHT); + boolean bottom = (anchor == RectangleAnchor.BOTTOM_LEFT + || anchor == RectangleAnchor.BOTTOM + || anchor == RectangleAnchor.BOTTOM_RIGHT); + Rectangle rect = line.getBounds(); + + // we expect the line to be vertical or horizontal + if (line.getX1() == line.getX2()) { // vertical + x = line.getX1(); + y = (line.getY1() + line.getY2()) / 2.0; + if (left) { + x = x - deltaX; + } + if (right) { + x = x + deltaX; + } + if (top) { + y = Math.min(line.getY1(), line.getY2()) + deltaY; + } + if (bottom) { + y = Math.max(line.getY1(), line.getY2()) - deltaY; + } + } + else { // horizontal + x = (line.getX1() + line.getX2()) / 2.0; + y = line.getY1(); + if (left) { + x = Math.min(line.getX1(), line.getX2()) + deltaX; + } + if (right) { + x = Math.max(line.getX1(), line.getX2()) - deltaX; + } + if (top) { + y = y - deltaY; + } + if (bottom) { + y = y + deltaY; + } + } + return new Point2D.Double(x, y); + } + + /** + * Returns the text anchor that is used to align a label to its anchor + * point. + * + * @param anchor the anchor. + * + * @return The text alignment point. + */ + private TextAnchor textAlignPtForLabelAnchorV(RectangleAnchor anchor) { + TextAnchor result = TextAnchor.CENTER; + if (anchor.equals(RectangleAnchor.TOP_LEFT)) { + result = TextAnchor.TOP_RIGHT; + } + else if (anchor.equals(RectangleAnchor.TOP)) { + result = TextAnchor.TOP_CENTER; + } + else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) { + result = TextAnchor.TOP_LEFT; + } + else if (anchor.equals(RectangleAnchor.LEFT)) { + result = TextAnchor.HALF_ASCENT_RIGHT; + } + else if (anchor.equals(RectangleAnchor.RIGHT)) { + result = TextAnchor.HALF_ASCENT_LEFT; + } + else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) { + result = TextAnchor.BOTTOM_RIGHT; + } + else if (anchor.equals(RectangleAnchor.BOTTOM)) { + result = TextAnchor.BOTTOM_CENTER; + } + else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { + result = TextAnchor.BOTTOM_LEFT; + } + return result; + } + + /** + * Returns the text anchor that is used to align a label to its anchor + * point. + * + * @param anchor the anchor. + * + * @return The text alignment point. + */ + private TextAnchor textAlignPtForLabelAnchorH(RectangleAnchor anchor) { + TextAnchor result = TextAnchor.CENTER; + if (anchor.equals(RectangleAnchor.TOP_LEFT)) { + result = TextAnchor.BOTTOM_LEFT; + } + else if (anchor.equals(RectangleAnchor.TOP)) { + result = TextAnchor.BOTTOM_CENTER; + } + else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) { + result = TextAnchor.BOTTOM_RIGHT; + } + else if (anchor.equals(RectangleAnchor.LEFT)) { + result = TextAnchor.HALF_ASCENT_LEFT; + } + else if (anchor.equals(RectangleAnchor.RIGHT)) { + result = TextAnchor.HALF_ASCENT_RIGHT; + } + else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) { + result = TextAnchor.TOP_LEFT; + } + else if (anchor.equals(RectangleAnchor.BOTTOM)) { + result = TextAnchor.TOP_CENTER; + } + else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { + result = TextAnchor.TOP_RIGHT; + } + return result; + } + + private RectangleAnchor flipAnchorH(RectangleAnchor anchor) { + RectangleAnchor result = anchor; + if (anchor.equals(RectangleAnchor.TOP_LEFT)) { + result = RectangleAnchor.TOP_RIGHT; + } + else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) { + result = RectangleAnchor.TOP_LEFT; + } + else if (anchor.equals(RectangleAnchor.LEFT)) { + result = RectangleAnchor.RIGHT; + } + else if (anchor.equals(RectangleAnchor.RIGHT)) { + result = RectangleAnchor.LEFT; + } + else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) { + result = RectangleAnchor.BOTTOM_RIGHT; + } + else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { + result = RectangleAnchor.BOTTOM_LEFT; + } + return result; + } + + private RectangleAnchor flipAnchorV(RectangleAnchor anchor) { + RectangleAnchor result = anchor; + if (anchor.equals(RectangleAnchor.TOP_LEFT)) { + result = RectangleAnchor.BOTTOM_LEFT; + } + else if (anchor.equals(RectangleAnchor.TOP_RIGHT)) { + result = RectangleAnchor.BOTTOM_RIGHT; + } + else if (anchor.equals(RectangleAnchor.TOP)) { + result = RectangleAnchor.BOTTOM; + } + else if (anchor.equals(RectangleAnchor.BOTTOM)) { + result = RectangleAnchor.TOP; + } + else if (anchor.equals(RectangleAnchor.BOTTOM_LEFT)) { + result = RectangleAnchor.TOP_LEFT; + } + else if (anchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { + result = RectangleAnchor.TOP_RIGHT; + } + return result; + } + + /** + * Tests this overlay for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CrosshairOverlay)) { + return false; + } + CrosshairOverlay that = (CrosshairOverlay) obj; + if (!this.xCrosshairs.equals(that.xCrosshairs)) { + return false; + } + if (!this.yCrosshairs.equals(that.yCrosshairs)) { + return false; + } + return true; + } + + /** + * Returns a clone of this instance. + * + * @return A clone of this instance. + * + * @throws java.lang.CloneNotSupportedException if there is some problem + * with the cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + CrosshairOverlay clone = (CrosshairOverlay) super.clone(); + clone.xCrosshairs = (List) ObjectUtilities.deepClone(this.xCrosshairs); + clone.yCrosshairs = (List) ObjectUtilities.deepClone(this.yCrosshairs); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/panel/Overlay.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/panel/Overlay.java new file mode 100755 index 0000000..40bd76e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/panel/Overlay.java @@ -0,0 +1,76 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------ + * Overlay.java + * ------------ + * (C) Copyright 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 09-Apr-2009 : Version 1 (DG); + * + */ +package org.jfree.chart.panel; + +import java.awt.Graphics2D; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.event.OverlayChangeListener; + +/** + * Defines the interface for an overlay that can be added to a + * {@link ChartPanel}. + * + * @since 1.0.13 + */ +public interface Overlay { + + /** + * Paints the crosshairs in the layer. + * + * @param g2 the graphics target. + * @param chartPanel the chart panel. + */ + public void paintOverlay(Graphics2D g2, ChartPanel chartPanel); + + /** + * Registers a change listener with the overlay. + * + * @param listener the listener. + */ + public void addChangeListener(OverlayChangeListener listener); + + /** + * Deregisters a listener from the overlay. + * + * @param listener the listener. + */ + public void removeChangeListener(OverlayChangeListener listener); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/panel/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/panel/package.html new file mode 100755 index 0000000..5059935 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/panel/package.html @@ -0,0 +1,6 @@ + + + +Classes related to the {@link org.jfree.chart.ChartPanel} class. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/AbstractPieLabelDistributor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/AbstractPieLabelDistributor.java new file mode 100755 index 0000000..edac9ac --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/AbstractPieLabelDistributor.java @@ -0,0 +1,112 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------- + * AbstractPieLabelDistributor.java + * -------------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 14-Jun-2007 : Version 1 (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +import java.io.Serializable; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +/** + * A base class for handling the distribution of pie section labels. Create + * your own subclass and set it using the + * {@link PiePlot#setLabelDistributor(AbstractPieLabelDistributor)} method + * if you want to customise the label distribution. + */ +public abstract class AbstractPieLabelDistributor implements Serializable { + + /** The label records. */ + protected List labels; + + /** + * Creates a new instance. + */ + public AbstractPieLabelDistributor() { + this.labels = new java.util.ArrayList(); + } + + /** + * Returns a label record from the list. + * + * @param index the index. + * + * @return The label record. + */ + public PieLabelRecord getPieLabelRecord(int index) { + return (PieLabelRecord) this.labels.get(index); + } + + /** + * Adds a label record. + * + * @param record the label record (null not permitted). + */ + public void addPieLabelRecord(PieLabelRecord record) { + ParamChecks.nullNotPermitted(record, "record"); + this.labels.add(record); + } + + /** + * Returns the number of items in the list. + * + * @return The item count. + */ + public int getItemCount() { + return this.labels.size(); + } + + /** + * Clears the list of labels. + */ + public void clear() { + this.labels.clear(); + } + + /** + * Called by the {@link PiePlot} class. Implementations should distribute + * the labels in this.labels then return. + * + * @param minY the y-coordinate for the top of the label area. + * @param height the height of the label area. + */ + public abstract void distributeLabels(double minY, double height); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CategoryCrosshairState.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CategoryCrosshairState.java new file mode 100755 index 0000000..a2e10ac --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CategoryCrosshairState.java @@ -0,0 +1,181 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * CategoryCrosshairState.java + * --------------------------- + * (C) Copyright 2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Jun-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.geom.Point2D; + +import org.jfree.chart.renderer.category.CategoryItemRenderer; + +/** + * Represents state information for the crosshairs in a {@link CategoryPlot}. + * An instance of this class is created at the start of the rendering process, + * and updated as each data item is rendered. At the end of the rendering + * process, this class holds the row key, column key and value for the + * crosshair location. + * + * @since 1.0.11 + */ +public class CategoryCrosshairState extends CrosshairState { + + /** + * The row key for the crosshair point. + */ + private Comparable rowKey; + + /** + * The column key for the crosshair point. + */ + private Comparable columnKey; + + /** + * Creates a new instance. + */ + public CategoryCrosshairState() { + this.rowKey = null; + this.columnKey = null; + } + + /** + * Returns the row key. + * + * @return The row key. + */ + public Comparable getRowKey() { + return this.rowKey; + } + + /** + * Sets the row key. + * + * @param key the row key. + */ + public void setRowKey(Comparable key) { + this.rowKey = key; + } + + /** + * Returns the column key. + * + * @return The column key. + */ + public Comparable getColumnKey() { + return this.columnKey; + } + + /** + * Sets the column key. + * + * @param key the key. + */ + public void setColumnKey(Comparable key) { + this.columnKey = key; + } + + /** + * Evaluates a data point from a {@link CategoryItemRenderer} and if it is + * the closest to the anchor point it becomes the new crosshair point. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param value y coordinate (measured against the range axis). + * @param datasetIndex the dataset index for this point. + * @param transX x translated into Java2D space. + * @param transY y translated into Java2D space. + * @param orientation the plot orientation. + */ + public void updateCrosshairPoint(Comparable rowKey, Comparable columnKey, + double value, int datasetIndex, double transX, double transY, + PlotOrientation orientation) { + + Point2D anchor = getAnchor(); + if (anchor != null) { + double xx = anchor.getX(); + double yy = anchor.getY(); + if (orientation == PlotOrientation.HORIZONTAL) { + double temp = yy; + yy = xx; + xx = temp; + } + double d = (transX - xx) * (transX - xx) + + (transY - yy) * (transY - yy); + + if (d < getCrosshairDistance()) { + this.rowKey = rowKey; + this.columnKey = columnKey; + setCrosshairY(value); + setDatasetIndex(datasetIndex); + setCrosshairDistance(d); + } + } + + } + + /** + * Updates only the crosshair row and column keys (this is for the case + * where the range crosshair does NOT lock onto the nearest data value). + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param datasetIndex the dataset axis index. + * @param transX the translated x-value. + * @param orientation the plot orientation. + */ + public void updateCrosshairX(Comparable rowKey, Comparable columnKey, + int datasetIndex, double transX, PlotOrientation orientation) { + + Point2D anchor = getAnchor(); + if (anchor != null) { + double anchorX = anchor.getX(); + if (orientation == PlotOrientation.HORIZONTAL) { + anchorX = anchor.getY(); + } + double d = Math.abs(transX - anchorX); + if (d < getCrosshairDistance()) { + this.rowKey = rowKey; + this.columnKey = columnKey; + setDatasetIndex(datasetIndex); + setCrosshairDistance(d); + } + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CategoryMarker.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CategoryMarker.java new file mode 100755 index 0000000..c5cf4f8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CategoryMarker.java @@ -0,0 +1,186 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * CategoryMarker.java + * ------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Nicolas Brodu; + * + * Changes + * ------- + * 20-May-2005 : Version 1 (DG); + * 19-Aug-2005 : Implemented equals(), fixed bug in constructor (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 05-Sep-2006 : Added MarkerChangeListener support (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Paint; +import java.awt.Stroke; +import java.io.Serializable; + +import org.jfree.chart.event.MarkerChangeEvent; +import org.jfree.chart.util.ParamChecks; +import org.jfree.ui.LengthAdjustmentType; + +/** + * A marker for a category. + *

+ * Note that for serialization to work correctly, the category key must be an + * instance of a serializable class. + * + * @see CategoryPlot#addDomainMarker(CategoryMarker) + */ +public class CategoryMarker extends Marker implements Cloneable, Serializable { + + /** The category key. */ + private Comparable key; + + /** + * A hint that the marker should be drawn as a line rather than a region. + */ + private boolean drawAsLine = false; + + /** + * Creates a new category marker for the specified category. + * + * @param key the category key. + */ + public CategoryMarker(Comparable key) { + this(key, Color.gray, new BasicStroke(1.0f)); + } + + /** + * Creates a new category marker. + * + * @param key the key. + * @param paint the paint (null not permitted). + * @param stroke the stroke (null not permitted). + */ + public CategoryMarker(Comparable key, Paint paint, Stroke stroke) { + this(key, paint, stroke, paint, stroke, 1.0f); + } + + /** + * Creates a new category marker. + * + * @param key the key. + * @param paint the paint (null not permitted). + * @param stroke the stroke (null not permitted). + * @param outlinePaint the outline paint (null permitted). + * @param outlineStroke the outline stroke (null permitted). + * @param alpha the alpha transparency. + */ + public CategoryMarker(Comparable key, Paint paint, Stroke stroke, + Paint outlinePaint, Stroke outlineStroke, + float alpha) { + super(paint, stroke, outlinePaint, outlineStroke, alpha); + this.key = key; + setLabelOffsetType(LengthAdjustmentType.EXPAND); + } + + /** + * Returns the key. + * + * @return The key. + */ + public Comparable getKey() { + return this.key; + } + + /** + * Sets the key and sends a {@link MarkerChangeEvent} to all registered + * listeners. + * + * @param key the key (null not permitted). + * + * @since 1.0.3 + */ + public void setKey(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + this.key = key; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Returns the flag that controls whether the marker is drawn as a region + * or a line. + * + * @return A line. + */ + public boolean getDrawAsLine() { + return this.drawAsLine; + } + + /** + * Sets the flag that controls whether the marker is drawn as a region or + * as a line, and sends a {@link MarkerChangeEvent} to all registered + * listeners. + * + * @param drawAsLine the flag. + */ + public void setDrawAsLine(boolean drawAsLine) { + this.drawAsLine = drawAsLine; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Tests the marker for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (!(obj instanceof CategoryMarker)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + CategoryMarker that = (CategoryMarker) obj; + if (!this.key.equals(that.key)) { + return false; + } + if (this.drawAsLine != that.drawAsLine) { + return false; + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CategoryPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CategoryPlot.java new file mode 100755 index 0000000..fb109f0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CategoryPlot.java @@ -0,0 +1,5170 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * CategoryPlot.java + * ----------------- + * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Jeremy Bowman; + * Arnaud Lelievre; + * Richard West, Advanced Micro Devices, Inc.; + * Ulrich Voigt - patch 2686040; + * Peter Kolb - patches 2603321 and 2809117; + * + * Changes + * ------- + * 21-Jun-2001 : Removed redundant JFreeChart parameter from constructors (DG); + * 21-Aug-2001 : Added standard header. Fixed DOS encoding problem (DG); + * 18-Sep-2001 : Updated header (DG); + * 15-Oct-2001 : Data source classes moved to com.jrefinery.data.* (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * 23-Oct-2001 : Changed intro and trail gaps on bar plots to use percentage of + * available space rather than a fixed number of units (DG); + * 12-Dec-2001 : Changed constructors to protected (DG); + * 13-Dec-2001 : Added tooltips (DG); + * 16-Jan-2002 : Increased maximum intro and trail gap percents, plus added + * some argument checking code. Thanks to Taoufik Romdhane for + * suggesting this (DG); + * 05-Feb-2002 : Added accessor methods for the tooltip generator, incorporated + * alpha-transparency for Plot and subclasses (DG); + * 06-Mar-2002 : Updated import statements (DG); + * 14-Mar-2002 : Renamed BarPlot.java --> CategoryPlot.java, and changed code + * to use the CategoryItemRenderer interface (DG); + * 22-Mar-2002 : Dropped the getCategories() method (DG); + * 23-Apr-2002 : Moved the dataset from the JFreeChart class to the Plot + * class (DG); + * 29-Apr-2002 : New methods to support printing values at the end of bars, + * contributed by Jeremy Bowman (DG); + * 11-May-2002 : New methods for label visibility and overlaid plot support, + * contributed by Jeremy Bowman (DG); + * 06-Jun-2002 : Removed the tooltip generator, this is now stored with the + * renderer. Moved constants into the CategoryPlotConstants + * interface. Updated Javadoc comments (DG); + * 10-Jun-2002 : Overridden datasetChanged() method to update the upper and + * lower bound on the range axis (if necessary), updated + * Javadocs (DG); + * 25-Jun-2002 : Removed redundant imports (DG); + * 20-Aug-2002 : Changed the constructor for Marker (DG); + * 28-Aug-2002 : Added listener notification to setDomainAxis() and + * setRangeAxis() (DG); + * 23-Sep-2002 : Added getLegendItems() method and fixed errors reported by + * Checkstyle (DG); + * 28-Oct-2002 : Changes to the CategoryDataset interface (DG); + * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG); + * 07-Nov-2002 : Renamed labelXXX as valueLabelXXX (DG); + * 18-Nov-2002 : Added grid settings for both domain and range axis (previously + * these were set in the axes) (DG); + * 19-Nov-2002 : Added axis location parameters to constructor (DG); + * 17-Jan-2003 : Moved to com.jrefinery.chart.plot package (DG); + * 14-Feb-2003 : Fixed bug in auto-range calculation for secondary axis (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 02-May-2003 : Moved render() method up from subclasses. Added secondary + * range markers. Added an attribute to control the dataset + * rendering order. Added a drawAnnotations() method. Changed + * the axis location from an int to an AxisLocation (DG); + * 07-May-2003 : Merged HorizontalCategoryPlot and VerticalCategoryPlot into + * this class (DG); + * 02-Jun-2003 : Removed check for range axis compatibility (DG); + * 04-Jul-2003 : Added a domain gridline position attribute (DG); + * 21-Jul-2003 : Moved DrawingSupplier to Plot superclass (DG); + * 19-Aug-2003 : Added equals() method and implemented Cloneable (DG); + * 01-Sep-2003 : Fixed bug 797466 (no change event when secondary dataset + * changes) (DG); + * 02-Sep-2003 : Fixed bug 795209 (wrong dataset checked in render2 method) and + * 790407 (initialise method) (DG); + * 08-Sep-2003 : Added internationalization via use of properties + * resourceBundle (RFE 690236) (AL); + * 08-Sep-2003 : Fixed bug (wrong secondary range axis being used). Changed + * ValueAxis API (DG); + * 10-Sep-2003 : Fixed bug in setRangeAxis() method (DG); + * 15-Sep-2003 : Fixed two bugs in serialization, implemented + * PublicCloneable (DG); + * 23-Oct-2003 : Added event notification for changes to renderer (DG); + * 26-Nov-2003 : Fixed bug (849645) in clearRangeMarkers() method (DG); + * 03-Dec-2003 : Modified draw method to accept anchor (DG); + * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); + * 10-Mar-2004 : Fixed bug in axis range calculation when secondary renderer is + * stacked (DG); + * 12-May-2004 : Added fixed legend items (DG); + * 19-May-2004 : Added check for null legend item from renderer (DG); + * 02-Jun-2004 : Updated the DatasetRenderingOrder class (DG); + * 05-Nov-2004 : Renamed getDatasetsMappedToRangeAxis() + * --> datasetsMappedToRangeAxis(), and ensured that returned + * list doesn't contain null datasets (DG); + * 12-Nov-2004 : Implemented new Zoomable interface (DG); + * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds() in + * CategoryItemRenderer (DG); + * 04-May-2005 : Fixed serialization of range markers (DG); + * 05-May-2005 : Updated draw() method parameters (DG); + * 20-May-2005 : Added setDomainAxes() and setRangeAxes() methods, as per + * RFE 1183100 (DG); + * 01-Jun-2005 : Upon deserialization, register plot as a listener with its + * axes, dataset(s) and renderer(s) - see patch 1209475 (DG); + * 02-Jun-2005 : Added support for domain markers (DG); + * 06-Jun-2005 : Fixed equals() method for use with GradientPaint (DG); + * 09-Jun-2005 : Added setRenderers(), as per RFE 1183100 (DG); + * 16-Jun-2005 : Added getDomainAxisCount() and getRangeAxisCount() methods, to + * match XYPlot (see RFE 1220495) (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 11-Jan-2006 : Added configureRangeAxes() to rendererChanged(), since the + * renderer might influence the axis range (DG); + * 27-Jan-2006 : Added various null argument checks (DG); + * 18-Aug-2006 : Added getDatasetCount() method, plus a fix for bug drawing + * category labels, thanks to Adriaan Joubert (1277726) (DG); + * 05-Sep-2006 : Added MarkerChangeEvent support (DG); + * 30-Oct-2006 : Added getDomainAxisIndex(), datasetsMappedToDomainAxis() and + * getCategoriesForAxis() methods (DG); + * 22-Nov-2006 : Fire PlotChangeEvent from setColumnRenderingOrder() and + * setRowRenderingOrder() (DG); + * 29-Nov-2006 : Fix for bug 1605207 (IntervalMarker exceeds bounds of data + * area) (DG); + * 26-Feb-2007 : Fix for bug 1669218 (setDomainAxisLocation() notify argument + * ignored) (DG); + * 13-Mar-2007 : Added null argument checks for setRangeCrosshairPaint() and + * setRangeCrosshairStroke(), fixed clipping for + * annotations (DG); + * 07-Jun-2007 : Override drawBackground() for new GradientPaint handling (DG); + * 10-Jul-2007 : Added getRangeAxisIndex(ValueAxis) method (DG); + * 24-Sep-2007 : Implemented new zoom methods (DG); + * 25-Oct-2007 : Added some argument checks (DG); + * 05-Nov-2007 : Applied patch 1823697, by Richard West, for removal of domain + * and range markers (DG); + * 14-Nov-2007 : Added missing event notifications (DG); + * 25-Mar-2008 : Added new methods with optional notification - see patch + * 1913751 (DG); + * 07-Apr-2008 : Fixed NPE in removeDomainMarker() and + * removeRangeMarker() (DG); + * 23-Apr-2008 : Fixed equals() and clone() methods (DG); + * 26-Jun-2008 : Fixed crosshair support (DG); + * 10-Jul-2008 : Fixed outline visibility for 3D renderers (DG); + * 12-Aug-2008 : Added rendererCount() method (DG); + * 25-Nov-2008 : Added facility to map datasets to multiples axes (DG); + * 15-Dec-2008 : Cleaned up grid drawing methods (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 21-Jan-2009 : Added rangeMinorGridlinesVisible flag (DG); + * 18-Mar-2009 : Modified anchored zoom behaviour (DG); + * 19-Mar-2009 : Implemented Pannable interface - see patch 2686040 (DG); + * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); + * 24-Jun-2009 : Implemented AnnotationChangeListener (see patch 2809117 by + * PK) (DG); + * 06-Jul-2009 : Fix for cloning of renderers - see bug 2817504 (DG) + * 10-Jul-2009 : Added optional drop shadow generator (DG); + * 27-Sep-2011 : Fixed annotation import (DG); + * 18-Oct-2011 : Fixed tooltip offset with shadow generator (DG); + * 20-Nov-2011 : Initialise shadow generator as null (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * 12-Sep-2013 : Check for KEY_SUPPRESS_SHADOW_GENERATION rendering hint (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.AlphaComposite; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Set; +import java.util.TreeMap; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.annotations.Annotation; +import org.jfree.chart.annotations.CategoryAnnotation; +import org.jfree.chart.axis.Axis; +import org.jfree.chart.axis.AxisCollection; +import org.jfree.chart.axis.AxisLocation; +import org.jfree.chart.axis.AxisSpace; +import org.jfree.chart.axis.AxisState; +import org.jfree.chart.axis.CategoryAnchor; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.TickType; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.axis.ValueTick; +import org.jfree.chart.event.AnnotationChangeEvent; +import org.jfree.chart.event.AnnotationChangeListener; +import org.jfree.chart.event.ChartChangeEventType; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.event.RendererChangeListener; +import org.jfree.chart.renderer.category.AbstractCategoryItemRenderer; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.renderer.category.CategoryItemRendererState; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.chart.util.ShadowGenerator; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.Dataset; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.Layer; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectList; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; +import org.jfree.util.SortOrder; + +/** + * A general plotting class that uses data from a {@link CategoryDataset} and + * renders each data item using a {@link CategoryItemRenderer}. + */ +public class CategoryPlot extends Plot implements ValueAxisPlot, Pannable, + Zoomable, AnnotationChangeListener, RendererChangeListener, + Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -3537691700434728188L; + + /** + * The default visibility of the grid lines plotted against the domain + * axis. + */ + public static final boolean DEFAULT_DOMAIN_GRIDLINES_VISIBLE = false; + + /** + * The default visibility of the grid lines plotted against the range + * axis. + */ + public static final boolean DEFAULT_RANGE_GRIDLINES_VISIBLE = true; + + /** The default grid line stroke. */ + public static final Stroke DEFAULT_GRIDLINE_STROKE = new BasicStroke(0.5f, + BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] + {2.0f, 2.0f}, 0.0f); + + /** The default grid line paint. */ + public static final Paint DEFAULT_GRIDLINE_PAINT = Color.lightGray; + + /** The default value label font. */ + public static final Font DEFAULT_VALUE_LABEL_FONT = new Font("SansSerif", + Font.PLAIN, 10); + + /** + * The default crosshair visibility. + * + * @since 1.0.5 + */ + public static final boolean DEFAULT_CROSSHAIR_VISIBLE = false; + + /** + * The default crosshair stroke. + * + * @since 1.0.5 + */ + public static final Stroke DEFAULT_CROSSHAIR_STROKE + = DEFAULT_GRIDLINE_STROKE; + + /** + * The default crosshair paint. + * + * @since 1.0.5 + */ + public static final Paint DEFAULT_CROSSHAIR_PAINT = Color.blue; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.plot.LocalizationBundle"); + + /** The plot orientation. */ + private PlotOrientation orientation; + + /** The offset between the data area and the axes. */ + private RectangleInsets axisOffset; + + /** Storage for the domain axes. */ + private ObjectList domainAxes; + + /** Storage for the domain axis locations. */ + private ObjectList domainAxisLocations; + + /** + * A flag that controls whether or not the shared domain axis is drawn + * (only relevant when the plot is being used as a subplot). + */ + private boolean drawSharedDomainAxis; + + /** Storage for the range axes. */ + private ObjectList rangeAxes; + + /** Storage for the range axis locations. */ + private ObjectList rangeAxisLocations; + + /** Storage for the datasets. */ + private ObjectList datasets; + + /** Storage for keys that map datasets to domain axes. */ + private TreeMap datasetToDomainAxesMap; + + /** Storage for keys that map datasets to range axes. */ + private TreeMap datasetToRangeAxesMap; + + /** Storage for the renderers. */ + private ObjectList renderers; + + /** The dataset rendering order. */ + private DatasetRenderingOrder renderingOrder + = DatasetRenderingOrder.REVERSE; + + /** + * Controls the order in which the columns are traversed when rendering the + * data items. + */ + private SortOrder columnRenderingOrder = SortOrder.ASCENDING; + + /** + * Controls the order in which the rows are traversed when rendering the + * data items. + */ + private SortOrder rowRenderingOrder = SortOrder.ASCENDING; + + /** + * A flag that controls whether the grid-lines for the domain axis are + * visible. + */ + private boolean domainGridlinesVisible; + + /** The position of the domain gridlines relative to the category. */ + private CategoryAnchor domainGridlinePosition; + + /** The stroke used to draw the domain grid-lines. */ + private transient Stroke domainGridlineStroke; + + /** The paint used to draw the domain grid-lines. */ + private transient Paint domainGridlinePaint; + + /** + * A flag that controls whether or not the zero baseline against the range + * axis is visible. + * + * @since 1.0.13 + */ + private boolean rangeZeroBaselineVisible; + + /** + * The stroke used for the zero baseline against the range axis. + * + * @since 1.0.13 + */ + private transient Stroke rangeZeroBaselineStroke; + + /** + * The paint used for the zero baseline against the range axis. + * + * @since 1.0.13 + */ + private transient Paint rangeZeroBaselinePaint; + + /** + * A flag that controls whether the grid-lines for the range axis are + * visible. + */ + private boolean rangeGridlinesVisible; + + /** The stroke used to draw the range axis grid-lines. */ + private transient Stroke rangeGridlineStroke; + + /** The paint used to draw the range axis grid-lines. */ + private transient Paint rangeGridlinePaint; + + /** + * A flag that controls whether or not gridlines are shown for the minor + * tick values on the primary range axis. + * + * @since 1.0.13 + */ + private boolean rangeMinorGridlinesVisible; + + /** + * The stroke used to draw the range minor grid-lines. + * + * @since 1.0.13 + */ + private transient Stroke rangeMinorGridlineStroke; + + /** + * The paint used to draw the range minor grid-lines. + * + * @since 1.0.13 + */ + private transient Paint rangeMinorGridlinePaint; + + /** The anchor value. */ + private double anchorValue; + + /** + * The index for the dataset that the crosshairs are linked to (this + * determines which axes the crosshairs are plotted against). + * + * @since 1.0.11 + */ + private int crosshairDatasetIndex; + + /** + * A flag that controls the visibility of the domain crosshair. + * + * @since 1.0.11 + */ + private boolean domainCrosshairVisible; + + /** + * The row key for the crosshair point. + * + * @since 1.0.11 + */ + private Comparable domainCrosshairRowKey; + + /** + * The column key for the crosshair point. + * + * @since 1.0.11 + */ + private Comparable domainCrosshairColumnKey; + + /** + * The stroke used to draw the domain crosshair if it is visible. + * + * @since 1.0.11 + */ + private transient Stroke domainCrosshairStroke; + + /** + * The paint used to draw the domain crosshair if it is visible. + * + * @since 1.0.11 + */ + private transient Paint domainCrosshairPaint; + + /** A flag that controls whether or not a range crosshair is drawn. */ + private boolean rangeCrosshairVisible; + + /** The range crosshair value. */ + private double rangeCrosshairValue; + + /** The pen/brush used to draw the crosshair (if any). */ + private transient Stroke rangeCrosshairStroke; + + /** The color used to draw the crosshair (if any). */ + private transient Paint rangeCrosshairPaint; + + /** + * A flag that controls whether or not the crosshair locks onto actual + * data points. + */ + private boolean rangeCrosshairLockedOnData = true; + + /** A map containing lists of markers for the domain axes. */ + private Map foregroundDomainMarkers; + + /** A map containing lists of markers for the domain axes. */ + private Map backgroundDomainMarkers; + + /** A map containing lists of markers for the range axes. */ + private Map foregroundRangeMarkers; + + /** A map containing lists of markers for the range axes. */ + private Map backgroundRangeMarkers; + + /** + * A (possibly empty) list of annotations for the plot. The list should + * be initialised in the constructor and never allowed to be + * null. + */ + private List annotations; + + /** + * The weight for the plot (only relevant when the plot is used as a subplot + * within a combined plot). + */ + private int weight; + + /** The fixed space for the domain axis. */ + private AxisSpace fixedDomainAxisSpace; + + /** The fixed space for the range axis. */ + private AxisSpace fixedRangeAxisSpace; + + /** + * An optional collection of legend items that can be returned by the + * getLegendItems() method. + */ + private LegendItemCollection fixedLegendItems; + + /** + * A flag that controls whether or not panning is enabled for the + * range axis/axes. + * + * @since 1.0.13 + */ + private boolean rangePannable; + + /** + * The shadow generator for the plot (null permitted). + * + * @since 1.0.14 + */ + private ShadowGenerator shadowGenerator; + + /** + * Default constructor. + */ + public CategoryPlot() { + this(null, null, null, null); + } + + /** + * Creates a new plot. + * + * @param dataset the dataset (null permitted). + * @param domainAxis the domain axis (null permitted). + * @param rangeAxis the range axis (null permitted). + * @param renderer the item renderer (null permitted). + * + */ + public CategoryPlot(CategoryDataset dataset, + CategoryAxis domainAxis, + ValueAxis rangeAxis, + CategoryItemRenderer renderer) { + + super(); + + this.orientation = PlotOrientation.VERTICAL; + + // allocate storage for dataset, axes and renderers + this.domainAxes = new ObjectList(); + this.domainAxisLocations = new ObjectList(); + this.rangeAxes = new ObjectList(); + this.rangeAxisLocations = new ObjectList(); + + this.datasetToDomainAxesMap = new TreeMap(); + this.datasetToRangeAxesMap = new TreeMap(); + + this.renderers = new ObjectList(); + + this.datasets = new ObjectList(); + this.datasets.set(0, dataset); + if (dataset != null) { + dataset.addChangeListener(this); + } + + this.axisOffset = RectangleInsets.ZERO_INSETS; + + setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT, false); + setRangeAxisLocation(AxisLocation.TOP_OR_LEFT, false); + + this.renderers.set(0, renderer); + if (renderer != null) { + renderer.setPlot(this); + renderer.addChangeListener(this); + } + + this.domainAxes.set(0, domainAxis); + this.mapDatasetToDomainAxis(0, 0); + if (domainAxis != null) { + domainAxis.setPlot(this); + domainAxis.addChangeListener(this); + } + this.drawSharedDomainAxis = false; + + this.rangeAxes.set(0, rangeAxis); + this.mapDatasetToRangeAxis(0, 0); + if (rangeAxis != null) { + rangeAxis.setPlot(this); + rangeAxis.addChangeListener(this); + } + + configureDomainAxes(); + configureRangeAxes(); + + this.domainGridlinesVisible = DEFAULT_DOMAIN_GRIDLINES_VISIBLE; + this.domainGridlinePosition = CategoryAnchor.MIDDLE; + this.domainGridlineStroke = DEFAULT_GRIDLINE_STROKE; + this.domainGridlinePaint = DEFAULT_GRIDLINE_PAINT; + + this.rangeZeroBaselineVisible = false; + this.rangeZeroBaselinePaint = Color.black; + this.rangeZeroBaselineStroke = new BasicStroke(0.5f); + + this.rangeGridlinesVisible = DEFAULT_RANGE_GRIDLINES_VISIBLE; + this.rangeGridlineStroke = DEFAULT_GRIDLINE_STROKE; + this.rangeGridlinePaint = DEFAULT_GRIDLINE_PAINT; + + this.rangeMinorGridlinesVisible = false; + this.rangeMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; + this.rangeMinorGridlinePaint = Color.white; + + this.foregroundDomainMarkers = new HashMap(); + this.backgroundDomainMarkers = new HashMap(); + this.foregroundRangeMarkers = new HashMap(); + this.backgroundRangeMarkers = new HashMap(); + + this.anchorValue = 0.0; + + this.domainCrosshairVisible = false; + this.domainCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; + this.domainCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; + + this.rangeCrosshairVisible = DEFAULT_CROSSHAIR_VISIBLE; + this.rangeCrosshairValue = 0.0; + this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; + this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; + + this.annotations = new java.util.ArrayList(); + + this.rangePannable = false; + this.shadowGenerator = null; + } + + /** + * Returns a string describing the type of plot. + * + * @return The type. + */ + @Override + public String getPlotType() { + return localizationResources.getString("Category_Plot"); + } + + /** + * Returns the orientation of the plot. + * + * @return The orientation of the plot (never null). + * + * @see #setOrientation(PlotOrientation) + */ + @Override + public PlotOrientation getOrientation() { + return this.orientation; + } + + /** + * Sets the orientation for the plot and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param orientation the orientation (null not permitted). + * + * @see #getOrientation() + */ + public void setOrientation(PlotOrientation orientation) { + ParamChecks.nullNotPermitted(orientation, "orientation"); + this.orientation = orientation; + fireChangeEvent(); + } + + /** + * Returns the axis offset. + * + * @return The axis offset (never null). + * + * @see #setAxisOffset(RectangleInsets) + */ + public RectangleInsets getAxisOffset() { + return this.axisOffset; + } + + /** + * Sets the axis offsets (gap between the data area and the axes) and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param offset the offset (null not permitted). + * + * @see #getAxisOffset() + */ + public void setAxisOffset(RectangleInsets offset) { + ParamChecks.nullNotPermitted(offset, "offset"); + this.axisOffset = offset; + fireChangeEvent(); + } + + /** + * Returns the domain axis for the plot. If the domain axis for this plot + * is null, then the method will return the parent plot's + * domain axis (if there is a parent plot). + * + * @return The domain axis (null permitted). + * + * @see #setDomainAxis(CategoryAxis) + */ + public CategoryAxis getDomainAxis() { + return getDomainAxis(0); + } + + /** + * Returns a domain axis. + * + * @param index the axis index. + * + * @return The axis (null possible). + * + * @see #setDomainAxis(int, CategoryAxis) + */ + public CategoryAxis getDomainAxis(int index) { + CategoryAxis result = null; + if (index < this.domainAxes.size()) { + result = (CategoryAxis) this.domainAxes.get(index); + } + if (result == null) { + Plot parent = getParent(); + if (parent instanceof CategoryPlot) { + CategoryPlot cp = (CategoryPlot) parent; + result = cp.getDomainAxis(index); + } + } + return result; + } + + /** + * Sets the domain axis for the plot and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param axis the axis (null permitted). + * + * @see #getDomainAxis() + */ + public void setDomainAxis(CategoryAxis axis) { + setDomainAxis(0, axis); + } + + /** + * Sets a domain axis and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param index the axis index. + * @param axis the axis (null permitted). + * + * @see #getDomainAxis(int) + */ + public void setDomainAxis(int index, CategoryAxis axis) { + setDomainAxis(index, axis, true); + } + + /** + * Sets a domain axis and, if requested, sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param index the axis index. + * @param axis the axis (null permitted). + * @param notify notify listeners? + */ + public void setDomainAxis(int index, CategoryAxis axis, boolean notify) { + CategoryAxis existing = (CategoryAxis) this.domainAxes.get(index); + if (existing != null) { + existing.removeChangeListener(this); + } + if (axis != null) { + axis.setPlot(this); + } + this.domainAxes.set(index, axis); + if (axis != null) { + axis.configure(); + axis.addChangeListener(this); + } + if (notify) { + fireChangeEvent(); + } + } + + /** + * Sets the domain axes for this plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param axes the axes (null not permitted). + * + * @see #setRangeAxes(ValueAxis[]) + */ + public void setDomainAxes(CategoryAxis[] axes) { + for (int i = 0; i < axes.length; i++) { + setDomainAxis(i, axes[i], false); + } + fireChangeEvent(); + } + + /** + * Returns the index of the specified axis, or -1 if the axis + * is not assigned to the plot. + * + * @param axis the axis (null not permitted). + * + * @return The axis index. + * + * @see #getDomainAxis(int) + * @see #getRangeAxisIndex(ValueAxis) + * + * @since 1.0.3 + */ + public int getDomainAxisIndex(CategoryAxis axis) { + ParamChecks.nullNotPermitted(axis, "axis"); + return this.domainAxes.indexOf(axis); + } + + /** + * Returns the domain axis location for the primary domain axis. + * + * @return The location (never null). + * + * @see #getRangeAxisLocation() + */ + public AxisLocation getDomainAxisLocation() { + return getDomainAxisLocation(0); + } + + /** + * Returns the location for a domain axis. + * + * @param index the axis index. + * + * @return The location. + * + * @see #setDomainAxisLocation(int, AxisLocation) + */ + public AxisLocation getDomainAxisLocation(int index) { + AxisLocation result = null; + if (index < this.domainAxisLocations.size()) { + result = (AxisLocation) this.domainAxisLocations.get(index); + } + if (result == null) { + result = AxisLocation.getOpposite(getDomainAxisLocation(0)); + } + return result; + } + + /** + * Sets the location of the domain axis and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param location the axis location (null not permitted). + * + * @see #getDomainAxisLocation() + * @see #setDomainAxisLocation(int, AxisLocation) + */ + public void setDomainAxisLocation(AxisLocation location) { + // delegate... + setDomainAxisLocation(0, location, true); + } + + /** + * Sets the location of the domain axis and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param location the axis location (null not permitted). + * @param notify a flag that controls whether listeners are notified. + */ + public void setDomainAxisLocation(AxisLocation location, boolean notify) { + // delegate... + setDomainAxisLocation(0, location, notify); + } + + /** + * Sets the location for a domain axis and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param index the axis index. + * @param location the location. + * + * @see #getDomainAxisLocation(int) + * @see #setRangeAxisLocation(int, AxisLocation) + */ + public void setDomainAxisLocation(int index, AxisLocation location) { + // delegate... + setDomainAxisLocation(index, location, true); + } + + /** + * Sets the location for a domain axis and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param index the axis index. + * @param location the location. + * @param notify notify listeners? + * + * @since 1.0.5 + * + * @see #getDomainAxisLocation(int) + * @see #setRangeAxisLocation(int, AxisLocation, boolean) + */ + public void setDomainAxisLocation(int index, AxisLocation location, + boolean notify) { + if (index == 0 && location == null) { + throw new IllegalArgumentException( + "Null 'location' for index 0 not permitted."); + } + this.domainAxisLocations.set(index, location); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the domain axis edge. This is derived from the axis location + * and the plot orientation. + * + * @return The edge (never null). + */ + public RectangleEdge getDomainAxisEdge() { + return getDomainAxisEdge(0); + } + + /** + * Returns the edge for a domain axis. + * + * @param index the axis index. + * + * @return The edge (never null). + */ + public RectangleEdge getDomainAxisEdge(int index) { + RectangleEdge result; + AxisLocation location = getDomainAxisLocation(index); + if (location != null) { + result = Plot.resolveDomainAxisLocation(location, this.orientation); + } + else { + result = RectangleEdge.opposite(getDomainAxisEdge(0)); + } + return result; + } + + /** + * Returns the number of domain axes. + * + * @return The axis count. + */ + public int getDomainAxisCount() { + return this.domainAxes.size(); + } + + /** + * Clears the domain axes from the plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + */ + public void clearDomainAxes() { + for (int i = 0; i < this.domainAxes.size(); i++) { + CategoryAxis axis = (CategoryAxis) this.domainAxes.get(i); + if (axis != null) { + axis.removeChangeListener(this); + } + } + this.domainAxes.clear(); + fireChangeEvent(); + } + + /** + * Configures the domain axes. + */ + public void configureDomainAxes() { + for (int i = 0; i < this.domainAxes.size(); i++) { + CategoryAxis axis = (CategoryAxis) this.domainAxes.get(i); + if (axis != null) { + axis.configure(); + } + } + } + + /** + * Returns the range axis for the plot. If the range axis for this plot is + * null, then the method will return the parent plot's range axis (if there + * is a parent plot). + * + * @return The range axis (possibly null). + */ + public ValueAxis getRangeAxis() { + return getRangeAxis(0); + } + + /** + * Returns a range axis. + * + * @param index the axis index. + * + * @return The axis (null possible). + */ + public ValueAxis getRangeAxis(int index) { + ValueAxis result = null; + if (index < this.rangeAxes.size()) { + result = (ValueAxis) this.rangeAxes.get(index); + } + if (result == null) { + Plot parent = getParent(); + if (parent instanceof CategoryPlot) { + CategoryPlot cp = (CategoryPlot) parent; + result = cp.getRangeAxis(index); + } + } + return result; + } + + /** + * Sets the range axis for the plot and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param axis the axis (null permitted). + */ + public void setRangeAxis(ValueAxis axis) { + setRangeAxis(0, axis); + } + + /** + * Sets a range axis and sends a {@link PlotChangeEvent} to all registered + * listeners. + * + * @param index the axis index. + * @param axis the axis. + */ + public void setRangeAxis(int index, ValueAxis axis) { + setRangeAxis(index, axis, true); + } + + /** + * Sets a range axis and, if requested, sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param index the axis index. + * @param axis the axis. + * @param notify notify listeners? + */ + public void setRangeAxis(int index, ValueAxis axis, boolean notify) { + ValueAxis existing = (ValueAxis) this.rangeAxes.get(index); + if (existing != null) { + existing.removeChangeListener(this); + } + if (axis != null) { + axis.setPlot(this); + } + this.rangeAxes.set(index, axis); + if (axis != null) { + axis.configure(); + axis.addChangeListener(this); + } + if (notify) { + fireChangeEvent(); + } + } + + /** + * Sets the range axes for this plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param axes the axes (null not permitted). + * + * @see #setDomainAxes(CategoryAxis[]) + */ + public void setRangeAxes(ValueAxis[] axes) { + for (int i = 0; i < axes.length; i++) { + setRangeAxis(i, axes[i], false); + } + fireChangeEvent(); + } + + /** + * Returns the index of the specified axis, or -1 if the axis + * is not assigned to the plot. + * + * @param axis the axis (null not permitted). + * + * @return The axis index. + * + * @see #getRangeAxis(int) + * @see #getDomainAxisIndex(CategoryAxis) + * + * @since 1.0.7 + */ + public int getRangeAxisIndex(ValueAxis axis) { + ParamChecks.nullNotPermitted(axis, "axis"); + int result = this.rangeAxes.indexOf(axis); + if (result < 0) { // try the parent plot + Plot parent = getParent(); + if (parent instanceof CategoryPlot) { + CategoryPlot p = (CategoryPlot) parent; + result = p.getRangeAxisIndex(axis); + } + } + return result; + } + + /** + * Returns the range axis location. + * + * @return The location (never null). + */ + public AxisLocation getRangeAxisLocation() { + return getRangeAxisLocation(0); + } + + /** + * Returns the location for a range axis. + * + * @param index the axis index. + * + * @return The location. + * + * @see #setRangeAxisLocation(int, AxisLocation) + */ + public AxisLocation getRangeAxisLocation(int index) { + AxisLocation result = null; + if (index < this.rangeAxisLocations.size()) { + result = (AxisLocation) this.rangeAxisLocations.get(index); + } + if (result == null) { + result = AxisLocation.getOpposite(getRangeAxisLocation(0)); + } + return result; + } + + /** + * Sets the location of the range axis and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param location the location (null not permitted). + * + * @see #setRangeAxisLocation(AxisLocation, boolean) + * @see #setDomainAxisLocation(AxisLocation) + */ + public void setRangeAxisLocation(AxisLocation location) { + // defer argument checking... + setRangeAxisLocation(location, true); + } + + /** + * Sets the location of the range axis and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param location the location (null not permitted). + * @param notify notify listeners? + * + * @see #setDomainAxisLocation(AxisLocation, boolean) + */ + public void setRangeAxisLocation(AxisLocation location, boolean notify) { + setRangeAxisLocation(0, location, notify); + } + + /** + * Sets the location for a range axis and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param index the axis index. + * @param location the location. + * + * @see #getRangeAxisLocation(int) + * @see #setRangeAxisLocation(int, AxisLocation, boolean) + */ + public void setRangeAxisLocation(int index, AxisLocation location) { + setRangeAxisLocation(index, location, true); + } + + /** + * Sets the location for a range axis and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param index the axis index. + * @param location the location. + * @param notify notify listeners? + * + * @see #getRangeAxisLocation(int) + * @see #setDomainAxisLocation(int, AxisLocation, boolean) + */ + public void setRangeAxisLocation(int index, AxisLocation location, + boolean notify) { + if (index == 0 && location == null) { + throw new IllegalArgumentException( + "Null 'location' for index 0 not permitted."); + } + this.rangeAxisLocations.set(index, location); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the edge where the primary range axis is located. + * + * @return The edge (never null). + */ + public RectangleEdge getRangeAxisEdge() { + return getRangeAxisEdge(0); + } + + /** + * Returns the edge for a range axis. + * + * @param index the axis index. + * + * @return The edge. + */ + public RectangleEdge getRangeAxisEdge(int index) { + AxisLocation location = getRangeAxisLocation(index); + return Plot.resolveRangeAxisLocation(location, this.orientation); + } + + /** + * Returns the number of range axes. + * + * @return The axis count. + */ + public int getRangeAxisCount() { + return this.rangeAxes.size(); + } + + /** + * Clears the range axes from the plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + */ + public void clearRangeAxes() { + for (int i = 0; i < this.rangeAxes.size(); i++) { + ValueAxis axis = (ValueAxis) this.rangeAxes.get(i); + if (axis != null) { + axis.removeChangeListener(this); + } + } + this.rangeAxes.clear(); + fireChangeEvent(); + } + + /** + * Configures the range axes. + */ + public void configureRangeAxes() { + for (int i = 0; i < this.rangeAxes.size(); i++) { + ValueAxis axis = (ValueAxis) this.rangeAxes.get(i); + if (axis != null) { + axis.configure(); + } + } + } + + /** + * Returns the primary dataset for the plot. + * + * @return The primary dataset (possibly null). + * + * @see #setDataset(CategoryDataset) + */ + public CategoryDataset getDataset() { + return getDataset(0); + } + + /** + * Returns the dataset at the given index. + * + * @param index the dataset index. + * + * @return The dataset (possibly null). + * + * @see #setDataset(int, CategoryDataset) + */ + public CategoryDataset getDataset(int index) { + CategoryDataset result = null; + if (this.datasets.size() > index) { + result = (CategoryDataset) this.datasets.get(index); + } + return result; + } + + /** + * Sets the dataset for the plot, replacing the existing dataset, if there + * is one. This method also calls the + * {@link #datasetChanged(DatasetChangeEvent)} method, which adjusts the + * axis ranges if necessary and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param dataset the dataset (null permitted). + * + * @see #getDataset() + */ + public void setDataset(CategoryDataset dataset) { + setDataset(0, dataset); + } + + /** + * Sets a dataset for the plot. + * + * @param index the dataset index. + * @param dataset the dataset (null permitted). + * + * @see #getDataset(int) + */ + public void setDataset(int index, CategoryDataset dataset) { + + CategoryDataset existing = (CategoryDataset) this.datasets.get(index); + if (existing != null) { + existing.removeChangeListener(this); + } + this.datasets.set(index, dataset); + if (dataset != null) { + dataset.addChangeListener(this); + } + + // send a dataset change event to self... + DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); + datasetChanged(event); + + } + + /** + * Returns the number of datasets. + * + * @return The number of datasets. + * + * @since 1.0.2 + */ + public int getDatasetCount() { + return this.datasets.size(); + } + + /** + * Returns the index of the specified dataset, or -1 if the + * dataset does not belong to the plot. + * + * @param dataset the dataset (null not permitted). + * + * @return The index. + * + * @since 1.0.11 + */ + public int indexOf(CategoryDataset dataset) { + int result = -1; + for (int i = 0; i < this.datasets.size(); i++) { + if (dataset == this.datasets.get(i)) { + result = i; + break; + } + } + return result; + } + + /** + * Maps a dataset to a particular domain axis. + * + * @param index the dataset index (zero-based). + * @param axisIndex the axis index (zero-based). + * + * @see #getDomainAxisForDataset(int) + */ + public void mapDatasetToDomainAxis(int index, int axisIndex) { + List axisIndices = new java.util.ArrayList(1); + axisIndices.add(new Integer(axisIndex)); + mapDatasetToDomainAxes(index, axisIndices); + } + + /** + * Maps the specified dataset to the axes in the list. Note that the + * conversion of data values into Java2D space is always performed using + * the first axis in the list. + * + * @param index the dataset index (zero-based). + * @param axisIndices the axis indices (null permitted). + * + * @since 1.0.12 + */ + public void mapDatasetToDomainAxes(int index, List axisIndices) { + if (index < 0) { + throw new IllegalArgumentException("Requires 'index' >= 0."); + } + checkAxisIndices(axisIndices); + Integer key = new Integer(index); + this.datasetToDomainAxesMap.put(key, new ArrayList(axisIndices)); + // fake a dataset change event to update axes... + datasetChanged(new DatasetChangeEvent(this, getDataset(index))); + } + + /** + * This method is used to perform argument checking on the list of + * axis indices passed to mapDatasetToDomainAxes() and + * mapDatasetToRangeAxes(). + * + * @param indices the list of indices (null permitted). + */ + private void checkAxisIndices(List indices) { + // axisIndices can be: + // 1. null; + // 2. non-empty, containing only Integer objects that are unique. + if (indices == null) { + return; // OK + } + int count = indices.size(); + if (count == 0) { + throw new IllegalArgumentException("Empty list not permitted."); + } + HashSet set = new HashSet(); + for (int i = 0; i < count; i++) { + Object item = indices.get(i); + if (!(item instanceof Integer)) { + throw new IllegalArgumentException( + "Indices must be Integer instances."); + } + if (set.contains(item)) { + throw new IllegalArgumentException("Indices must be unique."); + } + set.add(item); + } + } + + /** + * Returns the domain axis for a dataset. You can change the axis for a + * dataset using the {@link #mapDatasetToDomainAxis(int, int)} method. + * + * @param index the dataset index. + * + * @return The domain axis. + * + * @see #mapDatasetToDomainAxis(int, int) + */ + public CategoryAxis getDomainAxisForDataset(int index) { + if (index < 0) { + throw new IllegalArgumentException("Negative 'index'."); + } + CategoryAxis axis; + List axisIndices = (List) this.datasetToDomainAxesMap.get( + new Integer(index)); + if (axisIndices != null) { + // the first axis in the list is used for data <--> Java2D + Integer axisIndex = (Integer) axisIndices.get(0); + axis = getDomainAxis(axisIndex.intValue()); + } + else { + axis = getDomainAxis(0); + } + return axis; + } + + /** + * Maps a dataset to a particular range axis. + * + * @param index the dataset index (zero-based). + * @param axisIndex the axis index (zero-based). + * + * @see #getRangeAxisForDataset(int) + */ + public void mapDatasetToRangeAxis(int index, int axisIndex) { + List axisIndices = new java.util.ArrayList(1); + axisIndices.add(new Integer(axisIndex)); + mapDatasetToRangeAxes(index, axisIndices); + } + + /** + * Maps the specified dataset to the axes in the list. Note that the + * conversion of data values into Java2D space is always performed using + * the first axis in the list. + * + * @param index the dataset index (zero-based). + * @param axisIndices the axis indices (null permitted). + * + * @since 1.0.12 + */ + public void mapDatasetToRangeAxes(int index, List axisIndices) { + if (index < 0) { + throw new IllegalArgumentException("Requires 'index' >= 0."); + } + checkAxisIndices(axisIndices); + Integer key = new Integer(index); + this.datasetToRangeAxesMap.put(key, new ArrayList(axisIndices)); + // fake a dataset change event to update axes... + datasetChanged(new DatasetChangeEvent(this, getDataset(index))); + } + + /** + * Returns the range axis for a dataset. You can change the axis for a + * dataset using the {@link #mapDatasetToRangeAxis(int, int)} method. + * + * @param index the dataset index. + * + * @return The range axis. + * + * @see #mapDatasetToRangeAxis(int, int) + */ + public ValueAxis getRangeAxisForDataset(int index) { + if (index < 0) { + throw new IllegalArgumentException("Negative 'index'."); + } + ValueAxis axis = null; + List axisIndices = (List) this.datasetToRangeAxesMap.get( + new Integer(index)); + if (axisIndices != null) { + // the first axis in the list is used for data <--> Java2D + Integer axisIndex = (Integer) axisIndices.get(0); + axis = getRangeAxis(axisIndex.intValue()); + } + else { + axis = getRangeAxis(0); + } + return axis; + } + + /** + * Returns the number of renderer slots for this plot. + * + * @return The number of renderer slots. + * + * @since 1.0.11 + */ + public int getRendererCount() { + return this.renderers.size(); + } + + /** + * Returns a reference to the renderer for the plot. + * + * @return The renderer. + * + * @see #setRenderer(CategoryItemRenderer) + */ + public CategoryItemRenderer getRenderer() { + return getRenderer(0); + } + + /** + * Returns the renderer at the given index. + * + * @param index the renderer index. + * + * @return The renderer (possibly null). + * + * @see #setRenderer(int, CategoryItemRenderer) + */ + public CategoryItemRenderer getRenderer(int index) { + CategoryItemRenderer result = null; + if (this.renderers.size() > index) { + result = (CategoryItemRenderer) this.renderers.get(index); + } + return result; + } + + /** + * Sets the renderer at index 0 (sometimes referred to as the "primary" + * renderer) and sends a {@link PlotChangeEvent} to all registered + * listeners. + * + * @param renderer the renderer (null permitted. + * + * @see #getRenderer() + */ + public void setRenderer(CategoryItemRenderer renderer) { + setRenderer(0, renderer, true); + } + + /** + * Sets the renderer at index 0 (sometimes referred to as the "primary" + * renderer) and, if requested, sends a {@link PlotChangeEvent} to all + * registered listeners. + *

+ * You can set the renderer to null, but this is not + * recommended because: + *

    + *
  • no data will be displayed;
  • + *
  • the plot background will not be painted;
  • + *
+ * + * @param renderer the renderer (null permitted). + * @param notify notify listeners? + * + * @see #getRenderer() + */ + public void setRenderer(CategoryItemRenderer renderer, boolean notify) { + setRenderer(0, renderer, notify); + } + + /** + * Sets the renderer at the specified index and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the index. + * @param renderer the renderer (null permitted). + * + * @see #getRenderer(int) + * @see #setRenderer(int, CategoryItemRenderer, boolean) + */ + public void setRenderer(int index, CategoryItemRenderer renderer) { + setRenderer(index, renderer, true); + } + + /** + * Sets a renderer. A {@link PlotChangeEvent} is sent to all registered + * listeners. + * + * @param index the index. + * @param renderer the renderer (null permitted). + * @param notify notify listeners? + * + * @see #getRenderer(int) + */ + public void setRenderer(int index, CategoryItemRenderer renderer, + boolean notify) { + + // stop listening to the existing renderer... + CategoryItemRenderer existing + = (CategoryItemRenderer) this.renderers.get(index); + if (existing != null) { + existing.removeChangeListener(this); + } + + // register the new renderer... + this.renderers.set(index, renderer); + if (renderer != null) { + renderer.setPlot(this); + renderer.addChangeListener(this); + } + + configureDomainAxes(); + configureRangeAxes(); + + if (notify) { + fireChangeEvent(); + } + } + + /** + * Sets the renderers for this plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param renderers the renderers. + */ + public void setRenderers(CategoryItemRenderer[] renderers) { + for (int i = 0; i < renderers.length; i++) { + setRenderer(i, renderers[i], false); + } + fireChangeEvent(); + } + + /** + * Returns the renderer for the specified dataset. If the dataset doesn't + * belong to the plot, this method will return null. + * + * @param dataset the dataset (null permitted). + * + * @return The renderer (possibly null). + */ + public CategoryItemRenderer getRendererForDataset(CategoryDataset dataset) { + CategoryItemRenderer result = null; + for (int i = 0; i < this.datasets.size(); i++) { + if (this.datasets.get(i) == dataset) { + result = (CategoryItemRenderer) this.renderers.get(i); + break; + } + } + return result; + } + + /** + * Returns the index of the specified renderer, or -1 if the + * renderer is not assigned to this plot. + * + * @param renderer the renderer (null permitted). + * + * @return The renderer index. + */ + public int getIndexOf(CategoryItemRenderer renderer) { + return this.renderers.indexOf(renderer); + } + + /** + * Returns the dataset rendering order. + * + * @return The order (never null). + * + * @see #setDatasetRenderingOrder(DatasetRenderingOrder) + */ + public DatasetRenderingOrder getDatasetRenderingOrder() { + return this.renderingOrder; + } + + /** + * Sets the rendering order and sends a {@link PlotChangeEvent} to all + * registered listeners. By default, the plot renders the primary dataset + * last (so that the primary dataset overlays the secondary datasets). You + * can reverse this if you want to. + * + * @param order the rendering order (null not permitted). + * + * @see #getDatasetRenderingOrder() + */ + public void setDatasetRenderingOrder(DatasetRenderingOrder order) { + ParamChecks.nullNotPermitted(order, "order"); + this.renderingOrder = order; + fireChangeEvent(); + } + + /** + * Returns the order in which the columns are rendered. The default value + * is SortOrder.ASCENDING. + * + * @return The column rendering order (never null). + * + * @see #setColumnRenderingOrder(SortOrder) + */ + public SortOrder getColumnRenderingOrder() { + return this.columnRenderingOrder; + } + + /** + * Sets the column order in which the items in each dataset should be + * rendered and sends a {@link PlotChangeEvent} to all registered + * listeners. Note that this affects the order in which items are drawn, + * NOT their position in the chart. + * + * @param order the order (null not permitted). + * + * @see #getColumnRenderingOrder() + * @see #setRowRenderingOrder(SortOrder) + */ + public void setColumnRenderingOrder(SortOrder order) { + ParamChecks.nullNotPermitted(order, "order"); + this.columnRenderingOrder = order; + fireChangeEvent(); + } + + /** + * Returns the order in which the rows should be rendered. The default + * value is SortOrder.ASCENDING. + * + * @return The order (never null). + * + * @see #setRowRenderingOrder(SortOrder) + */ + public SortOrder getRowRenderingOrder() { + return this.rowRenderingOrder; + } + + /** + * Sets the row order in which the items in each dataset should be + * rendered and sends a {@link PlotChangeEvent} to all registered + * listeners. Note that this affects the order in which items are drawn, + * NOT their position in the chart. + * + * @param order the order (null not permitted). + * + * @see #getRowRenderingOrder() + * @see #setColumnRenderingOrder(SortOrder) + */ + public void setRowRenderingOrder(SortOrder order) { + ParamChecks.nullNotPermitted(order, "order"); + this.rowRenderingOrder = order; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether the domain grid-lines are visible. + * + * @return The true or false. + * + * @see #setDomainGridlinesVisible(boolean) + */ + public boolean isDomainGridlinesVisible() { + return this.domainGridlinesVisible; + } + + /** + * Sets the flag that controls whether or not grid-lines are drawn against + * the domain axis. + *

+ * If the flag value changes, a {@link PlotChangeEvent} is sent to all + * registered listeners. + * + * @param visible the new value of the flag. + * + * @see #isDomainGridlinesVisible() + */ + public void setDomainGridlinesVisible(boolean visible) { + if (this.domainGridlinesVisible != visible) { + this.domainGridlinesVisible = visible; + fireChangeEvent(); + } + } + + /** + * Returns the position used for the domain gridlines. + * + * @return The gridline position (never null). + * + * @see #setDomainGridlinePosition(CategoryAnchor) + */ + public CategoryAnchor getDomainGridlinePosition() { + return this.domainGridlinePosition; + } + + /** + * Sets the position used for the domain gridlines and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param position the position (null not permitted). + * + * @see #getDomainGridlinePosition() + */ + public void setDomainGridlinePosition(CategoryAnchor position) { + ParamChecks.nullNotPermitted(position, "position"); + this.domainGridlinePosition = position; + fireChangeEvent(); + } + + /** + * Returns the stroke used to draw grid-lines against the domain axis. + * + * @return The stroke (never null). + * + * @see #setDomainGridlineStroke(Stroke) + */ + public Stroke getDomainGridlineStroke() { + return this.domainGridlineStroke; + } + + /** + * Sets the stroke used to draw grid-lines against the domain axis and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getDomainGridlineStroke() + */ + public void setDomainGridlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.domainGridlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw grid-lines against the domain axis. + * + * @return The paint (never null). + * + * @see #setDomainGridlinePaint(Paint) + */ + public Paint getDomainGridlinePaint() { + return this.domainGridlinePaint; + } + + /** + * Sets the paint used to draw the grid-lines (if any) against the domain + * axis and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getDomainGridlinePaint() + */ + public void setDomainGridlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.domainGridlinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns a flag that controls whether or not a zero baseline is + * displayed for the range axis. + * + * @return A boolean. + * + * @see #setRangeZeroBaselineVisible(boolean) + * + * @since 1.0.13 + */ + public boolean isRangeZeroBaselineVisible() { + return this.rangeZeroBaselineVisible; + } + + /** + * Sets the flag that controls whether or not the zero baseline is + * displayed for the range axis, and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param visible the flag. + * + * @see #isRangeZeroBaselineVisible() + * + * @since 1.0.13 + */ + public void setRangeZeroBaselineVisible(boolean visible) { + this.rangeZeroBaselineVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the stroke used for the zero baseline against the range axis. + * + * @return The stroke (never null). + * + * @see #setRangeZeroBaselineStroke(Stroke) + * + * @since 1.0.13 + */ + public Stroke getRangeZeroBaselineStroke() { + return this.rangeZeroBaselineStroke; + } + + /** + * Sets the stroke for the zero baseline for the range axis, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getRangeZeroBaselineStroke() + * + * @since 1.0.13 + */ + public void setRangeZeroBaselineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.rangeZeroBaselineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint for the zero baseline (if any) plotted against the + * range axis. + * + * @return The paint (never null). + * + * @see #setRangeZeroBaselinePaint(Paint) + * + * @since 1.0.13 + */ + public Paint getRangeZeroBaselinePaint() { + return this.rangeZeroBaselinePaint; + } + + /** + * Sets the paint for the zero baseline plotted against the range axis and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getRangeZeroBaselinePaint() + * + * @since 1.0.13 + */ + public void setRangeZeroBaselinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.rangeZeroBaselinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether the range grid-lines are visible. + * + * @return The flag. + * + * @see #setRangeGridlinesVisible(boolean) + */ + public boolean isRangeGridlinesVisible() { + return this.rangeGridlinesVisible; + } + + /** + * Sets the flag that controls whether or not grid-lines are drawn against + * the range axis. If the flag changes value, a {@link PlotChangeEvent} is + * sent to all registered listeners. + * + * @param visible the new value of the flag. + * + * @see #isRangeGridlinesVisible() + */ + public void setRangeGridlinesVisible(boolean visible) { + if (this.rangeGridlinesVisible != visible) { + this.rangeGridlinesVisible = visible; + fireChangeEvent(); + } + } + + /** + * Returns the stroke used to draw the grid-lines against the range axis. + * + * @return The stroke (never null). + * + * @see #setRangeGridlineStroke(Stroke) + */ + public Stroke getRangeGridlineStroke() { + return this.rangeGridlineStroke; + } + + /** + * Sets the stroke used to draw the grid-lines against the range axis and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getRangeGridlineStroke() + */ + public void setRangeGridlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.rangeGridlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw the grid-lines against the range axis. + * + * @return The paint (never null). + * + * @see #setRangeGridlinePaint(Paint) + */ + public Paint getRangeGridlinePaint() { + return this.rangeGridlinePaint; + } + + /** + * Sets the paint used to draw the grid lines against the range axis and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getRangeGridlinePaint() + */ + public void setRangeGridlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.rangeGridlinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns true if the range axis minor grid is visible, and + * false otherwise. + * + * @return A boolean. + * + * @see #setRangeMinorGridlinesVisible(boolean) + * + * @since 1.0.13 + */ + public boolean isRangeMinorGridlinesVisible() { + return this.rangeMinorGridlinesVisible; + } + + /** + * Sets the flag that controls whether or not the range axis minor grid + * lines are visible. + *

+ * If the flag value is changed, a {@link PlotChangeEvent} is sent to all + * registered listeners. + * + * @param visible the new value of the flag. + * + * @see #isRangeMinorGridlinesVisible() + * + * @since 1.0.13 + */ + public void setRangeMinorGridlinesVisible(boolean visible) { + if (this.rangeMinorGridlinesVisible != visible) { + this.rangeMinorGridlinesVisible = visible; + fireChangeEvent(); + } + } + + /** + * Returns the stroke for the minor grid lines (if any) plotted against the + * range axis. + * + * @return The stroke (never null). + * + * @see #setRangeMinorGridlineStroke(Stroke) + * + * @since 1.0.13 + */ + public Stroke getRangeMinorGridlineStroke() { + return this.rangeMinorGridlineStroke; + } + + /** + * Sets the stroke for the minor grid lines plotted against the range axis, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getRangeMinorGridlineStroke() + * + * @since 1.0.13 + */ + public void setRangeMinorGridlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.rangeMinorGridlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint for the minor grid lines (if any) plotted against the + * range axis. + * + * @return The paint (never null). + * + * @see #setRangeMinorGridlinePaint(Paint) + * + * @since 1.0.13 + */ + public Paint getRangeMinorGridlinePaint() { + return this.rangeMinorGridlinePaint; + } + + /** + * Sets the paint for the minor grid lines plotted against the range axis + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getRangeMinorGridlinePaint() + * + * @since 1.0.13 + */ + public void setRangeMinorGridlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.rangeMinorGridlinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the fixed legend items, if any. + * + * @return The legend items (possibly null). + * + * @see #setFixedLegendItems(LegendItemCollection) + */ + public LegendItemCollection getFixedLegendItems() { + return this.fixedLegendItems; + } + + /** + * Sets the fixed legend items for the plot. Leave this set to + * null if you prefer the legend items to be created + * automatically. + * + * @param items the legend items (null permitted). + * + * @see #getFixedLegendItems() + */ + public void setFixedLegendItems(LegendItemCollection items) { + this.fixedLegendItems = items; + fireChangeEvent(); + } + + /** + * Returns the legend items for the plot. By default, this method creates + * a legend item for each series in each of the datasets. You can change + * this behaviour by overriding this method. + * + * @return The legend items. + */ + @Override + public LegendItemCollection getLegendItems() { + if (this.fixedLegendItems != null) { + return this.fixedLegendItems; + } + LegendItemCollection result = new LegendItemCollection(); + // get the legend items for the datasets... + int count = this.datasets.size(); + for (int datasetIndex = 0; datasetIndex < count; datasetIndex++) { + CategoryDataset dataset = getDataset(datasetIndex); + if (dataset != null) { + CategoryItemRenderer renderer = getRenderer(datasetIndex); + if (renderer != null) { + result.addAll(renderer.getLegendItems()); + } + } + } + return result; + } + + /** + * Handles a 'click' on the plot by updating the anchor value. + * + * @param x x-coordinate of the click (in Java2D space). + * @param y y-coordinate of the click (in Java2D space). + * @param info information about the plot's dimensions. + * + */ + @Override + public void handleClick(int x, int y, PlotRenderingInfo info) { + + Rectangle2D dataArea = info.getDataArea(); + if (dataArea.contains(x, y)) { + // set the anchor value for the range axis... + double java2D = 0.0; + if (this.orientation == PlotOrientation.HORIZONTAL) { + java2D = x; + } + else if (this.orientation == PlotOrientation.VERTICAL) { + java2D = y; + } + RectangleEdge edge = Plot.resolveRangeAxisLocation( + getRangeAxisLocation(), this.orientation); + double value = getRangeAxis().java2DToValue( + java2D, info.getDataArea(), edge); + setAnchorValue(value); + setRangeCrosshairValue(value); + } + + } + + /** + * Zooms (in or out) on the plot's value axis. + *

+ * If the value 0.0 is passed in as the zoom percent, the auto-range + * calculation for the axis is restored (which sets the range to include + * the minimum and maximum data values, thus displaying all the data). + * + * @param percent the zoom amount. + */ + @Override + public void zoom(double percent) { + + if (percent > 0.0) { + double range = getRangeAxis().getRange().getLength(); + double scaledRange = range * percent; + getRangeAxis().setRange(this.anchorValue - scaledRange / 2.0, + this.anchorValue + scaledRange / 2.0); + } + else { + getRangeAxis().setAutoRange(true); + } + + } + + /** + * Receives notification of a change to an {@link Annotation} added to + * this plot. + * + * @param event information about the event (not used here). + * + * @since 1.0.14 + */ + @Override + public void annotationChanged(AnnotationChangeEvent event) { + if (getParent() != null) { + getParent().annotationChanged(event); + } + else { + PlotChangeEvent e = new PlotChangeEvent(this); + notifyListeners(e); + } + } + + /** + * Receives notification of a change to the plot's dataset. + *

+ * The range axis bounds will be recalculated if necessary. + * + * @param event information about the event (not used here). + */ + @Override + public void datasetChanged(DatasetChangeEvent event) { + + int count = this.rangeAxes.size(); + for (int axisIndex = 0; axisIndex < count; axisIndex++) { + ValueAxis yAxis = getRangeAxis(axisIndex); + if (yAxis != null) { + yAxis.configure(); + } + } + if (getParent() != null) { + getParent().datasetChanged(event); + } + else { + PlotChangeEvent e = new PlotChangeEvent(this); + e.setType(ChartChangeEventType.DATASET_UPDATED); + notifyListeners(e); + } + + } + + /** + * Receives notification of a renderer change event. + * + * @param event the event. + */ + @Override + public void rendererChanged(RendererChangeEvent event) { + Plot parent = getParent(); + if (parent != null) { + if (parent instanceof RendererChangeListener) { + RendererChangeListener rcl = (RendererChangeListener) parent; + rcl.rendererChanged(event); + } + else { + // this should never happen with the existing code, but throw + // an exception in case future changes make it possible... + throw new RuntimeException( + "The renderer has changed and I don't know what to do!"); + } + } + else { + configureRangeAxes(); + PlotChangeEvent e = new PlotChangeEvent(this); + notifyListeners(e); + } + } + + /** + * Adds a marker for display (in the foreground) against the domain axis and + * sends a {@link PlotChangeEvent} to all registered listeners. Typically a + * marker will be drawn by the renderer as a line perpendicular to the + * domain axis, however this is entirely up to the renderer. + * + * @param marker the marker (null not permitted). + * + * @see #removeDomainMarker(Marker) + */ + public void addDomainMarker(CategoryMarker marker) { + addDomainMarker(marker, Layer.FOREGROUND); + } + + /** + * Adds a marker for display against the domain axis and sends a + * {@link PlotChangeEvent} to all registered listeners. Typically a marker + * will be drawn by the renderer as a line perpendicular to the domain + * axis, however this is entirely up to the renderer. + * + * @param marker the marker (null not permitted). + * @param layer the layer (foreground or background) (null + * not permitted). + * + * @see #removeDomainMarker(Marker, Layer) + */ + public void addDomainMarker(CategoryMarker marker, Layer layer) { + addDomainMarker(0, marker, layer); + } + + /** + * Adds a marker for display by a particular renderer and sends a + * {@link PlotChangeEvent} to all registered listeners. + *

+ * Typically a marker will be drawn by the renderer as a line perpendicular + * to a domain axis, however this is entirely up to the renderer. + * + * @param index the renderer index. + * @param marker the marker (null not permitted). + * @param layer the layer (null not permitted). + * + * @see #removeDomainMarker(int, Marker, Layer) + */ + public void addDomainMarker(int index, CategoryMarker marker, Layer layer) { + addDomainMarker(index, marker, layer, true); + } + + /** + * Adds a marker for display by a particular renderer and, if requested, + * sends a {@link PlotChangeEvent} to all registered listeners. + *

+ * Typically a marker will be drawn by the renderer as a line perpendicular + * to a domain axis, however this is entirely up to the renderer. + * + * @param index the renderer index. + * @param marker the marker (null not permitted). + * @param layer the layer (null not permitted). + * @param notify notify listeners? + * + * @since 1.0.10 + * + * @see #removeDomainMarker(int, Marker, Layer, boolean) + */ + public void addDomainMarker(int index, CategoryMarker marker, Layer layer, + boolean notify) { + ParamChecks.nullNotPermitted(marker, "marker"); + ParamChecks.nullNotPermitted(layer, "layer"); + Collection markers; + if (layer == Layer.FOREGROUND) { + markers = (Collection) this.foregroundDomainMarkers.get( + new Integer(index)); + if (markers == null) { + markers = new java.util.ArrayList(); + this.foregroundDomainMarkers.put(new Integer(index), markers); + } + markers.add(marker); + } + else if (layer == Layer.BACKGROUND) { + markers = (Collection) this.backgroundDomainMarkers.get( + new Integer(index)); + if (markers == null) { + markers = new java.util.ArrayList(); + this.backgroundDomainMarkers.put(new Integer(index), markers); + } + markers.add(marker); + } + marker.addChangeListener(this); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Clears all the domain markers for the plot and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @see #clearRangeMarkers() + */ + public void clearDomainMarkers() { + if (this.backgroundDomainMarkers != null) { + Set keys = this.backgroundDomainMarkers.keySet(); + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Integer key = (Integer) iterator.next(); + clearDomainMarkers(key.intValue()); + } + this.backgroundDomainMarkers.clear(); + } + if (this.foregroundDomainMarkers != null) { + Set keys = this.foregroundDomainMarkers.keySet(); + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Integer key = (Integer) iterator.next(); + clearDomainMarkers(key.intValue()); + } + this.foregroundDomainMarkers.clear(); + } + fireChangeEvent(); + } + + /** + * Returns the list of domain markers (read only) for the specified layer. + * + * @param layer the layer (foreground or background). + * + * @return The list of domain markers. + */ + public Collection getDomainMarkers(Layer layer) { + return getDomainMarkers(0, layer); + } + + /** + * Returns a collection of domain markers for a particular renderer and + * layer. + * + * @param index the renderer index. + * @param layer the layer. + * + * @return A collection of markers (possibly null). + */ + public Collection getDomainMarkers(int index, Layer layer) { + Collection result = null; + Integer key = new Integer(index); + if (layer == Layer.FOREGROUND) { + result = (Collection) this.foregroundDomainMarkers.get(key); + } + else if (layer == Layer.BACKGROUND) { + result = (Collection) this.backgroundDomainMarkers.get(key); + } + if (result != null) { + result = Collections.unmodifiableCollection(result); + } + return result; + } + + /** + * Clears all the domain markers for the specified renderer. + * + * @param index the renderer index. + * + * @see #clearRangeMarkers(int) + */ + public void clearDomainMarkers(int index) { + Integer key = new Integer(index); + if (this.backgroundDomainMarkers != null) { + Collection markers + = (Collection) this.backgroundDomainMarkers.get(key); + if (markers != null) { + Iterator iterator = markers.iterator(); + while (iterator.hasNext()) { + Marker m = (Marker) iterator.next(); + m.removeChangeListener(this); + } + markers.clear(); + } + } + if (this.foregroundDomainMarkers != null) { + Collection markers + = (Collection) this.foregroundDomainMarkers.get(key); + if (markers != null) { + Iterator iterator = markers.iterator(); + while (iterator.hasNext()) { + Marker m = (Marker) iterator.next(); + m.removeChangeListener(this); + } + markers.clear(); + } + } + fireChangeEvent(); + } + + /** + * Removes a marker for the domain axis and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param marker the marker. + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.7 + */ + public boolean removeDomainMarker(Marker marker) { + return removeDomainMarker(marker, Layer.FOREGROUND); + } + + /** + * Removes a marker for the domain axis in the specified layer and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param marker the marker (null not permitted). + * @param layer the layer (foreground or background). + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.7 + */ + public boolean removeDomainMarker(Marker marker, Layer layer) { + return removeDomainMarker(0, marker, layer); + } + + /** + * Removes a marker for a specific dataset/renderer and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the dataset/renderer index. + * @param marker the marker. + * @param layer the layer (foreground or background). + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.7 + */ + public boolean removeDomainMarker(int index, Marker marker, Layer layer) { + return removeDomainMarker(index, marker, layer, true); + } + + /** + * Removes a marker for a specific dataset/renderer and, if requested, + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param index the dataset/renderer index. + * @param marker the marker. + * @param layer the layer (foreground or background). + * @param notify notify listeners? + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.10 + */ + public boolean removeDomainMarker(int index, Marker marker, Layer layer, + boolean notify) { + ArrayList markers; + if (layer == Layer.FOREGROUND) { + markers = (ArrayList) this.foregroundDomainMarkers.get(new Integer( + index)); + } + else { + markers = (ArrayList) this.backgroundDomainMarkers.get(new Integer( + index)); + } + if (markers == null) { + return false; + } + boolean removed = markers.remove(marker); + if (removed && notify) { + fireChangeEvent(); + } + return removed; + } + + /** + * Adds a marker for display (in the foreground) against the range axis and + * sends a {@link PlotChangeEvent} to all registered listeners. Typically a + * marker will be drawn by the renderer as a line perpendicular to the + * range axis, however this is entirely up to the renderer. + * + * @param marker the marker (null not permitted). + * + * @see #removeRangeMarker(Marker) + */ + public void addRangeMarker(Marker marker) { + addRangeMarker(marker, Layer.FOREGROUND); + } + + /** + * Adds a marker for display against the range axis and sends a + * {@link PlotChangeEvent} to all registered listeners. Typically a marker + * will be drawn by the renderer as a line perpendicular to the range axis, + * however this is entirely up to the renderer. + * + * @param marker the marker (null not permitted). + * @param layer the layer (foreground or background) (null + * not permitted). + * + * @see #removeRangeMarker(Marker, Layer) + */ + public void addRangeMarker(Marker marker, Layer layer) { + addRangeMarker(0, marker, layer); + } + + /** + * Adds a marker for display by a particular renderer and sends a + * {@link PlotChangeEvent} to all registered listeners. + *

+ * Typically a marker will be drawn by the renderer as a line perpendicular + * to a range axis, however this is entirely up to the renderer. + * + * @param index the renderer index. + * @param marker the marker. + * @param layer the layer. + * + * @see #removeRangeMarker(int, Marker, Layer) + */ + public void addRangeMarker(int index, Marker marker, Layer layer) { + addRangeMarker(index, marker, layer, true); + } + + /** + * Adds a marker for display by a particular renderer and sends a + * {@link PlotChangeEvent} to all registered listeners. + *

+ * Typically a marker will be drawn by the renderer as a line perpendicular + * to a range axis, however this is entirely up to the renderer. + * + * @param index the renderer index. + * @param marker the marker. + * @param layer the layer. + * @param notify notify listeners? + * + * @since 1.0.10 + * + * @see #removeRangeMarker(int, Marker, Layer, boolean) + */ + public void addRangeMarker(int index, Marker marker, Layer layer, + boolean notify) { + Collection markers; + if (layer == Layer.FOREGROUND) { + markers = (Collection) this.foregroundRangeMarkers.get( + new Integer(index)); + if (markers == null) { + markers = new java.util.ArrayList(); + this.foregroundRangeMarkers.put(new Integer(index), markers); + } + markers.add(marker); + } + else if (layer == Layer.BACKGROUND) { + markers = (Collection) this.backgroundRangeMarkers.get( + new Integer(index)); + if (markers == null) { + markers = new java.util.ArrayList(); + this.backgroundRangeMarkers.put(new Integer(index), markers); + } + markers.add(marker); + } + marker.addChangeListener(this); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Clears all the range markers for the plot and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @see #clearDomainMarkers() + */ + public void clearRangeMarkers() { + if (this.backgroundRangeMarkers != null) { + Set keys = this.backgroundRangeMarkers.keySet(); + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Integer key = (Integer) iterator.next(); + clearRangeMarkers(key.intValue()); + } + this.backgroundRangeMarkers.clear(); + } + if (this.foregroundRangeMarkers != null) { + Set keys = this.foregroundRangeMarkers.keySet(); + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Integer key = (Integer) iterator.next(); + clearRangeMarkers(key.intValue()); + } + this.foregroundRangeMarkers.clear(); + } + fireChangeEvent(); + } + + /** + * Returns the list of range markers (read only) for the specified layer. + * + * @param layer the layer (foreground or background). + * + * @return The list of range markers. + * + * @see #getRangeMarkers(int, Layer) + */ + public Collection getRangeMarkers(Layer layer) { + return getRangeMarkers(0, layer); + } + + /** + * Returns a collection of range markers for a particular renderer and + * layer. + * + * @param index the renderer index. + * @param layer the layer. + * + * @return A collection of markers (possibly null). + */ + public Collection getRangeMarkers(int index, Layer layer) { + Collection result = null; + Integer key = new Integer(index); + if (layer == Layer.FOREGROUND) { + result = (Collection) this.foregroundRangeMarkers.get(key); + } + else if (layer == Layer.BACKGROUND) { + result = (Collection) this.backgroundRangeMarkers.get(key); + } + if (result != null) { + result = Collections.unmodifiableCollection(result); + } + return result; + } + + /** + * Clears all the range markers for the specified renderer. + * + * @param index the renderer index. + * + * @see #clearDomainMarkers(int) + */ + public void clearRangeMarkers(int index) { + Integer key = new Integer(index); + if (this.backgroundRangeMarkers != null) { + Collection markers + = (Collection) this.backgroundRangeMarkers.get(key); + if (markers != null) { + Iterator iterator = markers.iterator(); + while (iterator.hasNext()) { + Marker m = (Marker) iterator.next(); + m.removeChangeListener(this); + } + markers.clear(); + } + } + if (this.foregroundRangeMarkers != null) { + Collection markers + = (Collection) this.foregroundRangeMarkers.get(key); + if (markers != null) { + Iterator iterator = markers.iterator(); + while (iterator.hasNext()) { + Marker m = (Marker) iterator.next(); + m.removeChangeListener(this); + } + markers.clear(); + } + } + fireChangeEvent(); + } + + /** + * Removes a marker for the range axis and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param marker the marker. + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.7 + * + * @see #addRangeMarker(Marker) + */ + public boolean removeRangeMarker(Marker marker) { + return removeRangeMarker(marker, Layer.FOREGROUND); + } + + /** + * Removes a marker for the range axis in the specified layer and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param marker the marker (null not permitted). + * @param layer the layer (foreground or background). + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.7 + * + * @see #addRangeMarker(Marker, Layer) + */ + public boolean removeRangeMarker(Marker marker, Layer layer) { + return removeRangeMarker(0, marker, layer); + } + + /** + * Removes a marker for a specific dataset/renderer and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the dataset/renderer index. + * @param marker the marker. + * @param layer the layer (foreground or background). + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.7 + * + * @see #addRangeMarker(int, Marker, Layer) + */ + public boolean removeRangeMarker(int index, Marker marker, Layer layer) { + return removeRangeMarker(index, marker, layer, true); + } + + /** + * Removes a marker for a specific dataset/renderer and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the dataset/renderer index. + * @param marker the marker. + * @param layer the layer (foreground or background). + * @param notify notify listeners. + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.10 + * + * @see #addRangeMarker(int, Marker, Layer, boolean) + */ + public boolean removeRangeMarker(int index, Marker marker, Layer layer, + boolean notify) { + ParamChecks.nullNotPermitted(marker, "marker"); + ArrayList markers; + if (layer == Layer.FOREGROUND) { + markers = (ArrayList) this.foregroundRangeMarkers.get(new Integer( + index)); + } + else { + markers = (ArrayList) this.backgroundRangeMarkers.get(new Integer( + index)); + } + if (markers == null) { + return false; + } + boolean removed = markers.remove(marker); + if (removed && notify) { + fireChangeEvent(); + } + return removed; + } + + /** + * Returns the flag that controls whether or not the domain crosshair is + * displayed by the plot. + * + * @return A boolean. + * + * @since 1.0.11 + * + * @see #setDomainCrosshairVisible(boolean) + */ + public boolean isDomainCrosshairVisible() { + return this.domainCrosshairVisible; + } + + /** + * Sets the flag that controls whether or not the domain crosshair is + * displayed by the plot, and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param flag the new flag value. + * + * @since 1.0.11 + * + * @see #isDomainCrosshairVisible() + * @see #setRangeCrosshairVisible(boolean) + */ + public void setDomainCrosshairVisible(boolean flag) { + if (this.domainCrosshairVisible != flag) { + this.domainCrosshairVisible = flag; + fireChangeEvent(); + } + } + + /** + * Returns the row key for the domain crosshair. + * + * @return The row key. + * + * @since 1.0.11 + */ + public Comparable getDomainCrosshairRowKey() { + return this.domainCrosshairRowKey; + } + + /** + * Sets the row key for the domain crosshair and sends a + * {PlotChangeEvent} to all registered listeners. + * + * @param key the key. + * + * @since 1.0.11 + */ + public void setDomainCrosshairRowKey(Comparable key) { + setDomainCrosshairRowKey(key, true); + } + + /** + * Sets the row key for the domain crosshair and, if requested, sends a + * {PlotChangeEvent} to all registered listeners. + * + * @param key the key. + * @param notify notify listeners? + * + * @since 1.0.11 + */ + public void setDomainCrosshairRowKey(Comparable key, boolean notify) { + this.domainCrosshairRowKey = key; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the column key for the domain crosshair. + * + * @return The column key. + * + * @since 1.0.11 + */ + public Comparable getDomainCrosshairColumnKey() { + return this.domainCrosshairColumnKey; + } + + /** + * Sets the column key for the domain crosshair and sends + * a {@link PlotChangeEvent} to all registered listeners. + * + * @param key the key. + * + * @since 1.0.11 + */ + public void setDomainCrosshairColumnKey(Comparable key) { + setDomainCrosshairColumnKey(key, true); + } + + /** + * Sets the column key for the domain crosshair and, if requested, sends + * a {@link PlotChangeEvent} to all registered listeners. + * + * @param key the key. + * @param notify notify listeners? + * + * @since 1.0.11 + */ + public void setDomainCrosshairColumnKey(Comparable key, boolean notify) { + this.domainCrosshairColumnKey = key; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the dataset index for the crosshair. + * + * @return The dataset index. + * + * @since 1.0.11 + */ + public int getCrosshairDatasetIndex() { + return this.crosshairDatasetIndex; + } + + /** + * Sets the dataset index for the crosshair and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the index. + * + * @since 1.0.11 + */ + public void setCrosshairDatasetIndex(int index) { + setCrosshairDatasetIndex(index, true); + } + + /** + * Sets the dataset index for the crosshair and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the index. + * @param notify notify listeners? + * + * @since 1.0.11 + */ + public void setCrosshairDatasetIndex(int index, boolean notify) { + this.crosshairDatasetIndex = index; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the paint used to draw the domain crosshair. + * + * @return The paint (never null). + * + * @since 1.0.11 + * + * @see #setDomainCrosshairPaint(Paint) + * @see #getDomainCrosshairStroke() + */ + public Paint getDomainCrosshairPaint() { + return this.domainCrosshairPaint; + } + + /** + * Sets the paint used to draw the domain crosshair. + * + * @param paint the paint (null not permitted). + * + * @since 1.0.11 + * + * @see #getDomainCrosshairPaint() + */ + public void setDomainCrosshairPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.domainCrosshairPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the stroke used to draw the domain crosshair. + * + * @return The stroke (never null). + * + * @since 1.0.11 + * + * @see #setDomainCrosshairStroke(Stroke) + * @see #getDomainCrosshairPaint() + */ + public Stroke getDomainCrosshairStroke() { + return this.domainCrosshairStroke; + } + + /** + * Sets the stroke used to draw the domain crosshair, and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @since 1.0.11 + * + * @see #getDomainCrosshairStroke() + */ + public void setDomainCrosshairStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.domainCrosshairStroke = stroke; + } + + /** + * Returns a flag indicating whether or not the range crosshair is visible. + * + * @return The flag. + * + * @see #setRangeCrosshairVisible(boolean) + */ + public boolean isRangeCrosshairVisible() { + return this.rangeCrosshairVisible; + } + + /** + * Sets the flag indicating whether or not the range crosshair is visible. + * + * @param flag the new value of the flag. + * + * @see #isRangeCrosshairVisible() + */ + public void setRangeCrosshairVisible(boolean flag) { + if (this.rangeCrosshairVisible != flag) { + this.rangeCrosshairVisible = flag; + fireChangeEvent(); + } + } + + /** + * Returns a flag indicating whether or not the crosshair should "lock-on" + * to actual data values. + * + * @return The flag. + * + * @see #setRangeCrosshairLockedOnData(boolean) + */ + public boolean isRangeCrosshairLockedOnData() { + return this.rangeCrosshairLockedOnData; + } + + /** + * Sets the flag indicating whether or not the range crosshair should + * "lock-on" to actual data values, and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param flag the flag. + * + * @see #isRangeCrosshairLockedOnData() + */ + public void setRangeCrosshairLockedOnData(boolean flag) { + if (this.rangeCrosshairLockedOnData != flag) { + this.rangeCrosshairLockedOnData = flag; + fireChangeEvent(); + } + } + + /** + * Returns the range crosshair value. + * + * @return The value. + * + * @see #setRangeCrosshairValue(double) + */ + public double getRangeCrosshairValue() { + return this.rangeCrosshairValue; + } + + /** + * Sets the range crosshair value and, if the crosshair is visible, sends + * a {@link PlotChangeEvent} to all registered listeners. + * + * @param value the new value. + * + * @see #getRangeCrosshairValue() + */ + public void setRangeCrosshairValue(double value) { + setRangeCrosshairValue(value, true); + } + + /** + * Sets the range crosshair value and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners (but only if the + * crosshair is visible). + * + * @param value the new value. + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @see #getRangeCrosshairValue() + */ + public void setRangeCrosshairValue(double value, boolean notify) { + this.rangeCrosshairValue = value; + if (isRangeCrosshairVisible() && notify) { + fireChangeEvent(); + } + } + + /** + * Returns the pen-style (Stroke) used to draw the crosshair + * (if visible). + * + * @return The crosshair stroke (never null). + * + * @see #setRangeCrosshairStroke(Stroke) + * @see #isRangeCrosshairVisible() + * @see #getRangeCrosshairPaint() + */ + public Stroke getRangeCrosshairStroke() { + return this.rangeCrosshairStroke; + } + + /** + * Sets the pen-style (Stroke) used to draw the range + * crosshair (if visible), and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param stroke the new crosshair stroke (null not + * permitted). + * + * @see #getRangeCrosshairStroke() + */ + public void setRangeCrosshairStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.rangeCrosshairStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw the range crosshair. + * + * @return The paint (never null). + * + * @see #setRangeCrosshairPaint(Paint) + * @see #isRangeCrosshairVisible() + * @see #getRangeCrosshairStroke() + */ + public Paint getRangeCrosshairPaint() { + return this.rangeCrosshairPaint; + } + + /** + * Sets the paint used to draw the range crosshair (if visible) and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getRangeCrosshairPaint() + */ + public void setRangeCrosshairPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.rangeCrosshairPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the list of annotations. + * + * @return The list of annotations (never null). + * + * @see #addAnnotation(CategoryAnnotation) + * @see #clearAnnotations() + */ + public List getAnnotations() { + return this.annotations; + } + + /** + * Adds an annotation to the plot and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param annotation the annotation (null not permitted). + * + * @see #removeAnnotation(CategoryAnnotation) + */ + public void addAnnotation(CategoryAnnotation annotation) { + addAnnotation(annotation, true); + } + + /** + * Adds an annotation to the plot and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param annotation the annotation (null not permitted). + * @param notify notify listeners? + * + * @since 1.0.10 + */ + public void addAnnotation(CategoryAnnotation annotation, boolean notify) { + ParamChecks.nullNotPermitted(annotation, "annotation"); + this.annotations.add(annotation); + annotation.addChangeListener(this); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Removes an annotation from the plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param annotation the annotation (null not permitted). + * + * @return A boolean (indicates whether or not the annotation was removed). + * + * @see #addAnnotation(CategoryAnnotation) + */ + public boolean removeAnnotation(CategoryAnnotation annotation) { + return removeAnnotation(annotation, true); + } + + /** + * Removes an annotation from the plot and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param annotation the annotation (null not permitted). + * @param notify notify listeners? + * + * @return A boolean (indicates whether or not the annotation was removed). + * + * @since 1.0.10 + */ + public boolean removeAnnotation(CategoryAnnotation annotation, + boolean notify) { + ParamChecks.nullNotPermitted(annotation, "annotation"); + boolean removed = this.annotations.remove(annotation); + annotation.removeChangeListener(this); + if (removed && notify) { + fireChangeEvent(); + } + return removed; + } + + /** + * Clears all the annotations and sends a {@link PlotChangeEvent} to all + * registered listeners. + */ + public void clearAnnotations() { + for(int i = 0; i < this.annotations.size(); i++) { + CategoryAnnotation annotation + = (CategoryAnnotation) this.annotations.get(i); + annotation.removeChangeListener(this); + } + this.annotations.clear(); + fireChangeEvent(); + } + + /** + * Returns the shadow generator for the plot, if any. + * + * @return The shadow generator (possibly null). + * + * @since 1.0.14 + */ + public ShadowGenerator getShadowGenerator() { + return this.shadowGenerator; + } + + /** + * Sets the shadow generator for the plot and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @since 1.0.14 + */ + public void setShadowGenerator(ShadowGenerator generator) { + this.shadowGenerator = generator; + fireChangeEvent(); + } + + /** + * Calculates the space required for the domain axis/axes. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param space a carrier for the result (null permitted). + * + * @return The required space. + */ + protected AxisSpace calculateDomainAxisSpace(Graphics2D g2, + Rectangle2D plotArea, + AxisSpace space) { + + if (space == null) { + space = new AxisSpace(); + } + + // reserve some space for the domain axis... + if (this.fixedDomainAxisSpace != null) { + if (this.orientation == PlotOrientation.HORIZONTAL) { + space.ensureAtLeast( + this.fixedDomainAxisSpace.getLeft(), RectangleEdge.LEFT); + space.ensureAtLeast(this.fixedDomainAxisSpace.getRight(), + RectangleEdge.RIGHT); + } + else if (this.orientation == PlotOrientation.VERTICAL) { + space.ensureAtLeast(this.fixedDomainAxisSpace.getTop(), + RectangleEdge.TOP); + space.ensureAtLeast(this.fixedDomainAxisSpace.getBottom(), + RectangleEdge.BOTTOM); + } + } + else { + // reserve space for the primary domain axis... + RectangleEdge domainEdge = Plot.resolveDomainAxisLocation( + getDomainAxisLocation(), this.orientation); + if (this.drawSharedDomainAxis) { + space = getDomainAxis().reserveSpace(g2, this, plotArea, + domainEdge, space); + } + + // reserve space for any domain axes... + for (int i = 0; i < this.domainAxes.size(); i++) { + Axis xAxis = (Axis) this.domainAxes.get(i); + if (xAxis != null) { + RectangleEdge edge = getDomainAxisEdge(i); + space = xAxis.reserveSpace(g2, this, plotArea, edge, space); + } + } + } + + return space; + + } + + /** + * Calculates the space required for the range axis/axes. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param space a carrier for the result (null permitted). + * + * @return The required space. + */ + protected AxisSpace calculateRangeAxisSpace(Graphics2D g2, + Rectangle2D plotArea, + AxisSpace space) { + + if (space == null) { + space = new AxisSpace(); + } + + // reserve some space for the range axis... + if (this.fixedRangeAxisSpace != null) { + if (this.orientation == PlotOrientation.HORIZONTAL) { + space.ensureAtLeast(this.fixedRangeAxisSpace.getTop(), + RectangleEdge.TOP); + space.ensureAtLeast(this.fixedRangeAxisSpace.getBottom(), + RectangleEdge.BOTTOM); + } + else if (this.orientation == PlotOrientation.VERTICAL) { + space.ensureAtLeast(this.fixedRangeAxisSpace.getLeft(), + RectangleEdge.LEFT); + space.ensureAtLeast(this.fixedRangeAxisSpace.getRight(), + RectangleEdge.RIGHT); + } + } + else { + // reserve space for the range axes (if any)... + for (int i = 0; i < this.rangeAxes.size(); i++) { + Axis yAxis = (Axis) this.rangeAxes.get(i); + if (yAxis != null) { + RectangleEdge edge = getRangeAxisEdge(i); + space = yAxis.reserveSpace(g2, this, plotArea, edge, space); + } + } + } + return space; + + } + + /** + * Trims a rectangle to integer coordinates. + * + * @param rect the incoming rectangle. + * + * @return A rectangle with integer coordinates. + */ + private Rectangle integerise(Rectangle2D rect) { + int x0 = (int) Math.ceil(rect.getMinX()); + int y0 = (int) Math.ceil(rect.getMinY()); + int x1 = (int) Math.floor(rect.getMaxX()); + int y1 = (int) Math.floor(rect.getMaxY()); + return new Rectangle(x0, y0, (x1 - x0), (y1 - y0)); + } + + /** + * Calculates the space required for the axes. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * + * @return The space required for the axes. + */ + protected AxisSpace calculateAxisSpace(Graphics2D g2, + Rectangle2D plotArea) { + AxisSpace space = new AxisSpace(); + space = calculateRangeAxisSpace(g2, plotArea, space); + space = calculateDomainAxisSpace(g2, plotArea, space); + return space; + } + + /** + * Draws the plot on a Java 2D graphics device (such as the screen or a + * printer). + *

+ * At your option, you may supply an instance of {@link PlotRenderingInfo}. + * If you do, it will be populated with information about the drawing, + * including various plot dimensions and tooltip info. + * + * @param g2 the graphics device. + * @param area the area within which the plot (including axes) should + * be drawn. + * @param anchor the anchor point (null permitted). + * @param parentState the state from the parent plot, if there is one. + * @param state collects info as the chart is drawn (possibly + * null). + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, PlotRenderingInfo state) { + + // if the plot area is too small, just return... + boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); + boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); + if (b1 || b2) { + return; + } + + // record the plot area... + if (state == null) { + // if the incoming state is null, no information will be passed + // back to the caller - but we create a temporary state to record + // the plot area, since that is used later by the axes + state = new PlotRenderingInfo(null); + } + state.setPlotArea(area); + + // adjust the drawing area for the plot insets (if any)... + RectangleInsets insets = getInsets(); + insets.trim(area); + + // calculate the data area... + AxisSpace space = calculateAxisSpace(g2, area); + Rectangle2D dataArea = space.shrink(area, null); + this.axisOffset.trim(dataArea); + dataArea = integerise(dataArea); + if (dataArea.isEmpty()) { + return; + } + state.setDataArea(dataArea); + createAndAddEntity((Rectangle2D) dataArea.clone(), state, null, null); + + // if there is a renderer, it draws the background, otherwise use the + // default background... + if (getRenderer() != null) { + getRenderer().drawBackground(g2, this, dataArea); + } + else { + drawBackground(g2, dataArea); + } + + Map axisStateMap = drawAxes(g2, area, dataArea, state); + + // the anchor point is typically the point where the mouse last + // clicked - the crosshairs will be driven off this point... + if (anchor != null && !dataArea.contains(anchor)) { + anchor = ShapeUtilities.getPointInRectangle(anchor.getX(), + anchor.getY(), dataArea); + } + CategoryCrosshairState crosshairState = new CategoryCrosshairState(); + crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY); + crosshairState.setAnchor(anchor); + + // specify the anchor X and Y coordinates in Java2D space, for the + // cases where these are not updated during rendering (i.e. no lock + // on data) + crosshairState.setAnchorX(Double.NaN); + crosshairState.setAnchorY(Double.NaN); + if (anchor != null) { + ValueAxis rangeAxis = getRangeAxis(); + if (rangeAxis != null) { + double y; + if (getOrientation() == PlotOrientation.VERTICAL) { + y = rangeAxis.java2DToValue(anchor.getY(), dataArea, + getRangeAxisEdge()); + } + else { + y = rangeAxis.java2DToValue(anchor.getX(), dataArea, + getRangeAxisEdge()); + } + crosshairState.setAnchorY(y); + } + } + crosshairState.setRowKey(getDomainCrosshairRowKey()); + crosshairState.setColumnKey(getDomainCrosshairColumnKey()); + crosshairState.setCrosshairY(getRangeCrosshairValue()); + + // don't let anyone draw outside the data area + Shape savedClip = g2.getClip(); + g2.clip(dataArea); + + drawDomainGridlines(g2, dataArea); + + AxisState rangeAxisState = (AxisState) axisStateMap.get(getRangeAxis()); + if (rangeAxisState == null) { + if (parentState != null) { + rangeAxisState = (AxisState) parentState.getSharedAxisStates() + .get(getRangeAxis()); + } + } + if (rangeAxisState != null) { + drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks()); + drawZeroRangeBaseline(g2, dataArea); + } + + Graphics2D savedG2 = g2; + BufferedImage dataImage = null; + boolean suppressShadow = Boolean.TRUE.equals(g2.getRenderingHint( + JFreeChart.KEY_SUPPRESS_SHADOW_GENERATION)); + if (this.shadowGenerator != null && !suppressShadow) { + dataImage = new BufferedImage((int) dataArea.getWidth(), + (int)dataArea.getHeight(), BufferedImage.TYPE_INT_ARGB); + g2 = dataImage.createGraphics(); + g2.translate(-dataArea.getX(), -dataArea.getY()); + g2.setRenderingHints(savedG2.getRenderingHints()); + } + + // draw the markers... + for (int i = 0; i < this.renderers.size(); i++) { + drawDomainMarkers(g2, dataArea, i, Layer.BACKGROUND); + } + for (int i = 0; i < this.renderers.size(); i++) { + drawRangeMarkers(g2, dataArea, i, Layer.BACKGROUND); + } + + // now render data items... + boolean foundData = false; + + // set up the alpha-transparency... + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance( + AlphaComposite.SRC_OVER, getForegroundAlpha())); + + DatasetRenderingOrder order = getDatasetRenderingOrder(); + if (order == DatasetRenderingOrder.FORWARD) { + for (int i = 0; i < this.datasets.size(); i++) { + foundData = render(g2, dataArea, i, state, crosshairState) + || foundData; + } + } + else { // DatasetRenderingOrder.REVERSE + for (int i = this.datasets.size() - 1; i >= 0; i--) { + foundData = render(g2, dataArea, i, state, crosshairState) + || foundData; + } + } + // draw the foreground markers... + for (int i = 0; i < this.renderers.size(); i++) { + drawDomainMarkers(g2, dataArea, i, Layer.FOREGROUND); + } + for (int i = 0; i < this.renderers.size(); i++) { + drawRangeMarkers(g2, dataArea, i, Layer.FOREGROUND); + } + + // draw the annotations (if any)... + drawAnnotations(g2, dataArea); + + if (this.shadowGenerator != null && !suppressShadow) { + BufferedImage shadowImage = this.shadowGenerator.createDropShadow( + dataImage); + g2 = savedG2; + g2.drawImage(shadowImage, (int) dataArea.getX() + + this.shadowGenerator.calculateOffsetX(), + (int) dataArea.getY() + + this.shadowGenerator.calculateOffsetY(), null); + g2.drawImage(dataImage, (int) dataArea.getX(), + (int) dataArea.getY(), null); + } + g2.setClip(savedClip); + g2.setComposite(originalComposite); + + if (!foundData) { + drawNoDataMessage(g2, dataArea); + } + + int datasetIndex = crosshairState.getDatasetIndex(); + setCrosshairDatasetIndex(datasetIndex, false); + + // draw domain crosshair if required... + Comparable rowKey = crosshairState.getRowKey(); + Comparable columnKey = crosshairState.getColumnKey(); + setDomainCrosshairRowKey(rowKey, false); + setDomainCrosshairColumnKey(columnKey, false); + if (isDomainCrosshairVisible() && columnKey != null) { + Paint paint = getDomainCrosshairPaint(); + Stroke stroke = getDomainCrosshairStroke(); + drawDomainCrosshair(g2, dataArea, this.orientation, + datasetIndex, rowKey, columnKey, stroke, paint); + } + + // draw range crosshair if required... + ValueAxis yAxis = getRangeAxisForDataset(datasetIndex); + RectangleEdge yAxisEdge = getRangeAxisEdge(); + if (!this.rangeCrosshairLockedOnData && anchor != null) { + double yy; + if (getOrientation() == PlotOrientation.VERTICAL) { + yy = yAxis.java2DToValue(anchor.getY(), dataArea, yAxisEdge); + } + else { + yy = yAxis.java2DToValue(anchor.getX(), dataArea, yAxisEdge); + } + crosshairState.setCrosshairY(yy); + } + setRangeCrosshairValue(crosshairState.getCrosshairY(), false); + if (isRangeCrosshairVisible()) { + double y = getRangeCrosshairValue(); + Paint paint = getRangeCrosshairPaint(); + Stroke stroke = getRangeCrosshairStroke(); + drawRangeCrosshair(g2, dataArea, getOrientation(), y, yAxis, + stroke, paint); + } + + // draw an outline around the plot area... + if (isOutlineVisible()) { + if (getRenderer() != null) { + getRenderer().drawOutline(g2, this, dataArea); + } + else { + drawOutline(g2, dataArea); + } + } + + } + + /** + * Draws the plot background (the background color and/or image). + *

+ * This method will be called during the chart drawing process and is + * declared public so that it can be accessed by the renderers used by + * certain subclasses. You shouldn't need to call this method directly. + * + * @param g2 the graphics device. + * @param area the area within which the plot should be drawn. + */ + @Override + public void drawBackground(Graphics2D g2, Rectangle2D area) { + fillBackground(g2, area, this.orientation); + drawBackgroundImage(g2, area); + } + + /** + * A utility method for drawing the plot's axes. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param dataArea the data area. + * @param plotState collects information about the plot (null + * permitted). + * + * @return A map containing the axis states. + */ + protected Map drawAxes(Graphics2D g2, + Rectangle2D plotArea, + Rectangle2D dataArea, + PlotRenderingInfo plotState) { + + AxisCollection axisCollection = new AxisCollection(); + + // add domain axes to lists... + for (int index = 0; index < this.domainAxes.size(); index++) { + CategoryAxis xAxis = (CategoryAxis) this.domainAxes.get(index); + if (xAxis != null) { + axisCollection.add(xAxis, getDomainAxisEdge(index)); + } + } + + // add range axes to lists... + for (int index = 0; index < this.rangeAxes.size(); index++) { + ValueAxis yAxis = (ValueAxis) this.rangeAxes.get(index); + if (yAxis != null) { + axisCollection.add(yAxis, getRangeAxisEdge(index)); + } + } + + Map axisStateMap = new HashMap(); + + // draw the top axes + double cursor = dataArea.getMinY() - this.axisOffset.calculateTopOutset( + dataArea.getHeight()); + Iterator iterator = axisCollection.getAxesAtTop().iterator(); + while (iterator.hasNext()) { + Axis axis = (Axis) iterator.next(); + if (axis != null) { + AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, + RectangleEdge.TOP, plotState); + cursor = axisState.getCursor(); + axisStateMap.put(axis, axisState); + } + } + + // draw the bottom axes + cursor = dataArea.getMaxY() + + this.axisOffset.calculateBottomOutset(dataArea.getHeight()); + iterator = axisCollection.getAxesAtBottom().iterator(); + while (iterator.hasNext()) { + Axis axis = (Axis) iterator.next(); + if (axis != null) { + AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, + RectangleEdge.BOTTOM, plotState); + cursor = axisState.getCursor(); + axisStateMap.put(axis, axisState); + } + } + + // draw the left axes + cursor = dataArea.getMinX() + - this.axisOffset.calculateLeftOutset(dataArea.getWidth()); + iterator = axisCollection.getAxesAtLeft().iterator(); + while (iterator.hasNext()) { + Axis axis = (Axis) iterator.next(); + if (axis != null) { + AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, + RectangleEdge.LEFT, plotState); + cursor = axisState.getCursor(); + axisStateMap.put(axis, axisState); + } + } + + // draw the right axes + cursor = dataArea.getMaxX() + + this.axisOffset.calculateRightOutset(dataArea.getWidth()); + iterator = axisCollection.getAxesAtRight().iterator(); + while (iterator.hasNext()) { + Axis axis = (Axis) iterator.next(); + if (axis != null) { + AxisState axisState = axis.draw(g2, cursor, plotArea, dataArea, + RectangleEdge.RIGHT, plotState); + cursor = axisState.getCursor(); + axisStateMap.put(axis, axisState); + } + } + + return axisStateMap; + + } + + /** + * Draws a representation of a dataset within the dataArea region using the + * appropriate renderer. + * + * @param g2 the graphics device. + * @param dataArea the region in which the data is to be drawn. + * @param index the dataset and renderer index. + * @param info an optional object for collection dimension information. + * @param crosshairState a state object for tracking crosshair info + * (null permitted). + * + * @return A boolean that indicates whether or not real data was found. + * + * @since 1.0.11 + */ + public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, + PlotRenderingInfo info, CategoryCrosshairState crosshairState) { + + boolean foundData = false; + CategoryDataset currentDataset = getDataset(index); + CategoryItemRenderer renderer = getRenderer(index); + CategoryAxis domainAxis = getDomainAxisForDataset(index); + ValueAxis rangeAxis = getRangeAxisForDataset(index); + boolean hasData = !DatasetUtilities.isEmptyOrNull(currentDataset); + if (hasData && renderer != null) { + + foundData = true; + CategoryItemRendererState state = renderer.initialise(g2, dataArea, + this, index, info); + state.setCrosshairState(crosshairState); + int columnCount = currentDataset.getColumnCount(); + int rowCount = currentDataset.getRowCount(); + int passCount = renderer.getPassCount(); + for (int pass = 0; pass < passCount; pass++) { + if (this.columnRenderingOrder == SortOrder.ASCENDING) { + for (int column = 0; column < columnCount; column++) { + if (this.rowRenderingOrder == SortOrder.ASCENDING) { + for (int row = 0; row < rowCount; row++) { + renderer.drawItem(g2, state, dataArea, this, + domainAxis, rangeAxis, currentDataset, + row, column, pass); + } + } + else { + for (int row = rowCount - 1; row >= 0; row--) { + renderer.drawItem(g2, state, dataArea, this, + domainAxis, rangeAxis, currentDataset, + row, column, pass); + } + } + } + } + else { + for (int column = columnCount - 1; column >= 0; column--) { + if (this.rowRenderingOrder == SortOrder.ASCENDING) { + for (int row = 0; row < rowCount; row++) { + renderer.drawItem(g2, state, dataArea, this, + domainAxis, rangeAxis, currentDataset, + row, column, pass); + } + } + else { + for (int row = rowCount - 1; row >= 0; row--) { + renderer.drawItem(g2, state, dataArea, this, + domainAxis, rangeAxis, currentDataset, + row, column, pass); + } + } + } + } + } + } + return foundData; + + } + + /** + * Draws the domain gridlines for the plot, if they are visible. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * + * @see #drawRangeGridlines(Graphics2D, Rectangle2D, List) + */ + protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea) { + + if (!isDomainGridlinesVisible()) { + return; + } + CategoryAnchor anchor = getDomainGridlinePosition(); + RectangleEdge domainAxisEdge = getDomainAxisEdge(); + CategoryDataset dataset = getDataset(); + if (dataset == null) { + return; + } + CategoryAxis axis = getDomainAxis(); + if (axis != null) { + int columnCount = dataset.getColumnCount(); + for (int c = 0; c < columnCount; c++) { + double xx = axis.getCategoryJava2DCoordinate(anchor, c, + columnCount, dataArea, domainAxisEdge); + CategoryItemRenderer renderer1 = getRenderer(); + if (renderer1 != null) { + renderer1.drawDomainGridline(g2, this, dataArea, xx); + } + } + } + } + + /** + * Draws the range gridlines for the plot, if they are visible. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param ticks the ticks. + * + * @see #drawDomainGridlines(Graphics2D, Rectangle2D) + */ + protected void drawRangeGridlines(Graphics2D g2, Rectangle2D dataArea, + List ticks) { + // draw the range grid lines, if any... + if (!isRangeGridlinesVisible() && !isRangeMinorGridlinesVisible()) { + return; + } + // no axis, no gridlines... + ValueAxis axis = getRangeAxis(); + if (axis == null) { + return; + } + // no renderer, no gridlines... + CategoryItemRenderer r = getRenderer(); + if (r == null) { + return; + } + + Stroke gridStroke = null; + Paint gridPaint = null; + boolean paintLine; + Iterator iterator = ticks.iterator(); + while (iterator.hasNext()) { + paintLine = false; + ValueTick tick = (ValueTick) iterator.next(); + if ((tick.getTickType() == TickType.MINOR) + && isRangeMinorGridlinesVisible()) { + gridStroke = getRangeMinorGridlineStroke(); + gridPaint = getRangeMinorGridlinePaint(); + paintLine = true; + } + else if ((tick.getTickType() == TickType.MAJOR) + && isRangeGridlinesVisible()) { + gridStroke = getRangeGridlineStroke(); + gridPaint = getRangeGridlinePaint(); + paintLine = true; + } + if (((tick.getValue() != 0.0) + || !isRangeZeroBaselineVisible()) && paintLine) { + // the method we want isn't in the CategoryItemRenderer + // interface... + if (r instanceof AbstractCategoryItemRenderer) { + AbstractCategoryItemRenderer aci + = (AbstractCategoryItemRenderer) r; + aci.drawRangeLine(g2, this, axis, dataArea, + tick.getValue(), gridPaint, gridStroke); + } + else { + // we'll have to use the method in the interface, but + // this doesn't have the paint and stroke settings... + r.drawRangeGridline(g2, this, axis, dataArea, + tick.getValue()); + } + } + } + } + + /** + * Draws a base line across the chart at value zero on the range axis. + * + * @param g2 the graphics device. + * @param area the data area. + * + * @see #setRangeZeroBaselineVisible(boolean) + * + * @since 1.0.13 + */ + protected void drawZeroRangeBaseline(Graphics2D g2, Rectangle2D area) { + if (!isRangeZeroBaselineVisible()) { + return; + } + CategoryItemRenderer r = getRenderer(); + if (r instanceof AbstractCategoryItemRenderer) { + AbstractCategoryItemRenderer aci = (AbstractCategoryItemRenderer) r; + aci.drawRangeLine(g2, this, getRangeAxis(), area, 0.0, + this.rangeZeroBaselinePaint, this.rangeZeroBaselineStroke); + } + else { + r.drawRangeGridline(g2, this, getRangeAxis(), area, 0.0); + } + } + + /** + * Draws the annotations. + * + * @param g2 the graphics device. + * @param dataArea the data area. + */ + protected void drawAnnotations(Graphics2D g2, Rectangle2D dataArea) { + + if (getAnnotations() != null) { + Iterator iterator = getAnnotations().iterator(); + while (iterator.hasNext()) { + CategoryAnnotation annotation + = (CategoryAnnotation) iterator.next(); + annotation.draw(g2, this, dataArea, getDomainAxis(), + getRangeAxis()); + } + } + + } + + /** + * Draws the domain markers (if any) for an axis and layer. This method is + * typically called from within the draw() method. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param index the renderer index. + * @param layer the layer (foreground or background). + * + * @see #drawRangeMarkers(Graphics2D, Rectangle2D, int, Layer) + */ + protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea, + int index, Layer layer) { + + CategoryItemRenderer r = getRenderer(index); + if (r == null) { + return; + } + + Collection markers = getDomainMarkers(index, layer); + CategoryAxis axis = getDomainAxisForDataset(index); + if (markers != null && axis != null) { + Iterator iterator = markers.iterator(); + while (iterator.hasNext()) { + CategoryMarker marker = (CategoryMarker) iterator.next(); + r.drawDomainMarker(g2, this, axis, marker, dataArea); + } + } + + } + + /** + * Draws the range markers (if any) for an axis and layer. This method is + * typically called from within the draw() method. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param index the renderer index. + * @param layer the layer (foreground or background). + * + * @see #drawDomainMarkers(Graphics2D, Rectangle2D, int, Layer) + */ + protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea, + int index, Layer layer) { + + CategoryItemRenderer r = getRenderer(index); + if (r == null) { + return; + } + + Collection markers = getRangeMarkers(index, layer); + ValueAxis axis = getRangeAxisForDataset(index); + if (markers != null && axis != null) { + Iterator iterator = markers.iterator(); + while (iterator.hasNext()) { + Marker marker = (Marker) iterator.next(); + r.drawRangeMarker(g2, this, axis, marker, dataArea); + } + } + + } + + /** + * Utility method for drawing a line perpendicular to the range axis (used + * for crosshairs). + * + * @param g2 the graphics device. + * @param dataArea the area defined by the axes. + * @param value the data value. + * @param stroke the line stroke (null not permitted). + * @param paint the line paint (null not permitted). + */ + protected void drawRangeLine(Graphics2D g2, Rectangle2D dataArea, + double value, Stroke stroke, Paint paint) { + + double java2D = getRangeAxis().valueToJava2D(value, dataArea, + getRangeAxisEdge()); + Line2D line = null; + if (this.orientation == PlotOrientation.HORIZONTAL) { + line = new Line2D.Double(java2D, dataArea.getMinY(), java2D, + dataArea.getMaxY()); + } + else if (this.orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(dataArea.getMinX(), java2D, + dataArea.getMaxX(), java2D); + } + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(line); + + } + + /** + * Draws a domain crosshair. + * + * @param g2 the graphics target. + * @param dataArea the data area. + * @param orientation the plot orientation. + * @param datasetIndex the dataset index. + * @param rowKey the row key. + * @param columnKey the column key. + * @param stroke the stroke used to draw the crosshair line. + * @param paint the paint used to draw the crosshair line. + * + * @see #drawRangeCrosshair(Graphics2D, Rectangle2D, PlotOrientation, + * double, ValueAxis, Stroke, Paint) + * + * @since 1.0.11 + */ + protected void drawDomainCrosshair(Graphics2D g2, Rectangle2D dataArea, + PlotOrientation orientation, int datasetIndex, + Comparable rowKey, Comparable columnKey, Stroke stroke, + Paint paint) { + + CategoryDataset dataset = getDataset(datasetIndex); + CategoryAxis axis = getDomainAxisForDataset(datasetIndex); + CategoryItemRenderer renderer = getRenderer(datasetIndex); + Line2D line; + if (orientation == PlotOrientation.VERTICAL) { + double xx = renderer.getItemMiddle(rowKey, columnKey, dataset, axis, + dataArea, RectangleEdge.BOTTOM); + line = new Line2D.Double(xx, dataArea.getMinY(), xx, + dataArea.getMaxY()); + } + else { + double yy = renderer.getItemMiddle(rowKey, columnKey, dataset, axis, + dataArea, RectangleEdge.LEFT); + line = new Line2D.Double(dataArea.getMinX(), yy, + dataArea.getMaxX(), yy); + } + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(line); + + } + + /** + * Draws a range crosshair. + * + * @param g2 the graphics target. + * @param dataArea the data area. + * @param orientation the plot orientation. + * @param value the crosshair value. + * @param axis the axis against which the value is measured. + * @param stroke the stroke used to draw the crosshair line. + * @param paint the paint used to draw the crosshair line. + * + * @see #drawDomainCrosshair(Graphics2D, Rectangle2D, PlotOrientation, int, + * Comparable, Comparable, Stroke, Paint) + * + * @since 1.0.5 + */ + protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, + PlotOrientation orientation, double value, ValueAxis axis, + Stroke stroke, Paint paint) { + + if (!axis.getRange().contains(value)) { + return; + } + Line2D line; + if (orientation == PlotOrientation.HORIZONTAL) { + double xx = axis.valueToJava2D(value, dataArea, + RectangleEdge.BOTTOM); + line = new Line2D.Double(xx, dataArea.getMinY(), xx, + dataArea.getMaxY()); + } + else { + double yy = axis.valueToJava2D(value, dataArea, + RectangleEdge.LEFT); + line = new Line2D.Double(dataArea.getMinX(), yy, + dataArea.getMaxX(), yy); + } + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(line); + + } + + /** + * Returns the range of data values that will be plotted against the range + * axis. If the dataset is null, this method returns + * null. + * + * @param axis the axis. + * + * @return The data range. + */ + @Override + public Range getDataRange(ValueAxis axis) { + + Range result = null; + List mappedDatasets = new ArrayList(); + + int rangeIndex = this.rangeAxes.indexOf(axis); + if (rangeIndex >= 0) { + mappedDatasets.addAll(datasetsMappedToRangeAxis(rangeIndex)); + } + else if (axis == getRangeAxis()) { + mappedDatasets.addAll(datasetsMappedToRangeAxis(0)); + } + + // iterate through the datasets that map to the axis and get the union + // of the ranges. + Iterator iterator = mappedDatasets.iterator(); + while (iterator.hasNext()) { + CategoryDataset d = (CategoryDataset) iterator.next(); + CategoryItemRenderer r = getRendererForDataset(d); + if (r != null) { + result = Range.combine(result, r.findRangeBounds(d)); + } + } + return result; + + } + + /** + * Returns a list of the datasets that are mapped to the axis with the + * specified index. + * + * @param axisIndex the axis index. + * + * @return The list (possibly empty, but never null). + * + * @since 1.0.3 + */ + private List datasetsMappedToDomainAxis(int axisIndex) { + Integer key = new Integer(axisIndex); + List result = new ArrayList(); + for (int i = 0; i < this.datasets.size(); i++) { + List mappedAxes = (List) this.datasetToDomainAxesMap.get( + new Integer(i)); + CategoryDataset dataset = (CategoryDataset) this.datasets.get(i); + if (mappedAxes == null) { + if (key.equals(ZERO)) { + if (dataset != null) { + result.add(dataset); + } + } + } + else { + if (mappedAxes.contains(key)) { + if (dataset != null) { + result.add(dataset); + } + } + } + } + return result; + } + + /** + * A utility method that returns a list of datasets that are mapped to a + * given range axis. + * + * @param index the axis index. + * + * @return A list of datasets. + */ + private List datasetsMappedToRangeAxis(int index) { + Integer key = new Integer(index); + List result = new ArrayList(); + for (int i = 0; i < this.datasets.size(); i++) { + List mappedAxes = (List) this.datasetToRangeAxesMap.get( + new Integer(i)); + if (mappedAxes == null) { + if (key.equals(ZERO)) { + result.add(this.datasets.get(i)); + } + } + else { + if (mappedAxes.contains(key)) { + result.add(this.datasets.get(i)); + } + } + } + return result; + } + + /** + * Returns the weight for this plot when it is used as a subplot within a + * combined plot. + * + * @return The weight. + * + * @see #setWeight(int) + */ + public int getWeight() { + return this.weight; + } + + /** + * Sets the weight for the plot and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param weight the weight. + * + * @see #getWeight() + */ + public void setWeight(int weight) { + this.weight = weight; + fireChangeEvent(); + } + + /** + * Returns the fixed domain axis space. + * + * @return The fixed domain axis space (possibly null). + * + * @see #setFixedDomainAxisSpace(AxisSpace) + */ + public AxisSpace getFixedDomainAxisSpace() { + return this.fixedDomainAxisSpace; + } + + /** + * Sets the fixed domain axis space and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param space the space (null permitted). + * + * @see #getFixedDomainAxisSpace() + */ + public void setFixedDomainAxisSpace(AxisSpace space) { + setFixedDomainAxisSpace(space, true); + } + + /** + * Sets the fixed domain axis space and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param space the space (null permitted). + * @param notify notify listeners? + * + * @see #getFixedDomainAxisSpace() + * + * @since 1.0.7 + */ + public void setFixedDomainAxisSpace(AxisSpace space, boolean notify) { + this.fixedDomainAxisSpace = space; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the fixed range axis space. + * + * @return The fixed range axis space (possibly null). + * + * @see #setFixedRangeAxisSpace(AxisSpace) + */ + public AxisSpace getFixedRangeAxisSpace() { + return this.fixedRangeAxisSpace; + } + + /** + * Sets the fixed range axis space and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param space the space (null permitted). + * + * @see #getFixedRangeAxisSpace() + */ + public void setFixedRangeAxisSpace(AxisSpace space) { + setFixedRangeAxisSpace(space, true); + } + + /** + * Sets the fixed range axis space and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param space the space (null permitted). + * @param notify notify listeners? + * + * @see #getFixedRangeAxisSpace() + * + * @since 1.0.7 + */ + public void setFixedRangeAxisSpace(AxisSpace space, boolean notify) { + this.fixedRangeAxisSpace = space; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns a list of the categories in the plot's primary dataset. + * + * @return A list of the categories in the plot's primary dataset. + * + * @see #getCategoriesForAxis(CategoryAxis) + */ + public List getCategories() { + List result = null; + if (getDataset() != null) { + result = Collections.unmodifiableList(getDataset().getColumnKeys()); + } + return result; + } + + /** + * Returns a list of the categories that should be displayed for the + * specified axis. + * + * @param axis the axis (null not permitted) + * + * @return The categories. + * + * @since 1.0.3 + */ + public List getCategoriesForAxis(CategoryAxis axis) { + List result = new ArrayList(); + int axisIndex = this.domainAxes.indexOf(axis); + List datasets = datasetsMappedToDomainAxis(axisIndex); + Iterator iterator = datasets.iterator(); + while (iterator.hasNext()) { + CategoryDataset dataset = (CategoryDataset) iterator.next(); + // add the unique categories from this dataset + for (int i = 0; i < dataset.getColumnCount(); i++) { + Comparable category = dataset.getColumnKey(i); + if (!result.contains(category)) { + result.add(category); + } + } + } + return result; + } + + /** + * Returns the flag that controls whether or not the shared domain axis is + * drawn for each subplot. + * + * @return A boolean. + * + * @see #setDrawSharedDomainAxis(boolean) + */ + public boolean getDrawSharedDomainAxis() { + return this.drawSharedDomainAxis; + } + + /** + * Sets the flag that controls whether the shared domain axis is drawn when + * this plot is being used as a subplot. + * + * @param draw a boolean. + * + * @see #getDrawSharedDomainAxis() + */ + public void setDrawSharedDomainAxis(boolean draw) { + this.drawSharedDomainAxis = draw; + fireChangeEvent(); + } + + /** + * Returns false always, because the plot cannot be panned + * along the domain axis/axes. + * + * @return A boolean. + * + * @see #isRangePannable() + * + * @since 1.0.13 + */ + @Override + public boolean isDomainPannable() { + return false; + } + + /** + * Returns true if panning is enabled for the range axes, + * and false otherwise. + * + * @return A boolean. + * + * @see #setRangePannable(boolean) + * @see #isDomainPannable() + * + * @since 1.0.13 + */ + @Override + public boolean isRangePannable() { + return this.rangePannable; + } + + /** + * Sets the flag that enables or disables panning of the plot along + * the range axes. + * + * @param pannable the new flag value. + * + * @see #isRangePannable() + * + * @since 1.0.13 + */ + public void setRangePannable(boolean pannable) { + this.rangePannable = pannable; + } + + /** + * Pans the domain axes by the specified percentage. + * + * @param percent the distance to pan (as a percentage of the axis length). + * @param info the plot info + * @param source the source point where the pan action started. + * + * @since 1.0.13 + */ + @Override + public void panDomainAxes(double percent, PlotRenderingInfo info, + Point2D source) { + // do nothing, because the plot is not pannable along the domain axes + } + + /** + * Pans the range axes by the specified percentage. + * + * @param percent the distance to pan (as a percentage of the axis length). + * @param info the plot info + * @param source the source point where the pan action started. + * + * @since 1.0.13 + */ + @Override + public void panRangeAxes(double percent, PlotRenderingInfo info, + Point2D source) { + if (!isRangePannable()) { + return; + } + int rangeAxisCount = getRangeAxisCount(); + for (int i = 0; i < rangeAxisCount; i++) { + ValueAxis axis = getRangeAxis(i); + if (axis == null) { + continue; + } + double length = axis.getRange().getLength(); + double adj = percent * length; + if (axis.isInverted()) { + adj = -adj; + } + axis.setRange(axis.getLowerBound() + adj, + axis.getUpperBound() + adj); + } + } + + /** + * Returns false to indicate that the domain axes are not + * zoomable. + * + * @return A boolean. + * + * @see #isRangeZoomable() + */ + @Override + public boolean isDomainZoomable() { + return false; + } + + /** + * Returns true to indicate that the range axes are zoomable. + * + * @return A boolean. + * + * @see #isDomainZoomable() + */ + @Override + public boolean isRangeZoomable() { + return true; + } + + /** + * This method does nothing, because CategoryPlot doesn't + * support zooming on the domain. + * + * @param factor the zoom factor. + * @param state the plot state. + * @param source the source point (in Java2D space) for the zoom. + */ + @Override + public void zoomDomainAxes(double factor, PlotRenderingInfo state, + Point2D source) { + // can't zoom domain axis + } + + /** + * This method does nothing, because CategoryPlot doesn't + * support zooming on the domain. + * + * @param lowerPercent the lower bound. + * @param upperPercent the upper bound. + * @param state the plot state. + * @param source the source point (in Java2D space) for the zoom. + */ + @Override + public void zoomDomainAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo state, Point2D source) { + // can't zoom domain axis + } + + /** + * This method does nothing, because CategoryPlot doesn't + * support zooming on the domain. + * + * @param factor the zoom factor. + * @param info the plot rendering info. + * @param source the source point (in Java2D space). + * @param useAnchor use source point as zoom anchor? + * + * @see #zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean) + * + * @since 1.0.7 + */ + @Override + public void zoomDomainAxes(double factor, PlotRenderingInfo info, + Point2D source, boolean useAnchor) { + // can't zoom domain axis + } + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param state the plot state. + * @param source the source point (in Java2D space) for the zoom. + */ + @Override + public void zoomRangeAxes(double factor, PlotRenderingInfo state, + Point2D source) { + // delegate to other method + zoomRangeAxes(factor, state, source, false); + } + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info. + * @param source the source point. + * @param useAnchor a flag that controls whether or not the source point + * is used for the zoom anchor. + * + * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean) + * + * @since 1.0.7 + */ + @Override + public void zoomRangeAxes(double factor, PlotRenderingInfo info, + Point2D source, boolean useAnchor) { + + // perform the zoom on each range axis + for (int i = 0; i < this.rangeAxes.size(); i++) { + ValueAxis rangeAxis = (ValueAxis) this.rangeAxes.get(i); + if (rangeAxis != null) { + if (useAnchor) { + // get the relevant source coordinate given the plot + // orientation + double sourceY = source.getY(); + if (this.orientation == PlotOrientation.HORIZONTAL) { + sourceY = source.getX(); + } + double anchorY = rangeAxis.java2DToValue(sourceY, + info.getDataArea(), getRangeAxisEdge()); + rangeAxis.resizeRange2(factor, anchorY); + } + else { + rangeAxis.resizeRange(factor); + } + } + } + } + + /** + * Zooms in on the range axes. + * + * @param lowerPercent the lower bound. + * @param upperPercent the upper bound. + * @param state the plot state. + * @param source the source point (in Java2D space) for the zoom. + */ + @Override + public void zoomRangeAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo state, Point2D source) { + for (int i = 0; i < this.rangeAxes.size(); i++) { + ValueAxis rangeAxis = (ValueAxis) this.rangeAxes.get(i); + if (rangeAxis != null) { + rangeAxis.zoomRange(lowerPercent, upperPercent); + } + } + } + + /** + * Returns the anchor value. + * + * @return The anchor value. + * + * @see #setAnchorValue(double) + */ + public double getAnchorValue() { + return this.anchorValue; + } + + /** + * Sets the anchor value and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param value the anchor value. + * + * @see #getAnchorValue() + */ + public void setAnchorValue(double value) { + setAnchorValue(value, true); + } + + /** + * Sets the anchor value and, if requested, sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param value the value. + * @param notify notify listeners? + * + * @see #getAnchorValue() + */ + public void setAnchorValue(double value, boolean notify) { + this.anchorValue = value; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Tests the plot for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CategoryPlot)) { + return false; + } + CategoryPlot that = (CategoryPlot) obj; + if (this.orientation != that.orientation) { + return false; + } + if (!ObjectUtilities.equal(this.axisOffset, that.axisOffset)) { + return false; + } + if (!this.domainAxes.equals(that.domainAxes)) { + return false; + } + if (!this.domainAxisLocations.equals(that.domainAxisLocations)) { + return false; + } + if (this.drawSharedDomainAxis != that.drawSharedDomainAxis) { + return false; + } + if (!this.rangeAxes.equals(that.rangeAxes)) { + return false; + } + if (!this.rangeAxisLocations.equals(that.rangeAxisLocations)) { + return false; + } + if (!ObjectUtilities.equal(this.datasetToDomainAxesMap, + that.datasetToDomainAxesMap)) { + return false; + } + if (!ObjectUtilities.equal(this.datasetToRangeAxesMap, + that.datasetToRangeAxesMap)) { + return false; + } + if (!ObjectUtilities.equal(this.renderers, that.renderers)) { + return false; + } + if (this.renderingOrder != that.renderingOrder) { + return false; + } + if (this.columnRenderingOrder != that.columnRenderingOrder) { + return false; + } + if (this.rowRenderingOrder != that.rowRenderingOrder) { + return false; + } + if (this.domainGridlinesVisible != that.domainGridlinesVisible) { + return false; + } + if (this.domainGridlinePosition != that.domainGridlinePosition) { + return false; + } + if (!ObjectUtilities.equal(this.domainGridlineStroke, + that.domainGridlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.domainGridlinePaint, + that.domainGridlinePaint)) { + return false; + } + if (this.rangeGridlinesVisible != that.rangeGridlinesVisible) { + return false; + } + if (!ObjectUtilities.equal(this.rangeGridlineStroke, + that.rangeGridlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.rangeGridlinePaint, + that.rangeGridlinePaint)) { + return false; + } + if (this.anchorValue != that.anchorValue) { + return false; + } + if (this.rangeCrosshairVisible != that.rangeCrosshairVisible) { + return false; + } + if (this.rangeCrosshairValue != that.rangeCrosshairValue) { + return false; + } + if (!ObjectUtilities.equal(this.rangeCrosshairStroke, + that.rangeCrosshairStroke)) { + return false; + } + if (!PaintUtilities.equal(this.rangeCrosshairPaint, + that.rangeCrosshairPaint)) { + return false; + } + if (this.rangeCrosshairLockedOnData + != that.rangeCrosshairLockedOnData) { + return false; + } + if (!ObjectUtilities.equal(this.foregroundDomainMarkers, + that.foregroundDomainMarkers)) { + return false; + } + if (!ObjectUtilities.equal(this.backgroundDomainMarkers, + that.backgroundDomainMarkers)) { + return false; + } + if (!ObjectUtilities.equal(this.foregroundRangeMarkers, + that.foregroundRangeMarkers)) { + return false; + } + if (!ObjectUtilities.equal(this.backgroundRangeMarkers, + that.backgroundRangeMarkers)) { + return false; + } + if (!ObjectUtilities.equal(this.annotations, that.annotations)) { + return false; + } + if (this.weight != that.weight) { + return false; + } + if (!ObjectUtilities.equal(this.fixedDomainAxisSpace, + that.fixedDomainAxisSpace)) { + return false; + } + if (!ObjectUtilities.equal(this.fixedRangeAxisSpace, + that.fixedRangeAxisSpace)) { + return false; + } + if (!ObjectUtilities.equal(this.fixedLegendItems, + that.fixedLegendItems)) { + return false; + } + if (this.domainCrosshairVisible != that.domainCrosshairVisible) { + return false; + } + if (this.crosshairDatasetIndex != that.crosshairDatasetIndex) { + return false; + } + if (!ObjectUtilities.equal(this.domainCrosshairColumnKey, + that.domainCrosshairColumnKey)) { + return false; + } + if (!ObjectUtilities.equal(this.domainCrosshairRowKey, + that.domainCrosshairRowKey)) { + return false; + } + if (!PaintUtilities.equal(this.domainCrosshairPaint, + that.domainCrosshairPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.domainCrosshairStroke, + that.domainCrosshairStroke)) { + return false; + } + if (this.rangeMinorGridlinesVisible + != that.rangeMinorGridlinesVisible) { + return false; + } + if (!PaintUtilities.equal(this.rangeMinorGridlinePaint, + that.rangeMinorGridlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.rangeMinorGridlineStroke, + that.rangeMinorGridlineStroke)) { + return false; + } + if (this.rangeZeroBaselineVisible != that.rangeZeroBaselineVisible) { + return false; + } + if (!PaintUtilities.equal(this.rangeZeroBaselinePaint, + that.rangeZeroBaselinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.rangeZeroBaselineStroke, + that.rangeZeroBaselineStroke)) { + return false; + } + if (!ObjectUtilities.equal(this.shadowGenerator, + that.shadowGenerator)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the plot. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + + CategoryPlot clone = (CategoryPlot) super.clone(); + + clone.domainAxes = new ObjectList(); + for (int i = 0; i < this.domainAxes.size(); i++) { + CategoryAxis xAxis = (CategoryAxis) this.domainAxes.get(i); + if (xAxis != null) { + CategoryAxis clonedAxis = (CategoryAxis) xAxis.clone(); + clone.setDomainAxis(i, clonedAxis); + } + } + clone.domainAxisLocations + = (ObjectList) this.domainAxisLocations.clone(); + + clone.rangeAxes = new ObjectList(); + for (int i = 0; i < this.rangeAxes.size(); i++) { + ValueAxis yAxis = (ValueAxis) this.rangeAxes.get(i); + if (yAxis != null) { + ValueAxis clonedAxis = (ValueAxis) yAxis.clone(); + clone.setRangeAxis(i, clonedAxis); + } + } + clone.rangeAxisLocations = (ObjectList) this.rangeAxisLocations.clone(); + + clone.datasets = (ObjectList) this.datasets.clone(); + for (int i = 0; i < clone.datasets.size(); i++) { + CategoryDataset dataset = clone.getDataset(i); + if (dataset != null) { + dataset.addChangeListener(clone); + } + } + clone.datasetToDomainAxesMap = new TreeMap(); + clone.datasetToDomainAxesMap.putAll(this.datasetToDomainAxesMap); + clone.datasetToRangeAxesMap = new TreeMap(); + clone.datasetToRangeAxesMap.putAll(this.datasetToRangeAxesMap); + + clone.renderers = (ObjectList) this.renderers.clone(); + for (int i = 0; i < this.renderers.size(); i++) { + CategoryItemRenderer renderer2 = (CategoryItemRenderer) + this.renderers.get(i); + if (renderer2 instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) renderer2; + CategoryItemRenderer rc = (CategoryItemRenderer) pc.clone(); + clone.renderers.set(i, rc); + rc.setPlot(clone); + rc.addChangeListener(clone); + } + } + if (this.fixedDomainAxisSpace != null) { + clone.fixedDomainAxisSpace = (AxisSpace) ObjectUtilities.clone( + this.fixedDomainAxisSpace); + } + if (this.fixedRangeAxisSpace != null) { + clone.fixedRangeAxisSpace = (AxisSpace) ObjectUtilities.clone( + this.fixedRangeAxisSpace); + } + + clone.annotations = (List) ObjectUtilities.deepClone(this.annotations); + clone.foregroundDomainMarkers = cloneMarkerMap( + this.foregroundDomainMarkers); + clone.backgroundDomainMarkers = cloneMarkerMap( + this.backgroundDomainMarkers); + clone.foregroundRangeMarkers = cloneMarkerMap( + this.foregroundRangeMarkers); + clone.backgroundRangeMarkers = cloneMarkerMap( + this.backgroundRangeMarkers); + if (this.fixedLegendItems != null) { + clone.fixedLegendItems + = (LegendItemCollection) this.fixedLegendItems.clone(); + } + return clone; + + } + + /** + * A utility method to clone the marker maps. + * + * @param map the map to clone. + * + * @return A clone of the map. + * + * @throws CloneNotSupportedException if there is some problem cloning the + * map. + */ + private Map cloneMarkerMap(Map map) throws CloneNotSupportedException { + Map clone = new HashMap(); + Set keys = map.keySet(); + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Object key = iterator.next(); + List entry = (List) map.get(key); + Object toAdd = ObjectUtilities.deepClone(entry); + clone.put(key, toAdd); + } + 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.writeStroke(this.domainGridlineStroke, stream); + SerialUtilities.writePaint(this.domainGridlinePaint, stream); + SerialUtilities.writeStroke(this.rangeGridlineStroke, stream); + SerialUtilities.writePaint(this.rangeGridlinePaint, stream); + SerialUtilities.writeStroke(this.rangeCrosshairStroke, stream); + SerialUtilities.writePaint(this.rangeCrosshairPaint, stream); + SerialUtilities.writeStroke(this.domainCrosshairStroke, stream); + SerialUtilities.writePaint(this.domainCrosshairPaint, stream); + SerialUtilities.writeStroke(this.rangeMinorGridlineStroke, stream); + SerialUtilities.writePaint(this.rangeMinorGridlinePaint, stream); + SerialUtilities.writeStroke(this.rangeZeroBaselineStroke, stream); + SerialUtilities.writePaint(this.rangeZeroBaselinePaint, 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.domainGridlineStroke = SerialUtilities.readStroke(stream); + this.domainGridlinePaint = SerialUtilities.readPaint(stream); + this.rangeGridlineStroke = SerialUtilities.readStroke(stream); + this.rangeGridlinePaint = SerialUtilities.readPaint(stream); + this.rangeCrosshairStroke = SerialUtilities.readStroke(stream); + this.rangeCrosshairPaint = SerialUtilities.readPaint(stream); + this.domainCrosshairStroke = SerialUtilities.readStroke(stream); + this.domainCrosshairPaint = SerialUtilities.readPaint(stream); + this.rangeMinorGridlineStroke = SerialUtilities.readStroke(stream); + this.rangeMinorGridlinePaint = SerialUtilities.readPaint(stream); + this.rangeZeroBaselineStroke = SerialUtilities.readStroke(stream); + this.rangeZeroBaselinePaint = SerialUtilities.readPaint(stream); + + for (int i = 0; i < this.domainAxes.size(); i++) { + CategoryAxis xAxis = (CategoryAxis) this.domainAxes.get(i); + if (xAxis != null) { + xAxis.setPlot(this); + xAxis.addChangeListener(this); + } + } + for (int i = 0; i < this.rangeAxes.size(); i++) { + ValueAxis yAxis = (ValueAxis) this.rangeAxes.get(i); + if (yAxis != null) { + yAxis.setPlot(this); + yAxis.addChangeListener(this); + } + } + int datasetCount = this.datasets.size(); + for (int i = 0; i < datasetCount; i++) { + Dataset dataset = (Dataset) this.datasets.get(i); + if (dataset != null) { + dataset.addChangeListener(this); + } + } + int rendererCount = this.renderers.size(); + for (int i = 0; i < rendererCount; i++) { + CategoryItemRenderer renderer + = (CategoryItemRenderer) this.renderers.get(i); + if (renderer != null) { + renderer.addChangeListener(this); + } + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ColorPalette.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ColorPalette.java new file mode 100755 index 0000000..40c3719 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ColorPalette.java @@ -0,0 +1,473 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * ColorPalette.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); + * 26-Mar-2003 : Implemented Serializable (DG); + * 14-Aug-2003 : Implemented Cloneable (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 31-Jan-2007 : Deprecated (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.Color; +import java.awt.Paint; +import java.io.Serializable; +import java.util.Arrays; + +import org.jfree.chart.axis.ValueTick; +import org.jfree.chart.renderer.xy.XYBlockRenderer; + +/** + * Defines palette used by {@link ContourPlot}. + * + * @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 abstract class ColorPalette implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -9029901853079622051L; + + /** The min z-axis value. */ + protected double minZ = -1; + + /** The max z-axis value. */ + protected double maxZ = -1; + + /** Red components. */ + protected int[] r; + + /** Green components. */ + protected int[] g; + + /** Blue components. */ + protected int[] b; + + /** Tick values are stored for use with stepped palette. */ + protected double[] tickValues = null; + + /** Logscale? */ + protected boolean logscale = false; + + /** Inverse palette (ie, min and max colors are reversed). */ + protected boolean inverse = false; + + /** The palette name. */ + protected String paletteName = null; + + /** Controls whether palette colors are stepped (not continuous). */ + protected boolean stepped = false; + + /** Constant for converting loge to log10. */ + protected static final double log10 = Math.log(10); + + /** + * Default contructor. + */ + public ColorPalette() { + super(); + } + + /** + * Returns the color associated with a value. + * + * @param value the value. + * + * @return The color. + */ + public Paint getColor(double value) { + int izV = (int) (253 * (value - this.minZ) + / (this.maxZ - this.minZ)) + 2; + return new Color(this.r[izV], this.g[izV], this.b[izV]); + } + + /** + * Returns a color. + * + * @param izV the index into the palette (zero based). + * + * @return The color. + */ + public Color getColor(int izV) { + return new Color(this.r[izV], this.g[izV], this.b[izV]); + } + + /** + * Returns Color by mapping a given value to a linear palette. + * + * @param value the value. + * + * @return The color. + */ + public Color getColorLinear(double value) { + int izV; + if (this.stepped) { + int index = Arrays.binarySearch(this.tickValues, value); + if (index < 0) { + index = -1 * index - 2; + } + + if (index < 0) { // For the case were the first tick is greater + // than minZ + value = this.minZ; + } + else { + value = this.tickValues[index]; + } + } + izV = (int) (253 * (value - this.minZ) / (this.maxZ - this.minZ)) + 2; + izV = Math.min(izV, 255); + izV = Math.max(izV, 2); + return getColor(izV); + } + + /** + * Returns Color by mapping a given value to a common log palette. + * + * @param value the value. + * + * @return The color. + */ + public Color getColorLog(double value) { + int izV; + double minZtmp = this.minZ; + double maxZtmp = this.maxZ; + if (this.minZ <= 0.0) { +// negatives = true; + this.maxZ = maxZtmp - minZtmp + 1; + this.minZ = 1; + value = value - minZtmp + 1; + } + double minZlog = Math.log(this.minZ) / log10; + double maxZlog = Math.log(this.maxZ) / log10; + value = Math.log(value) / log10; + // value = Math.pow(10,value); + if (this.stepped) { + int numSteps = this.tickValues.length; + int steps = 256 / (numSteps - 1); + izV = steps * (int) (numSteps * (value - minZlog) + / (maxZlog - minZlog)) + 2; + // izV = steps*numSteps*(int)((value/minZ)/(maxZlog-minZlog)) + 2; + } + else { + izV = (int) (253 * (value - minZlog) / (maxZlog - minZlog)) + 2; + } + izV = Math.min(izV, 255); + izV = Math.max(izV, 2); + + this.minZ = minZtmp; + this.maxZ = maxZtmp; + + return getColor(izV); + } + + /** + * Returns the maximum Z value. + * + * @return The value. + */ + public double getMaxZ() { + return this.maxZ; + } + + /** + * Returns the minimum Z value. + * + * @return The value. + */ + public double getMinZ() { + return this.minZ; + } + + /** + * Returns Paint by mapping a given value to a either a linear or common + * log palette as controlled by the value logscale. + * + * @param value the value. + * + * @return The paint. + */ + public Paint getPaint(double value) { + if (isLogscale()) { + return getColorLog(value); + } + else { + return getColorLinear(value); + } + } + + /** + * Returns the palette name. + * + * @return The palette name. + */ + public String getPaletteName () { + return this.paletteName; + } + + /** + * Returns the tick values. + * + * @return The tick values. + */ + public double[] getTickValues() { + return this.tickValues; + } + + /** + * Called to initialize the palette's color indexes + */ + public abstract void initialize(); + + /** + * Inverts Palette + */ + public void invertPalette() { + + int[] red = new int[256]; + int[] green = new int[256]; + int[] blue = new int[256]; + for (int i = 0; i < 256; i++) { + red[i] = this.r[i]; + green[i] = this.g[i]; + blue[i] = this.b[i]; + } + + for (int i = 2; i < 256; i++) { + this.r[i] = red[257 - i]; + this.g[i] = green[257 - i]; + this.b[i] = blue[257 - i]; + } + } + + /** + * Returns the inverse flag. + * + * @return The flag. + */ + public boolean isInverse () { + return this.inverse; + } + + /** + * Returns the log-scale flag. + * + * @return The flag. + */ + public boolean isLogscale() { + return this.logscale; + } + + /** + * Returns the 'is-stepped' flag. + * + * @return The flag. + */ + public boolean isStepped () { + return this.stepped; + } + + /** + * Sets the inverse flag. + * + * @param inverse the new value. + */ + public void setInverse (boolean inverse) { + this.inverse = inverse; + initialize(); + if (inverse) { + invertPalette(); + } + } + + /** + * Sets the 'log-scale' flag. + * + * @param logscale the new value. + */ + public void setLogscale(boolean logscale) { + this.logscale = logscale; + } + + /** + * Sets the maximum Z value. + * + * @param newMaxZ the new value. + */ + public void setMaxZ(double newMaxZ) { + this.maxZ = newMaxZ; + } + + /** + * Sets the minimum Z value. + * + * @param newMinZ the new value. + */ + public void setMinZ(double newMinZ) { + this.minZ = newMinZ; + } + + /** + * Sets the palette name. + * + * @param paletteName the name. + */ + public void setPaletteName (String paletteName) { + this.paletteName = paletteName; + } + + /** + * Sets the stepped flag. + * + * @param stepped the flag. + */ + public void setStepped (boolean stepped) { + this.stepped = stepped; + } + + /** + * Sets the tick values. + * + * @param newTickValues the tick values. + */ + public void setTickValues(double[] newTickValues) { + this.tickValues = newTickValues; + } + + /** + * Store ticks. Required when doing stepped axis + * + * @param ticks the ticks. + */ + public void setTickValues(java.util.List ticks) { + this.tickValues = new double[ticks.size()]; + for (int i = 0; i < this.tickValues.length; i++) { + this.tickValues[i] = ((ValueTick) ticks.get(i)).getValue(); + } + } + + /** + * Tests an object for equality with this instance. + * + * @param o the object to test. + * + * @return A boolean. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof ColorPalette)) { + return false; + } + + ColorPalette colorPalette = (ColorPalette) o; + + if (this.inverse != colorPalette.inverse) { + return false; + } + if (this.logscale != colorPalette.logscale) { + return false; + } + if (this.maxZ != colorPalette.maxZ) { + return false; + } + if (this.minZ != colorPalette.minZ) { + return false; + } + if (this.stepped != colorPalette.stepped) { + return false; + } + if (!Arrays.equals(this.b, colorPalette.b)) { + return false; + } + if (!Arrays.equals(this.g, colorPalette.g)) { + return false; + } + if (this.paletteName != null + ? !this.paletteName.equals(colorPalette.paletteName) + : colorPalette.paletteName != null) { + return false; + } + if (!Arrays.equals(this.r, colorPalette.r)) { + return false; + } + if (!Arrays.equals(this.tickValues, colorPalette.tickValues)) { + return false; + } + + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result; + long temp; + temp = Double.doubleToLongBits(this.minZ); + result = (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.maxZ); + result = 29 * result + (int) (temp ^ (temp >>> 32)); + result = 29 * result + (this.logscale ? 1 : 0); + result = 29 * result + (this.inverse ? 1 : 0); + result = 29 * result + + (this.paletteName != null ? this.paletteName.hashCode() : 0); + result = 29 * result + (this.stepped ? 1 : 0); + return result; + } + + /** + * Returns a clone of the palette. + * + * @return A clone. + * + * @throws CloneNotSupportedException never. + */ + @Override + public Object clone() throws CloneNotSupportedException { + ColorPalette clone = (ColorPalette) super.clone(); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java new file mode 100755 index 0000000..ea6e00a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CombinedDomainCategoryPlot.java @@ -0,0 +1,699 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * CombinedDomainCategoryPlot.java + * ------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Nicolas Brodu; + * + * Changes: + * -------- + * 16-May-2003 : Version 1 (DG); + * 08-Aug-2003 : Adjusted totalWeight in remove() method (DG); + * 19-Aug-2003 : Added equals() method, implemented Cloneable and + * Serializable (DG); + * 11-Sep-2003 : Fix cloning support (subplots) (NB); + * 15-Sep-2003 : Implemented PublicCloneable (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 17-Sep-2003 : Updated handling of 'clicks' (DG); + * 04-May-2004 : Added getter/setter methods for 'gap' attribute (DG); + * 12-Nov-2004 : Implemented the Zoomable interface (DG); + * 25-Nov-2004 : Small update to clone() implementation (DG); + * 21-Feb-2005 : The getLegendItems() method now returns the fixed legend + * items if set (DG); + * 05-May-2005 : Updated draw() method parameters (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 13-Sep-2006 : Updated API docs (DG); + * 30-Oct-2006 : Added new getCategoriesForAxis() override (DG); + * 17-Apr-2007 : Added null argument checks to findSubplot() (DG); + * 14-Nov-2007 : Updated setFixedRangeAxisSpaceForSubplots() method (DG); + * 27-Mar-2008 : Add documentation for getDataRange() method (DG); + * 31-Mar-2008 : Updated getSubplots() to return EMPTY_LIST for null + * subplots, as suggested by Richard West (DG); + * 28-Apr-2008 : Fixed zooming problem (see bug 1950037) (DG); + * 26-Jun-2008 : Fixed crosshair support (DG); + * 11-Aug-2008 : Don't store totalWeight of subplots, calculate it as + * required (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.Graphics2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.axis.AxisSpace; +import org.jfree.chart.axis.AxisState; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.event.PlotChangeListener; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ShadowGenerator; +import org.jfree.data.Range; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectUtilities; + +/** + * A combined category plot where the domain axis is shared. + */ +public class CombinedDomainCategoryPlot extends CategoryPlot + implements PlotChangeListener { + + /** For serialization. */ + private static final long serialVersionUID = 8207194522653701572L; + + /** Storage for the subplot references. */ + private List subplots; + + /** The gap between subplots. */ + private double gap; + + /** Temporary storage for the subplot areas. */ + private transient Rectangle2D[] subplotAreas; + // TODO: move the above to the plot state + + /** + * Default constructor. + */ + public CombinedDomainCategoryPlot() { + this(new CategoryAxis()); + } + + /** + * Creates a new plot. + * + * @param domainAxis the shared domain axis (null not + * permitted). + */ + public CombinedDomainCategoryPlot(CategoryAxis domainAxis) { + super(null, domainAxis, null, null); + this.subplots = new java.util.ArrayList(); + this.gap = 5.0; + } + + /** + * Returns the space between subplots. The default value is 5.0. + * + * @return The gap (in Java2D units). + * + * @see #setGap(double) + */ + public double getGap() { + return this.gap; + } + + /** + * Sets the amount of space between subplots and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param gap the gap between subplots (in Java2D units). + * + * @see #getGap() + */ + public void setGap(double gap) { + this.gap = gap; + fireChangeEvent(); + } + + /** + * Adds a subplot to the combined chart and sends a {@link PlotChangeEvent} + * to all registered listeners. + *

+ * The domain axis for the subplot will be set to null. You + * must ensure that the subplot has a non-null range axis. + * + * @param subplot the subplot (null not permitted). + */ + public void add(CategoryPlot subplot) { + add(subplot, 1); + } + + /** + * Adds a subplot to the combined chart and sends a {@link PlotChangeEvent} + * to all registered listeners. + *

+ * The domain axis for the subplot will be set to null. You + * must ensure that the subplot has a non-null range axis. + * + * @param subplot the subplot (null not permitted). + * @param weight the weight (must be >= 1). + */ + public void add(CategoryPlot subplot, int weight) { + ParamChecks.nullNotPermitted(subplot, "subplot"); + if (weight < 1) { + throw new IllegalArgumentException("Require weight >= 1."); + } + subplot.setParent(this); + subplot.setWeight(weight); + subplot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); + subplot.setDomainAxis(null); + subplot.setOrientation(getOrientation()); + subplot.addChangeListener(this); + this.subplots.add(subplot); + CategoryAxis axis = getDomainAxis(); + if (axis != null) { + axis.configure(); + } + fireChangeEvent(); + } + + /** + * Removes a subplot from the combined chart. Potentially, this removes + * some unique categories from the overall union of the datasets...so the + * domain axis is reconfigured, then a {@link PlotChangeEvent} is sent to + * all registered listeners. + * + * @param subplot the subplot (null not permitted). + */ + public void remove(CategoryPlot subplot) { + ParamChecks.nullNotPermitted(subplot, "subplot"); + int position = -1; + int size = this.subplots.size(); + int i = 0; + while (position == -1 && i < size) { + if (this.subplots.get(i) == subplot) { + position = i; + } + i++; + } + if (position != -1) { + this.subplots.remove(position); + subplot.setParent(null); + subplot.removeChangeListener(this); + CategoryAxis domain = getDomainAxis(); + if (domain != null) { + domain.configure(); + } + fireChangeEvent(); + } + } + + /** + * Returns the list of subplots. The returned list may be empty, but is + * never null. + * + * @return An unmodifiable list of subplots. + */ + public List getSubplots() { + if (this.subplots != null) { + return Collections.unmodifiableList(this.subplots); + } + else { + return Collections.EMPTY_LIST; + } + } + + /** + * Returns the subplot (if any) that contains the (x, y) point (specified + * in Java2D space). + * + * @param info the chart rendering info (null not permitted). + * @param source the source point (null not permitted). + * + * @return A subplot (possibly null). + */ + public CategoryPlot findSubplot(PlotRenderingInfo info, Point2D source) { + ParamChecks.nullNotPermitted(info, "info"); + ParamChecks.nullNotPermitted(source, "source"); + CategoryPlot result = null; + int subplotIndex = info.getSubplotIndex(source); + if (subplotIndex >= 0) { + result = (CategoryPlot) this.subplots.get(subplotIndex); + } + return result; + } + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info (null not permitted). + * @param source the source point (null not permitted). + */ + @Override + public void zoomRangeAxes(double factor, PlotRenderingInfo info, + Point2D source) { + zoomRangeAxes(factor, info, source, false); + } + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info (null not permitted). + * @param source the source point (null not permitted). + * @param useAnchor zoom about the anchor point? + */ + @Override + public void zoomRangeAxes(double factor, PlotRenderingInfo info, + Point2D source, boolean useAnchor) { + // delegate 'info' and 'source' argument checks... + CategoryPlot subplot = findSubplot(info, source); + if (subplot != null) { + subplot.zoomRangeAxes(factor, info, source, useAnchor); + } + else { + // if the source point doesn't fall within a subplot, we do the + // zoom on all subplots... + Iterator iterator = getSubplots().iterator(); + while (iterator.hasNext()) { + subplot = (CategoryPlot) iterator.next(); + subplot.zoomRangeAxes(factor, info, source, useAnchor); + } + } + } + + /** + * Zooms in on the range axes. + * + * @param lowerPercent the lower bound. + * @param upperPercent the upper bound. + * @param info the plot rendering info (null not permitted). + * @param source the source point (null not permitted). + */ + @Override + public void zoomRangeAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo info, Point2D source) { + // delegate 'info' and 'source' argument checks... + CategoryPlot subplot = findSubplot(info, source); + if (subplot != null) { + subplot.zoomRangeAxes(lowerPercent, upperPercent, info, source); + } + else { + // if the source point doesn't fall within a subplot, we do the + // zoom on all subplots... + Iterator iterator = getSubplots().iterator(); + while (iterator.hasNext()) { + subplot = (CategoryPlot) iterator.next(); + subplot.zoomRangeAxes(lowerPercent, upperPercent, info, source); + } + } + } + + /** + * Calculates the space required for the axes. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * + * @return The space required for the axes. + */ + @Override + protected AxisSpace calculateAxisSpace(Graphics2D g2, + Rectangle2D plotArea) { + + AxisSpace space = new AxisSpace(); + PlotOrientation orientation = getOrientation(); + + // work out the space required by the domain axis... + AxisSpace fixed = getFixedDomainAxisSpace(); + if (fixed != null) { + if (orientation == PlotOrientation.HORIZONTAL) { + space.setLeft(fixed.getLeft()); + space.setRight(fixed.getRight()); + } + else if (orientation == PlotOrientation.VERTICAL) { + space.setTop(fixed.getTop()); + space.setBottom(fixed.getBottom()); + } + } + else { + CategoryAxis categoryAxis = getDomainAxis(); + RectangleEdge categoryEdge = Plot.resolveDomainAxisLocation( + getDomainAxisLocation(), orientation); + if (categoryAxis != null) { + space = categoryAxis.reserveSpace(g2, this, plotArea, + categoryEdge, space); + } + else { + if (getDrawSharedDomainAxis()) { + space = getDomainAxis().reserveSpace(g2, this, plotArea, + categoryEdge, space); + } + } + } + + Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); + + // work out the maximum height or width of the non-shared axes... + int n = this.subplots.size(); + int totalWeight = 0; + for (int i = 0; i < n; i++) { + CategoryPlot sub = (CategoryPlot) this.subplots.get(i); + totalWeight += sub.getWeight(); + } + this.subplotAreas = new Rectangle2D[n]; + double x = adjustedPlotArea.getX(); + double y = adjustedPlotArea.getY(); + double usableSize = 0.0; + if (orientation == PlotOrientation.HORIZONTAL) { + usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1); + } + else if (orientation == PlotOrientation.VERTICAL) { + usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1); + } + + for (int i = 0; i < n; i++) { + CategoryPlot plot = (CategoryPlot) this.subplots.get(i); + + // calculate sub-plot area + if (orientation == PlotOrientation.HORIZONTAL) { + double w = usableSize * plot.getWeight() / totalWeight; + this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, + adjustedPlotArea.getHeight()); + x = x + w + this.gap; + } + else if (orientation == PlotOrientation.VERTICAL) { + double h = usableSize * plot.getWeight() / totalWeight; + this.subplotAreas[i] = new Rectangle2D.Double(x, y, + adjustedPlotArea.getWidth(), h); + y = y + h + this.gap; + } + + AxisSpace subSpace = plot.calculateRangeAxisSpace(g2, + this.subplotAreas[i], null); + space.ensureAtLeast(subSpace); + + } + + return space; + } + + /** + * Draws the plot on a Java 2D graphics device (such as the screen or a + * printer). Will perform all the placement calculations for each of the + * sub-plots and then tell these to draw themselves. + * + * @param g2 the graphics device. + * @param area the area within which the plot (including axis labels) + * should be drawn. + * @param anchor the anchor point (null permitted). + * @param parentState the state from the parent plot, if there is one. + * @param info collects information about the drawing (null + * permitted). + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, PlotRenderingInfo info) { + + // set up info collection... + if (info != null) { + info.setPlotArea(area); + } + + // adjust the drawing area for plot insets (if any)... + RectangleInsets insets = getInsets(); + area.setRect(area.getX() + insets.getLeft(), + area.getY() + insets.getTop(), + area.getWidth() - insets.getLeft() - insets.getRight(), + area.getHeight() - insets.getTop() - insets.getBottom()); + + + // calculate the data area... + setFixedRangeAxisSpaceForSubplots(null); + AxisSpace space = calculateAxisSpace(g2, area); + Rectangle2D dataArea = space.shrink(area, null); + + // set the width and height of non-shared axis of all sub-plots + setFixedRangeAxisSpaceForSubplots(space); + + // draw the shared axis + CategoryAxis axis = getDomainAxis(); + RectangleEdge domainEdge = getDomainAxisEdge(); + double cursor = RectangleEdge.coordinate(dataArea, domainEdge); + AxisState axisState = axis.draw(g2, cursor, area, dataArea, + domainEdge, info); + if (parentState == null) { + parentState = new PlotState(); + } + parentState.getSharedAxisStates().put(axis, axisState); + + // draw all the subplots + for (int i = 0; i < this.subplots.size(); i++) { + CategoryPlot plot = (CategoryPlot) this.subplots.get(i); + PlotRenderingInfo subplotInfo = null; + if (info != null) { + subplotInfo = new PlotRenderingInfo(info.getOwner()); + info.addSubplotInfo(subplotInfo); + } + Point2D subAnchor = null; + if (anchor != null && this.subplotAreas[i].contains(anchor)) { + subAnchor = anchor; + } + plot.draw(g2, this.subplotAreas[i], subAnchor, parentState, + subplotInfo); + } + + if (info != null) { + info.setDataArea(dataArea); + } + + } + + /** + * Sets the size (width or height, depending on the orientation of the + * plot) for the range axis of each subplot. + * + * @param space the space (null permitted). + */ + protected void setFixedRangeAxisSpaceForSubplots(AxisSpace space) { + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + CategoryPlot plot = (CategoryPlot) iterator.next(); + plot.setFixedRangeAxisSpace(space, false); + } + } + + /** + * Sets the orientation of the plot (and all subplots). + * + * @param orientation the orientation (null not permitted). + */ + @Override + public void setOrientation(PlotOrientation orientation) { + super.setOrientation(orientation); + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + CategoryPlot plot = (CategoryPlot) iterator.next(); + plot.setOrientation(orientation); + } + + } + + /** + * Sets the shadow generator for the plot (and all subplots) and sends + * a {@link PlotChangeEvent} to all registered listeners. + * + * @param generator the new generator (null permitted). + */ + @Override + public void setShadowGenerator(ShadowGenerator generator) { + setNotify(false); + super.setShadowGenerator(generator); + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + CategoryPlot plot = (CategoryPlot) iterator.next(); + plot.setShadowGenerator(generator); + } + setNotify(true); + } + + /** + * Returns a range representing the extent of the data values in this plot + * (obtained from the subplots) that will be rendered against the specified + * axis. NOTE: This method is intended for internal JFreeChart use, and + * is public only so that code in the axis classes can call it. Since, + * for this class, the domain axis is a {@link CategoryAxis} + * (not a ValueAxisnull permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CombinedDomainCategoryPlot)) { + return false; + } + CombinedDomainCategoryPlot that = (CombinedDomainCategoryPlot) obj; + if (this.gap != that.gap) { + return false; + } + if (!ObjectUtilities.equal(this.subplots, that.subplots)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the plot. + * + * @return A clone. + * + * @throws CloneNotSupportedException this class will not throw this + * exception, but subclasses (if any) might. + */ + @Override + public Object clone() throws CloneNotSupportedException { + + CombinedDomainCategoryPlot result + = (CombinedDomainCategoryPlot) super.clone(); + result.subplots = (List) ObjectUtilities.deepClone(this.subplots); + for (Iterator it = result.subplots.iterator(); it.hasNext();) { + Plot child = (Plot) it.next(); + child.setParent(result); + } + return result; + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CombinedDomainXYPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CombinedDomainXYPlot.java new file mode 100755 index 0000000..d0aa945 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CombinedDomainXYPlot.java @@ -0,0 +1,763 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * CombinedDomainXYPlot.java + * ------------------------- + * (C) Copyright 2001-2012, by Bill Kelemen and Contributors. + * + * Original Author: Bill Kelemen; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Anthony Boulestreau; + * David Basten; + * Kevin Frechette (for ISTI); + * Nicolas Brodu; + * Petr Kubanek (bug 1606205); + * + * Changes: + * -------- + * 06-Dec-2001 : Version 1 (BK); + * 12-Dec-2001 : Removed unnecessary 'throws' clause from constructor (DG); + * 18-Dec-2001 : Added plotArea attribute and get/set methods (BK); + * 22-Dec-2001 : Fixed bug in chartChanged with multiple combinations of + * CombinedPlots (BK); + * 08-Jan-2002 : Moved to new package com.jrefinery.chart.combination (DG); + * 25-Feb-2002 : Updated import statements (DG); + * 28-Feb-2002 : Readded "this.plotArea = plotArea" that was deleted from + * draw() method (BK); + * 26-Mar-2002 : Added an empty zoom method (this method needs to be written so + * that combined plots will support zooming (DG); + * 29-Mar-2002 : Changed the method createCombinedAxis adding the creation of + * OverlaidSymbolicAxis and CombinedSymbolicAxis(AB); + * 23-Apr-2002 : Renamed CombinedPlot-->MultiXYPlot, and simplified the + * structure (DG); + * 23-May-2002 : Renamed (again) MultiXYPlot-->CombinedXYPlot (DG); + * 19-Jun-2002 : Added get/setGap() methods suggested by David Basten (DG); + * 25-Jun-2002 : Removed redundant imports (DG); + * 16-Jul-2002 : Draws shared axis after subplots (to fix missing gridlines), + * added overrides of 'setSeriesPaint()' and 'setXYItemRenderer()' + * that pass changes down to subplots (KF); + * 09-Oct-2002 : Added add(XYPlot) method (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 16-May-2003 : Renamed CombinedXYPlot --> CombinedDomainXYPlot (DG); + * 04-Aug-2003 : Removed leftover code that was causing domain axis drawing + * problem (DG); + * 08-Aug-2003 : Adjusted totalWeight in remove() method (DG); + * 21-Aug-2003 : Implemented Cloneable (DG); + * 11-Sep-2003 : Fix cloning support (subplots) (NB); + * 15-Sep-2003 : Fixed error in cloning (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 17-Sep-2003 : Updated handling of 'clicks' (DG); + * 12-Nov-2004 : Implemented the new Zoomable interface (DG); + * 25-Nov-2004 : Small update to clone() implementation (DG); + * 21-Feb-2005 : The getLegendItems() method now returns the fixed legend + * items if set (DG); + * 05-May-2005 : Removed unused draw() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 23-Aug-2006 : Override setFixedRangeAxisSpace() to update subplots (DG); + * 06-Feb-2007 : Fixed bug 1606205, draw shared axis after subplots (DG); + * 23-Mar-2007 : Reverted previous patch (bug fix 1606205) (DG); + * 17-Apr-2007 : Added null argument checks to findSubplot() (DG); + * 27-Nov-2007 : Modified setFixedRangeAxisSpaceForSubplots() so as not to + * trigger change event in subplots (DG); + * 28-Jan-2008 : Reset fixed range axis space in subplots for each call to + * draw() (DG); + * 27-Mar-2008 : Add documentation for getDataRange() method (DG); + * 31-Mar-2008 : Updated getSubplots() to return EMPTY_LIST for null + * subplots, as suggested by Richard West (DG); + * 28-Apr-2008 : Fixed zooming problem (see bug 1950037) (DG); + * 11-Aug-2008 : Don't store totalWeight of subplots, calculate it as + * required (DG); + * 21-Dec-2011 : Apply patch 3447161 by Ulrich Voigt and Martin Hoeller (MH); + * + */ + +package org.jfree.chart.plot; + +import java.awt.Graphics2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.axis.AxisSpace; +import org.jfree.chart.axis.AxisState; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.event.PlotChangeListener; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ShadowGenerator; +import org.jfree.data.Range; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectUtilities; + +/** + * An extension of {@link XYPlot} that contains multiple subplots that share a + * common domain axis. + */ +public class CombinedDomainXYPlot extends XYPlot + implements PlotChangeListener { + + /** For serialization. */ + private static final long serialVersionUID = -7765545541261907383L; + + /** Storage for the subplot references. */ + private List subplots; + + /** The gap between subplots. */ + private double gap = 5.0; + + /** Temporary storage for the subplot areas. */ + private transient Rectangle2D[] subplotAreas; + // TODO: the subplot areas needs to be moved out of the plot into the plot + // state + + /** + * Default constructor. + */ + public CombinedDomainXYPlot() { + this(new NumberAxis()); + } + + /** + * Creates a new combined plot that shares a domain axis among multiple + * subplots. + * + * @param domainAxis the shared axis. + */ + public CombinedDomainXYPlot(ValueAxis domainAxis) { + + super(null, // no data in the parent plot + domainAxis, + null, // no range axis + null); // no renderer + + this.subplots = new java.util.ArrayList(); + + } + + /** + * Returns a string describing the type of plot. + * + * @return The type of plot. + */ + @Override + public String getPlotType() { + return "Combined_Domain_XYPlot"; + } + + /** + * Sets the orientation for the plot (also changes the orientation for all + * the subplots to match). + * + * @param orientation the orientation (null not allowed). + */ + @Override + public void setOrientation(PlotOrientation orientation) { + super.setOrientation(orientation); + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + XYPlot plot = (XYPlot) iterator.next(); + plot.setOrientation(orientation); + } + } + + /** + * Sets the shadow generator for the plot (and all subplots) and sends + * a {@link PlotChangeEvent} to all registered listeners. + * + * @param generator the new generator (null permitted). + */ + @Override + public void setShadowGenerator(ShadowGenerator generator) { + setNotify(false); + super.setShadowGenerator(generator); + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + XYPlot plot = (XYPlot) iterator.next(); + plot.setShadowGenerator(generator); + } + setNotify(true); + } + + /** + * Returns a range representing the extent of the data values in this plot + * (obtained from the subplots) that will be rendered against the specified + * axis. NOTE: This method is intended for internal JFreeChart use, and + * is public only so that code in the axis classes can call it. Since + * only the domain axis is shared between subplots, the JFreeChart code + * will only call this method for the domain values (although this is not + * checked/enforced). + * + * @param axis the axis. + * + * @return The range (possibly null). + */ + @Override + public Range getDataRange(ValueAxis axis) { + Range result = null; + if (this.subplots != null) { + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + XYPlot subplot = (XYPlot) iterator.next(); + result = Range.combine(result, subplot.getDataRange(axis)); + } + } + return result; + } + + /** + * Returns the gap between subplots, measured in Java2D units. + * + * @return The gap (in Java2D units). + * + * @see #setGap(double) + */ + public double getGap() { + return this.gap; + } + + /** + * Sets the amount of space between subplots and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param gap the gap between subplots (in Java2D units). + * + * @see #getGap() + */ + public void setGap(double gap) { + this.gap = gap; + fireChangeEvent(); + } + + /** + * Adds a subplot (with a default 'weight' of 1) and sends a + * {@link PlotChangeEvent} to all registered listeners. + *

+ * The domain axis for the subplot will be set to null. You + * must ensure that the subplot has a non-null range axis. + * + * @param subplot the subplot (null not permitted). + */ + public void add(XYPlot subplot) { + // defer argument checking + add(subplot, 1); + } + + /** + * Adds a subplot with the specified weight and sends a + * {@link PlotChangeEvent} to all registered listeners. The weight + * determines how much space is allocated to the subplot relative to all + * the other subplots. + *

+ * The domain axis for the subplot will be set to null. You + * must ensure that the subplot has a non-null range axis. + * + * @param subplot the subplot (null not permitted). + * @param weight the weight (must be >= 1). + */ + public void add(XYPlot subplot, int weight) { + ParamChecks.nullNotPermitted(subplot, "subplot"); + if (weight <= 0) { + throw new IllegalArgumentException("Require weight >= 1."); + } + + // store the plot and its weight + subplot.setParent(this); + subplot.setWeight(weight); + subplot.setInsets(RectangleInsets.ZERO_INSETS, false); + subplot.setDomainAxis(null); + subplot.addChangeListener(this); + this.subplots.add(subplot); + + ValueAxis axis = getDomainAxis(); + if (axis != null) { + axis.configure(); + } + fireChangeEvent(); + } + + /** + * Removes a subplot from the combined chart and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param subplot the subplot (null not permitted). + */ + public void remove(XYPlot subplot) { + ParamChecks.nullNotPermitted(subplot, "subplot"); + int position = -1; + int size = this.subplots.size(); + int i = 0; + while (position == -1 && i < size) { + if (this.subplots.get(i) == subplot) { + position = i; + } + i++; + } + if (position != -1) { + this.subplots.remove(position); + subplot.setParent(null); + subplot.removeChangeListener(this); + ValueAxis domain = getDomainAxis(); + if (domain != null) { + domain.configure(); + } + fireChangeEvent(); + } + } + + /** + * Returns the list of subplots. The returned list may be empty, but is + * never null. + * + * @return An unmodifiable list of subplots. + */ + public List getSubplots() { + if (this.subplots != null) { + return Collections.unmodifiableList(this.subplots); + } + else { + return Collections.EMPTY_LIST; + } + } + + /** + * Calculates the axis space required. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * + * @return The space. + */ + @Override + protected AxisSpace calculateAxisSpace(Graphics2D g2, + Rectangle2D plotArea) { + + AxisSpace space = new AxisSpace(); + PlotOrientation orientation = getOrientation(); + + // work out the space required by the domain axis... + AxisSpace fixed = getFixedDomainAxisSpace(); + if (fixed != null) { + if (orientation == PlotOrientation.HORIZONTAL) { + space.setLeft(fixed.getLeft()); + space.setRight(fixed.getRight()); + } + else if (orientation == PlotOrientation.VERTICAL) { + space.setTop(fixed.getTop()); + space.setBottom(fixed.getBottom()); + } + } + else { + ValueAxis xAxis = getDomainAxis(); + RectangleEdge xEdge = Plot.resolveDomainAxisLocation( + getDomainAxisLocation(), orientation); + if (xAxis != null) { + space = xAxis.reserveSpace(g2, this, plotArea, xEdge, space); + } + } + + Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); + + // work out the maximum height or width of the non-shared axes... + int n = this.subplots.size(); + int totalWeight = 0; + for (int i = 0; i < n; i++) { + XYPlot sub = (XYPlot) this.subplots.get(i); + totalWeight += sub.getWeight(); + } + this.subplotAreas = new Rectangle2D[n]; + double x = adjustedPlotArea.getX(); + double y = adjustedPlotArea.getY(); + double usableSize = 0.0; + if (orientation == PlotOrientation.HORIZONTAL) { + usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1); + } + else if (orientation == PlotOrientation.VERTICAL) { + usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1); + } + + for (int i = 0; i < n; i++) { + XYPlot plot = (XYPlot) this.subplots.get(i); + + // calculate sub-plot area + if (orientation == PlotOrientation.HORIZONTAL) { + double w = usableSize * plot.getWeight() / totalWeight; + this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, + adjustedPlotArea.getHeight()); + x = x + w + this.gap; + } + else if (orientation == PlotOrientation.VERTICAL) { + double h = usableSize * plot.getWeight() / totalWeight; + this.subplotAreas[i] = new Rectangle2D.Double(x, y, + adjustedPlotArea.getWidth(), h); + y = y + h + this.gap; + } + + AxisSpace subSpace = plot.calculateRangeAxisSpace(g2, + this.subplotAreas[i], null); + space.ensureAtLeast(subSpace); + + } + + return space; + } + + /** + * Draws the plot within the specified area on a graphics device. + * + * @param g2 the graphics device. + * @param area the plot area (in Java2D space). + * @param anchor an anchor point in Java2D space (null + * permitted). + * @param parentState the state from the parent plot, if there is one + * (null permitted). + * @param info collects chart drawing information (null + * permitted). + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, PlotRenderingInfo info) { + + // set up info collection... + if (info != null) { + info.setPlotArea(area); + } + + // adjust the drawing area for plot insets (if any)... + RectangleInsets insets = getInsets(); + insets.trim(area); + + setFixedRangeAxisSpaceForSubplots(null); + AxisSpace space = calculateAxisSpace(g2, area); + Rectangle2D dataArea = space.shrink(area, null); + + // set the width and height of non-shared axis of all sub-plots + setFixedRangeAxisSpaceForSubplots(space); + + // draw the shared axis + ValueAxis axis = getDomainAxis(); + RectangleEdge edge = getDomainAxisEdge(); + double cursor = RectangleEdge.coordinate(dataArea, edge); + AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info); + if (parentState == null) { + parentState = new PlotState(); + } + parentState.getSharedAxisStates().put(axis, axisState); + + // draw all the subplots + for (int i = 0; i < this.subplots.size(); i++) { + XYPlot plot = (XYPlot) this.subplots.get(i); + PlotRenderingInfo subplotInfo = null; + if (info != null) { + subplotInfo = new PlotRenderingInfo(info.getOwner()); + info.addSubplotInfo(subplotInfo); + } + plot.draw(g2, this.subplotAreas[i], anchor, parentState, + subplotInfo); + } + + if (info != null) { + info.setDataArea(dataArea); + } + + } + + /** + * Returns a collection of legend items for the plot. + * + * @return The legend items. + */ + @Override + public LegendItemCollection getLegendItems() { + LegendItemCollection result = getFixedLegendItems(); + if (result == null) { + result = new LegendItemCollection(); + if (this.subplots != null) { + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + XYPlot plot = (XYPlot) iterator.next(); + LegendItemCollection more = plot.getLegendItems(); + result.addAll(more); + } + } + } + return result; + } + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info (null not permitted). + * @param source the source point (null not permitted). + */ + @Override + public void zoomRangeAxes(double factor, PlotRenderingInfo info, + Point2D source) { + zoomRangeAxes(factor, info, source, false); + } + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param state the plot state. + * @param source the source point (in Java2D coordinates). + * @param useAnchor use source point as zoom anchor? + */ + @Override + public void zoomRangeAxes(double factor, PlotRenderingInfo state, + Point2D source, boolean useAnchor) { + // delegate 'state' and 'source' argument checks... + XYPlot subplot = findSubplot(state, source); + if (subplot != null) { + subplot.zoomRangeAxes(factor, state, source, useAnchor); + } + else { + // if the source point doesn't fall within a subplot, we do the + // zoom on all subplots... + Iterator iterator = getSubplots().iterator(); + while (iterator.hasNext()) { + subplot = (XYPlot) iterator.next(); + subplot.zoomRangeAxes(factor, state, source, useAnchor); + } + } + } + + /** + * Zooms in on the range axes. + * + * @param lowerPercent the lower bound. + * @param upperPercent the upper bound. + * @param info the plot rendering info (null not permitted). + * @param source the source point (null not permitted). + */ + @Override + public void zoomRangeAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo info, Point2D source) { + // delegate 'info' and 'source' argument checks... + XYPlot subplot = findSubplot(info, source); + if (subplot != null) { + subplot.zoomRangeAxes(lowerPercent, upperPercent, info, source); + } + else { + // if the source point doesn't fall within a subplot, we do the + // zoom on all subplots... + Iterator iterator = getSubplots().iterator(); + while (iterator.hasNext()) { + subplot = (XYPlot) iterator.next(); + subplot.zoomRangeAxes(lowerPercent, upperPercent, info, source); + } + } + } + + /** + * Pans all range axes by the specified percentage. + * + * @param panRange the distance to pan (as a percentage of the axis length). + * @param info the plot info + * @param source the source point where the pan action started. + * + * @since 1.0.15 + */ + @Override + public void panRangeAxes(double panRange, PlotRenderingInfo info, + Point2D source) { + + XYPlot subplot = findSubplot(info, source); + if (subplot != null) { + PlotRenderingInfo subplotInfo = info.getSubplotInfo( + info.getSubplotIndex(source)); + if (subplotInfo == null) { + return; + } + + for (int i = 0; i < subplot.getRangeAxisCount(); i++) { + ValueAxis rangeAxis = subplot.getRangeAxis(i); + rangeAxis.pan(panRange); + } + } + } + + /** + * Returns the subplot (if any) that contains the (x, y) point (specified + * in Java2D space). + * + * @param info the chart rendering info (null not permitted). + * @param source the source point (null not permitted). + * + * @return A subplot (possibly null). + */ + public XYPlot findSubplot(PlotRenderingInfo info, Point2D source) { + ParamChecks.nullNotPermitted(info, "info"); + ParamChecks.nullNotPermitted(source, "source"); + XYPlot result = null; + int subplotIndex = info.getSubplotIndex(source); + if (subplotIndex >= 0) { + result = (XYPlot) this.subplots.get(subplotIndex); + } + return result; + } + + /** + * Sets the item renderer FOR ALL SUBPLOTS. Registered listeners are + * notified that the plot has been modified. + *

+ * Note: usually you will want to set the renderer independently for each + * subplot, which is NOT what this method does. + * + * @param renderer the new renderer. + */ + @Override + public void setRenderer(XYItemRenderer renderer) { + super.setRenderer(renderer); // not strictly necessary, since the + // renderer set for the + // parent plot is not used + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + XYPlot plot = (XYPlot) iterator.next(); + plot.setRenderer(renderer); + } + } + + /** + * Sets the fixed range axis space and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param space the space (null permitted). + */ + @Override + public void setFixedRangeAxisSpace(AxisSpace space) { + super.setFixedRangeAxisSpace(space); + setFixedRangeAxisSpaceForSubplots(space); + fireChangeEvent(); + } + + /** + * Sets the size (width or height, depending on the orientation of the + * plot) for the domain axis of each subplot. + * + * @param space the space. + */ + protected void setFixedRangeAxisSpaceForSubplots(AxisSpace space) { + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + XYPlot plot = (XYPlot) iterator.next(); + plot.setFixedRangeAxisSpace(space, false); + } + } + + /** + * Handles a 'click' on the plot by updating the anchor values. + * + * @param x x-coordinate, where the click occured. + * @param y y-coordinate, where the click occured. + * @param info object containing information about the plot dimensions. + */ + @Override + public void handleClick(int x, int y, PlotRenderingInfo info) { + Rectangle2D dataArea = info.getDataArea(); + if (dataArea.contains(x, y)) { + for (int i = 0; i < this.subplots.size(); i++) { + XYPlot subplot = (XYPlot) this.subplots.get(i); + PlotRenderingInfo subplotInfo = info.getSubplotInfo(i); + subplot.handleClick(x, y, subplotInfo); + } + } + } + + /** + * Receives a {@link PlotChangeEvent} and responds by notifying all + * listeners. + * + * @param event the event. + */ + @Override + public void plotChanged(PlotChangeEvent event) { + notifyListeners(event); + } + + /** + * Tests this plot for equality with another object. + * + * @param obj the other object. + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CombinedDomainXYPlot)) { + return false; + } + CombinedDomainXYPlot that = (CombinedDomainXYPlot) obj; + if (this.gap != that.gap) { + return false; + } + if (!ObjectUtilities.equal(this.subplots, that.subplots)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the annotation. + * + * @return A clone. + * + * @throws CloneNotSupportedException this class will not throw this + * exception, but subclasses (if any) might. + */ + @Override + public Object clone() throws CloneNotSupportedException { + + CombinedDomainXYPlot result = (CombinedDomainXYPlot) super.clone(); + result.subplots = (List) ObjectUtilities.deepClone(this.subplots); + for (Iterator it = result.subplots.iterator(); it.hasNext();) { + Plot child = (Plot) it.next(); + child.setParent(result); + } + + // after setting up all the subplots, the shared domain axis may need + // reconfiguring + ValueAxis domainAxis = result.getDomainAxis(); + if (domainAxis != null) { + domainAxis.configure(); + } + + return result; + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java new file mode 100755 index 0000000..6e94bd3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CombinedRangeCategoryPlot.java @@ -0,0 +1,590 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * CombinedRangeCategoryPlot.java + * ------------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Nicolas Brodu; + * + * Changes: + * -------- + * 16-May-2003 : Version 1 (DG); + * 08-Aug-2003 : Adjusted totalWeight in remove() method (DG); + * 19-Aug-2003 : Implemented Cloneable (DG); + * 11-Sep-2003 : Fix cloning support (subplots) (NB); + * 15-Sep-2003 : Implemented PublicCloneable. Fixed errors in cloning and + * serialization (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 17-Sep-2003 : Updated handling of 'clicks' (DG); + * 04-May-2004 : Added getter/setter methods for 'gap' attributes (DG); + * 12-Nov-2004 : Implements the new Zoomable interface (DG); + * 25-Nov-2004 : Small update to clone() implementation (DG); + * 21-Feb-2005 : Fixed bug in remove() method (id = 1121172) (DG); + * 21-Feb-2005 : The getLegendItems() method now returns the fixed legend + * items if set (DG); + * 05-May-2005 : Updated draw() method parameters (DG); + * 14-Nov-2007 : Updated setFixedDomainAxisSpaceForSubplots() method (DG); + * 27-Mar-2008 : Add documentation for getDataRange() method (DG); + * 31-Mar-2008 : Updated getSubplots() to return EMPTY_LIST for null + * subplots, as suggested by Richard West (DG); + * 26-Jun-2008 : Fixed crosshair support (DG); + * 11-Aug-2008 : Don't store totalWeight of subplots, calculate it as + * required (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.Graphics2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.axis.AxisSpace; +import org.jfree.chart.axis.AxisState; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.event.PlotChangeListener; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ShadowGenerator; +import org.jfree.data.Range; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectUtilities; + +/** + * A combined category plot where the range axis is shared. + */ +public class CombinedRangeCategoryPlot extends CategoryPlot + implements PlotChangeListener { + + /** For serialization. */ + private static final long serialVersionUID = 7260210007554504515L; + + /** Storage for the subplot references. */ + private List subplots; + + /** The gap between subplots. */ + private double gap; + + /** Temporary storage for the subplot areas. */ + private transient Rectangle2D[] subplotArea; // TODO: move to plot state + + /** + * Default constructor. + */ + public CombinedRangeCategoryPlot() { + this(new NumberAxis()); + } + + /** + * Creates a new plot. + * + * @param rangeAxis the shared range axis. + */ + public CombinedRangeCategoryPlot(ValueAxis rangeAxis) { + super(null, null, rangeAxis, null); + this.subplots = new java.util.ArrayList(); + this.gap = 5.0; + } + + /** + * Returns the space between subplots. + * + * @return The gap (in Java2D units). + */ + public double getGap() { + return this.gap; + } + + /** + * Sets the amount of space between subplots and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param gap the gap between subplots (in Java2D units). + */ + public void setGap(double gap) { + this.gap = gap; + fireChangeEvent(); + } + + /** + * Adds a subplot (with a default 'weight' of 1) and sends a + * {@link PlotChangeEvent} to all registered listeners. + *

+ * You must ensure that the subplot has a non-null domain axis. The range + * axis for the subplot will be set to null. + * + * @param subplot the subplot (null not permitted). + */ + public void add(CategoryPlot subplot) { + // defer argument checking + add(subplot, 1); + } + + /** + * Adds a subplot and sends a {@link PlotChangeEvent} to all registered + * listeners. + *

+ * You must ensure that the subplot has a non-null domain axis. The range + * axis for the subplot will be set to null. + * + * @param subplot the subplot (null not permitted). + * @param weight the weight (must be >= 1). + */ + public void add(CategoryPlot subplot, int weight) { + ParamChecks.nullNotPermitted(subplot, "subplot"); + if (weight <= 0) { + throw new IllegalArgumentException("Require weight >= 1."); + } + // store the plot and its weight + subplot.setParent(this); + subplot.setWeight(weight); + subplot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); + subplot.setRangeAxis(null); + subplot.setOrientation(getOrientation()); + subplot.addChangeListener(this); + this.subplots.add(subplot); + // configure the range axis... + ValueAxis axis = getRangeAxis(); + if (axis != null) { + axis.configure(); + } + fireChangeEvent(); + } + + /** + * Removes a subplot from the combined chart. + * + * @param subplot the subplot (null not permitted). + */ + public void remove(CategoryPlot subplot) { + ParamChecks.nullNotPermitted(subplot, "subplot"); + int position = -1; + int size = this.subplots.size(); + int i = 0; + while (position == -1 && i < size) { + if (this.subplots.get(i) == subplot) { + position = i; + } + i++; + } + if (position != -1) { + this.subplots.remove(position); + subplot.setParent(null); + subplot.removeChangeListener(this); + + ValueAxis range = getRangeAxis(); + if (range != null) { + range.configure(); + } + + ValueAxis range2 = getRangeAxis(1); + if (range2 != null) { + range2.configure(); + } + fireChangeEvent(); + } + } + + /** + * Returns the list of subplots. The returned list may be empty, but is + * never null. + * + * @return An unmodifiable list of subplots. + */ + public List getSubplots() { + if (this.subplots != null) { + return Collections.unmodifiableList(this.subplots); + } + else { + return Collections.EMPTY_LIST; + } + } + + /** + * Calculates the space required for the axes. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * + * @return The space required for the axes. + */ + @Override + protected AxisSpace calculateAxisSpace(Graphics2D g2, + Rectangle2D plotArea) { + + AxisSpace space = new AxisSpace(); + PlotOrientation orientation = getOrientation(); + + // work out the space required by the domain axis... + AxisSpace fixed = getFixedRangeAxisSpace(); + if (fixed != null) { + if (orientation == PlotOrientation.VERTICAL) { + space.setLeft(fixed.getLeft()); + space.setRight(fixed.getRight()); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + space.setTop(fixed.getTop()); + space.setBottom(fixed.getBottom()); + } + } + else { + ValueAxis valueAxis = getRangeAxis(); + RectangleEdge valueEdge = Plot.resolveRangeAxisLocation( + getRangeAxisLocation(), orientation); + if (valueAxis != null) { + space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, + space); + } + } + + Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); + // work out the maximum height or width of the non-shared axes... + int n = this.subplots.size(); + int totalWeight = 0; + for (int i = 0; i < n; i++) { + CategoryPlot sub = (CategoryPlot) this.subplots.get(i); + totalWeight += sub.getWeight(); + } + // calculate plotAreas of all sub-plots, maximum vertical/horizontal + // axis width/height + this.subplotArea = new Rectangle2D[n]; + double x = adjustedPlotArea.getX(); + double y = adjustedPlotArea.getY(); + double usableSize = 0.0; + if (orientation == PlotOrientation.VERTICAL) { + usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1); + } + + for (int i = 0; i < n; i++) { + CategoryPlot plot = (CategoryPlot) this.subplots.get(i); + + // calculate sub-plot area + if (orientation == PlotOrientation.VERTICAL) { + double w = usableSize * plot.getWeight() / totalWeight; + this.subplotArea[i] = new Rectangle2D.Double(x, y, w, + adjustedPlotArea.getHeight()); + x = x + w + this.gap; + } + else if (orientation == PlotOrientation.HORIZONTAL) { + double h = usableSize * plot.getWeight() / totalWeight; + this.subplotArea[i] = new Rectangle2D.Double(x, y, + adjustedPlotArea.getWidth(), h); + y = y + h + this.gap; + } + + AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, + this.subplotArea[i], null); + space.ensureAtLeast(subSpace); + + } + + return space; + } + + /** + * Draws the plot on a Java 2D graphics device (such as the screen or a + * printer). Will perform all the placement calculations for each + * sub-plots and then tell these to draw themselves. + * + * @param g2 the graphics device. + * @param area the area within which the plot (including axis labels) + * should be drawn. + * @param anchor the anchor point (null permitted). + * @param parentState the parent state. + * @param info collects information about the drawing (null + * permitted). + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, + PlotRenderingInfo info) { + + // set up info collection... + if (info != null) { + info.setPlotArea(area); + } + + // adjust the drawing area for plot insets (if any)... + RectangleInsets insets = getInsets(); + insets.trim(area); + + // calculate the data area... + AxisSpace space = calculateAxisSpace(g2, area); + Rectangle2D dataArea = space.shrink(area, null); + + // set the width and height of non-shared axis of all sub-plots + setFixedDomainAxisSpaceForSubplots(space); + + // draw the shared axis + ValueAxis axis = getRangeAxis(); + RectangleEdge rangeEdge = getRangeAxisEdge(); + double cursor = RectangleEdge.coordinate(dataArea, rangeEdge); + AxisState state = axis.draw(g2, cursor, area, dataArea, rangeEdge, + info); + if (parentState == null) { + parentState = new PlotState(); + } + parentState.getSharedAxisStates().put(axis, state); + + // draw all the charts + for (int i = 0; i < this.subplots.size(); i++) { + CategoryPlot plot = (CategoryPlot) this.subplots.get(i); + PlotRenderingInfo subplotInfo = null; + if (info != null) { + subplotInfo = new PlotRenderingInfo(info.getOwner()); + info.addSubplotInfo(subplotInfo); + } + Point2D subAnchor = null; + if (anchor != null && this.subplotArea[i].contains(anchor)) { + subAnchor = anchor; + } + plot.draw(g2, this.subplotArea[i], subAnchor, parentState, + subplotInfo); + } + + if (info != null) { + info.setDataArea(dataArea); + } + + } + + /** + * Sets the orientation for the plot (and all the subplots). + * + * @param orientation the orientation. + */ + @Override + public void setOrientation(PlotOrientation orientation) { + super.setOrientation(orientation); + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + CategoryPlot plot = (CategoryPlot) iterator.next(); + plot.setOrientation(orientation); + } + } + + /** + * Sets the shadow generator for the plot (and all subplots) and sends + * a {@link PlotChangeEvent} to all registered listeners. + * + * @param generator the new generator (null permitted). + */ + @Override + public void setShadowGenerator(ShadowGenerator generator) { + setNotify(false); + super.setShadowGenerator(generator); + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + CategoryPlot plot = (CategoryPlot) iterator.next(); + plot.setShadowGenerator(generator); + } + setNotify(true); + } + + /** + * Returns a range representing the extent of the data values in this plot + * (obtained from the subplots) that will be rendered against the specified + * axis. NOTE: This method is intended for internal JFreeChart use, and + * is public only so that code in the axis classes can call it. Since + * only the range axis is shared between subplots, the JFreeChart code + * will only call this method for the range values (although this is not + * checked/enforced). + * + * @param axis the axis. + * + * @return The range. + */ + @Override + public Range getDataRange(ValueAxis axis) { + Range result = null; + if (this.subplots != null) { + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + CategoryPlot subplot = (CategoryPlot) iterator.next(); + result = Range.combine(result, subplot.getDataRange(axis)); + } + } + return result; + } + + /** + * Returns a collection of legend items for the plot. + * + * @return The legend items. + */ + @Override + public LegendItemCollection getLegendItems() { + LegendItemCollection result = getFixedLegendItems(); + if (result == null) { + result = new LegendItemCollection(); + if (this.subplots != null) { + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + CategoryPlot plot = (CategoryPlot) iterator.next(); + LegendItemCollection more = plot.getLegendItems(); + result.addAll(more); + } + } + } + return result; + } + + /** + * Sets the size (width or height, depending on the orientation of the + * plot) for the domain axis of each subplot. + * + * @param space the space. + */ + protected void setFixedDomainAxisSpaceForSubplots(AxisSpace space) { + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + CategoryPlot plot = (CategoryPlot) iterator.next(); + plot.setFixedDomainAxisSpace(space, false); + } + } + + /** + * Handles a 'click' on the plot by updating the anchor value. + * + * @param x x-coordinate of the click. + * @param y y-coordinate of the click. + * @param info information about the plot's dimensions. + * + */ + @Override + public void handleClick(int x, int y, PlotRenderingInfo info) { + Rectangle2D dataArea = info.getDataArea(); + if (dataArea.contains(x, y)) { + for (int i = 0; i < this.subplots.size(); i++) { + CategoryPlot subplot = (CategoryPlot) this.subplots.get(i); + PlotRenderingInfo subplotInfo = info.getSubplotInfo(i); + subplot.handleClick(x, y, subplotInfo); + } + } + } + + /** + * Receives a {@link PlotChangeEvent} and responds by notifying all + * listeners. + * + * @param event the event. + */ + @Override + public void plotChanged(PlotChangeEvent event) { + notifyListeners(event); + } + + /** + * Tests the plot for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CombinedRangeCategoryPlot)) { + return false; + } + CombinedRangeCategoryPlot that = (CombinedRangeCategoryPlot) obj; + if (this.gap != that.gap) { + return false; + } + if (!ObjectUtilities.equal(this.subplots, that.subplots)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the plot. + * + * @return A clone. + * + * @throws CloneNotSupportedException this class will not throw this + * exception, but subclasses (if any) might. + */ + @Override + public Object clone() throws CloneNotSupportedException { + CombinedRangeCategoryPlot result + = (CombinedRangeCategoryPlot) super.clone(); + result.subplots = (List) ObjectUtilities.deepClone(this.subplots); + for (Iterator it = result.subplots.iterator(); it.hasNext();) { + Plot child = (Plot) it.next(); + child.setParent(result); + } + + // after setting up all the subplots, the shared range axis may need + // reconfiguring + ValueAxis rangeAxis = result.getRangeAxis(); + if (rangeAxis != null) { + rangeAxis.configure(); + } + + return result; + } + + /** + * 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(); + + // the range axis is deserialized before the subplots, so its value + // range is likely to be incorrect... + ValueAxis rangeAxis = getRangeAxis(); + if (rangeAxis != null) { + rangeAxis.configure(); + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CombinedRangeXYPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CombinedRangeXYPlot.java new file mode 100755 index 0000000..24b4739 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CombinedRangeXYPlot.java @@ -0,0 +1,743 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * CombinedRangeXYPlot.java + * ------------------------ + * (C) Copyright 2001-2012, by Bill Kelemen and Contributors. + * + * Original Author: Bill Kelemen; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Anthony Boulestreau; + * David Basten; + * Kevin Frechette (for ISTI); + * Arnaud Lelievre; + * Nicolas Brodu; + * Petr Kubanek (bug 1606205); + * + * Changes: + * -------- + * 06-Dec-2001 : Version 1 (BK); + * 12-Dec-2001 : Removed unnecessary 'throws' clause from constructor (DG); + * 18-Dec-2001 : Added plotArea attribute and get/set methods (BK); + * 22-Dec-2001 : Fixed bug in chartChanged with multiple combinations of + * CombinedPlots (BK); + * 08-Jan-2002 : Moved to new package com.jrefinery.chart.combination (DG); + * 25-Feb-2002 : Updated import statements (DG); + * 28-Feb-2002 : Readded "this.plotArea = plotArea" that was deleted from + * draw() method (BK); + * 26-Mar-2002 : Added an empty zoom method (this method needs to be written + * so that combined plots will support zooming (DG); + * 29-Mar-2002 : Changed the method createCombinedAxis adding the creation of + * OverlaidSymbolicAxis and CombinedSymbolicAxis(AB); + * 23-Apr-2002 : Renamed CombinedPlot-->MultiXYPlot, and simplified the + * structure (DG); + * 23-May-2002 : Renamed (again) MultiXYPlot-->CombinedXYPlot (DG); + * 19-Jun-2002 : Added get/setGap() methods suggested by David Basten (DG); + * 25-Jun-2002 : Removed redundant imports (DG); + * 16-Jul-2002 : Draws shared axis after subplots (to fix missing gridlines), + * added overrides of 'setSeriesPaint()' and 'setXYItemRenderer()' + * that pass changes down to subplots (KF); + * 09-Oct-2002 : Added add(XYPlot) method (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 16-May-2003 : Renamed CombinedXYPlot --> CombinedRangeXYPlot (DG); + * 26-Jun-2003 : Fixed bug 755547 (DG); + * 16-Jul-2003 : Removed getSubPlots() method (duplicate of getSubplots()) (DG); + * 08-Aug-2003 : Adjusted totalWeight in remove() method (DG); + * 21-Aug-2003 : Implemented Cloneable (DG); + * 08-Sep-2003 : Added internationalization via use of properties + * resourceBundle (RFE 690236) (AL); + * 11-Sep-2003 : Fix cloning support (subplots) (NB); + * 15-Sep-2003 : Fixed error in cloning (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 17-Sep-2003 : Updated handling of 'clicks' (DG); + * 12-Nov-2004 : Implements the new Zoomable interface (DG); + * 25-Nov-2004 : Small update to clone() implementation (DG); + * 21-Feb-2005 : The getLegendItems() method now returns the fixed legend + * items if set (DG); + * 05-May-2005 : Removed unused draw() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 13-Sep-2006 : Updated API docs (DG); + * 06-Feb-2007 : Fixed bug 1606205, draw shared axis after subplots (DG); + * 23-Mar-2007 : Reverted previous patch (DG); + * 17-Apr-2007 : Added null argument checks to findSubplot() (DG); + * 18-Jul-2007 : Fixed bug in removeSubplot (DG); + * 27-Nov-2007 : Modified setFixedDomainAxisSpaceForSubplots() so as not to + * trigger change events in subplots (DG); + * 27-Mar-2008 : Add documentation for getDataRange() method (DG); + * 31-Mar-2008 : Updated getSubplots() to return EMPTY_LIST for null + * subplots, as suggested by Richard West (DG); + * 28-Apr-2008 : Fixed zooming problem (see bug 1950037) (DG); + * 11-Aug-2008 : Don't store totalWeight of subplots, calculate it as + * required (DG); + * 21-Dec-2011 : Apply patch 3447161 by Ulrich Voigt and Martin Hoeller (MH); + * + */ + +package org.jfree.chart.plot; + +import java.awt.Graphics2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.axis.AxisSpace; +import org.jfree.chart.axis.AxisState; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.event.PlotChangeListener; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ShadowGenerator; +import org.jfree.data.Range; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectUtilities; + +/** + * An extension of {@link XYPlot} that contains multiple subplots that share a + * common range axis. + */ +public class CombinedRangeXYPlot extends XYPlot + implements PlotChangeListener { + + /** For serialization. */ + private static final long serialVersionUID = -5177814085082031168L; + + /** Storage for the subplot references. */ + private List subplots; + + /** The gap between subplots. */ + private double gap = 5.0; + + /** Temporary storage for the subplot areas. */ + private transient Rectangle2D[] subplotAreas; + + /** + * Default constructor. + */ + public CombinedRangeXYPlot() { + this(new NumberAxis()); + } + + /** + * Creates a new plot. + * + * @param rangeAxis the shared axis. + */ + public CombinedRangeXYPlot(ValueAxis rangeAxis) { + + super(null, // no data in the parent plot + null, + rangeAxis, + null); + + this.subplots = new java.util.ArrayList(); + + } + + /** + * Returns a string describing the type of plot. + * + * @return The type of plot. + */ + @Override + public String getPlotType() { + return localizationResources.getString("Combined_Range_XYPlot"); + } + + /** + * Returns the space between subplots. + * + * @return The gap. + * + * @see #setGap(double) + */ + public double getGap() { + return this.gap; + } + + /** + * Sets the amount of space between subplots. + * + * @param gap the gap between subplots. + * + * @see #getGap() + */ + public void setGap(double gap) { + this.gap = gap; + } + + /** + * Adds a subplot, with a default 'weight' of 1. + *

+ * You must ensure that the subplot has a non-null domain axis. The range + * axis for the subplot will be set to null. + * + * @param subplot the subplot. + */ + public void add(XYPlot subplot) { + add(subplot, 1); + } + + /** + * Adds a subplot with a particular weight (greater than or equal to one). + * The weight determines how much space is allocated to the subplot + * relative to all the other subplots. + *

+ * You must ensure that the subplot has a non-null domain axis. The range + * axis for the subplot will be set to null. + * + * @param subplot the subplot (null not permitted). + * @param weight the weight (must be 1 or greater). + */ + public void add(XYPlot subplot, int weight) { + ParamChecks.nullNotPermitted(subplot, "subplot"); + if (weight <= 0) { + String msg = "The 'weight' must be positive."; + throw new IllegalArgumentException(msg); + } + + // store the plot and its weight + subplot.setParent(this); + subplot.setWeight(weight); + subplot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); + subplot.setRangeAxis(null); + subplot.addChangeListener(this); + this.subplots.add(subplot); + configureRangeAxes(); + fireChangeEvent(); + + } + + /** + * Removes a subplot from the combined chart. + * + * @param subplot the subplot (null not permitted). + */ + public void remove(XYPlot subplot) { + ParamChecks.nullNotPermitted(subplot, "subplot"); + int position = -1; + int size = this.subplots.size(); + int i = 0; + while (position == -1 && i < size) { + if (this.subplots.get(i) == subplot) { + position = i; + } + i++; + } + if (position != -1) { + this.subplots.remove(position); + subplot.setParent(null); + subplot.removeChangeListener(this); + configureRangeAxes(); + fireChangeEvent(); + } + } + + /** + * Returns the list of subplots. The returned list may be empty, but is + * never null. + * + * @return An unmodifiable list of subplots. + */ + public List getSubplots() { + if (this.subplots != null) { + return Collections.unmodifiableList(this.subplots); + } + else { + return Collections.EMPTY_LIST; + } + } + + /** + * Calculates the space required for the axes. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * + * @return The space required for the axes. + */ + @Override + protected AxisSpace calculateAxisSpace(Graphics2D g2, + Rectangle2D plotArea) { + + AxisSpace space = new AxisSpace(); + PlotOrientation orientation = getOrientation(); + + // work out the space required by the domain axis... + AxisSpace fixed = getFixedRangeAxisSpace(); + if (fixed != null) { + if (orientation == PlotOrientation.VERTICAL) { + space.setLeft(fixed.getLeft()); + space.setRight(fixed.getRight()); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + space.setTop(fixed.getTop()); + space.setBottom(fixed.getBottom()); + } + } + else { + ValueAxis valueAxis = getRangeAxis(); + RectangleEdge valueEdge = Plot.resolveRangeAxisLocation( + getRangeAxisLocation(), orientation + ); + if (valueAxis != null) { + space = valueAxis.reserveSpace(g2, this, plotArea, valueEdge, + space); + } + } + + Rectangle2D adjustedPlotArea = space.shrink(plotArea, null); + // work out the maximum height or width of the non-shared axes... + int n = this.subplots.size(); + int totalWeight = 0; + for (int i = 0; i < n; i++) { + XYPlot sub = (XYPlot) this.subplots.get(i); + totalWeight += sub.getWeight(); + } + + // calculate plotAreas of all sub-plots, maximum vertical/horizontal + // axis width/height + this.subplotAreas = new Rectangle2D[n]; + double x = adjustedPlotArea.getX(); + double y = adjustedPlotArea.getY(); + double usableSize = 0.0; + if (orientation == PlotOrientation.VERTICAL) { + usableSize = adjustedPlotArea.getWidth() - this.gap * (n - 1); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + usableSize = adjustedPlotArea.getHeight() - this.gap * (n - 1); + } + + for (int i = 0; i < n; i++) { + XYPlot plot = (XYPlot) this.subplots.get(i); + + // calculate sub-plot area + if (orientation == PlotOrientation.VERTICAL) { + double w = usableSize * plot.getWeight() / totalWeight; + this.subplotAreas[i] = new Rectangle2D.Double(x, y, w, + adjustedPlotArea.getHeight()); + x = x + w + this.gap; + } + else if (orientation == PlotOrientation.HORIZONTAL) { + double h = usableSize * plot.getWeight() / totalWeight; + this.subplotAreas[i] = new Rectangle2D.Double(x, y, + adjustedPlotArea.getWidth(), h); + y = y + h + this.gap; + } + + AxisSpace subSpace = plot.calculateDomainAxisSpace(g2, + this.subplotAreas[i], null); + space.ensureAtLeast(subSpace); + + } + + return space; + } + + /** + * Draws the plot within the specified area on a graphics device. + * + * @param g2 the graphics device. + * @param area the plot area (in Java2D space). + * @param anchor an anchor point in Java2D space (null + * permitted). + * @param parentState the state from the parent plot, if there is one + * (null permitted). + * @param info collects chart drawing information (null + * permitted). + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, PlotRenderingInfo info) { + + // set up info collection... + if (info != null) { + info.setPlotArea(area); + } + + // adjust the drawing area for plot insets (if any)... + RectangleInsets insets = getInsets(); + insets.trim(area); + + AxisSpace space = calculateAxisSpace(g2, area); + Rectangle2D dataArea = space.shrink(area, null); + //this.axisOffset.trim(dataArea); + + // set the width and height of non-shared axis of all sub-plots + setFixedDomainAxisSpaceForSubplots(space); + + // draw the shared axis + ValueAxis axis = getRangeAxis(); + RectangleEdge edge = getRangeAxisEdge(); + double cursor = RectangleEdge.coordinate(dataArea, edge); + AxisState axisState = axis.draw(g2, cursor, area, dataArea, edge, info); + + if (parentState == null) { + parentState = new PlotState(); + } + parentState.getSharedAxisStates().put(axis, axisState); + + // draw all the charts + for (int i = 0; i < this.subplots.size(); i++) { + XYPlot plot = (XYPlot) this.subplots.get(i); + PlotRenderingInfo subplotInfo = null; + if (info != null) { + subplotInfo = new PlotRenderingInfo(info.getOwner()); + info.addSubplotInfo(subplotInfo); + } + plot.draw(g2, this.subplotAreas[i], anchor, parentState, + subplotInfo); + } + + if (info != null) { + info.setDataArea(dataArea); + } + + } + + /** + * Returns a collection of legend items for the plot. + * + * @return The legend items. + */ + @Override + public LegendItemCollection getLegendItems() { + LegendItemCollection result = getFixedLegendItems(); + if (result == null) { + result = new LegendItemCollection(); + + if (this.subplots != null) { + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + XYPlot plot = (XYPlot) iterator.next(); + LegendItemCollection more = plot.getLegendItems(); + result.addAll(more); + } + } + } + return result; + } + + /** + * Multiplies the range on the domain axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info (null not permitted). + * @param source the source point (null not permitted). + */ + @Override + public void zoomDomainAxes(double factor, PlotRenderingInfo info, + Point2D source) { + zoomDomainAxes(factor, info, source, false); + } + + /** + * Multiplies the range on the domain axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info (null not permitted). + * @param source the source point (null not permitted). + * @param useAnchor zoom about the anchor point? + */ + @Override + public void zoomDomainAxes(double factor, PlotRenderingInfo info, + Point2D source, boolean useAnchor) { + // delegate 'info' and 'source' argument checks... + XYPlot subplot = findSubplot(info, source); + if (subplot != null) { + subplot.zoomDomainAxes(factor, info, source, useAnchor); + } + else { + // if the source point doesn't fall within a subplot, we do the + // zoom on all subplots... + Iterator iterator = getSubplots().iterator(); + while (iterator.hasNext()) { + subplot = (XYPlot) iterator.next(); + subplot.zoomDomainAxes(factor, info, source, useAnchor); + } + } + } + + /** + * Zooms in on the domain axes. + * + * @param lowerPercent the lower bound. + * @param upperPercent the upper bound. + * @param info the plot rendering info (null not permitted). + * @param source the source point (null not permitted). + */ + @Override + public void zoomDomainAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo info, Point2D source) { + // delegate 'info' and 'source' argument checks... + XYPlot subplot = findSubplot(info, source); + if (subplot != null) { + subplot.zoomDomainAxes(lowerPercent, upperPercent, info, source); + } + else { + // if the source point doesn't fall within a subplot, we do the + // zoom on all subplots... + Iterator iterator = getSubplots().iterator(); + while (iterator.hasNext()) { + subplot = (XYPlot) iterator.next(); + subplot.zoomDomainAxes(lowerPercent, upperPercent, info, + source); + } + } + } + + /** + * Pans all domain axes by the specified percentage. + * + * @param panRange the distance to pan (as a percentage of the axis length). + * @param info the plot info + * @param source the source point where the pan action started. + * + * @since 1.0.15 + */ + @Override + public void panDomainAxes(double panRange, PlotRenderingInfo info, + Point2D source) { + + XYPlot subplot = findSubplot(info, source); + if (subplot != null) { + PlotRenderingInfo subplotInfo = info.getSubplotInfo( + info.getSubplotIndex(source)); + if (subplotInfo == null) { + return; + } + + for (int i = 0; i < subplot.getDomainAxisCount(); i++) { + ValueAxis domainAxis = subplot.getDomainAxis(i); + domainAxis.pan(panRange); + } + } + } + + /** + * Returns the subplot (if any) that contains the (x, y) point (specified + * in Java2D space). + * + * @param info the chart rendering info (null not permitted). + * @param source the source point (null not permitted). + * + * @return A subplot (possibly null). + */ + public XYPlot findSubplot(PlotRenderingInfo info, Point2D source) { + ParamChecks.nullNotPermitted(info, "info"); + ParamChecks.nullNotPermitted(source, "source"); + XYPlot result = null; + int subplotIndex = info.getSubplotIndex(source); + if (subplotIndex >= 0) { + result = (XYPlot) this.subplots.get(subplotIndex); + } + return result; + } + + /** + * Sets the item renderer FOR ALL SUBPLOTS. Registered listeners are + * notified that the plot has been modified. + *

+ * Note: usually you will want to set the renderer independently for each + * subplot, which is NOT what this method does. + * + * @param renderer the new renderer. + */ + @Override + public void setRenderer(XYItemRenderer renderer) { + super.setRenderer(renderer); // not strictly necessary, since the + // renderer set for the + // parent plot is not used + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + XYPlot plot = (XYPlot) iterator.next(); + plot.setRenderer(renderer); + } + } + + /** + * Sets the orientation for the plot (and all its subplots). + * + * @param orientation the orientation. + */ + @Override + public void setOrientation(PlotOrientation orientation) { + super.setOrientation(orientation); + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + XYPlot plot = (XYPlot) iterator.next(); + plot.setOrientation(orientation); + } + } + + /** + * Sets the shadow generator for the plot (and all subplots) and sends + * a {@link PlotChangeEvent} to all registered listeners. + * + * @param generator the new generator (null permitted). + */ + @Override + public void setShadowGenerator(ShadowGenerator generator) { + setNotify(false); + super.setShadowGenerator(generator); + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + XYPlot plot = (XYPlot) iterator.next(); + plot.setShadowGenerator(generator); + } + setNotify(true); + } + + /** + * Returns a range representing the extent of the data values in this plot + * (obtained from the subplots) that will be rendered against the specified + * axis. NOTE: This method is intended for internal JFreeChart use, and + * is public only so that code in the axis classes can call it. Since + * only the range axis is shared between subplots, the JFreeChart code + * will only call this method for the range values (although this is not + * checked/enforced). + * + * @param axis the axis. + * + * @return The range. + */ + @Override + public Range getDataRange(ValueAxis axis) { + Range result = null; + if (this.subplots != null) { + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + XYPlot subplot = (XYPlot) iterator.next(); + result = Range.combine(result, subplot.getDataRange(axis)); + } + } + return result; + } + + /** + * Sets the space (width or height, depending on the orientation of the + * plot) for the domain axis of each subplot. + * + * @param space the space. + */ + protected void setFixedDomainAxisSpaceForSubplots(AxisSpace space) { + Iterator iterator = this.subplots.iterator(); + while (iterator.hasNext()) { + XYPlot plot = (XYPlot) iterator.next(); + plot.setFixedDomainAxisSpace(space, false); + } + } + + /** + * Handles a 'click' on the plot by updating the anchor values... + * + * @param x x-coordinate, where the click occured. + * @param y y-coordinate, where the click occured. + * @param info object containing information about the plot dimensions. + */ + @Override + public void handleClick(int x, int y, PlotRenderingInfo info) { + Rectangle2D dataArea = info.getDataArea(); + if (dataArea.contains(x, y)) { + for (int i = 0; i < this.subplots.size(); i++) { + XYPlot subplot = (XYPlot) this.subplots.get(i); + PlotRenderingInfo subplotInfo = info.getSubplotInfo(i); + subplot.handleClick(x, y, subplotInfo); + } + } + } + + /** + * Receives a {@link PlotChangeEvent} and responds by notifying all + * listeners. + * + * @param event the event. + */ + @Override + public void plotChanged(PlotChangeEvent event) { + notifyListeners(event); + } + + /** + * Tests this plot for equality with another object. + * + * @param obj the other object. + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CombinedRangeXYPlot)) { + return false; + } + CombinedRangeXYPlot that = (CombinedRangeXYPlot) obj; + if (this.gap != that.gap) { + return false; + } + if (!ObjectUtilities.equal(this.subplots, that.subplots)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the plot. + * + * @return A clone. + * + * @throws CloneNotSupportedException this class will not throw this + * exception, but subclasses (if any) might. + */ + @Override + public Object clone() throws CloneNotSupportedException { + + CombinedRangeXYPlot result = (CombinedRangeXYPlot) super.clone(); + result.subplots = (List) ObjectUtilities.deepClone(this.subplots); + for (Iterator it = result.subplots.iterator(); it.hasNext();) { + Plot child = (Plot) it.next(); + child.setParent(result); + } + + // after setting up all the subplots, the shared range axis may need + // reconfiguring + ValueAxis rangeAxis = result.getRangeAxis(); + if (rangeAxis != null) { + rangeAxis.configure(); + } + + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CompassPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CompassPlot.java new file mode 100755 index 0000000..31825fc --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CompassPlot.java @@ -0,0 +1,890 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * CompassPlot.java + * ---------------- + * (C) Copyright 2002-2013, by the Australian Antarctic Division and + * Contributors. + * + * Original Author: Bryan Scott (for the Australian Antarctic Division); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Arnaud Lelievre; + * Martin Hoeller; + * + * Changes: + * -------- + * 25-Sep-2002 : Version 1, contributed by Bryan Scott (DG); + * 23-Jan-2003 : Removed one constructor (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 27-Mar-2003 : Changed MeterDataset to ValueDataset (DG); + * 21-Aug-2003 : Implemented Cloneable (DG); + * 08-Sep-2003 : Added internationalization via use of properties + * resourceBundle (RFE 690236) (AL); + * 09-Sep-2003 : Changed Color --> Paint (DG); + * 15-Sep-2003 : Added null data value check (bug report 805009) (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 16-Mar-2004 : Added support for revolutionDistance to enable support for + * other units than degrees. + * 16-Mar-2004 : Enabled LongNeedle to rotate about center. + * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); + * 17-Apr-2005 : Fixed bug in clone() method (DG); + * 05-May-2005 : Updated draw() method parameters (DG); + * 08-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); + * 16-Jun-2005 : Renamed getData() --> getDatasets() and + * addData() --> addDataset() (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 20-Mar-2007 : Fixed serialization (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 10-Oct-2011 : localization fix: bug #3353913 (MH); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Polygon; +import java.awt.Stroke; +import java.awt.geom.Area; +import java.awt.geom.Ellipse2D; +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 java.util.Arrays; +import java.util.ResourceBundle; + +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.needle.ArrowNeedle; +import org.jfree.chart.needle.LineNeedle; +import org.jfree.chart.needle.LongNeedle; +import org.jfree.chart.needle.MeterNeedle; +import org.jfree.chart.needle.MiddlePinNeedle; +import org.jfree.chart.needle.PinNeedle; +import org.jfree.chart.needle.PlumNeedle; +import org.jfree.chart.needle.PointerNeedle; +import org.jfree.chart.needle.ShipNeedle; +import org.jfree.chart.needle.WindNeedle; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.data.general.DefaultValueDataset; +import org.jfree.data.general.ValueDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; + +/** + * A specialised plot that draws a compass to indicate a direction based on the + * value from a {@link ValueDataset}. + */ +public class CompassPlot extends Plot implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 6924382802125527395L; + + /** The default label font. */ + public static final Font DEFAULT_LABEL_FONT = new Font("SansSerif", + Font.BOLD, 10); + + /** A constant for the label type. */ + public static final int NO_LABELS = 0; + + /** A constant for the label type. */ + public static final int VALUE_LABELS = 1; + + /** The label type (NO_LABELS, VALUE_LABELS). */ + private int labelType; + + /** The label font. */ + private Font labelFont; + + /** A flag that controls whether or not a border is drawn. */ + private boolean drawBorder = false; + + /** The rose highlight paint. */ + private transient Paint roseHighlightPaint = Color.black; + + /** The rose paint. */ + private transient Paint rosePaint = Color.yellow; + + /** The rose center paint. */ + private transient Paint roseCenterPaint = Color.white; + + /** The compass font. */ + private Font compassFont = new Font("Arial", Font.PLAIN, 10); + + /** A working shape. */ + private transient Ellipse2D circle1; + + /** A working shape. */ + private transient Ellipse2D circle2; + + /** A working area. */ + private transient Area a1; + + /** A working area. */ + private transient Area a2; + + /** A working shape. */ + private transient Rectangle2D rect1; + + /** An array of value datasets. */ + private ValueDataset[] datasets = new ValueDataset[1]; + + /** An array of needles. */ + private MeterNeedle[] seriesNeedle = new MeterNeedle[1]; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.plot.LocalizationBundle"); + + /** + * The count to complete one revolution. Can be arbitrarily set + * For degrees (the default) it is 360, for radians this is 2*Pi, etc + */ + protected double revolutionDistance = 360; + + /** + * Default constructor. + */ + public CompassPlot() { + this(new DefaultValueDataset()); + } + + /** + * Constructs a new compass plot. + * + * @param dataset the dataset for the plot (null permitted). + */ + public CompassPlot(ValueDataset dataset) { + super(); + if (dataset != null) { + this.datasets[0] = dataset; + dataset.addChangeListener(this); + } + this.circle1 = new Ellipse2D.Double(); + this.circle2 = new Ellipse2D.Double(); + this.rect1 = new Rectangle2D.Double(); + setSeriesNeedle(0); + } + + /** + * Returns the label type. Defined by the constants: {@link #NO_LABELS} + * and {@link #VALUE_LABELS}. + * + * @return The label type. + * + * @see #setLabelType(int) + */ + public int getLabelType() { + // FIXME: this attribute is never used - deprecate? + return this.labelType; + } + + /** + * Sets the label type (either {@link #NO_LABELS} or {@link #VALUE_LABELS}. + * + * @param type the type. + * + * @see #getLabelType() + */ + public void setLabelType(int type) { + // FIXME: this attribute is never used - deprecate? + if ((type != NO_LABELS) && (type != VALUE_LABELS)) { + throw new IllegalArgumentException( + "MeterPlot.setLabelType(int): unrecognised type."); + } + if (this.labelType != type) { + this.labelType = type; + fireChangeEvent(); + } + } + + /** + * Returns the label font. + * + * @return The label font. + * + * @see #setLabelFont(Font) + */ + public Font getLabelFont() { + // FIXME: this attribute is not used - deprecate? + return this.labelFont; + } + + /** + * Sets the label font and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param font the new label font. + * + * @see #getLabelFont() + */ + public void setLabelFont(Font font) { + // FIXME: this attribute is not used - deprecate? + ParamChecks.nullNotPermitted(font, "font"); + this.labelFont = font; + fireChangeEvent(); + } + + /** + * Returns the paint used to fill the outer circle of the compass. + * + * @return The paint (never null). + * + * @see #setRosePaint(Paint) + */ + public Paint getRosePaint() { + return this.rosePaint; + } + + /** + * Sets the paint used to fill the outer circle of the compass, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getRosePaint() + */ + public void setRosePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.rosePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint used to fill the inner background area of the + * compass. + * + * @return The paint (never null). + * + * @see #setRoseCenterPaint(Paint) + */ + public Paint getRoseCenterPaint() { + return this.roseCenterPaint; + } + + /** + * Sets the paint used to fill the inner background area of the compass, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getRoseCenterPaint() + */ + public void setRoseCenterPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.roseCenterPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw the circles, symbols and labels on the + * compass. + * + * @return The paint (never null). + * + * @see #setRoseHighlightPaint(Paint) + */ + public Paint getRoseHighlightPaint() { + return this.roseHighlightPaint; + } + + /** + * Sets the paint used to draw the circles, symbols and labels of the + * compass, and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getRoseHighlightPaint() + */ + public void setRoseHighlightPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.roseHighlightPaint = paint; + fireChangeEvent(); + } + + /** + * Returns a flag that controls whether or not a border is drawn. + * + * @return The flag. + * + * @see #setDrawBorder(boolean) + */ + public boolean getDrawBorder() { + return this.drawBorder; + } + + /** + * Sets a flag that controls whether or not a border is drawn. + * + * @param status the flag status. + * + * @see #getDrawBorder() + */ + public void setDrawBorder(boolean status) { + this.drawBorder = status; + fireChangeEvent(); + } + + /** + * Sets the series paint. + * + * @param series the series index. + * @param paint the paint. + * + * @see #setSeriesOutlinePaint(int, Paint) + */ + public void setSeriesPaint(int series, Paint paint) { + // super.setSeriesPaint(series, paint); + if ((series >= 0) && (series < this.seriesNeedle.length)) { + this.seriesNeedle[series].setFillPaint(paint); + } + } + + /** + * Sets the series outline paint. + * + * @param series the series index. + * @param p the paint. + * + * @see #setSeriesPaint(int, Paint) + */ + public void setSeriesOutlinePaint(int series, Paint p) { + + if ((series >= 0) && (series < this.seriesNeedle.length)) { + this.seriesNeedle[series].setOutlinePaint(p); + } + + } + + /** + * Sets the series outline stroke. + * + * @param series the series index. + * @param stroke the stroke. + * + * @see #setSeriesOutlinePaint(int, Paint) + */ + public void setSeriesOutlineStroke(int series, Stroke stroke) { + + if ((series >= 0) && (series < this.seriesNeedle.length)) { + this.seriesNeedle[series].setOutlineStroke(stroke); + } + + } + + /** + * Sets the needle type. + * + * @param type the type. + * + * @see #setSeriesNeedle(int, int) + */ + public void setSeriesNeedle(int type) { + setSeriesNeedle(0, type); + } + + /** + * Sets the needle for a series. The needle type is one of the following: + *

    + *
  • 0 = {@link ArrowNeedle};
  • + *
  • 1 = {@link LineNeedle};
  • + *
  • 2 = {@link LongNeedle};
  • + *
  • 3 = {@link PinNeedle};
  • + *
  • 4 = {@link PlumNeedle};
  • + *
  • 5 = {@link PointerNeedle};
  • + *
  • 6 = {@link ShipNeedle};
  • + *
  • 7 = {@link WindNeedle};
  • + *
  • 8 = {@link ArrowNeedle};
  • + *
  • 9 = {@link MiddlePinNeedle};
  • + *
+ * @param index the series index. + * @param type the needle type. + * + * @see #setSeriesNeedle(int) + */ + public void setSeriesNeedle(int index, int type) { + switch (type) { + case 0: + setSeriesNeedle(index, new ArrowNeedle(true)); + setSeriesPaint(index, Color.red); + this.seriesNeedle[index].setHighlightPaint(Color.white); + break; + case 1: + setSeriesNeedle(index, new LineNeedle()); + break; + case 2: + MeterNeedle longNeedle = new LongNeedle(); + longNeedle.setRotateY(0.5); + setSeriesNeedle(index, longNeedle); + break; + case 3: + setSeriesNeedle(index, new PinNeedle()); + break; + case 4: + setSeriesNeedle(index, new PlumNeedle()); + break; + case 5: + setSeriesNeedle(index, new PointerNeedle()); + break; + case 6: + setSeriesPaint(index, null); + setSeriesOutlineStroke(index, new BasicStroke(3)); + setSeriesNeedle(index, new ShipNeedle()); + break; + case 7: + setSeriesPaint(index, Color.blue); + setSeriesNeedle(index, new WindNeedle()); + break; + case 8: + setSeriesNeedle(index, new ArrowNeedle(true)); + break; + case 9: + setSeriesNeedle(index, new MiddlePinNeedle()); + break; + + default: + throw new IllegalArgumentException("Unrecognised type."); + } + + } + + /** + * Sets the needle for a series and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param index the series index. + * @param needle the needle. + */ + public void setSeriesNeedle(int index, MeterNeedle needle) { + if ((needle != null) && (index < this.seriesNeedle.length)) { + this.seriesNeedle[index] = needle; + } + fireChangeEvent(); + } + + /** + * Returns an array of dataset references for the plot. + * + * @return The dataset for the plot, cast as a ValueDataset. + * + * @see #addDataset(ValueDataset) + */ + public ValueDataset[] getDatasets() { + return this.datasets; + } + + /** + * Adds a dataset to the compass. + * + * @param dataset the new dataset (null ignored). + * + * @see #addDataset(ValueDataset, MeterNeedle) + */ + public void addDataset(ValueDataset dataset) { + addDataset(dataset, null); + } + + /** + * Adds a dataset to the compass. + * + * @param dataset the new dataset (null ignored). + * @param needle the needle (null permitted). + */ + public void addDataset(ValueDataset dataset, MeterNeedle needle) { + + if (dataset != null) { + int i = this.datasets.length + 1; + ValueDataset[] t = new ValueDataset[i]; + MeterNeedle[] p = new MeterNeedle[i]; + i = i - 2; + for (; i >= 0; --i) { + t[i] = this.datasets[i]; + p[i] = this.seriesNeedle[i]; + } + i = this.datasets.length; + t[i] = dataset; + p[i] = ((needle != null) ? needle : p[i - 1]); + + ValueDataset[] a = this.datasets; + MeterNeedle[] b = this.seriesNeedle; + this.datasets = t; + this.seriesNeedle = p; + + for (--i; i >= 0; --i) { + a[i] = null; + b[i] = null; + } + dataset.addChangeListener(this); + } + } + + /** + * Draws the plot on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device. + * @param area the area within which the plot should be drawn. + * @param anchor the anchor point (null permitted). + * @param parentState the state from the parent plot, if there is one. + * @param info collects info about the drawing. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, PlotRenderingInfo info) { + + int outerRadius, innerRadius; + int x1, y1, x2, y2; + double a; + + if (info != null) { + info.setPlotArea(area); + } + + // adjust for insets... + RectangleInsets insets = getInsets(); + insets.trim(area); + + // draw the background + if (this.drawBorder) { + drawBackground(g2, area); + } + + int midX = (int) (area.getWidth() / 2); + int midY = (int) (area.getHeight() / 2); + int radius = midX; + if (midY < midX) { + radius = midY; + } + --radius; + int diameter = 2 * radius; + + midX += (int) area.getMinX(); + midY += (int) area.getMinY(); + + this.circle1.setFrame(midX - radius, midY - radius, diameter, diameter); + this.circle2.setFrame( + midX - radius + 15, midY - radius + 15, + diameter - 30, diameter - 30 + ); + g2.setPaint(this.rosePaint); + this.a1 = new Area(this.circle1); + this.a2 = new Area(this.circle2); + this.a1.subtract(this.a2); + g2.fill(this.a1); + + g2.setPaint(this.roseCenterPaint); + x1 = diameter - 30; + g2.fillOval(midX - radius + 15, midY - radius + 15, x1, x1); + g2.setPaint(this.roseHighlightPaint); + g2.drawOval(midX - radius, midY - radius, diameter, diameter); + x1 = diameter - 20; + g2.drawOval(midX - radius + 10, midY - radius + 10, x1, x1); + x1 = diameter - 30; + g2.drawOval(midX - radius + 15, midY - radius + 15, x1, x1); + x1 = diameter - 80; + g2.drawOval(midX - radius + 40, midY - radius + 40, x1, x1); + + outerRadius = radius - 20; + innerRadius = radius - 32; + for (int w = 0; w < 360; w += 15) { + a = Math.toRadians(w); + x1 = midX - ((int) (Math.sin(a) * innerRadius)); + x2 = midX - ((int) (Math.sin(a) * outerRadius)); + y1 = midY - ((int) (Math.cos(a) * innerRadius)); + y2 = midY - ((int) (Math.cos(a) * outerRadius)); + g2.drawLine(x1, y1, x2, y2); + } + + g2.setPaint(this.roseHighlightPaint); + innerRadius = radius - 26; + outerRadius = 7; + for (int w = 45; w < 360; w += 90) { + a = Math.toRadians(w); + x1 = midX - ((int) (Math.sin(a) * innerRadius)); + y1 = midY - ((int) (Math.cos(a) * innerRadius)); + g2.fillOval(x1 - outerRadius, y1 - outerRadius, 2 * outerRadius, + 2 * outerRadius); + } + + /// Squares + for (int w = 0; w < 360; w += 90) { + a = Math.toRadians(w); + x1 = midX - ((int) (Math.sin(a) * innerRadius)); + y1 = midY - ((int) (Math.cos(a) * innerRadius)); + + Polygon p = new Polygon(); + p.addPoint(x1 - outerRadius, y1); + p.addPoint(x1, y1 + outerRadius); + p.addPoint(x1 + outerRadius, y1); + p.addPoint(x1, y1 - outerRadius); + g2.fillPolygon(p); + } + + /// Draw N, S, E, W + innerRadius = radius - 42; + Font f = getCompassFont(radius); + g2.setFont(f); + g2.drawString(localizationResources.getString("N"), midX - 5, midY - innerRadius + f.getSize()); + g2.drawString(localizationResources.getString("S"), midX - 5, midY + innerRadius - 5); + g2.drawString(localizationResources.getString("W"), midX - innerRadius + 5, midY + 5); + g2.drawString(localizationResources.getString("E"), midX + innerRadius - f.getSize(), midY + 5); + + // plot the data (unless the dataset is null)... + y1 = radius / 2; + x1 = radius / 6; + Rectangle2D needleArea = new Rectangle2D.Double( + (midX - x1), (midY - y1), (2 * x1), (2 * y1) + ); + int x = this.seriesNeedle.length; + int current; + double value; + int i = (this.datasets.length - 1); + for (; i >= 0; --i) { + ValueDataset data = this.datasets[i]; + + if (data != null && data.getValue() != null) { + value = (data.getValue().doubleValue()) + % this.revolutionDistance; + value = value / this.revolutionDistance * 360; + current = i % x; + this.seriesNeedle[current].draw(g2, needleArea, value); + } + } + + if (this.drawBorder) { + drawOutline(g2, area); + } + + } + + /** + * Returns a short string describing the type of plot. + * + * @return A string describing the plot. + */ + @Override + public String getPlotType() { + return localizationResources.getString("Compass_Plot"); + } + + /** + * Returns the legend items for the plot. For now, no legend is available + * - this method returns null. + * + * @return The legend items. + */ + @Override + public LegendItemCollection getLegendItems() { + return null; + } + + /** + * No zooming is implemented for compass plot, so this method is empty. + * + * @param percent the zoom amount. + */ + @Override + public void zoom(double percent) { + // no zooming possible + } + + /** + * Returns the font for the compass, adjusted for the size of the plot. + * + * @param radius the radius. + * + * @return The font. + */ + protected Font getCompassFont(int radius) { + float fontSize = radius / 10.0f; + if (fontSize < 8) { + fontSize = 8; + } + Font newFont = this.compassFont.deriveFont(fontSize); + return newFont; + } + + /** + * Tests an object for equality with this plot. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CompassPlot)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + CompassPlot that = (CompassPlot) obj; + if (this.labelType != that.labelType) { + return false; + } + if (!ObjectUtilities.equal(this.labelFont, that.labelFont)) { + return false; + } + if (this.drawBorder != that.drawBorder) { + return false; + } + if (!PaintUtilities.equal(this.roseHighlightPaint, + that.roseHighlightPaint)) { + return false; + } + if (!PaintUtilities.equal(this.rosePaint, that.rosePaint)) { + return false; + } + if (!PaintUtilities.equal(this.roseCenterPaint, + that.roseCenterPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.compassFont, that.compassFont)) { + return false; + } + if (!Arrays.equals(this.seriesNeedle, that.seriesNeedle)) { + return false; + } + if (getRevolutionDistance() != that.getRevolutionDistance()) { + return false; + } + return true; + + } + + /** + * Returns a clone of the plot. + * + * @return A clone. + * + * @throws CloneNotSupportedException this class will not throw this + * exception, but subclasses (if any) might. + */ + @Override + public Object clone() throws CloneNotSupportedException { + + CompassPlot clone = (CompassPlot) super.clone(); + if (this.circle1 != null) { + clone.circle1 = (Ellipse2D) this.circle1.clone(); + } + if (this.circle2 != null) { + clone.circle2 = (Ellipse2D) this.circle2.clone(); + } + if (this.a1 != null) { + clone.a1 = (Area) this.a1.clone(); + } + if (this.a2 != null) { + clone.a2 = (Area) this.a2.clone(); + } + if (this.rect1 != null) { + clone.rect1 = (Rectangle2D) this.rect1.clone(); + } + clone.datasets = (ValueDataset[]) this.datasets.clone(); + clone.seriesNeedle = (MeterNeedle[]) this.seriesNeedle.clone(); + + // clone share data sets => add the clone as listener to the dataset + for (int i = 0; i < this.datasets.length; ++i) { + if (clone.datasets[i] != null) { + clone.datasets[i].addChangeListener(clone); + } + } + return clone; + + } + + /** + * Sets the count to complete one revolution. Can be arbitrarily set + * For degrees (the default) it is 360, for radians this is 2*Pi, etc + * + * @param size the count to complete one revolution. + * + * @see #getRevolutionDistance() + */ + public void setRevolutionDistance(double size) { + if (size > 0) { + this.revolutionDistance = size; + } + } + + /** + * Gets the count to complete one revolution. + * + * @return The count to complete one revolution. + * + * @see #setRevolutionDistance(double) + */ + public double getRevolutionDistance() { + return this.revolutionDistance; + } + + /** + * 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.rosePaint, stream); + SerialUtilities.writePaint(this.roseCenterPaint, stream); + SerialUtilities.writePaint(this.roseHighlightPaint, 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.rosePaint = SerialUtilities.readPaint(stream); + this.roseCenterPaint = SerialUtilities.readPaint(stream); + this.roseHighlightPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ContourPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ContourPlot.java new file mode 100755 index 0000000..6a65662 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ContourPlot.java @@ -0,0 +1,1861 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * ContourPlot.java + * ---------------- + * (C) Copyright 2002-2013, by David M. O'Donnell and Contributors. + * + * Original Author: David M. O'Donnell; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Arnaud Lelievre; + * Nicolas Brodu; + * + * Changes + * ------- + * 26-Nov-2002 : Version 1 contributed by David M. O'Donnell (DG); + * 14-Jan-2003 : Added crosshair attributes (DG); + * 23-Jan-2003 : Removed two constructors (DG); + * 21-Mar-2003 : Bug fix 701744 (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); + * 08-Sep-2003 : Added internationalization via use of properties + * resourceBundle (RFE 690236) (AL); + * 11-Sep-2003 : Cloning support (NB); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 17-Jan-2004 : Removed references to DefaultContourDataset class, replaced + * with ContourDataset interface (with changes to the interface). + * See bug 741048 (DG); + * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); + * 06-Oct-2004 : Updated for changes in DatasetUtilities class (DG); + * 11-Nov-2004 : Renamed zoom methods to match ValueAxisPlot interface (DG); + * 25-Nov-2004 : Small update to clone() implementation (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); + * 05-May-2005 : Updated draw() method parameters (DG); + * 16-Jun-2005 : Added default constructor (DG); + * 01-Sep-2005 : Moved dataAreaRatio from Plot to here (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 31-Jan-2007 : Deprecated (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * 02-Jul-2013 : Fix NB warnings (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.AlphaComposite; +import java.awt.Composite; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.RenderingHints; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Ellipse2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.geom.RectangularShape; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; +import java.util.ResourceBundle; + +import org.jfree.chart.ClipPath; +import org.jfree.chart.annotations.XYAnnotation; +import org.jfree.chart.axis.AxisSpace; +import org.jfree.chart.axis.ColorBar; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.ContourEntity; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.AxisChangeEvent; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.labels.ContourToolTipGenerator; +import org.jfree.chart.labels.StandardContourToolTipGenerator; +import org.jfree.chart.renderer.xy.XYBlockRenderer; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.data.Range; +import org.jfree.data.contour.ContourDataset; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectUtilities; + +/** + * A class for creating shaded contours. + * + * @deprecated This plot is no longer supported, please use {@link XYPlot} with + * an {@link XYBlockRenderer}. + */ +public class ContourPlot extends Plot implements ContourValuePlot, + ValueAxisPlot, PropertyChangeListener, Serializable, Cloneable { + + /** For serialization. */ + private static final long serialVersionUID = 7861072556590502247L; + + /** The default insets. */ + protected static final RectangleInsets DEFAULT_INSETS + = new RectangleInsets(2.0, 2.0, 100.0, 10.0); + + /** The domain axis (used for the x-values). */ + private ValueAxis domainAxis; + + /** The range axis (used for the y-values). */ + private ValueAxis rangeAxis; + + /** The dataset. */ + private ContourDataset dataset; + + /** The colorbar axis (used for the z-values). */ + private ColorBar colorBar = null; + + /** The color bar location. */ + private RectangleEdge colorBarLocation; + + /** A flag that controls whether or not a domain crosshair is drawn..*/ + private boolean domainCrosshairVisible; + + /** The domain crosshair value. */ + private double domainCrosshairValue; + + /** The pen/brush used to draw the crosshair (if any). */ + private transient Stroke domainCrosshairStroke; + + /** The color used to draw the crosshair (if any). */ + private transient Paint domainCrosshairPaint; + + /** + * A flag that controls whether or not the crosshair locks onto actual data + * points. + */ + private boolean domainCrosshairLockedOnData = true; + + /** A flag that controls whether or not a range crosshair is drawn..*/ + private boolean rangeCrosshairVisible; + + /** The range crosshair value. */ + private double rangeCrosshairValue; + + /** The pen/brush used to draw the crosshair (if any). */ + private transient Stroke rangeCrosshairStroke; + + /** The color used to draw the crosshair (if any). */ + private transient Paint rangeCrosshairPaint; + + /** + * A flag that controls whether or not the crosshair locks onto actual data + * points. + */ + private boolean rangeCrosshairLockedOnData = true; + + /** + * Defines dataArea rectangle as the ratio formed from dividing height by + * width (of the dataArea). Modifies plot area calculations. + * ratio>0 will attempt to layout the plot so that the + * dataArea.height/dataArea.width = ratio. + * ratio<0 will attempt to layout the plot so that the + * dataArea.height/dataArea.width in plot units (not java2D units as when + * ratio>0) = -1.*ratio. + */ //dmo + private double dataAreaRatio = 0.0; //zero when the parameter is not set + + /** A list of markers (optional) for the domain axis. */ + private List domainMarkers; + + /** A list of markers (optional) for the range axis. */ + private List rangeMarkers; + + /** A list of annotations (optional) for the plot. */ + private List annotations; + + /** The tool tip generator. */ + private ContourToolTipGenerator toolTipGenerator; + + /** The URL text generator. */ + private XYURLGenerator urlGenerator; + + /** + * Controls whether data are render as filled rectangles or rendered as + * points + */ + private boolean renderAsPoints = false; + + /** + * Size of points rendered when renderAsPoints = true. Size is relative to + * dataArea + */ + private double ptSizePct = 0.05; + + /** Contains the a ClipPath to "trim" the contours. */ + private transient ClipPath clipPath = null; + + /** Set to Paint to represent missing values. */ + private transient Paint missingPaint = null; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.plot.LocalizationBundle"); + + /** + * Creates a new plot with no dataset or axes. + */ + public ContourPlot() { + this(null, null, null, null); + } + + /** + * Constructs a contour plot with the specified axes (other attributes take + * default values). + * + * @param dataset The dataset. + * @param domainAxis The domain axis. + * @param rangeAxis The range axis. + * @param colorBar The z-axis axis. + */ + public ContourPlot(ContourDataset dataset, + ValueAxis domainAxis, ValueAxis rangeAxis, + ColorBar colorBar) { + + super(); + + this.dataset = dataset; + if (dataset != null) { + dataset.addChangeListener(this); + } + + this.domainAxis = domainAxis; + if (domainAxis != null) { + domainAxis.setPlot(this); + domainAxis.addChangeListener(this); + } + + this.rangeAxis = rangeAxis; + if (rangeAxis != null) { + rangeAxis.setPlot(this); + rangeAxis.addChangeListener(this); + } + + this.colorBar = colorBar; + if (colorBar != null) { + colorBar.getAxis().setPlot(this); + colorBar.getAxis().addChangeListener(this); + colorBar.configure(this); + } + this.colorBarLocation = RectangleEdge.LEFT; + + this.toolTipGenerator = new StandardContourToolTipGenerator(); + + } + + /** + * Returns the color bar location. + * + * @return The color bar location. + */ + public RectangleEdge getColorBarLocation() { + return this.colorBarLocation; + } + + /** + * Sets the color bar location and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param edge the location. + */ + public void setColorBarLocation(RectangleEdge edge) { + this.colorBarLocation = edge; + fireChangeEvent(); + } + + /** + * Returns the primary dataset for the plot. + * + * @return The primary dataset (possibly null). + */ + public ContourDataset getDataset() { + return this.dataset; + } + + /** + * Sets the dataset for the plot, replacing the existing dataset if there + * is one. + * + * @param dataset the dataset (null permitted). + */ + public void setDataset(ContourDataset dataset) { + + // if there is an existing dataset, remove the plot from the list of + // change listeners... + ContourDataset existing = this.dataset; + if (existing != null) { + existing.removeChangeListener(this); + } + + // set the new dataset, and register the chart as a change listener... + this.dataset = dataset; + if (dataset != null) { + setDatasetGroup(dataset.getGroup()); + dataset.addChangeListener(this); + } + + // send a dataset change event to self... + DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); + datasetChanged(event); + + } + + /** + * Returns the domain axis for the plot. + * + * @return The domain axis. + */ + public ValueAxis getDomainAxis() { + + ValueAxis result = this.domainAxis; + + return result; + + } + + /** + * Sets the domain axis for the plot (this must be compatible with the plot + * type or an exception is thrown). + * + * @param axis The new axis. + */ + public void setDomainAxis(ValueAxis axis) { + + if (isCompatibleDomainAxis(axis)) { + + if (axis != null) { + axis.setPlot(this); + axis.addChangeListener(this); + } + + // plot is likely registered as a listener with the existing axis... + if (this.domainAxis != null) { + this.domainAxis.removeChangeListener(this); + } + + this.domainAxis = axis; + fireChangeEvent(); + + } + + } + + /** + * Returns the range axis for the plot. + * + * @return The range axis. + */ + public ValueAxis getRangeAxis() { + + ValueAxis result = this.rangeAxis; + + return result; + + } + + /** + * Sets the range axis for the plot. + *

+ * An exception is thrown if the new axis and the plot are not mutually + * compatible. + * + * @param axis The new axis (null permitted). + */ + public void setRangeAxis(ValueAxis axis) { + + if (axis != null) { + axis.setPlot(this); + axis.addChangeListener(this); + } + + // plot is likely registered as a listener with the existing axis... + if (this.rangeAxis != null) { + this.rangeAxis.removeChangeListener(this); + } + + this.rangeAxis = axis; + fireChangeEvent(); + + } + + /** + * Sets the colorbar for the plot. + * + * @param axis The new axis (null permitted). + */ + public void setColorBarAxis(ColorBar axis) { + + this.colorBar = axis; + fireChangeEvent(); + + } + + /** + * Returns the data area ratio. + * + * @return The ratio. + */ + public double getDataAreaRatio() { + return this.dataAreaRatio; + } + + /** + * Sets the data area ratio. + * + * @param ratio the ratio. + */ + public void setDataAreaRatio(double ratio) { + this.dataAreaRatio = ratio; + } + + /** + * Adds a marker for the domain axis. + *

+ * Typically a marker will be drawn by the renderer as a line perpendicular + * to the range axis, however this is entirely up to the renderer. + * + * @param marker the marker. + */ + public void addDomainMarker(Marker marker) { + + if (this.domainMarkers == null) { + this.domainMarkers = new java.util.ArrayList(); + } + this.domainMarkers.add(marker); + fireChangeEvent(); + + } + + /** + * Clears all the domain markers. + */ + public void clearDomainMarkers() { + if (this.domainMarkers != null) { + this.domainMarkers.clear(); + fireChangeEvent(); + } + } + + /** + * Adds a marker for the range axis. + *

+ * Typically a marker will be drawn by the renderer as a line perpendicular + * to the range axis, however this is entirely up to the renderer. + * + * @param marker The marker. + */ + public void addRangeMarker(Marker marker) { + + if (this.rangeMarkers == null) { + this.rangeMarkers = new java.util.ArrayList(); + } + this.rangeMarkers.add(marker); + fireChangeEvent(); + + } + + /** + * Clears all the range markers. + */ + public void clearRangeMarkers() { + if (this.rangeMarkers != null) { + this.rangeMarkers.clear(); + fireChangeEvent(); + } + } + + /** + * Adds an annotation to the plot. + * + * @param annotation the annotation. + */ + public void addAnnotation(XYAnnotation annotation) { + + if (this.annotations == null) { + this.annotations = new java.util.ArrayList(); + } + this.annotations.add(annotation); + fireChangeEvent(); + + } + + /** + * Clears all the annotations. + */ + public void clearAnnotations() { + if (this.annotations != null) { + this.annotations.clear(); + fireChangeEvent(); + } + } + + /** + * Checks the compatibility of a domain axis, returning true if the axis is + * compatible with the plot, and false otherwise. + * + * @param axis The proposed axis. + * + * @return true if the axis is compatible with the plot. + */ + public boolean isCompatibleDomainAxis(ValueAxis axis) { + + return true; + + } + + /** + * Draws the plot on a Java 2D graphics device (such as the screen or a + * printer). + *

+ * The optional info argument collects information about the + * rendering of the plot (dimensions, tooltip information etc). Just pass + * in null if you do not need this information. + * + * @param g2 the graphics device. + * @param area the area within which the plot (including axis labels) + * should be drawn. + * @param anchor the anchor point (null permitted). + * @param parentState the state from the parent plot, if there is one. + * @param info collects chart drawing information (null + * permitted). + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, PlotRenderingInfo info) { + + // if the plot area is too small, just return... + boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); + boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); + if (b1 || b2) { + return; + } + + // record the plot area... + if (info != null) { + info.setPlotArea(area); + } + + // adjust the drawing area for plot insets (if any)... + RectangleInsets insets = getInsets(); + insets.trim(area); + + AxisSpace space = new AxisSpace(); + + space = this.domainAxis.reserveSpace(g2, this, area, + RectangleEdge.BOTTOM, space); + space = this.rangeAxis.reserveSpace(g2, this, area, + RectangleEdge.LEFT, space); + + Rectangle2D estimatedDataArea = space.shrink(area, null); + + AxisSpace space2 = new AxisSpace(); + space2 = this.colorBar.reserveSpace(g2, this, area, estimatedDataArea, + this.colorBarLocation, space2); + Rectangle2D adjustedPlotArea = space2.shrink(area, null); + + Rectangle2D dataArea = space.shrink(adjustedPlotArea, null); + + Rectangle2D colorBarArea = space2.reserved(area, this.colorBarLocation); + + // additional dataArea modifications + if (getDataAreaRatio() != 0.0) { //check whether modification is + double ratio = getDataAreaRatio(); + Rectangle2D tmpDataArea = (Rectangle2D) dataArea.clone(); + double h = tmpDataArea.getHeight(); + double w = tmpDataArea.getWidth(); + + if (ratio > 0) { // ratio represents pixels + if (w * ratio <= h) { + h = ratio * w; + } + else { + w = h / ratio; + } + } + else { // ratio represents axis units + ratio *= -1.0; + double xLength = getDomainAxis().getRange().getLength(); + double yLength = getRangeAxis().getRange().getLength(); + double unitRatio = yLength / xLength; + + ratio = unitRatio * ratio; + + if (w * ratio <= h) { + h = ratio * w; + } + else { + w = h / ratio; + } + } + + dataArea.setRect(tmpDataArea.getX() + tmpDataArea.getWidth() / 2 + - w / 2, tmpDataArea.getY(), w, h); + } + + if (info != null) { + info.setDataArea(dataArea); + } + + CrosshairState crosshairState = new CrosshairState(); + crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY); + + // draw the plot background... + drawBackground(g2, dataArea); + + double cursor = dataArea.getMaxY(); + if (this.domainAxis != null) { + this.domainAxis.draw(g2, cursor, adjustedPlotArea, dataArea, + RectangleEdge.BOTTOM, info); + } + + if (this.rangeAxis != null) { + cursor = dataArea.getMinX(); + this.rangeAxis.draw(g2, cursor, adjustedPlotArea, dataArea, + RectangleEdge.LEFT, info); + } + + if (this.colorBar != null) { + cursor = 0.0; + this.colorBar.draw(g2, cursor, adjustedPlotArea, dataArea, + colorBarArea, this.colorBarLocation); + } + Shape originalClip = g2.getClip(); + Composite originalComposite = g2.getComposite(); + + g2.clip(dataArea); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + getForegroundAlpha())); + render(g2, dataArea, info, crosshairState); + + if (this.domainMarkers != null) { + Iterator iterator = this.domainMarkers.iterator(); + while (iterator.hasNext()) { + Marker marker = (Marker) iterator.next(); + drawDomainMarker(g2, this, getDomainAxis(), marker, dataArea); + } + } + + if (this.rangeMarkers != null) { + Iterator iterator = this.rangeMarkers.iterator(); + while (iterator.hasNext()) { + Marker marker = (Marker) iterator.next(); + drawRangeMarker(g2, this, getRangeAxis(), marker, dataArea); + } + } + +// TO DO: these annotations only work with XYPlot, see if it is possible to +// make ContourPlot a subclass of XYPlot (DG); + +// // draw the annotations... +// if (this.annotations != null) { +// Iterator iterator = this.annotations.iterator(); +// while (iterator.hasNext()) { +// Annotation annotation = (Annotation) iterator.next(); +// if (annotation instanceof XYAnnotation) { +// XYAnnotation xya = (XYAnnotation) annotation; +// // get the annotation to draw itself... +// xya.draw(g2, this, dataArea, getDomainAxis(), +// getRangeAxis()); +// } +// } +// } + + g2.setClip(originalClip); + g2.setComposite(originalComposite); + drawOutline(g2, dataArea); + + } + + /** + * Draws a representation of the data within the dataArea region, using the + * current renderer. + *

+ * The info and crosshairState arguments may be + * null. + * + * @param g2 the graphics device. + * @param dataArea the region in which the data is to be drawn. + * @param info an optional object for collection dimension information. + * @param crosshairState an optional object for collecting crosshair info. + */ + public void render(Graphics2D g2, Rectangle2D dataArea, + PlotRenderingInfo info, CrosshairState crosshairState) { + + // now get the data and plot it (the visual representation will depend + // on the renderer that has been set)... + ContourDataset data = getDataset(); + if (data != null) { + + ColorBar zAxis = getColorBar(); + + if (this.clipPath != null) { + GeneralPath clipper = getClipPath().draw(g2, dataArea, + this.domainAxis, this.rangeAxis); + if (this.clipPath.isClip()) { + g2.clip(clipper); + } + } + + if (this.renderAsPoints) { + pointRenderer(g2, dataArea, info, this, this.domainAxis, + this.rangeAxis, zAxis, data, crosshairState); + } + else { + contourRenderer(g2, dataArea, info, this, this.domainAxis, + this.rangeAxis, zAxis, data, crosshairState); + } + + // draw vertical crosshair if required... + setDomainCrosshairValue(crosshairState.getCrosshairX(), false); + if (isDomainCrosshairVisible()) { + drawVerticalLine(g2, dataArea, + getDomainCrosshairValue(), + getDomainCrosshairStroke(), + getDomainCrosshairPaint()); + } + + // draw horizontal crosshair if required... + setRangeCrosshairValue(crosshairState.getCrosshairY(), false); + if (isRangeCrosshairVisible()) { + drawHorizontalLine(g2, dataArea, + getRangeCrosshairValue(), + getRangeCrosshairStroke(), + getRangeCrosshairPaint()); + } + + } + else if (this.clipPath != null) { + getClipPath().draw(g2, dataArea, this.domainAxis, this.rangeAxis); + } + + } + + /** + * Fills the plot. + * + * @param g2 the graphics device. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @param plot the plot (can be used to obtain standard color + * information etc). + * @param horizontalAxis the domain (horizontal) axis. + * @param verticalAxis the range (vertical) axis. + * @param colorBar the color bar axis. + * @param data the dataset. + * @param crosshairState information about crosshairs on a plot. + */ + public void contourRenderer(Graphics2D g2, + Rectangle2D dataArea, + PlotRenderingInfo info, + ContourPlot plot, + ValueAxis horizontalAxis, + ValueAxis verticalAxis, + ColorBar colorBar, + ContourDataset data, + CrosshairState crosshairState) { + + // setup for collecting optional entity info... + Rectangle2D.Double entityArea; + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + } + + Rectangle2D.Double rect; + rect = new Rectangle2D.Double(); + + //turn off anti-aliasing when filling rectangles + Object antiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_OFF); + + // get the data points + Number[] xNumber = data.getXValues(); + Number[] yNumber = data.getYValues(); + Number[] zNumber = data.getZValues(); + + double[] x = new double[xNumber.length]; + double[] y = new double[yNumber.length]; + + for (int i = 0; i < x.length; i++) { + x[i] = xNumber[i].doubleValue(); + y[i] = yNumber[i].doubleValue(); + } + + int[] xIndex = data.indexX(); + int[] indexX = data.getXIndices(); + boolean vertInverted = ((NumberAxis) verticalAxis).isInverted(); + boolean horizInverted = false; + if (horizontalAxis instanceof NumberAxis) { + horizInverted = ((NumberAxis) horizontalAxis).isInverted(); + } + double transX = 0.0; + double transXm1; + double transXp1; + double transDXm1; + double transDXp1 = 0.0; + double transDX = 0.0; + double transY; + double transYm1; + double transYp1; + double transDYm1; + double transDYp1 = 0.0; + double transDY; + int iMax = xIndex[xIndex.length - 1]; + for (int k = 0; k < x.length; k++) { + int i = xIndex[k]; + if (indexX[i] == k) { // this is a new column + if (i == 0) { + transX = horizontalAxis.valueToJava2D(x[k], dataArea, + RectangleEdge.BOTTOM); + transXm1 = transX; + transXp1 = horizontalAxis.valueToJava2D( + x[indexX[i + 1]], dataArea, RectangleEdge.BOTTOM); + transDXm1 = Math.abs(0.5 * (transX - transXm1)); + transDXp1 = Math.abs(0.5 * (transX - transXp1)); + } + else if (i == iMax) { + transX = horizontalAxis.valueToJava2D(x[k], dataArea, + RectangleEdge.BOTTOM); + transXm1 = horizontalAxis.valueToJava2D(x[indexX[i - 1]], + dataArea, RectangleEdge.BOTTOM); + transXp1 = transX; + transDXm1 = Math.abs(0.5 * (transX - transXm1)); + transDXp1 = Math.abs(0.5 * (transX - transXp1)); + } + else { + transX = horizontalAxis.valueToJava2D(x[k], dataArea, + RectangleEdge.BOTTOM); + transXp1 = horizontalAxis.valueToJava2D(x[indexX[i + 1]], + dataArea, RectangleEdge.BOTTOM); + transDXm1 = transDXp1; + transDXp1 = Math.abs(0.5 * (transX - transXp1)); + } + + if (horizInverted) { + transX -= transDXp1; + } + else { + transX -= transDXm1; + } + + transDX = transDXm1 + transDXp1; + + transY = verticalAxis.valueToJava2D(y[k], dataArea, + RectangleEdge.LEFT); + transYm1 = transY; + if (k + 1 == y.length) { + continue; + } + transYp1 = verticalAxis.valueToJava2D(y[k + 1], dataArea, + RectangleEdge.LEFT); + transDYm1 = Math.abs(0.5 * (transY - transYm1)); + transDYp1 = Math.abs(0.5 * (transY - transYp1)); + } + else if ((i < indexX.length - 1 + && indexX[i + 1] - 1 == k) || k == x.length - 1) { + // end of column + transY = verticalAxis.valueToJava2D(y[k], dataArea, + RectangleEdge.LEFT); + transYm1 = verticalAxis.valueToJava2D(y[k - 1], dataArea, + RectangleEdge.LEFT); + transYp1 = transY; + transDYm1 = Math.abs(0.5 * (transY - transYm1)); + transDYp1 = Math.abs(0.5 * (transY - transYp1)); + } + else { + transY = verticalAxis.valueToJava2D(y[k], dataArea, + RectangleEdge.LEFT); + transYp1 = verticalAxis.valueToJava2D(y[k + 1], dataArea, + RectangleEdge.LEFT); + transDYm1 = transDYp1; + transDYp1 = Math.abs(0.5 * (transY - transYp1)); + } + if (vertInverted) { + transY -= transDYm1; + } + else { + transY -= transDYp1; + } + + transDY = transDYm1 + transDYp1; + + rect.setRect(transX, transY, transDX, transDY); + if (zNumber[k] != null) { + g2.setPaint(colorBar.getPaint(zNumber[k].doubleValue())); + g2.fill(rect); + } + else if (this.missingPaint != null) { + g2.setPaint(this.missingPaint); + g2.fill(rect); + } + + entityArea = rect; + + // add an entity for the item... + if (entities != null) { + String tip = ""; + if (getToolTipGenerator() != null) { + tip = this.toolTipGenerator.generateToolTip(data, k); + } +// Shape s = g2.getClip(); +// if (s.contains(rect) || s.intersects(rect)) { + String url = null; + // if (getURLGenerator() != null) { //dmo: look at this later + // url = getURLGenerator().generateURL(data, series, item); + // } + // Unlike XYItemRenderer, we need to clone entityArea since it + // reused. + ContourEntity entity = new ContourEntity( + (Rectangle2D.Double) entityArea.clone(), tip, url); + entity.setIndex(k); + entities.add(entity); +// } + } + + // do we need to update the crosshair values? + if (plot.isDomainCrosshairLockedOnData()) { + if (plot.isRangeCrosshairLockedOnData()) { + // both axes + crosshairState.updateCrosshairPoint(x[k], y[k], transX, + transY, PlotOrientation.VERTICAL); + } + else { + // just the horizontal axis... + crosshairState.updateCrosshairX(transX); + } + } + else { + if (plot.isRangeCrosshairLockedOnData()) { + // just the vertical axis... + crosshairState.updateCrosshairY(transY); + } + } + } + + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAlias); + + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @param plot the plot (can be used to obtain standard color + * information etc). + * @param domainAxis the domain (horizontal) axis. + * @param rangeAxis the range (vertical) axis. + * @param colorBar the color bar axis. + * @param data the dataset. + * @param crosshairState information about crosshairs on a plot. + */ + public void pointRenderer(Graphics2D g2, + Rectangle2D dataArea, + PlotRenderingInfo info, + ContourPlot plot, + ValueAxis domainAxis, + ValueAxis rangeAxis, + ColorBar colorBar, + ContourDataset data, + CrosshairState crosshairState) { + + // setup for collecting optional entity info... + RectangularShape entityArea; + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + } + +// Rectangle2D.Double rect = null; +// rect = new Rectangle2D.Double(); + RectangularShape rect = new Ellipse2D.Double(); + + + //turn off anti-aliasing when filling rectangles + Object antiAlias = g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING); + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, + RenderingHints.VALUE_ANTIALIAS_OFF); + + // if (tooltips!=null) tooltips.clearToolTips(); // reset collection + // get the data points + Number[] xNumber = data.getXValues(); + Number[] yNumber = data.getYValues(); + Number[] zNumber = data.getZValues(); + + double[] x = new double[xNumber.length]; + double[] y = new double[yNumber.length]; + + for (int i = 0; i < x.length; i++) { + x[i] = xNumber[i].doubleValue(); + y[i] = yNumber[i].doubleValue(); + } + + double transX; + double transDX; + double transY; + double transDY; + double size = dataArea.getWidth() * this.ptSizePct; + for (int k = 0; k < x.length; k++) { + + transX = domainAxis.valueToJava2D(x[k], dataArea, + RectangleEdge.BOTTOM) - 0.5 * size; + transY = rangeAxis.valueToJava2D(y[k], dataArea, RectangleEdge.LEFT) + - 0.5 * size; + transDX = size; + transDY = size; + + rect.setFrame(transX, transY, transDX, transDY); + + if (zNumber[k] != null) { + g2.setPaint(colorBar.getPaint(zNumber[k].doubleValue())); + g2.fill(rect); + } + else if (this.missingPaint != null) { + g2.setPaint(this.missingPaint); + g2.fill(rect); + } + + + entityArea = rect; + + // add an entity for the item... + if (entities != null) { + String tip = null; + if (getToolTipGenerator() != null) { + tip = this.toolTipGenerator.generateToolTip(data, k); + } + String url = null; + // if (getURLGenerator() != null) { //dmo: look at this later + // url = getURLGenerator().generateURL(data, series, item); + // } + // Unlike XYItemRenderer, we need to clone entityArea since it + // reused. + ContourEntity entity = new ContourEntity( + (RectangularShape) entityArea.clone(), tip, url); + entity.setIndex(k); + entities.add(entity); + } + + // do we need to update the crosshair values? + if (plot.isDomainCrosshairLockedOnData()) { + if (plot.isRangeCrosshairLockedOnData()) { + // both axes + crosshairState.updateCrosshairPoint(x[k], y[k], transX, + transY, PlotOrientation.VERTICAL); + } + else { + // just the horizontal axis... + crosshairState.updateCrosshairX(transX); + } + } + else { + if (plot.isRangeCrosshairLockedOnData()) { + // just the vertical axis... + crosshairState.updateCrosshairY(transY); + } + } + } + + + g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, antiAlias); + + } + + /** + * Utility method for drawing a crosshair on the chart (if required). + * + * @param g2 The graphics device. + * @param dataArea The data area. + * @param value The coordinate, where to draw the line. + * @param stroke The stroke to use. + * @param paint The paint to use. + */ + protected void drawVerticalLine(Graphics2D g2, Rectangle2D dataArea, + double value, Stroke stroke, Paint paint) { + + double xx = getDomainAxis().valueToJava2D(value, dataArea, + RectangleEdge.BOTTOM); + Line2D line = new Line2D.Double(xx, dataArea.getMinY(), xx, + dataArea.getMaxY()); + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(line); + + } + + /** + * Utility method for drawing a crosshair on the chart (if required). + * + * @param g2 The graphics device. + * @param dataArea The data area. + * @param value The coordinate, where to draw the line. + * @param stroke The stroke to use. + * @param paint The paint to use. + */ + protected void drawHorizontalLine(Graphics2D g2, Rectangle2D dataArea, + double value, Stroke stroke, + Paint paint) { + + double yy = getRangeAxis().valueToJava2D(value, dataArea, + RectangleEdge.LEFT); + Line2D line = new Line2D.Double(dataArea.getMinX(), yy, + dataArea.getMaxX(), yy); + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(line); + + } + + /** + * Handles a 'click' on the plot by updating the anchor values... + * + * @param x x-coordinate, where the click occured. + * @param y y-coordinate, where the click occured. + * @param info An object for collection dimension information. + */ + @Override + public void handleClick(int x, int y, PlotRenderingInfo info) { + +/* // set the anchor value for the horizontal axis... + ValueAxis hva = getDomainAxis(); + if (hva != null) { + double hvalue = hva.translateJava2DtoValue( + (float) x, info.getDataArea() + ); + + hva.setAnchorValue(hvalue); + setDomainCrosshairValue(hvalue); + } + + // set the anchor value for the vertical axis... + ValueAxis vva = getRangeAxis(); + if (vva != null) { + double vvalue = vva.translateJava2DtoValue( + (float) y, info.getDataArea() + ); + vva.setAnchorValue(vvalue); + setRangeCrosshairValue(vvalue); + } +*/ + } + + /** + * Zooms the axis ranges by the specified percentage about the anchor point. + * + * @param percent The amount of the zoom. + */ + @Override + public void zoom(double percent) { + + if (percent > 0) { + // double range = this.domainAxis.getRange().getLength(); + // double scaledRange = range * percent; + // domainAxis.setAnchoredRange(scaledRange); + + // range = this.rangeAxis.getRange().getLength(); + // scaledRange = range * percent; + // rangeAxis.setAnchoredRange(scaledRange); + } + else { + getRangeAxis().setAutoRange(true); + getDomainAxis().setAutoRange(true); + } + + } + + /** + * Returns the plot type as a string. + * + * @return A short string describing the type of plot. + */ + @Override + public String getPlotType() { + return localizationResources.getString("Contour_Plot"); + } + + /** + * Returns the range for an axis. + * + * @param axis the axis. + * + * @return The range for an axis. + */ + @Override + public Range getDataRange(ValueAxis axis) { + + if (this.dataset == null) { + return null; + } + + Range result = null; + + if (axis == getDomainAxis()) { + result = DatasetUtilities.findDomainBounds(this.dataset); + } + else if (axis == getRangeAxis()) { + result = DatasetUtilities.findRangeBounds(this.dataset); + } + return result; + } + + /** + * Returns the range for the Contours. + * + * @return The range for the Contours (z-axis). + */ + @Override + public Range getContourDataRange() { + Range result = null; + ContourDataset data = getDataset(); + if (data != null) { + Range h = getDomainAxis().getRange(); + Range v = getRangeAxis().getRange(); + result = this.visibleRange(data, h, v); + } + return result; + } + + /** + * Notifies all registered listeners of a property change. + *

+ * One source of property change events is the plot's renderer. + * + * @param event Information about the property change. + */ + @Override + public void propertyChange(PropertyChangeEvent event) { + fireChangeEvent(); + } + + /** + * Receives notification of a change to the plot's dataset. + *

+ * The chart reacts by passing on a chart change event to all registered + * listeners. + * + * @param event Information about the event (not used here). + */ + @Override + public void datasetChanged(DatasetChangeEvent event) { + if (this.domainAxis != null) { + this.domainAxis.configure(); + } + if (this.rangeAxis != null) { + this.rangeAxis.configure(); + } + if (this.colorBar != null) { + this.colorBar.configure(this); + } + super.datasetChanged(event); + } + + /** + * Returns the colorbar. + * + * @return The colorbar. + */ + public ColorBar getColorBar() { + return this.colorBar; + } + + /** + * Returns a flag indicating whether or not the domain crosshair is visible. + * + * @return The flag. + */ + public boolean isDomainCrosshairVisible() { + return this.domainCrosshairVisible; + } + + /** + * Sets the flag indicating whether or not the domain crosshair is visible. + * + * @param flag the new value of the flag. + */ + public void setDomainCrosshairVisible(boolean flag) { + + if (this.domainCrosshairVisible != flag) { + this.domainCrosshairVisible = flag; + fireChangeEvent(); + } + + } + + /** + * Returns a flag indicating whether or not the crosshair should "lock-on" + * to actual data values. + * + * @return The flag. + */ + public boolean isDomainCrosshairLockedOnData() { + return this.domainCrosshairLockedOnData; + } + + /** + * Sets the flag indicating whether or not the domain crosshair should + * "lock-on" to actual data values. + * + * @param flag the flag. + */ + public void setDomainCrosshairLockedOnData(boolean flag) { + if (this.domainCrosshairLockedOnData != flag) { + this.domainCrosshairLockedOnData = flag; + fireChangeEvent(); + } + } + + /** + * Returns the domain crosshair value. + * + * @return The value. + */ + public double getDomainCrosshairValue() { + return this.domainCrosshairValue; + } + + /** + * Sets the domain crosshair value. + *

+ * Registered listeners are notified that the plot has been modified, but + * only if the crosshair is visible. + * + * @param value the new value. + */ + public void setDomainCrosshairValue(double value) { + setDomainCrosshairValue(value, true); + } + + /** + * Sets the domain crosshair value. + *

+ * Registered listeners are notified that the axis has been modified, but + * only if the crosshair is visible. + * + * @param value the new value. + * @param notify a flag that controls whether or not listeners are + * notified. + */ + public void setDomainCrosshairValue(double value, boolean notify) { + this.domainCrosshairValue = value; + if (isDomainCrosshairVisible() && notify) { + fireChangeEvent(); + } + } + + /** + * Returns the Stroke used to draw the crosshair (if visible). + * + * @return The crosshair stroke. + */ + public Stroke getDomainCrosshairStroke() { + return this.domainCrosshairStroke; + } + + /** + * Sets the Stroke used to draw the crosshairs (if visible) and notifies + * registered listeners that the axis has been modified. + * + * @param stroke the new crosshair stroke. + */ + public void setDomainCrosshairStroke(Stroke stroke) { + this.domainCrosshairStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the domain crosshair color. + * + * @return The crosshair color. + */ + public Paint getDomainCrosshairPaint() { + return this.domainCrosshairPaint; + } + + /** + * Sets the Paint used to color the crosshairs (if visible) and notifies + * registered listeners that the axis has been modified. + * + * @param paint the new crosshair paint. + */ + public void setDomainCrosshairPaint(Paint paint) { + this.domainCrosshairPaint = paint; + fireChangeEvent(); + } + + /** + * Returns a flag indicating whether or not the range crosshair is visible. + * + * @return The flag. + */ + public boolean isRangeCrosshairVisible() { + return this.rangeCrosshairVisible; + } + + /** + * Sets the flag indicating whether or not the range crosshair is visible. + * + * @param flag the new value of the flag. + */ + public void setRangeCrosshairVisible(boolean flag) { + if (this.rangeCrosshairVisible != flag) { + this.rangeCrosshairVisible = flag; + fireChangeEvent(); + } + } + + /** + * Returns a flag indicating whether or not the crosshair should "lock-on" + * to actual data values. + * + * @return The flag. + */ + public boolean isRangeCrosshairLockedOnData() { + return this.rangeCrosshairLockedOnData; + } + + /** + * Sets the flag indicating whether or not the range crosshair should + * "lock-on" to actual data values. + * + * @param flag the flag. + */ + public void setRangeCrosshairLockedOnData(boolean flag) { + if (this.rangeCrosshairLockedOnData != flag) { + this.rangeCrosshairLockedOnData = flag; + fireChangeEvent(); + } + } + + /** + * Returns the range crosshair value. + * + * @return The value. + */ + public double getRangeCrosshairValue() { + return this.rangeCrosshairValue; + } + + /** + * Sets the domain crosshair value. + *

+ * Registered listeners are notified that the plot has been modified, but + * only if the crosshair is visible. + * + * @param value the new value. + */ + public void setRangeCrosshairValue(double value) { + setRangeCrosshairValue(value, true); + } + + /** + * Sets the range crosshair value. + *

+ * Registered listeners are notified that the axis has been modified, but + * only if the crosshair is visible. + * + * @param value the new value. + * @param notify a flag that controls whether or not listeners are + * notified. + */ + public void setRangeCrosshairValue(double value, boolean notify) { + this.rangeCrosshairValue = value; + if (isRangeCrosshairVisible() && notify) { + fireChangeEvent(); + } + } + + /** + * Returns the Stroke used to draw the crosshair (if visible). + * + * @return The crosshair stroke. + */ + public Stroke getRangeCrosshairStroke() { + return this.rangeCrosshairStroke; + } + + /** + * Sets the Stroke used to draw the crosshairs (if visible) and notifies + * registered listeners that the axis has been modified. + * + * @param stroke the new crosshair stroke. + */ + public void setRangeCrosshairStroke(Stroke stroke) { + this.rangeCrosshairStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the range crosshair color. + * + * @return The crosshair color. + */ + public Paint getRangeCrosshairPaint() { + return this.rangeCrosshairPaint; + } + + /** + * Sets the Paint used to color the crosshairs (if visible) and notifies + * registered listeners that the axis has been modified. + * + * @param paint the new crosshair paint. + */ + public void setRangeCrosshairPaint(Paint paint) { + this.rangeCrosshairPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the tool tip generator. + * + * @return The tool tip generator (possibly null). + */ + public ContourToolTipGenerator getToolTipGenerator() { + return this.toolTipGenerator; + } + + /** + * Sets the tool tip generator. + * + * @param generator the tool tip generator (null permitted). + */ + public void setToolTipGenerator(ContourToolTipGenerator generator) { + //Object oldValue = this.toolTipGenerator; + this.toolTipGenerator = generator; + } + + /** + * Returns the URL generator for HTML image maps. + * + * @return The URL generator (possibly null). + */ + public XYURLGenerator getURLGenerator() { + return this.urlGenerator; + } + + /** + * Sets the URL generator for HTML image maps. + * + * @param urlGenerator the URL generator (null permitted). + */ + public void setURLGenerator(XYURLGenerator urlGenerator) { + //Object oldValue = this.urlGenerator; + this.urlGenerator = urlGenerator; + } + + /** + * Draws a vertical line on the chart to represent a 'range marker'. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param marker the marker line. + * @param dataArea the axis data area. + */ + public void drawDomainMarker(Graphics2D g2, + ContourPlot plot, + ValueAxis domainAxis, + Marker marker, + Rectangle2D dataArea) { + + if (marker instanceof ValueMarker) { + ValueMarker vm = (ValueMarker) marker; + double value = vm.getValue(); + Range range = domainAxis.getRange(); + if (!range.contains(value)) { + return; + } + + double x = domainAxis.valueToJava2D(value, dataArea, + RectangleEdge.BOTTOM); + Line2D line = new Line2D.Double(x, dataArea.getMinY(), x, + dataArea.getMaxY()); + Paint paint = marker.getOutlinePaint(); + Stroke stroke = marker.getOutlineStroke(); + g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT); + g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE); + g2.draw(line); + } + + } + + /** + * Draws a horizontal line across the chart to represent a 'range marker'. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param rangeAxis the range axis. + * @param marker the marker line. + * @param dataArea the axis data area. + */ + public void drawRangeMarker(Graphics2D g2, + ContourPlot plot, + ValueAxis rangeAxis, + Marker marker, + Rectangle2D dataArea) { + + if (marker instanceof ValueMarker) { + ValueMarker vm = (ValueMarker) marker; + double value = vm.getValue(); + Range range = rangeAxis.getRange(); + if (!range.contains(value)) { + return; + } + + double y = rangeAxis.valueToJava2D(value, dataArea, + RectangleEdge.LEFT); + Line2D line = new Line2D.Double(dataArea.getMinX(), y, + dataArea.getMaxX(), y); + Paint paint = marker.getOutlinePaint(); + Stroke stroke = marker.getOutlineStroke(); + g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT); + g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE); + g2.draw(line); + } + + } + + /** + * Returns the clipPath. + * @return ClipPath + */ + public ClipPath getClipPath() { + return this.clipPath; + } + + /** + * Sets the clipPath. + * @param clipPath The clipPath to set + */ + public void setClipPath(ClipPath clipPath) { + this.clipPath = clipPath; + } + + /** + * Returns the ptSizePct. + * @return double + */ + public double getPtSizePct() { + return this.ptSizePct; + } + + /** + * Returns the renderAsPoints. + * @return boolean + */ + public boolean isRenderAsPoints() { + return this.renderAsPoints; + } + + /** + * Sets the ptSizePct. + * @param ptSizePct The ptSizePct to set + */ + public void setPtSizePct(double ptSizePct) { + this.ptSizePct = ptSizePct; + } + + /** + * Sets the renderAsPoints. + * @param renderAsPoints The renderAsPoints to set + */ + public void setRenderAsPoints(boolean renderAsPoints) { + this.renderAsPoints = renderAsPoints; + } + + /** + * Receives notification of a change to one of the plot's axes. + * + * @param event information about the event. + */ + @Override + public void axisChanged(AxisChangeEvent event) { + Object source = event.getSource(); + if (source.equals(this.rangeAxis) || source.equals(this.domainAxis)) { + ColorBar cba = this.colorBar; + if (this.colorBar.getAxis().isAutoRange()) { + cba.getAxis().configure(); + } + + } + super.axisChanged(event); + } + + /** + * Returns the visible z-range. + * + * @param data the dataset. + * @param x the x range. + * @param y the y range. + * + * @return The range. + */ + public Range visibleRange(ContourDataset data, Range x, Range y) { + Range range = data.getZValueRange(x, y); + return range; + } + + /** + * Returns the missingPaint. + * @return Paint + */ + public Paint getMissingPaint() { + return this.missingPaint; + } + + /** + * Sets the missingPaint. + * + * @param paint the missingPaint to set. + */ + public void setMissingPaint(Paint paint) { + this.missingPaint = paint; + } + + /** + * Multiplies the range on the domain axis/axes by the specified factor + * (to be implemented). + * + * @param x the x-coordinate (in Java2D space). + * @param y the y-coordinate (in Java2D space). + * @param factor the zoom factor. + */ + public void zoomDomainAxes(double x, double y, double factor) { + // TODO: to be implemented + } + + /** + * Zooms the domain axes (not yet implemented). + * + * @param x the x-coordinate (in Java2D space). + * @param y the y-coordinate (in Java2D space). + * @param lowerPercent the new lower bound. + * @param upperPercent the new upper bound. + */ + public void zoomDomainAxes(double x, double y, double lowerPercent, + double upperPercent) { + // TODO: to be implemented + } + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * + * @param x the x-coordinate (in Java2D space). + * @param y the y-coordinate (in Java2D space). + * @param factor the zoom factor. + */ + public void zoomRangeAxes(double x, double y, double factor) { + // TODO: to be implemented + } + + /** + * Zooms the range axes (not yet implemented). + * + * @param x the x-coordinate (in Java2D space). + * @param y the y-coordinate (in Java2D space). + * @param lowerPercent the new lower bound. + * @param upperPercent the new upper bound. + */ + public void zoomRangeAxes(double x, double y, double lowerPercent, + double upperPercent) { + // TODO: to be implemented + } + + /** + * Returns false. + * + * @return A boolean. + */ + public boolean isDomainZoomable() { + return false; + } + + /** + * Returns false. + * + * @return A boolean. + */ + public boolean isRangeZoomable() { + return false; + } + + /** + * Extends plot cloning to this plot type + * @see org.jfree.chart.plot.Plot#clone() + */ + @Override + public Object clone() throws CloneNotSupportedException { + ContourPlot clone = (ContourPlot) super.clone(); + + if (this.domainAxis != null) { + clone.domainAxis = (ValueAxis) this.domainAxis.clone(); + clone.domainAxis.setPlot(clone); + clone.domainAxis.addChangeListener(clone); + } + if (this.rangeAxis != null) { + clone.rangeAxis = (ValueAxis) this.rangeAxis.clone(); + clone.rangeAxis.setPlot(clone); + clone.rangeAxis.addChangeListener(clone); + } + + if (clone.dataset != null) { + clone.dataset.addChangeListener(clone); + } + + if (this.colorBar != null) { + clone.colorBar = (ColorBar) this.colorBar.clone(); + } + + clone.domainMarkers = (List) ObjectUtilities.deepClone( + this.domainMarkers); + clone.rangeMarkers = (List) ObjectUtilities.deepClone( + this.rangeMarkers); + clone.annotations = (List) ObjectUtilities.deepClone(this.annotations); + + if (this.clipPath != null) { + clone.clipPath = (ClipPath) this.clipPath.clone(); + } + + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ContourPlotUtilities.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ContourPlotUtilities.java new file mode 100755 index 0000000..ad93269 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ContourPlotUtilities.java @@ -0,0 +1,76 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * ContourPlotUtilities.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); + * 22-Jul-2003 : Made this class abstract as there is no need to instantiate + * it (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 31-Jan-2007 : Deprecated (DG); + * + */ + +package org.jfree.chart.plot; + +import org.jfree.chart.renderer.xy.XYBlockRenderer; +import org.jfree.data.Range; +import org.jfree.data.contour.ContourDataset; +import org.jfree.data.contour.DefaultContourDataset; + +/** + * Some utility methods for the {@link ContourPlot} class. + * + * @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 abstract class ContourPlotUtilities { + + /** + * Returns the visible z-range. + * + * @param data the dataset. + * @param x the x range. + * @param y the y range. + * + * @return The range. + */ + public static Range visibleRange(ContourDataset data, Range x, Range y) { + Range range = null; + range = ((DefaultContourDataset) data).getZValueRange(x, y); + return range; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ContourValuePlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ContourValuePlot.java new file mode 100755 index 0000000..57ec91e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ContourValuePlot.java @@ -0,0 +1,62 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * ContourValuePlot.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); + * + */ + +package org.jfree.chart.plot; + +import org.jfree.chart.renderer.xy.XYBlockRenderer; +import org.jfree.data.Range; + +/** + * An interface defining methods related to contour plots. + * + * @deprecated This interface 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 interface ContourValuePlot { + + /** + * Returns the range of data values to be plotted. + * + * @return The range. + */ + public Range getContourDataRange(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Crosshair.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Crosshair.java new file mode 100755 index 0000000..c6ddcd1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Crosshair.java @@ -0,0 +1,727 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * Crosshair.java + * -------------- + * (C) Copyright 2009-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 13-Feb-2009 : Version 1 (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.Paint; +import java.awt.Stroke; +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +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.labels.CrosshairLabelGenerator; +import org.jfree.chart.labels.StandardCrosshairLabelGenerator; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleAnchor; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A crosshair for display on a plot. + * + * @since 1.0.13 + */ +public class Crosshair implements Cloneable, PublicCloneable, Serializable { + + /** Flag controlling visibility. */ + private boolean visible; + + /** The crosshair value. */ + private double value; + + /** The paint for the crosshair line. */ + private transient Paint paint; + + /** The stroke for the crosshair line. */ + private transient Stroke stroke; + + /** + * A flag that controls whether or not the crosshair has a label + * visible. + */ + private boolean labelVisible; + + /** + * The label anchor. + */ + private RectangleAnchor labelAnchor; + + /** A label generator. */ + private CrosshairLabelGenerator labelGenerator; + + /** + * The x-offset in Java2D units. + */ + private double labelXOffset; + + /** + * The y-offset in Java2D units. + */ + private double labelYOffset; + + /** + * The label font. + */ + private Font labelFont; + + /** + * The label paint. + */ + private transient Paint labelPaint; + + /** + * The label background paint. + */ + private transient Paint labelBackgroundPaint; + + /** A flag that controls the visibility of the label outline. */ + private boolean labelOutlineVisible; + + /** The label outline stroke. */ + private transient Stroke labelOutlineStroke; + + /** The label outline paint. */ + private transient Paint labelOutlinePaint; + + /** Property change support. */ + private transient PropertyChangeSupport pcs; + + /** + * Creates a new crosshair with value 0.0. + */ + public Crosshair() { + this(0.0); + } + + /** + * Creates a new crosshair with the specified value. + * + * @param value the value. + */ + public Crosshair(double value) { + this(value, Color.black, new BasicStroke(1.0f)); + } + + /** + * Creates a new crosshair value with the specified value and line style. + * + * @param value the value. + * @param paint the line paint (null not permitted). + * @param stroke the line stroke (null not permitted). + */ + public Crosshair(double value, Paint paint, Stroke stroke) { + ParamChecks.nullNotPermitted(paint, "paint"); + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.visible = true; + this.value = value; + this.paint = paint; + this.stroke = stroke; + this.labelVisible = false; + this.labelGenerator = new StandardCrosshairLabelGenerator(); + this.labelAnchor = RectangleAnchor.BOTTOM_LEFT; + this.labelXOffset = 3.0; + this.labelYOffset = 3.0; + this.labelFont = new Font("Tahoma", Font.PLAIN, 12); + this.labelPaint = Color.black; + this.labelBackgroundPaint = new Color(0, 0, 255, 63); + this.labelOutlineVisible = true; + this.labelOutlinePaint = Color.black; + this.labelOutlineStroke = new BasicStroke(0.5f); + this.pcs = new PropertyChangeSupport(this); + } + + /** + * Returns the flag that indicates whether or not the crosshair is + * currently visible. + * + * @return A boolean. + * + * @see #setVisible(boolean) + */ + public boolean isVisible() { + return this.visible; + } + + /** + * Sets the flag that controls the visibility of the crosshair and sends + * a proerty change event (with the name 'visible') to all registered + * listeners. + * + * @param visible the new flag value. + * + * @see #isVisible() + */ + public void setVisible(boolean visible) { + boolean old = this.visible; + this.visible = visible; + this.pcs.firePropertyChange("visible", old, visible); + } + + /** + * Returns the crosshair value. + * + * @return The crosshair value. + * + * @see #setValue(double) + */ + public double getValue() { + return this.value; + } + + /** + * Sets the crosshair value and sends a property change event with the name + * 'value' to all registered listeners. + * + * @param value the value. + * + * @see #getValue() + */ + public void setValue(double value) { + Double oldValue = new Double(this.value); + this.value = value; + this.pcs.firePropertyChange("value", oldValue, new Double(value)); + } + + /** + * Returns the paint for the crosshair line. + * + * @return The paint (never null). + * + * @see #setPaint(java.awt.Paint) + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Sets the paint for the crosshair line and sends a property change event + * with the name "paint" to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getPaint() + */ + public void setPaint(Paint paint) { + Paint old = this.paint; + this.paint = paint; + this.pcs.firePropertyChange("paint", old, paint); + } + + /** + * Returns the stroke for the crosshair line. + * + * @return The stroke (never null). + * + * @see #setStroke(java.awt.Stroke) + */ + public Stroke getStroke() { + return this.stroke; + } + + /** + * Sets the stroke for the crosshair line and sends a property change event + * with the name "stroke" to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getStroke() + */ + public void setStroke(Stroke stroke) { + Stroke old = this.stroke; + this.stroke = stroke; + this.pcs.firePropertyChange("stroke", old, stroke); + } + + /** + * Returns the flag that controls whether or not a label is drawn for + * this crosshair. + * + * @return A boolean. + * + * @see #setLabelVisible(boolean) + */ + public boolean isLabelVisible() { + return this.labelVisible; + } + + /** + * Sets the flag that controls whether or not a label is drawn for the + * crosshair and sends a property change event (with the name + * 'labelVisible') to all registered listeners. + * + * @param visible the new flag value. + * + * @see #isLabelVisible() + */ + public void setLabelVisible(boolean visible) { + boolean old = this.labelVisible; + this.labelVisible = visible; + this.pcs.firePropertyChange("labelVisible", old, visible); + } + + /** + * Returns the crosshair label generator. + * + * @return The label crosshair generator (never null). + * + * @see #setLabelGenerator(org.jfree.chart.labels.CrosshairLabelGenerator) + */ + public CrosshairLabelGenerator getLabelGenerator() { + return this.labelGenerator; + } + + /** + * Sets the crosshair label generator and sends a property change event + * (with the name 'labelGenerator') to all registered listeners. + * + * @param generator the new generator (null not permitted). + * + * @see #getLabelGenerator() + */ + public void setLabelGenerator(CrosshairLabelGenerator generator) { + ParamChecks.nullNotPermitted(generator, "generator"); + CrosshairLabelGenerator old = this.labelGenerator; + this.labelGenerator = generator; + this.pcs.firePropertyChange("labelGenerator", old, generator); + } + + /** + * Returns the label anchor point. + * + * @return the label anchor point (never null. + * + * @see #setLabelAnchor(org.jfree.ui.RectangleAnchor) + */ + public RectangleAnchor getLabelAnchor() { + return this.labelAnchor; + } + + /** + * Sets the label anchor point and sends a property change event (with the + * name 'labelAnchor') to all registered listeners. + * + * @param anchor the anchor (null not permitted). + * + * @see #getLabelAnchor() + */ + public void setLabelAnchor(RectangleAnchor anchor) { + RectangleAnchor old = this.labelAnchor; + this.labelAnchor = anchor; + this.pcs.firePropertyChange("labelAnchor", old, anchor); + } + + /** + * Returns the x-offset for the label (in Java2D units). + * + * @return The x-offset. + * + * @see #setLabelXOffset(double) + */ + public double getLabelXOffset() { + return this.labelXOffset; + } + + /** + * Sets the x-offset and sends a property change event (with the name + * 'labelXOffset') to all registered listeners. + * + * @param offset the new offset. + * + * @see #getLabelXOffset() + */ + public void setLabelXOffset(double offset) { + Double old = new Double(this.labelXOffset); + this.labelXOffset = offset; + this.pcs.firePropertyChange("labelXOffset", old, new Double(offset)); + } + + /** + * Returns the y-offset for the label (in Java2D units). + * + * @return The y-offset. + * + * @see #setLabelYOffset(double) + */ + public double getLabelYOffset() { + return this.labelYOffset; + } + + /** + * Sets the y-offset and sends a property change event (with the name + * 'labelYOffset') to all registered listeners. + * + * @param offset the new offset. + * + * @see #getLabelYOffset() + */ + public void setLabelYOffset(double offset) { + Double old = new Double(this.labelYOffset); + this.labelYOffset = offset; + this.pcs.firePropertyChange("labelYOffset", old, new Double(offset)); + } + + /** + * Returns the label font. + * + * @return The label font (never null). + * + * @see #setLabelFont(java.awt.Font) + */ + public Font getLabelFont() { + return this.labelFont; + } + + /** + * Sets the label font and sends a property change event (with the name + * 'labelFont') to all registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getLabelFont() + */ + public void setLabelFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + Font old = this.labelFont; + this.labelFont = font; + this.pcs.firePropertyChange("labelFont", old, font); + } + + /** + * Returns the label paint. + * + * @return The label paint (never null). + * + * @see #setLabelPaint + */ + public Paint getLabelPaint() { + return this.labelPaint; + } + + /** + * Sets the label paint and sends a property change event (with the name + * 'labelPaint') to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getLabelPaint() + */ + public void setLabelPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + Paint old = this.labelPaint; + this.labelPaint = paint; + this.pcs.firePropertyChange("labelPaint", old, paint); + } + + /** + * Returns the label background paint. + * + * @return The label background paint (possibly null). + * + * @see #setLabelBackgroundPaint(java.awt.Paint) + */ + public Paint getLabelBackgroundPaint() { + return this.labelBackgroundPaint; + } + + /** + * Sets the label background paint and sends a property change event with + * the name 'labelBackgroundPaint') to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @see #getLabelBackgroundPaint() + */ + public void setLabelBackgroundPaint(Paint paint) { + Paint old = this.labelBackgroundPaint; + this.labelBackgroundPaint = paint; + this.pcs.firePropertyChange("labelBackgroundPaint", old, paint); + } + + /** + * Returns the flag that controls the visibility of the label outline. + * + * @return A boolean. + * + * @see #setLabelOutlineVisible(boolean) + */ + public boolean isLabelOutlineVisible() { + return this.labelOutlineVisible; + } + + /** + * Sets the flag that controls the visibility of the label outlines and + * sends a property change event (with the name "labelOutlineVisible") to + * all registered listeners. + * + * @param visible the new flag value. + * + * @see #isLabelOutlineVisible() + */ + public void setLabelOutlineVisible(boolean visible) { + boolean old = this.labelOutlineVisible; + this.labelOutlineVisible = visible; + this.pcs.firePropertyChange("labelOutlineVisible", old, visible); + } + + /** + * Returns the label outline paint. + * + * @return The label outline paint (never null). + * + * @see #setLabelOutlinePaint(java.awt.Paint) + */ + public Paint getLabelOutlinePaint() { + return this.labelOutlinePaint; + } + + /** + * Sets the label outline paint and sends a property change event (with the + * name "labelOutlinePaint") to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getLabelOutlinePaint() + */ + public void setLabelOutlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + Paint old = this.labelOutlinePaint; + this.labelOutlinePaint = paint; + this.pcs.firePropertyChange("labelOutlinePaint", old, paint); + } + + /** + * Returns the label outline stroke. + * + * @return The label outline stroke (never null). + * + * @see #setLabelOutlineStroke(java.awt.Stroke) + */ + public Stroke getLabelOutlineStroke() { + return this.labelOutlineStroke; + } + + /** + * Sets the label outline stroke and sends a property change event (with + * the name 'labelOutlineStroke') to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getLabelOutlineStroke() + */ + public void setLabelOutlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + Stroke old = this.labelOutlineStroke; + this.labelOutlineStroke = stroke; + this.pcs.firePropertyChange("labelOutlineStroke", old, stroke); + } + + /** + * Tests this crosshair for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Crosshair)) { + return false; + } + Crosshair that = (Crosshair) obj; + if (this.visible != that.visible) { + return false; + } + if (this.value != that.value) { + return false; + } + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + if (!this.stroke.equals(that.stroke)) { + return false; + } + if (this.labelVisible != that.labelVisible) { + return false; + } + if (!this.labelGenerator.equals(that.labelGenerator)) { + return false; + } + if (!this.labelAnchor.equals(that.labelAnchor)) { + return false; + } + if (this.labelXOffset != that.labelXOffset) { + return false; + } + if (this.labelYOffset != that.labelYOffset) { + return false; + } + if (!this.labelFont.equals(that.labelFont)) { + return false; + } + if (!PaintUtilities.equal(this.labelPaint, that.labelPaint)) { + return false; + } + if (!PaintUtilities.equal(this.labelBackgroundPaint, + that.labelBackgroundPaint)) { + return false; + } + if (this.labelOutlineVisible != that.labelOutlineVisible) { + return false; + } + if (!PaintUtilities.equal(this.labelOutlinePaint, + that.labelOutlinePaint)) { + return false; + } + if (!this.labelOutlineStroke.equals(that.labelOutlineStroke)) { + return false; + } + return true; // can't find any difference + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int hash = 7; + hash = HashUtilities.hashCode(hash, this.visible); + hash = HashUtilities.hashCode(hash, this.value); + hash = HashUtilities.hashCode(hash, this.paint); + hash = HashUtilities.hashCode(hash, this.stroke); + hash = HashUtilities.hashCode(hash, this.labelVisible); + hash = HashUtilities.hashCode(hash, this.labelAnchor); + hash = HashUtilities.hashCode(hash, this.labelGenerator); + hash = HashUtilities.hashCode(hash, this.labelXOffset); + hash = HashUtilities.hashCode(hash, this.labelYOffset); + hash = HashUtilities.hashCode(hash, this.labelFont); + hash = HashUtilities.hashCode(hash, this.labelPaint); + hash = HashUtilities.hashCode(hash, this.labelBackgroundPaint); + hash = HashUtilities.hashCode(hash, this.labelOutlineVisible); + hash = HashUtilities.hashCode(hash, this.labelOutlineStroke); + hash = HashUtilities.hashCode(hash, this.labelOutlinePaint); + return hash; + } + + /** + * Returns an independent copy of this instance. + * + * @return An independent copy of this instance. + * + * @throws java.lang.CloneNotSupportedException + */ + @Override + public Object clone() throws CloneNotSupportedException { + // FIXME: clone generator + return super.clone(); + } + + /** + * Adds a property change listener. + * + * @param l the listener. + * + * @see #removePropertyChangeListener(java.beans.PropertyChangeListener) + */ + public void addPropertyChangeListener(PropertyChangeListener l) { + this.pcs.addPropertyChangeListener(l); + } + + /** + * Removes a property change listener. + * + * @param l the listener. + * + * @see #addPropertyChangeListener(java.beans.PropertyChangeListener) + */ + public void removePropertyChangeListener(PropertyChangeListener l) { + this.pcs.removePropertyChangeListener(l); + } + + /** + * 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); + SerialUtilities.writePaint(this.labelPaint, stream); + SerialUtilities.writePaint(this.labelBackgroundPaint, stream); + SerialUtilities.writeStroke(this.labelOutlineStroke, stream); + SerialUtilities.writePaint(this.labelOutlinePaint, 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); + this.labelPaint = SerialUtilities.readPaint(stream); + this.labelBackgroundPaint = SerialUtilities.readPaint(stream); + this.labelOutlineStroke = SerialUtilities.readStroke(stream); + this.labelOutlinePaint = SerialUtilities.readPaint(stream); + this.pcs = new PropertyChangeSupport(this); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CrosshairState.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CrosshairState.java new file mode 100755 index 0000000..c9135ba --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/CrosshairState.java @@ -0,0 +1,501 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * CrosshairState.java + * ------------------- + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 24-Jan-2002 : Version 1 (DG); + * 05-Mar-2002 : Added Javadoc comments (DG); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 19-Sep-2003 : Modified crosshair distance calculation (DG); + * 04-Dec-2003 : Crosshair anchor point now stored outside chart since it is + * dependent on the display target (DG); + * 25-Feb-2004 : Replaced CrosshairInfo --> CrosshairState (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 13-Oct-2006 : Fixed initialisation of CrosshairState - see bug report + * 1565168 (DG); + * 06-Feb-2007 : Added new fields and methods to fix bug 1086307 (DG); + * 26-Jun-2008 : Now tracks dataset index (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.geom.Point2D; + +/** + * Maintains state information about crosshairs on a plot between successive + * calls to the renderer's draw method. This class is used internally by + * JFreeChart - it is not intended for external use. + */ +public class CrosshairState { + + /** + * A flag that controls whether the distance is calculated in data space + * or Java2D space. + */ + private boolean calculateDistanceInDataSpace = false; + + /** The x-value (in data space) for the anchor point. */ + private double anchorX; + + /** The y-value (in data space) for the anchor point. */ + private double anchorY; + + /** The anchor point in Java2D space - if null, don't update crosshair. */ + private Point2D anchor; + + /** The x-value for the current crosshair point. */ + private double crosshairX; + + /** The y-value for the current crosshair point. */ + private double crosshairY; + + /** + * The dataset index that the crosshair point relates to (this determines + * the axes that the crosshairs will be plotted against). + * + * @since 1.0.11 + */ + private int datasetIndex; + + /** + * The index of the domain axis that the crosshair x-value is measured + * against. + * + * @since 1.0.4 + */ + private int domainAxisIndex; + + /** + * The index of the range axis that the crosshair y-value is measured + * against. + * + * @since 1.0.4 + */ + private int rangeAxisIndex; + + /** + * The smallest distance (so far) between the anchor point and a data + * point. + */ + private double distance; + + /** + * Creates a new CrosshairState instance that calculates + * distance in Java2D space. + */ + public CrosshairState() { + this(false); + } + + /** + * Creates a new CrosshairState instance. + * + * @param calculateDistanceInDataSpace a flag that controls whether the + * distance is calculated in data + * space or Java2D space. + */ + public CrosshairState(boolean calculateDistanceInDataSpace) { + this.calculateDistanceInDataSpace = calculateDistanceInDataSpace; + } + + /** + * Returns the distance between the anchor point and the current crosshair + * point. + * + * @return The distance. + * + * @see #setCrosshairDistance(double) + * @since 1.0.3 + */ + public double getCrosshairDistance() { + return this.distance; + } + + /** + * Sets the distance between the anchor point and the current crosshair + * point. As each data point is processed, its distance to the anchor + * point is compared with this value and, if it is closer, the data point + * becomes the new crosshair point. + * + * @param distance the distance. + * + * @see #getCrosshairDistance() + */ + public void setCrosshairDistance(double distance) { + this.distance = distance; + } + + /** + * Evaluates a data point and if it is the closest to the anchor point it + * becomes the new crosshair point. + *

+ * To understand this method, you need to know the context in which it will + * be called. An instance of this class is passed to an + * {@link org.jfree.chart.renderer.xy.XYItemRenderer} as + * each data point is plotted. As the point is plotted, it is passed to + * this method to see if it should be the new crosshair point. + * + * @param x x coordinate (measured against the domain axis). + * @param y y coordinate (measured against the range axis). + * @param transX x translated into Java2D space. + * @param transY y translated into Java2D space. + * @param orientation the plot orientation. + * + * @deprecated Use {@link #updateCrosshairPoint(double, double, int, int, + * double, double, PlotOrientation)}. See bug report 1086307. + */ + public void updateCrosshairPoint(double x, double y, + double transX, double transY, + PlotOrientation orientation) { + updateCrosshairPoint(x, y, 0, 0, transX, transY, orientation); + } + + /** + * Evaluates a data point and if it is the closest to the anchor point it + * becomes the new crosshair point. + *

+ * To understand this method, you need to know the context in which it will + * be called. An instance of this class is passed to an + * {@link org.jfree.chart.renderer.xy.XYItemRenderer} as + * each data point is plotted. As the point is plotted, it is passed to + * this method to see if it should be the new crosshair point. + * + * @param x x coordinate (measured against the domain axis). + * @param y y coordinate (measured against the range axis). + * @param domainAxisIndex the index of the domain axis for this point. + * @param rangeAxisIndex the index of the range axis for this point. + * @param transX x translated into Java2D space. + * @param transY y translated into Java2D space. + * @param orientation the plot orientation. + * + * @since 1.0.4 + */ + public void updateCrosshairPoint(double x, double y, int domainAxisIndex, + int rangeAxisIndex, double transX, double transY, + PlotOrientation orientation) { + + if (this.anchor != null) { + double d = 0.0; + if (this.calculateDistanceInDataSpace) { + d = (x - this.anchorX) * (x - this.anchorX) + + (y - this.anchorY) * (y - this.anchorY); + } + else { + double xx = this.anchor.getX(); + double yy = this.anchor.getY(); + if (orientation == PlotOrientation.HORIZONTAL) { + double temp = yy; + yy = xx; + xx = temp; + } + d = (transX - xx) * (transX - xx) + + (transY - yy) * (transY - yy); + } + + if (d < this.distance) { + this.crosshairX = x; + this.crosshairY = y; + this.domainAxisIndex = domainAxisIndex; + this.rangeAxisIndex = rangeAxisIndex; + this.distance = d; + } + } + + } + + /** + * Evaluates an x-value and if it is the closest to the anchor x-value it + * becomes the new crosshair value. + *

+ * Used in cases where only the x-axis is numerical. + * + * @param candidateX x position of the candidate for the new crosshair + * point. + * + * @deprecated Use {@link #updateCrosshairX(double, int)}. See bug report + * 1086307. + */ + public void updateCrosshairX(double candidateX) { + updateCrosshairX(candidateX, 0); + } + + /** + * Evaluates an x-value and if it is the closest to the anchor x-value it + * becomes the new crosshair value. + *

+ * Used in cases where only the x-axis is numerical. + * + * @param candidateX x position of the candidate for the new crosshair + * point. + * @param domainAxisIndex the index of the domain axis for this x-value. + * + * @since 1.0.4 + */ + public void updateCrosshairX(double candidateX, int domainAxisIndex) { + + double d = Math.abs(candidateX - this.anchorX); + if (d < this.distance) { + this.crosshairX = candidateX; + this.domainAxisIndex = domainAxisIndex; + this.distance = d; + } + + } + + /** + * Evaluates a y-value and if it is the closest to the anchor y-value it + * becomes the new crosshair value. + *

+ * Used in cases where only the y-axis is numerical. + * + * @param candidateY y position of the candidate for the new crosshair + * point. + * + * @deprecated Use {@link #updateCrosshairY(double, int)}. See bug report + * 1086307. + */ + public void updateCrosshairY(double candidateY) { + updateCrosshairY(candidateY, 0); + } + + /** + * Evaluates a y-value and if it is the closest to the anchor y-value it + * becomes the new crosshair value. + *

+ * Used in cases where only the y-axis is numerical. + * + * @param candidateY y position of the candidate for the new crosshair + * point. + * @param rangeAxisIndex the index of the range axis for this y-value. + * + * @since 1.0.4 + */ + public void updateCrosshairY(double candidateY, int rangeAxisIndex) { + double d = Math.abs(candidateY - this.anchorY); + if (d < this.distance) { + this.crosshairY = candidateY; + this.rangeAxisIndex = rangeAxisIndex; + this.distance = d; + } + + } + + /** + * Returns the anchor point. + * + * @return The anchor point. + * + * @see #setAnchor(Point2D) + * + * @since 1.0.3 + */ + public Point2D getAnchor() { + return this.anchor; + } + + /** + * Sets the anchor point. This is usually the mouse click point in a chart + * panel, and the crosshair point will often be the data item that is + * closest to the anchor point. + *

+ * Note that the x and y coordinates (in data space) are not updated by + * this method - the caller is responsible for ensuring that this happens + * in sync. + * + * @param anchor the anchor point (null permitted). + * + * @see #getAnchor() + */ + public void setAnchor(Point2D anchor) { + this.anchor = anchor; + } + + /** + * Returns the x-coordinate (in data space) for the anchor point. + * + * @return The x-coordinate of the anchor point. + * + * @since 1.0.3 + */ + public double getAnchorX() { + return this.anchorX; + } + + /** + * Sets the x-coordinate (in data space) for the anchor point. Note that + * this does NOT update the anchor itself - the caller is responsible for + * ensuring this is done in sync. + * + * @param x the x-coordinate. + * + * @since 1.0.3 + */ + public void setAnchorX(double x) { + this.anchorX = x; + } + + /** + * Returns the y-coordinate (in data space) for the anchor point. + * + * @return The y-coordinate of teh anchor point. + * + * @since 1.0.3 + */ + public double getAnchorY() { + return this.anchorY; + } + + /** + * Sets the y-coordinate (in data space) for the anchor point. Note that + * this does NOT update the anchor itself - the caller is responsible for + * ensuring this is done in sync. + * + * @param y the y-coordinate. + * + * @since 1.0.3 + */ + public void setAnchorY(double y) { + this.anchorY = y; + } + + /** + * Get the x-value for the crosshair point. + * + * @return The x position of the crosshair point. + * + * @see #setCrosshairX(double) + */ + public double getCrosshairX() { + return this.crosshairX; + } + + /** + * Sets the x coordinate for the crosshair. This is the coordinate in data + * space measured against the domain axis. + * + * @param x the coordinate. + * + * @see #getCrosshairX() + * @see #setCrosshairY(double) + * @see #updateCrosshairPoint(double, double, double, double, + * PlotOrientation) + */ + public void setCrosshairX(double x) { + this.crosshairX = x; + } + + /** + * Get the y-value for the crosshair point. This is the coordinate in data + * space measured against the range axis. + * + * @return The y position of the crosshair point. + * + * @see #setCrosshairY(double) + */ + public double getCrosshairY() { + return this.crosshairY; + } + + /** + * Sets the y coordinate for the crosshair. + * + * @param y the y coordinate. + * + * @see #getCrosshairY() + * @see #setCrosshairX(double) + * @see #updateCrosshairPoint(double, double, double, double, + * PlotOrientation) + */ + public void setCrosshairY(double y) { + this.crosshairY = y; + } + + /** + * Returns the dataset index that the crosshair values relate to. The + * dataset is mapped to specific axes, and this is how the crosshairs are + * mapped also. + * + * @return The dataset index. + * + * @see #setDatasetIndex(int) + * + * @since 1.0.11 + */ + public int getDatasetIndex() { + return this.datasetIndex; + } + + /** + * Sets the dataset index that the current crosshair values relate to. + * + * @param index the dataset index. + * + * @see #getDatasetIndex() + * + * @since 1.0.11 + */ + public void setDatasetIndex(int index) { + this.datasetIndex = index; + } + + /** + * Returns the domain axis index for the crosshair x-value. + * + * @return The domain axis index. + * + * @since 1.0.4 + * + * @deprecated As of version 1.0.11, the domain axis should be determined + * using the dataset index. + */ + public int getDomainAxisIndex() { + return this.domainAxisIndex; + } + + /** + * Returns the range axis index for the crosshair y-value. + * + * @return The range axis index. + * + * @since 1.0.4 + * + * @deprecated As of version 1.0.11, the domain axis should be determined + * using the dataset index. + */ + public int getRangeAxisIndex() { + return this.rangeAxisIndex; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/DatasetRenderingOrder.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/DatasetRenderingOrder.java new file mode 100755 index 0000000..eb2a1e5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/DatasetRenderingOrder.java @@ -0,0 +1,144 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * DatasetRenderingOrder.java + * -------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 02-May-2003 : Version 1 (DG); + * 02-Jun-2004 : Changed 'STANDARD' --> 'FORWARD' (DG); + * 21-Nov-2007 : Implemented hashCode() (DG); + * + */ + +package org.jfree.chart.plot; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Defines the tokens that indicate the rendering order for datasets in a + * {@link org.jfree.chart.plot.CategoryPlot} or an + * {@link org.jfree.chart.plot.XYPlot}. + */ +public final class DatasetRenderingOrder implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -600593412366385072L; + + /** + * Render datasets in the order 0, 1, 2, ..., N-1, where N is the number + * of datasets. + */ + public static final DatasetRenderingOrder FORWARD + = new DatasetRenderingOrder("DatasetRenderingOrder.FORWARD"); + + /** + * Render datasets in the order N-1, N-2, ..., 2, 1, 0, where N is the + * number of datasets. + */ + public static final DatasetRenderingOrder REVERSE + = new DatasetRenderingOrder("DatasetRenderingOrder.REVERSE"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private DatasetRenderingOrder(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string (never null). + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof DatasetRenderingOrder)) { + return false; + } + DatasetRenderingOrder order = (DatasetRenderingOrder) obj; + if (!this.name.equals(order.toString())) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return this.name.hashCode(); + } + + /** + * 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(DatasetRenderingOrder.FORWARD)) { + return DatasetRenderingOrder.FORWARD; + } + else if (this.equals(DatasetRenderingOrder.REVERSE)) { + return DatasetRenderingOrder.REVERSE; + } + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/DefaultDrawingSupplier.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/DefaultDrawingSupplier.java new file mode 100755 index 0000000..7d05e8f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/DefaultDrawingSupplier.java @@ -0,0 +1,549 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * DefaultDrawingSupplier.java + * --------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Jeremy Bowman; + * + * Changes + * ------- + * 16-Jan-2003 : Version 1 (DG); + * 17-Jan-2003 : Added stroke method, renamed DefaultPaintSupplier + * --> DefaultDrawingSupplier (DG) + * 27-Jan-2003 : Incorporated code from SeriesShapeFactory, originally + * contributed by Jeremy Bowman (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 13-Jun-2007 : Added fillPaintSequence (DG); + * + */ + + package org.jfree.chart.plot; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Paint; +import java.awt.Polygon; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Ellipse2D; +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.ChartColor; +import org.jfree.io.SerialUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A default implementation of the {@link DrawingSupplier} interface. All + * {@link Plot} instances have a new instance of this class installed by + * default. + */ +public class DefaultDrawingSupplier implements DrawingSupplier, Cloneable, + PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -7339847061039422538L; + + /** The default fill paint sequence. */ + public static final Paint[] DEFAULT_PAINT_SEQUENCE + = ChartColor.createDefaultPaintArray(); + + /** The default outline paint sequence. */ + public static final Paint[] DEFAULT_OUTLINE_PAINT_SEQUENCE = new Paint[] { + Color.lightGray}; + + /** The default fill paint sequence. */ + public static final Paint[] DEFAULT_FILL_PAINT_SEQUENCE = new Paint[] { + Color.white}; + + /** The default stroke sequence. */ + public static final Stroke[] DEFAULT_STROKE_SEQUENCE = new Stroke[] { + new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, + BasicStroke.JOIN_BEVEL)}; + + /** The default outline stroke sequence. */ + public static final Stroke[] DEFAULT_OUTLINE_STROKE_SEQUENCE + = new Stroke[] {new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, + BasicStroke.JOIN_BEVEL)}; + + /** The default shape sequence. */ + public static final Shape[] DEFAULT_SHAPE_SEQUENCE + = createStandardSeriesShapes(); + + /** The paint sequence. */ + private transient Paint[] paintSequence; + + /** The current paint index. */ + private int paintIndex; + + /** The outline paint sequence. */ + private transient Paint[] outlinePaintSequence; + + /** The current outline paint index. */ + private int outlinePaintIndex; + + /** The fill paint sequence. */ + private transient Paint[] fillPaintSequence; + + /** The current fill paint index. */ + private int fillPaintIndex; + + /** The stroke sequence. */ + private transient Stroke[] strokeSequence; + + /** The current stroke index. */ + private int strokeIndex; + + /** The outline stroke sequence. */ + private transient Stroke[] outlineStrokeSequence; + + /** The current outline stroke index. */ + private int outlineStrokeIndex; + + /** The shape sequence. */ + private transient Shape[] shapeSequence; + + /** The current shape index. */ + private int shapeIndex; + + /** + * Creates a new supplier, with default sequences for fill paint, outline + * paint, stroke and shapes. + */ + public DefaultDrawingSupplier() { + + this(DEFAULT_PAINT_SEQUENCE, DEFAULT_FILL_PAINT_SEQUENCE, + DEFAULT_OUTLINE_PAINT_SEQUENCE, + DEFAULT_STROKE_SEQUENCE, + DEFAULT_OUTLINE_STROKE_SEQUENCE, + DEFAULT_SHAPE_SEQUENCE); + + } + + /** + * Creates a new supplier. + * + * @param paintSequence the fill paint sequence. + * @param outlinePaintSequence the outline paint sequence. + * @param strokeSequence the stroke sequence. + * @param outlineStrokeSequence the outline stroke sequence. + * @param shapeSequence the shape sequence. + */ + public DefaultDrawingSupplier(Paint[] paintSequence, + Paint[] outlinePaintSequence, + Stroke[] strokeSequence, + Stroke[] outlineStrokeSequence, + Shape[] shapeSequence) { + + this.paintSequence = paintSequence; + this.fillPaintSequence = DEFAULT_FILL_PAINT_SEQUENCE; + this.outlinePaintSequence = outlinePaintSequence; + this.strokeSequence = strokeSequence; + this.outlineStrokeSequence = outlineStrokeSequence; + this.shapeSequence = shapeSequence; + + } + + /** + * Creates a new supplier. + * + * @param paintSequence the paint sequence. + * @param fillPaintSequence the fill paint sequence. + * @param outlinePaintSequence the outline paint sequence. + * @param strokeSequence the stroke sequence. + * @param outlineStrokeSequence the outline stroke sequence. + * @param shapeSequence the shape sequence. + * + * @since 1.0.6 + */ + public DefaultDrawingSupplier(Paint[] paintSequence, + Paint[] fillPaintSequence, Paint[] outlinePaintSequence, + Stroke[] strokeSequence, Stroke[] outlineStrokeSequence, + Shape[] shapeSequence) { + + this.paintSequence = paintSequence; + this.fillPaintSequence = fillPaintSequence; + this.outlinePaintSequence = outlinePaintSequence; + this.strokeSequence = strokeSequence; + this.outlineStrokeSequence = outlineStrokeSequence; + this.shapeSequence = shapeSequence; + } + + /** + * Returns the next paint in the sequence. + * + * @return The paint. + */ + @Override + public Paint getNextPaint() { + Paint result + = this.paintSequence[this.paintIndex % this.paintSequence.length]; + this.paintIndex++; + return result; + } + + /** + * Returns the next outline paint in the sequence. + * + * @return The paint. + */ + @Override + public Paint getNextOutlinePaint() { + Paint result = this.outlinePaintSequence[ + this.outlinePaintIndex % this.outlinePaintSequence.length]; + this.outlinePaintIndex++; + return result; + } + + /** + * Returns the next fill paint in the sequence. + * + * @return The paint. + * + * @since 1.0.6 + */ + @Override + public Paint getNextFillPaint() { + Paint result = this.fillPaintSequence[this.fillPaintIndex + % this.fillPaintSequence.length]; + this.fillPaintIndex++; + return result; + } + + /** + * Returns the next stroke in the sequence. + * + * @return The stroke. + */ + @Override + public Stroke getNextStroke() { + Stroke result = this.strokeSequence[ + this.strokeIndex % this.strokeSequence.length]; + this.strokeIndex++; + return result; + } + + /** + * Returns the next outline stroke in the sequence. + * + * @return The stroke. + */ + @Override + public Stroke getNextOutlineStroke() { + Stroke result = this.outlineStrokeSequence[ + this.outlineStrokeIndex % this.outlineStrokeSequence.length]; + this.outlineStrokeIndex++; + return result; + } + + /** + * Returns the next shape in the sequence. + * + * @return The shape. + */ + @Override + public Shape getNextShape() { + Shape result = this.shapeSequence[ + this.shapeIndex % this.shapeSequence.length]; + this.shapeIndex++; + return result; + } + + /** + * Creates an array of standard shapes to display for the items in series + * on charts. + * + * @return The array of shapes. + */ + public static Shape[] createStandardSeriesShapes() { + + Shape[] result = new Shape[10]; + + double size = 6.0; + double delta = size / 2.0; + int[] xpoints; + int[] ypoints; + + // square + result[0] = new Rectangle2D.Double(-delta, -delta, size, size); + // circle + result[1] = new Ellipse2D.Double(-delta, -delta, size, size); + + // up-pointing triangle + xpoints = intArray(0.0, delta, -delta); + ypoints = intArray(-delta, delta, delta); + result[2] = new Polygon(xpoints, ypoints, 3); + + // diamond + xpoints = intArray(0.0, delta, 0.0, -delta); + ypoints = intArray(-delta, 0.0, delta, 0.0); + result[3] = new Polygon(xpoints, ypoints, 4); + + // horizontal rectangle + result[4] = new Rectangle2D.Double(-delta, -delta / 2, size, size / 2); + + // down-pointing triangle + xpoints = intArray(-delta, +delta, 0.0); + ypoints = intArray(-delta, -delta, delta); + result[5] = new Polygon(xpoints, ypoints, 3); + + // horizontal ellipse + result[6] = new Ellipse2D.Double(-delta, -delta / 2, size, size / 2); + + // right-pointing triangle + xpoints = intArray(-delta, delta, -delta); + ypoints = intArray(-delta, 0.0, delta); + result[7] = new Polygon(xpoints, ypoints, 3); + + // vertical rectangle + result[8] = new Rectangle2D.Double(-delta / 2, -delta, size / 2, size); + + // left-pointing triangle + xpoints = intArray(-delta, delta, delta); + ypoints = intArray(0.0, -delta, +delta); + result[9] = new Polygon(xpoints, ypoints, 3); + + return result; + + } + + /** + * Tests this object for equality with another object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DefaultDrawingSupplier)) { + return false; + } + DefaultDrawingSupplier that = (DefaultDrawingSupplier) obj; + if (!Arrays.equals(this.paintSequence, that.paintSequence)) { + return false; + } + if (this.paintIndex != that.paintIndex) { + return false; + } + if (!Arrays.equals(this.outlinePaintSequence, + that.outlinePaintSequence)) { + return false; + } + if (this.outlinePaintIndex != that.outlinePaintIndex) { + return false; + } + if (!Arrays.equals(this.strokeSequence, that.strokeSequence)) { + return false; + } + if (this.strokeIndex != that.strokeIndex) { + return false; + } + if (!Arrays.equals(this.outlineStrokeSequence, + that.outlineStrokeSequence)) { + return false; + } + if (this.outlineStrokeIndex != that.outlineStrokeIndex) { + return false; + } + if (!equalShapes(this.shapeSequence, that.shapeSequence)) { + return false; + } + if (this.shapeIndex != that.shapeIndex) { + return false; + } + return true; + } + + /** + * A utility method for testing the equality of two arrays of shapes. + * + * @param s1 the first array (null permitted). + * @param s2 the second array (null permitted). + * + * @return A boolean. + */ + private boolean equalShapes(Shape[] s1, Shape[] s2) { + if (s1 == null) { + return s2 == null; + } + if (s2 == null) { + return false; + } + if (s1.length != s2.length) { + return false; + } + for (int i = 0; i < s1.length; i++) { + if (!ShapeUtilities.equal(s1[i], s2[i])) { + return false; + } + } + return true; + } + + /** + * Handles serialization. + * + * @param stream the output stream. + * + * @throws IOException if there is an I/O problem. + */ + private void writeObject(ObjectOutputStream stream) throws IOException { + stream.defaultWriteObject(); + + int paintCount = this.paintSequence.length; + stream.writeInt(paintCount); + for (int i = 0; i < paintCount; i++) { + SerialUtilities.writePaint(this.paintSequence[i], stream); + } + + int outlinePaintCount = this.outlinePaintSequence.length; + stream.writeInt(outlinePaintCount); + for (int i = 0; i < outlinePaintCount; i++) { + SerialUtilities.writePaint(this.outlinePaintSequence[i], stream); + } + + int strokeCount = this.strokeSequence.length; + stream.writeInt(strokeCount); + for (int i = 0; i < strokeCount; i++) { + SerialUtilities.writeStroke(this.strokeSequence[i], stream); + } + + int outlineStrokeCount = this.outlineStrokeSequence.length; + stream.writeInt(outlineStrokeCount); + for (int i = 0; i < outlineStrokeCount; i++) { + SerialUtilities.writeStroke(this.outlineStrokeSequence[i], stream); + } + + int shapeCount = this.shapeSequence.length; + stream.writeInt(shapeCount); + for (int i = 0; i < shapeCount; i++) { + SerialUtilities.writeShape(this.shapeSequence[i], stream); + } + + } + + /** + * Restores a serialized object. + * + * @param stream the input stream. + * + * @throws IOException if there is an I/O problem. + * @throws ClassNotFoundException if there is a problem loading a class. + */ + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + + int paintCount = stream.readInt(); + this.paintSequence = new Paint[paintCount]; + for (int i = 0; i < paintCount; i++) { + this.paintSequence[i] = SerialUtilities.readPaint(stream); + } + + int outlinePaintCount = stream.readInt(); + this.outlinePaintSequence = new Paint[outlinePaintCount]; + for (int i = 0; i < outlinePaintCount; i++) { + this.outlinePaintSequence[i] = SerialUtilities.readPaint(stream); + } + + int strokeCount = stream.readInt(); + this.strokeSequence = new Stroke[strokeCount]; + for (int i = 0; i < strokeCount; i++) { + this.strokeSequence[i] = SerialUtilities.readStroke(stream); + } + + int outlineStrokeCount = stream.readInt(); + this.outlineStrokeSequence = new Stroke[outlineStrokeCount]; + for (int i = 0; i < outlineStrokeCount; i++) { + this.outlineStrokeSequence[i] = SerialUtilities.readStroke(stream); + } + + int shapeCount = stream.readInt(); + this.shapeSequence = new Shape[shapeCount]; + for (int i = 0; i < shapeCount; i++) { + this.shapeSequence[i] = SerialUtilities.readShape(stream); + } + + } + + /** + * Helper method to avoid lots of explicit casts in getShape(). Returns + * an array containing the provided doubles cast to ints. + * + * @param a x + * @param b y + * @param c z + * + * @return int[3] with converted params. + */ + private static int[] intArray(double a, double b, double c) { + return new int[] {(int) a, (int) b, (int) c}; + } + + /** + * Helper method to avoid lots of explicit casts in getShape(). Returns + * an array containing the provided doubles cast to ints. + * + * @param a x + * @param b y + * @param c z + * @param d t + * + * @return int[4] with converted params. + */ + private static int[] intArray(double a, double b, double c, double d) { + return new int[] {(int) a, (int) b, (int) c, (int) d}; + } + + /** + * Returns a clone. + * + * @return A clone. + * + * @throws CloneNotSupportedException if a component of the supplier does + * not support cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultDrawingSupplier clone = (DefaultDrawingSupplier) super.clone(); + return clone; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/DialShape.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/DialShape.java new file mode 100755 index 0000000..4e31303 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/DialShape.java @@ -0,0 +1,140 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * DialShape.java + * -------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 20-Aug-2003 : Version 1 (DG); + * 12-Nov-2007 : Implemented hashCode() (DG); + * + */ + +package org.jfree.chart.plot; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Used to indicate the background shape for a + * {@link org.jfree.chart.plot.MeterPlot}. + */ +public final class DialShape implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -3471933055190251131L; + + /** Circle. */ + public static final DialShape CIRCLE = new DialShape("DialShape.CIRCLE"); + + /** Chord. */ + public static final DialShape CHORD = new DialShape("DialShape.CHORD"); + + /** Pie. */ + public static final DialShape PIE = new DialShape("DialShape.PIE"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private DialShape(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof DialShape)) { + return false; + } + DialShape shape = (DialShape) obj; + if (!this.name.equals(shape.toString())) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return this.name.hashCode(); + } + + /** + * 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(DialShape.CIRCLE)) { + return DialShape.CIRCLE; + } + else if (this.equals(DialShape.CHORD)) { + return DialShape.CHORD; + } + else if (this.equals(DialShape.PIE)) { + return DialShape.PIE; + } + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/DrawingSupplier.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/DrawingSupplier.java new file mode 100755 index 0000000..081e417 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/DrawingSupplier.java @@ -0,0 +1,107 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * DrawingSupplier.java + * -------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Jan-2003 : Version 1 (DG); + * 17-Jan-2003 : Renamed PaintSupplier --> DrawingSupplier (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 13-Jun-2007 : Added getNextOutlinePaint() method. + * + */ + +package org.jfree.chart.plot; + +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; + +/** + * A supplier of Paint, Stroke and Shape + * objects for use by plots and renderers. By providing a central place for + * obtaining these items, we can ensure that duplication is avoided. + *

+ * To support the cloning of charts, classes that implement this interface + * should also implement PublicCloneable. + */ +public interface DrawingSupplier { + + /** + * Returns the next paint in a sequence maintained by the supplier. + * + * @return The paint. + */ + public Paint getNextPaint(); + + /** + * Returns the next outline paint in a sequence maintained by the supplier. + * + * @return The paint. + */ + public Paint getNextOutlinePaint(); + + /** + * Returns the next fill paint in a sequence maintained by the supplier. + * + * @return The paint. + * + * @since 1.0.6 + */ + public Paint getNextFillPaint(); + + /** + * Returns the next Stroke object in a sequence maintained by + * the supplier. + * + * @return The stroke. + */ + public Stroke getNextStroke(); + + /** + * Returns the next Stroke object in a sequence maintained by + * the supplier. + * + * @return The stroke. + */ + public Stroke getNextOutlineStroke(); + + /** + * Returns the next Shape object in a sequence maintained by + * the supplier. + * + * @return The shape. + */ + public Shape getNextShape(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/FastScatterPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/FastScatterPlot.java new file mode 100755 index 0000000..d96ccf1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/FastScatterPlot.java @@ -0,0 +1,1130 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * FastScatterPlot.java + * -------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Arnaud Lelievre; + * + * Changes + * ------- + * 29-Oct-2002 : Added standard header (DG); + * 07-Nov-2002 : Fixed errors reported by Checkstyle (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 19-Aug-2003 : Implemented Cloneable (DG); + * 08-Sep-2003 : Added internationalization via use of properties + * resourceBundle (RFE 690236) (AL); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 12-Nov-2003 : Implemented zooming (DG); + * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); + * 26-Jan-2004 : Added domain and range grid lines (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); + * 29-Sep-2004 : Removed hard-coded color (DG); + * 04-Oct-2004 : Reworked equals() method and renamed ArrayUtils + * --> ArrayUtilities (DG); + * 12-Nov-2004 : Implemented the new Zoomable interface (DG); + * 05-May-2005 : Updated draw() method parameters (DG); + * 16-Jun-2005 : Added get/setData() methods (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 10-Nov-2006 : Fixed bug 1593150, by not allowing null axes, and added + * setDomainAxis() and setRangeAxis() methods (DG); + * 24-Sep-2007 : Implemented new zooming methods (DG); + * 25-Mar-2008 : Make use of new fireChangeEvent() method (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 26-Mar-2009 : Implemented Pannable, and fixed bug in zooming (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.AlphaComposite; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Line2D; +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 java.util.Iterator; +import java.util.List; +import java.util.ResourceBundle; + +import org.jfree.chart.axis.AxisSpace; +import org.jfree.chart.axis.AxisState; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.axis.ValueTick; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.data.Range; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ArrayUtilities; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; + +/** + * A fast scatter plot. + */ +public class FastScatterPlot extends Plot implements ValueAxisPlot, Pannable, + Zoomable, Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7871545897358563521L; + + /** The default grid line stroke. */ + public static final Stroke DEFAULT_GRIDLINE_STROKE = new BasicStroke(0.5f, + BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, new float[] + {2.0f, 2.0f}, 0.0f); + + /** The default grid line paint. */ + public static final Paint DEFAULT_GRIDLINE_PAINT = Color.lightGray; + + /** The data. */ + private float[][] data; + + /** The x data range. */ + private Range xDataRange; + + /** The y data range. */ + private Range yDataRange; + + /** The domain axis (used for the x-values). */ + private ValueAxis domainAxis; + + /** The range axis (used for the y-values). */ + private ValueAxis rangeAxis; + + /** The paint used to plot data points. */ + private transient Paint paint; + + /** A flag that controls whether the domain grid-lines are visible. */ + private boolean domainGridlinesVisible; + + /** The stroke used to draw the domain grid-lines. */ + private transient Stroke domainGridlineStroke; + + /** The paint used to draw the domain grid-lines. */ + private transient Paint domainGridlinePaint; + + /** A flag that controls whether the range grid-lines are visible. */ + private boolean rangeGridlinesVisible; + + /** The stroke used to draw the range grid-lines. */ + private transient Stroke rangeGridlineStroke; + + /** The paint used to draw the range grid-lines. */ + private transient Paint rangeGridlinePaint; + + /** + * A flag that controls whether or not panning is enabled for the domain + * axis. + * + * @since 1.0.13 + */ + private boolean domainPannable; + + /** + * A flag that controls whether or not panning is enabled for the range + * axis. + * + * @since 1.0.13 + */ + private boolean rangePannable; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.plot.LocalizationBundle"); + + /** + * Creates a new instance of FastScatterPlot with default + * axes. + */ + public FastScatterPlot() { + this(null, new NumberAxis("X"), new NumberAxis("Y")); + } + + /** + * Creates a new fast scatter plot. + *

+ * The data is an array of x, y values: data[0][i] = x, data[1][i] = y. + * + * @param data the data (null permitted). + * @param domainAxis the domain (x) axis (null not permitted). + * @param rangeAxis the range (y) axis (null not permitted). + */ + public FastScatterPlot(float[][] data, + ValueAxis domainAxis, ValueAxis rangeAxis) { + + super(); + ParamChecks.nullNotPermitted(domainAxis, "domainAxis"); + ParamChecks.nullNotPermitted(rangeAxis, "rangeAxis"); + + this.data = data; + this.xDataRange = calculateXDataRange(data); + this.yDataRange = calculateYDataRange(data); + this.domainAxis = domainAxis; + this.domainAxis.setPlot(this); + this.domainAxis.addChangeListener(this); + this.rangeAxis = rangeAxis; + this.rangeAxis.setPlot(this); + this.rangeAxis.addChangeListener(this); + + this.paint = Color.red; + + this.domainGridlinesVisible = true; + this.domainGridlinePaint = FastScatterPlot.DEFAULT_GRIDLINE_PAINT; + this.domainGridlineStroke = FastScatterPlot.DEFAULT_GRIDLINE_STROKE; + + this.rangeGridlinesVisible = true; + this.rangeGridlinePaint = FastScatterPlot.DEFAULT_GRIDLINE_PAINT; + this.rangeGridlineStroke = FastScatterPlot.DEFAULT_GRIDLINE_STROKE; + } + + /** + * Returns a short string describing the plot type. + * + * @return A short string describing the plot type. + */ + @Override + public String getPlotType() { + return localizationResources.getString("Fast_Scatter_Plot"); + } + + /** + * Returns the data array used by the plot. + * + * @return The data array (possibly null). + * + * @see #setData(float[][]) + */ + public float[][] getData() { + return this.data; + } + + /** + * Sets the data array used by the plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param data the data array (null permitted). + * + * @see #getData() + */ + public void setData(float[][] data) { + this.data = data; + fireChangeEvent(); + } + + /** + * Returns the orientation of the plot. + * + * @return The orientation (always {@link PlotOrientation#VERTICAL}). + */ + @Override + public PlotOrientation getOrientation() { + return PlotOrientation.VERTICAL; + } + + /** + * Returns the domain axis for the plot. + * + * @return The domain axis (never null). + * + * @see #setDomainAxis(ValueAxis) + */ + public ValueAxis getDomainAxis() { + return this.domainAxis; + } + + /** + * Sets the domain axis and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param axis the axis (null not permitted). + * + * @since 1.0.3 + * + * @see #getDomainAxis() + */ + public void setDomainAxis(ValueAxis axis) { + ParamChecks.nullNotPermitted(axis, "axis"); + this.domainAxis = axis; + fireChangeEvent(); + } + + /** + * Returns the range axis for the plot. + * + * @return The range axis (never null). + * + * @see #setRangeAxis(ValueAxis) + */ + public ValueAxis getRangeAxis() { + return this.rangeAxis; + } + + /** + * Sets the range axis and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param axis the axis (null not permitted). + * + * @since 1.0.3 + * + * @see #getRangeAxis() + */ + public void setRangeAxis(ValueAxis axis) { + ParamChecks.nullNotPermitted(axis, "axis"); + this.rangeAxis = axis; + fireChangeEvent(); + } + + /** + * Returns the paint used to plot data points. The default is + * Color.red. + * + * @return The paint. + * + * @see #setPaint(Paint) + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Sets the color for the data points and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getPaint() + */ + public void setPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.paint = paint; + fireChangeEvent(); + } + + /** + * Returns true if the domain gridlines are visible, and + * false otherwise. + * + * @return true or false. + * + * @see #setDomainGridlinesVisible(boolean) + * @see #setDomainGridlinePaint(Paint) + */ + public boolean isDomainGridlinesVisible() { + return this.domainGridlinesVisible; + } + + /** + * Sets the flag that controls whether or not the domain grid-lines are + * visible. If the flag value is changed, a {@link PlotChangeEvent} is + * sent to all registered listeners. + * + * @param visible the new value of the flag. + * + * @see #getDomainGridlinePaint() + */ + public void setDomainGridlinesVisible(boolean visible) { + if (this.domainGridlinesVisible != visible) { + this.domainGridlinesVisible = visible; + fireChangeEvent(); + } + } + + /** + * Returns the stroke for the grid-lines (if any) plotted against the + * domain axis. + * + * @return The stroke (never null). + * + * @see #setDomainGridlineStroke(Stroke) + */ + public Stroke getDomainGridlineStroke() { + return this.domainGridlineStroke; + } + + /** + * Sets the stroke for the grid lines plotted against the domain axis and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getDomainGridlineStroke() + */ + public void setDomainGridlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.domainGridlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint for the grid lines (if any) plotted against the domain + * axis. + * + * @return The paint (never null). + * + * @see #setDomainGridlinePaint(Paint) + */ + public Paint getDomainGridlinePaint() { + return this.domainGridlinePaint; + } + + /** + * Sets the paint for the grid lines plotted against the domain axis and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getDomainGridlinePaint() + */ + public void setDomainGridlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.domainGridlinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns true if the range axis grid is visible, and + * false otherwise. + * + * @return true or false. + * + * @see #setRangeGridlinesVisible(boolean) + */ + public boolean isRangeGridlinesVisible() { + return this.rangeGridlinesVisible; + } + + /** + * Sets the flag that controls whether or not the range axis grid lines are + * visible. If the flag value is changed, a {@link PlotChangeEvent} is + * sent to all registered listeners. + * + * @param visible the new value of the flag. + * + * @see #isRangeGridlinesVisible() + */ + public void setRangeGridlinesVisible(boolean visible) { + if (this.rangeGridlinesVisible != visible) { + this.rangeGridlinesVisible = visible; + fireChangeEvent(); + } + } + + /** + * Returns the stroke for the grid lines (if any) plotted against the range + * axis. + * + * @return The stroke (never null). + * + * @see #setRangeGridlineStroke(Stroke) + */ + public Stroke getRangeGridlineStroke() { + return this.rangeGridlineStroke; + } + + /** + * Sets the stroke for the grid lines plotted against the range axis and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null permitted). + * + * @see #getRangeGridlineStroke() + */ + public void setRangeGridlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.rangeGridlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint for the grid lines (if any) plotted against the range + * axis. + * + * @return The paint (never null). + * + * @see #setRangeGridlinePaint(Paint) + */ + public Paint getRangeGridlinePaint() { + return this.rangeGridlinePaint; + } + + /** + * Sets the paint for the grid lines plotted against the range axis and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getRangeGridlinePaint() + */ + public void setRangeGridlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.rangeGridlinePaint = paint; + fireChangeEvent(); + } + + /** + * Draws the fast scatter plot on a Java 2D graphics device (such as the + * screen or a printer). + * + * @param g2 the graphics device. + * @param area the area within which the plot (including axis labels) + * should be drawn. + * @param anchor the anchor point (null permitted). + * @param parentState the state from the parent plot (ignored). + * @param info collects chart drawing information (null + * permitted). + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, PlotRenderingInfo info) { + + // set up info collection... + if (info != null) { + info.setPlotArea(area); + } + + // adjust the drawing area for plot insets (if any)... + RectangleInsets insets = getInsets(); + insets.trim(area); + + AxisSpace space = new AxisSpace(); + space = this.domainAxis.reserveSpace(g2, this, area, + RectangleEdge.BOTTOM, space); + space = this.rangeAxis.reserveSpace(g2, this, area, RectangleEdge.LEFT, + space); + Rectangle2D dataArea = space.shrink(area, null); + + if (info != null) { + info.setDataArea(dataArea); + } + + // draw the plot background and axes... + drawBackground(g2, dataArea); + + AxisState domainAxisState = this.domainAxis.draw(g2, + dataArea.getMaxY(), area, dataArea, RectangleEdge.BOTTOM, info); + AxisState rangeAxisState = this.rangeAxis.draw(g2, dataArea.getMinX(), + area, dataArea, RectangleEdge.LEFT, info); + drawDomainGridlines(g2, dataArea, domainAxisState.getTicks()); + drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks()); + + Shape originalClip = g2.getClip(); + Composite originalComposite = g2.getComposite(); + + g2.clip(dataArea); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + getForegroundAlpha())); + + render(g2, dataArea, info, null); + + g2.setClip(originalClip); + g2.setComposite(originalComposite); + drawOutline(g2, dataArea); + + } + + /** + * Draws a representation of the data within the dataArea region. The + * info and crosshairState arguments may be + * null. + * + * @param g2 the graphics device. + * @param dataArea the region in which the data is to be drawn. + * @param info an optional object for collection dimension information. + * @param crosshairState collects crosshair information (null + * permitted). + */ + public void render(Graphics2D g2, Rectangle2D dataArea, + PlotRenderingInfo info, CrosshairState crosshairState) { + + + //long start = System.currentTimeMillis(); + //System.out.println("Start: " + start); + g2.setPaint(this.paint); + + // if the axes use a linear scale, you can uncomment the code below and + // switch to the alternative transX/transY calculation inside the loop + // that follows - it is a little bit faster then. + // + // int xx = (int) dataArea.getMinX(); + // int ww = (int) dataArea.getWidth(); + // int yy = (int) dataArea.getMaxY(); + // int hh = (int) dataArea.getHeight(); + // double domainMin = this.domainAxis.getLowerBound(); + // double domainLength = this.domainAxis.getUpperBound() - domainMin; + // double rangeMin = this.rangeAxis.getLowerBound(); + // double rangeLength = this.rangeAxis.getUpperBound() - rangeMin; + + if (this.data != null) { + for (int i = 0; i < this.data[0].length; i++) { + float x = this.data[0][i]; + float y = this.data[1][i]; + + //int transX = (int) (xx + ww * (x - domainMin) / domainLength); + //int transY = (int) (yy - hh * (y - rangeMin) / rangeLength); + int transX = (int) this.domainAxis.valueToJava2D(x, dataArea, + RectangleEdge.BOTTOM); + int transY = (int) this.rangeAxis.valueToJava2D(y, dataArea, + RectangleEdge.LEFT); + g2.fillRect(transX, transY, 1, 1); + } + } + //long finish = System.currentTimeMillis(); + //System.out.println("Finish: " + finish); + //System.out.println("Time: " + (finish - start)); + + } + + /** + * Draws the gridlines for the plot, if they are visible. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param ticks the ticks. + */ + protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, + List ticks) { + + // draw the domain grid lines, if the flag says they're visible... + if (isDomainGridlinesVisible()) { + Iterator iterator = ticks.iterator(); + while (iterator.hasNext()) { + ValueTick tick = (ValueTick) iterator.next(); + double v = this.domainAxis.valueToJava2D(tick.getValue(), + dataArea, RectangleEdge.BOTTOM); + Line2D line = new Line2D.Double(v, dataArea.getMinY(), v, + dataArea.getMaxY()); + g2.setPaint(getDomainGridlinePaint()); + g2.setStroke(getDomainGridlineStroke()); + g2.draw(line); + } + } + } + + /** + * Draws the gridlines for the plot, if they are visible. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param ticks the ticks. + */ + protected void drawRangeGridlines(Graphics2D g2, Rectangle2D dataArea, + List ticks) { + + // draw the range grid lines, if the flag says they're visible... + if (isRangeGridlinesVisible()) { + Iterator iterator = ticks.iterator(); + while (iterator.hasNext()) { + ValueTick tick = (ValueTick) iterator.next(); + double v = this.rangeAxis.valueToJava2D(tick.getValue(), + dataArea, RectangleEdge.LEFT); + Line2D line = new Line2D.Double(dataArea.getMinX(), v, + dataArea.getMaxX(), v); + g2.setPaint(getRangeGridlinePaint()); + g2.setStroke(getRangeGridlineStroke()); + g2.draw(line); + } + } + + } + + /** + * Returns the range of data values to be plotted along the axis, or + * null if the specified axis isn't the domain axis or the + * range axis for the plot. + * + * @param axis the axis (null permitted). + * + * @return The range (possibly null). + */ + @Override + public Range getDataRange(ValueAxis axis) { + Range result = null; + if (axis == this.domainAxis) { + result = this.xDataRange; + } + else if (axis == this.rangeAxis) { + result = this.yDataRange; + } + return result; + } + + /** + * Calculates the X data range. + * + * @param data the data (null permitted). + * + * @return The range. + */ + private Range calculateXDataRange(float[][] data) { + + Range result = null; + + if (data != null) { + float lowest = Float.POSITIVE_INFINITY; + float highest = Float.NEGATIVE_INFINITY; + for (int i = 0; i < data[0].length; i++) { + float v = data[0][i]; + if (v < lowest) { + lowest = v; + } + if (v > highest) { + highest = v; + } + } + if (lowest <= highest) { + result = new Range(lowest, highest); + } + } + + return result; + + } + + /** + * Calculates the Y data range. + * + * @param data the data (null permitted). + * + * @return The range. + */ + private Range calculateYDataRange(float[][] data) { + + Range result = null; + if (data != null) { + float lowest = Float.POSITIVE_INFINITY; + float highest = Float.NEGATIVE_INFINITY; + for (int i = 0; i < data[0].length; i++) { + float v = data[1][i]; + if (v < lowest) { + lowest = v; + } + if (v > highest) { + highest = v; + } + } + if (lowest <= highest) { + result = new Range(lowest, highest); + } + } + return result; + + } + + /** + * Multiplies the range on the domain axis by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info. + * @param source the source point. + */ + @Override + public void zoomDomainAxes(double factor, PlotRenderingInfo info, + Point2D source) { + this.domainAxis.resizeRange(factor); + } + + /** + * Multiplies the range on the domain axis by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info. + * @param source the source point (in Java2D space). + * @param useAnchor use source point as zoom anchor? + * + * @see #zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean) + * + * @since 1.0.7 + */ + @Override + public void zoomDomainAxes(double factor, PlotRenderingInfo info, + Point2D source, boolean useAnchor) { + + if (useAnchor) { + // get the source coordinate - this plot has always a VERTICAL + // orientation + double sourceX = source.getX(); + double anchorX = this.domainAxis.java2DToValue(sourceX, + info.getDataArea(), RectangleEdge.BOTTOM); + this.domainAxis.resizeRange2(factor, anchorX); + } + else { + this.domainAxis.resizeRange(factor); + } + + } + + /** + * Zooms in on the domain axes. + * + * @param lowerPercent the new lower bound as a percentage of the current + * range. + * @param upperPercent the new upper bound as a percentage of the current + * range. + * @param info the plot rendering info. + * @param source the source point. + */ + @Override + public void zoomDomainAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo info, Point2D source) { + this.domainAxis.zoomRange(lowerPercent, upperPercent); + } + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info. + * @param source the source point. + */ + @Override + public void zoomRangeAxes(double factor, PlotRenderingInfo info, + Point2D source) { + this.rangeAxis.resizeRange(factor); + } + + /** + * Multiplies the range on the range axis by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info. + * @param source the source point (in Java2D space). + * @param useAnchor use source point as zoom anchor? + * + * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean) + * + * @since 1.0.7 + */ + @Override + public void zoomRangeAxes(double factor, PlotRenderingInfo info, + Point2D source, boolean useAnchor) { + + if (useAnchor) { + // get the source coordinate - this plot has always a VERTICAL + // orientation + double sourceY = source.getY(); + double anchorY = this.rangeAxis.java2DToValue(sourceY, + info.getDataArea(), RectangleEdge.LEFT); + this.rangeAxis.resizeRange2(factor, anchorY); + } + else { + this.rangeAxis.resizeRange(factor); + } + + } + + /** + * Zooms in on the range axes. + * + * @param lowerPercent the new lower bound as a percentage of the current + * range. + * @param upperPercent the new upper bound as a percentage of the current + * range. + * @param info the plot rendering info. + * @param source the source point. + */ + @Override + public void zoomRangeAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo info, Point2D source) { + this.rangeAxis.zoomRange(lowerPercent, upperPercent); + } + + /** + * Returns true. + * + * @return A boolean. + */ + @Override + public boolean isDomainZoomable() { + return true; + } + + /** + * Returns true. + * + * @return A boolean. + */ + @Override + public boolean isRangeZoomable() { + return true; + } + + /** + * Returns true if panning is enabled for the domain axes, + * and false otherwise. + * + * @return A boolean. + * + * @since 1.0.13 + */ + @Override + public boolean isDomainPannable() { + return this.domainPannable; + } + + /** + * Sets the flag that enables or disables panning of the plot along the + * domain axes. + * + * @param pannable the new flag value. + * + * @since 1.0.13 + */ + public void setDomainPannable(boolean pannable) { + this.domainPannable = pannable; + } + + /** + * Returns true if panning is enabled for the range axes, + * and false otherwise. + * + * @return A boolean. + * + * @since 1.0.13 + */ + @Override + public boolean isRangePannable() { + return this.rangePannable; + } + + /** + * Sets the flag that enables or disables panning of the plot along + * the range axes. + * + * @param pannable the new flag value. + * + * @since 1.0.13 + */ + public void setRangePannable(boolean pannable) { + this.rangePannable = pannable; + } + + /** + * Pans the domain axes by the specified percentage. + * + * @param percent the distance to pan (as a percentage of the axis length). + * @param info the plot info + * @param source the source point where the pan action started. + * + * @since 1.0.13 + */ + @Override + public void panDomainAxes(double percent, PlotRenderingInfo info, + Point2D source) { + if (!isDomainPannable() || this.domainAxis == null) { + return; + } + double length = this.domainAxis.getRange().getLength(); + double adj = -percent * length; + if (this.domainAxis.isInverted()) { + adj = -adj; + } + this.domainAxis.setRange(this.domainAxis.getLowerBound() + adj, + this.domainAxis.getUpperBound() + adj); + } + + /** + * Pans the range axes by the specified percentage. + * + * @param percent the distance to pan (as a percentage of the axis length). + * @param info the plot info + * @param source the source point where the pan action started. + * + * @since 1.0.13 + */ + @Override + public void panRangeAxes(double percent, PlotRenderingInfo info, + Point2D source) { + if (!isRangePannable() || this.rangeAxis == null) { + return; + } + double length = this.rangeAxis.getRange().getLength(); + double adj = percent * length; + if (this.rangeAxis.isInverted()) { + adj = -adj; + } + this.rangeAxis.setRange(this.rangeAxis.getLowerBound() + adj, + this.rangeAxis.getUpperBound() + adj); + } + + /** + * Tests an arbitrary object for equality with this plot. Note that + * FastScatterPlot carries its data around with it (rather + * than referencing a dataset), and the data is included in the + * equality test. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof FastScatterPlot)) { + return false; + } + FastScatterPlot that = (FastScatterPlot) obj; + if (this.domainPannable != that.domainPannable) { + return false; + } + if (this.rangePannable != that.rangePannable) { + return false; + } + if (!ArrayUtilities.equal(this.data, that.data)) { + return false; + } + if (!ObjectUtilities.equal(this.domainAxis, that.domainAxis)) { + return false; + } + if (!ObjectUtilities.equal(this.rangeAxis, that.rangeAxis)) { + return false; + } + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + if (this.domainGridlinesVisible != that.domainGridlinesVisible) { + return false; + } + if (!PaintUtilities.equal(this.domainGridlinePaint, + that.domainGridlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.domainGridlineStroke, + that.domainGridlineStroke)) { + return false; + } + if (!this.rangeGridlinesVisible == that.rangeGridlinesVisible) { + return false; + } + if (!PaintUtilities.equal(this.rangeGridlinePaint, + that.rangeGridlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.rangeGridlineStroke, + that.rangeGridlineStroke)) { + return false; + } + return true; + } + + /** + * Returns a clone of the plot. + * + * @return A clone. + * + * @throws CloneNotSupportedException if some component of the plot does + * not support cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + + FastScatterPlot clone = (FastScatterPlot) super.clone(); + if (this.data != null) { + clone.data = ArrayUtilities.clone(this.data); + } + if (this.domainAxis != null) { + clone.domainAxis = (ValueAxis) this.domainAxis.clone(); + clone.domainAxis.setPlot(clone); + clone.domainAxis.addChangeListener(clone); + } + if (this.rangeAxis != null) { + clone.rangeAxis = (ValueAxis) this.rangeAxis.clone(); + clone.rangeAxis.setPlot(clone); + clone.rangeAxis.addChangeListener(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.writePaint(this.paint, stream); + SerialUtilities.writeStroke(this.domainGridlineStroke, stream); + SerialUtilities.writePaint(this.domainGridlinePaint, stream); + SerialUtilities.writeStroke(this.rangeGridlineStroke, stream); + SerialUtilities.writePaint(this.rangeGridlinePaint, 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.domainGridlineStroke = SerialUtilities.readStroke(stream); + this.domainGridlinePaint = SerialUtilities.readPaint(stream); + + this.rangeGridlineStroke = SerialUtilities.readStroke(stream); + this.rangeGridlinePaint = SerialUtilities.readPaint(stream); + + if (this.domainAxis != null) { + this.domainAxis.addChangeListener(this); + } + + if (this.rangeAxis != null) { + this.rangeAxis.addChangeListener(this); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/GreyPalette.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/GreyPalette.java new file mode 100755 index 0000000..dd2a499 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/GreyPalette.java @@ -0,0 +1,98 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * GreyPalette.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); + * 26-Mar-2003 : Implemented Serializable (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 31-Jan-2007 : Deprecated (DG); + * + */ + +package org.jfree.chart.plot; + +import java.io.Serializable; + +import org.jfree.chart.renderer.xy.XYBlockRenderer; + + +/** + * A grey color palette. + * + * @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 GreyPalette extends ColorPalette implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -2120941170159987395L; + + /** + * Creates a new palette. + */ + public GreyPalette() { + super(); + initialize(); + } + + /** + * Intializes the palette's indices. + */ + @Override + public void initialize() { + + setPaletteName("Grey"); + + this.r = new int[256]; + this.g = new int[256]; + this.b = new int[256]; + + this.r[0] = 255; + this.g[0] = 255; + this.b[0] = 255; + this.r[1] = 0; + this.g[1] = 0; + this.b[1] = 0; + + for (int i = 2; i < 256; i++) { + this.r[i] = i; + this.g[i] = i; + this.b[i] = i; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/IntervalMarker.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/IntervalMarker.java new file mode 100755 index 0000000..71f6249 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/IntervalMarker.java @@ -0,0 +1,235 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * IntervalMarker.java + * ------------------- + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Aug-2002 : Added stroke to constructor in Marker class (DG); + * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 05-Sep-2006 : Added MarkerChangeEvent notification (DG); + * 18-Dec-2007 : Added new constructor (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Paint; +import java.awt.Stroke; +import java.io.Serializable; + +import org.jfree.chart.event.MarkerChangeEvent; +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.LengthAdjustmentType; +import org.jfree.util.ObjectUtilities; + +/** + * Represents an interval to be highlighted in some way. + */ +public class IntervalMarker extends Marker implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -1762344775267627916L; + + /** The start value. */ + private double startValue; + + /** The end value. */ + private double endValue; + + /** The gradient paint transformer (optional). */ + private GradientPaintTransformer gradientPaintTransformer; + + /** + * Constructs an interval marker. + * + * @param start the start of the interval. + * @param end the end of the interval. + */ + public IntervalMarker(double start, double end) { + this(start, end, Color.gray, new BasicStroke(0.5f), Color.gray, + new BasicStroke(0.5f), 0.8f); + } + + /** + * Creates a new interval marker with the specified range and fill paint. + * The outline paint and stroke default to null. + * + * @param start the lower bound of the interval. + * @param end the upper bound of the interval. + * @param paint the fill paint (null not permitted). + * + * @since 1.0.9 + */ + public IntervalMarker(double start, double end, Paint paint) { + this(start, end, paint, new BasicStroke(0.5f), null, null, 0.8f); + } + + /** + * Constructs an interval marker. + * + * @param start the start of the interval. + * @param end the end of the interval. + * @param paint the paint (null not permitted). + * @param stroke the stroke (null not permitted). + * @param outlinePaint the outline paint. + * @param outlineStroke the outline stroke. + * @param alpha the alpha transparency. + */ + public IntervalMarker(double start, double end, + Paint paint, Stroke stroke, + Paint outlinePaint, Stroke outlineStroke, + float alpha) { + + super(paint, stroke, outlinePaint, outlineStroke, alpha); + this.startValue = start; + this.endValue = end; + this.gradientPaintTransformer = null; + setLabelOffsetType(LengthAdjustmentType.CONTRACT); + + } + + /** + * Returns the start value for the interval. + * + * @return The start value. + */ + public double getStartValue() { + return this.startValue; + } + + /** + * Sets the start value for the marker and sends a + * {@link MarkerChangeEvent} to all registered listeners. + * + * @param value the value. + * + * @since 1.0.3 + */ + public void setStartValue(double value) { + this.startValue = value; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Returns the end value for the interval. + * + * @return The end value. + */ + public double getEndValue() { + return this.endValue; + } + + /** + * Sets the end value for the marker and sends a + * {@link MarkerChangeEvent} to all registered listeners. + * + * @param value the value. + * + * @since 1.0.3 + */ + public void setEndValue(double value) { + this.endValue = value; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Returns the gradient paint transformer. + * + * @return The gradient paint transformer (possibly null). + */ + public GradientPaintTransformer getGradientPaintTransformer() { + return this.gradientPaintTransformer; + } + + /** + * Sets the gradient paint transformer and sends a + * {@link MarkerChangeEvent} to all registered listeners. + * + * @param transformer the transformer (null permitted). + */ + public void setGradientPaintTransformer( + GradientPaintTransformer transformer) { + this.gradientPaintTransformer = transformer; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Tests the marker for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof IntervalMarker)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + IntervalMarker that = (IntervalMarker) obj; + if (this.startValue != that.startValue) { + return false; + } + if (this.endValue != that.endValue) { + return false; + } + if (!ObjectUtilities.equal(this.gradientPaintTransformer, + that.gradientPaintTransformer)) { + return false; + } + return true; + } + + /** + * Returns a clone of the marker. + * + * @return A clone. + * + * @throws CloneNotSupportedException Not thrown by this class, but the + * exception is declared for the use of subclasses. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/JThermometer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/JThermometer.java new file mode 100755 index 0000000..cf49a73 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/JThermometer.java @@ -0,0 +1,378 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * JThermometer.java + * ----------------- + * A plot that displays a single value in a thermometer type display. + * + * (C) Copyright 2000-2008, Australian Antarctic Division and Contributors. + * + * Original Author: Bryan Scott. + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Irv Thomae; + * + * Changes (from 17-Sep-2002) + * -------------------------- + * 17-Sep-2002 : Reviewed with Checkstyle utility (DG); + * 18-Sep-2003 : Integrated new methods contributed by Irv Thomae (DG); + * 08-Jan-2004 : Renamed AbstractTitle --> Title and moved to new package (DG); + * 31-May-2005 : Fixed typo in method name (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.CardLayout; +import java.awt.Color; +import java.awt.Font; +import java.awt.Paint; +import java.io.Serializable; +import java.text.DecimalFormat; + +import javax.swing.JPanel; + +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.title.TextTitle; +import org.jfree.chart.title.Title; +import org.jfree.data.general.DefaultValueDataset; +import org.jfree.ui.RectangleInsets; + +/** + * An initial quick and dirty. The concept behind this class would be to + * generate a gui bean that could be used within JBuilder, Netbeans etc... + */ +public class JThermometer extends JPanel implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 1079905665515589820L; + + /** The dataset. */ + private DefaultValueDataset data; + + /** The chart. */ + private JFreeChart chart; + + /** The chart panel. */ + private ChartPanel panel; + + /** The thermometer plot. */ + private ThermometerPlot plot = new ThermometerPlot(); + + /** + * Default constructor. + */ + public JThermometer() { + super(new CardLayout()); + this.plot.setInsets(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); + this.data = new DefaultValueDataset(); + this.plot.setDataset(this.data); + this.chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, + this.plot, false); + this.panel = new ChartPanel(this.chart); + add(this.panel, "Panel"); + setBackground(getBackground()); + } + + /** + * Adds a subtitle to the chart. + * + * @param subtitle the subtitle. + */ + public void addSubtitle(Title subtitle) { + this.chart.addSubtitle(subtitle); + } + + /** + * Adds a subtitle to the chart. + * + * @param subtitle the subtitle. + */ + public void addSubtitle(String subtitle) { + this.chart.addSubtitle(new TextTitle(subtitle)); + } + + /** + * Adds a subtitle to the chart. + * + * @param subtitle the subtitle. + * @param font the subtitle font. + */ + public void addSubtitle(String subtitle, Font font) { + this.chart.addSubtitle(new TextTitle(subtitle, font)); + } + + /** + * Sets the value format for the thermometer. + * + * @param df the formatter. + */ + public void setValueFormat(DecimalFormat df) { + this.plot.setValueFormat(df); + } + + /** + * Sets the lower and upper bounds for the thermometer. + * + * @param lower the lower bound. + * @param upper the upper bound. + */ + public void setRange(double lower, double upper) { + this.plot.setRange(lower, upper); + } + + /** + * Sets the range. + * + * @param range the range type. + * @param displayLow the low value. + * @param displayHigh the high value. + */ + public void setSubrangeInfo(int range, double displayLow, + double displayHigh) { + this.plot.setSubrangeInfo(range, displayLow, displayHigh); + } + + /** + * Sets the range. + * + * @param range the range type. + * @param rangeLow the low value for the range. + * @param rangeHigh the high value for the range. + * @param displayLow the low value for display. + * @param displayHigh the high value for display. + */ + public void setSubrangeInfo(int range, + double rangeLow, double rangeHigh, + double displayLow, double displayHigh) { + + this.plot.setSubrangeInfo(range, rangeLow, rangeHigh, displayLow, + displayHigh); + + } + + /** + * Sets the location at which the temperature value is displayed. + * + * @param loc the location. + */ + public void setValueLocation(int loc) { + this.plot.setValueLocation(loc); + this.panel.repaint(); + } + + /** + * Sets the value paint. + * + * @param paint the paint. + */ + public void setValuePaint(Paint paint) { + this.plot.setValuePaint(paint); + } + + /** + * Returns the value of the thermometer. + * + * @return The value. + */ + public Number getValue() { + if (this.data != null) { + return this.data.getValue(); + } + else { + return null; + } + } + + /** + * Sets the value of the thermometer. + * + * @param value the value. + */ + public void setValue(double value) { + setValue(new Double(value)); + } + + /** + * Sets the value of the thermometer. + * + * @param value the value. + */ + public void setValue(Number value) { + if (this.data != null) { + this.data.setValue(value); + } + } + + /** + * Sets the unit type. + * + * @param i the unit type. + */ + public void setUnits(int i) { + if (this.plot != null) { + this.plot.setUnits(i); + } + } + + /** + * Sets the outline paint. + * + * @param p the paint. + */ + public void setOutlinePaint(Paint p) { + if (this.plot != null) { + this.plot.setOutlinePaint(p); + } + } + + /** + * Sets the foreground color. + * + * @param fg the foreground color. + */ + @Override + public void setForeground(Color fg) { + super.setForeground(fg); + if (this.plot != null) { + this.plot.setThermometerPaint(fg); + } + } + + /** + * Sets the background color. + * + * @param bg the background color. + */ + @Override + public void setBackground(Color bg) { + super.setBackground(bg); + if (this.plot != null) { + this.plot.setBackgroundPaint(bg); + } + if (this.chart != null) { + this.chart.setBackgroundPaint(bg); + } + if (this.panel != null) { + this.panel.setBackground(bg); + } + } + + /** + * Sets the value font. + * + * @param f the font. + */ + public void setValueFont(Font f) { + if (this.plot != null) { + this.plot.setValueFont(f); + } + } + + /** + * Returns the tick label font. + * + * @return The tick label font. + */ + public Font getTickLabelFont() { + ValueAxis axis = this.plot.getRangeAxis(); + return axis.getTickLabelFont(); + } + + /** + * Sets the tick label font. + * + * @param font the font. + */ + public void setTickLabelFont(Font font) { + ValueAxis axis = this.plot.getRangeAxis(); + axis.setTickLabelFont(font); + } + + /** + * Increases or decreases the tick font size. + * + * @param delta the change in size. + */ + public void changeTickFontSize(int delta) { + Font f = getTickLabelFont(); + String fName = f.getFontName(); + Font newFont = new Font(fName, f.getStyle(), (f.getSize() + delta)); + setTickLabelFont(newFont); + } + + /** + * Sets the tick font style. + * + * @param style the style. + */ + public void setTickFontStyle(int style) { + Font f = getTickLabelFont(); + String fName = f.getFontName(); + Font newFont = new Font(fName, style, f.getSize()); + setTickLabelFont(newFont); + } + + /** + * Sets the flag that controls whether or not the display range follows the + * data value. + * + * @param flag the new value of the flag. + */ + public void setFollowDataInSubranges(boolean flag) { + this.plot.setFollowDataInSubranges(flag); + } + + /** + * Sets the flag that controls whether or not value lines are displayed. + * + * @param b the new flag value. + */ + public void setShowValueLines(boolean b) { + this.plot.setShowValueLines(b); + } + + /** + * Sets the location for the axis. + * + * @param location the location. + */ + public void setShowAxisLocation(int location) { + this.plot.setAxisLocation(location); + } + + /** + * Returns the location for the axis. + * + * @return The location. + */ + public int getShowAxisLocation() { + return this.plot.getAxisLocation(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle.properties new file mode 100755 index 0000000..bc3d81d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle.properties @@ -0,0 +1,30 @@ +# org.jfree.chart.plot.plot ResourceBundle properties file +# +# Changes (from 31-Aug-2003) +# -------------------------- +# 31-Aug-2003 : Initial version (AL); +# 19-Jan-2004 : Added Polar_Plot (DG); +# + +Category_Plot=Category Plot +Combined_Domain_XYPlot=Combined Domain XYPlot +Combined_Range_XYPlot=Combined Range XYPlot +Compass_Plot=Compass Plot +Contour_Plot=Contour Plot +Fast_Scatter_Plot=Fast Scatter Plot +Meter_Plot=Meter Plot +Period_Marker_Plot=Period Marker Plot +Pie_Plot=Pie Plot +Thermometer_Plot=Thermometer Plot +XY_Plot=XY Plot +Polar_Plot=Polar Plot +Too_many_elements=Too many elements + +#Secteurs 3D +Pie_3D_Plot=Pie 3D Plot + +# points of the compass +N=N +E=E +S=S +W=W diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_cs.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_cs.properties new file mode 100755 index 0000000..415264e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_cs.properties @@ -0,0 +1,30 @@ +# org.jfree.chart.plot.plot ResourceBundle properties file +# +# Changes (from 31-Aug-2003) +# -------------------------- +# 31-Aug-2003 : Initial version (AL); +# 19-Jan-2004 : Added Polar_Plot (DG); +# 20-Mar-2010 : Czech translation; +# + +Category_Plot=Graf kategori\u00ed +Combined_Domain_XYPlot=XY graf kombinovan\u00e9 oblasti +Combined_Range_XYPlot=XY graf kombinovan\u00e9ho rozsahu +Compass_Plot=Kompasov\u00fd graf +Contour_Plot=Obrysov\u00fd graf +Fast_Scatter_Plot=Graf s rychl\u00fdm rozptylem +Meter_Plot=Graf s m\u011b\u0159i\u010dem +Period_Marker_Plot=Period Marker Plot +Pie_Plot=Kol\u00e1\u010dov\u00fd graf +Thermometer_Plot=Teplom\u011brov\u00fd graf +XY_Plot=XY graf +Polar_Plot=Pol\u00e1rn\u00ed graf + +#Secteurs 3D +Pie_3D_Plot=3D kol\u00e1\u010dov\u00fd graf + +# points of the compass +N=N +E=E +S=S +W=W diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_de.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_de.properties new file mode 100755 index 0000000..6c26576 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_de.properties @@ -0,0 +1,29 @@ +# org.jfree.chart.plot.plot ResourceBundle properties file - german version +# +# Changes (from 31-Aug-2003) +# -------------------------- +# 31-Aug-2003 : Initial version (AL); +# 15-Mar-2004 : Revised version (Christian W. Zuckschwerdt); +# + +Category_Plot=Kategoriediagramm +Combined_Domain_XYPlot=Rubriken-kombiniertes XY-Diagramm +Combined_Range_XYPlot=Werte-kombiniertes XY-Diagramm +Compass_Plot=Kompass-Diagramm +Contour_Plot=Liniendiagramm +Fast_Scatter_Plot=Streudiagramm +Meter_Plot=Tachometer-Diagramm +Period_Marker_Plot=Zeitreihe +Pie_Plot=Kreisdiagramm +Thermometer_Plot=Thermometer-Diagramm +XY_Plot=XY-Diagramm +Too_many_elements=Zu viele Elemente + +#Secteurs 3D +Pie_3D_Plot=3D-Kreisdiagramm + +# points of the compass +N=N +E=O +S=S +W=W diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_es.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_es.properties new file mode 100755 index 0000000..41c797f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_es.properties @@ -0,0 +1,26 @@ +# org.jfree.chart.plot.plot ResourceBundle properties file - spanish version +# +# Changes (from 16-Dec-2003) +# -------------------------- +# 16-Dec-2003 : Initial Version: Complejo Hospitalario Universitario Juan Canalejo +# + +Category_Plot=Barras +Combined_Domain_XYPlot=Curvas combinadas por la abcisa +Combined_Range_XYPlot=Curvas combinadas por la ordenada +Compass_Plot=Diagrama del comp\u00a3s +Contour_Plot=Contorno del comp\u00a3s +Fast_Scatter_Plot=Dispersi\u00f3n +Meter_Plot=Diagrama del metro +Period_Marker_Plot=Diagrama del marcador del per�odo +Pie_Plot=Sectores +Thermometer_Plot=Term\u00f3metro +XY_Plot=Curvas +Pie_3D_Plot=Sectores 3D +Too_many_elements=Too many elements + +# points of the compass +N=N +E=E +S=S +W=W diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_fr.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_fr.properties new file mode 100755 index 0000000..f00b228 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_fr.properties @@ -0,0 +1,26 @@ +# org.jfree.chart.plot.plot ResourceBundle properties file - French version +# +# Changes (from 31-Aug-2003) +# -------------------------- +# 31-Aug-2003 : Initial version (AL); +# + +Category_Plot=Barres +Combined_Domain_XYPlot=Courbes combin\u00E9es sur l'abcisse +Combined_Range_XYPlot=Courbes combin\u00E9es sur l'ordonn\u00E9e +Compass_Plot=Compas +Contour_Plot=Contours +Fast_Scatter_Plot=Nuage de points +Meter_Plot=Niveaux +Period_Marker_Plot=Period Marker Plot +Pie_Plot=Secteurs +Thermometer_Plot=Thermom\u00E8tre +XY_Plot=Courbes +Pie_3D_Plot=Secteurs 3D +Too_many_elements=Too many elements + +# points of the compass +N=N +E=E +S=S +W=W diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_ja.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_ja.properties new file mode 100755 index 0000000..73bc674 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_ja.properties @@ -0,0 +1,14 @@ + +Category_Plot=\u30ab\u30c6\u30b4\u30ea\u306e\u30d7\u30ed\u30c3\u30c8 +Combined_Domain_XYPlot=\u5206\u985e\u306e\u7d44\u307f\u5408\u308f\u305b XY\u30d7\u30ed\u30c3\u30c8 +Combined_Range_XYPlot=\u6570\u5024\u306e\u7d44\u307f\u5408\u308f\u305b XY\u30d7\u30ed\u30c3\u30c8 +Compass_Plot=\u30b3\u30f3\u30d1\u30b9\u30d7\u30ed\u30c3\u30c8 +Contour_Plot=\u7b49\u9ad8\u7dda\u56f3 +Fast_Scatter_Plot=\u9ad8\u901f\u6563\u5e03\u56f3 +Meter_Plot=\u30e1\u30fc\u30bf\u30fc\u306e\u30d7\u30ed\u30c3\u30c8 +Period_Marker_Plot=\u671f\u9593\u30de\u30fc\u30ab\u30fc\u306e\u30d7\u30ed\u30c3\u30c8 +Pie_3D_Plot=3D\u5186\u30b0\u30e9\u30d5\u306e\u30d7\u30ed\u30c3\u30c8 +Pie_Plot=\u5186\u30b0\u30e9\u30d5\u306e\u30d7\u30ed\u30c3\u30c8 +Polar_Plot=\u6975\u5ea7\u6a19\u306e\u30d7\u30ed\u30c3\u30c8 +Thermometer_Plot=\u6e29\u5ea6\u8a08\u306e\u30d7\u30ed\u30c3\u30c8 +XY_Plot=XY \u30d7\u30ed\u30c3\u30c8 diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_nl.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_nl.properties new file mode 100755 index 0000000..86cd5f6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_nl.properties @@ -0,0 +1,29 @@ +# org.jfree.chart.plot.plot ResourceBundle properties file +# +# Changes (from 31-Aug-2003) +# -------------------------- +# 24-Mar-2003 : Translated into Dutch +# 31-Aug-2003 : Initial version (AL); +# + +Category_Plot=Categorie diagram +Combined_Domain_XYPlot=Diagrammen met gecombineerd domein +Combined_Range_XYPlot=Diagrammen met gecombineerd bereik +Compass_Plot=Kompas diagram +Contour_Plot=Contour diagram +Fast_Scatter_Plot=Spreidingsdiagram +Meter_Plot=Wijzerplaat-diagram +Period_Marker_Plot=Periodemarker-diagram +Pie_Plot=Taartdiagram +Thermometer_Plot=Thermometer-diagram +XY_Plot=XY Diagram +Too_many_elements=Too many elements + +#Secteurs 3D +Pie_3D_Plot=3D Taartdiagram + +# points of the compass +N=N +E=E +S=S +W=W diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_pl.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_pl.properties new file mode 100755 index 0000000..3130c69 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_pl.properties @@ -0,0 +1,29 @@ +# org.jfree.chart.plot.plot ResourceBundle properties file +# +# Changes (from 15-Mar-2004) +# -------------------------- +# 15-Mar-2004 : Initial version (Kuba Duda); +# + +Category_Plot=Wykres kategorii +Combined_Domain_XYPlot=Wykres kombinowany z dzielon\u0105 osi\u0105 domeny +Combined_Range_XYPlot=Wykres kombinowany z dzielon\u0105 osi\u0105 zasi\u0119gu +Compass_Plot=wykres kompasowy +Contour_Plot=Wykres konturowy +Fast_Scatter_Plot=Szybki wykres rozproszony punktowy +Meter_Plot=Wykres miernikowy +Period_Marker_Plot=Wykres zaznaczaj\u0105cy okresy czasu +Pie_Plot=Wykres ko\u0142owy +Thermometer_Plot=Wykres temperatury +XY_Plot=Wykres XY +Polar_Plot=Wykres dwuwymiarowy o wsp\u00f3\u0142rz\u0119dnych biegunowych +Too_many_elements=Too many elements + +#Secteurs 3D +Pie_3D_Plot=Wykres ko\u0142owy 3D + +# points of the compass +N=N +E=E +S=S +W=W diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_pt_PT.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_pt_PT.properties new file mode 100755 index 0000000..5902caf --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_pt_PT.properties @@ -0,0 +1,26 @@ +# org.jfree.chart.ChartPanel ResourceBundle properties file - portuguese version +# +# Changes (from 09-Set-2003) +# -------------------------- +# 09-Set-2003 : Initial version (Eduardo Ramalho); +# + +Category_Plot=Barras +Combined_Domain_XYPlot=Curvas combinadas pela abcissa +Combined_Range_XYPlot=Curvas combinadas pela ordenada +Compass_Plot=Compasso +Contour_Plot=Contours +Fast_Scatter_Plot=Dispers\u00E3o +Meter_Plot=N\u00EDvel +Period_Marker_Plot=Period Marker Plot +Pie_Plot=Sectores +Thermometer_Plot=Term\u00a2metro +XY_Plot=Curvas +Pie_3D_Plot=Sectores 3D +Too_many_elements=Too many elements + +# points of the compass +N=N +E=E +S=S +W=W diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_ru.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_ru.properties new file mode 100755 index 0000000..6b6d1fb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_ru.properties @@ -0,0 +1,28 @@ +# org.jfree.chart.plot.plot ResourceBundle properties file +# +# Changes (from 10-Nov-2003) +# -------------------------- +# 10-Nov-2003 : Initial version (AL); +# + +Category_Plot=\u041a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u044f +Combined_Domain_XYPlot=\u0421\u043e\u0432\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u043e\u0441\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 +Combined_Range_XYPlot=\u0421\u043e\u0432\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043f\u043e \u043e\u0441\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 +Compass_Plot=\u041a\u043e\u043c\u043f\u0430\u0441 +Contour_Plot=\u041a\u043e\u043d\u0442\u0443\u0440 +Fast_Scatter_Plot=\u0420\u043e\u0441\u0441\u044b\u043f\u044c +Meter_Plot=\u041c\u0435\u0442\u0440\u0438\u043a\u0430 +Period_Marker_Plot=\u041f\u0435\u0440\u0438\u043e\u0434 +Pie_Plot=\u041a\u0440\u0443\u0433 +Thermometer_Plot=\u0422\u0435\u0440\u043c\u043e\u043c\u0435\u0442\u0440 +XY_Plot=XY +Too_many_elements=Too many elements + +#Secteurs 3D +Pie_3D_Plot=\u0422\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u0439 \u043a\u0440\u0443\u0433 + +# points of the compass +N=N +E=E +S=S +W=W diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_zh_CN.properties b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_zh_CN.properties new file mode 100755 index 0000000..0754c55 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/LocalizationBundle_zh_CN.properties @@ -0,0 +1,29 @@ +# org.jfree.chart.plot.plot ResourceBundle properties file +# +# Changes +# ------- +# 29-Jun-2005 : Initial version, see: http://www.jfree.org/phpBB2/viewtopic.php?t=13495; +# + +Category_Plot=\u7c7b\u6bd4\u56fe +Combined_Domain_XYPlot=\u7ec4\u5408\u7684\u9879\u76ee XY \u56fe +Combined_Range_XYPlot=\u7ec4\u5408\u7684\u8303\u56f4 XY \u56fe +Compass_Plot=\u7f57\u76d8\u56fe +Contour_Plot=\u8f6e\u5ed3\u56fe +Fast_Scatter_Plot=\u5feb\u901f\u5206\u6563\u56fe +Meter_Plot=\u4eea\u8868\u56fe +Period_Marker_Plot=\u5468\u671f\u6807\u8bb0\u56fe +Pie_Plot=\u997c\u56fe +Thermometer_Plot=\u6e29\u5ea6\u8ba1\u56fe +XY_Plot=XY \u56fe +Polar_Plot=\u6781\u5750\u6807\u56fe +Too_many_elements=Too many elements + +#Secteurs 3D +Pie_3D_Plot=\u4e09\u7ef4\u997c\u56fe + +# points of the compass +N=N +E=E +S=S +W=W diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Marker.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Marker.java new file mode 100755 index 0000000..7adb986 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Marker.java @@ -0,0 +1,665 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------- + * Marker.java + * ----------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Nicolas Brodu; + * + * Changes + * ------- + * 02-Jul-2002 : Added extra constructor, standard header and Javadoc + * comments (DG); + * 20-Aug-2002 : Added the outline stroke attribute (DG); + * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 16-Oct-2002 : Added new constructor (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 21-May-2003 : Added labels (DG); + * 11-Sep-2003 : Implemented Cloneable (NB); + * 05-Nov-2003 : Added checks to ensure some attributes are never null (DG); + * 11-Feb-2003 : Moved to org.jfree.chart.plot package, plus significant API + * changes to support IntervalMarker in plots (DG); + * 14-Jun-2004 : Updated equals() method (DG); + * 21-Jan-2005 : Added settings to control direction of horizontal and + * vertical label offsets (DG); + * 01-Jun-2005 : Modified to use only one label offset type - this will be + * applied to the domain or range axis as appropriate (DG); + * 06-Jun-2005 : Fix equals() method to handle GradientPaint (DG); + * 19-Aug-2005 : Changed constructor from public --> protected (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 05-Sep-2006 : Added MarkerChangeListener support (DG); + * 26-Sep-2007 : Fix for serialization bug 1802195 (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.Paint; +import java.awt.Stroke; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.EventListener; + +import javax.swing.event.EventListenerList; + +import org.jfree.chart.event.MarkerChangeEvent; +import org.jfree.chart.event.MarkerChangeListener; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.LengthAdjustmentType; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.TextAnchor; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; + +/** + * The base class for markers that can be added to plots to highlight a value + * or range of values. + *

+ * An event notification mechanism was added to this class in JFreeChart + * version 1.0.3. + */ +public abstract class Marker implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -734389651405327166L; + + /** The paint (null is not allowed). */ + private transient Paint paint; + + /** The stroke (null is not allowed). */ + private transient Stroke stroke; + + /** The outline paint. */ + private transient Paint outlinePaint; + + /** The outline stroke. */ + private transient Stroke outlineStroke; + + /** The alpha transparency. */ + private float alpha; + + /** The label. */ + private String label = null; + + /** The label font. */ + private Font labelFont; + + /** The label paint. */ + private transient Paint labelPaint; + + /** The label position. */ + private RectangleAnchor labelAnchor; + + /** The text anchor for the label. */ + private TextAnchor labelTextAnchor; + + /** The label offset from the marker rectangle. */ + private RectangleInsets labelOffset; + + /** + * The offset type for the domain or range axis (never null). + */ + private LengthAdjustmentType labelOffsetType; + + /** Storage for registered change listeners. */ + private transient EventListenerList listenerList; + + /** + * Creates a new marker with default attributes. + */ + protected Marker() { + this(Color.gray); + } + + /** + * Constructs a new marker. + * + * @param paint the paint (null not permitted). + */ + protected Marker(Paint paint) { + this(paint, new BasicStroke(0.5f), Color.gray, new BasicStroke(0.5f), + 0.80f); + } + + /** + * Constructs a new marker. + * + * @param paint the paint (null not permitted). + * @param stroke the stroke (null not permitted). + * @param outlinePaint the outline paint (null permitted). + * @param outlineStroke the outline stroke (null permitted). + * @param alpha the alpha transparency (must be in the range 0.0f to + * 1.0f). + * + * @throws IllegalArgumentException if paint or + * stroke is null, or alpha is + * not in the specified range. + */ + protected Marker(Paint paint, Stroke stroke, Paint outlinePaint, + Stroke outlineStroke, float alpha) { + + ParamChecks.nullNotPermitted(paint, "paint"); + ParamChecks.nullNotPermitted(stroke, "stroke"); + if (alpha < 0.0f || alpha > 1.0f) { + throw new IllegalArgumentException( + "The 'alpha' value must be in the range 0.0f to 1.0f"); + } + + this.paint = paint; + this.stroke = stroke; + this.outlinePaint = outlinePaint; + this.outlineStroke = outlineStroke; + this.alpha = alpha; + + this.labelFont = new Font("SansSerif", Font.PLAIN, 9); + this.labelPaint = Color.black; + this.labelAnchor = RectangleAnchor.TOP_LEFT; + this.labelOffset = new RectangleInsets(3.0, 3.0, 3.0, 3.0); + this.labelOffsetType = LengthAdjustmentType.CONTRACT; + this.labelTextAnchor = TextAnchor.CENTER; + + this.listenerList = new EventListenerList(); + } + + /** + * Returns the paint. + * + * @return The paint (never null). + * + * @see #setPaint(Paint) + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Sets the paint and sends a {@link MarkerChangeEvent} to all registered + * listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getPaint() + */ + public void setPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.paint = paint; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Returns the stroke. + * + * @return The stroke (never null). + * + * @see #setStroke(Stroke) + */ + public Stroke getStroke() { + return this.stroke; + } + + /** + * Sets the stroke and sends a {@link MarkerChangeEvent} to all registered + * listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getStroke() + */ + public void setStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.stroke = stroke; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Returns the outline paint. + * + * @return The outline paint (possibly null). + * + * @see #setOutlinePaint(Paint) + */ + public Paint getOutlinePaint() { + return this.outlinePaint; + } + + /** + * Sets the outline paint and sends a {@link MarkerChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null permitted). + * + * @see #getOutlinePaint() + */ + public void setOutlinePaint(Paint paint) { + this.outlinePaint = paint; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Returns the outline stroke. + * + * @return The outline stroke (possibly null). + * + * @see #setOutlineStroke(Stroke) + */ + public Stroke getOutlineStroke() { + return this.outlineStroke; + } + + /** + * Sets the outline stroke and sends a {@link MarkerChangeEvent} to all + * registered listeners. + * + * @param stroke the stroke (null permitted). + * + * @see #getOutlineStroke() + */ + public void setOutlineStroke(Stroke stroke) { + this.outlineStroke = stroke; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Returns the alpha transparency. + * + * @return The alpha transparency. + * + * @see #setAlpha(float) + */ + public float getAlpha() { + return this.alpha; + } + + /** + * Sets the alpha transparency that should be used when drawing the + * marker, and sends a {@link MarkerChangeEvent} to all registered + * listeners. The alpha transparency is a value in the range 0.0f + * (completely transparent) to 1.0f (completely opaque). + * + * @param alpha the alpha transparency (must be in the range 0.0f to + * 1.0f). + * + * @throws IllegalArgumentException if alpha is not in the + * specified range. + * + * @see #getAlpha() + */ + public void setAlpha(float alpha) { + if (alpha < 0.0f || alpha > 1.0f) { + throw new IllegalArgumentException( + "The 'alpha' value must be in the range 0.0f to 1.0f"); + } + this.alpha = alpha; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Returns the label (if null no label is displayed). + * + * @return The label (possibly null). + * + * @see #setLabel(String) + */ + public String getLabel() { + return this.label; + } + + /** + * Sets the label (if null no label is displayed) and sends a + * {@link MarkerChangeEvent} to all registered listeners. + * + * @param label the label (null permitted). + * + * @see #getLabel() + */ + public void setLabel(String label) { + this.label = label; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Returns the label font. + * + * @return The label font (never null). + * + * @see #setLabelFont(Font) + */ + public Font getLabelFont() { + return this.labelFont; + } + + /** + * Sets the label font and sends a {@link MarkerChangeEvent} to all + * registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getLabelFont() + */ + public void setLabelFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.labelFont = font; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Returns the label paint. + * + * @return The label paint (never null). + * + * @see #setLabelPaint(Paint) + */ + public Paint getLabelPaint() { + return this.labelPaint; + } + + /** + * Sets the label paint and sends a {@link MarkerChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getLabelPaint() + */ + public void setLabelPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.labelPaint = paint; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Returns the label anchor. This defines the position of the label + * anchor, relative to the bounds of the marker. + * + * @return The label anchor (never null). + * + * @see #setLabelAnchor(RectangleAnchor) + */ + public RectangleAnchor getLabelAnchor() { + return this.labelAnchor; + } + + /** + * Sets the label anchor and sends a {@link MarkerChangeEvent} to all + * registered listeners. The anchor defines the position of the label + * anchor, relative to the bounds of the marker. + * + * @param anchor the anchor (null not permitted). + * + * @see #getLabelAnchor() + */ + public void setLabelAnchor(RectangleAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.labelAnchor = anchor; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Returns the label offset. + * + * @return The label offset (never null). + * + * @see #setLabelOffset(RectangleInsets) + */ + public RectangleInsets getLabelOffset() { + return this.labelOffset; + } + + /** + * Sets the label offset and sends a {@link MarkerChangeEvent} to all + * registered listeners. + * + * @param offset the label offset (null not permitted). + * + * @see #getLabelOffset() + */ + public void setLabelOffset(RectangleInsets offset) { + ParamChecks.nullNotPermitted(offset, "offset"); + this.labelOffset = offset; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Returns the label offset type. + * + * @return The type (never null). + * + * @see #setLabelOffsetType(LengthAdjustmentType) + */ + public LengthAdjustmentType getLabelOffsetType() { + return this.labelOffsetType; + } + + /** + * Sets the label offset type and sends a {@link MarkerChangeEvent} to all + * registered listeners. + * + * @param adj the type (null not permitted). + * + * @see #getLabelOffsetType() + */ + public void setLabelOffsetType(LengthAdjustmentType adj) { + ParamChecks.nullNotPermitted(adj, "adj"); + this.labelOffsetType = adj; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Returns the label text anchor. + * + * @return The label text anchor (never null). + * + * @see #setLabelTextAnchor(TextAnchor) + */ + public TextAnchor getLabelTextAnchor() { + return this.labelTextAnchor; + } + + /** + * Sets the label text anchor and sends a {@link MarkerChangeEvent} to + * all registered listeners. + * + * @param anchor the label text anchor (null not permitted). + * + * @see #getLabelTextAnchor() + */ + public void setLabelTextAnchor(TextAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.labelTextAnchor = anchor; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Registers an object for notification of changes to the marker. + * + * @param listener the object to be registered. + * + * @see #removeChangeListener(MarkerChangeListener) + * + * @since 1.0.3 + */ + public void addChangeListener(MarkerChangeListener listener) { + this.listenerList.add(MarkerChangeListener.class, listener); + } + + /** + * Unregisters an object for notification of changes to the marker. + * + * @param listener the object to be unregistered. + * + * @see #addChangeListener(MarkerChangeListener) + * + * @since 1.0.3 + */ + public void removeChangeListener(MarkerChangeListener listener) { + this.listenerList.remove(MarkerChangeListener.class, listener); + } + + /** + * Notifies all registered listeners that the marker has been modified. + * + * @param event information about the change event. + * + * @since 1.0.3 + */ + public void notifyListeners(MarkerChangeEvent event) { + + Object[] listeners = this.listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == MarkerChangeListener.class) { + ((MarkerChangeListener) listeners[i + 1]).markerChanged(event); + } + } + + } + + /** + * Returns an array containing all the listeners of the specified type. + * + * @param listenerType the listener type. + * + * @return The array of listeners. + * + * @since 1.0.3 + */ + public EventListener[] getListeners(Class listenerType) { + return this.listenerList.getListeners(listenerType); + } + + /** + * Tests the marker for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Marker)) { + return false; + } + Marker that = (Marker) obj; + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + if (!ObjectUtilities.equal(this.stroke, that.stroke)) { + return false; + } + if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) { + return false; + } + if (this.alpha != that.alpha) { + return false; + } + if (!ObjectUtilities.equal(this.label, that.label)) { + return false; + } + if (!ObjectUtilities.equal(this.labelFont, that.labelFont)) { + return false; + } + if (!PaintUtilities.equal(this.labelPaint, that.labelPaint)) { + return false; + } + if (this.labelAnchor != that.labelAnchor) { + return false; + } + if (this.labelTextAnchor != that.labelTextAnchor) { + return false; + } + if (!ObjectUtilities.equal(this.labelOffset, that.labelOffset)) { + return false; + } + if (!this.labelOffsetType.equals(that.labelOffsetType)) { + return false; + } + return true; + } + + /** + * Creates a clone of the marker. + * + * @return A clone. + * + * @throws CloneNotSupportedException never. + */ + @Override + 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); + SerialUtilities.writePaint(this.outlinePaint, stream); + SerialUtilities.writeStroke(this.outlineStroke, stream); + SerialUtilities.writePaint(this.labelPaint, 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); + this.outlinePaint = SerialUtilities.readPaint(stream); + this.outlineStroke = SerialUtilities.readStroke(stream); + this.labelPaint = SerialUtilities.readPaint(stream); + this.listenerList = new EventListenerList(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/MeterInterval.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/MeterInterval.java new file mode 100755 index 0000000..8372a45 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/MeterInterval.java @@ -0,0 +1,225 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * MeterInterval.java + * ------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Mar-2005 : Version 1 (DG); + * 29-Mar-2005 : Fixed serialization (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Paint; +import java.awt.Stroke; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.Range; +import org.jfree.io.SerialUtilities; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; + +/** + * An interval to be highlighted on a {@link MeterPlot}. Instances of this + * class are immutable. + */ +public class MeterInterval implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 1530982090622488257L; + + /** The interval label. */ + private String label; + + /** The interval range. */ + private Range range; + + /** The outline paint (used for the arc marking the interval). */ + private transient Paint outlinePaint; + + /** The outline stroke (used for the arc marking the interval). */ + private transient Stroke outlineStroke; + + /** The background paint for the interval. */ + private transient Paint backgroundPaint; + + /** + * Creates a new interval. + * + * @param label the label (null not permitted). + * @param range the range (null not permitted). + */ + public MeterInterval(String label, Range range) { + this(label, range, Color.yellow, new BasicStroke(2.0f), null); + } + + /** + * Creates a new interval. + * + * @param label the label (null not permitted). + * @param range the range (null not permitted). + * @param outlinePaint the outline paint (null permitted). + * @param outlineStroke the outline stroke (null permitted). + * @param backgroundPaint the background paint (null + * permitted). + */ + public MeterInterval(String label, Range range, Paint outlinePaint, + Stroke outlineStroke, Paint backgroundPaint) { + ParamChecks.nullNotPermitted(label, "label"); + ParamChecks.nullNotPermitted(range, "range"); + this.label = label; + this.range = range; + this.outlinePaint = outlinePaint; + this.outlineStroke = outlineStroke; + this.backgroundPaint = backgroundPaint; + } + + /** + * Returns the label. + * + * @return The label (never null). + */ + public String getLabel() { + return this.label; + } + + /** + * Returns the range. + * + * @return The range (never null). + */ + public Range getRange() { + return this.range; + } + + /** + * Returns the background paint. If null, the background + * should remain unfilled. + * + * @return The background paint (possibly null). + */ + public Paint getBackgroundPaint() { + return this.backgroundPaint; + } + + /** + * Returns the outline paint. + * + * @return The outline paint (possibly null). + */ + public Paint getOutlinePaint() { + return this.outlinePaint; + } + + /** + * Returns the outline stroke. + * + * @return The outline stroke (possibly null). + */ + public Stroke getOutlineStroke() { + return this.outlineStroke; + } + + /** + * Checks this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof MeterInterval)) { + return false; + } + MeterInterval that = (MeterInterval) obj; + if (!this.label.equals(that.label)) { + return false; + } + if (!this.range.equals(that.range)) { + return false; + } + if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { + return false; + } + return true; + } + + /** + * 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.outlinePaint, stream); + SerialUtilities.writeStroke(this.outlineStroke, stream); + SerialUtilities.writePaint(this.backgroundPaint, 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.outlinePaint = SerialUtilities.readPaint(stream); + this.outlineStroke = SerialUtilities.readStroke(stream); + this.backgroundPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/MeterPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/MeterPlot.java new file mode 100755 index 0000000..24ea9ae --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/MeterPlot.java @@ -0,0 +1,1322 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * MeterPlot.java + * -------------- + * (C) Copyright 2000-2013, by Hari and Contributors. + * + * Original Author: Hari (ourhari@hotmail.com); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Bob Orchard; + * Arnaud Lelievre; + * Nicolas Brodu; + * David Bastend; + * + * Changes + * ------- + * 01-Apr-2002 : Version 1, contributed by Hari (DG); + * 23-Apr-2002 : Moved dataset from JFreeChart to Plot (DG); + * 22-Aug-2002 : Added changes suggest by Bob Orchard, changed Color to Paint + * for consistency, plus added Javadoc comments (DG); + * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 23-Jan-2003 : Removed one constructor (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 20-Aug-2003 : Changed dataset from MeterDataset --> ValueDataset, added + * equals() method, + * 08-Sep-2003 : Added internationalization via use of properties + * resourceBundle (RFE 690236) (AL); + * implemented Cloneable, and various other changes (DG); + * 08-Sep-2003 : Added serialization methods (NB); + * 11-Sep-2003 : Added cloning support (NB); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 25-Sep-2003 : Fix useless cloning. Correct dataset listener registration in + * constructor. (NB) + * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); + * 17-Jan-2004 : Changed to allow dialBackgroundPaint to be set to null - see + * bug 823628 (DG); + * 07-Apr-2004 : Changed string bounds calculation (DG); + * 12-May-2004 : Added tickLabelFormat attribute - see RFE 949566. Also + * updated the equals() method (DG); + * 02-Nov-2004 : Added sanity checks for range, and only draw the needle if the + * value is contained within the overall range - see bug report + * 1056047 (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * 02-Feb-2005 : Added optional background paint for each region (DG); + * 22-Mar-2005 : Removed 'normal', 'warning' and 'critical' regions and put in + * facility to define an arbitrary number of MeterIntervals, + * based on a contribution by David Bastend (DG); + * 20-Apr-2005 : Small update for change to LegendItem constructors (DG); + * 05-May-2005 : Updated draw() method parameters (DG); + * 08-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); + * 10-Nov-2005 : Added tickPaint, tickSize and valuePaint attributes, and + * put value label drawing code into a separate method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 05-Mar-2007 : Restore clip region correctly (see bug 1667750) (DG); + * 18-May-2007 : Set dataset for LegendItem (DG); + * 29-Nov-2007 : Fixed serialization bug with dialOutlinePaint (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.AlphaComposite; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Polygon; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Arc2D; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Line2D; +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 java.text.NumberFormat; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.ResourceBundle; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.data.Range; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.ValueDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.TextAnchor; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; + +/** + * A plot that displays a single value in the form of a needle on a dial. + * Defined ranges (for example, 'normal', 'warning' and 'critical') can be + * highlighted on the dial. + */ +public class MeterPlot extends Plot implements Serializable, Cloneable { + + /** For serialization. */ + private static final long serialVersionUID = 2987472457734470962L; + + /** The default background paint. */ + static final Paint DEFAULT_DIAL_BACKGROUND_PAINT = Color.black; + + /** The default needle paint. */ + static final Paint DEFAULT_NEEDLE_PAINT = Color.green; + + /** The default value font. */ + static final Font DEFAULT_VALUE_FONT = new Font("SansSerif", Font.BOLD, 12); + + /** The default value paint. */ + static final Paint DEFAULT_VALUE_PAINT = Color.yellow; + + /** The default meter angle. */ + public static final int DEFAULT_METER_ANGLE = 270; + + /** The default border size. */ + public static final float DEFAULT_BORDER_SIZE = 3f; + + /** The default circle size. */ + public static final float DEFAULT_CIRCLE_SIZE = 10f; + + /** The default label font. */ + public static final Font DEFAULT_LABEL_FONT = new Font("SansSerif", + Font.BOLD, 10); + + /** The dataset (contains a single value). */ + private ValueDataset dataset; + + /** The dial shape (background shape). */ + private DialShape shape; + + /** The dial extent (measured in degrees). */ + private int meterAngle; + + /** The overall range of data values on the dial. */ + private Range range; + + /** The tick size. */ + private double tickSize; + + /** The paint used to draw the ticks. */ + private transient Paint tickPaint; + + /** The units displayed on the dial. */ + private String units; + + /** The font for the value displayed in the center of the dial. */ + private Font valueFont; + + /** The paint for the value displayed in the center of the dial. */ + private transient Paint valuePaint; + + /** A flag that controls whether or not the border is drawn. */ + private boolean drawBorder; + + /** The outline paint. */ + private transient Paint dialOutlinePaint; + + /** The paint for the dial background. */ + private transient Paint dialBackgroundPaint; + + /** The paint for the needle. */ + private transient Paint needlePaint; + + /** A flag that controls whether or not the tick labels are visible. */ + private boolean tickLabelsVisible; + + /** The tick label font. */ + private Font tickLabelFont; + + /** The tick label paint. */ + private transient Paint tickLabelPaint; + + /** The tick label format. */ + private NumberFormat tickLabelFormat; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.plot.LocalizationBundle"); + + /** + * A (possibly empty) list of the {@link MeterInterval}s to be highlighted + * on the dial. + */ + private List intervals; + + /** + * Creates a new plot with a default range of 0 to + * 100 and no value to display. + */ + public MeterPlot() { + this(null); + } + + /** + * Creates a new plot that displays the value from the supplied dataset. + * + * @param dataset the dataset (null permitted). + */ + public MeterPlot(ValueDataset dataset) { + super(); + this.shape = DialShape.CIRCLE; + this.meterAngle = DEFAULT_METER_ANGLE; + this.range = new Range(0.0, 100.0); + this.tickSize = 10.0; + this.tickPaint = Color.white; + this.units = "Units"; + this.needlePaint = MeterPlot.DEFAULT_NEEDLE_PAINT; + this.tickLabelsVisible = true; + this.tickLabelFont = MeterPlot.DEFAULT_LABEL_FONT; + this.tickLabelPaint = Color.black; + this.tickLabelFormat = NumberFormat.getInstance(); + this.valueFont = MeterPlot.DEFAULT_VALUE_FONT; + this.valuePaint = MeterPlot.DEFAULT_VALUE_PAINT; + this.dialBackgroundPaint = MeterPlot.DEFAULT_DIAL_BACKGROUND_PAINT; + this.intervals = new java.util.ArrayList(); + setDataset(dataset); + } + + /** + * Returns the dial shape. The default is {@link DialShape#CIRCLE}). + * + * @return The dial shape (never null). + * + * @see #setDialShape(DialShape) + */ + public DialShape getDialShape() { + return this.shape; + } + + /** + * Sets the dial shape and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param shape the shape (null not permitted). + * + * @see #getDialShape() + */ + public void setDialShape(DialShape shape) { + ParamChecks.nullNotPermitted(shape, "shape"); + this.shape = shape; + fireChangeEvent(); + } + + /** + * Returns the meter angle in degrees. This defines, in part, the shape + * of the dial. The default is 270 degrees. + * + * @return The meter angle (in degrees). + * + * @see #setMeterAngle(int) + */ + public int getMeterAngle() { + return this.meterAngle; + } + + /** + * Sets the angle (in degrees) for the whole range of the dial and sends + * a {@link PlotChangeEvent} to all registered listeners. + * + * @param angle the angle (in degrees, in the range 1-360). + * + * @see #getMeterAngle() + */ + public void setMeterAngle(int angle) { + if (angle < 1 || angle > 360) { + throw new IllegalArgumentException("Invalid 'angle' (" + angle + + ")"); + } + this.meterAngle = angle; + fireChangeEvent(); + } + + /** + * Returns the overall range for the dial. + * + * @return The overall range (never null). + * + * @see #setRange(Range) + */ + public Range getRange() { + return this.range; + } + + /** + * Sets the range for the dial and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param range the range (null not permitted and zero-length + * ranges not permitted). + * + * @see #getRange() + */ + public void setRange(Range range) { + ParamChecks.nullNotPermitted(range, "range"); + if (!(range.getLength() > 0.0)) { + throw new IllegalArgumentException( + "Range length must be positive."); + } + this.range = range; + fireChangeEvent(); + } + + /** + * Returns the tick size (the interval between ticks on the dial). + * + * @return The tick size. + * + * @see #setTickSize(double) + */ + public double getTickSize() { + return this.tickSize; + } + + /** + * Sets the tick size and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param size the tick size (must be > 0). + * + * @see #getTickSize() + */ + public void setTickSize(double size) { + if (size <= 0) { + throw new IllegalArgumentException("Requires 'size' > 0."); + } + this.tickSize = size; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw the ticks around the dial. + * + * @return The paint used to draw the ticks around the dial (never + * null). + * + * @see #setTickPaint(Paint) + */ + public Paint getTickPaint() { + return this.tickPaint; + } + + /** + * Sets the paint used to draw the tick labels around the dial and sends + * a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getTickPaint() + */ + public void setTickPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.tickPaint = paint; + fireChangeEvent(); + } + + /** + * Returns a string describing the units for the dial. + * + * @return The units (possibly null). + * + * @see #setUnits(String) + */ + public String getUnits() { + return this.units; + } + + /** + * Sets the units for the dial and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param units the units (null permitted). + * + * @see #getUnits() + */ + public void setUnits(String units) { + this.units = units; + fireChangeEvent(); + } + + /** + * Returns the paint for the needle. + * + * @return The paint (never null). + * + * @see #setNeedlePaint(Paint) + */ + public Paint getNeedlePaint() { + return this.needlePaint; + } + + /** + * Sets the paint used to display the needle and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getNeedlePaint() + */ + public void setNeedlePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.needlePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the flag that determines whether or not tick labels are visible. + * + * @return The flag. + * + * @see #setTickLabelsVisible(boolean) + */ + public boolean getTickLabelsVisible() { + return this.tickLabelsVisible; + } + + /** + * Sets the flag that controls whether or not the tick labels are visible + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param visible the flag. + * + * @see #getTickLabelsVisible() + */ + public void setTickLabelsVisible(boolean visible) { + if (this.tickLabelsVisible != visible) { + this.tickLabelsVisible = visible; + fireChangeEvent(); + } + } + + /** + * Returns the tick label font. + * + * @return The font (never null). + * + * @see #setTickLabelFont(Font) + */ + public Font getTickLabelFont() { + return this.tickLabelFont; + } + + /** + * Sets the tick label font and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getTickLabelFont() + */ + public void setTickLabelFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + if (!this.tickLabelFont.equals(font)) { + this.tickLabelFont = font; + fireChangeEvent(); + } + } + + /** + * Returns the tick label paint. + * + * @return The paint (never null). + * + * @see #setTickLabelPaint(Paint) + */ + public Paint getTickLabelPaint() { + return this.tickLabelPaint; + } + + /** + * Sets the tick label paint and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getTickLabelPaint() + */ + public void setTickLabelPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + if (!this.tickLabelPaint.equals(paint)) { + this.tickLabelPaint = paint; + fireChangeEvent(); + } + } + + /** + * Returns the tick label format. + * + * @return The tick label format (never null). + * + * @see #setTickLabelFormat(NumberFormat) + */ + public NumberFormat getTickLabelFormat() { + return this.tickLabelFormat; + } + + /** + * Sets the format for the tick labels and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param format the format (null not permitted). + * + * @see #getTickLabelFormat() + */ + public void setTickLabelFormat(NumberFormat format) { + ParamChecks.nullNotPermitted(format, "format"); + this.tickLabelFormat = format; + fireChangeEvent(); + } + + /** + * Returns the font for the value label. + * + * @return The font (never null). + * + * @see #setValueFont(Font) + */ + public Font getValueFont() { + return this.valueFont; + } + + /** + * Sets the font used to display the value label and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getValueFont() + */ + public void setValueFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.valueFont = font; + fireChangeEvent(); + } + + /** + * Returns the paint for the value label. + * + * @return The paint (never null). + * + * @see #setValuePaint(Paint) + */ + public Paint getValuePaint() { + return this.valuePaint; + } + + /** + * Sets the paint used to display the value label and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getValuePaint() + */ + public void setValuePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.valuePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint for the dial background. + * + * @return The paint (possibly null). + * + * @see #setDialBackgroundPaint(Paint) + */ + public Paint getDialBackgroundPaint() { + return this.dialBackgroundPaint; + } + + /** + * Sets the paint used to fill the dial background. Set this to + * null for no background. + * + * @param paint the paint (null permitted). + * + * @see #getDialBackgroundPaint() + */ + public void setDialBackgroundPaint(Paint paint) { + this.dialBackgroundPaint = paint; + fireChangeEvent(); + } + + /** + * Returns a flag that controls whether or not a rectangular border is + * drawn around the plot area. + * + * @return A flag. + * + * @see #setDrawBorder(boolean) + */ + public boolean getDrawBorder() { + return this.drawBorder; + } + + /** + * Sets the flag that controls whether or not a rectangular border is drawn + * around the plot area and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param draw the flag. + * + * @see #getDrawBorder() + */ + public void setDrawBorder(boolean draw) { + // TODO: fix output when this flag is set to true + this.drawBorder = draw; + fireChangeEvent(); + } + + /** + * Returns the dial outline paint. + * + * @return The paint. + * + * @see #setDialOutlinePaint(Paint) + */ + public Paint getDialOutlinePaint() { + return this.dialOutlinePaint; + } + + /** + * Sets the dial outline paint and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param paint the paint. + * + * @see #getDialOutlinePaint() + */ + public void setDialOutlinePaint(Paint paint) { + this.dialOutlinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the dataset for the plot. + * + * @return The dataset (possibly null). + * + * @see #setDataset(ValueDataset) + */ + public ValueDataset getDataset() { + return this.dataset; + } + + /** + * Sets the dataset for the plot, replacing the existing dataset if there + * is one, and triggers a {@link PlotChangeEvent}. + * + * @param dataset the dataset (null permitted). + * + * @see #getDataset() + */ + public void setDataset(ValueDataset dataset) { + + // if there is an existing dataset, remove the plot from the list of + // change listeners... + ValueDataset existing = this.dataset; + if (existing != null) { + existing.removeChangeListener(this); + } + + // set the new dataset, and register the chart as a change listener... + this.dataset = dataset; + if (dataset != null) { + setDatasetGroup(dataset.getGroup()); + dataset.addChangeListener(this); + } + + // send a dataset change event to self... + DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); + datasetChanged(event); + + } + + /** + * Returns an unmodifiable list of the intervals for the plot. + * + * @return A list. + * + * @see #addInterval(MeterInterval) + */ + public List getIntervals() { + return Collections.unmodifiableList(this.intervals); + } + + /** + * Adds an interval and sends a {@link PlotChangeEvent} to all registered + * listeners. + * + * @param interval the interval (null not permitted). + * + * @see #getIntervals() + * @see #clearIntervals() + */ + public void addInterval(MeterInterval interval) { + ParamChecks.nullNotPermitted(interval, "interval"); + this.intervals.add(interval); + fireChangeEvent(); + } + + /** + * Clears the intervals for the plot and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @see #addInterval(MeterInterval) + */ + public void clearIntervals() { + this.intervals.clear(); + fireChangeEvent(); + } + + /** + * Returns an item for each interval. + * + * @return A collection of legend items. + */ + @Override + public LegendItemCollection getLegendItems() { + LegendItemCollection result = new LegendItemCollection(); + Iterator iterator = this.intervals.iterator(); + while (iterator.hasNext()) { + MeterInterval mi = (MeterInterval) iterator.next(); + Paint color = mi.getBackgroundPaint(); + if (color == null) { + color = mi.getOutlinePaint(); + } + LegendItem item = new LegendItem(mi.getLabel(), mi.getLabel(), + null, null, new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0), + color); + item.setDataset(getDataset()); + result.add(item); + } + return result; + } + + /** + * Draws the plot on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device. + * @param area the area within which the plot should be drawn. + * @param anchor the anchor point (null permitted). + * @param parentState the state from the parent plot, if there is one. + * @param info collects info about the drawing. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, PlotRenderingInfo info) { + + if (info != null) { + info.setPlotArea(area); + } + + // adjust for insets... + RectangleInsets insets = getInsets(); + insets.trim(area); + + area.setRect(area.getX() + 4, area.getY() + 4, area.getWidth() - 8, + area.getHeight() - 8); + + // draw the background + if (this.drawBorder) { + drawBackground(g2, area); + } + + // adjust the plot area by the interior spacing value + double gapHorizontal = (2 * DEFAULT_BORDER_SIZE); + double gapVertical = (2 * DEFAULT_BORDER_SIZE); + double meterX = area.getX() + gapHorizontal / 2; + double meterY = area.getY() + gapVertical / 2; + double meterW = area.getWidth() - gapHorizontal; + double meterH = area.getHeight() - gapVertical + + ((this.meterAngle <= 180) && (this.shape != DialShape.CIRCLE) + ? area.getHeight() / 1.25 : 0); + + double min = Math.min(meterW, meterH) / 2; + meterX = (meterX + meterX + meterW) / 2 - min; + meterY = (meterY + meterY + meterH) / 2 - min; + meterW = 2 * min; + meterH = 2 * min; + + Rectangle2D meterArea = new Rectangle2D.Double(meterX, meterY, meterW, + meterH); + + Rectangle2D.Double originalArea = new Rectangle2D.Double( + meterArea.getX() - 4, meterArea.getY() - 4, + meterArea.getWidth() + 8, meterArea.getHeight() + 8); + + double meterMiddleX = meterArea.getCenterX(); + double meterMiddleY = meterArea.getCenterY(); + + // plot the data (unless the dataset is null)... + ValueDataset data = getDataset(); + if (data != null) { + double dataMin = this.range.getLowerBound(); + double dataMax = this.range.getUpperBound(); + + Shape savedClip = g2.getClip(); + g2.clip(originalArea); + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + getForegroundAlpha())); + + if (this.dialBackgroundPaint != null) { + fillArc(g2, originalArea, dataMin, dataMax, + this.dialBackgroundPaint, true); + } + drawTicks(g2, meterArea, dataMin, dataMax); + drawArcForInterval(g2, meterArea, new MeterInterval("", this.range, + this.dialOutlinePaint, new BasicStroke(1.0f), null)); + + Iterator iterator = this.intervals.iterator(); + while (iterator.hasNext()) { + MeterInterval interval = (MeterInterval) iterator.next(); + drawArcForInterval(g2, meterArea, interval); + } + + Number n = data.getValue(); + if (n != null) { + double value = n.doubleValue(); + drawValueLabel(g2, meterArea); + + if (this.range.contains(value)) { + g2.setPaint(this.needlePaint); + g2.setStroke(new BasicStroke(2.0f)); + + double radius = (meterArea.getWidth() / 2) + + DEFAULT_BORDER_SIZE + 15; + double valueAngle = valueToAngle(value); + double valueP1 = meterMiddleX + + (radius * Math.cos(Math.PI * (valueAngle / 180))); + double valueP2 = meterMiddleY + - (radius * Math.sin(Math.PI * (valueAngle / 180))); + + Polygon arrow = new Polygon(); + if ((valueAngle > 135 && valueAngle < 225) + || (valueAngle < 45 && valueAngle > -45)) { + + double valueP3 = (meterMiddleY + - DEFAULT_CIRCLE_SIZE / 4); + double valueP4 = (meterMiddleY + + DEFAULT_CIRCLE_SIZE / 4); + arrow.addPoint((int) meterMiddleX, (int) valueP3); + arrow.addPoint((int) meterMiddleX, (int) valueP4); + + } + else { + arrow.addPoint((int) (meterMiddleX + - DEFAULT_CIRCLE_SIZE / 4), (int) meterMiddleY); + arrow.addPoint((int) (meterMiddleX + + DEFAULT_CIRCLE_SIZE / 4), (int) meterMiddleY); + } + arrow.addPoint((int) valueP1, (int) valueP2); + g2.fill(arrow); + + Ellipse2D circle = new Ellipse2D.Double(meterMiddleX + - DEFAULT_CIRCLE_SIZE / 2, meterMiddleY + - DEFAULT_CIRCLE_SIZE / 2, DEFAULT_CIRCLE_SIZE, + DEFAULT_CIRCLE_SIZE); + g2.fill(circle); + } + } + + g2.setClip(savedClip); + g2.setComposite(originalComposite); + + } + if (this.drawBorder) { + drawOutline(g2, area); + } + + } + + /** + * Draws the arc to represent an interval. + * + * @param g2 the graphics device. + * @param meterArea the drawing area. + * @param interval the interval. + */ + protected void drawArcForInterval(Graphics2D g2, Rectangle2D meterArea, + MeterInterval interval) { + + double minValue = interval.getRange().getLowerBound(); + double maxValue = interval.getRange().getUpperBound(); + Paint outlinePaint = interval.getOutlinePaint(); + Stroke outlineStroke = interval.getOutlineStroke(); + Paint backgroundPaint = interval.getBackgroundPaint(); + + if (backgroundPaint != null) { + fillArc(g2, meterArea, minValue, maxValue, backgroundPaint, false); + } + if (outlinePaint != null) { + if (outlineStroke != null) { + drawArc(g2, meterArea, minValue, maxValue, outlinePaint, + outlineStroke); + } + drawTick(g2, meterArea, minValue, true); + drawTick(g2, meterArea, maxValue, true); + } + } + + /** + * Draws an arc. + * + * @param g2 the graphics device. + * @param area the plot area. + * @param minValue the minimum value. + * @param maxValue the maximum value. + * @param paint the paint. + * @param stroke the stroke. + */ + protected void drawArc(Graphics2D g2, Rectangle2D area, double minValue, + double maxValue, Paint paint, Stroke stroke) { + + double startAngle = valueToAngle(maxValue); + double endAngle = valueToAngle(minValue); + double extent = endAngle - startAngle; + + double x = area.getX(); + double y = area.getY(); + double w = area.getWidth(); + double h = area.getHeight(); + g2.setPaint(paint); + g2.setStroke(stroke); + + if (paint != null && stroke != null) { + Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle, + extent, Arc2D.OPEN); + g2.setPaint(paint); + g2.setStroke(stroke); + g2.draw(arc); + } + + } + + /** + * Fills an arc on the dial between the given values. + * + * @param g2 the graphics device. + * @param area the plot area. + * @param minValue the minimum data value. + * @param maxValue the maximum data value. + * @param paint the background paint (null not permitted). + * @param dial a flag that indicates whether the arc represents the whole + * dial. + */ + protected void fillArc(Graphics2D g2, Rectangle2D area, + double minValue, double maxValue, Paint paint, boolean dial) { + + ParamChecks.nullNotPermitted(paint, "paint"); + double startAngle = valueToAngle(maxValue); + double endAngle = valueToAngle(minValue); + double extent = endAngle - startAngle; + + double x = area.getX(); + double y = area.getY(); + double w = area.getWidth(); + double h = area.getHeight(); + int joinType = Arc2D.OPEN; + if (this.shape == DialShape.PIE) { + joinType = Arc2D.PIE; + } + else if (this.shape == DialShape.CHORD) { + if (dial && this.meterAngle > 180) { + joinType = Arc2D.CHORD; + } + else { + joinType = Arc2D.PIE; + } + } + else if (this.shape == DialShape.CIRCLE) { + joinType = Arc2D.PIE; + if (dial) { + extent = 360; + } + } + else { + throw new IllegalStateException("DialShape not recognised."); + } + + g2.setPaint(paint); + Arc2D.Double arc = new Arc2D.Double(x, y, w, h, startAngle, extent, + joinType); + g2.fill(arc); + } + + /** + * Translates a data value to an angle on the dial. + * + * @param value the value. + * + * @return The angle on the dial. + */ + public double valueToAngle(double value) { + value = value - this.range.getLowerBound(); + double baseAngle = 180 + ((this.meterAngle - 180) / 2); + return baseAngle - ((value / this.range.getLength()) * this.meterAngle); + } + + /** + * Draws the ticks that subdivide the overall range. + * + * @param g2 the graphics device. + * @param meterArea the meter area. + * @param minValue the minimum value. + * @param maxValue the maximum value. + */ + protected void drawTicks(Graphics2D g2, Rectangle2D meterArea, + double minValue, double maxValue) { + for (double v = minValue; v <= maxValue; v += this.tickSize) { + drawTick(g2, meterArea, v); + } + } + + /** + * Draws a tick. + * + * @param g2 the graphics device. + * @param meterArea the meter area. + * @param value the value. + */ + protected void drawTick(Graphics2D g2, Rectangle2D meterArea, + double value) { + drawTick(g2, meterArea, value, false); + } + + /** + * Draws a tick on the dial. + * + * @param g2 the graphics device. + * @param meterArea the meter area. + * @param value the tick value. + * @param label a flag that controls whether or not a value label is drawn. + */ + protected void drawTick(Graphics2D g2, Rectangle2D meterArea, + double value, boolean label) { + + double valueAngle = valueToAngle(value); + + double meterMiddleX = meterArea.getCenterX(); + double meterMiddleY = meterArea.getCenterY(); + + g2.setPaint(this.tickPaint); + g2.setStroke(new BasicStroke(2.0f)); + + double valueP2X; + double valueP2Y; + + double radius = (meterArea.getWidth() / 2) + DEFAULT_BORDER_SIZE; + double radius1 = radius - 15; + + double valueP1X = meterMiddleX + + (radius * Math.cos(Math.PI * (valueAngle / 180))); + double valueP1Y = meterMiddleY + - (radius * Math.sin(Math.PI * (valueAngle / 180))); + + valueP2X = meterMiddleX + + (radius1 * Math.cos(Math.PI * (valueAngle / 180))); + valueP2Y = meterMiddleY + - (radius1 * Math.sin(Math.PI * (valueAngle / 180))); + + Line2D.Double line = new Line2D.Double(valueP1X, valueP1Y, valueP2X, + valueP2Y); + g2.draw(line); + + if (this.tickLabelsVisible && label) { + + String tickLabel = this.tickLabelFormat.format(value); + g2.setFont(this.tickLabelFont); + g2.setPaint(this.tickLabelPaint); + + FontMetrics fm = g2.getFontMetrics(); + Rectangle2D tickLabelBounds + = TextUtilities.getTextBounds(tickLabel, g2, fm); + + double x = valueP2X; + double y = valueP2Y; + if (valueAngle == 90 || valueAngle == 270) { + x = x - tickLabelBounds.getWidth() / 2; + } + else if (valueAngle < 90 || valueAngle > 270) { + x = x - tickLabelBounds.getWidth(); + } + if ((valueAngle > 135 && valueAngle < 225) + || valueAngle > 315 || valueAngle < 45) { + y = y - tickLabelBounds.getHeight() / 2; + } + else { + y = y + tickLabelBounds.getHeight() / 2; + } + g2.drawString(tickLabel, (float) x, (float) y); + } + } + + /** + * Draws the value label just below the center of the dial. + * + * @param g2 the graphics device. + * @param area the plot area. + */ + protected void drawValueLabel(Graphics2D g2, Rectangle2D area) { + g2.setFont(this.valueFont); + g2.setPaint(this.valuePaint); + String valueStr = "No value"; + if (this.dataset != null) { + Number n = this.dataset.getValue(); + if (n != null) { + valueStr = this.tickLabelFormat.format(n.doubleValue()) + " " + + this.units; + } + } + float x = (float) area.getCenterX(); + float y = (float) area.getCenterY() + DEFAULT_CIRCLE_SIZE; + TextUtilities.drawAlignedString(valueStr, g2, x, y, + TextAnchor.TOP_CENTER); + } + + /** + * Returns a short string describing the type of plot. + * + * @return A string describing the type of plot. + */ + @Override + public String getPlotType() { + return localizationResources.getString("Meter_Plot"); + } + + /** + * A zoom method that does nothing. Plots are required to support the + * zoom operation. In the case of a meter plot, it doesn't make sense to + * zoom in or out, so the method is empty. + * + * @param percent The zoom percentage. + */ + @Override + public void zoom(double percent) { + // intentionally blank + } + + /** + * Tests the plot for equality with an arbitrary object. Note that the + * dataset is ignored for the purposes of testing equality. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof MeterPlot)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + MeterPlot that = (MeterPlot) obj; + if (!ObjectUtilities.equal(this.units, that.units)) { + return false; + } + if (!ObjectUtilities.equal(this.range, that.range)) { + return false; + } + if (!ObjectUtilities.equal(this.intervals, that.intervals)) { + return false; + } + if (!PaintUtilities.equal(this.dialOutlinePaint, + that.dialOutlinePaint)) { + return false; + } + if (this.shape != that.shape) { + return false; + } + if (!PaintUtilities.equal(this.dialBackgroundPaint, + that.dialBackgroundPaint)) { + return false; + } + if (!PaintUtilities.equal(this.needlePaint, that.needlePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.valueFont, that.valueFont)) { + return false; + } + if (!PaintUtilities.equal(this.valuePaint, that.valuePaint)) { + return false; + } + if (!PaintUtilities.equal(this.tickPaint, that.tickPaint)) { + return false; + } + if (this.tickSize != that.tickSize) { + return false; + } + if (this.tickLabelsVisible != that.tickLabelsVisible) { + return false; + } + if (!ObjectUtilities.equal(this.tickLabelFont, that.tickLabelFont)) { + return false; + } + if (!PaintUtilities.equal(this.tickLabelPaint, that.tickLabelPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.tickLabelFormat, + that.tickLabelFormat)) { + return false; + } + if (this.drawBorder != that.drawBorder) { + return false; + } + if (this.meterAngle != that.meterAngle) { + return false; + } + return true; + } + + /** + * 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.dialBackgroundPaint, stream); + SerialUtilities.writePaint(this.dialOutlinePaint, stream); + SerialUtilities.writePaint(this.needlePaint, stream); + SerialUtilities.writePaint(this.valuePaint, stream); + SerialUtilities.writePaint(this.tickPaint, stream); + SerialUtilities.writePaint(this.tickLabelPaint, 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.dialBackgroundPaint = SerialUtilities.readPaint(stream); + this.dialOutlinePaint = SerialUtilities.readPaint(stream); + this.needlePaint = SerialUtilities.readPaint(stream); + this.valuePaint = SerialUtilities.readPaint(stream); + this.tickPaint = SerialUtilities.readPaint(stream); + this.tickLabelPaint = SerialUtilities.readPaint(stream); + if (this.dataset != null) { + this.dataset.addChangeListener(this); + } + } + + /** + * Returns an independent copy (clone) of the plot. The dataset is NOT + * cloned - both the original and the clone will have a reference to the + * same dataset. + * + * @return A clone. + * + * @throws CloneNotSupportedException if some component of the plot cannot + * be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + MeterPlot clone = (MeterPlot) super.clone(); + clone.tickLabelFormat = (NumberFormat) this.tickLabelFormat.clone(); + // the following relies on the fact that the intervals are immutable + clone.intervals = new java.util.ArrayList(this.intervals); + if (clone.dataset != null) { + clone.dataset.addChangeListener(clone); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/MultiplePiePlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/MultiplePiePlot.java new file mode 100755 index 0000000..4dfa7a0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/MultiplePiePlot.java @@ -0,0 +1,684 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * MultiplePiePlot.java + * -------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Brian Cabana (patch 1943021); + * + * Changes + * ------- + * 29-Jan-2004 : Version 1 (DG); + * 31-Mar-2004 : Added setPieIndex() call during drawing (DG); + * 20-Apr-2005 : Small change for update to LegendItem constructors (DG); + * 05-May-2005 : Updated draw() method parameters (DG); + * 16-Jun-2005 : Added get/setDataset() and equals() methods (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 06-Apr-2006 : Fixed bug 1190647 - legend and section colors not consistent + * when aggregation limit is specified (DG); + * 27-Sep-2006 : Updated draw() method for deprecated code (DG); + * 17-Jan-2007 : Updated prefetchSectionPaints() to check settings in + * underlying PiePlot (DG); + * 17-May-2007 : Added argument check to setPieChart() (DG); + * 18-May-2007 : Set dataset for LegendItem (DG); + * 18-Apr-2008 : In the constructor, register the plot as a dataset listener - + * see patch 1943021 from Brian Cabana (DG); + * 30-Dec-2008 : Added legendItemShape field, and fixed cloning bug (DG); + * 09-Jan-2009 : See ignoreNullValues to true for sub-chart (DG); + * 01-Jun-2009 : Set series key in getLegendItems() (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.geom.Ellipse2D; +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 java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.jfree.chart.ChartRenderingInfo; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.title.TextTitle; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.CategoryToPieDataset; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.general.PieDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.ShapeUtilities; +import org.jfree.util.TableOrder; + +/** + * A plot that displays multiple pie plots using data from a + * {@link CategoryDataset}. + */ +public class MultiplePiePlot extends Plot implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -355377800470807389L; + + /** The chart object that draws the individual pie charts. */ + private JFreeChart pieChart; + + /** The dataset. */ + private CategoryDataset dataset; + + /** The data extract order (by row or by column). */ + private TableOrder dataExtractOrder; + + /** The pie section limit percentage. */ + private double limit = 0.0; + + /** + * The key for the aggregated items. + * + * @since 1.0.2 + */ + private Comparable aggregatedItemsKey; + + /** + * The paint for the aggregated items. + * + * @since 1.0.2 + */ + private transient Paint aggregatedItemsPaint; + + /** + * The colors to use for each section. + * + * @since 1.0.2 + */ + private transient Map sectionPaints; + + /** + * The legend item shape (never null). + * + * @since 1.0.12 + */ + private transient Shape legendItemShape; + + /** + * Creates a new plot with no data. + */ + public MultiplePiePlot() { + this(null); + } + + /** + * Creates a new plot. + * + * @param dataset the dataset (null permitted). + */ + public MultiplePiePlot(CategoryDataset dataset) { + super(); + setDataset(dataset); + PiePlot piePlot = new PiePlot(null); + piePlot.setIgnoreNullValues(true); + this.pieChart = new JFreeChart(piePlot); + this.pieChart.removeLegend(); + this.dataExtractOrder = TableOrder.BY_COLUMN; + this.pieChart.setBackgroundPaint(null); + TextTitle seriesTitle = new TextTitle("Series Title", + new Font("SansSerif", Font.BOLD, 12)); + seriesTitle.setPosition(RectangleEdge.BOTTOM); + this.pieChart.setTitle(seriesTitle); + this.aggregatedItemsKey = "Other"; + this.aggregatedItemsPaint = Color.lightGray; + this.sectionPaints = new HashMap(); + this.legendItemShape = new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0); + } + + /** + * Returns the dataset used by the plot. + * + * @return The dataset (possibly null). + */ + public CategoryDataset getDataset() { + return this.dataset; + } + + /** + * Sets the dataset used by the plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param dataset the dataset (null permitted). + */ + public void setDataset(CategoryDataset dataset) { + // if there is an existing dataset, remove the plot from the list of + // change listeners... + if (this.dataset != null) { + this.dataset.removeChangeListener(this); + } + + // set the new dataset, and register the chart as a change listener... + this.dataset = dataset; + if (dataset != null) { + setDatasetGroup(dataset.getGroup()); + dataset.addChangeListener(this); + } + + // send a dataset change event to self to trigger plot change event + datasetChanged(new DatasetChangeEvent(this, dataset)); + } + + /** + * Returns the pie chart that is used to draw the individual pie plots. + * Note that there are some attributes on this chart instance that will + * be ignored at rendering time (for example, legend item settings). + * + * @return The pie chart (never null). + * + * @see #setPieChart(JFreeChart) + */ + public JFreeChart getPieChart() { + return this.pieChart; + } + + /** + * Sets the chart that is used to draw the individual pie plots. The + * chart's plot must be an instance of {@link PiePlot}. + * + * @param pieChart the pie chart (null not permitted). + * + * @see #getPieChart() + */ + public void setPieChart(JFreeChart pieChart) { + ParamChecks.nullNotPermitted(pieChart, "pieChart"); + if (!(pieChart.getPlot() instanceof PiePlot)) { + throw new IllegalArgumentException("The 'pieChart' argument must " + + "be a chart based on a PiePlot."); + } + this.pieChart = pieChart; + fireChangeEvent(); + } + + /** + * Returns the data extract order (by row or by column). + * + * @return The data extract order (never null). + */ + public TableOrder getDataExtractOrder() { + return this.dataExtractOrder; + } + + /** + * Sets the data extract order (by row or by column) and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param order the order (null not permitted). + */ + public void setDataExtractOrder(TableOrder order) { + ParamChecks.nullNotPermitted(order, "order"); + this.dataExtractOrder = order; + fireChangeEvent(); + } + + /** + * Returns the limit (as a percentage) below which small pie sections are + * aggregated. + * + * @return The limit percentage. + */ + public double getLimit() { + return this.limit; + } + + /** + * Sets the limit below which pie sections are aggregated. + * Set this to 0.0 if you don't want any aggregation to occur. + * + * @param limit the limit percent. + */ + public void setLimit(double limit) { + this.limit = limit; + fireChangeEvent(); + } + + /** + * Returns the key for aggregated items in the pie plots, if there are any. + * The default value is "Other". + * + * @return The aggregated items key. + * + * @since 1.0.2 + */ + public Comparable getAggregatedItemsKey() { + return this.aggregatedItemsKey; + } + + /** + * Sets the key for aggregated items in the pie plots. You must ensure + * that this doesn't clash with any keys in the dataset. + * + * @param key the key (null not permitted). + * + * @since 1.0.2 + */ + public void setAggregatedItemsKey(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + this.aggregatedItemsKey = key; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw the pie section representing the + * aggregated items. The default value is Color.lightGray. + * + * @return The paint. + * + * @since 1.0.2 + */ + public Paint getAggregatedItemsPaint() { + return this.aggregatedItemsPaint; + } + + /** + * Sets the paint used to draw the pie section representing the aggregated + * items and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @since 1.0.2 + */ + public void setAggregatedItemsPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.aggregatedItemsPaint = paint; + fireChangeEvent(); + } + + /** + * Returns a short string describing the type of plot. + * + * @return The plot type. + */ + @Override + public String getPlotType() { + return "Multiple Pie Plot"; + // TODO: need to fetch this from localised resources + } + + /** + * Returns the shape used for legend items. + * + * @return The shape (never null). + * + * @see #setLegendItemShape(Shape) + * + * @since 1.0.12 + */ + public Shape getLegendItemShape() { + return this.legendItemShape; + } + + /** + * Sets the shape used for legend items and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param shape the shape (null not permitted). + * + * @see #getLegendItemShape() + * + * @since 1.0.12 + */ + public void setLegendItemShape(Shape shape) { + ParamChecks.nullNotPermitted(shape, "shape"); + this.legendItemShape = shape; + fireChangeEvent(); + } + + /** + * Draws the plot on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device. + * @param area the area within which the plot should be drawn. + * @param anchor the anchor point (null permitted). + * @param parentState the state from the parent plot, if there is one. + * @param info collects info about the drawing. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, PlotRenderingInfo info) { + + // adjust the drawing area for the plot insets (if any)... + RectangleInsets insets = getInsets(); + insets.trim(area); + drawBackground(g2, area); + drawOutline(g2, area); + + // check that there is some data to display... + if (DatasetUtilities.isEmptyOrNull(this.dataset)) { + drawNoDataMessage(g2, area); + return; + } + + int pieCount; + if (this.dataExtractOrder == TableOrder.BY_ROW) { + pieCount = this.dataset.getRowCount(); + } + else { + pieCount = this.dataset.getColumnCount(); + } + + // the columns variable is always >= rows + int displayCols = (int) Math.ceil(Math.sqrt(pieCount)); + int displayRows + = (int) Math.ceil((double) pieCount / (double) displayCols); + + // swap rows and columns to match plotArea shape + if (displayCols > displayRows && area.getWidth() < area.getHeight()) { + int temp = displayCols; + displayCols = displayRows; + displayRows = temp; + } + + prefetchSectionPaints(); + + int x = (int) area.getX(); + int y = (int) area.getY(); + int width = ((int) area.getWidth()) / displayCols; + int height = ((int) area.getHeight()) / displayRows; + int row = 0; + int column = 0; + int diff = (displayRows * displayCols) - pieCount; + int xoffset = 0; + Rectangle rect = new Rectangle(); + + for (int pieIndex = 0; pieIndex < pieCount; pieIndex++) { + rect.setBounds(x + xoffset + (width * column), y + (height * row), + width, height); + + String title; + if (this.dataExtractOrder == TableOrder.BY_ROW) { + title = this.dataset.getRowKey(pieIndex).toString(); + } + else { + title = this.dataset.getColumnKey(pieIndex).toString(); + } + this.pieChart.setTitle(title); + + PieDataset piedataset; + PieDataset dd = new CategoryToPieDataset(this.dataset, + this.dataExtractOrder, pieIndex); + if (this.limit > 0.0) { + piedataset = DatasetUtilities.createConsolidatedPieDataset( + dd, this.aggregatedItemsKey, this.limit); + } + else { + piedataset = dd; + } + PiePlot piePlot = (PiePlot) this.pieChart.getPlot(); + piePlot.setDataset(piedataset); + piePlot.setPieIndex(pieIndex); + + // update the section colors to match the global colors... + for (int i = 0; i < piedataset.getItemCount(); i++) { + Comparable key = piedataset.getKey(i); + Paint p; + if (key.equals(this.aggregatedItemsKey)) { + p = this.aggregatedItemsPaint; + } + else { + p = (Paint) this.sectionPaints.get(key); + } + piePlot.setSectionPaint(key, p); + } + + ChartRenderingInfo subinfo = null; + if (info != null) { + subinfo = new ChartRenderingInfo(); + } + this.pieChart.draw(g2, rect, subinfo); + if (info != null) { + assert subinfo != null; + info.getOwner().getEntityCollection().addAll( + subinfo.getEntityCollection()); + info.addSubplotInfo(subinfo.getPlotInfo()); + } + + ++column; + if (column == displayCols) { + column = 0; + ++row; + + if (row == displayRows - 1 && diff != 0) { + xoffset = (diff * width) / 2; + } + } + } + + } + + /** + * For each key in the dataset, check the sectionPaints + * cache to see if a paint is associated with that key and, if not, + * fetch one from the drawing supplier. These colors are cached so that + * the legend and all the subplots use consistent colors. + */ + private void prefetchSectionPaints() { + + // pre-fetch the colors for each key...this is because the subplots + // may not display every key, but we need the coloring to be + // consistent... + + PiePlot piePlot = (PiePlot) getPieChart().getPlot(); + + if (this.dataExtractOrder == TableOrder.BY_ROW) { + // column keys provide potential keys for individual pies + for (int c = 0; c < this.dataset.getColumnCount(); c++) { + Comparable key = this.dataset.getColumnKey(c); + Paint p = piePlot.getSectionPaint(key); + if (p == null) { + p = (Paint) this.sectionPaints.get(key); + if (p == null) { + p = getDrawingSupplier().getNextPaint(); + } + } + this.sectionPaints.put(key, p); + } + } + else { + // row keys provide potential keys for individual pies + for (int r = 0; r < this.dataset.getRowCount(); r++) { + Comparable key = this.dataset.getRowKey(r); + Paint p = piePlot.getSectionPaint(key); + if (p == null) { + p = (Paint) this.sectionPaints.get(key); + if (p == null) { + p = getDrawingSupplier().getNextPaint(); + } + } + this.sectionPaints.put(key, p); + } + } + + } + + /** + * Returns a collection of legend items for the pie chart. + * + * @return The legend items. + */ + @Override + public LegendItemCollection getLegendItems() { + + LegendItemCollection result = new LegendItemCollection(); + if (this.dataset == null) { + return result; + } + + List keys = null; + prefetchSectionPaints(); + if (this.dataExtractOrder == TableOrder.BY_ROW) { + keys = this.dataset.getColumnKeys(); + } + else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { + keys = this.dataset.getRowKeys(); + } + if (keys == null) { + return result; + } + int section = 0; + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Comparable key = (Comparable) iterator.next(); + String label = key.toString(); // TODO: use a generator here + String description = label; + Paint paint = (Paint) this.sectionPaints.get(key); + LegendItem item = new LegendItem(label, description, null, + null, getLegendItemShape(), paint, + Plot.DEFAULT_OUTLINE_STROKE, paint); + item.setSeriesKey(key); + item.setSeriesIndex(section); + item.setDataset(getDataset()); + result.add(item); + section++; + } + if (this.limit > 0.0) { + LegendItem a = new LegendItem(this.aggregatedItemsKey.toString(), + this.aggregatedItemsKey.toString(), null, null, + getLegendItemShape(), this.aggregatedItemsPaint, + Plot.DEFAULT_OUTLINE_STROKE, this.aggregatedItemsPaint); + result.add(a); + } + return result; + } + + /** + * Tests this plot for equality with an arbitrary object. Note that the + * plot's dataset is not considered in the equality test. + * + * @param obj the object (null permitted). + * + * @return true if this plot is equal to obj, and + * false otherwise. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof MultiplePiePlot)) { + return false; + } + MultiplePiePlot that = (MultiplePiePlot) obj; + if (this.dataExtractOrder != that.dataExtractOrder) { + return false; + } + if (this.limit != that.limit) { + return false; + } + if (!this.aggregatedItemsKey.equals(that.aggregatedItemsKey)) { + return false; + } + if (!PaintUtilities.equal(this.aggregatedItemsPaint, + that.aggregatedItemsPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.pieChart, that.pieChart)) { + return false; + } + if (!ShapeUtilities.equal(this.legendItemShape, that.legendItemShape)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + return true; + } + + /** + * Returns a clone of the plot. + * + * @return A clone. + * + * @throws CloneNotSupportedException if some component of the plot does + * not support cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + MultiplePiePlot clone = (MultiplePiePlot) super.clone(); + clone.pieChart = (JFreeChart) this.pieChart.clone(); + clone.sectionPaints = new HashMap(this.sectionPaints); + clone.legendItemShape = ShapeUtilities.clone(this.legendItemShape); + 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.aggregatedItemsPaint, stream); + SerialUtilities.writeShape(this.legendItemShape, 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.aggregatedItemsPaint = SerialUtilities.readPaint(stream); + this.legendItemShape = SerialUtilities.readShape(stream); + this.sectionPaints = new HashMap(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Pannable.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Pannable.java new file mode 100755 index 0000000..1341a00 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Pannable.java @@ -0,0 +1,97 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * Pannable.java + * ------------- + * + * (C) Copyright 2009, by Object Refinery Limited and Contributors. + * + * Original Author: Ulrich Voigt - patch 2686040; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 19-Mar-2009 : Version 1, with modifications from patch by UV (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.geom.Point2D; + +import org.jfree.chart.ChartPanel; + +/** + * An interface that the {@link ChartPanel} class uses to communicate with + * plots that support panning. + * + * @since 1.0.13 + */ +public interface Pannable { + + /** + * Returns the orientation of the plot. + * + * @return The orientation (never null). + */ + public PlotOrientation getOrientation(); + + /** + * Evaluates if the domain axis can be panned. + * + * @return true if the domain axis is pannable. + */ + public boolean isDomainPannable(); + + /** + * Evaluates if the range axis can be panned. + * + * @return true if the range axis is pannable. + */ + public boolean isRangePannable(); + + /** + * Pans the domain axes by the specified percentage. + * + * @param percent the distance to pan (as a percentage of the axis length). + * @param info the plot info + * @param source the source point where the pan action started. + */ + public void panDomainAxes(double percent, PlotRenderingInfo info, + Point2D source); + + /** + * Pans the range axes by the specified percentage. + * + * @param percent the distance to pan (as a percentage of the axis length). + * @param info the plot info + * @param source the source point where the pan action started. + */ + public void panRangeAxes(double percent, PlotRenderingInfo info, + Point2D source); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PieLabelDistributor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PieLabelDistributor.java new file mode 100755 index 0000000..7f3681a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PieLabelDistributor.java @@ -0,0 +1,224 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * PieLabelDistributor.java + * ------------------------ + * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Mar-2004 : Version 1 (DG); + * 18-Apr-2005 : Use StringBuffer (DG); + * 14-Jun-2007 : Now extends AbstractPieLabelDistributor (DG); + * 31-Mar-2008 : Fix bugs in label distribution (DG); + * + */ + +package org.jfree.chart.plot; + +import java.util.Collections; + +/** + * This class distributes the section labels for one side of a pie chart so + * that they do not overlap. + */ +public class PieLabelDistributor extends AbstractPieLabelDistributor { + + /** The minimum gap. */ + private double minGap = 4.0; + + /** + * Creates a new distributor. + * + * @param labelCount the number of labels (ignored). + */ + public PieLabelDistributor(int labelCount) { + super(); + } + + /** + * Distributes the labels. + * + * @param minY the minimum y-coordinate in Java2D-space. + * @param height the available height (in Java2D units). + */ + @Override + public void distributeLabels(double minY, double height) { + sort(); // sorts the label records into ascending order by baseY +// if (isOverlap()) { +// adjustInwards(); +// } + // if still overlapping, do something else... + if (isOverlap()) { + adjustDownwards(minY, height); + } + + if (isOverlap()) { + adjustUpwards(minY, height); + } + + if (isOverlap()) { + spreadEvenly(minY, height); + } + } + + /** + * Returns true if there are overlapping labels in the list, + * and false otherwise. + * + * @return A boolean. + */ + private boolean isOverlap() { + double y = 0.0; + for (int i = 0; i < this.labels.size(); i++) { + PieLabelRecord plr = getPieLabelRecord(i); + if (y > plr.getLowerY()) { + return true; + } + y = plr.getUpperY(); + } + return false; + } + + /** + * Adjusts the y-coordinate for the labels in towards the center in an + * attempt to fix overlapping. + */ + protected void adjustInwards() { + int lower = 0; + int upper = this.labels.size() - 1; + while (upper > lower) { + if (lower < upper - 1) { + PieLabelRecord r0 = getPieLabelRecord(lower); + PieLabelRecord r1 = getPieLabelRecord(lower + 1); + if (r1.getLowerY() < r0.getUpperY()) { + double adjust = r0.getUpperY() - r1.getLowerY() + + this.minGap; + r1.setAllocatedY(r1.getAllocatedY() + adjust); + } + } + PieLabelRecord r2 = getPieLabelRecord(upper - 1); + PieLabelRecord r3 = getPieLabelRecord(upper); + if (r2.getUpperY() > r3.getLowerY()) { + double adjust = (r2.getUpperY() - r3.getLowerY()) + this.minGap; + r3.setAllocatedY(r3.getAllocatedY() + adjust); + } + lower++; + upper--; + } + } + + /** + * Any labels that are overlapping are moved down in an attempt to + * eliminate the overlaps. + * + * @param minY the minimum y value (in Java2D coordinate space). + * @param height the height available for all labels. + */ + protected void adjustDownwards(double minY, double height) { + for (int i = 0; i < this.labels.size() - 1; i++) { + PieLabelRecord record0 = getPieLabelRecord(i); + PieLabelRecord record1 = getPieLabelRecord(i + 1); + if (record1.getLowerY() < record0.getUpperY()) { + record1.setAllocatedY(Math.min(minY + height + - record1.getLabelHeight() / 2.0, + record0.getUpperY() + this.minGap + + record1.getLabelHeight() / 2.0)); + } + } + } + + /** + * Any labels that are overlapping are moved up in an attempt to eliminate + * the overlaps. + * + * @param minY the minimum y value (in Java2D coordinate space). + * @param height the height available for all labels. + */ + protected void adjustUpwards(double minY, double height) { + for (int i = this.labels.size() - 1; i > 0; i--) { + PieLabelRecord record0 = getPieLabelRecord(i); + PieLabelRecord record1 = getPieLabelRecord(i - 1); + if (record1.getUpperY() > record0.getLowerY()) { + record1.setAllocatedY(Math.max(minY + + record1.getLabelHeight() / 2.0, record0.getLowerY() + - this.minGap - record1.getLabelHeight() / 2.0)); + } + } + } + + /** + * Labels are spaced evenly in the available space in an attempt to + * eliminate the overlaps. + * + * @param minY the minimum y value (in Java2D coordinate space). + * @param height the height available for all labels. + */ + protected void spreadEvenly(double minY, double height) { + double y = minY; + double sumOfLabelHeights = 0.0; + for (int i = 0; i < this.labels.size(); i++) { + sumOfLabelHeights += getPieLabelRecord(i).getLabelHeight(); + } + double gap = height - sumOfLabelHeights; + if (this.labels.size() > 1) { + gap = gap / (this.labels.size() - 1); + } + for (int i = 0; i < this.labels.size(); i++) { + PieLabelRecord record = getPieLabelRecord(i); + y = y + record.getLabelHeight() / 2.0; + record.setAllocatedY(y); + y = y + record.getLabelHeight() / 2.0 + gap; + } + } + + /** + * Sorts the label records into ascending order by y-value. + */ + public void sort() { + Collections.sort(this.labels); + } + + /** + * Returns a string containing a description of the object for + * debugging purposes. + * + * @return A string. + */ + @Override + public String toString() { + StringBuilder result = new StringBuilder(); + for (int i = 0; i < this.labels.size(); i++) { + result.append(getPieLabelRecord(i).toString()).append("\n"); + } + return result.toString(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PieLabelLinkStyle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PieLabelLinkStyle.java new file mode 100755 index 0000000..f217190 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PieLabelLinkStyle.java @@ -0,0 +1,142 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * PieLabelLinkStyle.java + * ---------------------- + * (C) Copyright 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 31-Mar-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Used to indicate the style for the lines linking pie sections to their + * corresponding labels. + * + * @since 1.0.10 + */ +public final class PieLabelLinkStyle implements Serializable { + + /** STANDARD. */ + public static final PieLabelLinkStyle STANDARD + = new PieLabelLinkStyle("PieLabelLinkStyle.STANDARD"); + + /** QUAD_CURVE. */ + public static final PieLabelLinkStyle QUAD_CURVE + = new PieLabelLinkStyle("PieLabelLinkStyle.QUAD_CURVE"); + + /** CUBIC_CURVE. */ + public static final PieLabelLinkStyle CUBIC_CURVE + = new PieLabelLinkStyle("PieLabelLinkStyle.CUBIC_CURVE"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private PieLabelLinkStyle(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof PieLabelLinkStyle)) { + return false; + } + PieLabelLinkStyle style = (PieLabelLinkStyle) obj; + if (!this.name.equals(style.toString())) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return this.name.hashCode(); + } + + /** + * Ensures that serialization returns the unique instances. + * + * @return The object. + * + * @throws ObjectStreamException if there is a problem. + */ + private Object readResolve() throws ObjectStreamException { + Object result = null; + if (this.equals(PieLabelLinkStyle.STANDARD)) { + result = PieLabelLinkStyle.STANDARD; + } + else if (this.equals(PieLabelLinkStyle.QUAD_CURVE)) { + result = PieLabelLinkStyle.QUAD_CURVE; + } + else if (this.equals(PieLabelLinkStyle.CUBIC_CURVE)) { + result = PieLabelLinkStyle.CUBIC_CURVE; + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PieLabelRecord.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PieLabelRecord.java new file mode 100755 index 0000000..1c6d929 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PieLabelRecord.java @@ -0,0 +1,287 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * PieLabelRecord.java + * ------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Mar-2004 : Version 1 (DG); + * 14-Jun-2007 : Implemented Serializable, updated API docs (DG); + * 21-Nov-2007 : Implemented equals() to shut up FindBugs (DG); + * + */ + +package org.jfree.chart.plot; + +import java.io.Serializable; + +import org.jfree.text.TextBox; + +/** + * A structure that retains information about the label for a section in a pie + * chart. + */ +public class PieLabelRecord implements Comparable, Serializable { + + /** The section key. */ + private Comparable key; + + /** The angle of the centre of the section (in radians). */ + private double angle; + + /** The base y-coordinate. */ + private double baseY; + + /** The allocated y-coordinate. */ + private double allocatedY; + + /** The label. */ + private TextBox label; + + /** The label height. */ + private double labelHeight; + + /** The gap. */ + private double gap; + + /** The link percent. */ + private double linkPercent; + + /** + * Creates a new record. + * + * @param key the section key. + * @param angle the angle to the middle of the section (in radians). + * @param baseY the base y-coordinate. + * @param label the section label. + * @param labelHeight the label height (in Java2D units). + * @param gap the offset to the left. + * @param linkPercent the link percent. + */ + public PieLabelRecord(Comparable key, double angle, double baseY, + TextBox label, double labelHeight, double gap, + double linkPercent) { + this.key = key; + this.angle = angle; + this.baseY = baseY; + this.allocatedY = baseY; + this.label = label; + this.labelHeight = labelHeight; + this.gap = gap; + this.linkPercent = linkPercent; + } + + /** + * Returns the base y-coordinate. This is where the label will appear if + * there is no overlapping of labels. + * + * @return The base y-coordinate. + */ + public double getBaseY() { + return this.baseY; + } + + /** + * Sets the base y-coordinate. + * + * @param base the base y-coordinate. + */ + public void setBaseY(double base) { + this.baseY = base; + } + + /** + * Returns the lower bound of the label. + * + * @return The lower bound. + */ + public double getLowerY() { + return this.allocatedY - this.labelHeight / 2.0; + } + + /** + * Returns the upper bound of the label. + * + * @return The upper bound. + */ + public double getUpperY() { + return this.allocatedY + this.labelHeight / 2.0; + } + + /** + * Returns the angle of the middle of the section, in radians. + * + * @return The angle, in radians. + */ + public double getAngle() { + return this.angle; + } + + /** + * Returns the key for the section that the label applies to. + * + * @return The key. + */ + public Comparable getKey() { + return this.key; + } + + /** + * Returns the label. + * + * @return The label. + */ + public TextBox getLabel() { + return this.label; + } + + /** + * Returns the label height (you could derive this from the label itself, + * but we cache the value so it can be retrieved quickly). + * + * @return The label height (in Java2D units). + */ + public double getLabelHeight() { + return this.labelHeight; + } + + /** + * Returns the allocated y-coordinate. + * + * @return The allocated y-coordinate. + */ + public double getAllocatedY() { + return this.allocatedY; + } + + /** + * Sets the allocated y-coordinate. + * + * @param y the y-coordinate. + */ + public void setAllocatedY(double y) { + this.allocatedY = y; + } + + /** + * Returns the gap. + * + * @return The gap. + */ + public double getGap() { + return this.gap; + } + + /** + * Returns the link percent. + * + * @return The link percent. + */ + public double getLinkPercent() { + return this.linkPercent; + } + + /** + * Compares this object to an arbitrary object. + * + * @param obj the object to compare against. + * + * @return An integer that specifies the relative order of the two objects. + */ + @Override + public int compareTo(Object obj) { + int result = 0; + if (obj instanceof PieLabelRecord) { + PieLabelRecord plr = (PieLabelRecord) obj; + if (this.baseY < plr.baseY) { + result = -1; + } + else if (this.baseY > plr.baseY) { + result = 1; + } + } + return result; + } + + /** + * Tests this record for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PieLabelRecord)) { + return false; + } + PieLabelRecord that = (PieLabelRecord) obj; + if (!this.key.equals(that.key)) { + return false; + } + if (this.angle != that.angle) { + return false; + } + if (this.gap != that.gap) { + return false; + } + if (this.allocatedY != that.allocatedY) { + return false; + } + if (this.baseY != that.baseY) { + return false; + } + if (this.labelHeight != that.labelHeight) { + return false; + } + if (this.linkPercent != that.linkPercent) { + return false; + } + if (!this.label.equals(that.label)) { + return false; + } + return true; + } + + /** + * Returns a string describing the object. This is used for debugging only. + * + * @return A string. + */ + @Override + public String toString() { + return this.baseY + ", " + this.key.toString(); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PiePlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PiePlot.java new file mode 100755 index 0000000..74efda7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PiePlot.java @@ -0,0 +1,3762 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------ + * PiePlot.java + * ------------ + * (C) Copyright 2000-2013, by Andrzej Porebski and Contributors. + * + * Original Author: Andrzej Porebski; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Martin Cordova (percentages in labels); + * Richard Atkinson (URL support for image maps); + * Christian W. Zuckschwerdt; + * Arnaud Lelievre; + * Martin Hilpert (patch 1891849); + * Andreas Schroeder (very minor); + * Christoph Beck (bug 2121818); + * + * Changes + * ------- + * 21-Jun-2001 : Removed redundant JFreeChart parameter from constructors (DG); + * 18-Sep-2001 : Updated header (DG); + * 15-Oct-2001 : Data source classes moved to com.jrefinery.data.* (DG); + * 19-Oct-2001 : Moved series paint and stroke methods from JFreeChart.java to + * Plot.java (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * 13-Nov-2001 : Modified plot subclasses so that null axes are possible for + * pie plot (DG); + * 17-Nov-2001 : Added PieDataset interface and amended this class accordingly, + * and completed removal of BlankAxis class as it is no longer + * required (DG); + * 19-Nov-2001 : Changed 'drawCircle' property to 'circular' property (DG); + * 21-Nov-2001 : Added options for exploding pie sections and filled out range + * of properties (DG); + * Added option for percentages in chart labels, based on code + * by Martin Cordova (DG); + * 30-Nov-2001 : Changed default font from "Arial" --> "SansSerif" (DG); + * 12-Dec-2001 : Removed unnecessary 'throws' clause in constructor (DG); + * 13-Dec-2001 : Added tooltips (DG); + * 16-Jan-2002 : Renamed tooltips class (DG); + * 22-Jan-2002 : Fixed bug correlating legend labels with pie data (DG); + * 05-Feb-2002 : Added alpha-transparency to plot class, and updated + * constructors accordingly (DG); + * 06-Feb-2002 : Added optional background image and alpha-transparency to Plot + * and subclasses. Clipped drawing within plot area (DG); + * 26-Mar-2002 : Added an empty zoom method (DG); + * 18-Apr-2002 : PieDataset is no longer sorted (oldman); + * 23-Apr-2002 : Moved dataset from JFreeChart to Plot. Added + * getLegendItemLabels() method (DG); + * 19-Jun-2002 : Added attributes to control starting angle and direction + * (default is now clockwise) (DG); + * 25-Jun-2002 : Removed redundant imports (DG); + * 02-Jul-2002 : Fixed sign of percentage bug introduced in 0.9.2 (DG); + * 16-Jul-2002 : Added check for null dataset in getLegendItemLabels() (DG); + * 30-Jul-2002 : Moved summation code to DatasetUtilities (DG); + * 05-Aug-2002 : Added URL support for image maps - new member variable for + * urlGenerator, modified constructor and minor change to the + * draw method (RA); + * 18-Sep-2002 : Modified the percent label creation and added setters for the + * formatters (AS); + * 24-Sep-2002 : Added getLegendItems() method (DG); + * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 09-Oct-2002 : Added check for null entity collection (DG); + * 30-Oct-2002 : Changed PieDataset interface (DG); + * 18-Nov-2002 : Changed CategoryDataset to TableDataset (DG); + * 02-Jan-2003 : Fixed "no data" message (DG); + * 23-Jan-2003 : Modified to extract data from rows OR columns in + * CategoryDataset (DG); + * 14-Feb-2003 : Fixed label drawing so that foreground alpha does not apply + * (bug id 685536) (DG); + * 07-Mar-2003 : Modified to pass pieIndex on to PieSectionEntity and tooltip + * and URL generators (DG); + * 21-Mar-2003 : Added a minimum angle for drawing arcs + * (see bug id 620031) (DG); + * 24-Apr-2003 : Switched around PieDataset and KeyedValuesDataset (DG); + * 02-Jun-2003 : Fixed bug 721733 (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 19-Aug-2003 : Implemented Cloneable (DG); + * 29-Aug-2003 : Fixed bug 796936 (null pointer on setOutlinePaint()) (DG); + * 08-Sep-2003 : Added internationalization via use of properties + * resourceBundle (RFE 690236) (AL); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); + * 05-Nov-2003 : Fixed missing legend bug (DG); + * 10-Nov-2003 : Re-added the DatasetChangeListener to constructors (CZ); + * 29-Jan-2004 : Fixed clipping bug in draw() method (DG); + * 11-Mar-2004 : Major overhaul to improve labelling (DG); + * 31-Mar-2004 : Made an adjustment for the plot area when the label generator + * is null. Fixed null pointer exception when the label + * generator returns null for a label (DG); + * 06-Apr-2004 : Added getter, setter, serialization and draw support for + * labelBackgroundPaint (AS); + * 08-Apr-2004 : Added flag to control whether null values are ignored or + * not (DG); + * 15-Apr-2004 : Fixed some minor warnings from Eclipse (DG); + * 26-Apr-2004 : Added attributes for label outline and shadow (DG); + * 04-Oct-2004 : Renamed ShapeUtils --> ShapeUtilities (DG); + * 04-Nov-2004 : Fixed null pointer exception with new LegendTitle class (DG); + * 09-Nov-2004 : Added user definable legend item shape (DG); + * 25-Nov-2004 : Added new legend label generator (DG); + * 20-Apr-2005 : Added a tool tip generator for legend labels (DG); + * 26-Apr-2005 : Removed LOGGER (DG); + * 05-May-2005 : Updated draw() method parameters (DG); + * 10-May-2005 : Added flag to control visibility of label linking lines, plus + * another flag to control the handling of zero values (DG); + * 08-Jun-2005 : Fixed bug in getLegendItems() method (not respecting flags + * for ignoring null and zero values), and fixed equals() method + * to handle GradientPaint (DG); + * 15-Jul-2005 : Added sectionOutlinesVisible attribute (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 09-Jan-2006 : Fixed bug 1400442, inconsistent treatment of null and zero + * values in dataset (DG); + * 28-Feb-2006 : Fixed bug 1440415, bad distribution of pie section + * labels (DG); + * 27-Sep-2006 : Initialised baseSectionPaint correctly, added lookup methods + * for section paint, outline paint and outline stroke (DG); + * 27-Sep-2006 : Refactored paint and stroke methods to use keys rather than + * section indices (DG); + * 03-Oct-2006 : Replaced call to JRE 1.5 method (DG); + * 23-Nov-2006 : Added support for URLs for the legend items (DG); + * 24-Nov-2006 : Cloning fixes (DG); + * 17-Apr-2007 : Check for null label in legend items (DG); + * 19-Apr-2007 : Deprecated override settings (DG); + * 18-May-2007 : Set dataset for LegendItem (DG); + * 14-Jun-2007 : Added label distributor attribute (DG); + * 18-Jul-2007 : Added simple label option (DG); + * 21-Nov-2007 : Fixed labelling bugs, added debug code, restored default + * white background (DG); + * 19-Mar-2008 : Fixed IllegalArgumentException when drawing with null + * dataset (DG); + * 31-Mar-2008 : Adjust the label area for the interiorGap (DG); + * 31-Mar-2008 : Added quad and cubic curve label link lines - see patch + * 1891849 by Martin Hilpert (DG); + * 02-Jul-2008 : Added autoPopulate flags (DG); + * 15-Aug-2008 : Added methods to clear section attributes (DG); + * 15-Aug-2008 : Fixed bug 2051168 - problem with LegendItemEntity + * generation (DG); + * 23-Sep-2008 : Added getLabelLinkDepth() method - see bug 2121818 reported + * by Christoph Beck (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 10-Jul-2009 : Added optional drop shadow generator (DG); + * 03-Sep-2009 : Fixed bug where sinmpleLabelOffset is ignored (DG); + * 04-Nov-2009 : Add mouse wheel rotation support (DG); + * 18-Oct-2011 : Fixed tooltip offset with shadow generator (DG); + * 20-Nov-2011 : Initialise shadow generator as null (DG); + * 01-Jul-2012 : General label once only in drawSimpleLabels() (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * 12-Sep-2013 : Check for KEY_SUPPRESS_SHADOW_GENERATION rendering hint (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.AlphaComposite; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.RadialGradientPaint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Arc2D; +import java.awt.geom.CubicCurve2D; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.QuadCurve2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.TreeMap; +import org.jfree.chart.JFreeChart; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.PaintMap; +import org.jfree.chart.StrokeMap; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.entity.PieSectionEntity; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.labels.PieSectionLabelGenerator; +import org.jfree.chart.labels.PieToolTipGenerator; +import org.jfree.chart.labels.StandardPieSectionLabelGenerator; +import org.jfree.chart.urls.PieURLGenerator; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.chart.util.ShadowGenerator; +import org.jfree.data.DefaultKeyedValues; +import org.jfree.data.KeyedValues; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.general.PieDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.text.G2TextMeasurer; +import org.jfree.text.TextBlock; +import org.jfree.text.TextBox; +import org.jfree.text.TextUtilities; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.TextAnchor; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.Rotation; +import org.jfree.util.ShapeUtilities; +import org.jfree.util.UnitType; + +/** + * A plot that displays data in the form of a pie chart, using data from any + * class that implements the {@link PieDataset} interface. + * The example shown here is generated by the PieChartDemo2.java + * program included in the JFreeChart Demo Collection: + *

+ * PiePlotSample.png + *

+ * Special notes: + *

    + *
  1. the default starting point is 12 o'clock and the pie sections proceed + * in a clockwise direction, but these settings can be changed;
  2. + *
  3. negative values in the dataset are ignored;
  4. + *
  5. there are utility methods for creating a {@link PieDataset} from a + * {@link org.jfree.data.category.CategoryDataset};
  6. + *
+ * + * @see Plot + * @see PieDataset + */ +public class PiePlot extends Plot implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -795612466005590431L; + + /** The default interior gap. */ + public static final double DEFAULT_INTERIOR_GAP = 0.08; + + /** The maximum interior gap (currently 40%). */ + public static final double MAX_INTERIOR_GAP = 0.40; + + /** The default starting angle for the pie chart. */ + public static final double DEFAULT_START_ANGLE = 90.0; + + /** The default section label font. */ + public static final Font DEFAULT_LABEL_FONT = new Font("SansSerif", + Font.PLAIN, 10); + + /** The default section label paint. */ + public static final Paint DEFAULT_LABEL_PAINT = Color.black; + + /** The default section label background paint. */ + public static final Paint DEFAULT_LABEL_BACKGROUND_PAINT = new Color(255, + 255, 192); + + /** The default section label outline paint. */ + public static final Paint DEFAULT_LABEL_OUTLINE_PAINT = Color.black; + + /** The default section label outline stroke. */ + public static final Stroke DEFAULT_LABEL_OUTLINE_STROKE = new BasicStroke( + 0.5f); + + /** The default section label shadow paint. */ + public static final Paint DEFAULT_LABEL_SHADOW_PAINT = new Color(151, 151, + 151, 128); + + /** The default minimum arc angle to draw. */ + public static final double DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW = 0.00001; + + /** The dataset for the pie chart. */ + private PieDataset dataset; + + /** The pie index (used by the {@link MultiplePiePlot} class). */ + private int pieIndex; + + /** + * The amount of space left around the outside of the pie plot, expressed + * as a percentage of the plot area width and height. + */ + private double interiorGap; + + /** Flag determining whether to draw an ellipse or a perfect circle. */ + private boolean circular; + + /** The starting angle. */ + private double startAngle; + + /** The direction for the pie segments. */ + private Rotation direction; + + /** The section paint map. */ + private PaintMap sectionPaintMap; + + /** The base section paint (fallback). */ + private transient Paint baseSectionPaint; + + /** + * A flag that controls whether or not the section paint is auto-populated + * from the drawing supplier. + * + * @since 1.0.11 + */ + private boolean autoPopulateSectionPaint; + + /** + * A flag that controls whether or not an outline is drawn for each + * section in the plot. + */ + private boolean sectionOutlinesVisible; + + /** The section outline paint map. */ + private PaintMap sectionOutlinePaintMap; + + /** The base section outline paint (fallback). */ + private transient Paint baseSectionOutlinePaint; + + /** + * A flag that controls whether or not the section outline paint is + * auto-populated from the drawing supplier. + * + * @since 1.0.11 + */ + private boolean autoPopulateSectionOutlinePaint; + + /** The section outline stroke map. */ + private StrokeMap sectionOutlineStrokeMap; + + /** The base section outline stroke (fallback). */ + private transient Stroke baseSectionOutlineStroke; + + /** + * A flag that controls whether or not the section outline stroke is + * auto-populated from the drawing supplier. + * + * @since 1.0.11 + */ + private boolean autoPopulateSectionOutlineStroke; + + /** The shadow paint. */ + private transient Paint shadowPaint = Color.gray; + + /** The x-offset for the shadow effect. */ + private double shadowXOffset = 4.0f; + + /** The y-offset for the shadow effect. */ + private double shadowYOffset = 4.0f; + + /** The percentage amount to explode each pie section. */ + private Map explodePercentages; + + /** The section label generator. */ + private PieSectionLabelGenerator labelGenerator; + + /** The font used to display the section labels. */ + private Font labelFont; + + /** The color used to draw the section labels. */ + private transient Paint labelPaint; + + /** + * The color used to draw the background of the section labels. If this + * is null, the background is not filled. + */ + private transient Paint labelBackgroundPaint; + + /** + * The paint used to draw the outline of the section labels + * (null permitted). + */ + private transient Paint labelOutlinePaint; + + /** + * The stroke used to draw the outline of the section labels + * (null permitted). + */ + private transient Stroke labelOutlineStroke; + + /** + * The paint used to draw the shadow for the section labels + * (null permitted). + */ + private transient Paint labelShadowPaint; + + /** + * A flag that controls whether simple or extended labels are used. + * + * @since 1.0.7 + */ + private boolean simpleLabels = true; + + /** + * The padding between the labels and the label outlines. This is not + * allowed to be null. + * + * @since 1.0.7 + */ + private RectangleInsets labelPadding; + + /** + * The simple label offset. + * + * @since 1.0.7 + */ + private RectangleInsets simpleLabelOffset; + + /** The maximum label width as a percentage of the plot width. */ + private double maximumLabelWidth = 0.14; + + /** + * The gap between the labels and the link corner, as a percentage of the + * plot width. + */ + private double labelGap = 0.025; + + /** A flag that controls whether or not the label links are drawn. */ + private boolean labelLinksVisible; + + /** + * The label link style. + * + * @since 1.0.10 + */ + private PieLabelLinkStyle labelLinkStyle = PieLabelLinkStyle.STANDARD; + + /** The link margin. */ + private double labelLinkMargin = 0.025; + + /** The paint used for the label linking lines. */ + private transient Paint labelLinkPaint = Color.black; + + /** The stroke used for the label linking lines. */ + private transient Stroke labelLinkStroke = new BasicStroke(0.5f); + + /** + * The pie section label distributor. + * + * @since 1.0.6 + */ + private AbstractPieLabelDistributor labelDistributor; + + /** The tooltip generator. */ + private PieToolTipGenerator toolTipGenerator; + + /** The URL generator. */ + private PieURLGenerator urlGenerator; + + /** The legend label generator. */ + private PieSectionLabelGenerator legendLabelGenerator; + + /** A tool tip generator for the legend. */ + private PieSectionLabelGenerator legendLabelToolTipGenerator; + + /** + * A URL generator for the legend items (optional). + * + * @since 1.0.4. + */ + private PieURLGenerator legendLabelURLGenerator; + + /** + * A flag that controls whether null values are ignored. + */ + private boolean ignoreNullValues; + + /** + * A flag that controls whether zero values are ignored. + */ + private boolean ignoreZeroValues; + + /** The legend item shape. */ + private transient Shape legendItemShape; + + /** + * The smallest arc angle that will get drawn (this is to avoid a bug in + * various Java implementations that causes the JVM to crash). See this + * link for details: + * + * http://www.jfree.org/phpBB2/viewtopic.php?t=2707 + * + * ...and this bug report in the Java Bug Parade: + * + * http://developer.java.sun.com/developer/bugParade/bugs/4836495.html + */ + private double minimumArcAngleToDraw; + + /** + * The shadow generator for the plot (null permitted). + * + * @since 1.0.14 + */ + private ShadowGenerator shadowGenerator; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.plot.LocalizationBundle"); + + /** + * This debug flag controls whether or not an outline is drawn showing the + * interior of the plot region. This is drawn as a lightGray rectangle + * showing the padding provided by the 'interiorGap' setting. + */ + static final boolean DEBUG_DRAW_INTERIOR = false; + + /** + * This debug flag controls whether or not an outline is drawn showing the + * link area (in blue) and link ellipse (in yellow). This controls where + * the label links have 'elbow' points. + */ + static final boolean DEBUG_DRAW_LINK_AREA = false; + + /** + * This debug flag controls whether or not an outline is drawn showing + * the pie area (in green). + */ + static final boolean DEBUG_DRAW_PIE_AREA = false; + + /** + * Creates a new plot. The dataset is initially set to null. + */ + public PiePlot() { + this(null); + } + + /** + * Creates a plot that will draw a pie chart for the specified dataset. + * + * @param dataset the dataset (null permitted). + */ + public PiePlot(PieDataset dataset) { + super(); + this.dataset = dataset; + if (dataset != null) { + dataset.addChangeListener(this); + } + this.pieIndex = 0; + + this.interiorGap = DEFAULT_INTERIOR_GAP; + this.circular = true; + this.startAngle = DEFAULT_START_ANGLE; + this.direction = Rotation.CLOCKWISE; + this.minimumArcAngleToDraw = DEFAULT_MINIMUM_ARC_ANGLE_TO_DRAW; + + this.sectionPaint = null; + this.sectionPaintMap = new PaintMap(); + this.baseSectionPaint = Color.gray; + this.autoPopulateSectionPaint = true; + + this.sectionOutlinesVisible = true; + this.sectionOutlinePaint = null; + this.sectionOutlinePaintMap = new PaintMap(); + this.baseSectionOutlinePaint = DEFAULT_OUTLINE_PAINT; + this.autoPopulateSectionOutlinePaint = false; + + this.sectionOutlineStroke = null; + this.sectionOutlineStrokeMap = new StrokeMap(); + this.baseSectionOutlineStroke = DEFAULT_OUTLINE_STROKE; + this.autoPopulateSectionOutlineStroke = false; + + this.explodePercentages = new TreeMap(); + + this.labelGenerator = new StandardPieSectionLabelGenerator(); + this.labelFont = DEFAULT_LABEL_FONT; + this.labelPaint = DEFAULT_LABEL_PAINT; + this.labelBackgroundPaint = DEFAULT_LABEL_BACKGROUND_PAINT; + this.labelOutlinePaint = DEFAULT_LABEL_OUTLINE_PAINT; + this.labelOutlineStroke = DEFAULT_LABEL_OUTLINE_STROKE; + this.labelShadowPaint = DEFAULT_LABEL_SHADOW_PAINT; + this.labelLinksVisible = true; + this.labelDistributor = new PieLabelDistributor(0); + + this.simpleLabels = false; + this.simpleLabelOffset = new RectangleInsets(UnitType.RELATIVE, 0.18, + 0.18, 0.18, 0.18); + this.labelPadding = new RectangleInsets(2, 2, 2, 2); + + this.toolTipGenerator = null; + this.urlGenerator = null; + this.legendLabelGenerator = new StandardPieSectionLabelGenerator(); + this.legendLabelToolTipGenerator = null; + this.legendLabelURLGenerator = null; + this.legendItemShape = Plot.DEFAULT_LEGEND_ITEM_CIRCLE; + + this.ignoreNullValues = false; + this.ignoreZeroValues = false; + + this.shadowGenerator = null; + } + + /** + * Returns the dataset. + * + * @return The dataset (possibly null). + * + * @see #setDataset(PieDataset) + */ + public PieDataset getDataset() { + return this.dataset; + } + + /** + * Sets the dataset and sends a {@link DatasetChangeEvent} to 'this'. + * + * @param dataset the dataset (null permitted). + * + * @see #getDataset() + */ + public void setDataset(PieDataset dataset) { + // if there is an existing dataset, remove the plot from the list of + // change listeners... + PieDataset existing = this.dataset; + if (existing != null) { + existing.removeChangeListener(this); + } + + // set the new dataset, and register the chart as a change listener... + this.dataset = dataset; + if (dataset != null) { + setDatasetGroup(dataset.getGroup()); + dataset.addChangeListener(this); + } + + // send a dataset change event to self... + DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); + datasetChanged(event); + } + + /** + * Returns the pie index (this is used by the {@link MultiplePiePlot} class + * to track subplots). + * + * @return The pie index. + * + * @see #setPieIndex(int) + */ + public int getPieIndex() { + return this.pieIndex; + } + + /** + * Sets the pie index (this is used by the {@link MultiplePiePlot} class to + * track subplots). + * + * @param index the index. + * + * @see #getPieIndex() + */ + public void setPieIndex(int index) { + this.pieIndex = index; + } + + /** + * Returns the start angle for the first pie section. This is measured in + * degrees starting from 3 o'clock and measuring anti-clockwise. + * + * @return The start angle. + * + * @see #setStartAngle(double) + */ + public double getStartAngle() { + return this.startAngle; + } + + /** + * Sets the starting angle and sends a {@link PlotChangeEvent} to all + * registered listeners. The initial default value is 90 degrees, which + * corresponds to 12 o'clock. A value of zero corresponds to 3 o'clock... + * this is the encoding used by Java's Arc2D class. + * + * @param angle the angle (in degrees). + * + * @see #getStartAngle() + */ + public void setStartAngle(double angle) { + this.startAngle = angle; + fireChangeEvent(); + } + + /** + * Returns the direction in which the pie sections are drawn (clockwise or + * anti-clockwise). + * + * @return The direction (never null). + * + * @see #setDirection(Rotation) + */ + public Rotation getDirection() { + return this.direction; + } + + /** + * Sets the direction in which the pie sections are drawn and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param direction the direction (null not permitted). + * + * @see #getDirection() + */ + public void setDirection(Rotation direction) { + ParamChecks.nullNotPermitted(direction, "direction"); + this.direction = direction; + fireChangeEvent(); + + } + + /** + * Returns the interior gap, measured as a percentage of the available + * drawing space. + * + * @return The gap (as a percentage of the available drawing space). + * + * @see #setInteriorGap(double) + */ + public double getInteriorGap() { + return this.interiorGap; + } + + /** + * Sets the interior gap and sends a {@link PlotChangeEvent} to all + * registered listeners. This controls the space between the edges of the + * pie plot and the plot area itself (the region where the section labels + * appear). + * + * @param percent the gap (as a percentage of the available drawing space). + * + * @see #getInteriorGap() + */ + public void setInteriorGap(double percent) { + + if ((percent < 0.0) || (percent > MAX_INTERIOR_GAP)) { + throw new IllegalArgumentException( + "Invalid 'percent' (" + percent + ") argument."); + } + + if (this.interiorGap != percent) { + this.interiorGap = percent; + fireChangeEvent(); + } + + } + + /** + * Returns a flag indicating whether the pie chart is circular, or + * stretched into an elliptical shape. + * + * @return A flag indicating whether the pie chart is circular. + * + * @see #setCircular(boolean) + */ + public boolean isCircular() { + return this.circular; + } + + /** + * A flag indicating whether the pie chart is circular, or stretched into + * an elliptical shape. + * + * @param flag the new value. + * + * @see #isCircular() + */ + public void setCircular(boolean flag) { + setCircular(flag, true); + } + + /** + * Sets the circular attribute and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param circular the new value of the flag. + * @param notify notify listeners? + * + * @see #isCircular() + */ + public void setCircular(boolean circular, boolean notify) { + this.circular = circular; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the flag that controls whether null values in the + * dataset are ignored. + * + * @return A boolean. + * + * @see #setIgnoreNullValues(boolean) + */ + public boolean getIgnoreNullValues() { + return this.ignoreNullValues; + } + + /** + * Sets a flag that controls whether null values are ignored, + * and sends a {@link PlotChangeEvent} to all registered listeners. At + * present, this only affects whether or not the key is presented in the + * legend. + * + * @param flag the flag. + * + * @see #getIgnoreNullValues() + * @see #setIgnoreZeroValues(boolean) + */ + public void setIgnoreNullValues(boolean flag) { + this.ignoreNullValues = flag; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether zero values in the + * dataset are ignored. + * + * @return A boolean. + * + * @see #setIgnoreZeroValues(boolean) + */ + public boolean getIgnoreZeroValues() { + return this.ignoreZeroValues; + } + + /** + * Sets a flag that controls whether zero values are ignored, + * and sends a {@link PlotChangeEvent} to all registered listeners. This + * only affects whether or not a label appears for the non-visible + * pie section. + * + * @param flag the flag. + * + * @see #getIgnoreZeroValues() + * @see #setIgnoreNullValues(boolean) + */ + public void setIgnoreZeroValues(boolean flag) { + this.ignoreZeroValues = flag; + fireChangeEvent(); + } + + //// SECTION PAINT //////////////////////////////////////////////////////// + + /** + * Returns the paint for the specified section. This is equivalent to + * lookupSectionPaint(section, getAutoPopulateSectionPaint()). + * + * @param key the section key. + * + * @return The paint for the specified section. + * + * @since 1.0.3 + * + * @see #lookupSectionPaint(Comparable, boolean) + */ + protected Paint lookupSectionPaint(Comparable key) { + return lookupSectionPaint(key, getAutoPopulateSectionPaint()); + } + + /** + * Returns the paint for the specified section. The lookup involves these + * steps: + *
    + *
  • if {@link #getSectionPaint()} is non-null, return + * it;
  • + *
  • if {@link #getSectionPaint(int)} is non-null return + * it;
  • + *
  • if {@link #getSectionPaint(int)} is null but + * autoPopulate is true, attempt to fetch + * a new paint from the drawing supplier + * ({@link #getDrawingSupplier()}); + *
  • if all else fails, return {@link #getBaseSectionPaint()}. + *
+ * + * @param key the section key. + * @param autoPopulate a flag that controls whether the drawing supplier + * is used to auto-populate the section paint settings. + * + * @return The paint. + * + * @since 1.0.3 + */ + protected Paint lookupSectionPaint(Comparable key, boolean autoPopulate) { + + // is there an override? + Paint result = getSectionPaint(); + if (result != null) { + return result; + } + + // if not, check if there is a paint defined for the specified key + result = this.sectionPaintMap.getPaint(key); + if (result != null) { + return result; + } + + // nothing defined - do we autoPopulate? + if (autoPopulate) { + DrawingSupplier ds = getDrawingSupplier(); + if (ds != null) { + result = ds.getNextPaint(); + this.sectionPaintMap.put(key, result); + } + else { + result = this.baseSectionPaint; + } + } + else { + result = this.baseSectionPaint; + } + return result; + } + + /** + * Returns the paint for ALL sections in the plot. + * + * @return The paint (possibly null). + * + * @see #setSectionPaint(Paint) + * + * @deprecated Use {@link #getSectionPaint(Comparable)} and + * {@link #getBaseSectionPaint()}. Deprecated as of version 1.0.6. + */ + public Paint getSectionPaint() { + return this.sectionPaint; + } + + /** + * Sets the paint for ALL sections in the plot. If this is set to + * null, then a list of paints is used instead (to allow + * different colors to be used for each section). + * + * @param paint the paint (null permitted). + * + * @see #getSectionPaint() + * + * @deprecated Use {@link #setSectionPaint(Comparable, Paint)} and + * {@link #setBaseSectionPaint(Paint)}. Deprecated as of version 1.0.6. + */ + public void setSectionPaint(Paint paint) { + this.sectionPaint = paint; + fireChangeEvent(); + } + + /** + * Returns a key for the specified section. If there is no such section + * in the dataset, we generate a key. This is to provide some backward + * compatibility for the (now deprecated) methods that get/set attributes + * based on section indices. The preferred way of doing this now is to + * link the attributes directly to the section key (there are new methods + * for this, starting from version 1.0.3). + * + * @param section the section index. + * + * @return The key. + * + * @since 1.0.3 + */ + protected Comparable getSectionKey(int section) { + Comparable key = null; + if (this.dataset != null) { + if (section >= 0 && section < this.dataset.getItemCount()) { + key = this.dataset.getKey(section); + } + } + if (key == null) { + key = new Integer(section); + } + return key; + } + + /** + * Returns the paint associated with the specified key, or + * null if there is no paint associated with the key. + * + * @param key the key (null not permitted). + * + * @return The paint associated with the specified key, or + * null. + * + * @throws IllegalArgumentException if key is + * null. + * + * @see #setSectionPaint(Comparable, Paint) + * + * @since 1.0.3 + */ + public Paint getSectionPaint(Comparable key) { + // null argument check delegated... + return this.sectionPaintMap.getPaint(key); + } + + /** + * Sets the paint associated with the specified key, and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param key the key (null not permitted). + * @param paint the paint. + * + * @throws IllegalArgumentException if key is + * null. + * + * @see #getSectionPaint(Comparable) + * + * @since 1.0.3 + */ + public void setSectionPaint(Comparable key, Paint paint) { + // null argument check delegated... + this.sectionPaintMap.put(key, paint); + fireChangeEvent(); + } + + /** + * Clears the section paint settings for this plot and, if requested, sends + * a {@link PlotChangeEvent} to all registered listeners. Be aware that + * if the autoPopulateSectionPaint flag is set, the section + * paints may be repopulated using the same colours as before. + * + * @param notify notify listeners? + * + * @since 1.0.11 + * + * @see #autoPopulateSectionPaint + */ + public void clearSectionPaints(boolean notify) { + this.sectionPaintMap.clear(); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base section paint. This is used when no other paint is + * defined, which is rare. The default value is Color.gray. + * + * @return The paint (never null). + * + * @see #setBaseSectionPaint(Paint) + */ + public Paint getBaseSectionPaint() { + return this.baseSectionPaint; + } + + /** + * Sets the base section paint and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getBaseSectionPaint() + */ + public void setBaseSectionPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.baseSectionPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not the section paint is + * auto-populated by the {@link #lookupSectionPaint(Comparable)} method. + * + * @return A boolean. + * + * @since 1.0.11 + */ + public boolean getAutoPopulateSectionPaint() { + return this.autoPopulateSectionPaint; + } + + /** + * Sets the flag that controls whether or not the section paint is + * auto-populated by the {@link #lookupSectionPaint(Comparable)} method, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param auto auto-populate? + * + * @since 1.0.11 + */ + public void setAutoPopulateSectionPaint(boolean auto) { + this.autoPopulateSectionPaint = auto; + fireChangeEvent(); + } + + //// SECTION OUTLINE PAINT //////////////////////////////////////////////// + + /** + * Returns the flag that controls whether or not the outline is drawn for + * each pie section. + * + * @return The flag that controls whether or not the outline is drawn for + * each pie section. + * + * @see #setSectionOutlinesVisible(boolean) + */ + public boolean getSectionOutlinesVisible() { + return this.sectionOutlinesVisible; + } + + /** + * Sets the flag that controls whether or not the outline is drawn for + * each pie section, and sends a {@link PlotChangeEvent} to all registered + * listeners. + * + * @param visible the flag. + * + * @see #getSectionOutlinesVisible() + */ + public void setSectionOutlinesVisible(boolean visible) { + this.sectionOutlinesVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the outline paint for the specified section. This is equivalent + * to lookupSectionPaint(section, + * getAutoPopulateSectionOutlinePaint()). + * + * @param key the section key. + * + * @return The paint for the specified section. + * + * @since 1.0.3 + * + * @see #lookupSectionOutlinePaint(Comparable, boolean) + */ + protected Paint lookupSectionOutlinePaint(Comparable key) { + return lookupSectionOutlinePaint(key, + getAutoPopulateSectionOutlinePaint()); + } + + /** + * Returns the outline paint for the specified section. The lookup + * involves these steps: + *
    + *
  • if {@link #getSectionOutlinePaint()} is non-null, + * return it;
  • + *
  • otherwise, if {@link #getSectionOutlinePaint(int)} is + * non-null return it;
  • + *
  • if {@link #getSectionOutlinePaint(int)} is null but + * autoPopulate is true, attempt to fetch + * a new outline paint from the drawing supplier + * ({@link #getDrawingSupplier()}); + *
  • if all else fails, return {@link #getBaseSectionOutlinePaint()}. + *
+ * + * @param key the section key. + * @param autoPopulate a flag that controls whether the drawing supplier + * is used to auto-populate the section outline paint settings. + * + * @return The paint. + * + * @since 1.0.3 + */ + protected Paint lookupSectionOutlinePaint(Comparable key, + boolean autoPopulate) { + + // is there an override? + Paint result = getSectionOutlinePaint(); + if (result != null) { + return result; + } + + // if not, check if there is a paint defined for the specified key + result = this.sectionOutlinePaintMap.getPaint(key); + if (result != null) { + return result; + } + + // nothing defined - do we autoPopulate? + if (autoPopulate) { + DrawingSupplier ds = getDrawingSupplier(); + if (ds != null) { + result = ds.getNextOutlinePaint(); + this.sectionOutlinePaintMap.put(key, result); + } + else { + result = this.baseSectionOutlinePaint; + } + } + else { + result = this.baseSectionOutlinePaint; + } + return result; + } + + /** + * Returns the outline paint associated with the specified key, or + * null if there is no paint associated with the key. + * + * @param key the key (null not permitted). + * + * @return The paint associated with the specified key, or + * null. + * + * @throws IllegalArgumentException if key is + * null. + * + * @see #setSectionOutlinePaint(Comparable, Paint) + * + * @since 1.0.3 + */ + public Paint getSectionOutlinePaint(Comparable key) { + // null argument check delegated... + return this.sectionOutlinePaintMap.getPaint(key); + } + + /** + * Sets the outline paint associated with the specified key, and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param key the key (null not permitted). + * @param paint the paint. + * + * @throws IllegalArgumentException if key is + * null. + * + * @see #getSectionOutlinePaint(Comparable) + * + * @since 1.0.3 + */ + public void setSectionOutlinePaint(Comparable key, Paint paint) { + // null argument check delegated... + this.sectionOutlinePaintMap.put(key, paint); + fireChangeEvent(); + } + + /** + * Clears the section outline paint settings for this plot and, if + * requested, sends a {@link PlotChangeEvent} to all registered listeners. + * Be aware that if the autoPopulateSectionPaint flag is set, + * the section paints may be repopulated using the same colours as before. + * + * @param notify notify listeners? + * + * @since 1.0.11 + * + * @see #autoPopulateSectionOutlinePaint + */ + public void clearSectionOutlinePaints(boolean notify) { + this.sectionOutlinePaintMap.clear(); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base section paint. This is used when no other paint is + * available. + * + * @return The paint (never null). + * + * @see #setBaseSectionOutlinePaint(Paint) + */ + public Paint getBaseSectionOutlinePaint() { + return this.baseSectionOutlinePaint; + } + + /** + * Sets the base section paint. + * + * @param paint the paint (null not permitted). + * + * @see #getBaseSectionOutlinePaint() + */ + public void setBaseSectionOutlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.baseSectionOutlinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not the section outline paint + * is auto-populated by the {@link #lookupSectionOutlinePaint(Comparable)} + * method. + * + * @return A boolean. + * + * @since 1.0.11 + */ + public boolean getAutoPopulateSectionOutlinePaint() { + return this.autoPopulateSectionOutlinePaint; + } + + /** + * Sets the flag that controls whether or not the section outline paint is + * auto-populated by the {@link #lookupSectionOutlinePaint(Comparable)} + * method, and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param auto auto-populate? + * + * @since 1.0.11 + */ + public void setAutoPopulateSectionOutlinePaint(boolean auto) { + this.autoPopulateSectionOutlinePaint = auto; + fireChangeEvent(); + } + + //// SECTION OUTLINE STROKE /////////////////////////////////////////////// + + /** + * Returns the outline stroke for the specified section. This is + * equivalent to lookupSectionOutlineStroke(section, + * getAutoPopulateSectionOutlineStroke()). + * + * @param key the section key. + * + * @return The stroke for the specified section. + * + * @since 1.0.3 + * + * @see #lookupSectionOutlineStroke(Comparable, boolean) + */ + protected Stroke lookupSectionOutlineStroke(Comparable key) { + return lookupSectionOutlineStroke(key, + getAutoPopulateSectionOutlineStroke()); + } + + /** + * Returns the outline stroke for the specified section. The lookup + * involves these steps: + *
    + *
  • if {@link #getSectionOutlineStroke()} is non-null, + * return it;
  • + *
  • otherwise, if {@link #getSectionOutlineStroke(int)} is + * non-null return it;
  • + *
  • if {@link #getSectionOutlineStroke(int)} is null but + * autoPopulate is true, attempt to fetch + * a new outline stroke from the drawing supplier + * ({@link #getDrawingSupplier()}); + *
  • if all else fails, return {@link #getBaseSectionOutlineStroke()}. + *
+ * + * @param key the section key. + * @param autoPopulate a flag that controls whether the drawing supplier + * is used to auto-populate the section outline stroke settings. + * + * @return The stroke. + * + * @since 1.0.3 + */ + protected Stroke lookupSectionOutlineStroke(Comparable key, + boolean autoPopulate) { + + // is there an override? + Stroke result = getSectionOutlineStroke(); + if (result != null) { + return result; + } + + // if not, check if there is a stroke defined for the specified key + result = this.sectionOutlineStrokeMap.getStroke(key); + if (result != null) { + return result; + } + + // nothing defined - do we autoPopulate? + if (autoPopulate) { + DrawingSupplier ds = getDrawingSupplier(); + if (ds != null) { + result = ds.getNextOutlineStroke(); + this.sectionOutlineStrokeMap.put(key, result); + } + else { + result = this.baseSectionOutlineStroke; + } + } + else { + result = this.baseSectionOutlineStroke; + } + return result; + } + + /** + * Returns the outline stroke associated with the specified key, or + * null if there is no stroke associated with the key. + * + * @param key the key (null not permitted). + * + * @return The stroke associated with the specified key, or + * null. + * + * @throws IllegalArgumentException if key is + * null. + * + * @see #setSectionOutlineStroke(Comparable, Stroke) + * + * @since 1.0.3 + */ + public Stroke getSectionOutlineStroke(Comparable key) { + // null argument check delegated... + return this.sectionOutlineStrokeMap.getStroke(key); + } + + /** + * Sets the outline stroke associated with the specified key, and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param key the key (null not permitted). + * @param stroke the stroke. + * + * @throws IllegalArgumentException if key is + * null. + * + * @see #getSectionOutlineStroke(Comparable) + * + * @since 1.0.3 + */ + public void setSectionOutlineStroke(Comparable key, Stroke stroke) { + // null argument check delegated... + this.sectionOutlineStrokeMap.put(key, stroke); + fireChangeEvent(); + } + + /** + * Clears the section outline stroke settings for this plot and, if + * requested, sends a {@link PlotChangeEvent} to all registered listeners. + * Be aware that if the autoPopulateSectionPaint flag is set, + * the section paints may be repopulated using the same colours as before. + * + * @param notify notify listeners? + * + * @since 1.0.11 + * + * @see #autoPopulateSectionOutlineStroke + */ + public void clearSectionOutlineStrokes(boolean notify) { + this.sectionOutlineStrokeMap.clear(); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base section stroke. This is used when no other stroke is + * available. + * + * @return The stroke (never null). + * + * @see #setBaseSectionOutlineStroke(Stroke) + */ + public Stroke getBaseSectionOutlineStroke() { + return this.baseSectionOutlineStroke; + } + + /** + * Sets the base section stroke. + * + * @param stroke the stroke (null not permitted). + * + * @see #getBaseSectionOutlineStroke() + */ + public void setBaseSectionOutlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.baseSectionOutlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not the section outline stroke + * is auto-populated by the {@link #lookupSectionOutlinePaint(Comparable)} + * method. + * + * @return A boolean. + * + * @since 1.0.11 + */ + public boolean getAutoPopulateSectionOutlineStroke() { + return this.autoPopulateSectionOutlineStroke; + } + + /** + * Sets the flag that controls whether or not the section outline stroke is + * auto-populated by the {@link #lookupSectionOutlineStroke(Comparable)} + * method, and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param auto auto-populate? + * + * @since 1.0.11 + */ + public void setAutoPopulateSectionOutlineStroke(boolean auto) { + this.autoPopulateSectionOutlineStroke = auto; + fireChangeEvent(); + } + + /** + * Returns the shadow paint. + * + * @return The paint (possibly null). + * + * @see #setShadowPaint(Paint) + */ + public Paint getShadowPaint() { + return this.shadowPaint; + } + + /** + * Sets the shadow paint and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null permitted). + * + * @see #getShadowPaint() + */ + public void setShadowPaint(Paint paint) { + this.shadowPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the x-offset for the shadow effect. + * + * @return The offset (in Java2D units). + * + * @see #setShadowXOffset(double) + */ + public double getShadowXOffset() { + return this.shadowXOffset; + } + + /** + * Sets the x-offset for the shadow effect and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param offset the offset (in Java2D units). + * + * @see #getShadowXOffset() + */ + public void setShadowXOffset(double offset) { + this.shadowXOffset = offset; + fireChangeEvent(); + } + + /** + * Returns the y-offset for the shadow effect. + * + * @return The offset (in Java2D units). + * + * @see #setShadowYOffset(double) + */ + public double getShadowYOffset() { + return this.shadowYOffset; + } + + /** + * Sets the y-offset for the shadow effect and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param offset the offset (in Java2D units). + * + * @see #getShadowYOffset() + */ + public void setShadowYOffset(double offset) { + this.shadowYOffset = offset; + fireChangeEvent(); + } + + /** + * Returns the amount that the section with the specified key should be + * exploded. + * + * @param key the key (null not permitted). + * + * @return The amount that the section with the specified key should be + * exploded. + * + * @throws IllegalArgumentException if key is + * null. + * + * @since 1.0.3 + * + * @see #setExplodePercent(Comparable, double) + */ + public double getExplodePercent(Comparable key) { + double result = 0.0; + if (this.explodePercentages != null) { + Number percent = (Number) this.explodePercentages.get(key); + if (percent != null) { + result = percent.doubleValue(); + } + } + return result; + } + + /** + * Sets the amount that a pie section should be exploded and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param key the section key (null not permitted). + * @param percent the explode percentage (0.30 = 30 percent). + * + * @since 1.0.3 + * + * @see #getExplodePercent(Comparable) + */ + public void setExplodePercent(Comparable key, double percent) { + ParamChecks.nullNotPermitted(key, "key"); + if (this.explodePercentages == null) { + this.explodePercentages = new TreeMap(); + } + this.explodePercentages.put(key, new Double(percent)); + fireChangeEvent(); + } + + /** + * Returns the maximum explode percent. + * + * @return The percent. + */ + public double getMaximumExplodePercent() { + if (this.dataset == null) { + return 0.0; + } + double result = 0.0; + Iterator iterator = this.dataset.getKeys().iterator(); + while (iterator.hasNext()) { + Comparable key = (Comparable) iterator.next(); + Number explode = (Number) this.explodePercentages.get(key); + if (explode != null) { + result = Math.max(result, explode.doubleValue()); + } + } + return result; + } + + /** + * Returns the section label generator. + * + * @return The generator (possibly null). + * + * @see #setLabelGenerator(PieSectionLabelGenerator) + */ + public PieSectionLabelGenerator getLabelGenerator() { + return this.labelGenerator; + } + + /** + * Sets the section label generator and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getLabelGenerator() + */ + public void setLabelGenerator(PieSectionLabelGenerator generator) { + this.labelGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the gap between the edge of the pie and the labels, expressed as + * a percentage of the plot width. + * + * @return The gap (a percentage, where 0.05 = five percent). + * + * @see #setLabelGap(double) + */ + public double getLabelGap() { + return this.labelGap; + } + + /** + * Sets the gap between the edge of the pie and the labels (expressed as a + * percentage of the plot width) and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param gap the gap (a percentage, where 0.05 = five percent). + * + * @see #getLabelGap() + */ + public void setLabelGap(double gap) { + this.labelGap = gap; + fireChangeEvent(); + } + + /** + * Returns the maximum label width as a percentage of the plot width. + * + * @return The width (a percentage, where 0.20 = 20 percent). + * + * @see #setMaximumLabelWidth(double) + */ + public double getMaximumLabelWidth() { + return this.maximumLabelWidth; + } + + /** + * Sets the maximum label width as a percentage of the plot width and sends + * a {@link PlotChangeEvent} to all registered listeners. + * + * @param width the width (a percentage, where 0.20 = 20 percent). + * + * @see #getMaximumLabelWidth() + */ + public void setMaximumLabelWidth(double width) { + this.maximumLabelWidth = width; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not label linking lines are + * visible. + * + * @return A boolean. + * + * @see #setLabelLinksVisible(boolean) + */ + public boolean getLabelLinksVisible() { + return this.labelLinksVisible; + } + + /** + * Sets the flag that controls whether or not label linking lines are + * visible and sends a {@link PlotChangeEvent} to all registered listeners. + * Please take care when hiding the linking lines - depending on the data + * values, the labels can be displayed some distance away from the + * corresponding pie section. + * + * @param visible the flag. + * + * @see #getLabelLinksVisible() + */ + public void setLabelLinksVisible(boolean visible) { + this.labelLinksVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the label link style. + * + * @return The label link style (never null). + * + * @see #setLabelLinkStyle(PieLabelLinkStyle) + * + * @since 1.0.10 + */ + public PieLabelLinkStyle getLabelLinkStyle() { + return this.labelLinkStyle; + } + + /** + * Sets the label link style and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param style the new style (null not permitted). + * + * @see #getLabelLinkStyle() + * + * @since 1.0.10 + */ + public void setLabelLinkStyle(PieLabelLinkStyle style) { + ParamChecks.nullNotPermitted(style, "style"); + this.labelLinkStyle = style; + fireChangeEvent(); + } + + /** + * Returns the margin (expressed as a percentage of the width or height) + * between the edge of the pie and the link point. + * + * @return The link margin (as a percentage, where 0.05 is five percent). + * + * @see #setLabelLinkMargin(double) + */ + public double getLabelLinkMargin() { + return this.labelLinkMargin; + } + + /** + * Sets the link margin and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param margin the margin. + * + * @see #getLabelLinkMargin() + */ + public void setLabelLinkMargin(double margin) { + this.labelLinkMargin = margin; + fireChangeEvent(); + } + + /** + * Returns the paint used for the lines that connect pie sections to their + * corresponding labels. + * + * @return The paint (never null). + * + * @see #setLabelLinkPaint(Paint) + */ + public Paint getLabelLinkPaint() { + return this.labelLinkPaint; + } + + /** + * Sets the paint used for the lines that connect pie sections to their + * corresponding labels, and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getLabelLinkPaint() + */ + public void setLabelLinkPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.labelLinkPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the stroke used for the label linking lines. + * + * @return The stroke. + * + * @see #setLabelLinkStroke(Stroke) + */ + public Stroke getLabelLinkStroke() { + return this.labelLinkStroke; + } + + /** + * Sets the link stroke and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param stroke the stroke. + * + * @see #getLabelLinkStroke() + */ + public void setLabelLinkStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.labelLinkStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the distance that the end of the label link is embedded into + * the plot, expressed as a percentage of the plot's radius. + *

+ * This method is overridden in the {@link RingPlot} class to resolve + * bug 2121818. + * + * @return 0.10. + * + * @since 1.0.12 + */ + protected double getLabelLinkDepth() { + return 0.1; + } + + /** + * Returns the section label font. + * + * @return The font (never null). + * + * @see #setLabelFont(Font) + */ + public Font getLabelFont() { + return this.labelFont; + } + + /** + * Sets the section label font and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getLabelFont() + */ + public void setLabelFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.labelFont = font; + fireChangeEvent(); + } + + /** + * Returns the section label paint. + * + * @return The paint (never null). + * + * @see #setLabelPaint(Paint) + */ + public Paint getLabelPaint() { + return this.labelPaint; + } + + /** + * Sets the section label paint and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getLabelPaint() + */ + public void setLabelPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.labelPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the section label background paint. + * + * @return The paint (possibly null). + * + * @see #setLabelBackgroundPaint(Paint) + */ + public Paint getLabelBackgroundPaint() { + return this.labelBackgroundPaint; + } + + /** + * Sets the section label background paint and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @see #getLabelBackgroundPaint() + */ + public void setLabelBackgroundPaint(Paint paint) { + this.labelBackgroundPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the section label outline paint. + * + * @return The paint (possibly null). + * + * @see #setLabelOutlinePaint(Paint) + */ + public Paint getLabelOutlinePaint() { + return this.labelOutlinePaint; + } + + /** + * Sets the section label outline paint and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @see #getLabelOutlinePaint() + */ + public void setLabelOutlinePaint(Paint paint) { + this.labelOutlinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the section label outline stroke. + * + * @return The stroke (possibly null). + * + * @see #setLabelOutlineStroke(Stroke) + */ + public Stroke getLabelOutlineStroke() { + return this.labelOutlineStroke; + } + + /** + * Sets the section label outline stroke and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null permitted). + * + * @see #getLabelOutlineStroke() + */ + public void setLabelOutlineStroke(Stroke stroke) { + this.labelOutlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the section label shadow paint. + * + * @return The paint (possibly null). + * + * @see #setLabelShadowPaint(Paint) + */ + public Paint getLabelShadowPaint() { + return this.labelShadowPaint; + } + + /** + * Sets the section label shadow paint and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @see #getLabelShadowPaint() + */ + public void setLabelShadowPaint(Paint paint) { + this.labelShadowPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the label padding. + * + * @return The label padding (never null). + * + * @since 1.0.7 + * + * @see #setLabelPadding(RectangleInsets) + */ + public RectangleInsets getLabelPadding() { + return this.labelPadding; + } + + /** + * Sets the padding between each label and its outline and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param padding the padding (null not permitted). + * + * @since 1.0.7 + * + * @see #getLabelPadding() + */ + public void setLabelPadding(RectangleInsets padding) { + ParamChecks.nullNotPermitted(padding, "padding"); + this.labelPadding = padding; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether simple or extended labels are + * displayed on the plot. + * + * @return A boolean. + * + * @since 1.0.7 + */ + public boolean getSimpleLabels() { + return this.simpleLabels; + } + + /** + * Sets the flag that controls whether simple or extended labels are + * displayed on the plot, and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param simple the new flag value. + * + * @since 1.0.7 + */ + public void setSimpleLabels(boolean simple) { + this.simpleLabels = simple; + fireChangeEvent(); + } + + /** + * Returns the offset used for the simple labels, if they are displayed. + * + * @return The offset (never null). + * + * @since 1.0.7 + * + * @see #setSimpleLabelOffset(RectangleInsets) + */ + public RectangleInsets getSimpleLabelOffset() { + return this.simpleLabelOffset; + } + + /** + * Sets the offset for the simple labels and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param offset the offset (null not permitted). + * + * @since 1.0.7 + * + * @see #getSimpleLabelOffset() + */ + public void setSimpleLabelOffset(RectangleInsets offset) { + ParamChecks.nullNotPermitted(offset, "offset"); + this.simpleLabelOffset = offset; + fireChangeEvent(); + } + + /** + * Returns the object responsible for the vertical layout of the pie + * section labels. + * + * @return The label distributor (never null). + * + * @since 1.0.6 + */ + public AbstractPieLabelDistributor getLabelDistributor() { + return this.labelDistributor; + } + + /** + * Sets the label distributor and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param distributor the distributor (null not permitted). + * + * @since 1.0.6 + */ + public void setLabelDistributor(AbstractPieLabelDistributor distributor) { + ParamChecks.nullNotPermitted(distributor, "distributor"); + this.labelDistributor = distributor; + fireChangeEvent(); + } + + /** + * Returns the tool tip generator, an object that is responsible for + * generating the text items used for tool tips by the plot. If the + * generator is null, no tool tips will be created. + * + * @return The generator (possibly null). + * + * @see #setToolTipGenerator(PieToolTipGenerator) + */ + public PieToolTipGenerator getToolTipGenerator() { + return this.toolTipGenerator; + } + + /** + * Sets the tool tip generator and sends a {@link PlotChangeEvent} to all + * registered listeners. Set the generator to null if you + * don't want any tool tips. + * + * @param generator the generator (null permitted). + * + * @see #getToolTipGenerator() + */ + public void setToolTipGenerator(PieToolTipGenerator generator) { + this.toolTipGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the URL generator. + * + * @return The generator (possibly null). + * + * @see #setURLGenerator(PieURLGenerator) + */ + public PieURLGenerator getURLGenerator() { + return this.urlGenerator; + } + + /** + * Sets the URL generator and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getURLGenerator() + */ + public void setURLGenerator(PieURLGenerator generator) { + this.urlGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the minimum arc angle that will be drawn. Pie sections for an + * angle smaller than this are not drawn, to avoid a JDK bug. + * + * @return The minimum angle. + * + * @see #setMinimumArcAngleToDraw(double) + */ + public double getMinimumArcAngleToDraw() { + return this.minimumArcAngleToDraw; + } + + /** + * Sets the minimum arc angle that will be drawn. Pie sections for an + * angle smaller than this are not drawn, to avoid a JDK bug. See this + * link for details: + *

+ * + * http://www.jfree.org/phpBB2/viewtopic.php?t=2707 + *

+ * ...and this bug report in the Java Bug Parade: + *

+ * + * http://developer.java.sun.com/developer/bugParade/bugs/4836495.html + * + * @param angle the minimum angle. + * + * @see #getMinimumArcAngleToDraw() + */ + public void setMinimumArcAngleToDraw(double angle) { + this.minimumArcAngleToDraw = angle; + } + + /** + * Returns the shape used for legend items. + * + * @return The shape (never null). + * + * @see #setLegendItemShape(Shape) + */ + public Shape getLegendItemShape() { + return this.legendItemShape; + } + + /** + * Sets the shape used for legend items and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param shape the shape (null not permitted). + * + * @see #getLegendItemShape() + */ + public void setLegendItemShape(Shape shape) { + ParamChecks.nullNotPermitted(shape, "shape"); + this.legendItemShape = shape; + fireChangeEvent(); + } + + /** + * Returns the legend label generator. + * + * @return The legend label generator (never null). + * + * @see #setLegendLabelGenerator(PieSectionLabelGenerator) + */ + public PieSectionLabelGenerator getLegendLabelGenerator() { + return this.legendLabelGenerator; + } + + /** + * Sets the legend label generator and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param generator the generator (null not permitted). + * + * @see #getLegendLabelGenerator() + */ + public void setLegendLabelGenerator(PieSectionLabelGenerator generator) { + ParamChecks.nullNotPermitted(generator, "generator"); + this.legendLabelGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the legend label tool tip generator. + * + * @return The legend label tool tip generator (possibly null). + * + * @see #setLegendLabelToolTipGenerator(PieSectionLabelGenerator) + */ + public PieSectionLabelGenerator getLegendLabelToolTipGenerator() { + return this.legendLabelToolTipGenerator; + } + + /** + * Sets the legend label tool tip generator and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getLegendLabelToolTipGenerator() + */ + public void setLegendLabelToolTipGenerator( + PieSectionLabelGenerator generator) { + this.legendLabelToolTipGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the legend label URL generator. + * + * @return The legend label URL generator (possibly null). + * + * @see #setLegendLabelURLGenerator(PieURLGenerator) + * + * @since 1.0.4 + */ + public PieURLGenerator getLegendLabelURLGenerator() { + return this.legendLabelURLGenerator; + } + + /** + * Sets the legend label URL generator and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getLegendLabelURLGenerator() + * + * @since 1.0.4 + */ + public void setLegendLabelURLGenerator(PieURLGenerator generator) { + this.legendLabelURLGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the shadow generator for the plot, if any. + * + * @return The shadow generator (possibly null). + * + * @since 1.0.14 + */ + public ShadowGenerator getShadowGenerator() { + return this.shadowGenerator; + } + + /** + * Sets the shadow generator for the plot and sends a + * {@link PlotChangeEvent} to all registered listeners. Note that this is + * a bitmap drop-shadow generation facility and is separate from the + * vector based show option that is controlled via the + * {@link #setShadowPaint(java.awt.Paint)} method. + * + * @param generator the generator (null permitted). + * + * @since 1.0.14 + */ + public void setShadowGenerator(ShadowGenerator generator) { + this.shadowGenerator = generator; + fireChangeEvent(); + } + + /** + * Handles a mouse wheel rotation (this method is intended for use by the + * {@link org.jfree.chart.MouseWheelHandler} class). + * + * @param rotateClicks the number of rotate clicks on the the mouse wheel. + * + * @since 1.0.14 + */ + public void handleMouseWheelRotation(int rotateClicks) { + setStartAngle(this.startAngle + rotateClicks * 4.0); + } + + /** + * Initialises the drawing procedure. This method will be called before + * the first item is rendered, giving the plot an opportunity to initialise + * any state information it wants to maintain. + * + * @param g2 the graphics device. + * @param plotArea the plot area (null not permitted). + * @param plot the plot. + * @param index the secondary index (null for primary + * renderer). + * @param info collects chart rendering information for return to caller. + * + * @return A state object (maintains state information relevant to one + * chart drawing). + */ + public PiePlotState initialise(Graphics2D g2, Rectangle2D plotArea, + PiePlot plot, Integer index, PlotRenderingInfo info) { + + PiePlotState state = new PiePlotState(info); + state.setPassesRequired(2); + if (this.dataset != null) { + state.setTotal(DatasetUtilities.calculatePieDatasetTotal( + plot.getDataset())); + } + state.setLatestAngle(plot.getStartAngle()); + return state; + + } + + /** + * Draws the plot on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device. + * @param area the area within which the plot should be drawn. + * @param anchor the anchor point (null permitted). + * @param parentState the state from the parent plot, if there is one. + * @param info collects info about the drawing + * (null permitted). + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, PlotRenderingInfo info) { + + // adjust for insets... + RectangleInsets insets = getInsets(); + insets.trim(area); + + if (info != null) { + info.setPlotArea(area); + info.setDataArea(area); + } + + drawBackground(g2, area); + drawOutline(g2, area); + + Shape savedClip = g2.getClip(); + g2.clip(area); + + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + getForegroundAlpha())); + + if (!DatasetUtilities.isEmptyOrNull(this.dataset)) { + Graphics2D savedG2 = g2; + boolean suppressShadow = Boolean.TRUE.equals(g2.getRenderingHint( + JFreeChart.KEY_SUPPRESS_SHADOW_GENERATION)); + BufferedImage dataImage = null; + if (this.shadowGenerator != null && !suppressShadow) { + dataImage = new BufferedImage((int) area.getWidth(), + (int) area.getHeight(), BufferedImage.TYPE_INT_ARGB); + g2 = dataImage.createGraphics(); + g2.translate(-area.getX(), -area.getY()); + g2.setRenderingHints(savedG2.getRenderingHints()); + } + drawPie(g2, area, info); + if (this.shadowGenerator != null && !suppressShadow) { + BufferedImage shadowImage + = this.shadowGenerator.createDropShadow(dataImage); + g2 = savedG2; + g2.drawImage(shadowImage, (int) area.getX() + + this.shadowGenerator.calculateOffsetX(), + (int) area.getY() + + this.shadowGenerator.calculateOffsetY(), null); + g2.drawImage(dataImage, (int) area.getX(), (int) area.getY(), + null); + } + } + else { + drawNoDataMessage(g2, area); + } + + g2.setClip(savedClip); + g2.setComposite(originalComposite); + + drawOutline(g2, area); + + } + + /** + * Draws the pie. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param info chart rendering info. + */ + protected void drawPie(Graphics2D g2, Rectangle2D plotArea, + PlotRenderingInfo info) { + + PiePlotState state = initialise(g2, plotArea, this, null, info); + + // adjust the plot area for interior spacing and labels... + double labelReserve = 0.0; + if (this.labelGenerator != null && !this.simpleLabels) { + labelReserve = this.labelGap + this.maximumLabelWidth; + } + double gapHorizontal = plotArea.getWidth() * labelReserve * 2.0; + double gapVertical = plotArea.getHeight() * this.interiorGap * 2.0; + + + if (DEBUG_DRAW_INTERIOR) { + double hGap = plotArea.getWidth() * this.interiorGap; + double vGap = plotArea.getHeight() * this.interiorGap; + + double igx1 = plotArea.getX() + hGap; + double igx2 = plotArea.getMaxX() - hGap; + double igy1 = plotArea.getY() + vGap; + double igy2 = plotArea.getMaxY() - vGap; + g2.setPaint(Color.gray); + g2.draw(new Rectangle2D.Double(igx1, igy1, igx2 - igx1, + igy2 - igy1)); + } + + double linkX = plotArea.getX() + gapHorizontal / 2; + double linkY = plotArea.getY() + gapVertical / 2; + double linkW = plotArea.getWidth() - gapHorizontal; + double linkH = plotArea.getHeight() - gapVertical; + + // make the link area a square if the pie chart is to be circular... + if (this.circular) { + double min = Math.min(linkW, linkH) / 2; + linkX = (linkX + linkX + linkW) / 2 - min; + linkY = (linkY + linkY + linkH) / 2 - min; + linkW = 2 * min; + linkH = 2 * min; + } + + // the link area defines the dog leg points for the linking lines to + // the labels + Rectangle2D linkArea = new Rectangle2D.Double(linkX, linkY, linkW, + linkH); + state.setLinkArea(linkArea); + + if (DEBUG_DRAW_LINK_AREA) { + g2.setPaint(Color.blue); + g2.draw(linkArea); + g2.setPaint(Color.yellow); + g2.draw(new Ellipse2D.Double(linkArea.getX(), linkArea.getY(), + linkArea.getWidth(), linkArea.getHeight())); + } + + // the explode area defines the max circle/ellipse for the exploded + // pie sections. it is defined by shrinking the linkArea by the + // linkMargin factor. + double lm = 0.0; + if (!this.simpleLabels) { + lm = this.labelLinkMargin; + } + double hh = linkArea.getWidth() * lm * 2.0; + double vv = linkArea.getHeight() * lm * 2.0; + Rectangle2D explodeArea = new Rectangle2D.Double(linkX + hh / 2.0, + linkY + vv / 2.0, linkW - hh, linkH - vv); + + state.setExplodedPieArea(explodeArea); + + // the pie area defines the circle/ellipse for regular pie sections. + // it is defined by shrinking the explodeArea by the explodeMargin + // factor. + double maximumExplodePercent = getMaximumExplodePercent(); + double percent = maximumExplodePercent / (1.0 + maximumExplodePercent); + + double h1 = explodeArea.getWidth() * percent; + double v1 = explodeArea.getHeight() * percent; + Rectangle2D pieArea = new Rectangle2D.Double(explodeArea.getX() + + h1 / 2.0, explodeArea.getY() + v1 / 2.0, + explodeArea.getWidth() - h1, explodeArea.getHeight() - v1); + + if (DEBUG_DRAW_PIE_AREA) { + g2.setPaint(Color.green); + g2.draw(pieArea); + } + state.setPieArea(pieArea); + state.setPieCenterX(pieArea.getCenterX()); + state.setPieCenterY(pieArea.getCenterY()); + state.setPieWRadius(pieArea.getWidth() / 2.0); + state.setPieHRadius(pieArea.getHeight() / 2.0); + + // plot the data (unless the dataset is null)... + if ((this.dataset != null) && (this.dataset.getKeys().size() > 0)) { + + List keys = this.dataset.getKeys(); + double totalValue = DatasetUtilities.calculatePieDatasetTotal( + this.dataset); + + int passesRequired = state.getPassesRequired(); + for (int pass = 0; pass < passesRequired; pass++) { + double runningTotal = 0.0; + for (int section = 0; section < keys.size(); section++) { + Number n = this.dataset.getValue(section); + if (n != null) { + double value = n.doubleValue(); + if (value > 0.0) { + runningTotal += value; + drawItem(g2, section, explodeArea, state, pass); + } + } + } + } + if (this.simpleLabels) { + drawSimpleLabels(g2, keys, totalValue, plotArea, linkArea, + state); + } + else { + drawLabels(g2, keys, totalValue, plotArea, linkArea, state); + } + + } + else { + drawNoDataMessage(g2, plotArea); + } + } + + /** + * Draws a single data item. + * + * @param g2 the graphics device (null not permitted). + * @param section the section index. + * @param dataArea the data plot area. + * @param state state information for one chart. + * @param currentPass the current pass index. + */ + protected void drawItem(Graphics2D g2, int section, Rectangle2D dataArea, + PiePlotState state, int currentPass) { + + Number n = this.dataset.getValue(section); + if (n == null) { + return; + } + double value = n.doubleValue(); + double angle1 = 0.0; + double angle2 = 0.0; + + if (this.direction == Rotation.CLOCKWISE) { + angle1 = state.getLatestAngle(); + angle2 = angle1 - value / state.getTotal() * 360.0; + } + else if (this.direction == Rotation.ANTICLOCKWISE) { + angle1 = state.getLatestAngle(); + angle2 = angle1 + value / state.getTotal() * 360.0; + } + else { + throw new IllegalStateException("Rotation type not recognised."); + } + + double angle = (angle2 - angle1); + if (Math.abs(angle) > getMinimumArcAngleToDraw()) { + double ep = 0.0; + double mep = getMaximumExplodePercent(); + if (mep > 0.0) { + ep = getExplodePercent(section) / mep; + } + Rectangle2D arcBounds = getArcBounds(state.getPieArea(), + state.getExplodedPieArea(), angle1, angle, ep); + Arc2D.Double arc = new Arc2D.Double(arcBounds, angle1, angle, + Arc2D.PIE); + + if (currentPass == 0) { + if (this.shadowPaint != null && this.shadowGenerator == null) { + Shape shadowArc = ShapeUtilities.createTranslatedShape( + arc, (float) this.shadowXOffset, + (float) this.shadowYOffset); + g2.setPaint(this.shadowPaint); + g2.fill(shadowArc); + } + } + else if (currentPass == 1) { + Comparable key = getSectionKey(section); + Paint paint = lookupSectionPaint(key, state); + g2.setPaint(paint); + g2.fill(arc); + + Paint outlinePaint = lookupSectionOutlinePaint(key); + Stroke outlineStroke = lookupSectionOutlineStroke(key); + if (this.sectionOutlinesVisible) { + g2.setPaint(outlinePaint); + g2.setStroke(outlineStroke); + g2.draw(arc); + } + + // update the linking line target for later + // add an entity for the pie section + if (state.getInfo() != null) { + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + String tip = null; + if (this.toolTipGenerator != null) { + tip = this.toolTipGenerator.generateToolTip( + this.dataset, key); + } + String url = null; + if (this.urlGenerator != null) { + url = this.urlGenerator.generateURL(this.dataset, + key, this.pieIndex); + } + PieSectionEntity entity = new PieSectionEntity( + arc, this.dataset, this.pieIndex, section, key, + tip, url); + entities.add(entity); + } + } + } + } + state.setLatestAngle(angle2); + } + + /** + * Draws the pie section labels in the simple form. + * + * @param g2 the graphics device. + * @param keys the section keys. + * @param totalValue the total value for all sections in the pie. + * @param plotArea the plot area. + * @param pieArea the area containing the pie. + * @param state the plot state. + * + * @since 1.0.7 + */ + protected void drawSimpleLabels(Graphics2D g2, List keys, + double totalValue, Rectangle2D plotArea, Rectangle2D pieArea, + PiePlotState state) { + + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + 1.0f)); + + Rectangle2D labelsArea = this.simpleLabelOffset.createInsetRectangle( + pieArea); + double runningTotal = 0.0; + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Comparable key = (Comparable) iterator.next(); + boolean include; + double v = 0.0; + Number n = getDataset().getValue(key); + if (n == null) { + include = !getIgnoreNullValues(); + } + else { + v = n.doubleValue(); + include = getIgnoreZeroValues() ? v > 0.0 : v >= 0.0; + } + + if (include) { + runningTotal = runningTotal + v; + // work out the mid angle (0 - 90 and 270 - 360) = right, + // otherwise left + double mid = getStartAngle() + (getDirection().getFactor() + * ((runningTotal - v / 2.0) * 360) / totalValue); + + Arc2D arc = new Arc2D.Double(labelsArea, getStartAngle(), + mid - getStartAngle(), Arc2D.OPEN); + int x = (int) arc.getEndPoint().getX(); + int y = (int) arc.getEndPoint().getY(); + + PieSectionLabelGenerator myLabelGenerator = getLabelGenerator(); + if (myLabelGenerator == null) { + continue; + } + String label = myLabelGenerator.generateSectionLabel( + this.dataset, key); + if (label == null) { + continue; + } + g2.setFont(this.labelFont); + FontMetrics fm = g2.getFontMetrics(); + Rectangle2D bounds = TextUtilities.getTextBounds(label, g2, fm); + Rectangle2D out = this.labelPadding.createOutsetRectangle( + bounds); + Shape bg = ShapeUtilities.createTranslatedShape(out, + x - bounds.getCenterX(), y - bounds.getCenterY()); + if (this.labelShadowPaint != null + && this.shadowGenerator == null) { + Shape shadow = ShapeUtilities.createTranslatedShape(bg, + this.shadowXOffset, this.shadowYOffset); + g2.setPaint(this.labelShadowPaint); + g2.fill(shadow); + } + if (this.labelBackgroundPaint != null) { + g2.setPaint(this.labelBackgroundPaint); + g2.fill(bg); + } + if (this.labelOutlinePaint != null + && this.labelOutlineStroke != null) { + g2.setPaint(this.labelOutlinePaint); + g2.setStroke(this.labelOutlineStroke); + g2.draw(bg); + } + + g2.setPaint(this.labelPaint); + g2.setFont(this.labelFont); + TextUtilities.drawAlignedString(label, g2, x, y, + TextAnchor.CENTER); + + } + } + + g2.setComposite(originalComposite); + + } + + /** + * Draws the labels for the pie sections. + * + * @param g2 the graphics device. + * @param keys the keys. + * @param totalValue the total value. + * @param plotArea the plot area. + * @param linkArea the link area. + * @param state the state. + */ + protected void drawLabels(Graphics2D g2, List keys, double totalValue, + Rectangle2D plotArea, Rectangle2D linkArea, + PiePlotState state) { + + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + 1.0f)); + + // classify the keys according to which side the label will appear... + DefaultKeyedValues leftKeys = new DefaultKeyedValues(); + DefaultKeyedValues rightKeys = new DefaultKeyedValues(); + + double runningTotal = 0.0; + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Comparable key = (Comparable) iterator.next(); + boolean include; + double v = 0.0; + Number n = this.dataset.getValue(key); + if (n == null) { + include = !this.ignoreNullValues; + } + else { + v = n.doubleValue(); + include = this.ignoreZeroValues ? v > 0.0 : v >= 0.0; + } + + if (include) { + runningTotal = runningTotal + v; + // work out the mid angle (0 - 90 and 270 - 360) = right, + // otherwise left + double mid = this.startAngle + (this.direction.getFactor() + * ((runningTotal - v / 2.0) * 360) / totalValue); + if (Math.cos(Math.toRadians(mid)) < 0.0) { + leftKeys.addValue(key, new Double(mid)); + } + else { + rightKeys.addValue(key, new Double(mid)); + } + } + } + + g2.setFont(getLabelFont()); + + // calculate the max label width from the plot dimensions, because + // a circular pie can leave a lot more room for labels... + double marginX = plotArea.getX(); + double gap = plotArea.getWidth() * this.labelGap; + double ww = linkArea.getX() - gap - marginX; + float labelWidth = (float) this.labelPadding.trimWidth(ww); + + // draw the labels... + if (this.labelGenerator != null) { + drawLeftLabels(leftKeys, g2, plotArea, linkArea, labelWidth, + state); + drawRightLabels(rightKeys, g2, plotArea, linkArea, labelWidth, + state); + } + g2.setComposite(originalComposite); + + } + + /** + * Draws the left labels. + * + * @param leftKeys a collection of keys and angles (to the middle of the + * section, in degrees) for the sections on the left side of the + * plot. + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param linkArea the link area. + * @param maxLabelWidth the maximum label width. + * @param state the state. + */ + protected void drawLeftLabels(KeyedValues leftKeys, Graphics2D g2, + Rectangle2D plotArea, Rectangle2D linkArea, + float maxLabelWidth, PiePlotState state) { + + this.labelDistributor.clear(); + double lGap = plotArea.getWidth() * this.labelGap; + double verticalLinkRadius = state.getLinkArea().getHeight() / 2.0; + for (int i = 0; i < leftKeys.getItemCount(); i++) { + String label = this.labelGenerator.generateSectionLabel( + this.dataset, leftKeys.getKey(i)); + if (label != null) { + TextBlock block = TextUtilities.createTextBlock(label, + this.labelFont, this.labelPaint, maxLabelWidth, + new G2TextMeasurer(g2)); + TextBox labelBox = new TextBox(block); + labelBox.setBackgroundPaint(this.labelBackgroundPaint); + labelBox.setOutlinePaint(this.labelOutlinePaint); + labelBox.setOutlineStroke(this.labelOutlineStroke); + if (this.shadowGenerator == null) { + labelBox.setShadowPaint(this.labelShadowPaint); + } + else { + labelBox.setShadowPaint(null); + } + labelBox.setInteriorGap(this.labelPadding); + double theta = Math.toRadians( + leftKeys.getValue(i).doubleValue()); + double baseY = state.getPieCenterY() - Math.sin(theta) + * verticalLinkRadius; + double hh = labelBox.getHeight(g2); + + this.labelDistributor.addPieLabelRecord(new PieLabelRecord( + leftKeys.getKey(i), theta, baseY, labelBox, hh, + lGap / 2.0 + lGap / 2.0 * -Math.cos(theta), 1.0 + - getLabelLinkDepth() + + getExplodePercent(leftKeys.getKey(i)))); + } + } + double hh = plotArea.getHeight(); + double gap = hh * getInteriorGap(); + this.labelDistributor.distributeLabels(plotArea.getMinY() + gap, + hh - 2 * gap); + for (int i = 0; i < this.labelDistributor.getItemCount(); i++) { + drawLeftLabel(g2, state, + this.labelDistributor.getPieLabelRecord(i)); + } + } + + /** + * Draws the right labels. + * + * @param keys the keys. + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param linkArea the link area. + * @param maxLabelWidth the maximum label width. + * @param state the state. + */ + protected void drawRightLabels(KeyedValues keys, Graphics2D g2, + Rectangle2D plotArea, Rectangle2D linkArea, + float maxLabelWidth, PiePlotState state) { + + // draw the right labels... + this.labelDistributor.clear(); + double lGap = plotArea.getWidth() * this.labelGap; + double verticalLinkRadius = state.getLinkArea().getHeight() / 2.0; + + for (int i = 0; i < keys.getItemCount(); i++) { + String label = this.labelGenerator.generateSectionLabel( + this.dataset, keys.getKey(i)); + + if (label != null) { + TextBlock block = TextUtilities.createTextBlock(label, + this.labelFont, this.labelPaint, maxLabelWidth, + new G2TextMeasurer(g2)); + TextBox labelBox = new TextBox(block); + labelBox.setBackgroundPaint(this.labelBackgroundPaint); + labelBox.setOutlinePaint(this.labelOutlinePaint); + labelBox.setOutlineStroke(this.labelOutlineStroke); + if (this.shadowGenerator == null) { + labelBox.setShadowPaint(this.labelShadowPaint); + } + else { + labelBox.setShadowPaint(null); + } + labelBox.setInteriorGap(this.labelPadding); + double theta = Math.toRadians(keys.getValue(i).doubleValue()); + double baseY = state.getPieCenterY() + - Math.sin(theta) * verticalLinkRadius; + double hh = labelBox.getHeight(g2); + this.labelDistributor.addPieLabelRecord(new PieLabelRecord( + keys.getKey(i), theta, baseY, labelBox, hh, + lGap / 2.0 + lGap / 2.0 * Math.cos(theta), + 1.0 - getLabelLinkDepth() + + getExplodePercent(keys.getKey(i)))); + } + } + double hh = plotArea.getHeight(); + double gap = 0.00; //hh * getInteriorGap(); + this.labelDistributor.distributeLabels(plotArea.getMinY() + gap, + hh - 2 * gap); + for (int i = 0; i < this.labelDistributor.getItemCount(); i++) { + drawRightLabel(g2, state, + this.labelDistributor.getPieLabelRecord(i)); + } + + } + + /** + * Returns a collection of legend items for the pie chart. + * + * @return The legend items (never null). + */ + @Override + public LegendItemCollection getLegendItems() { + + LegendItemCollection result = new LegendItemCollection(); + if (this.dataset == null) { + return result; + } + List keys = this.dataset.getKeys(); + int section = 0; + Shape shape = getLegendItemShape(); + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Comparable key = (Comparable) iterator.next(); + Number n = this.dataset.getValue(key); + boolean include; + if (n == null) { + include = !this.ignoreNullValues; + } + else { + double v = n.doubleValue(); + if (v == 0.0) { + include = !this.ignoreZeroValues; + } + else { + include = v > 0.0; + } + } + if (include) { + String label = this.legendLabelGenerator.generateSectionLabel( + this.dataset, key); + if (label != null) { + String description = label; + String toolTipText = null; + if (this.legendLabelToolTipGenerator != null) { + toolTipText = this.legendLabelToolTipGenerator + .generateSectionLabel(this.dataset, key); + } + String urlText = null; + if (this.legendLabelURLGenerator != null) { + urlText = this.legendLabelURLGenerator.generateURL( + this.dataset, key, this.pieIndex); + } + Paint paint = lookupSectionPaint(key); + Paint outlinePaint = lookupSectionOutlinePaint(key); + Stroke outlineStroke = lookupSectionOutlineStroke(key); + LegendItem item = new LegendItem(label, description, + toolTipText, urlText, true, shape, true, paint, + true, outlinePaint, outlineStroke, + false, // line not visible + new Line2D.Float(), new BasicStroke(), Color.black); + item.setDataset(getDataset()); + item.setSeriesIndex(this.dataset.getIndex(key)); + item.setSeriesKey(key); + result.add(item); + } + section++; + } + else { + section++; + } + } + return result; + } + + /** + * Returns a short string describing the type of plot. + * + * @return The plot type. + */ + @Override + public String getPlotType() { + return localizationResources.getString("Pie_Plot"); + } + + /** + * Returns a rectangle that can be used to create a pie section (taking + * into account the amount by which the pie section is 'exploded'). + * + * @param unexploded the area inside which the unexploded pie sections are + * drawn. + * @param exploded the area inside which the exploded pie sections are + * drawn. + * @param angle the start angle. + * @param extent the extent of the arc. + * @param explodePercent the amount by which the pie section is exploded. + * + * @return A rectangle that can be used to create a pie section. + */ + protected Rectangle2D getArcBounds(Rectangle2D unexploded, + Rectangle2D exploded, + double angle, double extent, + double explodePercent) { + + if (explodePercent == 0.0) { + return unexploded; + } + Arc2D arc1 = new Arc2D.Double(unexploded, angle, extent / 2, + Arc2D.OPEN); + Point2D point1 = arc1.getEndPoint(); + Arc2D.Double arc2 = new Arc2D.Double(exploded, angle, extent / 2, + Arc2D.OPEN); + Point2D point2 = arc2.getEndPoint(); + double deltaX = (point1.getX() - point2.getX()) * explodePercent; + double deltaY = (point1.getY() - point2.getY()) * explodePercent; + return new Rectangle2D.Double(unexploded.getX() - deltaX, + unexploded.getY() - deltaY, unexploded.getWidth(), + unexploded.getHeight()); + } + + /** + * Draws a section label on the left side of the pie chart. + * + * @param g2 the graphics device. + * @param state the state. + * @param record the label record. + */ + protected void drawLeftLabel(Graphics2D g2, PiePlotState state, + PieLabelRecord record) { + + double anchorX = state.getLinkArea().getMinX(); + double targetX = anchorX - record.getGap(); + double targetY = record.getAllocatedY(); + + if (this.labelLinksVisible) { + double theta = record.getAngle(); + double linkX = state.getPieCenterX() + Math.cos(theta) + * state.getPieWRadius() * record.getLinkPercent(); + double linkY = state.getPieCenterY() - Math.sin(theta) + * state.getPieHRadius() * record.getLinkPercent(); + double elbowX = state.getPieCenterX() + Math.cos(theta) + * state.getLinkArea().getWidth() / 2.0; + double elbowY = state.getPieCenterY() - Math.sin(theta) + * state.getLinkArea().getHeight() / 2.0; + double anchorY = elbowY; + g2.setPaint(this.labelLinkPaint); + g2.setStroke(this.labelLinkStroke); + PieLabelLinkStyle style = getLabelLinkStyle(); + if (style.equals(PieLabelLinkStyle.STANDARD)) { + g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY)); + g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY)); + g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY)); + } + else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) { + QuadCurve2D q = new QuadCurve2D.Float(); + q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY); + g2.draw(q); + g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY)); + } + else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) { + CubicCurve2D c = new CubicCurve2D .Float(); + c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY, + linkX, linkY); + g2.draw(c); + } + } + TextBox tb = record.getLabel(); + tb.draw(g2, (float) targetX, (float) targetY, RectangleAnchor.RIGHT); + + } + + /** + * Draws a section label on the right side of the pie chart. + * + * @param g2 the graphics device. + * @param state the state. + * @param record the label record. + */ + protected void drawRightLabel(Graphics2D g2, PiePlotState state, + PieLabelRecord record) { + + double anchorX = state.getLinkArea().getMaxX(); + double targetX = anchorX + record.getGap(); + double targetY = record.getAllocatedY(); + + if (this.labelLinksVisible) { + double theta = record.getAngle(); + double linkX = state.getPieCenterX() + Math.cos(theta) + * state.getPieWRadius() * record.getLinkPercent(); + double linkY = state.getPieCenterY() - Math.sin(theta) + * state.getPieHRadius() * record.getLinkPercent(); + double elbowX = state.getPieCenterX() + Math.cos(theta) + * state.getLinkArea().getWidth() / 2.0; + double elbowY = state.getPieCenterY() - Math.sin(theta) + * state.getLinkArea().getHeight() / 2.0; + double anchorY = elbowY; + g2.setPaint(this.labelLinkPaint); + g2.setStroke(this.labelLinkStroke); + PieLabelLinkStyle style = getLabelLinkStyle(); + if (style.equals(PieLabelLinkStyle.STANDARD)) { + g2.draw(new Line2D.Double(linkX, linkY, elbowX, elbowY)); + g2.draw(new Line2D.Double(anchorX, anchorY, elbowX, elbowY)); + g2.draw(new Line2D.Double(anchorX, anchorY, targetX, targetY)); + } + else if (style.equals(PieLabelLinkStyle.QUAD_CURVE)) { + QuadCurve2D q = new QuadCurve2D.Float(); + q.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY); + g2.draw(q); + g2.draw(new Line2D.Double(elbowX, elbowY, linkX, linkY)); + } + else if (style.equals(PieLabelLinkStyle.CUBIC_CURVE)) { + CubicCurve2D c = new CubicCurve2D .Float(); + c.setCurve(targetX, targetY, anchorX, anchorY, elbowX, elbowY, + linkX, linkY); + g2.draw(c); + } + } + + TextBox tb = record.getLabel(); + tb.draw(g2, (float) targetX, (float) targetY, RectangleAnchor.LEFT); + + } + + /** + * Returns the center for the specified section. + * Checks to see if the section is exploded and recalculates the + * new center if so. + * + * @param state PiePlotState + * @param key section key. + * + * @return The center for the specified section. + * + * @since 1.0.14 + */ + protected Point2D getArcCenter(PiePlotState state, Comparable key) { + Point2D center = new Point2D.Double(state.getPieCenterX(), state + .getPieCenterY()); + + double ep = getExplodePercent(key); + double mep = getMaximumExplodePercent(); + if (mep > 0.0) { + ep = ep / mep; + } + if (ep != 0) { + Rectangle2D pieArea = state.getPieArea(); + Rectangle2D expPieArea = state.getExplodedPieArea(); + double angle1, angle2; + Number n = this.dataset.getValue(key); + double value = n.doubleValue(); + + if (this.direction == Rotation.CLOCKWISE) { + angle1 = state.getLatestAngle(); + angle2 = angle1 - value / state.getTotal() * 360.0; + } else if (this.direction == Rotation.ANTICLOCKWISE) { + angle1 = state.getLatestAngle(); + angle2 = angle1 + value / state.getTotal() * 360.0; + } else { + throw new IllegalStateException("Rotation type not recognised."); + } + double angle = (angle2 - angle1); + + Arc2D arc1 = new Arc2D.Double(pieArea, angle1, angle / 2, + Arc2D.OPEN); + Point2D point1 = arc1.getEndPoint(); + Arc2D.Double arc2 = new Arc2D.Double(expPieArea, angle1, angle / 2, + Arc2D.OPEN); + Point2D point2 = arc2.getEndPoint(); + double deltaX = (point1.getX() - point2.getX()) * ep; + double deltaY = (point1.getY() - point2.getY()) * ep; + + center = new Point2D.Double(state.getPieCenterX() - deltaX, + state.getPieCenterY() - deltaY); + + } + return center; + } + + /** + * Returns the paint for the specified section. This is equivalent to + * lookupSectionPaint(section). + * Checks to see if the user set the Paint to be of type RadialGradientPaint + * If so it adjusts the center and radius to match the Pie + * + * @param key the section key. + * @param state PiePlotState. + * + * @return The paint for the specified section. + * + * @since 1.0.14 + */ + protected Paint lookupSectionPaint(Comparable key, PiePlotState state) { + Paint paint = lookupSectionPaint(key, getAutoPopulateSectionPaint()); + // for a RadialGradientPaint we adjust the center and radius to match + // the current pie segment... + if (paint instanceof RadialGradientPaint) { + RadialGradientPaint rgp = (RadialGradientPaint) paint; + Point2D center = getArcCenter(state, key); + float radius = (float) Math.max(state.getPieHRadius(), + state.getPieWRadius()); + float[] fractions = rgp.getFractions(); + Color[] colors = rgp.getColors(); + paint = new RadialGradientPaint(center, radius, fractions, colors); + } + return paint; + } + + /** + * Tests this plot for equality with an arbitrary object. Note that the + * plot's dataset is NOT included in the test for equality. + * + * @param obj the object to test against (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PiePlot)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + PiePlot that = (PiePlot) obj; + if (this.pieIndex != that.pieIndex) { + return false; + } + if (this.interiorGap != that.interiorGap) { + return false; + } + if (this.circular != that.circular) { + return false; + } + if (this.startAngle != that.startAngle) { + return false; + } + if (this.direction != that.direction) { + return false; + } + if (this.ignoreZeroValues != that.ignoreZeroValues) { + return false; + } + if (this.ignoreNullValues != that.ignoreNullValues) { + return false; + } + if (!PaintUtilities.equal(this.sectionPaint, that.sectionPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.sectionPaintMap, + that.sectionPaintMap)) { + return false; + } + if (!PaintUtilities.equal(this.baseSectionPaint, + that.baseSectionPaint)) { + return false; + } + if (this.sectionOutlinesVisible != that.sectionOutlinesVisible) { + return false; + } + if (!PaintUtilities.equal(this.sectionOutlinePaint, + that.sectionOutlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.sectionOutlinePaintMap, + that.sectionOutlinePaintMap)) { + return false; + } + if (!PaintUtilities.equal(this.baseSectionOutlinePaint, + that.baseSectionOutlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.sectionOutlineStroke, + that.sectionOutlineStroke)) { + return false; + } + if (!ObjectUtilities.equal(this.sectionOutlineStrokeMap, + that.sectionOutlineStrokeMap)) { + return false; + } + if (!ObjectUtilities.equal(this.baseSectionOutlineStroke, + that.baseSectionOutlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.shadowPaint, that.shadowPaint)) { + return false; + } + if (!(this.shadowXOffset == that.shadowXOffset)) { + return false; + } + if (!(this.shadowYOffset == that.shadowYOffset)) { + return false; + } + if (!ObjectUtilities.equal(this.explodePercentages, + that.explodePercentages)) { + return false; + } + if (!ObjectUtilities.equal(this.labelGenerator, + that.labelGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.labelFont, that.labelFont)) { + return false; + } + if (!PaintUtilities.equal(this.labelPaint, that.labelPaint)) { + return false; + } + if (!PaintUtilities.equal(this.labelBackgroundPaint, + that.labelBackgroundPaint)) { + return false; + } + if (!PaintUtilities.equal(this.labelOutlinePaint, + that.labelOutlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.labelOutlineStroke, + that.labelOutlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.labelShadowPaint, + that.labelShadowPaint)) { + return false; + } + if (this.simpleLabels != that.simpleLabels) { + return false; + } + if (!this.simpleLabelOffset.equals(that.simpleLabelOffset)) { + return false; + } + if (!this.labelPadding.equals(that.labelPadding)) { + return false; + } + if (!(this.maximumLabelWidth == that.maximumLabelWidth)) { + return false; + } + if (!(this.labelGap == that.labelGap)) { + return false; + } + if (!(this.labelLinkMargin == that.labelLinkMargin)) { + return false; + } + if (this.labelLinksVisible != that.labelLinksVisible) { + return false; + } + if (!this.labelLinkStyle.equals(that.labelLinkStyle)) { + return false; + } + if (!PaintUtilities.equal(this.labelLinkPaint, that.labelLinkPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.labelLinkStroke, + that.labelLinkStroke)) { + return false; + } + if (!ObjectUtilities.equal(this.toolTipGenerator, + that.toolTipGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.urlGenerator, that.urlGenerator)) { + return false; + } + if (!(this.minimumArcAngleToDraw == that.minimumArcAngleToDraw)) { + return false; + } + if (!ShapeUtilities.equal(this.legendItemShape, that.legendItemShape)) { + return false; + } + if (!ObjectUtilities.equal(this.legendLabelGenerator, + that.legendLabelGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.legendLabelToolTipGenerator, + that.legendLabelToolTipGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.legendLabelURLGenerator, + that.legendLabelURLGenerator)) { + return false; + } + if (this.autoPopulateSectionPaint != that.autoPopulateSectionPaint) { + return false; + } + if (this.autoPopulateSectionOutlinePaint + != that.autoPopulateSectionOutlinePaint) { + return false; + } + if (this.autoPopulateSectionOutlineStroke + != that.autoPopulateSectionOutlineStroke) { + return false; + } + if (!ObjectUtilities.equal(this.shadowGenerator, + that.shadowGenerator)) { + return false; + } + // can't find any difference... + return true; + } + + /** + * Returns a clone of the plot. + * + * @return A clone. + * + * @throws CloneNotSupportedException if some component of the plot does + * not support cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + PiePlot clone = (PiePlot) super.clone(); + if (clone.dataset != null) { + clone.dataset.addChangeListener(clone); + } + if (this.urlGenerator instanceof PublicCloneable) { + clone.urlGenerator = (PieURLGenerator) ObjectUtilities.clone( + this.urlGenerator); + } + clone.legendItemShape = ShapeUtilities.clone(this.legendItemShape); + if (this.legendLabelGenerator != null) { + clone.legendLabelGenerator = (PieSectionLabelGenerator) + ObjectUtilities.clone(this.legendLabelGenerator); + } + if (this.legendLabelToolTipGenerator != null) { + clone.legendLabelToolTipGenerator = (PieSectionLabelGenerator) + ObjectUtilities.clone(this.legendLabelToolTipGenerator); + } + if (this.legendLabelURLGenerator instanceof PublicCloneable) { + clone.legendLabelURLGenerator = (PieURLGenerator) + ObjectUtilities.clone(this.legendLabelURLGenerator); + } + 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.sectionPaint, stream); + SerialUtilities.writePaint(this.baseSectionPaint, stream); + SerialUtilities.writePaint(this.sectionOutlinePaint, stream); + SerialUtilities.writePaint(this.baseSectionOutlinePaint, stream); + SerialUtilities.writeStroke(this.sectionOutlineStroke, stream); + SerialUtilities.writeStroke(this.baseSectionOutlineStroke, stream); + SerialUtilities.writePaint(this.shadowPaint, stream); + SerialUtilities.writePaint(this.labelPaint, stream); + SerialUtilities.writePaint(this.labelBackgroundPaint, stream); + SerialUtilities.writePaint(this.labelOutlinePaint, stream); + SerialUtilities.writeStroke(this.labelOutlineStroke, stream); + SerialUtilities.writePaint(this.labelShadowPaint, stream); + SerialUtilities.writePaint(this.labelLinkPaint, stream); + SerialUtilities.writeStroke(this.labelLinkStroke, stream); + SerialUtilities.writeShape(this.legendItemShape, 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.sectionPaint = SerialUtilities.readPaint(stream); + this.baseSectionPaint = SerialUtilities.readPaint(stream); + this.sectionOutlinePaint = SerialUtilities.readPaint(stream); + this.baseSectionOutlinePaint = SerialUtilities.readPaint(stream); + this.sectionOutlineStroke = SerialUtilities.readStroke(stream); + this.baseSectionOutlineStroke = SerialUtilities.readStroke(stream); + this.shadowPaint = SerialUtilities.readPaint(stream); + this.labelPaint = SerialUtilities.readPaint(stream); + this.labelBackgroundPaint = SerialUtilities.readPaint(stream); + this.labelOutlinePaint = SerialUtilities.readPaint(stream); + this.labelOutlineStroke = SerialUtilities.readStroke(stream); + this.labelShadowPaint = SerialUtilities.readPaint(stream); + this.labelLinkPaint = SerialUtilities.readPaint(stream); + this.labelLinkStroke = SerialUtilities.readStroke(stream); + this.legendItemShape = SerialUtilities.readShape(stream); + } + + // DEPRECATED FIELDS AND METHODS... + + /** + * The paint for ALL sections (overrides list). + * + * @deprecated This field is redundant, it is sufficient to use + * sectionPaintMap and baseSectionPaint. Deprecated as of version + * 1.0.6. + */ + private transient Paint sectionPaint; + + /** + * The outline paint for ALL sections (overrides list). + * + * @deprecated This field is redundant, it is sufficient to use + * sectionOutlinePaintMap and baseSectionOutlinePaint. Deprecated as + * of version 1.0.6. + */ + private transient Paint sectionOutlinePaint; + + /** + * The outline stroke for ALL sections (overrides list). + * + * @deprecated This field is redundant, it is sufficient to use + * sectionOutlineStrokeMap and baseSectionOutlineStroke. Deprecated as + * of version 1.0.6. + */ + private transient Stroke sectionOutlineStroke; + + /** + * Returns the paint for the specified section. + * + * @param section the section index (zero-based). + * + * @return The paint (never null). + * + * @deprecated Use {@link #getSectionPaint(Comparable)} instead. + */ + public Paint getSectionPaint(int section) { + Comparable key = getSectionKey(section); + return getSectionPaint(key); + } + + /** + * Sets the paint used to fill a section of the pie and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param section the section index (zero-based). + * @param paint the paint (null permitted). + * + * @deprecated Use {@link #setSectionPaint(Comparable, Paint)} instead. + */ + public void setSectionPaint(int section, Paint paint) { + Comparable key = getSectionKey(section); + setSectionPaint(key, paint); + } + + /** + * Returns the outline paint for ALL sections in the plot. + * + * @return The paint (possibly null). + * + * @see #setSectionOutlinePaint(Paint) + * + * @deprecated Use {@link #getSectionOutlinePaint(Comparable)} and + * {@link #getBaseSectionOutlinePaint()}. Deprecated as of version + * 1.0.6. + */ + public Paint getSectionOutlinePaint() { + return this.sectionOutlinePaint; + } + + /** + * Sets the outline paint for ALL sections in the plot. If this is set to + * null, then a list of paints is used instead (to allow + * different colors to be used for each section). + * + * @param paint the paint (null permitted). + * + * @see #getSectionOutlinePaint() + * + * @deprecated Use {@link #setSectionOutlinePaint(Comparable, Paint)} and + * {@link #setBaseSectionOutlinePaint(Paint)}. Deprecated as of + * version 1.0.6. + */ + public void setSectionOutlinePaint(Paint paint) { + this.sectionOutlinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint for the specified section. + * + * @param section the section index (zero-based). + * + * @return The paint (possibly null). + * + * @deprecated Use {@link #getSectionOutlinePaint(Comparable)} instead. + */ + public Paint getSectionOutlinePaint(int section) { + Comparable key = getSectionKey(section); + return getSectionOutlinePaint(key); + } + + /** + * Sets the paint used to fill a section of the pie and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param section the section index (zero-based). + * @param paint the paint (null permitted). + * + * @deprecated Use {@link #setSectionOutlinePaint(Comparable, Paint)} + * instead. + */ + public void setSectionOutlinePaint(int section, Paint paint) { + Comparable key = getSectionKey(section); + setSectionOutlinePaint(key, paint); + } + + /** + * Returns the outline stroke for ALL sections in the plot. + * + * @return The stroke (possibly null). + * + * @see #setSectionOutlineStroke(Stroke) + * + * @deprecated Use {@link #getSectionOutlineStroke(Comparable)} and + * {@link #getBaseSectionOutlineStroke()}. Deprecated as of version + * 1.0.6. + */ + public Stroke getSectionOutlineStroke() { + return this.sectionOutlineStroke; + } + + /** + * Sets the outline stroke for ALL sections in the plot. If this is set to + * null, then a list of paints is used instead (to allow + * different colors to be used for each section). + * + * @param stroke the stroke (null permitted). + * + * @see #getSectionOutlineStroke() + * + * @deprecated Use {@link #setSectionOutlineStroke(Comparable, Stroke)} and + * {@link #setBaseSectionOutlineStroke(Stroke)}. Deprecated as of + * version 1.0.6. + */ + public void setSectionOutlineStroke(Stroke stroke) { + this.sectionOutlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the stroke for the specified section. + * + * @param section the section index (zero-based). + * + * @return The stroke (possibly null). + * + * @deprecated Use {@link #getSectionOutlineStroke(Comparable)} instead. + */ + public Stroke getSectionOutlineStroke(int section) { + Comparable key = getSectionKey(section); + return getSectionOutlineStroke(key); + } + + /** + * Sets the stroke used to fill a section of the pie and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param section the section index (zero-based). + * @param stroke the stroke (null permitted). + * + * @deprecated Use {@link #setSectionOutlineStroke(Comparable, Stroke)} + * instead. + */ + public void setSectionOutlineStroke(int section, Stroke stroke) { + Comparable key = getSectionKey(section); + setSectionOutlineStroke(key, stroke); + } + + /** + * Returns the amount that a section should be 'exploded'. + * + * @param section the section number. + * + * @return The amount that a section should be 'exploded'. + * + * @deprecated Use {@link #getExplodePercent(Comparable)} instead. + */ + public double getExplodePercent(int section) { + Comparable key = getSectionKey(section); + return getExplodePercent(key); + } + + /** + * Sets the amount that a pie section should be exploded and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param section the section index. + * @param percent the explode percentage (0.30 = 30 percent). + * + * @deprecated Use {@link #setExplodePercent(Comparable, double)} instead. + */ + public void setExplodePercent(int section, double percent) { + Comparable key = getSectionKey(section); + setExplodePercent(key, percent); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PiePlot3D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PiePlot3D.java new file mode 100755 index 0000000..a2dbcf3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PiePlot3D.java @@ -0,0 +1,1055 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * PiePlot3D.java + * -------------- + * (C) Copyright 2000-2013, by Object Refinery and Contributors. + * + * Original Author: Tomer Peretz; + * Contributor(s): Richard Atkinson; + * David Gilbert (for Object Refinery Limited); + * Xun Kang; + * Christian W. Zuckschwerdt; + * Arnaud Lelievre; + * Dave Crane; + * Martin Hoeller; + * DaveLaw (dave ATT davelaw DOTT de); + * + * Changes + * ------- + * 21-Jun-2002 : Version 1; + * 31-Jul-2002 : Modified to use startAngle and direction, drawing modified so + * that charts render with foreground alpha < 1.0 (DG); + * 05-Aug-2002 : Small modification to draw method to support URLs for HTML + * image maps (RA); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 18-Oct-2002 : Added drawing bug fix sent in by Xun Kang, and made a couple + * of other related fixes (DG); + * 30-Oct-2002 : Changed the PieDataset interface. Fixed another drawing + * bug (DG); + * 12-Nov-2002 : Fixed null pointer exception for zero or negative values (DG); + * 07-Mar-2003 : Modified to pass pieIndex on to PieSectionEntity (DG); + * 21-Mar-2003 : Added workaround for bug id 620031 (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 29-Aug-2003 : Small changes for API updates in PiePlot class (DG); + * 02-Sep-2003 : Fixed bug where the 'no data' message is not displayed (DG); + * 08-Sep-2003 : Added internationalization via use of properties + * resourceBundle (RFE 690236) (AL); + * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); + * 20-Nov-2003 : Fixed bug 845289 (sides not showing) (DG); + * 25-Nov-2003 : Added patch (845095) to fix outline paint issues (DG); + * 10-Mar-2004 : Numerous changes to enhance labelling (DG); + * 31-Mar-2004 : Adjusted plot area when label generator is null (DG); + * 08-Apr-2004 : Added flag to PiePlot class to control the treatment of null + * values (DG); + * Added pieIndex to PieSectionEntity (DG); + * 15-Nov-2004 : Removed creation of default tool tip generator (DG); + * 16-Jun-2005 : Added default constructor (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 27-Sep-2006 : Updated draw() method for new lookup methods (DG); + * 22-Mar-2007 : Added equals() override (DG); + * 18-Jun-2007 : Added handling for simple label option (DG); + * 04-Oct-2007 : Added option to darken sides of plot - thanks to Alex Moots + * (see patch 1805262) (DG); + * 21-Nov-2007 : Changed default depth factor, fixed labelling bugs and added + * debug code - see debug flags in PiePlot class (DG); + * 20-Mar-2008 : Fixed bug 1920854 - multiple redraws of the section + * labels (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * 10-Jul-2009 : Added drop shaow support (DG); + * 10-Oct-2011 : Localization fix: bug #3353913 (MH); + * 18-Oct-2011 : Fix tooltip offset with shadow generator (DG); + * 11-Jun-2012 : Utilise new PaintAlpha class (patch 3204823 from DaveLaw) (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Polygon; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Arc2D; +import java.awt.geom.Area; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.entity.PieSectionEntity; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.labels.PieToolTipGenerator; +import org.jfree.chart.util.PaintAlpha; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.general.PieDataset; +import org.jfree.ui.RectangleInsets; + +/** + * A plot that displays data in the form of a 3D pie chart, using data from + * any class that implements the {@link PieDataset} interface. + *

+ * Although this class extends {@link PiePlot}, it does not currently support + * exploded sections. + */ +public class PiePlot3D extends PiePlot implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 3408984188945161432L; + + /** The factor of the depth of the pie from the plot height */ + private double depthFactor = 0.12; + + /** + * A flag that controls whether or not the sides of the pie chart + * are rendered using a darker colour. + * + * @since 1.0.7. + */ + private boolean darkerSides = false; // default preserves previous + // behaviour + + /** + * Creates a new instance with no dataset. + */ + public PiePlot3D() { + this(null); + } + + /** + * Creates a pie chart with a three dimensional effect using the specified + * dataset. + * + * @param dataset the dataset (null permitted). + */ + public PiePlot3D(PieDataset dataset) { + super(dataset); + setCircular(false, false); + } + + /** + * Returns the depth factor for the chart. + * + * @return The depth factor. + * + * @see #setDepthFactor(double) + */ + public double getDepthFactor() { + return this.depthFactor; + } + + /** + * Sets the pie depth as a percentage of the height of the plot area, and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param factor the depth factor (for example, 0.20 is twenty percent). + * + * @see #getDepthFactor() + */ + public void setDepthFactor(double factor) { + this.depthFactor = factor; + fireChangeEvent(); + } + + /** + * Returns a flag that controls whether or not the sides of the pie chart + * are rendered using a darker colour. + * + * @return A boolean. + * + * @see #setDarkerSides(boolean) + * + * @since 1.0.7 + */ + public boolean getDarkerSides() { + return this.darkerSides; + } + + /** + * Sets a flag that controls whether or not the sides of the pie chart + * are rendered using a darker colour, and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param darker true to darken the sides, false to use the default + * behaviour. + * + * @see #getDarkerSides() + * + * @since 1.0.7. + */ + public void setDarkerSides(boolean darker) { + this.darkerSides = darker; + fireChangeEvent(); + } + + /** + * Draws the plot on a Java 2D graphics device (such as the screen or a + * printer). This method is called by the + * {@link org.jfree.chart.JFreeChart} class, you don't normally need + * to call it yourself. + * + * @param g2 the graphics device. + * @param plotArea the area within which the plot should be drawn. + * @param anchor the anchor point. + * @param parentState the state from the parent plot, if there is one. + * @param info collects info about the drawing + * (null permitted). + */ + @Override + public void draw(Graphics2D g2, Rectangle2D plotArea, Point2D anchor, + PlotState parentState, PlotRenderingInfo info) { + + // adjust for insets... + RectangleInsets insets = getInsets(); + insets.trim(plotArea); + + Rectangle2D originalPlotArea = (Rectangle2D) plotArea.clone(); + if (info != null) { + info.setPlotArea(plotArea); + info.setDataArea(plotArea); + } + + drawBackground(g2, plotArea); + + Shape savedClip = g2.getClip(); + g2.clip(plotArea); + + Graphics2D savedG2 = g2; + BufferedImage dataImage = null; + if (getShadowGenerator() != null) { + dataImage = new BufferedImage((int) plotArea.getWidth(), + (int) plotArea.getHeight(), BufferedImage.TYPE_INT_ARGB); + g2 = dataImage.createGraphics(); + g2.translate(-plotArea.getX(), -plotArea.getY()); + g2.setRenderingHints(savedG2.getRenderingHints()); + originalPlotArea = (Rectangle2D) plotArea.clone(); + } + // adjust the plot area by the interior spacing value + double gapPercent = getInteriorGap(); + double labelPercent = 0.0; + if (getLabelGenerator() != null) { + labelPercent = getLabelGap() + getMaximumLabelWidth(); + } + double gapHorizontal = plotArea.getWidth() * (gapPercent + + labelPercent) * 2.0; + double gapVertical = plotArea.getHeight() * gapPercent * 2.0; + + if (DEBUG_DRAW_INTERIOR) { + double hGap = plotArea.getWidth() * getInteriorGap(); + double vGap = plotArea.getHeight() * getInteriorGap(); + double igx1 = plotArea.getX() + hGap; + double igx2 = plotArea.getMaxX() - hGap; + double igy1 = plotArea.getY() + vGap; + double igy2 = plotArea.getMaxY() - vGap; + g2.setPaint(Color.lightGray); + g2.draw(new Rectangle2D.Double(igx1, igy1, igx2 - igx1, + igy2 - igy1)); + } + + double linkX = plotArea.getX() + gapHorizontal / 2; + double linkY = plotArea.getY() + gapVertical / 2; + double linkW = plotArea.getWidth() - gapHorizontal; + double linkH = plotArea.getHeight() - gapVertical; + + // make the link area a square if the pie chart is to be circular... + if (isCircular()) { // is circular? + double min = Math.min(linkW, linkH) / 2; + linkX = (linkX + linkX + linkW) / 2 - min; + linkY = (linkY + linkY + linkH) / 2 - min; + linkW = 2 * min; + linkH = 2 * min; + } + + PiePlotState state = initialise(g2, plotArea, this, null, info); + + // the link area defines the dog leg points for the linking lines to + // the labels + Rectangle2D linkAreaXX = new Rectangle2D.Double(linkX, linkY, linkW, + linkH * (1 - this.depthFactor)); + state.setLinkArea(linkAreaXX); + + if (DEBUG_DRAW_LINK_AREA) { + g2.setPaint(Color.blue); + g2.draw(linkAreaXX); + g2.setPaint(Color.yellow); + g2.draw(new Ellipse2D.Double(linkAreaXX.getX(), linkAreaXX.getY(), + linkAreaXX.getWidth(), linkAreaXX.getHeight())); + } + + // the explode area defines the max circle/ellipse for the exploded pie + // sections. + // it is defined by shrinking the linkArea by the linkMargin factor. + double hh = linkW * getLabelLinkMargin(); + double vv = linkH * getLabelLinkMargin(); + Rectangle2D explodeArea = new Rectangle2D.Double(linkX + hh / 2.0, + linkY + vv / 2.0, linkW - hh, linkH - vv); + + state.setExplodedPieArea(explodeArea); + + // the pie area defines the circle/ellipse for regular pie sections. + // it is defined by shrinking the explodeArea by the explodeMargin + // factor. + double maximumExplodePercent = getMaximumExplodePercent(); + double percent = maximumExplodePercent / (1.0 + maximumExplodePercent); + + double h1 = explodeArea.getWidth() * percent; + double v1 = explodeArea.getHeight() * percent; + Rectangle2D pieArea = new Rectangle2D.Double(explodeArea.getX() + + h1 / 2.0, explodeArea.getY() + v1 / 2.0, + explodeArea.getWidth() - h1, explodeArea.getHeight() - v1); + + // the link area defines the dog-leg point for the linking lines to + // the labels + int depth = (int) (pieArea.getHeight() * this.depthFactor); + Rectangle2D linkArea = new Rectangle2D.Double(linkX, linkY, linkW, + linkH - depth); + state.setLinkArea(linkArea); + + state.setPieArea(pieArea); + state.setPieCenterX(pieArea.getCenterX()); + state.setPieCenterY(pieArea.getCenterY() - depth / 2.0); + state.setPieWRadius(pieArea.getWidth() / 2.0); + state.setPieHRadius((pieArea.getHeight() - depth) / 2.0); + + // get the data source - return if null; + PieDataset dataset = getDataset(); + if (DatasetUtilities.isEmptyOrNull(getDataset())) { + drawNoDataMessage(g2, plotArea); + g2.setClip(savedClip); + drawOutline(g2, plotArea); + return; + } + + // if too any elements + if (dataset.getKeys().size() > plotArea.getWidth()) { + String text = localizationResources.getString("Too_many_elements"); + Font sfont = new Font("dialog", Font.BOLD, 10); + g2.setFont(sfont); + FontMetrics fm = g2.getFontMetrics(sfont); + int stringWidth = fm.stringWidth(text); + + g2.drawString(text, (int) (plotArea.getX() + (plotArea.getWidth() + - stringWidth) / 2), (int) (plotArea.getY() + + (plotArea.getHeight() / 2))); + return; + } + // if we are drawing a perfect circle, we need to readjust the top left + // coordinates of the drawing area for the arcs to arrive at this + // effect. + if (isCircular()) { + double min = Math.min(plotArea.getWidth(), + plotArea.getHeight()) / 2; + plotArea = new Rectangle2D.Double(plotArea.getCenterX() - min, + plotArea.getCenterY() - min, 2 * min, 2 * min); + } + // get a list of keys... + List sectionKeys = dataset.getKeys(); + + if (sectionKeys.isEmpty()) { + return; + } + + // establish the coordinates of the top left corner of the drawing area + double arcX = pieArea.getX(); + double arcY = pieArea.getY(); + + //g2.clip(clipArea); + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + getForegroundAlpha())); + + double totalValue = DatasetUtilities.calculatePieDatasetTotal(dataset); + double runningTotal = 0; + if (depth < 0) { + return; // if depth is negative don't draw anything + } + + ArrayList arcList = new ArrayList(); + Arc2D.Double arc; + Paint paint; + Paint outlinePaint; + Stroke outlineStroke; + + Iterator iterator = sectionKeys.iterator(); + while (iterator.hasNext()) { + + Comparable currentKey = (Comparable) iterator.next(); + Number dataValue = dataset.getValue(currentKey); + if (dataValue == null) { + arcList.add(null); + continue; + } + double value = dataValue.doubleValue(); + if (value <= 0) { + arcList.add(null); + continue; + } + double startAngle = getStartAngle(); + double direction = getDirection().getFactor(); + double angle1 = startAngle + (direction * (runningTotal * 360)) + / totalValue; + double angle2 = startAngle + (direction * (runningTotal + value) + * 360) / totalValue; + if (Math.abs(angle2 - angle1) > getMinimumArcAngleToDraw()) { + arcList.add(new Arc2D.Double(arcX, arcY + depth, + pieArea.getWidth(), pieArea.getHeight() - depth, + angle1, angle2 - angle1, Arc2D.PIE)); + } + else { + arcList.add(null); + } + runningTotal += value; + } + + Shape oldClip = g2.getClip(); + + Ellipse2D top = new Ellipse2D.Double(pieArea.getX(), pieArea.getY(), + pieArea.getWidth(), pieArea.getHeight() - depth); + + Ellipse2D bottom = new Ellipse2D.Double(pieArea.getX(), pieArea.getY() + + depth, pieArea.getWidth(), pieArea.getHeight() - depth); + + Rectangle2D lower = new Rectangle2D.Double(top.getX(), + top.getCenterY(), pieArea.getWidth(), bottom.getMaxY() + - top.getCenterY()); + + Rectangle2D upper = new Rectangle2D.Double(pieArea.getX(), top.getY(), + pieArea.getWidth(), bottom.getCenterY() - top.getY()); + + Area a = new Area(top); + a.add(new Area(lower)); + Area b = new Area(bottom); + b.add(new Area(upper)); + Area pie = new Area(a); + pie.intersect(b); + + Area front = new Area(pie); + front.subtract(new Area(top)); + + Area back = new Area(pie); + back.subtract(new Area(bottom)); + + // draw the bottom circle + int[] xs; + int[] ys; + + int categoryCount = arcList.size(); + for (int categoryIndex = 0; categoryIndex < categoryCount; + categoryIndex++) { + arc = (Arc2D.Double) arcList.get(categoryIndex); + if (arc == null) { + continue; + } + Comparable key = getSectionKey(categoryIndex); + paint = lookupSectionPaint(key); + outlinePaint = lookupSectionOutlinePaint(key); + outlineStroke = lookupSectionOutlineStroke(key); + g2.setPaint(paint); + g2.fill(arc); + g2.setPaint(outlinePaint); + g2.setStroke(outlineStroke); + g2.draw(arc); + g2.setPaint(paint); + + Point2D p1 = arc.getStartPoint(); + + // draw the height + xs = new int[] {(int) arc.getCenterX(), (int) arc.getCenterX(), + (int) p1.getX(), (int) p1.getX()}; + ys = new int[] {(int) arc.getCenterY(), (int) arc.getCenterY() + - depth, (int) p1.getY() - depth, (int) p1.getY()}; + Polygon polygon = new Polygon(xs, ys, 4); + g2.setPaint(java.awt.Color.lightGray); + g2.fill(polygon); + g2.setPaint(outlinePaint); + g2.setStroke(outlineStroke); + g2.draw(polygon); + g2.setPaint(paint); + + } + + g2.setPaint(Color.gray); + g2.fill(back); + g2.fill(front); + + // cycle through once drawing only the sides at the back... + int cat = 0; + iterator = arcList.iterator(); + while (iterator.hasNext()) { + Arc2D segment = (Arc2D) iterator.next(); + if (segment != null) { + Comparable key = getSectionKey(cat); + paint = lookupSectionPaint(key); + outlinePaint = lookupSectionOutlinePaint(key); + outlineStroke = lookupSectionOutlineStroke(key); + drawSide(g2, pieArea, segment, front, back, paint, + outlinePaint, outlineStroke, false, true); + } + cat++; + } + + // cycle through again drawing only the sides at the front... + cat = 0; + iterator = arcList.iterator(); + while (iterator.hasNext()) { + Arc2D segment = (Arc2D) iterator.next(); + if (segment != null) { + Comparable key = getSectionKey(cat); + paint = lookupSectionPaint(key); + outlinePaint = lookupSectionOutlinePaint(key); + outlineStroke = lookupSectionOutlineStroke(key); + drawSide(g2, pieArea, segment, front, back, paint, + outlinePaint, outlineStroke, true, false); + } + cat++; + } + + g2.setClip(oldClip); + + // draw the sections at the top of the pie (and set up tooltips)... + Arc2D upperArc; + for (int sectionIndex = 0; sectionIndex < categoryCount; + sectionIndex++) { + arc = (Arc2D.Double) arcList.get(sectionIndex); + if (arc == null) { + continue; + } + upperArc = new Arc2D.Double(arcX, arcY, pieArea.getWidth(), + pieArea.getHeight() - depth, arc.getAngleStart(), + arc.getAngleExtent(), Arc2D.PIE); + + Comparable currentKey = (Comparable) sectionKeys.get(sectionIndex); + paint = lookupSectionPaint(currentKey, true); + outlinePaint = lookupSectionOutlinePaint(currentKey); + outlineStroke = lookupSectionOutlineStroke(currentKey); + g2.setPaint(paint); + g2.fill(upperArc); + g2.setStroke(outlineStroke); + g2.setPaint(outlinePaint); + g2.draw(upperArc); + + // add a tooltip for the section... + if (info != null) { + EntityCollection entities + = info.getOwner().getEntityCollection(); + if (entities != null) { + String tip = null; + PieToolTipGenerator tipster = getToolTipGenerator(); + if (tipster != null) { + // @mgs: using the method's return value was missing + tip = tipster.generateToolTip(dataset, currentKey); + } + String url = null; + if (getURLGenerator() != null) { + url = getURLGenerator().generateURL(dataset, currentKey, + getPieIndex()); + } + PieSectionEntity entity = new PieSectionEntity( + upperArc, dataset, getPieIndex(), sectionIndex, + currentKey, tip, url); + entities.add(entity); + } + } + } + + List keys = dataset.getKeys(); + Rectangle2D adjustedPlotArea = new Rectangle2D.Double( + originalPlotArea.getX(), originalPlotArea.getY(), + originalPlotArea.getWidth(), originalPlotArea.getHeight() + - depth); + if (getSimpleLabels()) { + drawSimpleLabels(g2, keys, totalValue, adjustedPlotArea, + linkArea, state); + } + else { + drawLabels(g2, keys, totalValue, adjustedPlotArea, linkArea, + state); + } + + if (getShadowGenerator() != null) { + BufferedImage shadowImage + = getShadowGenerator().createDropShadow(dataImage); + g2 = savedG2; + g2.drawImage(shadowImage, (int) plotArea.getX() + + getShadowGenerator().calculateOffsetX(), + (int) plotArea.getY() + + getShadowGenerator().calculateOffsetY(), null); + g2.drawImage(dataImage, (int) plotArea.getX(), + (int) plotArea.getY(), null); + } + + g2.setClip(savedClip); + g2.setComposite(originalComposite); + drawOutline(g2, originalPlotArea); + + } + + /** + * Draws the side of a pie section. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param arc the arc. + * @param front the front of the pie. + * @param back the back of the pie. + * @param paint the color. + * @param outlinePaint the outline paint. + * @param outlineStroke the outline stroke. + * @param drawFront draw the front? + * @param drawBack draw the back? + */ + protected void drawSide(Graphics2D g2, + Rectangle2D plotArea, + Arc2D arc, + Area front, + Area back, + Paint paint, + Paint outlinePaint, + Stroke outlineStroke, + boolean drawFront, + boolean drawBack) { + + if (getDarkerSides()) { + paint = PaintAlpha.darker(paint); + } + + double start = arc.getAngleStart(); + double extent = arc.getAngleExtent(); + double end = start + extent; + + g2.setStroke(outlineStroke); + + // for CLOCKWISE charts, the extent will be negative... + if (extent < 0.0) { + + if (isAngleAtFront(start)) { // start at front + + if (!isAngleAtBack(end)) { + + if (extent > -180.0) { // the segment is entirely at the + // front of the chart + if (drawFront) { + Area side = new Area(new Rectangle2D.Double( + arc.getEndPoint().getX(), plotArea.getY(), + arc.getStartPoint().getX() + - arc.getEndPoint().getX(), + plotArea.getHeight())); + side.intersect(front); + g2.setPaint(paint); + g2.fill(side); + g2.setPaint(outlinePaint); + g2.draw(side); + } + } + else { // the segment starts at the front, and wraps all + // the way around + // the back and finishes at the front again + Area side1 = new Area(new Rectangle2D.Double( + plotArea.getX(), plotArea.getY(), + arc.getStartPoint().getX() - plotArea.getX(), + plotArea.getHeight())); + side1.intersect(front); + + Area side2 = new Area(new Rectangle2D.Double( + arc.getEndPoint().getX(), plotArea.getY(), + plotArea.getMaxX() - arc.getEndPoint().getX(), + plotArea.getHeight())); + + side2.intersect(front); + g2.setPaint(paint); + if (drawFront) { + g2.fill(side1); + g2.fill(side2); + } + + if (drawBack) { + g2.fill(back); + } + + g2.setPaint(outlinePaint); + if (drawFront) { + g2.draw(side1); + g2.draw(side2); + } + + if (drawBack) { + g2.draw(back); + } + + } + } + else { // starts at the front, finishes at the back (going + // around the left side) + + if (drawBack) { + Area side2 = new Area(new Rectangle2D.Double( + plotArea.getX(), plotArea.getY(), + arc.getEndPoint().getX() - plotArea.getX(), + plotArea.getHeight())); + side2.intersect(back); + g2.setPaint(paint); + g2.fill(side2); + g2.setPaint(outlinePaint); + g2.draw(side2); + } + + if (drawFront) { + Area side1 = new Area(new Rectangle2D.Double( + plotArea.getX(), plotArea.getY(), + arc.getStartPoint().getX() - plotArea.getX(), + plotArea.getHeight())); + side1.intersect(front); + g2.setPaint(paint); + g2.fill(side1); + g2.setPaint(outlinePaint); + g2.draw(side1); + } + } + } + else { // the segment starts at the back (still extending + // CLOCKWISE) + + if (!isAngleAtFront(end)) { + if (extent > -180.0) { // whole segment stays at the back + if (drawBack) { + Area side = new Area(new Rectangle2D.Double( + arc.getStartPoint().getX(), plotArea.getY(), + arc.getEndPoint().getX() + - arc.getStartPoint().getX(), + plotArea.getHeight())); + side.intersect(back); + g2.setPaint(paint); + g2.fill(side); + g2.setPaint(outlinePaint); + g2.draw(side); + } + } + else { // starts at the back, wraps around front, and + // finishes at back again + Area side1 = new Area(new Rectangle2D.Double( + arc.getStartPoint().getX(), plotArea.getY(), + plotArea.getMaxX() - arc.getStartPoint().getX(), + plotArea.getHeight())); + side1.intersect(back); + + Area side2 = new Area(new Rectangle2D.Double( + plotArea.getX(), plotArea.getY(), + arc.getEndPoint().getX() - plotArea.getX(), + plotArea.getHeight())); + + side2.intersect(back); + + g2.setPaint(paint); + if (drawBack) { + g2.fill(side1); + g2.fill(side2); + } + + if (drawFront) { + g2.fill(front); + } + + g2.setPaint(outlinePaint); + if (drawBack) { + g2.draw(side1); + g2.draw(side2); + } + + if (drawFront) { + g2.draw(front); + } + + } + } + else { // starts at back, finishes at front (CLOCKWISE) + + if (drawBack) { + Area side1 = new Area(new Rectangle2D.Double( + arc.getStartPoint().getX(), plotArea.getY(), + plotArea.getMaxX() - arc.getStartPoint().getX(), + plotArea.getHeight())); + side1.intersect(back); + g2.setPaint(paint); + g2.fill(side1); + g2.setPaint(outlinePaint); + g2.draw(side1); + } + + if (drawFront) { + Area side2 = new Area(new Rectangle2D.Double( + arc.getEndPoint().getX(), plotArea.getY(), + plotArea.getMaxX() - arc.getEndPoint().getX(), + plotArea.getHeight())); + side2.intersect(front); + g2.setPaint(paint); + g2.fill(side2); + g2.setPaint(outlinePaint); + g2.draw(side2); + } + + } + } + } + else if (extent > 0.0) { // the pie sections are arranged ANTICLOCKWISE + + if (isAngleAtFront(start)) { // segment starts at the front + + if (!isAngleAtBack(end)) { // and finishes at the front + + if (extent < 180.0) { // segment only occupies the front + if (drawFront) { + Area side = new Area(new Rectangle2D.Double( + arc.getStartPoint().getX(), plotArea.getY(), + arc.getEndPoint().getX() + - arc.getStartPoint().getX(), + plotArea.getHeight())); + side.intersect(front); + g2.setPaint(paint); + g2.fill(side); + g2.setPaint(outlinePaint); + g2.draw(side); + } + } + else { // segments wraps right around the back... + Area side1 = new Area(new Rectangle2D.Double( + arc.getStartPoint().getX(), plotArea.getY(), + plotArea.getMaxX() - arc.getStartPoint().getX(), + plotArea.getHeight())); + side1.intersect(front); + + Area side2 = new Area(new Rectangle2D.Double( + plotArea.getX(), plotArea.getY(), + arc.getEndPoint().getX() - plotArea.getX(), + plotArea.getHeight())); + side2.intersect(front); + + g2.setPaint(paint); + if (drawFront) { + g2.fill(side1); + g2.fill(side2); + } + + if (drawBack) { + g2.fill(back); + } + + g2.setPaint(outlinePaint); + if (drawFront) { + g2.draw(side1); + g2.draw(side2); + } + + if (drawBack) { + g2.draw(back); + } + + } + } + else { // segments starts at front and finishes at back... + if (drawBack) { + Area side2 = new Area(new Rectangle2D.Double( + arc.getEndPoint().getX(), plotArea.getY(), + plotArea.getMaxX() - arc.getEndPoint().getX(), + plotArea.getHeight())); + side2.intersect(back); + g2.setPaint(paint); + g2.fill(side2); + g2.setPaint(outlinePaint); + g2.draw(side2); + } + + if (drawFront) { + Area side1 = new Area(new Rectangle2D.Double( + arc.getStartPoint().getX(), plotArea.getY(), + plotArea.getMaxX() - arc.getStartPoint().getX(), + plotArea.getHeight())); + side1.intersect(front); + g2.setPaint(paint); + g2.fill(side1); + g2.setPaint(outlinePaint); + g2.draw(side1); + } + } + } + else { // segment starts at back + + if (!isAngleAtFront(end)) { + if (extent < 180.0) { // and finishes at back + if (drawBack) { + Area side = new Area(new Rectangle2D.Double( + arc.getEndPoint().getX(), plotArea.getY(), + arc.getStartPoint().getX() + - arc.getEndPoint().getX(), + plotArea.getHeight())); + side.intersect(back); + g2.setPaint(paint); + g2.fill(side); + g2.setPaint(outlinePaint); + g2.draw(side); + } + } + else { // starts at back and wraps right around to the + // back again + Area side1 = new Area(new Rectangle2D.Double( + arc.getStartPoint().getX(), plotArea.getY(), + plotArea.getX() - arc.getStartPoint().getX(), + plotArea.getHeight())); + side1.intersect(back); + + Area side2 = new Area(new Rectangle2D.Double( + arc.getEndPoint().getX(), plotArea.getY(), + plotArea.getMaxX() - arc.getEndPoint().getX(), + plotArea.getHeight())); + side2.intersect(back); + + g2.setPaint(paint); + if (drawBack) { + g2.fill(side1); + g2.fill(side2); + } + + if (drawFront) { + g2.fill(front); + } + + g2.setPaint(outlinePaint); + if (drawBack) { + g2.draw(side1); + g2.draw(side2); + } + + if (drawFront) { + g2.draw(front); + } + + } + } + else { // starts at the back and finishes at the front + // (wrapping the left side) + if (drawBack) { + Area side1 = new Area(new Rectangle2D.Double( + plotArea.getX(), plotArea.getY(), + arc.getStartPoint().getX() - plotArea.getX(), + plotArea.getHeight())); + side1.intersect(back); + g2.setPaint(paint); + g2.fill(side1); + g2.setPaint(outlinePaint); + g2.draw(side1); + } + + if (drawFront) { + Area side2 = new Area(new Rectangle2D.Double( + plotArea.getX(), plotArea.getY(), + arc.getEndPoint().getX() - plotArea.getX(), + plotArea.getHeight())); + side2.intersect(front); + g2.setPaint(paint); + g2.fill(side2); + g2.setPaint(outlinePaint); + g2.draw(side2); + } + } + } + + } + + } + + /** + * Returns a short string describing the type of plot. + * + * @return Pie 3D Plot. + */ + @Override + public String getPlotType() { + return localizationResources.getString("Pie_3D_Plot"); + } + + /** + * A utility method that returns true if the angle represents a point at + * the front of the 3D pie chart. 0 - 180 degrees is the back, 180 - 360 + * is the front. + * + * @param angle the angle. + * + * @return A boolean. + */ + private boolean isAngleAtFront(double angle) { + return (Math.sin(Math.toRadians(angle)) < 0.0); + } + + /** + * A utility method that returns true if the angle represents a point at + * the back of the 3D pie chart. 0 - 180 degrees is the back, 180 - 360 + * is the front. + * + * @param angle the angle. + * + * @return true if the angle is at the back of the pie. + */ + private boolean isAngleAtBack(double angle) { + return (Math.sin(Math.toRadians(angle)) > 0.0); + } + + /** + * Tests this plot for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PiePlot3D)) { + return false; + } + PiePlot3D that = (PiePlot3D) obj; + if (this.depthFactor != that.depthFactor) { + return false; + } + if (this.darkerSides != that.darkerSides) { + return false; + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PiePlotState.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PiePlotState.java new file mode 100755 index 0000000..4213a00 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PiePlotState.java @@ -0,0 +1,279 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * PiePlotState.java + * ----------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 06-Mar-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.renderer.RendererState; + +/** + * A renderer state. + */ +public class PiePlotState extends RendererState { + + /** The number of passes required by the renderer. */ + private int passesRequired; + + /** The total of the values in the dataset. */ + private double total; + + /** The latest angle. */ + private double latestAngle; + + /** The exploded pie area. */ + private Rectangle2D explodedPieArea; + + /** The pie area. */ + private Rectangle2D pieArea; + + /** The center of the pie in Java 2D coordinates. */ + private double pieCenterX; + + /** The center of the pie in Java 2D coordinates. */ + private double pieCenterY; + + /** The vertical pie radius. */ + private double pieHRadius; + + /** The horizontal pie radius. */ + private double pieWRadius; + + /** The link area. */ + private Rectangle2D linkArea; + + /** + * Creates a new object for recording temporary state information for a + * renderer. + * + * @param info the plot rendering info. + */ + public PiePlotState(PlotRenderingInfo info) { + super(info); + this.passesRequired = 1; + this.total = 0.0; + } + + /** + * Returns the number of passes required by the renderer. + * + * @return The number of passes. + */ + public int getPassesRequired() { + return this.passesRequired; + } + + /** + * Sets the number of passes required by the renderer. + * + * @param passes the passes. + */ + public void setPassesRequired(int passes) { + this.passesRequired = passes; + } + + /** + * Returns the total of the values in the dataset. + * + * @return The total. + */ + public double getTotal() { + return this.total; + } + + /** + * Sets the total. + * + * @param total the total. + */ + public void setTotal(double total) { + this.total = total; + } + + /** + * Returns the latest angle. + * + * @return The latest angle. + */ + public double getLatestAngle() { + return this.latestAngle; + } + + /** + * Sets the latest angle. + * + * @param angle the angle. + */ + public void setLatestAngle(double angle) { + this.latestAngle = angle; + } + + /** + * Returns the pie area. + * + * @return The pie area. + */ + public Rectangle2D getPieArea() { + return this.pieArea; + } + + /** + * Sets the pie area. + * + * @param area the area. + */ + public void setPieArea(Rectangle2D area) { + this.pieArea = area; + } + + /** + * Returns the exploded pie area. + * + * @return The exploded pie area. + */ + public Rectangle2D getExplodedPieArea() { + return this.explodedPieArea; + } + + /** + * Sets the exploded pie area. + * + * @param area the area. + */ + public void setExplodedPieArea(Rectangle2D area) { + this.explodedPieArea = area; + } + + /** + * Returns the x-coordinate of the center of the pie chart. + * + * @return The x-coordinate (in Java2D space). + */ + public double getPieCenterX() { + return this.pieCenterX; + } + + /** + * Sets the x-coordinate of the center of the pie chart. + * + * @param x the x-coordinate (in Java2D space). + */ + public void setPieCenterX(double x) { + this.pieCenterX = x; + } + + /** + * Returns the y-coordinate (in Java2D space) of the center of the pie + * chart. For the {@link PiePlot3D} class, we derive this from the top of + * the pie. + * + * @return The y-coordinate (in Java2D space). + */ + public double getPieCenterY() { + return this.pieCenterY; + } + + /** + * Sets the y-coordinate of the center of the pie chart. This method is + * used by the plot and typically is not called directly by applications. + * + * @param y the y-coordinate (in Java2D space). + */ + public void setPieCenterY(double y) { + this.pieCenterY = y; + } + + /** + * Returns the link area. This defines the "dog-leg" point for the label + * linking lines. + * + * @return The link area. + */ + public Rectangle2D getLinkArea() { + return this.linkArea; + } + + /** + * Sets the label link area. This defines the "dog-leg" point for the + * label linking lines. + * + * @param area the area. + */ + public void setLinkArea(Rectangle2D area) { + this.linkArea = area; + } + + /** + * Returns the vertical pie radius. + * + * @return The radius. + */ + public double getPieHRadius() { + return this.pieHRadius; + } + + /** + * Sets the vertical pie radius. + * + * @param radius the radius. + */ + public void setPieHRadius(double radius) { + this.pieHRadius = radius; + } + + /** + * Returns the horizontal pie radius. + * + * @return The radius. + */ + public double getPieWRadius() { + return this.pieWRadius; + } + + /** + * Sets the horizontal pie radius. + * + * @param radius the radius. + */ + public void setPieWRadius(double radius) { + this.pieWRadius = radius; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Plot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Plot.java new file mode 100755 index 0000000..5022eea --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Plot.java @@ -0,0 +1,1540 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------- + * Plot.java + * --------- + * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Sylvain Vieujot; + * Jeremy Bowman; + * Andreas Schneider; + * Gideon Krause; + * Nicolas Brodu; + * Michal Krause; + * Richard West, Advanced Micro Devices, Inc.; + * Peter Kolb - patches 2603321, 2809117; + * + * Changes + * ------- + * 21-Jun-2001 : Removed redundant JFreeChart parameter from constructors (DG); + * 18-Sep-2001 : Updated header info and fixed DOS encoding problem (DG); + * 19-Oct-2001 : Moved series paint and stroke methods from JFreeChart + * class (DG); + * 23-Oct-2001 : Created renderer for LinePlot class (DG); + * 07-Nov-2001 : Changed type names for ChartChangeEvent (DG); + * Tidied up some Javadoc comments (DG); + * 13-Nov-2001 : Changes to allow for null axes on plots such as PiePlot (DG); + * Added plot/axis compatibility checks (DG); + * 12-Dec-2001 : Changed constructors to protected, and removed unnecessary + * 'throws' clauses (DG); + * 13-Dec-2001 : Added tooltips (DG); + * 22-Jan-2002 : Added handleClick() method, as part of implementation for + * crosshairs (DG); + * Moved tooltips reference into ChartInfo class (DG); + * 23-Jan-2002 : Added test for null axes in chartChanged() method, thanks + * to Barry Evans for the bug report (number 506979 on + * SourceForge) (DG); + * Added a zoom() method (DG); + * 05-Feb-2002 : Updated setBackgroundPaint(), setOutlineStroke() and + * setOutlinePaint() to better handle null values, as suggested + * by Sylvain Vieujot (DG); + * 06-Feb-2002 : Added background image, plus alpha transparency for background + * and foreground (DG); + * 06-Mar-2002 : Added AxisConstants interface (DG); + * 26-Mar-2002 : Changed zoom method from empty to abstract (DG); + * 23-Apr-2002 : Moved dataset from JFreeChart class (DG); + * 11-May-2002 : Added ShapeFactory interface for getShape() methods, + * contributed by Jeremy Bowman (DG); + * 28-May-2002 : Fixed bug in setSeriesPaint(int, Paint) for subplots (AS); + * 25-Jun-2002 : Removed redundant imports (DG); + * 30-Jul-2002 : Added 'no data' message for charts with null or empty + * datasets (DG); + * 21-Aug-2002 : Added code to extend series array if necessary (refer to + * SourceForge bug id 594547 for details) (DG); + * 17-Sep-2002 : Fixed bug in getSeriesOutlineStroke() method, reported by + * Andreas Schroeder (DG); + * 23-Sep-2002 : Added getLegendItems() abstract method (DG); + * 24-Sep-2002 : Removed firstSeriesIndex, subplots now use their own paint + * settings, there is a new mechanism for the legend to collect + * the legend items (DG); + * 27-Sep-2002 : Added dataset group (DG); + * 14-Oct-2002 : Moved listener storage into EventListenerList. Changed some + * abstract methods to empty implementations (DG); + * 28-Oct-2002 : Added a getBackgroundImage() method (DG); + * 21-Nov-2002 : Added a plot index for identifying subplots in combined and + * overlaid charts (DG); + * 22-Nov-2002 : Changed all attributes from 'protected' to 'private'. Added + * dataAreaRatio attribute from David M O'Donnell's code (DG); + * 09-Jan-2003 : Integrated fix for plot border contributed by Gideon + * Krause (DG); + * 17-Jan-2003 : Moved to com.jrefinery.chart.plot (DG); + * 23-Jan-2003 : Removed one constructor (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 14-Jul-2003 : Moved the dataset and secondaryDataset attributes to the + * CategoryPlot and XYPlot classes (DG); + * 21-Jul-2003 : Moved DrawingSupplier from CategoryPlot and XYPlot up to this + * class (DG); + * 20-Aug-2003 : Implemented Cloneable (DG); + * 11-Sep-2003 : Listeners and clone (NB); + * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); + * 03-Dec-2003 : Modified draw method to accept anchor (DG); + * 12-Mar-2004 : Fixed clipping bug in drawNoDataMessage() method (DG); + * 07-Apr-2004 : Modified string bounds calculation (DG); + * 04-Nov-2004 : Added default shapes for legend items (DG); + * 25-Nov-2004 : Some changes to the clone() method implementation (DG); + * 23-Feb-2005 : Implemented new LegendItemSource interface (and also + * PublicCloneable) (DG); + * 21-Apr-2005 : Replaced Insets with RectangleInsets (DG); + * 05-May-2005 : Removed unused draw() method (DG); + * 06-Jun-2005 : Fixed bugs in equals() method (DG); + * 01-Sep-2005 : Moved dataAreaRatio from here to ContourPlot (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 30-Jun-2006 : Added background image alpha - see bug report 1514904 (DG); + * 05-Sep-2006 : Implemented the MarkerChangeListener interface (DG); + * 11-Jan-2007 : Added some argument checks, event notifications, and many + * API doc updates (DG); + * 03-Apr-2007 : Made drawBackgroundImage() public (DG); + * 07-Jun-2007 : Added new fillBackground() method to handle GradientPaint + * taking into account orientation (DG); + * 25-Mar-2008 : Added fireChangeEvent() method - see patch 1914411 (DG); + * 15-Aug-2008 : Added setDrawingSupplier() method with notify flag (DG); + * 13-Jan-2009 : Added notify flag (DG); + * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); + * 24-Jun-2009 : Implemented AnnotationChangeListener (see patch 2809117 by + * PK) (DG); + * 13-Jul-2009 : Plot background image should be clipped if necessary (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.AlphaComposite; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Ellipse2D; +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 javax.swing.event.EventListenerList; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.LegendItemSource; +import org.jfree.chart.annotations.Annotation; +import org.jfree.chart.axis.AxisLocation; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.entity.PlotEntity; +import org.jfree.chart.event.AnnotationChangeEvent; +import org.jfree.chart.event.AnnotationChangeListener; +import org.jfree.chart.event.AxisChangeEvent; +import org.jfree.chart.event.AxisChangeListener; +import org.jfree.chart.event.ChartChangeEventType; +import org.jfree.chart.event.MarkerChangeEvent; +import org.jfree.chart.event.MarkerChangeListener; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.event.PlotChangeListener; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetChangeListener; +import org.jfree.data.general.DatasetGroup; +import org.jfree.io.SerialUtilities; +import org.jfree.text.G2TextMeasurer; +import org.jfree.text.TextBlock; +import org.jfree.text.TextBlockAnchor; +import org.jfree.text.TextUtilities; +import org.jfree.ui.Align; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * The base class for all plots in JFreeChart. The {@link JFreeChart} class + * delegates the drawing of axes and data to the plot. This base class + * provides facilities common to most plot types. + */ +public abstract class Plot implements AxisChangeListener, + DatasetChangeListener, AnnotationChangeListener, MarkerChangeListener, + LegendItemSource, PublicCloneable, Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -8831571430103671324L; + + /** Useful constant representing zero. */ + public static final Number ZERO = new Integer(0); + + /** The default insets. */ + public static final RectangleInsets DEFAULT_INSETS + = new RectangleInsets(4.0, 8.0, 4.0, 8.0); + + /** The default outline stroke. */ + public static final Stroke DEFAULT_OUTLINE_STROKE = new BasicStroke(0.5f, + BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND); + + /** The default outline color. */ + public static final Paint DEFAULT_OUTLINE_PAINT = Color.gray; + + /** The default foreground alpha transparency. */ + public static final float DEFAULT_FOREGROUND_ALPHA = 1.0f; + + /** The default background alpha transparency. */ + public static final float DEFAULT_BACKGROUND_ALPHA = 1.0f; + + /** The default background color. */ + public static final Paint DEFAULT_BACKGROUND_PAINT = Color.white; + + /** The minimum width at which the plot should be drawn. */ + public static final int MINIMUM_WIDTH_TO_DRAW = 10; + + /** The minimum height at which the plot should be drawn. */ + public static final int MINIMUM_HEIGHT_TO_DRAW = 10; + + /** A default box shape for legend items. */ + public static final Shape DEFAULT_LEGEND_ITEM_BOX + = new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0); + + /** A default circle shape for legend items. */ + public static final Shape DEFAULT_LEGEND_ITEM_CIRCLE + = new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0); + + /** The parent plot (null if this is the root plot). */ + private Plot parent; + + /** The dataset group (to be used for thread synchronisation). */ + private DatasetGroup datasetGroup; + + /** The message to display if no data is available. */ + private String noDataMessage; + + /** The font used to display the 'no data' message. */ + private Font noDataMessageFont; + + /** The paint used to draw the 'no data' message. */ + private transient Paint noDataMessagePaint; + + /** Amount of blank space around the plot area. */ + private RectangleInsets insets; + + /** + * A flag that controls whether or not the plot outline is drawn. + * + * @since 1.0.6 + */ + private boolean outlineVisible; + + /** The Stroke used to draw an outline around the plot. */ + private transient Stroke outlineStroke; + + /** The Paint used to draw an outline around the plot. */ + private transient Paint outlinePaint; + + /** An optional color used to fill the plot background. */ + private transient Paint backgroundPaint; + + /** An optional image for the plot background. */ + private transient Image backgroundImage; // not currently serialized + + /** The alignment for the background image. */ + private int backgroundImageAlignment = Align.FIT; + + /** The alpha value used to draw the background image. */ + private float backgroundImageAlpha = 0.5f; + + /** The alpha-transparency for the plot. */ + private float foregroundAlpha; + + /** The alpha transparency for the background paint. */ + private float backgroundAlpha; + + /** The drawing supplier. */ + private DrawingSupplier drawingSupplier; + + /** Storage for registered change listeners. */ + private transient EventListenerList listenerList; + + /** + * A flag that controls whether or not the plot will notify listeners + * of changes (defaults to true, but sometimes it is useful to disable + * this). + * + * @since 1.0.13 + */ + private boolean notify; + + /** + * Creates a new plot. + */ + protected Plot() { + + this.parent = null; + this.insets = DEFAULT_INSETS; + this.backgroundPaint = DEFAULT_BACKGROUND_PAINT; + this.backgroundAlpha = DEFAULT_BACKGROUND_ALPHA; + this.backgroundImage = null; + this.outlineVisible = true; + this.outlineStroke = DEFAULT_OUTLINE_STROKE; + this.outlinePaint = DEFAULT_OUTLINE_PAINT; + this.foregroundAlpha = DEFAULT_FOREGROUND_ALPHA; + + this.noDataMessage = null; + this.noDataMessageFont = new Font("SansSerif", Font.PLAIN, 12); + this.noDataMessagePaint = Color.black; + + this.drawingSupplier = new DefaultDrawingSupplier(); + + this.notify = true; + this.listenerList = new EventListenerList(); + + } + + /** + * Returns the dataset group for the plot (not currently used). + * + * @return The dataset group. + * + * @see #setDatasetGroup(DatasetGroup) + */ + public DatasetGroup getDatasetGroup() { + return this.datasetGroup; + } + + /** + * Sets the dataset group (not currently used). + * + * @param group the dataset group (null permitted). + * + * @see #getDatasetGroup() + */ + protected void setDatasetGroup(DatasetGroup group) { + this.datasetGroup = group; + } + + /** + * Returns the string that is displayed when the dataset is empty or + * null. + * + * @return The 'no data' message (null possible). + * + * @see #setNoDataMessage(String) + * @see #getNoDataMessageFont() + * @see #getNoDataMessagePaint() + */ + public String getNoDataMessage() { + return this.noDataMessage; + } + + /** + * Sets the message that is displayed when the dataset is empty or + * null, and sends a {@link PlotChangeEvent} to all registered + * listeners. + * + * @param message the message (null permitted). + * + * @see #getNoDataMessage() + */ + public void setNoDataMessage(String message) { + this.noDataMessage = message; + fireChangeEvent(); + } + + /** + * Returns the font used to display the 'no data' message. + * + * @return The font (never null). + * + * @see #setNoDataMessageFont(Font) + * @see #getNoDataMessage() + */ + public Font getNoDataMessageFont() { + return this.noDataMessageFont; + } + + /** + * Sets the font used to display the 'no data' message and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getNoDataMessageFont() + */ + public void setNoDataMessageFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.noDataMessageFont = font; + fireChangeEvent(); + } + + /** + * Returns the paint used to display the 'no data' message. + * + * @return The paint (never null). + * + * @see #setNoDataMessagePaint(Paint) + * @see #getNoDataMessage() + */ + public Paint getNoDataMessagePaint() { + return this.noDataMessagePaint; + } + + /** + * Sets the paint used to display the 'no data' message and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getNoDataMessagePaint() + */ + public void setNoDataMessagePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.noDataMessagePaint = paint; + fireChangeEvent(); + } + + /** + * Returns a short string describing the plot type. + *

+ * Note: this gets used in the chart property editing user interface, + * but there needs to be a better mechanism for identifying the plot type. + * + * @return A short string describing the plot type (never + * null). + */ + public abstract String getPlotType(); + + /** + * Returns the parent plot (or null if this plot is not part + * of a combined plot). + * + * @return The parent plot. + * + * @see #setParent(Plot) + * @see #getRootPlot() + */ + public Plot getParent() { + return this.parent; + } + + /** + * Sets the parent plot. This method is intended for internal use, you + * shouldn't need to call it directly. + * + * @param parent the parent plot (null permitted). + * + * @see #getParent() + */ + public void setParent(Plot parent) { + this.parent = parent; + } + + /** + * Returns the root plot. + * + * @return The root plot. + * + * @see #getParent() + */ + public Plot getRootPlot() { + + Plot p = getParent(); + if (p == null) { + return this; + } + return p.getRootPlot(); + + } + + /** + * Returns true if this plot is part of a combined plot + * structure (that is, {@link #getParent()} returns a non-null + * value), and false otherwise. + * + * @return true if this plot is part of a combined plot + * structure. + * + * @see #getParent() + */ + public boolean isSubplot() { + return (getParent() != null); + } + + /** + * Returns the insets for the plot area. + * + * @return The insets (never null). + * + * @see #setInsets(RectangleInsets) + */ + public RectangleInsets getInsets() { + return this.insets; + } + + /** + * Sets the insets for the plot and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param insets the new insets (null not permitted). + * + * @see #getInsets() + * @see #setInsets(RectangleInsets, boolean) + */ + public void setInsets(RectangleInsets insets) { + setInsets(insets, true); + } + + /** + * Sets the insets for the plot and, if requested, and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param insets the new insets (null not permitted). + * @param notify a flag that controls whether the registered listeners are + * notified. + * + * @see #getInsets() + * @see #setInsets(RectangleInsets) + */ + public void setInsets(RectangleInsets insets, boolean notify) { + ParamChecks.nullNotPermitted(insets, "insets"); + if (!this.insets.equals(insets)) { + this.insets = insets; + if (notify) { + fireChangeEvent(); + } + } + + } + + /** + * Returns the background color of the plot area. + * + * @return The paint (possibly null). + * + * @see #setBackgroundPaint(Paint) + */ + public Paint getBackgroundPaint() { + return this.backgroundPaint; + } + + /** + * Sets the background color of the plot area and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @see #getBackgroundPaint() + */ + public void setBackgroundPaint(Paint paint) { + + if (paint == null) { + if (this.backgroundPaint != null) { + this.backgroundPaint = null; + fireChangeEvent(); + } + } + else { + if (this.backgroundPaint != null) { + if (this.backgroundPaint.equals(paint)) { + return; // nothing to do + } + } + this.backgroundPaint = paint; + fireChangeEvent(); + } + + } + + /** + * Returns the alpha transparency of the plot area background. + * + * @return The alpha transparency. + * + * @see #setBackgroundAlpha(float) + */ + public float getBackgroundAlpha() { + return this.backgroundAlpha; + } + + /** + * Sets the alpha transparency of the plot area background, and notifies + * registered listeners that the plot has been modified. + * + * @param alpha the new alpha value (in the range 0.0f to 1.0f). + * + * @see #getBackgroundAlpha() + */ + public void setBackgroundAlpha(float alpha) { + if (this.backgroundAlpha != alpha) { + this.backgroundAlpha = alpha; + fireChangeEvent(); + } + } + + /** + * Returns the drawing supplier for the plot. + * + * @return The drawing supplier (possibly null). + * + * @see #setDrawingSupplier(DrawingSupplier) + */ + public DrawingSupplier getDrawingSupplier() { + DrawingSupplier result; + Plot p = getParent(); + if (p != null) { + result = p.getDrawingSupplier(); + } + else { + result = this.drawingSupplier; + } + return result; + } + + /** + * Sets the drawing supplier for the plot and sends a + * {@link PlotChangeEvent} to all registered listeners. The drawing + * supplier is responsible for supplying a limitless (possibly repeating) + * sequence of Paint, Stroke and + * Shape objects that the plot's renderer(s) can use to + * populate its (their) tables. + * + * @param supplier the new supplier. + * + * @see #getDrawingSupplier() + */ + public void setDrawingSupplier(DrawingSupplier supplier) { + this.drawingSupplier = supplier; + fireChangeEvent(); + } + + /** + * Sets the drawing supplier for the plot and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. The drawing + * supplier is responsible for supplying a limitless (possibly repeating) + * sequence of Paint, Stroke and + * Shape objects that the plot's renderer(s) can use to + * populate its (their) tables. + * + * @param supplier the new supplier. + * @param notify notify listeners? + * + * @see #getDrawingSupplier() + * + * @since 1.0.11 + */ + public void setDrawingSupplier(DrawingSupplier supplier, boolean notify) { + this.drawingSupplier = supplier; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the background image that is used to fill the plot's background + * area. + * + * @return The image (possibly null). + * + * @see #setBackgroundImage(Image) + */ + public Image getBackgroundImage() { + return this.backgroundImage; + } + + /** + * Sets the background image for the plot and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param image the image (null permitted). + * + * @see #getBackgroundImage() + */ + public void setBackgroundImage(Image image) { + this.backgroundImage = image; + fireChangeEvent(); + } + + /** + * Returns the background image alignment. Alignment constants are defined + * in the org.jfree.ui.Align class in the JCommon class + * library. + * + * @return The alignment. + * + * @see #setBackgroundImageAlignment(int) + */ + public int getBackgroundImageAlignment() { + return this.backgroundImageAlignment; + } + + /** + * Sets the alignment for the background image and sends a + * {@link PlotChangeEvent} to all registered listeners. Alignment options + * are defined by the {@link org.jfree.ui.Align} class in the JCommon + * class library. + * + * @param alignment the alignment. + * + * @see #getBackgroundImageAlignment() + */ + public void setBackgroundImageAlignment(int alignment) { + if (this.backgroundImageAlignment != alignment) { + this.backgroundImageAlignment = alignment; + fireChangeEvent(); + } + } + + /** + * Returns the alpha transparency used to draw the background image. This + * is a value in the range 0.0f to 1.0f, where 0.0f is fully transparent + * and 1.0f is fully opaque. + * + * @return The alpha transparency. + * + * @see #setBackgroundImageAlpha(float) + */ + public float getBackgroundImageAlpha() { + return this.backgroundImageAlpha; + } + + /** + * Sets the alpha transparency used when drawing the background image. + * + * @param alpha the alpha transparency (in the range 0.0f to 1.0f, where + * 0.0f is fully transparent, and 1.0f is fully opaque). + * + * @throws IllegalArgumentException if alpha is not within + * the specified range. + * + * @see #getBackgroundImageAlpha() + */ + public void setBackgroundImageAlpha(float alpha) { + if (alpha < 0.0f || alpha > 1.0f) { + throw new IllegalArgumentException( + "The 'alpha' value must be in the range 0.0f to 1.0f."); + } + if (this.backgroundImageAlpha != alpha) { + this.backgroundImageAlpha = alpha; + fireChangeEvent(); + } + } + + /** + * Returns the flag that controls whether or not the plot outline is + * drawn. The default value is true. Note that for + * historical reasons, the plot's outline paint and stroke can take on + * null values, in which case the outline will not be drawn + * even if this flag is set to true. + * + * @return The outline visibility flag. + * + * @since 1.0.6 + * + * @see #setOutlineVisible(boolean) + */ + public boolean isOutlineVisible() { + return this.outlineVisible; + } + + /** + * Sets the flag that controls whether or not the plot's outline is + * drawn, and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param visible the new flag value. + * + * @since 1.0.6 + * + * @see #isOutlineVisible() + */ + public void setOutlineVisible(boolean visible) { + this.outlineVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the stroke used to outline the plot area. + * + * @return The stroke (possibly null). + * + * @see #setOutlineStroke(Stroke) + */ + public Stroke getOutlineStroke() { + return this.outlineStroke; + } + + /** + * Sets the stroke used to outline the plot area and sends a + * {@link PlotChangeEvent} to all registered listeners. If you set this + * attribute to null, no outline will be drawn. + * + * @param stroke the stroke (null permitted). + * + * @see #getOutlineStroke() + */ + public void setOutlineStroke(Stroke stroke) { + if (stroke == null) { + if (this.outlineStroke != null) { + this.outlineStroke = null; + fireChangeEvent(); + } + } + else { + if (this.outlineStroke != null) { + if (this.outlineStroke.equals(stroke)) { + return; // nothing to do + } + } + this.outlineStroke = stroke; + fireChangeEvent(); + } + } + + /** + * Returns the color used to draw the outline of the plot area. + * + * @return The color (possibly null). + * + * @see #setOutlinePaint(Paint) + */ + public Paint getOutlinePaint() { + return this.outlinePaint; + } + + /** + * Sets the paint used to draw the outline of the plot area and sends a + * {@link PlotChangeEvent} to all registered listeners. If you set this + * attribute to null, no outline will be drawn. + * + * @param paint the paint (null permitted). + * + * @see #getOutlinePaint() + */ + public void setOutlinePaint(Paint paint) { + if (paint == null) { + if (this.outlinePaint != null) { + this.outlinePaint = null; + fireChangeEvent(); + } + } + else { + if (this.outlinePaint != null) { + if (this.outlinePaint.equals(paint)) { + return; // nothing to do + } + } + this.outlinePaint = paint; + fireChangeEvent(); + } + } + + /** + * Returns the alpha-transparency for the plot foreground. + * + * @return The alpha-transparency. + * + * @see #setForegroundAlpha(float) + */ + public float getForegroundAlpha() { + return this.foregroundAlpha; + } + + /** + * Sets the alpha-transparency for the plot and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param alpha the new alpha transparency. + * + * @see #getForegroundAlpha() + */ + public void setForegroundAlpha(float alpha) { + if (this.foregroundAlpha != alpha) { + this.foregroundAlpha = alpha; + fireChangeEvent(); + } + } + + /** + * Returns the legend items for the plot. By default, this method returns + * null. Subclasses should override to return a + * {@link LegendItemCollection}. + * + * @return The legend items for the plot (possibly null). + */ + @Override + public LegendItemCollection getLegendItems() { + return null; + } + + /** + * Returns a flag that controls whether or not change events are sent to + * registered listeners. + * + * @return A boolean. + * + * @see #setNotify(boolean) + * + * @since 1.0.13 + */ + public boolean isNotify() { + return this.notify; + } + + /** + * Sets a flag that controls whether or not listeners receive + * {@link PlotChangeEvent} notifications. + * + * @param notify a boolean. + * + * @see #isNotify() + * + * @since 1.0.13 + */ + public void setNotify(boolean notify) { + this.notify = notify; + // if the flag is being set to true, there may be queued up changes... + if (notify) { + notifyListeners(new PlotChangeEvent(this)); + } + } + + /** + * Registers an object for notification of changes to the plot. + * + * @param listener the object to be registered. + * + * @see #removeChangeListener(PlotChangeListener) + */ + public void addChangeListener(PlotChangeListener listener) { + this.listenerList.add(PlotChangeListener.class, listener); + } + + /** + * Unregisters an object for notification of changes to the plot. + * + * @param listener the object to be unregistered. + * + * @see #addChangeListener(PlotChangeListener) + */ + public void removeChangeListener(PlotChangeListener listener) { + this.listenerList.remove(PlotChangeListener.class, listener); + } + + /** + * Notifies all registered listeners that the plot has been modified. + * + * @param event information about the change event. + */ + public void notifyListeners(PlotChangeEvent event) { + // if the 'notify' flag has been switched to false, we don't notify + // the listeners + if (!this.notify) { + return; + } + Object[] listeners = this.listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == PlotChangeListener.class) { + ((PlotChangeListener) listeners[i + 1]).plotChanged(event); + } + } + } + + /** + * Sends a {@link PlotChangeEvent} to all registered listeners. + * + * @since 1.0.10 + */ + protected void fireChangeEvent() { + notifyListeners(new PlotChangeEvent(this)); + } + + /** + * Draws the plot within the specified area. The anchor is a point on the + * chart that is specified externally (for instance, it may be the last + * point of the last mouse click performed by the user) - plots can use or + * ignore this value as they see fit. + *

+ * Subclasses need to provide an implementation of this method, obviously. + * + * @param g2 the graphics device. + * @param area the plot area. + * @param anchor the anchor point (null permitted). + * @param parentState the parent state (if any). + * @param info carries back plot rendering info. + */ + public abstract void draw(Graphics2D g2, + Rectangle2D area, + Point2D anchor, + PlotState parentState, + PlotRenderingInfo info); + + /** + * Draws the plot background (the background color and/or image). + *

+ * This method will be called during the chart drawing process and is + * declared public so that it can be accessed by the renderers used by + * certain subclasses. You shouldn't need to call this method directly. + * + * @param g2 the graphics device. + * @param area the area within which the plot should be drawn. + */ + public void drawBackground(Graphics2D g2, Rectangle2D area) { + // some subclasses override this method completely, so don't put + // anything here that *must* be done + fillBackground(g2, area); + drawBackgroundImage(g2, area); + } + + /** + * Fills the specified area with the background paint. + * + * @param g2 the graphics device. + * @param area the area. + * + * @see #getBackgroundPaint() + * @see #getBackgroundAlpha() + * @see #fillBackground(Graphics2D, Rectangle2D, PlotOrientation) + */ + protected void fillBackground(Graphics2D g2, Rectangle2D area) { + fillBackground(g2, area, PlotOrientation.VERTICAL); + } + + /** + * Fills the specified area with the background paint. If the background + * paint is an instance of GradientPaint, the gradient will + * run in the direction suggested by the plot's orientation. + * + * @param g2 the graphics target. + * @param area the plot area. + * @param orientation the plot orientation (null not + * permitted). + * + * @since 1.0.6 + */ + protected void fillBackground(Graphics2D g2, Rectangle2D area, + PlotOrientation orientation) { + ParamChecks.nullNotPermitted(orientation, "orientation"); + if (this.backgroundPaint == null) { + return; + } + Paint p = this.backgroundPaint; + if (p instanceof GradientPaint) { + GradientPaint gp = (GradientPaint) p; + if (orientation == PlotOrientation.VERTICAL) { + p = new GradientPaint((float) area.getCenterX(), + (float) area.getMaxY(), gp.getColor1(), + (float) area.getCenterX(), (float) area.getMinY(), + gp.getColor2()); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + p = new GradientPaint((float) area.getMinX(), + (float) area.getCenterY(), gp.getColor1(), + (float) area.getMaxX(), (float) area.getCenterY(), + gp.getColor2()); + } + } + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + this.backgroundAlpha)); + g2.setPaint(p); + g2.fill(area); + g2.setComposite(originalComposite); + } + + /** + * Draws the background image (if there is one) aligned within the + * specified area. + * + * @param g2 the graphics device. + * @param area the area. + * + * @see #getBackgroundImage() + * @see #getBackgroundImageAlignment() + * @see #getBackgroundImageAlpha() + */ + public void drawBackgroundImage(Graphics2D g2, Rectangle2D area) { + if (this.backgroundImage == null) { + return; // nothing to do + } + Composite savedComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + this.backgroundImageAlpha)); + Rectangle2D dest = new Rectangle2D.Double(0.0, 0.0, + this.backgroundImage.getWidth(null), + this.backgroundImage.getHeight(null)); + Align.align(dest, area, this.backgroundImageAlignment); + Shape savedClip = g2.getClip(); + g2.clip(area); + g2.drawImage(this.backgroundImage, (int) dest.getX(), + (int) dest.getY(), (int) dest.getWidth() + 1, + (int) dest.getHeight() + 1, null); + g2.setClip(savedClip); + g2.setComposite(savedComposite); + } + + /** + * Draws the plot outline. This method will be called during the chart + * drawing process and is declared public so that it can be accessed by the + * renderers used by certain subclasses. You shouldn't need to call this + * method directly. + * + * @param g2 the graphics device. + * @param area the area within which the plot should be drawn. + */ + public void drawOutline(Graphics2D g2, Rectangle2D area) { + if (!this.outlineVisible) { + return; + } + if ((this.outlineStroke != null) && (this.outlinePaint != null)) { + g2.setStroke(this.outlineStroke); + g2.setPaint(this.outlinePaint); + g2.draw(area); + } + } + + /** + * Draws a message to state that there is no data to plot. + * + * @param g2 the graphics device. + * @param area the area within which the plot should be drawn. + */ + protected void drawNoDataMessage(Graphics2D g2, Rectangle2D area) { + Shape savedClip = g2.getClip(); + g2.clip(area); + String message = this.noDataMessage; + if (message != null) { + g2.setFont(this.noDataMessageFont); + g2.setPaint(this.noDataMessagePaint); + TextBlock block = TextUtilities.createTextBlock( + this.noDataMessage, this.noDataMessageFont, + this.noDataMessagePaint, 0.9f * (float) area.getWidth(), + new G2TextMeasurer(g2)); + block.draw(g2, (float) area.getCenterX(), + (float) area.getCenterY(), TextBlockAnchor.CENTER); + } + g2.setClip(savedClip); + } + + /** + * Creates a plot entity that contains a reference to the plot and the + * data area as shape. + * + * @param dataArea the data area used as hot spot for the entity. + * @param plotState the plot rendering info containing a reference to the + * EntityCollection. + * @param toolTip the tool tip (defined in the respective Plot + * subclass) (null permitted). + * @param urlText the url (defined in the respective Plot subclass) + * (null permitted). + * + * @since 1.0.13 + */ + protected void createAndAddEntity(Rectangle2D dataArea, + PlotRenderingInfo plotState, String toolTip, String urlText) { + if (plotState != null && plotState.getOwner() != null) { + EntityCollection e = plotState.getOwner().getEntityCollection(); + if (e != null) { + e.add(new PlotEntity(dataArea, this, toolTip, urlText)); + } + } + } + + /** + * Handles a 'click' on the plot. Since the plot does not maintain any + * information about where it has been drawn, the plot rendering info is + * supplied as an argument so that the plot dimensions can be determined. + * + * @param x the x coordinate (in Java2D space). + * @param y the y coordinate (in Java2D space). + * @param info an object containing information about the dimensions of + * the plot. + */ + public void handleClick(int x, int y, PlotRenderingInfo info) { + // provides a 'no action' default + } + + /** + * Performs a zoom on the plot. Subclasses should override if zooming is + * appropriate for the type of plot. + * + * @param percent the zoom percentage. + */ + public void zoom(double percent) { + // do nothing by default. + } + + /** + * Receives notification of a change to an {@link Annotation} added to + * this plot. + * + * @param event information about the event (not used here). + * + * @since 1.0.14 + */ + @Override + public void annotationChanged(AnnotationChangeEvent event) { + fireChangeEvent(); + } + + /** + * Receives notification of a change to one of the plot's axes. + * + * @param event information about the event (not used here). + */ + @Override + public void axisChanged(AxisChangeEvent event) { + fireChangeEvent(); + } + + /** + * Receives notification of a change to the plot's dataset. + *

+ * The plot reacts by passing on a plot change event to all registered + * listeners. + * + * @param event information about the event (not used here). + */ + @Override + public void datasetChanged(DatasetChangeEvent event) { + PlotChangeEvent newEvent = new PlotChangeEvent(this); + newEvent.setType(ChartChangeEventType.DATASET_UPDATED); + notifyListeners(newEvent); + } + + /** + * Receives notification of a change to a marker that is assigned to the + * plot. + * + * @param event the event. + * + * @since 1.0.3 + */ + @Override + public void markerChanged(MarkerChangeEvent event) { + fireChangeEvent(); + } + + /** + * Adjusts the supplied x-value. + * + * @param x the x-value. + * @param w1 width 1. + * @param w2 width 2. + * @param edge the edge (left or right). + * + * @return The adjusted x-value. + */ + protected double getRectX(double x, double w1, double w2, + RectangleEdge edge) { + + double result = x; + if (edge == RectangleEdge.LEFT) { + result = result + w1; + } + else if (edge == RectangleEdge.RIGHT) { + result = result + w2; + } + return result; + + } + + /** + * Adjusts the supplied y-value. + * + * @param y the x-value. + * @param h1 height 1. + * @param h2 height 2. + * @param edge the edge (top or bottom). + * + * @return The adjusted y-value. + */ + protected double getRectY(double y, double h1, double h2, + RectangleEdge edge) { + + double result = y; + if (edge == RectangleEdge.TOP) { + result = result + h1; + } + else if (edge == RectangleEdge.BOTTOM) { + result = result + h2; + } + return result; + + } + + /** + * Tests this plot for equality with another object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Plot)) { + return false; + } + Plot that = (Plot) obj; + if (!ObjectUtilities.equal(this.noDataMessage, that.noDataMessage)) { + return false; + } + if (!ObjectUtilities.equal( + this.noDataMessageFont, that.noDataMessageFont + )) { + return false; + } + if (!PaintUtilities.equal(this.noDataMessagePaint, + that.noDataMessagePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.insets, that.insets)) { + return false; + } + if (this.outlineVisible != that.outlineVisible) { + return false; + } + if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { + return false; + } + if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.backgroundImage, + that.backgroundImage)) { + return false; + } + if (this.backgroundImageAlignment != that.backgroundImageAlignment) { + return false; + } + if (this.backgroundImageAlpha != that.backgroundImageAlpha) { + return false; + } + if (this.foregroundAlpha != that.foregroundAlpha) { + return false; + } + if (this.backgroundAlpha != that.backgroundAlpha) { + return false; + } + if (!this.drawingSupplier.equals(that.drawingSupplier)) { + return false; + } + if (this.notify != that.notify) { + return false; + } + return true; + } + + /** + * Creates a clone of the plot. + * + * @return A clone. + * + * @throws CloneNotSupportedException if some component of the plot does not + * support cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + + Plot clone = (Plot) super.clone(); + // private Plot parent <-- don't clone the parent plot, but take care + // childs in combined plots instead + if (this.datasetGroup != null) { + clone.datasetGroup + = (DatasetGroup) ObjectUtilities.clone(this.datasetGroup); + } + clone.drawingSupplier + = (DrawingSupplier) ObjectUtilities.clone(this.drawingSupplier); + clone.listenerList = new EventListenerList(); + 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.noDataMessagePaint, stream); + SerialUtilities.writeStroke(this.outlineStroke, stream); + SerialUtilities.writePaint(this.outlinePaint, stream); + // backgroundImage + SerialUtilities.writePaint(this.backgroundPaint, 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.noDataMessagePaint = SerialUtilities.readPaint(stream); + this.outlineStroke = SerialUtilities.readStroke(stream); + this.outlinePaint = SerialUtilities.readPaint(stream); + // backgroundImage + this.backgroundPaint = SerialUtilities.readPaint(stream); + + this.listenerList = new EventListenerList(); + + } + + /** + * Resolves a domain axis location for a given plot orientation. + * + * @param location the location (null not permitted). + * @param orientation the orientation (null not permitted). + * + * @return The edge (never null). + */ + public static RectangleEdge resolveDomainAxisLocation( + AxisLocation location, PlotOrientation orientation) { + + ParamChecks.nullNotPermitted(location, "location"); + ParamChecks.nullNotPermitted(orientation, "orientation"); + + RectangleEdge result = null; + if (location == AxisLocation.TOP_OR_RIGHT) { + if (orientation == PlotOrientation.HORIZONTAL) { + result = RectangleEdge.RIGHT; + } + else if (orientation == PlotOrientation.VERTICAL) { + result = RectangleEdge.TOP; + } + } + else if (location == AxisLocation.TOP_OR_LEFT) { + if (orientation == PlotOrientation.HORIZONTAL) { + result = RectangleEdge.LEFT; + } + else if (orientation == PlotOrientation.VERTICAL) { + result = RectangleEdge.TOP; + } + } + else if (location == AxisLocation.BOTTOM_OR_RIGHT) { + if (orientation == PlotOrientation.HORIZONTAL) { + result = RectangleEdge.RIGHT; + } + else if (orientation == PlotOrientation.VERTICAL) { + result = RectangleEdge.BOTTOM; + } + } + else if (location == AxisLocation.BOTTOM_OR_LEFT) { + if (orientation == PlotOrientation.HORIZONTAL) { + result = RectangleEdge.LEFT; + } + else if (orientation == PlotOrientation.VERTICAL) { + result = RectangleEdge.BOTTOM; + } + } + // the above should cover all the options... + if (result == null) { + throw new IllegalStateException("resolveDomainAxisLocation()"); + } + return result; + + } + + /** + * Resolves a range axis location for a given plot orientation. + * + * @param location the location (null not permitted). + * @param orientation the orientation (null not permitted). + * + * @return The edge (never null). + */ + public static RectangleEdge resolveRangeAxisLocation( + AxisLocation location, PlotOrientation orientation) { + + ParamChecks.nullNotPermitted(location, "location"); + ParamChecks.nullNotPermitted(orientation, "orientation"); + + RectangleEdge result = null; + if (location == AxisLocation.TOP_OR_RIGHT) { + if (orientation == PlotOrientation.HORIZONTAL) { + result = RectangleEdge.TOP; + } + else if (orientation == PlotOrientation.VERTICAL) { + result = RectangleEdge.RIGHT; + } + } + else if (location == AxisLocation.TOP_OR_LEFT) { + if (orientation == PlotOrientation.HORIZONTAL) { + result = RectangleEdge.TOP; + } + else if (orientation == PlotOrientation.VERTICAL) { + result = RectangleEdge.LEFT; + } + } + else if (location == AxisLocation.BOTTOM_OR_RIGHT) { + if (orientation == PlotOrientation.HORIZONTAL) { + result = RectangleEdge.BOTTOM; + } + else if (orientation == PlotOrientation.VERTICAL) { + result = RectangleEdge.RIGHT; + } + } + else if (location == AxisLocation.BOTTOM_OR_LEFT) { + if (orientation == PlotOrientation.HORIZONTAL) { + result = RectangleEdge.BOTTOM; + } + else if (orientation == PlotOrientation.VERTICAL) { + result = RectangleEdge.LEFT; + } + } + + // the above should cover all the options... + if (result == null) { + throw new IllegalStateException("resolveRangeAxisLocation()"); + } + return result; + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PlotOrientation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PlotOrientation.java new file mode 100755 index 0000000..0ee424d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PlotOrientation.java @@ -0,0 +1,137 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * PlotOrientation.java + * -------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 02-May-2003 : Version 1 (DG); + * 17-Jul-2003 : Added readResolve() method (DG); + * 21-Nov-2007 : Implemented hashCode() (DG); + * + */ + +package org.jfree.chart.plot; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Used to indicate the orientation (horizontal or vertical) of a 2D plot. + */ +public final class PlotOrientation implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -2508771828190337782L; + + /** For a plot where the range axis is horizontal. */ + public static final PlotOrientation HORIZONTAL + = new PlotOrientation("PlotOrientation.HORIZONTAL"); + + /** For a plot where the range axis is vertical. */ + public static final PlotOrientation VERTICAL + = new PlotOrientation("PlotOrientation.VERTICAL"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private PlotOrientation(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof PlotOrientation)) { + return false; + } + PlotOrientation orientation = (PlotOrientation) obj; + if (!this.name.equals(orientation.toString())) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return this.name.hashCode(); + } + + /** + * Ensures that serialization returns the unique instances. + * + * @return The object. + * + * @throws ObjectStreamException if there is a problem. + */ + private Object readResolve() throws ObjectStreamException { + Object result = null; + if (this.equals(PlotOrientation.HORIZONTAL)) { + result = PlotOrientation.HORIZONTAL; + } + else if (this.equals(PlotOrientation.VERTICAL)) { + result = PlotOrientation.VERTICAL; + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PlotRenderingInfo.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PlotRenderingInfo.java new file mode 100755 index 0000000..33a3b72 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PlotRenderingInfo.java @@ -0,0 +1,290 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * PlotRenderingInfo.java + * ---------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Sep-2003 : Version 1 (DG); + * 23-Sep-2003 : Added Javadocs (DG); + * 12-Nov-2004 : Added getSubplotCount() and findSubplot() methods (DG); + * 01-Nov-2005 : Made 'owner' non-transient to fix bug 1344048 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 01-Dec-2006 : Implemented clone() method properly (DG); + * 17-Apr-2007 : Fixed bug 1698965 (NPE in CombinedDomainXYPlot) (DG); + * + */ + +package org.jfree.chart.plot; + +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 java.util.List; + +import org.jfree.chart.ChartRenderingInfo; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.util.ObjectUtilities; + +/** + * Stores information about the dimensions of a plot and its subplots. + */ +public class PlotRenderingInfo implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 8446720134379617220L; + + /** The owner of this info. */ + private ChartRenderingInfo owner; + + /** The plot area. */ + private transient Rectangle2D plotArea; + + /** The data area. */ + private transient Rectangle2D dataArea; + + /** + * Storage for the plot rendering info objects belonging to the subplots. + */ + private List subplotInfo; + + /** + * Creates a new instance. + * + * @param owner the owner (null permitted). + */ + public PlotRenderingInfo(ChartRenderingInfo owner) { + this.owner = owner; + this.dataArea = new Rectangle2D.Double(); + this.subplotInfo = new java.util.ArrayList(); + } + + /** + * Returns the owner (as specified in the constructor). + * + * @return The owner (possibly null). + */ + public ChartRenderingInfo getOwner() { + return this.owner; + } + + /** + * Returns the plot area (in Java2D space). + * + * @return The plot area (possibly null). + * + * @see #setPlotArea(Rectangle2D) + */ + public Rectangle2D getPlotArea() { + return this.plotArea; + } + + /** + * Sets the plot area. + * + * @param area the plot area (in Java2D space, null + * permitted but discouraged) + * + * @see #getPlotArea() + */ + public void setPlotArea(Rectangle2D area) { + this.plotArea = area; + } + + /** + * Returns the plot's data area (in Java2D space). + * + * @return The data area (possibly null). + * + * @see #setDataArea(Rectangle2D) + */ + public Rectangle2D getDataArea() { + return this.dataArea; + } + + /** + * Sets the data area. + * + * @param area the data area (in Java2D space, null permitted + * but discouraged). + * + * @see #getDataArea() + */ + public void setDataArea(Rectangle2D area) { + this.dataArea = area; + } + + /** + * Returns the number of subplots (possibly zero). + * + * @return The subplot count. + */ + public int getSubplotCount() { + return this.subplotInfo.size(); + } + + /** + * Adds the info for a subplot. + * + * @param info the subplot info. + * + * @see #getSubplotInfo(int) + */ + public void addSubplotInfo(PlotRenderingInfo info) { + this.subplotInfo.add(info); + } + + /** + * Returns the info for a subplot. + * + * @param index the subplot index. + * + * @return The info. + * + * @see #addSubplotInfo(PlotRenderingInfo) + */ + public PlotRenderingInfo getSubplotInfo(int index) { + return (PlotRenderingInfo) this.subplotInfo.get(index); + } + + /** + * Returns the index of the subplot that contains the specified + * (x, y) point (the "source" point). The source point will usually + * come from a mouse click on a {@link org.jfree.chart.ChartPanel}, + * and this method is then used to determine the subplot that + * contains the source point. + * + * @param source the source point (in Java2D space, null not + * permitted). + * + * @return The subplot index (or -1 if no subplot contains + * source). + */ + public int getSubplotIndex(Point2D source) { + ParamChecks.nullNotPermitted(source, "source"); + int subplotCount = getSubplotCount(); + for (int i = 0; i < subplotCount; i++) { + PlotRenderingInfo info = getSubplotInfo(i); + Rectangle2D area = info.getDataArea(); + if (area.contains(source)) { + return i; + } + } + return -1; + } + + /** + * Tests this instance for equality against an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof PlotRenderingInfo)) { + return false; + } + PlotRenderingInfo that = (PlotRenderingInfo) obj; + if (!ObjectUtilities.equal(this.dataArea, that.dataArea)) { + return false; + } + if (!ObjectUtilities.equal(this.plotArea, that.plotArea)) { + return false; + } + if (!ObjectUtilities.equal(this.subplotInfo, that.subplotInfo)) { + return false; + } + return true; + } + + /** + * Returns a clone of this object. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + PlotRenderingInfo clone = (PlotRenderingInfo) super.clone(); + if (this.plotArea != null) { + clone.plotArea = (Rectangle2D) this.plotArea.clone(); + } + if (this.dataArea != null) { + clone.dataArea = (Rectangle2D) this.dataArea.clone(); + } + clone.subplotInfo = new java.util.ArrayList(this.subplotInfo.size()); + for (int i = 0; i < this.subplotInfo.size(); i++) { + PlotRenderingInfo info + = (PlotRenderingInfo) this.subplotInfo.get(i); + clone.subplotInfo.add(info.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.dataArea, stream); + SerialUtilities.writeShape(this.plotArea, 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.dataArea = (Rectangle2D) SerialUtilities.readShape(stream); + this.plotArea = (Rectangle2D) SerialUtilities.readShape(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PlotState.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PlotState.java new file mode 100755 index 0000000..bbb2bd8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PlotState.java @@ -0,0 +1,70 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * PlotState.java + * -------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Oct-2003 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import java.util.HashMap; +import java.util.Map; + +/** + * Records information about the state of a plot during the drawing process. + */ +public class PlotState { + + /** The shared axis states. */ + private Map sharedAxisStates; + + /** + * Creates a new state object. + */ + public PlotState() { + this.sharedAxisStates = new HashMap(); + } + + /** + * Returns a map containing the shared axis states. + * + * @return A map. + */ + public Map getSharedAxisStates() { + return this.sharedAxisStates; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PlotUtilities.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PlotUtilities.java new file mode 100755 index 0000000..2d7fb23 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PlotUtilities.java @@ -0,0 +1,76 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * PlotUtilities.java + * ------------------ + * (C) Copyright 2007, 2008, by Sergei Ivanov and Contributors. + * + * Original Author: Sergei Ivanov; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 26-Sep-2007 : Version 1, contributed by Sergei Ivanov (see patch + * 1772932) (DG); + * + */ + +package org.jfree.chart.plot; + +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.xy.XYDataset; + +/** + * Some utility methods related to the plot classes. + * + * @since 1.0.7 + */ +public class PlotUtilities { + + /** + * Returns true if all the datasets belonging to the specified + * plot are empty or null, and false otherwise. + * + * @param plot the plot (null permitted). + * + * @return A boolean. + * + * @since 1.0.7 + */ + public static boolean isEmptyOrNull(XYPlot plot) { + if (plot != null) { + for (int i = 0, n = plot.getDatasetCount(); i < n; i++) { + final XYDataset dataset = plot.getDataset(i); + if (!DatasetUtilities.isEmptyOrNull(dataset)) { + return false; + } + } + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PolarAxisLocation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PolarAxisLocation.java new file mode 100755 index 0000000..dd213c4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PolarAxisLocation.java @@ -0,0 +1,168 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * PolarAxisLocation.java + * ---------------------- + * (C) Copyright 2009, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 25-Nov-2009 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Used to indicate the location of an axis on a {@link PolarPlot}. + * + * @since 1.0.14 + */ +public final class PolarAxisLocation implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -3276922179323563410L; + + /** Axis left of north. */ + public static final PolarAxisLocation NORTH_LEFT + = new PolarAxisLocation("PolarAxisLocation.NORTH_LEFT"); + + /** Axis right of north. */ + public static final PolarAxisLocation NORTH_RIGHT + = new PolarAxisLocation("PolarAxisLocation.NORTH_RIGHT"); + + /** Axis left of south. */ + public static final PolarAxisLocation SOUTH_LEFT + = new PolarAxisLocation("PolarAxisLocation.SOUTH_LEFT"); + + /** Axis right of south. */ + public static final PolarAxisLocation SOUTH_RIGHT + = new PolarAxisLocation("PolarAxisLocation.SOUTH_RIGHT"); + + /** Axis above east. */ + public static final PolarAxisLocation EAST_ABOVE + = new PolarAxisLocation("PolarAxisLocation.EAST_ABOVE"); + + /** Axis below east. */ + public static final PolarAxisLocation EAST_BELOW + = new PolarAxisLocation("PolarAxisLocation.EAST_BELOW"); + + /** Axis above west. */ + public static final PolarAxisLocation WEST_ABOVE + = new PolarAxisLocation("PolarAxisLocation.WEST_ABOVE"); + + /** Axis below west. */ + public static final PolarAxisLocation WEST_BELOW + = new PolarAxisLocation("PolarAxisLocation.WEST_BELOW"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private PolarAxisLocation(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PolarAxisLocation)) { + return false; + } + PolarAxisLocation location = (PolarAxisLocation) obj; + if (!this.name.equals(location.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(PolarAxisLocation.NORTH_RIGHT)) { + return PolarAxisLocation.NORTH_RIGHT; + } + else if (this.equals(PolarAxisLocation.NORTH_LEFT)) { + return PolarAxisLocation.NORTH_LEFT; + } + else if (this.equals(PolarAxisLocation.SOUTH_RIGHT)) { + return PolarAxisLocation.SOUTH_RIGHT; + } + else if (this.equals(PolarAxisLocation.SOUTH_LEFT)) { + return PolarAxisLocation.SOUTH_LEFT; + } + else if (this.equals(PolarAxisLocation.EAST_ABOVE)) { + return PolarAxisLocation.EAST_ABOVE; + } + else if (this.equals(PolarAxisLocation.EAST_BELOW)) { + return PolarAxisLocation.EAST_BELOW; + } + else if (this.equals(PolarAxisLocation.WEST_ABOVE)) { + return PolarAxisLocation.WEST_ABOVE; + } + else if (this.equals(PolarAxisLocation.WEST_BELOW)) { + return PolarAxisLocation.WEST_BELOW; + } + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PolarPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PolarPlot.java new file mode 100755 index 0000000..6af96ba --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/PolarPlot.java @@ -0,0 +1,2233 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * PolarPlot.java + * -------------- + * (C) Copyright 2004-2013, by Solution Engineering, Inc. and Contributors. + * + * Original Author: Daniel Bridenbecker, Solution Engineering, Inc.; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Martin Hoeller (patches 1871902 and 2850344); + * + * Changes + * ------- + * 19-Jan-2004 : Version 1, contributed by DB with minor changes by DG (DG); + * 07-Apr-2004 : Changed text bounds calculation (DG); + * 05-May-2005 : Updated draw() method parameters (DG); + * 09-Jun-2005 : Fixed getDataRange() and equals() methods (DG); + * 25-Oct-2005 : Implemented Zoomable (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 07-Feb-2007 : Fixed bug 1599761, data value less than axis minimum (DG); + * 21-Mar-2007 : Fixed serialization bug (DG); + * 24-Sep-2007 : Implemented new zooming methods (DG); + * 17-Feb-2007 : Added angle tick unit attribute (see patch 1871902 by + * Martin Hoeller) (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 03-Sep-2009 : Applied patch 2850344 by Martin Hoeller (DG); + * 27-Nov-2009 : Added support for multiple datasets, renderers and axes (DG); + * 09-Dec-2009 : Extended getLegendItems() to handle multiple datasets (DG); + * 25-Jun-2010 : Better support for multiple axes (MH); + * 03-Oct-2011 : Added support for angleOffset and direction (MH); + * 12-Nov-2011 : Fixed bug 3432721, log-axis doesn't work (MH); + * 12-Dec-2011 : Added support for radiusMinorGridlinesVisible (MH); + * 02-Jul-2013 : Use ParamChecks (DG); + * 05-Jul-2013 : Fire change event from setRadiusMinorGridlinesVisible (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.AlphaComposite; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Point; +import java.awt.Shape; +import java.awt.Stroke; +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 java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.TreeMap; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.axis.Axis; +import org.jfree.chart.axis.AxisState; +import org.jfree.chart.axis.NumberTick; +import org.jfree.chart.axis.NumberTickUnit; +import org.jfree.chart.axis.TickType; +import org.jfree.chart.axis.TickUnit; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.axis.ValueTick; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.event.RendererChangeListener; +import org.jfree.chart.renderer.PolarItemRenderer; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.data.Range; +import org.jfree.data.general.Dataset; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.TextAnchor; +import org.jfree.util.ObjectList; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * Plots data that is in (theta, radius) pairs where + * theta equal to zero is due north and increases clockwise. + */ +public class PolarPlot extends Plot implements ValueAxisPlot, Zoomable, + RendererChangeListener, Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 3794383185924179525L; + + /** The default margin. */ + private static final int DEFAULT_MARGIN = 20; + + /** The annotation margin. */ + private static final double ANNOTATION_MARGIN = 7.0; + + /** + * The default angle tick unit size. + * + * @since 1.0.10 + */ + public static final double DEFAULT_ANGLE_TICK_UNIT_SIZE = 45.0; + + /** + * The default angle offset. + * + * @since 1.0.14 + */ + public static final double DEFAULT_ANGLE_OFFSET = -90.0; + + /** The default grid line stroke. */ + public static final Stroke DEFAULT_GRIDLINE_STROKE = new BasicStroke( + 0.5f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, + 0.0f, new float[]{2.0f, 2.0f}, 0.0f); + + /** The default grid line paint. */ + public static final Paint DEFAULT_GRIDLINE_PAINT = Color.gray; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.plot.LocalizationBundle"); + + /** The angles that are marked with gridlines. */ + private List angleTicks; + + /** The range axis (used for the y-values). */ + private ObjectList axes; + + /** The axis locations. */ + private ObjectList axisLocations; + + /** Storage for the datasets. */ + private ObjectList datasets; + + /** Storage for the renderers. */ + private ObjectList renderers; + + /** + * The tick unit that controls the spacing between the angular grid lines. + * + * @since 1.0.10 + */ + private TickUnit angleTickUnit; + + /** + * An offset for the angles, to start with 0 degrees at north, east, south + * or west. + * + * @since 1.0.14 + */ + private double angleOffset; + + /** + * A flag indicating if the angles increase counterclockwise or clockwise. + * + * @since 1.0.14 + */ + private boolean counterClockwise; + + /** A flag that controls whether or not the angle labels are visible. */ + private boolean angleLabelsVisible = true; + + /** The font used to display the angle labels - never null. */ + private Font angleLabelFont = new Font("SansSerif", Font.PLAIN, 12); + + /** The paint used to display the angle labels. */ + private transient Paint angleLabelPaint = Color.black; + + /** A flag that controls whether the angular grid-lines are visible. */ + private boolean angleGridlinesVisible; + + /** The stroke used to draw the angular grid-lines. */ + private transient Stroke angleGridlineStroke; + + /** The paint used to draw the angular grid-lines. */ + private transient Paint angleGridlinePaint; + + /** A flag that controls whether the radius grid-lines are visible. */ + private boolean radiusGridlinesVisible; + + /** The stroke used to draw the radius grid-lines. */ + private transient Stroke radiusGridlineStroke; + + /** The paint used to draw the radius grid-lines. */ + private transient Paint radiusGridlinePaint; + + /** + * A flag that controls whether the radial minor grid-lines are visible. + * @since 1.0.15 + */ + private boolean radiusMinorGridlinesVisible; + + /** The annotations for the plot. */ + private List cornerTextItems = new ArrayList(); + + /** + * The actual margin in pixels. + * + * @since 1.0.14 + */ + private int margin; + + /** + * An optional collection of legend items that can be returned by the + * getLegendItems() method. + */ + private LegendItemCollection fixedLegendItems; + + /** + * Storage for the mapping between datasets/renderers and range axes. The + * keys in the map are Integer objects, corresponding to the dataset + * index. The values in the map are List objects containing Integer + * objects (corresponding to the axis indices). If the map contains no + * entry for a dataset, it is assumed to map to the primary domain axis + * (index = 0). + */ + private Map datasetToAxesMap; + + /** + * Default constructor. + */ + public PolarPlot() { + this(null, null, null); + } + + /** + * Creates a new plot. + * + * @param dataset the dataset (null permitted). + * @param radiusAxis the radius axis (null permitted). + * @param renderer the renderer (null permitted). + */ + public PolarPlot(XYDataset dataset, ValueAxis radiusAxis, + PolarItemRenderer renderer) { + + super(); + + this.datasets = new ObjectList(); + this.datasets.set(0, dataset); + if (dataset != null) { + dataset.addChangeListener(this); + } + this.angleTickUnit = new NumberTickUnit(DEFAULT_ANGLE_TICK_UNIT_SIZE); + + this.axes = new ObjectList(); + this.datasetToAxesMap = new TreeMap(); + this.axes.set(0, radiusAxis); + if (radiusAxis != null) { + radiusAxis.setPlot(this); + radiusAxis.addChangeListener(this); + } + + // define the default locations for up to 8 axes... + this.axisLocations = new ObjectList(); + this.axisLocations.set(0, PolarAxisLocation.EAST_ABOVE); + this.axisLocations.set(1, PolarAxisLocation.NORTH_LEFT); + this.axisLocations.set(2, PolarAxisLocation.WEST_BELOW); + this.axisLocations.set(3, PolarAxisLocation.SOUTH_RIGHT); + this.axisLocations.set(4, PolarAxisLocation.EAST_BELOW); + this.axisLocations.set(5, PolarAxisLocation.NORTH_RIGHT); + this.axisLocations.set(6, PolarAxisLocation.WEST_ABOVE); + this.axisLocations.set(7, PolarAxisLocation.SOUTH_LEFT); + + this.renderers = new ObjectList(); + this.renderers.set(0, renderer); + if (renderer != null) { + renderer.setPlot(this); + renderer.addChangeListener(this); + } + + this.angleOffset = DEFAULT_ANGLE_OFFSET; + this.counterClockwise = false; + this.angleGridlinesVisible = true; + this.angleGridlineStroke = DEFAULT_GRIDLINE_STROKE; + this.angleGridlinePaint = DEFAULT_GRIDLINE_PAINT; + + this.radiusGridlinesVisible = true; + this.radiusMinorGridlinesVisible = true; + this.radiusGridlineStroke = DEFAULT_GRIDLINE_STROKE; + this.radiusGridlinePaint = DEFAULT_GRIDLINE_PAINT; + this.margin = DEFAULT_MARGIN; + } + + /** + * Returns the plot type as a string. + * + * @return A short string describing the type of plot. + */ + @Override + public String getPlotType() { + return PolarPlot.localizationResources.getString("Polar_Plot"); + } + + /** + * Returns the primary axis for the plot. + * + * @return The primary axis (possibly null). + * + * @see #setAxis(ValueAxis) + */ + public ValueAxis getAxis() { + return getAxis(0); + } + + /** + * Returns an axis for the plot. + * + * @param index the axis index. + * + * @return The axis (null possible). + * + * @see #setAxis(int, ValueAxis) + * + * @since 1.0.14 + */ + public ValueAxis getAxis(int index) { + ValueAxis result = null; + if (index < this.axes.size()) { + result = (ValueAxis) this.axes.get(index); + } + return result; + } + + /** + * Sets the primary axis for the plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param axis the new primary axis (null permitted). + */ + public void setAxis(ValueAxis axis) { + setAxis(0, axis); + } + + /** + * Sets an axis for the plot and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param index the axis index. + * @param axis the axis (null permitted). + * + * @see #getAxis(int) + * + * @since 1.0.14 + */ + public void setAxis(int index, ValueAxis axis) { + setAxis(index, axis, true); + } + + /** + * Sets an axis for the plot and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the axis index. + * @param axis the axis (null permitted). + * @param notify notify listeners? + * + * @see #getAxis(int) + * + * @since 1.0.14 + */ + public void setAxis(int index, ValueAxis axis, boolean notify) { + ValueAxis existing = getAxis(index); + if (existing != null) { + existing.removeChangeListener(this); + } + if (axis != null) { + axis.setPlot(this); + } + this.axes.set(index, axis); + if (axis != null) { + axis.configure(); + axis.addChangeListener(this); + } + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the location of the primary axis. + * + * @return The location (never null). + * + * @see #setAxisLocation(PolarAxisLocation) + * + * @since 1.0.14 + */ + public PolarAxisLocation getAxisLocation() { + return getAxisLocation(0); + } + + /** + * Returns the location for an axis. + * + * @param index the axis index. + * + * @return The location (never null). + * + * @see #setAxisLocation(int, PolarAxisLocation) + * + * @since 1.0.14 + */ + public PolarAxisLocation getAxisLocation(int index) { + PolarAxisLocation result = null; + if (index < this.axisLocations.size()) { + result = (PolarAxisLocation) this.axisLocations.get(index); + } + return result; + } + + /** + * Sets the location of the primary axis and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param location the location (null not permitted). + * + * @see #getAxisLocation() + * + * @since 1.0.14 + */ + public void setAxisLocation(PolarAxisLocation location) { + // delegate... + setAxisLocation(0, location, true); + } + + /** + * Sets the location of the primary axis and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param location the location (null not permitted). + * @param notify notify listeners? + * + * @see #getAxisLocation() + * + * @since 1.0.14 + */ + public void setAxisLocation(PolarAxisLocation location, boolean notify) { + // delegate... + setAxisLocation(0, location, notify); + } + + /** + * Sets the location for an axis and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param index the axis index. + * @param location the location (null not permitted). + * + * @see #getAxisLocation(int) + * + * @since 1.0.14 + */ + public void setAxisLocation(int index, PolarAxisLocation location) { + // delegate... + setAxisLocation(index, location, true); + } + + /** + * Sets the axis location for an axis and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the axis index. + * @param location the location (null not permitted). + * @param notify notify listeners? + * + * @since 1.0.14 + */ + public void setAxisLocation(int index, PolarAxisLocation location, + boolean notify) { + ParamChecks.nullNotPermitted(location, "location"); + this.axisLocations.set(index, location); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the number of domain axes. + * + * @return The axis count. + * + * @since 1.0.14 + **/ + public int getAxisCount() { + return this.axes.size(); + } + + /** + * Returns the primary dataset for the plot. + * + * @return The primary dataset (possibly null). + * + * @see #setDataset(XYDataset) + */ + public XYDataset getDataset() { + return getDataset(0); + } + + /** + * Returns the dataset with the specified index, if any. + * + * @param index the dataset index. + * + * @return The dataset (possibly null). + * + * @see #setDataset(int, XYDataset) + * + * @since 1.0.14 + */ + public XYDataset getDataset(int index) { + XYDataset result = null; + if (index < this.datasets.size()) { + result = (XYDataset) this.datasets.get(index); + } + return result; + } + + /** + * Sets the primary dataset for the plot, replacing the existing dataset + * if there is one, and sends a {@code link PlotChangeEvent} to all + * registered listeners. + * + * @param dataset the dataset (null permitted). + * + * @see #getDataset() + */ + public void setDataset(XYDataset dataset) { + setDataset(0, dataset); + } + + /** + * Sets a dataset for the plot, replacing the existing dataset at the same + * index if there is one, and sends a {@code link PlotChangeEvent} to all + * registered listeners. + * + * @param index the dataset index. + * @param dataset the dataset (null permitted). + * + * @see #getDataset(int) + * + * @since 1.0.14 + */ + public void setDataset(int index, XYDataset dataset) { + XYDataset existing = getDataset(index); + if (existing != null) { + existing.removeChangeListener(this); + } + this.datasets.set(index, dataset); + if (dataset != null) { + dataset.addChangeListener(this); + } + + // send a dataset change event to self... + DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); + datasetChanged(event); + } + + /** + * Returns the number of datasets. + * + * @return The number of datasets. + * + * @since 1.0.14 + */ + public int getDatasetCount() { + return this.datasets.size(); + } + + /** + * Returns the index of the specified dataset, or -1 if the + * dataset does not belong to the plot. + * + * @param dataset the dataset (null not permitted). + * + * @return The index. + * + * @since 1.0.14 + */ + public int indexOf(XYDataset dataset) { + int result = -1; + for (int i = 0; i < this.datasets.size(); i++) { + if (dataset == this.datasets.get(i)) { + result = i; + break; + } + } + return result; + } + + /** + * Returns the primary renderer. + * + * @return The renderer (possibly null). + * + * @see #setRenderer(PolarItemRenderer) + */ + public PolarItemRenderer getRenderer() { + return getRenderer(0); + } + + /** + * Returns the renderer at the specified index, if there is one. + * + * @param index the renderer index. + * + * @return The renderer (possibly null). + * + * @see #setRenderer(int, PolarItemRenderer) + * + * @since 1.0.14 + */ + public PolarItemRenderer getRenderer(int index) { + PolarItemRenderer result = null; + if (index < this.renderers.size()) { + result = (PolarItemRenderer) this.renderers.get(index); + } + return result; + } + + /** + * Sets the primary renderer, and notifies all listeners of a change to the + * plot. If the renderer is set to null, no data items will + * be drawn for the corresponding dataset. + * + * @param renderer the new renderer (null permitted). + * + * @see #getRenderer() + */ + public void setRenderer(PolarItemRenderer renderer) { + setRenderer(0, renderer); + } + + /** + * Sets a renderer and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param index the index. + * @param renderer the renderer. + * + * @see #getRenderer(int) + * + * @since 1.0.14 + */ + public void setRenderer(int index, PolarItemRenderer renderer) { + setRenderer(index, renderer, true); + } + + /** + * Sets a renderer and, if requested, sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param index the index. + * @param renderer the renderer. + * @param notify notify listeners? + * + * @see #getRenderer(int) + * + * @since 1.0.14 + */ + public void setRenderer(int index, PolarItemRenderer renderer, + boolean notify) { + PolarItemRenderer existing = getRenderer(index); + if (existing != null) { + existing.removeChangeListener(this); + } + this.renderers.set(index, renderer); + if (renderer != null) { + renderer.setPlot(this); + renderer.addChangeListener(this); + } + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the tick unit that controls the spacing of the angular grid + * lines. + * + * @return The tick unit (never null). + * + * @since 1.0.10 + */ + public TickUnit getAngleTickUnit() { + return this.angleTickUnit; + } + + /** + * Sets the tick unit that controls the spacing of the angular grid + * lines, and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param unit the tick unit (null not permitted). + * + * @since 1.0.10 + */ + public void setAngleTickUnit(TickUnit unit) { + ParamChecks.nullNotPermitted(unit, "unit"); + this.angleTickUnit = unit; + fireChangeEvent(); + } + + /** + * Returns the offset that is used for all angles. + * + * @return The offset for the angles. + * @since 1.0.14 + */ + public double getAngleOffset() { + return this.angleOffset; + } + + /** + * Sets the offset that is used for all angles and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * This is useful to let 0 degrees be at the north, east, south or west + * side of the chart. + * + * @param offset The offset + * @since 1.0.14 + */ + public void setAngleOffset(double offset) { + this.angleOffset = offset; + fireChangeEvent(); + } + + /** + * Get the direction for growing angle degrees. + * + * @return true if angle increases counterclockwise, + * false otherwise. + * @since 1.0.14 + */ + public boolean isCounterClockwise() { + return this.counterClockwise; + } + + /** + * Sets the flag for increasing angle degrees direction. + * + * true for counterclockwise, false for + * clockwise. + * + * @param counterClockwise The flag. + * @since 1.0.14 + */ + public void setCounterClockwise(boolean counterClockwise) + { + this.counterClockwise = counterClockwise; + } + + /** + * Returns a flag that controls whether or not the angle labels are visible. + * + * @return A boolean. + * + * @see #setAngleLabelsVisible(boolean) + */ + public boolean isAngleLabelsVisible() { + return this.angleLabelsVisible; + } + + /** + * Sets the flag that controls whether or not the angle labels are visible, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param visible the flag. + * + * @see #isAngleLabelsVisible() + */ + public void setAngleLabelsVisible(boolean visible) { + if (this.angleLabelsVisible != visible) { + this.angleLabelsVisible = visible; + fireChangeEvent(); + } + } + + /** + * Returns the font used to display the angle labels. + * + * @return A font (never null). + * + * @see #setAngleLabelFont(Font) + */ + public Font getAngleLabelFont() { + return this.angleLabelFont; + } + + /** + * Sets the font used to display the angle labels and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getAngleLabelFont() + */ + public void setAngleLabelFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.angleLabelFont = font; + fireChangeEvent(); + } + + /** + * Returns the paint used to display the angle labels. + * + * @return A paint (never null). + * + * @see #setAngleLabelPaint(Paint) + */ + public Paint getAngleLabelPaint() { + return this.angleLabelPaint; + } + + /** + * Sets the paint used to display the angle labels and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + */ + public void setAngleLabelPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.angleLabelPaint = paint; + fireChangeEvent(); + } + + /** + * Returns true if the angular gridlines are visible, and + * false otherwise. + * + * @return true or false. + * + * @see #setAngleGridlinesVisible(boolean) + */ + public boolean isAngleGridlinesVisible() { + return this.angleGridlinesVisible; + } + + /** + * Sets the flag that controls whether or not the angular grid-lines are + * visible. + *

+ * If the flag value is changed, a {@link PlotChangeEvent} is sent to all + * registered listeners. + * + * @param visible the new value of the flag. + * + * @see #isAngleGridlinesVisible() + */ + public void setAngleGridlinesVisible(boolean visible) { + if (this.angleGridlinesVisible != visible) { + this.angleGridlinesVisible = visible; + fireChangeEvent(); + } + } + + /** + * Returns the stroke for the grid-lines (if any) plotted against the + * angular axis. + * + * @return The stroke (possibly null). + * + * @see #setAngleGridlineStroke(Stroke) + */ + public Stroke getAngleGridlineStroke() { + return this.angleGridlineStroke; + } + + /** + * Sets the stroke for the grid lines plotted against the angular axis and + * sends a {@link PlotChangeEvent} to all registered listeners. + *

+ * If you set this to null, no grid lines will be drawn. + * + * @param stroke the stroke (null permitted). + * + * @see #getAngleGridlineStroke() + */ + public void setAngleGridlineStroke(Stroke stroke) { + this.angleGridlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint for the grid lines (if any) plotted against the + * angular axis. + * + * @return The paint (possibly null). + * + * @see #setAngleGridlinePaint(Paint) + */ + public Paint getAngleGridlinePaint() { + return this.angleGridlinePaint; + } + + /** + * Sets the paint for the grid lines plotted against the angular axis. + *

+ * If you set this to null, no grid lines will be drawn. + * + * @param paint the paint (null permitted). + * + * @see #getAngleGridlinePaint() + */ + public void setAngleGridlinePaint(Paint paint) { + this.angleGridlinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns true if the radius axis grid is visible, and + * false otherwise. + * + * @return true or false. + * + * @see #setRadiusGridlinesVisible(boolean) + */ + public boolean isRadiusGridlinesVisible() { + return this.radiusGridlinesVisible; + } + + /** + * Sets the flag that controls whether or not the radius axis grid lines + * are visible. + *

+ * If the flag value is changed, a {@link PlotChangeEvent} is sent to all + * registered listeners. + * + * @param visible the new value of the flag. + * + * @see #isRadiusGridlinesVisible() + */ + public void setRadiusGridlinesVisible(boolean visible) { + if (this.radiusGridlinesVisible != visible) { + this.radiusGridlinesVisible = visible; + fireChangeEvent(); + } + } + + /** + * Returns the stroke for the grid lines (if any) plotted against the + * radius axis. + * + * @return The stroke (possibly null). + * + * @see #setRadiusGridlineStroke(Stroke) + */ + public Stroke getRadiusGridlineStroke() { + return this.radiusGridlineStroke; + } + + /** + * Sets the stroke for the grid lines plotted against the radius axis and + * sends a {@link PlotChangeEvent} to all registered listeners. + *

+ * If you set this to null, no grid lines will be drawn. + * + * @param stroke the stroke (null permitted). + * + * @see #getRadiusGridlineStroke() + */ + public void setRadiusGridlineStroke(Stroke stroke) { + this.radiusGridlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint for the grid lines (if any) plotted against the radius + * axis. + * + * @return The paint (possibly null). + * + * @see #setRadiusGridlinePaint(Paint) + */ + public Paint getRadiusGridlinePaint() { + return this.radiusGridlinePaint; + } + + /** + * Sets the paint for the grid lines plotted against the radius axis and + * sends a {@link PlotChangeEvent} to all registered listeners. + *

+ * If you set this to null, no grid lines will be drawn. + * + * @param paint the paint (null permitted). + * + * @see #getRadiusGridlinePaint() + */ + public void setRadiusGridlinePaint(Paint paint) { + this.radiusGridlinePaint = paint; + fireChangeEvent(); + } + + /** + * Return the current value of the flag indicating if radial minor + * grid-lines will be drawn or not. + * + * @return Returns true if radial minor grid-lines are drawn. + * @since 1.0.15 + */ + public boolean isRadiusMinorGridlinesVisible() { + return this.radiusMinorGridlinesVisible; + } + + /** + * Set the flag that determines if radial minor grid-lines will be drawn, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param flag true to draw the radial minor grid-lines, + * false to hide them. + * @since 1.0.15 + */ + public void setRadiusMinorGridlinesVisible(boolean flag) { + this.radiusMinorGridlinesVisible = flag; + fireChangeEvent(); + } + + /** + * Returns the margin around the plot area. + * + * @return The actual margin in pixels. + * + * @since 1.0.14 + */ + public int getMargin() { + return this.margin; + } + + /** + * Set the margin around the plot area and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param margin The new margin in pixels. + * + * @since 1.0.14 + */ + public void setMargin(int margin) { + this.margin = margin; + fireChangeEvent(); + } + + /** + * Returns the fixed legend items, if any. + * + * @return The legend items (possibly null). + * + * @see #setFixedLegendItems(LegendItemCollection) + * + * @since 1.0.14 + */ + public LegendItemCollection getFixedLegendItems() { + return this.fixedLegendItems; + } + + /** + * Sets the fixed legend items for the plot. Leave this set to + * null if you prefer the legend items to be created + * automatically. + * + * @param items the legend items (null permitted). + * + * @see #getFixedLegendItems() + * + * @since 1.0.14 + */ + public void setFixedLegendItems(LegendItemCollection items) { + this.fixedLegendItems = items; + fireChangeEvent(); + } + + /** + * Add text to be displayed in the lower right hand corner and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param text the text to display (null not permitted). + * + * @see #removeCornerTextItem(String) + */ + public void addCornerTextItem(String text) { + ParamChecks.nullNotPermitted(text, "text"); + this.cornerTextItems.add(text); + fireChangeEvent(); + } + + /** + * Remove the given text from the list of corner text items and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param text the text to remove (null ignored). + * + * @see #addCornerTextItem(String) + */ + public void removeCornerTextItem(String text) { + boolean removed = this.cornerTextItems.remove(text); + if (removed) { + fireChangeEvent(); + } + } + + /** + * Clear the list of corner text items and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @see #addCornerTextItem(String) + * @see #removeCornerTextItem(String) + */ + public void clearCornerTextItems() { + if (this.cornerTextItems.size() > 0) { + this.cornerTextItems.clear(); + fireChangeEvent(); + } + } + + /** + * Generates a list of tick values for the angular tick marks. + * + * @return A list of {@link NumberTick} instances. + * + * @since 1.0.10 + */ + protected List refreshAngleTicks() { + List ticks = new ArrayList(); + for (double currentTickVal = 0.0; currentTickVal < 360.0; + currentTickVal += this.angleTickUnit.getSize()) { + + TextAnchor ta = calculateTextAnchor(currentTickVal); + NumberTick tick = new NumberTick(new Double(currentTickVal), + this.angleTickUnit.valueToString(currentTickVal), + ta, TextAnchor.CENTER, 0.0); + ticks.add(tick); + } + return ticks; + } + + /** + * Calculate the text position for the given degrees. + * + * @param angleDegrees the angle in degrees. + * + * @return The optimal text anchor. + * @since 1.0.14 + */ + protected TextAnchor calculateTextAnchor(double angleDegrees) { + TextAnchor ta = TextAnchor.CENTER; + + // normalize angle + double offset = this.angleOffset; + while (offset < 0.0) { + offset += 360.0; + } + double normalizedAngle = (((this.counterClockwise ? -1 : 1) + * angleDegrees) + offset) % 360; + while (this.counterClockwise && (normalizedAngle < 0.0)) { + normalizedAngle += 360.0; + } + + if (normalizedAngle == 0.0) { + ta = TextAnchor.CENTER_LEFT; + } + else if (normalizedAngle > 0.0 && normalizedAngle < 90.0) { + ta = TextAnchor.TOP_LEFT; + } + else if (normalizedAngle == 90.0) { + ta = TextAnchor.TOP_CENTER; + } + else if (normalizedAngle > 90.0 && normalizedAngle < 180.0) { + ta = TextAnchor.TOP_RIGHT; + } + else if (normalizedAngle == 180) { + ta = TextAnchor.CENTER_RIGHT; + } + else if (normalizedAngle > 180.0 && normalizedAngle < 270.0) { + ta = TextAnchor.BOTTOM_RIGHT; + } + else if (normalizedAngle == 270) { + ta = TextAnchor.BOTTOM_CENTER; + } + else if (normalizedAngle > 270.0 && normalizedAngle < 360.0) { + ta = TextAnchor.BOTTOM_LEFT; + } + return ta; + } + + /** + * Maps a dataset to a particular axis. All data will be plotted + * against axis zero by default, no mapping is required for this case. + * + * @param index the dataset index (zero-based). + * @param axisIndex the axis index. + * + * @since 1.0.14 + */ + public void mapDatasetToAxis(int index, int axisIndex) { + List axisIndices = new java.util.ArrayList(1); + axisIndices.add(new Integer(axisIndex)); + mapDatasetToAxes(index, axisIndices); + } + + /** + * Maps the specified dataset to the axes in the list. Note that the + * conversion of data values into Java2D space is always performed using + * the first axis in the list. + * + * @param index the dataset index (zero-based). + * @param axisIndices the axis indices (null permitted). + * + * @since 1.0.14 + */ + public void mapDatasetToAxes(int index, List axisIndices) { + if (index < 0) { + throw new IllegalArgumentException("Requires 'index' >= 0."); + } + checkAxisIndices(axisIndices); + Integer key = new Integer(index); + this.datasetToAxesMap.put(key, new ArrayList(axisIndices)); + // fake a dataset change event to update axes... + datasetChanged(new DatasetChangeEvent(this, getDataset(index))); + } + + /** + * This method is used to perform argument checking on the list of + * axis indices passed to mapDatasetToAxes(). + * + * @param indices the list of indices (null permitted). + */ + private void checkAxisIndices(List indices) { + // axisIndices can be: + // 1. null; + // 2. non-empty, containing only Integer objects that are unique. + if (indices == null) { + return; // OK + } + int count = indices.size(); + if (count == 0) { + throw new IllegalArgumentException("Empty list not permitted."); + } + HashSet set = new HashSet(); + for (int i = 0; i < count; i++) { + Object item = indices.get(i); + if (!(item instanceof Integer)) { + throw new IllegalArgumentException( + "Indices must be Integer instances."); + } + if (set.contains(item)) { + throw new IllegalArgumentException("Indices must be unique."); + } + set.add(item); + } + } + + /** + * Returns the axis for a dataset. + * + * @param index the dataset index. + * + * @return The axis. + * + * @since 1.0.14 + */ + public ValueAxis getAxisForDataset(int index) { + ValueAxis valueAxis; + List axisIndices = (List) this.datasetToAxesMap.get( + new Integer(index)); + if (axisIndices != null) { + // the first axis in the list is used for data <--> Java2D + Integer axisIndex = (Integer) axisIndices.get(0); + valueAxis = getAxis(axisIndex.intValue()); + } + else { + valueAxis = getAxis(0); + } + return valueAxis; + } + + /** + * Returns the index of the given axis. + * + * @param axis the axis. + * + * @return The axis index or -1 if axis is not used in this plot. + * + * @since 1.0.14 + */ + public int getAxisIndex(ValueAxis axis) { + int result = this.axes.indexOf(axis); + if (result < 0) { + // try the parent plot + Plot parent = getParent(); + if (parent instanceof PolarPlot) { + PolarPlot p = (PolarPlot) parent; + result = p.getAxisIndex(axis); + } + } + return result; + } + + /** + * Returns the index of the specified renderer, or -1 if the + * renderer is not assigned to this plot. + * + * @param renderer the renderer (null permitted). + * + * @return The renderer index. + * + * @since 1.0.14 + */ + public int getIndexOf(PolarItemRenderer renderer) { + return this.renderers.indexOf(renderer); + } + + /** + * Draws the plot on a Java 2D graphics device (such as the screen or a + * printer). + *

+ * This plot relies on a {@link PolarItemRenderer} to draw each + * item in the plot. This allows the visual representation of the data to + * be changed easily. + *

+ * The optional info argument collects information about the rendering of + * the plot (dimensions, tooltip information etc). Just pass in + * null if you do not need this information. + * + * @param g2 the graphics device. + * @param area the area within which the plot (including axes and + * labels) should be drawn. + * @param anchor the anchor point (null permitted). + * @param parentState ignored. + * @param info collects chart drawing information (null + * permitted). + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, PlotRenderingInfo info) { + + // if the plot area is too small, just return... + boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); + boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); + if (b1 || b2) { + return; + } + + // record the plot area... + if (info != null) { + info.setPlotArea(area); + } + + // adjust the drawing area for the plot insets (if any)... + RectangleInsets insets = getInsets(); + insets.trim(area); + + Rectangle2D dataArea = area; + if (info != null) { + info.setDataArea(dataArea); + } + + // draw the plot background and axes... + drawBackground(g2, dataArea); + int axisCount = this.axes.size(); + AxisState state = null; + for (int i = 0; i < axisCount; i++) { + ValueAxis axis = getAxis(i); + if (axis != null) { + PolarAxisLocation location + = (PolarAxisLocation) this.axisLocations.get(i); + AxisState s = this.drawAxis(axis, location, g2, dataArea); + if (i == 0) { + state = s; + } + } + } + + // now for each dataset, get the renderer and the appropriate axis + // and render the dataset... + Shape originalClip = g2.getClip(); + Composite originalComposite = g2.getComposite(); + + g2.clip(dataArea); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + getForegroundAlpha())); + this.angleTicks = refreshAngleTicks(); + drawGridlines(g2, dataArea, this.angleTicks, state.getTicks()); + render(g2, dataArea, info); + g2.setClip(originalClip); + g2.setComposite(originalComposite); + drawOutline(g2, dataArea); + drawCornerTextItems(g2, dataArea); + } + + /** + * Draws the corner text items. + * + * @param g2 the drawing surface. + * @param area the area. + */ + protected void drawCornerTextItems(Graphics2D g2, Rectangle2D area) { + if (this.cornerTextItems.isEmpty()) { + return; + } + + g2.setColor(Color.black); + double width = 0.0; + double height = 0.0; + for (Iterator it = this.cornerTextItems.iterator(); it.hasNext();) { + String msg = (String) it.next(); + FontMetrics fm = g2.getFontMetrics(); + Rectangle2D bounds = TextUtilities.getTextBounds(msg, g2, fm); + width = Math.max(width, bounds.getWidth()); + height += bounds.getHeight(); + } + + double xadj = ANNOTATION_MARGIN * 2.0; + double yadj = ANNOTATION_MARGIN; + width += xadj; + height += yadj; + + double x = area.getMaxX() - width; + double y = area.getMaxY() - height; + g2.drawRect((int) x, (int) y, (int) width, (int) height); + x += ANNOTATION_MARGIN; + for (Iterator it = this.cornerTextItems.iterator(); it.hasNext();) { + String msg = (String) it.next(); + Rectangle2D bounds = TextUtilities.getTextBounds(msg, g2, + g2.getFontMetrics()); + y += bounds.getHeight(); + g2.drawString(msg, (int) x, (int) y); + } + } + + /** + * Draws the axis with the specified index. + * + * @param axis the axis. + * @param location the axis location. + * @param g2 the graphics target. + * @param plotArea the plot area. + * + * @return The axis state. + * + * @since 1.0.14 + */ + protected AxisState drawAxis(ValueAxis axis, PolarAxisLocation location, + Graphics2D g2, Rectangle2D plotArea) { + + double centerX = plotArea.getCenterX(); + double centerY = plotArea.getCenterY(); + double r = Math.min(plotArea.getWidth() / 2.0, + plotArea.getHeight() / 2.0) - this.margin; + double x = centerX - r; + double y = centerY - r; + + Rectangle2D dataArea = null; + AxisState result = null; + if (location == PolarAxisLocation.NORTH_RIGHT) { + dataArea = new Rectangle2D.Double(x, y, r, r); + result = axis.draw(g2, centerX, plotArea, dataArea, + RectangleEdge.RIGHT, null); + } + else if (location == PolarAxisLocation.NORTH_LEFT) { + dataArea = new Rectangle2D.Double(centerX, y, r, r); + result = axis.draw(g2, centerX, plotArea, dataArea, + RectangleEdge.LEFT, null); + } + else if (location == PolarAxisLocation.SOUTH_LEFT) { + dataArea = new Rectangle2D.Double(centerX, centerY, r, r); + result = axis.draw(g2, centerX, plotArea, dataArea, + RectangleEdge.LEFT, null); + } + else if (location == PolarAxisLocation.SOUTH_RIGHT) { + dataArea = new Rectangle2D.Double(x, centerY, r, r); + result = axis.draw(g2, centerX, plotArea, dataArea, + RectangleEdge.RIGHT, null); + } + else if (location == PolarAxisLocation.EAST_ABOVE) { + dataArea = new Rectangle2D.Double(centerX, centerY, r, r); + result = axis.draw(g2, centerY, plotArea, dataArea, + RectangleEdge.TOP, null); + } + else if (location == PolarAxisLocation.EAST_BELOW) { + dataArea = new Rectangle2D.Double(centerX, y, r, r); + result = axis.draw(g2, centerY, plotArea, dataArea, + RectangleEdge.BOTTOM, null); + } + else if (location == PolarAxisLocation.WEST_ABOVE) { + dataArea = new Rectangle2D.Double(x, centerY, r, r); + result = axis.draw(g2, centerY, plotArea, dataArea, + RectangleEdge.TOP, null); + } + else if (location == PolarAxisLocation.WEST_BELOW) { + dataArea = new Rectangle2D.Double(x, y, r, r); + result = axis.draw(g2, centerY, plotArea, dataArea, + RectangleEdge.BOTTOM, null); + } + + return result; + } + + /** + * Draws a representation of the data within the dataArea region, using the + * current m_Renderer. + * + * @param g2 the graphics device. + * @param dataArea the region in which the data is to be drawn. + * @param info an optional object for collection dimension + * information (null permitted). + */ + protected void render(Graphics2D g2, Rectangle2D dataArea, + PlotRenderingInfo info) { + + // now get the data and plot it (the visual representation will depend + // on the m_Renderer that has been set)... + boolean hasData = false; + int datasetCount = this.datasets.size(); + for (int i = datasetCount - 1; i >= 0; i--) { + XYDataset dataset = getDataset(i); + if (dataset == null) { + continue; + } + PolarItemRenderer renderer = getRenderer(i); + if (renderer == null) { + continue; + } + if (!DatasetUtilities.isEmptyOrNull(dataset)) { + hasData = true; + int seriesCount = dataset.getSeriesCount(); + for (int series = 0; series < seriesCount; series++) { + renderer.drawSeries(g2, dataArea, info, this, dataset, + series); + } + } + } + if (!hasData) { + drawNoDataMessage(g2, dataArea); + } + } + + /** + * Draws the gridlines for the plot, if they are visible. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param angularTicks the ticks for the angular axis. + * @param radialTicks the ticks for the radial axis. + */ + protected void drawGridlines(Graphics2D g2, Rectangle2D dataArea, + List angularTicks, List radialTicks) { + + PolarItemRenderer renderer = getRenderer(); + // no renderer, no gridlines... + if (renderer == null) { + return; + } + + // draw the domain grid lines, if any... + if (isAngleGridlinesVisible()) { + Stroke gridStroke = getAngleGridlineStroke(); + Paint gridPaint = getAngleGridlinePaint(); + if ((gridStroke != null) && (gridPaint != null)) { + renderer.drawAngularGridLines(g2, this, angularTicks, + dataArea); + } + } + + // draw the radius grid lines, if any... + if (isRadiusGridlinesVisible()) { + Stroke gridStroke = getRadiusGridlineStroke(); + Paint gridPaint = getRadiusGridlinePaint(); + if ((gridStroke != null) && (gridPaint != null)) { + List ticks = buildRadialTicks(radialTicks); + renderer.drawRadialGridLines(g2, this, getAxis(), + ticks, dataArea); + } + } + } + + /** + * Create a list of ticks based on the given list and plot properties. + * Only ticks of a specific type may be in the result list. + * + * @param allTicks A list of all available ticks for the primary axis. + * null not permitted. + * @return Ticks to use for radial gridlines. + * @since 1.0.15 + */ + protected List buildRadialTicks(List allTicks) + { + List ticks = new ArrayList(); + Iterator it = allTicks.iterator(); + while (it.hasNext()) { + ValueTick tick = (ValueTick) it.next(); + if (isRadiusMinorGridlinesVisible() || + TickType.MAJOR.equals(tick.getTickType())) { + ticks.add(tick); + } + } + return ticks; + } + + /** + * Zooms the axis ranges by the specified percentage about the anchor point. + * + * @param percent the amount of the zoom. + */ + @Override + public void zoom(double percent) { + for (int axisIdx = 0; axisIdx < getAxisCount(); axisIdx++) { + final ValueAxis axis = getAxis(axisIdx); + if (axis != null) { + if (percent > 0.0) { + double radius = axis.getUpperBound(); + double scaledRadius = radius * percent; + axis.setUpperBound(scaledRadius); + axis.setAutoRange(false); + } + else { + axis.setAutoRange(true); + } + } + } + } + + /** + * A utility method that returns a list of datasets that are mapped to a + * particular axis. + * + * @param axisIndex the axis index (null not permitted). + * + * @return A list of datasets. + * + * @since 1.0.14 + */ + private List getDatasetsMappedToAxis(Integer axisIndex) { + ParamChecks.nullNotPermitted(axisIndex, "axisIndex"); + List result = new ArrayList(); + for (int i = 0; i < this.datasets.size(); i++) { + List mappedAxes = (List) this.datasetToAxesMap.get(new Integer(i)); + if (mappedAxes == null) { + if (axisIndex.equals(ZERO)) { + result.add(this.datasets.get(i)); + } + } + else { + if (mappedAxes.contains(axisIndex)) { + result.add(this.datasets.get(i)); + } + } + } + return result; + } + + /** + * Returns the range for the specified axis. + * + * @param axis the axis. + * + * @return The range. + */ + @Override + public Range getDataRange(ValueAxis axis) { + Range result = null; + int axisIdx = getAxisIndex(axis); + List mappedDatasets = new ArrayList(); + + if (axisIdx >= 0) { + mappedDatasets = getDatasetsMappedToAxis(new Integer(axisIdx)); + } + + // iterate through the datasets that map to the axis and get the union + // of the ranges. + Iterator iterator = mappedDatasets.iterator(); + int datasetIdx = -1; + while (iterator.hasNext()) { + datasetIdx++; + XYDataset d = (XYDataset) iterator.next(); + if (d != null) { + // FIXME better ask the renderer instead of DatasetUtilities + result = Range.combine(result, + DatasetUtilities.findRangeBounds(d)); + } + } + + return result; + } + + /** + * Receives notification of a change to the plot's m_Dataset. + *

+ * The axis ranges are updated if necessary. + * + * @param event information about the event (not used here). + */ + @Override + public void datasetChanged(DatasetChangeEvent event) { + for (int i = 0; i < this.axes.size(); i++) { + final ValueAxis axis = (ValueAxis) this.axes.get(i); + if (axis != null) { + axis.configure(); + } + } + if (getParent() != null) { + getParent().datasetChanged(event); + } + else { + super.datasetChanged(event); + } + } + + /** + * Notifies all registered listeners of a property change. + *

+ * One source of property change events is the plot's m_Renderer. + * + * @param event information about the property change. + */ + @Override + public void rendererChanged(RendererChangeEvent event) { + fireChangeEvent(); + } + + /** + * Returns the legend items for the plot. Each legend item is generated by + * the plot's m_Renderer, since the m_Renderer is responsible for the visual + * representation of the data. + * + * @return The legend items. + */ + @Override + public LegendItemCollection getLegendItems() { + if (this.fixedLegendItems != null) { + return this.fixedLegendItems; + } + LegendItemCollection result = new LegendItemCollection(); + int count = this.datasets.size(); + for (int datasetIndex = 0; datasetIndex < count; datasetIndex++) { + XYDataset dataset = getDataset(datasetIndex); + PolarItemRenderer renderer = getRenderer(datasetIndex); + if (dataset != null && renderer != null) { + int seriesCount = dataset.getSeriesCount(); + for (int i = 0; i < seriesCount; i++) { + LegendItem item = renderer.getLegendItem(i); + result.add(item); + } + } + } + return result; + } + + /** + * Tests this plot for equality with another object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PolarPlot)) { + return false; + } + PolarPlot that = (PolarPlot) obj; + if (!this.axes.equals(that.axes)) { + return false; + } + if (!this.axisLocations.equals(that.axisLocations)) { + return false; + } + if (!this.renderers.equals(that.renderers)) { + return false; + } + if (!this.angleTickUnit.equals(that.angleTickUnit)) { + return false; + } + if (this.angleGridlinesVisible != that.angleGridlinesVisible) { + return false; + } + if (this.angleOffset != that.angleOffset) + { + return false; + } + if (this.counterClockwise != that.counterClockwise) + { + return false; + } + if (this.angleLabelsVisible != that.angleLabelsVisible) { + return false; + } + if (!this.angleLabelFont.equals(that.angleLabelFont)) { + return false; + } + if (!PaintUtilities.equal(this.angleLabelPaint, that.angleLabelPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.angleGridlineStroke, + that.angleGridlineStroke)) { + return false; + } + if (!PaintUtilities.equal( + this.angleGridlinePaint, that.angleGridlinePaint + )) { + return false; + } + if (this.radiusGridlinesVisible != that.radiusGridlinesVisible) { + return false; + } + if (!ObjectUtilities.equal(this.radiusGridlineStroke, + that.radiusGridlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.radiusGridlinePaint, + that.radiusGridlinePaint)) { + return false; + } + if (this.radiusMinorGridlinesVisible != + that.radiusMinorGridlinesVisible) { + return false; + } + if (!this.cornerTextItems.equals(that.cornerTextItems)) { + return false; + } + if (this.margin != that.margin) { + return false; + } + if (!ObjectUtilities.equal(this.fixedLegendItems, + that.fixedLegendItems)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the plot. + * + * @return A clone. + * + * @throws CloneNotSupportedException this can occur if some component of + * the plot cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + PolarPlot clone = (PolarPlot) super.clone(); + clone.axes = (ObjectList) ObjectUtilities.clone(this.axes); + for (int i = 0; i < this.axes.size(); i++) { + ValueAxis axis = (ValueAxis) this.axes.get(i); + if (axis != null) { + ValueAxis clonedAxis = (ValueAxis) axis.clone(); + clone.axes.set(i, clonedAxis); + clonedAxis.setPlot(clone); + clonedAxis.addChangeListener(clone); + } + } + + // the datasets are not cloned, but listeners need to be added... + clone.datasets = (ObjectList) ObjectUtilities.clone(this.datasets); + for (int i = 0; i < clone.datasets.size(); ++i) { + XYDataset d = getDataset(i); + if (d != null) { + d.addChangeListener(clone); + } + } + + clone.renderers = (ObjectList) ObjectUtilities.clone(this.renderers); + for (int i = 0; i < this.renderers.size(); i++) { + PolarItemRenderer renderer2 = (PolarItemRenderer) this.renderers.get(i); + if (renderer2 instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) renderer2; + PolarItemRenderer rc = (PolarItemRenderer) pc.clone(); + clone.renderers.set(i, rc); + rc.setPlot(clone); + rc.addChangeListener(clone); + } + } + + clone.cornerTextItems = new ArrayList(this.cornerTextItems); + + 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.writeStroke(this.angleGridlineStroke, stream); + SerialUtilities.writePaint(this.angleGridlinePaint, stream); + SerialUtilities.writeStroke(this.radiusGridlineStroke, stream); + SerialUtilities.writePaint(this.radiusGridlinePaint, stream); + SerialUtilities.writePaint(this.angleLabelPaint, 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.angleGridlineStroke = SerialUtilities.readStroke(stream); + this.angleGridlinePaint = SerialUtilities.readPaint(stream); + this.radiusGridlineStroke = SerialUtilities.readStroke(stream); + this.radiusGridlinePaint = SerialUtilities.readPaint(stream); + this.angleLabelPaint = SerialUtilities.readPaint(stream); + + int rangeAxisCount = this.axes.size(); + for (int i = 0; i < rangeAxisCount; i++) { + Axis axis = (Axis) this.axes.get(i); + if (axis != null) { + axis.setPlot(this); + axis.addChangeListener(this); + } + } + int datasetCount = this.datasets.size(); + for (int i = 0; i < datasetCount; i++) { + Dataset dataset = (Dataset) this.datasets.get(i); + if (dataset != null) { + dataset.addChangeListener(this); + } + } + int rendererCount = this.renderers.size(); + for (int i = 0; i < rendererCount; i++) { + PolarItemRenderer renderer = (PolarItemRenderer) this.renderers.get(i); + if (renderer != null) { + renderer.addChangeListener(this); + } + } + } + + /** + * This method is required by the {@link Zoomable} interface, but since + * the plot does not have any domain axes, it does nothing. + * + * @param factor the zoom factor. + * @param state the plot state. + * @param source the source point (in Java2D coordinates). + */ + @Override + public void zoomDomainAxes(double factor, PlotRenderingInfo state, + Point2D source) { + // do nothing + } + + /** + * This method is required by the {@link Zoomable} interface, but since + * the plot does not have any domain axes, it does nothing. + * + * @param factor the zoom factor. + * @param state the plot state. + * @param source the source point (in Java2D coordinates). + * @param useAnchor use source point as zoom anchor? + * + * @since 1.0.7 + */ + @Override + public void zoomDomainAxes(double factor, PlotRenderingInfo state, + Point2D source, boolean useAnchor) { + // do nothing + } + + /** + * This method is required by the {@link Zoomable} interface, but since + * the plot does not have any domain axes, it does nothing. + * + * @param lowerPercent the new lower bound. + * @param upperPercent the new upper bound. + * @param state the plot state. + * @param source the source point (in Java2D coordinates). + */ + @Override + public void zoomDomainAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo state, Point2D source) { + // do nothing + } + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param state the plot state. + * @param source the source point (in Java2D coordinates). + */ + @Override + public void zoomRangeAxes(double factor, PlotRenderingInfo state, + Point2D source) { + zoom(factor); + } + + /** + * Multiplies the range on the range axis by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info. + * @param source the source point (in Java2D space). + * @param useAnchor use source point as zoom anchor? + * + * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean) + * + * @since 1.0.7 + */ + @Override + public void zoomRangeAxes(double factor, PlotRenderingInfo info, + Point2D source, boolean useAnchor) { + // get the source coordinate - this plot has always a VERTICAL + // orientation + final double sourceX = source.getX(); + + for (int axisIdx = 0; axisIdx < getAxisCount(); axisIdx++) { + final ValueAxis axis = getAxis(axisIdx); + if (axis != null) { + if (useAnchor) { + double anchorX = axis.java2DToValue(sourceX, + info.getDataArea(), RectangleEdge.BOTTOM); + axis.resizeRange(factor, anchorX); + } + else { + axis.resizeRange(factor); + } + } + } + } + + /** + * Zooms in on the range axes. + * + * @param lowerPercent the new lower bound. + * @param upperPercent the new upper bound. + * @param state the plot state. + * @param source the source point (in Java2D coordinates). + */ + @Override + public void zoomRangeAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo state, Point2D source) { + zoom((upperPercent + lowerPercent) / 2.0); + } + + /** + * Returns false always. + * + * @return false always. + */ + @Override + public boolean isDomainZoomable() { + return false; + } + + /** + * Returns true to indicate that the range axis is zoomable. + * + * @return true. + */ + @Override + public boolean isRangeZoomable() { + return true; + } + + /** + * Returns the orientation of the plot. + * + * @return The orientation. + */ + @Override + public PlotOrientation getOrientation() { + return PlotOrientation.HORIZONTAL; + } + + /** + * Translates a (theta, radius) pair into Java2D coordinates. If + * radius is less than the lower bound of the axis, then + * this method returns the centre point. + * + * @param angleDegrees the angle in degrees. + * @param radius the radius. + * @param axis the axis. + * @param dataArea the data area. + * + * @return A point in Java2D space. + * + * @since 1.0.14 + */ + public Point translateToJava2D(double angleDegrees, double radius, + ValueAxis axis, Rectangle2D dataArea) { + + if (counterClockwise) { + angleDegrees = -angleDegrees; + } + double radians = Math.toRadians(angleDegrees + this.angleOffset); + + double minx = dataArea.getMinX() + this.margin; + double maxx = dataArea.getMaxX() - this.margin; + double miny = dataArea.getMinY() + this.margin; + double maxy = dataArea.getMaxY() - this.margin; + + double halfWidth = (maxx - minx) / 2.0; + double halfHeight = (maxy - miny) / 2.0; + + double midX = minx + halfWidth; + double midY = miny + halfHeight; + + double l = Math.min(halfWidth, halfHeight); + Rectangle2D quadrant = new Rectangle2D.Double(midX, midY, l, l); + + double axisMin = axis.getLowerBound(); + double adjustedRadius = Math.max(radius, axisMin); + + double length = axis.valueToJava2D(adjustedRadius, quadrant, RectangleEdge.BOTTOM) - midX; + float x = (float) (midX + Math.cos(radians) * length); + float y = (float) (midY + Math.sin(radians) * length); + + int ix = Math.round(x); + int iy = Math.round(y); + + Point p = new Point(ix, iy); + return p; + + } + + /** + * Translates a (theta, radius) pair into Java2D coordinates. If + * radius is less than the lower bound of the axis, then + * this method returns the centre point. + * + * @param angleDegrees the angle in degrees. + * @param radius the radius. + * @param dataArea the data area. + * + * @return A point in Java2D space. + * + * @deprecated Since 1.0.14, use {@link #translateToJava2D(double, double, + * org.jfree.chart.axis.ValueAxis, java.awt.geom.Rectangle2D)} instead. + */ + public Point translateValueThetaRadiusToJava2D(double angleDegrees, + double radius, Rectangle2D dataArea) { + + return translateToJava2D(angleDegrees, radius, getAxis(), dataArea); + } + + /** + * Returns the upper bound of the radius axis. + * + * @return The upper bound. + * + * @deprecated Since 1.0.14, use {@link #getAxis()} and call the + * getUpperBound() method. + */ + public double getMaxRadius() { + return getAxis().getUpperBound(); + } + + /** + * Returns the number of series in the dataset for this plot. If the + * dataset is null, the method returns 0. + * + * @return The series count. + * + * @deprecated Since 1.0.14, grab a reference to the dataset and check + * the series count directly. + */ + public int getSeriesCount() { + int result = 0; + XYDataset dataset = getDataset(0); + if (dataset != null) { + result = dataset.getSeriesCount(); + } + return result; + } + + /** + * A utility method for drawing the axes. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param dataArea the data area. + * + * @return A map containing the axis states. + * + * @deprecated As of version 1.0.14, this method is no longer used. + */ + protected AxisState drawAxis(Graphics2D g2, Rectangle2D plotArea, + Rectangle2D dataArea) { + return getAxis().draw(g2, dataArea.getMinY(), plotArea, dataArea, + RectangleEdge.TOP, null); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/RainbowPalette.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/RainbowPalette.java new file mode 100755 index 0000000..0b44d48 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/RainbowPalette.java @@ -0,0 +1,192 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * RainbowPalette.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); + * 26-Mar-2003 : Implemented Serializable (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 31-Jan-2007 : Deprecated (DG); + * + */ + +package org.jfree.chart.plot; + +import java.io.Serializable; + +import org.jfree.chart.renderer.xy.XYBlockRenderer; + +/** + * Contains the data to construct an 8-bit rainbow palette + * This come from an old application which ran on 8-bit graphics device. + * Thus indexes 0 and 1 were preserved for rendering white and black + * respectively. + * + * @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 RainbowPalette extends ColorPalette implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -1906707320728242478L; + + /** The red values. */ + private int[] red = {255, 0, 120, 115, 111, 106, 102, 97, + 93, 88, 84, 79, 75, 70, 66, 61, + 57, 52, 48, 43, 39, 34, 30, 25, + 21, 16, 12, 7, 3, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 5, + 10, 14, 19, 23, 28, 32, 37, 41, + 46, 50, 55, 59, 64, 68, 73, 77, + 82, 86, 91, 95, 100, 104, 109, 113, + 118, 123, 127, 132, 136, 141, 145, 150, + 154, 159, 163, 168, 172, 177, 181, 186, + 190, 195, 199, 204, 208, 213, 217, 222, + 226, 231, 235, 240, 244, 249, 253, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255}; + + /** The green values. */ + private int[] green = {255, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 2, 6, 11, + 15, 20, 24, 29, 33, 38, 42, 47, + 51, 56, 60, 65, 69, 74, 78, 83, + 87, 92, 96, 101, 105, 110, 114, 119, + 123, 128, 132, 137, 141, 146, 150, 155, + 159, 164, 168, 173, 177, 182, 186, 191, + 195, 200, 204, 209, 213, 218, 222, 227, + 231, 236, 241, 245, 250, 254, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 252, + 248, 243, 239, 234, 230, 225, 221, 216, + 212, 207, 203, 198, 194, 189, 185, 180, + 176, 171, 167, 162, 158, 153, 149, 144, + 140, 135, 131, 126, 122, 117, 113, 108, + 104, 99, 95, 90, 86, 81, 77, 72, + 68, 63, 59, 54, 50, 45, 41, 36, + 32, 27, 23, 18, 14, 9, 5, 0}; + + /** The blue values. */ + private int[] blue = {255, 0, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 255, 255, + 255, 255, 255, 255, 255, 255, 251, 247, + 242, 238, 233, 229, 224, 220, 215, 211, + 206, 202, 197, 193, 188, 184, 179, 175, + 170, 166, 161, 157, 152, 148, 143, 139, + 134, 130, 125, 121, 116, 112, 107, 103, + 98, 94, 89, 85, 80, 76, 71, 67, + 62, 58, 53, 49, 44, 40, 35, 31, + 26, 22, 17, 13, 8, 4, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0}; + + /** + * Default constructor. + */ + public RainbowPalette() { + super(); + initialize(); + } + + /** + * Intializes the palettes indexes + */ + @Override + public void initialize() { + + setPaletteName("Rainbow"); + + this.r = new int[this.red.length]; + this.g = new int[this.green.length]; + this.b = new int[this.blue.length]; + System.arraycopy(this.red, 0, this.r, 0, this.red.length); + System.arraycopy(this.green, 0, this.g, 0, this.green.length); + System.arraycopy(this.blue, 0, this.b, 0, this.blue.length); + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/RingPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/RingPlot.java new file mode 100755 index 0000000..522040e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/RingPlot.java @@ -0,0 +1,563 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * RingPlot.java + * ------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limtied); + * Contributor(s): Christoph Beck (bug 2121818); + * + * Changes + * ------- + * 08-Nov-2004 : Version 1 (DG); + * 22-Feb-2005 : Renamed DonutPlot --> RingPlot (DG); + * 06-Jun-2005 : Added default constructor and fixed equals() method to handle + * GradientPaint (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 20-Dec-2005 : Fixed problem with entity shape (bug 1386328) (DG); + * 27-Sep-2006 : Updated drawItem() method for new lookup methods (DG); + * 12-Oct-2006 : Added configurable section depth (DG); + * 14-Feb-2007 : Added notification in setSectionDepth() method (DG); + * 23-Sep-2008 : Fix for bug 2121818 by Christoph Beck (DG); + * 13-Jul-2009 : Added support for shadow generator (DG); + * 11-Oct-2011 : Check sectionOutlineVisible - bug 3237879 (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +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.Arc2D; +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.entity.EntityCollection; +import org.jfree.chart.entity.PieSectionEntity; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.labels.PieToolTipGenerator; +import org.jfree.chart.urls.PieURLGenerator; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.general.PieDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.Rotation; +import org.jfree.util.ShapeUtilities; +import org.jfree.util.UnitType; + +/** + * A customised pie plot that leaves a hole in the middle. + */ +public class RingPlot extends PiePlot implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 1556064784129676620L; + + /** + * A flag that controls whether or not separators are drawn between the + * sections of the chart. + */ + private boolean separatorsVisible; + + /** The stroke used to draw separators. */ + private transient Stroke separatorStroke; + + /** The paint used to draw separators. */ + private transient Paint separatorPaint; + + /** + * The length of the inner separator extension (as a percentage of the + * depth of the sections). + */ + private double innerSeparatorExtension; + + /** + * The length of the outer separator extension (as a percentage of the + * depth of the sections). + */ + private double outerSeparatorExtension; + + /** + * The depth of the section as a percentage of the diameter. + */ + private double sectionDepth; + + /** + * Creates a new plot with a null dataset. + */ + public RingPlot() { + this(null); + } + + /** + * Creates a new plot for the specified dataset. + * + * @param dataset the dataset (null permitted). + */ + public RingPlot(PieDataset dataset) { + super(dataset); + this.separatorsVisible = true; + this.separatorStroke = new BasicStroke(0.5f); + this.separatorPaint = Color.gray; + this.innerSeparatorExtension = 0.20; // twenty percent + this.outerSeparatorExtension = 0.20; // twenty percent + this.sectionDepth = 0.20; // 20% + } + + /** + * Returns a flag that indicates whether or not separators are drawn between + * the sections in the chart. + * + * @return A boolean. + * + * @see #setSeparatorsVisible(boolean) + */ + public boolean getSeparatorsVisible() { + return this.separatorsVisible; + } + + /** + * Sets the flag that controls whether or not separators are drawn between + * the sections in the chart, and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param visible the flag. + * + * @see #getSeparatorsVisible() + */ + public void setSeparatorsVisible(boolean visible) { + this.separatorsVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the separator stroke. + * + * @return The stroke (never null). + * + * @see #setSeparatorStroke(Stroke) + */ + public Stroke getSeparatorStroke() { + return this.separatorStroke; + } + + /** + * Sets the stroke used to draw the separator between sections and sends + * a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getSeparatorStroke() + */ + public void setSeparatorStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.separatorStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the separator paint. + * + * @return The paint (never null). + * + * @see #setSeparatorPaint(Paint) + */ + public Paint getSeparatorPaint() { + return this.separatorPaint; + } + + /** + * Sets the paint used to draw the separator between sections and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getSeparatorPaint() + */ + public void setSeparatorPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.separatorPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the length of the inner extension of the separator line that + * is drawn between sections, expressed as a percentage of the depth of + * the section. + * + * @return The inner separator extension (as a percentage). + * + * @see #setInnerSeparatorExtension(double) + */ + public double getInnerSeparatorExtension() { + return this.innerSeparatorExtension; + } + + /** + * Sets the length of the inner extension of the separator line that is + * drawn between sections, as a percentage of the depth of the + * sections, and sends a {@link PlotChangeEvent} to all registered + * listeners. + * + * @param percent the percentage. + * + * @see #getInnerSeparatorExtension() + * @see #setOuterSeparatorExtension(double) + */ + public void setInnerSeparatorExtension(double percent) { + this.innerSeparatorExtension = percent; + fireChangeEvent(); + } + + /** + * Returns the length of the outer extension of the separator line that + * is drawn between sections, expressed as a percentage of the depth of + * the section. + * + * @return The outer separator extension (as a percentage). + * + * @see #setOuterSeparatorExtension(double) + */ + public double getOuterSeparatorExtension() { + return this.outerSeparatorExtension; + } + + /** + * Sets the length of the outer extension of the separator line that is + * drawn between sections, as a percentage of the depth of the + * sections, and sends a {@link PlotChangeEvent} to all registered + * listeners. + * + * @param percent the percentage. + * + * @see #getOuterSeparatorExtension() + */ + public void setOuterSeparatorExtension(double percent) { + this.outerSeparatorExtension = percent; + fireChangeEvent(); + } + + /** + * Returns the depth of each section, expressed as a percentage of the + * plot radius. + * + * @return The depth of each section. + * + * @see #setSectionDepth(double) + * @since 1.0.3 + */ + public double getSectionDepth() { + return this.sectionDepth; + } + + /** + * The section depth is given as percentage of the plot radius. + * Specifying 1.0 results in a straightforward pie chart. + * + * @param sectionDepth the section depth. + * + * @see #getSectionDepth() + * @since 1.0.3 + */ + public void setSectionDepth(double sectionDepth) { + this.sectionDepth = sectionDepth; + fireChangeEvent(); + } + + /** + * Initialises the plot state (which will store the total of all dataset + * values, among other things). This method is called once at the + * beginning of each drawing. + * + * @param g2 the graphics device. + * @param plotArea the plot area (null not permitted). + * @param plot the plot. + * @param index the secondary index (null for primary + * renderer). + * @param info collects chart rendering information for return to caller. + * + * @return A state object (maintains state information relevant to one + * chart drawing). + */ + @Override + public PiePlotState initialise(Graphics2D g2, Rectangle2D plotArea, + PiePlot plot, Integer index, PlotRenderingInfo info) { + + PiePlotState state = super.initialise(g2, plotArea, plot, index, info); + state.setPassesRequired(3); + return state; + + } + + /** + * Draws a single data item. + * + * @param g2 the graphics device (null not permitted). + * @param section the section index. + * @param dataArea the data plot area. + * @param state state information for one chart. + * @param currentPass the current pass index. + */ + @Override + protected void drawItem(Graphics2D g2, int section, Rectangle2D dataArea, + PiePlotState state, int currentPass) { + + PieDataset dataset = getDataset(); + Number n = dataset.getValue(section); + if (n == null) { + return; + } + double value = n.doubleValue(); + double angle1 = 0.0; + double angle2 = 0.0; + + Rotation direction = getDirection(); + if (direction == Rotation.CLOCKWISE) { + angle1 = state.getLatestAngle(); + angle2 = angle1 - value / state.getTotal() * 360.0; + } + else if (direction == Rotation.ANTICLOCKWISE) { + angle1 = state.getLatestAngle(); + angle2 = angle1 + value / state.getTotal() * 360.0; + } + else { + throw new IllegalStateException("Rotation type not recognised."); + } + + double angle = (angle2 - angle1); + if (Math.abs(angle) > getMinimumArcAngleToDraw()) { + Comparable key = getSectionKey(section); + double ep = 0.0; + double mep = getMaximumExplodePercent(); + if (mep > 0.0) { + ep = getExplodePercent(key) / mep; + } + Rectangle2D arcBounds = getArcBounds(state.getPieArea(), + state.getExplodedPieArea(), angle1, angle, ep); + Arc2D.Double arc = new Arc2D.Double(arcBounds, angle1, angle, + Arc2D.OPEN); + + // create the bounds for the inner arc + double depth = this.sectionDepth / 2.0; + RectangleInsets s = new RectangleInsets(UnitType.RELATIVE, + depth, depth, depth, depth); + Rectangle2D innerArcBounds = new Rectangle2D.Double(); + innerArcBounds.setRect(arcBounds); + s.trim(innerArcBounds); + // calculate inner arc in reverse direction, for later + // GeneralPath construction + Arc2D.Double arc2 = new Arc2D.Double(innerArcBounds, angle1 + + angle, -angle, Arc2D.OPEN); + GeneralPath path = new GeneralPath(); + path.moveTo((float) arc.getStartPoint().getX(), + (float) arc.getStartPoint().getY()); + path.append(arc.getPathIterator(null), false); + path.append(arc2.getPathIterator(null), true); + path.closePath(); + + Line2D separator = new Line2D.Double(arc2.getEndPoint(), + arc.getStartPoint()); + + if (currentPass == 0) { + Paint shadowPaint = getShadowPaint(); + double shadowXOffset = getShadowXOffset(); + double shadowYOffset = getShadowYOffset(); + if (shadowPaint != null && getShadowGenerator() == null) { + Shape shadowArc = ShapeUtilities.createTranslatedShape( + path, (float) shadowXOffset, (float) shadowYOffset); + g2.setPaint(shadowPaint); + g2.fill(shadowArc); + } + } + else if (currentPass == 1) { + Paint paint = lookupSectionPaint(key); + g2.setPaint(paint); + g2.fill(path); + Paint outlinePaint = lookupSectionOutlinePaint(key); + Stroke outlineStroke = lookupSectionOutlineStroke(key); + if (getSectionOutlinesVisible() && outlinePaint != null + && outlineStroke != null) { + g2.setPaint(outlinePaint); + g2.setStroke(outlineStroke); + g2.draw(path); + } + + // add an entity for the pie section + if (state.getInfo() != null) { + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + String tip = null; + PieToolTipGenerator toolTipGenerator + = getToolTipGenerator(); + if (toolTipGenerator != null) { + tip = toolTipGenerator.generateToolTip(dataset, + key); + } + String url = null; + PieURLGenerator urlGenerator = getURLGenerator(); + if (urlGenerator != null) { + url = urlGenerator.generateURL(dataset, key, + getPieIndex()); + } + PieSectionEntity entity = new PieSectionEntity(path, + dataset, getPieIndex(), section, key, tip, + url); + entities.add(entity); + } + } + } + else if (currentPass == 2) { + if (this.separatorsVisible) { + Line2D extendedSeparator = extendLine(separator, + this.innerSeparatorExtension, + this.outerSeparatorExtension); + g2.setStroke(this.separatorStroke); + g2.setPaint(this.separatorPaint); + g2.draw(extendedSeparator); + } + } + } + state.setLatestAngle(angle2); + } + + /** + * This method overrides the default value for cases where the ring plot + * is very thin. This fixes bug 2121818. + * + * @return The label link depth, as a percentage of the plot's radius. + */ + @Override + protected double getLabelLinkDepth() { + return Math.min(super.getLabelLinkDepth(), getSectionDepth() / 2); + } + + /** + * Tests this plot for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof RingPlot)) { + return false; + } + RingPlot that = (RingPlot) obj; + if (this.separatorsVisible != that.separatorsVisible) { + return false; + } + if (!ObjectUtilities.equal(this.separatorStroke, + that.separatorStroke)) { + return false; + } + if (!PaintUtilities.equal(this.separatorPaint, that.separatorPaint)) { + return false; + } + if (this.innerSeparatorExtension != that.innerSeparatorExtension) { + return false; + } + if (this.outerSeparatorExtension != that.outerSeparatorExtension) { + return false; + } + if (this.sectionDepth != that.sectionDepth) { + return false; + } + return super.equals(obj); + } + + /** + * Creates a new line by extending an existing line. + * + * @param line the line (null not permitted). + * @param startPercent the amount to extend the line at the start point + * end. + * @param endPercent the amount to extend the line at the end point end. + * + * @return A new line. + */ + private Line2D extendLine(Line2D line, double startPercent, + double endPercent) { + ParamChecks.nullNotPermitted(line, "line"); + double x1 = line.getX1(); + double x2 = line.getX2(); + double deltaX = x2 - x1; + double y1 = line.getY1(); + double y2 = line.getY2(); + double deltaY = y2 - y1; + x1 = x1 - (startPercent * deltaX); + y1 = y1 - (startPercent * deltaY); + x2 = x2 + (endPercent * deltaX); + y2 = y2 + (endPercent * deltaY); + return new Line2D.Double(x1, y1, x2, y2); + } + + /** + * 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.writeStroke(this.separatorStroke, stream); + SerialUtilities.writePaint(this.separatorPaint, 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.separatorStroke = SerialUtilities.readStroke(stream); + this.separatorPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/SeriesRenderingOrder.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/SeriesRenderingOrder.java new file mode 100755 index 0000000..52e8bda --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/SeriesRenderingOrder.java @@ -0,0 +1,142 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * SeriesRenderingOrder.java + * -------------------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: Eric Thomas (www.isti.com); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 21-Apr-2005 : Version 1 contributed by Eric Thomas (ET); + * 21-Nov-2007 : Implemented hashCode() (DG); + * + */ + +package org.jfree.chart.plot; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Defines the tokens that indicate the rendering order for series in a + * {@link org.jfree.chart.plot.XYPlot}. + */ +public final class SeriesRenderingOrder implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 209336477448807735L; + + /** + * Render series in the order 0, 1, 2, ..., N-1, where N is the number + * of series. + */ + public static final SeriesRenderingOrder FORWARD + = new SeriesRenderingOrder("SeriesRenderingOrder.FORWARD"); + + /** + * Render series in the order N-1, N-2, ..., 2, 1, 0, where N is the + * number of series. + */ + public static final SeriesRenderingOrder REVERSE + = new SeriesRenderingOrder("SeriesRenderingOrder.REVERSE"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private SeriesRenderingOrder(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string (never null). + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof SeriesRenderingOrder)) { + return false; + } + SeriesRenderingOrder order = (SeriesRenderingOrder) obj; + if (!this.name.equals(order.toString())) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return this.name.hashCode(); + } + + /** + * 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(SeriesRenderingOrder.FORWARD)) { + return SeriesRenderingOrder.FORWARD; + } + else if (this.equals(SeriesRenderingOrder.REVERSE)) { + return SeriesRenderingOrder.REVERSE; + } + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/SpiderWebPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/SpiderWebPlot.java new file mode 100755 index 0000000..c68c267 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/SpiderWebPlot.java @@ -0,0 +1,1649 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * SpiderWebPlot.java + * ------------------ + * (C) Copyright 2005-2013, by Heaps of Flavour Pty Ltd and Contributors. + * + * Company Info: http://www.i4-talent.com + * + * Original Author: Don Elliott; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Nina Jeliazkova; + * + * Changes + * ------- + * 28-Jan-2005 : First cut - missing a few features - still to do: + * - needs tooltips/URL/label generator functions + * - ticks on axes / background grid? + * 31-Jan-2005 : Renamed SpiderWebPlot, added label generator support, and + * reformatted for consistency with other source files in + * JFreeChart (DG); + * 20-Apr-2005 : Renamed CategoryLabelGenerator + * --> CategoryItemLabelGenerator (DG); + * 05-May-2005 : Updated draw() method parameters (DG); + * 10-Jun-2005 : Added equals() method and fixed serialization (DG); + * 16-Jun-2005 : Added default constructor and get/setDataset() + * methods (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 05-Apr-2006 : Fixed bug preventing the display of zero values - see patch + * 1462727 (DG); + * 05-Apr-2006 : Added support for mouse clicks, tool tips and URLs - see patch + * 1463455 (DG); + * 01-Jun-2006 : Fix bug 1493199, NullPointerException when drawing with null + * info (DG); + * 05-Feb-2007 : Added attributes for axis stroke and paint, while fixing + * bug 1651277, and implemented clone() properly (DG); + * 06-Feb-2007 : Changed getPlotValue() to protected, as suggested in bug + * 1605202 (DG); + * 05-Mar-2007 : Restore clip region correctly (see bug 1667750) (DG); + * 18-May-2007 : Set dataset for LegendItem (DG); + * 02-Jun-2008 : Fixed bug with chart entities using TableOrder.BY_COLUMN (DG); + * 02-Jun-2008 : Fixed bug with null dataset (DG); + * 01-Jun-2009 : Set series key in getLegendItems() (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.AlphaComposite; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Polygon; +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.font.FontRenderContext; +import java.awt.font.LineMetrics; +import java.awt.geom.Arc2D; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Line2D; +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 java.util.Iterator; +import java.util.List; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.entity.CategoryItemEntity; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.labels.CategoryItemLabelGenerator; +import org.jfree.chart.labels.CategoryToolTipGenerator; +import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; +import org.jfree.chart.urls.CategoryURLGenerator; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintList; +import org.jfree.util.PaintUtilities; +import org.jfree.util.Rotation; +import org.jfree.util.ShapeUtilities; +import org.jfree.util.StrokeList; +import org.jfree.util.TableOrder; + +/** + * A plot that displays data from a {@link CategoryDataset} in the form of a + * "spider web". Multiple series can be plotted on the same axis to allow + * easy comparison. This plot doesn't support negative values at present. + */ +public class SpiderWebPlot extends Plot implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -5376340422031599463L; + + /** The default head radius percent (currently 1%). */ + public static final double DEFAULT_HEAD = 0.01; + + /** The default axis label gap (currently 10%). */ + public static final double DEFAULT_AXIS_LABEL_GAP = 0.10; + + /** The default interior gap. */ + public static final double DEFAULT_INTERIOR_GAP = 0.25; + + /** The maximum interior gap (currently 40%). */ + public static final double MAX_INTERIOR_GAP = 0.40; + + /** The default starting angle for the radar chart axes. */ + public static final double DEFAULT_START_ANGLE = 90.0; + + /** The default series label font. */ + public static final Font DEFAULT_LABEL_FONT = new Font("SansSerif", + Font.PLAIN, 10); + + /** The default series label paint. */ + public static final Paint DEFAULT_LABEL_PAINT = Color.black; + + /** The default series label background paint. */ + public static final Paint DEFAULT_LABEL_BACKGROUND_PAINT + = new Color(255, 255, 192); + + /** The default series label outline paint. */ + public static final Paint DEFAULT_LABEL_OUTLINE_PAINT = Color.black; + + /** The default series label outline stroke. */ + public static final Stroke DEFAULT_LABEL_OUTLINE_STROKE + = new BasicStroke(0.5f); + + /** The default series label shadow paint. */ + public static final Paint DEFAULT_LABEL_SHADOW_PAINT = Color.lightGray; + + /** + * The default maximum value plotted - forces the plot to evaluate + * the maximum from the data passed in + */ + public static final double DEFAULT_MAX_VALUE = -1.0; + + /** The head radius as a percentage of the available drawing area. */ + protected double headPercent; + + /** The space left around the outside of the plot as a percentage. */ + private double interiorGap; + + /** The gap between the labels and the axes as a %age of the radius. */ + private double axisLabelGap; + + /** + * The paint used to draw the axis lines. + * + * @since 1.0.4 + */ + private transient Paint axisLinePaint; + + /** + * The stroke used to draw the axis lines. + * + * @since 1.0.4 + */ + private transient Stroke axisLineStroke; + + /** The dataset. */ + private CategoryDataset dataset; + + /** The maximum value we are plotting against on each category axis */ + private double maxValue; + + /** + * The data extract order (BY_ROW or BY_COLUMN). This denotes whether + * the data series are stored in rows (in which case the category names are + * derived from the column keys) or in columns (in which case the category + * names are derived from the row keys). + */ + private TableOrder dataExtractOrder; + + /** The starting angle. */ + private double startAngle; + + /** The direction for drawing the radar axis & plots. */ + private Rotation direction; + + /** The legend item shape. */ + private transient Shape legendItemShape; + + /** The paint for ALL series (overrides list). */ + private transient Paint seriesPaint; + + /** The series paint list. */ + private PaintList seriesPaintList; + + /** The base series paint (fallback). */ + private transient Paint baseSeriesPaint; + + /** The outline paint for ALL series (overrides list). */ + private transient Paint seriesOutlinePaint; + + /** The series outline paint list. */ + private PaintList seriesOutlinePaintList; + + /** The base series outline paint (fallback). */ + private transient Paint baseSeriesOutlinePaint; + + /** The outline stroke for ALL series (overrides list). */ + private transient Stroke seriesOutlineStroke; + + /** The series outline stroke list. */ + private StrokeList seriesOutlineStrokeList; + + /** The base series outline stroke (fallback). */ + private transient Stroke baseSeriesOutlineStroke; + + /** The font used to display the category labels. */ + private Font labelFont; + + /** The color used to draw the category labels. */ + private transient Paint labelPaint; + + /** The label generator. */ + private CategoryItemLabelGenerator labelGenerator; + + /** controls if the web polygons are filled or not */ + private boolean webFilled = true; + + /** A tooltip generator for the plot (null permitted). */ + private CategoryToolTipGenerator toolTipGenerator; + + /** A URL generator for the plot (null permitted). */ + private CategoryURLGenerator urlGenerator; + + /** + * Creates a default plot with no dataset. + */ + public SpiderWebPlot() { + this(null); + } + + /** + * Creates a new spider web plot with the given dataset, with each row + * representing a series. + * + * @param dataset the dataset (null permitted). + */ + public SpiderWebPlot(CategoryDataset dataset) { + this(dataset, TableOrder.BY_ROW); + } + + /** + * Creates a new spider web plot with the given dataset. + * + * @param dataset the dataset. + * @param extract controls how data is extracted ({@link TableOrder#BY_ROW} + * or {@link TableOrder#BY_COLUMN}). + */ + public SpiderWebPlot(CategoryDataset dataset, TableOrder extract) { + super(); + ParamChecks.nullNotPermitted(extract, "extract"); + this.dataset = dataset; + if (dataset != null) { + dataset.addChangeListener(this); + } + + this.dataExtractOrder = extract; + this.headPercent = DEFAULT_HEAD; + this.axisLabelGap = DEFAULT_AXIS_LABEL_GAP; + this.axisLinePaint = Color.black; + this.axisLineStroke = new BasicStroke(1.0f); + + this.interiorGap = DEFAULT_INTERIOR_GAP; + this.startAngle = DEFAULT_START_ANGLE; + this.direction = Rotation.CLOCKWISE; + this.maxValue = DEFAULT_MAX_VALUE; + + this.seriesPaint = null; + this.seriesPaintList = new PaintList(); + this.baseSeriesPaint = null; + + this.seriesOutlinePaint = null; + this.seriesOutlinePaintList = new PaintList(); + this.baseSeriesOutlinePaint = DEFAULT_OUTLINE_PAINT; + + this.seriesOutlineStroke = null; + this.seriesOutlineStrokeList = new StrokeList(); + this.baseSeriesOutlineStroke = DEFAULT_OUTLINE_STROKE; + + this.labelFont = DEFAULT_LABEL_FONT; + this.labelPaint = DEFAULT_LABEL_PAINT; + this.labelGenerator = new StandardCategoryItemLabelGenerator(); + + this.legendItemShape = DEFAULT_LEGEND_ITEM_CIRCLE; + } + + /** + * Returns a short string describing the type of plot. + * + * @return The plot type. + */ + @Override + public String getPlotType() { + // return localizationResources.getString("Radar_Plot"); + return ("Spider Web Plot"); + } + + /** + * Returns the dataset. + * + * @return The dataset (possibly null). + * + * @see #setDataset(CategoryDataset) + */ + public CategoryDataset getDataset() { + return this.dataset; + } + + /** + * Sets the dataset used by the plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param dataset the dataset (null permitted). + * + * @see #getDataset() + */ + public void setDataset(CategoryDataset dataset) { + // if there is an existing dataset, remove the plot from the list of + // change listeners... + if (this.dataset != null) { + this.dataset.removeChangeListener(this); + } + + // set the new dataset, and register the chart as a change listener... + this.dataset = dataset; + if (dataset != null) { + setDatasetGroup(dataset.getGroup()); + dataset.addChangeListener(this); + } + + // send a dataset change event to self to trigger plot change event + datasetChanged(new DatasetChangeEvent(this, dataset)); + } + + /** + * Method to determine if the web chart is to be filled. + * + * @return A boolean. + * + * @see #setWebFilled(boolean) + */ + public boolean isWebFilled() { + return this.webFilled; + } + + /** + * Sets the webFilled flag and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param flag the flag. + * + * @see #isWebFilled() + */ + public void setWebFilled(boolean flag) { + this.webFilled = flag; + fireChangeEvent(); + } + + /** + * Returns the data extract order (by row or by column). + * + * @return The data extract order (never null). + * + * @see #setDataExtractOrder(TableOrder) + */ + public TableOrder getDataExtractOrder() { + return this.dataExtractOrder; + } + + /** + * Sets the data extract order (by row or by column) and sends a + * {@link PlotChangeEvent}to all registered listeners. + * + * @param order the order (null not permitted). + * + * @throws IllegalArgumentException if order is + * null. + * + * @see #getDataExtractOrder() + */ + public void setDataExtractOrder(TableOrder order) { + ParamChecks.nullNotPermitted(order, "order"); + this.dataExtractOrder = order; + fireChangeEvent(); + } + + /** + * Returns the head percent. + * + * @return The head percent. + * + * @see #setHeadPercent(double) + */ + public double getHeadPercent() { + return this.headPercent; + } + + /** + * Sets the head percent and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param percent the percent. + * + * @see #getHeadPercent() + */ + public void setHeadPercent(double percent) { + this.headPercent = percent; + fireChangeEvent(); + } + + /** + * Returns the start angle for the first radar axis. + *
+ * This is measured in degrees starting from 3 o'clock (Java Arc2D default) + * and measuring anti-clockwise. + * + * @return The start angle. + * + * @see #setStartAngle(double) + */ + public double getStartAngle() { + return this.startAngle; + } + + /** + * Sets the starting angle and sends a {@link PlotChangeEvent} to all + * registered listeners. + *

+ * The initial default value is 90 degrees, which corresponds to 12 o'clock. + * A value of zero corresponds to 3 o'clock... this is the encoding used by + * Java's Arc2D class. + * + * @param angle the angle (in degrees). + * + * @see #getStartAngle() + */ + public void setStartAngle(double angle) { + this.startAngle = angle; + fireChangeEvent(); + } + + /** + * Returns the maximum value any category axis can take. + * + * @return The maximum value. + * + * @see #setMaxValue(double) + */ + public double getMaxValue() { + return this.maxValue; + } + + /** + * Sets the maximum value any category axis can take and sends + * a {@link PlotChangeEvent} to all registered listeners. + * + * @param value the maximum value. + * + * @see #getMaxValue() + */ + public void setMaxValue(double value) { + this.maxValue = value; + fireChangeEvent(); + } + + /** + * Returns the direction in which the radar axes are drawn + * (clockwise or anti-clockwise). + * + * @return The direction (never null). + * + * @see #setDirection(Rotation) + */ + public Rotation getDirection() { + return this.direction; + } + + /** + * Sets the direction in which the radar axes are drawn and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param direction the direction (null not permitted). + * + * @see #getDirection() + */ + public void setDirection(Rotation direction) { + ParamChecks.nullNotPermitted(direction, "direction"); + this.direction = direction; + fireChangeEvent(); + } + + /** + * Returns the interior gap, measured as a percentage of the available + * drawing space. + * + * @return The gap (as a percentage of the available drawing space). + * + * @see #setInteriorGap(double) + */ + public double getInteriorGap() { + return this.interiorGap; + } + + /** + * Sets the interior gap and sends a {@link PlotChangeEvent} to all + * registered listeners. This controls the space between the edges of the + * plot and the plot area itself (the region where the axis labels appear). + * + * @param percent the gap (as a percentage of the available drawing space). + * + * @see #getInteriorGap() + */ + public void setInteriorGap(double percent) { + if ((percent < 0.0) || (percent > MAX_INTERIOR_GAP)) { + throw new IllegalArgumentException( + "Percentage outside valid range."); + } + if (this.interiorGap != percent) { + this.interiorGap = percent; + fireChangeEvent(); + } + } + + /** + * Returns the axis label gap. + * + * @return The axis label gap. + * + * @see #setAxisLabelGap(double) + */ + public double getAxisLabelGap() { + return this.axisLabelGap; + } + + /** + * Sets the axis label gap and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param gap the gap. + * + * @see #getAxisLabelGap() + */ + public void setAxisLabelGap(double gap) { + this.axisLabelGap = gap; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw the axis lines. + * + * @return The paint used to draw the axis lines (never null). + * + * @see #setAxisLinePaint(Paint) + * @see #getAxisLineStroke() + * @since 1.0.4 + */ + public Paint getAxisLinePaint() { + return this.axisLinePaint; + } + + /** + * Sets the paint used to draw the axis lines and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getAxisLinePaint() + * @since 1.0.4 + */ + public void setAxisLinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.axisLinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the stroke used to draw the axis lines. + * + * @return The stroke used to draw the axis lines (never null). + * + * @see #setAxisLineStroke(Stroke) + * @see #getAxisLinePaint() + * @since 1.0.4 + */ + public Stroke getAxisLineStroke() { + return this.axisLineStroke; + } + + /** + * Sets the stroke used to draw the axis lines and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getAxisLineStroke() + * @since 1.0.4 + */ + public void setAxisLineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.axisLineStroke = stroke; + fireChangeEvent(); + } + + //// SERIES PAINT ///////////////////////// + + /** + * Returns the paint for ALL series in the plot. + * + * @return The paint (possibly null). + * + * @see #setSeriesPaint(Paint) + */ + public Paint getSeriesPaint() { + return this.seriesPaint; + } + + /** + * Sets the paint for ALL series in the plot. If this is set to null + * , then a list of paints is used instead (to allow different colors + * to be used for each series of the radar group). + * + * @param paint the paint (null permitted). + * + * @see #getSeriesPaint() + */ + public void setSeriesPaint(Paint paint) { + this.seriesPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint for the specified series. + * + * @param series the series index (zero-based). + * + * @return The paint (never null). + * + * @see #setSeriesPaint(int, Paint) + */ + public Paint getSeriesPaint(int series) { + + // return the override, if there is one... + if (this.seriesPaint != null) { + return this.seriesPaint; + } + + // otherwise look up the paint list + Paint result = this.seriesPaintList.getPaint(series); + if (result == null) { + DrawingSupplier supplier = getDrawingSupplier(); + if (supplier != null) { + Paint p = supplier.getNextPaint(); + this.seriesPaintList.setPaint(series, p); + result = p; + } + else { + result = this.baseSeriesPaint; + } + } + return result; + + } + + /** + * Sets the paint used to fill a series of the radar and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param paint the paint (null permitted). + * + * @see #getSeriesPaint(int) + */ + public void setSeriesPaint(int series, Paint paint) { + this.seriesPaintList.setPaint(series, paint); + fireChangeEvent(); + } + + /** + * Returns the base series paint. This is used when no other paint is + * available. + * + * @return The paint (never null). + * + * @see #setBaseSeriesPaint(Paint) + */ + public Paint getBaseSeriesPaint() { + return this.baseSeriesPaint; + } + + /** + * Sets the base series paint. + * + * @param paint the paint (null not permitted). + * + * @see #getBaseSeriesPaint() + */ + public void setBaseSeriesPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.baseSeriesPaint = paint; + fireChangeEvent(); + } + + //// SERIES OUTLINE PAINT //////////////////////////// + + /** + * Returns the outline paint for ALL series in the plot. + * + * @return The paint (possibly null). + */ + public Paint getSeriesOutlinePaint() { + return this.seriesOutlinePaint; + } + + /** + * Sets the outline paint for ALL series in the plot. If this is set to + * null, then a list of paints is used instead (to allow + * different colors to be used for each series). + * + * @param paint the paint (null permitted). + */ + public void setSeriesOutlinePaint(Paint paint) { + this.seriesOutlinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint for the specified series. + * + * @param series the series index (zero-based). + * + * @return The paint (never null). + */ + public Paint getSeriesOutlinePaint(int series) { + // return the override, if there is one... + if (this.seriesOutlinePaint != null) { + return this.seriesOutlinePaint; + } + // otherwise look up the paint list + Paint result = this.seriesOutlinePaintList.getPaint(series); + if (result == null) { + result = this.baseSeriesOutlinePaint; + } + return result; + } + + /** + * Sets the paint used to fill a series of the radar and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param paint the paint (null permitted). + */ + public void setSeriesOutlinePaint(int series, Paint paint) { + this.seriesOutlinePaintList.setPaint(series, paint); + fireChangeEvent(); + } + + /** + * Returns the base series paint. This is used when no other paint is + * available. + * + * @return The paint (never null). + */ + public Paint getBaseSeriesOutlinePaint() { + return this.baseSeriesOutlinePaint; + } + + /** + * Sets the base series paint. + * + * @param paint the paint (null not permitted). + */ + public void setBaseSeriesOutlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.baseSeriesOutlinePaint = paint; + fireChangeEvent(); + } + + //// SERIES OUTLINE STROKE ///////////////////// + + /** + * Returns the outline stroke for ALL series in the plot. + * + * @return The stroke (possibly null). + */ + public Stroke getSeriesOutlineStroke() { + return this.seriesOutlineStroke; + } + + /** + * Sets the outline stroke for ALL series in the plot. If this is set to + * null, then a list of paints is used instead (to allow + * different colors to be used for each series). + * + * @param stroke the stroke (null permitted). + */ + public void setSeriesOutlineStroke(Stroke stroke) { + this.seriesOutlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the stroke for the specified series. + * + * @param series the series index (zero-based). + * + * @return The stroke (never null). + */ + public Stroke getSeriesOutlineStroke(int series) { + + // return the override, if there is one... + if (this.seriesOutlineStroke != null) { + return this.seriesOutlineStroke; + } + + // otherwise look up the paint list + Stroke result = this.seriesOutlineStrokeList.getStroke(series); + if (result == null) { + result = this.baseSeriesOutlineStroke; + } + return result; + + } + + /** + * Sets the stroke used to fill a series of the radar and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param stroke the stroke (null permitted). + */ + public void setSeriesOutlineStroke(int series, Stroke stroke) { + this.seriesOutlineStrokeList.setStroke(series, stroke); + fireChangeEvent(); + } + + /** + * Returns the base series stroke. This is used when no other stroke is + * available. + * + * @return The stroke (never null). + */ + public Stroke getBaseSeriesOutlineStroke() { + return this.baseSeriesOutlineStroke; + } + + /** + * Sets the base series stroke. + * + * @param stroke the stroke (null not permitted). + */ + public void setBaseSeriesOutlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.baseSeriesOutlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the shape used for legend items. + * + * @return The shape (never null). + * + * @see #setLegendItemShape(Shape) + */ + public Shape getLegendItemShape() { + return this.legendItemShape; + } + + /** + * Sets the shape used for legend items and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param shape the shape (null not permitted). + * + * @see #getLegendItemShape() + */ + public void setLegendItemShape(Shape shape) { + ParamChecks.nullNotPermitted(shape, "shape"); + this.legendItemShape = shape; + fireChangeEvent(); + } + + /** + * Returns the series label font. + * + * @return The font (never null). + * + * @see #setLabelFont(Font) + */ + public Font getLabelFont() { + return this.labelFont; + } + + /** + * Sets the series label font and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getLabelFont() + */ + public void setLabelFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.labelFont = font; + fireChangeEvent(); + } + + /** + * Returns the series label paint. + * + * @return The paint (never null). + * + * @see #setLabelPaint(Paint) + */ + public Paint getLabelPaint() { + return this.labelPaint; + } + + /** + * Sets the series label paint and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getLabelPaint() + */ + public void setLabelPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.labelPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the label generator. + * + * @return The label generator (never null). + * + * @see #setLabelGenerator(CategoryItemLabelGenerator) + */ + public CategoryItemLabelGenerator getLabelGenerator() { + return this.labelGenerator; + } + + /** + * Sets the label generator and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param generator the generator (null not permitted). + * + * @see #getLabelGenerator() + */ + public void setLabelGenerator(CategoryItemLabelGenerator generator) { + ParamChecks.nullNotPermitted(generator, "generator"); + this.labelGenerator = generator; + } + + /** + * Returns the tool tip generator for the plot. + * + * @return The tool tip generator (possibly null). + * + * @see #setToolTipGenerator(CategoryToolTipGenerator) + * + * @since 1.0.2 + */ + public CategoryToolTipGenerator getToolTipGenerator() { + return this.toolTipGenerator; + } + + /** + * Sets the tool tip generator for the plot and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getToolTipGenerator() + * + * @since 1.0.2 + */ + public void setToolTipGenerator(CategoryToolTipGenerator generator) { + this.toolTipGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the URL generator for the plot. + * + * @return The URL generator (possibly null). + * + * @see #setURLGenerator(CategoryURLGenerator) + * + * @since 1.0.2 + */ + public CategoryURLGenerator getURLGenerator() { + return this.urlGenerator; + } + + /** + * Sets the URL generator for the plot and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getURLGenerator() + * + * @since 1.0.2 + */ + public void setURLGenerator(CategoryURLGenerator generator) { + this.urlGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns a collection of legend items for the spider web chart. + * + * @return The legend items (never null). + */ + @Override + public LegendItemCollection getLegendItems() { + LegendItemCollection result = new LegendItemCollection(); + if (getDataset() == null) { + return result; + } + List keys = null; + if (this.dataExtractOrder == TableOrder.BY_ROW) { + keys = this.dataset.getRowKeys(); + } + else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { + keys = this.dataset.getColumnKeys(); + } + if (keys == null) { + return result; + } + + int series = 0; + Iterator iterator = keys.iterator(); + Shape shape = getLegendItemShape(); + while (iterator.hasNext()) { + Comparable key = (Comparable) iterator.next(); + String label = key.toString(); + String description = label; + Paint paint = getSeriesPaint(series); + Paint outlinePaint = getSeriesOutlinePaint(series); + Stroke stroke = getSeriesOutlineStroke(series); + LegendItem item = new LegendItem(label, description, + null, null, shape, paint, stroke, outlinePaint); + item.setDataset(getDataset()); + item.setSeriesKey(key); + item.setSeriesIndex(series); + result.add(item); + series++; + } + return result; + } + + /** + * Returns a cartesian point from a polar angle, length and bounding box + * + * @param bounds the area inside which the point needs to be. + * @param angle the polar angle, in degrees. + * @param length the relative length. Given in percent of maximum extend. + * + * @return The cartesian point. + */ + protected Point2D getWebPoint(Rectangle2D bounds, + double angle, double length) { + + double angrad = Math.toRadians(angle); + double x = Math.cos(angrad) * length * bounds.getWidth() / 2; + double y = -Math.sin(angrad) * length * bounds.getHeight() / 2; + + return new Point2D.Double(bounds.getX() + x + bounds.getWidth() / 2, + bounds.getY() + y + bounds.getHeight() / 2); + } + + /** + * Draws the plot on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device. + * @param area the area within which the plot should be drawn. + * @param anchor the anchor point (null permitted). + * @param parentState the state from the parent plot, if there is one. + * @param info collects info about the drawing. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, PlotRenderingInfo info) { + + // adjust for insets... + RectangleInsets insets = getInsets(); + insets.trim(area); + + if (info != null) { + info.setPlotArea(area); + info.setDataArea(area); + } + + drawBackground(g2, area); + drawOutline(g2, area); + + Shape savedClip = g2.getClip(); + + g2.clip(area); + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + getForegroundAlpha())); + + if (!DatasetUtilities.isEmptyOrNull(this.dataset)) { + int seriesCount, catCount; + + if (this.dataExtractOrder == TableOrder.BY_ROW) { + seriesCount = this.dataset.getRowCount(); + catCount = this.dataset.getColumnCount(); + } + else { + seriesCount = this.dataset.getColumnCount(); + catCount = this.dataset.getRowCount(); + } + + // ensure we have a maximum value to use on the axes + if (this.maxValue == DEFAULT_MAX_VALUE) { + calculateMaxValue(seriesCount, catCount); + } + + // Next, setup the plot area + + // adjust the plot area by the interior spacing value + + double gapHorizontal = area.getWidth() * getInteriorGap(); + double gapVertical = area.getHeight() * getInteriorGap(); + + double X = area.getX() + gapHorizontal / 2; + double Y = area.getY() + gapVertical / 2; + double W = area.getWidth() - gapHorizontal; + double H = area.getHeight() - gapVertical; + + double headW = area.getWidth() * this.headPercent; + double headH = area.getHeight() * this.headPercent; + + // make the chart area a square + double min = Math.min(W, H) / 2; + X = (X + X + W) / 2 - min; + Y = (Y + Y + H) / 2 - min; + W = 2 * min; + H = 2 * min; + + Point2D centre = new Point2D.Double(X + W / 2, Y + H / 2); + Rectangle2D radarArea = new Rectangle2D.Double(X, Y, W, H); + + // draw the axis and category label + for (int cat = 0; cat < catCount; cat++) { + double angle = getStartAngle() + + (getDirection().getFactor() * cat * 360 / catCount); + + Point2D endPoint = getWebPoint(radarArea, angle, 1); + // 1 = end of axis + Line2D line = new Line2D.Double(centre, endPoint); + g2.setPaint(this.axisLinePaint); + g2.setStroke(this.axisLineStroke); + g2.draw(line); + drawLabel(g2, radarArea, 0.0, cat, angle, 360.0 / catCount); + } + + // Now actually plot each of the series polygons.. + for (int series = 0; series < seriesCount; series++) { + drawRadarPoly(g2, radarArea, centre, info, series, catCount, + headH, headW); + } + } + else { + drawNoDataMessage(g2, area); + } + g2.setClip(savedClip); + g2.setComposite(originalComposite); + drawOutline(g2, area); + } + + /** + * loop through each of the series to get the maximum value + * on each category axis + * + * @param seriesCount the number of series + * @param catCount the number of categories + */ + private void calculateMaxValue(int seriesCount, int catCount) { + double v; + Number nV; + + for (int seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) { + for (int catIndex = 0; catIndex < catCount; catIndex++) { + nV = getPlotValue(seriesIndex, catIndex); + if (nV != null) { + v = nV.doubleValue(); + if (v > this.maxValue) { + this.maxValue = v; + } + } + } + } + } + + /** + * Draws a radar plot polygon. + * + * @param g2 the graphics device. + * @param plotArea the area we are plotting in (already adjusted). + * @param centre the centre point of the radar axes + * @param info chart rendering info. + * @param series the series within the dataset we are plotting + * @param catCount the number of categories per radar plot + * @param headH the data point height + * @param headW the data point width + */ + protected void drawRadarPoly(Graphics2D g2, + Rectangle2D plotArea, + Point2D centre, + PlotRenderingInfo info, + int series, int catCount, + double headH, double headW) { + + Polygon polygon = new Polygon(); + + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + } + + // plot the data... + for (int cat = 0; cat < catCount; cat++) { + + Number dataValue = getPlotValue(series, cat); + + if (dataValue != null) { + double value = dataValue.doubleValue(); + + if (value >= 0) { // draw the polygon series... + + // Finds our starting angle from the centre for this axis + + double angle = getStartAngle() + + (getDirection().getFactor() * cat * 360 / catCount); + + // The following angle calc will ensure there isn't a top + // vertical axis - this may be useful if you don't want any + // given criteria to 'appear' move important than the + // others.. + // + (getDirection().getFactor() + // * (cat + 0.5) * 360 / catCount); + + // find the point at the appropriate distance end point + // along the axis/angle identified above and add it to the + // polygon + + Point2D point = getWebPoint(plotArea, angle, + value / this.maxValue); + polygon.addPoint((int) point.getX(), (int) point.getY()); + + // put an elipse at the point being plotted.. + + Paint paint = getSeriesPaint(series); + Paint outlinePaint = getSeriesOutlinePaint(series); + Stroke outlineStroke = getSeriesOutlineStroke(series); + + Ellipse2D head = new Ellipse2D.Double(point.getX() + - headW / 2, point.getY() - headH / 2, headW, + headH); + g2.setPaint(paint); + g2.fill(head); + g2.setStroke(outlineStroke); + g2.setPaint(outlinePaint); + g2.draw(head); + + if (entities != null) { + int row, col; + if (this.dataExtractOrder == TableOrder.BY_ROW) { + row = series; + col = cat; + } + else { + row = cat; + col = series; + } + String tip = null; + if (this.toolTipGenerator != null) { + tip = this.toolTipGenerator.generateToolTip( + this.dataset, row, col); + } + + String url = null; + if (this.urlGenerator != null) { + url = this.urlGenerator.generateURL(this.dataset, + row, col); + } + + Shape area = new Rectangle( + (int) (point.getX() - headW), + (int) (point.getY() - headH), + (int) (headW * 2), (int) (headH * 2)); + CategoryItemEntity entity = new CategoryItemEntity( + area, tip, url, this.dataset, + this.dataset.getRowKey(row), + this.dataset.getColumnKey(col)); + entities.add(entity); + } + + } + } + } + // Plot the polygon + + Paint paint = getSeriesPaint(series); + g2.setPaint(paint); + g2.setStroke(getSeriesOutlineStroke(series)); + g2.draw(polygon); + + // Lastly, fill the web polygon if this is required + + if (this.webFilled) { + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + 0.1f)); + g2.fill(polygon); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + getForegroundAlpha())); + } + } + + /** + * Returns the value to be plotted at the interseries of the + * series and the category. This allows us to plot + * BY_ROW or BY_COLUMN which basically is just + * reversing the definition of the categories and data series being + * plotted. + * + * @param series the series to be plotted. + * @param cat the category within the series to be plotted. + * + * @return The value to be plotted (possibly null). + * + * @see #getDataExtractOrder() + */ + protected Number getPlotValue(int series, int cat) { + Number value = null; + if (this.dataExtractOrder == TableOrder.BY_ROW) { + value = this.dataset.getValue(series, cat); + } + else if (this.dataExtractOrder == TableOrder.BY_COLUMN) { + value = this.dataset.getValue(cat, series); + } + return value; + } + + /** + * Draws the label for one axis. + * + * @param g2 the graphics device. + * @param plotArea the plot area + * @param value the value of the label (ignored). + * @param cat the category (zero-based index). + * @param startAngle the starting angle. + * @param extent the extent of the arc. + */ + protected void drawLabel(Graphics2D g2, Rectangle2D plotArea, double value, + int cat, double startAngle, double extent) { + FontRenderContext frc = g2.getFontRenderContext(); + + String label; + if (this.dataExtractOrder == TableOrder.BY_ROW) { + // if series are in rows, then the categories are the column keys + label = this.labelGenerator.generateColumnLabel(this.dataset, cat); + } + else { + // if series are in columns, then the categories are the row keys + label = this.labelGenerator.generateRowLabel(this.dataset, cat); + } + + Rectangle2D labelBounds = getLabelFont().getStringBounds(label, frc); + LineMetrics lm = getLabelFont().getLineMetrics(label, frc); + double ascent = lm.getAscent(); + + Point2D labelLocation = calculateLabelLocation(labelBounds, ascent, + plotArea, startAngle); + + Composite saveComposite = g2.getComposite(); + + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + 1.0f)); + g2.setPaint(getLabelPaint()); + g2.setFont(getLabelFont()); + g2.drawString(label, (float) labelLocation.getX(), + (float) labelLocation.getY()); + g2.setComposite(saveComposite); + } + + /** + * Returns the location for a label + * + * @param labelBounds the label bounds. + * @param ascent the ascent (height of font). + * @param plotArea the plot area + * @param startAngle the start angle for the pie series. + * + * @return The location for a label. + */ + protected Point2D calculateLabelLocation(Rectangle2D labelBounds, + double ascent, + Rectangle2D plotArea, + double startAngle) + { + Arc2D arc1 = new Arc2D.Double(plotArea, startAngle, 0, Arc2D.OPEN); + Point2D point1 = arc1.getEndPoint(); + + double deltaX = -(point1.getX() - plotArea.getCenterX()) + * this.axisLabelGap; + double deltaY = -(point1.getY() - plotArea.getCenterY()) + * this.axisLabelGap; + + double labelX = point1.getX() - deltaX; + double labelY = point1.getY() - deltaY; + + if (labelX < plotArea.getCenterX()) { + labelX -= labelBounds.getWidth(); + } + + if (labelX == plotArea.getCenterX()) { + labelX -= labelBounds.getWidth() / 2; + } + + if (labelY > plotArea.getCenterY()) { + labelY += ascent; + } + + return new Point2D.Double(labelX, labelY); + } + + /** + * Tests this plot for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SpiderWebPlot)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + SpiderWebPlot that = (SpiderWebPlot) obj; + if (!this.dataExtractOrder.equals(that.dataExtractOrder)) { + return false; + } + if (this.headPercent != that.headPercent) { + return false; + } + if (this.interiorGap != that.interiorGap) { + return false; + } + if (this.startAngle != that.startAngle) { + return false; + } + if (!this.direction.equals(that.direction)) { + return false; + } + if (this.maxValue != that.maxValue) { + return false; + } + if (this.webFilled != that.webFilled) { + return false; + } + if (this.axisLabelGap != that.axisLabelGap) { + return false; + } + if (!PaintUtilities.equal(this.axisLinePaint, that.axisLinePaint)) { + return false; + } + if (!this.axisLineStroke.equals(that.axisLineStroke)) { + return false; + } + if (!ShapeUtilities.equal(this.legendItemShape, that.legendItemShape)) { + return false; + } + if (!PaintUtilities.equal(this.seriesPaint, that.seriesPaint)) { + return false; + } + if (!this.seriesPaintList.equals(that.seriesPaintList)) { + return false; + } + if (!PaintUtilities.equal(this.baseSeriesPaint, that.baseSeriesPaint)) { + return false; + } + if (!PaintUtilities.equal(this.seriesOutlinePaint, + that.seriesOutlinePaint)) { + return false; + } + if (!this.seriesOutlinePaintList.equals(that.seriesOutlinePaintList)) { + return false; + } + if (!PaintUtilities.equal(this.baseSeriesOutlinePaint, + that.baseSeriesOutlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.seriesOutlineStroke, + that.seriesOutlineStroke)) { + return false; + } + if (!this.seriesOutlineStrokeList.equals( + that.seriesOutlineStrokeList)) { + return false; + } + if (!this.baseSeriesOutlineStroke.equals( + that.baseSeriesOutlineStroke)) { + return false; + } + if (!this.labelFont.equals(that.labelFont)) { + return false; + } + if (!PaintUtilities.equal(this.labelPaint, that.labelPaint)) { + return false; + } + if (!this.labelGenerator.equals(that.labelGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.toolTipGenerator, + that.toolTipGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.urlGenerator, + that.urlGenerator)) { + return false; + } + return true; + } + + /** + * Returns a clone of this plot. + * + * @return A clone of this plot. + * + * @throws CloneNotSupportedException if the plot cannot be cloned for + * any reason. + */ + @Override + public Object clone() throws CloneNotSupportedException { + SpiderWebPlot clone = (SpiderWebPlot) super.clone(); + clone.legendItemShape = ShapeUtilities.clone(this.legendItemShape); + clone.seriesPaintList = (PaintList) this.seriesPaintList.clone(); + clone.seriesOutlinePaintList + = (PaintList) this.seriesOutlinePaintList.clone(); + clone.seriesOutlineStrokeList + = (StrokeList) this.seriesOutlineStrokeList.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.legendItemShape, stream); + SerialUtilities.writePaint(this.seriesPaint, stream); + SerialUtilities.writePaint(this.baseSeriesPaint, stream); + SerialUtilities.writePaint(this.seriesOutlinePaint, stream); + SerialUtilities.writePaint(this.baseSeriesOutlinePaint, stream); + SerialUtilities.writeStroke(this.seriesOutlineStroke, stream); + SerialUtilities.writeStroke(this.baseSeriesOutlineStroke, stream); + SerialUtilities.writePaint(this.labelPaint, stream); + SerialUtilities.writePaint(this.axisLinePaint, stream); + SerialUtilities.writeStroke(this.axisLineStroke, 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.legendItemShape = SerialUtilities.readShape(stream); + this.seriesPaint = SerialUtilities.readPaint(stream); + this.baseSeriesPaint = SerialUtilities.readPaint(stream); + this.seriesOutlinePaint = SerialUtilities.readPaint(stream); + this.baseSeriesOutlinePaint = SerialUtilities.readPaint(stream); + this.seriesOutlineStroke = SerialUtilities.readStroke(stream); + this.baseSeriesOutlineStroke = SerialUtilities.readStroke(stream); + this.labelPaint = SerialUtilities.readPaint(stream); + this.axisLinePaint = SerialUtilities.readPaint(stream); + this.axisLineStroke = SerialUtilities.readStroke(stream); + if (this.dataset != null) { + this.dataset.addChangeListener(this); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ThermometerPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ThermometerPlot.java new file mode 100755 index 0000000..818b7ce --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ThermometerPlot.java @@ -0,0 +1,1820 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * ThermometerPlot.java + * -------------------- + * + * (C) Copyright 2000-2013, by Bryan Scott and Contributors. + * + * Original Author: Bryan Scott (based on MeterPlot by Hari). + * Contributor(s): David Gilbert (for Object Refinery Limited). + * Arnaud Lelievre; + * Julien Henry (see patch 1769088) (DG); + * + * Changes + * ------- + * 11-Apr-2002 : Version 1, contributed by Bryan Scott; + * 15-Apr-2002 : Changed to implement VerticalValuePlot; + * 29-Apr-2002 : Added getVerticalValueAxis() method (DG); + * 25-Jun-2002 : Removed redundant imports (DG); + * 17-Sep-2002 : Reviewed with Checkstyle utility (DG); + * 18-Sep-2002 : Extensive changes made to API, to iron out bugs and + * inconsistencies (DG); + * 13-Oct-2002 : Corrected error datasetChanged which would generate exceptions + * when value set to null (BRS). + * 23-Jan-2003 : Removed one constructor (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 02-Jun-2003 : Removed test for compatible range axis (DG); + * 01-Jul-2003 : Added additional check in draw method to ensure value not + * null (BRS); + * 08-Sep-2003 : Added internationalization via use of properties + * resourceBundle (RFE 690236) (AL); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 29-Sep-2003 : Updated draw to set value of cursor to non-zero and allow + * painting of axis. An incomplete fix and needs to be set for + * left or right drawing (BRS); + * 19-Nov-2003 : Added support for value labels to be displayed left of the + * thermometer + * 19-Nov-2003 : Improved axis drawing (now default axis does not draw axis line + * and is closer to the bulb). Added support for the positioning + * of the axis to the left or right of the bulb. (BRS); + * 03-Dec-2003 : Directly mapped deprecated setData()/getData() method to + * get/setDataset() (TM); + * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); + * 07-Apr-2004 : Changed string width calculation (DG); + * 12-Nov-2004 : Implemented the new Zoomable interface (DG); + * 06-Jan-2004 : Added getOrientation() method (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); + * 29-Mar-2005 : Fixed equals() method (DG); + * 05-May-2005 : Updated draw() method parameters (DG); + * 09-Jun-2005 : Fixed more bugs in equals() method (DG); + * 10-Jun-2005 : Fixed minor bug in setDisplayRange() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 14-Nov-2006 : Fixed margin when drawing (DG); + * 03-May-2007 : Fixed datasetChanged() to handle null dataset, added null + * argument check and event notification to setRangeAxis(), + * added null argument check to setPadding(), setValueFont(), + * setValuePaint(), setValueFormat() and setMercuryPaint(), + * deprecated get/setShowValueLines(), deprecated + * getMinimum/MaximumVerticalDataValue(), and fixed serialization + * bug (DG); + * 24-Sep-2007 : Implemented new methods in Zoomable interface (DG); + * 08-Oct-2007 : Added attributes for thermometer dimensions - see patch 1769088 + * by Julien Henry (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Stroke; +import java.awt.geom.Area; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.geom.RoundRectangle2D; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.Arrays; +import java.util.ResourceBundle; + +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.data.Range; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DefaultValueDataset; +import org.jfree.data.general.ValueDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.UnitType; + +/** + * A plot that displays a single value (from a {@link ValueDataset}) in a + * thermometer type display. + *

+ * This plot supports a number of options: + *

    + *
  1. three sub-ranges which could be viewed as 'Normal', 'Warning' + * and 'Critical' ranges.
  2. + *
  3. the thermometer can be run in two modes: + *
      + *
    • fixed range, or
    • + *
    • range adjusts to current sub-range.
    • + *
    + *
  4. + *
  5. settable units to be displayed.
  6. + *
  7. settable display location for the value text.
  8. + *
+ */ +public class ThermometerPlot extends Plot implements ValueAxisPlot, + Zoomable, Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 4087093313147984390L; + + /** A constant for unit type 'None'. */ + public static final int UNITS_NONE = 0; + + /** A constant for unit type 'Fahrenheit'. */ + public static final int UNITS_FAHRENHEIT = 1; + + /** A constant for unit type 'Celcius'. */ + public static final int UNITS_CELCIUS = 2; + + /** A constant for unit type 'Kelvin'. */ + public static final int UNITS_KELVIN = 3; + + /** A constant for the value label position (no label). */ + public static final int NONE = 0; + + /** A constant for the value label position (right of the thermometer). */ + public static final int RIGHT = 1; + + /** A constant for the value label position (left of the thermometer). */ + public static final int LEFT = 2; + + /** A constant for the value label position (in the thermometer bulb). */ + public static final int BULB = 3; + + /** A constant for the 'normal' range. */ + public static final int NORMAL = 0; + + /** A constant for the 'warning' range. */ + public static final int WARNING = 1; + + /** A constant for the 'critical' range. */ + public static final int CRITICAL = 2; + + /** + * The bulb radius. + * + * @deprecated As of 1.0.7, use {@link #getBulbRadius()}. + */ + protected static final int BULB_RADIUS = 40; + + /** + * The bulb diameter. + * + * @deprecated As of 1.0.7, use {@link #getBulbDiameter()}. + */ + protected static final int BULB_DIAMETER = BULB_RADIUS * 2; + + /** + * The column radius. + * + * @deprecated As of 1.0.7, use {@link #getColumnRadius()}. + */ + protected static final int COLUMN_RADIUS = 20; + + /** + * The column diameter. + * + * @deprecated As of 1.0.7, use {@link #getColumnDiameter()}. + */ + protected static final int COLUMN_DIAMETER = COLUMN_RADIUS * 2; + + /** + * The gap radius. + * + * @deprecated As of 1.0.7, use {@link #getGap()}. + */ + protected static final int GAP_RADIUS = 5; + + /** + * The gap diameter. + * + * @deprecated As of 1.0.7, use {@link #getGap()} times two. + */ + protected static final int GAP_DIAMETER = GAP_RADIUS * 2; + + /** The axis gap. */ + protected static final int AXIS_GAP = 10; + + /** The unit strings. */ + protected static final String[] UNITS = {"", "\u00B0F", "\u00B0C", + "\u00B0K"}; + + /** Index for low value in subrangeInfo matrix. */ + protected static final int RANGE_LOW = 0; + + /** Index for high value in subrangeInfo matrix. */ + protected static final int RANGE_HIGH = 1; + + /** Index for display low value in subrangeInfo matrix. */ + protected static final int DISPLAY_LOW = 2; + + /** Index for display high value in subrangeInfo matrix. */ + protected static final int DISPLAY_HIGH = 3; + + /** The default lower bound. */ + protected static final double DEFAULT_LOWER_BOUND = 0.0; + + /** The default upper bound. */ + protected static final double DEFAULT_UPPER_BOUND = 100.0; + + /** + * The default bulb radius. + * + * @since 1.0.7 + */ + protected static final int DEFAULT_BULB_RADIUS = 40; + + /** + * The default column radius. + * + * @since 1.0.7 + */ + protected static final int DEFAULT_COLUMN_RADIUS = 20; + + /** + * The default gap between the outlines representing the thermometer. + * + * @since 1.0.7 + */ + protected static final int DEFAULT_GAP = 5; + + /** The dataset for the plot. */ + private ValueDataset dataset; + + /** The range axis. */ + private ValueAxis rangeAxis; + + /** The lower bound for the thermometer. */ + private double lowerBound = DEFAULT_LOWER_BOUND; + + /** The upper bound for the thermometer. */ + private double upperBound = DEFAULT_UPPER_BOUND; + + /** + * The value label position. + * + * @since 1.0.7 + */ + private int bulbRadius = DEFAULT_BULB_RADIUS; + + /** + * The column radius. + * + * @since 1.0.7 + */ + private int columnRadius = DEFAULT_COLUMN_RADIUS; + + /** + * The gap between the two outlines the represent the thermometer. + * + * @since 1.0.7 + */ + private int gap = DEFAULT_GAP; + + /** + * Blank space inside the plot area around the outside of the thermometer. + */ + private RectangleInsets padding; + + /** Stroke for drawing the thermometer */ + private transient Stroke thermometerStroke = new BasicStroke(1.0f); + + /** Paint for drawing the thermometer */ + private transient Paint thermometerPaint = Color.black; + + /** The display units */ + private int units = UNITS_CELCIUS; + + /** The value label position. */ + private int valueLocation = BULB; + + /** The position of the axis **/ + private int axisLocation = LEFT; + + /** The font to write the value in */ + private Font valueFont = new Font("SansSerif", Font.BOLD, 16); + + /** Colour that the value is written in */ + private transient Paint valuePaint = Color.white; + + /** Number format for the value */ + private NumberFormat valueFormat = new DecimalFormat(); + + /** The default paint for the mercury in the thermometer. */ + private transient Paint mercuryPaint = Color.lightGray; + + /** A flag that controls whether value lines are drawn. */ + private boolean showValueLines = false; + + /** The display sub-range. */ + private int subrange = -1; + + /** The start and end values for the subranges. */ + private double[][] subrangeInfo = { + {0.0, 50.0, 0.0, 50.0}, + {50.0, 75.0, 50.0, 75.0}, + {75.0, 100.0, 75.0, 100.0} + }; + + /** + * A flag that controls whether or not the axis range adjusts to the + * sub-ranges. + */ + private boolean followDataInSubranges = false; + + /** + * A flag that controls whether or not the mercury paint changes with + * the subranges. + */ + private boolean useSubrangePaint = true; + + /** Paint for each range */ + private transient Paint[] subrangePaint = {Color.green, Color.orange, + Color.red}; + + /** A flag that controls whether the sub-range indicators are visible. */ + private boolean subrangeIndicatorsVisible = true; + + /** The stroke for the sub-range indicators. */ + private transient Stroke subrangeIndicatorStroke = new BasicStroke(2.0f); + + /** The range indicator stroke. */ + private transient Stroke rangeIndicatorStroke = new BasicStroke(3.0f); + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.plot.LocalizationBundle"); + + /** + * Creates a new thermometer plot. + */ + public ThermometerPlot() { + this(new DefaultValueDataset()); + } + + /** + * Creates a new thermometer plot, using default attributes where necessary. + * + * @param dataset the data set. + */ + public ThermometerPlot(ValueDataset dataset) { + + super(); + + this.padding = new RectangleInsets(UnitType.RELATIVE, 0.05, 0.05, 0.05, + 0.05); + this.dataset = dataset; + if (dataset != null) { + dataset.addChangeListener(this); + } + NumberAxis axis = new NumberAxis(null); + axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + axis.setAxisLineVisible(false); + axis.setPlot(this); + axis.addChangeListener(this); + this.rangeAxis = axis; + setAxisRange(); + } + + /** + * Returns the dataset for the plot. + * + * @return The dataset (possibly null). + * + * @see #setDataset(ValueDataset) + */ + public ValueDataset getDataset() { + return this.dataset; + } + + /** + * Sets the dataset for the plot, replacing the existing dataset if there + * is one, and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param dataset the dataset (null permitted). + * + * @see #getDataset() + */ + public void setDataset(ValueDataset dataset) { + + // if there is an existing dataset, remove the plot from the list + // of change listeners... + ValueDataset existing = this.dataset; + if (existing != null) { + existing.removeChangeListener(this); + } + + // set the new dataset, and register the chart as a change listener... + this.dataset = dataset; + if (dataset != null) { + setDatasetGroup(dataset.getGroup()); + dataset.addChangeListener(this); + } + + // send a dataset change event to self... + DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); + datasetChanged(event); + + } + + /** + * Returns the range axis. + * + * @return The range axis (never null). + * + * @see #setRangeAxis(ValueAxis) + */ + public ValueAxis getRangeAxis() { + return this.rangeAxis; + } + + /** + * Sets the range axis for the plot and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param axis the new axis (null not permitted). + * + * @see #getRangeAxis() + */ + public void setRangeAxis(ValueAxis axis) { + ParamChecks.nullNotPermitted(axis, "axis"); + // plot is registered as a listener with the existing axis... + this.rangeAxis.removeChangeListener(this); + + axis.setPlot(this); + axis.addChangeListener(this); + this.rangeAxis = axis; + fireChangeEvent(); + } + + /** + * Returns the lower bound for the thermometer. The data value can be set + * lower than this, but it will not be shown in the thermometer. + * + * @return The lower bound. + * + * @see #setLowerBound(double) + */ + public double getLowerBound() { + return this.lowerBound; + } + + /** + * Sets the lower bound for the thermometer. + * + * @param lower the lower bound. + * + * @see #getLowerBound() + */ + public void setLowerBound(double lower) { + this.lowerBound = lower; + setAxisRange(); + } + + /** + * Returns the upper bound for the thermometer. The data value can be set + * higher than this, but it will not be shown in the thermometer. + * + * @return The upper bound. + * + * @see #setUpperBound(double) + */ + public double getUpperBound() { + return this.upperBound; + } + + /** + * Sets the upper bound for the thermometer. + * + * @param upper the upper bound. + * + * @see #getUpperBound() + */ + public void setUpperBound(double upper) { + this.upperBound = upper; + setAxisRange(); + } + + /** + * Sets the lower and upper bounds for the thermometer. + * + * @param lower the lower bound. + * @param upper the upper bound. + */ + public void setRange(double lower, double upper) { + this.lowerBound = lower; + this.upperBound = upper; + setAxisRange(); + } + + /** + * Returns the padding for the thermometer. This is the space inside the + * plot area. + * + * @return The padding (never null). + * + * @see #setPadding(RectangleInsets) + */ + public RectangleInsets getPadding() { + return this.padding; + } + + /** + * Sets the padding for the thermometer and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param padding the padding (null not permitted). + * + * @see #getPadding() + */ + public void setPadding(RectangleInsets padding) { + ParamChecks.nullNotPermitted(padding, "padding"); + this.padding = padding; + fireChangeEvent(); + } + + /** + * Returns the stroke used to draw the thermometer outline. + * + * @return The stroke (never null). + * + * @see #setThermometerStroke(Stroke) + * @see #getThermometerPaint() + */ + public Stroke getThermometerStroke() { + return this.thermometerStroke; + } + + /** + * Sets the stroke used to draw the thermometer outline and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param s the new stroke (null ignored). + * + * @see #getThermometerStroke() + */ + public void setThermometerStroke(Stroke s) { + if (s != null) { + this.thermometerStroke = s; + fireChangeEvent(); + } + } + + /** + * Returns the paint used to draw the thermometer outline. + * + * @return The paint (never null). + * + * @see #setThermometerPaint(Paint) + * @see #getThermometerStroke() + */ + public Paint getThermometerPaint() { + return this.thermometerPaint; + } + + /** + * Sets the paint used to draw the thermometer outline and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the new paint (null ignored). + * + * @see #getThermometerPaint() + */ + public void setThermometerPaint(Paint paint) { + if (paint != null) { + this.thermometerPaint = paint; + fireChangeEvent(); + } + } + + /** + * Returns a code indicating the unit display type. This is one of + * {@link #UNITS_NONE}, {@link #UNITS_FAHRENHEIT}, {@link #UNITS_CELCIUS} + * and {@link #UNITS_KELVIN}. + * + * @return The units type. + * + * @see #setUnits(int) + */ + public int getUnits() { + return this.units; + } + + /** + * Sets the units to be displayed in the thermometer. Use one of the + * following constants: + * + *
    + *
  • UNITS_NONE : no units displayed.
  • + *
  • UNITS_FAHRENHEIT : units displayed in Fahrenheit.
  • + *
  • UNITS_CELCIUS : units displayed in Celcius.
  • + *
  • UNITS_KELVIN : units displayed in Kelvin.
  • + *
+ * + * @param u the new unit type. + * + * @see #getUnits() + */ + public void setUnits(int u) { + if ((u >= 0) && (u < UNITS.length)) { + if (this.units != u) { + this.units = u; + fireChangeEvent(); + } + } + } + + /** + * Sets the unit type. + * + * @param u the unit type (null ignored). + * + * @deprecated Use setUnits(int) instead. Deprecated as of version 1.0.6, + * because this method is a little obscure and redundant anyway. + */ + public void setUnits(String u) { + if (u == null) { + return; + } + + u = u.toUpperCase().trim(); + for (int i = 0; i < UNITS.length; ++i) { + if (u.equals(UNITS[i].toUpperCase().trim())) { + setUnits(i); + i = UNITS.length; + } + } + } + + /** + * Returns a code indicating the location at which the value label is + * displayed. + * + * @return The location (one of {@link #NONE}, {@link #RIGHT}, + * {@link #LEFT} and {@link #BULB}.). + */ + public int getValueLocation() { + return this.valueLocation; + } + + /** + * Sets the location at which the current value is displayed and sends a + * {@link PlotChangeEvent} to all registered listeners. + *

+ * The location can be one of the constants: + * NONE, + * RIGHT + * LEFT and + * BULB. + * + * @param location the location. + */ + public void setValueLocation(int location) { + if ((location >= 0) && (location < 4)) { + this.valueLocation = location; + fireChangeEvent(); + } + else { + throw new IllegalArgumentException("Location not recognised."); + } + } + + /** + * Returns the axis location. + * + * @return The location (one of {@link #NONE}, {@link #LEFT} and + * {@link #RIGHT}). + * + * @see #setAxisLocation(int) + */ + public int getAxisLocation() { + return this.axisLocation; + } + + /** + * Sets the location at which the axis is displayed relative to the + * thermometer, and sends a {@link PlotChangeEvent} to all registered + * listeners. + * + * @param location the location (one of {@link #NONE}, {@link #LEFT} and + * {@link #RIGHT}). + * + * @see #getAxisLocation() + */ + public void setAxisLocation(int location) { + if ((location >= 0) && (location < 3)) { + this.axisLocation = location; + fireChangeEvent(); + } + else { + throw new IllegalArgumentException("Location not recognised."); + } + } + + /** + * Gets the font used to display the current value. + * + * @return The font. + * + * @see #setValueFont(Font) + */ + public Font getValueFont() { + return this.valueFont; + } + + /** + * Sets the font used to display the current value. + * + * @param f the new font (null not permitted). + * + * @see #getValueFont() + */ + public void setValueFont(Font f) { + ParamChecks.nullNotPermitted(f, "f"); + if (!this.valueFont.equals(f)) { + this.valueFont = f; + fireChangeEvent(); + } + } + + /** + * Gets the paint used to display the current value. + * + * @return The paint. + * + * @see #setValuePaint(Paint) + */ + public Paint getValuePaint() { + return this.valuePaint; + } + + /** + * Sets the paint used to display the current value and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the new paint (null not permitted). + * + * @see #getValuePaint() + */ + public void setValuePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + if (!this.valuePaint.equals(paint)) { + this.valuePaint = paint; + fireChangeEvent(); + } + } + + // FIXME: No getValueFormat() method? + + /** + * Sets the formatter for the value label and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param formatter the new formatter (null not permitted). + */ + public void setValueFormat(NumberFormat formatter) { + ParamChecks.nullNotPermitted(formatter, "formatter"); + this.valueFormat = formatter; + fireChangeEvent(); + } + + /** + * Returns the default mercury paint. + * + * @return The paint (never null). + * + * @see #setMercuryPaint(Paint) + */ + public Paint getMercuryPaint() { + return this.mercuryPaint; + } + + /** + * Sets the default mercury paint and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param paint the new paint (null not permitted). + * + * @see #getMercuryPaint() + */ + public void setMercuryPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.mercuryPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether not value lines are displayed. + * + * @return The flag. + * + * @see #setShowValueLines(boolean) + * + * @deprecated This flag doesn't do anything useful/visible. Deprecated + * as of version 1.0.6. + */ + public boolean getShowValueLines() { + return this.showValueLines; + } + + /** + * Sets the display as to whether to show value lines in the output. + * + * @param b Whether to show value lines in the thermometer + * + * @see #getShowValueLines() + * + * @deprecated This flag doesn't do anything useful/visible. Deprecated + * as of version 1.0.6. + */ + public void setShowValueLines(boolean b) { + this.showValueLines = b; + fireChangeEvent(); + } + + /** + * Sets information for a particular range. + * + * @param range the range to specify information about. + * @param low the low value for the range + * @param hi the high value for the range + */ + public void setSubrangeInfo(int range, double low, double hi) { + setSubrangeInfo(range, low, hi, low, hi); + } + + /** + * Sets the subrangeInfo attribute of the ThermometerPlot object + * + * @param range the new rangeInfo value. + * @param rangeLow the new rangeInfo value + * @param rangeHigh the new rangeInfo value + * @param displayLow the new rangeInfo value + * @param displayHigh the new rangeInfo value + */ + public void setSubrangeInfo(int range, + double rangeLow, double rangeHigh, + double displayLow, double displayHigh) { + + if ((range >= 0) && (range < 3)) { + setSubrange(range, rangeLow, rangeHigh); + setDisplayRange(range, displayLow, displayHigh); + setAxisRange(); + fireChangeEvent(); + } + + } + + /** + * Sets the bounds for a subrange. + * + * @param range the range type. + * @param low the low value. + * @param high the high value. + */ + public void setSubrange(int range, double low, double high) { + if ((range >= 0) && (range < 3)) { + this.subrangeInfo[range][RANGE_HIGH] = high; + this.subrangeInfo[range][RANGE_LOW] = low; + } + } + + /** + * Sets the displayed bounds for a sub range. + * + * @param range the range type. + * @param low the low value. + * @param high the high value. + */ + public void setDisplayRange(int range, double low, double high) { + + if ((range >= 0) && (range < this.subrangeInfo.length) + && isValidNumber(high) && isValidNumber(low)) { + + if (high > low) { + this.subrangeInfo[range][DISPLAY_HIGH] = high; + this.subrangeInfo[range][DISPLAY_LOW] = low; + } + else { + this.subrangeInfo[range][DISPLAY_HIGH] = low; + this.subrangeInfo[range][DISPLAY_LOW] = high; + } + + } + + } + + /** + * Gets the paint used for a particular subrange. + * + * @param range the range (. + * + * @return The paint. + * + * @see #setSubrangePaint(int, Paint) + */ + public Paint getSubrangePaint(int range) { + if ((range >= 0) && (range < this.subrangePaint.length)) { + return this.subrangePaint[range]; + } + else { + return this.mercuryPaint; + } + } + + /** + * Sets the paint to be used for a subrange and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param range the range (0, 1 or 2). + * @param paint the paint to be applied (null not permitted). + * + * @see #getSubrangePaint(int) + */ + public void setSubrangePaint(int range, Paint paint) { + if ((range >= 0) + && (range < this.subrangePaint.length) && (paint != null)) { + this.subrangePaint[range] = paint; + fireChangeEvent(); + } + } + + /** + * Returns a flag that controls whether or not the thermometer axis zooms + * to display the subrange within which the data value falls. + * + * @return The flag. + */ + public boolean getFollowDataInSubranges() { + return this.followDataInSubranges; + } + + /** + * Sets the flag that controls whether or not the thermometer axis zooms + * to display the subrange within which the data value falls. + * + * @param flag the flag. + */ + public void setFollowDataInSubranges(boolean flag) { + this.followDataInSubranges = flag; + fireChangeEvent(); + } + + /** + * Returns a flag that controls whether or not the mercury color changes + * for each subrange. + * + * @return The flag. + * + * @see #setUseSubrangePaint(boolean) + */ + public boolean getUseSubrangePaint() { + return this.useSubrangePaint; + } + + /** + * Sets the range colour change option. + * + * @param flag the new range colour change option + * + * @see #getUseSubrangePaint() + */ + public void setUseSubrangePaint(boolean flag) { + this.useSubrangePaint = flag; + fireChangeEvent(); + } + + /** + * Returns the bulb radius, in Java2D units. + + * @return The bulb radius. + * + * @since 1.0.7 + */ + public int getBulbRadius() { + return this.bulbRadius; + } + + /** + * Sets the bulb radius (in Java2D units) and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param r the new radius (in Java2D units). + * + * @see #getBulbRadius() + * + * @since 1.0.7 + */ + public void setBulbRadius(int r) { + this.bulbRadius = r; + fireChangeEvent(); + } + + /** + * Returns the bulb diameter, which is always twice the value returned + * by {@link #getBulbRadius()}. + * + * @return The bulb diameter. + * + * @since 1.0.7 + */ + public int getBulbDiameter() { + return getBulbRadius() * 2; + } + + /** + * Returns the column radius, in Java2D units. + * + * @return The column radius. + * + * @see #setColumnRadius(int) + * + * @since 1.0.7 + */ + public int getColumnRadius() { + return this.columnRadius; + } + + /** + * Sets the column radius (in Java2D units) and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param r the new radius. + * + * @see #getColumnRadius() + * + * @since 1.0.7 + */ + public void setColumnRadius(int r) { + this.columnRadius = r; + fireChangeEvent(); + } + + /** + * Returns the column diameter, which is always twice the value returned + * by {@link #getColumnRadius()}. + * + * @return The column diameter. + * + * @since 1.0.7 + */ + public int getColumnDiameter() { + return getColumnRadius() * 2; + } + + /** + * Returns the gap, in Java2D units, between the two outlines that + * represent the thermometer. + * + * @return The gap. + * + * @see #setGap(int) + * + * @since 1.0.7 + */ + public int getGap() { + return this.gap; + } + + /** + * Sets the gap (in Java2D units) between the two outlines that represent + * the thermometer, and sends a {@link PlotChangeEvent} to all registered + * listeners. + * + * @param gap the new gap. + * + * @see #getGap() + * + * @since 1.0.7 + */ + public void setGap(int gap) { + this.gap = gap; + fireChangeEvent(); + } + + /** + * Draws the plot on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device. + * @param area the area within which the plot should be drawn. + * @param anchor the anchor point (null permitted). + * @param parentState the state from the parent plot, if there is one. + * @param info collects info about the drawing. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, + PlotRenderingInfo info) { + + RoundRectangle2D outerStem = new RoundRectangle2D.Double(); + RoundRectangle2D innerStem = new RoundRectangle2D.Double(); + RoundRectangle2D mercuryStem = new RoundRectangle2D.Double(); + Ellipse2D outerBulb = new Ellipse2D.Double(); + Ellipse2D innerBulb = new Ellipse2D.Double(); + String temp; + FontMetrics metrics; + if (info != null) { + info.setPlotArea(area); + } + + // adjust for insets... + RectangleInsets insets = getInsets(); + insets.trim(area); + drawBackground(g2, area); + + // adjust for padding... + Rectangle2D interior = (Rectangle2D) area.clone(); + this.padding.trim(interior); + int midX = (int) (interior.getX() + (interior.getWidth() / 2)); + int midY = (int) (interior.getY() + (interior.getHeight() / 2)); + int stemTop = (int) (interior.getMinY() + getBulbRadius()); + int stemBottom = (int) (interior.getMaxY() - getBulbDiameter()); + Rectangle2D dataArea = new Rectangle2D.Double(midX - getColumnRadius(), + stemTop, getColumnRadius(), stemBottom - stemTop); + + outerBulb.setFrame(midX - getBulbRadius(), stemBottom, + getBulbDiameter(), getBulbDiameter()); + + outerStem.setRoundRect(midX - getColumnRadius(), interior.getMinY(), + getColumnDiameter(), stemBottom + getBulbDiameter() - stemTop, + getColumnDiameter(), getColumnDiameter()); + + Area outerThermometer = new Area(outerBulb); + Area tempArea = new Area(outerStem); + outerThermometer.add(tempArea); + + innerBulb.setFrame(midX - getBulbRadius() + getGap(), stemBottom + + getGap(), getBulbDiameter() - getGap() * 2, getBulbDiameter() + - getGap() * 2); + + innerStem.setRoundRect(midX - getColumnRadius() + getGap(), + interior.getMinY() + getGap(), getColumnDiameter() + - getGap() * 2, stemBottom + getBulbDiameter() - getGap() * 2 + - stemTop, getColumnDiameter() - getGap() * 2, + getColumnDiameter() - getGap() * 2); + + Area innerThermometer = new Area(innerBulb); + tempArea = new Area(innerStem); + innerThermometer.add(tempArea); + + if ((this.dataset != null) && (this.dataset.getValue() != null)) { + double current = this.dataset.getValue().doubleValue(); + double ds = this.rangeAxis.valueToJava2D(current, dataArea, + RectangleEdge.LEFT); + + int i = getColumnDiameter() - getGap() * 2; // already calculated + int j = getColumnRadius() - getGap(); // already calculated + int l = (i / 2); + int k = (int) Math.round(ds); + if (k < (getGap() + interior.getMinY())) { + k = (int) (getGap() + interior.getMinY()); + l = getBulbRadius(); + } + + Area mercury = new Area(innerBulb); + + if (k < (stemBottom + getBulbRadius())) { + mercuryStem.setRoundRect(midX - j, k, i, + (stemBottom + getBulbRadius()) - k, l, l); + tempArea = new Area(mercuryStem); + mercury.add(tempArea); + } + + g2.setPaint(getCurrentPaint()); + g2.fill(mercury); + + // draw range indicators... + if (this.subrangeIndicatorsVisible) { + g2.setStroke(this.subrangeIndicatorStroke); + Range range = this.rangeAxis.getRange(); + + // draw start of normal range + double value = this.subrangeInfo[NORMAL][RANGE_LOW]; + if (range.contains(value)) { + double x = midX + getColumnRadius() + 2; + double y = this.rangeAxis.valueToJava2D(value, dataArea, + RectangleEdge.LEFT); + Line2D line = new Line2D.Double(x, y, x + 10, y); + g2.setPaint(this.subrangePaint[NORMAL]); + g2.draw(line); + } + + // draw start of warning range + value = this.subrangeInfo[WARNING][RANGE_LOW]; + if (range.contains(value)) { + double x = midX + getColumnRadius() + 2; + double y = this.rangeAxis.valueToJava2D(value, dataArea, + RectangleEdge.LEFT); + Line2D line = new Line2D.Double(x, y, x + 10, y); + g2.setPaint(this.subrangePaint[WARNING]); + g2.draw(line); + } + + // draw start of critical range + value = this.subrangeInfo[CRITICAL][RANGE_LOW]; + if (range.contains(value)) { + double x = midX + getColumnRadius() + 2; + double y = this.rangeAxis.valueToJava2D(value, dataArea, + RectangleEdge.LEFT); + Line2D line = new Line2D.Double(x, y, x + 10, y); + g2.setPaint(this.subrangePaint[CRITICAL]); + g2.draw(line); + } + } + + // draw the axis... + if ((this.rangeAxis != null) && (this.axisLocation != NONE)) { + int drawWidth = AXIS_GAP; + if (this.showValueLines) { + drawWidth += getColumnDiameter(); + } + Rectangle2D drawArea; + double cursor; + + switch (this.axisLocation) { + case RIGHT: + cursor = midX + getColumnRadius(); + drawArea = new Rectangle2D.Double(cursor, + stemTop, drawWidth, (stemBottom - stemTop + 1)); + this.rangeAxis.draw(g2, cursor, area, drawArea, + RectangleEdge.RIGHT, null); + break; + + case LEFT: + default: + //cursor = midX - COLUMN_RADIUS - AXIS_GAP; + cursor = midX - getColumnRadius(); + drawArea = new Rectangle2D.Double(cursor, stemTop, + drawWidth, (stemBottom - stemTop + 1)); + this.rangeAxis.draw(g2, cursor, area, drawArea, + RectangleEdge.LEFT, null); + break; + } + + } + + // draw text value on screen + g2.setFont(this.valueFont); + g2.setPaint(this.valuePaint); + metrics = g2.getFontMetrics(); + switch (this.valueLocation) { + case RIGHT: + g2.drawString(this.valueFormat.format(current), + midX + getColumnRadius() + getGap(), midY); + break; + case LEFT: + String valueString = this.valueFormat.format(current); + int stringWidth = metrics.stringWidth(valueString); + g2.drawString(valueString, midX - getColumnRadius() + - getGap() - stringWidth, midY); + break; + case BULB: + temp = this.valueFormat.format(current); + i = metrics.stringWidth(temp) / 2; + g2.drawString(temp, midX - i, + stemBottom + getBulbRadius() + getGap()); + break; + default: + } + /***/ + } + + g2.setPaint(this.thermometerPaint); + g2.setFont(this.valueFont); + + // draw units indicator + metrics = g2.getFontMetrics(); + int tickX1 = midX - getColumnRadius() - getGap() * 2 + - metrics.stringWidth(UNITS[this.units]); + if (tickX1 > area.getMinX()) { + g2.drawString(UNITS[this.units], tickX1, + (int) (area.getMinY() + 20)); + } + + // draw thermometer outline + g2.setStroke(this.thermometerStroke); + g2.draw(outerThermometer); + g2.draw(innerThermometer); + + drawOutline(g2, area); + } + + /** + * A zoom method that does nothing. Plots are required to support the + * zoom operation. In the case of a thermometer chart, it doesn't make + * sense to zoom in or out, so the method is empty. + * + * @param percent the zoom percentage. + */ + @Override + public void zoom(double percent) { + // intentionally blank + } + + /** + * Returns a short string describing the type of plot. + * + * @return A short string describing the type of plot. + */ + @Override + public String getPlotType() { + return localizationResources.getString("Thermometer_Plot"); + } + + /** + * Checks to see if a new value means the axis range needs adjusting. + * + * @param event the dataset change event. + */ + @Override + public void datasetChanged(DatasetChangeEvent event) { + if (this.dataset != null) { + Number vn = this.dataset.getValue(); + if (vn != null) { + double value = vn.doubleValue(); + if (inSubrange(NORMAL, value)) { + this.subrange = NORMAL; + } + else if (inSubrange(WARNING, value)) { + this.subrange = WARNING; + } + else if (inSubrange(CRITICAL, value)) { + this.subrange = CRITICAL; + } + else { + this.subrange = -1; + } + setAxisRange(); + } + } + super.datasetChanged(event); + } + + /** + * Returns the minimum value in either the domain or the range, whichever + * is displayed against the vertical axis for the particular type of plot + * implementing this interface. + * + * @return The minimum value in either the domain or the range. + * + * @deprecated This method is not used. Officially deprecated in version + * 1.0.6. + */ + public Number getMinimumVerticalDataValue() { + return new Double(this.lowerBound); + } + + /** + * Returns the maximum value in either the domain or the range, whichever + * is displayed against the vertical axis for the particular type of plot + * implementing this interface. + * + * @return The maximum value in either the domain or the range + * + * @deprecated This method is not used. Officially deprecated in version + * 1.0.6. + */ + public Number getMaximumVerticalDataValue() { + return new Double(this.upperBound); + } + + /** + * Returns the data range. + * + * @param axis the axis. + * + * @return The range of data displayed. + */ + @Override + public Range getDataRange(ValueAxis axis) { + return new Range(this.lowerBound, this.upperBound); + } + + /** + * Sets the axis range to the current values in the rangeInfo array. + */ + protected void setAxisRange() { + if ((this.subrange >= 0) && (this.followDataInSubranges)) { + this.rangeAxis.setRange( + new Range(this.subrangeInfo[this.subrange][DISPLAY_LOW], + this.subrangeInfo[this.subrange][DISPLAY_HIGH])); + } + else { + this.rangeAxis.setRange(this.lowerBound, this.upperBound); + } + } + + /** + * Returns the legend items for the plot. + * + * @return null. + */ + @Override + public LegendItemCollection getLegendItems() { + return null; + } + + /** + * Returns the orientation of the plot. + * + * @return The orientation (always {@link PlotOrientation#VERTICAL}). + */ + @Override + public PlotOrientation getOrientation() { + return PlotOrientation.VERTICAL; + } + + /** + * Determine whether a number is valid and finite. + * + * @param d the number to be tested. + * + * @return true if the number is valid and finite, and + * false otherwise. + */ + protected static boolean isValidNumber(double d) { + return (!(Double.isNaN(d) || Double.isInfinite(d))); + } + + /** + * Returns true if the value is in the specified range, and false otherwise. + * + * @param subrange the subrange. + * @param value the value to check. + * + * @return A boolean. + */ + private boolean inSubrange(int subrange, double value) { + return (value > this.subrangeInfo[subrange][RANGE_LOW] + && value <= this.subrangeInfo[subrange][RANGE_HIGH]); + } + + /** + * Returns the mercury paint corresponding to the current data value. + * Called from the {@link #draw(Graphics2D, Rectangle2D, Point2D, + * PlotState, PlotRenderingInfo)} method. + * + * @return The paint (never null). + */ + private Paint getCurrentPaint() { + Paint result = this.mercuryPaint; + if (this.useSubrangePaint) { + double value = this.dataset.getValue().doubleValue(); + if (inSubrange(NORMAL, value)) { + result = this.subrangePaint[NORMAL]; + } + else if (inSubrange(WARNING, value)) { + result = this.subrangePaint[WARNING]; + } + else if (inSubrange(CRITICAL, value)) { + result = this.subrangePaint[CRITICAL]; + } + } + return result; + } + + /** + * Tests this plot for equality with another object. The plot's dataset + * is not considered in the test. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ThermometerPlot)) { + return false; + } + ThermometerPlot that = (ThermometerPlot) obj; + if (!super.equals(obj)) { + return false; + } + if (!ObjectUtilities.equal(this.rangeAxis, that.rangeAxis)) { + return false; + } + if (this.axisLocation != that.axisLocation) { + return false; + } + if (this.lowerBound != that.lowerBound) { + return false; + } + if (this.upperBound != that.upperBound) { + return false; + } + if (!ObjectUtilities.equal(this.padding, that.padding)) { + return false; + } + if (!ObjectUtilities.equal(this.thermometerStroke, + that.thermometerStroke)) { + return false; + } + if (!PaintUtilities.equal(this.thermometerPaint, + that.thermometerPaint)) { + return false; + } + if (this.units != that.units) { + return false; + } + if (this.valueLocation != that.valueLocation) { + return false; + } + if (!ObjectUtilities.equal(this.valueFont, that.valueFont)) { + return false; + } + if (!PaintUtilities.equal(this.valuePaint, that.valuePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.valueFormat, that.valueFormat)) { + return false; + } + if (!PaintUtilities.equal(this.mercuryPaint, that.mercuryPaint)) { + return false; + } + if (this.showValueLines != that.showValueLines) { + return false; + } + if (this.subrange != that.subrange) { + return false; + } + if (this.followDataInSubranges != that.followDataInSubranges) { + return false; + } + if (!equal(this.subrangeInfo, that.subrangeInfo)) { + return false; + } + if (this.useSubrangePaint != that.useSubrangePaint) { + return false; + } + if (this.bulbRadius != that.bulbRadius) { + return false; + } + if (this.columnRadius != that.columnRadius) { + return false; + } + if (this.gap != that.gap) { + return false; + } + for (int i = 0; i < this.subrangePaint.length; i++) { + if (!PaintUtilities.equal(this.subrangePaint[i], + that.subrangePaint[i])) { + return false; + } + } + return true; + } + + /** + * Tests two double[][] arrays for equality. + * + * @param array1 the first array (null permitted). + * @param array2 the second arrray (null permitted). + * + * @return A boolean. + */ + private static boolean equal(double[][] array1, double[][] array2) { + if (array1 == null) { + return (array2 == null); + } + if (array2 == null) { + return false; + } + if (array1.length != array2.length) { + return false; + } + for (int i = 0; i < array1.length; i++) { + if (!Arrays.equals(array1[i], array2[i])) { + return false; + } + } + return true; + } + + /** + * Returns a clone of the plot. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the plot cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + + ThermometerPlot clone = (ThermometerPlot) super.clone(); + + if (clone.dataset != null) { + clone.dataset.addChangeListener(clone); + } + clone.rangeAxis = (ValueAxis) ObjectUtilities.clone(this.rangeAxis); + if (clone.rangeAxis != null) { + clone.rangeAxis.setPlot(clone); + clone.rangeAxis.addChangeListener(clone); + } + clone.valueFormat = (NumberFormat) this.valueFormat.clone(); + clone.subrangePaint = (Paint[]) this.subrangePaint.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.writeStroke(this.thermometerStroke, stream); + SerialUtilities.writePaint(this.thermometerPaint, stream); + SerialUtilities.writePaint(this.valuePaint, stream); + SerialUtilities.writePaint(this.mercuryPaint, stream); + SerialUtilities.writeStroke(this.subrangeIndicatorStroke, stream); + SerialUtilities.writeStroke(this.rangeIndicatorStroke, stream); + for (int i = 0; i < 3; i++) { + SerialUtilities.writePaint(this.subrangePaint[i], 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.thermometerStroke = SerialUtilities.readStroke(stream); + this.thermometerPaint = SerialUtilities.readPaint(stream); + this.valuePaint = SerialUtilities.readPaint(stream); + this.mercuryPaint = SerialUtilities.readPaint(stream); + this.subrangeIndicatorStroke = SerialUtilities.readStroke(stream); + this.rangeIndicatorStroke = SerialUtilities.readStroke(stream); + this.subrangePaint = new Paint[3]; + for (int i = 0; i < 3; i++) { + this.subrangePaint[i] = SerialUtilities.readPaint(stream); + } + if (this.rangeAxis != null) { + this.rangeAxis.addChangeListener(this); + } + } + + /** + * Multiplies the range on the domain axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param state the plot state. + * @param source the source point. + */ + @Override + public void zoomDomainAxes(double factor, PlotRenderingInfo state, + Point2D source) { + // no domain axis to zoom + } + + /** + * Multiplies the range on the domain axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param state the plot state. + * @param source the source point. + * @param useAnchor a flag that controls whether or not the source point + * is used for the zoom anchor. + * + * @since 1.0.7 + */ + @Override + public void zoomDomainAxes(double factor, PlotRenderingInfo state, + Point2D source, boolean useAnchor) { + // no domain axis to zoom + } + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param state the plot state. + * @param source the source point. + */ + @Override + public void zoomRangeAxes(double factor, PlotRenderingInfo state, + Point2D source) { + this.rangeAxis.resizeRange(factor); + } + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param state the plot state. + * @param source the source point. + * @param useAnchor a flag that controls whether or not the source point + * is used for the zoom anchor. + * + * @since 1.0.7 + */ + @Override + public void zoomRangeAxes(double factor, PlotRenderingInfo state, + Point2D source, boolean useAnchor) { + double anchorY = this.getRangeAxis().java2DToValue(source.getY(), + state.getDataArea(), RectangleEdge.LEFT); + this.rangeAxis.resizeRange(factor, anchorY); + } + + /** + * This method does nothing. + * + * @param lowerPercent the lower percent. + * @param upperPercent the upper percent. + * @param state the plot state. + * @param source the source point. + */ + @Override + public void zoomDomainAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo state, Point2D source) { + // no domain axis to zoom + } + + /** + * Zooms the range axes. + * + * @param lowerPercent the lower percent. + * @param upperPercent the upper percent. + * @param state the plot state. + * @param source the source point. + */ + @Override + public void zoomRangeAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo state, Point2D source) { + this.rangeAxis.zoomRange(lowerPercent, upperPercent); + } + + /** + * Returns false. + * + * @return A boolean. + */ + @Override + public boolean isDomainZoomable() { + return false; + } + + /** + * Returns true. + * + * @return A boolean. + */ + @Override + public boolean isRangeZoomable() { + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ValueAxisPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ValueAxisPlot.java new file mode 100755 index 0000000..55404d4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ValueAxisPlot.java @@ -0,0 +1,64 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * ValueAxisPlot.java + * ------------------ + * + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 07-May-2003 : Version 1 (DG); + * 11-Nov-2004 : Changed Horizontal --> Domain and Vertical --> Range (DG); + * 12-Nov-2004 : Moved zooming methods to new Zoomable interface (DG); + * + */ + +package org.jfree.chart.plot; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.data.Range; + +/** + * An interface that is implemented by plots that use a {@link ValueAxis}, + * providing a standard method to find the current data range. + */ +public interface ValueAxisPlot { + + /** + * Returns the data range that should apply for the specified axis. + * + * @param axis the axis. + * + * @return The data range. + */ + public Range getDataRange(ValueAxis axis); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ValueMarker.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ValueMarker.java new file mode 100755 index 0000000..05c7c35 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/ValueMarker.java @@ -0,0 +1,157 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * ValueMarker.java + * ---------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 09-Feb-2004 : Version 1 (DG); + * 16-Feb-2005 : Added new constructor (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 05-Sep-2006 : Added setValue() method (DG); + * 08-Oct-2007 : Fixed bug 1808376, constructor calling super with incorrect + * values (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.Paint; +import java.awt.Stroke; + +import org.jfree.chart.event.MarkerChangeEvent; + +/** + * A marker that represents a single value. Markers can be added to plots to + * highlight specific values. + */ +public class ValueMarker extends Marker { + + /** The value. */ + private double value; + + /** + * Creates a new marker. + * + * @param value the value. + */ + public ValueMarker(double value) { + super(); + this.value = value; + } + + /** + * Creates a new marker. + * + * @param value the value. + * @param paint the paint (null not permitted). + * @param stroke the stroke (null not permitted). + */ + public ValueMarker(double value, Paint paint, Stroke stroke) { + this(value, paint, stroke, paint, stroke, 1.0f); + } + + /** + * Creates a new value marker. + * + * @param value the value. + * @param paint the paint (null not permitted). + * @param stroke the stroke (null not permitted). + * @param outlinePaint the outline paint (null permitted). + * @param outlineStroke the outline stroke (null permitted). + * @param alpha the alpha transparency (in the range 0.0f to 1.0f). + */ + public ValueMarker(double value, Paint paint, Stroke stroke, + Paint outlinePaint, Stroke outlineStroke, float alpha) { + super(paint, stroke, outlinePaint, outlineStroke, alpha); + this.value = value; + } + + /** + * Returns the value. + * + * @return The value. + * + * @see #setValue(double) + */ + public double getValue() { + return this.value; + } + + /** + * Sets the value for the marker and sends a {@link MarkerChangeEvent} to + * all registered listeners. + * + * @param value the value. + * + * @see #getValue() + * + * @since 1.0.3 + */ + public void setValue(double value) { + this.value = value; + notifyListeners(new MarkerChangeEvent(this)); + } + + /** + * Tests this marker for equality with an arbitrary object. This method + * returns true if: + * + *

    + *
  • obj is not null;
  • + *
  • obj is an instance of ValueMarker;
  • + *
  • obj has the same value as this marker;
  • + *
  • super.equals(obj) returns true.
  • + *
+ * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof ValueMarker)) { + return false; + } + ValueMarker that = (ValueMarker) obj; + if (this.value != that.value) { + return false; + } + return true; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/WaferMapPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/WaferMapPlot.java new file mode 100755 index 0000000..9e24b43 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/WaferMapPlot.java @@ -0,0 +1,434 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * WaferMapPlot.java + * ----------------- + * + * (C) Copyright 2003-2008, by Robert Redburn and Contributors. + * + * Original Author: Robert Redburn; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 25-Nov-2003 : Version 1 contributed by Robert Redburn (DG); + * 05-May-2005 : Updated draw() method parameters (DG); + * 10-Jun-2005 : Changed private --> protected for drawChipGrid(), + * drawWaferEdge() and getWafterEdge() (DG); + * 16-Jun-2005 : Added default constructor and setDataset() method (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * + */ + +package org.jfree.chart.plot; + +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.Arc2D; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; +import java.util.ResourceBundle; + +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.event.RendererChangeListener; +import org.jfree.chart.renderer.WaferMapRenderer; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.WaferMapDataset; +import org.jfree.ui.RectangleInsets; + +/** + * A wafer map plot. + */ +public class WaferMapPlot extends Plot implements RendererChangeListener, + Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 4668320403707308155L; + + /** The default grid line stroke. */ + public static final Stroke DEFAULT_GRIDLINE_STROKE = new BasicStroke(0.5f, + BasicStroke.CAP_BUTT, + BasicStroke.JOIN_BEVEL, + 0.0f, + new float[] {2.0f, 2.0f}, + 0.0f); + + /** The default grid line paint. */ + public static final Paint DEFAULT_GRIDLINE_PAINT = Color.lightGray; + + /** The default crosshair visibility. */ + public static final boolean DEFAULT_CROSSHAIR_VISIBLE = false; + + /** The default crosshair stroke. */ + public static final Stroke DEFAULT_CROSSHAIR_STROKE + = DEFAULT_GRIDLINE_STROKE; + + /** The default crosshair paint. */ + public static final Paint DEFAULT_CROSSHAIR_PAINT = Color.blue; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.plot.LocalizationBundle"); + + /** The plot orientation. + * vertical = notch down + * horizontal = notch right + */ + private PlotOrientation orientation; + + /** The dataset. */ + private WaferMapDataset dataset; + + /** + * Object responsible for drawing the visual representation of each point + * on the plot. + */ + private WaferMapRenderer renderer; + + /** + * Creates a new plot with no dataset. + */ + public WaferMapPlot() { + this(null); + } + + /** + * Creates a new plot. + * + * @param dataset the dataset (null permitted). + */ + public WaferMapPlot(WaferMapDataset dataset) { + this(dataset, null); + } + + /** + * Creates a new plot. + * + * @param dataset the dataset (null permitted). + * @param renderer the renderer (null permitted). + */ + public WaferMapPlot(WaferMapDataset dataset, WaferMapRenderer renderer) { + + super(); + + this.orientation = PlotOrientation.VERTICAL; + + this.dataset = dataset; + if (dataset != null) { + dataset.addChangeListener(this); + } + + this.renderer = renderer; + if (renderer != null) { + renderer.setPlot(this); + renderer.addChangeListener(this); + } + + } + + /** + * Returns the plot type as a string. + * + * @return A short string describing the type of plot. + */ + @Override + public String getPlotType() { + return ("WMAP_Plot"); + } + + /** + * Returns the dataset + * + * @return The dataset (possibly null). + */ + public WaferMapDataset getDataset() { + return this.dataset; + } + + /** + * Sets the dataset used by the plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param dataset the dataset (null permitted). + */ + public void setDataset(WaferMapDataset dataset) { + // if there is an existing dataset, remove the plot from the list of + // change listeners... + if (this.dataset != null) { + this.dataset.removeChangeListener(this); + } + + // set the new dataset, and register the chart as a change listener... + this.dataset = dataset; + if (dataset != null) { + setDatasetGroup(dataset.getGroup()); + dataset.addChangeListener(this); + } + + // send a dataset change event to self to trigger plot change event + datasetChanged(new DatasetChangeEvent(this, dataset)); + } + + /** + * Sets the item renderer, and notifies all listeners of a change to the + * plot. If the renderer is set to null, no chart will be + * drawn. + * + * @param renderer the new renderer (null permitted). + */ + public void setRenderer(WaferMapRenderer renderer) { + if (this.renderer != null) { + this.renderer.removeChangeListener(this); + } + this.renderer = renderer; + if (renderer != null) { + renderer.setPlot(this); + } + fireChangeEvent(); + } + + /** + * Draws the wafermap view. + * + * @param g2 the graphics device. + * @param area the plot area. + * @param anchor the anchor point (null permitted). + * @param state the plot state. + * @param info the plot rendering info. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState state, + PlotRenderingInfo info) { + + // if the plot area is too small, just return... + boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); + boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); + if (b1 || b2) { + return; + } + + // record the plot area... + if (info != null) { + info.setPlotArea(area); + } + + // adjust the drawing area for the plot insets (if any)... + RectangleInsets insets = getInsets(); + insets.trim(area); + + drawChipGrid(g2, area); + drawWaferEdge(g2, area); + + } + + /** + * Calculates and draws the chip locations on the wafer. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + */ + protected void drawChipGrid(Graphics2D g2, Rectangle2D plotArea) { + + Shape savedClip = g2.getClip(); + g2.setClip(getWaferEdge(plotArea)); + Rectangle2D chip = new Rectangle2D.Double(); + int xchips = 35; + int ychips = 20; + double space = 1d; + if (this.dataset != null) { + xchips = this.dataset.getMaxChipX() + 2; + ychips = this.dataset.getMaxChipY() + 2; + space = this.dataset.getChipSpace(); + } + double startX = plotArea.getX(); + double startY = plotArea.getY(); + double chipWidth = 1d; + double chipHeight = 1d; + if (plotArea.getWidth() != plotArea.getHeight()) { + double major, minor; + if (plotArea.getWidth() > plotArea.getHeight()) { + major = plotArea.getWidth(); + minor = plotArea.getHeight(); + } + else { + major = plotArea.getHeight(); + minor = plotArea.getWidth(); + } + //set upperLeft point + if (plotArea.getWidth() == minor) { // x is minor + startY += (major - minor) / 2; + chipWidth = (plotArea.getWidth() - (space * xchips - 1)) + / xchips; + chipHeight = (plotArea.getWidth() - (space * ychips - 1)) + / ychips; + } + else { // y is minor + startX += (major - minor) / 2; + chipWidth = (plotArea.getHeight() - (space * xchips - 1)) + / xchips; + chipHeight = (plotArea.getHeight() - (space * ychips - 1)) + / ychips; + } + } + + for (int x = 1; x <= xchips; x++) { + double upperLeftX = (startX - chipWidth) + (chipWidth * x) + + (space * (x - 1)); + for (int y = 1; y <= ychips; y++) { + double upperLeftY = (startY - chipHeight) + (chipHeight * y) + + (space * (y - 1)); + chip.setFrame(upperLeftX, upperLeftY, chipWidth, chipHeight); + g2.setColor(Color.white); + if (this.dataset.getChipValue(x - 1, ychips - y - 1) != null) { + g2.setPaint( + this.renderer.getChipColor( + this.dataset.getChipValue(x - 1, ychips - y - 1) + ) + ); + } + g2.fill(chip); + g2.setColor(Color.lightGray); + g2.draw(chip); + } + } + g2.setClip(savedClip); + } + + /** + * Calculates the location of the waferedge. + * + * @param plotArea the plot area. + * + * @return The wafer edge. + */ + protected Ellipse2D getWaferEdge(Rectangle2D plotArea) { + Ellipse2D edge = new Ellipse2D.Double(); + double diameter = plotArea.getWidth(); + double upperLeftX = plotArea.getX(); + double upperLeftY = plotArea.getY(); + //get major dimension + if (plotArea.getWidth() != plotArea.getHeight()) { + double major, minor; + if (plotArea.getWidth() > plotArea.getHeight()) { + major = plotArea.getWidth(); + minor = plotArea.getHeight(); + } + else { + major = plotArea.getHeight(); + minor = plotArea.getWidth(); + } + //ellipse diameter is the minor dimension + diameter = minor; + //set upperLeft point + if (plotArea.getWidth() == minor) { // x is minor + upperLeftY = plotArea.getY() + (major - minor) / 2; + } + else { // y is minor + upperLeftX = plotArea.getX() + (major - minor) / 2; + } + } + edge.setFrame(upperLeftX, upperLeftY, diameter, diameter); + return edge; + } + + /** + * Draws the waferedge, including the notch. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + */ + protected void drawWaferEdge(Graphics2D g2, Rectangle2D plotArea) { + // draw the wafer + Ellipse2D waferEdge = getWaferEdge(plotArea); + g2.setColor(Color.black); + g2.draw(waferEdge); + // calculate and draw the notch + // horizontal orientation is considered notch right + // vertical orientation is considered notch down + Arc2D notch; + Rectangle2D waferFrame = waferEdge.getFrame(); + double notchDiameter = waferFrame.getWidth() * 0.04; + if (this.orientation == PlotOrientation.HORIZONTAL) { + Rectangle2D notchFrame = + new Rectangle2D.Double( + waferFrame.getX() + waferFrame.getWidth() + - (notchDiameter / 2), waferFrame.getY() + + (waferFrame.getHeight() / 2) - (notchDiameter / 2), + notchDiameter, notchDiameter + ); + notch = new Arc2D.Double(notchFrame, 90d, 180d, Arc2D.OPEN); + } + else { + Rectangle2D notchFrame = + new Rectangle2D.Double( + waferFrame.getX() + (waferFrame.getWidth() / 2) + - (notchDiameter / 2), waferFrame.getY() + + waferFrame.getHeight() - (notchDiameter / 2), + notchDiameter, notchDiameter + ); + notch = new Arc2D.Double(notchFrame, 0d, 180d, Arc2D.OPEN); + } + g2.setColor(Color.white); + g2.fill(notch); + g2.setColor(Color.black); + g2.draw(notch); + + } + + /** + * Return the legend items from the renderer. + * + * @return The legend items. + */ + @Override + public LegendItemCollection getLegendItems() { + return this.renderer.getLegendCollection(); + } + + /** + * Notifies all registered listeners of a renderer change. + * + * @param event the event. + */ + @Override + public void rendererChanged(RendererChangeEvent event) { + fireChangeEvent(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/XYCrosshairState.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/XYCrosshairState.java new file mode 100755 index 0000000..f391312 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/XYCrosshairState.java @@ -0,0 +1,58 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * XYCrosshairState.java + * --------------------- + * (C) Copyright 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Jun-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import org.jfree.chart.renderer.xy.XYItemRenderer; + +/** + * Crosshair state information for the {@link XYPlot} and {@link XYItemRenderer} + * classes. + */ +public class XYCrosshairState extends CrosshairState { + + /** + * Creates a new instance. + */ + public XYCrosshairState() { + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/XYPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/XYPlot.java new file mode 100755 index 0000000..3508b42 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/XYPlot.java @@ -0,0 +1,5767 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------- + * XYPlot.java + * ----------- + * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Craig MacFarlane; + * Mark Watson (www.markwatson.com); + * Jonathan Nash; + * Gideon Krause; + * Klaus Rheinwald; + * Xavier Poinsard; + * Richard Atkinson; + * Arnaud Lelievre; + * Nicolas Brodu; + * Eduardo Ramalho; + * Sergei Ivanov; + * Richard West, Advanced Micro Devices, Inc.; + * Ulrich Voigt - patches 1997549 and 2686040; + * Peter Kolb - patches 1934255, 2603321 and 2809117; + * Andrew Mickish - patch 1868749; + * + * Changes (from 21-Jun-2001) + * -------------------------- + * 21-Jun-2001 : Removed redundant JFreeChart parameter from constructors (DG); + * 18-Sep-2001 : Updated header and fixed DOS encoding problem (DG); + * 15-Oct-2001 : Data source classes moved to com.jrefinery.data.* (DG); + * 19-Oct-2001 : Removed the code for drawing the visual representation of each + * data point into a separate class StandardXYItemRenderer. + * This will make it easier to add variations to the way the + * charts are drawn. Based on code contributed by Mark + * Watson (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * 20-Nov-2001 : Fixed clipping bug that shows up when chart is displayed + * inside JScrollPane (DG); + * 12-Dec-2001 : Removed unnecessary 'throws' clauses from constructor (DG); + * 13-Dec-2001 : Added skeleton code for tooltips. Added new constructor. (DG); + * 16-Jan-2002 : Renamed the tooltips class (DG); + * 22-Jan-2002 : Added DrawInfo class, incorporating tooltips and crosshairs. + * Crosshairs based on code by Jonathan Nash (DG); + * 05-Feb-2002 : Added alpha-transparency setting based on code by Sylvain + * Vieujot (DG); + * 26-Feb-2002 : Updated getMinimumXXX() and getMaximumXXX() methods to handle + * special case when chart is null (DG); + * 28-Feb-2002 : Renamed Datasets.java --> DatasetUtilities.java (DG); + * 28-Mar-2002 : The plot now registers with the renderer as a property change + * listener. Also added a new constructor (DG); + * 09-Apr-2002 : Removed the transRangeZero from the renderer.drawItem() + * method. Moved the tooltip generator into the renderer (DG); + * 23-Apr-2002 : Fixed bug in methods for drawing horizontal and vertical + * lines (DG); + * 13-May-2002 : Small change to the draw() method so that it works for + * OverlaidXYPlot also (DG); + * 25-Jun-2002 : Removed redundant import (DG); + * 20-Aug-2002 : Renamed getItemRenderer() --> getRenderer(), and + * setXYItemRenderer() --> setRenderer() (DG); + * 28-Aug-2002 : Added mechanism for (optional) plot annotations (DG); + * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 18-Nov-2002 : Added grid settings for both domain and range axis (previously + * these were set in the axes) (DG); + * 09-Jan-2003 : Further additions to the grid settings, plus integrated plot + * border bug fix contributed by Gideon Krause (DG); + * 22-Jan-2003 : Removed monolithic constructor (DG); + * 04-Mar-2003 : Added 'no data' message, see bug report 691634. Added + * secondary range markers using code contributed by Klaus + * Rheinwald (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 03-Apr-2003 : Added setDomainAxisLocation() method (DG); + * 30-Apr-2003 : Moved annotation drawing into a separate method (DG); + * 01-May-2003 : Added multi-pass mechanism for renderers (DG); + * 02-May-2003 : Changed axis locations from int to AxisLocation (DG); + * 15-May-2003 : Added an orientation attribute (DG); + * 02-Jun-2003 : Removed range axis compatibility test (DG); + * 05-Jun-2003 : Added domain and range grid bands (sponsored by Focus Computer + * Services Ltd) (DG); + * 26-Jun-2003 : Fixed bug (757303) in getDataRange() method (DG); + * 02-Jul-2003 : Added patch from bug report 698646 (secondary axes for + * overlaid plots) (DG); + * 23-Jul-2003 : Added support for multiple secondary datasets, axes and + * renderers (DG); + * 27-Jul-2003 : Added support for stacked XY area charts (RA); + * 19-Aug-2003 : Implemented Cloneable (DG); + * 01-Sep-2003 : Fixed bug where change to secondary datasets didn't generate + * change event (797466) (DG) + * 08-Sep-2003 : Added internationalization via use of properties + * resourceBundle (RFE 690236) (AL); + * 08-Sep-2003 : Changed ValueAxis API (DG); + * 08-Sep-2003 : Fixes for serialization (NB); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 17-Sep-2003 : Fixed zooming to include secondary domain axes (DG); + * 18-Sep-2003 : Added getSecondaryDomainAxisCount() and + * getSecondaryRangeAxisCount() methods suggested by Eduardo + * Ramalho (RFE 808548) (DG); + * 23-Sep-2003 : Split domain and range markers into foreground and + * background (DG); + * 06-Oct-2003 : Fixed bug in clearDomainMarkers() and clearRangeMarkers() + * methods. Fixed bug (815876) in addSecondaryRangeMarker() + * method. Added new addSecondaryDomainMarker methods (see bug + * id 815869) (DG); + * 10-Nov-2003 : Added getSecondaryDomain/RangeAxisMappedToDataset() methods + * requested by Eduardo Ramalho (DG); + * 24-Nov-2003 : Removed unnecessary notification when updating axis anchor + * values (DG); + * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); + * 12-Mar-2004 : Fixed bug where primary renderer is always used to determine + * range type (DG); + * 22-Mar-2004 : Fixed cloning bug (DG); + * 23-Mar-2004 : Fixed more cloning bugs (DG); + * 07-Apr-2004 : Fixed problem with axis range when the secondary renderer is + * stacked, see this post in the forum: + * http://www.jfree.org/phpBB2/viewtopic.php?t=8204 (DG); + * 07-Apr-2004 : Added get/setDatasetRenderingOrder() methods (DG); + * 26-Apr-2004 : Added option to fill quadrant areas in the background of the + * plot (DG); + * 27-Apr-2004 : Removed major distinction between primary and secondary + * datasets, renderers and axes (DG); + * 30-Apr-2004 : Modified to make use of the new getRangeExtent() method in the + * renderer interface (DG); + * 13-May-2004 : Added optional fixedLegendItems attribute (DG); + * 19-May-2004 : Added indexOf() method (DG); + * 03-Jun-2004 : Fixed zooming bug (DG); + * 18-Aug-2004 : Added removedAnnotation() method (by tkram01) (DG); + * 05-Oct-2004 : Modified storage type for dataset-to-axis maps (DG); + * 06-Oct-2004 : Modified getDataRange() method to use renderer to determine + * the x-value range (now matches behaviour for y-values). Added + * getDomainAxisIndex() method (DG); + * 12-Nov-2004 : Implemented new Zoomable interface (DG); + * 25-Nov-2004 : Small update to clone() implementation (DG); + * 22-Feb-2005 : Changed axis offsets from Spacer --> RectangleInsets (DG); + * 24-Feb-2005 : Added indexOf(XYItemRenderer) method (DG); + * 21-Mar-2005 : Register plot as change listener in setRenderer() method (DG); + * 21-Apr-2005 : Added get/setSeriesRenderingOrder() methods (ET); + * 26-Apr-2005 : Removed LOGGER (DG); + * 04-May-2005 : Fixed serialization of domain and range markers (DG); + * 05-May-2005 : Removed unused draw() method (DG); + * 20-May-2005 : Added setDomainAxes() and setRangeAxes() methods, as per + * RFE 1183100 (DG); + * 01-Jun-2005 : Upon deserialization, register plot as a listener with its + * axes, dataset(s) and renderer(s) - see patch 1209475 (DG); + * 01-Jun-2005 : Added clearDomainMarkers(int) method to match + * clearRangeMarkers(int) (DG); + * 06-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); + * 09-Jun-2005 : Added setRenderers(), as per RFE 1183100 (DG); + * 06-Jul-2005 : Fixed crosshair bug (id = 1233336) (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 26-Jan-2006 : Added getAnnotations() method (DG); + * 05-Sep-2006 : Added MarkerChangeEvent support (DG); + * 13-Oct-2006 : Fixed initialisation of CrosshairState - see bug report + * 1565168 (DG); + * 22-Nov-2006 : Fixed equals() and cloning() for quadrant attributes, plus + * API doc updates (DG); + * 29-Nov-2006 : Added argument checks (DG); + * 15-Jan-2007 : Fixed bug in drawRangeMarkers() (DG); + * 07-Feb-2007 : Fixed bug 1654215, renderer with no dataset (DG); + * 26-Feb-2007 : Added missing setDomainAxisLocation() and + * setRangeAxisLocation() methods (DG); + * 02-Mar-2007 : Fix for crosshair positioning with horizontal orientation + * (see patch 1671648 by Sergei Ivanov) (DG); + * 13-Mar-2007 : Added null argument checks for crosshair attributes (DG); + * 23-Mar-2007 : Added domain zero base line facility (DG); + * 04-May-2007 : Render only visible data items if possible (DG); + * 24-May-2007 : Fixed bug in render method for an empty series (DG); + * 07-Jun-2007 : Modified drawBackground() to pass orientation to + * fillBackground() for handling GradientPaint (DG); + * 24-Sep-2007 : Added new zoom methods (DG); + * 26-Sep-2007 : Include index value in IllegalArgumentExceptions (DG); + * 05-Nov-2007 : Applied patch 1823697, by Richard West, for removal of domain + * and range markers (DG); + * 12-Nov-2007 : Fixed bug in equals() method for domain and range tick + * band paint attributes (DG); + * 27-Nov-2007 : Added new setFixedDomain/RangeAxisSpace() methods (DG); + * 04-Jan-2008 : Fix for quadrant painting error - see patch 1849564 (DG); + * 25-Mar-2008 : Added new methods with optional notification - see patch + * 1913751 (DG); + * 07-Apr-2008 : Fixed NPE in removeDomainMarker() and + * removeRangeMarker() (DG); + * 22-May-2008 : Modified calculateAxisSpace() to process range axes first, + * then adjust the plot area before calculating the space + * for the domain axes (DG); + * 09-Jul-2008 : Added renderer state notification when series pass begins + * and ends - see patch 1997549 by Ulrich Voigt (DG); + * 25-Jul-2008 : Fixed NullPointerException for plots with no axes (DG); + * 15-Aug-2008 : Added getRendererCount() method (DG); + * 25-Sep-2008 : Added minor tick support, see patch 1934255 by Peter Kolb (DG); + * 25-Nov-2008 : Allow datasets to be mapped to multiple axes - based on patch + * 1868749 by Andrew Mickish (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 10-Mar-2009 : Allow some annotations to contribute to axis autoRange (DG); + * 18-Mar-2009 : Modified anchored zoom behaviour and fixed bug in + * "process visible range" rendering (DG); + * 19-Mar-2009 : Added panning support based on patch 2686040 by Ulrich + * Voigt (DG); + * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); + * 30-Mar-2009 : Delegate panning to axes (DG); + * 10-May-2009 : Added check for fixedLegendItems in equals(), and code to + * handle cloning (DG); + * 24-Jun-2009 : Added support for annotation events - see patch 2809117 + * by PK (DG); + * 06-Jul-2009 : Fix for cloning of renderers - see bug 2817504 (DG) + * 10-Jul-2009 : Added optional drop shadow generator (DG); + * 18-Oct-2011 : Fix tooltip offset with shadow renderer (DG); + * 12-Sep-2013 : Check for KEY_SUPPRESS_SHADOW_GENERATION rendering hint (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.AlphaComposite; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.ResourceBundle; +import java.util.Set; +import java.util.TreeMap; +import org.jfree.chart.JFreeChart; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.annotations.Annotation; +import org.jfree.chart.annotations.XYAnnotation; +import org.jfree.chart.annotations.XYAnnotationBoundsInfo; +import org.jfree.chart.axis.Axis; +import org.jfree.chart.axis.AxisCollection; +import org.jfree.chart.axis.AxisLocation; +import org.jfree.chart.axis.AxisSpace; +import org.jfree.chart.axis.AxisState; +import org.jfree.chart.axis.TickType; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.axis.ValueTick; +import org.jfree.chart.event.AnnotationChangeEvent; +import org.jfree.chart.event.ChartChangeEventType; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.event.RendererChangeListener; +import org.jfree.chart.renderer.RendererUtilities; +import org.jfree.chart.renderer.xy.AbstractXYItemRenderer; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.chart.renderer.xy.XYItemRendererState; +import org.jfree.chart.util.ParamChecks; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.chart.util.ShadowGenerator; +import org.jfree.data.Range; +import org.jfree.data.general.Dataset; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.Layer; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectList; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A general class for plotting data in the form of (x, y) pairs. This plot can + * use data from any class that implements the {@link XYDataset} interface. + *

+ * XYPlot makes use of an {@link XYItemRenderer} to draw each point + * on the plot. By using different renderers, various chart types can be + * produced. + *

+ * The {@link org.jfree.chart.ChartFactory} class contains static methods for + * creating pre-configured charts. + */ +public class XYPlot extends Plot implements ValueAxisPlot, Pannable, Zoomable, + RendererChangeListener, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7044148245716569264L; + + /** The default grid line stroke. */ + public static final Stroke DEFAULT_GRIDLINE_STROKE = new BasicStroke(0.5f, + BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0.0f, + new float[] {2.0f, 2.0f}, 0.0f); + + /** The default grid line paint. */ + public static final Paint DEFAULT_GRIDLINE_PAINT = Color.lightGray; + + /** The default crosshair visibility. */ + public static final boolean DEFAULT_CROSSHAIR_VISIBLE = false; + + /** The default crosshair stroke. */ + public static final Stroke DEFAULT_CROSSHAIR_STROKE + = DEFAULT_GRIDLINE_STROKE; + + /** The default crosshair paint. */ + public static final Paint DEFAULT_CROSSHAIR_PAINT = Color.blue; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.plot.LocalizationBundle"); + + /** The plot orientation. */ + private PlotOrientation orientation; + + /** The offset between the data area and the axes. */ + private RectangleInsets axisOffset; + + /** The domain axis / axes (used for the x-values). */ + private ObjectList domainAxes; + + /** The domain axis locations. */ + private ObjectList domainAxisLocations; + + /** The range axis (used for the y-values). */ + private ObjectList rangeAxes; + + /** The range axis location. */ + private ObjectList rangeAxisLocations; + + /** Storage for the datasets. */ + private ObjectList datasets; + + /** Storage for the renderers. */ + private ObjectList renderers; + + /** + * Storage for the mapping between datasets/renderers and domain axes. The + * keys in the map are Integer objects, corresponding to the dataset + * index. The values in the map are List objects containing Integer + * objects (corresponding to the axis indices). If the map contains no + * entry for a dataset, it is assumed to map to the primary domain axis + * (index = 0). + */ + private Map datasetToDomainAxesMap; + + /** + * Storage for the mapping between datasets/renderers and range axes. The + * keys in the map are Integer objects, corresponding to the dataset + * index. The values in the map are List objects containing Integer + * objects (corresponding to the axis indices). If the map contains no + * entry for a dataset, it is assumed to map to the primary domain axis + * (index = 0). + */ + private Map datasetToRangeAxesMap; + + /** The origin point for the quadrants (if drawn). */ + private transient Point2D quadrantOrigin = new Point2D.Double(0.0, 0.0); + + /** The paint used for each quadrant. */ + private transient Paint[] quadrantPaint + = new Paint[] {null, null, null, null}; + + /** A flag that controls whether the domain grid-lines are visible. */ + private boolean domainGridlinesVisible; + + /** The stroke used to draw the domain grid-lines. */ + private transient Stroke domainGridlineStroke; + + /** The paint used to draw the domain grid-lines. */ + private transient Paint domainGridlinePaint; + + /** A flag that controls whether the range grid-lines are visible. */ + private boolean rangeGridlinesVisible; + + /** The stroke used to draw the range grid-lines. */ + private transient Stroke rangeGridlineStroke; + + /** The paint used to draw the range grid-lines. */ + private transient Paint rangeGridlinePaint; + + /** + * A flag that controls whether the domain minor grid-lines are visible. + * + * @since 1.0.12 + */ + private boolean domainMinorGridlinesVisible; + + /** + * The stroke used to draw the domain minor grid-lines. + * + * @since 1.0.12 + */ + private transient Stroke domainMinorGridlineStroke; + + /** + * The paint used to draw the domain minor grid-lines. + * + * @since 1.0.12 + */ + private transient Paint domainMinorGridlinePaint; + + /** + * A flag that controls whether the range minor grid-lines are visible. + * + * @since 1.0.12 + */ + private boolean rangeMinorGridlinesVisible; + + /** + * The stroke used to draw the range minor grid-lines. + * + * @since 1.0.12 + */ + private transient Stroke rangeMinorGridlineStroke; + + /** + * The paint used to draw the range minor grid-lines. + * + * @since 1.0.12 + */ + private transient Paint rangeMinorGridlinePaint; + + /** + * A flag that controls whether or not the zero baseline against the domain + * axis is visible. + * + * @since 1.0.5 + */ + private boolean domainZeroBaselineVisible; + + /** + * The stroke used for the zero baseline against the domain axis. + * + * @since 1.0.5 + */ + private transient Stroke domainZeroBaselineStroke; + + /** + * The paint used for the zero baseline against the domain axis. + * + * @since 1.0.5 + */ + private transient Paint domainZeroBaselinePaint; + + /** + * A flag that controls whether or not the zero baseline against the range + * axis is visible. + */ + private boolean rangeZeroBaselineVisible; + + /** The stroke used for the zero baseline against the range axis. */ + private transient Stroke rangeZeroBaselineStroke; + + /** The paint used for the zero baseline against the range axis. */ + private transient Paint rangeZeroBaselinePaint; + + /** A flag that controls whether or not a domain crosshair is drawn..*/ + private boolean domainCrosshairVisible; + + /** The domain crosshair value. */ + private double domainCrosshairValue; + + /** The pen/brush used to draw the crosshair (if any). */ + private transient Stroke domainCrosshairStroke; + + /** The color used to draw the crosshair (if any). */ + private transient Paint domainCrosshairPaint; + + /** + * A flag that controls whether or not the crosshair locks onto actual + * data points. + */ + private boolean domainCrosshairLockedOnData = true; + + /** A flag that controls whether or not a range crosshair is drawn..*/ + private boolean rangeCrosshairVisible; + + /** The range crosshair value. */ + private double rangeCrosshairValue; + + /** The pen/brush used to draw the crosshair (if any). */ + private transient Stroke rangeCrosshairStroke; + + /** The color used to draw the crosshair (if any). */ + private transient Paint rangeCrosshairPaint; + + /** + * A flag that controls whether or not the crosshair locks onto actual + * data points. + */ + private boolean rangeCrosshairLockedOnData = true; + + /** A map of lists of foreground markers (optional) for the domain axes. */ + private Map foregroundDomainMarkers; + + /** A map of lists of background markers (optional) for the domain axes. */ + private Map backgroundDomainMarkers; + + /** A map of lists of foreground markers (optional) for the range axes. */ + private Map foregroundRangeMarkers; + + /** A map of lists of background markers (optional) for the range axes. */ + private Map backgroundRangeMarkers; + + /** + * A (possibly empty) list of annotations for the plot. The list should + * be initialised in the constructor and never allowed to be + * null. + */ + private List annotations; + + /** The paint used for the domain tick bands (if any). */ + private transient Paint domainTickBandPaint; + + /** The paint used for the range tick bands (if any). */ + private transient Paint rangeTickBandPaint; + + /** The fixed domain axis space. */ + private AxisSpace fixedDomainAxisSpace; + + /** The fixed range axis space. */ + private AxisSpace fixedRangeAxisSpace; + + /** + * The order of the dataset rendering (REVERSE draws the primary dataset + * last so that it appears to be on top). + */ + private DatasetRenderingOrder datasetRenderingOrder + = DatasetRenderingOrder.REVERSE; + + /** + * The order of the series rendering (REVERSE draws the primary series + * last so that it appears to be on top). + */ + private SeriesRenderingOrder seriesRenderingOrder + = SeriesRenderingOrder.REVERSE; + + /** + * The weight for this plot (only relevant if this is a subplot in a + * combined plot). + */ + private int weight; + + /** + * An optional collection of legend items that can be returned by the + * getLegendItems() method. + */ + private LegendItemCollection fixedLegendItems; + + /** + * A flag that controls whether or not panning is enabled for the domain + * axis/axes. + * + * @since 1.0.13 + */ + private boolean domainPannable; + + /** + * A flag that controls whether or not panning is enabled for the range + * axis/axes. + * + * @since 1.0.13 + */ + private boolean rangePannable; + + /** + * The shadow generator (null permitted). + * + * @since 1.0.14 + */ + private ShadowGenerator shadowGenerator; + + /** + * Creates a new XYPlot instance with no dataset, no axes and + * no renderer. You should specify these items before using the plot. + */ + public XYPlot() { + this(null, null, null, null); + } + + /** + * Creates a new plot with the specified dataset, axes and renderer. Any + * of the arguments can be null, but in that case you should + * take care to specify the value before using the plot (otherwise a + * NullPointerException may be thrown). + * + * @param dataset the dataset (null permitted). + * @param domainAxis the domain axis (null permitted). + * @param rangeAxis the range axis (null permitted). + * @param renderer the renderer (null permitted). + */ + public XYPlot(XYDataset dataset, + ValueAxis domainAxis, + ValueAxis rangeAxis, + XYItemRenderer renderer) { + + super(); + + this.orientation = PlotOrientation.VERTICAL; + this.weight = 1; // only relevant when this is a subplot + this.axisOffset = RectangleInsets.ZERO_INSETS; + + // allocate storage for datasets, axes and renderers (all optional) + this.domainAxes = new ObjectList(); + this.domainAxisLocations = new ObjectList(); + this.foregroundDomainMarkers = new HashMap(); + this.backgroundDomainMarkers = new HashMap(); + + this.rangeAxes = new ObjectList(); + this.rangeAxisLocations = new ObjectList(); + this.foregroundRangeMarkers = new HashMap(); + this.backgroundRangeMarkers = new HashMap(); + + this.datasets = new ObjectList(); + this.renderers = new ObjectList(); + + this.datasetToDomainAxesMap = new TreeMap(); + this.datasetToRangeAxesMap = new TreeMap(); + + this.annotations = new java.util.ArrayList(); + + this.datasets.set(0, dataset); + if (dataset != null) { + dataset.addChangeListener(this); + } + + this.renderers.set(0, renderer); + if (renderer != null) { + renderer.setPlot(this); + renderer.addChangeListener(this); + } + + this.domainAxes.set(0, domainAxis); + this.mapDatasetToDomainAxis(0, 0); + if (domainAxis != null) { + domainAxis.setPlot(this); + domainAxis.addChangeListener(this); + } + this.domainAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT); + + this.rangeAxes.set(0, rangeAxis); + this.mapDatasetToRangeAxis(0, 0); + if (rangeAxis != null) { + rangeAxis.setPlot(this); + rangeAxis.addChangeListener(this); + } + this.rangeAxisLocations.set(0, AxisLocation.BOTTOM_OR_LEFT); + + configureDomainAxes(); + configureRangeAxes(); + + this.domainGridlinesVisible = true; + this.domainGridlineStroke = DEFAULT_GRIDLINE_STROKE; + this.domainGridlinePaint = DEFAULT_GRIDLINE_PAINT; + + this.domainMinorGridlinesVisible = false; + this.domainMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; + this.domainMinorGridlinePaint = Color.white; + + this.domainZeroBaselineVisible = false; + this.domainZeroBaselinePaint = Color.black; + this.domainZeroBaselineStroke = new BasicStroke(0.5f); + + this.rangeGridlinesVisible = true; + this.rangeGridlineStroke = DEFAULT_GRIDLINE_STROKE; + this.rangeGridlinePaint = DEFAULT_GRIDLINE_PAINT; + + this.rangeMinorGridlinesVisible = false; + this.rangeMinorGridlineStroke = DEFAULT_GRIDLINE_STROKE; + this.rangeMinorGridlinePaint = Color.white; + + this.rangeZeroBaselineVisible = false; + this.rangeZeroBaselinePaint = Color.black; + this.rangeZeroBaselineStroke = new BasicStroke(0.5f); + + this.domainCrosshairVisible = false; + this.domainCrosshairValue = 0.0; + this.domainCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; + this.domainCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; + + this.rangeCrosshairVisible = false; + this.rangeCrosshairValue = 0.0; + this.rangeCrosshairStroke = DEFAULT_CROSSHAIR_STROKE; + this.rangeCrosshairPaint = DEFAULT_CROSSHAIR_PAINT; + this.shadowGenerator = null; + } + + /** + * Returns the plot type as a string. + * + * @return A short string describing the type of plot. + */ + @Override + public String getPlotType() { + return localizationResources.getString("XY_Plot"); + } + + /** + * Returns the orientation of the plot. + * + * @return The orientation (never null). + * + * @see #setOrientation(PlotOrientation) + */ + @Override + public PlotOrientation getOrientation() { + return this.orientation; + } + + /** + * Sets the orientation for the plot and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param orientation the orientation (null not allowed). + * + * @see #getOrientation() + */ + public void setOrientation(PlotOrientation orientation) { + ParamChecks.nullNotPermitted(orientation, "orientation"); + if (orientation != this.orientation) { + this.orientation = orientation; + fireChangeEvent(); + } + } + + /** + * Returns the axis offset. + * + * @return The axis offset (never null). + * + * @see #setAxisOffset(RectangleInsets) + */ + public RectangleInsets getAxisOffset() { + return this.axisOffset; + } + + /** + * Sets the axis offsets (gap between the data area and the axes) and sends + * a {@link PlotChangeEvent} to all registered listeners. + * + * @param offset the offset (null not permitted). + * + * @see #getAxisOffset() + */ + public void setAxisOffset(RectangleInsets offset) { + ParamChecks.nullNotPermitted(offset, "offset"); + this.axisOffset = offset; + fireChangeEvent(); + } + + /** + * Returns the domain axis with index 0. If the domain axis for this plot + * is null, then the method will return the parent plot's + * domain axis (if there is a parent plot). + * + * @return The domain axis (possibly null). + * + * @see #getDomainAxis(int) + * @see #setDomainAxis(ValueAxis) + */ + public ValueAxis getDomainAxis() { + return getDomainAxis(0); + } + + /** + * Returns the domain axis with the specified index, or null. + * + * @param index the axis index. + * + * @return The axis (null possible). + * + * @see #setDomainAxis(int, ValueAxis) + */ + public ValueAxis getDomainAxis(int index) { + ValueAxis result = null; + if (index < this.domainAxes.size()) { + result = (ValueAxis) this.domainAxes.get(index); + } + if (result == null) { + Plot parent = getParent(); + if (parent instanceof XYPlot) { + XYPlot xy = (XYPlot) parent; + result = xy.getDomainAxis(index); + } + } + return result; + } + + /** + * Sets the domain axis for the plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param axis the new axis (null permitted). + * + * @see #getDomainAxis() + * @see #setDomainAxis(int, ValueAxis) + */ + public void setDomainAxis(ValueAxis axis) { + setDomainAxis(0, axis); + } + + /** + * Sets a domain axis and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param index the axis index. + * @param axis the axis (null permitted). + * + * @see #getDomainAxis(int) + * @see #setRangeAxis(int, ValueAxis) + */ + public void setDomainAxis(int index, ValueAxis axis) { + setDomainAxis(index, axis, true); + } + + /** + * Sets a domain axis and, if requested, sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param index the axis index. + * @param axis the axis. + * @param notify notify listeners? + * + * @see #getDomainAxis(int) + */ + public void setDomainAxis(int index, ValueAxis axis, boolean notify) { + ValueAxis existing = getDomainAxis(index); + if (existing != null) { + existing.removeChangeListener(this); + } + if (axis != null) { + axis.setPlot(this); + } + this.domainAxes.set(index, axis); + if (axis != null) { + axis.configure(); + axis.addChangeListener(this); + } + if (notify) { + fireChangeEvent(); + } + } + + /** + * Sets the domain axes for this plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param axes the axes (null not permitted). + * + * @see #setRangeAxes(ValueAxis[]) + */ + public void setDomainAxes(ValueAxis[] axes) { + for (int i = 0; i < axes.length; i++) { + setDomainAxis(i, axes[i], false); + } + fireChangeEvent(); + } + + /** + * Returns the location of the primary domain axis. + * + * @return The location (never null). + * + * @see #setDomainAxisLocation(AxisLocation) + */ + public AxisLocation getDomainAxisLocation() { + return (AxisLocation) this.domainAxisLocations.get(0); + } + + /** + * Sets the location of the primary domain axis and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param location the location (null not permitted). + * + * @see #getDomainAxisLocation() + */ + public void setDomainAxisLocation(AxisLocation location) { + // delegate... + setDomainAxisLocation(0, location, true); + } + + /** + * Sets the location of the domain axis and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param location the location (null not permitted). + * @param notify notify listeners? + * + * @see #getDomainAxisLocation() + */ + public void setDomainAxisLocation(AxisLocation location, boolean notify) { + // delegate... + setDomainAxisLocation(0, location, notify); + } + + /** + * Returns the edge for the primary domain axis (taking into account the + * plot's orientation). + * + * @return The edge. + * + * @see #getDomainAxisLocation() + * @see #getOrientation() + */ + public RectangleEdge getDomainAxisEdge() { + return Plot.resolveDomainAxisLocation(getDomainAxisLocation(), + this.orientation); + } + + /** + * Returns the number of domain axes. + * + * @return The axis count. + * + * @see #getRangeAxisCount() + */ + public int getDomainAxisCount() { + return this.domainAxes.size(); + } + + /** + * Clears the domain axes from the plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @see #clearRangeAxes() + */ + public void clearDomainAxes() { + for (int i = 0; i < this.domainAxes.size(); i++) { + ValueAxis axis = (ValueAxis) this.domainAxes.get(i); + if (axis != null) { + axis.removeChangeListener(this); + } + } + this.domainAxes.clear(); + fireChangeEvent(); + } + + /** + * Configures the domain axes. + */ + public void configureDomainAxes() { + for (int i = 0; i < this.domainAxes.size(); i++) { + ValueAxis axis = (ValueAxis) this.domainAxes.get(i); + if (axis != null) { + axis.configure(); + } + } + } + + /** + * Returns the location for a domain axis. If this hasn't been set + * explicitly, the method returns the location that is opposite to the + * primary domain axis location. + * + * @param index the axis index. + * + * @return The location (never null). + * + * @see #setDomainAxisLocation(int, AxisLocation) + */ + public AxisLocation getDomainAxisLocation(int index) { + AxisLocation result = null; + if (index < this.domainAxisLocations.size()) { + result = (AxisLocation) this.domainAxisLocations.get(index); + } + if (result == null) { + result = AxisLocation.getOpposite(getDomainAxisLocation()); + } + return result; + } + + /** + * Sets the location for a domain axis and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param index the axis index. + * @param location the location (null not permitted for index + * 0). + * + * @see #getDomainAxisLocation(int) + */ + public void setDomainAxisLocation(int index, AxisLocation location) { + // delegate... + setDomainAxisLocation(index, location, true); + } + + /** + * Sets the axis location for a domain axis and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the axis index. + * @param location the location (null not permitted for + * index 0). + * @param notify notify listeners? + * + * @since 1.0.5 + * + * @see #getDomainAxisLocation(int) + * @see #setRangeAxisLocation(int, AxisLocation, boolean) + */ + public void setDomainAxisLocation(int index, AxisLocation location, + boolean notify) { + + if (index == 0 && location == null) { + throw new IllegalArgumentException( + "Null 'location' for index 0 not permitted."); + } + this.domainAxisLocations.set(index, location); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the edge for a domain axis. + * + * @param index the axis index. + * + * @return The edge. + * + * @see #getRangeAxisEdge(int) + */ + public RectangleEdge getDomainAxisEdge(int index) { + AxisLocation location = getDomainAxisLocation(index); + return Plot.resolveDomainAxisLocation(location, this.orientation); + } + + /** + * Returns the range axis for the plot. If the range axis for this plot is + * null, then the method will return the parent plot's range + * axis (if there is a parent plot). + * + * @return The range axis. + * + * @see #getRangeAxis(int) + * @see #setRangeAxis(ValueAxis) + */ + public ValueAxis getRangeAxis() { + return getRangeAxis(0); + } + + /** + * Sets the range axis for the plot and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param axis the axis (null permitted). + * + * @see #getRangeAxis() + * @see #setRangeAxis(int, ValueAxis) + */ + public void setRangeAxis(ValueAxis axis) { + + if (axis != null) { + axis.setPlot(this); + } + + // plot is likely registered as a listener with the existing axis... + ValueAxis existing = getRangeAxis(); + if (existing != null) { + existing.removeChangeListener(this); + } + + this.rangeAxes.set(0, axis); + if (axis != null) { + axis.configure(); + axis.addChangeListener(this); + } + fireChangeEvent(); + + } + + /** + * Returns the location of the primary range axis. + * + * @return The location (never null). + * + * @see #setRangeAxisLocation(AxisLocation) + */ + public AxisLocation getRangeAxisLocation() { + return (AxisLocation) this.rangeAxisLocations.get(0); + } + + /** + * Sets the location of the primary range axis and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param location the location (null not permitted). + * + * @see #getRangeAxisLocation() + */ + public void setRangeAxisLocation(AxisLocation location) { + // delegate... + setRangeAxisLocation(0, location, true); + } + + /** + * Sets the location of the primary range axis and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param location the location (null not permitted). + * @param notify notify listeners? + * + * @see #getRangeAxisLocation() + */ + public void setRangeAxisLocation(AxisLocation location, boolean notify) { + // delegate... + setRangeAxisLocation(0, location, notify); + } + + /** + * Returns the edge for the primary range axis. + * + * @return The range axis edge. + * + * @see #getRangeAxisLocation() + * @see #getOrientation() + */ + public RectangleEdge getRangeAxisEdge() { + return Plot.resolveRangeAxisLocation(getRangeAxisLocation(), + this.orientation); + } + + /** + * Returns a range axis. + * + * @param index the axis index. + * + * @return The axis (null possible). + * + * @see #setRangeAxis(int, ValueAxis) + */ + public ValueAxis getRangeAxis(int index) { + ValueAxis result = null; + if (index < this.rangeAxes.size()) { + result = (ValueAxis) this.rangeAxes.get(index); + } + if (result == null) { + Plot parent = getParent(); + if (parent instanceof XYPlot) { + XYPlot xy = (XYPlot) parent; + result = xy.getRangeAxis(index); + } + } + return result; + } + + /** + * Sets a range axis and sends a {@link PlotChangeEvent} to all registered + * listeners. + * + * @param index the axis index. + * @param axis the axis (null permitted). + * + * @see #getRangeAxis(int) + */ + public void setRangeAxis(int index, ValueAxis axis) { + setRangeAxis(index, axis, true); + } + + /** + * Sets a range axis and, if requested, sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param index the axis index. + * @param axis the axis (null permitted). + * @param notify notify listeners? + * + * @see #getRangeAxis(int) + */ + public void setRangeAxis(int index, ValueAxis axis, boolean notify) { + ValueAxis existing = getRangeAxis(index); + if (existing != null) { + existing.removeChangeListener(this); + } + if (axis != null) { + axis.setPlot(this); + } + this.rangeAxes.set(index, axis); + if (axis != null) { + axis.configure(); + axis.addChangeListener(this); + } + if (notify) { + fireChangeEvent(); + } + } + + /** + * Sets the range axes for this plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param axes the axes (null not permitted). + * + * @see #setDomainAxes(ValueAxis[]) + */ + public void setRangeAxes(ValueAxis[] axes) { + for (int i = 0; i < axes.length; i++) { + setRangeAxis(i, axes[i], false); + } + fireChangeEvent(); + } + + /** + * Returns the number of range axes. + * + * @return The axis count. + * + * @see #getDomainAxisCount() + */ + public int getRangeAxisCount() { + return this.rangeAxes.size(); + } + + /** + * Clears the range axes from the plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @see #clearDomainAxes() + */ + public void clearRangeAxes() { + for (int i = 0; i < this.rangeAxes.size(); i++) { + ValueAxis axis = (ValueAxis) this.rangeAxes.get(i); + if (axis != null) { + axis.removeChangeListener(this); + } + } + this.rangeAxes.clear(); + fireChangeEvent(); + } + + /** + * Configures the range axes. + * + * @see #configureDomainAxes() + */ + public void configureRangeAxes() { + for (int i = 0; i < this.rangeAxes.size(); i++) { + ValueAxis axis = (ValueAxis) this.rangeAxes.get(i); + if (axis != null) { + axis.configure(); + } + } + } + + /** + * Returns the location for a range axis. If this hasn't been set + * explicitly, the method returns the location that is opposite to the + * primary range axis location. + * + * @param index the axis index. + * + * @return The location (never null). + * + * @see #setRangeAxisLocation(int, AxisLocation) + */ + public AxisLocation getRangeAxisLocation(int index) { + AxisLocation result = null; + if (index < this.rangeAxisLocations.size()) { + result = (AxisLocation) this.rangeAxisLocations.get(index); + } + if (result == null) { + result = AxisLocation.getOpposite(getRangeAxisLocation()); + } + return result; + } + + /** + * Sets the location for a range axis and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param index the axis index. + * @param location the location (null permitted). + * + * @see #getRangeAxisLocation(int) + */ + public void setRangeAxisLocation(int index, AxisLocation location) { + // delegate... + setRangeAxisLocation(index, location, true); + } + + /** + * Sets the axis location for a domain axis and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the axis index. + * @param location the location (null not permitted for + * index 0). + * @param notify notify listeners? + * + * @since 1.0.5 + * + * @see #getRangeAxisLocation(int) + * @see #setDomainAxisLocation(int, AxisLocation, boolean) + */ + public void setRangeAxisLocation(int index, AxisLocation location, + boolean notify) { + + if (index == 0 && location == null) { + throw new IllegalArgumentException( + "Null 'location' for index 0 not permitted."); + } + this.rangeAxisLocations.set(index, location); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the edge for a range axis. + * + * @param index the axis index. + * + * @return The edge. + * + * @see #getRangeAxisLocation(int) + * @see #getOrientation() + */ + public RectangleEdge getRangeAxisEdge(int index) { + AxisLocation location = getRangeAxisLocation(index); + return Plot.resolveRangeAxisLocation(location, this.orientation); + } + + /** + * Returns the primary dataset for the plot. + * + * @return The primary dataset (possibly null). + * + * @see #getDataset(int) + * @see #setDataset(XYDataset) + */ + public XYDataset getDataset() { + return getDataset(0); + } + + /** + * Returns a dataset. + * + * @param index the dataset index. + * + * @return The dataset (possibly null). + * + * @see #setDataset(int, XYDataset) + */ + public XYDataset getDataset(int index) { + XYDataset result = null; + if (this.datasets.size() > index) { + result = (XYDataset) this.datasets.get(index); + } + return result; + } + + /** + * Sets the primary dataset for the plot, replacing the existing dataset if + * there is one. + * + * @param dataset the dataset (null permitted). + * + * @see #getDataset() + * @see #setDataset(int, XYDataset) + */ + public void setDataset(XYDataset dataset) { + setDataset(0, dataset); + } + + /** + * Sets a dataset for the plot. + * + * @param index the dataset index. + * @param dataset the dataset (null permitted). + * + * @see #getDataset(int) + */ + public void setDataset(int index, XYDataset dataset) { + XYDataset existing = getDataset(index); + if (existing != null) { + existing.removeChangeListener(this); + } + this.datasets.set(index, dataset); + if (dataset != null) { + dataset.addChangeListener(this); + } + + // send a dataset change event to self... + DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); + datasetChanged(event); + } + + /** + * Returns the number of datasets. + * + * @return The number of datasets. + */ + public int getDatasetCount() { + return this.datasets.size(); + } + + /** + * Returns the index of the specified dataset, or -1 if the + * dataset does not belong to the plot. + * + * @param dataset the dataset (null not permitted). + * + * @return The index. + */ + public int indexOf(XYDataset dataset) { + int result = -1; + for (int i = 0; i < this.datasets.size(); i++) { + if (dataset == this.datasets.get(i)) { + result = i; + break; + } + } + return result; + } + + /** + * Maps a dataset to a particular domain axis. All data will be plotted + * against axis zero by default, no mapping is required for this case. + * + * @param index the dataset index (zero-based). + * @param axisIndex the axis index. + * + * @see #mapDatasetToRangeAxis(int, int) + */ + public void mapDatasetToDomainAxis(int index, int axisIndex) { + List axisIndices = new java.util.ArrayList(1); + axisIndices.add(new Integer(axisIndex)); + mapDatasetToDomainAxes(index, axisIndices); + } + + /** + * Maps the specified dataset to the axes in the list. Note that the + * conversion of data values into Java2D space is always performed using + * the first axis in the list. + * + * @param index the dataset index (zero-based). + * @param axisIndices the axis indices (null permitted). + * + * @since 1.0.12 + */ + public void mapDatasetToDomainAxes(int index, List axisIndices) { + if (index < 0) { + throw new IllegalArgumentException("Requires 'index' >= 0."); + } + checkAxisIndices(axisIndices); + Integer key = new Integer(index); + this.datasetToDomainAxesMap.put(key, new ArrayList(axisIndices)); + // fake a dataset change event to update axes... + datasetChanged(new DatasetChangeEvent(this, getDataset(index))); + } + + /** + * Maps a dataset to a particular range axis. All data will be plotted + * against axis zero by default, no mapping is required for this case. + * + * @param index the dataset index (zero-based). + * @param axisIndex the axis index. + * + * @see #mapDatasetToDomainAxis(int, int) + */ + public void mapDatasetToRangeAxis(int index, int axisIndex) { + List axisIndices = new java.util.ArrayList(1); + axisIndices.add(new Integer(axisIndex)); + mapDatasetToRangeAxes(index, axisIndices); + } + + /** + * Maps the specified dataset to the axes in the list. Note that the + * conversion of data values into Java2D space is always performed using + * the first axis in the list. + * + * @param index the dataset index (zero-based). + * @param axisIndices the axis indices (null permitted). + * + * @since 1.0.12 + */ + public void mapDatasetToRangeAxes(int index, List axisIndices) { + if (index < 0) { + throw new IllegalArgumentException("Requires 'index' >= 0."); + } + checkAxisIndices(axisIndices); + Integer key = new Integer(index); + this.datasetToRangeAxesMap.put(key, new ArrayList(axisIndices)); + // fake a dataset change event to update axes... + datasetChanged(new DatasetChangeEvent(this, getDataset(index))); + } + + /** + * This method is used to perform argument checking on the list of + * axis indices passed to mapDatasetToDomainAxes() and + * mapDatasetToRangeAxes(). + * + * @param indices the list of indices (null permitted). + */ + private void checkAxisIndices(List indices) { + // axisIndices can be: + // 1. null; + // 2. non-empty, containing only Integer objects that are unique. + if (indices == null) { + return; // OK + } + int count = indices.size(); + if (count == 0) { + throw new IllegalArgumentException("Empty list not permitted."); + } + HashSet set = new HashSet(); + for (int i = 0; i < count; i++) { + Object item = indices.get(i); + if (!(item instanceof Integer)) { + throw new IllegalArgumentException( + "Indices must be Integer instances."); + } + if (set.contains(item)) { + throw new IllegalArgumentException("Indices must be unique."); + } + set.add(item); + } + } + + /** + * Returns the number of renderer slots for this plot. + * + * @return The number of renderer slots. + * + * @since 1.0.11 + */ + public int getRendererCount() { + return this.renderers.size(); + } + + /** + * Returns the renderer for the primary dataset. + * + * @return The item renderer (possibly null). + * + * @see #setRenderer(XYItemRenderer) + */ + public XYItemRenderer getRenderer() { + return getRenderer(0); + } + + /** + * Returns the renderer for a dataset, or null. + * + * @param index the renderer index. + * + * @return The renderer (possibly null). + * + * @see #setRenderer(int, XYItemRenderer) + */ + public XYItemRenderer getRenderer(int index) { + XYItemRenderer result = null; + if (this.renderers.size() > index) { + result = (XYItemRenderer) this.renderers.get(index); + } + return result; + + } + + /** + * Sets the renderer for the primary dataset and sends a + * {@link PlotChangeEvent} to all registered listeners. If the renderer + * is set to null, no data will be displayed. + * + * @param renderer the renderer (null permitted). + * + * @see #getRenderer() + */ + public void setRenderer(XYItemRenderer renderer) { + setRenderer(0, renderer); + } + + /** + * Sets a renderer and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param index the index. + * @param renderer the renderer. + * + * @see #getRenderer(int) + */ + public void setRenderer(int index, XYItemRenderer renderer) { + setRenderer(index, renderer, true); + } + + /** + * Sets a renderer and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param index the index. + * @param renderer the renderer. + * @param notify notify listeners? + * + * @see #getRenderer(int) + */ + public void setRenderer(int index, XYItemRenderer renderer, + boolean notify) { + XYItemRenderer existing = getRenderer(index); + if (existing != null) { + existing.removeChangeListener(this); + } + this.renderers.set(index, renderer); + if (renderer != null) { + renderer.setPlot(this); + renderer.addChangeListener(this); + } + configureDomainAxes(); + configureRangeAxes(); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Sets the renderers for this plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param renderers the renderers (null not permitted). + */ + public void setRenderers(XYItemRenderer[] renderers) { + for (int i = 0; i < renderers.length; i++) { + setRenderer(i, renderers[i], false); + } + fireChangeEvent(); + } + + /** + * Returns the dataset rendering order. + * + * @return The order (never null). + * + * @see #setDatasetRenderingOrder(DatasetRenderingOrder) + */ + public DatasetRenderingOrder getDatasetRenderingOrder() { + return this.datasetRenderingOrder; + } + + /** + * Sets the rendering order and sends a {@link PlotChangeEvent} to all + * registered listeners. By default, the plot renders the primary dataset + * last (so that the primary dataset overlays the secondary datasets). + * You can reverse this if you want to. + * + * @param order the rendering order (null not permitted). + * + * @see #getDatasetRenderingOrder() + */ + public void setDatasetRenderingOrder(DatasetRenderingOrder order) { + ParamChecks.nullNotPermitted(order, "order"); + this.datasetRenderingOrder = order; + fireChangeEvent(); + } + + /** + * Returns the series rendering order. + * + * @return the order (never null). + * + * @see #setSeriesRenderingOrder(SeriesRenderingOrder) + */ + public SeriesRenderingOrder getSeriesRenderingOrder() { + return this.seriesRenderingOrder; + } + + /** + * Sets the series order and sends a {@link PlotChangeEvent} to all + * registered listeners. By default, the plot renders the primary series + * last (so that the primary series appears to be on top). + * You can reverse this if you want to. + * + * @param order the rendering order (null not permitted). + * + * @see #getSeriesRenderingOrder() + */ + public void setSeriesRenderingOrder(SeriesRenderingOrder order) { + ParamChecks.nullNotPermitted(order, "order"); + this.seriesRenderingOrder = order; + fireChangeEvent(); + } + + /** + * Returns the index of the specified renderer, or -1 if the + * renderer is not assigned to this plot. + * + * @param renderer the renderer (null permitted). + * + * @return The renderer index. + */ + public int getIndexOf(XYItemRenderer renderer) { + return this.renderers.indexOf(renderer); + } + + /** + * Returns the renderer for the specified dataset. The code first + * determines the index of the dataset, then checks if there is a + * renderer with the same index (if not, the method returns renderer(0). + * + * @param dataset the dataset (null permitted). + * + * @return The renderer (possibly null). + */ + public XYItemRenderer getRendererForDataset(XYDataset dataset) { + XYItemRenderer result = null; + for (int i = 0; i < this.datasets.size(); i++) { + if (this.datasets.get(i) == dataset) { + result = (XYItemRenderer) this.renderers.get(i); + if (result == null) { + result = getRenderer(); + } + break; + } + } + return result; + } + + /** + * Returns the weight for this plot when it is used as a subplot within a + * combined plot. + * + * @return The weight. + * + * @see #setWeight(int) + */ + public int getWeight() { + return this.weight; + } + + /** + * Sets the weight for the plot and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param weight the weight. + * + * @see #getWeight() + */ + public void setWeight(int weight) { + this.weight = weight; + fireChangeEvent(); + } + + /** + * Returns true if the domain gridlines are visible, and + * false otherwise. + * + * @return true or false. + * + * @see #setDomainGridlinesVisible(boolean) + */ + public boolean isDomainGridlinesVisible() { + return this.domainGridlinesVisible; + } + + /** + * Sets the flag that controls whether or not the domain grid-lines are + * visible. + *

+ * If the flag value is changed, a {@link PlotChangeEvent} is sent to all + * registered listeners. + * + * @param visible the new value of the flag. + * + * @see #isDomainGridlinesVisible() + */ + public void setDomainGridlinesVisible(boolean visible) { + if (this.domainGridlinesVisible != visible) { + this.domainGridlinesVisible = visible; + fireChangeEvent(); + } + } + + /** + * Returns true if the domain minor gridlines are visible, and + * false otherwise. + * + * @return true or false. + * + * @see #setDomainMinorGridlinesVisible(boolean) + * + * @since 1.0.12 + */ + public boolean isDomainMinorGridlinesVisible() { + return this.domainMinorGridlinesVisible; + } + + /** + * Sets the flag that controls whether or not the domain minor grid-lines + * are visible. + *

+ * If the flag value is changed, a {@link PlotChangeEvent} is sent to all + * registered listeners. + * + * @param visible the new value of the flag. + * + * @see #isDomainMinorGridlinesVisible() + * + * @since 1.0.12 + */ + public void setDomainMinorGridlinesVisible(boolean visible) { + if (this.domainMinorGridlinesVisible != visible) { + this.domainMinorGridlinesVisible = visible; + fireChangeEvent(); + } + } + + /** + * Returns the stroke for the grid-lines (if any) plotted against the + * domain axis. + * + * @return The stroke (never null). + * + * @see #setDomainGridlineStroke(Stroke) + */ + public Stroke getDomainGridlineStroke() { + return this.domainGridlineStroke; + } + + /** + * Sets the stroke for the grid lines plotted against the domain axis, and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @throws IllegalArgumentException if stroke is + * null. + * + * @see #getDomainGridlineStroke() + */ + public void setDomainGridlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.domainGridlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the stroke for the minor grid-lines (if any) plotted against the + * domain axis. + * + * @return The stroke (never null). + * + * @see #setDomainMinorGridlineStroke(Stroke) + * + * @since 1.0.12 + */ + + public Stroke getDomainMinorGridlineStroke() { + return this.domainMinorGridlineStroke; + } + + /** + * Sets the stroke for the minor grid lines plotted against the domain + * axis, and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @throws IllegalArgumentException if stroke is + * null. + * + * @see #getDomainMinorGridlineStroke() + * + * @since 1.0.12 + */ + public void setDomainMinorGridlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.domainMinorGridlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint for the grid lines (if any) plotted against the domain + * axis. + * + * @return The paint (never null). + * + * @see #setDomainGridlinePaint(Paint) + */ + public Paint getDomainGridlinePaint() { + return this.domainGridlinePaint; + } + + /** + * Sets the paint for the grid lines plotted against the domain axis, and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @throws IllegalArgumentException if paint is + * null. + * + * @see #getDomainGridlinePaint() + */ + public void setDomainGridlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.domainGridlinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint for the minor grid lines (if any) plotted against the + * domain axis. + * + * @return The paint (never null). + * + * @see #setDomainMinorGridlinePaint(Paint) + * + * @since 1.0.12 + */ + public Paint getDomainMinorGridlinePaint() { + return this.domainMinorGridlinePaint; + } + + /** + * Sets the paint for the minor grid lines plotted against the domain axis, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @throws IllegalArgumentException if paint is + * null. + * + * @see #getDomainMinorGridlinePaint() + * + * @since 1.0.12 + */ + public void setDomainMinorGridlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.domainMinorGridlinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns true if the range axis grid is visible, and + * false otherwise. + * + * @return A boolean. + * + * @see #setRangeGridlinesVisible(boolean) + */ + public boolean isRangeGridlinesVisible() { + return this.rangeGridlinesVisible; + } + + /** + * Sets the flag that controls whether or not the range axis grid lines + * are visible. + *

+ * If the flag value is changed, a {@link PlotChangeEvent} is sent to all + * registered listeners. + * + * @param visible the new value of the flag. + * + * @see #isRangeGridlinesVisible() + */ + public void setRangeGridlinesVisible(boolean visible) { + if (this.rangeGridlinesVisible != visible) { + this.rangeGridlinesVisible = visible; + fireChangeEvent(); + } + } + + /** + * Returns the stroke for the grid lines (if any) plotted against the + * range axis. + * + * @return The stroke (never null). + * + * @see #setRangeGridlineStroke(Stroke) + */ + public Stroke getRangeGridlineStroke() { + return this.rangeGridlineStroke; + } + + /** + * Sets the stroke for the grid lines plotted against the range axis, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getRangeGridlineStroke() + */ + public void setRangeGridlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.rangeGridlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint for the grid lines (if any) plotted against the range + * axis. + * + * @return The paint (never null). + * + * @see #setRangeGridlinePaint(Paint) + */ + public Paint getRangeGridlinePaint() { + return this.rangeGridlinePaint; + } + + /** + * Sets the paint for the grid lines plotted against the range axis and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getRangeGridlinePaint() + */ + public void setRangeGridlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.rangeGridlinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns true if the range axis minor grid is visible, and + * false otherwise. + * + * @return A boolean. + * + * @see #setRangeMinorGridlinesVisible(boolean) + * + * @since 1.0.12 + */ + public boolean isRangeMinorGridlinesVisible() { + return this.rangeMinorGridlinesVisible; + } + + /** + * Sets the flag that controls whether or not the range axis minor grid + * lines are visible. + *

+ * If the flag value is changed, a {@link PlotChangeEvent} is sent to all + * registered listeners. + * + * @param visible the new value of the flag. + * + * @see #isRangeMinorGridlinesVisible() + * + * @since 1.0.12 + */ + public void setRangeMinorGridlinesVisible(boolean visible) { + if (this.rangeMinorGridlinesVisible != visible) { + this.rangeMinorGridlinesVisible = visible; + fireChangeEvent(); + } + } + + /** + * Returns the stroke for the minor grid lines (if any) plotted against the + * range axis. + * + * @return The stroke (never null). + * + * @see #setRangeMinorGridlineStroke(Stroke) + * + * @since 1.0.12 + */ + public Stroke getRangeMinorGridlineStroke() { + return this.rangeMinorGridlineStroke; + } + + /** + * Sets the stroke for the minor grid lines plotted against the range axis, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getRangeMinorGridlineStroke() + * + * @since 1.0.12 + */ + public void setRangeMinorGridlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.rangeMinorGridlineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint for the minor grid lines (if any) plotted against the + * range axis. + * + * @return The paint (never null). + * + * @see #setRangeMinorGridlinePaint(Paint) + * + * @since 1.0.12 + */ + public Paint getRangeMinorGridlinePaint() { + return this.rangeMinorGridlinePaint; + } + + /** + * Sets the paint for the minor grid lines plotted against the range axis + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getRangeMinorGridlinePaint() + * + * @since 1.0.12 + */ + public void setRangeMinorGridlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.rangeMinorGridlinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns a flag that controls whether or not a zero baseline is + * displayed for the domain axis. + * + * @return A boolean. + * + * @since 1.0.5 + * + * @see #setDomainZeroBaselineVisible(boolean) + */ + public boolean isDomainZeroBaselineVisible() { + return this.domainZeroBaselineVisible; + } + + /** + * Sets the flag that controls whether or not the zero baseline is + * displayed for the domain axis, and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param visible the flag. + * + * @since 1.0.5 + * + * @see #isDomainZeroBaselineVisible() + */ + public void setDomainZeroBaselineVisible(boolean visible) { + this.domainZeroBaselineVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the stroke used for the zero baseline against the domain axis. + * + * @return The stroke (never null). + * + * @since 1.0.5 + * + * @see #setDomainZeroBaselineStroke(Stroke) + */ + public Stroke getDomainZeroBaselineStroke() { + return this.domainZeroBaselineStroke; + } + + /** + * Sets the stroke for the zero baseline for the domain axis, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @since 1.0.5 + * + * @see #getRangeZeroBaselineStroke() + */ + public void setDomainZeroBaselineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.domainZeroBaselineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint for the zero baseline (if any) plotted against the + * domain axis. + * + * @since 1.0.5 + * + * @return The paint (never null). + * + * @see #setDomainZeroBaselinePaint(Paint) + */ + public Paint getDomainZeroBaselinePaint() { + return this.domainZeroBaselinePaint; + } + + /** + * Sets the paint for the zero baseline plotted against the domain axis and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @since 1.0.5 + * + * @see #getDomainZeroBaselinePaint() + */ + public void setDomainZeroBaselinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.domainZeroBaselinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns a flag that controls whether or not a zero baseline is + * displayed for the range axis. + * + * @return A boolean. + * + * @see #setRangeZeroBaselineVisible(boolean) + */ + public boolean isRangeZeroBaselineVisible() { + return this.rangeZeroBaselineVisible; + } + + /** + * Sets the flag that controls whether or not the zero baseline is + * displayed for the range axis, and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param visible the flag. + * + * @see #isRangeZeroBaselineVisible() + */ + public void setRangeZeroBaselineVisible(boolean visible) { + this.rangeZeroBaselineVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the stroke used for the zero baseline against the range axis. + * + * @return The stroke (never null). + * + * @see #setRangeZeroBaselineStroke(Stroke) + */ + public Stroke getRangeZeroBaselineStroke() { + return this.rangeZeroBaselineStroke; + } + + /** + * Sets the stroke for the zero baseline for the range axis, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getRangeZeroBaselineStroke() + */ + public void setRangeZeroBaselineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.rangeZeroBaselineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the paint for the zero baseline (if any) plotted against the + * range axis. + * + * @return The paint (never null). + * + * @see #setRangeZeroBaselinePaint(Paint) + */ + public Paint getRangeZeroBaselinePaint() { + return this.rangeZeroBaselinePaint; + } + + /** + * Sets the paint for the zero baseline plotted against the range axis and + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getRangeZeroBaselinePaint() + */ + public void setRangeZeroBaselinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.rangeZeroBaselinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint used for the domain tick bands. If this is + * null, no tick bands will be drawn. + * + * @return The paint (possibly null). + * + * @see #setDomainTickBandPaint(Paint) + */ + public Paint getDomainTickBandPaint() { + return this.domainTickBandPaint; + } + + /** + * Sets the paint for the domain tick bands. + * + * @param paint the paint (null permitted). + * + * @see #getDomainTickBandPaint() + */ + public void setDomainTickBandPaint(Paint paint) { + this.domainTickBandPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint used for the range tick bands. If this is + * null, no tick bands will be drawn. + * + * @return The paint (possibly null). + * + * @see #setRangeTickBandPaint(Paint) + */ + public Paint getRangeTickBandPaint() { + return this.rangeTickBandPaint; + } + + /** + * Sets the paint for the range tick bands. + * + * @param paint the paint (null permitted). + * + * @see #getRangeTickBandPaint() + */ + public void setRangeTickBandPaint(Paint paint) { + this.rangeTickBandPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the origin for the quadrants that can be displayed on the plot. + * This defaults to (0, 0). + * + * @return The origin point (never null). + * + * @see #setQuadrantOrigin(Point2D) + */ + public Point2D getQuadrantOrigin() { + return this.quadrantOrigin; + } + + /** + * Sets the quadrant origin and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param origin the origin (null not permitted). + * + * @see #getQuadrantOrigin() + */ + public void setQuadrantOrigin(Point2D origin) { + ParamChecks.nullNotPermitted(origin, "origin"); + this.quadrantOrigin = origin; + fireChangeEvent(); + } + + /** + * Returns the paint used for the specified quadrant. + * + * @param index the quadrant index (0-3). + * + * @return The paint (possibly null). + * + * @see #setQuadrantPaint(int, Paint) + */ + public Paint getQuadrantPaint(int index) { + if (index < 0 || index > 3) { + throw new IllegalArgumentException("The index value (" + index + + ") should be in the range 0 to 3."); + } + return this.quadrantPaint[index]; + } + + /** + * Sets the paint used for the specified quadrant and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the quadrant index (0-3). + * @param paint the paint (null permitted). + * + * @see #getQuadrantPaint(int) + */ + public void setQuadrantPaint(int index, Paint paint) { + if (index < 0 || index > 3) { + throw new IllegalArgumentException("The index value (" + index + + ") should be in the range 0 to 3."); + } + this.quadrantPaint[index] = paint; + fireChangeEvent(); + } + + /** + * Adds a marker for the domain axis and sends a {@link PlotChangeEvent} + * to all registered listeners. + *

+ * Typically a marker will be drawn by the renderer as a line perpendicular + * to the domain axis, however this is entirely up to the renderer. + * + * @param marker the marker (null not permitted). + * + * @see #addDomainMarker(Marker, Layer) + * @see #clearDomainMarkers() + */ + public void addDomainMarker(Marker marker) { + // defer argument checking... + addDomainMarker(marker, Layer.FOREGROUND); + } + + /** + * Adds a marker for the domain axis in the specified layer and sends a + * {@link PlotChangeEvent} to all registered listeners. + *

+ * Typically a marker will be drawn by the renderer as a line perpendicular + * to the domain axis, however this is entirely up to the renderer. + * + * @param marker the marker (null not permitted). + * @param layer the layer (foreground or background). + * + * @see #addDomainMarker(int, Marker, Layer) + */ + public void addDomainMarker(Marker marker, Layer layer) { + addDomainMarker(0, marker, layer); + } + + /** + * Clears all the (foreground and background) domain markers and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @see #addDomainMarker(int, Marker, Layer) + */ + public void clearDomainMarkers() { + if (this.backgroundDomainMarkers != null) { + Set keys = this.backgroundDomainMarkers.keySet(); + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Integer key = (Integer) iterator.next(); + clearDomainMarkers(key.intValue()); + } + this.backgroundDomainMarkers.clear(); + } + if (this.foregroundDomainMarkers != null) { + Set keys = this.foregroundDomainMarkers.keySet(); + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Integer key = (Integer) iterator.next(); + clearDomainMarkers(key.intValue()); + } + this.foregroundDomainMarkers.clear(); + } + fireChangeEvent(); + } + + /** + * Clears the (foreground and background) domain markers for a particular + * renderer and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param index the renderer index. + * + * @see #clearRangeMarkers(int) + */ + public void clearDomainMarkers(int index) { + Integer key = new Integer(index); + if (this.backgroundDomainMarkers != null) { + Collection markers + = (Collection) this.backgroundDomainMarkers.get(key); + if (markers != null) { + Iterator iterator = markers.iterator(); + while (iterator.hasNext()) { + Marker m = (Marker) iterator.next(); + m.removeChangeListener(this); + } + markers.clear(); + } + } + if (this.foregroundRangeMarkers != null) { + Collection markers + = (Collection) this.foregroundDomainMarkers.get(key); + if (markers != null) { + Iterator iterator = markers.iterator(); + while (iterator.hasNext()) { + Marker m = (Marker) iterator.next(); + m.removeChangeListener(this); + } + markers.clear(); + } + } + fireChangeEvent(); + } + + /** + * Adds a marker for a specific dataset/renderer and sends a + * {@link PlotChangeEvent} to all registered listeners. + *

+ * Typically a marker will be drawn by the renderer as a line perpendicular + * to the domain axis (that the renderer is mapped to), however this is + * entirely up to the renderer. + * + * @param index the dataset/renderer index. + * @param marker the marker. + * @param layer the layer (foreground or background). + * + * @see #clearDomainMarkers(int) + * @see #addRangeMarker(int, Marker, Layer) + */ + public void addDomainMarker(int index, Marker marker, Layer layer) { + addDomainMarker(index, marker, layer, true); + } + + /** + * Adds a marker for a specific dataset/renderer and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + *

+ * Typically a marker will be drawn by the renderer as a line perpendicular + * to the domain axis (that the renderer is mapped to), however this is + * entirely up to the renderer. + * + * @param index the dataset/renderer index. + * @param marker the marker. + * @param layer the layer (foreground or background). + * @param notify notify listeners? + * + * @since 1.0.10 + */ + public void addDomainMarker(int index, Marker marker, Layer layer, + boolean notify) { + ParamChecks.nullNotPermitted(marker, "marker"); + ParamChecks.nullNotPermitted(layer, "layer"); + Collection markers; + if (layer == Layer.FOREGROUND) { + markers = (Collection) this.foregroundDomainMarkers.get( + new Integer(index)); + if (markers == null) { + markers = new java.util.ArrayList(); + this.foregroundDomainMarkers.put(new Integer(index), markers); + } + markers.add(marker); + } + else if (layer == Layer.BACKGROUND) { + markers = (Collection) this.backgroundDomainMarkers.get( + new Integer(index)); + if (markers == null) { + markers = new java.util.ArrayList(); + this.backgroundDomainMarkers.put(new Integer(index), markers); + } + markers.add(marker); + } + marker.addChangeListener(this); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Removes a marker for the domain axis and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param marker the marker. + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.7 + */ + public boolean removeDomainMarker(Marker marker) { + return removeDomainMarker(marker, Layer.FOREGROUND); + } + + /** + * Removes a marker for the domain axis in the specified layer and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param marker the marker (null not permitted). + * @param layer the layer (foreground or background). + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.7 + */ + public boolean removeDomainMarker(Marker marker, Layer layer) { + return removeDomainMarker(0, marker, layer); + } + + /** + * Removes a marker for a specific dataset/renderer and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the dataset/renderer index. + * @param marker the marker. + * @param layer the layer (foreground or background). + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.7 + */ + public boolean removeDomainMarker(int index, Marker marker, Layer layer) { + return removeDomainMarker(index, marker, layer, true); + } + + /** + * Removes a marker for a specific dataset/renderer and, if requested, + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param index the dataset/renderer index. + * @param marker the marker. + * @param layer the layer (foreground or background). + * @param notify notify listeners? + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.10 + */ + public boolean removeDomainMarker(int index, Marker marker, Layer layer, + boolean notify) { + ArrayList markers; + if (layer == Layer.FOREGROUND) { + markers = (ArrayList) this.foregroundDomainMarkers.get( + new Integer(index)); + } + else { + markers = (ArrayList) this.backgroundDomainMarkers.get( + new Integer(index)); + } + if (markers == null) { + return false; + } + boolean removed = markers.remove(marker); + if (removed && notify) { + fireChangeEvent(); + } + return removed; + } + + /** + * Adds a marker for the range axis and sends a {@link PlotChangeEvent} to + * all registered listeners. + *

+ * Typically a marker will be drawn by the renderer as a line perpendicular + * to the range axis, however this is entirely up to the renderer. + * + * @param marker the marker (null not permitted). + * + * @see #addRangeMarker(Marker, Layer) + */ + public void addRangeMarker(Marker marker) { + addRangeMarker(marker, Layer.FOREGROUND); + } + + /** + * Adds a marker for the range axis in the specified layer and sends a + * {@link PlotChangeEvent} to all registered listeners. + *

+ * Typically a marker will be drawn by the renderer as a line perpendicular + * to the range axis, however this is entirely up to the renderer. + * + * @param marker the marker (null not permitted). + * @param layer the layer (foreground or background). + * + * @see #addRangeMarker(int, Marker, Layer) + */ + public void addRangeMarker(Marker marker, Layer layer) { + addRangeMarker(0, marker, layer); + } + + /** + * Clears all the range markers and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @see #clearRangeMarkers() + */ + public void clearRangeMarkers() { + if (this.backgroundRangeMarkers != null) { + Set keys = this.backgroundRangeMarkers.keySet(); + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Integer key = (Integer) iterator.next(); + clearRangeMarkers(key.intValue()); + } + this.backgroundRangeMarkers.clear(); + } + if (this.foregroundRangeMarkers != null) { + Set keys = this.foregroundRangeMarkers.keySet(); + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Integer key = (Integer) iterator.next(); + clearRangeMarkers(key.intValue()); + } + this.foregroundRangeMarkers.clear(); + } + fireChangeEvent(); + } + + /** + * Adds a marker for a specific dataset/renderer and sends a + * {@link PlotChangeEvent} to all registered listeners. + *

+ * Typically a marker will be drawn by the renderer as a line perpendicular + * to the range axis, however this is entirely up to the renderer. + * + * @param index the dataset/renderer index. + * @param marker the marker. + * @param layer the layer (foreground or background). + * + * @see #clearRangeMarkers(int) + * @see #addDomainMarker(int, Marker, Layer) + */ + public void addRangeMarker(int index, Marker marker, Layer layer) { + addRangeMarker(index, marker, layer, true); + } + + /** + * Adds a marker for a specific dataset/renderer and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + *

+ * Typically a marker will be drawn by the renderer as a line perpendicular + * to the range axis, however this is entirely up to the renderer. + * + * @param index the dataset/renderer index. + * @param marker the marker. + * @param layer the layer (foreground or background). + * @param notify notify listeners? + * + * @since 1.0.10 + */ + public void addRangeMarker(int index, Marker marker, Layer layer, + boolean notify) { + Collection markers; + if (layer == Layer.FOREGROUND) { + markers = (Collection) this.foregroundRangeMarkers.get( + new Integer(index)); + if (markers == null) { + markers = new java.util.ArrayList(); + this.foregroundRangeMarkers.put(new Integer(index), markers); + } + markers.add(marker); + } + else if (layer == Layer.BACKGROUND) { + markers = (Collection) this.backgroundRangeMarkers.get( + new Integer(index)); + if (markers == null) { + markers = new java.util.ArrayList(); + this.backgroundRangeMarkers.put(new Integer(index), markers); + } + markers.add(marker); + } + marker.addChangeListener(this); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Clears the (foreground and background) range markers for a particular + * renderer. + * + * @param index the renderer index. + */ + public void clearRangeMarkers(int index) { + Integer key = new Integer(index); + if (this.backgroundRangeMarkers != null) { + Collection markers + = (Collection) this.backgroundRangeMarkers.get(key); + if (markers != null) { + Iterator iterator = markers.iterator(); + while (iterator.hasNext()) { + Marker m = (Marker) iterator.next(); + m.removeChangeListener(this); + } + markers.clear(); + } + } + if (this.foregroundRangeMarkers != null) { + Collection markers + = (Collection) this.foregroundRangeMarkers.get(key); + if (markers != null) { + Iterator iterator = markers.iterator(); + while (iterator.hasNext()) { + Marker m = (Marker) iterator.next(); + m.removeChangeListener(this); + } + markers.clear(); + } + } + fireChangeEvent(); + } + + /** + * Removes a marker for the range axis and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param marker the marker. + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.7 + */ + public boolean removeRangeMarker(Marker marker) { + return removeRangeMarker(marker, Layer.FOREGROUND); + } + + /** + * Removes a marker for the range axis in the specified layer and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param marker the marker (null not permitted). + * @param layer the layer (foreground or background). + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.7 + */ + public boolean removeRangeMarker(Marker marker, Layer layer) { + return removeRangeMarker(0, marker, layer); + } + + /** + * Removes a marker for a specific dataset/renderer and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the dataset/renderer index. + * @param marker the marker (null not permitted). + * @param layer the layer (foreground or background). + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.7 + */ + public boolean removeRangeMarker(int index, Marker marker, Layer layer) { + return removeRangeMarker(index, marker, layer, true); + } + + /** + * Removes a marker for a specific dataset/renderer and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the dataset/renderer index. + * @param marker the marker (null not permitted). + * @param layer the layer (foreground or background) (null not permitted). + * @param notify notify listeners? + * + * @return A boolean indicating whether or not the marker was actually + * removed. + * + * @since 1.0.10 + */ + public boolean removeRangeMarker(int index, Marker marker, Layer layer, + boolean notify) { + ParamChecks.nullNotPermitted(marker, "marker"); + ParamChecks.nullNotPermitted(layer, "layer"); + List markers; + if (layer == Layer.FOREGROUND) { + markers = (List) this.foregroundRangeMarkers.get( + new Integer(index)); + } + else { + markers = (List) this.backgroundRangeMarkers.get( + new Integer(index)); + } + if (markers == null) { + return false; + } + boolean removed = markers.remove(marker); + if (removed && notify) { + fireChangeEvent(); + } + return removed; + } + + /** + * Adds an annotation to the plot and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param annotation the annotation (null not permitted). + * + * @see #getAnnotations() + * @see #removeAnnotation(XYAnnotation) + */ + public void addAnnotation(XYAnnotation annotation) { + addAnnotation(annotation, true); + } + + /** + * Adds an annotation to the plot and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param annotation the annotation (null not permitted). + * @param notify notify listeners? + * + * @since 1.0.10 + */ + public void addAnnotation(XYAnnotation annotation, boolean notify) { + ParamChecks.nullNotPermitted(annotation, "annotation"); + this.annotations.add(annotation); + annotation.addChangeListener(this); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Removes an annotation from the plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param annotation the annotation (null not permitted). + * + * @return A boolean (indicates whether or not the annotation was removed). + * + * @see #addAnnotation(XYAnnotation) + * @see #getAnnotations() + */ + public boolean removeAnnotation(XYAnnotation annotation) { + return removeAnnotation(annotation, true); + } + + /** + * Removes an annotation from the plot and sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param annotation the annotation (null not permitted). + * @param notify notify listeners? + * + * @return A boolean (indicates whether or not the annotation was removed). + * + * @since 1.0.10 + */ + public boolean removeAnnotation(XYAnnotation annotation, boolean notify) { + ParamChecks.nullNotPermitted(annotation, "annotation"); + boolean removed = this.annotations.remove(annotation); + annotation.removeChangeListener(this); + if (removed && notify) { + fireChangeEvent(); + } + return removed; + } + + /** + * Returns the list of annotations. + * + * @return The list of annotations. + * + * @since 1.0.1 + * + * @see #addAnnotation(XYAnnotation) + */ + public List getAnnotations() { + return new ArrayList(this.annotations); + } + + /** + * Clears all the annotations and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @see #addAnnotation(XYAnnotation) + */ + public void clearAnnotations() { + for(int i = 0; i < this.annotations.size(); i++){ + XYAnnotation annotation = (XYAnnotation) this.annotations.get(i); + annotation.removeChangeListener(this); + } + this.annotations.clear(); + fireChangeEvent(); + } + + /** + * Returns the shadow generator for the plot, if any. + * + * @return The shadow generator (possibly null). + * + * @since 1.0.14 + */ + public ShadowGenerator getShadowGenerator() { + return this.shadowGenerator; + } + + /** + * Sets the shadow generator for the plot and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @since 1.0.14 + */ + public void setShadowGenerator(ShadowGenerator generator) { + this.shadowGenerator = generator; + fireChangeEvent(); + } + + /** + * Calculates the space required for all the axes in the plot. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * + * @return The required space. + */ + protected AxisSpace calculateAxisSpace(Graphics2D g2, + Rectangle2D plotArea) { + AxisSpace space = new AxisSpace(); + space = calculateRangeAxisSpace(g2, plotArea, space); + Rectangle2D revPlotArea = space.shrink(plotArea, null); + space = calculateDomainAxisSpace(g2, revPlotArea, space); + return space; + } + + /** + * Calculates the space required for the domain axis/axes. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param space a carrier for the result (null permitted). + * + * @return The required space. + */ + protected AxisSpace calculateDomainAxisSpace(Graphics2D g2, + Rectangle2D plotArea, AxisSpace space) { + + if (space == null) { + space = new AxisSpace(); + } + + // reserve some space for the domain axis... + if (this.fixedDomainAxisSpace != null) { + if (this.orientation == PlotOrientation.HORIZONTAL) { + space.ensureAtLeast(this.fixedDomainAxisSpace.getLeft(), + RectangleEdge.LEFT); + space.ensureAtLeast(this.fixedDomainAxisSpace.getRight(), + RectangleEdge.RIGHT); + } + else if (this.orientation == PlotOrientation.VERTICAL) { + space.ensureAtLeast(this.fixedDomainAxisSpace.getTop(), + RectangleEdge.TOP); + space.ensureAtLeast(this.fixedDomainAxisSpace.getBottom(), + RectangleEdge.BOTTOM); + } + } + else { + // reserve space for the domain axes... + for (int i = 0; i < this.domainAxes.size(); i++) { + Axis axis = (Axis) this.domainAxes.get(i); + if (axis != null) { + RectangleEdge edge = getDomainAxisEdge(i); + space = axis.reserveSpace(g2, this, plotArea, edge, space); + } + } + } + + return space; + + } + + /** + * Calculates the space required for the range axis/axes. + * + * @param g2 the graphics device. + * @param plotArea the plot area. + * @param space a carrier for the result (null permitted). + * + * @return The required space. + */ + protected AxisSpace calculateRangeAxisSpace(Graphics2D g2, + Rectangle2D plotArea, AxisSpace space) { + + if (space == null) { + space = new AxisSpace(); + } + + // reserve some space for the range axis... + if (this.fixedRangeAxisSpace != null) { + if (this.orientation == PlotOrientation.HORIZONTAL) { + space.ensureAtLeast(this.fixedRangeAxisSpace.getTop(), + RectangleEdge.TOP); + space.ensureAtLeast(this.fixedRangeAxisSpace.getBottom(), + RectangleEdge.BOTTOM); + } + else if (this.orientation == PlotOrientation.VERTICAL) { + space.ensureAtLeast(this.fixedRangeAxisSpace.getLeft(), + RectangleEdge.LEFT); + space.ensureAtLeast(this.fixedRangeAxisSpace.getRight(), + RectangleEdge.RIGHT); + } + } + else { + // reserve space for the range axes... + for (int i = 0; i < this.rangeAxes.size(); i++) { + Axis axis = (Axis) this.rangeAxes.get(i); + if (axis != null) { + RectangleEdge edge = getRangeAxisEdge(i); + space = axis.reserveSpace(g2, this, plotArea, edge, space); + } + } + } + return space; + + } + + /** + * Trims a rectangle to integer coordinates. + * + * @param rect the incoming rectangle. + * + * @return A rectangle with integer coordinates. + */ + private Rectangle integerise(Rectangle2D rect) { + int x0 = (int) Math.ceil(rect.getMinX()); + int y0 = (int) Math.ceil(rect.getMinY()); + int x1 = (int) Math.floor(rect.getMaxX()); + int y1 = (int) Math.floor(rect.getMaxY()); + return new Rectangle(x0, y0, (x1 - x0), (y1 - y0)); + } + + /** + * Draws the plot within the specified area on a graphics device. + * + * @param g2 the graphics device. + * @param area the plot area (in Java2D space). + * @param anchor an anchor point in Java2D space (null + * permitted). + * @param parentState the state from the parent plot, if there is one + * (null permitted). + * @param info collects chart drawing information (null + * permitted). + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, PlotRenderingInfo info) { + + // if the plot area is too small, just return... + boolean b1 = (area.getWidth() <= MINIMUM_WIDTH_TO_DRAW); + boolean b2 = (area.getHeight() <= MINIMUM_HEIGHT_TO_DRAW); + if (b1 || b2) { + return; + } + + // record the plot area... + if (info != null) { + info.setPlotArea(area); + } + + // adjust the drawing area for the plot insets (if any)... + RectangleInsets insets = getInsets(); + insets.trim(area); + + AxisSpace space = calculateAxisSpace(g2, area); + Rectangle2D dataArea = space.shrink(area, null); + this.axisOffset.trim(dataArea); + + dataArea = integerise(dataArea); + if (dataArea.isEmpty()) { + return; + } + createAndAddEntity((Rectangle2D) dataArea.clone(), info, null, null); + if (info != null) { + info.setDataArea(dataArea); + } + + // draw the plot background and axes... + drawBackground(g2, dataArea); + Map axisStateMap = drawAxes(g2, area, dataArea, info); + + PlotOrientation orient = getOrientation(); + + // the anchor point is typically the point where the mouse last + // clicked - the crosshairs will be driven off this point... + if (anchor != null && !dataArea.contains(anchor)) { + anchor = null; + } + CrosshairState crosshairState = new CrosshairState(); + crosshairState.setCrosshairDistance(Double.POSITIVE_INFINITY); + crosshairState.setAnchor(anchor); + + crosshairState.setAnchorX(Double.NaN); + crosshairState.setAnchorY(Double.NaN); + if (anchor != null) { + ValueAxis domainAxis = getDomainAxis(); + if (domainAxis != null) { + double x; + if (orient == PlotOrientation.VERTICAL) { + x = domainAxis.java2DToValue(anchor.getX(), dataArea, + getDomainAxisEdge()); + } + else { + x = domainAxis.java2DToValue(anchor.getY(), dataArea, + getDomainAxisEdge()); + } + crosshairState.setAnchorX(x); + } + ValueAxis rangeAxis = getRangeAxis(); + if (rangeAxis != null) { + double y; + if (orient == PlotOrientation.VERTICAL) { + y = rangeAxis.java2DToValue(anchor.getY(), dataArea, + getRangeAxisEdge()); + } + else { + y = rangeAxis.java2DToValue(anchor.getX(), dataArea, + getRangeAxisEdge()); + } + crosshairState.setAnchorY(y); + } + } + crosshairState.setCrosshairX(getDomainCrosshairValue()); + crosshairState.setCrosshairY(getRangeCrosshairValue()); + Shape originalClip = g2.getClip(); + Composite originalComposite = g2.getComposite(); + + g2.clip(dataArea); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + getForegroundAlpha())); + + AxisState domainAxisState = (AxisState) axisStateMap.get( + getDomainAxis()); + if (domainAxisState == null) { + if (parentState != null) { + domainAxisState = (AxisState) parentState.getSharedAxisStates() + .get(getDomainAxis()); + } + } + + AxisState rangeAxisState = (AxisState) axisStateMap.get(getRangeAxis()); + if (rangeAxisState == null) { + if (parentState != null) { + rangeAxisState = (AxisState) parentState.getSharedAxisStates() + .get(getRangeAxis()); + } + } + if (domainAxisState != null) { + drawDomainTickBands(g2, dataArea, domainAxisState.getTicks()); + } + if (rangeAxisState != null) { + drawRangeTickBands(g2, dataArea, rangeAxisState.getTicks()); + } + if (domainAxisState != null) { + drawDomainGridlines(g2, dataArea, domainAxisState.getTicks()); + drawZeroDomainBaseline(g2, dataArea); + } + if (rangeAxisState != null) { + drawRangeGridlines(g2, dataArea, rangeAxisState.getTicks()); + drawZeroRangeBaseline(g2, dataArea); + } + + Graphics2D savedG2 = g2; + BufferedImage dataImage = null; + boolean suppressShadow = Boolean.TRUE.equals(g2.getRenderingHint( + JFreeChart.KEY_SUPPRESS_SHADOW_GENERATION)); + if (this.shadowGenerator != null && !suppressShadow) { + dataImage = new BufferedImage((int) dataArea.getWidth(), + (int)dataArea.getHeight(), BufferedImage.TYPE_INT_ARGB); + g2 = dataImage.createGraphics(); + g2.translate(-dataArea.getX(), -dataArea.getY()); + g2.setRenderingHints(savedG2.getRenderingHints()); + } + + // draw the markers that are associated with a specific renderer... + for (int i = 0; i < this.renderers.size(); i++) { + drawDomainMarkers(g2, dataArea, i, Layer.BACKGROUND); + } + for (int i = 0; i < this.renderers.size(); i++) { + drawRangeMarkers(g2, dataArea, i, Layer.BACKGROUND); + } + + // now draw annotations and render data items... + boolean foundData = false; + DatasetRenderingOrder order = getDatasetRenderingOrder(); + if (order == DatasetRenderingOrder.FORWARD) { + + // draw background annotations + int rendererCount = this.renderers.size(); + for (int i = 0; i < rendererCount; i++) { + XYItemRenderer r = getRenderer(i); + if (r != null) { + ValueAxis domainAxis = getDomainAxisForDataset(i); + ValueAxis rangeAxis = getRangeAxisForDataset(i); + r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, + Layer.BACKGROUND, info); + } + } + + // render data items... + for (int i = 0; i < getDatasetCount(); i++) { + foundData = render(g2, dataArea, i, info, crosshairState) + || foundData; + } + + // draw foreground annotations + for (int i = 0; i < rendererCount; i++) { + XYItemRenderer r = getRenderer(i); + if (r != null) { + ValueAxis domainAxis = getDomainAxisForDataset(i); + ValueAxis rangeAxis = getRangeAxisForDataset(i); + r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, + Layer.FOREGROUND, info); + } + } + + } + else if (order == DatasetRenderingOrder.REVERSE) { + + // draw background annotations + int rendererCount = this.renderers.size(); + for (int i = rendererCount - 1; i >= 0; i--) { + XYItemRenderer r = getRenderer(i); + if (i >= getDatasetCount()) { // we need the dataset to make + continue; // a link to the axes + } + if (r != null) { + ValueAxis domainAxis = getDomainAxisForDataset(i); + ValueAxis rangeAxis = getRangeAxisForDataset(i); + r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, + Layer.BACKGROUND, info); + } + } + + for (int i = getDatasetCount() - 1; i >= 0; i--) { + foundData = render(g2, dataArea, i, info, crosshairState) + || foundData; + } + + // draw foreground annotations + for (int i = rendererCount - 1; i >= 0; i--) { + XYItemRenderer r = getRenderer(i); + if (i >= getDatasetCount()) { // we need the dataset to make + continue; // a link to the axes + } + if (r != null) { + ValueAxis domainAxis = getDomainAxisForDataset(i); + ValueAxis rangeAxis = getRangeAxisForDataset(i); + r.drawAnnotations(g2, dataArea, domainAxis, rangeAxis, + Layer.FOREGROUND, info); + } + } + + } + + // draw domain crosshair if required... + int xAxisIndex = crosshairState.getDomainAxisIndex(); + ValueAxis xAxis = getDomainAxis(xAxisIndex); + RectangleEdge xAxisEdge = getDomainAxisEdge(xAxisIndex); + if (!this.domainCrosshairLockedOnData && anchor != null) { + double xx; + if (orient == PlotOrientation.VERTICAL) { + xx = xAxis.java2DToValue(anchor.getX(), dataArea, xAxisEdge); + } + else { + xx = xAxis.java2DToValue(anchor.getY(), dataArea, xAxisEdge); + } + crosshairState.setCrosshairX(xx); + } + setDomainCrosshairValue(crosshairState.getCrosshairX(), false); + if (isDomainCrosshairVisible()) { + double x = getDomainCrosshairValue(); + Paint paint = getDomainCrosshairPaint(); + Stroke stroke = getDomainCrosshairStroke(); + drawDomainCrosshair(g2, dataArea, orient, x, xAxis, stroke, paint); + } + + // draw range crosshair if required... + int yAxisIndex = crosshairState.getRangeAxisIndex(); + ValueAxis yAxis = getRangeAxis(yAxisIndex); + RectangleEdge yAxisEdge = getRangeAxisEdge(yAxisIndex); + if (!this.rangeCrosshairLockedOnData && anchor != null) { + double yy; + if (orient == PlotOrientation.VERTICAL) { + yy = yAxis.java2DToValue(anchor.getY(), dataArea, yAxisEdge); + } else { + yy = yAxis.java2DToValue(anchor.getX(), dataArea, yAxisEdge); + } + crosshairState.setCrosshairY(yy); + } + setRangeCrosshairValue(crosshairState.getCrosshairY(), false); + if (isRangeCrosshairVisible()) { + double y = getRangeCrosshairValue(); + Paint paint = getRangeCrosshairPaint(); + Stroke stroke = getRangeCrosshairStroke(); + drawRangeCrosshair(g2, dataArea, orient, y, yAxis, stroke, paint); + } + + if (!foundData) { + drawNoDataMessage(g2, dataArea); + } + + for (int i = 0; i < this.renderers.size(); i++) { + drawDomainMarkers(g2, dataArea, i, Layer.FOREGROUND); + } + for (int i = 0; i < this.renderers.size(); i++) { + drawRangeMarkers(g2, dataArea, i, Layer.FOREGROUND); + } + + drawAnnotations(g2, dataArea, info); + if (this.shadowGenerator != null && !suppressShadow) { + BufferedImage shadowImage + = this.shadowGenerator.createDropShadow(dataImage); + g2 = savedG2; + g2.drawImage(shadowImage, (int) dataArea.getX() + + this.shadowGenerator.calculateOffsetX(), + (int) dataArea.getY() + + this.shadowGenerator.calculateOffsetY(), null); + g2.drawImage(dataImage, (int) dataArea.getX(), + (int) dataArea.getY(), null); + } + g2.setClip(originalClip); + g2.setComposite(originalComposite); + + drawOutline(g2, dataArea); + + } + + /** + * Draws the background for the plot. + * + * @param g2 the graphics device. + * @param area the area. + */ + @Override + public void drawBackground(Graphics2D g2, Rectangle2D area) { + fillBackground(g2, area, this.orientation); + drawQuadrants(g2, area); + drawBackgroundImage(g2, area); + } + + /** + * Draws the quadrants. + * + * @param g2 the graphics device. + * @param area the area. + * + * @see #setQuadrantOrigin(Point2D) + * @see #setQuadrantPaint(int, Paint) + */ + protected void drawQuadrants(Graphics2D g2, Rectangle2D area) { + // 0 | 1 + // --+-- + // 2 | 3 + boolean somethingToDraw = false; + + ValueAxis xAxis = getDomainAxis(); + if (xAxis == null) { // we can't draw quadrants without a valid x-axis + return; + } + double x = xAxis.getRange().constrain(this.quadrantOrigin.getX()); + double xx = xAxis.valueToJava2D(x, area, getDomainAxisEdge()); + + ValueAxis yAxis = getRangeAxis(); + if (yAxis == null) { // we can't draw quadrants without a valid y-axis + return; + } + double y = yAxis.getRange().constrain(this.quadrantOrigin.getY()); + double yy = yAxis.valueToJava2D(y, area, getRangeAxisEdge()); + + double xmin = xAxis.getLowerBound(); + double xxmin = xAxis.valueToJava2D(xmin, area, getDomainAxisEdge()); + + double xmax = xAxis.getUpperBound(); + double xxmax = xAxis.valueToJava2D(xmax, area, getDomainAxisEdge()); + + double ymin = yAxis.getLowerBound(); + double yymin = yAxis.valueToJava2D(ymin, area, getRangeAxisEdge()); + + double ymax = yAxis.getUpperBound(); + double yymax = yAxis.valueToJava2D(ymax, area, getRangeAxisEdge()); + + Rectangle2D[] r = new Rectangle2D[] {null, null, null, null}; + if (this.quadrantPaint[0] != null) { + if (x > xmin && y < ymax) { + if (this.orientation == PlotOrientation.HORIZONTAL) { + r[0] = new Rectangle2D.Double(Math.min(yymax, yy), + Math.min(xxmin, xx), Math.abs(yy - yymax), + Math.abs(xx - xxmin)); + } + else { // PlotOrientation.VERTICAL + r[0] = new Rectangle2D.Double(Math.min(xxmin, xx), + Math.min(yymax, yy), Math.abs(xx - xxmin), + Math.abs(yy - yymax)); + } + somethingToDraw = true; + } + } + if (this.quadrantPaint[1] != null) { + if (x < xmax && y < ymax) { + if (this.orientation == PlotOrientation.HORIZONTAL) { + r[1] = new Rectangle2D.Double(Math.min(yymax, yy), + Math.min(xxmax, xx), Math.abs(yy - yymax), + Math.abs(xx - xxmax)); + } + else { // PlotOrientation.VERTICAL + r[1] = new Rectangle2D.Double(Math.min(xx, xxmax), + Math.min(yymax, yy), Math.abs(xx - xxmax), + Math.abs(yy - yymax)); + } + somethingToDraw = true; + } + } + if (this.quadrantPaint[2] != null) { + if (x > xmin && y > ymin) { + if (this.orientation == PlotOrientation.HORIZONTAL) { + r[2] = new Rectangle2D.Double(Math.min(yymin, yy), + Math.min(xxmin, xx), Math.abs(yy - yymin), + Math.abs(xx - xxmin)); + } + else { // PlotOrientation.VERTICAL + r[2] = new Rectangle2D.Double(Math.min(xxmin, xx), + Math.min(yymin, yy), Math.abs(xx - xxmin), + Math.abs(yy - yymin)); + } + somethingToDraw = true; + } + } + if (this.quadrantPaint[3] != null) { + if (x < xmax && y > ymin) { + if (this.orientation == PlotOrientation.HORIZONTAL) { + r[3] = new Rectangle2D.Double(Math.min(yymin, yy), + Math.min(xxmax, xx), Math.abs(yy - yymin), + Math.abs(xx - xxmax)); + } + else { // PlotOrientation.VERTICAL + r[3] = new Rectangle2D.Double(Math.min(xx, xxmax), + Math.min(yymin, yy), Math.abs(xx - xxmax), + Math.abs(yy - yymin)); + } + somethingToDraw = true; + } + } + if (somethingToDraw) { + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + getBackgroundAlpha())); + for (int i = 0; i < 4; i++) { + if (this.quadrantPaint[i] != null && r[i] != null) { + g2.setPaint(this.quadrantPaint[i]); + g2.fill(r[i]); + } + } + g2.setComposite(originalComposite); + } + } + + /** + * Draws the domain tick bands, if any. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param ticks the ticks. + * + * @see #setDomainTickBandPaint(Paint) + */ + public void drawDomainTickBands(Graphics2D g2, Rectangle2D dataArea, + List ticks) { + Paint bandPaint = getDomainTickBandPaint(); + if (bandPaint != null) { + boolean fillBand = false; + ValueAxis xAxis = getDomainAxis(); + double previous = xAxis.getLowerBound(); + Iterator iterator = ticks.iterator(); + while (iterator.hasNext()) { + ValueTick tick = (ValueTick) iterator.next(); + double current = tick.getValue(); + if (fillBand) { + getRenderer().fillDomainGridBand(g2, this, xAxis, dataArea, + previous, current); + } + previous = current; + fillBand = !fillBand; + } + double end = xAxis.getUpperBound(); + if (fillBand) { + getRenderer().fillDomainGridBand(g2, this, xAxis, dataArea, + previous, end); + } + } + } + + /** + * Draws the range tick bands, if any. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param ticks the ticks. + * + * @see #setRangeTickBandPaint(Paint) + */ + public void drawRangeTickBands(Graphics2D g2, Rectangle2D dataArea, + List ticks) { + Paint bandPaint = getRangeTickBandPaint(); + if (bandPaint != null) { + boolean fillBand = false; + ValueAxis axis = getRangeAxis(); + double previous = axis.getLowerBound(); + Iterator iterator = ticks.iterator(); + while (iterator.hasNext()) { + ValueTick tick = (ValueTick) iterator.next(); + double current = tick.getValue(); + if (fillBand) { + getRenderer().fillRangeGridBand(g2, this, axis, dataArea, + previous, current); + } + previous = current; + fillBand = !fillBand; + } + double end = axis.getUpperBound(); + if (fillBand) { + getRenderer().fillRangeGridBand(g2, this, axis, dataArea, + previous, end); + } + } + } + + /** + * A utility method for drawing the axes. + * + * @param g2 the graphics device (null not permitted). + * @param plotArea the plot area (null not permitted). + * @param dataArea the data area (null not permitted). + * @param plotState collects information about the plot (null + * permitted). + * + * @return A map containing the state for each axis drawn. + */ + protected Map drawAxes(Graphics2D g2, + Rectangle2D plotArea, + Rectangle2D dataArea, + PlotRenderingInfo plotState) { + + AxisCollection axisCollection = new AxisCollection(); + + // add domain axes to lists... + for (int index = 0; index < this.domainAxes.size(); index++) { + ValueAxis axis = (ValueAxis) this.domainAxes.get(index); + if (axis != null) { + axisCollection.add(axis, getDomainAxisEdge(index)); + } + } + + // add range axes to lists... + for (int index = 0; index < this.rangeAxes.size(); index++) { + ValueAxis yAxis = (ValueAxis) this.rangeAxes.get(index); + if (yAxis != null) { + axisCollection.add(yAxis, getRangeAxisEdge(index)); + } + } + + Map axisStateMap = new HashMap(); + + // draw the top axes + double cursor = dataArea.getMinY() - this.axisOffset.calculateTopOutset( + dataArea.getHeight()); + Iterator iterator = axisCollection.getAxesAtTop().iterator(); + while (iterator.hasNext()) { + ValueAxis axis = (ValueAxis) iterator.next(); + AxisState info = axis.draw(g2, cursor, plotArea, dataArea, + RectangleEdge.TOP, plotState); + cursor = info.getCursor(); + axisStateMap.put(axis, info); + } + + // draw the bottom axes + cursor = dataArea.getMaxY() + + this.axisOffset.calculateBottomOutset(dataArea.getHeight()); + iterator = axisCollection.getAxesAtBottom().iterator(); + while (iterator.hasNext()) { + ValueAxis axis = (ValueAxis) iterator.next(); + AxisState info = axis.draw(g2, cursor, plotArea, dataArea, + RectangleEdge.BOTTOM, plotState); + cursor = info.getCursor(); + axisStateMap.put(axis, info); + } + + // draw the left axes + cursor = dataArea.getMinX() + - this.axisOffset.calculateLeftOutset(dataArea.getWidth()); + iterator = axisCollection.getAxesAtLeft().iterator(); + while (iterator.hasNext()) { + ValueAxis axis = (ValueAxis) iterator.next(); + AxisState info = axis.draw(g2, cursor, plotArea, dataArea, + RectangleEdge.LEFT, plotState); + cursor = info.getCursor(); + axisStateMap.put(axis, info); + } + + // draw the right axes + cursor = dataArea.getMaxX() + + this.axisOffset.calculateRightOutset(dataArea.getWidth()); + iterator = axisCollection.getAxesAtRight().iterator(); + while (iterator.hasNext()) { + ValueAxis axis = (ValueAxis) iterator.next(); + AxisState info = axis.draw(g2, cursor, plotArea, dataArea, + RectangleEdge.RIGHT, plotState); + cursor = info.getCursor(); + axisStateMap.put(axis, info); + } + + return axisStateMap; + } + + /** + * Draws a representation of the data within the dataArea region, using the + * current renderer. + *

+ * The info and crosshairState arguments may be + * null. + * + * @param g2 the graphics device. + * @param dataArea the region in which the data is to be drawn. + * @param index the dataset index. + * @param info an optional object for collection dimension information. + * @param crosshairState collects crosshair information + * (null permitted). + * + * @return A flag that indicates whether any data was actually rendered. + */ + public boolean render(Graphics2D g2, Rectangle2D dataArea, int index, + PlotRenderingInfo info, CrosshairState crosshairState) { + + boolean foundData = false; + XYDataset dataset = getDataset(index); + if (!DatasetUtilities.isEmptyOrNull(dataset)) { + foundData = true; + ValueAxis xAxis = getDomainAxisForDataset(index); + ValueAxis yAxis = getRangeAxisForDataset(index); + if (xAxis == null || yAxis == null) { + return foundData; // can't render anything without axes + } + XYItemRenderer renderer = getRenderer(index); + if (renderer == null) { + renderer = getRenderer(); + if (renderer == null) { // no default renderer available + return foundData; + } + } + + XYItemRendererState state = renderer.initialise(g2, dataArea, this, + dataset, info); + int passCount = renderer.getPassCount(); + + SeriesRenderingOrder seriesOrder = getSeriesRenderingOrder(); + if (seriesOrder == SeriesRenderingOrder.REVERSE) { + //render series in reverse order + for (int pass = 0; pass < passCount; pass++) { + int seriesCount = dataset.getSeriesCount(); + for (int series = seriesCount - 1; series >= 0; series--) { + int firstItem = 0; + int lastItem = dataset.getItemCount(series) - 1; + if (lastItem == -1) { + continue; + } + if (state.getProcessVisibleItemsOnly()) { + int[] itemBounds = RendererUtilities.findLiveItems( + dataset, series, xAxis.getLowerBound(), + xAxis.getUpperBound()); + firstItem = Math.max(itemBounds[0] - 1, 0); + lastItem = Math.min(itemBounds[1] + 1, lastItem); + } + state.startSeriesPass(dataset, series, firstItem, + lastItem, pass, passCount); + for (int item = firstItem; item <= lastItem; item++) { + renderer.drawItem(g2, state, dataArea, info, + this, xAxis, yAxis, dataset, series, item, + crosshairState, pass); + } + state.endSeriesPass(dataset, series, firstItem, + lastItem, pass, passCount); + } + } + } + else { + //render series in forward order + for (int pass = 0; pass < passCount; pass++) { + int seriesCount = dataset.getSeriesCount(); + for (int series = 0; series < seriesCount; series++) { + int firstItem = 0; + int lastItem = dataset.getItemCount(series) - 1; + if (state.getProcessVisibleItemsOnly()) { + int[] itemBounds = RendererUtilities.findLiveItems( + dataset, series, xAxis.getLowerBound(), + xAxis.getUpperBound()); + firstItem = Math.max(itemBounds[0] - 1, 0); + lastItem = Math.min(itemBounds[1] + 1, lastItem); + } + state.startSeriesPass(dataset, series, firstItem, + lastItem, pass, passCount); + for (int item = firstItem; item <= lastItem; item++) { + renderer.drawItem(g2, state, dataArea, info, + this, xAxis, yAxis, dataset, series, item, + crosshairState, pass); + } + state.endSeriesPass(dataset, series, firstItem, + lastItem, pass, passCount); + } + } + } + } + return foundData; + } + + /** + * Returns the domain axis for a dataset. + * + * @param index the dataset index. + * + * @return The axis. + */ + public ValueAxis getDomainAxisForDataset(int index) { + int upper = Math.max(getDatasetCount(), getRendererCount()); + if (index < 0 || index >= upper) { + throw new IllegalArgumentException("Index " + index + + " out of bounds."); + } + ValueAxis valueAxis; + List axisIndices = (List) this.datasetToDomainAxesMap.get( + new Integer(index)); + if (axisIndices != null) { + // the first axis in the list is used for data <--> Java2D + Integer axisIndex = (Integer) axisIndices.get(0); + valueAxis = getDomainAxis(axisIndex.intValue()); + } + else { + valueAxis = getDomainAxis(0); + } + return valueAxis; + } + + /** + * Returns the range axis for a dataset. + * + * @param index the dataset index. + * + * @return The axis. + */ + public ValueAxis getRangeAxisForDataset(int index) { + int upper = Math.max(getDatasetCount(), getRendererCount()); + if (index < 0 || index >= upper) { + throw new IllegalArgumentException("Index " + index + + " out of bounds."); + } + ValueAxis valueAxis; + List axisIndices = (List) this.datasetToRangeAxesMap.get( + new Integer(index)); + if (axisIndices != null) { + // the first axis in the list is used for data <--> Java2D + Integer axisIndex = (Integer) axisIndices.get(0); + valueAxis = getRangeAxis(axisIndex.intValue()); + } + else { + valueAxis = getRangeAxis(0); + } + return valueAxis; + } + + /** + * Draws the gridlines for the plot, if they are visible. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param ticks the ticks. + * + * @see #drawRangeGridlines(Graphics2D, Rectangle2D, List) + */ + protected void drawDomainGridlines(Graphics2D g2, Rectangle2D dataArea, + List ticks) { + + // no renderer, no gridlines... + if (getRenderer() == null) { + return; + } + + // draw the domain grid lines, if any... + if (isDomainGridlinesVisible() || isDomainMinorGridlinesVisible()) { + Stroke gridStroke = null; + Paint gridPaint = null; + Iterator iterator = ticks.iterator(); + boolean paintLine; + while (iterator.hasNext()) { + paintLine = false; + ValueTick tick = (ValueTick) iterator.next(); + if ((tick.getTickType() == TickType.MINOR) + && isDomainMinorGridlinesVisible()) { + gridStroke = getDomainMinorGridlineStroke(); + gridPaint = getDomainMinorGridlinePaint(); + paintLine = true; + } + else if ((tick.getTickType() == TickType.MAJOR) + && isDomainGridlinesVisible()) { + gridStroke = getDomainGridlineStroke(); + gridPaint = getDomainGridlinePaint(); + paintLine = true; + } + XYItemRenderer r = getRenderer(); + if ((r instanceof AbstractXYItemRenderer) && paintLine) { + ((AbstractXYItemRenderer) r).drawDomainLine(g2, this, + getDomainAxis(), dataArea, tick.getValue(), + gridPaint, gridStroke); + } + } + } + } + + /** + * Draws the gridlines for the plot's primary range axis, if they are + * visible. + * + * @param g2 the graphics device. + * @param area the data area. + * @param ticks the ticks. + * + * @see #drawDomainGridlines(Graphics2D, Rectangle2D, List) + */ + protected void drawRangeGridlines(Graphics2D g2, Rectangle2D area, + List ticks) { + + // no renderer, no gridlines... + if (getRenderer() == null) { + return; + } + + // draw the range grid lines, if any... + if (isRangeGridlinesVisible() || isRangeMinorGridlinesVisible()) { + Stroke gridStroke = null; + Paint gridPaint = null; + ValueAxis axis = getRangeAxis(); + if (axis != null) { + Iterator iterator = ticks.iterator(); + boolean paintLine; + while (iterator.hasNext()) { + paintLine = false; + ValueTick tick = (ValueTick) iterator.next(); + if ((tick.getTickType() == TickType.MINOR) + && isRangeMinorGridlinesVisible()) { + gridStroke = getRangeMinorGridlineStroke(); + gridPaint = getRangeMinorGridlinePaint(); + paintLine = true; + } + else if ((tick.getTickType() == TickType.MAJOR) + && isRangeGridlinesVisible()) { + gridStroke = getRangeGridlineStroke(); + gridPaint = getRangeGridlinePaint(); + paintLine = true; + } + if ((tick.getValue() != 0.0 + || !isRangeZeroBaselineVisible()) && paintLine) { + getRenderer().drawRangeLine(g2, this, getRangeAxis(), + area, tick.getValue(), gridPaint, gridStroke); + } + } + } + } + } + + /** + * Draws a base line across the chart at value zero on the domain axis. + * + * @param g2 the graphics device. + * @param area the data area. + * + * @see #setDomainZeroBaselineVisible(boolean) + * + * @since 1.0.5 + */ + protected void drawZeroDomainBaseline(Graphics2D g2, Rectangle2D area) { + if (isDomainZeroBaselineVisible()) { + XYItemRenderer r = getRenderer(); + // FIXME: the renderer interface doesn't have the drawDomainLine() + // method, so we have to rely on the renderer being a subclass of + // AbstractXYItemRenderer (which is lame) + if (r instanceof AbstractXYItemRenderer) { + AbstractXYItemRenderer renderer = (AbstractXYItemRenderer) r; + renderer.drawDomainLine(g2, this, getDomainAxis(), area, 0.0, + this.domainZeroBaselinePaint, + this.domainZeroBaselineStroke); + } + } + } + + /** + * Draws a base line across the chart at value zero on the range axis. + * + * @param g2 the graphics device. + * @param area the data area. + * + * @see #setRangeZeroBaselineVisible(boolean) + */ + protected void drawZeroRangeBaseline(Graphics2D g2, Rectangle2D area) { + if (isRangeZeroBaselineVisible()) { + getRenderer().drawRangeLine(g2, this, getRangeAxis(), area, 0.0, + this.rangeZeroBaselinePaint, this.rangeZeroBaselineStroke); + } + } + + /** + * Draws the annotations for the plot. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param info the chart rendering info. + */ + public void drawAnnotations(Graphics2D g2, + Rectangle2D dataArea, + PlotRenderingInfo info) { + + Iterator iterator = this.annotations.iterator(); + while (iterator.hasNext()) { + XYAnnotation annotation = (XYAnnotation) iterator.next(); + ValueAxis xAxis = getDomainAxis(); + ValueAxis yAxis = getRangeAxis(); + annotation.draw(g2, this, dataArea, xAxis, yAxis, 0, info); + } + + } + + /** + * Draws the domain markers (if any) for an axis and layer. This method is + * typically called from within the draw() method. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param index the renderer index. + * @param layer the layer (foreground or background). + */ + protected void drawDomainMarkers(Graphics2D g2, Rectangle2D dataArea, + int index, Layer layer) { + + XYItemRenderer r = getRenderer(index); + if (r == null) { + return; + } + // check that the renderer has a corresponding dataset (it doesn't + // matter if the dataset is null) + if (index >= getDatasetCount()) { + return; + } + Collection markers = getDomainMarkers(index, layer); + ValueAxis axis = getDomainAxisForDataset(index); + if (markers != null && axis != null) { + Iterator iterator = markers.iterator(); + while (iterator.hasNext()) { + Marker marker = (Marker) iterator.next(); + r.drawDomainMarker(g2, this, axis, marker, dataArea); + } + } + + } + + /** + * Draws the range markers (if any) for a renderer and layer. This method + * is typically called from within the draw() method. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param index the renderer index. + * @param layer the layer (foreground or background). + */ + protected void drawRangeMarkers(Graphics2D g2, Rectangle2D dataArea, + int index, Layer layer) { + + XYItemRenderer r = getRenderer(index); + if (r == null) { + return; + } + // check that the renderer has a corresponding dataset (it doesn't + // matter if the dataset is null) + if (index >= getDatasetCount()) { + return; + } + Collection markers = getRangeMarkers(index, layer); + ValueAxis axis = getRangeAxisForDataset(index); + if (markers != null && axis != null) { + Iterator iterator = markers.iterator(); + while (iterator.hasNext()) { + Marker marker = (Marker) iterator.next(); + r.drawRangeMarker(g2, this, axis, marker, dataArea); + } + } + } + + /** + * Returns the list of domain markers (read only) for the specified layer. + * + * @param layer the layer (foreground or background). + * + * @return The list of domain markers. + * + * @see #getRangeMarkers(Layer) + */ + public Collection getDomainMarkers(Layer layer) { + return getDomainMarkers(0, layer); + } + + /** + * Returns the list of range markers (read only) for the specified layer. + * + * @param layer the layer (foreground or background). + * + * @return The list of range markers. + * + * @see #getDomainMarkers(Layer) + */ + public Collection getRangeMarkers(Layer layer) { + return getRangeMarkers(0, layer); + } + + /** + * Returns a collection of domain markers for a particular renderer and + * layer. + * + * @param index the renderer index. + * @param layer the layer. + * + * @return A collection of markers (possibly null). + * + * @see #getRangeMarkers(int, Layer) + */ + public Collection getDomainMarkers(int index, Layer layer) { + Collection result = null; + Integer key = new Integer(index); + if (layer == Layer.FOREGROUND) { + result = (Collection) this.foregroundDomainMarkers.get(key); + } + else if (layer == Layer.BACKGROUND) { + result = (Collection) this.backgroundDomainMarkers.get(key); + } + if (result != null) { + result = Collections.unmodifiableCollection(result); + } + return result; + } + + /** + * Returns a collection of range markers for a particular renderer and + * layer. + * + * @param index the renderer index. + * @param layer the layer. + * + * @return A collection of markers (possibly null). + * + * @see #getDomainMarkers(int, Layer) + */ + public Collection getRangeMarkers(int index, Layer layer) { + Collection result = null; + Integer key = new Integer(index); + if (layer == Layer.FOREGROUND) { + result = (Collection) this.foregroundRangeMarkers.get(key); + } + else if (layer == Layer.BACKGROUND) { + result = (Collection) this.backgroundRangeMarkers.get(key); + } + if (result != null) { + result = Collections.unmodifiableCollection(result); + } + return result; + } + + /** + * Utility method for drawing a horizontal line across the data area of the + * plot. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param value the coordinate, where to draw the line. + * @param stroke the stroke to use. + * @param paint the paint to use. + */ + protected void drawHorizontalLine(Graphics2D g2, Rectangle2D dataArea, + double value, Stroke stroke, + Paint paint) { + + ValueAxis axis = getRangeAxis(); + if (getOrientation() == PlotOrientation.HORIZONTAL) { + axis = getDomainAxis(); + } + if (axis.getRange().contains(value)) { + double yy = axis.valueToJava2D(value, dataArea, RectangleEdge.LEFT); + Line2D line = new Line2D.Double(dataArea.getMinX(), yy, + dataArea.getMaxX(), yy); + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(line); + } + + } + + /** + * Draws a domain crosshair. + * + * @param g2 the graphics target. + * @param dataArea the data area. + * @param orientation the plot orientation. + * @param value the crosshair value. + * @param axis the axis against which the value is measured. + * @param stroke the stroke used to draw the crosshair line. + * @param paint the paint used to draw the crosshair line. + * + * @since 1.0.4 + */ + protected void drawDomainCrosshair(Graphics2D g2, Rectangle2D dataArea, + PlotOrientation orientation, double value, ValueAxis axis, + Stroke stroke, Paint paint) { + + if (axis.getRange().contains(value)) { + Line2D line; + if (orientation == PlotOrientation.VERTICAL) { + double xx = axis.valueToJava2D(value, dataArea, + RectangleEdge.BOTTOM); + line = new Line2D.Double(xx, dataArea.getMinY(), xx, + dataArea.getMaxY()); + } + else { + double yy = axis.valueToJava2D(value, dataArea, + RectangleEdge.LEFT); + line = new Line2D.Double(dataArea.getMinX(), yy, + dataArea.getMaxX(), yy); + } + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(line); + } + + } + + /** + * Utility method for drawing a vertical line on the data area of the plot. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param value the coordinate, where to draw the line. + * @param stroke the stroke to use. + * @param paint the paint to use. + */ + protected void drawVerticalLine(Graphics2D g2, Rectangle2D dataArea, + double value, Stroke stroke, Paint paint) { + + ValueAxis axis = getDomainAxis(); + if (getOrientation() == PlotOrientation.HORIZONTAL) { + axis = getRangeAxis(); + } + if (axis.getRange().contains(value)) { + double xx = axis.valueToJava2D(value, dataArea, + RectangleEdge.BOTTOM); + Line2D line = new Line2D.Double(xx, dataArea.getMinY(), xx, + dataArea.getMaxY()); + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(line); + } + + } + + /** + * Draws a range crosshair. + * + * @param g2 the graphics target. + * @param dataArea the data area. + * @param orientation the plot orientation. + * @param value the crosshair value. + * @param axis the axis against which the value is measured. + * @param stroke the stroke used to draw the crosshair line. + * @param paint the paint used to draw the crosshair line. + * + * @since 1.0.4 + */ + protected void drawRangeCrosshair(Graphics2D g2, Rectangle2D dataArea, + PlotOrientation orientation, double value, ValueAxis axis, + Stroke stroke, Paint paint) { + + if (axis.getRange().contains(value)) { + Line2D line; + if (orientation == PlotOrientation.HORIZONTAL) { + double xx = axis.valueToJava2D(value, dataArea, + RectangleEdge.BOTTOM); + line = new Line2D.Double(xx, dataArea.getMinY(), xx, + dataArea.getMaxY()); + } + else { + double yy = axis.valueToJava2D(value, dataArea, + RectangleEdge.LEFT); + line = new Line2D.Double(dataArea.getMinX(), yy, + dataArea.getMaxX(), yy); + } + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(line); + } + + } + + /** + * Handles a 'click' on the plot by updating the anchor values. + * + * @param x the x-coordinate, where the click occurred, in Java2D space. + * @param y the y-coordinate, where the click occurred, in Java2D space. + * @param info object containing information about the plot dimensions. + */ + @Override + public void handleClick(int x, int y, PlotRenderingInfo info) { + + Rectangle2D dataArea = info.getDataArea(); + if (dataArea.contains(x, y)) { + // set the anchor value for the horizontal axis... + ValueAxis xaxis = getDomainAxis(); + if (xaxis != null) { + double hvalue = xaxis.java2DToValue(x, info.getDataArea(), + getDomainAxisEdge()); + setDomainCrosshairValue(hvalue); + } + + // set the anchor value for the vertical axis... + ValueAxis yaxis = getRangeAxis(); + if (yaxis != null) { + double vvalue = yaxis.java2DToValue(y, info.getDataArea(), + getRangeAxisEdge()); + setRangeCrosshairValue(vvalue); + } + } + } + + /** + * A utility method that returns a list of datasets that are mapped to a + * particular axis. + * + * @param axisIndex the axis index (null not permitted). + * + * @return A list of datasets. + */ + private List getDatasetsMappedToDomainAxis(Integer axisIndex) { + ParamChecks.nullNotPermitted(axisIndex, "axisIndex"); + List result = new ArrayList(); + for (int i = 0; i < this.datasets.size(); i++) { + List mappedAxes = (List) this.datasetToDomainAxesMap.get( + new Integer(i)); + if (mappedAxes == null) { + if (axisIndex.equals(ZERO)) { + result.add(this.datasets.get(i)); + } + } + else { + if (mappedAxes.contains(axisIndex)) { + result.add(this.datasets.get(i)); + } + } + } + return result; + } + + /** + * A utility method that returns a list of datasets that are mapped to a + * particular axis. + * + * @param axisIndex the axis index (null not permitted). + * + * @return A list of datasets. + */ + private List getDatasetsMappedToRangeAxis(Integer axisIndex) { + ParamChecks.nullNotPermitted(axisIndex, "axisIndex"); + List result = new ArrayList(); + for (int i = 0; i < this.datasets.size(); i++) { + List mappedAxes = (List) this.datasetToRangeAxesMap.get( + new Integer(i)); + if (mappedAxes == null) { + if (axisIndex.equals(ZERO)) { + result.add(this.datasets.get(i)); + } + } + else { + if (mappedAxes.contains(axisIndex)) { + result.add(this.datasets.get(i)); + } + } + } + return result; + } + + /** + * Returns the index of the given domain axis. + * + * @param axis the axis. + * + * @return The axis index. + * + * @see #getRangeAxisIndex(ValueAxis) + */ + public int getDomainAxisIndex(ValueAxis axis) { + int result = this.domainAxes.indexOf(axis); + if (result < 0) { + // try the parent plot + Plot parent = getParent(); + if (parent instanceof XYPlot) { + XYPlot p = (XYPlot) parent; + result = p.getDomainAxisIndex(axis); + } + } + return result; + } + + /** + * Returns the index of the given range axis. + * + * @param axis the axis. + * + * @return The axis index. + * + * @see #getDomainAxisIndex(ValueAxis) + */ + public int getRangeAxisIndex(ValueAxis axis) { + int result = this.rangeAxes.indexOf(axis); + if (result < 0) { + // try the parent plot + Plot parent = getParent(); + if (parent instanceof XYPlot) { + XYPlot p = (XYPlot) parent; + result = p.getRangeAxisIndex(axis); + } + } + return result; + } + + /** + * Returns the range for the specified axis. + * + * @param axis the axis. + * + * @return The range. + */ + @Override + public Range getDataRange(ValueAxis axis) { + + Range result = null; + List mappedDatasets = new ArrayList(); + List includedAnnotations = new ArrayList(); + boolean isDomainAxis = true; + + // is it a domain axis? + int domainIndex = getDomainAxisIndex(axis); + if (domainIndex >= 0) { + isDomainAxis = true; + mappedDatasets.addAll(getDatasetsMappedToDomainAxis( + new Integer(domainIndex))); + if (domainIndex == 0) { + // grab the plot's annotations + Iterator iterator = this.annotations.iterator(); + while (iterator.hasNext()) { + XYAnnotation annotation = (XYAnnotation) iterator.next(); + if (annotation instanceof XYAnnotationBoundsInfo) { + includedAnnotations.add(annotation); + } + } + } + } + + // or is it a range axis? + int rangeIndex = getRangeAxisIndex(axis); + if (rangeIndex >= 0) { + isDomainAxis = false; + mappedDatasets.addAll(getDatasetsMappedToRangeAxis( + new Integer(rangeIndex))); + if (rangeIndex == 0) { + Iterator iterator = this.annotations.iterator(); + while (iterator.hasNext()) { + XYAnnotation annotation = (XYAnnotation) iterator.next(); + if (annotation instanceof XYAnnotationBoundsInfo) { + includedAnnotations.add(annotation); + } + } + } + } + + // iterate through the datasets that map to the axis and get the union + // of the ranges. + Iterator iterator = mappedDatasets.iterator(); + while (iterator.hasNext()) { + XYDataset d = (XYDataset) iterator.next(); + if (d != null) { + XYItemRenderer r = getRendererForDataset(d); + if (isDomainAxis) { + if (r != null) { + result = Range.combine(result, r.findDomainBounds(d)); + } + else { + result = Range.combine(result, + DatasetUtilities.findDomainBounds(d)); + } + } + else { + if (r != null) { + result = Range.combine(result, r.findRangeBounds(d)); + } + else { + result = Range.combine(result, + DatasetUtilities.findRangeBounds(d)); + } + } + // FIXME: the XYItemRenderer interface doesn't specify the + // getAnnotations() method but it should + if (r instanceof AbstractXYItemRenderer) { + AbstractXYItemRenderer rr = (AbstractXYItemRenderer) r; + Collection c = rr.getAnnotations(); + Iterator i = c.iterator(); + while (i.hasNext()) { + XYAnnotation a = (XYAnnotation) i.next(); + if (a instanceof XYAnnotationBoundsInfo) { + includedAnnotations.add(a); + } + } + } + } + } + + Iterator it = includedAnnotations.iterator(); + while (it.hasNext()) { + XYAnnotationBoundsInfo xyabi = (XYAnnotationBoundsInfo) it.next(); + if (xyabi.getIncludeInDataBounds()) { + if (isDomainAxis) { + result = Range.combine(result, xyabi.getXRange()); + } + else { + result = Range.combine(result, xyabi.getYRange()); + } + } + } + + return result; + + } + + /** + * Receives notification of a change to an {@link Annotation} added to + * this plot. + * + * @param event information about the event (not used here). + * + * @since 1.0.14 + */ + @Override + public void annotationChanged(AnnotationChangeEvent event) { + if (getParent() != null) { + getParent().annotationChanged(event); + } + else { + PlotChangeEvent e = new PlotChangeEvent(this); + notifyListeners(e); + } + } + + /** + * Receives notification of a change to the plot's dataset. + *

+ * The axis ranges are updated if necessary. + * + * @param event information about the event (not used here). + */ + @Override + public void datasetChanged(DatasetChangeEvent event) { + configureDomainAxes(); + configureRangeAxes(); + if (getParent() != null) { + getParent().datasetChanged(event); + } + else { + PlotChangeEvent e = new PlotChangeEvent(this); + e.setType(ChartChangeEventType.DATASET_UPDATED); + notifyListeners(e); + } + } + + /** + * Receives notification of a renderer change event. + * + * @param event the event. + */ + @Override + public void rendererChanged(RendererChangeEvent event) { + // if the event was caused by a change to series visibility, then + // the axis ranges might need updating... + if (event.getSeriesVisibilityChanged()) { + configureDomainAxes(); + configureRangeAxes(); + } + fireChangeEvent(); + } + + /** + * Returns a flag indicating whether or not the domain crosshair is visible. + * + * @return The flag. + * + * @see #setDomainCrosshairVisible(boolean) + */ + public boolean isDomainCrosshairVisible() { + return this.domainCrosshairVisible; + } + + /** + * Sets the flag indicating whether or not the domain crosshair is visible + * and, if the flag changes, sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param flag the new value of the flag. + * + * @see #isDomainCrosshairVisible() + */ + public void setDomainCrosshairVisible(boolean flag) { + if (this.domainCrosshairVisible != flag) { + this.domainCrosshairVisible = flag; + fireChangeEvent(); + } + } + + /** + * Returns a flag indicating whether or not the crosshair should "lock-on" + * to actual data values. + * + * @return The flag. + * + * @see #setDomainCrosshairLockedOnData(boolean) + */ + public boolean isDomainCrosshairLockedOnData() { + return this.domainCrosshairLockedOnData; + } + + /** + * Sets the flag indicating whether or not the domain crosshair should + * "lock-on" to actual data values. If the flag value changes, this + * method sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param flag the flag. + * + * @see #isDomainCrosshairLockedOnData() + */ + public void setDomainCrosshairLockedOnData(boolean flag) { + if (this.domainCrosshairLockedOnData != flag) { + this.domainCrosshairLockedOnData = flag; + fireChangeEvent(); + } + } + + /** + * Returns the domain crosshair value. + * + * @return The value. + * + * @see #setDomainCrosshairValue(double) + */ + public double getDomainCrosshairValue() { + return this.domainCrosshairValue; + } + + /** + * Sets the domain crosshair value and sends a {@link PlotChangeEvent} to + * all registered listeners (provided that the domain crosshair is visible). + * + * @param value the value. + * + * @see #getDomainCrosshairValue() + */ + public void setDomainCrosshairValue(double value) { + setDomainCrosshairValue(value, true); + } + + /** + * Sets the domain crosshair value and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners (provided that the + * domain crosshair is visible). + * + * @param value the new value. + * @param notify notify listeners? + * + * @see #getDomainCrosshairValue() + */ + public void setDomainCrosshairValue(double value, boolean notify) { + this.domainCrosshairValue = value; + if (isDomainCrosshairVisible() && notify) { + fireChangeEvent(); + } + } + + /** + * Returns the {@link Stroke} used to draw the crosshair (if visible). + * + * @return The crosshair stroke (never null). + * + * @see #setDomainCrosshairStroke(Stroke) + * @see #isDomainCrosshairVisible() + * @see #getDomainCrosshairPaint() + */ + public Stroke getDomainCrosshairStroke() { + return this.domainCrosshairStroke; + } + + /** + * Sets the Stroke used to draw the crosshairs (if visible) and notifies + * registered listeners that the axis has been modified. + * + * @param stroke the new crosshair stroke (null not + * permitted). + * + * @see #getDomainCrosshairStroke() + */ + public void setDomainCrosshairStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.domainCrosshairStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the domain crosshair paint. + * + * @return The crosshair paint (never null). + * + * @see #setDomainCrosshairPaint(Paint) + * @see #isDomainCrosshairVisible() + * @see #getDomainCrosshairStroke() + */ + public Paint getDomainCrosshairPaint() { + return this.domainCrosshairPaint; + } + + /** + * Sets the paint used to draw the crosshairs (if visible) and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the new crosshair paint (null not permitted). + * + * @see #getDomainCrosshairPaint() + */ + public void setDomainCrosshairPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.domainCrosshairPaint = paint; + fireChangeEvent(); + } + + /** + * Returns a flag indicating whether or not the range crosshair is visible. + * + * @return The flag. + * + * @see #setRangeCrosshairVisible(boolean) + * @see #isDomainCrosshairVisible() + */ + public boolean isRangeCrosshairVisible() { + return this.rangeCrosshairVisible; + } + + /** + * Sets the flag indicating whether or not the range crosshair is visible. + * If the flag value changes, this method sends a {@link PlotChangeEvent} + * to all registered listeners. + * + * @param flag the new value of the flag. + * + * @see #isRangeCrosshairVisible() + */ + public void setRangeCrosshairVisible(boolean flag) { + if (this.rangeCrosshairVisible != flag) { + this.rangeCrosshairVisible = flag; + fireChangeEvent(); + } + } + + /** + * Returns a flag indicating whether or not the crosshair should "lock-on" + * to actual data values. + * + * @return The flag. + * + * @see #setRangeCrosshairLockedOnData(boolean) + */ + public boolean isRangeCrosshairLockedOnData() { + return this.rangeCrosshairLockedOnData; + } + + /** + * Sets the flag indicating whether or not the range crosshair should + * "lock-on" to actual data values. If the flag value changes, this method + * sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param flag the flag. + * + * @see #isRangeCrosshairLockedOnData() + */ + public void setRangeCrosshairLockedOnData(boolean flag) { + if (this.rangeCrosshairLockedOnData != flag) { + this.rangeCrosshairLockedOnData = flag; + fireChangeEvent(); + } + } + + /** + * Returns the range crosshair value. + * + * @return The value. + * + * @see #setRangeCrosshairValue(double) + */ + public double getRangeCrosshairValue() { + return this.rangeCrosshairValue; + } + + /** + * Sets the range crosshair value. + *

+ * Registered listeners are notified that the plot has been modified, but + * only if the crosshair is visible. + * + * @param value the new value. + * + * @see #getRangeCrosshairValue() + */ + public void setRangeCrosshairValue(double value) { + setRangeCrosshairValue(value, true); + } + + /** + * Sets the range crosshair value and sends a {@link PlotChangeEvent} to + * all registered listeners, but only if the crosshair is visible. + * + * @param value the new value. + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @see #getRangeCrosshairValue() + */ + public void setRangeCrosshairValue(double value, boolean notify) { + this.rangeCrosshairValue = value; + if (isRangeCrosshairVisible() && notify) { + fireChangeEvent(); + } + } + + /** + * Returns the stroke used to draw the crosshair (if visible). + * + * @return The crosshair stroke (never null). + * + * @see #setRangeCrosshairStroke(Stroke) + * @see #isRangeCrosshairVisible() + * @see #getRangeCrosshairPaint() + */ + public Stroke getRangeCrosshairStroke() { + return this.rangeCrosshairStroke; + } + + /** + * Sets the stroke used to draw the crosshairs (if visible) and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param stroke the new crosshair stroke (null not + * permitted). + * + * @see #getRangeCrosshairStroke() + */ + public void setRangeCrosshairStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.rangeCrosshairStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the range crosshair paint. + * + * @return The crosshair paint (never null). + * + * @see #setRangeCrosshairPaint(Paint) + * @see #isRangeCrosshairVisible() + * @see #getRangeCrosshairStroke() + */ + public Paint getRangeCrosshairPaint() { + return this.rangeCrosshairPaint; + } + + /** + * Sets the paint used to color the crosshairs (if visible) and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param paint the new crosshair paint (null not permitted). + * + * @see #getRangeCrosshairPaint() + */ + public void setRangeCrosshairPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.rangeCrosshairPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the fixed domain axis space. + * + * @return The fixed domain axis space (possibly null). + * + * @see #setFixedDomainAxisSpace(AxisSpace) + */ + public AxisSpace getFixedDomainAxisSpace() { + return this.fixedDomainAxisSpace; + } + + /** + * Sets the fixed domain axis space and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param space the space (null permitted). + * + * @see #getFixedDomainAxisSpace() + */ + public void setFixedDomainAxisSpace(AxisSpace space) { + setFixedDomainAxisSpace(space, true); + } + + /** + * Sets the fixed domain axis space and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param space the space (null permitted). + * @param notify notify listeners? + * + * @see #getFixedDomainAxisSpace() + * + * @since 1.0.9 + */ + public void setFixedDomainAxisSpace(AxisSpace space, boolean notify) { + this.fixedDomainAxisSpace = space; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the fixed range axis space. + * + * @return The fixed range axis space (possibly null). + * + * @see #setFixedRangeAxisSpace(AxisSpace) + */ + public AxisSpace getFixedRangeAxisSpace() { + return this.fixedRangeAxisSpace; + } + + /** + * Sets the fixed range axis space and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param space the space (null permitted). + * + * @see #getFixedRangeAxisSpace() + */ + public void setFixedRangeAxisSpace(AxisSpace space) { + setFixedRangeAxisSpace(space, true); + } + + /** + * Sets the fixed range axis space and, if requested, sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param space the space (null permitted). + * @param notify notify listeners? + * + * @see #getFixedRangeAxisSpace() + * + * @since 1.0.9 + */ + public void setFixedRangeAxisSpace(AxisSpace space, boolean notify) { + this.fixedRangeAxisSpace = space; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns true if panning is enabled for the domain axes, + * and false otherwise. + * + * @return A boolean. + * + * @since 1.0.13 + */ + @Override + public boolean isDomainPannable() { + return this.domainPannable; + } + + /** + * Sets the flag that enables or disables panning of the plot along the + * domain axes. + * + * @param pannable the new flag value. + * + * @since 1.0.13 + */ + public void setDomainPannable(boolean pannable) { + this.domainPannable = pannable; + } + + /** + * Returns true if panning is enabled for the range axes, + * and false otherwise. + * + * @return A boolean. + * + * @since 1.0.13 + */ + @Override + public boolean isRangePannable() { + return this.rangePannable; + } + + /** + * Sets the flag that enables or disables panning of the plot along + * the range axes. + * + * @param pannable the new flag value. + * + * @since 1.0.13 + */ + public void setRangePannable(boolean pannable) { + this.rangePannable = pannable; + } + + /** + * Pans the domain axes by the specified percentage. + * + * @param percent the distance to pan (as a percentage of the axis length). + * @param info the plot info + * @param source the source point where the pan action started. + * + * @since 1.0.13 + */ + @Override + public void panDomainAxes(double percent, PlotRenderingInfo info, + Point2D source) { + if (!isDomainPannable()) { + return; + } + int domainAxisCount = getDomainAxisCount(); + for (int i = 0; i < domainAxisCount; i++) { + ValueAxis axis = getDomainAxis(i); + if (axis == null) { + continue; + } + if (axis.isInverted()) { + percent = -percent; + } + axis.pan(percent); + } + } + + /** + * Pans the range axes by the specified percentage. + * + * @param percent the distance to pan (as a percentage of the axis length). + * @param info the plot info + * @param source the source point where the pan action started. + * + * @since 1.0.13 + */ + @Override + public void panRangeAxes(double percent, PlotRenderingInfo info, + Point2D source) { + if (!isRangePannable()) { + return; + } + int rangeAxisCount = getRangeAxisCount(); + for (int i = 0; i < rangeAxisCount; i++) { + ValueAxis axis = getRangeAxis(i); + if (axis == null) { + continue; + } + if (axis.isInverted()) { + percent = -percent; + } + axis.pan(percent); + } + } + + /** + * Multiplies the range on the domain axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info. + * @param source the source point (in Java2D space). + * + * @see #zoomRangeAxes(double, PlotRenderingInfo, Point2D) + */ + @Override + public void zoomDomainAxes(double factor, PlotRenderingInfo info, + Point2D source) { + // delegate to other method + zoomDomainAxes(factor, info, source, false); + } + + /** + * Multiplies the range on the domain axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info. + * @param source the source point (in Java2D space). + * @param useAnchor use source point as zoom anchor? + * + * @see #zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean) + * + * @since 1.0.7 + */ + @Override + public void zoomDomainAxes(double factor, PlotRenderingInfo info, + Point2D source, boolean useAnchor) { + + // perform the zoom on each domain axis + for (int i = 0; i < this.domainAxes.size(); i++) { + ValueAxis domainAxis = (ValueAxis) this.domainAxes.get(i); + if (domainAxis != null) { + if (useAnchor) { + // get the relevant source coordinate given the plot + // orientation + double sourceX = source.getX(); + if (this.orientation == PlotOrientation.HORIZONTAL) { + sourceX = source.getY(); + } + double anchorX = domainAxis.java2DToValue(sourceX, + info.getDataArea(), getDomainAxisEdge()); + domainAxis.resizeRange2(factor, anchorX); + } + else { + domainAxis.resizeRange(factor); + } + } + } + } + + /** + * Zooms in on the domain axis/axes. The new lower and upper bounds are + * specified as percentages of the current axis range, where 0 percent is + * the current lower bound and 100 percent is the current upper bound. + * + * @param lowerPercent a percentage that determines the new lower bound + * for the axis (e.g. 0.20 is twenty percent). + * @param upperPercent a percentage that determines the new upper bound + * for the axis (e.g. 0.80 is eighty percent). + * @param info the plot rendering info. + * @param source the source point (ignored). + * + * @see #zoomRangeAxes(double, double, PlotRenderingInfo, Point2D) + */ + @Override + public void zoomDomainAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo info, Point2D source) { + for (int i = 0; i < this.domainAxes.size(); i++) { + ValueAxis domainAxis = (ValueAxis) this.domainAxes.get(i); + if (domainAxis != null) { + domainAxis.zoomRange(lowerPercent, upperPercent); + } + } + } + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info. + * @param source the source point. + * + * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean) + */ + @Override + public void zoomRangeAxes(double factor, PlotRenderingInfo info, + Point2D source) { + // delegate to other method + zoomRangeAxes(factor, info, source, false); + } + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * + * @param factor the zoom factor. + * @param info the plot rendering info. + * @param source the source point. + * @param useAnchor a flag that controls whether or not the source point + * is used for the zoom anchor. + * + * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D, boolean) + * + * @since 1.0.7 + */ + @Override + public void zoomRangeAxes(double factor, PlotRenderingInfo info, + Point2D source, boolean useAnchor) { + + // perform the zoom on each range axis + for (int i = 0; i < this.rangeAxes.size(); i++) { + ValueAxis rangeAxis = (ValueAxis) this.rangeAxes.get(i); + if (rangeAxis != null) { + if (useAnchor) { + // get the relevant source coordinate given the plot + // orientation + double sourceY = source.getY(); + if (this.orientation == PlotOrientation.HORIZONTAL) { + sourceY = source.getX(); + } + double anchorY = rangeAxis.java2DToValue(sourceY, + info.getDataArea(), getRangeAxisEdge()); + rangeAxis.resizeRange2(factor, anchorY); + } + else { + rangeAxis.resizeRange(factor); + } + } + } + } + + /** + * Zooms in on the range axes. + * + * @param lowerPercent the lower bound. + * @param upperPercent the upper bound. + * @param info the plot rendering info. + * @param source the source point. + * + * @see #zoomDomainAxes(double, double, PlotRenderingInfo, Point2D) + */ + @Override + public void zoomRangeAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo info, Point2D source) { + for (int i = 0; i < this.rangeAxes.size(); i++) { + ValueAxis rangeAxis = (ValueAxis) this.rangeAxes.get(i); + if (rangeAxis != null) { + rangeAxis.zoomRange(lowerPercent, upperPercent); + } + } + } + + /** + * Returns true, indicating that the domain axis/axes for this + * plot are zoomable. + * + * @return A boolean. + * + * @see #isRangeZoomable() + */ + @Override + public boolean isDomainZoomable() { + return true; + } + + /** + * Returns true, indicating that the range axis/axes for this + * plot are zoomable. + * + * @return A boolean. + * + * @see #isDomainZoomable() + */ + @Override + public boolean isRangeZoomable() { + return true; + } + + /** + * Returns the number of series in the primary dataset for this plot. If + * the dataset is null, the method returns 0. + * + * @return The series count. + */ + public int getSeriesCount() { + int result = 0; + XYDataset dataset = getDataset(); + if (dataset != null) { + result = dataset.getSeriesCount(); + } + return result; + } + + /** + * Returns the fixed legend items, if any. + * + * @return The legend items (possibly null). + * + * @see #setFixedLegendItems(LegendItemCollection) + */ + public LegendItemCollection getFixedLegendItems() { + return this.fixedLegendItems; + } + + /** + * Sets the fixed legend items for the plot. Leave this set to + * null if you prefer the legend items to be created + * automatically. + * + * @param items the legend items (null permitted). + * + * @see #getFixedLegendItems() + */ + public void setFixedLegendItems(LegendItemCollection items) { + this.fixedLegendItems = items; + fireChangeEvent(); + } + + /** + * Returns the legend items for the plot. Each legend item is generated by + * the plot's renderer, since the renderer is responsible for the visual + * representation of the data. + * + * @return The legend items. + */ + @Override + public LegendItemCollection getLegendItems() { + if (this.fixedLegendItems != null) { + return this.fixedLegendItems; + } + LegendItemCollection result = new LegendItemCollection(); + int count = this.datasets.size(); + for (int datasetIndex = 0; datasetIndex < count; datasetIndex++) { + XYDataset dataset = getDataset(datasetIndex); + if (dataset != null) { + XYItemRenderer renderer = getRenderer(datasetIndex); + if (renderer == null) { + renderer = getRenderer(0); + } + if (renderer != null) { + int seriesCount = dataset.getSeriesCount(); + for (int i = 0; i < seriesCount; i++) { + if (renderer.isSeriesVisible(i) + && renderer.isSeriesVisibleInLegend(i)) { + LegendItem item = renderer.getLegendItem( + datasetIndex, i); + if (item != null) { + result.add(item); + } + } + } + } + } + } + return result; + } + + /** + * Tests this plot for equality with another object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYPlot)) { + return false; + } + XYPlot that = (XYPlot) obj; + if (this.weight != that.weight) { + return false; + } + if (this.orientation != that.orientation) { + return false; + } + if (!this.domainAxes.equals(that.domainAxes)) { + return false; + } + if (!this.domainAxisLocations.equals(that.domainAxisLocations)) { + return false; + } + if (this.rangeCrosshairLockedOnData + != that.rangeCrosshairLockedOnData) { + return false; + } + if (this.domainGridlinesVisible != that.domainGridlinesVisible) { + return false; + } + if (this.rangeGridlinesVisible != that.rangeGridlinesVisible) { + return false; + } + if (this.domainMinorGridlinesVisible + != that.domainMinorGridlinesVisible) { + return false; + } + if (this.rangeMinorGridlinesVisible + != that.rangeMinorGridlinesVisible) { + return false; + } + if (this.domainZeroBaselineVisible != that.domainZeroBaselineVisible) { + return false; + } + if (this.rangeZeroBaselineVisible != that.rangeZeroBaselineVisible) { + return false; + } + if (this.domainCrosshairVisible != that.domainCrosshairVisible) { + return false; + } + if (this.domainCrosshairValue != that.domainCrosshairValue) { + return false; + } + if (this.domainCrosshairLockedOnData + != that.domainCrosshairLockedOnData) { + return false; + } + if (this.rangeCrosshairVisible != that.rangeCrosshairVisible) { + return false; + } + if (this.rangeCrosshairValue != that.rangeCrosshairValue) { + return false; + } + if (!ObjectUtilities.equal(this.axisOffset, that.axisOffset)) { + return false; + } + if (!ObjectUtilities.equal(this.renderers, that.renderers)) { + return false; + } + if (!ObjectUtilities.equal(this.rangeAxes, that.rangeAxes)) { + return false; + } + if (!this.rangeAxisLocations.equals(that.rangeAxisLocations)) { + return false; + } + if (!ObjectUtilities.equal(this.datasetToDomainAxesMap, + that.datasetToDomainAxesMap)) { + return false; + } + if (!ObjectUtilities.equal(this.datasetToRangeAxesMap, + that.datasetToRangeAxesMap)) { + return false; + } + if (!ObjectUtilities.equal(this.domainGridlineStroke, + that.domainGridlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.domainGridlinePaint, + that.domainGridlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.rangeGridlineStroke, + that.rangeGridlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.rangeGridlinePaint, + that.rangeGridlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.domainMinorGridlineStroke, + that.domainMinorGridlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.domainMinorGridlinePaint, + that.domainMinorGridlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.rangeMinorGridlineStroke, + that.rangeMinorGridlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.rangeMinorGridlinePaint, + that.rangeMinorGridlinePaint)) { + return false; + } + if (!PaintUtilities.equal(this.domainZeroBaselinePaint, + that.domainZeroBaselinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.domainZeroBaselineStroke, + that.domainZeroBaselineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.rangeZeroBaselinePaint, + that.rangeZeroBaselinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.rangeZeroBaselineStroke, + that.rangeZeroBaselineStroke)) { + return false; + } + if (!ObjectUtilities.equal(this.domainCrosshairStroke, + that.domainCrosshairStroke)) { + return false; + } + if (!PaintUtilities.equal(this.domainCrosshairPaint, + that.domainCrosshairPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.rangeCrosshairStroke, + that.rangeCrosshairStroke)) { + return false; + } + if (!PaintUtilities.equal(this.rangeCrosshairPaint, + that.rangeCrosshairPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.foregroundDomainMarkers, + that.foregroundDomainMarkers)) { + return false; + } + if (!ObjectUtilities.equal(this.backgroundDomainMarkers, + that.backgroundDomainMarkers)) { + return false; + } + if (!ObjectUtilities.equal(this.foregroundRangeMarkers, + that.foregroundRangeMarkers)) { + return false; + } + if (!ObjectUtilities.equal(this.backgroundRangeMarkers, + that.backgroundRangeMarkers)) { + return false; + } + if (!ObjectUtilities.equal(this.foregroundDomainMarkers, + that.foregroundDomainMarkers)) { + return false; + } + if (!ObjectUtilities.equal(this.backgroundDomainMarkers, + that.backgroundDomainMarkers)) { + return false; + } + if (!ObjectUtilities.equal(this.foregroundRangeMarkers, + that.foregroundRangeMarkers)) { + return false; + } + if (!ObjectUtilities.equal(this.backgroundRangeMarkers, + that.backgroundRangeMarkers)) { + return false; + } + if (!ObjectUtilities.equal(this.annotations, that.annotations)) { + return false; + } + if (!ObjectUtilities.equal(this.fixedLegendItems, + that.fixedLegendItems)) { + return false; + } + if (!PaintUtilities.equal(this.domainTickBandPaint, + that.domainTickBandPaint)) { + return false; + } + if (!PaintUtilities.equal(this.rangeTickBandPaint, + that.rangeTickBandPaint)) { + return false; + } + if (!this.quadrantOrigin.equals(that.quadrantOrigin)) { + return false; + } + for (int i = 0; i < 4; i++) { + if (!PaintUtilities.equal(this.quadrantPaint[i], + that.quadrantPaint[i])) { + return false; + } + } + if (!ObjectUtilities.equal(this.shadowGenerator, + that.shadowGenerator)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the plot. + * + * @return A clone. + * + * @throws CloneNotSupportedException this can occur if some component of + * the plot cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + + XYPlot clone = (XYPlot) super.clone(); + clone.domainAxes = (ObjectList) ObjectUtilities.clone(this.domainAxes); + for (int i = 0; i < this.domainAxes.size(); i++) { + ValueAxis axis = (ValueAxis) this.domainAxes.get(i); + if (axis != null) { + ValueAxis clonedAxis = (ValueAxis) axis.clone(); + clone.domainAxes.set(i, clonedAxis); + clonedAxis.setPlot(clone); + clonedAxis.addChangeListener(clone); + } + } + clone.domainAxisLocations = (ObjectList) + this.domainAxisLocations.clone(); + + clone.rangeAxes = (ObjectList) ObjectUtilities.clone(this.rangeAxes); + for (int i = 0; i < this.rangeAxes.size(); i++) { + ValueAxis axis = (ValueAxis) this.rangeAxes.get(i); + if (axis != null) { + ValueAxis clonedAxis = (ValueAxis) axis.clone(); + clone.rangeAxes.set(i, clonedAxis); + clonedAxis.setPlot(clone); + clonedAxis.addChangeListener(clone); + } + } + clone.rangeAxisLocations = (ObjectList) ObjectUtilities.clone( + this.rangeAxisLocations); + + // the datasets are not cloned, but listeners need to be added... + clone.datasets = (ObjectList) ObjectUtilities.clone(this.datasets); + for (int i = 0; i < clone.datasets.size(); ++i) { + XYDataset d = getDataset(i); + if (d != null) { + d.addChangeListener(clone); + } + } + + clone.datasetToDomainAxesMap = new TreeMap(); + clone.datasetToDomainAxesMap.putAll(this.datasetToDomainAxesMap); + clone.datasetToRangeAxesMap = new TreeMap(); + clone.datasetToRangeAxesMap.putAll(this.datasetToRangeAxesMap); + + clone.renderers = (ObjectList) ObjectUtilities.clone(this.renderers); + for (int i = 0; i < this.renderers.size(); i++) { + XYItemRenderer renderer2 = (XYItemRenderer) this.renderers.get(i); + if (renderer2 instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) renderer2; + XYItemRenderer rc = (XYItemRenderer) pc.clone(); + clone.renderers.set(i, rc); + rc.setPlot(clone); + rc.addChangeListener(clone); + } + } + clone.foregroundDomainMarkers = (Map) ObjectUtilities.clone( + this.foregroundDomainMarkers); + clone.backgroundDomainMarkers = (Map) ObjectUtilities.clone( + this.backgroundDomainMarkers); + clone.foregroundRangeMarkers = (Map) ObjectUtilities.clone( + this.foregroundRangeMarkers); + clone.backgroundRangeMarkers = (Map) ObjectUtilities.clone( + this.backgroundRangeMarkers); + clone.annotations = (List) ObjectUtilities.deepClone(this.annotations); + if (this.fixedDomainAxisSpace != null) { + clone.fixedDomainAxisSpace = (AxisSpace) ObjectUtilities.clone( + this.fixedDomainAxisSpace); + } + if (this.fixedRangeAxisSpace != null) { + clone.fixedRangeAxisSpace = (AxisSpace) ObjectUtilities.clone( + this.fixedRangeAxisSpace); + } + if (this.fixedLegendItems != null) { + clone.fixedLegendItems + = (LegendItemCollection) this.fixedLegendItems.clone(); + } + clone.quadrantOrigin = (Point2D) ObjectUtilities.clone( + this.quadrantOrigin); + clone.quadrantPaint = (Paint[]) this.quadrantPaint.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.writeStroke(this.domainGridlineStroke, stream); + SerialUtilities.writePaint(this.domainGridlinePaint, stream); + SerialUtilities.writeStroke(this.rangeGridlineStroke, stream); + SerialUtilities.writePaint(this.rangeGridlinePaint, stream); + SerialUtilities.writeStroke(this.domainMinorGridlineStroke, stream); + SerialUtilities.writePaint(this.domainMinorGridlinePaint, stream); + SerialUtilities.writeStroke(this.rangeMinorGridlineStroke, stream); + SerialUtilities.writePaint(this.rangeMinorGridlinePaint, stream); + SerialUtilities.writeStroke(this.rangeZeroBaselineStroke, stream); + SerialUtilities.writePaint(this.rangeZeroBaselinePaint, stream); + SerialUtilities.writeStroke(this.domainCrosshairStroke, stream); + SerialUtilities.writePaint(this.domainCrosshairPaint, stream); + SerialUtilities.writeStroke(this.rangeCrosshairStroke, stream); + SerialUtilities.writePaint(this.rangeCrosshairPaint, stream); + SerialUtilities.writePaint(this.domainTickBandPaint, stream); + SerialUtilities.writePaint(this.rangeTickBandPaint, stream); + SerialUtilities.writePoint2D(this.quadrantOrigin, stream); + for (int i = 0; i < 4; i++) { + SerialUtilities.writePaint(this.quadrantPaint[i], stream); + } + SerialUtilities.writeStroke(this.domainZeroBaselineStroke, stream); + SerialUtilities.writePaint(this.domainZeroBaselinePaint, 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.domainGridlineStroke = SerialUtilities.readStroke(stream); + this.domainGridlinePaint = SerialUtilities.readPaint(stream); + this.rangeGridlineStroke = SerialUtilities.readStroke(stream); + this.rangeGridlinePaint = SerialUtilities.readPaint(stream); + this.domainMinorGridlineStroke = SerialUtilities.readStroke(stream); + this.domainMinorGridlinePaint = SerialUtilities.readPaint(stream); + this.rangeMinorGridlineStroke = SerialUtilities.readStroke(stream); + this.rangeMinorGridlinePaint = SerialUtilities.readPaint(stream); + this.rangeZeroBaselineStroke = SerialUtilities.readStroke(stream); + this.rangeZeroBaselinePaint = SerialUtilities.readPaint(stream); + this.domainCrosshairStroke = SerialUtilities.readStroke(stream); + this.domainCrosshairPaint = SerialUtilities.readPaint(stream); + this.rangeCrosshairStroke = SerialUtilities.readStroke(stream); + this.rangeCrosshairPaint = SerialUtilities.readPaint(stream); + this.domainTickBandPaint = SerialUtilities.readPaint(stream); + this.rangeTickBandPaint = SerialUtilities.readPaint(stream); + this.quadrantOrigin = SerialUtilities.readPoint2D(stream); + this.quadrantPaint = new Paint[4]; + for (int i = 0; i < 4; i++) { + this.quadrantPaint[i] = SerialUtilities.readPaint(stream); + } + + this.domainZeroBaselineStroke = SerialUtilities.readStroke(stream); + this.domainZeroBaselinePaint = SerialUtilities.readPaint(stream); + + // register the plot as a listener with its axes, datasets, and + // renderers... + int domainAxisCount = this.domainAxes.size(); + for (int i = 0; i < domainAxisCount; i++) { + Axis axis = (Axis) this.domainAxes.get(i); + if (axis != null) { + axis.setPlot(this); + axis.addChangeListener(this); + } + } + int rangeAxisCount = this.rangeAxes.size(); + for (int i = 0; i < rangeAxisCount; i++) { + Axis axis = (Axis) this.rangeAxes.get(i); + if (axis != null) { + axis.setPlot(this); + axis.addChangeListener(this); + } + } + int datasetCount = this.datasets.size(); + for (int i = 0; i < datasetCount; i++) { + Dataset dataset = (Dataset) this.datasets.get(i); + if (dataset != null) { + dataset.addChangeListener(this); + } + } + int rendererCount = this.renderers.size(); + for (int i = 0; i < rendererCount; i++) { + XYItemRenderer renderer = (XYItemRenderer) this.renderers.get(i); + if (renderer != null) { + renderer.addChangeListener(this); + } + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Zoomable.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Zoomable.java new file mode 100755 index 0000000..d48ee90 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/Zoomable.java @@ -0,0 +1,180 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * Zoomable.java + * ------------- + * + * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Rune Fauske; + * + * Changes + * ------- + * 12-Nov-2004 : Version 1 (DG); + * 26-Jan-2004 : Added getOrientation() method (DG); + * 04-Sep-2006 : Added credit for Rune Fauske, see patch 1050659 (DG); + * 21-Sep-2007 : Added new zooming methods with 'useAnchor' flag. This breaks + * the API, but is the cleanest way I can think of to fix a + * long-standing bug (DG); + * + */ + +package org.jfree.chart.plot; + +import java.awt.geom.Point2D; + +import org.jfree.chart.ChartPanel; + +/** + * A plot that is zoomable must implement this interface to provide a + * mechanism for the {@link ChartPanel} to control the zooming. + */ +public interface Zoomable { + + /** + * Returns true if the plot's domain is zoomable, and + * false otherwise. + * + * @return A boolean. + * + * @see #isRangeZoomable() + */ + public boolean isDomainZoomable(); + + /** + * Returns true if the plot's range is zoomable, and + * false otherwise. + * + * @return A boolean. + * + * @see #isDomainZoomable() + */ + public boolean isRangeZoomable(); + + /** + * Returns the orientation of the plot. + * + * @return The orientation. + */ + public PlotOrientation getOrientation(); + + /** + * Multiplies the range on the domain axis/axes by the specified factor. + * The source point can be used in some cases to identify a + * subplot, or to determine the center of zooming (refer to the + * documentation of the implementing class for details). + * + * @param factor the zoom factor. + * @param state the plot state. + * @param source the source point (in Java2D coordinates). + * + * @see #zoomRangeAxes(double, PlotRenderingInfo, Point2D) + */ + public void zoomDomainAxes(double factor, PlotRenderingInfo state, + Point2D source); + + /** + * Multiplies the range on the domain axis/axes by the specified factor. + * The source point can be used in some cases to identify a + * subplot, or to determine the center of zooming (refer to the + * documentation of the implementing class for details). + * + * @param factor the zoom factor. + * @param state the plot state. + * @param source the source point (in Java2D coordinates). + * @param useAnchor use source point as zoom anchor? + * + * @see #zoomRangeAxes(double, PlotRenderingInfo, Point2D, boolean) + * + * @since 1.0.7 + */ + public void zoomDomainAxes(double factor, PlotRenderingInfo state, + Point2D source, boolean useAnchor); + + /** + * Zooms in on the domain axes. The source point can be used + * in some cases to identify a subplot for zooming. + * + * @param lowerPercent the new lower bound. + * @param upperPercent the new upper bound. + * @param state the plot state. + * @param source the source point (in Java2D coordinates). + * + * @see #zoomRangeAxes(double, double, PlotRenderingInfo, Point2D) + */ + public void zoomDomainAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo state, Point2D source); + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * The source point can be used in some cases to identify a + * subplot, or to determine the center of zooming (refer to the + * documentation of the implementing class for details). + * + * @param factor the zoom factor. + * @param state the plot state. + * @param source the source point (in Java2D coordinates). + * + * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D) + */ + public void zoomRangeAxes(double factor, PlotRenderingInfo state, + Point2D source); + + /** + * Multiplies the range on the range axis/axes by the specified factor. + * The source point can be used in some cases to identify a + * subplot, or to determine the center of zooming (refer to the + * documentation of the implementing class for details). + * + * @param factor the zoom factor. + * @param state the plot state. + * @param source the source point (in Java2D coordinates). + * @param useAnchor use source point as zoom anchor? + * + * @see #zoomDomainAxes(double, PlotRenderingInfo, Point2D) + * + * @since 1.0.7 + */ + public void zoomRangeAxes(double factor, PlotRenderingInfo state, + Point2D source, boolean useAnchor); + + /** + * Zooms in on the range axes. The source point can be used + * in some cases to identify a subplot for zooming. + * + * @param lowerPercent the new lower bound. + * @param upperPercent the new upper bound. + * @param state the plot state. + * @param source the source point (in Java2D coordinates). + * + * @see #zoomDomainAxes(double, double, PlotRenderingInfo, Point2D) + */ + public void zoomRangeAxes(double lowerPercent, double upperPercent, + PlotRenderingInfo state, Point2D source); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/AbstractDialLayer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/AbstractDialLayer.java new file mode 100755 index 0000000..975aeba --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/AbstractDialLayer.java @@ -0,0 +1,220 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * AbstractDialLayer.java + * ---------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 06-Nov-2006 : Version 1 (DG); + * 17-Nov-2006 : Added visible flag (DG); + * 16-Oct-2007 : Implemented equals() and clone() (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import java.io.IOException; +import java.io.ObjectInputStream; +import java.util.Arrays; +import java.util.EventListener; +import java.util.List; + +import javax.swing.event.EventListenerList; + +import org.jfree.chart.HashUtilities; + +/** + * A base class that can be used to implement a {@link DialLayer}. It includes + * an event notification mechanism. + * + * @since 1.0.7 + */ +public abstract class AbstractDialLayer implements DialLayer { + + /** A flag that controls whether or not the layer is visible. */ + private boolean visible; + + /** Storage for registered listeners. */ + private transient EventListenerList listenerList; + + /** + * Creates a new instance. + */ + protected AbstractDialLayer() { + this.visible = true; + this.listenerList = new EventListenerList(); + } + + /** + * Returns true if this layer is visible (should be displayed), + * and false otherwise. + * + * @return A boolean. + * + * @see #setVisible(boolean) + */ + @Override + public boolean isVisible() { + return this.visible; + } + + /** + * Sets the flag that determines whether or not this layer is drawn by + * the plot, and sends a {@link DialLayerChangeEvent} to all registered + * listeners. + * + * @param visible the flag. + * + * @see #isVisible() + */ + public void setVisible(boolean visible) { + this.visible = visible; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof AbstractDialLayer)) { + return false; + } + AbstractDialLayer that = (AbstractDialLayer) obj; + return this.visible == that.visible; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 23; + result = HashUtilities.hashCode(result, this.visible); + return result; + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning this + * instance. + */ + @Override + public Object clone() throws CloneNotSupportedException { + AbstractDialLayer clone = (AbstractDialLayer) super.clone(); + // we don't clone the listeners + clone.listenerList = new EventListenerList(); + return clone; + } + + /** + * Registers an object for notification of changes to the dial layer. + * + * @param listener the object that is being registered. + * + * @see #removeChangeListener(DialLayerChangeListener) + */ + @Override + public void addChangeListener(DialLayerChangeListener listener) { + this.listenerList.add(DialLayerChangeListener.class, listener); + } + + /** + * Deregisters an object for notification of changes to the dial layer. + * + * @param listener the object to deregister. + * + * @see #addChangeListener(DialLayerChangeListener) + */ + @Override + public void removeChangeListener(DialLayerChangeListener listener) { + this.listenerList.remove(DialLayerChangeListener.class, listener); + } + + /** + * Returns true if the specified object is registered with + * the dataset as a listener. Most applications won't need to call this + * method, it exists mainly for use by unit testing code. + * + * @param listener the listener. + * + * @return A boolean. + */ + @Override + public boolean hasListener(EventListener listener) { + List list = Arrays.asList(this.listenerList.getListenerList()); + return list.contains(listener); + } + + /** + * Notifies all registered listeners that the dial layer has changed. + * The {@link DialLayerChangeEvent} provides information about the change. + * + * @param event information about the change to the axis. + */ + protected void notifyListeners(DialLayerChangeEvent event) { + Object[] listeners = this.listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == DialLayerChangeListener.class) { + ((DialLayerChangeListener) listeners[i + 1]).dialLayerChanged( + event); + } + } + } + + /** + * 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.listenerList = new EventListenerList(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/ArcDialFrame.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/ArcDialFrame.java new file mode 100755 index 0000000..d80b7a4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/ArcDialFrame.java @@ -0,0 +1,521 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * ArcDialFrame.java + * ----------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 08-Mar-2007 : Fix in hashCode() (DG); + * 17-Oct-2007 : Updated equals() (DG); + * 24-Oct-2007 : Added argument checks and API docs, and renamed + * StandardDialFrame --> ArcDialFrame (DG); + * + */ + +package org.jfree.chart.plot.dial; + +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.Arc2D; +import java.awt.geom.Area; +import java.awt.geom.GeneralPath; +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.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A standard frame for the {@link DialPlot} class. + * + * @since 1.0.7 + */ +public class ArcDialFrame extends AbstractDialLayer implements DialFrame, + Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + static final long serialVersionUID = -4089176959553523499L; + + /** + * The color used for the front of the panel. This field is transient + * because it requires special handling for serialization. + */ + private transient Paint backgroundPaint; + + /** + * The color used for the border around the window. This field is transient + * because it requires special handling for serialization. + */ + private transient Paint foregroundPaint; + + /** + * The stroke for drawing the frame outline. This field is transient + * because it requires special handling for serialization. + */ + private transient Stroke stroke; + + /** + * The start angle. + */ + private double startAngle; + + /** + * The end angle. + */ + private double extent; + + /** The inner radius, relative to the framing rectangle. */ + private double innerRadius; + + /** The outer radius, relative to the framing rectangle. */ + private double outerRadius; + + /** + * Creates a new instance of ArcDialFrame that spans + * 180 degrees. + */ + public ArcDialFrame() { + this(0, 180); + } + + /** + * Creates a new instance of ArcDialFrame that spans + * the arc specified. + * + * @param startAngle the startAngle (in degrees). + * @param extent the extent of the arc (in degrees, counter-clockwise). + */ + public ArcDialFrame(double startAngle, double extent) { + this.backgroundPaint = Color.gray; + this.foregroundPaint = new Color(100, 100, 150); + this.stroke = new BasicStroke(2.0f); + this.innerRadius = 0.25; + this.outerRadius = 0.75; + this.startAngle = startAngle; + this.extent = extent; + } + + /** + * Returns the background paint (never null). + * + * @return The background paint. + * + * @see #setBackgroundPaint(Paint) + */ + public Paint getBackgroundPaint() { + return this.backgroundPaint; + } + + /** + * Sets the background paint and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getBackgroundPaint() + */ + public void setBackgroundPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.backgroundPaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the foreground paint. + * + * @return The foreground paint (never null). + * + * @see #setForegroundPaint(Paint) + */ + public Paint getForegroundPaint() { + return this.foregroundPaint; + } + + /** + * Sets the foreground paint and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getForegroundPaint() + */ + public void setForegroundPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.foregroundPaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the stroke. + * + * @return The stroke (never null). + * + * @see #setStroke(Stroke) + */ + public Stroke getStroke() { + return this.stroke; + } + + /** + * Sets the stroke and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getStroke() + */ + public void setStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.stroke = stroke; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the inner radius, relative to the framing rectangle. + * + * @return The inner radius. + * + * @see #setInnerRadius(double) + */ + public double getInnerRadius() { + return this.innerRadius; + } + + /** + * Sets the inner radius and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param radius the inner radius. + * + * @see #getInnerRadius() + */ + public void setInnerRadius(double radius) { + if (radius < 0.0) { + throw new IllegalArgumentException("Negative 'radius' argument."); + } + this.innerRadius = radius; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the outer radius, relative to the framing rectangle. + * + * @return The outer radius. + * + * @see #setOuterRadius(double) + */ + public double getOuterRadius() { + return this.outerRadius; + } + + /** + * Sets the outer radius and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param radius the outer radius. + * + * @see #getOuterRadius() + */ + public void setOuterRadius(double radius) { + if (radius < 0.0) { + throw new IllegalArgumentException("Negative 'radius' argument."); + } + this.outerRadius = radius; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the start angle. + * + * @return The start angle. + * + * @see #setStartAngle(double) + */ + public double getStartAngle() { + return this.startAngle; + } + + /** + * Sets the start angle and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param angle the angle. + * + * @see #getStartAngle() + */ + public void setStartAngle(double angle) { + this.startAngle = angle; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the extent. + * + * @return The extent. + * + * @see #setExtent(double) + */ + public double getExtent() { + return this.extent; + } + + /** + * Sets the extent and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param extent the extent. + * + * @see #getExtent() + */ + public void setExtent(double extent) { + this.extent = extent; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the shape for the window for this dial. Some dial layers will + * request that their drawing be clipped within this window. + * + * @param frame the reference frame (null not permitted). + * + * @return The shape of the dial's window. + */ + @Override + public Shape getWindow(Rectangle2D frame) { + + Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame, + this.innerRadius, this.innerRadius); + Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame, + this.outerRadius, this.outerRadius); + Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle, + this.extent, Arc2D.OPEN); + Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle + + this.extent, -this.extent, Arc2D.OPEN); + GeneralPath p = new GeneralPath(); + Point2D point1 = inner.getStartPoint(); + p.moveTo((float) point1.getX(), (float) point1.getY()); + p.append(inner, true); + p.append(outer, true); + p.closePath(); + return p; + + } + + /** + * Returns the outer window. + * + * @param frame the frame. + * + * @return The outer window. + */ + protected Shape getOuterWindow(Rectangle2D frame) { + double radiusMargin = 0.02; + double angleMargin = 1.5; + Rectangle2D innerFrame = DialPlot.rectangleByRadius(frame, + this.innerRadius - radiusMargin, this.innerRadius + - radiusMargin); + Rectangle2D outerFrame = DialPlot.rectangleByRadius(frame, + this.outerRadius + radiusMargin, this.outerRadius + + radiusMargin); + Arc2D inner = new Arc2D.Double(innerFrame, this.startAngle + - angleMargin, this.extent + 2 * angleMargin, Arc2D.OPEN); + Arc2D outer = new Arc2D.Double(outerFrame, this.startAngle + + angleMargin + this.extent, -this.extent - 2 * angleMargin, + Arc2D.OPEN); + GeneralPath p = new GeneralPath(); + Point2D point1 = inner.getStartPoint(); + p.moveTo((float) point1.getX(), (float) point1.getY()); + p.append(inner, true); + p.append(outer, true); + p.closePath(); + return p; + } + + /** + * Draws the frame. + * + * @param g2 the graphics target. + * @param plot the plot. + * @param frame the dial's reference frame. + * @param view the dial's view rectangle. + */ + @Override + public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, + Rectangle2D view) { + + Shape window = getWindow(frame); + Shape outerWindow = getOuterWindow(frame); + + Area area1 = new Area(outerWindow); + Area area2 = new Area(window); + area1.subtract(area2); + g2.setPaint(Color.lightGray); + g2.fill(area1); + + g2.setStroke(this.stroke); + g2.setPaint(this.foregroundPaint); + g2.draw(window); + g2.draw(outerWindow); + + } + + /** + * Returns false to indicate that this dial layer is not + * clipped to the dial window. + * + * @return false. + */ + @Override + public boolean isClippedToWindow() { + return false; + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ArcDialFrame)) { + return false; + } + ArcDialFrame that = (ArcDialFrame) obj; + if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { + return false; + } + if (!PaintUtilities.equal(this.foregroundPaint, that.foregroundPaint)) { + return false; + } + if (this.startAngle != that.startAngle) { + return false; + } + if (this.extent != that.extent) { + return false; + } + if (this.innerRadius != that.innerRadius) { + return false; + } + if (this.outerRadius != that.outerRadius) { + return false; + } + if (!this.stroke.equals(that.stroke)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return The hash code. + */ + @Override + public int hashCode() { + int result = 193; + long temp = Double.doubleToLongBits(this.startAngle); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.extent); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.innerRadius); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.outerRadius); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + result = 37 * result + HashUtilities.hashCodeForPaint( + this.backgroundPaint); + result = 37 * result + HashUtilities.hashCodeForPaint( + this.foregroundPaint); + result = 37 * result + this.stroke.hashCode(); + return result; + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if any attribute of this instance + * cannot be cloned. + */ + @Override + 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.backgroundPaint, stream); + SerialUtilities.writePaint(this.foregroundPaint, 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.backgroundPaint = SerialUtilities.readPaint(stream); + this.foregroundPaint = SerialUtilities.readPaint(stream); + this.stroke = SerialUtilities.readStroke(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialBackground.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialBackground.java new file mode 100755 index 0000000..dfcc159 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialBackground.java @@ -0,0 +1,272 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * DialBackground.java + * ------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 16-Oct-2007 : The equals() method needs to call super.equals() (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Paint; +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.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.StandardGradientPaintTransformer; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A regular dial layer that can be used to draw the background for a dial. + * + * @since 1.0.7 + */ +public class DialBackground extends AbstractDialLayer implements DialLayer, + Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + static final long serialVersionUID = -9019069533317612375L; + + /** + * The background paint. This field is transient because serialization + * requires special handling. + */ + private transient Paint paint; + + /** + * The transformer used when the background paint is an instance of + * GradientPaint. + */ + private GradientPaintTransformer gradientPaintTransformer; + + /** + * Creates a new instance of DialBackground. The + * default background paint is Color.white. + */ + public DialBackground() { + this(Color.white); + } + + /** + * Creates a new instance of DialBackground. The + * + * @param paint the paint (null not permitted). + * + * @throws IllegalArgumentException if paint is + * null. + */ + public DialBackground(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.paint = paint; + this.gradientPaintTransformer = new StandardGradientPaintTransformer(); + } + + /** + * Returns the paint used to fill the background. + * + * @return The paint (never null). + * + * @see #setPaint(Paint) + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Sets the paint for the dial background and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getPaint() + */ + public void setPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.paint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the transformer used to adjust the coordinates of any + * GradientPaint instance used for the background paint. + * + * @return The transformer (never null). + * + * @see #setGradientPaintTransformer(GradientPaintTransformer) + */ + public GradientPaintTransformer getGradientPaintTransformer() { + return this.gradientPaintTransformer; + } + + /** + * Sets the transformer used to adjust the coordinates of any + * GradientPaint instance used for the background paint, and + * sends a {@link DialLayerChangeEvent} to all registered listeners. + * + * @param t the transformer (null not permitted). + * + * @see #getGradientPaintTransformer() + */ + public void setGradientPaintTransformer(GradientPaintTransformer t) { + ParamChecks.nullNotPermitted(t, "t"); + this.gradientPaintTransformer = t; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns true to indicate that this layer should be + * clipped within the dial window. + * + * @return true. + */ + @Override + public boolean isClippedToWindow() { + return true; + } + + /** + * Draws the background to the specified graphics device. If the dial + * frame specifies a window, the clipping region will already have been + * set to this window before this method is called. + * + * @param g2 the graphics device (null not permitted). + * @param plot the plot (ignored here). + * @param frame the dial frame (ignored here). + * @param view the view rectangle (null not permitted). + */ + @Override + public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, + Rectangle2D view) { + + Paint p = this.paint; + if (p instanceof GradientPaint) { + p = this.gradientPaintTransformer.transform((GradientPaint) p, + view); + } + g2.setPaint(p); + g2.fill(view); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DialBackground)) { + return false; + } + DialBackground that = (DialBackground) obj; + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + if (!this.gradientPaintTransformer.equals( + that.gradientPaintTransformer)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return The hash code. + */ + @Override + public int hashCode() { + int result = 193; + result = 37 * result + HashUtilities.hashCodeForPaint(this.paint); + result = 37 * result + this.gradientPaintTransformer.hashCode(); + return result; + } + + /** + * Returns a clone of this instance. + * + * @return The clone. + * + * @throws CloneNotSupportedException if some attribute of this instance + * cannot be cloned. + */ + @Override + 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialCap.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialCap.java new file mode 100755 index 0000000..6c500ed --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialCap.java @@ -0,0 +1,342 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------ + * DialCap.java + * ------------ + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 17-Oct-2007 : Updated equals() method (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Stroke; +import java.awt.geom.Ellipse2D; +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.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A regular dial layer that can be used to draw a cap over the center of + * the dial (the base of the dial pointer(s)). + * + * @since 1.0.7 + */ +public class DialCap extends AbstractDialLayer implements DialLayer, Cloneable, + PublicCloneable, Serializable { + + /** For serialization. */ + static final long serialVersionUID = -2929484264982524463L; + + /** + * The radius of the cap, as a percentage of the framing rectangle. + */ + private double radius; + + /** + * The fill paint. This field is transient because it requires special + * handling for serialization. + */ + private transient Paint fillPaint; + + /** + * The paint used to draw the cap outline (this should never be + * null). This field is transient because it requires + * special handling for serialization. + */ + private transient Paint outlinePaint; + + /** + * The stroke used to draw the cap outline (this should never be + * null). This field is transient because it requires + * special handling for serialization. + */ + private transient Stroke outlineStroke; + + /** + * Creates a new instance of StandardDialBackground. The + * default background paint is Color.white. + */ + public DialCap() { + this.radius = 0.05; + this.fillPaint = Color.white; + this.outlinePaint = Color.black; + this.outlineStroke = new BasicStroke(2.0f); + } + + /** + * Returns the radius of the cap, as a percentage of the dial's framing + * rectangle. + * + * @return The radius. + * + * @see #setRadius(double) + */ + public double getRadius() { + return this.radius; + } + + /** + * Sets the radius of the cap, as a percentage of the dial's framing + * rectangle, and sends a {@link DialLayerChangeEvent} to all registered + * listeners. + * + * @param radius the radius (must be greater than zero). + * + * @see #getRadius() + */ + public void setRadius(double radius) { + if (radius <= 0.0) { + throw new IllegalArgumentException("Requires radius > 0.0."); + } + this.radius = radius; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the paint used to fill the cap. + * + * @return The paint (never null). + * + * @see #setFillPaint(Paint) + */ + public Paint getFillPaint() { + return this.fillPaint; + } + + /** + * Sets the paint for the cap background and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getFillPaint() + */ + public void setFillPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.fillPaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the paint used to draw the outline of the cap. + * + * @return The paint (never null). + * + * @see #setOutlinePaint(Paint) + */ + public Paint getOutlinePaint() { + return this.outlinePaint; + } + + /** + * Sets the paint used to draw the outline of the cap and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getOutlinePaint() + */ + public void setOutlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.outlinePaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the stroke used to draw the outline of the cap. + * + * @return The stroke (never null). + * + * @see #setOutlineStroke(Stroke) + */ + public Stroke getOutlineStroke() { + return this.outlineStroke; + } + + /** + * Sets the stroke used to draw the outline of the cap and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getOutlineStroke() + */ + public void setOutlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.outlineStroke = stroke; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns true to indicate that this layer should be + * clipped within the dial window. + * + * @return true. + */ + @Override + public boolean isClippedToWindow() { + return true; + } + + /** + * Draws the background to the specified graphics device. If the dial + * frame specifies a window, the clipping region will already have been + * set to this window before this method is called. + * + * @param g2 the graphics device (null not permitted). + * @param plot the plot (ignored here). + * @param frame the dial frame (ignored here). + * @param view the view rectangle (null not permitted). + */ + @Override + public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, + Rectangle2D view) { + + g2.setPaint(this.fillPaint); + + Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, + this.radius); + Ellipse2D e = new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(), + f.getHeight()); + g2.fill(e); + g2.setPaint(this.outlinePaint); + g2.setStroke(this.outlineStroke); + g2.draw(e); + + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DialCap)) { + return false; + } + DialCap that = (DialCap) obj; + if (this.radius != that.radius) { + return false; + } + if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { + return false; + } + if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { + return false; + } + if (!this.outlineStroke.equals(that.outlineStroke)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return The hash code. + */ + @Override + public int hashCode() { + int result = 193; + result = 37 * result + HashUtilities.hashCodeForPaint(this.fillPaint); + result = 37 * result + HashUtilities.hashCodeForPaint( + this.outlinePaint); + result = 37 * result + this.outlineStroke.hashCode(); + return result; + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if some attribute of the cap cannot + * be cloned. + */ + @Override + 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.fillPaint, stream); + SerialUtilities.writePaint(this.outlinePaint, stream); + SerialUtilities.writeStroke(this.outlineStroke, 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.fillPaint = SerialUtilities.readPaint(stream); + this.outlinePaint = SerialUtilities.readPaint(stream); + this.outlineStroke = SerialUtilities.readStroke(stream); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialFrame.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialFrame.java new file mode 100755 index 0000000..3df2716 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialFrame.java @@ -0,0 +1,70 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * DialFrame.java + * -------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import java.awt.Shape; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +/** + * A dial frame is the face plate for a dial plot - it is always drawn last. + * JFreeChart includes a couple of implementations of this interface + * ({@link StandardDialFrame} and {@link ArcDialFrame}). + *

+ * Classes that implement this interface should be {@link Serializable}, + * otherwise chart serialization may fail. + * + * @since 1.0.7 + */ +public interface DialFrame extends DialLayer { + + /** + * Returns the shape of the viewing window for the dial, or + * null if the dial is completely open. Other layers in the + * plot will rely on their drawing to be clipped within this window. + * + * @param frame the reference frame for the dial. + * + * @return The window. + */ + public Shape getWindow(Rectangle2D frame); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialLayer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialLayer.java new file mode 100755 index 0000000..c148150 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialLayer.java @@ -0,0 +1,118 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * DialLayer.java + * -------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; +import java.util.EventListener; + +/** + * A dial layer draws itself within a reference frame. The view frame is a + * subset of the reference frame, and defines the area that is actually + * visible. + *

+ * Classes that implement this interface should be {@link Serializable}, + * otherwise chart serialization may fail. + * + * @since 1.0.7 + */ +public interface DialLayer { + + /** + * Returns a flag that indicates whether or not the layer is visible. + * + * @return A boolean. + */ + public boolean isVisible(); + + /** + * Registers a listener with this layer, so that it receives notification + * of changes to this layer. + * + * @param listener the listener. + */ + public void addChangeListener(DialLayerChangeListener listener); + + /** + * Deregisters a listener, so that it no longer receives notification of + * changes to this layer. + * + * @param listener the listener. + */ + public void removeChangeListener(DialLayerChangeListener listener); + + /** + * Returns true if the specified listener is currently + * registered with the this layer. + * + * @param listener the listener. + * + * @return A boolean. + */ + public boolean hasListener(EventListener listener); + + /** + * Returns true if the drawing should be clipped to the + * dial window (which is defined by the {@link DialFrame}), and + * false otherwise. + * + * @return A boolean. + */ + public boolean isClippedToWindow(); + + /** + * Draws the content of this layer. + * + * @param g2 the graphics target (null not permitted). + * @param plot the plot (typically this should not be null, + * but for a layer that doesn't need to reference the plot, it may + * be permitted). + * @param frame the reference frame for the dial's geometry + * (null not permitted). This is typically larger than + * the visible area of the dial (see the next parameter). + * @param view the visible area for the dial (null not + * permitted). + */ + public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, + Rectangle2D view); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialLayerChangeEvent.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialLayerChangeEvent.java new file mode 100755 index 0000000..a93f28a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialLayerChangeEvent.java @@ -0,0 +1,75 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * DialLayerChangeEvent.java + * ------------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 06-Nov-2006 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import org.jfree.chart.event.ChartChangeEvent; + +/** + * An event that can be forwarded to any {@link DialLayerChangeListener} to + * signal a change to a {@link DialLayer}. + * + * @since 1.0.7 + */ +public class DialLayerChangeEvent extends ChartChangeEvent { + + /** The dial layer that generated the event. */ + private DialLayer layer; + + /** + * Creates a new instance. + * + * @param layer the dial layer that generated the event. + */ + public DialLayerChangeEvent(DialLayer layer) { + super(layer); + this.layer = layer; + } + + /** + * Returns the layer that generated the event. + * + * @return The layer that generated the event. + */ + public DialLayer getDialLayer() { + return this.layer; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialLayerChangeListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialLayerChangeListener.java new file mode 100755 index 0000000..5b3fd99 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialLayerChangeListener.java @@ -0,0 +1,62 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * DialLayerChangeListener.java + * ---------------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 06-Nov-2006 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import java.util.EventListener; + +/** + * The interface via which an object is notified of changes to a + * {@link DialLayer}. The {@link DialPlot} class listens for changes to its + * layers in this way. + * + * @since 1.0.7 + */ +public interface DialLayerChangeListener extends EventListener { + + /** + * A call-back method for receiving notification of a change to a + * {@link DialLayer}. + * + * @param event the event. + */ + public void dialLayerChanged(DialLayerChangeEvent event); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialPlot.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialPlot.java new file mode 100755 index 0000000..3b87e94 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialPlot.java @@ -0,0 +1,835 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * DialPlot.java + * ------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 08-Mar-2007 : Fix in hashCode() (DG); + * 17-Oct-2007 : Fixed listener registration/deregistration bugs (DG); + * 24-Oct-2007 : Maintain pointers in their own list, so they can be + * drawn after other layers (DG); + * 15-Feb-2008 : Fixed clipping bug (1873160) (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.PlotState; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.ValueDataset; +import org.jfree.util.ObjectList; +import org.jfree.util.ObjectUtilities; + +/** + * A dial plot composed of user-definable layers. + * The example shown here is generated by the DialDemo2.java + * program included in the JFreeChart Demo Collection: + *

+ * DialPlotSample.png + * + * @since 1.0.7 + */ +public class DialPlot extends Plot implements DialLayerChangeListener { + + /** + * The background layer (optional). + */ + private DialLayer background; + + /** + * The needle cap (optional). + */ + private DialLayer cap; + + /** + * The dial frame. + */ + private DialFrame dialFrame; + + /** + * The dataset(s) for the dial plot. + */ + private ObjectList datasets; + + /** + * The scale(s) for the dial plot. + */ + private ObjectList scales; + + /** Storage for keys that map datasets to scales. */ + private ObjectList datasetToScaleMap; + + /** + * The drawing layers for the dial plot. + */ + private List layers; + + /** + * The pointer(s) for the dial. + */ + private List pointers; + + /** + * The x-coordinate for the view window. + */ + private double viewX; + + /** + * The y-coordinate for the view window. + */ + private double viewY; + + /** + * The width of the view window, expressed as a percentage. + */ + private double viewW; + + /** + * The height of the view window, expressed as a percentage. + */ + private double viewH; + + /** + * Creates a new instance of DialPlot. + */ + public DialPlot() { + this(null); + } + + /** + * Creates a new instance of DialPlot. + * + * @param dataset the dataset (null permitted). + */ + public DialPlot(ValueDataset dataset) { + this.background = null; + this.cap = null; + this.dialFrame = new ArcDialFrame(); + this.datasets = new ObjectList(); + if (dataset != null) { + setDataset(dataset); + } + this.scales = new ObjectList(); + this.datasetToScaleMap = new ObjectList(); + this.layers = new java.util.ArrayList(); + this.pointers = new java.util.ArrayList(); + this.viewX = 0.0; + this.viewY = 0.0; + this.viewW = 1.0; + this.viewH = 1.0; + } + + /** + * Returns the background. + * + * @return The background (possibly null). + * + * @see #setBackground(DialLayer) + */ + public DialLayer getBackground() { + return this.background; + } + + /** + * Sets the background layer and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param background the background layer (null permitted). + * + * @see #getBackground() + */ + public void setBackground(DialLayer background) { + if (this.background != null) { + this.background.removeChangeListener(this); + } + this.background = background; + if (background != null) { + background.addChangeListener(this); + } + fireChangeEvent(); + } + + /** + * Returns the cap. + * + * @return The cap (possibly null). + * + * @see #setCap(DialLayer) + */ + public DialLayer getCap() { + return this.cap; + } + + /** + * Sets the cap and sends a {@link PlotChangeEvent} to all registered + * listeners. + * + * @param cap the cap (null permitted). + * + * @see #getCap() + */ + public void setCap(DialLayer cap) { + if (this.cap != null) { + this.cap.removeChangeListener(this); + } + this.cap = cap; + if (cap != null) { + cap.addChangeListener(this); + } + fireChangeEvent(); + } + + /** + * Returns the dial's frame. + * + * @return The dial's frame (never null). + * + * @see #setDialFrame(DialFrame) + */ + public DialFrame getDialFrame() { + return this.dialFrame; + } + + /** + * Sets the dial's frame and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param frame the frame (null not permitted). + * + * @see #getDialFrame() + */ + public void setDialFrame(DialFrame frame) { + ParamChecks.nullNotPermitted(frame, "frame"); + this.dialFrame.removeChangeListener(this); + this.dialFrame = frame; + frame.addChangeListener(this); + fireChangeEvent(); + } + + /** + * Returns the x-coordinate of the viewing rectangle. This is specified + * in the range 0.0 to 1.0, relative to the dial's framing rectangle. + * + * @return The x-coordinate of the viewing rectangle. + * + * @see #setView(double, double, double, double) + */ + public double getViewX() { + return this.viewX; + } + + /** + * Returns the y-coordinate of the viewing rectangle. This is specified + * in the range 0.0 to 1.0, relative to the dial's framing rectangle. + * + * @return The y-coordinate of the viewing rectangle. + * + * @see #setView(double, double, double, double) + */ + public double getViewY() { + return this.viewY; + } + + /** + * Returns the width of the viewing rectangle. This is specified + * in the range 0.0 to 1.0, relative to the dial's framing rectangle. + * + * @return The width of the viewing rectangle. + * + * @see #setView(double, double, double, double) + */ + public double getViewWidth() { + return this.viewW; + } + + /** + * Returns the height of the viewing rectangle. This is specified + * in the range 0.0 to 1.0, relative to the dial's framing rectangle. + * + * @return The height of the viewing rectangle. + * + * @see #setView(double, double, double, double) + */ + public double getViewHeight() { + return this.viewH; + } + + /** + * Sets the viewing rectangle, relative to the dial's framing rectangle, + * and sends a {@link PlotChangeEvent} to all registered listeners. + * + * @param x the x-coordinate (in the range 0.0 to 1.0). + * @param y the y-coordinate (in the range 0.0 to 1.0). + * @param w the width (in the range 0.0 to 1.0). + * @param h the height (in the range 0.0 to 1.0). + * + * @see #getViewX() + * @see #getViewY() + * @see #getViewWidth() + * @see #getViewHeight() + */ + public void setView(double x, double y, double w, double h) { + this.viewX = x; + this.viewY = y; + this.viewW = w; + this.viewH = h; + fireChangeEvent(); + } + + /** + * Adds a layer to the plot and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param layer the layer (null not permitted). + */ + public void addLayer(DialLayer layer) { + ParamChecks.nullNotPermitted(layer, "layer"); + this.layers.add(layer); + layer.addChangeListener(this); + fireChangeEvent(); + } + + /** + * Returns the index for the specified layer. + * + * @param layer the layer (null not permitted). + * + * @return The layer index. + */ + public int getLayerIndex(DialLayer layer) { + ParamChecks.nullNotPermitted(layer, "layer"); + return this.layers.indexOf(layer); + } + + /** + * Removes the layer at the specified index and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the index. + */ + public void removeLayer(int index) { + DialLayer layer = (DialLayer) this.layers.get(index); + if (layer != null) { + layer.removeChangeListener(this); + } + this.layers.remove(index); + fireChangeEvent(); + } + + /** + * Removes the specified layer and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param layer the layer (null not permitted). + */ + public void removeLayer(DialLayer layer) { + // defer argument checking + removeLayer(getLayerIndex(layer)); + } + + /** + * Adds a pointer to the plot and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param pointer the pointer (null not permitted). + */ + public void addPointer(DialPointer pointer) { + ParamChecks.nullNotPermitted(pointer, "pointer"); + this.pointers.add(pointer); + pointer.addChangeListener(this); + fireChangeEvent(); + } + + /** + * Returns the index for the specified pointer. + * + * @param pointer the pointer (null not permitted). + * + * @return The pointer index. + */ + public int getPointerIndex(DialPointer pointer) { + ParamChecks.nullNotPermitted(pointer, "pointer"); + return this.pointers.indexOf(pointer); + } + + /** + * Removes the pointer at the specified index and sends a + * {@link PlotChangeEvent} to all registered listeners. + * + * @param index the index. + */ + public void removePointer(int index) { + DialPointer pointer = (DialPointer) this.pointers.get(index); + if (pointer != null) { + pointer.removeChangeListener(this); + } + this.pointers.remove(index); + fireChangeEvent(); + } + + /** + * Removes the specified pointer and sends a {@link PlotChangeEvent} to all + * registered listeners. + * + * @param pointer the pointer (null not permitted). + */ + public void removePointer(DialPointer pointer) { + // defer argument checking + removeLayer(getPointerIndex(pointer)); + } + + /** + * Returns the dial pointer that is associated with the specified + * dataset, or null. + * + * @param datasetIndex the dataset index. + * + * @return The pointer. + */ + public DialPointer getPointerForDataset(int datasetIndex) { + DialPointer result = null; + Iterator iterator = this.pointers.iterator(); + while (iterator.hasNext()) { + DialPointer p = (DialPointer) iterator.next(); + if (p.getDatasetIndex() == datasetIndex) { + return p; + } + } + return result; + } + + /** + * Returns the primary dataset for the plot. + * + * @return The primary dataset (possibly null). + */ + public ValueDataset getDataset() { + return getDataset(0); + } + + /** + * Returns the dataset at the given index. + * + * @param index the dataset index. + * + * @return The dataset (possibly null). + */ + public ValueDataset getDataset(int index) { + ValueDataset result = null; + if (this.datasets.size() > index) { + result = (ValueDataset) this.datasets.get(index); + } + return result; + } + + /** + * Sets the dataset for the plot, replacing the existing dataset, if there + * is one, and sends a {@link PlotChangeEvent} to all registered + * listeners. + * + * @param dataset the dataset (null permitted). + */ + public void setDataset(ValueDataset dataset) { + setDataset(0, dataset); + } + + /** + * Sets a dataset for the plot. + * + * @param index the dataset index. + * @param dataset the dataset (null permitted). + */ + public void setDataset(int index, ValueDataset dataset) { + + ValueDataset existing = (ValueDataset) this.datasets.get(index); + if (existing != null) { + existing.removeChangeListener(this); + } + this.datasets.set(index, dataset); + if (dataset != null) { + dataset.addChangeListener(this); + } + + // send a dataset change event to self... + DatasetChangeEvent event = new DatasetChangeEvent(this, dataset); + datasetChanged(event); + + } + + /** + * Returns the number of datasets. + * + * @return The number of datasets. + */ + public int getDatasetCount() { + return this.datasets.size(); + } + + /** + * Draws the plot. This method is usually called by the {@link JFreeChart} + * instance that manages the plot. + * + * @param g2 the graphics target. + * @param area the area in which the plot should be drawn. + * @param anchor the anchor point (typically the last point that the + * mouse clicked on, null is permitted). + * @param parentState the state for the parent plot (if any). + * @param info used to collect plot rendering info (null + * permitted). + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area, Point2D anchor, + PlotState parentState, PlotRenderingInfo info) { + + Shape origClip = g2.getClip(); + g2.setClip(area); + + // first, expand the viewing area into a drawing frame + Rectangle2D frame = viewToFrame(area); + + // draw the background if there is one... + if (this.background != null && this.background.isVisible()) { + if (this.background.isClippedToWindow()) { + Shape savedClip = g2.getClip(); + g2.clip(this.dialFrame.getWindow(frame)); + this.background.draw(g2, this, frame, area); + g2.setClip(savedClip); + } + else { + this.background.draw(g2, this, frame, area); + } + } + + Iterator iterator = this.layers.iterator(); + while (iterator.hasNext()) { + DialLayer current = (DialLayer) iterator.next(); + if (current.isVisible()) { + if (current.isClippedToWindow()) { + Shape savedClip = g2.getClip(); + g2.clip(this.dialFrame.getWindow(frame)); + current.draw(g2, this, frame, area); + g2.setClip(savedClip); + } + else { + current.draw(g2, this, frame, area); + } + } + } + + // draw the pointers + iterator = this.pointers.iterator(); + while (iterator.hasNext()) { + DialPointer current = (DialPointer) iterator.next(); + if (current.isVisible()) { + if (current.isClippedToWindow()) { + Shape savedClip = g2.getClip(); + g2.clip(this.dialFrame.getWindow(frame)); + current.draw(g2, this, frame, area); + g2.setClip(savedClip); + } + else { + current.draw(g2, this, frame, area); + } + } + } + + // draw the cap if there is one... + if (this.cap != null && this.cap.isVisible()) { + if (this.cap.isClippedToWindow()) { + Shape savedClip = g2.getClip(); + g2.clip(this.dialFrame.getWindow(frame)); + this.cap.draw(g2, this, frame, area); + g2.setClip(savedClip); + } + else { + this.cap.draw(g2, this, frame, area); + } + } + + if (this.dialFrame.isVisible()) { + this.dialFrame.draw(g2, this, frame, area); + } + + g2.setClip(origClip); + + } + + /** + * Returns the frame surrounding the specified view rectangle. + * + * @param view the view rectangle (null not permitted). + * + * @return The frame rectangle. + */ + private Rectangle2D viewToFrame(Rectangle2D view) { + double width = view.getWidth() / this.viewW; + double height = view.getHeight() / this.viewH; + double x = view.getX() - (width * this.viewX); + double y = view.getY() - (height * this.viewY); + return new Rectangle2D.Double(x, y, width, height); + } + + /** + * Returns the value from the specified dataset. + * + * @param datasetIndex the dataset index. + * + * @return The data value. + */ + public double getValue(int datasetIndex) { + double result = Double.NaN; + ValueDataset dataset = getDataset(datasetIndex); + if (dataset != null) { + Number n = dataset.getValue(); + if (n != null) { + result = n.doubleValue(); + } + } + return result; + } + + /** + * Adds a dial scale to the plot and sends a {@link PlotChangeEvent} to + * all registered listeners. + * + * @param index the scale index. + * @param scale the scale (null not permitted). + */ + public void addScale(int index, DialScale scale) { + ParamChecks.nullNotPermitted(scale, "scale"); + DialScale existing = (DialScale) this.scales.get(index); + if (existing != null) { + removeLayer(existing); + } + this.layers.add(scale); + this.scales.set(index, scale); + scale.addChangeListener(this); + fireChangeEvent(); + } + + /** + * Returns the scale at the given index. + * + * @param index the scale index. + * + * @return The scale (possibly null). + */ + public DialScale getScale(int index) { + DialScale result = null; + if (this.scales.size() > index) { + result = (DialScale) this.scales.get(index); + } + return result; + } + + /** + * Maps a dataset to a particular scale. + * + * @param index the dataset index (zero-based). + * @param scaleIndex the scale index (zero-based). + */ + public void mapDatasetToScale(int index, int scaleIndex) { + this.datasetToScaleMap.set(index, new Integer(scaleIndex)); + fireChangeEvent(); + } + + /** + * Returns the dial scale for a specific dataset. + * + * @param datasetIndex the dataset index. + * + * @return The dial scale. + */ + public DialScale getScaleForDataset(int datasetIndex) { + DialScale result = (DialScale) this.scales.get(0); + Integer scaleIndex = (Integer) this.datasetToScaleMap.get(datasetIndex); + if (scaleIndex != null) { + result = getScale(scaleIndex.intValue()); + } + return result; + } + + /** + * A utility method that computes a rectangle using relative radius values. + * + * @param rect the reference rectangle (null not permitted). + * @param radiusW the width radius (must be > 0.0) + * @param radiusH the height radius. + * + * @return A new rectangle. + */ + public static Rectangle2D rectangleByRadius(Rectangle2D rect, + double radiusW, double radiusH) { + ParamChecks.nullNotPermitted(rect, "rect"); + double x = rect.getCenterX(); + double y = rect.getCenterY(); + double w = rect.getWidth() * radiusW; + double h = rect.getHeight() * radiusH; + return new Rectangle2D.Double(x - w / 2.0, y - h / 2.0, w, h); + } + + /** + * Receives notification when a layer has changed, and responds by + * forwarding a {@link PlotChangeEvent} to all registered listeners. + * + * @param event the event. + */ + @Override + public void dialLayerChanged(DialLayerChangeEvent event) { + fireChangeEvent(); + } + + /** + * Tests this DialPlot instance for equality with an + * arbitrary object. The plot's dataset(s) is (are) not included in + * the test. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DialPlot)) { + return false; + } + DialPlot that = (DialPlot) obj; + if (!ObjectUtilities.equal(this.background, that.background)) { + return false; + } + if (!ObjectUtilities.equal(this.cap, that.cap)) { + return false; + } + if (!this.dialFrame.equals(that.dialFrame)) { + return false; + } + if (this.viewX != that.viewX) { + return false; + } + if (this.viewY != that.viewY) { + return false; + } + if (this.viewW != that.viewW) { + return false; + } + if (this.viewH != that.viewH) { + return false; + } + if (!this.layers.equals(that.layers)) { + return false; + } + if (!this.pointers.equals(that.pointers)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return The hash code. + */ + @Override + public int hashCode() { + int result = 193; + result = 37 * result + ObjectUtilities.hashCode(this.background); + result = 37 * result + ObjectUtilities.hashCode(this.cap); + result = 37 * result + this.dialFrame.hashCode(); + long temp = Double.doubleToLongBits(this.viewX); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.viewY); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.viewW); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.viewH); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + /** + * Returns the plot type. + * + * @return "DialPlot" + */ + @Override + public String getPlotType() { + return "DialPlot"; + } + + /** + * 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(); + } + + /** + * 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(); + } + + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialPointer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialPointer.java new file mode 100755 index 0000000..7287b24 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialPointer.java @@ -0,0 +1,656 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * DialPointer.java + * ---------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 17-Oct-2007 : Added equals() overrides (DG); + * 24-Oct-2007 : Implemented PublicCloneable, changed default radius, + * and added argument checks (DG); + * 23-Nov-2007 : Added fillPaint and outlinePaint attributes to + * DialPointer.Pointer (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Stroke; +import java.awt.geom.Arc2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; +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.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A base class for the pointer in a {@link DialPlot}. + * + * @since 1.0.7 + */ +public abstract class DialPointer extends AbstractDialLayer + implements DialLayer, Cloneable, PublicCloneable, Serializable { + + /** The needle radius. */ + double radius; + + /** + * The dataset index for the needle. + */ + int datasetIndex; + + /** + * Creates a new DialPointer instance. + */ + protected DialPointer() { + this(0); + } + + /** + * Creates a new pointer for the specified dataset. + * + * @param datasetIndex the dataset index. + */ + protected DialPointer(int datasetIndex) { + this.radius = 0.9; + this.datasetIndex = datasetIndex; + } + + /** + * Returns the dataset index that the pointer maps to. + * + * @return The dataset index. + * + * @see #getDatasetIndex() + */ + public int getDatasetIndex() { + return this.datasetIndex; + } + + /** + * Sets the dataset index for the pointer and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param index the index. + * + * @see #getDatasetIndex() + */ + public void setDatasetIndex(int index) { + this.datasetIndex = index; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the radius of the pointer, as a percentage of the dial's + * framing rectangle. + * + * @return The radius. + * + * @see #setRadius(double) + */ + public double getRadius() { + return this.radius; + } + + /** + * Sets the radius of the pointer and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param radius the radius. + * + * @see #getRadius() + */ + public void setRadius(double radius) { + this.radius = radius; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns true to indicate that this layer should be + * clipped within the dial window. + * + * @return true. + */ + @Override + public boolean isClippedToWindow() { + return true; + } + + /** + * Checks this instance for equality with an arbitrary object. + * + * @param obj the object (null not permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DialPointer)) { + return false; + } + DialPointer that = (DialPointer) obj; + if (this.datasetIndex != that.datasetIndex) { + return false; + } + if (this.radius != that.radius) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 23; + result = HashUtilities.hashCode(result, this.radius); + return result; + } + + /** + * Returns a clone of the pointer. + * + * @return a clone. + * + * @throws CloneNotSupportedException if one of the attributes cannot + * be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * A dial pointer that draws a thin line (like a pin). + */ + public static class Pin extends DialPointer { + + /** For serialization. */ + static final long serialVersionUID = -8445860485367689750L; + + /** The paint. */ + private transient Paint paint; + + /** The stroke. */ + private transient Stroke stroke; + + /** + * Creates a new instance. + */ + public Pin() { + this(0); + } + + /** + * Creates a new instance. + * + * @param datasetIndex the dataset index. + */ + public Pin(int datasetIndex) { + super(datasetIndex); + this.paint = Color.red; + this.stroke = new BasicStroke(3.0f, BasicStroke.CAP_ROUND, + BasicStroke.JOIN_BEVEL); + } + + /** + * Returns the paint. + * + * @return The paint (never null). + * + * @see #setPaint(Paint) + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Sets the paint and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getPaint() + */ + public void setPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.paint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the stroke. + * + * @return The stroke (never null). + * + * @see #setStroke(Stroke) + */ + public Stroke getStroke() { + return this.stroke; + } + + /** + * Sets the stroke and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getStroke() + */ + public void setStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.stroke = stroke; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Draws the pointer. + * + * @param g2 the graphics target. + * @param plot the plot. + * @param frame the dial's reference frame. + * @param view the dial's view. + */ + @Override + public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, + Rectangle2D view) { + + g2.setPaint(this.paint); + g2.setStroke(this.stroke); + Rectangle2D arcRect = DialPlot.rectangleByRadius(frame, + this.radius, this.radius); + + double value = plot.getValue(this.datasetIndex); + DialScale scale = plot.getScaleForDataset(this.datasetIndex); + double angle = scale.valueToAngle(value); + + Arc2D arc = new Arc2D.Double(arcRect, angle, 0, Arc2D.OPEN); + Point2D pt = arc.getEndPoint(); + + Line2D line = new Line2D.Double(frame.getCenterX(), + frame.getCenterY(), pt.getX(), pt.getY()); + g2.draw(line); + } + + /** + * Tests this pointer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DialPointer.Pin)) { + return false; + } + DialPointer.Pin that = (DialPointer.Pin) obj; + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + if (!this.stroke.equals(that.stroke)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = super.hashCode(); + result = HashUtilities.hashCode(result, this.paint); + result = HashUtilities.hashCode(result, this.stroke); + 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); + 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); + } + + } + + /** + * A dial pointer. + */ + public static class Pointer extends DialPointer { + + /** For serialization. */ + static final long serialVersionUID = -4180500011963176960L; + + /** + * The radius that defines the width of the pointer at the base. + */ + private double widthRadius; + + /** + * The fill paint. + * + * @since 1.0.8 + */ + private transient Paint fillPaint; + + /** + * The outline paint. + * + * @since 1.0.8 + */ + private transient Paint outlinePaint; + + /** + * Creates a new instance. + */ + public Pointer() { + this(0); + } + + /** + * Creates a new instance. + * + * @param datasetIndex the dataset index. + */ + public Pointer(int datasetIndex) { + super(datasetIndex); + this.widthRadius = 0.05; + this.fillPaint = Color.gray; + this.outlinePaint = Color.black; + } + + /** + * Returns the width radius. + * + * @return The width radius. + * + * @see #setWidthRadius(double) + */ + public double getWidthRadius() { + return this.widthRadius; + } + + /** + * Sets the width radius and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param radius the radius + * + * @see #getWidthRadius() + */ + public void setWidthRadius(double radius) { + this.widthRadius = radius; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the fill paint. + * + * @return The paint (never null). + * + * @see #setFillPaint(Paint) + * + * @since 1.0.8 + */ + public Paint getFillPaint() { + return this.fillPaint; + } + + /** + * Sets the fill paint and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getFillPaint() + * + * @since 1.0.8 + */ + public void setFillPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.fillPaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the outline paint. + * + * @return The paint (never null). + * + * @see #setOutlinePaint(Paint) + * + * @since 1.0.8 + */ + public Paint getOutlinePaint() { + return this.outlinePaint; + } + + /** + * Sets the outline paint and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getOutlinePaint() + * + * @since 1.0.8 + */ + public void setOutlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.outlinePaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Draws the pointer. + * + * @param g2 the graphics target. + * @param plot the plot. + * @param frame the dial's reference frame. + * @param view the dial's view. + */ + @Override + public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, + Rectangle2D view) { + + g2.setPaint(Color.blue); + g2.setStroke(new BasicStroke(1.0f)); + Rectangle2D lengthRect = DialPlot.rectangleByRadius(frame, + this.radius, this.radius); + Rectangle2D widthRect = DialPlot.rectangleByRadius(frame, + this.widthRadius, this.widthRadius); + double value = plot.getValue(this.datasetIndex); + DialScale scale = plot.getScaleForDataset(this.datasetIndex); + double angle = scale.valueToAngle(value); + + Arc2D arc1 = new Arc2D.Double(lengthRect, angle, 0, Arc2D.OPEN); + Point2D pt1 = arc1.getEndPoint(); + Arc2D arc2 = new Arc2D.Double(widthRect, angle - 90.0, 180.0, + Arc2D.OPEN); + Point2D pt2 = arc2.getStartPoint(); + Point2D pt3 = arc2.getEndPoint(); + Arc2D arc3 = new Arc2D.Double(widthRect, angle - 180.0, 0.0, + Arc2D.OPEN); + Point2D pt4 = arc3.getStartPoint(); + + GeneralPath gp = new GeneralPath(); + gp.moveTo((float) pt1.getX(), (float) pt1.getY()); + gp.lineTo((float) pt2.getX(), (float) pt2.getY()); + gp.lineTo((float) pt4.getX(), (float) pt4.getY()); + gp.lineTo((float) pt3.getX(), (float) pt3.getY()); + gp.closePath(); + g2.setPaint(this.fillPaint); + g2.fill(gp); + + g2.setPaint(this.outlinePaint); + Line2D line = new Line2D.Double(frame.getCenterX(), + frame.getCenterY(), pt1.getX(), pt1.getY()); + g2.draw(line); + + line.setLine(pt2, pt3); + g2.draw(line); + + line.setLine(pt3, pt1); + g2.draw(line); + + line.setLine(pt2, pt1); + g2.draw(line); + + line.setLine(pt2, pt4); + g2.draw(line); + + line.setLine(pt3, pt4); + g2.draw(line); + } + + /** + * Tests this pointer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DialPointer.Pointer)) { + return false; + } + DialPointer.Pointer that = (DialPointer.Pointer) obj; + + if (this.widthRadius != that.widthRadius) { + return false; + } + if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { + return false; + } + if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = super.hashCode(); + result = HashUtilities.hashCode(result, this.widthRadius); + result = HashUtilities.hashCode(result, this.fillPaint); + result = HashUtilities.hashCode(result, this.outlinePaint); + 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.fillPaint, stream); + SerialUtilities.writePaint(this.outlinePaint, 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.fillPaint = SerialUtilities.readPaint(stream); + this.outlinePaint = SerialUtilities.readPaint(stream); + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialScale.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialScale.java new file mode 100755 index 0000000..45cbb18 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialScale.java @@ -0,0 +1,75 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * DialScale.java + * -------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 17-Oct-2007 : Made this an extension of the DialLayer interface (DG); + * + */ + +package org.jfree.chart.plot.dial; + +/** + * A dial scale is a specialised layer that has the ability to convert data + * values into angles. + * + * @since 1.0.7 + */ +public interface DialScale extends DialLayer { + + /** + * Converts a data value to an angle (in degrees, using the same + * specification as Java's Arc2D class). + * + * @param value the data value. + * + * @return The angle in degrees. + * + * @see #angleToValue(double) + */ + public double valueToAngle(double value); + + /** + * Converts an angle (in degrees) to a data value. + * + * @param angle the angle (in degrees). + * + * @return The data value. + * + * @see #valueToAngle(double) + */ + public double angleToValue(double angle); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialTextAnnotation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialTextAnnotation.java new file mode 100755 index 0000000..1289b6d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialTextAnnotation.java @@ -0,0 +1,405 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * DialTextAnnotation.java + * ----------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 08-Mar-2007 : Fix in hashCode() (DG); + * 17-Oct-2007 : Updated equals() (DG); + * 24-Oct-2007 : Added getAnchor() and setAnchor() methods (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.geom.Arc2D; +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.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.ui.TextAnchor; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A text annotation for a {@link DialPlot}. + * + * @since 1.0.7 + */ +public class DialTextAnnotation extends AbstractDialLayer implements DialLayer, + Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + static final long serialVersionUID = 3065267524054428071L; + + /** The label text. */ + private String label; + + /** The font. */ + private Font font; + + /** + * The paint for the label. This field is transient because it requires + * special handling for serialization. + */ + private transient Paint paint; + + /** The angle that defines the anchor point for the annotation. */ + private double angle; + + /** The radius that defines the anchor point for the annotation. */ + private double radius; + + /** The text anchor to be aligned to the annotation's anchor point. */ + private TextAnchor anchor; + + /** + * Creates a new instance of DialTextAnnotation. + * + * @param label the label (null not permitted). + */ + public DialTextAnnotation(String label) { + ParamChecks.nullNotPermitted(label, "label"); + this.angle = -90.0; + this.radius = 0.3; + this.font = new Font("Dialog", Font.BOLD, 14); + this.paint = Color.black; + this.label = label; + this.anchor = TextAnchor.TOP_CENTER; + } + + /** + * Returns the label text. + * + * @return The label text (never nullnull not permitted). + * + * @see #getLabel() + */ + public void setLabel(String label) { + ParamChecks.nullNotPermitted(label, "label"); + this.label = label; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the font used to display the label. + * + * @return The font (never null). + * + * @see #setFont(Font) + */ + public Font getFont() { + return this.font; + } + + /** + * Sets the font used to display the label and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getFont() + */ + public void setFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.font = font; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the paint used to display the label. + * + * @return The paint (never null). + * + * @see #setPaint(Paint) + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Sets the paint used to display the label and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getPaint() + */ + public void setPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.paint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the angle used to calculate the anchor point. + * + * @return The angle (in degrees). + * + * @see #setAngle(double) + * @see #getRadius() + */ + public double getAngle() { + return this.angle; + } + + /** + * Sets the angle used to calculate the anchor point and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param angle the angle (in degrees). + * + * @see #getAngle() + * @see #setRadius(double) + */ + public void setAngle(double angle) { + this.angle = angle; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the radius used to calculate the anchor point. This is + * specified as a percentage relative to the dial's framing rectangle. + * + * @return The radius. + * + * @see #setRadius(double) + * @see #getAngle() + */ + public double getRadius() { + return this.radius; + } + + /** + * Sets the radius used to calculate the anchor point and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param radius the radius (as a percentage of the dial's framing + * rectangle). + * + * @see #getRadius() + * @see #setAngle(double) + */ + public void setRadius(double radius) { + if (radius < 0.0) { + throw new IllegalArgumentException( + "The 'radius' cannot be negative."); + } + this.radius = radius; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the text anchor point that will be aligned to the position + * specified by {@link #getAngle()} and {@link #getRadius()}. + * + * @return The anchor point. + * + * @see #setAnchor(TextAnchor) + */ + public TextAnchor getAnchor() { + return this.anchor; + } + + /** + * Sets the text anchor point and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param anchor the anchor point (null not permitted). + * + * @see #getAnchor() + */ + public void setAnchor(TextAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.anchor = anchor; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns true to indicate that this layer should be + * clipped within the dial window. + * + * @return true. + */ + @Override + public boolean isClippedToWindow() { + return true; + } + + /** + * Draws the background to the specified graphics device. If the dial + * frame specifies a window, the clipping region will already have been + * set to this window before this method is called. + * + * @param g2 the graphics device (null not permitted). + * @param plot the plot (ignored here). + * @param frame the dial frame (ignored here). + * @param view the view rectangle (null not permitted). + */ + @Override + public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, + Rectangle2D view) { + + // work out the anchor point + Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, + this.radius); + Arc2D arc = new Arc2D.Double(f, this.angle, 0.0, Arc2D.OPEN); + Point2D pt = arc.getStartPoint(); + g2.setPaint(this.paint); + g2.setFont(this.font); + TextUtilities.drawAlignedString(this.label, g2, (float) pt.getX(), + (float) pt.getY(), this.anchor); + + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DialTextAnnotation)) { + return false; + } + DialTextAnnotation that = (DialTextAnnotation) obj; + if (!this.label.equals(that.label)) { + return false; + } + if (!this.font.equals(that.font)) { + return false; + } + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + if (this.radius != that.radius) { + return false; + } + if (this.angle != that.angle) { + return false; + } + if (!this.anchor.equals(that.anchor)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return The hash code. + */ + @Override + public int hashCode() { + int result = 193; + result = 37 * result + HashUtilities.hashCodeForPaint(this.paint); + result = 37 * result + this.font.hashCode(); + result = 37 * result + this.label.hashCode(); + result = 37 * result + this.anchor.hashCode(); + long temp = Double.doubleToLongBits(this.angle); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.radius); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + /** + * Returns a clone of this instance. + * + * @return The clone. + * + * @throws CloneNotSupportedException if some attribute of this instance + * cannot be cloned. + */ + @Override + 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialValueIndicator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialValueIndicator.java new file mode 100755 index 0000000..d57da29 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/DialValueIndicator.java @@ -0,0 +1,779 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * DialValueIndicator.java + * ----------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 17-Oct-2007 : Updated equals() (DG); + * 24-Oct-2007 : Added default constructor and missing event notification (DG); + * 09-Jun-2009 : Improved indicator resizing, fixes bug 2802014 (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Arc2D; +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 java.text.DecimalFormat; +import java.text.NumberFormat; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.Size2D; +import org.jfree.ui.TextAnchor; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A value indicator for a {@link DialPlot}. + * + * @since 1.0.7 + */ +public class DialValueIndicator extends AbstractDialLayer implements DialLayer, + Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + static final long serialVersionUID = 803094354130942585L; + + /** The dataset index. */ + private int datasetIndex; + + /** The angle that defines the anchor point. */ + private double angle; + + /** The radius that defines the anchor point. */ + private double radius; + + /** The frame anchor. */ + private RectangleAnchor frameAnchor; + + /** The template value. */ + private Number templateValue; + + /** + * A data value that will be formatted to determine the maximum size of + * the indicator bounds. If this is null, the indicator bounds can grow + * as large as necessary to contain the actual data value. + * + * @since 1.0.14 + */ + private Number maxTemplateValue; + + /** The formatter. */ + private NumberFormat formatter; + + /** The font. */ + private Font font; + + /** The paint. */ + private transient Paint paint; + + /** The background paint. */ + private transient Paint backgroundPaint; + + /** The outline stroke. */ + private transient Stroke outlineStroke; + + /** The outline paint. */ + private transient Paint outlinePaint; + + /** The insets. */ + private RectangleInsets insets; + + /** The value anchor. */ + private RectangleAnchor valueAnchor; + + /** The text anchor for displaying the value. */ + private TextAnchor textAnchor; + + /** + * Creates a new instance of DialValueIndicator. + */ + public DialValueIndicator() { + this(0); + } + + /** + * Creates a new instance of DialValueIndicator. + * + * @param datasetIndex the dataset index. + */ + public DialValueIndicator(int datasetIndex) { + this.datasetIndex = datasetIndex; + this.angle = -90.0; + this.radius = 0.3; + this.frameAnchor = RectangleAnchor.CENTER; + this.templateValue = new Double(100.0); + this.maxTemplateValue = null; + this.formatter = new DecimalFormat("0.0"); + this.font = new Font("Dialog", Font.BOLD, 14); + this.paint = Color.black; + this.backgroundPaint = Color.white; + this.outlineStroke = new BasicStroke(1.0f); + this.outlinePaint = Color.blue; + this.insets = new RectangleInsets(4, 4, 4, 4); + this.valueAnchor = RectangleAnchor.RIGHT; + this.textAnchor = TextAnchor.CENTER_RIGHT; + } + + /** + * Returns the index of the dataset from which this indicator fetches its + * current value. + * + * @return The dataset index. + * + * @see #setDatasetIndex(int) + */ + public int getDatasetIndex() { + return this.datasetIndex; + } + + /** + * Sets the dataset index and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param index the index. + * + * @see #getDatasetIndex() + */ + public void setDatasetIndex(int index) { + this.datasetIndex = index; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the angle for the anchor point. The angle is specified in + * degrees using the same orientation as Java's Arc2D class. + * + * @return The angle (in degrees). + * + * @see #setAngle(double) + */ + public double getAngle() { + return this.angle; + } + + /** + * Sets the angle for the anchor point and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param angle the angle (in degrees). + * + * @see #getAngle() + */ + public void setAngle(double angle) { + this.angle = angle; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the radius. + * + * @return The radius. + * + * @see #setRadius(double) + */ + public double getRadius() { + return this.radius; + } + + /** + * Sets the radius and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param radius the radius. + * + * @see #getRadius() + */ + public void setRadius(double radius) { + this.radius = radius; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the frame anchor. + * + * @return The frame anchor. + * + * @see #setFrameAnchor(RectangleAnchor) + */ + public RectangleAnchor getFrameAnchor() { + return this.frameAnchor; + } + + /** + * Sets the frame anchor and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param anchor the anchor (null not permitted). + * + * @see #getFrameAnchor() + */ + public void setFrameAnchor(RectangleAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.frameAnchor = anchor; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the template value. + * + * @return The template value (never null). + * + * @see #setTemplateValue(Number) + */ + public Number getTemplateValue() { + return this.templateValue; + } + + /** + * Sets the template value and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param value the value (null not permitted). + * + * @see #setTemplateValue(Number) + */ + public void setTemplateValue(Number value) { + ParamChecks.nullNotPermitted(value, "value"); + this.templateValue = value; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the template value for the maximum size of the indicator + * bounds. + * + * @return The template value (possibly null). + * + * @since 1.0.14 + * + * @see #setMaxTemplateValue(java.lang.Number) + */ + public Number getMaxTemplateValue() { + return this.maxTemplateValue; + } + + /** + * Sets the template value for the maximum size of the indicator bounds + * and sends a {@link DialLayerChangeEvent} to all registered listeners. + * + * @param value the value (null permitted). + * + * @since 1.0.14 + * + * @see #getMaxTemplateValue() + */ + public void setMaxTemplateValue(Number value) { + this.maxTemplateValue = value; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the formatter used to format the value. + * + * @return The formatter (never null). + * + * @see #setNumberFormat(NumberFormat) + */ + public NumberFormat getNumberFormat() { + return this.formatter; + } + + /** + * Sets the formatter used to format the value and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param formatter the formatter (null not permitted). + * + * @see #getNumberFormat() + */ + public void setNumberFormat(NumberFormat formatter) { + ParamChecks.nullNotPermitted(formatter, "formatter"); + this.formatter = formatter; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the font. + * + * @return The font (never null). + * + * @see #getFont() + */ + public Font getFont() { + return this.font; + } + + /** + * Sets the font and sends a {@link DialLayerChangeEvent} to all registered + * listeners. + * + * @param font the font (null not permitted). + */ + public void setFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.font = font; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the paint. + * + * @return The paint (never null). + * + * @see #setPaint(Paint) + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Sets the paint and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getPaint() + */ + public void setPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.paint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the background paint. + * + * @return The background paint. + * + * @see #setBackgroundPaint(Paint) + */ + public Paint getBackgroundPaint() { + return this.backgroundPaint; + } + + /** + * Sets the background paint and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getBackgroundPaint() + */ + public void setBackgroundPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.backgroundPaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the outline stroke. + * + * @return The outline stroke (never null). + * + * @see #setOutlineStroke(Stroke) + */ + public Stroke getOutlineStroke() { + return this.outlineStroke; + } + + /** + * Sets the outline stroke and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getOutlineStroke() + */ + public void setOutlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.outlineStroke = stroke; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the outline paint. + * + * @return The outline paint (never null). + * + * @see #setOutlinePaint(Paint) + */ + public Paint getOutlinePaint() { + return this.outlinePaint; + } + + /** + * Sets the outline paint and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getOutlinePaint() + */ + public void setOutlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.outlinePaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the insets. + * + * @return The insets (never null). + * + * @see #setInsets(RectangleInsets) + */ + public RectangleInsets getInsets() { + return this.insets; + } + + /** + * Sets the insets and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param insets the insets (null not permitted). + * + * @see #getInsets() + */ + public void setInsets(RectangleInsets insets) { + ParamChecks.nullNotPermitted(insets, "insets"); + this.insets = insets; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the value anchor. + * + * @return The value anchor (never null). + * + * @see #setValueAnchor(RectangleAnchor) + */ + public RectangleAnchor getValueAnchor() { + return this.valueAnchor; + } + + /** + * Sets the value anchor and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param anchor the anchor (null not permitted). + * + * @see #getValueAnchor() + */ + public void setValueAnchor(RectangleAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.valueAnchor = anchor; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the text anchor. + * + * @return The text anchor (never null). + * + * @see #setTextAnchor(TextAnchor) + */ + public TextAnchor getTextAnchor() { + return this.textAnchor; + } + + /** + * Sets the text anchor and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param anchor the anchor (null not permitted). + * + * @see #getTextAnchor() + */ + public void setTextAnchor(TextAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.textAnchor = anchor; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns true to indicate that this layer should be + * clipped within the dial window. + * + * @return true. + */ + @Override + public boolean isClippedToWindow() { + return true; + } + + /** + * Draws the background to the specified graphics device. If the dial + * frame specifies a window, the clipping region will already have been + * set to this window before this method is called. + * + * @param g2 the graphics device (null not permitted). + * @param plot the plot (ignored here). + * @param frame the dial frame (ignored here). + * @param view the view rectangle (null not permitted). + */ + @Override + public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, + Rectangle2D view) { + + // work out the anchor point + Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, + this.radius); + Arc2D arc = new Arc2D.Double(f, this.angle, 0.0, Arc2D.OPEN); + Point2D pt = arc.getStartPoint(); + + // the indicator bounds is calculated from the templateValue (which + // determines the minimum size), the maxTemplateValue (which, if + // specified, provides a maximum size) and the actual value + FontMetrics fm = g2.getFontMetrics(this.font); + double value = plot.getValue(this.datasetIndex); + String valueStr = this.formatter.format(value); + Rectangle2D valueBounds = TextUtilities.getTextBounds(valueStr, g2, fm); + + // calculate the bounds of the template value + String s = this.formatter.format(this.templateValue); + Rectangle2D tb = TextUtilities.getTextBounds(s, g2, fm); + double minW = tb.getWidth(); + double minH = tb.getHeight(); + + double maxW = Double.MAX_VALUE; + double maxH = Double.MAX_VALUE; + if (this.maxTemplateValue != null) { + s = this.formatter.format(this.maxTemplateValue); + tb = TextUtilities.getTextBounds(s, g2, fm); + maxW = Math.max(tb.getWidth(), minW); + maxH = Math.max(tb.getHeight(), minH); + } + double w = fixToRange(valueBounds.getWidth(), minW, maxW); + double h = fixToRange(valueBounds.getHeight(), minH, maxH); + + // align this rectangle to the frameAnchor + Rectangle2D bounds = RectangleAnchor.createRectangle(new Size2D(w, h), + pt.getX(), pt.getY(), this.frameAnchor); + + // add the insets + Rectangle2D fb = this.insets.createOutsetRectangle(bounds); + + // draw the background + g2.setPaint(this.backgroundPaint); + g2.fill(fb); + + // draw the border + g2.setStroke(this.outlineStroke); + g2.setPaint(this.outlinePaint); + g2.draw(fb); + + // now find the text anchor point + Shape savedClip = g2.getClip(); + g2.clip(fb); + + Point2D pt2 = RectangleAnchor.coordinates(bounds, this.valueAnchor); + g2.setPaint(this.paint); + g2.setFont(this.font); + TextUtilities.drawAlignedString(valueStr, g2, (float) pt2.getX(), + (float) pt2.getY(), this.textAnchor); + g2.setClip(savedClip); + + } + + /** + * A utility method that adjusts a value, if necessary, to be within a + * specified range. + * + * @param x the value. + * @param minX the minimum value in the range. + * @param maxX the maximum value in the range. + * + * @return The adjusted value. + */ + private double fixToRange(double x, double minX, double maxX) { + if (minX > maxX) { + throw new IllegalArgumentException("Requires 'minX' <= 'maxX'."); + } + if (x < minX) { + return minX; + } + else if (x > maxX) { + return maxX; + } + else { + return x; + } + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DialValueIndicator)) { + return false; + } + DialValueIndicator that = (DialValueIndicator) obj; + if (this.datasetIndex != that.datasetIndex) { + return false; + } + if (this.angle != that.angle) { + return false; + } + if (this.radius != that.radius) { + return false; + } + if (!this.frameAnchor.equals(that.frameAnchor)) { + return false; + } + if (!this.templateValue.equals(that.templateValue)) { + return false; + } + if (!ObjectUtilities.equal(this.maxTemplateValue, + that.maxTemplateValue)) { + return false; + } + if (!this.font.equals(that.font)) { + return false; + } + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { + return false; + } + if (!this.outlineStroke.equals(that.outlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { + return false; + } + if (!this.insets.equals(that.insets)) { + return false; + } + if (!this.valueAnchor.equals(that.valueAnchor)) { + return false; + } + if (!this.textAnchor.equals(that.textAnchor)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return The hash code. + */ + @Override + public int hashCode() { + int result = 193; + result = 37 * result + HashUtilities.hashCodeForPaint(this.paint); + result = 37 * result + HashUtilities.hashCodeForPaint( + this.backgroundPaint); + result = 37 * result + HashUtilities.hashCodeForPaint( + this.outlinePaint); + result = 37 * result + this.outlineStroke.hashCode(); + return result; + } + + /** + * Returns a clone of this instance. + * + * @return The clone. + * + * @throws CloneNotSupportedException if some attribute of this instance + * cannot be cloned. + */ + @Override + 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.writePaint(this.backgroundPaint, stream); + SerialUtilities.writePaint(this.outlinePaint, stream); + SerialUtilities.writeStroke(this.outlineStroke, 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.backgroundPaint = SerialUtilities.readPaint(stream); + this.outlinePaint = SerialUtilities.readPaint(stream); + this.outlineStroke = SerialUtilities.readStroke(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/StandardDialFrame.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/StandardDialFrame.java new file mode 100755 index 0000000..3f12771 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/StandardDialFrame.java @@ -0,0 +1,362 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * StandardDialFrame.java + * ---------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 08-Mar-2007 : Fix in hashCode() (DG); + * 29-Oct-2007 : Renamed StandardDialFrame (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot.dial; + +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.Area; +import java.awt.geom.Ellipse2D; +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.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A simple circular frame for the {@link DialPlot} class. + * + * @since 1.0.7 + */ +public class StandardDialFrame extends AbstractDialLayer implements DialFrame, + Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + static final long serialVersionUID = 1016585407507121596L; + + /** The outer radius, relative to the framing rectangle. */ + private double radius; + + /** + * The color used for the front of the panel. This field is transient + * because it requires special handling for serialization. + */ + private transient Paint backgroundPaint; + + /** + * The color used for the border around the window. This field is transient + * because it requires special handling for serialization. + */ + private transient Paint foregroundPaint; + + /** + * The stroke for drawing the frame outline. This field is transient + * because it requires special handling for serialization. + */ + private transient Stroke stroke; + + /** + * Creates a new instance of StandardDialFrame. + */ + public StandardDialFrame() { + this.backgroundPaint = Color.gray; + this.foregroundPaint = Color.black; + this.stroke = new BasicStroke(2.0f); + this.radius = 0.95; + } + + /** + * Returns the radius, relative to the framing rectangle. + * + * @return The radius. + * + * @see #setRadius(double) + */ + public double getRadius() { + return this.radius; + } + + /** + * Sets the radius and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param radius the radius (must be positive). + * + * @see #getRadius() + */ + public void setRadius(double radius) { + if (radius <= 0) { + throw new IllegalArgumentException( + "The 'radius' must be positive."); + } + this.radius = radius; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the background paint. + * + * @return The background paint (never null). + * + * @see #setBackgroundPaint(Paint) + */ + public Paint getBackgroundPaint() { + return this.backgroundPaint; + } + + /** + * Sets the background paint and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getBackgroundPaint() + */ + public void setBackgroundPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.backgroundPaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the foreground paint. + * + * @return The foreground paint (never null). + * + * @see #setForegroundPaint(Paint) + */ + public Paint getForegroundPaint() { + return this.foregroundPaint; + } + + /** + * Sets the foreground paint and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getForegroundPaint() + */ + public void setForegroundPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.foregroundPaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the stroke for the frame. + * + * @return The stroke (never null). + * + * @see #setStroke(Stroke) + */ + public Stroke getStroke() { + return this.stroke; + } + + /** + * Sets the stroke and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getStroke() + */ + public void setStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.stroke = stroke; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the shape for the window for this dial. Some dial layers will + * request that their drawing be clipped within this window. + * + * @param frame the reference frame (null not permitted). + * + * @return The shape of the dial's window. + */ + @Override + public Shape getWindow(Rectangle2D frame) { + Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius, + this.radius); + return new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(), + f.getHeight()); + } + + /** + * Returns false to indicate that this dial layer is not + * clipped to the dial window. + * + * @return A boolean. + */ + @Override + public boolean isClippedToWindow() { + return false; + } + + /** + * Draws the frame. This method is called by the {@link DialPlot} class, + * you shouldn't need to call it directly. + * + * @param g2 the graphics target (null not permitted). + * @param plot the plot (null not permitted). + * @param frame the frame (null not permitted). + * @param view the view (null not permitted). + */ + @Override + public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, + Rectangle2D view) { + + Shape window = getWindow(frame); + + Rectangle2D f = DialPlot.rectangleByRadius(frame, this.radius + 0.02, + this.radius + 0.02); + Ellipse2D e = new Ellipse2D.Double(f.getX(), f.getY(), f.getWidth(), + f.getHeight()); + + Area area = new Area(e); + Area area2 = new Area(window); + area.subtract(area2); + g2.setPaint(this.backgroundPaint); + g2.fill(area); + + g2.setStroke(this.stroke); + g2.setPaint(this.foregroundPaint); + g2.draw(window); + g2.draw(e); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardDialFrame)) { + return false; + } + StandardDialFrame that = (StandardDialFrame) obj; + if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { + return false; + } + if (!PaintUtilities.equal(this.foregroundPaint, that.foregroundPaint)) { + return false; + } + if (this.radius != that.radius) { + return false; + } + if (!this.stroke.equals(that.stroke)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return The hash code. + */ + @Override + public int hashCode() { + int result = 193; + long temp = Double.doubleToLongBits(this.radius); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + result = 37 * result + HashUtilities.hashCodeForPaint( + this.backgroundPaint); + result = 37 * result + HashUtilities.hashCodeForPaint( + this.foregroundPaint); + result = 37 * result + this.stroke.hashCode(); + return result; + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if any of the frame's attributes + * cannot be cloned. + */ + @Override + 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.backgroundPaint, stream); + SerialUtilities.writePaint(this.foregroundPaint, 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.backgroundPaint = SerialUtilities.readPaint(stream); + this.foregroundPaint = SerialUtilities.readPaint(stream); + this.stroke = SerialUtilities.readStroke(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/StandardDialRange.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/StandardDialRange.java new file mode 100755 index 0000000..39b2872 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/StandardDialRange.java @@ -0,0 +1,439 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * StandardDialRange.java + * ---------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 08-Mar-2007 : Fix in hashCode() (DG); + * 17-Oct-2007 : Removed increment attribute (DG); + * 24-Oct-2007 : Added scaleIndex (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.geom.Arc2D; +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.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A layer that draws a range highlight on a dial plot. + * + * @since 1.0.7 + */ +public class StandardDialRange extends AbstractDialLayer implements DialLayer, + Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + static final long serialVersionUID = 345515648249364904L; + + /** The scale index. */ + private int scaleIndex; + + /** The minimum data value for the scale. */ + private double lowerBound; + + /** The maximum data value for the scale. */ + private double upperBound; + + /** + * The paint used to draw the range highlight. This field is transient + * because it requires special handling for serialization. + */ + private transient Paint paint; + + /** + * The factor (in the range 0.0 to 1.0) that determines the inside limit + * of the range highlight. + */ + private double innerRadius; + + /** + * The factor (in the range 0.0 to 1.0) that determines the outside limit + * of the range highlight. + */ + private double outerRadius; + + /** + * Creates a new instance of StandardDialRange. + */ + public StandardDialRange() { + this(0.0, 100.0, Color.white); + } + + /** + * Creates a new instance of StandardDialRange. + * + * @param lower the lower bound. + * @param upper the upper bound. + * @param paint the paint (null not permitted). + */ + public StandardDialRange(double lower, double upper, Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.scaleIndex = 0; + this.lowerBound = lower; + this.upperBound = upper; + this.innerRadius = 0.48; + this.outerRadius = 0.52; + this.paint = paint; + } + + /** + * Returns the scale index. + * + * @return The scale index. + * + * @see #setScaleIndex(int) + */ + public int getScaleIndex() { + return this.scaleIndex; + } + + /** + * Sets the scale index and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param index the scale index. + * + * @see #getScaleIndex() + */ + public void setScaleIndex(int index) { + this.scaleIndex = index; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the lower bound (a data value) of the dial range. + * + * @return The lower bound of the dial range. + * + * @see #setLowerBound(double) + */ + public double getLowerBound() { + return this.lowerBound; + } + + /** + * Sets the lower bound of the dial range and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param bound the lower bound. + * + * @see #getLowerBound() + */ + public void setLowerBound(double bound) { + if (bound >= this.upperBound) { + throw new IllegalArgumentException( + "Lower bound must be less than upper bound."); + } + this.lowerBound = bound; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the upper bound of the dial range. + * + * @return The upper bound. + * + * @see #setUpperBound(double) + */ + public double getUpperBound() { + return this.upperBound; + } + + /** + * Sets the upper bound of the dial range and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param bound the upper bound. + * + * @see #getUpperBound() + */ + public void setUpperBound(double bound) { + if (bound <= this.lowerBound) { + throw new IllegalArgumentException( + "Lower bound must be less than upper bound."); + } + this.upperBound = bound; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Sets the bounds for the range and sends a {@link DialLayerChangeEvent} + * to all registered listeners. + * + * @param lower the lower bound. + * @param upper the upper bound. + */ + public void setBounds(double lower, double upper) { + if (lower >= upper) { + throw new IllegalArgumentException( + "Lower must be less than upper."); + } + this.lowerBound = lower; + this.upperBound = upper; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the paint used to highlight the range. + * + * @return The paint (never null). + * + * @see #setPaint(Paint) + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Sets the paint used to highlight the range and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getPaint() + */ + public void setPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.paint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the inner radius. + * + * @return The inner radius. + * + * @see #setInnerRadius(double) + */ + public double getInnerRadius() { + return this.innerRadius; + } + + /** + * Sets the inner radius and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param radius the radius. + * + * @see #getInnerRadius() + */ + public void setInnerRadius(double radius) { + this.innerRadius = radius; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the outer radius. + * + * @return The outer radius. + * + * @see #setOuterRadius(double) + */ + public double getOuterRadius() { + return this.outerRadius; + } + + /** + * Sets the outer radius and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param radius the radius. + * + * @see #getOuterRadius() + */ + public void setOuterRadius(double radius) { + this.outerRadius = radius; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns true to indicate that this layer should be + * clipped within the dial window. + * + * @return true. + */ + @Override + public boolean isClippedToWindow() { + return true; + } + + /** + * Draws the range. + * + * @param g2 the graphics target. + * @param plot the plot. + * @param frame the dial's reference frame (in Java2D space). + * @param view the dial's view rectangle (in Java2D space). + */ + @Override + public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, + Rectangle2D view) { + + Rectangle2D arcRectInner = DialPlot.rectangleByRadius(frame, + this.innerRadius, this.innerRadius); + Rectangle2D arcRectOuter = DialPlot.rectangleByRadius(frame, + this.outerRadius, this.outerRadius); + + DialScale scale = plot.getScale(this.scaleIndex); + if (scale == null) { + throw new RuntimeException("No scale for scaleIndex = " + + this.scaleIndex); + } + double angleMin = scale.valueToAngle(this.lowerBound); + double angleMax = scale.valueToAngle(this.upperBound); + + Arc2D arcInner = new Arc2D.Double(arcRectInner, angleMin, + angleMax - angleMin, Arc2D.OPEN); + Arc2D arcOuter = new Arc2D.Double(arcRectOuter, angleMax, + angleMin - angleMax, Arc2D.OPEN); + + g2.setPaint(this.paint); + g2.setStroke(new BasicStroke(2.0f)); + g2.draw(arcInner); + g2.draw(arcOuter); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardDialRange)) { + return false; + } + StandardDialRange that = (StandardDialRange) obj; + if (this.scaleIndex != that.scaleIndex) { + return false; + } + if (this.lowerBound != that.lowerBound) { + return false; + } + if (this.upperBound != that.upperBound) { + return false; + } + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + if (this.innerRadius != that.innerRadius) { + return false; + } + if (this.outerRadius != that.outerRadius) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return The hash code. + */ + @Override + public int hashCode() { + int result = 193; + long temp = Double.doubleToLongBits(this.lowerBound); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.upperBound); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.innerRadius); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.outerRadius); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + result = 37 * result + HashUtilities.hashCodeForPaint(this.paint); + return result; + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if any of the attributes of this + * instance cannot be cloned. + */ + @Override + 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); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/StandardDialScale.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/StandardDialScale.java new file mode 100755 index 0000000..995d40b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/StandardDialScale.java @@ -0,0 +1,1024 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * StandardDialScale.java + * ---------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 17-Nov-2006 : Added flags for tick label visibility (DG); + * 24-Oct-2007 : Added tick label formatter (DG); + * 19-Nov-2007 : Added some missing accessor methods (DG); + * 27-Feb-2009 : Fixed bug 2617557: tickLabelPaint ignored (DG); + * 09-Feb-2010 : Fixed bug 2946521 (DG); + * 08-Jan-2012 : Added missing angleToValue() implementation (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Stroke; +import java.awt.geom.Arc2D; +import java.awt.geom.Line2D; +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 java.text.DecimalFormat; +import java.text.NumberFormat; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.ui.TextAnchor; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A scale for a {@link DialPlot}. + * + * @since 1.0.7 + */ +public class StandardDialScale extends AbstractDialLayer implements DialScale, + Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + static final long serialVersionUID = 3715644629665918516L; + + /** The minimum data value for the scale. */ + private double lowerBound; + + /** The maximum data value for the scale. */ + private double upperBound; + + /** + * The start angle for the scale display, in degrees (using the same + * encoding as Arc2D). + */ + private double startAngle; + + /** The extent of the scale display. */ + private double extent; + + /** + * The factor (in the range 0.0 to 1.0) that determines the outside limit + * of the tick marks. + */ + private double tickRadius; + + /** + * The increment (in data units) between major tick marks. + */ + private double majorTickIncrement; + + /** + * The factor that is subtracted from the tickRadius to determine the + * inner point of the major ticks. + */ + private double majorTickLength; + + /** + * The paint to use for major tick marks. This field is transient because + * it requires special handling for serialization. + */ + private transient Paint majorTickPaint; + + /** + * The stroke to use for major tick marks. This field is transient because + * it requires special handling for serialization. + */ + private transient Stroke majorTickStroke; + + /** + * The number of minor ticks between each major tick. + */ + private int minorTickCount; + + /** + * The factor that is subtracted from the tickRadius to determine the + * inner point of the minor ticks. + */ + private double minorTickLength; + + /** + * The paint to use for minor tick marks. This field is transient because + * it requires special handling for serialization. + */ + private transient Paint minorTickPaint; + + /** + * The stroke to use for minor tick marks. This field is transient because + * it requires special handling for serialization. + */ + private transient Stroke minorTickStroke; + + /** + * The tick label offset. + */ + private double tickLabelOffset; + + /** + * The tick label font. + */ + private Font tickLabelFont; + + /** + * A flag that controls whether or not the tick labels are + * displayed. + */ + private boolean tickLabelsVisible; + + /** + * The number formatter for the tick labels. + */ + private NumberFormat tickLabelFormatter; + + /** + * A flag that controls whether or not the first tick label is + * displayed. + */ + private boolean firstTickLabelVisible; + + /** + * The tick label paint. This field is transient because it requires + * special handling for serialization. + */ + private transient Paint tickLabelPaint; + + /** + * Creates a new instance of DialScale. + */ + public StandardDialScale() { + this(0.0, 100.0, 175, -170, 10.0, 4); + } + + /** + * Creates a new instance. + * + * @param lowerBound the lower bound of the scale. + * @param upperBound the upper bound of the scale. + * @param startAngle the start angle (in degrees, using the same + * orientation as Java's Arc2D class). + * @param extent the extent (in degrees, counter-clockwise). + * @param majorTickIncrement the interval between major tick marks (must + * be > 0). + * @param minorTickCount the number of minor ticks between major tick + * marks. + */ + public StandardDialScale(double lowerBound, double upperBound, + double startAngle, double extent, double majorTickIncrement, + int minorTickCount) { + if (majorTickIncrement <= 0.0) { + throw new IllegalArgumentException( + "Requires 'majorTickIncrement' > 0."); + } + this.startAngle = startAngle; + this.extent = extent; + this.lowerBound = lowerBound; + this.upperBound = upperBound; + this.tickRadius = 0.70; + this.tickLabelsVisible = true; + this.tickLabelFormatter = new DecimalFormat("0.0"); + this.firstTickLabelVisible = true; + this.tickLabelFont = new Font("Dialog", Font.BOLD, 16); + this.tickLabelPaint = Color.blue; + this.tickLabelOffset = 0.10; + this.majorTickIncrement = majorTickIncrement; + this.majorTickLength = 0.04; + this.majorTickPaint = Color.black; + this.majorTickStroke = new BasicStroke(3.0f); + this.minorTickCount = minorTickCount; + this.minorTickLength = 0.02; + this.minorTickPaint = Color.black; + this.minorTickStroke = new BasicStroke(1.0f); + } + + /** + * Returns the lower bound for the scale. + * + * @return The lower bound for the scale. + * + * @see #setLowerBound(double) + * + * @since 1.0.8 + */ + public double getLowerBound() { + return this.lowerBound; + } + + /** + * Sets the lower bound for the scale and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param lower the lower bound. + * + * @see #getLowerBound() + * + * @since 1.0.8 + */ + public void setLowerBound(double lower) { + this.lowerBound = lower; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the upper bound for the scale. + * + * @return The upper bound for the scale. + * + * @see #setUpperBound(double) + * + * @since 1.0.8 + */ + public double getUpperBound() { + return this.upperBound; + } + + /** + * Sets the upper bound for the scale and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param upper the upper bound. + * + * @see #getUpperBound() + * + * @since 1.0.8 + */ + public void setUpperBound(double upper) { + this.upperBound = upper; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the start angle for the scale (in degrees using the same + * orientation as Java's Arc2D class). + * + * @return The start angle. + * + * @see #setStartAngle(double) + */ + public double getStartAngle() { + return this.startAngle; + } + + /** + * Sets the start angle for the scale and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param angle the angle (in degrees). + * + * @see #getStartAngle() + */ + public void setStartAngle(double angle) { + this.startAngle = angle; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the extent. + * + * @return The extent. + * + * @see #setExtent(double) + */ + public double getExtent() { + return this.extent; + } + + /** + * Sets the extent and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param extent the extent. + * + * @see #getExtent() + */ + public void setExtent(double extent) { + this.extent = extent; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the radius (as a percentage of the maximum space available) of + * the outer limit of the tick marks. + * + * @return The tick radius. + * + * @see #setTickRadius(double) + */ + public double getTickRadius() { + return this.tickRadius; + } + + /** + * Sets the tick radius and sends a {@link DialLayerChangeEvent} to all + * registered listeners. + * + * @param radius the radius. + * + * @see #getTickRadius() + */ + public void setTickRadius(double radius) { + if (radius <= 0.0) { + throw new IllegalArgumentException( + "The 'radius' must be positive."); + } + this.tickRadius = radius; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the increment (in data units) between major tick labels. + * + * @return The increment between major tick labels. + * + * @see #setMajorTickIncrement(double) + */ + public double getMajorTickIncrement() { + return this.majorTickIncrement; + } + + /** + * Sets the increment (in data units) between major tick labels and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param increment the increment (must be > 0). + * + * @see #getMajorTickIncrement() + */ + public void setMajorTickIncrement(double increment) { + if (increment <= 0.0) { + throw new IllegalArgumentException( + "The 'increment' must be positive."); + } + this.majorTickIncrement = increment; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the length factor for the major tick marks. The value is + * subtracted from the tick radius to determine the inner starting point + * for the tick marks. + * + * @return The length factor. + * + * @see #setMajorTickLength(double) + */ + public double getMajorTickLength() { + return this.majorTickLength; + } + + /** + * Sets the length factor for the major tick marks and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param length the length. + * + * @see #getMajorTickLength() + */ + public void setMajorTickLength(double length) { + if (length < 0.0) { + throw new IllegalArgumentException("Negative 'length' argument."); + } + this.majorTickLength = length; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the major tick paint. + * + * @return The major tick paint (never null). + * + * @see #setMajorTickPaint(Paint) + */ + public Paint getMajorTickPaint() { + return this.majorTickPaint; + } + + /** + * Sets the major tick paint and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getMajorTickPaint() + */ + public void setMajorTickPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.majorTickPaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the stroke used to draw the major tick marks. + * + * @return The stroke (never null). + * + * @see #setMajorTickStroke(Stroke) + */ + public Stroke getMajorTickStroke() { + return this.majorTickStroke; + } + + /** + * Sets the stroke used to draw the major tick marks and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getMajorTickStroke() + */ + public void setMajorTickStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.majorTickStroke = stroke; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the number of minor tick marks between major tick marks. + * + * @return The number of minor tick marks between major tick marks. + * + * @see #setMinorTickCount(int) + */ + public int getMinorTickCount() { + return this.minorTickCount; + } + + /** + * Sets the number of minor tick marks between major tick marks and sends + * a {@link DialLayerChangeEvent} to all registered listeners. + * + * @param count the count. + * + * @see #getMinorTickCount() + */ + public void setMinorTickCount(int count) { + if (count < 0) { + throw new IllegalArgumentException( + "The 'count' cannot be negative."); + } + this.minorTickCount = count; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the length factor for the minor tick marks. The value is + * subtracted from the tick radius to determine the inner starting point + * for the tick marks. + * + * @return The length factor. + * + * @see #setMinorTickLength(double) + */ + public double getMinorTickLength() { + return this.minorTickLength; + } + + /** + * Sets the length factor for the minor tick marks and sends + * a {@link DialLayerChangeEvent} to all registered listeners. + * + * @param length the length. + * + * @see #getMinorTickLength() + */ + public void setMinorTickLength(double length) { + if (length < 0.0) { + throw new IllegalArgumentException("Negative 'length' argument."); + } + this.minorTickLength = length; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the paint used to draw the minor tick marks. + * + * @return The paint (never null). + * + * @see #setMinorTickPaint(Paint) + */ + public Paint getMinorTickPaint() { + return this.minorTickPaint; + } + + /** + * Sets the paint used to draw the minor tick marks and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getMinorTickPaint() + */ + public void setMinorTickPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.minorTickPaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the stroke used to draw the minor tick marks. + * + * @return The paint (never null). + * + * @see #setMinorTickStroke(Stroke) + * + * @since 1.0.8 + */ + public Stroke getMinorTickStroke() { + return this.minorTickStroke; + } + + /** + * Sets the stroke used to draw the minor tick marks and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getMinorTickStroke() + * + * @since 1.0.8 + */ + public void setMinorTickStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.minorTickStroke = stroke; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the tick label offset. + * + * @return The tick label offset. + * + * @see #setTickLabelOffset(double) + */ + public double getTickLabelOffset() { + return this.tickLabelOffset; + } + + /** + * Sets the tick label offset and sends a {@link DialLayerChangeEvent} to + * all registered listeners. + * + * @param offset the offset. + * + * @see #getTickLabelOffset() + */ + public void setTickLabelOffset(double offset) { + this.tickLabelOffset = offset; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the font used to draw the tick labels. + * + * @return The font (never null). + * + * @see #setTickLabelFont(Font) + */ + public Font getTickLabelFont() { + return this.tickLabelFont; + } + + /** + * Sets the font used to display the tick labels and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getTickLabelFont() + */ + public void setTickLabelFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.tickLabelFont = font; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the paint used to draw the tick labels. + * + * @return The paint (null not permitted). + * + * @see #setTickLabelPaint(Paint) + */ + public Paint getTickLabelPaint() { + return this.tickLabelPaint; + } + + /** + * Sets the paint used to draw the tick labels and sends a + * {@link DialLayerChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + */ + public void setTickLabelPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.tickLabelPaint = paint; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns true if the tick labels should be displayed, + * and false otherwise. + * + * @return A boolean. + * + * @see #setTickLabelsVisible(boolean) + */ + public boolean getTickLabelsVisible() { + return this.tickLabelsVisible; + } + + /** + * Sets the flag that controls whether or not the tick labels are + * displayed, and sends a {@link DialLayerChangeEvent} to all registered + * listeners. + * + * @param visible the new flag value. + * + * @see #getTickLabelsVisible() + */ + public void setTickLabelsVisible(boolean visible) { + this.tickLabelsVisible = visible; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns the number formatter used to convert the tick label values to + * strings. + * + * @return The formatter (never null). + * + * @see #setTickLabelFormatter(NumberFormat) + */ + public NumberFormat getTickLabelFormatter() { + return this.tickLabelFormatter; + } + + /** + * Sets the number formatter used to convert the tick label values to + * strings, and sends a {@link DialLayerChangeEvent} to all registered + * listeners. + * + * @param formatter the formatter (null not permitted). + * + * @see #getTickLabelFormatter() + */ + public void setTickLabelFormatter(NumberFormat formatter) { + ParamChecks.nullNotPermitted(formatter, "formatter"); + this.tickLabelFormatter = formatter; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns a flag that controls whether or not the first tick label is + * visible. + * + * @return A boolean. + * + * @see #setFirstTickLabelVisible(boolean) + */ + public boolean getFirstTickLabelVisible() { + return this.firstTickLabelVisible; + } + + /** + * Sets a flag that controls whether or not the first tick label is + * visible, and sends a {@link DialLayerChangeEvent} to all registered + * listeners. + * + * @param visible the new flag value. + * + * @see #getFirstTickLabelVisible() + */ + public void setFirstTickLabelVisible(boolean visible) { + this.firstTickLabelVisible = visible; + notifyListeners(new DialLayerChangeEvent(this)); + } + + /** + * Returns true to indicate that this layer should be + * clipped within the dial window. + * + * @return true. + */ + @Override + public boolean isClippedToWindow() { + return true; + } + + /** + * Draws the scale on the dial plot. + * + * @param g2 the graphics target (null not permitted). + * @param plot the dial plot (null not permitted). + * @param frame the reference frame that is used to construct the + * geometry of the plot (null not permitted). + * @param view the visible part of the plot (null not + * permitted). + */ + @Override + public void draw(Graphics2D g2, DialPlot plot, Rectangle2D frame, + Rectangle2D view) { + + Rectangle2D arcRect = DialPlot.rectangleByRadius(frame, + this.tickRadius, this.tickRadius); + Rectangle2D arcRectMajor = DialPlot.rectangleByRadius(frame, + this.tickRadius - this.majorTickLength, + this.tickRadius - this.majorTickLength); + Rectangle2D arcRectMinor = arcRect; + if (this.minorTickCount > 0 && this.minorTickLength > 0.0) { + arcRectMinor = DialPlot.rectangleByRadius(frame, + this.tickRadius - this.minorTickLength, + this.tickRadius - this.minorTickLength); + } + Rectangle2D arcRectForLabels = DialPlot.rectangleByRadius(frame, + this.tickRadius - this.tickLabelOffset, + this.tickRadius - this.tickLabelOffset); + + boolean firstLabel = true; + + Arc2D arc = new Arc2D.Double(); + Line2D workingLine = new Line2D.Double(); + for (double v = this.lowerBound; v <= this.upperBound; + v += this.majorTickIncrement) { + arc.setArc(arcRect, this.startAngle, valueToAngle(v) + - this.startAngle, Arc2D.OPEN); + Point2D pt0 = arc.getEndPoint(); + arc.setArc(arcRectMajor, this.startAngle, valueToAngle(v) + - this.startAngle, Arc2D.OPEN); + Point2D pt1 = arc.getEndPoint(); + g2.setPaint(this.majorTickPaint); + g2.setStroke(this.majorTickStroke); + workingLine.setLine(pt0, pt1); + g2.draw(workingLine); + arc.setArc(arcRectForLabels, this.startAngle, valueToAngle(v) + - this.startAngle, Arc2D.OPEN); + Point2D pt2 = arc.getEndPoint(); + + if (this.tickLabelsVisible) { + if (!firstLabel || this.firstTickLabelVisible) { + g2.setFont(this.tickLabelFont); + g2.setPaint(this.tickLabelPaint); + TextUtilities.drawAlignedString( + this.tickLabelFormatter.format(v), g2, + (float) pt2.getX(), (float) pt2.getY(), + TextAnchor.CENTER); + } + } + firstLabel = false; + + // now do the minor tick marks + if (this.minorTickCount > 0 && this.minorTickLength > 0.0) { + double minorTickIncrement = this.majorTickIncrement + / (this.minorTickCount + 1); + for (int i = 0; i < this.minorTickCount; i++) { + double vv = v + ((i + 1) * minorTickIncrement); + if (vv >= this.upperBound) { + break; + } + double angle = valueToAngle(vv); + + arc.setArc(arcRect, this.startAngle, angle + - this.startAngle, Arc2D.OPEN); + pt0 = arc.getEndPoint(); + arc.setArc(arcRectMinor, this.startAngle, angle + - this.startAngle, Arc2D.OPEN); + Point2D pt3 = arc.getEndPoint(); + g2.setStroke(this.minorTickStroke); + g2.setPaint(this.minorTickPaint); + workingLine.setLine(pt0, pt3); + g2.draw(workingLine); + } + } + + } + } + + /** + * Converts a data value to an angle against this scale. + * + * @param value the data value. + * + * @return The angle (in degrees, using the same specification as Java's + * Arc2D class). + * + * @see #angleToValue(double) + */ + @Override + public double valueToAngle(double value) { + double range = this.upperBound - this.lowerBound; + double unit = this.extent / range; + return this.startAngle + unit * (value - this.lowerBound); + } + + /** + * Converts the given angle to a data value, based on this scale. + * + * @param angle the angle (in degrees). + * + * @return The data value. + * + * @see #valueToAngle(double) + */ + @Override + public double angleToValue(double angle) { + double range = this.upperBound - this.lowerBound; + double unit = range / this.extent; + return (angle - this.startAngle) * unit; + } + + /** + * Tests this StandardDialScale for equality with an arbitrary + * object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardDialScale)) { + return false; + } + StandardDialScale that = (StandardDialScale) obj; + if (this.lowerBound != that.lowerBound) { + return false; + } + if (this.upperBound != that.upperBound) { + return false; + } + if (this.startAngle != that.startAngle) { + return false; + } + if (this.extent != that.extent) { + return false; + } + if (this.tickRadius != that.tickRadius) { + return false; + } + if (this.majorTickIncrement != that.majorTickIncrement) { + return false; + } + if (this.majorTickLength != that.majorTickLength) { + return false; + } + if (!PaintUtilities.equal(this.majorTickPaint, that.majorTickPaint)) { + return false; + } + if (!this.majorTickStroke.equals(that.majorTickStroke)) { + return false; + } + if (this.minorTickCount != that.minorTickCount) { + return false; + } + if (this.minorTickLength != that.minorTickLength) { + return false; + } + if (!PaintUtilities.equal(this.minorTickPaint, that.minorTickPaint)) { + return false; + } + if (!this.minorTickStroke.equals(that.minorTickStroke)) { + return false; + } + if (this.tickLabelsVisible != that.tickLabelsVisible) { + return false; + } + if (this.tickLabelOffset != that.tickLabelOffset) { + return false; + } + if (!this.tickLabelFont.equals(that.tickLabelFont)) { + return false; + } + if (!PaintUtilities.equal(this.tickLabelPaint, that.tickLabelPaint)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 193; + // lowerBound + long temp = Double.doubleToLongBits(this.lowerBound); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + // upperBound + temp = Double.doubleToLongBits(this.upperBound); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + // startAngle + temp = Double.doubleToLongBits(this.startAngle); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + // extent + temp = Double.doubleToLongBits(this.extent); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + // tickRadius + temp = Double.doubleToLongBits(this.tickRadius); + result = 37 * result + (int) (temp ^ (temp >>> 32)); + // majorTickIncrement + // majorTickLength + // majorTickPaint + // majorTickStroke + // minorTickCount + // minorTickLength + // minorTickPaint + // minorTickStroke + // tickLabelOffset + // tickLabelFont + // tickLabelsVisible + // tickLabelFormatter + // firstTickLabelsVisible + return result; + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if this instance is not cloneable. + */ + @Override + 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.majorTickPaint, stream); + SerialUtilities.writeStroke(this.majorTickStroke, stream); + SerialUtilities.writePaint(this.minorTickPaint, stream); + SerialUtilities.writeStroke(this.minorTickStroke, stream); + SerialUtilities.writePaint(this.tickLabelPaint, 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.majorTickPaint = SerialUtilities.readPaint(stream); + this.majorTickStroke = SerialUtilities.readStroke(stream); + this.minorTickPaint = SerialUtilities.readPaint(stream); + this.minorTickStroke = SerialUtilities.readStroke(stream); + this.tickLabelPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/package.html new file mode 100755 index 0000000..521161f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/dial/package.html @@ -0,0 +1,6 @@ + + + +Classes for creating dial plots. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/package.html new file mode 100755 index 0000000..d5f0e49 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/plot/package.html @@ -0,0 +1,6 @@ + + + +Plot classes and related interfaces. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/AbstractRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/AbstractRenderer.java new file mode 100755 index 0000000..3c5add3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/AbstractRenderer.java @@ -0,0 +1,4118 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * AbstractRenderer.java + * --------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Nicolas Brodu; + * + * Changes: + * -------- + * 22-Aug-2002 : Version 1, draws code out of AbstractXYItemRenderer to share + * with AbstractCategoryItemRenderer (DG); + * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 06-Nov-2002 : Moved to the com.jrefinery.chart.renderer package (DG); + * 21-Nov-2002 : Added a paint table for the renderer to use (DG); + * 17-Jan-2003 : Moved plot classes into a separate package (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 29-Apr-2003 : Added valueLabelFont and valueLabelPaint attributes, based on + * code from Arnaud Lelievre (DG); + * 29-Jul-2003 : Amended code that doesn't compile with JDK 1.2.2 (DG); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 15-Sep-2003 : Fixed serialization (NB); + * 17-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 07-Oct-2003 : Moved PlotRenderingInfo into RendererState to allow for + * multiple threads using a single renderer (DG); + * 20-Oct-2003 : Added missing setOutlinePaint() method (DG); + * 23-Oct-2003 : Split item label attributes into 'positive' and 'negative' + * values (DG); + * 26-Nov-2003 : Added methods to get the positive and negative item label + * positions (DG); + * 01-Mar-2004 : Modified readObject() method to prevent null pointer exceptions + * after deserialization (DG); + * 19-Jul-2004 : Fixed bug in getItemLabelFont(int, int) method (DG); + * 04-Oct-2004 : Updated equals() method, eliminated use of NumberUtils, + * renamed BooleanUtils --> BooleanUtilities, ShapeUtils --> + * ShapeUtilities (DG); + * 15-Mar-2005 : Fixed serialization of baseFillPaint (DG); + * 16-May-2005 : Base outline stroke should never be null (DG); + * 01-Jun-2005 : Added hasListener() method for unit testing (DG); + * 08-Jun-2005 : Fixed equals() method to handle GradientPaint (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Minor API doc update (DG); + * 19-Feb-2007 : Fixes for clone() method (DG); + * 28-Feb-2007 : Use cached event to signal changes (DG); + * 19-Apr-2007 : Deprecated seriesVisible and seriesVisibleInLegend flags (DG); + * 20-Apr-2007 : Deprecated paint, fillPaint, outlinePaint, stroke, + * outlineStroke, shape, itemLabelsVisible, itemLabelFont, + * itemLabelPaint, positiveItemLabelPosition, + * negativeItemLabelPosition and createEntities override + * fields (DG); + * 13-Jun-2007 : Added new autoPopulate flags for core series attributes (DG); + * 23-Oct-2007 : Updated lookup methods to better handle overridden + * methods (DG); + * 04-Dec-2007 : Modified hashCode() implementation (DG); + * 29-Apr-2008 : Minor API doc update (DG); + * 17-Jun-2008 : Added legendShape, legendTextFont and legendTextPaint + * attributes (DG); + * 18-Aug-2008 : Added clearSeriesPaints() and clearSeriesStrokes() (DG); + * 28-Jan-2009 : Equals method doesn't test Shape equality correctly (DG); + * 27-Mar-2009 : Added dataBoundsIncludesVisibleSeriesOnly attribute, and + * updated renderer events for series visibility changes (DG); + * 01-Apr-2009 : Factored up the defaultEntityRadius field from the + * AbstractXYItemRenderer class (DG); + * 28-Apr-2009 : Added flag to allow a renderer to treat the legend shape as + * a line (DG); + * 05-Jul-2012 : No need for BooleanUtilities now that min JDK = 1.4.2 (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +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 java.util.Arrays; +import java.util.EventListener; +import java.util.List; + +import javax.swing.event.EventListenerList; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.event.RendererChangeListener; +import org.jfree.chart.labels.ItemLabelAnchor; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.plot.DrawingSupplier; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.title.LegendTitle; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.TextAnchor; +import org.jfree.util.BooleanList; +import org.jfree.util.ObjectList; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintList; +import org.jfree.util.PaintUtilities; +import org.jfree.util.ShapeList; +import org.jfree.util.ShapeUtilities; +import org.jfree.util.StrokeList; + +/** + * Base class providing common services for renderers. Most methods that update + * attributes of the renderer will fire a {@link RendererChangeEvent}, which + * normally means the plot that owns the renderer will receive notification that + * the renderer has been changed (the plot will, in turn, notify the chart). + */ +public abstract class AbstractRenderer implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -828267569428206075L; + + /** Zero represented as a Double. */ + public static final Double ZERO = new Double(0.0); + + /** The default paint. */ + public static final Paint DEFAULT_PAINT = Color.blue; + + /** The default outline paint. */ + public static final Paint DEFAULT_OUTLINE_PAINT = Color.gray; + + /** The default stroke. */ + public static final Stroke DEFAULT_STROKE = new BasicStroke(1.0f); + + /** The default outline stroke. */ + public static final Stroke DEFAULT_OUTLINE_STROKE = new BasicStroke(1.0f); + + /** The default shape. */ + public static final Shape DEFAULT_SHAPE + = new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0); + + /** The default value label font. */ + public static final Font DEFAULT_VALUE_LABEL_FONT + = new Font("SansSerif", Font.PLAIN, 10); + + /** The default value label paint. */ + public static final Paint DEFAULT_VALUE_LABEL_PAINT = Color.black; + + /** A list of flags that controls whether or not each series is visible. */ + private BooleanList seriesVisibleList; + + /** The default visibility for each series. */ + private boolean baseSeriesVisible; + + /** + * A list of flags that controls whether or not each series is visible in + * the legend. + */ + private BooleanList seriesVisibleInLegendList; + + /** The default visibility for each series in the legend. */ + private boolean baseSeriesVisibleInLegend; + + /** The paint list. */ + private PaintList paintList; + + /** + * A flag that controls whether or not the paintList is auto-populated + * in the {@link #lookupSeriesPaint(int)} method. + * + * @since 1.0.6 + */ + private boolean autoPopulateSeriesPaint; + + /** The base paint. */ + private transient Paint basePaint; + + /** The fill paint list. */ + private PaintList fillPaintList; + + /** + * A flag that controls whether or not the fillPaintList is auto-populated + * in the {@link #lookupSeriesFillPaint(int)} method. + * + * @since 1.0.6 + */ + private boolean autoPopulateSeriesFillPaint; + + /** The base fill paint. */ + private transient Paint baseFillPaint; + + /** The outline paint list. */ + private PaintList outlinePaintList; + + /** + * A flag that controls whether or not the outlinePaintList is + * auto-populated in the {@link #lookupSeriesOutlinePaint(int)} method. + * + * @since 1.0.6 + */ + private boolean autoPopulateSeriesOutlinePaint; + + /** The base outline paint. */ + private transient Paint baseOutlinePaint; + + /** The stroke list. */ + private StrokeList strokeList; + + /** + * A flag that controls whether or not the strokeList is auto-populated + * in the {@link #lookupSeriesStroke(int)} method. + * + * @since 1.0.6 + */ + private boolean autoPopulateSeriesStroke; + + /** The base stroke. */ + private transient Stroke baseStroke; + + /** The outline stroke list. */ + private StrokeList outlineStrokeList; + + /** The base outline stroke. */ + private transient Stroke baseOutlineStroke; + + /** + * A flag that controls whether or not the outlineStrokeList is + * auto-populated in the {@link #lookupSeriesOutlineStroke(int)} method. + * + * @since 1.0.6 + */ + private boolean autoPopulateSeriesOutlineStroke; + + /** A shape list. */ + private ShapeList shapeList; + + /** + * A flag that controls whether or not the shapeList is auto-populated + * in the {@link #lookupSeriesShape(int)} method. + * + * @since 1.0.6 + */ + private boolean autoPopulateSeriesShape; + + /** The base shape. */ + private transient Shape baseShape; + + /** Visibility of the item labels PER series. */ + private BooleanList itemLabelsVisibleList; + + /** The base item labels visible. */ + private Boolean baseItemLabelsVisible; + + /** The item label font list (one font per series). */ + private ObjectList itemLabelFontList; + + /** The base item label font. */ + private Font baseItemLabelFont; + + /** The item label paint list (one paint per series). */ + private PaintList itemLabelPaintList; + + /** The base item label paint. */ + private transient Paint baseItemLabelPaint; + + /** The positive item label position (per series). */ + private ObjectList positiveItemLabelPositionList; + + /** The fallback positive item label position. */ + private ItemLabelPosition basePositiveItemLabelPosition; + + /** The negative item label position (per series). */ + private ObjectList negativeItemLabelPositionList; + + /** The fallback negative item label position. */ + private ItemLabelPosition baseNegativeItemLabelPosition; + + /** The item label anchor offset. */ + private double itemLabelAnchorOffset = 2.0; + + /** + * Flags that control whether or not entities are generated for each + * series. This will be overridden by 'createEntities'. + */ + private BooleanList createEntitiesList; + + /** + * The default flag that controls whether or not entities are generated. + * This flag is used when both the above flags return null. + */ + private boolean baseCreateEntities; + + /** + * The per-series legend shape settings. + * + * @since 1.0.11 + */ + private ShapeList legendShapeList; + + /** + * The base shape for legend items. If this is null, the + * series shape will be used. + * + * @since 1.0.11 + */ + private transient Shape baseLegendShape; + + /** + * A special flag that, if true, will cause the getLegendItem() method + * to configure the legend shape as if it were a line. + * + * @since 1.0.14 + */ + private boolean treatLegendShapeAsLine; + + /** + * The per-series legend text font. + * + * @since 1.0.11 + */ + private ObjectList legendTextFont; + + /** + * The base legend font. + * + * @since 1.0.11 + */ + private Font baseLegendTextFont; + + /** + * The per series legend text paint settings. + * + * @since 1.0.11 + */ + private PaintList legendTextPaint; + + /** + * The default paint for the legend text items (if this is + * null, the {@link LegendTitle} class will determine the + * text paint to use. + * + * @since 1.0.11 + */ + private transient Paint baseLegendTextPaint; + + /** + * A flag that controls whether or not the renderer will include the + * non-visible series when calculating the data bounds. + * + * @since 1.0.13 + */ + private boolean dataBoundsIncludesVisibleSeriesOnly = true; + + /** The default radius for the entity 'hotspot' */ + private int defaultEntityRadius; + + /** Storage for registered change listeners. */ + private transient EventListenerList listenerList; + + /** An event for re-use. */ + private transient RendererChangeEvent event; + + /** + * Default constructor. + */ + public AbstractRenderer() { + + this.seriesVisible = null; + this.seriesVisibleList = new BooleanList(); + this.baseSeriesVisible = true; + + this.seriesVisibleInLegend = null; + this.seriesVisibleInLegendList = new BooleanList(); + this.baseSeriesVisibleInLegend = true; + + this.paint = null; + this.paintList = new PaintList(); + this.basePaint = DEFAULT_PAINT; + this.autoPopulateSeriesPaint = true; + + this.fillPaint = null; + this.fillPaintList = new PaintList(); + this.baseFillPaint = Color.white; + this.autoPopulateSeriesFillPaint = false; + + this.outlinePaint = null; + this.outlinePaintList = new PaintList(); + this.baseOutlinePaint = DEFAULT_OUTLINE_PAINT; + this.autoPopulateSeriesOutlinePaint = false; + + this.stroke = null; + this.strokeList = new StrokeList(); + this.baseStroke = DEFAULT_STROKE; + this.autoPopulateSeriesStroke = true; + + this.outlineStroke = null; + this.outlineStrokeList = new StrokeList(); + this.baseOutlineStroke = DEFAULT_OUTLINE_STROKE; + this.autoPopulateSeriesOutlineStroke = false; + + this.shape = null; + this.shapeList = new ShapeList(); + this.baseShape = DEFAULT_SHAPE; + this.autoPopulateSeriesShape = true; + + this.itemLabelsVisible = null; + this.itemLabelsVisibleList = new BooleanList(); + this.baseItemLabelsVisible = Boolean.FALSE; + + this.itemLabelFont = null; + this.itemLabelFontList = new ObjectList(); + this.baseItemLabelFont = new Font("SansSerif", Font.PLAIN, 10); + + this.itemLabelPaint = null; + this.itemLabelPaintList = new PaintList(); + this.baseItemLabelPaint = Color.black; + + this.positiveItemLabelPosition = null; + this.positiveItemLabelPositionList = new ObjectList(); + this.basePositiveItemLabelPosition = new ItemLabelPosition( + ItemLabelAnchor.OUTSIDE12, TextAnchor.BOTTOM_CENTER); + + this.negativeItemLabelPosition = null; + this.negativeItemLabelPositionList = new ObjectList(); + this.baseNegativeItemLabelPosition = new ItemLabelPosition( + ItemLabelAnchor.OUTSIDE6, TextAnchor.TOP_CENTER); + + this.createEntities = null; + this.createEntitiesList = new BooleanList(); + this.baseCreateEntities = true; + + this.defaultEntityRadius = 3; + + this.legendShapeList = new ShapeList(); + this.baseLegendShape = null; + + this.treatLegendShapeAsLine = false; + + this.legendTextFont = new ObjectList(); + this.baseLegendTextFont = null; + + this.legendTextPaint = new PaintList(); + this.baseLegendTextPaint = null; + + this.listenerList = new EventListenerList(); + + } + + /** + * Returns the drawing supplier from the plot. + * + * @return The drawing supplier. + */ + public abstract DrawingSupplier getDrawingSupplier(); + + // SERIES VISIBLE (not yet respected by all renderers) + + /** + * Returns a boolean that indicates whether or not the specified item + * should be drawn. + * + * @param series the series index. + * @param item the item index. + * + * @return A boolean. + */ + public boolean getItemVisible(int series, int item) { + return isSeriesVisible(series); + } + + /** + * Returns a boolean that indicates whether or not the specified series + * should be drawn. In fact this method should be named + * lookupSeriesVisible() to be consistent with the other series + * attributes and avoid confusion with the getSeriesVisible() method. + * + * @param series the series index. + * + * @return A boolean. + */ + public boolean isSeriesVisible(int series) { + boolean result = this.baseSeriesVisible; + if (this.seriesVisible != null) { + result = this.seriesVisible.booleanValue(); + } + else { + Boolean b = this.seriesVisibleList.getBoolean(series); + if (b != null) { + result = b.booleanValue(); + } + } + return result; + } + + /** + * Returns the flag that controls whether a series is visible. + * + * @param series the series index (zero-based). + * + * @return The flag (possibly null). + * + * @see #setSeriesVisible(int, Boolean) + */ + public Boolean getSeriesVisible(int series) { + return this.seriesVisibleList.getBoolean(series); + } + + /** + * Sets the flag that controls whether a series is visible and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the flag (null permitted). + * + * @see #getSeriesVisible(int) + */ + public void setSeriesVisible(int series, Boolean visible) { + setSeriesVisible(series, visible, true); + } + + /** + * Sets the flag that controls whether a series is visible and, if + * requested, sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index. + * @param visible the flag (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesVisible(int) + */ + public void setSeriesVisible(int series, Boolean visible, boolean notify) { + this.seriesVisibleList.setBoolean(series, visible); + if (notify) { + // we create an event with a special flag set...the purpose of + // this is to communicate to the plot (the default receiver of + // the event) that series visibility has changed so the axis + // ranges might need updating... + RendererChangeEvent e = new RendererChangeEvent(this, true); + notifyListeners(e); + } + } + + /** + * Returns the base visibility for all series. + * + * @return The base visibility. + * + * @see #setBaseSeriesVisible(boolean) + */ + public boolean getBaseSeriesVisible() { + return this.baseSeriesVisible; + } + + /** + * Sets the base visibility and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param visible the flag. + * + * @see #getBaseSeriesVisible() + */ + public void setBaseSeriesVisible(boolean visible) { + // defer argument checking... + setBaseSeriesVisible(visible, true); + } + + /** + * Sets the base visibility and, if requested, sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the visibility. + * @param notify notify listeners? + * + * @see #getBaseSeriesVisible() + */ + public void setBaseSeriesVisible(boolean visible, boolean notify) { + this.baseSeriesVisible = visible; + if (notify) { + // we create an event with a special flag set...the purpose of + // this is to communicate to the plot (the default receiver of + // the event) that series visibility has changed so the axis + // ranges might need updating... + RendererChangeEvent e = new RendererChangeEvent(this, true); + notifyListeners(e); + } + } + + // SERIES VISIBLE IN LEGEND (not yet respected by all renderers) + + /** + * Returns true if the series should be shown in the legend, + * and false otherwise. + * + * @param series the series index. + * + * @return A boolean. + */ + public boolean isSeriesVisibleInLegend(int series) { + boolean result = this.baseSeriesVisibleInLegend; + if (this.seriesVisibleInLegend != null) { + result = this.seriesVisibleInLegend.booleanValue(); + } + else { + Boolean b = this.seriesVisibleInLegendList.getBoolean(series); + if (b != null) { + result = b.booleanValue(); + } + } + return result; + } + + /** + * Returns the flag that controls whether a series is visible in the + * legend. This method returns only the "per series" settings - to + * incorporate the override and base settings as well, you need to use the + * {@link #isSeriesVisibleInLegend(int)} method. + * + * @param series the series index (zero-based). + * + * @return The flag (possibly null). + * + * @see #setSeriesVisibleInLegend(int, Boolean) + */ + public Boolean getSeriesVisibleInLegend(int series) { + return this.seriesVisibleInLegendList.getBoolean(series); + } + + /** + * Sets the flag that controls whether a series is visible in the legend + * and sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the flag (null permitted). + * + * @see #getSeriesVisibleInLegend(int) + */ + public void setSeriesVisibleInLegend(int series, Boolean visible) { + setSeriesVisibleInLegend(series, visible, true); + } + + /** + * Sets the flag that controls whether a series is visible in the legend + * and, if requested, sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index. + * @param visible the flag (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesVisibleInLegend(int) + */ + public void setSeriesVisibleInLegend(int series, Boolean visible, + boolean notify) { + this.seriesVisibleInLegendList.setBoolean(series, visible); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base visibility in the legend for all series. + * + * @return The base visibility. + * + * @see #setBaseSeriesVisibleInLegend(boolean) + */ + public boolean getBaseSeriesVisibleInLegend() { + return this.baseSeriesVisibleInLegend; + } + + /** + * Sets the base visibility in the legend and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the flag. + * + * @see #getBaseSeriesVisibleInLegend() + */ + public void setBaseSeriesVisibleInLegend(boolean visible) { + // defer argument checking... + setBaseSeriesVisibleInLegend(visible, true); + } + + /** + * Sets the base visibility in the legend and, if requested, sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the visibility. + * @param notify notify listeners? + * + * @see #getBaseSeriesVisibleInLegend() + */ + public void setBaseSeriesVisibleInLegend(boolean visible, boolean notify) { + this.baseSeriesVisibleInLegend = visible; + if (notify) { + fireChangeEvent(); + } + } + + // PAINT + + /** + * Returns the paint used to color data items as they are drawn. + *

+ * The default implementation passes control to the + * lookupSeriesPaint() method. You can override this method + * if you require different behaviour. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The paint (never null). + */ + public Paint getItemPaint(int row, int column) { + return lookupSeriesPaint(row); + } + + /** + * Returns the paint used to color an item drawn by the renderer. + * + * @param series the series index (zero-based). + * + * @return The paint (never null). + * + * @since 1.0.6 + */ + public Paint lookupSeriesPaint(int series) { + + // return the override, if there is one... + if (this.paint != null) { + return this.paint; + } + + // otherwise look up the paint list + Paint seriesPaint = getSeriesPaint(series); + if (seriesPaint == null && this.autoPopulateSeriesPaint) { + DrawingSupplier supplier = getDrawingSupplier(); + if (supplier != null) { + seriesPaint = supplier.getNextPaint(); + setSeriesPaint(series, seriesPaint, false); + } + } + if (seriesPaint == null) { + seriesPaint = this.basePaint; + } + return seriesPaint; + + } + + /** + * Returns the paint used to color an item drawn by the renderer. + * + * @param series the series index (zero-based). + * + * @return The paint (possibly null). + * + * @see #setSeriesPaint(int, Paint) + */ + public Paint getSeriesPaint(int series) { + return this.paintList.getPaint(series); + } + + /** + * Sets the paint used for a series and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param series the series index (zero-based). + * @param paint the paint (null permitted). + * + * @see #getSeriesPaint(int) + */ + public void setSeriesPaint(int series, Paint paint) { + setSeriesPaint(series, paint, true); + } + + /** + * Sets the paint used for a series and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index. + * @param paint the paint (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesPaint(int) + */ + public void setSeriesPaint(int series, Paint paint, boolean notify) { + this.paintList.setPaint(series, paint); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Clears the series paint settings for this renderer and, if requested, + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param notify notify listeners? + * + * @since 1.0.11 + */ + public void clearSeriesPaints(boolean notify) { + this.paintList.clear(); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base paint. + * + * @return The base paint (never null). + * + * @see #setBasePaint(Paint) + */ + public Paint getBasePaint() { + return this.basePaint; + } + + /** + * Sets the base paint and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getBasePaint() + */ + public void setBasePaint(Paint paint) { + // defer argument checking... + setBasePaint(paint, true); + } + + /** + * Sets the base paint and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * @param notify notify listeners? + * + * @see #getBasePaint() + */ + public void setBasePaint(Paint paint, boolean notify) { + this.basePaint = paint; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the flag that controls whether or not the series paint list is + * automatically populated when {@link #lookupSeriesPaint(int)} is called. + * + * @return A boolean. + * + * @since 1.0.6 + * + * @see #setAutoPopulateSeriesPaint(boolean) + */ + public boolean getAutoPopulateSeriesPaint() { + return this.autoPopulateSeriesPaint; + } + + /** + * Sets the flag that controls whether or not the series paint list is + * automatically populated when {@link #lookupSeriesPaint(int)} is called. + * + * @param auto the new flag value. + * + * @since 1.0.6 + * + * @see #getAutoPopulateSeriesPaint() + */ + public void setAutoPopulateSeriesPaint(boolean auto) { + this.autoPopulateSeriesPaint = auto; + } + + //// FILL PAINT ////////////////////////////////////////////////////////// + + /** + * Returns the paint used to fill data items as they are drawn. The + * default implementation passes control to the + * {@link #lookupSeriesFillPaint(int)} method - you can override this + * method if you require different behaviour. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The paint (never null). + */ + public Paint getItemFillPaint(int row, int column) { + return lookupSeriesFillPaint(row); + } + + /** + * Returns the paint used to fill an item drawn by the renderer. + * + * @param series the series (zero-based index). + * + * @return The paint (never null). + * + * @since 1.0.6 + */ + public Paint lookupSeriesFillPaint(int series) { + + // return the override, if there is one... + if (this.fillPaint != null) { + return this.fillPaint; + } + + // otherwise look up the paint table + Paint seriesFillPaint = getSeriesFillPaint(series); + if (seriesFillPaint == null && this.autoPopulateSeriesFillPaint) { + DrawingSupplier supplier = getDrawingSupplier(); + if (supplier != null) { + seriesFillPaint = supplier.getNextFillPaint(); + setSeriesFillPaint(series, seriesFillPaint, false); + } + } + if (seriesFillPaint == null) { + seriesFillPaint = this.baseFillPaint; + } + return seriesFillPaint; + + } + + /** + * Returns the paint used to fill an item drawn by the renderer. + * + * @param series the series (zero-based index). + * + * @return The paint (never null). + * + * @see #setSeriesFillPaint(int, Paint) + */ + public Paint getSeriesFillPaint(int series) { + return this.fillPaintList.getPaint(series); + } + + /** + * Sets the paint used for a series fill and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param paint the paint (null permitted). + * + * @see #getSeriesFillPaint(int) + */ + public void setSeriesFillPaint(int series, Paint paint) { + setSeriesFillPaint(series, paint, true); + } + + /** + * Sets the paint used to fill a series and, if requested, + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param paint the paint (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesFillPaint(int) + */ + public void setSeriesFillPaint(int series, Paint paint, boolean notify) { + this.fillPaintList.setPaint(series, paint); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base (or default) fill paint. + * + * @return The paint (never null). + * + * @see #setBaseFillPaint(Paint) + */ + public Paint getBaseFillPaint() { + return this.baseFillPaint; + } + + /** + * Sets the base fill paint and sends a {@link RendererChangeEvent} to + * all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getBaseFillPaint() + */ + public void setBaseFillPaint(Paint paint) { + // defer argument checking... + setBaseFillPaint(paint, true); + } + + /** + * Sets the base fill paint and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * @param notify notify listeners? + * + * @see #getBaseFillPaint() + */ + public void setBaseFillPaint(Paint paint, boolean notify) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.baseFillPaint = paint; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the flag that controls whether or not the series fill paint list + * is automatically populated when {@link #lookupSeriesFillPaint(int)} is + * called. + * + * @return A boolean. + * + * @since 1.0.6 + * + * @see #setAutoPopulateSeriesFillPaint(boolean) + */ + public boolean getAutoPopulateSeriesFillPaint() { + return this.autoPopulateSeriesFillPaint; + } + + /** + * Sets the flag that controls whether or not the series fill paint list is + * automatically populated when {@link #lookupSeriesFillPaint(int)} is + * called. + * + * @param auto the new flag value. + * + * @since 1.0.6 + * + * @see #getAutoPopulateSeriesFillPaint() + */ + public void setAutoPopulateSeriesFillPaint(boolean auto) { + this.autoPopulateSeriesFillPaint = auto; + } + + // OUTLINE PAINT ////////////////////////////////////////////////////////// + + /** + * Returns the paint used to outline data items as they are drawn. + *

+ * The default implementation passes control to the + * {@link #lookupSeriesOutlinePaint} method. You can override this method + * if you require different behaviour. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The paint (never null). + */ + public Paint getItemOutlinePaint(int row, int column) { + return lookupSeriesOutlinePaint(row); + } + + /** + * Returns the paint used to outline an item drawn by the renderer. + * + * @param series the series (zero-based index). + * + * @return The paint (never null). + * + * @since 1.0.6 + */ + public Paint lookupSeriesOutlinePaint(int series) { + + // return the override, if there is one... + if (this.outlinePaint != null) { + return this.outlinePaint; + } + + // otherwise look up the paint table + Paint seriesOutlinePaint = getSeriesOutlinePaint(series); + if (seriesOutlinePaint == null && this.autoPopulateSeriesOutlinePaint) { + DrawingSupplier supplier = getDrawingSupplier(); + if (supplier != null) { + seriesOutlinePaint = supplier.getNextOutlinePaint(); + setSeriesOutlinePaint(series, seriesOutlinePaint, false); + } + } + if (seriesOutlinePaint == null) { + seriesOutlinePaint = this.baseOutlinePaint; + } + return seriesOutlinePaint; + + } + + /** + * Returns the paint used to outline an item drawn by the renderer. + * + * @param series the series (zero-based index). + * + * @return The paint (possibly null). + * + * @see #setSeriesOutlinePaint(int, Paint) + */ + public Paint getSeriesOutlinePaint(int series) { + return this.outlinePaintList.getPaint(series); + } + + /** + * Sets the paint used for a series outline and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param paint the paint (null permitted). + * + * @see #getSeriesOutlinePaint(int) + */ + public void setSeriesOutlinePaint(int series, Paint paint) { + setSeriesOutlinePaint(series, paint, true); + } + + /** + * Sets the paint used to draw the outline for a series and, if requested, + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param paint the paint (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesOutlinePaint(int) + */ + public void setSeriesOutlinePaint(int series, Paint paint, boolean notify) { + this.outlinePaintList.setPaint(series, paint); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base (or default) outline paint. + * + * @return The paint (never null). + * + * @see #setBaseOutlinePaint(Paint) + */ + public Paint getBaseOutlinePaint() { + return this.baseOutlinePaint; + } + + /** + * Sets the base outline paint and sends a {@link RendererChangeEvent} to + * all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getBaseOutlinePaint() + */ + public void setBaseOutlinePaint(Paint paint) { + // defer argument checking... + setBaseOutlinePaint(paint, true); + } + + /** + * Sets the base outline paint and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * @param notify notify listeners? + * + * @see #getBaseOutlinePaint() + */ + public void setBaseOutlinePaint(Paint paint, boolean notify) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.baseOutlinePaint = paint; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the flag that controls whether or not the series outline paint + * list is automatically populated when + * {@link #lookupSeriesOutlinePaint(int)} is called. + * + * @return A boolean. + * + * @since 1.0.6 + * + * @see #setAutoPopulateSeriesOutlinePaint(boolean) + */ + public boolean getAutoPopulateSeriesOutlinePaint() { + return this.autoPopulateSeriesOutlinePaint; + } + + /** + * Sets the flag that controls whether or not the series outline paint list + * is automatically populated when {@link #lookupSeriesOutlinePaint(int)} + * is called. + * + * @param auto the new flag value. + * + * @since 1.0.6 + * + * @see #getAutoPopulateSeriesOutlinePaint() + */ + public void setAutoPopulateSeriesOutlinePaint(boolean auto) { + this.autoPopulateSeriesOutlinePaint = auto; + } + + // STROKE + + /** + * Returns the stroke used to draw data items. + *

+ * The default implementation passes control to the getSeriesStroke method. + * You can override this method if you require different behaviour. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The stroke (never null). + */ + public Stroke getItemStroke(int row, int column) { + return lookupSeriesStroke(row); + } + + /** + * Returns the stroke used to draw the items in a series. + * + * @param series the series (zero-based index). + * + * @return The stroke (never null). + * + * @since 1.0.6 + */ + public Stroke lookupSeriesStroke(int series) { + + // return the override, if there is one... + if (this.stroke != null) { + return this.stroke; + } + + // otherwise look up the paint table + Stroke result = getSeriesStroke(series); + if (result == null && this.autoPopulateSeriesStroke) { + DrawingSupplier supplier = getDrawingSupplier(); + if (supplier != null) { + result = supplier.getNextStroke(); + setSeriesStroke(series, result, false); + } + } + if (result == null) { + result = this.baseStroke; + } + return result; + + } + + /** + * Returns the stroke used to draw the items in a series. + * + * @param series the series (zero-based index). + * + * @return The stroke (possibly null). + * + * @see #setSeriesStroke(int, Stroke) + */ + public Stroke getSeriesStroke(int series) { + return this.strokeList.getStroke(series); + } + + /** + * Sets the stroke used for a series and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param series the series index (zero-based). + * @param stroke the stroke (null permitted). + * + * @see #getSeriesStroke(int) + */ + public void setSeriesStroke(int series, Stroke stroke) { + setSeriesStroke(series, stroke, true); + } + + /** + * Sets the stroke for a series and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param stroke the stroke (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesStroke(int) + */ + public void setSeriesStroke(int series, Stroke stroke, boolean notify) { + this.strokeList.setStroke(series, stroke); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Clears the series stroke settings for this renderer and, if requested, + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param notify notify listeners? + * + * @since 1.0.11 + */ + public void clearSeriesStrokes(boolean notify) { + this.strokeList.clear(); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base (or default) stroke. + * + * @return The base stroke (never null). + * + * @see #setBaseStroke(Stroke) + */ + public Stroke getBaseStroke() { + return this.baseStroke; + } + + /** + * Sets the base stroke and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getBaseStroke() + */ + public void setBaseStroke(Stroke stroke) { + // defer argument checking... + setBaseStroke(stroke, true); + } + + /** + * Sets the base stroke and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * @param notify notify listeners? + * + * @see #getBaseStroke() + */ + public void setBaseStroke(Stroke stroke, boolean notify) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.baseStroke = stroke; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the flag that controls whether or not the series stroke list is + * automatically populated when {@link #lookupSeriesStroke(int)} is called. + * + * @return A boolean. + * + * @since 1.0.6 + * + * @see #setAutoPopulateSeriesStroke(boolean) + */ + public boolean getAutoPopulateSeriesStroke() { + return this.autoPopulateSeriesStroke; + } + + /** + * Sets the flag that controls whether or not the series stroke list is + * automatically populated when {@link #lookupSeriesStroke(int)} is called. + * + * @param auto the new flag value. + * + * @since 1.0.6 + * + * @see #getAutoPopulateSeriesStroke() + */ + public void setAutoPopulateSeriesStroke(boolean auto) { + this.autoPopulateSeriesStroke = auto; + } + + // OUTLINE STROKE + + /** + * Returns the stroke used to outline data items. The default + * implementation passes control to the + * {@link #lookupSeriesOutlineStroke(int)} method. You can override this + * method if you require different behaviour. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The stroke (never null). + */ + public Stroke getItemOutlineStroke(int row, int column) { + return lookupSeriesOutlineStroke(row); + } + + /** + * Returns the stroke used to outline the items in a series. + * + * @param series the series (zero-based index). + * + * @return The stroke (never null). + * + * @since 1.0.6 + */ + public Stroke lookupSeriesOutlineStroke(int series) { + + // return the override, if there is one... + if (this.outlineStroke != null) { + return this.outlineStroke; + } + + // otherwise look up the stroke table + Stroke result = getSeriesOutlineStroke(series); + if (result == null && this.autoPopulateSeriesOutlineStroke) { + DrawingSupplier supplier = getDrawingSupplier(); + if (supplier != null) { + result = supplier.getNextOutlineStroke(); + setSeriesOutlineStroke(series, result, false); + } + } + if (result == null) { + result = this.baseOutlineStroke; + } + return result; + + } + + /** + * Returns the stroke used to outline the items in a series. + * + * @param series the series (zero-based index). + * + * @return The stroke (possibly null). + * + * @see #setSeriesOutlineStroke(int, Stroke) + */ + public Stroke getSeriesOutlineStroke(int series) { + return this.outlineStrokeList.getStroke(series); + } + + /** + * Sets the outline stroke used for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param stroke the stroke (null permitted). + * + * @see #getSeriesOutlineStroke(int) + */ + public void setSeriesOutlineStroke(int series, Stroke stroke) { + setSeriesOutlineStroke(series, stroke, true); + } + + /** + * Sets the outline stroke for a series and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index. + * @param stroke the stroke (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesOutlineStroke(int) + */ + public void setSeriesOutlineStroke(int series, Stroke stroke, + boolean notify) { + this.outlineStrokeList.setStroke(series, stroke); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base (or default) outline stroke. + * + * @return The stroke (never null). + * + * @see #setBaseOutlineStroke(Stroke) + */ + public Stroke getBaseOutlineStroke() { + return this.baseOutlineStroke; + } + + /** + * Sets the base outline stroke and sends a {@link RendererChangeEvent} to + * all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getBaseOutlineStroke() + */ + public void setBaseOutlineStroke(Stroke stroke) { + setBaseOutlineStroke(stroke, true); + } + + /** + * Sets the base outline stroke and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @see #getBaseOutlineStroke() + */ + public void setBaseOutlineStroke(Stroke stroke, boolean notify) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.baseOutlineStroke = stroke; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the flag that controls whether or not the series outline stroke + * list is automatically populated when + * {@link #lookupSeriesOutlineStroke(int)} is called. + * + * @return A boolean. + * + * @since 1.0.6 + * + * @see #setAutoPopulateSeriesOutlineStroke(boolean) + */ + public boolean getAutoPopulateSeriesOutlineStroke() { + return this.autoPopulateSeriesOutlineStroke; + } + + /** + * Sets the flag that controls whether or not the series outline stroke list + * is automatically populated when {@link #lookupSeriesOutlineStroke(int)} + * is called. + * + * @param auto the new flag value. + * + * @since 1.0.6 + * + * @see #getAutoPopulateSeriesOutlineStroke() + */ + public void setAutoPopulateSeriesOutlineStroke(boolean auto) { + this.autoPopulateSeriesOutlineStroke = auto; + } + + // SHAPE + + /** + * Returns a shape used to represent a data item. + *

+ * The default implementation passes control to the + * {@link #lookupSeriesShape(int)} method. You can override this method if + * you require different behaviour. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The shape (never null). + */ + public Shape getItemShape(int row, int column) { + return lookupSeriesShape(row); + } + + /** + * Returns a shape used to represent the items in a series. + * + * @param series the series (zero-based index). + * + * @return The shape (never null). + * + * @since 1.0.6 + */ + public Shape lookupSeriesShape(int series) { + + // return the override, if there is one... + if (this.shape != null) { + return this.shape; + } + + // otherwise look up the shape list + Shape result = getSeriesShape(series); + if (result == null && this.autoPopulateSeriesShape) { + DrawingSupplier supplier = getDrawingSupplier(); + if (supplier != null) { + result = supplier.getNextShape(); + setSeriesShape(series, result, false); + } + } + if (result == null) { + result = this.baseShape; + } + return result; + + } + + /** + * Returns a shape used to represent the items in a series. + * + * @param series the series (zero-based index). + * + * @return The shape (possibly null). + * + * @see #setSeriesShape(int, Shape) + */ + public Shape getSeriesShape(int series) { + return this.shapeList.getShape(series); + } + + /** + * Sets the shape used for a series and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param series the series index (zero-based). + * @param shape the shape (null permitted). + * + * @see #getSeriesShape(int) + */ + public void setSeriesShape(int series, Shape shape) { + setSeriesShape(series, shape, true); + } + + /** + * Sets the shape for a series and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero based). + * @param shape the shape (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesShape(int) + */ + public void setSeriesShape(int series, Shape shape, boolean notify) { + this.shapeList.setShape(series, shape); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base (or default) shape. + * + * @return The shape (never null). + * + * @see #setBaseShape(Shape) + */ + public Shape getBaseShape() { + return this.baseShape; + } + + /** + * Sets the base shape and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param shape the shape (null not permitted). + * + * @see #getBaseShape() + */ + public void setBaseShape(Shape shape) { + // defer argument checking... + setBaseShape(shape, true); + } + + /** + * Sets the base shape and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param shape the shape (null not permitted). + * @param notify notify listeners? + * + * @see #getBaseShape() + */ + public void setBaseShape(Shape shape, boolean notify) { + ParamChecks.nullNotPermitted(shape, "shape"); + this.baseShape = shape; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the flag that controls whether or not the series shape list is + * automatically populated when {@link #lookupSeriesShape(int)} is called. + * + * @return A boolean. + * + * @since 1.0.6 + * + * @see #setAutoPopulateSeriesShape(boolean) + */ + public boolean getAutoPopulateSeriesShape() { + return this.autoPopulateSeriesShape; + } + + /** + * Sets the flag that controls whether or not the series shape list is + * automatically populated when {@link #lookupSeriesShape(int)} is called. + * + * @param auto the new flag value. + * + * @since 1.0.6 + * + * @see #getAutoPopulateSeriesShape() + */ + public void setAutoPopulateSeriesShape(boolean auto) { + this.autoPopulateSeriesShape = auto; + } + + // ITEM LABEL VISIBILITY... + + /** + * Returns true if an item label is visible, and + * false otherwise. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return A boolean. + */ + public boolean isItemLabelVisible(int row, int column) { + return isSeriesItemLabelsVisible(row); + } + + /** + * Returns true if the item labels for a series are visible, + * and false otherwise. + * + * @param series the series index (zero-based). + * + * @return A boolean. + */ + public boolean isSeriesItemLabelsVisible(int series) { + + // return the override, if there is one... + if (this.itemLabelsVisible != null) { + return this.itemLabelsVisible.booleanValue(); + } + + // otherwise look up the boolean table + Boolean b = this.itemLabelsVisibleList.getBoolean(series); + if (b == null) { + b = this.baseItemLabelsVisible; + } + if (b == null) { + b = Boolean.FALSE; + } + return b.booleanValue(); + + } + + /** + * Sets a flag that controls the visibility of the item labels for a series, + * and sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the flag. + */ + public void setSeriesItemLabelsVisible(int series, boolean visible) { + setSeriesItemLabelsVisible(series, Boolean.valueOf(visible)); + } + + /** + * Sets the visibility of the item labels for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the flag (null permitted). + */ + public void setSeriesItemLabelsVisible(int series, Boolean visible) { + setSeriesItemLabelsVisible(series, visible, true); + } + + /** + * Sets the visibility of item labels for a series and, if requested, sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the visible flag. + * @param notify a flag that controls whether or not listeners are + * notified. + */ + public void setSeriesItemLabelsVisible(int series, Boolean visible, + boolean notify) { + this.itemLabelsVisibleList.setBoolean(series, visible); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base setting for item label visibility. A null + * result should be interpreted as equivalent to Boolean.FALSE. + * + * @return A flag (possibly null). + * + * @see #setBaseItemLabelsVisible(boolean) + */ + public Boolean getBaseItemLabelsVisible() { + // this should have been defined as a boolean primitive, because + // allowing null values is a nuisance...but it is part of the final + // API now, so we'll have to support it. + return this.baseItemLabelsVisible; + } + + /** + * Sets the base flag that controls whether or not item labels are visible, + * and sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the flag. + * + * @see #getBaseItemLabelsVisible() + */ + public void setBaseItemLabelsVisible(boolean visible) { + setBaseItemLabelsVisible(Boolean.valueOf(visible)); + } + + /** + * Sets the base setting for item label visibility and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the flag (null is permitted, and viewed + * as equivalent to Boolean.FALSE). + */ + public void setBaseItemLabelsVisible(Boolean visible) { + setBaseItemLabelsVisible(visible, true); + } + + /** + * Sets the base visibility for item labels and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the flag (null is permitted, and viewed + * as equivalent to Boolean.FALSE). + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @see #getBaseItemLabelsVisible() + */ + public void setBaseItemLabelsVisible(Boolean visible, boolean notify) { + this.baseItemLabelsVisible = visible; + if (notify) { + fireChangeEvent(); + } + } + + //// ITEM LABEL FONT ////////////////////////////////////////////////////// + + /** + * Returns the font for an item label. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The font (never null). + */ + public Font getItemLabelFont(int row, int column) { + Font result = this.itemLabelFont; + if (result == null) { + result = getSeriesItemLabelFont(row); + if (result == null) { + result = this.baseItemLabelFont; + } + } + return result; + } + + /** + * Returns the font for all the item labels in a series. + * + * @param series the series index (zero-based). + * + * @return The font (possibly null). + * + * @see #setSeriesItemLabelFont(int, Font) + */ + public Font getSeriesItemLabelFont(int series) { + return (Font) this.itemLabelFontList.get(series); + } + + /** + * Sets the item label font for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param font the font (null permitted). + * + * @see #getSeriesItemLabelFont(int) + */ + public void setSeriesItemLabelFont(int series, Font font) { + setSeriesItemLabelFont(series, font, true); + } + + /** + * Sets the item label font for a series and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero based). + * @param font the font (null permitted). + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @see #getSeriesItemLabelFont(int) + */ + public void setSeriesItemLabelFont(int series, Font font, boolean notify) { + this.itemLabelFontList.set(series, font); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base item label font (this is used when no other font + * setting is available). + * + * @return The font (never null). + * + * @see #setBaseItemLabelFont(Font) + */ + public Font getBaseItemLabelFont() { + return this.baseItemLabelFont; + } + + /** + * Sets the base item label font and sends a {@link RendererChangeEvent} to + * all registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getBaseItemLabelFont() + */ + public void setBaseItemLabelFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + setBaseItemLabelFont(font, true); + } + + /** + * Sets the base item label font and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param font the font (null not permitted). + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @see #getBaseItemLabelFont() + */ + public void setBaseItemLabelFont(Font font, boolean notify) { + this.baseItemLabelFont = font; + if (notify) { + fireChangeEvent(); + } + } + + //// ITEM LABEL PAINT //////////////////////////////////////////////////// + + /** + * Returns the paint used to draw an item label. + * + * @param row the row index (zero based). + * @param column the column index (zero based). + * + * @return The paint (never null). + */ + public Paint getItemLabelPaint(int row, int column) { + Paint result = this.itemLabelPaint; + if (result == null) { + result = getSeriesItemLabelPaint(row); + if (result == null) { + result = this.baseItemLabelPaint; + } + } + return result; + } + + /** + * Returns the paint used to draw the item labels for a series. + * + * @param series the series index (zero based). + * + * @return The paint (possibly null). + * + * @see #setSeriesItemLabelPaint(int, Paint) + */ + public Paint getSeriesItemLabelPaint(int series) { + return this.itemLabelPaintList.getPaint(series); + } + + /** + * Sets the item label paint for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series (zero based index). + * @param paint the paint (null permitted). + * + * @see #getSeriesItemLabelPaint(int) + */ + public void setSeriesItemLabelPaint(int series, Paint paint) { + setSeriesItemLabelPaint(series, paint, true); + } + + /** + * Sets the item label paint for a series and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero based). + * @param paint the paint (null permitted). + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @see #getSeriesItemLabelPaint(int) + */ + public void setSeriesItemLabelPaint(int series, Paint paint, + boolean notify) { + this.itemLabelPaintList.setPaint(series, paint); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base item label paint. + * + * @return The paint (never null). + * + * @see #setBaseItemLabelPaint(Paint) + */ + public Paint getBaseItemLabelPaint() { + return this.baseItemLabelPaint; + } + + /** + * Sets the base item label paint and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getBaseItemLabelPaint() + */ + public void setBaseItemLabelPaint(Paint paint) { + // defer argument checking... + setBaseItemLabelPaint(paint, true); + } + + /** + * Sets the base item label paint and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners.. + * + * @param paint the paint (null not permitted). + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @see #getBaseItemLabelPaint() + */ + public void setBaseItemLabelPaint(Paint paint, boolean notify) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.baseItemLabelPaint = paint; + if (notify) { + fireChangeEvent(); + } + } + + // POSITIVE ITEM LABEL POSITION... + + /** + * Returns the item label position for positive values. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The item label position (never null). + * + * @see #getNegativeItemLabelPosition(int, int) + */ + public ItemLabelPosition getPositiveItemLabelPosition(int row, int column) { + return getSeriesPositiveItemLabelPosition(row); + } + + /** + * Returns the item label position for all positive values in a series. + * + * @param series the series index (zero-based). + * + * @return The item label position (never null). + * + * @see #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition) + */ + public ItemLabelPosition getSeriesPositiveItemLabelPosition(int series) { + + // return the override, if there is one... + if (this.positiveItemLabelPosition != null) { + return this.positiveItemLabelPosition; + } + + // otherwise look up the position table + ItemLabelPosition position = (ItemLabelPosition) + this.positiveItemLabelPositionList.get(series); + if (position == null) { + position = this.basePositiveItemLabelPosition; + } + return position; + + } + + /** + * Sets the item label position for all positive values in a series and + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param position the position (null permitted). + * + * @see #getSeriesPositiveItemLabelPosition(int) + */ + public void setSeriesPositiveItemLabelPosition(int series, + ItemLabelPosition position) { + setSeriesPositiveItemLabelPosition(series, position, true); + } + + /** + * Sets the item label position for all positive values in a series and (if + * requested) sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index (zero-based). + * @param position the position (null permitted). + * @param notify notify registered listeners? + * + * @see #getSeriesPositiveItemLabelPosition(int) + */ + public void setSeriesPositiveItemLabelPosition(int series, + ItemLabelPosition position, + boolean notify) { + this.positiveItemLabelPositionList.set(series, position); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base positive item label position. + * + * @return The position (never null). + * + * @see #setBasePositiveItemLabelPosition(ItemLabelPosition) + */ + public ItemLabelPosition getBasePositiveItemLabelPosition() { + return this.basePositiveItemLabelPosition; + } + + /** + * Sets the base positive item label position. + * + * @param position the position (null not permitted). + * + * @see #getBasePositiveItemLabelPosition() + */ + public void setBasePositiveItemLabelPosition(ItemLabelPosition position) { + // defer argument checking... + setBasePositiveItemLabelPosition(position, true); + } + + /** + * Sets the base positive item label position and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param position the position (null not permitted). + * @param notify notify registered listeners? + * + * @see #getBasePositiveItemLabelPosition() + */ + public void setBasePositiveItemLabelPosition(ItemLabelPosition position, + boolean notify) { + ParamChecks.nullNotPermitted(position, "position"); + this.basePositiveItemLabelPosition = position; + if (notify) { + fireChangeEvent(); + } + } + + // NEGATIVE ITEM LABEL POSITION... + + /** + * Returns the item label position for negative values. This method can be + * overridden to provide customisation of the item label position for + * individual data items. + * + * @param row the row index (zero-based). + * @param column the column (zero-based). + * + * @return The item label position (never null). + * + * @see #getPositiveItemLabelPosition(int, int) + */ + public ItemLabelPosition getNegativeItemLabelPosition(int row, int column) { + return getSeriesNegativeItemLabelPosition(row); + } + + /** + * Returns the item label position for all negative values in a series. + * + * @param series the series index (zero-based). + * + * @return The item label position (never null). + * + * @see #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition) + */ + public ItemLabelPosition getSeriesNegativeItemLabelPosition(int series) { + + // return the override, if there is one... + if (this.negativeItemLabelPosition != null) { + return this.negativeItemLabelPosition; + } + + // otherwise look up the position list + ItemLabelPosition position = (ItemLabelPosition) + this.negativeItemLabelPositionList.get(series); + if (position == null) { + position = this.baseNegativeItemLabelPosition; + } + return position; + + } + + /** + * Sets the item label position for negative values in a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param position the position (null permitted). + * + * @see #getSeriesNegativeItemLabelPosition(int) + */ + public void setSeriesNegativeItemLabelPosition(int series, + ItemLabelPosition position) { + setSeriesNegativeItemLabelPosition(series, position, true); + } + + /** + * Sets the item label position for negative values in a series and (if + * requested) sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index (zero-based). + * @param position the position (null permitted). + * @param notify notify registered listeners? + * + * @see #getSeriesNegativeItemLabelPosition(int) + */ + public void setSeriesNegativeItemLabelPosition(int series, + ItemLabelPosition position, + boolean notify) { + this.negativeItemLabelPositionList.set(series, position); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base item label position for negative values. + * + * @return The position (never null). + * + * @see #setBaseNegativeItemLabelPosition(ItemLabelPosition) + */ + public ItemLabelPosition getBaseNegativeItemLabelPosition() { + return this.baseNegativeItemLabelPosition; + } + + /** + * Sets the base item label position for negative values and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param position the position (null not permitted). + * + * @see #getBaseNegativeItemLabelPosition() + */ + public void setBaseNegativeItemLabelPosition(ItemLabelPosition position) { + setBaseNegativeItemLabelPosition(position, true); + } + + /** + * Sets the base negative item label position and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param position the position (null not permitted). + * @param notify notify registered listeners? + * + * @see #getBaseNegativeItemLabelPosition() + */ + public void setBaseNegativeItemLabelPosition(ItemLabelPosition position, + boolean notify) { + ParamChecks.nullNotPermitted(position, "position"); + this.baseNegativeItemLabelPosition = position; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the item label anchor offset. + * + * @return The offset. + * + * @see #setItemLabelAnchorOffset(double) + */ + public double getItemLabelAnchorOffset() { + return this.itemLabelAnchorOffset; + } + + /** + * Sets the item label anchor offset. + * + * @param offset the offset. + * + * @see #getItemLabelAnchorOffset() + */ + public void setItemLabelAnchorOffset(double offset) { + this.itemLabelAnchorOffset = offset; + fireChangeEvent(); + } + + /** + * Returns a boolean that indicates whether or not the specified item + * should have a chart entity created for it. + * + * @param series the series index. + * @param item the item index. + * + * @return A boolean. + */ + public boolean getItemCreateEntity(int series, int item) { + if (this.createEntities != null) { + return this.createEntities.booleanValue(); + } + else { + Boolean b = getSeriesCreateEntities(series); + if (b != null) { + return b.booleanValue(); + } + else { + return this.baseCreateEntities; + } + } + } + + /** + * Returns the flag that controls whether entities are created for a + * series. + * + * @param series the series index (zero-based). + * + * @return The flag (possibly null). + * + * @see #setSeriesCreateEntities(int, Boolean) + */ + public Boolean getSeriesCreateEntities(int series) { + return this.createEntitiesList.getBoolean(series); + } + + /** + * Sets the flag that controls whether entities are created for a series, + * and sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param create the flag (null permitted). + * + * @see #getSeriesCreateEntities(int) + */ + public void setSeriesCreateEntities(int series, Boolean create) { + setSeriesCreateEntities(series, create, true); + } + + /** + * Sets the flag that controls whether entities are created for a series + * and, if requested, sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index. + * @param create the flag (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesCreateEntities(int) + */ + public void setSeriesCreateEntities(int series, Boolean create, + boolean notify) { + this.createEntitiesList.setBoolean(series, create); + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the base visibility for all series. + * + * @return The base visibility. + * + * @see #setBaseCreateEntities(boolean) + */ + public boolean getBaseCreateEntities() { + return this.baseCreateEntities; + } + + /** + * Sets the base flag that controls whether entities are created + * for a series, and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param create the flag. + * + * @see #getBaseCreateEntities() + */ + public void setBaseCreateEntities(boolean create) { + // defer argument checking... + setBaseCreateEntities(create, true); + } + + /** + * Sets the base flag that controls whether entities are created and, + * if requested, sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param create the visibility. + * @param notify notify listeners? + * + * @see #getBaseCreateEntities() + */ + public void setBaseCreateEntities(boolean create, boolean notify) { + this.baseCreateEntities = create; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the radius of the circle used for the default entity area + * when no area is specified. + * + * @return A radius. + * + * @see #setDefaultEntityRadius(int) + */ + public int getDefaultEntityRadius() { + return this.defaultEntityRadius; + } + + /** + * Sets the radius of the circle used for the default entity area + * when no area is specified. + * + * @param radius the radius. + * + * @see #getDefaultEntityRadius() + */ + public void setDefaultEntityRadius(int radius) { + this.defaultEntityRadius = radius; + } + + /** + * Performs a lookup for the legend shape. + * + * @param series the series index. + * + * @return The shape (possibly null). + * + * @since 1.0.11 + */ + public Shape lookupLegendShape(int series) { + Shape result = getLegendShape(series); + if (result == null) { + result = this.baseLegendShape; + } + if (result == null) { + result = lookupSeriesShape(series); + } + return result; + } + + /** + * Returns the legend shape defined for the specified series (possibly + * null). + * + * @param series the series index. + * + * @return The shape (possibly null). + * + * @see #lookupLegendShape(int) + * + * @since 1.0.11 + */ + public Shape getLegendShape(int series) { + return this.legendShapeList.getShape(series); + } + + /** + * Sets the shape used for the legend item for the specified series, and + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index. + * @param shape the shape (null permitted). + * + * @since 1.0.11 + */ + public void setLegendShape(int series, Shape shape) { + this.legendShapeList.setShape(series, shape); + fireChangeEvent(); + } + + /** + * Returns the default legend shape, which may be null. + * + * @return The default legend shape. + * + * @since 1.0.11 + */ + public Shape getBaseLegendShape() { + return this.baseLegendShape; + } + + /** + * Sets the default legend shape and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param shape the shape (null permitted). + * + * @since 1.0.11 + */ + public void setBaseLegendShape(Shape shape) { + this.baseLegendShape = shape; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not the legend shape is + * treated as a line when creating legend items. + * + * @return A boolean. + * + * @since 1.0.14 + */ + protected boolean getTreatLegendShapeAsLine() { + return this.treatLegendShapeAsLine; + } + + /** + * Sets the flag that controls whether or not the legend shape is + * treated as a line when creating legend items. + * + * @param treatAsLine the new flag value. + * + * @since 1.0.14 + */ + protected void setTreatLegendShapeAsLine(boolean treatAsLine) { + if (this.treatLegendShapeAsLine != treatAsLine) { + this.treatLegendShapeAsLine = treatAsLine; + fireChangeEvent(); + } + } + + /** + * Performs a lookup for the legend text font. + * + * @param series the series index. + * + * @return The font (possibly null). + * + * @since 1.0.11 + */ + public Font lookupLegendTextFont(int series) { + Font result = getLegendTextFont(series); + if (result == null) { + result = this.baseLegendTextFont; + } + return result; + } + + /** + * Returns the legend text font defined for the specified series (possibly + * null). + * + * @param series the series index. + * + * @return The font (possibly null). + * + * @see #lookupLegendTextFont(int) + * + * @since 1.0.11 + */ + public Font getLegendTextFont(int series) { + return (Font) this.legendTextFont.get(series); + } + + /** + * Sets the font used for the legend text for the specified series, and + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index. + * @param font the font (null permitted). + * + * @since 1.0.11 + */ + public void setLegendTextFont(int series, Font font) { + this.legendTextFont.set(series, font); + fireChangeEvent(); + } + + /** + * Returns the default legend text font, which may be null. + * + * @return The default legend text font. + * + * @since 1.0.11 + */ + public Font getBaseLegendTextFont() { + return this.baseLegendTextFont; + } + + /** + * Sets the default legend text font and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param font the font (null permitted). + * + * @since 1.0.11 + */ + public void setBaseLegendTextFont(Font font) { + this.baseLegendTextFont = font; + fireChangeEvent(); + } + + /** + * Performs a lookup for the legend text paint. + * + * @param series the series index. + * + * @return The paint (possibly null). + * + * @since 1.0.11 + */ + public Paint lookupLegendTextPaint(int series) { + Paint result = getLegendTextPaint(series); + if (result == null) { + result = this.baseLegendTextPaint; + } + return result; + } + + /** + * Returns the legend text paint defined for the specified series (possibly + * null). + * + * @param series the series index. + * + * @return The paint (possibly null). + * + * @see #lookupLegendTextPaint(int) + * + * @since 1.0.11 + */ + public Paint getLegendTextPaint(int series) { + return this.legendTextPaint.getPaint(series); + } + + /** + * Sets the paint used for the legend text for the specified series, and + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index. + * @param paint the paint (null permitted). + * + * @since 1.0.11 + */ + public void setLegendTextPaint(int series, Paint paint) { + this.legendTextPaint.setPaint(series, paint); + fireChangeEvent(); + } + + /** + * Returns the default legend text paint, which may be null. + * + * @return The default legend text paint. + * + * @since 1.0.11 + */ + public Paint getBaseLegendTextPaint() { + return this.baseLegendTextPaint; + } + + /** + * Sets the default legend text paint and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @since 1.0.11 + */ + public void setBaseLegendTextPaint(Paint paint) { + this.baseLegendTextPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not the data bounds reported + * by this renderer will exclude non-visible series. + * + * @return A boolean. + * + * @since 1.0.13 + */ + public boolean getDataBoundsIncludesVisibleSeriesOnly() { + return this.dataBoundsIncludesVisibleSeriesOnly; + } + + /** + * Sets the flag that controls whether or not the data bounds reported + * by this renderer will exclude non-visible series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param visibleOnly include only visible series. + * + * @since 1.0.13 + */ + public void setDataBoundsIncludesVisibleSeriesOnly(boolean visibleOnly) { + this.dataBoundsIncludesVisibleSeriesOnly = visibleOnly; + notifyListeners(new RendererChangeEvent(this, true)); + } + + /** The adjacent offset. */ + private static final double ADJ = Math.cos(Math.PI / 6.0); + + /** The opposite offset. */ + private static final double OPP = Math.sin(Math.PI / 6.0); + + /** + * Calculates the item label anchor point. + * + * @param anchor the anchor. + * @param x the x coordinate. + * @param y the y coordinate. + * @param orientation the plot orientation. + * + * @return The anchor point (never null). + */ + protected Point2D calculateLabelAnchorPoint(ItemLabelAnchor anchor, + double x, double y, PlotOrientation orientation) { + Point2D result = null; + if (anchor == ItemLabelAnchor.CENTER) { + result = new Point2D.Double(x, y); + } + else if (anchor == ItemLabelAnchor.INSIDE1) { + result = new Point2D.Double(x + OPP * this.itemLabelAnchorOffset, + y - ADJ * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.INSIDE2) { + result = new Point2D.Double(x + ADJ * this.itemLabelAnchorOffset, + y - OPP * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.INSIDE3) { + result = new Point2D.Double(x + this.itemLabelAnchorOffset, y); + } + else if (anchor == ItemLabelAnchor.INSIDE4) { + result = new Point2D.Double(x + ADJ * this.itemLabelAnchorOffset, + y + OPP * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.INSIDE5) { + result = new Point2D.Double(x + OPP * this.itemLabelAnchorOffset, + y + ADJ * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.INSIDE6) { + result = new Point2D.Double(x, y + this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.INSIDE7) { + result = new Point2D.Double(x - OPP * this.itemLabelAnchorOffset, + y + ADJ * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.INSIDE8) { + result = new Point2D.Double(x - ADJ * this.itemLabelAnchorOffset, + y + OPP * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.INSIDE9) { + result = new Point2D.Double(x - this.itemLabelAnchorOffset, y); + } + else if (anchor == ItemLabelAnchor.INSIDE10) { + result = new Point2D.Double(x - ADJ * this.itemLabelAnchorOffset, + y - OPP * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.INSIDE11) { + result = new Point2D.Double(x - OPP * this.itemLabelAnchorOffset, + y - ADJ * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.INSIDE12) { + result = new Point2D.Double(x, y - this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.OUTSIDE1) { + result = new Point2D.Double( + x + 2.0 * OPP * this.itemLabelAnchorOffset, + y - 2.0 * ADJ * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.OUTSIDE2) { + result = new Point2D.Double( + x + 2.0 * ADJ * this.itemLabelAnchorOffset, + y - 2.0 * OPP * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.OUTSIDE3) { + result = new Point2D.Double(x + 2.0 * this.itemLabelAnchorOffset, + y); + } + else if (anchor == ItemLabelAnchor.OUTSIDE4) { + result = new Point2D.Double( + x + 2.0 * ADJ * this.itemLabelAnchorOffset, + y + 2.0 * OPP * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.OUTSIDE5) { + result = new Point2D.Double( + x + 2.0 * OPP * this.itemLabelAnchorOffset, + y + 2.0 * ADJ * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.OUTSIDE6) { + result = new Point2D.Double(x, + y + 2.0 * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.OUTSIDE7) { + result = new Point2D.Double( + x - 2.0 * OPP * this.itemLabelAnchorOffset, + y + 2.0 * ADJ * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.OUTSIDE8) { + result = new Point2D.Double( + x - 2.0 * ADJ * this.itemLabelAnchorOffset, + y + 2.0 * OPP * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.OUTSIDE9) { + result = new Point2D.Double(x - 2.0 * this.itemLabelAnchorOffset, + y); + } + else if (anchor == ItemLabelAnchor.OUTSIDE10) { + result = new Point2D.Double( + x - 2.0 * ADJ * this.itemLabelAnchorOffset, + y - 2.0 * OPP * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.OUTSIDE11) { + result = new Point2D.Double( + x - 2.0 * OPP * this.itemLabelAnchorOffset, + y - 2.0 * ADJ * this.itemLabelAnchorOffset); + } + else if (anchor == ItemLabelAnchor.OUTSIDE12) { + result = new Point2D.Double(x, + y - 2.0 * this.itemLabelAnchorOffset); + } + return result; + } + + /** + * Registers an object to receive notification of changes to the renderer. + * + * @param listener the listener (null not permitted). + * + * @see #removeChangeListener(RendererChangeListener) + */ + public void addChangeListener(RendererChangeListener listener) { + ParamChecks.nullNotPermitted(listener, "listener"); + this.listenerList.add(RendererChangeListener.class, listener); + } + + /** + * Deregisters an object so that it no longer receives + * notification of changes to the renderer. + * + * @param listener the object (null not permitted). + * + * @see #addChangeListener(RendererChangeListener) + */ + public void removeChangeListener(RendererChangeListener listener) { + ParamChecks.nullNotPermitted(listener, "listener"); + this.listenerList.remove(RendererChangeListener.class, listener); + } + + /** + * Returns true if the specified object is registered with + * the dataset as a listener. Most applications won't need to call this + * method, it exists mainly for use by unit testing code. + * + * @param listener the listener. + * + * @return A boolean. + */ + public boolean hasListener(EventListener listener) { + List list = Arrays.asList(this.listenerList.getListenerList()); + return list.contains(listener); + } + + /** + * Sends a {@link RendererChangeEvent} to all registered listeners. + * + * @since 1.0.5 + */ + protected void fireChangeEvent() { + + // the commented out code would be better, but only if + // RendererChangeEvent is immutable, which it isn't. See if there is + // a way to fix this... + + //if (this.event == null) { + // this.event = new RendererChangeEvent(this); + //} + //notifyListeners(this.event); + + notifyListeners(new RendererChangeEvent(this)); + } + + /** + * Notifies all registered listeners that the renderer has been modified. + * + * @param event information about the change event. + */ + public void notifyListeners(RendererChangeEvent event) { + Object[] ls = this.listenerList.getListenerList(); + for (int i = ls.length - 2; i >= 0; i -= 2) { + if (ls[i] == RendererChangeListener.class) { + ((RendererChangeListener) ls[i + 1]).rendererChanged(event); + } + } + } + + /** + * Tests this renderer for equality with another object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof AbstractRenderer)) { + return false; + } + AbstractRenderer that = (AbstractRenderer) obj; + if (this.dataBoundsIncludesVisibleSeriesOnly + != that.dataBoundsIncludesVisibleSeriesOnly) { + return false; + } + if (this.treatLegendShapeAsLine != that.treatLegendShapeAsLine) { + return false; + } + if (this.defaultEntityRadius != that.defaultEntityRadius) { + return false; + } + if (!ObjectUtilities.equal(this.seriesVisible, that.seriesVisible)) { + return false; + } + if (!this.seriesVisibleList.equals(that.seriesVisibleList)) { + return false; + } + if (this.baseSeriesVisible != that.baseSeriesVisible) { + return false; + } + if (!ObjectUtilities.equal(this.seriesVisibleInLegend, + that.seriesVisibleInLegend)) { + return false; + } + if (!this.seriesVisibleInLegendList.equals( + that.seriesVisibleInLegendList)) { + return false; + } + if (this.baseSeriesVisibleInLegend != that.baseSeriesVisibleInLegend) { + return false; + } + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + if (!ObjectUtilities.equal(this.paintList, that.paintList)) { + return false; + } + if (!PaintUtilities.equal(this.basePaint, that.basePaint)) { + return false; + } + if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.fillPaintList, that.fillPaintList)) { + return false; + } + if (!PaintUtilities.equal(this.baseFillPaint, that.baseFillPaint)) { + return false; + } + if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.outlinePaintList, + that.outlinePaintList)) { + return false; + } + if (!PaintUtilities.equal(this.baseOutlinePaint, + that.baseOutlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.stroke, that.stroke)) { + return false; + } + if (!ObjectUtilities.equal(this.strokeList, that.strokeList)) { + return false; + } + if (!ObjectUtilities.equal(this.baseStroke, that.baseStroke)) { + return false; + } + if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) { + return false; + } + if (!ObjectUtilities.equal(this.outlineStrokeList, + that.outlineStrokeList)) { + return false; + } + if (!ObjectUtilities.equal( + this.baseOutlineStroke, that.baseOutlineStroke) + ) { + return false; + } + if (!ShapeUtilities.equal(this.shape, that.shape)) { + return false; + } + if (!ObjectUtilities.equal(this.shapeList, that.shapeList)) { + return false; + } + if (!ShapeUtilities.equal(this.baseShape, that.baseShape)) { + return false; + } + if (!ObjectUtilities.equal(this.itemLabelsVisible, + that.itemLabelsVisible)) { + return false; + } + if (!ObjectUtilities.equal(this.itemLabelsVisibleList, + that.itemLabelsVisibleList)) { + return false; + } + if (!ObjectUtilities.equal(this.baseItemLabelsVisible, + that.baseItemLabelsVisible)) { + return false; + } + if (!ObjectUtilities.equal(this.itemLabelFont, that.itemLabelFont)) { + return false; + } + if (!ObjectUtilities.equal(this.itemLabelFontList, + that.itemLabelFontList)) { + return false; + } + if (!ObjectUtilities.equal(this.baseItemLabelFont, + that.baseItemLabelFont)) { + return false; + } + + if (!PaintUtilities.equal(this.itemLabelPaint, that.itemLabelPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.itemLabelPaintList, + that.itemLabelPaintList)) { + return false; + } + if (!PaintUtilities.equal(this.baseItemLabelPaint, + that.baseItemLabelPaint)) { + return false; + } + + if (!ObjectUtilities.equal(this.positiveItemLabelPosition, + that.positiveItemLabelPosition)) { + return false; + } + if (!ObjectUtilities.equal(this.positiveItemLabelPositionList, + that.positiveItemLabelPositionList)) { + return false; + } + if (!ObjectUtilities.equal(this.basePositiveItemLabelPosition, + that.basePositiveItemLabelPosition)) { + return false; + } + + if (!ObjectUtilities.equal(this.negativeItemLabelPosition, + that.negativeItemLabelPosition)) { + return false; + } + if (!ObjectUtilities.equal(this.negativeItemLabelPositionList, + that.negativeItemLabelPositionList)) { + return false; + } + if (!ObjectUtilities.equal(this.baseNegativeItemLabelPosition, + that.baseNegativeItemLabelPosition)) { + return false; + } + if (this.itemLabelAnchorOffset != that.itemLabelAnchorOffset) { + return false; + } + if (!ObjectUtilities.equal(this.createEntities, that.createEntities)) { + return false; + } + if (!ObjectUtilities.equal(this.createEntitiesList, + that.createEntitiesList)) { + return false; + } + if (this.baseCreateEntities != that.baseCreateEntities) { + return false; + } + if (!ObjectUtilities.equal(this.legendShapeList, + that.legendShapeList)) { + return false; + } + if (!ShapeUtilities.equal(this.baseLegendShape, + that.baseLegendShape)) { + return false; + } + if (!ObjectUtilities.equal(this.legendTextFont, that.legendTextFont)) { + return false; + } + if (!ObjectUtilities.equal(this.baseLegendTextFont, + that.baseLegendTextFont)) { + return false; + } + if (!ObjectUtilities.equal(this.legendTextPaint, + that.legendTextPaint)) { + return false; + } + if (!PaintUtilities.equal(this.baseLegendTextPaint, + that.baseLegendTextPaint)) { + return false; + } + return true; + } + + /** + * Returns a hashcode for the renderer. + * + * @return The hashcode. + */ + @Override + public int hashCode() { + int result = 193; + result = HashUtilities.hashCode(result, this.seriesVisibleList); + result = HashUtilities.hashCode(result, this.baseSeriesVisible); + result = HashUtilities.hashCode(result, this.seriesVisibleInLegendList); + result = HashUtilities.hashCode(result, this.baseSeriesVisibleInLegend); + result = HashUtilities.hashCode(result, this.paintList); + result = HashUtilities.hashCode(result, this.basePaint); + result = HashUtilities.hashCode(result, this.fillPaintList); + result = HashUtilities.hashCode(result, this.baseFillPaint); + result = HashUtilities.hashCode(result, this.outlinePaintList); + result = HashUtilities.hashCode(result, this.baseOutlinePaint); + result = HashUtilities.hashCode(result, this.strokeList); + result = HashUtilities.hashCode(result, this.baseStroke); + result = HashUtilities.hashCode(result, this.outlineStrokeList); + result = HashUtilities.hashCode(result, this.baseOutlineStroke); + // shapeList + // baseShape + result = HashUtilities.hashCode(result, this.itemLabelsVisibleList); + result = HashUtilities.hashCode(result, this.baseItemLabelsVisible); + // itemLabelFontList + // baseItemLabelFont + // itemLabelPaintList + // baseItemLabelPaint + // positiveItemLabelPositionList + // basePositiveItemLabelPosition + // negativeItemLabelPositionList + // baseNegativeItemLabelPosition + // itemLabelAnchorOffset + // createEntityList + // baseCreateEntities + return result; + } + + /** + * Returns an independent copy of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if some component of the renderer + * does not support cloning. + */ + @Override + protected Object clone() throws CloneNotSupportedException { + AbstractRenderer clone = (AbstractRenderer) super.clone(); + + if (this.seriesVisibleList != null) { + clone.seriesVisibleList + = (BooleanList) this.seriesVisibleList.clone(); + } + + if (this.seriesVisibleInLegendList != null) { + clone.seriesVisibleInLegendList + = (BooleanList) this.seriesVisibleInLegendList.clone(); + } + + // 'paint' : immutable, no need to clone reference + if (this.paintList != null) { + clone.paintList = (PaintList) this.paintList.clone(); + } + // 'basePaint' : immutable, no need to clone reference + + if (this.fillPaintList != null) { + clone.fillPaintList = (PaintList) this.fillPaintList.clone(); + } + // 'outlinePaint' : immutable, no need to clone reference + if (this.outlinePaintList != null) { + clone.outlinePaintList = (PaintList) this.outlinePaintList.clone(); + } + // 'baseOutlinePaint' : immutable, no need to clone reference + + // 'stroke' : immutable, no need to clone reference + if (this.strokeList != null) { + clone.strokeList = (StrokeList) this.strokeList.clone(); + } + // 'baseStroke' : immutable, no need to clone reference + + // 'outlineStroke' : immutable, no need to clone reference + if (this.outlineStrokeList != null) { + clone.outlineStrokeList + = (StrokeList) this.outlineStrokeList.clone(); + } + // 'baseOutlineStroke' : immutable, no need to clone reference + + if (this.shape != null) { + clone.shape = ShapeUtilities.clone(this.shape); + } + if (this.shapeList != null) { + clone.shapeList = (ShapeList) this.shapeList.clone(); + } + if (this.baseShape != null) { + clone.baseShape = ShapeUtilities.clone(this.baseShape); + } + + // 'itemLabelsVisible' : immutable, no need to clone reference + if (this.itemLabelsVisibleList != null) { + clone.itemLabelsVisibleList + = (BooleanList) this.itemLabelsVisibleList.clone(); + } + // 'basePaint' : immutable, no need to clone reference + + // 'itemLabelFont' : immutable, no need to clone reference + if (this.itemLabelFontList != null) { + clone.itemLabelFontList + = (ObjectList) this.itemLabelFontList.clone(); + } + // 'baseItemLabelFont' : immutable, no need to clone reference + + // 'itemLabelPaint' : immutable, no need to clone reference + if (this.itemLabelPaintList != null) { + clone.itemLabelPaintList + = (PaintList) this.itemLabelPaintList.clone(); + } + // 'baseItemLabelPaint' : immutable, no need to clone reference + + // 'postiveItemLabelAnchor' : immutable, no need to clone reference + if (this.positiveItemLabelPositionList != null) { + clone.positiveItemLabelPositionList + = (ObjectList) this.positiveItemLabelPositionList.clone(); + } + // 'baseItemLabelAnchor' : immutable, no need to clone reference + + // 'negativeItemLabelAnchor' : immutable, no need to clone reference + if (this.negativeItemLabelPositionList != null) { + clone.negativeItemLabelPositionList + = (ObjectList) this.negativeItemLabelPositionList.clone(); + } + // 'baseNegativeItemLabelAnchor' : immutable, no need to clone reference + + if (this.createEntitiesList != null) { + clone.createEntitiesList + = (BooleanList) this.createEntitiesList.clone(); + } + + if (this.legendShapeList != null) { + clone.legendShapeList = (ShapeList) this.legendShapeList.clone(); + } + if (this.legendTextFont != null) { + clone.legendTextFont = (ObjectList) this.legendTextFont.clone(); + } + if (this.legendTextPaint != null) { + clone.legendTextPaint = (PaintList) this.legendTextPaint.clone(); + } + clone.listenerList = new EventListenerList(); + clone.event = null; + 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.paint, stream); + SerialUtilities.writePaint(this.basePaint, stream); + SerialUtilities.writePaint(this.fillPaint, stream); + SerialUtilities.writePaint(this.baseFillPaint, stream); + SerialUtilities.writePaint(this.outlinePaint, stream); + SerialUtilities.writePaint(this.baseOutlinePaint, stream); + SerialUtilities.writeStroke(this.stroke, stream); + SerialUtilities.writeStroke(this.baseStroke, stream); + SerialUtilities.writeStroke(this.outlineStroke, stream); + SerialUtilities.writeStroke(this.baseOutlineStroke, stream); + SerialUtilities.writeShape(this.shape, stream); + SerialUtilities.writeShape(this.baseShape, stream); + SerialUtilities.writePaint(this.itemLabelPaint, stream); + SerialUtilities.writePaint(this.baseItemLabelPaint, stream); + SerialUtilities.writeShape(this.baseLegendShape, stream); + SerialUtilities.writePaint(this.baseLegendTextPaint, 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.basePaint = SerialUtilities.readPaint(stream); + this.fillPaint = SerialUtilities.readPaint(stream); + this.baseFillPaint = SerialUtilities.readPaint(stream); + this.outlinePaint = SerialUtilities.readPaint(stream); + this.baseOutlinePaint = SerialUtilities.readPaint(stream); + this.stroke = SerialUtilities.readStroke(stream); + this.baseStroke = SerialUtilities.readStroke(stream); + this.outlineStroke = SerialUtilities.readStroke(stream); + this.baseOutlineStroke = SerialUtilities.readStroke(stream); + this.shape = SerialUtilities.readShape(stream); + this.baseShape = SerialUtilities.readShape(stream); + this.itemLabelPaint = SerialUtilities.readPaint(stream); + this.baseItemLabelPaint = SerialUtilities.readPaint(stream); + this.baseLegendShape = SerialUtilities.readShape(stream); + this.baseLegendTextPaint = SerialUtilities.readPaint(stream); + + // listeners are not restored automatically, but storage must be + // provided... + this.listenerList = new EventListenerList(); + + } + + // === DEPRECATED CODE === + + /** + * A flag that controls the visibility of ALL series. + * + * @deprecated This field is redundant, you can rely on seriesVisibleList + * and baseSeriesVisible. Deprecated from version 1.0.6 onwards. + */ + private Boolean seriesVisible; + + /** + * A flag that controls the visibility of ALL series in the legend. + * + * @deprecated This field is redundant, you can rely on + * seriesVisibleInLegendList and baseSeriesVisibleInLegend. + * Deprecated from version 1.0.6 onwards. + */ + private Boolean seriesVisibleInLegend; + + /** + * The paint for ALL series (optional). + * + * @deprecated This field is redundant, you can rely on paintList and + * basePaint. Deprecated from version 1.0.6 onwards. + */ + private transient Paint paint; + + /** + * The fill paint for ALL series (optional). + * + * @deprecated This field is redundant, you can rely on fillPaintList and + * baseFillPaint. Deprecated from version 1.0.6 onwards. + */ + private transient Paint fillPaint; + + /** + * The outline paint for ALL series (optional). + * + * @deprecated This field is redundant, you can rely on outlinePaintList + * and baseOutlinePaint. Deprecated from version 1.0.6 onwards. + */ + private transient Paint outlinePaint; + + /** + * The stroke for ALL series (optional). + * + * @deprecated This field is redundant, you can rely on strokeList and + * baseStroke. Deprecated from version 1.0.6 onwards. + */ + private transient Stroke stroke; + + /** + * The outline stroke for ALL series (optional). + * + * @deprecated This field is redundant, you can rely on strokeList and + * baseStroke. Deprecated from version 1.0.6 onwards. + */ + private transient Stroke outlineStroke; + + /** + * The shape for ALL series (optional). + * + * @deprecated This field is redundant, you can rely on shapeList and + * baseShape. Deprecated from version 1.0.6 onwards. + */ + private transient Shape shape; + + /** + * Visibility of the item labels for ALL series (optional). + * + * @deprecated This field is redundant, you can rely on + * itemLabelsVisibleList and baseItemLabelsVisible. Deprecated from + * version 1.0.6 onwards. + */ + private Boolean itemLabelsVisible; + + /** + * The item label font for ALL series (optional). + * + * @deprecated This field is redundant, you can rely on itemLabelFontList + * and baseItemLabelFont. Deprecated from version 1.0.6 onwards. + */ + private Font itemLabelFont; + + /** + * The item label paint for ALL series. + * + * @deprecated This field is redundant, you can rely on itemLabelPaintList + * and baseItemLabelPaint. Deprecated from version 1.0.6 onwards. + */ + private transient Paint itemLabelPaint; + + /** + * The positive item label position for ALL series (optional). + * + * @deprecated This field is redundant, you can rely on the + * positiveItemLabelPositionList and basePositiveItemLabelPosition + * fields. Deprecated from version 1.0.6 onwards. + */ + private ItemLabelPosition positiveItemLabelPosition; + + /** + * The negative item label position for ALL series (optional). + * + * @deprecated This field is redundant, you can rely on the + * negativeItemLabelPositionList and baseNegativeItemLabelPosition + * fields. Deprecated from version 1.0.6 onwards. + */ + private ItemLabelPosition negativeItemLabelPosition; + + /** + * A flag that controls whether or not entities are generated for + * ALL series (optional). + * + * @deprecated This field is redundant, you can rely on the + * createEntitiesList and baseCreateEntities fields. Deprecated from + * version 1.0.6 onwards. + */ + private Boolean createEntities; + + /** + * Returns the flag that controls the visibility of ALL series. This flag + * overrides the per series and default settings - you must set it to + * null if you want the other settings to apply. + * + * @return The flag (possibly null). + * + * @see #setSeriesVisible(Boolean) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesVisible(int)} and + * {@link #getBaseSeriesVisible()}. + */ + public Boolean getSeriesVisible() { + return this.seriesVisible; + } + + /** + * Sets the flag that controls the visibility of ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. This flag + * overrides the per series and default settings - you must set it to + * null if you want the other settings to apply. + * + * @param visible the flag (null permitted). + * + * @see #getSeriesVisible() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesVisible(int, Boolean)} + * and {@link #setBaseSeriesVisible(boolean)}. + */ + public void setSeriesVisible(Boolean visible) { + setSeriesVisible(visible, true); + } + + /** + * Sets the flag that controls the visibility of ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. This flag + * overrides the per series and default settings - you must set it to + * null if you want the other settings to apply. + * + * @param visible the flag (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesVisible() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesVisible(int, Boolean)} + * and {@link #setBaseSeriesVisible(boolean)}. + */ + public void setSeriesVisible(Boolean visible, boolean notify) { + this.seriesVisible = visible; + if (notify) { + // we create an event with a special flag set...the purpose of + // this is to communicate to the plot (the default receiver of + // the event) that series visibility has changed so the axis + // ranges might need updating... + RendererChangeEvent e = new RendererChangeEvent(this, true); + notifyListeners(e); + } + } + + /** + * Returns the flag that controls the visibility of ALL series in the + * legend. This flag overrides the per series and default settings - you + * must set it to null if you want the other settings to + * apply. + * + * @return The flag (possibly null). + * + * @see #setSeriesVisibleInLegend(Boolean) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesVisibleInLegend(int)} + * and {@link #getBaseSeriesVisibleInLegend()}. + */ + public Boolean getSeriesVisibleInLegend() { + return this.seriesVisibleInLegend; + } + + /** + * Sets the flag that controls the visibility of ALL series in the legend + * and sends a {@link RendererChangeEvent} to all registered listeners. + * This flag overrides the per series and default settings - you must set + * it to null if you want the other settings to apply. + * + * @param visible the flag (null permitted). + * + * @see #getSeriesVisibleInLegend() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesVisibleInLegend(int, + * Boolean)} and {@link #setBaseSeriesVisibleInLegend(boolean)}. + */ + public void setSeriesVisibleInLegend(Boolean visible) { + setSeriesVisibleInLegend(visible, true); + } + + /** + * Sets the flag that controls the visibility of ALL series in the legend + * and sends a {@link RendererChangeEvent} to all registered listeners. + * This flag overrides the per series and default settings - you must set + * it to null if you want the other settings to apply. + * + * @param visible the flag (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesVisibleInLegend() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesVisibleInLegend(int, + * Boolean, boolean)} and {@link #setBaseSeriesVisibleInLegend(boolean, + * boolean)}. + */ + public void setSeriesVisibleInLegend(Boolean visible, boolean notify) { + this.seriesVisibleInLegend = visible; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Sets the paint to be used for ALL series, and sends a + * {@link RendererChangeEvent} to all registered listeners. If this is + * null, the renderer will use the paint for the series. + * + * @param paint the paint (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesPaint(int, Paint)} and + * {@link #setBasePaint(Paint)}. + */ + public void setPaint(Paint paint) { + setPaint(paint, true); + } + + /** + * Sets the paint to be used for all series and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * @param notify notify listeners? + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesPaint(int, Paint, + * boolean)} and {@link #setBasePaint(Paint, boolean)}. + */ + public void setPaint(Paint paint, boolean notify) { + this.paint = paint; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Sets the fill paint for ALL series (optional). + * + * @param paint the paint (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesFillPaint(int, Paint)} + * and {@link #setBaseFillPaint(Paint)}. + */ + public void setFillPaint(Paint paint) { + setFillPaint(paint, true); + } + + /** + * Sets the fill paint for ALL series and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * @param notify notify listeners? + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesFillPaint(int, Paint, + * boolean)} and {@link #setBaseFillPaint(Paint, boolean)}. + */ + public void setFillPaint(Paint paint, boolean notify) { + this.fillPaint = paint; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Sets the outline paint for ALL series (optional) and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesOutlinePaint(int, + * Paint)} and {@link #setBaseOutlinePaint(Paint)}. + */ + public void setOutlinePaint(Paint paint) { + setOutlinePaint(paint, true); + } + + /** + * Sets the outline paint for ALL series and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * @param notify notify listeners? + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesOutlinePaint(int, + * Paint, boolean)} and {@link #setBaseOutlinePaint(Paint, boolean)}. + */ + public void setOutlinePaint(Paint paint, boolean notify) { + this.outlinePaint = paint; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Sets the stroke for ALL series and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param stroke the stroke (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesStroke(int, Stroke)} + * and {@link #setBaseStroke(Stroke)}. + */ + public void setStroke(Stroke stroke) { + setStroke(stroke, true); + } + + /** + * Sets the stroke for ALL series and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null permitted). + * @param notify notify listeners? + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesStroke(int, Stroke, + * boolean)} and {@link #setBaseStroke(Stroke, boolean)}. + */ + public void setStroke(Stroke stroke, boolean notify) { + this.stroke = stroke; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Sets the outline stroke for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesOutlineStroke(int, + * Stroke)} and {@link #setBaseOutlineStroke(Stroke)}. + */ + public void setOutlineStroke(Stroke stroke) { + setOutlineStroke(stroke, true); + } + + /** + * Sets the outline stroke for ALL series and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null permitted). + * @param notify notify listeners? + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesOutlineStroke(int, + * Stroke, boolean)} and {@link #setBaseOutlineStroke(Stroke, boolean)}. + */ + public void setOutlineStroke(Stroke stroke, boolean notify) { + this.outlineStroke = stroke; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Sets the shape for ALL series (optional) and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param shape the shape (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesShape(int, Shape)} + * and {@link #setBaseShape(Shape)}. + */ + public void setShape(Shape shape) { + setShape(shape, true); + } + + /** + * Sets the shape for ALL series and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param shape the shape (null permitted). + * @param notify notify listeners? + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesShape(int, Shape, + * boolean)} and {@link #setBaseShape(Shape, boolean)}. + */ + public void setShape(Shape shape, boolean notify) { + this.shape = shape; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Sets the visibility of the item labels for ALL series. + * + * @param visible the flag. + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, + * Boolean)} and {@link #setBaseItemLabelsVisible(boolean)}. + */ + public void setItemLabelsVisible(boolean visible) { + setItemLabelsVisible(Boolean.valueOf(visible)); + // The following alternative is only supported in JDK 1.4 - we support + // JDK 1.3.1 onwards + // setItemLabelsVisible(Boolean.valueOf(visible)); + } + + /** + * Sets the visibility of the item labels for ALL series (optional). + * + * @param visible the flag (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, + * Boolean)} and {@link #setBaseItemLabelsVisible(boolean)}. + */ + public void setItemLabelsVisible(Boolean visible) { + setItemLabelsVisible(visible, true); + } + + /** + * Sets the visibility of item labels for ALL series and, if requested, + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param visible a flag that controls whether or not the item labels are + * visible (null permitted). + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, + * Boolean, boolean)} and {@link #setBaseItemLabelsVisible(Boolean, + * boolean)}. + */ + public void setItemLabelsVisible(Boolean visible, boolean notify) { + this.itemLabelsVisible = visible; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the font used for all item labels. This may be + * null, in which case the per series font settings will apply. + * + * @return The font (possibly null). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesItemLabelFont(int)} and + * {@link #getBaseItemLabelFont()}. + */ + public Font getItemLabelFont() { + return this.itemLabelFont; + } + + /** + * Sets the item label font for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. You can set + * this to null if you prefer to set the font on a per series + * basis. + * + * @param font the font (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelFont(int, + * Font)} and {@link #setBaseItemLabelFont(Font)}. + */ + public void setItemLabelFont(Font font) { + setItemLabelFont(font, true); + } + + /** + * Sets the item label font for ALL series and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param font the font (null permitted). + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelFont(int, + * Font, boolean)} and {@link #setBaseItemLabelFont(Font, boolean)}. + */ + public void setItemLabelFont(Font font, boolean notify) { + this.itemLabelFont = font; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the paint used for all item labels. This may be + * null, in which case the per series paint settings will + * apply. + * + * @return The paint (possibly null). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesItemLabelPaint(int)} + * and {@link #getBaseItemLabelPaint()}. + */ + public Paint getItemLabelPaint() { + return this.itemLabelPaint; + } + + /** + * Sets the item label paint for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelPaint(int, + * Paint)} and {@link #setBaseItemLabelPaint(Paint)}. + */ + public void setItemLabelPaint(Paint paint) { + setItemLabelPaint(paint, true); + } + + /** + * Sets the item label paint for ALL series and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint. + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelPaint(int, + * Paint, boolean)} and {@link #setBaseItemLabelPaint(Paint, boolean)}. + */ + public void setItemLabelPaint(Paint paint, boolean notify) { + this.itemLabelPaint = paint; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the item label position for positive values in ALL series. + * + * @return The item label position (possibly null). + * + * @see #setPositiveItemLabelPosition(ItemLabelPosition) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #getSeriesPositiveItemLabelPosition(int)} + * and {@link #getBasePositiveItemLabelPosition()}. + */ + public ItemLabelPosition getPositiveItemLabelPosition() { + return this.positiveItemLabelPosition; + } + + /** + * Sets the item label position for positive values in ALL series, and + * sends a {@link RendererChangeEvent} to all registered listeners. You + * need to set this to null to expose the settings for + * individual series. + * + * @param position the position (null permitted). + * + * @see #getPositiveItemLabelPosition() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition)} + * and {@link #setBasePositiveItemLabelPosition(ItemLabelPosition)}. + */ + public void setPositiveItemLabelPosition(ItemLabelPosition position) { + setPositiveItemLabelPosition(position, true); + } + + /** + * Sets the positive item label position for ALL series and (if requested) + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param position the position (null permitted). + * @param notify notify registered listeners? + * + * @see #getPositiveItemLabelPosition() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition, + * boolean)} and {@link #setBasePositiveItemLabelPosition( + * ItemLabelPosition, boolean)}. + */ + public void setPositiveItemLabelPosition(ItemLabelPosition position, + boolean notify) { + this.positiveItemLabelPosition = position; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the item label position for negative values in ALL series. + * + * @return The item label position (possibly null). + * + * @see #setNegativeItemLabelPosition(ItemLabelPosition) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #getSeriesNegativeItemLabelPosition(int)} + * and {@link #getBaseNegativeItemLabelPosition()}. + */ + public ItemLabelPosition getNegativeItemLabelPosition() { + return this.negativeItemLabelPosition; + } + + /** + * Sets the item label position for negative values in ALL series, and + * sends a {@link RendererChangeEvent} to all registered listeners. You + * need to set this to null to expose the settings for + * individual series. + * + * @param position the position (null permitted). + * + * @see #getNegativeItemLabelPosition() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition)} + * and {@link #setBaseNegativeItemLabelPosition(ItemLabelPosition)}. + */ + public void setNegativeItemLabelPosition(ItemLabelPosition position) { + setNegativeItemLabelPosition(position, true); + } + + /** + * Sets the item label position for negative values in ALL series and (if + * requested) sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param position the position (null permitted). + * @param notify notify registered listeners? + * + * @see #getNegativeItemLabelPosition() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition, + * boolean)} and {@link #setBaseNegativeItemLabelPosition( + * ItemLabelPosition, boolean)}. + */ + public void setNegativeItemLabelPosition(ItemLabelPosition position, + boolean notify) { + this.negativeItemLabelPosition = position; + if (notify) { + fireChangeEvent(); + } + } + + /** + * Returns the flag that controls whether or not chart entities are created + * for the items in ALL series. This flag overrides the per series and + * default settings - you must set it to null if you want the + * other settings to apply. + * + * @return The flag (possibly null). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesCreateEntities(int)} + * and {@link #getBaseCreateEntities()}. + */ + public Boolean getCreateEntities() { + return this.createEntities; + } + + /** + * Sets the flag that controls whether or not chart entities are created + * for the items in ALL series, and sends a {@link RendererChangeEvent} to + * all registered listeners. This flag overrides the per series and + * default settings - you must set it to null if you want the + * other settings to apply. + * + * @param create the flag (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesCreateEntities(int, + * Boolean)} and {@link #setBaseCreateEntities(boolean)}. + */ + public void setCreateEntities(Boolean create) { + setCreateEntities(create, true); + } + + /** + * Sets the flag that controls whether or not chart entities are created + * for the items in ALL series, and sends a {@link RendererChangeEvent} to + * all registered listeners. This flag overrides the per series and + * default settings - you must set it to null if you want the + * other settings to apply. + * + * @param create the flag (null permitted). + * @param notify notify listeners? + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelFont(int, + * Font, boolean)} and {@link #setBaseItemLabelFont(Font, boolean)}. + */ + public void setCreateEntities(Boolean create, boolean notify) { + this.createEntities = create; + if (notify) { + fireChangeEvent(); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/AreaRendererEndType.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/AreaRendererEndType.java new file mode 100755 index 0000000..ff6a269 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/AreaRendererEndType.java @@ -0,0 +1,138 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * AreaRendererEndType.java + * ------------------------ + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 29-April-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.renderer; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * An enumeration of the 'end types' for an area renderer. + */ +public final class AreaRendererEndType implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -1774146392916359839L; + + /** + * The area tapers from the first or last value down to zero. + */ + public static final AreaRendererEndType TAPER = new AreaRendererEndType( + "AreaRendererEndType.TAPER"); + + /** + * The area is truncated at the first or last value. + */ + public static final AreaRendererEndType TRUNCATE = new AreaRendererEndType( + "AreaRendererEndType.TRUNCATE"); + + /** + * The area is levelled at the first or last value. + */ + public static final AreaRendererEndType LEVEL = new AreaRendererEndType( + "AreaRendererEndType.LEVEL"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private AreaRendererEndType(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof AreaRendererEndType)) { + return false; + } + AreaRendererEndType that = (AreaRendererEndType) obj; + if (!this.name.equals(that.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 { + Object result = null; + if (this.equals(AreaRendererEndType.LEVEL)) { + result = AreaRendererEndType.LEVEL; + } + else if (this.equals(AreaRendererEndType.TAPER)) { + result = AreaRendererEndType.TAPER; + } + else if (this.equals(AreaRendererEndType.TRUNCATE)) { + result = AreaRendererEndType.TRUNCATE; + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java new file mode 100755 index 0000000..c47e996 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/DefaultPolarItemRenderer.java @@ -0,0 +1,1012 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * DefaultPolarItemRenderer.java + * ----------------------------- + * (C) Copyright 2004-2013, by Solution Engineering, Inc. and + * Contributors. + * + * Original Author: Daniel Bridenbecker, Solution Engineering, Inc.; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Martin Hoeller (patch 2850344); + * + * Changes + * ------- + * 19-Jan-2004 : Version 1, contributed by DB with minor changes by DG (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 04-Oct-2004 : Renamed BooleanUtils --> BooleanUtilities (DG); + * 20-Apr-2005 : Update for change to LegendItem class (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 04-Aug-2006 : Implemented equals() and clone() (DG); + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * 14-Mar-2007 : Fixed clone() method (DG); + * 04-May-2007 : Fixed lookup for series paint and stroke (DG); + * 18-May-2007 : Set dataset for LegendItem (DG); + * 03-Sep-2009 : Applied patch 2850344 by Martin Hoeller (DG); + * 27-Nov-2009 : Updated for modification to PolarItemRenderer interface (DG); + * 03-Oct-2011 : Fixed potential NPE in equals() (MH); + * 03-Oct-2011 : Added flag to connectFirstAndLastPoint (MH); + * 03-Oct-2011 : Added tooltip and URL generator support (MH); + * 03-Oct-2011 : Added some configuration options for the legend (MH); + * 03-Oct-2011 : Added support for PolarPlot's angleOffset and direction (MH); + * 16-Oct-2011 : Fixed serialization problems with fillComposite (MH); + * 18-Sep-2012 : Fixed bug 3508799: seriesKey always null in LegendItem (DG); + * 01-Jul-2013 : Remove deprecated method calls (DG); + * 04-Jul-2013 : Fix rendering bug when axis is inverted (DG); + * + */ + +package org.jfree.chart.renderer; + +import java.awt.AlphaComposite; +import java.awt.Composite; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Point; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Ellipse2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; +import java.awt.geom.PathIterator; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.axis.NumberTick; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.entity.XYItemEntity; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.XYSeriesLabelGenerator; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.DrawingSupplier; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.PolarPlot; +import org.jfree.chart.renderer.xy.AbstractXYItemRenderer; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.util.BooleanList; +import org.jfree.util.BooleanUtilities; +import org.jfree.util.ObjectList; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A renderer that can be used with the {@link PolarPlot} class. + */ +public class DefaultPolarItemRenderer extends AbstractRenderer + implements PolarItemRenderer { + + /** The plot that the renderer is assigned to. */ + private PolarPlot plot; + + /** Flags that control whether the renderer fills each series or not. */ + private BooleanList seriesFilled; + + /** + * Flag that controls whether an outline is drawn for filled series or + * not. + * + * @since 1.0.14 + */ + private boolean drawOutlineWhenFilled; + + /** + * The composite to use when filling series. + * + * @since 1.0.14 + */ + private transient Composite fillComposite; + + /** + * A flag that controls whether the fill paint is used for filling + * shapes. + * + * @since 1.0.14 + */ + private boolean useFillPaint; + + /** + * The shape that is used to represent a line in the legend. + * + * @since 1.0.14 + */ + private transient Shape legendLine; + + /** + * Flag that controls whether item shapes are visible or not. + * + * @since 1.0.14 + */ + private boolean shapesVisible; + + /** + * Flag that controls if the first and last point of the dataset should be + * connected or not. + * + * @since 1.0.14 + */ + private boolean connectFirstAndLastPoint; + + /** + * A list of tool tip generators (one per series). + * + * @since 1.0.14 + */ + private ObjectList toolTipGeneratorList; + + /** + * The base tool tip generator. + * + * @since 1.0.14 + */ + private XYToolTipGenerator baseToolTipGenerator; + + /** + * The URL text generator. + * + * @since 1.0.14 + */ + private XYURLGenerator urlGenerator; + + /** + * The legend item tool tip generator. + * + * @since 1.0.14 + */ + private XYSeriesLabelGenerator legendItemToolTipGenerator; + + /** + * The legend item URL generator. + * + * @since 1.0.14 + */ + private XYSeriesLabelGenerator legendItemURLGenerator; + + /** + * Creates a new instance of DefaultPolarItemRenderer + */ + public DefaultPolarItemRenderer() { + this.seriesFilled = new BooleanList(); + this.drawOutlineWhenFilled = true; + this.fillComposite = AlphaComposite.getInstance( + AlphaComposite.SRC_OVER, 0.3f); + this.useFillPaint = false; // use item paint for fills by default + this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0); + this.shapesVisible = true; + this.connectFirstAndLastPoint = true; + + this.toolTipGeneratorList = new ObjectList(); + this.urlGenerator = null; + this.legendItemToolTipGenerator = null; + this.legendItemURLGenerator = null; + } + + /** + * Set the plot associated with this renderer. + * + * @param plot the plot. + * + * @see #getPlot() + */ + @Override + public void setPlot(PolarPlot plot) { + this.plot = plot; + } + + /** + * Return the plot associated with this renderer. + * + * @return The plot. + * + * @see #setPlot(PolarPlot) + */ + @Override + public PolarPlot getPlot() { + return this.plot; + } + + /** + * Returns true if the renderer will draw an outline around + * a filled polygon, false otherwise. + * + * @return A boolean. + * + * @since 1.0.14 + */ + public boolean getDrawOutlineWhenFilled() { + return this.drawOutlineWhenFilled; + } + + /** + * Set the flag that controls whether the outline around a filled + * polygon will be drawn or not and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param drawOutlineWhenFilled the flag. + * + * @since 1.0.14 + */ + public void setDrawOutlineWhenFilled(boolean drawOutlineWhenFilled) { + this.drawOutlineWhenFilled = drawOutlineWhenFilled; + fireChangeEvent(); + } + + /** + * Get the composite that is used for filling. + * + * @return The composite (never null). + * + * @since 1.0.14 + */ + public Composite getFillComposite() { + return this.fillComposite; + } + + /** + * Sets the composite which will be used for filling polygons and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param composite the composite to use (null not + * permitted). + * + * @since 1.0.14 + */ + public void setFillComposite(Composite composite) { + ParamChecks.nullNotPermitted(composite, "composite"); + this.fillComposite = composite; + fireChangeEvent(); + } + + /** + * Returns true if a shape will be drawn for every item, or + * false if not. + * + * @return A boolean. + * + * @since 1.0.14 + */ + public boolean getShapesVisible() { + return this.shapesVisible; + } + + /** + * Set the flag that controls whether a shape will be drawn for every + * item, or not and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param visible the flag. + * + * @since 1.0.14 + */ + public void setShapesVisible(boolean visible) { + this.shapesVisible = visible; + fireChangeEvent(); + } + + /** + * Returns true if first and last point of a series will be + * connected, false otherwise. + * + * @return The current status of the flag. + * + * @since 1.0.14 + */ + public boolean getConnectFirstAndLastPoint() { + return this.connectFirstAndLastPoint; + } + + /** + * Set the flag that controls whether the first and last point of a series + * will be connected or not and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param connect the flag. + * + * @since 1.0.14 + */ + public void setConnectFirstAndLastPoint(boolean connect) { + this.connectFirstAndLastPoint = connect; + fireChangeEvent(); + } + + /** + * Returns the drawing supplier from the plot. + * + * @return The drawing supplier. + */ + @Override + public DrawingSupplier getDrawingSupplier() { + DrawingSupplier result = null; + PolarPlot p = getPlot(); + if (p != null) { + result = p.getDrawingSupplier(); + } + return result; + } + + /** + * Returns true if the renderer should fill the specified + * series, and false otherwise. + * + * @param series the series index (zero-based). + * + * @return A boolean. + */ + public boolean isSeriesFilled(int series) { + boolean result = false; + Boolean b = this.seriesFilled.getBoolean(series); + if (b != null) { + result = b.booleanValue(); + } + return result; + } + + /** + * Sets a flag that controls whether or not a series is filled. + * + * @param series the series index. + * @param filled the flag. + */ + public void setSeriesFilled(int series, boolean filled) { + this.seriesFilled.setBoolean(series, BooleanUtilities.valueOf(filled)); + } + + /** + * Returns true if the renderer should use the fill paint + * setting to fill shapes, and false if it should just + * use the regular paint. + * + * @return A boolean. + * + * @see #setUseFillPaint(boolean) + * @since 1.0.14 + */ + public boolean getUseFillPaint() { + return this.useFillPaint; + } + + /** + * Sets the flag that controls whether the fill paint is used to fill + * shapes, and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param flag the flag. + * + * @see #getUseFillPaint() + * @since 1.0.14 + */ + public void setUseFillPaint(boolean flag) { + this.useFillPaint = flag; + fireChangeEvent(); + } + + /** + * Returns the shape used to represent a line in the legend. + * + * @return The legend line (never null). + * + * @see #setLegendLine(Shape) + */ + public Shape getLegendLine() { + return this.legendLine; + } + + /** + * Sets the shape used as a line in each legend item and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param line the line (null not permitted). + * + * @see #getLegendLine() + */ + public void setLegendLine(Shape line) { + ParamChecks.nullNotPermitted(line, "line"); + this.legendLine = line; + fireChangeEvent(); + } + + /** + * Adds an entity to the collection. + * + * @param entities the entity collection being populated. + * @param area the entity area (if null a default will be + * used). + * @param dataset the dataset. + * @param series the series. + * @param item the item. + * @param entityX the entity's center x-coordinate in user space (only + * used if area is null). + * @param entityY the entity's center y-coordinate in user space (only + * used if area is null). + */ + protected void addEntity(EntityCollection entities, Shape area, + XYDataset dataset, int series, int item, + double entityX, double entityY) { + if (!getItemCreateEntity(series, item)) { + return; + } + Shape hotspot = area; + if (hotspot == null) { + double r = getDefaultEntityRadius(); + double w = r * 2; + if (getPlot().getOrientation() == PlotOrientation.VERTICAL) { + hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w); + } + else { + hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w); + } + } + String tip = null; + XYToolTipGenerator generator = getToolTipGenerator(series, item); + if (generator != null) { + tip = generator.generateToolTip(dataset, series, item); + } + String url = null; + if (getURLGenerator() != null) { + url = getURLGenerator().generateURL(dataset, series, item); + } + XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item, + tip, url); + entities.add(entity); + } + + /** + * Plots the data for a given series. + * + * @param g2 the drawing surface. + * @param dataArea the data area. + * @param info collects plot rendering info. + * @param plot the plot. + * @param dataset the dataset. + * @param seriesIndex the series index. + */ + @Override + public void drawSeries(Graphics2D g2, Rectangle2D dataArea, + PlotRenderingInfo info, PolarPlot plot, XYDataset dataset, + int seriesIndex) { + + final int numPoints = dataset.getItemCount(seriesIndex); + if (numPoints == 0) { + return; + } + GeneralPath poly = null; + ValueAxis axis = plot.getAxisForDataset(plot.indexOf(dataset)); + for (int i = 0; i < numPoints; i++) { + double theta = dataset.getXValue(seriesIndex, i); + double radius = dataset.getYValue(seriesIndex, i); + Point p = plot.translateToJava2D(theta, radius, axis, dataArea); + if (poly == null) { + poly = new GeneralPath(); + poly.moveTo(p.x, p.y); + } + else { + poly.lineTo(p.x, p.y); + } + } + assert poly != null; + if (getConnectFirstAndLastPoint()) { + poly.closePath(); + } + + g2.setPaint(lookupSeriesPaint(seriesIndex)); + g2.setStroke(lookupSeriesStroke(seriesIndex)); + if (isSeriesFilled(seriesIndex)) { + Composite savedComposite = g2.getComposite(); + g2.setComposite(this.fillComposite); + g2.fill(poly); + g2.setComposite(savedComposite); + if (this.drawOutlineWhenFilled) { + // draw the outline of the filled polygon + g2.setPaint(lookupSeriesOutlinePaint(seriesIndex)); + g2.draw(poly); + } + } + else { + // just the lines, no filling + g2.draw(poly); + } + + // draw the item shapes + if (this.shapesVisible) { + // setup for collecting optional entity info... + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + } + + PathIterator pi = poly.getPathIterator(null); + int i = 0; + while (!pi.isDone()) { + final float[] coords = new float[6]; + final int segType = pi.currentSegment(coords); + pi.next(); + if (segType != PathIterator.SEG_LINETO && + segType != PathIterator.SEG_MOVETO) { + continue; + } + final int x = Math.round(coords[0]); + final int y = Math.round(coords[1]); + final Shape shape = ShapeUtilities.createTranslatedShape( + getItemShape(seriesIndex, i++), x, y); + + Paint paint; + if (useFillPaint) { + paint = lookupSeriesFillPaint(seriesIndex); + } + else { + paint = lookupSeriesPaint(seriesIndex); + } + g2.setPaint(paint); + g2.fill(shape); + if (isSeriesFilled(seriesIndex) && this.drawOutlineWhenFilled) { + g2.setPaint(lookupSeriesOutlinePaint(seriesIndex)); + g2.setStroke(lookupSeriesOutlineStroke(seriesIndex)); + g2.draw(shape); + } + + // add an entity for the item, but only if it falls within the + // data area... + if (entities != null && + AbstractXYItemRenderer.isPointInRect(dataArea, x, y)) { + addEntity(entities, shape, dataset, seriesIndex, i-1, x, y); + } + } + } + } + + /** + * Draw the angular gridlines - the spokes. + * + * @param g2 the drawing surface. + * @param plot the plot (null not permitted). + * @param ticks the ticks (null not permitted). + * @param dataArea the data area. + */ + @Override + public void drawAngularGridLines(Graphics2D g2, PolarPlot plot, + List ticks, Rectangle2D dataArea) { + + g2.setFont(plot.getAngleLabelFont()); + g2.setStroke(plot.getAngleGridlineStroke()); + g2.setPaint(plot.getAngleGridlinePaint()); + + ValueAxis axis = plot.getAxis(); + double centerValue, outerValue; + if (axis.isInverted()) { + outerValue = axis.getLowerBound(); + centerValue = axis.getUpperBound(); + } else { + outerValue = axis.getUpperBound(); + centerValue = axis.getLowerBound(); + } + Point center = plot.translateToJava2D(0, centerValue, axis, dataArea); + Iterator iterator = ticks.iterator(); + while (iterator.hasNext()) { + NumberTick tick = (NumberTick) iterator.next(); + double tickVal = tick.getNumber().doubleValue(); + Point p = plot.translateToJava2D(tickVal, outerValue, axis, + dataArea); + g2.setPaint(plot.getAngleGridlinePaint()); + g2.drawLine(center.x, center.y, p.x, p.y); + if (plot.isAngleLabelsVisible()) { + int x = p.x; + int y = p.y; + g2.setPaint(plot.getAngleLabelPaint()); + TextUtilities.drawAlignedString(tick.getText(), g2, x, y, + tick.getTextAnchor()); + } + } + } + + /** + * Draw the radial gridlines - the rings. + * + * @param g2 the drawing surface (null not permitted). + * @param plot the plot (null not permitted). + * @param radialAxis the radial axis (null not permitted). + * @param ticks the ticks (null not permitted). + * @param dataArea the data area. + */ + @Override + public void drawRadialGridLines(Graphics2D g2, PolarPlot plot, + ValueAxis radialAxis, List ticks, Rectangle2D dataArea) { + + ParamChecks.nullNotPermitted(radialAxis, "radialAxis"); + g2.setFont(radialAxis.getTickLabelFont()); + g2.setPaint(plot.getRadiusGridlinePaint()); + g2.setStroke(plot.getRadiusGridlineStroke()); + + double centerValue; + if (radialAxis.isInverted()) { + centerValue = radialAxis.getUpperBound(); + } else { + centerValue = radialAxis.getLowerBound(); + } + Point center = plot.translateToJava2D(0, centerValue, radialAxis, dataArea); + + Iterator iterator = ticks.iterator(); + while (iterator.hasNext()) { + NumberTick tick = (NumberTick) iterator.next(); + double angleDegrees = plot.isCounterClockwise() + ? plot.getAngleOffset() : -plot.getAngleOffset(); + Point p = plot.translateToJava2D(angleDegrees, + tick.getNumber().doubleValue(), radialAxis, dataArea); + int r = p.x - center.x; + int upperLeftX = center.x - r; + int upperLeftY = center.y - r; + int d = 2 * r; + Ellipse2D ring = new Ellipse2D.Double(upperLeftX, upperLeftY, d, d); + g2.setPaint(plot.getRadiusGridlinePaint()); + g2.draw(ring); + } + } + + /** + * Return the legend for the given series. + * + * @param series the series index. + * + * @return The legend item. + */ + @Override + public LegendItem getLegendItem(int series) { + LegendItem result; + PolarPlot plot = getPlot(); + if (plot == null) { + return null; + } + XYDataset dataset = plot.getDataset(plot.getIndexOf(this)); + if (dataset == null) { + return null; + } + + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel(dataset, + series); + } + + Comparable seriesKey = dataset.getSeriesKey(series); + String label = seriesKey.toString(); + String description = label; + Shape shape = lookupSeriesShape(series); + Paint paint; + if (this.useFillPaint) { + paint = lookupSeriesFillPaint(series); + } + else { + paint = lookupSeriesPaint(series); + } + Stroke stroke = lookupSeriesStroke(series); + Paint outlinePaint = lookupSeriesOutlinePaint(series); + Stroke outlineStroke = lookupSeriesOutlineStroke(series); + boolean shapeOutlined = isSeriesFilled(series) + && this.drawOutlineWhenFilled; + result = new LegendItem(label, description, toolTipText, urlText, + getShapesVisible(), shape, /* shapeFilled=*/ true, paint, + shapeOutlined, outlinePaint, outlineStroke, + /* lineVisible= */ true, this.legendLine, stroke, paint); + result.setToolTipText(toolTipText); + result.setURLText(urlText); + result.setDataset(dataset); + result.setSeriesKey(seriesKey); + result.setSeriesIndex(series); + + return result; + } + + /** + * Returns the tooltip generator for the specified series and item. + * + * @param series the series index. + * @param item the item index. + * + * @return The tooltip generator (possibly null). + * + * @since 1.0.14 + */ + @Override + public XYToolTipGenerator getToolTipGenerator(int series, int item) { + XYToolTipGenerator generator + = (XYToolTipGenerator) this.toolTipGeneratorList.get(series); + if (generator == null) { + generator = this.baseToolTipGenerator; + } + return generator; + } + + /** + * Returns the tool tip generator for the specified series. + * + * @return The tooltip generator (possibly null). + * + * @since 1.0.14 + */ + @Override + public XYToolTipGenerator getSeriesToolTipGenerator(int series) { + return (XYToolTipGenerator) this.toolTipGeneratorList.get(series); + } + + /** + * Sets the tooltip generator for the specified series. + * + * @param series the series index. + * @param generator the tool tip generator (null permitted). + * + * @since 1.0.14 + */ + @Override + public void setSeriesToolTipGenerator(int series, + XYToolTipGenerator generator) { + this.toolTipGeneratorList.set(series, generator); + fireChangeEvent(); + } + + /** + * Returns the default tool tip generator. + * + * @return The default tool tip generator (possibly null). + * + * @since 1.0.14 + */ + @Override + public XYToolTipGenerator getBaseToolTipGenerator() { + return this.baseToolTipGenerator; + } + + /** + * Sets the default tool tip generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @since 1.0.14 + */ + @Override + public void setBaseToolTipGenerator(XYToolTipGenerator generator) { + this.baseToolTipGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the URL generator. + * + * @return The URL generator (possibly null). + * + * @since 1.0.14 + */ + @Override + public XYURLGenerator getURLGenerator() { + return this.urlGenerator; + } + + /** + * Sets the URL generator. + * + * @param urlGenerator the generator (null permitted) + * + * @since 1.0.14 + */ + @Override + public void setURLGenerator(XYURLGenerator urlGenerator) { + this.urlGenerator = urlGenerator; + fireChangeEvent(); + } + + /** + * Returns the legend item tool tip generator. + * + * @return The tool tip generator (possibly null). + * + * @see #setLegendItemToolTipGenerator(XYSeriesLabelGenerator) + * @since 1.0.14 + */ + public XYSeriesLabelGenerator getLegendItemToolTipGenerator() { + return this.legendItemToolTipGenerator; + } + + /** + * Sets the legend item tool tip generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getLegendItemToolTipGenerator() + * @since 1.0.14 + */ + public void setLegendItemToolTipGenerator( + XYSeriesLabelGenerator generator) { + this.legendItemToolTipGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the legend item URL generator. + * + * @return The URL generator (possibly null). + * + * @see #setLegendItemURLGenerator(XYSeriesLabelGenerator) + * @since 1.0.14 + */ + public XYSeriesLabelGenerator getLegendItemURLGenerator() { + return this.legendItemURLGenerator; + } + + /** + * Sets the legend item URL generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getLegendItemURLGenerator() + * @since 1.0.14 + */ + public void setLegendItemURLGenerator(XYSeriesLabelGenerator generator) { + this.legendItemURLGenerator = generator; + fireChangeEvent(); + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null not permitted). + * + * @return true if this renderer is equal to obj, + * and false otherwise. + */ + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (!(obj instanceof DefaultPolarItemRenderer)) { + return false; + } + DefaultPolarItemRenderer that = (DefaultPolarItemRenderer) obj; + if (!this.seriesFilled.equals(that.seriesFilled)) { + return false; + } + if (this.drawOutlineWhenFilled != that.drawOutlineWhenFilled) { + return false; + } + if (!ObjectUtilities.equal(this.fillComposite, that.fillComposite)) { + return false; + } + if (this.useFillPaint != that.useFillPaint) { + return false; + } + if (!ShapeUtilities.equal(this.legendLine, that.legendLine)) { + return false; + } + if (this.shapesVisible != that.shapesVisible) { + return false; + } + if (this.connectFirstAndLastPoint != that.connectFirstAndLastPoint) { + return false; + } + if (!this.toolTipGeneratorList.equals(that.toolTipGeneratorList)) { + return false; + } + if (!ObjectUtilities.equal(this.baseToolTipGenerator, + that.baseToolTipGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.urlGenerator, that.urlGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.legendItemToolTipGenerator, + that.legendItemToolTipGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.legendItemURLGenerator, + that.legendItemURLGenerator)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultPolarItemRenderer clone + = (DefaultPolarItemRenderer) super.clone(); + if (this.legendLine != null) { + clone.legendLine = ShapeUtilities.clone(this.legendLine); + } + clone.seriesFilled = (BooleanList) this.seriesFilled.clone(); + clone.toolTipGeneratorList + = (ObjectList) this.toolTipGeneratorList.clone(); + if (clone.baseToolTipGenerator instanceof PublicCloneable) { + clone.baseToolTipGenerator = (XYToolTipGenerator) + ObjectUtilities.clone(this.baseToolTipGenerator); + } + if (clone.urlGenerator instanceof PublicCloneable) { + clone.urlGenerator = (XYURLGenerator) + ObjectUtilities.clone(this.urlGenerator); + } + if (clone.legendItemToolTipGenerator instanceof PublicCloneable) { + clone.legendItemToolTipGenerator = (XYSeriesLabelGenerator) + ObjectUtilities.clone(this.legendItemToolTipGenerator); + } + if (clone.legendItemURLGenerator instanceof PublicCloneable) { + clone.legendItemURLGenerator = (XYSeriesLabelGenerator) + ObjectUtilities.clone(this.legendItemURLGenerator); + } + return clone; + } + + /** + * 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.legendLine = SerialUtilities.readShape(stream); + this.fillComposite = SerialUtilities.readComposite(stream); + } + + /** + * 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.legendLine, stream); + SerialUtilities.writeComposite(this.fillComposite, stream); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/GrayPaintScale.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/GrayPaintScale.java new file mode 100755 index 0000000..3a9fc7a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/GrayPaintScale.java @@ -0,0 +1,237 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * GrayPaintScale.java + * ------------------- + * (C) Copyright 2006-2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Jul-2006 : Version 1 (DG); + * 31-Jan-2007 : Renamed min and max to lowerBound and upperBound (DG); + * 26-Sep-2007 : Fixed bug 1767315, problem in getPaint() method (DG); + * 29-Jan-2009 : Added alpha transparency field and hashCode() method (DG); + * + */ + +package org.jfree.chart.renderer; + +import java.awt.Color; +import java.awt.Paint; +import java.io.Serializable; + +import org.jfree.chart.HashUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A paint scale that returns shades of gray. + * + * @since 1.0.4 + */ +public class GrayPaintScale + implements PaintScale, PublicCloneable, Serializable { + + /** The lower bound. */ + private double lowerBound; + + /** The upper bound. */ + private double upperBound; + + /** + * The alpha transparency (0-255). + * + * @since 1.0.13 + */ + private int alpha; + + /** + * Creates a new GrayPaintScale instance with default values. + */ + public GrayPaintScale() { + this(0.0, 1.0); + } + + /** + * Creates a new paint scale for values in the specified range. + * + * @param lowerBound the lower bound. + * @param upperBound the upper bound. + * + * @throws IllegalArgumentException if lowerBound is not + * less than upperBound. + */ + public GrayPaintScale(double lowerBound, double upperBound) { + this(lowerBound, upperBound, 255); + } + + /** + * Creates a new paint scale for values in the specified range. + * + * @param lowerBound the lower bound. + * @param upperBound the upper bound. + * @param alpha the alpha transparency (0-255). + * + * @throws IllegalArgumentException if lowerBound is not + * less than upperBound, or alpha is not in + * the range 0 to 255. + * + * @since 1.0.13 + */ + public GrayPaintScale(double lowerBound, double upperBound, int alpha) { + if (lowerBound >= upperBound) { + throw new IllegalArgumentException( + "Requires lowerBound < upperBound."); + } + if (alpha < 0 || alpha > 255) { + throw new IllegalArgumentException( + "Requires alpha in the range 0 to 255."); + + } + this.lowerBound = lowerBound; + this.upperBound = upperBound; + this.alpha = alpha; + } + + /** + * Returns the lower bound. + * + * @return The lower bound. + * + * @see #getUpperBound() + */ + @Override + public double getLowerBound() { + return this.lowerBound; + } + + /** + * Returns the upper bound. + * + * @return The upper bound. + * + * @see #getLowerBound() + */ + @Override + public double getUpperBound() { + return this.upperBound; + } + + /** + * Returns the alpha transparency that was specified in the constructor. + * + * @return The alpha transparency (in the range 0 to 255). + * + * @since 1.0.13 + */ + public int getAlpha() { + return this.alpha; + } + + /** + * Returns a paint for the specified value. + * + * @param value the value (must be within the range specified by the + * lower and upper bounds for the scale). + * + * @return A paint for the specified value. + */ + @Override + public Paint getPaint(double value) { + double v = Math.max(value, this.lowerBound); + v = Math.min(v, this.upperBound); + int g = (int) ((v - this.lowerBound) / (this.upperBound + - this.lowerBound) * 255.0); + // FIXME: it probably makes sense to allocate an array of 256 Colors + // and lazily populate this array... + return new Color(g, g, g, this.alpha); + } + + /** + * Tests this GrayPaintScale instance for equality with an + * arbitrary object. This method returns true if and only + * if: + *

    + *
  • obj is not null;
  • + *
  • obj is an instance of GrayPaintScale;
  • + *
+ * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof GrayPaintScale)) { + return false; + } + GrayPaintScale that = (GrayPaintScale) obj; + if (this.lowerBound != that.lowerBound) { + return false; + } + if (this.upperBound != that.upperBound) { + return false; + } + if (this.alpha != that.alpha) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int hash = 7; + hash = HashUtilities.hashCode(hash, this.lowerBound); + hash = HashUtilities.hashCode(hash, this.upperBound); + hash = 43 * hash + this.alpha; + return hash; + } + + /** + * Returns a clone of this GrayPaintScale instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning this + * instance. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/LookupPaintScale.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/LookupPaintScale.java new file mode 100755 index 0000000..bddba73 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/LookupPaintScale.java @@ -0,0 +1,407 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * LookupPaintScale.java + * --------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Jul-2006 : Version 1 (DG); + * 31-Jan-2007 : Fixed serialization support (DG); + * 09-Mar-2007 : Fixed cloning (DG); + * 14-Jun-2007 : Use double primitive in PaintItem (DG); + * 28-Mar-2009 : Made PaintItem inner class static (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer; + +import java.awt.Color; +import java.awt.Paint; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Collections; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.io.SerialUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A paint scale that uses a lookup table to associate paint instances + * with data value ranges. + * + * @since 1.0.4 + */ +public class LookupPaintScale + implements PaintScale, PublicCloneable, Serializable { + + /** + * Stores the paint for a value. + */ + static class PaintItem implements Comparable, Serializable { + + /** For serialization. */ + static final long serialVersionUID = 698920578512361570L; + + /** The value. */ + double value; + + /** The paint. */ + transient Paint paint; + + /** + * Creates a new instance. + * + * @param value the value. + * @param paint the paint. + */ + public PaintItem(double value, Paint paint) { + this.value = value; + this.paint = paint; + } + + /** + * Compares this item to an arbitrary object. + * + * @param obj the object. + * + * @return An int defining the relative order of the objects. + */ + @Override + public int compareTo(Object obj) { + PaintItem that = (PaintItem) obj; + double d1 = this.value; + double d2 = that.value; + if (d1 > d2) { + return 1; + } + if (d1 < d2) { + return -1; + } + return 0; + } + + /** + * Tests this item for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PaintItem)) { + return false; + } + PaintItem that = (PaintItem) obj; + if (this.value != that.value) { + return false; + } + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + return true; + } + + /** + * 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); + } + + } + + /** For serialization. */ + static final long serialVersionUID = -5239384246251042006L; + + /** The lower bound. */ + private double lowerBound; + + /** The upper bound. */ + private double upperBound; + + /** The default paint. */ + private transient Paint defaultPaint; + + /** The lookup table. */ + private List lookupTable; + + /** + * Creates a new paint scale. + */ + public LookupPaintScale() { + this(0.0, 1.0, Color.lightGray); + } + + /** + * Creates a new paint scale with the specified default paint. + * + * @param lowerBound the lower bound. + * @param upperBound the upper bound. + * @param defaultPaint the default paint (null not + * permitted). + */ + public LookupPaintScale(double lowerBound, double upperBound, + Paint defaultPaint) { + if (lowerBound >= upperBound) { + throw new IllegalArgumentException( + "Requires lowerBound < upperBound."); + } + ParamChecks.nullNotPermitted(defaultPaint, "defaultPaint"); + this.lowerBound = lowerBound; + this.upperBound = upperBound; + this.defaultPaint = defaultPaint; + this.lookupTable = new java.util.ArrayList(); + } + + /** + * Returns the default paint (never null). + * + * @return The default paint. + */ + public Paint getDefaultPaint() { + return this.defaultPaint; + } + + /** + * Returns the lower bound. + * + * @return The lower bound. + * + * @see #getUpperBound() + */ + @Override + public double getLowerBound() { + return this.lowerBound; + } + + /** + * Returns the upper bound. + * + * @return The upper bound. + * + * @see #getLowerBound() + */ + @Override + public double getUpperBound() { + return this.upperBound; + } + + /** + * Adds an entry to the lookup table. Any values from n up + * to but not including the next value in the table take on the specified + * paint. + * + * @param value the data value (null not permitted). + * @param paint the paint. + * + * @deprecated Use {@link #add(double, Paint)}. + */ + public void add(Number value, Paint paint) { + add(value.doubleValue(), paint); + } + + /** + * Adds an entry to the lookup table. Any values from n up + * to but not including the next value in the table take on the specified + * paint. + * + * @param value the data value. + * @param paint the paint. + * + * @since 1.0.6 + */ + public void add(double value, Paint paint) { + PaintItem item = new PaintItem(value, paint); + int index = Collections.binarySearch(this.lookupTable, item); + if (index >= 0) { + this.lookupTable.set(index, item); + } + else { + this.lookupTable.add(-(index + 1), item); + } + } + + /** + * Returns the paint associated with the specified value. + * + * @param value the value. + * + * @return The paint. + * + * @see #getDefaultPaint() + */ + @Override + public Paint getPaint(double value) { + + // handle value outside bounds... + if (value < this.lowerBound) { + return this.defaultPaint; + } + if (value > this.upperBound) { + return this.defaultPaint; + } + + int count = this.lookupTable.size(); + if (count == 0) { + return this.defaultPaint; + } + + // handle special case where value is less that item zero + PaintItem item = (PaintItem) this.lookupTable.get(0); + if (value < item.value) { + return this.defaultPaint; + } + + // for value in bounds, do the lookup... + int low = 0; + int high = this.lookupTable.size() - 1; + while (high - low > 1) { + int current = (low + high) / 2; + item = (PaintItem) this.lookupTable.get(current); + if (value >= item.value) { + low = current; + } + else { + high = current; + } + } + if (high > low) { + item = (PaintItem) this.lookupTable.get(high); + if (value < item.value) { + item = (PaintItem) this.lookupTable.get(low); + } + } + return (item != null ? item.paint : this.defaultPaint); + } + + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof LookupPaintScale)) { + return false; + } + LookupPaintScale that = (LookupPaintScale) obj; + if (this.lowerBound != that.lowerBound) { + return false; + } + if (this.upperBound != that.upperBound) { + return false; + } + if (!PaintUtilities.equal(this.defaultPaint, that.defaultPaint)) { + return false; + } + if (!this.lookupTable.equals(that.lookupTable)) { + return false; + } + return true; + } + + /** + * Returns a clone of the instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning the + * instance. + */ + @Override + public Object clone() throws CloneNotSupportedException { + LookupPaintScale clone = (LookupPaintScale) super.clone(); + clone.lookupTable = new java.util.ArrayList(this.lookupTable); + 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.defaultPaint, 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.defaultPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/NotOutlierException.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/NotOutlierException.java new file mode 100755 index 0000000..e26c10d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/NotOutlierException.java @@ -0,0 +1,61 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * NotOutlierException.java + * ------------------------ + * (C) Copyright 2003-2008, by David Browning and Contributors. + * + * Original Author: David Browning (for Australian Institute of Marine + * Science); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Aug-2003 : Version 1, contributed by David Browning (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.renderer; + +/** + * An exception that is generated by the {@link Outlier}, {@link OutlierList} + * and {@link OutlierListCollection} classes. + */ +public class NotOutlierException extends Exception { + + /** + * Creates a new exception. + * + * @param message the exception message. + */ + public NotOutlierException(String message) { + super(message); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/Outlier.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/Outlier.java new file mode 100755 index 0000000..678a661 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/Outlier.java @@ -0,0 +1,213 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------ + * Outlier.java + * ------------ + * (C) Copyright 2003-2008, by David Browning and Contributors. + * + * Original Author: David Browning (for Australian Institute of Marine + * Science); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 05-Aug-2003 : Version 1, contributed by David Browning (DG); + * 28-Aug-2003 : Minor tidy-up (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * 21-Nov-2007 : Implemented equals() to shut up FindBugs (DG); + * + */ + +package org.jfree.chart.renderer; + +import java.awt.geom.Point2D; + +/** + * Represents one outlier in the box and whisker plot. + *

+ * All the coordinates in this class are in Java2D space. + */ +public class Outlier implements Comparable { + + /** + * The xy coordinates of the bounding box containing the outlier ellipse. + */ + private Point2D point; + + /** The radius of the ellipse */ + private double radius; + + /** + * Constructs an outlier item consisting of a point and the radius of the + * outlier ellipse + * + * @param xCoord the x coordinate of the point. + * @param yCoord the y coordinate of the point. + * @param radius the radius of the ellipse. + */ + public Outlier(double xCoord, double yCoord, double radius) { + this.point = new Point2D.Double(xCoord - radius, yCoord - radius); + this.radius = radius; + } + + /** + * Returns the xy coordinates of the bounding box containing the outlier + * ellipse. + * + * @return The location of the outlier ellipse. + */ + public Point2D getPoint() { + return this.point; + } + + /** + * Sets the xy coordinates of the bounding box containing the outlier + * ellipse. + * + * @param point the location. + */ + public void setPoint(Point2D point) { + this.point = point; + } + + /** + * Returns the x coordinate of the bounding box containing the outlier + * ellipse. + * + * @return The x coordinate. + */ + public double getX() { + return getPoint().getX(); + } + + /** + * Returns the y coordinate of the bounding box containing the outlier + * ellipse. + * + * @return The y coordinate. + */ + public double getY() { + return getPoint().getY(); + } + + /** + * Returns the radius of the outlier ellipse. + * + * @return The radius. + */ + public double getRadius() { + return this.radius; + } + + /** + * Sets the radius of the outlier ellipse. + * + * @param radius the new radius. + */ + public void setRadius(double radius) { + this.radius = radius; + } + + /** + * Compares this object with the specified object for order, based on + * the outlier's point. + * + * @param o the Object to be compared. + * @return A negative integer, zero, or a positive integer as this object + * is less than, equal to, or greater than the specified object. + * + */ + @Override + public int compareTo(Object o) { + Outlier outlier = (Outlier) o; + Point2D p1 = getPoint(); + Point2D p2 = outlier.getPoint(); + if (p1.equals(p2)) { + return 0; + } + else if ((p1.getX() < p2.getX()) || (p1.getY() < p2.getY())) { + return -1; + } + else { + return 1; + } + } + + /** + * Returns a true if outlier is overlapped and false if it is not. + * Overlapping is determined by the respective bounding boxes plus + * a small margin. + * + * @param other the other outlier. + * + * @return A boolean indicating whether or not an overlap has + * occurred. + */ + public boolean overlaps(Outlier other) { + return ((other.getX() >= getX() - (this.radius * 1.1)) + && (other.getX() <= getX() + (this.radius * 1.1)) + && (other.getY() >= getY() - (this.radius * 1.1)) + && (other.getY() <= getY() + (this.radius * 1.1))); + } + + /** + * Tests this outlier for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Outlier)) { + return false; + } + Outlier that = (Outlier) obj; + if (!this.point.equals(that.point)) { + return false; + } + if (this.radius != that.radius) { + return false; + } + return true; + } + + /** + * Returns a textual representation of the outlier. + * + * @return A String representing the outlier. + */ + @Override + public String toString() { + return "{" + getX() + "," + getY() + "}"; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/OutlierList.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/OutlierList.java new file mode 100755 index 0000000..ab7c20b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/OutlierList.java @@ -0,0 +1,185 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * OutlierList.java + * ---------------- + * (C) Copyright 2003-2008, by David Browning and Contributors. + * + * Original Author: David Browning (for Australian Institute of Marine + * Science); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 05-Aug-2003 : Version 1, contributed by David Browning (DG); + * 28-Aug-2003 : Minor tidy-up including Javadocs (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.renderer; + +import java.awt.geom.Point2D; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * A collection of outliers for a single entity in a box and whisker plot. + * + * Outliers are grouped in lists for each entity. Lists contain + * one or more outliers, determined by whether overlaps have + * occured. Overlapping outliers are grouped in the same list. + * + * Each list contains an averaged outlier, which is the same as a single + * outlier if there is only one outlier in the list, but the average of + * all the outliers in the list if there is more than one. + * + * NB This is simply my scheme for displaying outliers, and might not be + * acceptable by the wider community. + */ +public class OutlierList { + + /** Storage for the outliers. */ + private List outliers; + + /** The averaged outlier. */ + private Outlier averagedOutlier; + + /** + * A flag that indicates whether or not there are multiple outliers in the + * list. + */ + private boolean multiple = false; + + /** + * Creates a new list containing a single outlier. + * + * @param outlier the outlier. + */ + public OutlierList(Outlier outlier) { + this.outliers = new ArrayList(); + setAveragedOutlier(outlier); + } + + /** + * Adds an outlier to the list. + * + * @param outlier the outlier. + * + * @return A boolean. + */ + public boolean add(Outlier outlier) { + return this.outliers.add(outlier); + } + + /** + * Returns the number of outliers in the list. + * + * @return The item count. + */ + public int getItemCount() { + return this.outliers.size(); + } + + /** + * Returns the averaged outlier. + * + * @return The averaged outlier. + */ + public Outlier getAveragedOutlier() { + return this.averagedOutlier; + } + + /** + * Sets the averaged outlier. + * + * @param averagedOutlier the averaged outlier. + */ + public void setAveragedOutlier(Outlier averagedOutlier) { + this.averagedOutlier = averagedOutlier; + } + + /** + * Returns true if the list contains multiple outliers, and + * false otherwise. + * + * @return A boolean. + */ + public boolean isMultiple() { + return this.multiple; + } + + /** + * Sets the flag that indicates whether or not this list represents + * multiple outliers. + * + * @param multiple the flag. + */ + public void setMultiple(boolean multiple) { + this.multiple = multiple; + } + + /** + * Returns true if the outlier overlaps, and + * false otherwise. + * + * @param other the outlier. + * + * @return A boolean. + */ + public boolean isOverlapped(Outlier other) { + + if (other == null) { + return false; + } + + boolean result = other.overlaps(getAveragedOutlier()); + return result; + + } + + /** + * Updates the averaged outlier. + * + */ + public void updateAveragedOutlier() { + double totalXCoords = 0.0; + double totalYCoords = 0.0; + int size = getItemCount(); + for (Iterator iterator = this.outliers.iterator(); + iterator.hasNext();) { + Outlier o = (Outlier) iterator.next(); + totalXCoords += o.getX(); + totalYCoords += o.getY(); + } + getAveragedOutlier().getPoint().setLocation( + new Point2D.Double(totalXCoords / size, totalYCoords / size)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/OutlierListCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/OutlierListCollection.java new file mode 100755 index 0000000..2defa41 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/OutlierListCollection.java @@ -0,0 +1,186 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * OutlierListCollection.java + * -------------------------- + * (C) Copyright 2003-2008, by David Browning and Contributors. + * + * Original Author: David Browning (for Australian Institute of Marine + * Science); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Aug-2003 : Version 1, contributed by David Browning (DG); + * 01-Sep-2003 : Made storage internal rather than extending ArrayList (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.renderer; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * A collection of outlier lists for a box and whisker plot. Each collection is + * associated with a single box and whisker entity. + * + * Outliers are grouped in lists for each entity. Lists contain + * one or more outliers, determined by whether overlaps have + * occurred. Overlapping outliers are grouped in the same list. + * + * @see org.jfree.chart.renderer.OutlierList + */ +public class OutlierListCollection { + + /** Storage for the outlier lists. */ + private List outlierLists; + + /** + * Unbelievably, outliers which are more than 2 * interquartile range are + * called far outs... See Tukey EDA (a classic one of a kind...) + */ + private boolean highFarOut = false; + + /** + * A flag that indicates whether or not the collection contains low far + * out values. + */ + private boolean lowFarOut = false; + + /** + * Creates a new empty collection. + */ + public OutlierListCollection() { + this.outlierLists = new ArrayList(); + } + + /** + * A flag to indicate the presence of one or more far out values at the + * top end of the range. + * + * @return A boolean. + */ + public boolean isHighFarOut() { + return this.highFarOut; + } + + /** + * Sets the flag that indicates the presence of one or more far out values + * at the top end of the range. + * + * @param farOut the flag. + */ + public void setHighFarOut(boolean farOut) { + this.highFarOut = farOut; + } + + /** + * A flag to indicate the presence of one or more far out values at the + * bottom end of the range. + * + * @return A boolean. + */ + public boolean isLowFarOut() { + return this.lowFarOut; + } + + /** + * Sets the flag that indicates the presence of one or more far out values + * at the bottom end of the range. + * + * @param farOut the flag. + */ + public void setLowFarOut(boolean farOut) { + this.lowFarOut = farOut; + } + /** + * Appends the specified element as a new OutlierList to the + * end of this list if it does not overlap an outlier in an existing list. + * + * If it does overlap, it is appended to the outlier list which it overlaps + * and that list is updated. + * + * @param outlier element to be appended to this list. + * + * @return true (as per the general contract of Collection.add). + */ + public boolean add(Outlier outlier) { + + if (this.outlierLists.isEmpty()) { + return this.outlierLists.add(new OutlierList(outlier)); + } + else { + boolean updated = false; + for (Iterator iterator = this.outlierLists.iterator(); + iterator.hasNext();) { + OutlierList list = (OutlierList) iterator.next(); + if (list.isOverlapped(outlier)) { + updated = updateOutlierList(list, outlier); + } + } + if (!updated) { + //System.err.print(" creating new outlier list "); + updated = this.outlierLists.add(new OutlierList(outlier)); + } + return updated; + } + + } + + /** + * Returns an iterator for the outlier lists. + * + * @return An iterator. + */ + public Iterator iterator() { + return this.outlierLists.iterator(); + } + + + /** + * Updates the outlier list by adding the outlier to the end of the list and + * setting the averaged outlier to the average x and y coordinnate values + * of the outliers in the list. + * + * @param list the outlier list to be updated. + * @param outlier the outlier to be added + * + * @return true (as per the general contract of Collection.add). + */ + private boolean updateOutlierList(OutlierList list, Outlier outlier) { + boolean result = false; + result = list.add(outlier); + list.updateAveragedOutlier(); + list.setMultiple(true); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/PaintScale.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/PaintScale.java new file mode 100755 index 0000000..5d78a32 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/PaintScale.java @@ -0,0 +1,88 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * PaintScale.java + * --------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Jul-2006 : Version 1 (DG); + * 31-Jan-2007 : Added getLowerBound() and getUpperBound() methods (DG); + * + */ + +package org.jfree.chart.renderer; + +import java.awt.Paint; + +import org.jfree.chart.renderer.xy.XYBlockRenderer; + +/** + * A source for Paint instances, used by the + * {@link XYBlockRenderer}. + *

+ * NOTE: Classes that implement this interface should also implement + * PublicCloneable and Serializable, so + * that any renderer (or other object instance) that references an instance of + * this interface can still be cloned or serialized. + * + * @since 1.0.4 + */ +public interface PaintScale { + + /** + * Returns the lower bound for the scale. + * + * @return The lower bound. + * + * @see #getUpperBound() + */ + public double getLowerBound(); + + /** + * Returns the upper bound for the scale. + * + * @return The upper bound. + * + * @see #getLowerBound() + */ + public double getUpperBound(); + + /** + * Returns a Paint instance for the specified value. + * + * @param value the value. + * + * @return A Paint instance (never null). + */ + public Paint getPaint(double value); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/PolarItemRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/PolarItemRenderer.java new file mode 100755 index 0000000..867c02a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/PolarItemRenderer.java @@ -0,0 +1,225 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * PolarItemRenderer.java + * ---------------------- + * (C) Copyright 2004-2011, 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); + * 03-Oct-2011 : Added tooltip and URL generator support (MH); + * + */ + +package org.jfree.chart.renderer; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.util.List; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.event.RendererChangeListener; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.PolarPlot; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.data.xy.XYDataset; + +/** + * The interface for a renderer that can be used by the {@link PolarPlot} + * class. + */ +public interface PolarItemRenderer { + + /** + * Plots the data for a given series. + * + * @param g2 the drawing surface. + * @param dataArea the data area. + * @param info collects plot rendering info. + * @param plot the plot. + * @param dataset the dataset. + * @param seriesIndex the series index. + */ + public void drawSeries(Graphics2D g2, Rectangle2D dataArea, + PlotRenderingInfo info, PolarPlot plot, XYDataset dataset, + int seriesIndex); + + /** + * Draw the angular gridlines - the spokes. + * + * @param g2 the drawing surface. + * @param plot the plot. + * @param ticks the ticks. + * @param dataArea the data area. + */ + public void drawAngularGridLines(Graphics2D g2, PolarPlot plot, + List ticks, Rectangle2D dataArea); + + /** + * Draw the radial gridlines - the rings. + * + * @param g2 the drawing surface. + * @param plot the plot. + * @param radialAxis the radial axis. + * @param ticks the ticks. + * @param dataArea the data area. + */ + public void drawRadialGridLines(Graphics2D g2, PolarPlot plot, + ValueAxis radialAxis, List ticks, Rectangle2D dataArea); + + /** + * Return the legend for the given series. + * + * @param series the series index. + * + * @return The legend item. + */ + public LegendItem getLegendItem(int series); + + /** + * Returns the plot that this renderer has been assigned to. + * + * @return The plot. + */ + public PolarPlot getPlot(); + + /** + * Sets the plot that this renderer is assigned to. This method will be + * called by the plot class...you do not need to call it yourself. + * + * @param plot the plot. + */ + public void setPlot(PolarPlot plot); + + /** + * Adds a change listener. + * + * @param listener the listener. + */ + public void addChangeListener(RendererChangeListener listener); + + /** + * Removes a change listener. + * + * @param listener the listener. + */ + public void removeChangeListener(RendererChangeListener listener); + + + //// TOOL TIP GENERATOR /////////////////////////////////////////////////// + + /** + * Returns the tool tip generator for a data item. + * + * @param row the row index (zero based). + * @param column the column index (zero based). + * + * @return The generator (possibly null). + * + * @since 1.0.14 + */ + public XYToolTipGenerator getToolTipGenerator(int row, int column); + + /** + * Returns the tool tip generator for a series. + * + * @param series the series index (zero based). + * + * @return The generator (possibly null). + * + * @see #setSeriesToolTipGenerator(int, XYToolTipGenerator) + * + * @since 1.0.14 + */ + public XYToolTipGenerator getSeriesToolTipGenerator(int series); + + /** + * Sets the tool tip generator for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero based). + * @param generator the generator (null permitted). + * + * @see #getSeriesToolTipGenerator(int) + * + * @since 1.0.14 + */ + public void setSeriesToolTipGenerator(int series, + XYToolTipGenerator generator); + + /** + * Returns the base tool tip generator. + * + * @return The generator (possibly null). + * + * @see #setBaseToolTipGenerator(XYToolTipGenerator) + * + * @since 1.0.14 + */ + public XYToolTipGenerator getBaseToolTipGenerator(); + + /** + * Sets the base tool tip generator and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getBaseToolTipGenerator() + * + * @since 1.0.14 + */ + public void setBaseToolTipGenerator(XYToolTipGenerator generator); + + + //// URL GENERATOR //////////////////////////////////////////////////////// + + /** + * Returns the URL generator for HTML image maps. + * + * @return The URL generator (possibly null). + * + * @since 1.0.14 + */ + public XYURLGenerator getURLGenerator(); + + /** + * Sets the URL generator for HTML image maps. + * + * @param urlGenerator the URL generator (null permitted). + * + * @since 1.0.14 + */ + public void setURLGenerator(XYURLGenerator urlGenerator); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/RendererState.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/RendererState.java new file mode 100755 index 0000000..a36abdd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/RendererState.java @@ -0,0 +1,93 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * RendererState.java + * ------------------ + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 07-Oct-2003 : Version 1 (DG); + * 09-Jun-2005 : Added a convenience method to access the entity + * collection (DG); + * + */ + +package org.jfree.chart.renderer; + +import org.jfree.chart.ChartRenderingInfo; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.plot.PlotRenderingInfo; + +/** + * Represents the current state of a renderer. + */ +public class RendererState { + + /** The plot rendering info. */ + private PlotRenderingInfo info; + + /** + * Creates a new state object. + * + * @param info the plot rendering info. + */ + public RendererState(PlotRenderingInfo info) { + this.info = info; + } + + /** + * Returns the plot rendering info. + * + * @return The info. + */ + public PlotRenderingInfo getInfo() { + return this.info; + } + + /** + * A convenience method that returns a reference to the entity + * collection (may be null) being used to record + * chart entities. + * + * @return The entity collection (possibly null). + */ + public EntityCollection getEntityCollection() { + EntityCollection result = null; + if (this.info != null) { + ChartRenderingInfo owner = this.info.getOwner(); + if (owner != null) { + result = owner.getEntityCollection(); + } + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/RendererUtilities.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/RendererUtilities.java new file mode 100755 index 0000000..b2b019b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/RendererUtilities.java @@ -0,0 +1,268 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * RendererUtilities.java + * ---------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Apr-2007 : Version 1 (DG); + * 27-Mar-2009 : Fixed results for unsorted datasets (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * 23-Aug-2012 : Fixed rendering anomaly bug 3561093 (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer; + +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.DomainOrder; +import org.jfree.data.xy.XYDataset; + +/** + * Utility methods related to the rendering process. + * + * @since 1.0.6 + */ +public class RendererUtilities { + + /** + * Finds the lower index of the range of live items in the specified data + * series. + * + * @param dataset the dataset (null not permitted). + * @param series the series index. + * @param xLow the lowest x-value in the live range. + * @param xHigh the highest x-value in the live range. + * + * @return The index of the required item. + * + * @since 1.0.6 + * + * @see #findLiveItemsUpperBound(XYDataset, int, double, double) + */ + public static int findLiveItemsLowerBound(XYDataset dataset, int series, + double xLow, double xHigh) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + if (xLow >= xHigh) { + throw new IllegalArgumentException("Requires xLow < xHigh."); + } + int itemCount = dataset.getItemCount(series); + if (itemCount <= 1) { + return 0; + } + if (dataset.getDomainOrder() == DomainOrder.ASCENDING) { + // for data in ascending order by x-value, we are (broadly) looking + // for the index of the highest x-value that is less than xLow + int low = 0; + int high = itemCount - 1; + double lowValue = dataset.getXValue(series, low); + if (lowValue >= xLow) { + // special case where the lowest x-value is >= xLow + return low; + } + double highValue = dataset.getXValue(series, high); + if (highValue < xLow) { + // special case where the highest x-value is < xLow + return high; + } + while (high - low > 1) { + int mid = (low + high) / 2; + double midV = dataset.getXValue(series, mid); + if (midV >= xLow) { + high = mid; + } + else { + low = mid; + } + } + return high; + } + else if (dataset.getDomainOrder() == DomainOrder.DESCENDING) { + // when the x-values are sorted in descending order, the lower + // bound is found by calculating relative to the xHigh value + int low = 0; + int high = itemCount - 1; + double lowValue = dataset.getXValue(series, low); + if (lowValue <= xHigh) { + return low; + } + double highValue = dataset.getXValue(series, high); + if (highValue > xHigh) { + return high; + } + while (high - low > 1) { + int mid = (low + high) / 2; + double midV = dataset.getXValue(series, mid); + if (midV > xHigh) { + low = mid; + } + else { + high = mid; + } + } + return high; + } + else { + // we don't know anything about the ordering of the x-values, + // but we can still skip any initial values that fall outside the + // range... + int index = 0; + // skip any items that don't need including... + double x = dataset.getXValue(series, index); + while (index < itemCount && x < xLow) { + index++; + if (index < itemCount) { + x = dataset.getXValue(series, index); + } + } + return Math.min(Math.max(0, index), itemCount - 1); + } + } + + /** + * Finds the upper index of the range of live items in the specified data + * series. + * + * @param dataset the dataset (null not permitted). + * @param series the series index. + * @param xLow the lowest x-value in the live range. + * @param xHigh the highest x-value in the live range. + * + * @return The index of the required item. + * + * @since 1.0.6 + * + * @see #findLiveItemsLowerBound(XYDataset, int, double, double) + */ + public static int findLiveItemsUpperBound(XYDataset dataset, int series, + double xLow, double xHigh) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + if (xLow >= xHigh) { + throw new IllegalArgumentException("Requires xLow < xHigh."); + } + int itemCount = dataset.getItemCount(series); + if (itemCount <= 1) { + return 0; + } + if (dataset.getDomainOrder() == DomainOrder.ASCENDING) { + int low = 0; + int high = itemCount - 1; + double lowValue = dataset.getXValue(series, low); + if (lowValue > xHigh) { + return low; + } + double highValue = dataset.getXValue(series, high); + if (highValue <= xHigh) { + return high; + } + int mid = (low + high) / 2; + while (high - low > 1) { + double midV = dataset.getXValue(series, mid); + if (midV <= xHigh) { + low = mid; + } + else { + high = mid; + } + mid = (low + high) / 2; + } + return mid; + } + else if (dataset.getDomainOrder() == DomainOrder.DESCENDING) { + // when the x-values are descending, the upper bound is found by + // comparing against xLow + int low = 0; + int high = itemCount - 1; + int mid = (low + high) / 2; + double lowValue = dataset.getXValue(series, low); + if (lowValue < xLow) { + return low; + } + double highValue = dataset.getXValue(series, high); + if (highValue >= xLow) { + return high; + } + while (high - low > 1) { + double midV = dataset.getXValue(series, mid); + if (midV >= xLow) { + low = mid; + } + else { + high = mid; + } + mid = (low + high) / 2; + } + return mid; + } + else { + // we don't know anything about the ordering of the x-values, + // but we can still skip any trailing values that fall outside the + // range... + int index = itemCount - 1; + // skip any items that don't need including... + double x = dataset.getXValue(series, index); + while (index >= 0 && x > xHigh) { + index--; + if (index >= 0) { + x = dataset.getXValue(series, index); + } + } + return Math.max(index, 0); + } + } + + /** + * Finds a range of item indices that is guaranteed to contain all the + * x-values from x0 to x1 (inclusive). + * + * @param dataset the dataset (null not permitted). + * @param series the series index. + * @param xLow the lower bound of the x-value range. + * @param xHigh the upper bound of the x-value range. + * + * @return The indices of the boundary items. + */ + public static int[] findLiveItems(XYDataset dataset, int series, + double xLow, double xHigh) { + // here we could probably be a little faster by searching for both + // indices simultaneously, but I'll look at that later if it seems + // like it matters... + int i0 = findLiveItemsLowerBound(dataset, series, xLow, xHigh); + int i1 = findLiveItemsUpperBound(dataset, series, xLow, xHigh); + if (i0 > i1) { + i0 = i1; + } + return new int[] {i0, i1}; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/WaferMapRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/WaferMapRenderer.java new file mode 100755 index 0000000..3c73822 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/WaferMapRenderer.java @@ -0,0 +1,386 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * WaferMapRenderer.java + * --------------------- + * (C) Copyright 2003-2008, by Robert Redburn and Contributors. + * + * Original Author: Robert Redburn; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 25-Nov-2003 : Version 1, contributed by Robert Redburn. Changes have been + * made to fit the JFreeChart coding style (DG); + * 20-Apr-2005 : Small update for changes to LegendItem class (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.renderer; + +import java.awt.Color; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Rectangle2D; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.plot.DrawingSupplier; +import org.jfree.chart.plot.WaferMapPlot; +import org.jfree.data.general.WaferMapDataset; + +/** + * A renderer for wafer map plots. Provides color managment facilities. + */ +public class WaferMapRenderer extends AbstractRenderer { + + /** paint index */ + private Map paintIndex; + + /** plot */ + private WaferMapPlot plot; + + /** paint limit */ + private int paintLimit; + + /** default paint limit */ + private static final int DEFAULT_PAINT_LIMIT = 35; + + /** default multivalue paint calculation */ + public static final int POSITION_INDEX = 0; + + /** The default value index. */ + public static final int VALUE_INDEX = 1; + + /** paint index method */ + private int paintIndexMethod; + + /** + * Creates a new renderer. + */ + public WaferMapRenderer() { + this(null, null); + } + + /** + * Creates a new renderer. + * + * @param paintLimit the paint limit. + * @param paintIndexMethod the paint index method. + */ + public WaferMapRenderer(int paintLimit, int paintIndexMethod) { + this(new Integer(paintLimit), new Integer(paintIndexMethod)); + } + + /** + * Creates a new renderer. + * + * @param paintLimit the paint limit. + * @param paintIndexMethod the paint index method. + */ + public WaferMapRenderer(Integer paintLimit, Integer paintIndexMethod) { + + super(); + this.paintIndex = new HashMap(); + + if (paintLimit == null) { + this.paintLimit = DEFAULT_PAINT_LIMIT; + } + else { + this.paintLimit = paintLimit.intValue(); + } + + this.paintIndexMethod = VALUE_INDEX; + if (paintIndexMethod != null) { + if (isMethodValid(paintIndexMethod.intValue())) { + this.paintIndexMethod = paintIndexMethod.intValue(); + } + } + } + + /** + * Verifies that the passed paint index method is valid. + * + * @param method the method. + * + * @return true or false. + */ + private boolean isMethodValid(int method) { + switch (method) { + case POSITION_INDEX: return true; + case VALUE_INDEX: return true; + default: return false; + } + } + + /** + * Returns the drawing supplier from the plot. + * + * @return The drawing supplier. + */ + @Override + public DrawingSupplier getDrawingSupplier() { + DrawingSupplier result = null; + WaferMapPlot p = getPlot(); + if (p != null) { + result = p.getDrawingSupplier(); + } + return result; + } + + /** + * Returns the plot. + * + * @return The plot. + */ + public WaferMapPlot getPlot() { + return this.plot; + } + + /** + * Sets the plot and build the paint index. + * + * @param plot the plot. + */ + public void setPlot(WaferMapPlot plot) { + this.plot = plot; + makePaintIndex(); + } + + /** + * Returns the paint for a given chip value. + * + * @param value the value. + * + * @return The paint. + */ + public Paint getChipColor(Number value) { + return getSeriesPaint(getPaintIndex(value)); + } + + /** + * Returns the paint index for a given chip value. + * + * @param value the value. + * + * @return The paint index. + */ + private int getPaintIndex(Number value) { + return ((Integer) this.paintIndex.get(value)).intValue(); + } + + /** + * Builds a map of chip values to paint colors. + * paintlimit is the maximum allowed number of colors. + */ + private void makePaintIndex() { + if (this.plot == null) { + return; + } + WaferMapDataset data = this.plot.getDataset(); + Number dataMin = data.getMinValue(); + Number dataMax = data.getMaxValue(); + Set uniqueValues = data.getUniqueValues(); + if (uniqueValues.size() <= this.paintLimit) { + int count = 0; // assign a color for each unique value + for (Iterator i = uniqueValues.iterator(); i.hasNext();) { + this.paintIndex.put(i.next(), new Integer(count++)); + } + } + else { + // more values than paints so map + // multiple values to the same color + switch (this.paintIndexMethod) { + case POSITION_INDEX: + makePositionIndex(uniqueValues); + break; + case VALUE_INDEX: + makeValueIndex(dataMax, dataMin, uniqueValues); + break; + default: + break; + } + } + } + + /** + * Builds the paintindex by assigning colors based on the number + * of unique values: totalvalues/totalcolors. + * + * @param uniqueValues the set of unique values. + */ + private void makePositionIndex(Set uniqueValues) { + int valuesPerColor = (int) Math.ceil( + (double) uniqueValues.size() / this.paintLimit + ); + int count = 0; // assign a color for each unique value + int paint = 0; + for (Iterator i = uniqueValues.iterator(); i.hasNext();) { + this.paintIndex.put(i.next(), new Integer(paint)); + if (++count % valuesPerColor == 0) { + paint++; + } + if (paint > this.paintLimit) { + paint = this.paintLimit; + } + } + } + + /** + * Builds the paintindex by assigning colors evenly across the range + * of values: maxValue-minValue/totalcolors + * + * @param max the maximum value. + * @param min the minumum value. + * @param uniqueValues the unique values. + */ + private void makeValueIndex(Number max, Number min, Set uniqueValues) { + double valueRange = max.doubleValue() - min.doubleValue(); + double valueStep = valueRange / this.paintLimit; + int paint = 0; + double cutPoint = min.doubleValue() + valueStep; + for (Iterator i = uniqueValues.iterator(); i.hasNext();) { + Number value = (Number) i.next(); + while (value.doubleValue() > cutPoint) { + cutPoint += valueStep; + paint++; + if (paint > this.paintLimit) { + paint = this.paintLimit; + } + } + this.paintIndex.put(value, new Integer(paint)); + } + } + + /** + * Builds the list of legend entries. called by getLegendItems in + * WaferMapPlot to populate the plot legend. + * + * @return The legend items. + */ + public LegendItemCollection getLegendCollection() { + LegendItemCollection result = new LegendItemCollection(); + if (this.paintIndex != null && this.paintIndex.size() > 0) { + if (this.paintIndex.size() <= this.paintLimit) { + for (Iterator i = this.paintIndex.entrySet().iterator(); + i.hasNext();) { + // in this case, every color has a unique value + Map.Entry entry = (Map.Entry) i.next(); + String label = entry.getKey().toString(); + String description = label; + Shape shape = new Rectangle2D.Double(1d, 1d, 1d, 1d); + Paint paint = lookupSeriesPaint( + ((Integer) entry.getValue()).intValue()); + Paint outlinePaint = Color.black; + Stroke outlineStroke = DEFAULT_STROKE; + + result.add(new LegendItem(label, description, null, + null, shape, paint, outlineStroke, outlinePaint)); + + } + } + else { + // in this case, every color has a range of values + Set unique = new HashSet(); + for (Iterator i = this.paintIndex.entrySet().iterator(); + i.hasNext();) { + Map.Entry entry = (Map.Entry) i.next(); + if (unique.add(entry.getValue())) { + String label = getMinPaintValue( + (Integer) entry.getValue()).toString() + + " - " + getMaxPaintValue( + (Integer) entry.getValue()).toString(); + String description = label; + Shape shape = new Rectangle2D.Double(1d, 1d, 1d, 1d); + Paint paint = getSeriesPaint( + ((Integer) entry.getValue()).intValue() + ); + Paint outlinePaint = Color.black; + Stroke outlineStroke = DEFAULT_STROKE; + + result.add(new LegendItem(label, description, + null, null, shape, paint, outlineStroke, + outlinePaint)); + } + } // end foreach map entry + } // end else + } + return result; + } + + /** + * Returns the minimum chip value assigned to a color + * in the paintIndex + * + * @param index the index. + * + * @return The value. + */ + private Number getMinPaintValue(Integer index) { + double minValue = Double.POSITIVE_INFINITY; + for (Iterator i = this.paintIndex.entrySet().iterator(); i.hasNext();) { + Map.Entry entry = (Map.Entry) i.next(); + if (((Integer) entry.getValue()).equals(index)) { + if (((Number) entry.getKey()).doubleValue() < minValue) { + minValue = ((Number) entry.getKey()).doubleValue(); + } + } + } + return new Double(minValue); + } + + /** + * Returns the maximum chip value assigned to a color + * in the paintIndex + * + * @param index the index. + * + * @return The value + */ + private Number getMaxPaintValue(Integer index) { + double maxValue = Double.NEGATIVE_INFINITY; + for (Iterator i = this.paintIndex.entrySet().iterator(); i.hasNext();) { + Map.Entry entry = (Map.Entry) i.next(); + if (((Integer) entry.getValue()).equals(index)) { + if (((Number) entry.getKey()).doubleValue() > maxValue) { + maxValue = ((Number) entry.getKey()).doubleValue(); + } + } + } + return new Double(maxValue); + } + + +} // end class wafermaprenderer diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java new file mode 100755 index 0000000..27ef468 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/AbstractCategoryItemRenderer.java @@ -0,0 +1,1848 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * AbstractCategoryItemRenderer.java + * --------------------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Richard Atkinson; + * Peter Kolb (patch 2497611); + * + * Changes: + * -------- + * 29-May-2002 : Version 1 (DG); + * 06-Jun-2002 : Added accessor methods for the tool tip generator (DG); + * 11-Jun-2002 : Made constructors protected (DG); + * 26-Jun-2002 : Added axis to initialise method (DG); + * 05-Aug-2002 : Added urlGenerator member variable plus accessors (RA); + * 22-Aug-2002 : Added categoriesPaint attribute, based on code submitted by + * Janet Banks. This can be used when there is only one series, + * and you want each category item to have a different color (DG); + * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 29-Oct-2002 : Fixed bug where background image for plot was not being + * drawn (DG); + * 05-Nov-2002 : Replaced references to CategoryDataset with TableDataset (DG); + * 26-Nov 2002 : Replaced the isStacked() method with getRangeType() (DG); + * 09-Jan-2003 : Renamed grid-line methods (DG); + * 17-Jan-2003 : Moved plot classes into separate package (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 12-May-2003 : Modified to take into account the plot orientation (DG); + * 12-Aug-2003 : Very minor javadoc corrections (DB) + * 13-Aug-2003 : Implemented Cloneable (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 05-Nov-2003 : Fixed marker rendering bug (833623) (DG); + * 21-Jan-2004 : Update for renamed method in ValueAxis (DG); + * 11-Feb-2004 : Modified labelling for markers (DG); + * 12-Feb-2004 : Updated clone() method (DG); + * 15-Apr-2004 : Created a new CategoryToolTipGenerator interface (DG); + * 05-May-2004 : Fixed bug (948310) where interval markers extend outside axis + * range (DG); + * 14-Jun-2004 : Fixed bug in drawRangeMarker() method - now uses 'paint' and + * 'stroke' rather than 'outlinePaint' and 'outlineStroke' (DG); + * 15-Jun-2004 : Interval markers can now use GradientPaint (DG); + * 30-Sep-2004 : Moved drawRotatedString() from RefineryUtilities + * --> TextUtilities (DG); + * 01-Oct-2004 : Fixed bug 1029697, problem with label alignment in + * drawRangeMarker() method (DG); + * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds() (DG); + * 21-Jan-2005 : Modified return type of calculateRangeMarkerTextAnchorPoint() + * method (DG); + * 08-Mar-2005 : Fixed positioning of marker labels (DG); + * 20-Apr-2005 : Added legend label, tooltip and URL generators (DG); + * 01-Jun-2005 : Handle one dimension of the marker label adjustment + * automatically (DG); + * 09-Jun-2005 : Added utility method for adding an item entity (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 01-Mar-2006 : Updated getLegendItems() to check seriesVisibleInLegend + * flags (DG); + * 20-Jul-2006 : Set dataset and series indices in LegendItem (DG); + * 23-Oct-2006 : Draw outlines for interval markers (DG); + * 24-Oct-2006 : Respect alpha setting in markers, as suggested by Sergei + * Ivanov in patch 1567843 (DG); + * 30-Nov-2006 : Added a check for series visibility in the getLegendItem() + * method (DG); + * 07-Dec-2006 : Fix for equals() method (DG); + * 22-Feb-2007 : Added createState() method (DG); + * 01-Mar-2007 : Fixed interval marker drawing (patch 1670686 thanks to + * Sergei Ivanov) (DG); + * 20-Apr-2007 : Updated getLegendItem() for renderer change, and deprecated + * itemLabelGenerator, toolTipGenerator and itemURLGenerator + * override fields (DG); + * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); + * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * 26-Jun-2008 : Added crosshair support (DG); + * 25-Nov-2008 : Fixed bug in findRangeBounds() method (DG); + * 14-Jan-2009 : Update initialise() to store visible series indices (PK); + * 21-Jan-2009 : Added drawRangeLine() method (DG); + * 27-Mar-2009 : Added new findRangeBounds() method to account for hidden + * series (DG); + * 01-Apr-2009 : Added new addEntity() method (DG); + * 09-Feb-2010 : Fixed bug 2947660 (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.AlphaComposite; +import java.awt.Composite; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import java.util.ArrayList; +import java.util.List; +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.CategoryItemEntity; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.CategoryItemLabelGenerator; +import org.jfree.chart.labels.CategorySeriesLabelGenerator; +import org.jfree.chart.labels.CategoryToolTipGenerator; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.labels.StandardCategorySeriesLabelGenerator; +import org.jfree.chart.plot.CategoryCrosshairState; +import org.jfree.chart.plot.CategoryMarker; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.DrawingSupplier; +import org.jfree.chart.plot.IntervalMarker; +import org.jfree.chart.plot.Marker; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.ValueMarker; +import org.jfree.chart.renderer.AbstractRenderer; +import org.jfree.chart.urls.CategoryURLGenerator; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.LengthAdjustmentType; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectList; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.SortOrder; + +/** + * An abstract base class that you can use to implement a new + * {@link CategoryItemRenderer}. When you create a new + * {@link CategoryItemRenderer} you are not required to extend this class, + * but it makes the job easier. + */ +public abstract class AbstractCategoryItemRenderer extends AbstractRenderer + implements CategoryItemRenderer, Cloneable, PublicCloneable, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 1247553218442497391L; + + /** The plot that the renderer is assigned to. */ + private CategoryPlot plot; + + /** A list of item label generators (one per series). */ + private ObjectList itemLabelGeneratorList; + + /** The base item label generator. */ + private CategoryItemLabelGenerator baseItemLabelGenerator; + + /** A list of tool tip generators (one per series). */ + private ObjectList toolTipGeneratorList; + + /** The base tool tip generator. */ + private CategoryToolTipGenerator baseToolTipGenerator; + + /** A list of item label generators (one per series). */ + private ObjectList itemURLGeneratorList; + + /** The base item label generator. */ + private CategoryURLGenerator baseItemURLGenerator; + + /** The legend item label generator. */ + private CategorySeriesLabelGenerator legendItemLabelGenerator; + + /** The legend item tool tip generator. */ + private CategorySeriesLabelGenerator legendItemToolTipGenerator; + + /** The legend item URL generator. */ + private CategorySeriesLabelGenerator legendItemURLGenerator; + + /** The number of rows in the dataset (temporary record). */ + private transient int rowCount; + + /** The number of columns in the dataset (temporary record). */ + private transient int columnCount; + + /** + * Creates a new renderer with no tool tip generator and no URL generator. + * The defaults (no tool tip or URL generators) have been chosen to + * minimise the processing required to generate a default chart. If you + * require tool tips or URLs, then you can easily add the required + * generators. + */ + protected AbstractCategoryItemRenderer() { + this.itemLabelGenerator = null; + this.itemLabelGeneratorList = new ObjectList(); + this.toolTipGenerator = null; + this.toolTipGeneratorList = new ObjectList(); + this.itemURLGenerator = null; + this.itemURLGeneratorList = new ObjectList(); + this.legendItemLabelGenerator + = new StandardCategorySeriesLabelGenerator(); + } + + /** + * Returns the number of passes through the dataset required by the + * renderer. This method returns 1, subclasses should + * override if they need more passes. + * + * @return The pass count. + */ + @Override + public int getPassCount() { + return 1; + } + + /** + * Returns the plot that the renderer has been assigned to (where + * null indicates that the renderer is not currently assigned + * to a plot). + * + * @return The plot (possibly null). + * + * @see #setPlot(CategoryPlot) + */ + @Override + public CategoryPlot getPlot() { + return this.plot; + } + + /** + * Sets the plot that the renderer has been assigned to. This method is + * usually called by the {@link CategoryPlot}, in normal usage you + * shouldn't need to call this method directly. + * + * @param plot the plot (null not permitted). + * + * @see #getPlot() + */ + @Override + public void setPlot(CategoryPlot plot) { + ParamChecks.nullNotPermitted(plot, "plot"); + this.plot = plot; + } + + // ITEM LABEL GENERATOR + + /** + * Returns the item label generator for a data item. This implementation + * simply passes control to the {@link #getSeriesItemLabelGenerator(int)} + * method. If, for some reason, you want a different generator for + * individual items, you can override this method. + * + * @param row the row index (zero based). + * @param column the column index (zero based). + * + * @return The generator (possibly null). + */ + @Override + public CategoryItemLabelGenerator getItemLabelGenerator(int row, + int column) { + return getSeriesItemLabelGenerator(row); + } + + /** + * Returns the item label generator for a series. + * + * @param series the series index (zero based). + * + * @return The generator (possibly null). + * + * @see #setSeriesItemLabelGenerator(int, CategoryItemLabelGenerator) + */ + @Override + public CategoryItemLabelGenerator getSeriesItemLabelGenerator(int series) { + + // return the generator for ALL series, if there is one... + if (this.itemLabelGenerator != null) { + return this.itemLabelGenerator; + } + + // otherwise look up the generator table + CategoryItemLabelGenerator generator = (CategoryItemLabelGenerator) + this.itemLabelGeneratorList.get(series); + if (generator == null) { + generator = this.baseItemLabelGenerator; + } + return generator; + + } + + /** + * Sets the item label generator for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero based). + * @param generator the generator (null permitted). + * + * @see #getSeriesItemLabelGenerator(int) + */ + @Override + public void setSeriesItemLabelGenerator(int series, + CategoryItemLabelGenerator generator) { + this.itemLabelGeneratorList.set(series, generator); + fireChangeEvent(); + } + + /** + * Returns the base item label generator. + * + * @return The generator (possibly null). + * + * @see #setBaseItemLabelGenerator(CategoryItemLabelGenerator) + */ + @Override + public CategoryItemLabelGenerator getBaseItemLabelGenerator() { + return this.baseItemLabelGenerator; + } + + /** + * Sets the base item label generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getBaseItemLabelGenerator() + */ + @Override + public void setBaseItemLabelGenerator( + CategoryItemLabelGenerator generator) { + this.baseItemLabelGenerator = generator; + fireChangeEvent(); + } + + // TOOL TIP GENERATOR + + /** + * Returns the tool tip generator that should be used for the specified + * item. This method looks up the generator using the "three-layer" + * approach outlined in the general description of this interface. You + * can override this method if you want to return a different generator per + * item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The generator (possibly null). + */ + @Override + public CategoryToolTipGenerator getToolTipGenerator(int row, int column) { + + CategoryToolTipGenerator result; + if (this.toolTipGenerator != null) { + result = this.toolTipGenerator; + } + else { + result = getSeriesToolTipGenerator(row); + if (result == null) { + result = this.baseToolTipGenerator; + } + } + return result; + } + + /** + * Returns the tool tip generator for the specified series (a "layer 1" + * generator). + * + * @param series the series index (zero-based). + * + * @return The tool tip generator (possibly null). + * + * @see #setSeriesToolTipGenerator(int, CategoryToolTipGenerator) + */ + @Override + public CategoryToolTipGenerator getSeriesToolTipGenerator(int series) { + return (CategoryToolTipGenerator) this.toolTipGeneratorList.get(series); + } + + /** + * Sets the tool tip generator for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param generator the generator (null permitted). + * + * @see #getSeriesToolTipGenerator(int) + */ + @Override + public void setSeriesToolTipGenerator(int series, + CategoryToolTipGenerator generator) { + this.toolTipGeneratorList.set(series, generator); + fireChangeEvent(); + } + + /** + * Returns the base tool tip generator (the "layer 2" generator). + * + * @return The tool tip generator (possibly null). + * + * @see #setBaseToolTipGenerator(CategoryToolTipGenerator) + */ + @Override + public CategoryToolTipGenerator getBaseToolTipGenerator() { + return this.baseToolTipGenerator; + } + + /** + * Sets the base tool tip generator and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getBaseToolTipGenerator() + */ + @Override + public void setBaseToolTipGenerator(CategoryToolTipGenerator generator) { + this.baseToolTipGenerator = generator; + fireChangeEvent(); + } + + // URL GENERATOR + + /** + * Returns the URL generator for a data item. This method just calls the + * getSeriesItemURLGenerator method, but you can override this behaviour if + * you want to. + * + * @param row the row index (zero based). + * @param column the column index (zero based). + * + * @return The URL generator. + */ + @Override + public CategoryURLGenerator getItemURLGenerator(int row, int column) { + return getSeriesItemURLGenerator(row); + } + + /** + * Returns the URL generator for a series. + * + * @param series the series index (zero based). + * + * @return The URL generator for the series. + * + * @see #setSeriesItemURLGenerator(int, CategoryURLGenerator) + */ + @Override + public CategoryURLGenerator getSeriesItemURLGenerator(int series) { + + // return the generator for ALL series, if there is one... + if (this.itemURLGenerator != null) { + return this.itemURLGenerator; + } + + // otherwise look up the generator table + CategoryURLGenerator generator + = (CategoryURLGenerator) this.itemURLGeneratorList.get(series); + if (generator == null) { + generator = this.baseItemURLGenerator; + } + return generator; + + } + + /** + * Sets the URL generator for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero based). + * @param generator the generator. + * + * @see #getSeriesItemURLGenerator(int) + */ + @Override + public void setSeriesItemURLGenerator(int series, + CategoryURLGenerator generator) { + this.itemURLGeneratorList.set(series, generator); + fireChangeEvent(); + } + + /** + * Returns the base item URL generator. + * + * @return The item URL generator. + * + * @see #setBaseItemURLGenerator(CategoryURLGenerator) + */ + @Override + public CategoryURLGenerator getBaseItemURLGenerator() { + return this.baseItemURLGenerator; + } + + /** + * Sets the base item URL generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the item URL generator (null permitted). + * + * @see #getBaseItemURLGenerator() + */ + @Override + public void setBaseItemURLGenerator(CategoryURLGenerator generator) { + this.baseItemURLGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the number of rows in the dataset. This value is updated in the + * {@link AbstractCategoryItemRenderer#initialise} method. + * + * @return The row count. + */ + public int getRowCount() { + return this.rowCount; + } + + /** + * Returns the number of columns in the dataset. This value is updated in + * the {@link AbstractCategoryItemRenderer#initialise} method. + * + * @return The column count. + */ + public int getColumnCount() { + return this.columnCount; + } + + /** + * Creates a new state instance---this method is called from the + * {@link #initialise(Graphics2D, Rectangle2D, CategoryPlot, int, + * PlotRenderingInfo)} method. Subclasses can override this method if + * they need to use a subclass of {@link CategoryItemRendererState}. + * + * @param info collects plot rendering info (null permitted). + * + * @return The new state instance (never null). + * + * @since 1.0.5 + */ + protected CategoryItemRendererState createState(PlotRenderingInfo info) { + return new CategoryItemRendererState(info); + } + + /** + * Initialises the renderer and returns a state object that will be used + * for the remainder of the drawing process for a single chart. The state + * object allows for the fact that the renderer may be used simultaneously + * by multiple threads (each thread will work with a separate state object). + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param plot the plot. + * @param rendererIndex the renderer index. + * @param info an object for returning information about the structure of + * the plot (null permitted). + * + * @return The renderer state. + */ + @Override + public CategoryItemRendererState initialise(Graphics2D g2, + Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, + PlotRenderingInfo info) { + + setPlot(plot); + CategoryDataset data = plot.getDataset(rendererIndex); + if (data != null) { + this.rowCount = data.getRowCount(); + this.columnCount = data.getColumnCount(); + } + else { + this.rowCount = 0; + this.columnCount = 0; + } + CategoryItemRendererState state = createState(info); + int[] visibleSeriesTemp = new int[this.rowCount]; + int visibleSeriesCount = 0; + for (int row = 0; row < this.rowCount; row++) { + if (isSeriesVisible(row)) { + visibleSeriesTemp[visibleSeriesCount] = row; + visibleSeriesCount++; + } + } + int[] visibleSeries = new int[visibleSeriesCount]; + System.arraycopy(visibleSeriesTemp, 0, visibleSeries, 0, + visibleSeriesCount); + state.setVisibleSeriesArray(visibleSeries); + return state; + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (or null if the dataset is + * null or empty). + */ + @Override + public Range findRangeBounds(CategoryDataset dataset) { + return findRangeBounds(dataset, false); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * @param includeInterval include the y-interval if the dataset has one. + * + * @return The range (null if the dataset is null + * or empty). + * + * @since 1.0.13 + */ + protected Range findRangeBounds(CategoryDataset dataset, + boolean includeInterval) { + if (dataset == null) { + return null; + } + if (getDataBoundsIncludesVisibleSeriesOnly()) { + List visibleSeriesKeys = new ArrayList(); + int seriesCount = dataset.getRowCount(); + for (int s = 0; s < seriesCount; s++) { + if (isSeriesVisible(s)) { + visibleSeriesKeys.add(dataset.getRowKey(s)); + } + } + return DatasetUtilities.findRangeBounds(dataset, + visibleSeriesKeys, includeInterval); + } + else { + return DatasetUtilities.findRangeBounds(dataset, includeInterval); + } + } + + /** + * Returns the Java2D coordinate for the middle of the specified data item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param dataset the dataset. + * @param axis the axis. + * @param area the data area. + * @param edge the edge along which the axis lies. + * + * @return The Java2D coordinate for the middle of the item. + * + * @since 1.0.11 + */ + @Override + public double getItemMiddle(Comparable rowKey, Comparable columnKey, + CategoryDataset dataset, CategoryAxis axis, Rectangle2D area, + RectangleEdge edge) { + return axis.getCategoryMiddle(columnKey, dataset.getColumnKeys(), area, + edge); + } + + /** + * Draws a background for the data area. The default implementation just + * gets the plot to draw the background, but some renderers will override + * this behaviour. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param dataArea the data area. + */ + @Override + public void drawBackground(Graphics2D g2, CategoryPlot plot, + Rectangle2D dataArea) { + plot.drawBackground(g2, dataArea); + } + + /** + * Draws an outline for the data area. The default implementation just + * gets the plot to draw the outline, but some renderers will override this + * behaviour. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param dataArea the data area. + */ + @Override + public void drawOutline(Graphics2D g2, CategoryPlot plot, + Rectangle2D dataArea) { + plot.drawOutline(g2, dataArea); + } + + /** + * Draws a grid line against the domain axis. + *

+ * Note that this default implementation assumes that the horizontal axis + * is the domain axis. If this is not the case, you will need to override + * this method. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param dataArea the area for plotting data (not yet adjusted for any + * 3D effect). + * @param value the Java2D value at which the grid line should be drawn. + * + * @see #drawRangeGridline(Graphics2D, CategoryPlot, ValueAxis, + * Rectangle2D, double) + */ + @Override + public void drawDomainGridline(Graphics2D g2, CategoryPlot plot, + Rectangle2D dataArea, double value) { + + Line2D line = null; + PlotOrientation orientation = plot.getOrientation(); + + if (orientation == PlotOrientation.HORIZONTAL) { + line = new Line2D.Double(dataArea.getMinX(), value, + dataArea.getMaxX(), value); + } + else if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(value, dataArea.getMinY(), value, + dataArea.getMaxY()); + } + + Paint paint = plot.getDomainGridlinePaint(); + if (paint == null) { + paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT; + } + g2.setPaint(paint); + + Stroke stroke = plot.getDomainGridlineStroke(); + if (stroke == null) { + stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE; + } + g2.setStroke(stroke); + + g2.draw(line); + } + + /** + * Draws a grid line against the range axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param dataArea the area for plotting data (not yet adjusted for any + * 3D effect). + * @param value the value at which the grid line should be drawn. + * + * @see #drawDomainGridline(Graphics2D, CategoryPlot, Rectangle2D, double) + */ + @Override + public void drawRangeGridline(Graphics2D g2, CategoryPlot plot, + ValueAxis axis, Rectangle2D dataArea, double value) { + + Range range = axis.getRange(); + if (!range.contains(value)) { + return; + } + + PlotOrientation orientation = plot.getOrientation(); + double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); + Line2D line = null; + if (orientation == PlotOrientation.HORIZONTAL) { + line = new Line2D.Double(v, dataArea.getMinY(), v, + dataArea.getMaxY()); + } + else if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(dataArea.getMinX(), v, + dataArea.getMaxX(), v); + } + + Paint paint = plot.getRangeGridlinePaint(); + if (paint == null) { + paint = CategoryPlot.DEFAULT_GRIDLINE_PAINT; + } + g2.setPaint(paint); + + Stroke stroke = plot.getRangeGridlineStroke(); + if (stroke == null) { + stroke = CategoryPlot.DEFAULT_GRIDLINE_STROKE; + } + g2.setStroke(stroke); + + g2.draw(line); + + } + + /** + * Draws a line perpendicular to the range axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param dataArea the area for plotting data (not yet adjusted for any 3D + * effect). + * @param value the value at which the grid line should be drawn. + * @param paint the paint (null not permitted). + * @param stroke the stroke (null not permitted). + * + * @see #drawRangeGridline + * + * @since 1.0.13 + */ + public void drawRangeLine(Graphics2D g2, CategoryPlot plot, ValueAxis axis, + Rectangle2D dataArea, double value, Paint paint, Stroke stroke) { + + // TODO: In JFreeChart 1.2.0, put this method in the + // CategoryItemRenderer interface + Range range = axis.getRange(); + if (!range.contains(value)) { + return; + } + + PlotOrientation orientation = plot.getOrientation(); + Line2D line = null; + double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); + if (orientation == PlotOrientation.HORIZONTAL) { + line = new Line2D.Double(v, dataArea.getMinY(), v, + dataArea.getMaxY()); + } + else if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(dataArea.getMinX(), v, + dataArea.getMaxX(), v); + } + + g2.setPaint(paint); + g2.setStroke(stroke); + g2.draw(line); + + } + + /** + * Draws a marker for the domain axis. + * + * @param g2 the graphics device (not null). + * @param plot the plot (not null). + * @param axis the range axis (not null). + * @param marker the marker to be drawn (not null). + * @param dataArea the area inside the axes (not null). + * + * @see #drawRangeMarker(Graphics2D, CategoryPlot, ValueAxis, Marker, + * Rectangle2D) + */ + @Override + public void drawDomainMarker(Graphics2D g2, CategoryPlot plot, + CategoryAxis axis, CategoryMarker marker, Rectangle2D dataArea) { + + Comparable category = marker.getKey(); + CategoryDataset dataset = plot.getDataset(plot.getIndexOf(this)); + int columnIndex = dataset.getColumnIndex(category); + if (columnIndex < 0) { + return; + } + + final Composite savedComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance( + AlphaComposite.SRC_OVER, marker.getAlpha())); + + PlotOrientation orientation = plot.getOrientation(); + Rectangle2D bounds; + if (marker.getDrawAsLine()) { + double v = axis.getCategoryMiddle(columnIndex, + dataset.getColumnCount(), dataArea, + plot.getDomainAxisEdge()); + Line2D line = null; + if (orientation == PlotOrientation.HORIZONTAL) { + line = new Line2D.Double(dataArea.getMinX(), v, + dataArea.getMaxX(), v); + } + else if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(v, dataArea.getMinY(), v, + dataArea.getMaxY()); + } else { + throw new IllegalStateException(); + } + g2.setPaint(marker.getPaint()); + g2.setStroke(marker.getStroke()); + g2.draw(line); + bounds = line.getBounds2D(); + } + else { + double v0 = axis.getCategoryStart(columnIndex, + dataset.getColumnCount(), dataArea, + plot.getDomainAxisEdge()); + double v1 = axis.getCategoryEnd(columnIndex, + dataset.getColumnCount(), dataArea, + plot.getDomainAxisEdge()); + Rectangle2D area = null; + if (orientation == PlotOrientation.HORIZONTAL) { + area = new Rectangle2D.Double(dataArea.getMinX(), v0, + dataArea.getWidth(), (v1 - v0)); + } + else if (orientation == PlotOrientation.VERTICAL) { + area = new Rectangle2D.Double(v0, dataArea.getMinY(), + (v1 - v0), dataArea.getHeight()); + } + g2.setPaint(marker.getPaint()); + g2.fill(area); + bounds = area; + } + + String label = marker.getLabel(); + RectangleAnchor anchor = marker.getLabelAnchor(); + if (label != null) { + Font labelFont = marker.getLabelFont(); + g2.setFont(labelFont); + g2.setPaint(marker.getLabelPaint()); + Point2D coordinates = calculateDomainMarkerTextAnchorPoint( + g2, orientation, dataArea, bounds, marker.getLabelOffset(), + marker.getLabelOffsetType(), anchor); + TextUtilities.drawAlignedString(label, g2, + (float) coordinates.getX(), (float) coordinates.getY(), + marker.getLabelTextAnchor()); + } + g2.setComposite(savedComposite); + } + + /** + * Draws a marker for the range axis. + * + * @param g2 the graphics device (not null). + * @param plot the plot (not null). + * @param axis the range axis (not null). + * @param marker the marker to be drawn (not null). + * @param dataArea the area inside the axes (not null). + * + * @see #drawDomainMarker(Graphics2D, CategoryPlot, CategoryAxis, + * CategoryMarker, Rectangle2D) + */ + @Override + public void drawRangeMarker(Graphics2D g2, CategoryPlot plot, + ValueAxis axis, Marker marker, Rectangle2D dataArea) { + + if (marker instanceof ValueMarker) { + ValueMarker vm = (ValueMarker) marker; + double value = vm.getValue(); + Range range = axis.getRange(); + + if (!range.contains(value)) { + return; + } + + final Composite savedComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance( + AlphaComposite.SRC_OVER, marker.getAlpha())); + + PlotOrientation orientation = plot.getOrientation(); + double v = axis.valueToJava2D(value, dataArea, + plot.getRangeAxisEdge()); + Line2D line = null; + if (orientation == PlotOrientation.HORIZONTAL) { + line = new Line2D.Double(v, dataArea.getMinY(), v, + dataArea.getMaxY()); + } + else if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(dataArea.getMinX(), v, + dataArea.getMaxX(), v); + } else { + throw new IllegalStateException(); + } + + g2.setPaint(marker.getPaint()); + g2.setStroke(marker.getStroke()); + g2.draw(line); + + String label = marker.getLabel(); + RectangleAnchor anchor = marker.getLabelAnchor(); + if (label != null) { + Font labelFont = marker.getLabelFont(); + g2.setFont(labelFont); + g2.setPaint(marker.getLabelPaint()); + Point2D coordinates = calculateRangeMarkerTextAnchorPoint( + g2, orientation, dataArea, line.getBounds2D(), + marker.getLabelOffset(), LengthAdjustmentType.EXPAND, + anchor); + TextUtilities.drawAlignedString(label, g2, + (float) coordinates.getX(), (float) coordinates.getY(), + marker.getLabelTextAnchor()); + } + g2.setComposite(savedComposite); + } + else if (marker instanceof IntervalMarker) { + IntervalMarker im = (IntervalMarker) marker; + double start = im.getStartValue(); + double end = im.getEndValue(); + Range range = axis.getRange(); + if (!(range.intersects(start, end))) { + return; + } + + final Composite savedComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance( + AlphaComposite.SRC_OVER, marker.getAlpha())); + + double start2d = axis.valueToJava2D(start, dataArea, + plot.getRangeAxisEdge()); + double end2d = axis.valueToJava2D(end, dataArea, + plot.getRangeAxisEdge()); + double low = Math.min(start2d, end2d); + double high = Math.max(start2d, end2d); + + PlotOrientation orientation = plot.getOrientation(); + Rectangle2D rect = null; + if (orientation == PlotOrientation.HORIZONTAL) { + // clip left and right bounds to data area + low = Math.max(low, dataArea.getMinX()); + high = Math.min(high, dataArea.getMaxX()); + rect = new Rectangle2D.Double(low, + dataArea.getMinY(), high - low, + dataArea.getHeight()); + } + else if (orientation == PlotOrientation.VERTICAL) { + // clip top and bottom bounds to data area + low = Math.max(low, dataArea.getMinY()); + high = Math.min(high, dataArea.getMaxY()); + rect = new Rectangle2D.Double(dataArea.getMinX(), + low, dataArea.getWidth(), + high - low); + } + Paint p = marker.getPaint(); + if (p instanceof GradientPaint) { + GradientPaint gp = (GradientPaint) p; + GradientPaintTransformer t = im.getGradientPaintTransformer(); + if (t != null) { + gp = t.transform(gp, rect); + } + g2.setPaint(gp); + } + else { + g2.setPaint(p); + } + g2.fill(rect); + + // now draw the outlines, if visible... + if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) { + if (orientation == PlotOrientation.VERTICAL) { + Line2D line = new Line2D.Double(); + double x0 = dataArea.getMinX(); + double x1 = dataArea.getMaxX(); + g2.setPaint(im.getOutlinePaint()); + g2.setStroke(im.getOutlineStroke()); + if (range.contains(start)) { + line.setLine(x0, start2d, x1, start2d); + g2.draw(line); + } + if (range.contains(end)) { + line.setLine(x0, end2d, x1, end2d); + g2.draw(line); + } + } + else { // PlotOrientation.HORIZONTAL + Line2D line = new Line2D.Double(); + double y0 = dataArea.getMinY(); + double y1 = dataArea.getMaxY(); + g2.setPaint(im.getOutlinePaint()); + g2.setStroke(im.getOutlineStroke()); + if (range.contains(start)) { + line.setLine(start2d, y0, start2d, y1); + g2.draw(line); + } + if (range.contains(end)) { + line.setLine(end2d, y0, end2d, y1); + g2.draw(line); + } + } + } + + String label = marker.getLabel(); + RectangleAnchor anchor = marker.getLabelAnchor(); + if (label != null) { + Font labelFont = marker.getLabelFont(); + g2.setFont(labelFont); + g2.setPaint(marker.getLabelPaint()); + Point2D coordinates = calculateRangeMarkerTextAnchorPoint( + g2, orientation, dataArea, rect, + marker.getLabelOffset(), marker.getLabelOffsetType(), + anchor); + TextUtilities.drawAlignedString(label, g2, + (float) coordinates.getX(), (float) coordinates.getY(), + marker.getLabelTextAnchor()); + } + g2.setComposite(savedComposite); + } + } + + /** + * Calculates the (x, y) coordinates for drawing the label for a marker on + * the range axis. + * + * @param g2 the graphics device. + * @param orientation the plot orientation. + * @param dataArea the data area. + * @param markerArea the rectangle surrounding the marker. + * @param markerOffset the marker offset. + * @param labelOffsetType the label offset type. + * @param anchor the label anchor. + * + * @return The coordinates for drawing the marker label. + */ + protected Point2D calculateDomainMarkerTextAnchorPoint(Graphics2D g2, + PlotOrientation orientation, Rectangle2D dataArea, + Rectangle2D markerArea, RectangleInsets markerOffset, + LengthAdjustmentType labelOffsetType, RectangleAnchor anchor) { + + Rectangle2D anchorRect = null; + if (orientation == PlotOrientation.HORIZONTAL) { + anchorRect = markerOffset.createAdjustedRectangle(markerArea, + LengthAdjustmentType.CONTRACT, labelOffsetType); + } + else if (orientation == PlotOrientation.VERTICAL) { + anchorRect = markerOffset.createAdjustedRectangle(markerArea, + labelOffsetType, LengthAdjustmentType.CONTRACT); + } + return RectangleAnchor.coordinates(anchorRect, anchor); + + } + + /** + * Calculates the (x, y) coordinates for drawing a marker label. + * + * @param g2 the graphics device. + * @param orientation the plot orientation. + * @param dataArea the data area. + * @param markerArea the rectangle surrounding the marker. + * @param markerOffset the marker offset. + * @param labelOffsetType the label offset type. + * @param anchor the label anchor. + * + * @return The coordinates for drawing the marker label. + */ + protected Point2D calculateRangeMarkerTextAnchorPoint(Graphics2D g2, + PlotOrientation orientation, Rectangle2D dataArea, + Rectangle2D markerArea, RectangleInsets markerOffset, + LengthAdjustmentType labelOffsetType, RectangleAnchor anchor) { + + Rectangle2D anchorRect = null; + if (orientation == PlotOrientation.HORIZONTAL) { + anchorRect = markerOffset.createAdjustedRectangle(markerArea, + labelOffsetType, LengthAdjustmentType.CONTRACT); + } + else if (orientation == PlotOrientation.VERTICAL) { + anchorRect = markerOffset.createAdjustedRectangle(markerArea, + LengthAdjustmentType.CONTRACT, labelOffsetType); + } + return RectangleAnchor.coordinates(anchorRect, anchor); + + } + + /** + * Returns a legend item for a series. This default implementation will + * return null if {@link #isSeriesVisible(int)} or + * {@link #isSeriesVisibleInLegend(int)} returns false. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return The legend item (possibly null). + * + * @see #getLegendItems() + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + + CategoryPlot p = getPlot(); + if (p == null) { + return null; + } + + // check that a legend item needs to be displayed... + if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { + return null; + } + + CategoryDataset dataset = p.getDataset(datasetIndex); + String label = this.legendItemLabelGenerator.generateLabel(dataset, + series); + String description = label; + String toolTipText = null; + if (this.legendItemToolTipGenerator != null) { + toolTipText = this.legendItemToolTipGenerator.generateLabel( + dataset, series); + } + String urlText = null; + if (this.legendItemURLGenerator != null) { + urlText = this.legendItemURLGenerator.generateLabel(dataset, + series); + } + Shape shape = lookupLegendShape(series); + Paint paint = lookupSeriesPaint(series); + Paint outlinePaint = lookupSeriesOutlinePaint(series); + Stroke outlineStroke = lookupSeriesOutlineStroke(series); + + LegendItem item = new LegendItem(label, description, toolTipText, + urlText, shape, paint, outlineStroke, outlinePaint); + item.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + item.setLabelPaint(labelPaint); + } + item.setSeriesKey(dataset.getRowKey(series)); + item.setSeriesIndex(series); + item.setDataset(dataset); + item.setDatasetIndex(datasetIndex); + return item; + } + + /** + * Tests this renderer for equality with another object. + * + * @param obj the object. + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof AbstractCategoryItemRenderer)) { + return false; + } + AbstractCategoryItemRenderer that = (AbstractCategoryItemRenderer) obj; + + if (!ObjectUtilities.equal(this.itemLabelGenerator, + that.itemLabelGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.itemLabelGeneratorList, + that.itemLabelGeneratorList)) { + return false; + } + if (!ObjectUtilities.equal(this.baseItemLabelGenerator, + that.baseItemLabelGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.toolTipGenerator, + that.toolTipGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.toolTipGeneratorList, + that.toolTipGeneratorList)) { + return false; + } + if (!ObjectUtilities.equal(this.baseToolTipGenerator, + that.baseToolTipGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.itemURLGenerator, + that.itemURLGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.itemURLGeneratorList, + that.itemURLGeneratorList)) { + return false; + } + if (!ObjectUtilities.equal(this.baseItemURLGenerator, + that.baseItemURLGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.legendItemLabelGenerator, + that.legendItemLabelGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.legendItemToolTipGenerator, + that.legendItemToolTipGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.legendItemURLGenerator, + that.legendItemURLGenerator)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for the renderer. + * + * @return The hash code. + */ + @Override + public int hashCode() { + int result = super.hashCode(); + return result; + } + + /** + * Returns the drawing supplier from the plot. + * + * @return The drawing supplier (possibly null). + */ + @Override + public DrawingSupplier getDrawingSupplier() { + DrawingSupplier result = null; + CategoryPlot cp = getPlot(); + if (cp != null) { + result = cp.getDrawingSupplier(); + } + return result; + } + + /** + * Considers the current (x, y) coordinate and updates the crosshair point + * if it meets the criteria (usually means the (x, y) coordinate is the + * closest to the anchor point so far). + * + * @param crosshairState the crosshair state (null permitted, + * but the method does nothing in that case). + * @param rowKey the row key. + * @param columnKey the column key. + * @param value the data value. + * @param datasetIndex the dataset index. + * @param transX the x-value translated to Java2D space. + * @param transY the y-value translated to Java2D space. + * @param orientation the plot orientation (null not + * permitted). + * + * @since 1.0.11 + */ + protected void updateCrosshairValues(CategoryCrosshairState crosshairState, + Comparable rowKey, Comparable columnKey, double value, + int datasetIndex, + double transX, double transY, PlotOrientation orientation) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + + if (crosshairState != null) { + if (this.plot.isRangeCrosshairLockedOnData()) { + // both axes + crosshairState.updateCrosshairPoint(rowKey, columnKey, value, + datasetIndex, transX, transY, orientation); + } + else { + crosshairState.updateCrosshairX(rowKey, columnKey, + datasetIndex, transX, orientation); + } + } + } + + /** + * Draws an item label. + * + * @param g2 the graphics device. + * @param orientation the orientation. + * @param dataset the dataset. + * @param row the row. + * @param column the column. + * @param x the x coordinate (in Java2D space). + * @param y the y coordinate (in Java2D space). + * @param negative indicates a negative value (which affects the item + * label position). + */ + protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation, + CategoryDataset dataset, int row, int column, + double x, double y, boolean negative) { + + CategoryItemLabelGenerator generator = getItemLabelGenerator(row, + column); + if (generator != null) { + Font labelFont = getItemLabelFont(row, column); + Paint paint = getItemLabelPaint(row, column); + g2.setFont(labelFont); + g2.setPaint(paint); + String label = generator.generateLabel(dataset, row, column); + ItemLabelPosition position; + if (!negative) { + position = getPositiveItemLabelPosition(row, column); + } + else { + position = getNegativeItemLabelPosition(row, column); + } + Point2D anchorPoint = calculateLabelAnchorPoint( + position.getItemLabelAnchor(), x, y, orientation); + TextUtilities.drawRotatedString(label, g2, + (float) anchorPoint.getX(), (float) anchorPoint.getY(), + position.getTextAnchor(), + position.getAngle(), position.getRotationAnchor()); + } + + } + + /** + * Returns an independent copy of the renderer. The plot + * reference is shallow copied. + * + * @return A clone. + * + * @throws CloneNotSupportedException can be thrown if one of the objects + * belonging to the renderer does not support cloning (for example, + * an item label generator). + */ + @Override + public Object clone() throws CloneNotSupportedException { + + AbstractCategoryItemRenderer clone + = (AbstractCategoryItemRenderer) super.clone(); + + if (this.itemLabelGenerator != null) { + if (this.itemLabelGenerator instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.itemLabelGenerator; + clone.itemLabelGenerator + = (CategoryItemLabelGenerator) pc.clone(); + } + else { + throw new CloneNotSupportedException( + "ItemLabelGenerator not cloneable."); + } + } + + if (this.itemLabelGeneratorList != null) { + clone.itemLabelGeneratorList + = (ObjectList) this.itemLabelGeneratorList.clone(); + } + + if (this.baseItemLabelGenerator != null) { + if (this.baseItemLabelGenerator instanceof PublicCloneable) { + PublicCloneable pc + = (PublicCloneable) this.baseItemLabelGenerator; + clone.baseItemLabelGenerator + = (CategoryItemLabelGenerator) pc.clone(); + } + else { + throw new CloneNotSupportedException( + "ItemLabelGenerator not cloneable."); + } + } + + if (this.toolTipGenerator != null) { + if (this.toolTipGenerator instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.toolTipGenerator; + clone.toolTipGenerator = (CategoryToolTipGenerator) pc.clone(); + } + else { + throw new CloneNotSupportedException( + "Tool tip generator not cloneable."); + } + } + + if (this.toolTipGeneratorList != null) { + clone.toolTipGeneratorList + = (ObjectList) this.toolTipGeneratorList.clone(); + } + + if (this.baseToolTipGenerator != null) { + if (this.baseToolTipGenerator instanceof PublicCloneable) { + PublicCloneable pc + = (PublicCloneable) this.baseToolTipGenerator; + clone.baseToolTipGenerator + = (CategoryToolTipGenerator) pc.clone(); + } + else { + throw new CloneNotSupportedException( + "Base tool tip generator not cloneable."); + } + } + + if (this.itemURLGenerator != null) { + if (this.itemURLGenerator instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.itemURLGenerator; + clone.itemURLGenerator = (CategoryURLGenerator) pc.clone(); + } + else { + throw new CloneNotSupportedException( + "Item URL generator not cloneable."); + } + } + + if (this.itemURLGeneratorList != null) { + clone.itemURLGeneratorList + = (ObjectList) this.itemURLGeneratorList.clone(); + } + + if (this.baseItemURLGenerator != null) { + if (this.baseItemURLGenerator instanceof PublicCloneable) { + PublicCloneable pc + = (PublicCloneable) this.baseItemURLGenerator; + clone.baseItemURLGenerator = (CategoryURLGenerator) pc.clone(); + } + else { + throw new CloneNotSupportedException( + "Base item URL generator not cloneable."); + } + } + + if (this.legendItemLabelGenerator instanceof PublicCloneable) { + clone.legendItemLabelGenerator = (CategorySeriesLabelGenerator) + ObjectUtilities.clone(this.legendItemLabelGenerator); + } + if (this.legendItemToolTipGenerator instanceof PublicCloneable) { + clone.legendItemToolTipGenerator = (CategorySeriesLabelGenerator) + ObjectUtilities.clone(this.legendItemToolTipGenerator); + } + if (this.legendItemURLGenerator instanceof PublicCloneable) { + clone.legendItemURLGenerator = (CategorySeriesLabelGenerator) + ObjectUtilities.clone(this.legendItemURLGenerator); + } + return clone; + } + + /** + * Returns a domain axis for a plot. + * + * @param plot the plot. + * @param index the axis index. + * + * @return A domain axis. + */ + protected CategoryAxis getDomainAxis(CategoryPlot plot, int index) { + CategoryAxis result = plot.getDomainAxis(index); + if (result == null) { + result = plot.getDomainAxis(); + } + return result; + } + + /** + * Returns a range axis for a plot. + * + * @param plot the plot. + * @param index the axis index. + * + * @return A range axis. + */ + protected ValueAxis getRangeAxis(CategoryPlot plot, int index) { + ValueAxis result = plot.getRangeAxis(index); + if (result == null) { + result = plot.getRangeAxis(); + } + return result; + } + + /** + * Returns a (possibly empty) collection of legend items for the series + * that this renderer is responsible for drawing. + * + * @return The legend item collection (never null). + * + * @see #getLegendItem(int, int) + */ + @Override + public LegendItemCollection getLegendItems() { + LegendItemCollection result = new LegendItemCollection(); + if (this.plot == null) { + return result; + } + int index = this.plot.getIndexOf(this); + CategoryDataset dataset = this.plot.getDataset(index); + if (dataset == null) { + return result; + } + int seriesCount = dataset.getRowCount(); + if (plot.getRowRenderingOrder().equals(SortOrder.ASCENDING)) { + for (int i = 0; i < seriesCount; i++) { + if (isSeriesVisibleInLegend(i)) { + LegendItem item = getLegendItem(index, i); + if (item != null) { + result.add(item); + } + } + } + } + else { + for (int i = seriesCount - 1; i >= 0; i--) { + if (isSeriesVisibleInLegend(i)) { + LegendItem item = getLegendItem(index, i); + if (item != null) { + result.add(item); + } + } + } + } + return result; + } + + /** + * Returns the legend item label generator. + * + * @return The label generator (never null). + * + * @see #setLegendItemLabelGenerator(CategorySeriesLabelGenerator) + */ + public CategorySeriesLabelGenerator getLegendItemLabelGenerator() { + return this.legendItemLabelGenerator; + } + + /** + * Sets the legend item label generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null not permitted). + * + * @see #getLegendItemLabelGenerator() + */ + public void setLegendItemLabelGenerator( + CategorySeriesLabelGenerator generator) { + ParamChecks.nullNotPermitted(generator, "generator"); + this.legendItemLabelGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the legend item tool tip generator. + * + * @return The tool tip generator (possibly null). + * + * @see #setLegendItemToolTipGenerator(CategorySeriesLabelGenerator) + */ + public CategorySeriesLabelGenerator getLegendItemToolTipGenerator() { + return this.legendItemToolTipGenerator; + } + + /** + * Sets the legend item tool tip generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #setLegendItemToolTipGenerator(CategorySeriesLabelGenerator) + */ + public void setLegendItemToolTipGenerator( + CategorySeriesLabelGenerator generator) { + this.legendItemToolTipGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the legend item URL generator. + * + * @return The URL generator (possibly null). + * + * @see #setLegendItemURLGenerator(CategorySeriesLabelGenerator) + */ + public CategorySeriesLabelGenerator getLegendItemURLGenerator() { + return this.legendItemURLGenerator; + } + + /** + * Sets the legend item URL generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getLegendItemURLGenerator() + */ + public void setLegendItemURLGenerator( + CategorySeriesLabelGenerator generator) { + this.legendItemURLGenerator = generator; + fireChangeEvent(); + } + + /** + * Adds an entity with the specified hotspot. + * + * @param entities the entity collection. + * @param dataset the dataset. + * @param row the row index. + * @param column the column index. + * @param hotspot the hotspot (null not permitted). + */ + protected void addItemEntity(EntityCollection entities, + CategoryDataset dataset, int row, int column, Shape hotspot) { + ParamChecks.nullNotPermitted(hotspot, "hotspot"); + if (!getItemCreateEntity(row, column)) { + return; + } + String tip = null; + CategoryToolTipGenerator tipster = getToolTipGenerator(row, column); + if (tipster != null) { + tip = tipster.generateToolTip(dataset, row, column); + } + String url = null; + CategoryURLGenerator urlster = getItemURLGenerator(row, column); + if (urlster != null) { + url = urlster.generateURL(dataset, row, column); + } + CategoryItemEntity entity = new CategoryItemEntity(hotspot, tip, url, + dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); + entities.add(entity); + } + + /** + * Adds an entity to the collection. + * + * @param entities the entity collection being populated. + * @param hotspot the entity area (if null a default will be + * used). + * @param dataset the dataset. + * @param row the series. + * @param column the item. + * @param entityX the entity's center x-coordinate in user space (only + * used if area is null). + * @param entityY the entity's center y-coordinate in user space (only + * used if area is null). + * + * @since 1.0.13 + */ + protected void addEntity(EntityCollection entities, Shape hotspot, + CategoryDataset dataset, int row, int column, + double entityX, double entityY) { + if (!getItemCreateEntity(row, column)) { + return; + } + Shape s = hotspot; + if (hotspot == null) { + double r = getDefaultEntityRadius(); + double w = r * 2; + if (getPlot().getOrientation() == PlotOrientation.VERTICAL) { + s = new Ellipse2D.Double(entityX - r, entityY - r, w, w); + } + else { + s = new Ellipse2D.Double(entityY - r, entityX - r, w, w); + } + } + String tip = null; + CategoryToolTipGenerator generator = getToolTipGenerator(row, column); + if (generator != null) { + tip = generator.generateToolTip(dataset, row, column); + } + String url = null; + CategoryURLGenerator urlster = getItemURLGenerator(row, column); + if (urlster != null) { + url = urlster.generateURL(dataset, row, column); + } + CategoryItemEntity entity = new CategoryItemEntity(s, tip, url, + dataset, dataset.getRowKey(row), dataset.getColumnKey(column)); + entities.add(entity); + } + + // === DEPRECATED CODE === + + /** + * The item label generator for ALL series. + * + * @deprecated This field is redundant and deprecated as of version 1.0.6. + */ + private CategoryItemLabelGenerator itemLabelGenerator; + + /** + * The tool tip generator for ALL series. + * + * @deprecated This field is redundant and deprecated as of version 1.0.6. + */ + private CategoryToolTipGenerator toolTipGenerator; + + /** + * The URL generator. + * + * @deprecated This field is redundant and deprecated as of version 1.0.6. + */ + private CategoryURLGenerator itemURLGenerator; + + /** + * Sets the item label generator for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelGenerator(int, + * CategoryItemLabelGenerator)} and + * {@link #setBaseItemLabelGenerator(CategoryItemLabelGenerator)}. + */ + @Override + public void setItemLabelGenerator(CategoryItemLabelGenerator generator) { + this.itemLabelGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the tool tip generator that will be used for ALL items in the + * dataset (the "layer 0" generator). + * + * @return A tool tip generator (possibly null). + * + * @see #setToolTipGenerator(CategoryToolTipGenerator) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesToolTipGenerator(int)} + * and {@link #getBaseToolTipGenerator()}. + */ + @Override + public CategoryToolTipGenerator getToolTipGenerator() { + return this.toolTipGenerator; + } + + /** + * Sets the tool tip generator for ALL series and sends a + * {@link org.jfree.chart.event.RendererChangeEvent} to all registered + * listeners. + * + * @param generator the generator (null permitted). + * + * @see #getToolTipGenerator() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesToolTipGenerator(int, + * CategoryToolTipGenerator)} and + * {@link #setBaseToolTipGenerator(CategoryToolTipGenerator)}. + */ + @Override + public void setToolTipGenerator(CategoryToolTipGenerator generator) { + this.toolTipGenerator = generator; + fireChangeEvent(); + } + + /** + * Sets the item URL generator for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator. + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemURLGenerator(int, + * CategoryURLGenerator)} and + * {@link #setBaseItemURLGenerator(CategoryURLGenerator)}. + */ + @Override + public void setItemURLGenerator(CategoryURLGenerator generator) { + this.itemURLGenerator = generator; + fireChangeEvent(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/AreaRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/AreaRenderer.java new file mode 100755 index 0000000..bf3d7a7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/AreaRenderer.java @@ -0,0 +1,370 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * AreaRenderer.java + * ----------------- + * (C) Copyright 2002-2013, by Jon Iles and Contributors. + * + * Original Author: Jon Iles; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Christian W. Zuckschwerdt; + * + * Changes: + * -------- + * 21-May-2002 : Version 1, contributed by John Iles (DG); + * 29-May-2002 : Now extends AbstractCategoryItemRenderer (DG); + * 11-Jun-2002 : Updated Javadoc comments (DG); + * 25-Jun-2002 : Removed unnecessary imports (DG); + * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 10-Oct-2002 : Added constructors and basic entity support (DG); + * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and + * CategoryToolTipGenerator interface (DG); + * 05-Nov-2002 : Replaced references to CategoryDataset with TableDataset (DG); + * 06-Nov-2002 : Renamed drawCategoryItem() --> drawItem() and now using axis + * for category spacing. Renamed AreaCategoryItemRenderer + * --> AreaRenderer (DG); + * 17-Jan-2003 : Moved plot classes into a separate package (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 10-Apr-2003 : Changed CategoryDataset to KeyedValues2DDataset in + * drawItem() method (DG); + * 12-May-2003 : Modified to take into account the plot orientation (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 07-Oct-2003 : Added renderer state (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 20-Apr-2005 : Apply tooltips and URLs to legend items (DG); + * 09-Jun-2005 : Use addItemEntity() method from superclass (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 11-Oct-2006 : Fixed bug in equals() method (DG); + * 30-Nov-2006 : Added checks for series visibility (DG); + * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); + * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); + * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); + * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * 26-Jun-2008 : Added crosshair support (DG); + * 26-May-2009 : Support AreaRendererEndType.LEVEL (DG); + * 27-May-2009 : Fixed item label anchor for horizontal orientation (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.GeneralPath; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.renderer.AreaRendererEndType; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.category.CategoryDataset; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PublicCloneable; + +/** + * A category item renderer that draws area charts. You can use this renderer + * with the {@link CategoryPlot} class. The example shown here is generated + * by the AreaChartDemo1.java program included in the JFreeChart + * Demo Collection: + *

+ * AreaRendererSample.png + */ +public class AreaRenderer extends AbstractCategoryItemRenderer + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -4231878281385812757L; + + /** A flag that controls how the ends of the areas are drawn. */ + private AreaRendererEndType endType; + + /** + * Creates a new renderer. + */ + public AreaRenderer() { + super(); + this.endType = AreaRendererEndType.TAPER; + setBaseLegendShape(new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0)); + } + + /** + * Returns a token that controls how the renderer draws the end points. + * The default value is {@link AreaRendererEndType#TAPER}. + * + * @return The end type (never null). + * + * @see #setEndType + */ + public AreaRendererEndType getEndType() { + return this.endType; + } + + /** + * Sets a token that controls how the renderer draws the end points, and + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param type the end type (null not permitted). + * + * @see #getEndType() + */ + public void setEndType(AreaRendererEndType type) { + ParamChecks.nullNotPermitted(type, "type"); + this.endType = type; + fireChangeEvent(); + } + + /** + * Returns a legend item for a series. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return The legend item. + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + + // if there is no plot, there is no dataset to access... + CategoryPlot cp = getPlot(); + if (cp == null) { + return null; + } + + // check that a legend item needs to be displayed... + if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { + return null; + } + + CategoryDataset dataset = cp.getDataset(datasetIndex); + String label = getLegendItemLabelGenerator().generateLabel(dataset, + series); + String description = label; + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel(dataset, + series); + } + Shape shape = lookupLegendShape(series); + Paint paint = lookupSeriesPaint(series); + Paint outlinePaint = lookupSeriesOutlinePaint(series); + Stroke outlineStroke = lookupSeriesOutlineStroke(series); + + LegendItem result = new LegendItem(label, description, toolTipText, + urlText, shape, paint, outlineStroke, outlinePaint); + result.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + result.setLabelPaint(labelPaint); + } + result.setDataset(dataset); + result.setDatasetIndex(datasetIndex); + result.setSeriesKey(dataset.getRowKey(series)); + result.setSeriesIndex(series); + return result; + + } + + /** + * Draw a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data plot area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, + int pass) { + + // do nothing if item is not visible or null + if (!getItemVisible(row, column)) { + return; + } + Number value = dataset.getValue(row, column); + if (value == null) { + return; + } + PlotOrientation orientation = plot.getOrientation(); + RectangleEdge axisEdge = plot.getDomainAxisEdge(); + int count = dataset.getColumnCount(); + float x0 = (float) domainAxis.getCategoryStart(column, count, dataArea, + axisEdge); + float x1 = (float) domainAxis.getCategoryMiddle(column, count, + dataArea, axisEdge); + float x2 = (float) domainAxis.getCategoryEnd(column, count, dataArea, + axisEdge); + + x0 = Math.round(x0); + x1 = Math.round(x1); + x2 = Math.round(x2); + + if (this.endType == AreaRendererEndType.TRUNCATE) { + if (column == 0) { + x0 = x1; + } + else if (column == getColumnCount() - 1) { + x2 = x1; + } + } + + double yy1 = value.doubleValue(); + + double yy0 = 0.0; + if (this.endType == AreaRendererEndType.LEVEL) { + yy0 = yy1; + } + if (column > 0) { + Number n0 = dataset.getValue(row, column - 1); + if (n0 != null) { + yy0 = (n0.doubleValue() + yy1) / 2.0; + } + } + + double yy2 = 0.0; + if (column < dataset.getColumnCount() - 1) { + Number n2 = dataset.getValue(row, column + 1); + if (n2 != null) { + yy2 = (n2.doubleValue() + yy1) / 2.0; + } + } + else if (this.endType == AreaRendererEndType.LEVEL) { + yy2 = yy1; + } + + RectangleEdge edge = plot.getRangeAxisEdge(); + float y0 = (float) rangeAxis.valueToJava2D(yy0, dataArea, edge); + float y1 = (float) rangeAxis.valueToJava2D(yy1, dataArea, edge); + float y2 = (float) rangeAxis.valueToJava2D(yy2, dataArea, edge); + float yz = (float) rangeAxis.valueToJava2D(0.0, dataArea, edge); + double labelXX = x1; + double labelYY = y1; + g2.setPaint(getItemPaint(row, column)); + g2.setStroke(getItemStroke(row, column)); + + GeneralPath area = new GeneralPath(); + + if (orientation == PlotOrientation.VERTICAL) { + area.moveTo(x0, yz); + area.lineTo(x0, y0); + area.lineTo(x1, y1); + area.lineTo(x2, y2); + area.lineTo(x2, yz); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + area.moveTo(yz, x0); + area.lineTo(y0, x0); + area.lineTo(y1, x1); + area.lineTo(y2, x2); + area.lineTo(yz, x2); + double temp = labelXX; + labelXX = labelYY; + labelYY = temp; + } + area.closePath(); + + g2.setPaint(getItemPaint(row, column)); + g2.fill(area); + + // draw the item labels if there are any... + if (isItemLabelVisible(row, column)) { + drawItemLabel(g2, orientation, dataset, row, column, labelXX, + labelYY, (value.doubleValue() < 0.0)); + } + + // submit the current data point as a crosshair candidate + int datasetIndex = plot.indexOf(dataset); + updateCrosshairValues(state.getCrosshairState(), + dataset.getRowKey(row), dataset.getColumnKey(column), yy1, + datasetIndex, x1, y1, orientation); + + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, area); + } + + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object to test (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof AreaRenderer)) { + return false; + } + AreaRenderer that = (AreaRenderer) obj; + if (!this.endType.equals(that.endType)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns an independent copy of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException should not happen. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/BarPainter.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/BarPainter.java new file mode 100755 index 0000000..e95c676 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/BarPainter.java @@ -0,0 +1,93 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * BarPainter.java + * --------------- + * (C) Copyright 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 19-Jun-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Graphics2D; +import java.awt.geom.RectangularShape; + +import org.jfree.ui.RectangleEdge; + +/** + * The interface for plugin painter for the {@link BarRenderer} class. When + * developing a class that implements this interface, bear in mind the + * following: + *

    + *
  • the equals(Object) method should be overridden;
  • + *
  • instances of the class should be immutable OR implement the + * PublicCloneable interface, so that a renderer using the + * painter can be cloned reliably; + *
  • the class should be Serializable, otherwise chart + * serialization will not be supported.
  • + *
+ * + * @since 1.0.11 + */ +public interface BarPainter { + + /** + * Paints a single bar on behalf of a renderer. + * + * @param g2 the graphics target. + * @param renderer the renderer. + * @param row the row index for the item. + * @param column the column index for the item. + * @param bar the bounds for the bar. + * @param base the base of the bar. + */ + public void paintBar(Graphics2D g2, BarRenderer renderer, + int row, int column, RectangularShape bar, RectangleEdge base); + + /** + * Paints the shadow for a single bar on behalf of a renderer. + * + * @param g2 the graphics target. + * @param renderer the renderer. + * @param row the row index for the item. + * @param column the column index for the item. + * @param bar the bounds for the bar. + * @param base the base of the bar. + * @param pegShadow peg the shadow to the base of the bar? + */ + public void paintBarShadow(Graphics2D g2, BarRenderer renderer, + int row, int column, RectangularShape bar, RectangleEdge base, + boolean pegShadow); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/BarRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/BarRenderer.java new file mode 100755 index 0000000..33ba26a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/BarRenderer.java @@ -0,0 +1,1404 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * BarRenderer.java + * ---------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Christian W. Zuckschwerdt; + * Peter Kolb (patches 2497611, 2791407); + * + * Changes + * ------- + * 14-Mar-2002 : Version 1 (DG); + * 23-May-2002 : Added tooltip generator to renderer (DG); + * 29-May-2002 : Moved tooltip generator to abstract super-class (DG); + * 25-Jun-2002 : Changed constructor to protected and removed redundant + * code (DG); + * 26-Jun-2002 : Added axis to initialise method, and record upper and lower + * clip values (DG); + * 24-Sep-2002 : Added getLegendItem() method (DG); + * 09-Oct-2002 : Modified constructor to include URL generator (DG); + * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG); + * 10-Jan-2003 : Moved get/setItemMargin() method up from subclasses (DG); + * 17-Jan-2003 : Moved plot classes into a separate package (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Modified clipping to allow for dual axes and datasets (DG); + * 12-May-2003 : Merged horizontal and vertical bar renderers (DG); + * 12-Jun-2003 : Updates for item labels (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 02-Sep-2003 : Changed initialise method to fix bug 790407 (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 07-Oct-2003 : Added renderer state (DG); + * 27-Oct-2003 : Merged drawHorizontalItem() and drawVerticalItem() + * methods (DG); + * 28-Oct-2003 : Added support for gradient paint on bars (DG); + * 14-Nov-2003 : Added 'maxBarWidth' attribute (DG); + * 10-Feb-2004 : Small changes inside drawItem() method to ease cut-and-paste + * overriding (DG); + * 19-Mar-2004 : Fixed bug introduced with separation of tool tip and item + * label generators. Fixed equals() method (DG); + * 11-May-2004 : Fix for null pointer exception (bug id 951127) (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 26-Jan-2005 : Provided override for getLegendItem() method (DG); + * 20-Apr-2005 : Generate legend labels, tooltips and URLs (DG); + * 18-May-2005 : Added configurable base value (DG); + * 09-Jun-2005 : Use addItemEntity() method from superclass (DG); + * 01-Dec-2005 : Update legend item to use/not use outline (DG); + * ------------: JFreeChart 1.0.x --------------------------------------------- + * 06-Dec-2005 : Fixed bug 1374222 (JDK 1.4 specific code) (DG); + * 11-Jan-2006 : Fixed bug 1401856 (bad rendering for non-zero base) (DG); + * 04-Aug-2006 : Fixed bug 1467706 (missing item labels for zero value + * bars) (DG); + * 04-Dec-2006 : Fixed bug in rendering to non-primary axis (DG); + * 13-Dec-2006 : Add support for GradientPaint display in legend items (DG); + * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); + * 11-May-2007 : Check for visibility in getLegendItem() (DG); + * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); + * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); + * 07-May-2008 : If minimumBarLength is > 0.0, extend the non-base end of the + * bar (DG); + * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * 24-Jun-2008 : Added barPainter mechanism (DG); + * 26-Jun-2008 : Added crosshair support (DG); + * 13-Aug-2008 : Added shadowPaint attribute (DG); + * 14-Jan-2009 : Added support for seriesVisible flags (PK); + * 03-Feb-2009 : Added defaultShadowsVisible flag - see patch 2511330 (PK); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Line2D; +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.LegendItem; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.CategoryItemLabelGenerator; +import org.jfree.chart.labels.ItemLabelAnchor; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.StandardGradientPaintTransformer; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A {@link CategoryItemRenderer} that draws individual data items as bars. + * The example shown here is generated by the BarChartDemo1.java + * program included in the JFreeChart Demo Collection: + *

+ * BarRendererSample.png + */ +public class BarRenderer extends AbstractCategoryItemRenderer + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 6000649414965887481L; + + /** The default item margin percentage. */ + public static final double DEFAULT_ITEM_MARGIN = 0.20; + + /** + * Constant that controls the minimum width before a bar has an outline + * drawn. + */ + public static final double BAR_OUTLINE_WIDTH_THRESHOLD = 3.0; + + /** + * The default bar painter assigned to each new instance of this renderer. + * + * @since 1.0.11 + */ + private static BarPainter defaultBarPainter = new GradientBarPainter(); + + /** + * Returns the default bar painter. + * + * @return The default bar painter. + * + * @since 1.0.11 + */ + public static BarPainter getDefaultBarPainter() { + return BarRenderer.defaultBarPainter; + } + + /** + * Sets the default bar painter. + * + * @param painter the painter (null not permitted). + * + * @since 1.0.11 + */ + public static void setDefaultBarPainter(BarPainter painter) { + ParamChecks.nullNotPermitted(painter, "painter"); + BarRenderer.defaultBarPainter = painter; + } + + /** + * The default value for the initialisation of the shadowsVisible flag. + */ + private static boolean defaultShadowsVisible = true; + + /** + * Returns the default value for the shadowsVisible flag. + * + * @return A boolean. + * + * @see #setDefaultShadowsVisible(boolean) + * + * @since 1.0.13 + */ + public static boolean getDefaultShadowsVisible() { + return BarRenderer.defaultShadowsVisible; + } + + /** + * Sets the default value for the shadows visible flag. + * + * @param visible the new value for the default. + * + * @see #getDefaultShadowsVisible() + * + * @since 1.0.13 + */ + public static void setDefaultShadowsVisible(boolean visible) { + BarRenderer.defaultShadowsVisible = visible; + } + + /** The margin between items (bars) within a category. */ + private double itemMargin; + + /** A flag that controls whether or not bar outlines are drawn. */ + private boolean drawBarOutline; + + /** The maximum bar width as a percentage of the available space. */ + private double maximumBarWidth; + + /** The minimum bar length (in Java2D units). */ + private double minimumBarLength; + + /** + * An optional class used to transform gradient paint objects to fit each + * bar. + */ + private GradientPaintTransformer gradientPaintTransformer; + + /** + * The fallback position if a positive item label doesn't fit inside the + * bar. + */ + private ItemLabelPosition positiveItemLabelPositionFallback; + + /** + * The fallback position if a negative item label doesn't fit inside the + * bar. + */ + private ItemLabelPosition negativeItemLabelPositionFallback; + + /** The upper clip (axis) value for the axis. */ + private double upperClip; + // TODO: this needs to move into the renderer state + + /** The lower clip (axis) value for the axis. */ + private double lowerClip; + // TODO: this needs to move into the renderer state + + /** The base value for the bars (defaults to 0.0). */ + private double base; + + /** + * A flag that controls whether the base value is included in the range + * returned by the findRangeBounds() method. + */ + private boolean includeBaseInRange; + + /** + * The bar painter (never null). + * + * @since 1.0.11 + */ + private BarPainter barPainter; + + /** + * The flag that controls whether or not shadows are drawn for the bars. + * + * @since 1.0.11 + */ + private boolean shadowsVisible; + + /** + * The shadow paint. + * + * @since 1.0.11 + */ + private transient Paint shadowPaint; + + /** + * The x-offset for the shadow effect. + * + * @since 1.0.11 + */ + private double shadowXOffset; + + /** + * The y-offset for the shadow effect. + * + * @since 1.0.11 + */ + private double shadowYOffset; + + /** + * Creates a new bar renderer with default settings. + */ + public BarRenderer() { + super(); + this.base = 0.0; + this.includeBaseInRange = true; + this.itemMargin = DEFAULT_ITEM_MARGIN; + this.drawBarOutline = false; + this.maximumBarWidth = 1.0; + // 100 percent, so it will not apply unless changed + this.positiveItemLabelPositionFallback = null; + this.negativeItemLabelPositionFallback = null; + this.gradientPaintTransformer = new StandardGradientPaintTransformer(); + this.minimumBarLength = 0.0; + setBaseLegendShape(new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0)); + this.barPainter = getDefaultBarPainter(); + this.shadowsVisible = getDefaultShadowsVisible(); + this.shadowPaint = Color.gray; + this.shadowXOffset = 4.0; + this.shadowYOffset = 4.0; + } + + /** + * Returns the base value for the bars. The default value is + * 0.0. + * + * @return The base value for the bars. + * + * @see #setBase(double) + */ + public double getBase() { + return this.base; + } + + /** + * Sets the base value for the bars and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param base the new base value. + * + * @see #getBase() + */ + public void setBase(double base) { + this.base = base; + fireChangeEvent(); + } + + /** + * Returns the item margin as a percentage of the available space for all + * bars. + * + * @return The margin percentage (where 0.10 is ten percent). + * + * @see #setItemMargin(double) + */ + public double getItemMargin() { + return this.itemMargin; + } + + /** + * Sets the item margin and sends a {@link RendererChangeEvent} to all + * registered listeners. The value is expressed as a percentage of the + * available width for plotting all the bars, with the resulting amount to + * be distributed between all the bars evenly. + * + * @param percent the margin (where 0.10 is ten percent). + * + * @see #getItemMargin() + */ + public void setItemMargin(double percent) { + this.itemMargin = percent; + fireChangeEvent(); + } + + /** + * Returns a flag that controls whether or not bar outlines are drawn. + * + * @return A boolean. + * + * @see #setDrawBarOutline(boolean) + */ + public boolean isDrawBarOutline() { + return this.drawBarOutline; + } + + /** + * Sets the flag that controls whether or not bar outlines are drawn and + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param draw the flag. + * + * @see #isDrawBarOutline() + */ + public void setDrawBarOutline(boolean draw) { + this.drawBarOutline = draw; + fireChangeEvent(); + } + + /** + * Returns the maximum bar width, as a percentage of the available drawing + * space. + * + * @return The maximum bar width. + * + * @see #setMaximumBarWidth(double) + */ + public double getMaximumBarWidth() { + return this.maximumBarWidth; + } + + /** + * Sets the maximum bar width, which is specified as a percentage of the + * available space for all bars, and sends a {@link RendererChangeEvent} to + * all registered listeners. + * + * @param percent the percent (where 0.05 is five percent). + * + * @see #getMaximumBarWidth() + */ + public void setMaximumBarWidth(double percent) { + this.maximumBarWidth = percent; + fireChangeEvent(); + } + + /** + * Returns the minimum bar length (in Java2D units). The default value is + * 0.0. + * + * @return The minimum bar length. + * + * @see #setMinimumBarLength(double) + */ + public double getMinimumBarLength() { + return this.minimumBarLength; + } + + /** + * Sets the minimum bar length and sends a {@link RendererChangeEvent} to + * all registered listeners. The minimum bar length is specified in Java2D + * units, and can be used to prevent bars that represent very small data + * values from disappearing when drawn on the screen. Typically you would + * set this to (say) 0.5 or 1.0 Java 2D units. Use this attribute with + * caution, however, because setting it to a non-zero value will + * artificially increase the length of bars representing small values, + * which may misrepresent your data. + * + * @param min the minimum bar length (in Java2D units, must be >= 0.0). + * + * @see #getMinimumBarLength() + */ + public void setMinimumBarLength(double min) { + if (min < 0.0) { + throw new IllegalArgumentException("Requires 'min' >= 0.0"); + } + this.minimumBarLength = min; + fireChangeEvent(); + } + + /** + * Returns the gradient paint transformer (an object used to transform + * gradient paint objects to fit each bar). + * + * @return A transformer (null possible). + * + * @see #setGradientPaintTransformer(GradientPaintTransformer) + */ + public GradientPaintTransformer getGradientPaintTransformer() { + return this.gradientPaintTransformer; + } + + /** + * Sets the gradient paint transformer and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param transformer the transformer (null permitted). + * + * @see #getGradientPaintTransformer() + */ + public void setGradientPaintTransformer( + GradientPaintTransformer transformer) { + this.gradientPaintTransformer = transformer; + fireChangeEvent(); + } + + /** + * Returns the fallback position for positive item labels that don't fit + * within a bar. + * + * @return The fallback position (null possible). + * + * @see #setPositiveItemLabelPositionFallback(ItemLabelPosition) + */ + public ItemLabelPosition getPositiveItemLabelPositionFallback() { + return this.positiveItemLabelPositionFallback; + } + + /** + * Sets the fallback position for positive item labels that don't fit + * within a bar, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param position the position (null permitted). + * + * @see #getPositiveItemLabelPositionFallback() + */ + public void setPositiveItemLabelPositionFallback( + ItemLabelPosition position) { + this.positiveItemLabelPositionFallback = position; + fireChangeEvent(); + } + + /** + * Returns the fallback position for negative item labels that don't fit + * within a bar. + * + * @return The fallback position (null possible). + * + * @see #setPositiveItemLabelPositionFallback(ItemLabelPosition) + */ + public ItemLabelPosition getNegativeItemLabelPositionFallback() { + return this.negativeItemLabelPositionFallback; + } + + /** + * Sets the fallback position for negative item labels that don't fit + * within a bar, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param position the position (null permitted). + * + * @see #getNegativeItemLabelPositionFallback() + */ + public void setNegativeItemLabelPositionFallback( + ItemLabelPosition position) { + this.negativeItemLabelPositionFallback = position; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not the base value for the + * bars is included in the range calculated by + * {@link #findRangeBounds(CategoryDataset)}. + * + * @return true if the base is included in the range, and + * false otherwise. + * + * @since 1.0.1 + * + * @see #setIncludeBaseInRange(boolean) + */ + public boolean getIncludeBaseInRange() { + return this.includeBaseInRange; + } + + /** + * Sets the flag that controls whether or not the base value for the bars + * is included in the range calculated by + * {@link #findRangeBounds(CategoryDataset)}. If the flag is changed, + * a {@link RendererChangeEvent} is sent to all registered listeners. + * + * @param include the new value for the flag. + * + * @since 1.0.1 + * + * @see #getIncludeBaseInRange() + */ + public void setIncludeBaseInRange(boolean include) { + if (this.includeBaseInRange != include) { + this.includeBaseInRange = include; + fireChangeEvent(); + } + } + + /** + * Returns the bar painter. + * + * @return The bar painter (never null). + * + * @see #setBarPainter(BarPainter) + * + * @since 1.0.11 + */ + public BarPainter getBarPainter() { + return this.barPainter; + } + + /** + * Sets the bar painter for this renderer and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param painter the painter (null not permitted). + * + * @see #getBarPainter() + * + * @since 1.0.11 + */ + public void setBarPainter(BarPainter painter) { + ParamChecks.nullNotPermitted(painter, "painter"); + this.barPainter = painter; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not shadows are drawn for + * the bars. + * + * @return A boolean. + * + * @since 1.0.11 + */ + public boolean getShadowsVisible() { + return this.shadowsVisible; + } + + /** + * Sets the flag that controls whether or not shadows are + * drawn by the renderer. + * + * @param visible the new flag value. + * + * @since 1.0.11 + */ + public void setShadowVisible(boolean visible) { + this.shadowsVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the shadow paint. + * + * @return The shadow paint. + * + * @see #setShadowPaint(Paint) + * + * @since 1.0.11 + */ + public Paint getShadowPaint() { + return this.shadowPaint; + } + + /** + * Sets the shadow paint and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getShadowPaint() + * + * @since 1.0.11 + */ + public void setShadowPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.shadowPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the shadow x-offset. + * + * @return The shadow x-offset. + * + * @since 1.0.11 + */ + public double getShadowXOffset() { + return this.shadowXOffset; + } + + /** + * Sets the x-offset for the bar shadow and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param offset the offset. + * + * @since 1.0.11 + */ + public void setShadowXOffset(double offset) { + this.shadowXOffset = offset; + fireChangeEvent(); + } + + /** + * Returns the shadow y-offset. + * + * @return The shadow y-offset. + * + * @since 1.0.11 + */ + public double getShadowYOffset() { + return this.shadowYOffset; + } + + /** + * Sets the y-offset for the bar shadow and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param offset the offset. + * + * @since 1.0.11 + */ + public void setShadowYOffset(double offset) { + this.shadowYOffset = offset; + fireChangeEvent(); + } + + /** + * Returns the lower clip value. This value is recalculated in the + * initialise() method. + * + * @return The value. + */ + public double getLowerClip() { + // TODO: this attribute should be transferred to the renderer state. + return this.lowerClip; + } + + /** + * Returns the upper clip value. This value is recalculated in the + * initialise() method. + * + * @return The value. + */ + public double getUpperClip() { + // TODO: this attribute should be transferred to the renderer state. + return this.upperClip; + } + + /** + * Initialises the renderer and returns a state object that will be passed + * to subsequent calls to the drawItem method. This method gets called + * once at the start of the process of drawing a chart. + * + * @param g2 the graphics device. + * @param dataArea the area in which the data is to be plotted. + * @param plot the plot. + * @param rendererIndex the renderer index. + * @param info collects chart rendering information for return to caller. + * + * @return The renderer state. + */ + @Override + public CategoryItemRendererState initialise(Graphics2D g2, + Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, + PlotRenderingInfo info) { + + CategoryItemRendererState state = super.initialise(g2, dataArea, plot, + rendererIndex, info); + + // get the clipping values... + ValueAxis rangeAxis = plot.getRangeAxisForDataset(rendererIndex); + this.lowerClip = rangeAxis.getRange().getLowerBound(); + this.upperClip = rangeAxis.getRange().getUpperBound(); + + // calculate the bar width + calculateBarWidth(plot, dataArea, rendererIndex, state); + + return state; + + } + + /** + * Calculates the bar width and stores it in the renderer state. + * + * @param plot the plot. + * @param dataArea the data area. + * @param rendererIndex the renderer index. + * @param state the renderer state. + */ + protected void calculateBarWidth(CategoryPlot plot, + Rectangle2D dataArea, + int rendererIndex, + CategoryItemRendererState state) { + + CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); + CategoryDataset dataset = plot.getDataset(rendererIndex); + if (dataset != null) { + int columns = dataset.getColumnCount(); + int rows = state.getVisibleSeriesCount() >= 0 + ? state.getVisibleSeriesCount() : dataset.getRowCount(); + double space = 0.0; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + space = dataArea.getHeight(); + } + else if (orientation == PlotOrientation.VERTICAL) { + space = dataArea.getWidth(); + } + double maxWidth = space * getMaximumBarWidth(); + double categoryMargin = 0.0; + double currentItemMargin = 0.0; + if (columns > 1) { + categoryMargin = domainAxis.getCategoryMargin(); + } + if (rows > 1) { + currentItemMargin = getItemMargin(); + } + double used = space * (1 - domainAxis.getLowerMargin() + - domainAxis.getUpperMargin() + - categoryMargin - currentItemMargin); + if ((rows * columns) > 0) { + state.setBarWidth(Math.min(used / (rows * columns), maxWidth)); + } + else { + state.setBarWidth(Math.min(used, maxWidth)); + } + } + } + + /** + * Calculates the coordinate of the first "side" of a bar. This will be + * the minimum x-coordinate for a vertical bar, and the minimum + * y-coordinate for a horizontal bar. + * + * @param plot the plot. + * @param orientation the plot orientation. + * @param dataArea the data area. + * @param domainAxis the domain axis. + * @param state the renderer state (has the bar width precalculated). + * @param row the row index. + * @param column the column index. + * + * @return The coordinate. + */ + protected double calculateBarW0(CategoryPlot plot, + PlotOrientation orientation, Rectangle2D dataArea, + CategoryAxis domainAxis, CategoryItemRendererState state, + int row, int column) { + // calculate bar width... + double space; + if (orientation == PlotOrientation.HORIZONTAL) { + space = dataArea.getHeight(); + } + else { + space = dataArea.getWidth(); + } + double barW0 = domainAxis.getCategoryStart(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()); + int seriesCount = state.getVisibleSeriesCount() >= 0 + ? state.getVisibleSeriesCount() : getRowCount(); + int categoryCount = getColumnCount(); + if (seriesCount > 1) { + double seriesGap = space * getItemMargin() + / (categoryCount * (seriesCount - 1)); + double seriesW = calculateSeriesWidth(space, domainAxis, + categoryCount, seriesCount); + barW0 = barW0 + row * (seriesW + seriesGap) + + (seriesW / 2.0) - (state.getBarWidth() / 2.0); + } + else { + barW0 = domainAxis.getCategoryMiddle(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() + / 2.0; + } + return barW0; + } + + /** + * Calculates the coordinates for the length of a single bar. + * + * @param value the value represented by the bar. + * + * @return The coordinates for each end of the bar (or null if + * the bar is not visible for the current axis range). + */ + protected double[] calculateBarL0L1(double value) { + double lclip = getLowerClip(); + double uclip = getUpperClip(); + double barLow = Math.min(this.base, value); + double barHigh = Math.max(this.base, value); + if (barHigh < lclip) { // bar is not visible + return null; + } + if (barLow > uclip) { // bar is not visible + return null; + } + barLow = Math.max(barLow, lclip); + barHigh = Math.min(barHigh, uclip); + return new double[] {barLow, barHigh}; + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. This takes into account the range + * of values in the dataset, plus the flag that determines whether or not + * the base value for the bars should be included in the range. + * + * @param dataset the dataset (null permitted). + * @param includeInterval include the interval if the dataset has one? + * + * @return The range (or null if the dataset is + * null or empty). + */ + @Override + public Range findRangeBounds(CategoryDataset dataset, + boolean includeInterval) { + if (dataset == null) { + return null; + } + Range result = super.findRangeBounds(dataset, includeInterval); + if (result != null) { + if (this.includeBaseInRange) { + result = Range.expandToInclude(result, this.base); + } + } + return result; + } + + /** + * Returns a legend item for a series. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return The legend item (possibly null). + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + + CategoryPlot cp = getPlot(); + if (cp == null) { + return null; + } + + // check that a legend item needs to be displayed... + if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { + return null; + } + + CategoryDataset dataset = cp.getDataset(datasetIndex); + String label = getLegendItemLabelGenerator().generateLabel(dataset, + series); + String description = label; + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel(dataset, + series); + } + Shape shape = lookupLegendShape(series); + Paint paint = lookupSeriesPaint(series); + Paint outlinePaint = lookupSeriesOutlinePaint(series); + Stroke outlineStroke = lookupSeriesOutlineStroke(series); + + LegendItem result = new LegendItem(label, description, toolTipText, + urlText, true, shape, true, paint, isDrawBarOutline(), + outlinePaint, outlineStroke, false, new Line2D.Float(), + new BasicStroke(1.0f), Color.black); + result.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + result.setLabelPaint(labelPaint); + } + result.setDataset(dataset); + result.setDatasetIndex(datasetIndex); + result.setSeriesKey(dataset.getRowKey(series)); + result.setSeriesIndex(series); + if (this.gradientPaintTransformer != null) { + result.setFillPaintTransformer(this.gradientPaintTransformer); + } + return result; + } + + /** + * Draws the bar for a single (series, category) data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, + int column, int pass) { + + // nothing is drawn if the row index is not included in the list with + // the indices of the visible rows... + int visibleRow = state.getVisibleSeriesIndex(row); + if (visibleRow < 0) { + return; + } + // nothing is drawn for null values... + Number dataValue = dataset.getValue(row, column); + if (dataValue == null) { + return; + } + + final double value = dataValue.doubleValue(); + PlotOrientation orientation = plot.getOrientation(); + double barW0 = calculateBarW0(plot, orientation, dataArea, domainAxis, + state, visibleRow, column); + double[] barL0L1 = calculateBarL0L1(value); + if (barL0L1 == null) { + return; // the bar is not visible + } + + RectangleEdge edge = plot.getRangeAxisEdge(); + double transL0 = rangeAxis.valueToJava2D(barL0L1[0], dataArea, edge); + double transL1 = rangeAxis.valueToJava2D(barL0L1[1], dataArea, edge); + + // in the following code, barL0 is (in Java2D coordinates) the LEFT + // end of the bar for a horizontal bar chart, and the TOP end of the + // bar for a vertical bar chart. Whether this is the BASE of the bar + // or not depends also on (a) whether the data value is 'negative' + // relative to the base value and (b) whether or not the range axis is + // inverted. This only matters if/when we apply the minimumBarLength + // attribute, because we should extend the non-base end of the bar + boolean positive = (value >= this.base); + boolean inverted = rangeAxis.isInverted(); + double barL0 = Math.min(transL0, transL1); + double barLength = Math.abs(transL1 - transL0); + double barLengthAdj = 0.0; + if (barLength > 0.0 && barLength < getMinimumBarLength()) { + barLengthAdj = getMinimumBarLength() - barLength; + } + double barL0Adj = 0.0; + RectangleEdge barBase; + if (orientation == PlotOrientation.HORIZONTAL) { + if (positive && inverted || !positive && !inverted) { + barL0Adj = barLengthAdj; + barBase = RectangleEdge.RIGHT; + } + else { + barBase = RectangleEdge.LEFT; + } + } + else { + if (positive && !inverted || !positive && inverted) { + barL0Adj = barLengthAdj; + barBase = RectangleEdge.BOTTOM; + } + else { + barBase = RectangleEdge.TOP; + } + } + + // draw the bar... + Rectangle2D bar; + if (orientation == PlotOrientation.HORIZONTAL) { + bar = new Rectangle2D.Double(barL0 - barL0Adj, barW0, + barLength + barLengthAdj, state.getBarWidth()); + } + else { + bar = new Rectangle2D.Double(barW0, barL0 - barL0Adj, + state.getBarWidth(), barLength + barLengthAdj); + } + if (getShadowsVisible()) { + this.barPainter.paintBarShadow(g2, this, row, column, bar, barBase, + true); + } + this.barPainter.paintBar(g2, this, row, column, bar, barBase); + + CategoryItemLabelGenerator generator = getItemLabelGenerator(row, + column); + if (generator != null && isItemLabelVisible(row, column)) { + drawItemLabel(g2, dataset, row, column, plot, generator, bar, + (value < 0.0)); + } + + // submit the current data point as a crosshair candidate + int datasetIndex = plot.indexOf(dataset); + updateCrosshairValues(state.getCrosshairState(), + dataset.getRowKey(row), dataset.getColumnKey(column), value, + datasetIndex, barW0, barL0, orientation); + + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, bar); + } + + } + + /** + * Calculates the available space for each series. + * + * @param space the space along the entire axis (in Java2D units). + * @param axis the category axis. + * @param categories the number of categories. + * @param series the number of series. + * + * @return The width of one series. + */ + protected double calculateSeriesWidth(double space, CategoryAxis axis, + int categories, int series) { + double factor = 1.0 - getItemMargin() - axis.getLowerMargin() + - axis.getUpperMargin(); + if (categories > 1) { + factor = factor - axis.getCategoryMargin(); + } + return (space * factor) / (categories * series); + } + + /** + * Draws an item label. This method is overridden so that the bar can be + * used to calculate the label anchor point. + * + * @param g2 the graphics device. + * @param data the dataset. + * @param row the row. + * @param column the column. + * @param plot the plot. + * @param generator the label generator. + * @param bar the bar. + * @param negative a flag indicating a negative value. + */ + protected void drawItemLabel(Graphics2D g2, + CategoryDataset data, + int row, + int column, + CategoryPlot plot, + CategoryItemLabelGenerator generator, + Rectangle2D bar, + boolean negative) { + + String label = generator.generateLabel(data, row, column); + if (label == null) { + return; // nothing to do + } + + Font labelFont = getItemLabelFont(row, column); + g2.setFont(labelFont); + Paint paint = getItemLabelPaint(row, column); + g2.setPaint(paint); + + // find out where to place the label... + ItemLabelPosition position; + if (!negative) { + position = getPositiveItemLabelPosition(row, column); + } + else { + position = getNegativeItemLabelPosition(row, column); + } + + // work out the label anchor point... + Point2D anchorPoint = calculateLabelAnchorPoint( + position.getItemLabelAnchor(), bar, plot.getOrientation()); + + if (isInternalAnchor(position.getItemLabelAnchor())) { + Shape bounds = TextUtilities.calculateRotatedStringBounds(label, + g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), + position.getTextAnchor(), position.getAngle(), + position.getRotationAnchor()); + + if (bounds != null) { + if (!bar.contains(bounds.getBounds2D())) { + if (!negative) { + position = getPositiveItemLabelPositionFallback(); + } + else { + position = getNegativeItemLabelPositionFallback(); + } + if (position != null) { + anchorPoint = calculateLabelAnchorPoint( + position.getItemLabelAnchor(), bar, + plot.getOrientation()); + } + } + } + + } + + if (position != null) { + TextUtilities.drawRotatedString(label, g2, + (float) anchorPoint.getX(), (float) anchorPoint.getY(), + position.getTextAnchor(), position.getAngle(), + position.getRotationAnchor()); + } + } + + /** + * Calculates the item label anchor point. + * + * @param anchor the anchor. + * @param bar the bar. + * @param orientation the plot orientation. + * + * @return The anchor point. + */ + private Point2D calculateLabelAnchorPoint(ItemLabelAnchor anchor, + Rectangle2D bar, + PlotOrientation orientation) { + + Point2D result = null; + double offset = getItemLabelAnchorOffset(); + double x0 = bar.getX() - offset; + double x1 = bar.getX(); + double x2 = bar.getX() + offset; + double x3 = bar.getCenterX(); + double x4 = bar.getMaxX() - offset; + double x5 = bar.getMaxX(); + double x6 = bar.getMaxX() + offset; + + double y0 = bar.getMaxY() + offset; + double y1 = bar.getMaxY(); + double y2 = bar.getMaxY() - offset; + double y3 = bar.getCenterY(); + double y4 = bar.getMinY() + offset; + double y5 = bar.getMinY(); + double y6 = bar.getMinY() - offset; + + if (anchor == ItemLabelAnchor.CENTER) { + result = new Point2D.Double(x3, y3); + } + else if (anchor == ItemLabelAnchor.INSIDE1) { + result = new Point2D.Double(x4, y4); + } + else if (anchor == ItemLabelAnchor.INSIDE2) { + result = new Point2D.Double(x4, y4); + } + else if (anchor == ItemLabelAnchor.INSIDE3) { + result = new Point2D.Double(x4, y3); + } + else if (anchor == ItemLabelAnchor.INSIDE4) { + result = new Point2D.Double(x4, y2); + } + else if (anchor == ItemLabelAnchor.INSIDE5) { + result = new Point2D.Double(x4, y2); + } + else if (anchor == ItemLabelAnchor.INSIDE6) { + result = new Point2D.Double(x3, y2); + } + else if (anchor == ItemLabelAnchor.INSIDE7) { + result = new Point2D.Double(x2, y2); + } + else if (anchor == ItemLabelAnchor.INSIDE8) { + result = new Point2D.Double(x2, y2); + } + else if (anchor == ItemLabelAnchor.INSIDE9) { + result = new Point2D.Double(x2, y3); + } + else if (anchor == ItemLabelAnchor.INSIDE10) { + result = new Point2D.Double(x2, y4); + } + else if (anchor == ItemLabelAnchor.INSIDE11) { + result = new Point2D.Double(x2, y4); + } + else if (anchor == ItemLabelAnchor.INSIDE12) { + result = new Point2D.Double(x3, y4); + } + else if (anchor == ItemLabelAnchor.OUTSIDE1) { + result = new Point2D.Double(x5, y6); + } + else if (anchor == ItemLabelAnchor.OUTSIDE2) { + result = new Point2D.Double(x6, y5); + } + else if (anchor == ItemLabelAnchor.OUTSIDE3) { + result = new Point2D.Double(x6, y3); + } + else if (anchor == ItemLabelAnchor.OUTSIDE4) { + result = new Point2D.Double(x6, y1); + } + else if (anchor == ItemLabelAnchor.OUTSIDE5) { + result = new Point2D.Double(x5, y0); + } + else if (anchor == ItemLabelAnchor.OUTSIDE6) { + result = new Point2D.Double(x3, y0); + } + else if (anchor == ItemLabelAnchor.OUTSIDE7) { + result = new Point2D.Double(x1, y0); + } + else if (anchor == ItemLabelAnchor.OUTSIDE8) { + result = new Point2D.Double(x0, y1); + } + else if (anchor == ItemLabelAnchor.OUTSIDE9) { + result = new Point2D.Double(x0, y3); + } + else if (anchor == ItemLabelAnchor.OUTSIDE10) { + result = new Point2D.Double(x0, y5); + } + else if (anchor == ItemLabelAnchor.OUTSIDE11) { + result = new Point2D.Double(x1, y6); + } + else if (anchor == ItemLabelAnchor.OUTSIDE12) { + result = new Point2D.Double(x3, y6); + } + + return result; + + } + + /** + * Returns true if the specified anchor point is inside a bar. + * + * @param anchor the anchor point. + * + * @return A boolean. + */ + private boolean isInternalAnchor(ItemLabelAnchor anchor) { + return anchor == ItemLabelAnchor.CENTER + || anchor == ItemLabelAnchor.INSIDE1 + || anchor == ItemLabelAnchor.INSIDE2 + || anchor == ItemLabelAnchor.INSIDE3 + || anchor == ItemLabelAnchor.INSIDE4 + || anchor == ItemLabelAnchor.INSIDE5 + || anchor == ItemLabelAnchor.INSIDE6 + || anchor == ItemLabelAnchor.INSIDE7 + || anchor == ItemLabelAnchor.INSIDE8 + || anchor == ItemLabelAnchor.INSIDE9 + || anchor == ItemLabelAnchor.INSIDE10 + || anchor == ItemLabelAnchor.INSIDE11 + || anchor == ItemLabelAnchor.INSIDE12; + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof BarRenderer)) { + return false; + } + BarRenderer that = (BarRenderer) obj; + if (this.base != that.base) { + return false; + } + if (this.itemMargin != that.itemMargin) { + return false; + } + if (this.drawBarOutline != that.drawBarOutline) { + return false; + } + if (this.maximumBarWidth != that.maximumBarWidth) { + return false; + } + if (this.minimumBarLength != that.minimumBarLength) { + return false; + } + if (!ObjectUtilities.equal(this.gradientPaintTransformer, + that.gradientPaintTransformer)) { + return false; + } + if (!ObjectUtilities.equal(this.positiveItemLabelPositionFallback, + that.positiveItemLabelPositionFallback)) { + return false; + } + if (!ObjectUtilities.equal(this.negativeItemLabelPositionFallback, + that.negativeItemLabelPositionFallback)) { + return false; + } + if (!this.barPainter.equals(that.barPainter)) { + return false; + } + if (this.shadowsVisible != that.shadowsVisible) { + return false; + } + if (!PaintUtilities.equal(this.shadowPaint, that.shadowPaint)) { + return false; + } + if (this.shadowXOffset != that.shadowXOffset) { + return false; + } + if (this.shadowYOffset != that.shadowYOffset) { + return false; + } + return super.equals(obj); + } + + /** + * 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.shadowPaint, 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.shadowPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/BarRenderer3D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/BarRenderer3D.java new file mode 100755 index 0000000..2b48f06 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/BarRenderer3D.java @@ -0,0 +1,832 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * BarRenderer3D.java + * ------------------ + * (C) Copyright 2001-2013, by Serge V. Grachov and Contributors. + * + * Original Author: Serge V. Grachov; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Tin Luu; + * Milo Simpson; + * Richard Atkinson; + * Rich Unger; + * Christian W. Zuckschwerdt; + * DaveLaw (dave ATT davelaw DOTT de) - patch 3204823; + * + * Changes + * ------- + * 31-Oct-2001 : First version, contributed by Serge V. Grachov (DG); + * 15-Nov-2001 : Modified to allow for null data values (DG); + * 13-Dec-2001 : Added tooltips (DG); + * 16-Jan-2002 : Added fix for single category or single series datasets, + * pointed out by Taoufik Romdhane (DG); + * 24-May-2002 : Incorporated tooltips into chart entities (DG); + * 11-Jun-2002 : Added check for (permitted) null info object, bug and fix + * reported by David Basten. Also updated Javadocs. (DG); + * 19-Jun-2002 : Added code to draw labels on bars (TL); + * 26-Jun-2002 : Added bar clipping to avoid PRExceptions (DG); + * 05-Aug-2002 : Small modification to drawCategoryItem method to support URLs + * for HTML image maps (RA); + * 06-Aug-2002 : Value labels now use number formatter, thanks to Milo + * Simpson (DG); + * 08-Aug-2002 : Applied fixed in bug id 592218 (DG); + * 20-Sep-2002 : Added fix for categoryPaint by Rich Unger, and fixed errors + * reported by Checkstyle (DG); + * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and + * CategoryToolTipGenerator interface (DG); + * 05-Nov-2002 : Replaced references to CategoryDataset with TableDataset (DG); + * 06-Nov-2002 : Moved to the com.jrefinery.chart.renderer package (DG); + * 28-Jan-2003 : Added an attribute to control the shading of the left and + * bottom walls in the plot background (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 10-Apr-2003 : Removed category paint usage (DG); + * 13-May-2003 : Renamed VerticalBarRenderer3D --> BarRenderer3D and merged with + * HorizontalBarRenderer3D (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 19-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 07-Oct-2003 : Added renderer state (DG); + * 08-Oct-2003 : Removed clipping (replaced with flag in CategoryPlot to + * control order in which the data items are processed) (DG); + * 20-Oct-2003 : Fixed bug (outline stroke not being used for bar + * outlines) (DG); + * 21-Oct-2003 : Bar width moved into CategoryItemRendererState (DG); + * 24-Nov-2003 : Fixed bug 846324 (item labels not showing) (DG); + * 27-Nov-2003 : Added code to respect maxBarWidth setting (DG); + * 02-Feb-2004 : Fixed bug where 'drawBarOutline' flag is not respected (DG); + * 10-Feb-2004 : Small change to drawItem() method to make cut-and-paste + * overriding easier (DG); + * 04-Oct-2004 : Fixed bug with item label positioning when plot alignment is + * horizontal (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 20-Apr-2005 : Renamed CategoryLabelGenerator + * --> CategoryItemLabelGenerator (DG); + * 25-Apr-2005 : Override initialise() method to fix bug 1189642 (DG); + * 09-Jun-2005 : Use addEntityItem from super class (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 07-Dec-2006 : Implemented equals() override (DG); + * 17-Jan-2007 : Fixed bug in drawDomainGridline() method (DG); + * 03-Apr-2007 : Fixed bugs in drawBackground() method (DG); + * 16-Oct-2007 : Fixed bug in range marker drawing (DG); + * 19-Mar-2009 : Override for drawRangeLine() method (DG); + * 11-Jun-2012 : Utilise new PaintAlpha class - patch 3204823 from DaveLaw (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Paint; +import java.awt.Stroke; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; +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.Effect3D; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.CategoryItemLabelGenerator; +import org.jfree.chart.labels.ItemLabelAnchor; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Marker; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.ValueMarker; +import org.jfree.chart.util.PaintAlpha; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.ui.LengthAdjustmentType; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.TextAnchor; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A renderer for bars with a 3D effect, for use with the + * {@link CategoryPlot} class. The example shown here is generated + * by the BarChart3DDemo1.java program included in the JFreeChart + * Demo Collection: + *

+ * BarRenderer3DSample.png + */ +public class BarRenderer3D extends BarRenderer + implements Effect3D, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7686976503536003636L; + + /** The default x-offset for the 3D effect. */ + public static final double DEFAULT_X_OFFSET = 12.0; + + /** The default y-offset for the 3D effect. */ + public static final double DEFAULT_Y_OFFSET = 8.0; + + /** The default wall paint. */ + public static final Paint DEFAULT_WALL_PAINT = new Color(0xDD, 0xDD, 0xDD); + + /** The size of x-offset for the 3D effect. */ + private double xOffset; + + /** The size of y-offset for the 3D effect. */ + private double yOffset; + + /** The paint used to shade the left and lower 3D wall. */ + private transient Paint wallPaint; + + /** + * Default constructor, creates a renderer with a default '3D effect'. + */ + public BarRenderer3D() { + this(DEFAULT_X_OFFSET, DEFAULT_Y_OFFSET); + } + + /** + * Constructs a new renderer with the specified '3D effect'. + * + * @param xOffset the x-offset for the 3D effect. + * @param yOffset the y-offset for the 3D effect. + */ + public BarRenderer3D(double xOffset, double yOffset) { + + super(); + this.xOffset = xOffset; + this.yOffset = yOffset; + this.wallPaint = DEFAULT_WALL_PAINT; + // set the default item label positions + ItemLabelPosition p1 = new ItemLabelPosition(ItemLabelAnchor.INSIDE12, + TextAnchor.TOP_CENTER); + setBasePositiveItemLabelPosition(p1); + ItemLabelPosition p2 = new ItemLabelPosition(ItemLabelAnchor.INSIDE12, + TextAnchor.TOP_CENTER); + setBaseNegativeItemLabelPosition(p2); + + } + + /** + * Returns the x-offset for the 3D effect. + * + * @return The 3D effect. + * + * @see #getYOffset() + */ + @Override + public double getXOffset() { + return this.xOffset; + } + + /** + * Returns the y-offset for the 3D effect. + * + * @return The 3D effect. + */ + @Override + public double getYOffset() { + return this.yOffset; + } + + /** + * Returns the paint used to highlight the left and bottom wall in the plot + * background. + * + * @return The paint. + * + * @see #setWallPaint(Paint) + */ + public Paint getWallPaint() { + return this.wallPaint; + } + + /** + * Sets the paint used to hightlight the left and bottom walls in the plot + * background, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getWallPaint() + */ + public void setWallPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.wallPaint = paint; + fireChangeEvent(); + } + + + /** + * Initialises the renderer and returns a state object that will be passed + * to subsequent calls to the drawItem method. This method gets called + * once at the start of the process of drawing a chart. + * + * @param g2 the graphics device. + * @param dataArea the area in which the data is to be plotted. + * @param plot the plot. + * @param rendererIndex the renderer index. + * @param info collects chart rendering information for return to caller. + * + * @return The renderer state. + */ + @Override + public CategoryItemRendererState initialise(Graphics2D g2, + Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, + PlotRenderingInfo info) { + + Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), + dataArea.getY() + getYOffset(), dataArea.getWidth() + - getXOffset(), dataArea.getHeight() - getYOffset()); + CategoryItemRendererState state = super.initialise(g2, adjusted, plot, + rendererIndex, info); + return state; + + } + + /** + * Draws the background for the plot. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param dataArea the area inside the axes. + */ + @Override + public void drawBackground(Graphics2D g2, CategoryPlot plot, + Rectangle2D dataArea) { + + float x0 = (float) dataArea.getX(); + float x1 = x0 + (float) Math.abs(this.xOffset); + float x3 = (float) dataArea.getMaxX(); + float x2 = x3 - (float) Math.abs(this.xOffset); + + float y0 = (float) dataArea.getMaxY(); + float y1 = y0 - (float) Math.abs(this.yOffset); + float y3 = (float) dataArea.getMinY(); + float y2 = y3 + (float) Math.abs(this.yOffset); + + GeneralPath clip = new GeneralPath(); + clip.moveTo(x0, y0); + clip.lineTo(x0, y2); + clip.lineTo(x1, y3); + clip.lineTo(x3, y3); + clip.lineTo(x3, y1); + clip.lineTo(x2, y0); + clip.closePath(); + + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + plot.getBackgroundAlpha())); + + // fill background... + Paint backgroundPaint = plot.getBackgroundPaint(); + if (backgroundPaint != null) { + g2.setPaint(backgroundPaint); + g2.fill(clip); + } + + GeneralPath leftWall = new GeneralPath(); + leftWall.moveTo(x0, y0); + leftWall.lineTo(x0, y2); + leftWall.lineTo(x1, y3); + leftWall.lineTo(x1, y1); + leftWall.closePath(); + g2.setPaint(getWallPaint()); + g2.fill(leftWall); + + GeneralPath bottomWall = new GeneralPath(); + bottomWall.moveTo(x0, y0); + bottomWall.lineTo(x1, y1); + bottomWall.lineTo(x3, y1); + bottomWall.lineTo(x2, y0); + bottomWall.closePath(); + g2.setPaint(getWallPaint()); + g2.fill(bottomWall); + + // highlight the background corners... + g2.setPaint(Color.lightGray); + Line2D corner = new Line2D.Double(x0, y0, x1, y1); + g2.draw(corner); + corner.setLine(x1, y1, x1, y3); + g2.draw(corner); + corner.setLine(x1, y1, x3, y1); + g2.draw(corner); + + // draw background image, if there is one... + Image backgroundImage = plot.getBackgroundImage(); + if (backgroundImage != null) { + Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX() + + getXOffset(), dataArea.getY(), + dataArea.getWidth() - getXOffset(), + dataArea.getHeight() - getYOffset()); + plot.drawBackgroundImage(g2, adjusted); + } + + g2.setComposite(originalComposite); + + } + + /** + * Draws the outline for the plot. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param dataArea the area inside the axes. + */ + @Override + public void drawOutline(Graphics2D g2, CategoryPlot plot, + Rectangle2D dataArea) { + + float x0 = (float) dataArea.getX(); + float x1 = x0 + (float) Math.abs(this.xOffset); + float x3 = (float) dataArea.getMaxX(); + float x2 = x3 - (float) Math.abs(this.xOffset); + + float y0 = (float) dataArea.getMaxY(); + float y1 = y0 - (float) Math.abs(this.yOffset); + float y3 = (float) dataArea.getMinY(); + float y2 = y3 + (float) Math.abs(this.yOffset); + + GeneralPath clip = new GeneralPath(); + clip.moveTo(x0, y0); + clip.lineTo(x0, y2); + clip.lineTo(x1, y3); + clip.lineTo(x3, y3); + clip.lineTo(x3, y1); + clip.lineTo(x2, y0); + clip.closePath(); + + // put an outline around the data area... + Stroke outlineStroke = plot.getOutlineStroke(); + Paint outlinePaint = plot.getOutlinePaint(); + if ((outlineStroke != null) && (outlinePaint != null)) { + g2.setStroke(outlineStroke); + g2.setPaint(outlinePaint); + g2.draw(clip); + } + + } + + /** + * Draws a grid line against the domain axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param dataArea the area for plotting data (not yet adjusted for any + * 3D effect). + * @param value the Java2D value at which the grid line should be drawn. + * + */ + @Override + public void drawDomainGridline(Graphics2D g2, CategoryPlot plot, + Rectangle2D dataArea, double value) { + + Line2D line1 = null; + Line2D line2 = null; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + double y0 = value; + double y1 = value - getYOffset(); + double x0 = dataArea.getMinX(); + double x1 = x0 + getXOffset(); + double x2 = dataArea.getMaxX(); + line1 = new Line2D.Double(x0, y0, x1, y1); + line2 = new Line2D.Double(x1, y1, x2, y1); + } + else if (orientation == PlotOrientation.VERTICAL) { + double x0 = value; + double x1 = value + getXOffset(); + double y0 = dataArea.getMaxY(); + double y1 = y0 - getYOffset(); + double y2 = dataArea.getMinY(); + line1 = new Line2D.Double(x0, y0, x1, y1); + line2 = new Line2D.Double(x1, y1, x1, y2); + } + Paint paint = plot.getDomainGridlinePaint(); + Stroke stroke = plot.getDomainGridlineStroke(); + g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT); + g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE); + g2.draw(line1); + g2.draw(line2); + + } + + /** + * Draws a grid line against the range axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param dataArea the area for plotting data (not yet adjusted for any + * 3D effect). + * @param value the value at which the grid line should be drawn. + * + */ + @Override + public void drawRangeGridline(Graphics2D g2, CategoryPlot plot, + ValueAxis axis, Rectangle2D dataArea, double value) { + + Range range = axis.getRange(); + + if (!range.contains(value)) { + return; + } + + Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), + dataArea.getY() + getYOffset(), dataArea.getWidth() + - getXOffset(), dataArea.getHeight() - getYOffset()); + + Line2D line1 = null; + Line2D line2 = null; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + double x0 = axis.valueToJava2D(value, adjusted, + plot.getRangeAxisEdge()); + double x1 = x0 + getXOffset(); + double y0 = dataArea.getMaxY(); + double y1 = y0 - getYOffset(); + double y2 = dataArea.getMinY(); + line1 = new Line2D.Double(x0, y0, x1, y1); + line2 = new Line2D.Double(x1, y1, x1, y2); + } + else if (orientation == PlotOrientation.VERTICAL) { + double y0 = axis.valueToJava2D(value, adjusted, + plot.getRangeAxisEdge()); + double y1 = y0 - getYOffset(); + double x0 = dataArea.getMinX(); + double x1 = x0 + getXOffset(); + double x2 = dataArea.getMaxX(); + line1 = new Line2D.Double(x0, y0, x1, y1); + line2 = new Line2D.Double(x1, y1, x2, y1); + } + Paint paint = plot.getRangeGridlinePaint(); + Stroke stroke = plot.getRangeGridlineStroke(); + g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT); + g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE); + g2.draw(line1); + g2.draw(line2); + + } + + /** + * Draws a line perpendicular to the range axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param dataArea the area for plotting data (not yet adjusted for any 3D + * effect). + * @param value the value at which the grid line should be drawn. + * @param paint the paint. + * @param stroke the stroke. + * + * @see #drawRangeGridline + * + * @since 1.0.13 + */ + @Override + public void drawRangeLine(Graphics2D g2, CategoryPlot plot, ValueAxis axis, + Rectangle2D dataArea, double value, Paint paint, Stroke stroke) { + + Range range = axis.getRange(); + if (!range.contains(value)) { + return; + } + + Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), + dataArea.getY() + getYOffset(), dataArea.getWidth() + - getXOffset(), dataArea.getHeight() - getYOffset()); + + Line2D line1 = null; + Line2D line2 = null; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + double x0 = axis.valueToJava2D(value, adjusted, + plot.getRangeAxisEdge()); + double x1 = x0 + getXOffset(); + double y0 = dataArea.getMaxY(); + double y1 = y0 - getYOffset(); + double y2 = dataArea.getMinY(); + line1 = new Line2D.Double(x0, y0, x1, y1); + line2 = new Line2D.Double(x1, y1, x1, y2); + } + else if (orientation == PlotOrientation.VERTICAL) { + double y0 = axis.valueToJava2D(value, adjusted, + plot.getRangeAxisEdge()); + double y1 = y0 - getYOffset(); + double x0 = dataArea.getMinX(); + double x1 = x0 + getXOffset(); + double x2 = dataArea.getMaxX(); + line1 = new Line2D.Double(x0, y0, x1, y1); + line2 = new Line2D.Double(x1, y1, x2, y1); + } + g2.setPaint(paint); + g2.setStroke(stroke); + g2.draw(line1); + g2.draw(line2); + + } + + /** + * Draws a range marker. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param marker the marker. + * @param dataArea the area for plotting data (not including 3D effect). + */ + @Override + public void drawRangeMarker(Graphics2D g2, CategoryPlot plot, + ValueAxis axis, Marker marker, Rectangle2D dataArea) { + + + Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), + dataArea.getY() + getYOffset(), dataArea.getWidth() + - getXOffset(), dataArea.getHeight() - getYOffset()); + if (marker instanceof ValueMarker) { + ValueMarker vm = (ValueMarker) marker; + double value = vm.getValue(); + Range range = axis.getRange(); + if (!range.contains(value)) { + return; + } + + GeneralPath path = null; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + float x = (float) axis.valueToJava2D(value, adjusted, + plot.getRangeAxisEdge()); + float y = (float) adjusted.getMaxY(); + path = new GeneralPath(); + path.moveTo(x, y); + path.lineTo((float) (x + getXOffset()), + y - (float) getYOffset()); + path.lineTo((float) (x + getXOffset()), + (float) (adjusted.getMinY() - getYOffset())); + path.lineTo(x, (float) adjusted.getMinY()); + path.closePath(); + } + else if (orientation == PlotOrientation.VERTICAL) { + float y = (float) axis.valueToJava2D(value, adjusted, + plot.getRangeAxisEdge()); + float x = (float) dataArea.getX(); + path = new GeneralPath(); + path.moveTo(x, y); + path.lineTo(x + (float) this.xOffset, y - (float) this.yOffset); + path.lineTo((float) (adjusted.getMaxX() + this.xOffset), + y - (float) this.yOffset); + path.lineTo((float) (adjusted.getMaxX()), y); + path.closePath(); + } else { + throw new IllegalStateException(); + } + g2.setPaint(marker.getPaint()); + g2.fill(path); + g2.setPaint(marker.getOutlinePaint()); + g2.draw(path); + + String label = marker.getLabel(); + RectangleAnchor anchor = marker.getLabelAnchor(); + if (label != null) { + Font labelFont = marker.getLabelFont(); + g2.setFont(labelFont); + g2.setPaint(marker.getLabelPaint()); + Point2D coordinates = calculateRangeMarkerTextAnchorPoint( + g2, orientation, dataArea, path.getBounds2D(), + marker.getLabelOffset(), LengthAdjustmentType.EXPAND, + anchor); + TextUtilities.drawAlignedString(label, g2, + (float) coordinates.getX(), (float) coordinates.getY(), + marker.getLabelTextAnchor()); + } + + } + else { + super.drawRangeMarker(g2, plot, axis, marker, adjusted); + // TODO: draw the interval marker with a 3D effect + } + } + + /** + * Draws a 3D bar to represent one data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area for plotting the data. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, + int pass) { + + // check the value we are plotting... + Number dataValue = dataset.getValue(row, column); + if (dataValue == null) { + return; + } + + double value = dataValue.doubleValue(); + + Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), + dataArea.getY() + getYOffset(), + dataArea.getWidth() - getXOffset(), + dataArea.getHeight() - getYOffset()); + + PlotOrientation orientation = plot.getOrientation(); + + double barW0 = calculateBarW0(plot, orientation, adjusted, domainAxis, + state, row, column); + double[] barL0L1 = calculateBarL0L1(value); + if (barL0L1 == null) { + return; // the bar is not visible + } + + RectangleEdge edge = plot.getRangeAxisEdge(); + double transL0 = rangeAxis.valueToJava2D(barL0L1[0], adjusted, edge); + double transL1 = rangeAxis.valueToJava2D(barL0L1[1], adjusted, edge); + double barL0 = Math.min(transL0, transL1); + double barLength = Math.abs(transL1 - transL0); + + // draw the bar... + Rectangle2D bar; + if (orientation == PlotOrientation.HORIZONTAL) { + bar = new Rectangle2D.Double(barL0, barW0, barLength, + state.getBarWidth()); + } + else { + bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(), + barLength); + } + Paint itemPaint = getItemPaint(row, column); + g2.setPaint(itemPaint); + g2.fill(bar); + + double x0 = bar.getMinX(); + double x1 = x0 + getXOffset(); + double x2 = bar.getMaxX(); + double x3 = x2 + getXOffset(); + + double y0 = bar.getMinY() - getYOffset(); + double y1 = bar.getMinY(); + double y2 = bar.getMaxY() - getYOffset(); + double y3 = bar.getMaxY(); + + GeneralPath bar3dRight = null; + GeneralPath bar3dTop; + if (barLength > 0.0) { + bar3dRight = new GeneralPath(); + bar3dRight.moveTo((float) x2, (float) y3); + bar3dRight.lineTo((float) x2, (float) y1); + bar3dRight.lineTo((float) x3, (float) y0); + bar3dRight.lineTo((float) x3, (float) y2); + bar3dRight.closePath(); + + g2.setPaint(PaintAlpha.darker(itemPaint)); + g2.fill(bar3dRight); + } + + bar3dTop = new GeneralPath(); + bar3dTop.moveTo((float) x0, (float) y1); + bar3dTop.lineTo((float) x1, (float) y0); + bar3dTop.lineTo((float) x3, (float) y0); + bar3dTop.lineTo((float) x2, (float) y1); + bar3dTop.closePath(); + g2.fill(bar3dTop); + + if (isDrawBarOutline() + && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { + g2.setStroke(getItemOutlineStroke(row, column)); + g2.setPaint(getItemOutlinePaint(row, column)); + g2.draw(bar); + if (bar3dRight != null) { + g2.draw(bar3dRight); + } + g2.draw(bar3dTop); + } + + CategoryItemLabelGenerator generator + = getItemLabelGenerator(row, column); + if (generator != null && isItemLabelVisible(row, column)) { + drawItemLabel(g2, dataset, row, column, plot, generator, bar, + (value < 0.0)); + } + + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + GeneralPath barOutline = new GeneralPath(); + barOutline.moveTo((float) x0, (float) y3); + barOutline.lineTo((float) x0, (float) y1); + barOutline.lineTo((float) x1, (float) y0); + barOutline.lineTo((float) x3, (float) y0); + barOutline.lineTo((float) x3, (float) y2); + barOutline.lineTo((float) x2, (float) y3); + barOutline.closePath(); + addItemEntity(entities, dataset, row, column, barOutline); + } + + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof BarRenderer3D)) { + return false; + } + BarRenderer3D that = (BarRenderer3D) obj; + if (this.xOffset != that.xOffset) { + return false; + } + if (this.yOffset != that.yOffset) { + return false; + } + if (!PaintUtilities.equal(this.wallPaint, that.wallPaint)) { + return false; + } + return super.equals(obj); + } + + /** + * 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.wallPaint, 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.wallPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java new file mode 100755 index 0000000..90b19b6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/BoxAndWhiskerRenderer.java @@ -0,0 +1,1116 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * BoxAndWhiskerRenderer.java + * -------------------------- + * (C) Copyright 2003-2013, by David Browning and Contributors. + * + * Original Author: David Browning (for the Australian Institute of Marine + * Science); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Tim Bardzil; + * Rob Van der Sanden (patches 1866446 and 1888422); + * Peter Becker (patches 2868585 and 2868608); + * Martin Krauskopf (patch 3421088); + * Martin Hoeller; + * + * Changes + * ------- + * 21-Aug-2003 : Version 1, contributed by David Browning (for the Australian + * Institute of Marine Science); + * 01-Sep-2003 : Incorporated outlier and farout symbols for low values + * also (DG); + * 08-Sep-2003 : Changed ValueAxis API (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 07-Oct-2003 : Added renderer state (DG); + * 12-Nov-2003 : Fixed casting bug reported by Tim Bardzil (DG); + * 13-Nov-2003 : Added drawHorizontalItem() method contributed by Tim + * Bardzil (DG); + * 25-Apr-2004 : Added fillBox attribute, equals() method and added + * serialization code (DG); + * 29-Apr-2004 : Changed drawing of upper and lower shadows - see bug report + * 944011 (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 09-Mar-2005 : Override getLegendItem() method so that legend item shapes + * are shown as blocks (DG); + * 20-Apr-2005 : Generate legend labels, tooltips and URLs (DG); + * 09-Jun-2005 : Updated equals() to handle GradientPaint (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 12-Oct-2006 : Source reformatting and API doc updates (DG); + * 12-Oct-2006 : Fixed bug 1572478, potential NullPointerException (DG); + * 05-Feb-2006 : Added event notifications to a couple of methods (DG); + * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); + * 11-May-2007 : Added check for visibility in getLegendItem() (DG); + * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); + * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); + * 03-Jan-2008 : Check visibility of average marker before drawing it (DG); + * 15-Jan-2008 : Add getMaximumBarWidth() and setMaximumBarWidth() + * methods (RVdS); + * 14-Feb-2008 : Fix bar position for horizontal chart, see patch + * 1888422 (RVdS); + * 27-Mar-2008 : Boxes should use outlinePaint/Stroke settings (DG); + * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * 02-Oct-2008 : Check item visibility in drawItem() method (DG); + * 21-Jan-2009 : Added flags to control visibility of mean and median + * indicators (DG); + * 28-Sep-2009 : Added fireChangeEvent() to setMedianVisible (DG); + * 28-Sep-2009 : Added useOutlinePaintForWhiskers flag, see patch 2868585 + * by Peter Becker (DG); + * 28-Sep-2009 : Added whiskerWidth attribute, see patch 2868608 by Peter + * Becker (DG); + * 11-Oct-2011 : applied patch #3421088 from Martin Krauskopf to fix bug (MH); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Line2D; +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 java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.renderer.Outlier; +import org.jfree.chart.renderer.OutlierList; +import org.jfree.chart.renderer.OutlierListCollection; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.statistics.BoxAndWhiskerCategoryDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A box-and-whisker renderer. This renderer requires a + * {@link BoxAndWhiskerCategoryDataset} and is for use with the + * {@link CategoryPlot} class. The example shown here is generated + * by the BoxAndWhiskerChartDemo1.java program included in the + * JFreeChart Demo Collection: + *

+ * BoxAndWhiskerRendererSample.png + */ +public class BoxAndWhiskerRenderer extends AbstractCategoryItemRenderer + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 632027470694481177L; + + /** The color used to paint the median line and average marker. */ + private transient Paint artifactPaint; + + /** A flag that controls whether or not the box is filled. */ + private boolean fillBox; + + /** The margin between items (boxes) within a category. */ + private double itemMargin; + + /** + * The maximum bar width as percentage of the available space in the plot. + * Take care with the encoding - for example, 0.05 is five percent. + */ + private double maximumBarWidth; + + /** + * A flag that controls whether or not the median indicator is drawn. + * + * @since 1.0.13 + */ + private boolean medianVisible; + + /** + * A flag that controls whether or not the mean indicator is drawn. + * + * @since 1.0.13 + */ + private boolean meanVisible; + + /** + * A flag that, if true, causes the whiskers to be drawn + * using the outline paint for the series. The default value is + * false and in that case the regular series paint is used. + * + * @since 1.0.14 + */ + private boolean useOutlinePaintForWhiskers; + + /** + * The width of the whiskers as fraction of the bar width. + * + * @since 1.0.14 + */ + private double whiskerWidth; + + /** + * Default constructor. + */ + public BoxAndWhiskerRenderer() { + this.artifactPaint = Color.black; + this.fillBox = true; + this.itemMargin = 0.20; + this.maximumBarWidth = 1.0; + this.medianVisible = true; + this.meanVisible = true; + this.useOutlinePaintForWhiskers = false; + this.whiskerWidth = 1.0; + setBaseLegendShape(new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0)); + } + + /** + * Returns the paint used to color the median and average markers. + * + * @return The paint used to draw the median and average markers (never + * null). + * + * @see #setArtifactPaint(Paint) + */ + public Paint getArtifactPaint() { + return this.artifactPaint; + } + + /** + * Sets the paint used to color the median and average markers and sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getArtifactPaint() + */ + public void setArtifactPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.artifactPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not the box is filled. + * + * @return A boolean. + * + * @see #setFillBox(boolean) + */ + public boolean getFillBox() { + return this.fillBox; + } + + /** + * Sets the flag that controls whether or not the box is filled and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param flag the flag. + * + * @see #getFillBox() + */ + public void setFillBox(boolean flag) { + this.fillBox = flag; + fireChangeEvent(); + } + + /** + * Returns the item margin. This is a percentage of the available space + * that is allocated to the space between items in the chart. + * + * @return The margin. + * + * @see #setItemMargin(double) + */ + public double getItemMargin() { + return this.itemMargin; + } + + /** + * Sets the item margin and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param margin the margin (a percentage). + * + * @see #getItemMargin() + */ + public void setItemMargin(double margin) { + this.itemMargin = margin; + fireChangeEvent(); + } + + /** + * Returns the maximum bar width as a percentage of the available drawing + * space. Take care with the encoding, for example 0.10 is ten percent. + * + * @return The maximum bar width. + * + * @see #setMaximumBarWidth(double) + * + * @since 1.0.10 + */ + public double getMaximumBarWidth() { + return this.maximumBarWidth; + } + + /** + * Sets the maximum bar width, which is specified as a percentage of the + * available space for all bars, and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param percent the maximum bar width (a percentage, where 0.10 is ten + * percent). + * + * @see #getMaximumBarWidth() + * + * @since 1.0.10 + */ + public void setMaximumBarWidth(double percent) { + this.maximumBarWidth = percent; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not the mean indicator is + * draw for each item. + * + * @return A boolean. + * + * @see #setMeanVisible(boolean) + * + * @since 1.0.13 + */ + public boolean isMeanVisible() { + return this.meanVisible; + } + + /** + * Sets the flag that controls whether or not the mean indicator is drawn + * for each item, and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param visible the new flag value. + * + * @see #isMeanVisible() + * + * @since 1.0.13 + */ + public void setMeanVisible(boolean visible) { + if (this.meanVisible == visible) { + return; + } + this.meanVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not the median indicator is + * draw for each item. + * + * @return A boolean. + * + * @see #setMedianVisible(boolean) + * + * @since 1.0.13 + */ + public boolean isMedianVisible() { + return this.medianVisible; + } + + /** + * Sets the flag that controls whether or not the median indicator is drawn + * for each item, and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param visible the new flag value. + * + * @see #isMedianVisible() + * + * @since 1.0.13 + */ + public void setMedianVisible(boolean visible) { + if (this.medianVisible == visible) { + return; + } + this.medianVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the flag that, if true, causes the whiskers to + * be drawn using the series outline paint. + * + * @return A boolean. + * + * @since 1.0.14 + */ + public boolean getUseOutlinePaintForWhiskers() { + return this.useOutlinePaintForWhiskers; + } + + /** + * Sets the flag that, if true, causes the whiskers to + * be drawn using the series outline paint, and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param flag the new flag value. + * + * @since 1.0.14 + */ + public void setUseOutlinePaintForWhiskers(boolean flag) { + if (this.useOutlinePaintForWhiskers == flag) { + return; + } + this.useOutlinePaintForWhiskers = flag; + fireChangeEvent(); + } + + /** + * Returns the width of the whiskers as fraction of the bar width. + * + * @return The width of the whiskers. + * + * @see #setWhiskerWidth(double) + * + * @since 1.0.14 + */ + public double getWhiskerWidth() { + return this.whiskerWidth; + } + + /** + * Sets the width of the whiskers as a fraction of the bar width and sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param width a value between 0 and 1 indicating how wide the + * whisker is supposed to be compared to the bar. + * @see #getWhiskerWidth() + * @see CategoryItemRendererState#getBarWidth() + * + * @since 1.0.14 + */ + public void setWhiskerWidth(double width) { + if (width < 0 || width > 1) { + throw new IllegalArgumentException( + "Value for whisker width out of range"); + } + if (width == this.whiskerWidth) { + return; + } + this.whiskerWidth = width; + fireChangeEvent(); + } + + /** + * Returns a legend item for a series. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return The legend item (possibly null). + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + + CategoryPlot cp = getPlot(); + if (cp == null) { + return null; + } + + // check that a legend item needs to be displayed... + if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { + return null; + } + + CategoryDataset dataset = cp.getDataset(datasetIndex); + String label = getLegendItemLabelGenerator().generateLabel(dataset, + series); + String description = label; + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel(dataset, + series); + } + Shape shape = lookupLegendShape(series); + Paint paint = lookupSeriesPaint(series); + Paint outlinePaint = lookupSeriesOutlinePaint(series); + Stroke outlineStroke = lookupSeriesOutlineStroke(series); + LegendItem result = new LegendItem(label, description, toolTipText, + urlText, shape, paint, outlineStroke, outlinePaint); + result.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + result.setLabelPaint(labelPaint); + } + result.setDataset(dataset); + result.setDatasetIndex(datasetIndex); + result.setSeriesKey(dataset.getRowKey(series)); + result.setSeriesIndex(series); + return result; + + } + + /** + * Returns the range of values from the specified dataset that the + * renderer will require to display all the data. + * + * @param dataset the dataset. + * + * @return The range. + */ + @Override + public Range findRangeBounds(CategoryDataset dataset) { + return super.findRangeBounds(dataset, true); + } + + /** + * Initialises the renderer. This method gets called once at the start of + * the process of drawing a chart. + * + * @param g2 the graphics device. + * @param dataArea the area in which the data is to be plotted. + * @param plot the plot. + * @param rendererIndex the renderer index. + * @param info collects chart rendering information for return to caller. + * + * @return The renderer state. + */ + @Override + public CategoryItemRendererState initialise(Graphics2D g2, + Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, + PlotRenderingInfo info) { + + CategoryItemRendererState state = super.initialise(g2, dataArea, plot, + rendererIndex, info); + // calculate the box width + CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); + CategoryDataset dataset = plot.getDataset(rendererIndex); + if (dataset != null) { + int columns = dataset.getColumnCount(); + int rows = dataset.getRowCount(); + double space = 0.0; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + space = dataArea.getHeight(); + } + else if (orientation == PlotOrientation.VERTICAL) { + space = dataArea.getWidth(); + } + double maxWidth = space * getMaximumBarWidth(); + double categoryMargin = 0.0; + double currentItemMargin = 0.0; + if (columns > 1) { + categoryMargin = domainAxis.getCategoryMargin(); + } + if (rows > 1) { + currentItemMargin = getItemMargin(); + } + double used = space * (1 - domainAxis.getLowerMargin() + - domainAxis.getUpperMargin() + - categoryMargin - currentItemMargin); + if ((rows * columns) > 0) { + state.setBarWidth(Math.min(used / (dataset.getColumnCount() + * dataset.getRowCount()), maxWidth)); + } + else { + state.setBarWidth(Math.min(used, maxWidth)); + } + } + return state; + + } + + /** + * Draw a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area in which the data is drawn. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the data (must be an instance of + * {@link BoxAndWhiskerCategoryDataset}). + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, + int pass) { + + // do nothing if item is not visible + if (!getItemVisible(row, column)) { + return; + } + + if (!(dataset instanceof BoxAndWhiskerCategoryDataset)) { + throw new IllegalArgumentException( + "BoxAndWhiskerRenderer.drawItem() : the data should be " + + "of type BoxAndWhiskerCategoryDataset only."); + } + + PlotOrientation orientation = plot.getOrientation(); + + if (orientation == PlotOrientation.HORIZONTAL) { + drawHorizontalItem(g2, state, dataArea, plot, domainAxis, + rangeAxis, dataset, row, column); + } + else if (orientation == PlotOrientation.VERTICAL) { + drawVerticalItem(g2, state, dataArea, plot, domainAxis, + rangeAxis, dataset, row, column); + } + + } + + /** + * Draws the visual representation of a single data item when the plot has + * a horizontal orientation. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the plot 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 (must be an instance of + * {@link BoxAndWhiskerCategoryDataset}). + * @param row the row index (zero-based). + * @param column the column index (zero-based). + */ + public void drawHorizontalItem(Graphics2D g2, + CategoryItemRendererState state, Rectangle2D dataArea, + CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, + CategoryDataset dataset, int row, int column) { + + BoxAndWhiskerCategoryDataset bawDataset + = (BoxAndWhiskerCategoryDataset) dataset; + + double categoryEnd = domainAxis.getCategoryEnd(column, + getColumnCount(), dataArea, plot.getDomainAxisEdge()); + double categoryStart = domainAxis.getCategoryStart(column, + getColumnCount(), dataArea, plot.getDomainAxisEdge()); + double categoryWidth = Math.abs(categoryEnd - categoryStart); + + double yy = categoryStart; + int seriesCount = getRowCount(); + int categoryCount = getColumnCount(); + + if (seriesCount > 1) { + double seriesGap = dataArea.getHeight() * getItemMargin() + / (categoryCount * (seriesCount - 1)); + double usedWidth = (state.getBarWidth() * seriesCount) + + (seriesGap * (seriesCount - 1)); + // offset the start of the boxes if the total width used is smaller + // than the category width + double offset = (categoryWidth - usedWidth) / 2; + yy = yy + offset + (row * (state.getBarWidth() + seriesGap)); + } + else { + // offset the start of the box if the box width is smaller than + // the category width + double offset = (categoryWidth - state.getBarWidth()) / 2; + yy = yy + offset; + } + + g2.setPaint(getItemPaint(row, column)); + Stroke s = getItemStroke(row, column); + g2.setStroke(s); + + RectangleEdge location = plot.getRangeAxisEdge(); + + Number xQ1 = bawDataset.getQ1Value(row, column); + Number xQ3 = bawDataset.getQ3Value(row, column); + Number xMax = bawDataset.getMaxRegularValue(row, column); + Number xMin = bawDataset.getMinRegularValue(row, column); + + Shape box = null; + if (xQ1 != null && xQ3 != null && xMax != null && xMin != null) { + + double xxQ1 = rangeAxis.valueToJava2D(xQ1.doubleValue(), dataArea, + location); + double xxQ3 = rangeAxis.valueToJava2D(xQ3.doubleValue(), dataArea, + location); + double xxMax = rangeAxis.valueToJava2D(xMax.doubleValue(), dataArea, + location); + double xxMin = rangeAxis.valueToJava2D(xMin.doubleValue(), dataArea, + location); + double yymid = yy + state.getBarWidth() / 2.0; + double halfW = (state.getBarWidth() / 2.0) * this.whiskerWidth; + + // draw the box... + box = new Rectangle2D.Double(Math.min(xxQ1, xxQ3), yy, + Math.abs(xxQ1 - xxQ3), state.getBarWidth()); + if (this.fillBox) { + g2.fill(box); + } + + Paint outlinePaint = getItemOutlinePaint(row, column); + if (this.useOutlinePaintForWhiskers) { + g2.setPaint(outlinePaint); + } + // draw the upper shadow... + g2.draw(new Line2D.Double(xxMax, yymid, xxQ3, yymid)); + g2.draw(new Line2D.Double(xxMax, yymid - halfW, xxMax, + yymid + halfW)); + + // draw the lower shadow... + g2.draw(new Line2D.Double(xxMin, yymid, xxQ1, yymid)); + g2.draw(new Line2D.Double(xxMin, yymid - halfW, xxMin, + yy + halfW)); + + g2.setStroke(getItemOutlineStroke(row, column)); + g2.setPaint(outlinePaint); + g2.draw(box); + } + + // draw mean - SPECIAL AIMS REQUIREMENT... + g2.setPaint(this.artifactPaint); + double aRadius; // average radius + if (this.meanVisible) { + Number xMean = bawDataset.getMeanValue(row, column); + if (xMean != null) { + double xxMean = rangeAxis.valueToJava2D(xMean.doubleValue(), + dataArea, location); + aRadius = state.getBarWidth() / 4; + // here we check that the average marker will in fact be + // visible before drawing it... + if ((xxMean > (dataArea.getMinX() - aRadius)) + && (xxMean < (dataArea.getMaxX() + aRadius))) { + Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xxMean + - aRadius, yy + aRadius, aRadius * 2, aRadius * 2); + g2.fill(avgEllipse); + g2.draw(avgEllipse); + } + } + } + + // draw median... + if (this.medianVisible) { + Number xMedian = bawDataset.getMedianValue(row, column); + if (xMedian != null) { + double xxMedian = rangeAxis.valueToJava2D(xMedian.doubleValue(), + dataArea, location); + g2.draw(new Line2D.Double(xxMedian, yy, xxMedian, + yy + state.getBarWidth())); + } + } + + // collect entity and tool tip information... + if (state.getInfo() != null && box != null) { + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, box); + } + } + + } + + /** + * Draws the visual representation of a single data item when the plot has + * a vertical orientation. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the plot 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 (must be an instance of + * {@link BoxAndWhiskerCategoryDataset}). + * @param row the row index (zero-based). + * @param column the column index (zero-based). + */ + public void drawVerticalItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, int column) { + + BoxAndWhiskerCategoryDataset bawDataset + = (BoxAndWhiskerCategoryDataset) dataset; + + double categoryEnd = domainAxis.getCategoryEnd(column, + getColumnCount(), dataArea, plot.getDomainAxisEdge()); + double categoryStart = domainAxis.getCategoryStart(column, + getColumnCount(), dataArea, plot.getDomainAxisEdge()); + double categoryWidth = categoryEnd - categoryStart; + + double xx = categoryStart; + int seriesCount = getRowCount(); + int categoryCount = getColumnCount(); + + if (seriesCount > 1) { + double seriesGap = dataArea.getWidth() * getItemMargin() + / (categoryCount * (seriesCount - 1)); + double usedWidth = (state.getBarWidth() * seriesCount) + + (seriesGap * (seriesCount - 1)); + // offset the start of the boxes if the total width used is smaller + // than the category width + double offset = (categoryWidth - usedWidth) / 2; + xx = xx + offset + (row * (state.getBarWidth() + seriesGap)); + } + else { + // offset the start of the box if the box width is smaller than the + // category width + double offset = (categoryWidth - state.getBarWidth()) / 2; + xx = xx + offset; + } + + double yyAverage; + double yyOutlier; + + Paint itemPaint = getItemPaint(row, column); + g2.setPaint(itemPaint); + Stroke s = getItemStroke(row, column); + g2.setStroke(s); + + double aRadius = 0; // average radius + + RectangleEdge location = plot.getRangeAxisEdge(); + + Number yQ1 = bawDataset.getQ1Value(row, column); + Number yQ3 = bawDataset.getQ3Value(row, column); + Number yMax = bawDataset.getMaxRegularValue(row, column); + Number yMin = bawDataset.getMinRegularValue(row, column); + Shape box = null; + if (yQ1 != null && yQ3 != null && yMax != null && yMin != null) { + + double yyQ1 = rangeAxis.valueToJava2D(yQ1.doubleValue(), dataArea, + location); + double yyQ3 = rangeAxis.valueToJava2D(yQ3.doubleValue(), dataArea, + location); + double yyMax = rangeAxis.valueToJava2D(yMax.doubleValue(), + dataArea, location); + double yyMin = rangeAxis.valueToJava2D(yMin.doubleValue(), + dataArea, location); + double xxmid = xx + state.getBarWidth() / 2.0; + double halfW = (state.getBarWidth() / 2.0) * this.whiskerWidth; + + // draw the body... + box = new Rectangle2D.Double(xx, Math.min(yyQ1, yyQ3), + state.getBarWidth(), Math.abs(yyQ1 - yyQ3)); + if (this.fillBox) { + g2.fill(box); + } + + Paint outlinePaint = getItemOutlinePaint(row, column); + if (this.useOutlinePaintForWhiskers) { + g2.setPaint(outlinePaint); + } + // draw the upper shadow... + g2.draw(new Line2D.Double(xxmid, yyMax, xxmid, yyQ3)); + g2.draw(new Line2D.Double(xxmid - halfW, yyMax, xxmid + halfW, yyMax)); + + // draw the lower shadow... + g2.draw(new Line2D.Double(xxmid, yyMin, xxmid, yyQ1)); + g2.draw(new Line2D.Double(xxmid - halfW, yyMin, xxmid + halfW, yyMin)); + + g2.setStroke(getItemOutlineStroke(row, column)); + g2.setPaint(outlinePaint); + g2.draw(box); + } + + g2.setPaint(this.artifactPaint); + + // draw mean - SPECIAL AIMS REQUIREMENT... + if (this.meanVisible) { + Number yMean = bawDataset.getMeanValue(row, column); + if (yMean != null) { + yyAverage = rangeAxis.valueToJava2D(yMean.doubleValue(), + dataArea, location); + aRadius = state.getBarWidth() / 4; + // here we check that the average marker will in fact be + // visible before drawing it... + if ((yyAverage > (dataArea.getMinY() - aRadius)) + && (yyAverage < (dataArea.getMaxY() + aRadius))) { + Ellipse2D.Double avgEllipse = new Ellipse2D.Double( + xx + aRadius, yyAverage - aRadius, aRadius * 2, + aRadius * 2); + g2.fill(avgEllipse); + g2.draw(avgEllipse); + } + } + } + + // draw median... + if (this.medianVisible) { + Number yMedian = bawDataset.getMedianValue(row, column); + if (yMedian != null) { + double yyMedian = rangeAxis.valueToJava2D( + yMedian.doubleValue(), dataArea, location); + g2.draw(new Line2D.Double(xx, yyMedian, + xx + state.getBarWidth(), yyMedian)); + } + } + + // draw yOutliers... + double maxAxisValue = rangeAxis.valueToJava2D( + rangeAxis.getUpperBound(), dataArea, location) + aRadius; + double minAxisValue = rangeAxis.valueToJava2D( + rangeAxis.getLowerBound(), dataArea, location) - aRadius; + + g2.setPaint(itemPaint); + + // draw outliers + double oRadius = state.getBarWidth() / 3; // outlier radius + List outliers = new ArrayList(); + OutlierListCollection outlierListCollection + = new OutlierListCollection(); + + // From outlier array sort out which are outliers and put these into a + // list If there are any farouts, set the flag on the + // OutlierListCollection + List yOutliers = bawDataset.getOutliers(row, column); + if (yOutliers != null) { + for (int i = 0; i < yOutliers.size(); i++) { + double outlier = ((Number) yOutliers.get(i)).doubleValue(); + Number minOutlier = bawDataset.getMinOutlier(row, column); + Number maxOutlier = bawDataset.getMaxOutlier(row, column); + Number minRegular = bawDataset.getMinRegularValue(row, column); + Number maxRegular = bawDataset.getMaxRegularValue(row, column); + if (outlier > maxOutlier.doubleValue()) { + outlierListCollection.setHighFarOut(true); + } + else if (outlier < minOutlier.doubleValue()) { + outlierListCollection.setLowFarOut(true); + } + else if (outlier > maxRegular.doubleValue()) { + yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, + location); + outliers.add(new Outlier(xx + state.getBarWidth() / 2.0, + yyOutlier, oRadius)); + } + else if (outlier < minRegular.doubleValue()) { + yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, + location); + outliers.add(new Outlier(xx + state.getBarWidth() / 2.0, + yyOutlier, oRadius)); + } + Collections.sort(outliers); + } + + // Process outliers. Each outlier is either added to the + // appropriate outlier list or a new outlier list is made + for (Iterator iterator = outliers.iterator(); iterator.hasNext();) { + Outlier outlier = (Outlier) iterator.next(); + outlierListCollection.add(outlier); + } + + for (Iterator iterator = outlierListCollection.iterator(); + iterator.hasNext();) { + OutlierList list = (OutlierList) iterator.next(); + Outlier outlier = list.getAveragedOutlier(); + Point2D point = outlier.getPoint(); + + if (list.isMultiple()) { + drawMultipleEllipse(point, state.getBarWidth(), oRadius, + g2); + } + else { + drawEllipse(point, oRadius, g2); + } + } + + // draw farout indicators + if (outlierListCollection.isHighFarOut()) { + drawHighFarOut(aRadius / 2.0, g2, + xx + state.getBarWidth() / 2.0, maxAxisValue); + } + + if (outlierListCollection.isLowFarOut()) { + drawLowFarOut(aRadius / 2.0, g2, + xx + state.getBarWidth() / 2.0, minAxisValue); + } + } + // collect entity and tool tip information... + if (state.getInfo() != null && box != null) { + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, box); + } + } + + } + + /** + * Draws a dot to represent an outlier. + * + * @param point the location. + * @param oRadius the radius. + * @param g2 the graphics device. + */ + private void drawEllipse(Point2D point, double oRadius, Graphics2D g2) { + Ellipse2D dot = new Ellipse2D.Double(point.getX() + oRadius / 2, + point.getY(), oRadius, oRadius); + g2.draw(dot); + } + + /** + * Draws two dots to represent the average value of more than one outlier. + * + * @param point the location + * @param boxWidth the box width. + * @param oRadius the radius. + * @param g2 the graphics device. + */ + private void drawMultipleEllipse(Point2D point, double boxWidth, + double oRadius, Graphics2D g2) { + + Ellipse2D dot1 = new Ellipse2D.Double(point.getX() - (boxWidth / 2) + + oRadius, point.getY(), oRadius, oRadius); + Ellipse2D dot2 = new Ellipse2D.Double(point.getX() + (boxWidth / 2), + point.getY(), oRadius, oRadius); + g2.draw(dot1); + g2.draw(dot2); + } + + /** + * Draws a triangle to indicate the presence of far-out values. + * + * @param aRadius the radius. + * @param g2 the graphics device. + * @param xx the x coordinate. + * @param m the y coordinate. + */ + private void drawHighFarOut(double aRadius, Graphics2D g2, double xx, + double m) { + double side = aRadius * 2; + g2.draw(new Line2D.Double(xx - side, m + side, xx + side, m + side)); + g2.draw(new Line2D.Double(xx - side, m + side, xx, m)); + g2.draw(new Line2D.Double(xx + side, m + side, xx, m)); + } + + /** + * Draws a triangle to indicate the presence of far-out values. + * + * @param aRadius the radius. + * @param g2 the graphics device. + * @param xx the x coordinate. + * @param m the y coordinate. + */ + private void drawLowFarOut(double aRadius, Graphics2D g2, double xx, + double m) { + double side = aRadius * 2; + g2.draw(new Line2D.Double(xx - side, m - side, xx + side, m - side)); + g2.draw(new Line2D.Double(xx - side, m - side, xx, m)); + g2.draw(new Line2D.Double(xx + side, m - side, xx, m)); + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof BoxAndWhiskerRenderer)) { + return false; + } + BoxAndWhiskerRenderer that = (BoxAndWhiskerRenderer) obj; + if (this.fillBox != that.fillBox) { + return false; + } + if (this.itemMargin != that.itemMargin) { + return false; + } + if (this.maximumBarWidth != that.maximumBarWidth) { + return false; + } + if (this.meanVisible != that.meanVisible) { + return false; + } + if (this.medianVisible != that.medianVisible) { + return false; + } + if (this.useOutlinePaintForWhiskers + != that.useOutlinePaintForWhiskers) { + return false; + } + if (this.whiskerWidth != that.whiskerWidth) { + return false; + } + if (!PaintUtilities.equal(this.artifactPaint, that.artifactPaint)) { + return false; + } + return super.equals(obj); + } + + /** + * 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.artifactPaint, 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.artifactPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/CategoryItemRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/CategoryItemRenderer.java new file mode 100755 index 0000000..0132763 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/CategoryItemRenderer.java @@ -0,0 +1,1870 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * CategoryItemRenderer.java + * ------------------------- + * + * (C) Copyright 2001-2011, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Mark Watson (www.markwatson.com); + * + * Changes + * ------- + * 23-Oct-2001 : Version 1 (DG); + * 16-Jan-2002 : Renamed HorizontalCategoryItemRenderer.java + * --> CategoryItemRenderer.java (DG); + * 05-Feb-2002 : Changed return type of the drawCategoryItem method from void + * to Shape, as part of the tooltips implementation (DG) + * + * NOTE (30-May-2002) : this has subsequently been changed back + * to void, tooltips are now collected along with entities in + * ChartRenderingInfo (DG); + * + * 14-Mar-2002 : Added the initialise method, and changed all bar plots to use + * this renderer (DG); + * 23-May-2002 : Added ChartRenderingInfo to the initialise method (DG); + * 29-May-2002 : Added the getAxisArea(Rectangle2D) method (DG); + * 06-Jun-2002 : Updated Javadoc comments (DG); + * 26-Jun-2002 : Added range axis to the initialise method (DG); + * 24-Sep-2002 : Added getLegendItem() method (DG); + * 23-Oct-2002 : Added methods to get/setToolTipGenerator (DG); + * 05-Nov-2002 : Replaced references to CategoryDataset with TableDataset (DG); + * 06-Nov-2002 : Added the domain axis to the drawCategoryItem method. Renamed + * drawCategoryItem() --> drawItem() (DG); + * 20-Nov-2002 : Changed signature of drawItem() method to reflect use of + * TableDataset (DG); + * 26-Nov-2002 : Replaced the isStacked() method with the getRangeType() + * method (DG); + * 08-Jan-2003 : Changed getSeriesCount() --> getRowCount() and + * getCategoryCount() --> getColumnCount() (DG); + * 09-Jan-2003 : Changed name of grid-line methods (DG); + * 21-Jan-2003 : Merged TableDataset with CategoryDataset (DG); + * 10-Apr-2003 : Changed CategoryDataset to KeyedValues2DDataset in + * drawItem() method (DG); + * 29-Apr-2003 : Eliminated Renderer interface (DG); + * 02-Sep-2003 : Fix for bug 790407 (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 20-Oct-2003 : Added setOutlinePaint() method (DG); + * 06-Feb-2004 : Added missing methods, and moved deprecated methods (DG); + * 19-Feb-2004 : Added extra setXXXLabelsVisible() methods (DG); + * 29-Apr-2004 : Changed Integer --> int in initialise() method (DG); + * 18-May-2004 : Added methods for item label paint (DG); + * 05-Nov-2004 : Added getPassCount() method and 'pass' parameter to drawItem() + * method (DG); + * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); + * 23-Feb-2005 : Now extends LegendItemSource (DG); + * 20-Apr-2005 : Renamed CategoryLabelGenerator + * --> CategoryItemLabelGenerator (DG); + * 20-May-2005 : Added drawDomainMarker() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 20-Feb-2007 : Updated API docs (DG); + * 19-Apr-2007 : Deprecated seriesVisible and seriesVisibleInLegend flags (DG); + * 20-Apr-2007 : Deprecated paint, fillPaint, outlinePaint, stroke, + * outlineStroke, shape, itemLabelsVisible, itemLabelFont, + * itemLabelPaint, positiveItemLabelPosition, + * negativeItemLabelPosition and createEntities override + * fields (DG); + * 26-Jun-2008 : Added new method required for crosshair support - THIS CHANGES + * THE API as of version 1.0.11 (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemSource; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.event.RendererChangeListener; +import org.jfree.chart.labels.CategoryItemLabelGenerator; +import org.jfree.chart.labels.CategoryToolTipGenerator; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.plot.CategoryMarker; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Marker; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.urls.CategoryURLGenerator; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.ui.RectangleEdge; + +/** + * A plug-in object that is used by the {@link CategoryPlot} class to display + * individual data items from a {@link CategoryDataset}. + *

+ * This interface defines the methods that must be provided by all renderers. + * If you are implementing a custom renderer, you should consider extending the + * {@link AbstractCategoryItemRenderer} class. + *

+ * Most renderer attributes are defined using a "three layer" approach. When + * looking up an attribute (for example, the outline paint) the renderer first + * checks to see if there is a setting (in layer 0) that applies to ALL items + * that the renderer draws. If there is, that setting is used, but if it is + * null the renderer looks up the next layer, which contains + * "per series" settings for the attribute (many attributes are defined on a + * per series basis, so this is the layer that is most commonly used). If the + * layer 1 setting is null, the renderer will look up the final + * layer, which provides a default or "base" setting. Some attributes allow + * the base setting to be null, while other attributes enforce + * non-null values. + */ +public interface CategoryItemRenderer extends LegendItemSource { + + /** + * Returns the number of passes through the dataset required by the + * renderer. Usually this will be one, but some renderers may use + * a second or third pass to overlay items on top of things that were + * drawn in an earlier pass. + * + * @return The pass count. + */ + public int getPassCount(); + + /** + * Returns the plot that the renderer has been assigned to (where + * null indicates that the renderer is not currently assigned + * to a plot). + * + * @return The plot (possibly null). + * + * @see #setPlot(CategoryPlot) + */ + public CategoryPlot getPlot(); + + /** + * Sets the plot that the renderer has been assigned to. This method is + * usually called by the {@link CategoryPlot}, in normal usage you + * shouldn't need to call this method directly. + * + * @param plot the plot (null not permitted). + * + * @see #getPlot() + */ + public void setPlot(CategoryPlot plot); + + /** + * Adds a change listener. + * + * @param listener the listener. + * + * @see #removeChangeListener(RendererChangeListener) + */ + public void addChangeListener(RendererChangeListener listener); + + /** + * Removes a change listener. + * + * @param listener the listener. + * + * @see #addChangeListener(RendererChangeListener) + */ + public void removeChangeListener(RendererChangeListener listener); + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (or null if the dataset is + * null or empty). + */ + public Range findRangeBounds(CategoryDataset dataset); + + /** + * Initialises the renderer. This method will be called before the first + * item is rendered, giving the renderer an opportunity to initialise any + * state information it wants to maintain. The renderer can do nothing if + * it chooses. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param rendererIndex the renderer index. + * @param info collects chart rendering information for return to caller. + * + * @return A state object (maintains state information relevant to one + * chart drawing). + */ + public CategoryItemRendererState initialise(Graphics2D g2, + Rectangle2D dataArea, + CategoryPlot plot, + int rendererIndex, + PlotRenderingInfo info); + + /** + * Returns a boolean that indicates whether or not the specified item + * should be drawn (this is typically used to hide an entire series). + * + * @param series the series index. + * @param item the item index. + * + * @return A boolean. + */ + public boolean getItemVisible(int series, int item); + + /** + * Returns a boolean that indicates whether or not the specified series + * should be drawn (this is typically used to hide an entire series). + * + * @param series the series index. + * + * @return A boolean. + */ + public boolean isSeriesVisible(int series); + + /** + * Returns the flag that controls the visibility of ALL series. This flag + * overrides the per series and default settings - you must set it to + * null if you want the other settings to apply. + * + * @return The flag (possibly null). + * + * @see #setSeriesVisible(Boolean) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesVisible(int)} and + * {@link #getBaseSeriesVisible()}. + */ + public Boolean getSeriesVisible(); + + /** + * Sets the flag that controls the visibility of ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. This flag + * overrides the per series and default settings - you must set it to + * null if you want the other settings to apply. + * + * @param visible the flag (null permitted). + * + * @see #getSeriesVisible() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesVisible(int, Boolean)} + * and {@link #setBaseSeriesVisible(boolean)}. + */ + public void setSeriesVisible(Boolean visible); + + /** + * Sets the flag that controls the visibility of ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. This flag + * overrides the per series and default settings - you must set it to + * null if you want the other settings to apply. + * + * @param visible the flag (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesVisible() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesVisible(int, Boolean, + * boolean)} and {@link #setBaseSeriesVisible(boolean, boolean)}. + */ + public void setSeriesVisible(Boolean visible, boolean notify); + + /** + * Returns the flag that controls whether a series is visible. + * + * @param series the series index (zero-based). + * + * @return The flag (possibly null). + * + * @see #setSeriesVisible(int, Boolean) + */ + public Boolean getSeriesVisible(int series); + + /** + * Sets the flag that controls whether a series is visible and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the flag (null permitted). + * + * @see #getSeriesVisible(int) + */ + public void setSeriesVisible(int series, Boolean visible); + + /** + * Sets the flag that controls whether a series is visible and, if + * requested, sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index. + * @param visible the flag (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesVisible(int) + */ + public void setSeriesVisible(int series, Boolean visible, boolean notify); + + /** + * Returns the base visibility for all series. + * + * @return The base visibility. + * + * @see #setBaseSeriesVisible(boolean) + */ + public boolean getBaseSeriesVisible(); + + /** + * Sets the base visibility and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param visible the flag. + * + * @see #getBaseSeriesVisible() + */ + public void setBaseSeriesVisible(boolean visible); + + /** + * Sets the base visibility and, if requested, sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the visibility. + * @param notify notify listeners? + * + * @see #getBaseSeriesVisible() + */ + public void setBaseSeriesVisible(boolean visible, boolean notify); + + // SERIES VISIBLE IN LEGEND (not yet respected by all renderers) + + /** + * Returns true if the series should be shown in the legend, + * and false otherwise. + * + * @param series the series index. + * + * @return A boolean. + */ + public boolean isSeriesVisibleInLegend(int series); + + /** + * Returns the flag that controls the visibility of ALL series in the + * legend. This flag overrides the per series and default settings - you + * must set it to null if you want the other settings to + * apply. + * + * @return The flag (possibly null). + * + * @see #setSeriesVisibleInLegend(Boolean) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesVisibleInLegend(int)} + * and {@link #getBaseSeriesVisibleInLegend()}. + */ + public Boolean getSeriesVisibleInLegend(); + + /** + * Sets the flag that controls the visibility of ALL series in the legend + * and sends a {@link RendererChangeEvent} to all registered listeners. + * This flag overrides the per series and default settings - you must set + * it to null if you want the other settings to apply. + * + * @param visible the flag (null permitted). + * + * @see #getSeriesVisibleInLegend() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesVisibleInLegend(int, + * Boolean)} and {@link #setBaseSeriesVisibleInLegend(boolean)}. + */ + public void setSeriesVisibleInLegend(Boolean visible); + + /** + * Sets the flag that controls the visibility of ALL series in the legend + * and sends a {@link RendererChangeEvent} to all registered listeners. + * This flag overrides the per series and default settings - you must set + * it to null if you want the other settings to apply. + * + * @param visible the flag (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesVisibleInLegend() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesVisibleInLegend(int, + * Boolean, boolean)} and {@link #setBaseSeriesVisibleInLegend(boolean, + * boolean)}. + */ + public void setSeriesVisibleInLegend(Boolean visible, boolean notify); + + /** + * Returns the flag that controls whether a series is visible in the + * legend. This method returns only the "per series" settings - to + * incorporate the override and base settings as well, you need to use the + * {@link #isSeriesVisibleInLegend(int)} method. + * + * @param series the series index (zero-based). + * + * @return The flag (possibly null). + * + * @see #setSeriesVisibleInLegend(int, Boolean) + */ + public Boolean getSeriesVisibleInLegend(int series); + + /** + * Sets the flag that controls whether a series is visible in the legend + * and sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the flag (null permitted). + * + * @see #getSeriesVisibleInLegend(int) + */ + public void setSeriesVisibleInLegend(int series, Boolean visible); + + /** + * Sets the flag that controls whether a series is visible in the legend + * and, if requested, sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index. + * @param visible the flag (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesVisibleInLegend(int) + */ + public void setSeriesVisibleInLegend(int series, Boolean visible, + boolean notify); + + /** + * Returns the base visibility in the legend for all series. + * + * @return The base visibility. + * + * @see #setBaseSeriesVisibleInLegend(boolean) + */ + public boolean getBaseSeriesVisibleInLegend(); + + /** + * Sets the base visibility in the legend and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the flag. + * + * @see #getBaseSeriesVisibleInLegend() + */ + public void setBaseSeriesVisibleInLegend(boolean visible); + + /** + * Sets the base visibility in the legend and, if requested, sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the visibility. + * @param notify notify listeners? + * + * @see #getBaseSeriesVisibleInLegend() + */ + public void setBaseSeriesVisibleInLegend(boolean visible, boolean notify); + + + //// PAINT ///////////////////////////////////////////////////////////////// + + /** + * Returns the paint used to fill data items as they are drawn. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The paint (never null). + */ + public Paint getItemPaint(int row, int column); + + /** + * Sets the paint to be used for ALL series, and sends a + * {@link RendererChangeEvent} to all registered listeners. If this is + * null, the renderer will use the paint for the series. + * + * @param paint the paint (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesPaint(int, Paint)} and + * {@link #setBasePaint(Paint)}. + */ + public void setPaint(Paint paint); + + /** + * Returns the paint used to fill an item drawn by the renderer. + * + * @param series the series index (zero-based). + * + * @return The paint (possibly null). + * + * @see #setSeriesPaint(int, Paint) + */ + public Paint getSeriesPaint(int series); + + /** + * Sets the paint used for a series and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param series the series index (zero-based). + * @param paint the paint (null permitted). + * + * @see #getSeriesPaint(int) + */ + public void setSeriesPaint(int series, Paint paint); + + // FIXME: add setSeriesPaint(int, Paint, boolean)? + + /** + * Returns the base paint. + * + * @return The base paint (never null). + * + * @see #setBasePaint(Paint) + */ + public Paint getBasePaint(); + + /** + * Sets the base paint and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getBasePaint() + */ + public void setBasePaint(Paint paint); + + // FIXME: add setBasePaint(int, Paint, boolean)? + + //// FILL PAINT ///////////////////////////////////////////////////////// + +// /** +// * Returns the paint used to fill data items as they are drawn. +// * +// * @param row the row (or series) index (zero-based). +// * @param column the column (or category) index (zero-based). +// * +// * @return The paint (never null). +// */ +// public Paint getItemFillPaint(int row, int column); +// +// /** +// * Returns the paint used to fill an item drawn by the renderer. +// * +// * @param series the series (zero-based index). +// * +// * @return The paint (possibly null). +// * +// * @see #setSeriesFillPaint(int, Paint) +// */ +// public Paint getSeriesFillPaint(int series); +// +// /** +// * Sets the paint used for a series outline and sends a +// * {@link RendererChangeEvent} to all registered listeners. +// * +// * @param series the series index (zero-based). +// * @param paint the paint (null permitted). +// * +// * @see #getSeriesFillPaint(int) +// */ +// public void setSeriesFillPaint(int series, Paint paint); +// +// /** +// * Returns the base outline paint. +// * +// * @return The paint (never null). +// * +// * @see #setBaseFillPaint(Paint) +// */ +// public Paint getBaseFillPaint(); +// +// /** +// * Sets the base outline paint and sends a {@link RendererChangeEvent} to +// * all registered listeners. +// * +// * @param paint the paint (null not permitted). +// * +// * @see #getBaseFillPaint() +// */ +// public void setBaseFillPaint(Paint paint); + + //// OUTLINE PAINT ///////////////////////////////////////////////////////// + + /** + * Returns the paint used to outline data items as they are drawn. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The paint (never null). + */ + public Paint getItemOutlinePaint(int row, int column); + + /** + * Sets the outline paint for ALL series (optional). + * + * @param paint the paint (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesOutlinePaint(int, + * Paint)} and {@link #setBaseOutlinePaint(Paint)}. + */ + public void setOutlinePaint(Paint paint); + + /** + * Returns the paint used to outline an item drawn by the renderer. + * + * @param series the series (zero-based index). + * + * @return The paint (possibly null). + * + * @see #setSeriesOutlinePaint(int, Paint) + */ + public Paint getSeriesOutlinePaint(int series); + + /** + * Sets the paint used for a series outline and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param paint the paint (null permitted). + * + * @see #getSeriesOutlinePaint(int) + */ + public void setSeriesOutlinePaint(int series, Paint paint); + + // FIXME: add setSeriesOutlinePaint(int, Paint, boolean)? + + /** + * Returns the base outline paint. + * + * @return The paint (never null). + * + * @see #setBaseOutlinePaint(Paint) + */ + public Paint getBaseOutlinePaint(); + + /** + * Sets the base outline paint and sends a {@link RendererChangeEvent} to + * all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getBaseOutlinePaint() + */ + public void setBaseOutlinePaint(Paint paint); + + // FIXME: add setBaseOutlinePaint(Paint, boolean)? + + //// STROKE //////////////////////////////////////////////////////////////// + + /** + * Returns the stroke used to draw data items. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The stroke (never null). + */ + public Stroke getItemStroke(int row, int column); + + /** + * Sets the stroke for ALL series and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param stroke the stroke (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesStroke(int, Stroke)} + * and {@link #setBaseStroke(Stroke)}. + */ + public void setStroke(Stroke stroke); + + /** + * Returns the stroke used to draw the items in a series. + * + * @param series the series (zero-based index). + * + * @return The stroke (never null). + * + * @see #setSeriesStroke(int, Stroke) + */ + public Stroke getSeriesStroke(int series); + + /** + * Sets the stroke used for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param stroke the stroke (null permitted). + * + * @see #getSeriesStroke(int) + */ + public void setSeriesStroke(int series, Stroke stroke); + + // FIXME: add setSeriesStroke(int, Stroke, boolean) ? + + /** + * Returns the base stroke. + * + * @return The base stroke (never null). + * + * @see #setBaseStroke(Stroke) + */ + public Stroke getBaseStroke(); + + /** + * Sets the base stroke and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getBaseStroke() + */ + public void setBaseStroke(Stroke stroke); + + // FIXME: add setBaseStroke(Stroke, boolean) ? + + //// OUTLINE STROKE //////////////////////////////////////////////////////// + + /** + * Returns the stroke used to outline data items. + *

+ * The default implementation passes control to the + * lookupSeriesOutlineStroke method. You can override this method if you + * require different behaviour. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The stroke (never null). + */ + public Stroke getItemOutlineStroke(int row, int column); + + /** + * Sets the outline stroke for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesOutlineStroke(int, + * Stroke)} and {@link #setBaseOutlineStroke(Stroke)}. + */ + public void setOutlineStroke(Stroke stroke); + + /** + * Returns the stroke used to outline the items in a series. + * + * @param series the series (zero-based index). + * + * @return The stroke (possibly null). + * + * @see #setSeriesOutlineStroke(int, Stroke) + */ + public Stroke getSeriesOutlineStroke(int series); + + /** + * Sets the outline stroke used for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param stroke the stroke (null permitted). + * + * @see #getSeriesOutlineStroke(int) + */ + public void setSeriesOutlineStroke(int series, Stroke stroke); + + // FIXME: add setSeriesOutlineStroke(int, Stroke, boolean) ? + + /** + * Returns the base outline stroke. + * + * @return The stroke (never null). + * + * @see #setBaseOutlineStroke(Stroke) + */ + public Stroke getBaseOutlineStroke(); + + /** + * Sets the base outline stroke and sends a {@link RendererChangeEvent} to + * all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getBaseOutlineStroke() + */ + public void setBaseOutlineStroke(Stroke stroke); + + // FIXME: add setBaseOutlineStroke(Stroke, boolean) ? + + //// SHAPE ///////////////////////////////////////////////////////////////// + + /** + * Returns a shape used to represent a data item. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The shape (never null). + */ + public Shape getItemShape(int row, int column); + + /** + * Sets the shape for ALL series (optional) and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param shape the shape (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesShape(int, Shape)} and + * {@link #setBaseShape(Shape)}. + */ + public void setShape(Shape shape); + + /** + * Returns a shape used to represent the items in a series. + * + * @param series the series (zero-based index). + * + * @return The shape (possibly null). + * + * @see #setSeriesShape(int, Shape) + */ + public Shape getSeriesShape(int series); + + /** + * Sets the shape used for a series and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param series the series index (zero-based). + * @param shape the shape (null permitted). + * + * @see #getSeriesShape(int) + */ + public void setSeriesShape(int series, Shape shape); + + // FIXME: add setSeriesShape(int, Shape, boolean) ? + + /** + * Returns the base shape. + * + * @return The shape (never null). + * + * @see #setBaseShape(Shape) + */ + public Shape getBaseShape(); + + /** + * Sets the base shape and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param shape the shape (null not permitted). + * + * @see #getBaseShape() + */ + public void setBaseShape(Shape shape); + + // FIXME: add setBaseShape(Shape, boolean) ? + + // ITEM LABELS VISIBLE + + /** + * Returns true if an item label is visible, and + * false otherwise. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return A boolean. + */ + public boolean isItemLabelVisible(int row, int column); + + /** + * Sets a flag that controls whether or not the item labels for ALL series + * are visible. + * + * @param visible the flag. + * + * @see #setItemLabelsVisible(Boolean) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, + * Boolean)} and {@link #setBaseItemLabelsVisible(boolean)}. + */ + public void setItemLabelsVisible(boolean visible); + + /** + * Sets a flag that controls whether or not the item labels for ALL series + * are visible. + * + * @param visible the flag (null permitted). + * + * @see #setItemLabelsVisible(boolean) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, + * Boolean)} and {@link #setBaseItemLabelsVisible(boolean)}. + */ + public void setItemLabelsVisible(Boolean visible); + + /** + * Sets the visibility of item labels for ALL series and, if requested, + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param visible a flag that controls whether or not the item labels are + * visible (null permitted). + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, + * Boolean, boolean)} and {@link #setBaseItemLabelsVisible(Boolean, + * boolean)}. + */ + public void setItemLabelsVisible(Boolean visible, boolean notify); + + /** + * Returns true if the item labels for a series are visible, + * and false otherwise. + * + * @param series the series index (zero-based). + * + * @return A boolean. + * + * @see #setSeriesItemLabelsVisible(int, Boolean) + */ + public boolean isSeriesItemLabelsVisible(int series); + + /** + * Sets a flag that controls the visibility of the item labels for a series. + * + * @param series the series index (zero-based). + * @param visible the flag. + * + * @see #isSeriesItemLabelsVisible(int) + */ + public void setSeriesItemLabelsVisible(int series, boolean visible); + + /** + * Sets a flag that controls the visibility of the item labels for a series. + * + * @param series the series index (zero-based). + * @param visible the flag (null permitted). + * + * @see #isSeriesItemLabelsVisible(int) + */ + public void setSeriesItemLabelsVisible(int series, Boolean visible); + + /** + * Sets the visibility of item labels for a series and, if requested, sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the visible flag. + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @see #isSeriesItemLabelsVisible(int) + */ + public void setSeriesItemLabelsVisible(int series, Boolean visible, + boolean notify); + + /** + * Returns the base setting for item label visibility. A null + * result should be interpreted as equivalent to Boolean.FALSE + * (this is an error in the API design, the return value should have been + * a boolean primitive). + * + * @return A flag (possibly null). + * + * @see #setBaseItemLabelsVisible(Boolean) + */ + public Boolean getBaseItemLabelsVisible(); + + /** + * Sets the base flag that controls whether or not item labels are visible + * and sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the flag. + * + * @see #getBaseItemLabelsVisible() + */ + public void setBaseItemLabelsVisible(boolean visible); + + /** + * Sets the base setting for item label visibility and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the flag (null permitted). + * + * @see #getBaseItemLabelsVisible() + */ + public void setBaseItemLabelsVisible(Boolean visible); + + /** + * Sets the base visibility for item labels and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the visibility flag. + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @see #getBaseItemLabelsVisible() + */ + public void setBaseItemLabelsVisible(Boolean visible, boolean notify); + + // ITEM LABEL GENERATOR + + /** + * Returns the item label generator for the specified data item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The generator (possibly null). + */ + public CategoryItemLabelGenerator getItemLabelGenerator(int series, + int item); + + /** + * Sets the item label generator for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. This overrides + * the per-series settings. + * + * @param generator the generator (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelGenerator(int, + * CategoryItemLabelGenerator)} and + * {@link #setBaseItemLabelGenerator(CategoryItemLabelGenerator)}. + */ + public void setItemLabelGenerator(CategoryItemLabelGenerator generator); + + /** + * Returns the item label generator for a series. + * + * @param series the series index (zero-based). + * + * @return The label generator (possibly null). + * + * @see #setSeriesItemLabelGenerator(int, CategoryItemLabelGenerator) + */ + public CategoryItemLabelGenerator getSeriesItemLabelGenerator(int series); + + /** + * Sets the item label generator for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param generator the generator. + * + * @see #getSeriesItemLabelGenerator(int) + */ + public void setSeriesItemLabelGenerator(int series, + CategoryItemLabelGenerator generator); + + // FIXME: add setSeriesItemLabelGenerator(int, CategoryItemLabelGenerator, + // boolean) + + /** + * Returns the base item label generator. + * + * @return The generator (possibly null). + * + * @see #setBaseItemLabelGenerator(CategoryItemLabelGenerator) + */ + public CategoryItemLabelGenerator getBaseItemLabelGenerator(); + + /** + * Sets the base item label generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getBaseItemLabelGenerator() + */ + public void setBaseItemLabelGenerator(CategoryItemLabelGenerator generator); + + // FIXME: add setBaseItemLabelGenerator(CategoryItemLabelGenerator, + // boolean) ? + + // TOOL TIP GENERATOR + + /** + * Returns the tool tip generator that should be used for the specified + * item. This method looks up the generator using the "three-layer" + * approach outlined in the general description of this interface. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The generator (possibly null). + */ + public CategoryToolTipGenerator getToolTipGenerator(int row, int column); + + /** + * Returns the tool tip generator that will be used for ALL items in the + * dataset (the "layer 0" generator). + * + * @return A tool tip generator (possibly null). + * + * @see #setToolTipGenerator(CategoryToolTipGenerator) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesToolTipGenerator(int)} + * and {@link #getBaseToolTipGenerator()}. + */ + public CategoryToolTipGenerator getToolTipGenerator(); + + /** + * Sets the tool tip generator for ALL series and sends a + * {@link org.jfree.chart.event.RendererChangeEvent} to all registered + * listeners. + * + * @param generator the generator (null permitted). + * + * @see #getToolTipGenerator() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesToolTipGenerator(int, + * CategoryToolTipGenerator)} and + * {@link #setBaseToolTipGenerator(CategoryToolTipGenerator)}. + */ + public void setToolTipGenerator(CategoryToolTipGenerator generator); + + /** + * Returns the tool tip generator for the specified series (a "layer 1" + * generator). + * + * @param series the series index (zero-based). + * + * @return The tool tip generator (possibly null). + * + * @see #setSeriesToolTipGenerator(int, CategoryToolTipGenerator) + */ + public CategoryToolTipGenerator getSeriesToolTipGenerator(int series); + + /** + * Sets the tool tip generator for a series and sends a + * {@link org.jfree.chart.event.RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index (zero-based). + * @param generator the generator (null permitted). + * + * @see #getSeriesToolTipGenerator(int) + */ + public void setSeriesToolTipGenerator(int series, + CategoryToolTipGenerator generator); + + // FIXME: add setSeriesToolTipGenerator(int, CategoryToolTipGenerator, + // boolean) ? + + /** + * Returns the base tool tip generator (the "layer 2" generator). + * + * @return The tool tip generator (possibly null). + * + * @see #setBaseToolTipGenerator(CategoryToolTipGenerator) + */ + public CategoryToolTipGenerator getBaseToolTipGenerator(); + + /** + * Sets the base tool tip generator and sends a + * {@link org.jfree.chart.event.RendererChangeEvent} to all registered + * listeners. + * + * @param generator the generator (null permitted). + * + * @see #getBaseToolTipGenerator() + */ + public void setBaseToolTipGenerator(CategoryToolTipGenerator generator); + + // FIXME: add setBaseToolTipGenerator(CategoryToolTipGenerator, boolean) ? + + //// ITEM LABEL FONT ////////////////////////////////////////////////////// + + /** + * Returns the font for an item label. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The font (never null). + */ + public Font getItemLabelFont(int row, int column); + + /** + * Returns the font used for all item labels. This may be + * null, in which case the per series font settings will apply. + * + * @return The font (possibly null). + * + * @see #setItemLabelFont(Font) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesItemLabelFont(int)} and + * {@link #getBaseItemLabelFont()}. + */ + public Font getItemLabelFont(); + + /** + * Sets the item label font for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. You can set + * this to null if you prefer to set the font on a per series + * basis. + * + * @param font the font (null permitted). + * + * @see #getItemLabelFont() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelFont(int, + * Font)} and {@link #setBaseItemLabelFont(Font)}. + */ + public void setItemLabelFont(Font font); + + /** + * Returns the font for all the item labels in a series. + * + * @param series the series index (zero-based). + * + * @return The font (possibly null). + * + * @see #setSeriesItemLabelFont(int, Font) + */ + public Font getSeriesItemLabelFont(int series); + + /** + * Sets the item label font for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param font the font (null permitted). + * + * @see #getSeriesItemLabelFont(int) + */ + public void setSeriesItemLabelFont(int series, Font font); + + // FIXME: add setSeriesItemLabelFont(int, Font, boolean) ? + + /** + * Returns the base item label font (this is used when no other font + * setting is available). + * + * @return The font (never null). + * + * @see #setBaseItemLabelFont(Font) + */ + public Font getBaseItemLabelFont(); + + /** + * Sets the base item label font and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getBaseItemLabelFont() + */ + public void setBaseItemLabelFont(Font font); + + // FIXME: add setBaseItemLabelFont(Font, boolean) ? + + //// ITEM LABEL PAINT ///////////////////////////////////////////////////// + + /** + * Returns the paint used to draw an item label. + * + * @param row the row index (zero based). + * @param column the column index (zero based). + * + * @return The paint (never null). + */ + public Paint getItemLabelPaint(int row, int column); + + /** + * Returns the paint used for all item labels. This may be + * null, in which case the per series paint settings will + * apply. + * + * @return The paint (possibly null). + * + * @see #setItemLabelPaint(Paint) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesItemLabelPaint(int)} + * and {@link #getBaseItemLabelPaint()}. + */ + public Paint getItemLabelPaint(); + + /** + * Sets the item label paint for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @see #getItemLabelPaint() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelPaint(int, + * Paint)} and {@link #setBaseItemLabelPaint(Paint)}. + */ + public void setItemLabelPaint(Paint paint); + + /** + * Returns the paint used to draw the item labels for a series. + * + * @param series the series index (zero based). + * + * @return The paint (possibly null). + * + * @see #setSeriesItemLabelPaint(int, Paint) + */ + public Paint getSeriesItemLabelPaint(int series); + + /** + * Sets the item label paint for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series (zero based index). + * @param paint the paint (null permitted). + * + * @see #getSeriesItemLabelPaint(int) + */ + public void setSeriesItemLabelPaint(int series, Paint paint); + + // FIXME: add setSeriesItemLabelPaint(int, Paint, boolean) ? + + /** + * Returns the base item label paint. + * + * @return The paint (never null). + * + * @see #setBaseItemLabelPaint(Paint) + */ + public Paint getBaseItemLabelPaint(); + + /** + * Sets the base item label paint and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getBaseItemLabelPaint() + */ + public void setBaseItemLabelPaint(Paint paint); + + // FIXME: add setBaseItemLabelPaint(Paint, boolean) ? + + // POSITIVE ITEM LABEL POSITION... + + /** + * Returns the item label position for positive values. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The item label position (never null). + */ + public ItemLabelPosition getPositiveItemLabelPosition(int row, int column); + + /** + * Returns the item label position for positive values in ALL series. + * + * @return The item label position (possibly null). + * + * @see #setPositiveItemLabelPosition(ItemLabelPosition) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #getSeriesPositiveItemLabelPosition(int)} + * and {@link #getBasePositiveItemLabelPosition()}. + */ + public ItemLabelPosition getPositiveItemLabelPosition(); + + /** + * Sets the item label position for positive values in ALL series, and + * sends a {@link RendererChangeEvent} to all registered listeners. You + * need to set this to null to expose the settings for + * individual series. + * + * @param position the position (null permitted). + * + * @see #getPositiveItemLabelPosition() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition)} + * and {@link #setBasePositiveItemLabelPosition(ItemLabelPosition)}. + */ + public void setPositiveItemLabelPosition(ItemLabelPosition position); + + /** + * Sets the positive item label position for ALL series and (if requested) + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param position the position (null permitted). + * @param notify notify registered listeners? + * + * @see #getPositiveItemLabelPosition() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition, + * boolean)} and {@link #setBasePositiveItemLabelPosition( + * ItemLabelPosition, boolean)}. + */ + public void setPositiveItemLabelPosition(ItemLabelPosition position, + boolean notify); + + /** + * Returns the item label position for all positive values in a series. + * + * @param series the series index (zero-based). + * + * @return The item label position. + * + * @see #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition) + */ + public ItemLabelPosition getSeriesPositiveItemLabelPosition(int series); + + /** + * Sets the item label position for all positive values in a series and + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param position the position (null permitted). + * + * @see #getSeriesPositiveItemLabelPosition(int) + */ + public void setSeriesPositiveItemLabelPosition(int series, + ItemLabelPosition position); + + /** + * Sets the item label position for all positive values in a series and (if + * requested) sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index (zero-based). + * @param position the position (null permitted). + * @param notify notify registered listeners? + * + * @see #getSeriesPositiveItemLabelPosition(int) + */ + public void setSeriesPositiveItemLabelPosition(int series, + ItemLabelPosition position, boolean notify); + + /** + * Returns the base positive item label position. + * + * @return The position. + * + * @see #setBasePositiveItemLabelPosition(ItemLabelPosition) + */ + public ItemLabelPosition getBasePositiveItemLabelPosition(); + + /** + * Sets the base positive item label position. + * + * @param position the position. + * + * @see #getBasePositiveItemLabelPosition() + */ + public void setBasePositiveItemLabelPosition(ItemLabelPosition position); + + /** + * Sets the base positive item label position and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param position the position. + * @param notify notify registered listeners? + * + * @see #getBasePositiveItemLabelPosition() + */ + public void setBasePositiveItemLabelPosition(ItemLabelPosition position, + boolean notify); + + + // NEGATIVE ITEM LABEL POSITION... + + /** + * Returns the item label position for negative values. This method can be + * overridden to provide customisation of the item label position for + * individual data items. + * + * @param row the row index (zero-based). + * @param column the column (zero-based). + * + * @return The item label position. + */ + public ItemLabelPosition getNegativeItemLabelPosition(int row, int column); + + /** + * Returns the item label position for negative values in ALL series. + * + * @return The item label position (possibly null). + * + * @see #setNegativeItemLabelPosition(ItemLabelPosition) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #getSeriesNegativeItemLabelPosition(int)} + * and {@link #getBaseNegativeItemLabelPosition()}. + */ + public ItemLabelPosition getNegativeItemLabelPosition(); + + /** + * Sets the item label position for negative values in ALL series, and + * sends a {@link RendererChangeEvent} to all registered listeners. You + * need to set this to null to expose the settings for + * individual series. + * + * @param position the position (null permitted). + * + * @see #getNegativeItemLabelPosition() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition)} + * and {@link #setBaseNegativeItemLabelPosition(ItemLabelPosition)}. + */ + public void setNegativeItemLabelPosition(ItemLabelPosition position); + + /** + * Sets the item label position for negative values in ALL series and (if + * requested) sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param position the position (null permitted). + * @param notify notify registered listeners? + * + * @see #getNegativeItemLabelPosition() + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition, + * boolean)} and {@link #setBaseNegativeItemLabelPosition( + * ItemLabelPosition, boolean)}. + */ + public void setNegativeItemLabelPosition(ItemLabelPosition position, + boolean notify); + + /** + * Returns the item label position for all negative values in a series. + * + * @param series the series index (zero-based). + * + * @return The item label position. + * + * @see #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition) + */ + public ItemLabelPosition getSeriesNegativeItemLabelPosition(int series); + + /** + * Sets the item label position for negative values in a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param position the position (null permitted). + * + * @see #getSeriesNegativeItemLabelPosition(int) + */ + public void setSeriesNegativeItemLabelPosition(int series, + ItemLabelPosition position); + + /** + * Sets the item label position for negative values in a series and (if + * requested) sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index (zero-based). + * @param position the position (null permitted). + * @param notify notify registered listeners? + * + * @see #getSeriesNegativeItemLabelPosition(int) + */ + public void setSeriesNegativeItemLabelPosition(int series, + ItemLabelPosition position, + boolean notify); + + /** + * Returns the base item label position for negative values. + * + * @return The position. + * + * @see #setBaseNegativeItemLabelPosition(ItemLabelPosition) + */ + public ItemLabelPosition getBaseNegativeItemLabelPosition(); + + /** + * Sets the base item label position for negative values and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param position the position. + * + * @see #getBaseNegativeItemLabelPosition() + */ + public void setBaseNegativeItemLabelPosition(ItemLabelPosition position); + + /** + * Sets the base negative item label position and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param position the position. + * @param notify notify registered listeners? + * + * @see #getBaseNegativeItemLabelPosition() + */ + public void setBaseNegativeItemLabelPosition(ItemLabelPosition position, + boolean notify); + + // CREATE ENTITIES + // FIXME: these methods should be defined + +// public boolean getItemCreateEntity(int series, int item); +// +// public Boolean getSeriesCreateEntities(int series); +// +// public void setSeriesCreateEntities(int series, Boolean create); +// +// public void setSeriesCreateEntities(int series, Boolean create, +// boolean notify); +// +// public boolean getBaseCreateEntities(); +// +// public void setBaseCreateEntities(boolean create); +// +// public void setBaseCreateEntities(boolean create, boolean notify); + + + // ITEM URL GENERATOR + + /** + * Returns the URL generator for an item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The item URL generator. + */ + public CategoryURLGenerator getItemURLGenerator(int series, int item); + + /** + * Sets the item URL generator for ALL series. + * + * @param generator the generator. + * + * @see #getSeriesItemURLGenerator(int) + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemURLGenerator(int, + * CategoryURLGenerator)} and + * {@link #setBaseItemURLGenerator(CategoryURLGenerator)}. + */ + public void setItemURLGenerator(CategoryURLGenerator generator); + + /** + * Returns the item URL generator for a series. + * + * @param series the series index (zero-based). + * + * @return The URL generator. + * + * @see #setSeriesItemURLGenerator(int, CategoryURLGenerator) + */ + public CategoryURLGenerator getSeriesItemURLGenerator(int series); + + /** + * Sets the item URL generator for a series. + * + * @param series the series index (zero-based). + * @param generator the generator. + * + * @see #getSeriesItemURLGenerator(int) + */ + public void setSeriesItemURLGenerator(int series, + CategoryURLGenerator generator); + + // FIXME: add setSeriesItemURLGenerator(int, CategoryURLGenerator, boolean)? + + /** + * Returns the base item URL generator. + * + * @return The item URL generator (possibly null). + * + * @see #setBaseItemURLGenerator(CategoryURLGenerator) + */ + public CategoryURLGenerator getBaseItemURLGenerator(); + + /** + * Sets the base item URL generator and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param generator the item URL generator (null permitted). + * + * @see #getBaseItemURLGenerator() + */ + public void setBaseItemURLGenerator(CategoryURLGenerator generator); + + // FIXME: add setBaseItemURLGenerator(CategoryURLGenerator, boolean) ? + + /** + * Returns a legend item for a series. This method can return + * null, in which case the series will have no entry in the + * legend. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series (zero-based index). + * + * @return The legend item (possibly null). + */ + public LegendItem getLegendItem(int datasetIndex, int series); + + /** + * Draws a background for the data area. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param dataArea the data area. + */ + public void drawBackground(Graphics2D g2, CategoryPlot plot, + Rectangle2D dataArea); + + /** + * Draws an outline for the data area. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param dataArea the data area. + */ + public void drawOutline(Graphics2D g2, CategoryPlot plot, + Rectangle2D dataArea); + + /** + * Draws a single data item. + * + * @param g2 the graphics device. + * @param state state information for one chart. + * @param dataArea the data plot area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the data. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, + int pass); + + /** + * Draws a grid line against the domain axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param dataArea the area for plotting data (not yet adjusted for any + * 3D effect). + * @param value the value. + * + * @see #drawRangeGridline(Graphics2D, CategoryPlot, ValueAxis, + * Rectangle2D, double) + */ + public void drawDomainGridline(Graphics2D g2, CategoryPlot plot, + Rectangle2D dataArea, double value); + + /** + * Draws a grid line against the range axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param dataArea the area for plotting data (not yet adjusted for any + * 3D effect). + * @param value the value. + * + * @see #drawDomainGridline(Graphics2D, CategoryPlot, Rectangle2D, double) + */ + public void drawRangeGridline(Graphics2D g2, CategoryPlot plot, + ValueAxis axis, Rectangle2D dataArea, double value); + + /** + * Draws a line (or some other marker) to indicate a particular category on + * the domain axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the category axis. + * @param marker the marker. + * @param dataArea the area for plotting data (not including 3D effect). + * + * @see #drawRangeMarker(Graphics2D, CategoryPlot, ValueAxis, Marker, + * Rectangle2D) + */ + public void drawDomainMarker(Graphics2D g2, CategoryPlot plot, + CategoryAxis axis, CategoryMarker marker, Rectangle2D dataArea); + + /** + * Draws a line (or some other marker) to indicate a particular value on + * the range axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param marker the marker. + * @param dataArea the area for plotting data (not including 3D effect). + * + * @see #drawDomainMarker(Graphics2D, CategoryPlot, CategoryAxis, + * CategoryMarker, Rectangle2D) + */ + public void drawRangeMarker(Graphics2D g2, CategoryPlot plot, + ValueAxis axis, Marker marker, Rectangle2D dataArea); + + /** + * Returns the Java2D coordinate for the middle of the specified data item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param dataset the dataset. + * @param axis the axis. + * @param area the data area. + * @param edge the edge along which the axis lies. + * + * @return The Java2D coordinate for the middle of the item. + * + * @since 1.0.11 + */ + public double getItemMiddle(Comparable rowKey, Comparable columnKey, + CategoryDataset dataset, CategoryAxis axis, Rectangle2D area, + RectangleEdge edge); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/CategoryItemRendererState.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/CategoryItemRendererState.java new file mode 100755 index 0000000..335708e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/CategoryItemRendererState.java @@ -0,0 +1,228 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * CategoryItemRendererState.java + * ------------------------------ + * (C) Copyright 2003-2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (patch 2497611); + * + * Changes (since 20-Oct-2003): + * ---------------------------- + * 20-Oct-2003 : Added series running total (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 01-Dec-2006 : Updated API docs (DG); + * 26-Jun-2008 : Added CrosshairState (DG); + * 14-Jan-2009 : Added visibleSeries[] array (PK); + * 04-Feb-2009 : Added getVisibleSeriesArray() method (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import org.jfree.chart.plot.CategoryCrosshairState; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.renderer.RendererState; + +/** + * An object that retains temporary state information for a + * {@link CategoryItemRenderer}. + */ +public class CategoryItemRendererState extends RendererState { + + /** The bar width. */ + private double barWidth; + + /** The series running total. */ + private double seriesRunningTotal; + + /** The array with the indices of the visible series.*/ + private int[] visibleSeries; + + /** + * State information for crosshairs in the plot (this is updated by the + * renderer, but may be passed to several renderers in one chart). + * + * @since 1.0.11 + */ + private CategoryCrosshairState crosshairState; + + /** + * Creates a new object for recording temporary state information for a + * renderer. + * + * @param info the plot rendering info (null permitted). + */ + public CategoryItemRendererState(PlotRenderingInfo info) { + super(info); + this.barWidth = 0.0; + this.seriesRunningTotal = 0.0; + } + + /** + * Returns the bar width. + * + * @return The bar width. + * + * @see #setBarWidth(double) + */ + public double getBarWidth() { + return this.barWidth; + } + + /** + * Sets the bar width. The renderer calculates this value and stores it + * here - it is not intended that users can manually set the bar width. + * + * @param width the width. + * + * @see #getBarWidth() + */ + public void setBarWidth(double width) { + this.barWidth = width; + } + + /** + * Returns the series running total. + * + * @return The running total. + * + * @see #setSeriesRunningTotal(double) + */ + public double getSeriesRunningTotal() { + return this.seriesRunningTotal; + } + + /** + * Sets the series running total (this method is intended for the use of + * the renderer only). + * + * @param total the new total. + * + * @see #getSeriesRunningTotal() + */ + void setSeriesRunningTotal(double total) { + this.seriesRunningTotal = total; + } + + /** + * Returns the crosshair state, if any. + * + * @return The crosshair state (possibly null). + * + * @since 1.0.11 + * + * @see #setCrosshairState(CategoryCrosshairState) + */ + public CategoryCrosshairState getCrosshairState() { + return this.crosshairState; + } + + /** + * Sets the crosshair state. + * + * @param state the new state (null permitted). + * + * @since 1.0.11 + * + * @see #getCrosshairState() + */ + public void setCrosshairState(CategoryCrosshairState state) { + this.crosshairState = state; + } + + /** + * Returns the index of the row relative to the visible rows. If no + * visible rows have been specified, the original row index is returned. + * If the row index is not included in the array of visible rows, + * -1 is returned. + * + * @param rowIndex the row index. + * + * @return The new row index or -1. + * + * @since 1.0.13 + */ + public int getVisibleSeriesIndex(int rowIndex) { + if (this.visibleSeries == null) { + return rowIndex; + } + int index = -1; + for (int vRow = 0; vRow < this.visibleSeries.length; vRow++) { + if (this.visibleSeries[vRow] == rowIndex) { + index = vRow; + break; + } + } + return index; + } + + /** + * Returns the number of visible series or -1 if no visible series have + * been specified. + * + * @return The number or -1. + * + * @since 1.0.13 + */ + public int getVisibleSeriesCount() { + if (this.visibleSeries == null) { + return -1; + } + return this.visibleSeries.length; + } + + /** + * Returns a copy of the visible series array. + * + * @return The visible series array (possibly null). + * + * @since 1.0.13 + */ + public int[] getVisibleSeriesArray() { + if (this.visibleSeries == null) { + return null; + } + int[] result = new int[this.visibleSeries.length]; + System.arraycopy(this.visibleSeries, 0, result, 0, + this.visibleSeries.length); + return result; + } + + /** + * Sets an array with the indices of the visible rows. + * + * @param visibleSeries the array (null permitted). + * + * @since 1.0.13 + */ + public void setVisibleSeriesArray(int[] visibleSeries) { + this.visibleSeries = visibleSeries; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/CategoryStepRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/CategoryStepRenderer.java new file mode 100755 index 0000000..b67f234 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/CategoryStepRenderer.java @@ -0,0 +1,373 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * CategoryStepRenderer.java + * ------------------------- + * + * (C) Copyright 2004-2008, by Brian Cole and Contributors. + * + * Original Author: Brian Cole; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 21-Apr-2004 : Version 1, contributed by Brian Cole (DG); + * 22-Apr-2004 : Fixed Checkstyle complaints (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 08-Mar-2005 : Added equals() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 30-Nov-2006 : Added checks for series visibility (DG); + * 22-Feb-2007 : Use new state object for reusable line, enable chart entities + * (for tooltips, URLs), added new getLegendItem() override (DG); + * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); + * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); + * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.renderer.xy.XYStepRenderer; +import org.jfree.data.category.CategoryDataset; +import org.jfree.util.PublicCloneable; + +/** + * A "step" renderer similar to {@link XYStepRenderer} but + * that can be used with the {@link CategoryPlot} class. The example shown + * here is generated by the CategoryStepChartDemo1.java program + * included in the JFreeChart Demo Collection: + *

+ * CategoryStepRendererSample.png + */ +public class CategoryStepRenderer extends AbstractCategoryItemRenderer + implements Cloneable, PublicCloneable, Serializable { + + /** + * State information for the renderer. + */ + protected static class State extends CategoryItemRendererState { + + /** + * A working line for re-use to avoid creating large numbers of + * objects. + */ + public Line2D line; + + /** + * Creates a new state instance. + * + * @param info collects plot rendering information (null + * permitted). + */ + public State(PlotRenderingInfo info) { + super(info); + this.line = new Line2D.Double(); + } + + } + + /** For serialization. */ + private static final long serialVersionUID = -5121079703118261470L; + + /** The stagger width. */ + public static final int STAGGER_WIDTH = 5; // could make this configurable + + /** + * A flag that controls whether or not the steps for multiple series are + * staggered. + */ + private boolean stagger = false; + + /** + * Creates a new renderer (stagger defaults to false). + */ + public CategoryStepRenderer() { + this(false); + } + + /** + * Creates a new renderer. + * + * @param stagger should the horizontal part of the step be staggered by + * series? + */ + public CategoryStepRenderer(boolean stagger) { + this.stagger = stagger; + setBaseLegendShape(new Rectangle2D.Double(-4.0, -3.0, 8.0, 6.0)); + } + + /** + * Returns the flag that controls whether the series steps are staggered. + * + * @return A boolean. + */ + public boolean getStagger() { + return this.stagger; + } + + /** + * Sets the flag that controls whether or not the series steps are + * staggered and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param shouldStagger a boolean. + */ + public void setStagger(boolean shouldStagger) { + this.stagger = shouldStagger; + fireChangeEvent(); + } + + /** + * Returns a legend item for a series. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return The legend item. + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + + CategoryPlot p = getPlot(); + if (p == null) { + return null; + } + + // check that a legend item needs to be displayed... + if (!isSeriesVisible(series) || !isSeriesVisibleInLegend(series)) { + return null; + } + + CategoryDataset dataset = p.getDataset(datasetIndex); + String label = getLegendItemLabelGenerator().generateLabel(dataset, + series); + String description = label; + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel(dataset, + series); + } + Shape shape = lookupLegendShape(series); + Paint paint = lookupSeriesPaint(series); + + LegendItem item = new LegendItem(label, description, toolTipText, + urlText, shape, paint); + item.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + item.setLabelPaint(labelPaint); + } + item.setSeriesKey(dataset.getRowKey(series)); + item.setSeriesIndex(series); + item.setDataset(dataset); + item.setDatasetIndex(datasetIndex); + return item; + } + + /** + * Creates a new state instance. This method is called from + * {@link #initialise(Graphics2D, Rectangle2D, CategoryPlot, int, + * PlotRenderingInfo)}, and we override it to ensure that the state + * contains a working Line2D instance. + * + * @param info the plot rendering info (null is permitted). + * + * @return A new state instance. + */ + @Override + protected CategoryItemRendererState createState(PlotRenderingInfo info) { + return new State(info); + } + + /** + * Draws a line taking into account the specified orientation. + *

+ * In version 1.0.5, the signature of this method was changed by the + * addition of the 'state' parameter. This is an incompatible change, but + * is considered a low risk because it is unlikely that anyone has + * subclassed this renderer. If this *does* cause trouble for you, please + * report it as a bug. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param orientation the plot orientation. + * @param x0 the x-coordinate for the start of the line. + * @param y0 the y-coordinate for the start of the line. + * @param x1 the x-coordinate for the end of the line. + * @param y1 the y-coordinate for the end of the line. + */ + protected void drawLine(Graphics2D g2, State state, + PlotOrientation orientation, double x0, double y0, double x1, + double y1) { + + if (orientation == PlotOrientation.VERTICAL) { + state.line.setLine(x0, y0, x1, y1); + g2.draw(state.line); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + state.line.setLine(y0, x0, y1, x1); // switch x and y + g2.draw(state.line); + } + + } + + /** + * Draw a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area in which the data is drawn. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, + int column, int pass) { + + // do nothing if item is not visible + if (!getItemVisible(row, column)) { + return; + } + + Number value = dataset.getValue(row, column); + if (value == null) { + return; + } + PlotOrientation orientation = plot.getOrientation(); + + // current data point... + double x1s = domainAxis.getCategoryStart(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()); + double x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()); + double x1e = 2 * x1 - x1s; // or: x1s + 2*(x1-x1s) + double y1 = rangeAxis.valueToJava2D(value.doubleValue(), dataArea, + plot.getRangeAxisEdge()); + g2.setPaint(getItemPaint(row, column)); + g2.setStroke(getItemStroke(row, column)); + + if (column != 0) { + Number previousValue = dataset.getValue(row, column - 1); + if (previousValue != null) { + // previous data point... + double previous = previousValue.doubleValue(); + double x0s = domainAxis.getCategoryStart(column - 1, + getColumnCount(), dataArea, plot.getDomainAxisEdge()); + double x0 = domainAxis.getCategoryMiddle(column - 1, + getColumnCount(), dataArea, plot.getDomainAxisEdge()); + double x0e = 2 * x0 - x0s; // or: x0s + 2*(x0-x0s) + double y0 = rangeAxis.valueToJava2D(previous, dataArea, + plot.getRangeAxisEdge()); + if (getStagger()) { + int xStagger = row * STAGGER_WIDTH; + if (xStagger > (x1s - x0e)) { + xStagger = (int) (x1s - x0e); + } + x1s = x0e + xStagger; + } + drawLine(g2, (State) state, orientation, x0e, y0, x1s, y0); + // extend x0's flat bar + + drawLine(g2, (State) state, orientation, x1s, y0, x1s, y1); + // upright bar + } + } + drawLine(g2, (State) state, orientation, x1s, y1, x1e, y1); + // x1's flat bar + + // draw the item labels if there are any... + if (isItemLabelVisible(row, column)) { + drawItemLabel(g2, orientation, dataset, row, column, x1, y1, + (value.doubleValue() < 0.0)); + } + + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + Rectangle2D hotspot = new Rectangle2D.Double(); + if (orientation == PlotOrientation.VERTICAL) { + hotspot.setRect(x1s, y1, x1e - x1s, 4.0); + } + else { + hotspot.setRect(y1 - 2.0, x1s, 4.0, x1e - x1s); + } + addItemEntity(entities, dataset, row, column, hotspot); + } + + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CategoryStepRenderer)) { + return false; + } + CategoryStepRenderer that = (CategoryStepRenderer) obj; + if (this.stagger != that.stagger) { + return false; + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/DefaultCategoryItemRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/DefaultCategoryItemRenderer.java new file mode 100755 index 0000000..a575758 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/DefaultCategoryItemRenderer.java @@ -0,0 +1,59 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------- + * DefaultCategoryItemRenderer.java + * -------------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Apr-2003 : Version 1 (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.io.Serializable; + +import org.jfree.chart.plot.CategoryPlot; + +/** + * A default renderer for the {@link CategoryPlot} class. This is simply an + * alias for the {@link LineAndShapeRenderer} class. + */ +public class DefaultCategoryItemRenderer extends LineAndShapeRenderer + implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -7793786349384231896L; + + // no new methods + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/GanttRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/GanttRenderer.java new file mode 100755 index 0000000..3901ab0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/GanttRenderer.java @@ -0,0 +1,634 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * GanttRenderer.java + * ------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Sep-2003 : Version 1 (DG); + * 23-Sep-2003 : Fixed Checkstyle issues (DG); + * 21-Oct-2003 : Bar width moved into CategoryItemRendererState (DG); + * 03-Feb-2004 : Added get/set methods for attributes (DG); + * 12-Aug-2004 : Fixed rendering problem with maxBarWidth attribute (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 20-Apr-2005 : Renamed CategoryLabelGenerator + * --> CategoryItemLabelGenerator (DG); + * 01-Dec-2005 : Fix for bug 1369954, drawBarOutline flag ignored (DG); + * ------------- JFREECHART 1.0.x -------------------------------------------- + * 17-Jan-2006 : Set includeBaseInRange flag to false (DG); + * 20-Mar-2007 : Implemented equals() and fixed serialization (DG); + * 24-Jun-2008 : Added new barPainter mechanism (DG); + * 26-Jun-2008 : Added crosshair support (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.category; + +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.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.CategoryItemLabelGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.gantt.GanttCategoryDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PaintUtilities; + +/** + * A renderer for simple Gantt charts. The example shown + * here is generated by the GanttDemo1.java program + * included in the JFreeChart Demo Collection: + *

+ * GanttRendererSample.png + */ +public class GanttRenderer extends IntervalBarRenderer + implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -4010349116350119512L; + + /** The paint for displaying the percentage complete. */ + private transient Paint completePaint; + + /** The paint for displaying the incomplete part of a task. */ + private transient Paint incompletePaint; + + /** + * Controls the starting edge of the progress indicator (expressed as a + * percentage of the overall bar width). + */ + private double startPercent; + + /** + * Controls the ending edge of the progress indicator (expressed as a + * percentage of the overall bar width). + */ + private double endPercent; + + /** + * Creates a new renderer. + */ + public GanttRenderer() { + super(); + setIncludeBaseInRange(false); + this.completePaint = Color.green; + this.incompletePaint = Color.red; + this.startPercent = 0.35; + this.endPercent = 0.65; + } + + /** + * Returns the paint used to show the percentage complete. + * + * @return The paint (never null. + * + * @see #setCompletePaint(Paint) + */ + public Paint getCompletePaint() { + return this.completePaint; + } + + /** + * Sets the paint used to show the percentage complete and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getCompletePaint() + */ + public void setCompletePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.completePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint used to show the percentage incomplete. + * + * @return The paint (never null). + * + * @see #setCompletePaint(Paint) + */ + public Paint getIncompletePaint() { + return this.incompletePaint; + } + + /** + * Sets the paint used to show the percentage incomplete and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getIncompletePaint() + */ + public void setIncompletePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.incompletePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the position of the start of the progress indicator, as a + * percentage of the bar width. + * + * @return The start percent. + * + * @see #setStartPercent(double) + */ + public double getStartPercent() { + return this.startPercent; + } + + /** + * Sets the position of the start of the progress indicator, as a + * percentage of the bar width, and sends a {@link RendererChangeEvent} to + * all registered listeners. + * + * @param percent the percent. + * + * @see #getStartPercent() + */ + public void setStartPercent(double percent) { + this.startPercent = percent; + fireChangeEvent(); + } + + /** + * Returns the position of the end of the progress indicator, as a + * percentage of the bar width. + * + * @return The end percent. + * + * @see #setEndPercent(double) + */ + public double getEndPercent() { + return this.endPercent; + } + + /** + * Sets the position of the end of the progress indicator, as a percentage + * of the bar width, and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param percent the percent. + * + * @see #getEndPercent() + */ + public void setEndPercent(double percent) { + this.endPercent = percent; + fireChangeEvent(); + } + + /** + * Draws the bar for a single (series, category) data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, + int column, int pass) { + + if (dataset instanceof GanttCategoryDataset) { + GanttCategoryDataset gcd = (GanttCategoryDataset) dataset; + drawTasks(g2, state, dataArea, plot, domainAxis, rangeAxis, gcd, + row, column); + } + else { // let the superclass handle it... + super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, + dataset, row, column, pass); + } + + } + + /** + * Draws the tasks/subtasks for one item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data plot area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the data. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + */ + protected void drawTasks(Graphics2D g2, + CategoryItemRendererState state, + Rectangle2D dataArea, + CategoryPlot plot, + CategoryAxis domainAxis, + ValueAxis rangeAxis, + GanttCategoryDataset dataset, + int row, + int column) { + + int count = dataset.getSubIntervalCount(row, column); + if (count == 0) { + drawTask(g2, state, dataArea, plot, domainAxis, rangeAxis, + dataset, row, column); + } + + PlotOrientation orientation = plot.getOrientation(); + for (int subinterval = 0; subinterval < count; subinterval++) { + + RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); + + // value 0 + Number value0 = dataset.getStartValue(row, column, subinterval); + if (value0 == null) { + return; + } + double translatedValue0 = rangeAxis.valueToJava2D( + value0.doubleValue(), dataArea, rangeAxisLocation); + + // value 1 + Number value1 = dataset.getEndValue(row, column, subinterval); + if (value1 == null) { + return; + } + double translatedValue1 = rangeAxis.valueToJava2D( + value1.doubleValue(), dataArea, rangeAxisLocation); + + if (translatedValue1 < translatedValue0) { + double temp = translatedValue1; + translatedValue1 = translatedValue0; + translatedValue0 = temp; + } + + double rectStart = calculateBarW0(plot, plot.getOrientation(), + dataArea, domainAxis, state, row, column); + double rectLength = Math.abs(translatedValue1 - translatedValue0); + double rectBreadth = state.getBarWidth(); + + // DRAW THE BARS... + Rectangle2D bar = null; + RectangleEdge barBase = null; + if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { + bar = new Rectangle2D.Double(translatedValue0, rectStart, + rectLength, rectBreadth); + barBase = RectangleEdge.LEFT; + } + else if (plot.getOrientation() == PlotOrientation.VERTICAL) { + bar = new Rectangle2D.Double(rectStart, translatedValue0, + rectBreadth, rectLength); + barBase = RectangleEdge.BOTTOM; + } + + Rectangle2D completeBar = null; + Rectangle2D incompleteBar = null; + Number percent = dataset.getPercentComplete(row, column, + subinterval); + double start = getStartPercent(); + double end = getEndPercent(); + if (percent != null) { + double p = percent.doubleValue(); + if (orientation == PlotOrientation.HORIZONTAL) { + completeBar = new Rectangle2D.Double(translatedValue0, + rectStart + start * rectBreadth, rectLength * p, + rectBreadth * (end - start)); + incompleteBar = new Rectangle2D.Double(translatedValue0 + + rectLength * p, rectStart + start * rectBreadth, + rectLength * (1 - p), rectBreadth * (end - start)); + } + else if (orientation == PlotOrientation.VERTICAL) { + completeBar = new Rectangle2D.Double(rectStart + start + * rectBreadth, translatedValue0 + rectLength + * (1 - p), rectBreadth * (end - start), + rectLength * p); + incompleteBar = new Rectangle2D.Double(rectStart + start + * rectBreadth, translatedValue0, rectBreadth + * (end - start), rectLength * (1 - p)); + } + + } + + if (getShadowsVisible()) { + getBarPainter().paintBarShadow(g2, this, row, column, bar, + barBase, true); + } + getBarPainter().paintBar(g2, this, row, column, bar, barBase); + + if (completeBar != null) { + g2.setPaint(getCompletePaint()); + g2.fill(completeBar); + } + if (incompleteBar != null) { + g2.setPaint(getIncompletePaint()); + g2.fill(incompleteBar); + } + if (isDrawBarOutline() + && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { + g2.setStroke(getItemStroke(row, column)); + g2.setPaint(getItemOutlinePaint(row, column)); + g2.draw(bar); + } + + if (subinterval == count - 1) { + // submit the current data point as a crosshair candidate + int datasetIndex = plot.indexOf(dataset); + Comparable columnKey = dataset.getColumnKey(column); + Comparable rowKey = dataset.getRowKey(row); + double xx = domainAxis.getCategorySeriesMiddle(columnKey, + rowKey, dataset, getItemMargin(), dataArea, + plot.getDomainAxisEdge()); + updateCrosshairValues(state.getCrosshairState(), + dataset.getRowKey(row), dataset.getColumnKey(column), + value1.doubleValue(), datasetIndex, xx, + translatedValue1, orientation); + + } + // collect entity and tool tip information... + if (state.getInfo() != null) { + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, bar); + } + } + } + } + + /** + * Draws a single task. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data plot area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the data. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + */ + protected void drawTask(Graphics2D g2, + CategoryItemRendererState state, + Rectangle2D dataArea, + CategoryPlot plot, + CategoryAxis domainAxis, + ValueAxis rangeAxis, + GanttCategoryDataset dataset, + int row, + int column) { + + PlotOrientation orientation = plot.getOrientation(); + RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); + + // Y0 + Number value0 = dataset.getEndValue(row, column); + if (value0 == null) { + return; + } + double java2dValue0 = rangeAxis.valueToJava2D(value0.doubleValue(), + dataArea, rangeAxisLocation); + + // Y1 + Number value1 = dataset.getStartValue(row, column); + if (value1 == null) { + return; + } + double java2dValue1 = rangeAxis.valueToJava2D(value1.doubleValue(), + dataArea, rangeAxisLocation); + + if (java2dValue1 < java2dValue0) { + double temp = java2dValue1; + java2dValue1 = java2dValue0; + java2dValue0 = temp; + value1 = value0; + } + + double rectStart = calculateBarW0(plot, orientation, dataArea, + domainAxis, state, row, column); + double rectBreadth = state.getBarWidth(); + double rectLength = Math.abs(java2dValue1 - java2dValue0); + + Rectangle2D bar = null; + RectangleEdge barBase = null; + if (orientation == PlotOrientation.HORIZONTAL) { + bar = new Rectangle2D.Double(java2dValue0, rectStart, rectLength, + rectBreadth); + barBase = RectangleEdge.LEFT; + } + else if (orientation == PlotOrientation.VERTICAL) { + bar = new Rectangle2D.Double(rectStart, java2dValue1, rectBreadth, + rectLength); + barBase = RectangleEdge.BOTTOM; + } + + Rectangle2D completeBar = null; + Rectangle2D incompleteBar = null; + Number percent = dataset.getPercentComplete(row, column); + double start = getStartPercent(); + double end = getEndPercent(); + if (percent != null) { + double p = percent.doubleValue(); + if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { + completeBar = new Rectangle2D.Double(java2dValue0, + rectStart + start * rectBreadth, rectLength * p, + rectBreadth * (end - start)); + incompleteBar = new Rectangle2D.Double(java2dValue0 + + rectLength * p, rectStart + start * rectBreadth, + rectLength * (1 - p), rectBreadth * (end - start)); + } + else if (plot.getOrientation() == PlotOrientation.VERTICAL) { + completeBar = new Rectangle2D.Double(rectStart + start + * rectBreadth, java2dValue1 + rectLength * (1 - p), + rectBreadth * (end - start), rectLength * p); + incompleteBar = new Rectangle2D.Double(rectStart + start + * rectBreadth, java2dValue1, rectBreadth * (end + - start), rectLength * (1 - p)); + } + + } + + if (getShadowsVisible()) { + getBarPainter().paintBarShadow(g2, this, row, column, bar, + barBase, true); + } + getBarPainter().paintBar(g2, this, row, column, bar, barBase); + + if (completeBar != null) { + g2.setPaint(getCompletePaint()); + g2.fill(completeBar); + } + if (incompleteBar != null) { + g2.setPaint(getIncompletePaint()); + g2.fill(incompleteBar); + } + + // draw the outline... + if (isDrawBarOutline() + && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { + Stroke stroke = getItemOutlineStroke(row, column); + Paint paint = getItemOutlinePaint(row, column); + if (stroke != null && paint != null) { + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(bar); + } + } + + CategoryItemLabelGenerator generator = getItemLabelGenerator(row, + column); + if (generator != null && isItemLabelVisible(row, column)) { + drawItemLabel(g2, dataset, row, column, plot, generator, bar, + false); + } + + // submit the current data point as a crosshair candidate + int datasetIndex = plot.indexOf(dataset); + Comparable columnKey = dataset.getColumnKey(column); + Comparable rowKey = dataset.getRowKey(row); + double xx = domainAxis.getCategorySeriesMiddle(columnKey, rowKey, + dataset, getItemMargin(), dataArea, plot.getDomainAxisEdge()); + updateCrosshairValues(state.getCrosshairState(), + dataset.getRowKey(row), dataset.getColumnKey(column), + value1.doubleValue(), datasetIndex, xx, java2dValue1, + orientation); + + // collect entity and tool tip information... + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, bar); + } + } + + /** + * Returns the Java2D coordinate for the middle of the specified data item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param dataset the dataset. + * @param axis the axis. + * @param area the drawing area. + * @param edge the edge along which the axis lies. + * + * @return The Java2D coordinate. + * + * @since 1.0.11 + */ + @Override + public double getItemMiddle(Comparable rowKey, Comparable columnKey, + CategoryDataset dataset, CategoryAxis axis, Rectangle2D area, + RectangleEdge edge) { + return axis.getCategorySeriesMiddle(columnKey, rowKey, dataset, + getItemMargin(), area, edge); + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof GanttRenderer)) { + return false; + } + GanttRenderer that = (GanttRenderer) obj; + if (!PaintUtilities.equal(this.completePaint, that.completePaint)) { + return false; + } + if (!PaintUtilities.equal(this.incompletePaint, that.incompletePaint)) { + return false; + } + if (this.startPercent != that.startPercent) { + return false; + } + if (this.endPercent != that.endPercent) { + return false; + } + return super.equals(obj); + } + + /** + * 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.completePaint, stream); + SerialUtilities.writePaint(this.incompletePaint, 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.completePaint = SerialUtilities.readPaint(stream); + this.incompletePaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/GradientBarPainter.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/GradientBarPainter.java new file mode 100755 index 0000000..55d0ab8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/GradientBarPainter.java @@ -0,0 +1,381 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * GradientBarPainter.java + * ----------------------- + * (C) Copyright 2008-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 19-Jun-2008 : Version 1 (DG); + * 15-Aug-2008 : Use outline paint and shadow paint (DG); + * 17-Sep-2013 : Fix coordinate error in gradient (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Stroke; +import java.awt.geom.Rectangle2D; +import java.awt.geom.RectangularShape; +import java.io.Serializable; + +import org.jfree.chart.HashUtilities; +import org.jfree.ui.RectangleEdge; + +/** + * An implementation of the {@link BarPainter} interface that uses several + * gradient fills to enrich the appearance of the bars. + * + * @since 1.0.11 + */ +public class GradientBarPainter implements BarPainter, Serializable { + + /** The division point between the first and second gradient regions. */ + private double g1; + + /** The division point between the second and third gradient regions. */ + private double g2; + + /** The division point between the third and fourth gradient regions. */ + private double g3; + + /** + * Creates a new instance. + */ + public GradientBarPainter() { + this(0.10, 0.20, 0.80); + } + + /** + * Creates a new instance. + * + * @param g1 + * @param g2 + * @param g3 + */ + public GradientBarPainter(double g1, double g2, double g3) { + this.g1 = g1; + this.g2 = g2; + this.g3 = g3; + } + + /** + * Paints a single bar instance. + * + * @param g2 the graphics target. + * @param renderer the renderer. + * @param row the row index. + * @param column the column index. + * @param bar the bar + * @param base indicates which side of the rectangle is the base of the + * bar. + */ + @Override + public void paintBar(Graphics2D g2, BarRenderer renderer, int row, + int column, RectangularShape bar, RectangleEdge base) { + + Paint itemPaint = renderer.getItemPaint(row, column); + + Color c0, c1; + if (itemPaint instanceof Color) { + c0 = (Color) itemPaint; + c1 = c0.brighter(); + } + else if (itemPaint instanceof GradientPaint) { + GradientPaint gp = (GradientPaint) itemPaint; + c0 = gp.getColor1(); + c1 = gp.getColor2(); + } + else { + c0 = Color.BLUE; + c1 = Color.BLUE.brighter(); + } + + // as a special case, if the bar colour has alpha == 0, we draw + // nothing. + if (c0.getAlpha() == 0) { + return; + } + + if (base == RectangleEdge.TOP || base == RectangleEdge.BOTTOM) { + Rectangle2D[] regions = splitVerticalBar(bar, this.g1, this.g2, + this.g3); + GradientPaint gp = new GradientPaint((float) regions[0].getMinX(), + 0.0f, c0, (float) regions[0].getMaxX(), 0.0f, Color.WHITE); + g2.setPaint(gp); + g2.fill(regions[0]); + + gp = new GradientPaint((float) regions[1].getMinX(), 0.0f, + Color.WHITE, (float) regions[1].getMaxX(), 0.0f, c0); + g2.setPaint(gp); + g2.fill(regions[1]); + + gp = new GradientPaint((float) regions[2].getMinX(), 0.0f, c0, + (float) regions[2].getMaxX(), 0.0f, c1); + g2.setPaint(gp); + g2.fill(regions[2]); + + gp = new GradientPaint((float) regions[3].getMinX(), 0.0f, c1, + (float) regions[3].getMaxX(), 0.0f, c0); + g2.setPaint(gp); + g2.fill(regions[3]); + } + else if (base == RectangleEdge.LEFT || base == RectangleEdge.RIGHT) { + Rectangle2D[] regions = splitHorizontalBar(bar, this.g1, this.g2, + this.g3); + GradientPaint gp = new GradientPaint(0.0f, + (float) regions[0].getMinY(), c0, 0.0f, + (float) regions[0].getMaxY(), Color.WHITE); + g2.setPaint(gp); + g2.fill(regions[0]); + + gp = new GradientPaint(0.0f, (float) regions[1].getMinY(), + Color.WHITE, 0.0f, (float) regions[1].getMaxY(), c0); + g2.setPaint(gp); + g2.fill(regions[1]); + + gp = new GradientPaint(0.0f, (float) regions[2].getMinY(), c0, + 0.0f, (float) regions[2].getMaxY(), c1); + g2.setPaint(gp); + g2.fill(regions[2]); + + gp = new GradientPaint(0.0f, (float) regions[3].getMinY(), c1, + 0.0f, (float) regions[3].getMaxY(), c0); + g2.setPaint(gp); + g2.fill(regions[3]); + + } + + // draw the outline... + if (renderer.isDrawBarOutline() + /*&& state.getBarWidth() > renderer.BAR_OUTLINE_WIDTH_THRESHOLD*/) { + Stroke stroke = renderer.getItemOutlineStroke(row, column); + Paint paint = renderer.getItemOutlinePaint(row, column); + if (stroke != null && paint != null) { + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(bar); + } + } + + } + + /** + * Paints a single bar instance. + * + * @param g2 the graphics target. + * @param renderer the renderer. + * @param row the row index. + * @param column the column index. + * @param bar the bar + * @param base indicates which side of the rectangle is the base of the + * bar. + * @param pegShadow peg the shadow to the base of the bar? + */ + @Override + public void paintBarShadow(Graphics2D g2, BarRenderer renderer, int row, + int column, RectangularShape bar, RectangleEdge base, + boolean pegShadow) { + + // handle a special case - if the bar colour has alpha == 0, it is + // invisible so we shouldn't draw any shadow + Paint itemPaint = renderer.getItemPaint(row, column); + if (itemPaint instanceof Color) { + Color c = (Color) itemPaint; + if (c.getAlpha() == 0) { + return; + } + } + + RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(), + renderer.getShadowYOffset(), base, pegShadow); + g2.setPaint(renderer.getShadowPaint()); + g2.fill(shadow); + + } + + /** + * Creates a shadow for the bar. + * + * @param bar the bar shape. + * @param xOffset the x-offset for the shadow. + * @param yOffset the y-offset for the shadow. + * @param base the edge that is the base of the bar. + * @param pegShadow peg the shadow to the base? + * + * @return A rectangle for the shadow. + */ + private Rectangle2D createShadow(RectangularShape bar, double xOffset, + double yOffset, RectangleEdge base, boolean pegShadow) { + double x0 = bar.getMinX(); + double x1 = bar.getMaxX(); + double y0 = bar.getMinY(); + double y1 = bar.getMaxY(); + if (base == RectangleEdge.TOP) { + x0 += xOffset; + x1 += xOffset; + if (!pegShadow) { + y0 += yOffset; + } + y1 += yOffset; + } + else if (base == RectangleEdge.BOTTOM) { + x0 += xOffset; + x1 += xOffset; + y0 += yOffset; + if (!pegShadow) { + y1 += yOffset; + } + } + else if (base == RectangleEdge.LEFT) { + if (!pegShadow) { + x0 += xOffset; + } + x1 += xOffset; + y0 += yOffset; + y1 += yOffset; + } + else if (base == RectangleEdge.RIGHT) { + x0 += xOffset; + if (!pegShadow) { + x1 += xOffset; + } + y0 += yOffset; + y1 += yOffset; + } + return new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); + } + + /** + * Splits a bar into subregions (elsewhere, these subregions will have + * different gradients applied to them). + * + * @param bar the bar shape. + * @param a the first division. + * @param b the second division. + * @param c the third division. + * + * @return An array containing four subregions. + */ + private Rectangle2D[] splitVerticalBar(RectangularShape bar, double a, + double b, double c) { + Rectangle2D[] result = new Rectangle2D[4]; + double x0 = bar.getMinX(); + double x1 = Math.rint(x0 + (bar.getWidth() * a)); + double x2 = Math.rint(x0 + (bar.getWidth() * b)); + double x3 = Math.rint(x0 + (bar.getWidth() * c)); + result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), + x1 - x0, bar.getHeight()); + result[1] = new Rectangle2D.Double(x1, bar.getMinY(), x2 - x1, + bar.getHeight()); + result[2] = new Rectangle2D.Double(x2, bar.getMinY(), x3 - x2, + bar.getHeight()); + result[3] = new Rectangle2D.Double(x3, bar.getMinY(), + bar.getMaxX() - x3, bar.getHeight()); + return result; + } + + /** + * Splits a bar into subregions (elsewhere, these subregions will have + * different gradients applied to them). + * + * @param bar the bar shape. + * @param a the first division. + * @param b the second division. + * @param c the third division. + * + * @return An array containing four subregions. + */ + private Rectangle2D[] splitHorizontalBar(RectangularShape bar, double a, + double b, double c) { + Rectangle2D[] result = new Rectangle2D[4]; + double y0 = bar.getMinY(); + double y1 = Math.rint(y0 + (bar.getHeight() * a)); + double y2 = Math.rint(y0 + (bar.getHeight() * b)); + double y3 = Math.rint(y0 + (bar.getHeight() * c)); + result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), + bar.getWidth(), y1 - y0); + result[1] = new Rectangle2D.Double(bar.getMinX(), y1, bar.getWidth(), + y2 - y1); + result[2] = new Rectangle2D.Double(bar.getMinX(), y2, bar.getWidth(), + y3 - y2); + result[3] = new Rectangle2D.Double(bar.getMinX(), y3, bar.getWidth(), + bar.getMaxY() - y3); + return result; + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the obj (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof GradientBarPainter)) { + return false; + } + GradientBarPainter that = (GradientBarPainter) obj; + if (this.g1 != that.g1) { + return false; + } + if (this.g2 != that.g2) { + return false; + } + if (this.g3 != that.g3) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int hash = 37; + hash = HashUtilities.hashCode(hash, this.g1); + hash = HashUtilities.hashCode(hash, this.g2); + hash = HashUtilities.hashCode(hash, this.g3); + return hash; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java new file mode 100755 index 0000000..0ab7225 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/GroupedStackedBarRenderer.java @@ -0,0 +1,371 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * GroupedStackedBarRenderer.java + * ------------------------------ + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Apr-2004 : Version 1 (DG); + * 08-Jul-2004 : Added equals() method (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds (DG); + * 20-Apr-2005 : Renamed CategoryLabelGenerator + * --> CategoryItemLabelGenerator (DG); + * 22-Sep-2005 : Renamed getMaxBarWidth() --> getMaximumBarWidth() (DG); + * 20-Dec-2007 : Fix for bug 1848961 (DG); + * 24-Jun-2008 : Added new barPainter mechanism (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.CategoryItemLabelGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.KeyToGroupMap; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PublicCloneable; + +/** + * A renderer that draws stacked bars within groups. This will probably be + * merged with the {@link StackedBarRenderer} class at some point. The example + * shown here is generated by the StackedBarChartDemo4.java + * program included in the JFreeChart Demo Collection: + *

+ * GroupedStackedBarRendererSample.png + */ +public class GroupedStackedBarRenderer extends StackedBarRenderer + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -2725921399005922939L; + + /** A map used to assign each series to a group. */ + private KeyToGroupMap seriesToGroupMap; + + /** + * Creates a new renderer. + */ + public GroupedStackedBarRenderer() { + super(); + this.seriesToGroupMap = new KeyToGroupMap(); + } + + /** + * Updates the map used to assign each series to a group, and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param map the map (null not permitted). + */ + public void setSeriesToGroupMap(KeyToGroupMap map) { + ParamChecks.nullNotPermitted(map, "map"); + this.seriesToGroupMap = map; + fireChangeEvent(); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (or null if the dataset is + * null or empty). + */ + @Override + public Range findRangeBounds(CategoryDataset dataset) { + if (dataset == null) { + return null; + } + Range r = DatasetUtilities.findStackedRangeBounds( + dataset, this.seriesToGroupMap); + return r; + } + + /** + * Calculates the bar width and stores it in the renderer state. We + * override the method in the base class to take account of the + * series-to-group mapping. + * + * @param plot the plot. + * @param dataArea the data area. + * @param rendererIndex the renderer index. + * @param state the renderer state. + */ + @Override + protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, + int rendererIndex, CategoryItemRendererState state) { + + // calculate the bar width + CategoryAxis xAxis = plot.getDomainAxisForDataset(rendererIndex); + CategoryDataset data = plot.getDataset(rendererIndex); + if (data != null) { + PlotOrientation orientation = plot.getOrientation(); + double space = 0.0; + if (orientation == PlotOrientation.HORIZONTAL) { + space = dataArea.getHeight(); + } + else if (orientation == PlotOrientation.VERTICAL) { + space = dataArea.getWidth(); + } + double maxWidth = space * getMaximumBarWidth(); + int groups = this.seriesToGroupMap.getGroupCount(); + int categories = data.getColumnCount(); + int columns = groups * categories; + double categoryMargin = 0.0; + double itemMargin = 0.0; + if (categories > 1) { + categoryMargin = xAxis.getCategoryMargin(); + } + if (groups > 1) { + itemMargin = getItemMargin(); + } + + double used = space * (1 - xAxis.getLowerMargin() + - xAxis.getUpperMargin() + - categoryMargin - itemMargin); + if (columns > 0) { + state.setBarWidth(Math.min(used / columns, maxWidth)); + } + else { + state.setBarWidth(Math.min(used, maxWidth)); + } + } + + } + + /** + * Calculates the coordinate of the first "side" of a bar. This will be + * the minimum x-coordinate for a vertical bar, and the minimum + * y-coordinate for a horizontal bar. + * + * @param plot the plot. + * @param orientation the plot orientation. + * @param dataArea the data area. + * @param domainAxis the domain axis. + * @param state the renderer state (has the bar width precalculated). + * @param row the row index. + * @param column the column index. + * + * @return The coordinate. + */ + @Override + protected double calculateBarW0(CategoryPlot plot, + PlotOrientation orientation, Rectangle2D dataArea, + CategoryAxis domainAxis, CategoryItemRendererState state, + int row, int column) { + // calculate bar width... + double space; + if (orientation == PlotOrientation.HORIZONTAL) { + space = dataArea.getHeight(); + } + else { + space = dataArea.getWidth(); + } + double barW0 = domainAxis.getCategoryStart(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()); + int groupCount = this.seriesToGroupMap.getGroupCount(); + int groupIndex = this.seriesToGroupMap.getGroupIndex( + this.seriesToGroupMap.getGroup(plot.getDataset( + plot.getIndexOf(this)).getRowKey(row))); + int categoryCount = getColumnCount(); + if (groupCount > 1) { + double groupGap = space * getItemMargin() + / (categoryCount * (groupCount - 1)); + double groupW = calculateSeriesWidth(space, domainAxis, + categoryCount, groupCount); + barW0 = barW0 + groupIndex * (groupW + groupGap) + + (groupW / 2.0) - (state.getBarWidth() / 2.0); + } + else { + barW0 = domainAxis.getCategoryMiddle(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()) + - state.getBarWidth() / 2.0; + } + return barW0; + } + + /** + * Draws a stacked bar for a specific item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the plot area. + * @param plot the plot. + * @param domainAxis the domain (category) axis. + * @param rangeAxis the range (value) axis. + * @param dataset the data. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, + int column, int pass) { + + // nothing is drawn for null values... + Number dataValue = dataset.getValue(row, column); + if (dataValue == null) { + return; + } + + double value = dataValue.doubleValue(); + Comparable group = this.seriesToGroupMap.getGroup( + dataset.getRowKey(row)); + PlotOrientation orientation = plot.getOrientation(); + double barW0 = calculateBarW0(plot, orientation, dataArea, domainAxis, + state, row, column); + + double positiveBase = 0.0; + double negativeBase = 0.0; + + for (int i = 0; i < row; i++) { + if (group.equals(this.seriesToGroupMap.getGroup( + dataset.getRowKey(i)))) { + Number v = dataset.getValue(i, column); + if (v != null) { + double d = v.doubleValue(); + if (d > 0) { + positiveBase = positiveBase + d; + } + else { + negativeBase = negativeBase + d; + } + } + } + } + + double translatedBase; + double translatedValue; + boolean positive = (value > 0.0); + boolean inverted = rangeAxis.isInverted(); + RectangleEdge barBase; + if (orientation == PlotOrientation.HORIZONTAL) { + if (positive && inverted || !positive && !inverted) { + barBase = RectangleEdge.RIGHT; + } + else { + barBase = RectangleEdge.LEFT; + } + } + else { + if (positive && !inverted || !positive && inverted) { + barBase = RectangleEdge.BOTTOM; + } + else { + barBase = RectangleEdge.TOP; + } + } + RectangleEdge location = plot.getRangeAxisEdge(); + if (value > 0.0) { + translatedBase = rangeAxis.valueToJava2D(positiveBase, dataArea, + location); + translatedValue = rangeAxis.valueToJava2D(positiveBase + value, + dataArea, location); + } + else { + translatedBase = rangeAxis.valueToJava2D(negativeBase, dataArea, + location); + translatedValue = rangeAxis.valueToJava2D(negativeBase + value, + dataArea, location); + } + double barL0 = Math.min(translatedBase, translatedValue); + double barLength = Math.max(Math.abs(translatedValue - translatedBase), + getMinimumBarLength()); + + Rectangle2D bar; + if (orientation == PlotOrientation.HORIZONTAL) { + bar = new Rectangle2D.Double(barL0, barW0, barLength, + state.getBarWidth()); + } + else { + bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(), + barLength); + } + getBarPainter().paintBar(g2, this, row, column, bar, barBase); + + CategoryItemLabelGenerator generator = getItemLabelGenerator(row, + column); + if (generator != null && isItemLabelVisible(row, column)) { + drawItemLabel(g2, dataset, row, column, plot, generator, bar, + (value < 0.0)); + } + + // collect entity and tool tip information... + if (state.getInfo() != null) { + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, bar); + } + } + + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof GroupedStackedBarRenderer)) { + return false; + } + GroupedStackedBarRenderer that = (GroupedStackedBarRenderer) obj; + if (!this.seriesToGroupMap.equals(that.seriesToGroupMap)) { + return false; + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/IntervalBarRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/IntervalBarRenderer.java new file mode 100755 index 0000000..5e0fd4e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/IntervalBarRenderer.java @@ -0,0 +1,274 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * IntervalBarRenderer.java + * ------------------------ + * (C) Copyright 2002-2011, by Jeremy Bowman. + * + * Original Author: Jeremy Bowman; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Christian W. Zuckschwerdt; + * Peter Kolb (patch 2497611, 2791407); + * + * Changes + * ------- + * 29-Apr-2002 : Version 1, contributed by Jeremy Bowman (DG); + * 11-May-2002 : Use CategoryPlot.getLabelsVisible() (JB); + * 29-May-2002 : Added constructors (DG); + * 26-Jun-2002 : Added axis to initialise method (DG); + * 20-Sep-2002 : Added basic support for chart entities (DG); + * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and + * CategoryToolTipGenerator interface (DG); + * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 19-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 08-Sep-2003 : Added checks for null values (DG); + * 07-Oct-2003 : Added renderer state (DG); + * 21-Oct-2003 : Bar width moved into renderer state (DG); + * 23-Dec-2003 : Removed the deprecated MultiIntervalCategoryDataset + * interface (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 20-Apr-2005 : Renamed CategoryLabelGenerator + * --> CategoryItemLabelGenerator (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 24-Jun-2008 : Added new barPainter mechanism (DG); + * 07-Oct-2008 : Override equals() method to fix minor bug (DG); + * 14-Jan-2009 : Added support for seriesVisible flags (PK); + * 16-May-2009 : The findRangeBounds() method needs to include the dataset + * interval (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * 30-Oct-2011 : Fixed alignment when setMaximumBarWidth is applied (DG); + */ + +package org.jfree.chart.renderer.category; + +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.entity.EntityCollection; +import org.jfree.chart.labels.CategoryItemLabelGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.IntervalCategoryDataset; +import org.jfree.ui.RectangleEdge; + +/** + * A renderer that handles the drawing of bars for a bar plot where + * each bar has a high and low value. This renderer is for use with the + * {@link CategoryPlot} class. The example shown here is generated by the + * IntervalBarChartDemo1.java program included in the JFreeChart + * Demo Collection: + *

+ * IntervalBarRendererSample.png + */ +public class IntervalBarRenderer extends BarRenderer { + + /** For serialization. */ + private static final long serialVersionUID = -5068857361615528725L; + + /** + * Constructs a new renderer. + */ + public IntervalBarRenderer() { + super(); + } + + /** + * Returns the range of values from the specified dataset. For this + * renderer, this is equivalent to calling + * findRangeBounds(dataset, true). + * + * @param dataset the dataset (null permitted). + * + * @return The range (or null if the dataset is + * null or empty). + */ + @Override + public Range findRangeBounds(CategoryDataset dataset) { + return findRangeBounds(dataset, true); + } + + /** + * Draws the bar for a single (series, category) data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, + int pass) { + + if (dataset instanceof IntervalCategoryDataset) { + IntervalCategoryDataset d = (IntervalCategoryDataset) dataset; + drawInterval(g2, state, dataArea, plot, domainAxis, rangeAxis, + d, row, column); + } + else { + super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, + dataset, row, column, pass); + } + + } + + /** + * Draws a single interval. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data plot area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the data. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + */ + protected void drawInterval(Graphics2D g2, + CategoryItemRendererState state, + Rectangle2D dataArea, + CategoryPlot plot, + CategoryAxis domainAxis, + ValueAxis rangeAxis, + IntervalCategoryDataset dataset, + int row, + int column) { + + int visibleRow = state.getVisibleSeriesIndex(row); + if (visibleRow < 0) { + return; + } + + PlotOrientation orientation = plot.getOrientation(); + double rectX = 0.0; + double rectY = 0.0; + + RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); + + // Y0 + Number value0 = dataset.getEndValue(row, column); + if (value0 == null) { + return; + } + double java2dValue0 = rangeAxis.valueToJava2D(value0.doubleValue(), + dataArea, rangeAxisLocation); + + // Y1 + Number value1 = dataset.getStartValue(row, column); + if (value1 == null) { + return; + } + double java2dValue1 = rangeAxis.valueToJava2D( + value1.doubleValue(), dataArea, rangeAxisLocation); + + if (java2dValue1 < java2dValue0) { + double temp = java2dValue1; + java2dValue1 = java2dValue0; + java2dValue0 = temp; + } + + // BAR WIDTH + double rectWidth = state.getBarWidth(); + + // BAR HEIGHT + double rectHeight = Math.abs(java2dValue1 - java2dValue0); + + RectangleEdge barBase = RectangleEdge.LEFT; + if (orientation == PlotOrientation.HORIZONTAL) { + // BAR Y + rectX = java2dValue0; + rectY = calculateBarW0(getPlot(), orientation, dataArea, + domainAxis, state, visibleRow, column); + rectHeight = state.getBarWidth(); + rectWidth = Math.abs(java2dValue1 - java2dValue0); + barBase = RectangleEdge.LEFT; + } + else if (orientation == PlotOrientation.VERTICAL) { + // BAR X + rectX = calculateBarW0(getPlot(), orientation, dataArea, + domainAxis, state, visibleRow, column); + rectY = java2dValue0; + barBase = RectangleEdge.BOTTOM; + } + Rectangle2D bar = new Rectangle2D.Double(rectX, rectY, rectWidth, + rectHeight); + BarPainter painter = getBarPainter(); + if (getShadowsVisible()) { + painter.paintBarShadow(g2, this, row, column, bar, barBase, false); + } + getBarPainter().paintBar(g2, this, row, column, bar, barBase); + + CategoryItemLabelGenerator generator = getItemLabelGenerator(row, + column); + if (generator != null && isItemLabelVisible(row, column)) { + drawItemLabel(g2, dataset, row, column, plot, generator, bar, + false); + } + + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, bar); + } + + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof IntervalBarRenderer)) { + return false; + } + // there are no fields to check + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/LayeredBarRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/LayeredBarRenderer.java new file mode 100755 index 0000000..fd8f1a7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/LayeredBarRenderer.java @@ -0,0 +1,465 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * LayeredBarRenderer.java + * ----------------------- + * (C) Copyright 2003-2009, by Arnaud Lelievre and Contributors. + * + * Original Author: Arnaud Lelievre (for Garden); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Zoheb Borbora; + * + * Changes + * ------- + * 28-Aug-2003 : Version 1 (AL); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 07-Oct-2003 : Added renderer state (DG); + * 21-Oct-2003 : Bar width moved to renderer state (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 20-Apr-2005 : Renamed CategoryLabelGenerator + * --> CategoryItemLabelGenerator (DG); + * 17-Nov-2005 : Added support for gradient paint (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 18-Aug-2006 : Fixed the bar width calculation to respect the maximum bar + * width setting (thanks to Zoheb Borbora) (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Stroke; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.labels.CategoryItemLabelGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.category.CategoryDataset; +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.ObjectList; + +/** + * A {@link CategoryItemRenderer} that represents data using bars which are + * superimposed. The example shown here is generated by the + * LayeredBarChartDemo1.java program included in the JFreeChart + * Demo Collection: + *

+ * LayeredBarRendererSample.png + */ +public class LayeredBarRenderer extends BarRenderer implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -8716572894780469487L; + + /** A list of the width of each series bar. */ + protected ObjectList seriesBarWidthList; + + /** + * Default constructor. + */ + public LayeredBarRenderer() { + super(); + this.seriesBarWidthList = new ObjectList(); + } + + /** + * Returns the bar width for a series, or Double.NaN if no + * width has been set. + * + * @param series the series index (zero based). + * + * @return The width for the series (1.0=100%, it is the maximum). + */ + public double getSeriesBarWidth(int series) { + double result = Double.NaN; + Number n = (Number) this.seriesBarWidthList.get(series); + if (n != null) { + result = n.doubleValue(); + } + return result; + } + + /** + * Sets the width of the bars of a series. + * + * @param series the series index (zero based). + * @param width the width of the series bar in percentage (1.0=100%, it is + * the maximum). + */ + public void setSeriesBarWidth(int series, double width) { + this.seriesBarWidthList.set(series, new Double(width)); + } + + /** + * Calculates the bar width and stores it in the renderer state. + * + * @param plot the plot. + * @param dataArea the data area. + * @param rendererIndex the renderer index. + * @param state the renderer state. + */ + @Override + protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, + int rendererIndex, CategoryItemRendererState state) { + + // calculate the bar width - this calculation differs from the + // BarRenderer calculation because the bars are layered on top of one + // another, so there is effectively only one bar per category for + // the purpose of the bar width calculation + CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); + CategoryDataset dataset = plot.getDataset(rendererIndex); + if (dataset != null) { + int columns = dataset.getColumnCount(); + int rows = dataset.getRowCount(); + double space = 0.0; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + space = dataArea.getHeight(); + } + else if (orientation == PlotOrientation.VERTICAL) { + space = dataArea.getWidth(); + } + double maxWidth = space * getMaximumBarWidth(); + double categoryMargin = 0.0; + if (columns > 1) { + categoryMargin = domainAxis.getCategoryMargin(); + } + double used = space * (1 - domainAxis.getLowerMargin() + - domainAxis.getUpperMargin() - categoryMargin); + if ((rows * columns) > 0) { + state.setBarWidth(Math.min(used / (dataset.getColumnCount()), + maxWidth)); + } + else { + state.setBarWidth(Math.min(used, maxWidth)); + } + } + } + + /** + * Draws the bar for one item in the dataset. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the plot area. + * @param plot the plot. + * @param domainAxis the domain (category) axis. + * @param rangeAxis the range (value) axis. + * @param data the data. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset data, int row, int column, + int pass) { + + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + drawHorizontalItem(g2, state, dataArea, plot, domainAxis, + rangeAxis, data, row, column); + } + else if (orientation == PlotOrientation.VERTICAL) { + drawVerticalItem(g2, state, dataArea, plot, domainAxis, rangeAxis, + data, row, column); + } + + } + + /** + * Draws the bar for a single (series, category) data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + */ + protected void drawHorizontalItem(Graphics2D g2, + CategoryItemRendererState state, + Rectangle2D dataArea, + CategoryPlot plot, + CategoryAxis domainAxis, + ValueAxis rangeAxis, + CategoryDataset dataset, + int row, + int column) { + + // nothing is drawn for null values... + Number dataValue = dataset.getValue(row, column); + if (dataValue == null) { + return; + } + + // X + double value = dataValue.doubleValue(); + double base = 0.0; + double lclip = getLowerClip(); + double uclip = getUpperClip(); + if (uclip <= 0.0) { // cases 1, 2, 3 and 4 + if (value >= uclip) { + return; // bar is not visible + } + base = uclip; + if (value <= lclip) { + value = lclip; + } + } + else if (lclip <= 0.0) { // cases 5, 6, 7 and 8 + if (value >= uclip) { + value = uclip; + } + else { + if (value <= lclip) { + value = lclip; + } + } + } + else { // cases 9, 10, 11 and 12 + if (value <= lclip) { + return; // bar is not visible + } + base = lclip; + if (value >= uclip) { + value = uclip; + } + } + + RectangleEdge edge = plot.getRangeAxisEdge(); + double transX1 = rangeAxis.valueToJava2D(base, dataArea, edge); + double transX2 = rangeAxis.valueToJava2D(value, dataArea, edge); + double rectX = Math.min(transX1, transX2); + double rectWidth = Math.abs(transX2 - transX1); + + // Y + double rectY = domainAxis.getCategoryMiddle(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() / 2.0; + + int seriesCount = getRowCount(); + + // draw the bar... + double shift = 0.0; + double rectHeight; + double widthFactor = 1.0; + double seriesBarWidth = getSeriesBarWidth(row); + if (!Double.isNaN(seriesBarWidth)) { + widthFactor = seriesBarWidth; + } + rectHeight = widthFactor * state.getBarWidth(); + rectY = rectY + (1 - widthFactor) * state.getBarWidth() / 2.0; + if (seriesCount > 1) { + shift = rectHeight * 0.20 / (seriesCount - 1); + } + + Rectangle2D bar = new Rectangle2D.Double(rectX, + (rectY + ((seriesCount - 1 - row) * shift)), rectWidth, + (rectHeight - (seriesCount - 1 - row) * shift * 2)); + + Paint itemPaint = getItemPaint(row, column); + GradientPaintTransformer t = getGradientPaintTransformer(); + if (t != null && itemPaint instanceof GradientPaint) { + itemPaint = t.transform((GradientPaint) itemPaint, bar); + } + g2.setPaint(itemPaint); + g2.fill(bar); + + // draw the outline... + if (isDrawBarOutline() + && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { + Stroke stroke = getItemOutlineStroke(row, column); + Paint paint = getItemOutlinePaint(row, column); + if (stroke != null && paint != null) { + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(bar); + } + } + + CategoryItemLabelGenerator generator + = getItemLabelGenerator(row, column); + if (generator != null && isItemLabelVisible(row, column)) { + drawItemLabel(g2, dataset, row, column, plot, generator, bar, + (transX1 > transX2)); + } + + // collect entity and tool tip information... + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, bar); + } + } + + /** + * Draws the bar for a single (series, category) data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + */ + protected void drawVerticalItem(Graphics2D g2, + CategoryItemRendererState state, + Rectangle2D dataArea, + CategoryPlot plot, + CategoryAxis domainAxis, + ValueAxis rangeAxis, + CategoryDataset dataset, + int row, + int column) { + + // nothing is drawn for null values... + Number dataValue = dataset.getValue(row, column); + if (dataValue == null) { + return; + } + + // BAR X + double rectX = domainAxis.getCategoryMiddle(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() / 2.0; + + int seriesCount = getRowCount(); + + // BAR Y + double value = dataValue.doubleValue(); + double base = 0.0; + double lclip = getLowerClip(); + double uclip = getUpperClip(); + + if (uclip <= 0.0) { // cases 1, 2, 3 and 4 + if (value >= uclip) { + return; // bar is not visible + } + base = uclip; + if (value <= lclip) { + value = lclip; + } + } + else if (lclip <= 0.0) { // cases 5, 6, 7 and 8 + if (value >= uclip) { + value = uclip; + } + else { + if (value <= lclip) { + value = lclip; + } + } + } + else { // cases 9, 10, 11 and 12 + if (value <= lclip) { + return; // bar is not visible + } + base = getLowerClip(); + if (value >= uclip) { + value = uclip; + } + } + + RectangleEdge edge = plot.getRangeAxisEdge(); + double transY1 = rangeAxis.valueToJava2D(base, dataArea, edge); + double transY2 = rangeAxis.valueToJava2D(value, dataArea, edge); + double rectY = Math.min(transY2, transY1); + + double rectWidth; + double rectHeight = Math.abs(transY2 - transY1); + + // draw the bar... + double shift = 0.0; + double widthFactor = 1.0; + double seriesBarWidth = getSeriesBarWidth(row); + if (!Double.isNaN(seriesBarWidth)) { + widthFactor = seriesBarWidth; + } + rectWidth = widthFactor * state.getBarWidth(); + rectX = rectX + (1 - widthFactor) * state.getBarWidth() / 2.0; + if (seriesCount > 1) { + // needs to be improved !!! + shift = rectWidth * 0.20 / (seriesCount - 1); + } + + Rectangle2D bar = new Rectangle2D.Double( + (rectX + ((seriesCount - 1 - row) * shift)), rectY, + (rectWidth - (seriesCount - 1 - row) * shift * 2), rectHeight); + Paint itemPaint = getItemPaint(row, column); + GradientPaintTransformer t = getGradientPaintTransformer(); + if (t != null && itemPaint instanceof GradientPaint) { + itemPaint = t.transform((GradientPaint) itemPaint, bar); + } + g2.setPaint(itemPaint); + g2.fill(bar); + + // draw the outline... + if (isDrawBarOutline() + && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { + Stroke stroke = getItemOutlineStroke(row, column); + Paint paint = getItemOutlinePaint(row, column); + if (stroke != null && paint != null) { + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(bar); + } + } + + // draw the item labels if there are any... + double transX1 = rangeAxis.valueToJava2D(base, dataArea, edge); + double transX2 = rangeAxis.valueToJava2D(value, dataArea, edge); + + CategoryItemLabelGenerator generator + = getItemLabelGenerator(row, column); + if (generator != null && isItemLabelVisible(row, column)) { + drawItemLabel(g2, dataset, row, column, plot, generator, bar, + (transX1 > transX2)); + } + + // collect entity and tool tip information... + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, bar); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/LevelRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/LevelRenderer.java new file mode 100755 index 0000000..ba1feca --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/LevelRenderer.java @@ -0,0 +1,477 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * LevelRenderer.java + * ------------------ + * (C) Copyright 2004-2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (patch 2511330); + * + * Changes + * ------- + * 09-Jan-2004 : Version 1 (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 20-Apr-2005 : Renamed CategoryLabelGenerator + * --> CategoryItemLabelGenerator (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 23-Jan-2006 : Renamed getMaxItemWidth() --> getMaximumItemWidth() (DG); + * 13-May-2008 : Code clean-up (DG); + * 26-Jun-2008 : Added crosshair support (DG); + * 23-Jan-2009 : Set more appropriate default shape in legend (DG); + * 23-Jan-2009 : Added support for seriesVisible flags - see patch + * 2511330 (PK) + * + */ + +package org.jfree.chart.renderer.category; + +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.Serializable; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.CategoryItemLabelGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.data.category.CategoryDataset; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PublicCloneable; + +/** + * A {@link CategoryItemRenderer} that draws individual data items as + * horizontal lines, spaced in the same way as bars in a bar chart. The + * example shown here is generated by the + * OverlaidBarChartDemo2.java program included in the JFreeChart + * Demo Collection: + *

+ * LevelRendererSample.png + */ +public class LevelRenderer extends AbstractCategoryItemRenderer + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -8204856624355025117L; + + /** The default item margin percentage. */ + public static final double DEFAULT_ITEM_MARGIN = 0.20; + + /** The margin between items within a category. */ + private double itemMargin; + + /** The maximum item width as a percentage of the available space. */ + private double maxItemWidth; + + /** + * Creates a new renderer with default settings. + */ + public LevelRenderer() { + super(); + this.itemMargin = DEFAULT_ITEM_MARGIN; + this.maxItemWidth = 1.0; // 100 percent, so it will not apply unless + // changed + setBaseLegendShape(new Rectangle2D.Float(-5.0f, -1.0f, 10.0f, 2.0f)); + // set the outline paint to fully transparent, then the legend shape + // will just have the same colour as the lines drawn by the renderer + setBaseOutlinePaint(new Color(0, 0, 0, 0)); + } + + /** + * Returns the item margin. + * + * @return The margin. + * + * @see #setItemMargin(double) + */ + public double getItemMargin() { + return this.itemMargin; + } + + /** + * Sets the item margin and sends a {@link RendererChangeEvent} to all + * registered listeners. The value is expressed as a percentage of the + * available width for plotting all the bars, with the resulting amount to + * be distributed between all the bars evenly. + * + * @param percent the new margin. + * + * @see #getItemMargin() + */ + public void setItemMargin(double percent) { + this.itemMargin = percent; + fireChangeEvent(); + } + + /** + * Returns the maximum width, as a percentage of the available drawing + * space. + * + * @return The maximum width. + * + * @see #setMaximumItemWidth(double) + */ + public double getMaximumItemWidth() { + return getMaxItemWidth(); + } + + /** + * Sets the maximum item width, which is specified as a percentage of the + * available space for all items, and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param percent the percent. + * + * @see #getMaximumItemWidth() + */ + public void setMaximumItemWidth(double percent) { + setMaxItemWidth(percent); + } + + /** + * Initialises the renderer and returns a state object that will be passed + * to subsequent calls to the drawItem method. + *

+ * This method gets called once at the start of the process of drawing a + * chart. + * + * @param g2 the graphics device. + * @param dataArea the area in which the data is to be plotted. + * @param plot the plot. + * @param rendererIndex the renderer index. + * @param info collects chart rendering information for return to caller. + * + * @return The renderer state. + */ + @Override + public CategoryItemRendererState initialise(Graphics2D g2, + Rectangle2D dataArea, CategoryPlot plot, int rendererIndex, + PlotRenderingInfo info) { + + CategoryItemRendererState state = super.initialise(g2, dataArea, plot, + rendererIndex, info); + calculateItemWidth(plot, dataArea, rendererIndex, state); + return state; + + } + + /** + * Calculates the bar width and stores it in the renderer state. + * + * @param plot the plot. + * @param dataArea the data area. + * @param rendererIndex the renderer index. + * @param state the renderer state. + */ + protected void calculateItemWidth(CategoryPlot plot, + Rectangle2D dataArea, int rendererIndex, + CategoryItemRendererState state) { + + CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); + CategoryDataset dataset = plot.getDataset(rendererIndex); + if (dataset != null) { + int columns = dataset.getColumnCount(); + int rows = state.getVisibleSeriesCount() >= 0 + ? state.getVisibleSeriesCount() : dataset.getRowCount(); + double space = 0.0; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + space = dataArea.getHeight(); + } + else if (orientation == PlotOrientation.VERTICAL) { + space = dataArea.getWidth(); + } + double maxWidth = space * getMaximumItemWidth(); + double categoryMargin = 0.0; + double currentItemMargin = 0.0; + if (columns > 1) { + categoryMargin = domainAxis.getCategoryMargin(); + } + if (rows > 1) { + currentItemMargin = getItemMargin(); + } + double used = space * (1 - domainAxis.getLowerMargin() + - domainAxis.getUpperMargin() + - categoryMargin - currentItemMargin); + if ((rows * columns) > 0) { + state.setBarWidth(Math.min(used / (rows * columns), maxWidth)); + } + else { + state.setBarWidth(Math.min(used, maxWidth)); + } + } + } + + /** + * Calculates the coordinate of the first "side" of a bar. This will be + * the minimum x-coordinate for a vertical bar, and the minimum + * y-coordinate for a horizontal bar. + * + * @param plot the plot. + * @param orientation the plot orientation. + * @param dataArea the data area. + * @param domainAxis the domain axis. + * @param state the renderer state (has the bar width precalculated). + * @param row the row index. + * @param column the column index. + * + * @return The coordinate. + */ + protected double calculateBarW0(CategoryPlot plot, + PlotOrientation orientation, Rectangle2D dataArea, + CategoryAxis domainAxis, CategoryItemRendererState state, int row, + int column) { + // calculate bar width... + double space; + if (orientation == PlotOrientation.HORIZONTAL) { + space = dataArea.getHeight(); + } + else { + space = dataArea.getWidth(); + } + double barW0 = domainAxis.getCategoryStart(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()); + int seriesCount = state.getVisibleSeriesCount(); + if (seriesCount < 0) { + seriesCount = getRowCount(); + } + int categoryCount = getColumnCount(); + if (seriesCount > 1) { + double seriesGap = space * getItemMargin() + / (categoryCount * (seriesCount - 1)); + double seriesW = calculateSeriesWidth(space, domainAxis, + categoryCount, seriesCount); + barW0 = barW0 + row * (seriesW + seriesGap) + + (seriesW / 2.0) - (state.getBarWidth() / 2.0); + } + else { + barW0 = domainAxis.getCategoryMiddle(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()) - state.getBarWidth() + / 2.0; + } + return barW0; + } + + /** + * Draws the bar for a single (series, category) data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, + int pass) { + + // nothing is drawn if the row index is not included in the list with + // the indices of the visible rows... + int visibleRow = state.getVisibleSeriesIndex(row); + if (visibleRow < 0) { + return; + } + + // nothing is drawn for null values... + Number dataValue = dataset.getValue(row, column); + if (dataValue == null) { + return; + } + + double value = dataValue.doubleValue(); + + PlotOrientation orientation = plot.getOrientation(); + double barW0 = calculateBarW0(plot, orientation, dataArea, domainAxis, + state, visibleRow, column); + RectangleEdge edge = plot.getRangeAxisEdge(); + double barL = rangeAxis.valueToJava2D(value, dataArea, edge); + + // draw the bar... + Line2D line; + double x, y; + if (orientation == PlotOrientation.HORIZONTAL) { + x = barL; + y = barW0 + state.getBarWidth() / 2.0; + line = new Line2D.Double(barL, barW0, barL, + barW0 + state.getBarWidth()); + } + else { + x = barW0 + state.getBarWidth() / 2.0; + y = barL; + line = new Line2D.Double(barW0, barL, barW0 + state.getBarWidth(), + barL); + } + Stroke itemStroke = getItemStroke(row, column); + Paint itemPaint = getItemPaint(row, column); + g2.setStroke(itemStroke); + g2.setPaint(itemPaint); + g2.draw(line); + + CategoryItemLabelGenerator generator = getItemLabelGenerator(row, + column); + if (generator != null && isItemLabelVisible(row, column)) { + drawItemLabel(g2, orientation, dataset, row, column, x, y, + (value < 0.0)); + } + + // submit the current data point as a crosshair candidate + int datasetIndex = plot.indexOf(dataset); + updateCrosshairValues(state.getCrosshairState(), + dataset.getRowKey(row), dataset.getColumnKey(column), value, + datasetIndex, barW0, barL, orientation); + + // collect entity and tool tip information... + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, line.getBounds()); + } + + } + + /** + * Calculates the available space for each series. + * + * @param space the space along the entire axis (in Java2D units). + * @param axis the category axis. + * @param categories the number of categories. + * @param series the number of series. + * + * @return The width of one series. + */ + protected double calculateSeriesWidth(double space, CategoryAxis axis, + int categories, int series) { + double factor = 1.0 - getItemMargin() - axis.getLowerMargin() + - axis.getUpperMargin(); + if (categories > 1) { + factor = factor - axis.getCategoryMargin(); + } + return (space * factor) / (categories * series); + } + + /** + * Returns the Java2D coordinate for the middle of the specified data item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param dataset the dataset. + * @param axis the axis. + * @param area the drawing area. + * @param edge the edge along which the axis lies. + * + * @return The Java2D coordinate. + * + * @since 1.0.11 + */ + @Override + public double getItemMiddle(Comparable rowKey, Comparable columnKey, + CategoryDataset dataset, CategoryAxis axis, Rectangle2D area, + RectangleEdge edge) { + return axis.getCategorySeriesMiddle(columnKey, rowKey, dataset, + this.itemMargin, area, edge); + } + + /** + * Tests an object for equality with this instance. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof LevelRenderer)) { + return false; + } + LevelRenderer that = (LevelRenderer) obj; + if (this.itemMargin != that.itemMargin) { + return false; + } + if (this.maxItemWidth != that.maxItemWidth) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = HashUtilities.hashCode(hash, this.itemMargin); + hash = HashUtilities.hashCode(hash, this.maxItemWidth); + return hash; + } + + /** + * Returns the maximum width, as a percentage of the available drawing + * space. + * + * @return The maximum width. + * + * @deprecated Use {@link #getMaximumItemWidth()} instead. + */ + public double getMaxItemWidth() { + return this.maxItemWidth; + } + + /** + * Sets the maximum item width, which is specified as a percentage of the + * available space for all items, and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param percent the percent. + * + * @deprecated Use {@link #setMaximumItemWidth(double)} instead. + */ + public void setMaxItemWidth(double percent) { + this.maxItemWidth = percent; + fireChangeEvent(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java new file mode 100755 index 0000000..3762c82 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/LineAndShapeRenderer.java @@ -0,0 +1,1120 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * LineAndShapeRenderer.java + * ------------------------- + * (C) Copyright 2001-2009, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Mark Watson (www.markwatson.com); + * Jeremy Bowman; + * Richard Atkinson; + * Christian W. Zuckschwerdt; + * Peter Kolb (patch 2497611); + * + * Changes + * ------- + * 23-Oct-2001 : Version 1 (DG); + * 15-Nov-2001 : Modified to allow for null data values (DG); + * 16-Jan-2002 : Renamed HorizontalCategoryItemRenderer.java + * --> CategoryItemRenderer.java (DG); + * 05-Feb-2002 : Changed return type of the drawCategoryItem method from void + * to Shape, as part of the tooltips implementation (DG); + * 11-May-2002 : Support for value label drawing (JB); + * 29-May-2002 : Now extends AbstractCategoryItemRenderer (DG); + * 25-Jun-2002 : Removed redundant import (DG); + * 05-Aug-2002 : Small modification to drawCategoryItem method to support URLs + * for HTML image maps (RA); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 11-Oct-2002 : Added new constructor to incorporate tool tip and URL + * generators (DG); + * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and + * CategoryToolTipGenerator interface (DG); + * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG); + * 06-Nov-2002 : Renamed drawCategoryItem() --> drawItem() and now using axis + * for category spacing (DG); + * 17-Jan-2003 : Moved plot classes to a separate package (DG); + * 10-Apr-2003 : Changed CategoryDataset to KeyedValues2DDataset in drawItem() + * method (DG); + * 12-May-2003 : Modified to take into account the plot orientation (DG); + * 29-Jul-2003 : Amended code that doesn't compile with JDK 1.2.2 (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 22-Sep-2003 : Fixed cloning (DG); + * 10-Feb-2004 : Small change to drawItem() method to make cut-and-paste + * override easier (DG); + * 16-Jun-2004 : Fixed bug (id=972454) with label positioning on horizontal + * charts (DG); + * 15-Oct-2004 : Updated equals() method (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 11-Nov-2004 : Now uses ShapeUtilities class to translate shapes (DG); + * 27-Jan-2005 : Changed attribute names, modified constructor and removed + * constants (DG); + * 01-Feb-2005 : Removed unnecessary constants (DG); + * 15-Mar-2005 : Fixed bug 1163897, concerning outlines for shapes (DG); + * 13-Apr-2005 : Check flags that control series visibility (DG); + * 20-Apr-2005 : Use generators for legend labels, tooltips and URLs (DG); + * 09-Jun-2005 : Use addItemEntity() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 25-May-2006 : Added check to drawItem() to detect when both the line and + * the shape are not visible (DG); + * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); + * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); + * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); + * 24-Sep-2007 : Deprecated redundant fields/methods (DG); + * 27-Sep-2007 : Added option to offset series x-position within category (DG); + * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * 26-Jun-2008 : Added crosshair support (DG); + * 14-Jan-2009 : Added support for seriesVisible flags (PK); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.category.CategoryDataset; +import org.jfree.util.BooleanList; +import org.jfree.util.BooleanUtilities; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A renderer that draws shapes for each data item, and lines between data + * items (for use with the {@link CategoryPlot} class). + * The example shown here is generated by the LineChartDemo1.java + * program included in the JFreeChart Demo Collection: + *

+ * LineAndShapeRendererSample.png + */ +public class LineAndShapeRenderer extends AbstractCategoryItemRenderer + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -197749519869226398L; + + /** + * A flag that controls whether or not lines are visible for ALL series. + * + * @deprecated As of 1.0.7 (this override flag is unnecessary). + */ + private Boolean linesVisible; + + /** + * A table of flags that control (per series) whether or not lines are + * visible. + */ + private BooleanList seriesLinesVisible; + + /** + * A flag indicating whether or not lines are drawn between non-null + * points. + */ + private boolean baseLinesVisible; + + /** + * A flag that controls whether or not shapes are visible for ALL series. + * + * @deprecated As of 1.0.7 (this override flag is unnecessary). + */ + private Boolean shapesVisible; + + /** + * A table of flags that control (per series) whether or not shapes are + * visible. + */ + private BooleanList seriesShapesVisible; + + /** The default value returned by the getShapeVisible() method. */ + private boolean baseShapesVisible; + + /** + * A flag that controls whether or not shapes are filled for ALL series. + * + * @deprecated As of 1.0.7 (this override flag is unnecessary). + */ + private Boolean shapesFilled; + + /** + * A table of flags that control (per series) whether or not shapes are + * filled. + */ + private BooleanList seriesShapesFilled; + + /** The default value returned by the getShapeFilled() method. */ + private boolean baseShapesFilled; + + /** + * A flag that controls whether the fill paint is used for filling + * shapes. + */ + private boolean useFillPaint; + + /** A flag that controls whether outlines are drawn for shapes. */ + private boolean drawOutlines; + + /** + * A flag that controls whether the outline paint is used for drawing shape + * outlines - if not, the regular series paint is used. + */ + private boolean useOutlinePaint; + + /** + * A flag that controls whether or not the x-position for each item is + * offset within the category according to the series. + * + * @since 1.0.7 + */ + private boolean useSeriesOffset; + + /** + * The item margin used for series offsetting - this allows the positioning + * to match the bar positions of the {@link BarRenderer} class. + * + * @since 1.0.7 + */ + private double itemMargin; + + /** + * Creates a renderer with both lines and shapes visible by default. + */ + public LineAndShapeRenderer() { + this(true, true); + } + + /** + * Creates a new renderer with lines and/or shapes visible. + * + * @param lines draw lines? + * @param shapes draw shapes? + */ + public LineAndShapeRenderer(boolean lines, boolean shapes) { + super(); + this.linesVisible = null; + this.seriesLinesVisible = new BooleanList(); + this.baseLinesVisible = lines; + this.shapesVisible = null; + this.seriesShapesVisible = new BooleanList(); + this.baseShapesVisible = shapes; + this.shapesFilled = null; + this.seriesShapesFilled = new BooleanList(); + this.baseShapesFilled = true; + this.useFillPaint = false; + this.drawOutlines = true; + this.useOutlinePaint = false; + this.useSeriesOffset = false; // preserves old behaviour + this.itemMargin = 0.0; + } + + // LINES VISIBLE + + /** + * Returns the flag used to control whether or not the line for an item is + * visible. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return A boolean. + */ + public boolean getItemLineVisible(int series, int item) { + Boolean flag = this.linesVisible; + if (flag == null) { + flag = getSeriesLinesVisible(series); + } + if (flag != null) { + return flag.booleanValue(); + } + else { + return this.baseLinesVisible; + } + } + + /** + * Returns a flag that controls whether or not lines are drawn for ALL + * series. If this flag is null, then the "per series" + * settings will apply. + * + * @return A flag (possibly null). + * + * @see #setLinesVisible(Boolean) + * + * @deprecated As of 1.0.7 (the override facility is unnecessary, just + * use the per-series and base (default) settings). + */ + public Boolean getLinesVisible() { + return this.linesVisible; + } + + /** + * Sets a flag that controls whether or not lines are drawn between the + * items in ALL series, and sends a {@link RendererChangeEvent} to all + * registered listeners. You need to set this to null if you + * want the "per series" settings to apply. + * + * @param visible the flag (null permitted). + * + * @see #getLinesVisible() + * + * @deprecated As of 1.0.7 (the override facility is unnecessary, just + * use the per-series and base (default) settings). + */ + public void setLinesVisible(Boolean visible) { + this.linesVisible = visible; + fireChangeEvent(); + } + + /** + * Sets a flag that controls whether or not lines are drawn between the + * items in ALL series, and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param visible the flag. + * + * @see #getLinesVisible() + * + * @deprecated As of 1.0.7 (the override facility is unnecessary, just + * use the per-series and base (default) settings). + */ + public void setLinesVisible(boolean visible) { + setLinesVisible(BooleanUtilities.valueOf(visible)); + } + + /** + * Returns the flag used to control whether or not the lines for a series + * are visible. + * + * @param series the series index (zero-based). + * + * @return The flag (possibly null). + * + * @see #setSeriesLinesVisible(int, Boolean) + */ + public Boolean getSeriesLinesVisible(int series) { + return this.seriesLinesVisible.getBoolean(series); + } + + /** + * Sets the 'lines visible' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param flag the flag (null permitted). + * + * @see #getSeriesLinesVisible(int) + */ + public void setSeriesLinesVisible(int series, Boolean flag) { + this.seriesLinesVisible.setBoolean(series, flag); + fireChangeEvent(); + } + + /** + * Sets the 'lines visible' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the flag. + * + * @see #getSeriesLinesVisible(int) + */ + public void setSeriesLinesVisible(int series, boolean visible) { + setSeriesLinesVisible(series, BooleanUtilities.valueOf(visible)); + } + + /** + * Returns the base 'lines visible' attribute. + * + * @return The base flag. + * + * @see #getBaseLinesVisible() + */ + public boolean getBaseLinesVisible() { + return this.baseLinesVisible; + } + + /** + * Sets the base 'lines visible' flag and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param flag the flag. + * + * @see #getBaseLinesVisible() + */ + public void setBaseLinesVisible(boolean flag) { + this.baseLinesVisible = flag; + fireChangeEvent(); + } + + // SHAPES VISIBLE + + /** + * Returns the flag used to control whether or not the shape for an item is + * visible. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return A boolean. + */ + public boolean getItemShapeVisible(int series, int item) { + Boolean flag = this.shapesVisible; + if (flag == null) { + flag = getSeriesShapesVisible(series); + } + if (flag != null) { + return flag.booleanValue(); + } + else { + return this.baseShapesVisible; + } + } + + /** + * Returns the flag that controls whether the shapes are visible for the + * items in ALL series. + * + * @return The flag (possibly null). + * + * @see #setShapesVisible(Boolean) + * + * @deprecated As of 1.0.7 (the override facility is unnecessary, just + * use the per-series and base (default) settings). + */ + public Boolean getShapesVisible() { + return this.shapesVisible; + } + + /** + * Sets the 'shapes visible' for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the flag (null permitted). + * + * @see #getShapesVisible() + * + * @deprecated As of 1.0.7 (the override facility is unnecessary, just + * use the per-series and base (default) settings). + */ + public void setShapesVisible(Boolean visible) { + this.shapesVisible = visible; + fireChangeEvent(); + } + + /** + * Sets the 'shapes visible' for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the flag. + * + * @see #getShapesVisible() + * + * @deprecated As of 1.0.7 (the override facility is unnecessary, just + * use the per-series and base (default) settings). + */ + public void setShapesVisible(boolean visible) { + setShapesVisible(BooleanUtilities.valueOf(visible)); + } + + /** + * Returns the flag used to control whether or not the shapes for a series + * are visible. + * + * @param series the series index (zero-based). + * + * @return A boolean. + * + * @see #setSeriesShapesVisible(int, Boolean) + */ + public Boolean getSeriesShapesVisible(int series) { + return this.seriesShapesVisible.getBoolean(series); + } + + /** + * Sets the 'shapes visible' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the flag. + * + * @see #getSeriesShapesVisible(int) + */ + public void setSeriesShapesVisible(int series, boolean visible) { + setSeriesShapesVisible(series, BooleanUtilities.valueOf(visible)); + } + + /** + * Sets the 'shapes visible' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param flag the flag. + * + * @see #getSeriesShapesVisible(int) + */ + public void setSeriesShapesVisible(int series, Boolean flag) { + this.seriesShapesVisible.setBoolean(series, flag); + fireChangeEvent(); + } + + /** + * Returns the base 'shape visible' attribute. + * + * @return The base flag. + * + * @see #setBaseShapesVisible(boolean) + */ + public boolean getBaseShapesVisible() { + return this.baseShapesVisible; + } + + /** + * Sets the base 'shapes visible' flag and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param flag the flag. + * + * @see #getBaseShapesVisible() + */ + public void setBaseShapesVisible(boolean flag) { + this.baseShapesVisible = flag; + fireChangeEvent(); + } + + /** + * Returns true if outlines should be drawn for shapes, and + * false otherwise. + * + * @return A boolean. + * + * @see #setDrawOutlines(boolean) + */ + public boolean getDrawOutlines() { + return this.drawOutlines; + } + + /** + * Sets the flag that controls whether outlines are drawn for + * shapes, and sends a {@link RendererChangeEvent} to all registered + * listeners. + *

+ * In some cases, shapes look better if they do NOT have an outline, but + * this flag allows you to set your own preference. + * + * @param flag the flag. + * + * @see #getDrawOutlines() + */ + public void setDrawOutlines(boolean flag) { + this.drawOutlines = flag; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether the outline paint is used for + * shape outlines. If not, the regular series paint is used. + * + * @return A boolean. + * + * @see #setUseOutlinePaint(boolean) + */ + public boolean getUseOutlinePaint() { + return this.useOutlinePaint; + } + + /** + * Sets the flag that controls whether the outline paint is used for shape + * outlines, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param use the flag. + * + * @see #getUseOutlinePaint() + */ + public void setUseOutlinePaint(boolean use) { + this.useOutlinePaint = use; + fireChangeEvent(); + } + + // SHAPES FILLED + + /** + * Returns the flag used to control whether or not the shape for an item + * is filled. The default implementation passes control to the + * getSeriesShapesFilled method. You can override this method + * if you require different behaviour. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return A boolean. + */ + public boolean getItemShapeFilled(int series, int item) { + return getSeriesShapesFilled(series); + } + + /** + * Returns the flag used to control whether or not the shapes for a series + * are filled. + * + * @param series the series index (zero-based). + * + * @return A boolean. + */ + public boolean getSeriesShapesFilled(int series) { + + // return the overall setting, if there is one... + if (this.shapesFilled != null) { + return this.shapesFilled.booleanValue(); + } + + // otherwise look up the paint table + Boolean flag = this.seriesShapesFilled.getBoolean(series); + if (flag != null) { + return flag.booleanValue(); + } + else { + return this.baseShapesFilled; + } + + } + + /** + * Returns the flag that controls whether or not shapes are filled for + * ALL series. + * + * @return A Boolean. + * + * @see #setShapesFilled(Boolean) + * + * @deprecated As of 1.0.7 (the override facility is unnecessary, just + * use the per-series and base (default) settings). + */ + public Boolean getShapesFilled() { + return this.shapesFilled; + } + + /** + * Sets the 'shapes filled' for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param filled the flag. + * + * @see #getShapesFilled() + * + * @deprecated As of 1.0.7 (the override facility is unnecessary, just + * use the per-series and base (default) settings). + */ + public void setShapesFilled(boolean filled) { + if (filled) { + setShapesFilled(Boolean.TRUE); + } + else { + setShapesFilled(Boolean.FALSE); + } + } + + /** + * Sets the 'shapes filled' for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param filled the flag (null permitted). + * + * @see #getShapesFilled() + * + * @deprecated As of 1.0.7 (the override facility is unnecessary, just + * use the per-series and base (default) settings). + */ + public void setShapesFilled(Boolean filled) { + this.shapesFilled = filled; + fireChangeEvent(); + } + + /** + * Sets the 'shapes filled' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param filled the flag. + * + * @see #getSeriesShapesFilled(int) + */ + public void setSeriesShapesFilled(int series, Boolean filled) { + this.seriesShapesFilled.setBoolean(series, filled); + fireChangeEvent(); + } + + /** + * Sets the 'shapes filled' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param filled the flag. + * + * @see #getSeriesShapesFilled(int) + */ + public void setSeriesShapesFilled(int series, boolean filled) { + // delegate + setSeriesShapesFilled(series, BooleanUtilities.valueOf(filled)); + } + + /** + * Returns the base 'shape filled' attribute. + * + * @return The base flag. + * + * @see #setBaseShapesFilled(boolean) + */ + public boolean getBaseShapesFilled() { + return this.baseShapesFilled; + } + + /** + * Sets the base 'shapes filled' flag and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param flag the flag. + * + * @see #getBaseShapesFilled() + */ + public void setBaseShapesFilled(boolean flag) { + this.baseShapesFilled = flag; + fireChangeEvent(); + } + + /** + * Returns true if the renderer should use the fill paint + * setting to fill shapes, and false if it should just + * use the regular paint. + * + * @return A boolean. + * + * @see #setUseFillPaint(boolean) + */ + public boolean getUseFillPaint() { + return this.useFillPaint; + } + + /** + * Sets the flag that controls whether the fill paint is used to fill + * shapes, and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param flag the flag. + * + * @see #getUseFillPaint() + */ + public void setUseFillPaint(boolean flag) { + this.useFillPaint = flag; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not the x-position for each + * data item is offset within the category according to the series. + * + * @return A boolean. + * + * @see #setUseSeriesOffset(boolean) + * + * @since 1.0.7 + */ + public boolean getUseSeriesOffset() { + return this.useSeriesOffset; + } + + /** + * Sets the flag that controls whether or not the x-position for each + * data item is offset within its category according to the series, and + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param offset the offset. + * + * @see #getUseSeriesOffset() + * + * @since 1.0.7 + */ + public void setUseSeriesOffset(boolean offset) { + this.useSeriesOffset = offset; + fireChangeEvent(); + } + + /** + * Returns the item margin, which is the gap between items within a + * category (expressed as a percentage of the overall category width). + * This can be used to match the offset alignment with the bars drawn by + * a {@link BarRenderer}). + * + * @return The item margin. + * + * @see #setItemMargin(double) + * @see #getUseSeriesOffset() + * + * @since 1.0.7 + */ + public double getItemMargin() { + return this.itemMargin; + } + + /** + * Sets the item margin, which is the gap between items within a category + * (expressed as a percentage of the overall category width), and sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param margin the margin (0.0 <= margin < 1.0). + * + * @see #getItemMargin() + * @see #getUseSeriesOffset() + * + * @since 1.0.7 + */ + public void setItemMargin(double margin) { + if (margin < 0.0 || margin >= 1.0) { + throw new IllegalArgumentException("Requires 0.0 <= margin < 1.0."); + } + this.itemMargin = margin; + fireChangeEvent(); + } + + /** + * Returns a legend item for a series. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return The legend item. + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + + CategoryPlot cp = getPlot(); + if (cp == null) { + return null; + } + + if (isSeriesVisible(series) && isSeriesVisibleInLegend(series)) { + CategoryDataset dataset = cp.getDataset(datasetIndex); + String label = getLegendItemLabelGenerator().generateLabel( + dataset, series); + String description = label; + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel( + dataset, series); + } + Shape shape = lookupLegendShape(series); + Paint paint = lookupSeriesPaint(series); + Paint fillPaint = (this.useFillPaint + ? getItemFillPaint(series, 0) : paint); + boolean shapeOutlineVisible = this.drawOutlines; + Paint outlinePaint = (this.useOutlinePaint + ? getItemOutlinePaint(series, 0) : paint); + Stroke outlineStroke = lookupSeriesOutlineStroke(series); + boolean lineVisible = getItemLineVisible(series, 0); + boolean shapeVisible = getItemShapeVisible(series, 0); + LegendItem result = new LegendItem(label, description, toolTipText, + urlText, shapeVisible, shape, getItemShapeFilled(series, 0), + fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke, + lineVisible, new Line2D.Double(-7.0, 0.0, 7.0, 0.0), + getItemStroke(series, 0), getItemPaint(series, 0)); + result.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + result.setLabelPaint(labelPaint); + } + result.setDataset(dataset); + result.setDatasetIndex(datasetIndex); + result.setSeriesKey(dataset.getRowKey(series)); + result.setSeriesIndex(series); + return result; + } + return null; + + } + + /** + * This renderer uses two passes to draw the data. + * + * @return The pass count (2 for this renderer). + */ + @Override + public int getPassCount() { + return 2; + } + + /** + * Draw a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area in which the data is drawn. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, + int pass) { + + // do nothing if item is not visible + if (!getItemVisible(row, column)) { + return; + } + + // do nothing if both the line and shape are not visible + if (!getItemLineVisible(row, column) + && !getItemShapeVisible(row, column)) { + return; + } + + // nothing is drawn for null... + Number v = dataset.getValue(row, column); + if (v == null) { + return; + } + + int visibleRow = state.getVisibleSeriesIndex(row); + if (visibleRow < 0) { + return; + } + int visibleRowCount = state.getVisibleSeriesCount(); + + PlotOrientation orientation = plot.getOrientation(); + + // current data point... + double x1; + if (this.useSeriesOffset) { + x1 = domainAxis.getCategorySeriesMiddle(column, + dataset.getColumnCount(), visibleRow, visibleRowCount, + this.itemMargin, dataArea, plot.getDomainAxisEdge()); + } + else { + x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()); + } + double value = v.doubleValue(); + double y1 = rangeAxis.valueToJava2D(value, dataArea, + plot.getRangeAxisEdge()); + + if (pass == 0 && getItemLineVisible(row, column)) { + if (column != 0) { + Number previousValue = dataset.getValue(row, column - 1); + if (previousValue != null) { + // previous data point... + double previous = previousValue.doubleValue(); + double x0; + if (this.useSeriesOffset) { + x0 = domainAxis.getCategorySeriesMiddle( + column - 1, dataset.getColumnCount(), + visibleRow, visibleRowCount, + this.itemMargin, dataArea, + plot.getDomainAxisEdge()); + } + else { + x0 = domainAxis.getCategoryMiddle(column - 1, + getColumnCount(), dataArea, + plot.getDomainAxisEdge()); + } + double y0 = rangeAxis.valueToJava2D(previous, dataArea, + plot.getRangeAxisEdge()); + + Line2D line = null; + if (orientation == PlotOrientation.HORIZONTAL) { + line = new Line2D.Double(y0, x0, y1, x1); + } + else if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(x0, y0, x1, y1); + } + g2.setPaint(getItemPaint(row, column)); + g2.setStroke(getItemStroke(row, column)); + g2.draw(line); + } + } + } + + if (pass == 1) { + Shape shape = getItemShape(row, column); + if (orientation == PlotOrientation.HORIZONTAL) { + shape = ShapeUtilities.createTranslatedShape(shape, y1, x1); + } + else if (orientation == PlotOrientation.VERTICAL) { + shape = ShapeUtilities.createTranslatedShape(shape, x1, y1); + } + + if (getItemShapeVisible(row, column)) { + if (getItemShapeFilled(row, column)) { + if (this.useFillPaint) { + g2.setPaint(getItemFillPaint(row, column)); + } + else { + g2.setPaint(getItemPaint(row, column)); + } + g2.fill(shape); + } + if (this.drawOutlines) { + if (this.useOutlinePaint) { + g2.setPaint(getItemOutlinePaint(row, column)); + } + else { + g2.setPaint(getItemPaint(row, column)); + } + g2.setStroke(getItemOutlineStroke(row, column)); + g2.draw(shape); + } + } + + // draw the item label if there is one... + if (isItemLabelVisible(row, column)) { + if (orientation == PlotOrientation.HORIZONTAL) { + drawItemLabel(g2, orientation, dataset, row, column, y1, + x1, (value < 0.0)); + } + else if (orientation == PlotOrientation.VERTICAL) { + drawItemLabel(g2, orientation, dataset, row, column, x1, + y1, (value < 0.0)); + } + } + + // submit the current data point as a crosshair candidate + int datasetIndex = plot.indexOf(dataset); + updateCrosshairValues(state.getCrosshairState(), + dataset.getRowKey(row), dataset.getColumnKey(column), + value, datasetIndex, x1, y1, orientation); + + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, shape); + } + } + + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof LineAndShapeRenderer)) { + return false; + } + + LineAndShapeRenderer that = (LineAndShapeRenderer) obj; + if (this.baseLinesVisible != that.baseLinesVisible) { + return false; + } + if (!ObjectUtilities.equal(this.seriesLinesVisible, + that.seriesLinesVisible)) { + return false; + } + if (!ObjectUtilities.equal(this.linesVisible, that.linesVisible)) { + return false; + } + if (this.baseShapesVisible != that.baseShapesVisible) { + return false; + } + if (!ObjectUtilities.equal(this.seriesShapesVisible, + that.seriesShapesVisible)) { + return false; + } + if (!ObjectUtilities.equal(this.shapesVisible, that.shapesVisible)) { + return false; + } + if (!ObjectUtilities.equal(this.shapesFilled, that.shapesFilled)) { + return false; + } + if (!ObjectUtilities.equal(this.seriesShapesFilled, + that.seriesShapesFilled)) { + return false; + } + if (this.baseShapesFilled != that.baseShapesFilled) { + return false; + } + if (this.useOutlinePaint != that.useOutlinePaint) { + return false; + } + if (this.useSeriesOffset != that.useSeriesOffset) { + return false; + } + if (this.itemMargin != that.itemMargin) { + return false; + } + return super.equals(obj); + } + + /** + * Returns an independent copy of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException should not happen. + */ + @Override + public Object clone() throws CloneNotSupportedException { + LineAndShapeRenderer clone = (LineAndShapeRenderer) super.clone(); + clone.seriesLinesVisible + = (BooleanList) this.seriesLinesVisible.clone(); + clone.seriesShapesVisible + = (BooleanList) this.seriesShapesVisible.clone(); + clone.seriesShapesFilled + = (BooleanList) this.seriesShapesFilled.clone(); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/LineRenderer3D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/LineRenderer3D.java new file mode 100755 index 0000000..d7cae3a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/LineRenderer3D.java @@ -0,0 +1,670 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * LineRenderer3D.java + * ------------------- + * (C) Copyright 2004-2013, by Tobias Selb and Contributors. + * + * Original Author: Tobias Selb (http://www.uepselon.com); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Martin Hoeller (patch 3435374); + * + * Changes + * ------- + * 15-Oct-2004 : Version 1 (TS); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 11-Nov-2004 : Now uses ShapeUtilities class to translate shapes (DG); + * 26-Jan-2005 : Update for changes in super class (DG); + * 13-Apr-2005 : Check item visibility in drawItem() method (DG); + * 09-Jun-2005 : Use addItemEntity() in drawItem() method (DG); + * 10-Jun-2005 : Fixed capitalisation of setXOffset() and setYOffset() (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 01-Dec-2006 : Fixed equals() and serialization (DG); + * 17-Jan-2007 : Fixed bug in drawDomainGridline() method and added + * argument check to setWallPaint() (DG); + * 03-Apr-2007 : Fixed bugs in drawBackground() method (DG); + * 16-Oct-2007 : Fixed bug in range marker drawing (DG); + * 09-Nov-2011 : Fixed bug 3433405 - wrong item label position (MH); + * 13-Nov-2011 : Fixed item labels overlapped by line - patch 3435374 (MH); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Paint; +import java.awt.Shape; +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.Effect3D; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Marker; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.ValueMarker; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.ShapeUtilities; + +/** + * A line renderer with a 3D effect. The example shown here is generated by + * the LineChart3DDemo1.java program included in the JFreeChart + * Demo Collection: + *

+ * LineRenderer3DSample.png + */ +public class LineRenderer3D extends LineAndShapeRenderer + implements Effect3D, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 5467931468380928736L; + + /** The default x-offset for the 3D effect. */ + public static final double DEFAULT_X_OFFSET = 12.0; + + /** The default y-offset for the 3D effect. */ + public static final double DEFAULT_Y_OFFSET = 8.0; + + /** The default wall paint. */ + public static final Paint DEFAULT_WALL_PAINT = new Color(0xDD, 0xDD, 0xDD); + + /** The size of x-offset for the 3D effect. */ + private double xOffset; + + /** The size of y-offset for the 3D effect. */ + private double yOffset; + + /** The paint used to shade the left and lower 3D wall. */ + private transient Paint wallPaint; + + /** + * Creates a new renderer. + */ + public LineRenderer3D() { + super(true, false); // create a line renderer only + this.xOffset = DEFAULT_X_OFFSET; + this.yOffset = DEFAULT_Y_OFFSET; + this.wallPaint = DEFAULT_WALL_PAINT; + } + + /** + * Returns the x-offset for the 3D effect. + * + * @return The x-offset. + * + * @see #setXOffset(double) + * @see #getYOffset() + */ + @Override + public double getXOffset() { + return this.xOffset; + } + + /** + * Returns the y-offset for the 3D effect. + * + * @return The y-offset. + * + * @see #setYOffset(double) + * @see #getXOffset() + */ + @Override + public double getYOffset() { + return this.yOffset; + } + + /** + * Sets the x-offset and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param xOffset the x-offset. + * + * @see #getXOffset() + */ + public void setXOffset(double xOffset) { + this.xOffset = xOffset; + fireChangeEvent(); + } + + /** + * Sets the y-offset and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param yOffset the y-offset. + * + * @see #getYOffset() + */ + public void setYOffset(double yOffset) { + this.yOffset = yOffset; + fireChangeEvent(); + } + + /** + * Returns the paint used to highlight the left and bottom wall in the plot + * background. + * + * @return The paint. + * + * @see #setWallPaint(Paint) + */ + public Paint getWallPaint() { + return this.wallPaint; + } + + /** + * Sets the paint used to highlight the left and bottom walls in the plot + * background, and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getWallPaint() + */ + public void setWallPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.wallPaint = paint; + fireChangeEvent(); + } + + /** + * Draws the background for the plot. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param dataArea the area inside the axes. + */ + @Override + public void drawBackground(Graphics2D g2, CategoryPlot plot, + Rectangle2D dataArea) { + + float x0 = (float) dataArea.getX(); + float x1 = x0 + (float) Math.abs(this.xOffset); + float x3 = (float) dataArea.getMaxX(); + float x2 = x3 - (float) Math.abs(this.xOffset); + + float y0 = (float) dataArea.getMaxY(); + float y1 = y0 - (float) Math.abs(this.yOffset); + float y3 = (float) dataArea.getMinY(); + float y2 = y3 + (float) Math.abs(this.yOffset); + + GeneralPath clip = new GeneralPath(); + clip.moveTo(x0, y0); + clip.lineTo(x0, y2); + clip.lineTo(x1, y3); + clip.lineTo(x3, y3); + clip.lineTo(x3, y1); + clip.lineTo(x2, y0); + clip.closePath(); + + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, + plot.getBackgroundAlpha())); + + // fill background... + Paint backgroundPaint = plot.getBackgroundPaint(); + if (backgroundPaint != null) { + g2.setPaint(backgroundPaint); + g2.fill(clip); + } + + GeneralPath leftWall = new GeneralPath(); + leftWall.moveTo(x0, y0); + leftWall.lineTo(x0, y2); + leftWall.lineTo(x1, y3); + leftWall.lineTo(x1, y1); + leftWall.closePath(); + g2.setPaint(getWallPaint()); + g2.fill(leftWall); + + GeneralPath bottomWall = new GeneralPath(); + bottomWall.moveTo(x0, y0); + bottomWall.lineTo(x1, y1); + bottomWall.lineTo(x3, y1); + bottomWall.lineTo(x2, y0); + bottomWall.closePath(); + g2.setPaint(getWallPaint()); + g2.fill(bottomWall); + + // higlight the background corners... + g2.setPaint(Color.lightGray); + Line2D corner = new Line2D.Double(x0, y0, x1, y1); + g2.draw(corner); + corner.setLine(x1, y1, x1, y3); + g2.draw(corner); + corner.setLine(x1, y1, x3, y1); + g2.draw(corner); + + // draw background image, if there is one... + Image backgroundImage = plot.getBackgroundImage(); + if (backgroundImage != null) { + Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX() + + getXOffset(), dataArea.getY(), + dataArea.getWidth() - getXOffset(), + dataArea.getHeight() - getYOffset()); + plot.drawBackgroundImage(g2, adjusted); + } + + g2.setComposite(originalComposite); + + } + + /** + * Draws the outline for the plot. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param dataArea the area inside the axes. + */ + @Override + public void drawOutline(Graphics2D g2, CategoryPlot plot, + Rectangle2D dataArea) { + + float x0 = (float) dataArea.getX(); + float x1 = x0 + (float) Math.abs(this.xOffset); + float x3 = (float) dataArea.getMaxX(); + float x2 = x3 - (float) Math.abs(this.xOffset); + + float y0 = (float) dataArea.getMaxY(); + float y1 = y0 - (float) Math.abs(this.yOffset); + float y3 = (float) dataArea.getMinY(); + float y2 = y3 + (float) Math.abs(this.yOffset); + + GeneralPath clip = new GeneralPath(); + clip.moveTo(x0, y0); + clip.lineTo(x0, y2); + clip.lineTo(x1, y3); + clip.lineTo(x3, y3); + clip.lineTo(x3, y1); + clip.lineTo(x2, y0); + clip.closePath(); + + // put an outline around the data area... + Stroke outlineStroke = plot.getOutlineStroke(); + Paint outlinePaint = plot.getOutlinePaint(); + if ((outlineStroke != null) && (outlinePaint != null)) { + g2.setStroke(outlineStroke); + g2.setPaint(outlinePaint); + g2.draw(clip); + } + + } + + /** + * Draws a grid line against the domain axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param dataArea the area for plotting data (not yet adjusted for any + * 3D effect). + * @param value the Java2D value at which the grid line should be drawn. + * + */ + @Override + public void drawDomainGridline(Graphics2D g2, CategoryPlot plot, + Rectangle2D dataArea, double value) { + + Line2D line1 = null; + Line2D line2 = null; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + double y0 = value; + double y1 = value - getYOffset(); + double x0 = dataArea.getMinX(); + double x1 = x0 + getXOffset(); + double x2 = dataArea.getMaxX(); + line1 = new Line2D.Double(x0, y0, x1, y1); + line2 = new Line2D.Double(x1, y1, x2, y1); + } + else if (orientation == PlotOrientation.VERTICAL) { + double x0 = value; + double x1 = value + getXOffset(); + double y0 = dataArea.getMaxY(); + double y1 = y0 - getYOffset(); + double y2 = dataArea.getMinY(); + line1 = new Line2D.Double(x0, y0, x1, y1); + line2 = new Line2D.Double(x1, y1, x1, y2); + } + g2.setPaint(plot.getDomainGridlinePaint()); + g2.setStroke(plot.getDomainGridlineStroke()); + g2.draw(line1); + g2.draw(line2); + + } + + /** + * Draws a grid line against the range axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param dataArea the area for plotting data (not yet adjusted for any + * 3D effect). + * @param value the value at which the grid line should be drawn. + * + */ + @Override + public void drawRangeGridline(Graphics2D g2, CategoryPlot plot, + ValueAxis axis, Rectangle2D dataArea, double value) { + + Range range = axis.getRange(); + + if (!range.contains(value)) { + return; + } + + Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), + dataArea.getY() + getYOffset(), + dataArea.getWidth() - getXOffset(), + dataArea.getHeight() - getYOffset()); + + Line2D line1 = null; + Line2D line2 = null; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + double x0 = axis.valueToJava2D(value, adjusted, + plot.getRangeAxisEdge()); + double x1 = x0 + getXOffset(); + double y0 = dataArea.getMaxY(); + double y1 = y0 - getYOffset(); + double y2 = dataArea.getMinY(); + line1 = new Line2D.Double(x0, y0, x1, y1); + line2 = new Line2D.Double(x1, y1, x1, y2); + } + else if (orientation == PlotOrientation.VERTICAL) { + double y0 = axis.valueToJava2D(value, adjusted, + plot.getRangeAxisEdge()); + double y1 = y0 - getYOffset(); + double x0 = dataArea.getMinX(); + double x1 = x0 + getXOffset(); + double x2 = dataArea.getMaxX(); + line1 = new Line2D.Double(x0, y0, x1, y1); + line2 = new Line2D.Double(x1, y1, x2, y1); + } + g2.setPaint(plot.getRangeGridlinePaint()); + g2.setStroke(plot.getRangeGridlineStroke()); + g2.draw(line1); + g2.draw(line2); + + } + + /** + * Draws a range marker. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param marker the marker. + * @param dataArea the area for plotting data (not including 3D effect). + */ + @Override + public void drawRangeMarker(Graphics2D g2, CategoryPlot plot, + ValueAxis axis, Marker marker, Rectangle2D dataArea) { + + Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), + dataArea.getY() + getYOffset(), + dataArea.getWidth() - getXOffset(), + dataArea.getHeight() - getYOffset()); + + if (marker instanceof ValueMarker) { + ValueMarker vm = (ValueMarker) marker; + double value = vm.getValue(); + Range range = axis.getRange(); + if (!range.contains(value)) { + return; + } + + GeneralPath path = null; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + float x = (float) axis.valueToJava2D(value, adjusted, + plot.getRangeAxisEdge()); + float y = (float) adjusted.getMaxY(); + path = new GeneralPath(); + path.moveTo(x, y); + path.lineTo((float) (x + getXOffset()), + y - (float) getYOffset()); + path.lineTo((float) (x + getXOffset()), + (float) (adjusted.getMinY() - getYOffset())); + path.lineTo(x, (float) adjusted.getMinY()); + path.closePath(); + } + else if (orientation == PlotOrientation.VERTICAL) { + float y = (float) axis.valueToJava2D(value, adjusted, + plot.getRangeAxisEdge()); + float x = (float) dataArea.getX(); + path = new GeneralPath(); + path.moveTo(x, y); + path.lineTo(x + (float) this.xOffset, y - (float) this.yOffset); + path.lineTo((float) (adjusted.getMaxX() + this.xOffset), + y - (float) this.yOffset); + path.lineTo((float) (adjusted.getMaxX()), y); + path.closePath(); + } + g2.setPaint(marker.getPaint()); + g2.fill(path); + g2.setPaint(marker.getOutlinePaint()); + g2.draw(path); + } + else { + super.drawRangeMarker(g2, plot, axis, marker, adjusted); + // TODO: draw the interval marker with a 3D effect + } + } + + /** + * Draw a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area in which the data is drawn. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, + int column, int pass) { + + if (!getItemVisible(row, column)) { + return; + } + + // nothing is drawn for null... + Number v = dataset.getValue(row, column); + if (v == null) { + return; + } + + Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), + dataArea.getY() + getYOffset(), + dataArea.getWidth() - getXOffset(), + dataArea.getHeight() - getYOffset()); + + PlotOrientation orientation = plot.getOrientation(); + + // current data point... + double x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), + adjusted, plot.getDomainAxisEdge()); + double value = v.doubleValue(); + double y1 = rangeAxis.valueToJava2D(value, adjusted, + plot.getRangeAxisEdge()); + + Shape shape = getItemShape(row, column); + if (orientation == PlotOrientation.HORIZONTAL) { + shape = ShapeUtilities.createTranslatedShape(shape, y1, x1); + } + else if (orientation == PlotOrientation.VERTICAL) { + shape = ShapeUtilities.createTranslatedShape(shape, x1, y1); + } + + if (pass == 0 && getItemLineVisible(row, column)) { + if (column != 0) { + + Number previousValue = dataset.getValue(row, column - 1); + if (previousValue != null) { + + // previous data point... + double previous = previousValue.doubleValue(); + double x0 = domainAxis.getCategoryMiddle(column - 1, + getColumnCount(), adjusted, + plot.getDomainAxisEdge()); + double y0 = rangeAxis.valueToJava2D(previous, adjusted, + plot.getRangeAxisEdge()); + + double x2 = x0 + getXOffset(); + double y2 = y0 - getYOffset(); + double x3 = x1 + getXOffset(); + double y3 = y1 - getYOffset(); + + GeneralPath clip = new GeneralPath(); + + if (orientation == PlotOrientation.HORIZONTAL) { + clip.moveTo((float) y0, (float) x0); + clip.lineTo((float) y1, (float) x1); + clip.lineTo((float) y3, (float) x3); + clip.lineTo((float) y2, (float) x2); + clip.lineTo((float) y0, (float) x0); + clip.closePath(); + } + else if (orientation == PlotOrientation.VERTICAL) { + clip.moveTo((float) x0, (float) y0); + clip.lineTo((float) x1, (float) y1); + clip.lineTo((float) x3, (float) y3); + clip.lineTo((float) x2, (float) y2); + clip.lineTo((float) x0, (float) y0); + clip.closePath(); + } + + g2.setPaint(getItemPaint(row, column)); + g2.fill(clip); + g2.setStroke(getItemOutlineStroke(row, column)); + g2.setPaint(getItemOutlinePaint(row, column)); + g2.draw(clip); + } + } + } + + // draw the item label if there is one... + if (pass == 1 && isItemLabelVisible(row, column)) { + if (orientation == PlotOrientation.HORIZONTAL) { + drawItemLabel(g2, orientation, dataset, row, column, y1, x1, + (value < 0.0)); + } + else if (orientation == PlotOrientation.VERTICAL) { + drawItemLabel(g2, orientation, dataset, row, column, x1, y1, + (value < 0.0)); + } + } + + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, shape); + } + + } + + /** + * Checks this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof LineRenderer3D)) { + return false; + } + LineRenderer3D that = (LineRenderer3D) obj; + if (this.xOffset != that.xOffset) { + return false; + } + if (this.yOffset != that.yOffset) { + return false; + } + if (!PaintUtilities.equal(this.wallPaint, that.wallPaint)) { + return false; + } + return super.equals(obj); + } + + /** + * 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.wallPaint, 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.wallPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java new file mode 100755 index 0000000..6e47112 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/MinMaxCategoryRenderer.java @@ -0,0 +1,568 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * MinMaxCategoryRenderer.java + * --------------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: Tomer Peretz; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Christian W. Zuckschwerdt; + * Nicolas Brodu (for Astrium and EADS Corporate Research + * Center); + * + * Changes: + * -------- + * 29-May-2002 : Version 1 (TP); + * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and + * CategoryToolTipGenerator interface (DG); + * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG); + * 17-Jan-2003 : Moved plot classes to a separate package (DG); + * 10-Apr-2003 : Changed CategoryDataset to KeyedValues2DDataset in drawItem() + * method (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 08-Sep-2003 : Implemented Serializable (NB); + * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 17-Nov-2005 : Added change events and argument checks (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 09-Mar-2007 : Fixed problem with horizontal rendering (DG); + * 28-Sep-2007 : Added equals() method override (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Component; +import java.awt.Graphics; +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.Arc2D; +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 javax.swing.Icon; + +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.category.CategoryDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.util.PaintUtilities; + +/** + * Renderer for drawing min max plot. This renderer draws all the series under + * the same category in the same x position using objectIcon and + * a line from the maximum value to the minimum value. For use with the + * {@link CategoryPlot} class. The example shown here is generated by + * the MinMaxCategoryPlotDemo1.java program included in the + * JFreeChart Demo Collection: + *

+ * MinMaxCategoryRendererSample.png + */ +public class MinMaxCategoryRenderer extends AbstractCategoryItemRenderer { + + /** For serialization. */ + private static final long serialVersionUID = 2935615937671064911L; + + /** A flag indicating whether or not lines are drawn between XY points. */ + private boolean plotLines = false; + + /** + * The paint of the line between the minimum value and the maximum value. + */ + private transient Paint groupPaint = Color.black; + + /** + * The stroke of the line between the minimum value and the maximum value. + */ + private transient Stroke groupStroke = new BasicStroke(1.0f); + + /** The icon used to indicate the minimum value.*/ + private transient Icon minIcon = getIcon(new Arc2D.Double(-4, -4, 8, 8, 0, + 360, Arc2D.OPEN), null, Color.black); + + /** The icon used to indicate the maximum value.*/ + private transient Icon maxIcon = getIcon(new Arc2D.Double(-4, -4, 8, 8, 0, + 360, Arc2D.OPEN), null, Color.black); + + /** The icon used to indicate the values.*/ + private transient Icon objectIcon = getIcon(new Line2D.Double(-4, 0, 4, 0), + false, true); + + /** The last category. */ + private int lastCategory = -1; + + /** The minimum. */ + private double min; + + /** The maximum. */ + private double max; + + /** + * Default constructor. + */ + public MinMaxCategoryRenderer() { + super(); + } + + /** + * Gets whether or not lines are drawn between category points. + * + * @return boolean true if line will be drawn between sequenced categories, + * otherwise false. + * + * @see #setDrawLines(boolean) + */ + public boolean isDrawLines() { + return this.plotLines; + } + + /** + * Sets the flag that controls whether or not lines are drawn to connect + * the items within a series and sends a {@link RendererChangeEvent} to + * all registered listeners. + * + * @param draw the new value of the flag. + * + * @see #isDrawLines() + */ + public void setDrawLines(boolean draw) { + if (this.plotLines != draw) { + this.plotLines = draw; + fireChangeEvent(); + } + } + + /** + * Returns the paint used to draw the line between the minimum and maximum + * value items in each category. + * + * @return The paint (never null). + * + * @see #setGroupPaint(Paint) + */ + public Paint getGroupPaint() { + return this.groupPaint; + } + + /** + * Sets the paint used to draw the line between the minimum and maximum + * value items in each category and sends a {@link RendererChangeEvent} to + * all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getGroupPaint() + */ + public void setGroupPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.groupPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the stroke used to draw the line between the minimum and maximum + * value items in each category. + * + * @return The stroke (never null). + * + * @see #setGroupStroke(Stroke) + */ + public Stroke getGroupStroke() { + return this.groupStroke; + } + + /** + * Sets the stroke of the line between the minimum value and the maximum + * value and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param stroke the new stroke (null not permitted). + */ + public void setGroupStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.groupStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the icon drawn for each data item. + * + * @return The icon (never null). + * + * @see #setObjectIcon(Icon) + */ + public Icon getObjectIcon() { + return this.objectIcon; + } + + /** + * Sets the icon drawn for each data item and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param icon the icon. + * + * @see #getObjectIcon() + */ + public void setObjectIcon(Icon icon) { + ParamChecks.nullNotPermitted(icon, "icon"); + this.objectIcon = icon; + fireChangeEvent(); + } + + /** + * Returns the icon displayed for the maximum value data item within each + * category. + * + * @return The icon (never null). + * + * @see #setMaxIcon(Icon) + */ + public Icon getMaxIcon() { + return this.maxIcon; + } + + /** + * Sets the icon displayed for the maximum value data item within each + * category and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param icon the icon (null not permitted). + * + * @see #getMaxIcon() + */ + public void setMaxIcon(Icon icon) { + ParamChecks.nullNotPermitted(icon, "icon"); + this.maxIcon = icon; + fireChangeEvent(); + } + + /** + * Returns the icon displayed for the minimum value data item within each + * category. + * + * @return The icon (never null). + * + * @see #setMinIcon(Icon) + */ + public Icon getMinIcon() { + return this.minIcon; + } + + /** + * Sets the icon displayed for the minimum value data item within each + * category and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param icon the icon (null not permitted). + * + * @see #getMinIcon() + */ + public void setMinIcon(Icon icon) { + ParamChecks.nullNotPermitted(icon, "icon"); + this.minIcon = icon; + fireChangeEvent(); + } + + /** + * Draw a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area in which the data is drawn. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, + int pass) { + + // first check the number we are plotting... + Number value = dataset.getValue(row, column); + if (value != null) { + // current data point... + double x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()); + double y1 = rangeAxis.valueToJava2D(value.doubleValue(), dataArea, + plot.getRangeAxisEdge()); + Shape hotspot = new Rectangle2D.Double(x1 - 4, y1 - 4, 8.0, 8.0); + + g2.setPaint(getItemPaint(row, column)); + g2.setStroke(getItemStroke(row, column)); + + PlotOrientation orient = plot.getOrientation(); + if (orient == PlotOrientation.VERTICAL) { + this.objectIcon.paintIcon(null, g2, (int) x1, (int) y1); + } + else { + this.objectIcon.paintIcon(null, g2, (int) y1, (int) x1); + } + + if (this.lastCategory == column) { + if (this.min > value.doubleValue()) { + this.min = value.doubleValue(); + } + if (this.max < value.doubleValue()) { + this.max = value.doubleValue(); + } + + // last series, so we are ready to draw the min and max + if (dataset.getRowCount() - 1 == row) { + g2.setPaint(this.groupPaint); + g2.setStroke(this.groupStroke); + double minY = rangeAxis.valueToJava2D(this.min, dataArea, + plot.getRangeAxisEdge()); + double maxY = rangeAxis.valueToJava2D(this.max, dataArea, + plot.getRangeAxisEdge()); + + if (orient == PlotOrientation.VERTICAL) { + g2.draw(new Line2D.Double(x1, minY, x1, maxY)); + this.minIcon.paintIcon(null, g2, (int) x1, (int) minY); + this.maxIcon.paintIcon(null, g2, (int) x1, (int) maxY); + } + else { + g2.draw(new Line2D.Double(minY, x1, maxY, x1)); + this.minIcon.paintIcon(null, g2, (int) minY, (int) x1); + this.maxIcon.paintIcon(null, g2, (int) maxY, (int) x1); + } + } + } + else { // reset the min and max + this.lastCategory = column; + this.min = value.doubleValue(); + this.max = value.doubleValue(); + } + + // connect to the previous point + if (this.plotLines) { + if (column != 0) { + Number previousValue = dataset.getValue(row, column - 1); + if (previousValue != null) { + // previous data point... + double previous = previousValue.doubleValue(); + double x0 = domainAxis.getCategoryMiddle(column - 1, + getColumnCount(), dataArea, + plot.getDomainAxisEdge()); + double y0 = rangeAxis.valueToJava2D(previous, dataArea, + plot.getRangeAxisEdge()); + g2.setPaint(getItemPaint(row, column)); + g2.setStroke(getItemStroke(row, column)); + Line2D line; + if (orient == PlotOrientation.VERTICAL) { + line = new Line2D.Double(x0, y0, x1, y1); + } + else { + line = new Line2D.Double(y0, x0, y1, x1); + } + g2.draw(line); + } + } + } + + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, hotspot); + } + } + } + + /** + * Tests this instance for equality with an arbitrary object. The icon + * fields are NOT included in the test, so this implementation is a little + * weak. + * + * @param obj the object (null permitted). + * + * @return A boolean. + * + * @since 1.0.7 + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof MinMaxCategoryRenderer)) { + return false; + } + MinMaxCategoryRenderer that = (MinMaxCategoryRenderer) obj; + if (this.plotLines != that.plotLines) { + return false; + } + if (!PaintUtilities.equal(this.groupPaint, that.groupPaint)) { + return false; + } + if (!this.groupStroke.equals(that.groupStroke)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns an icon. + * + * @param shape the shape. + * @param fillPaint the fill paint. + * @param outlinePaint the outline paint. + * + * @return The icon. + */ + private Icon getIcon(Shape shape, final Paint fillPaint, + final Paint outlinePaint) { + + final int width = shape.getBounds().width; + final int height = shape.getBounds().height; + final GeneralPath path = new GeneralPath(shape); + return new Icon() { + @Override + public void paintIcon(Component c, Graphics g, int x, int y) { + Graphics2D g2 = (Graphics2D) g; + path.transform(AffineTransform.getTranslateInstance(x, y)); + if (fillPaint != null) { + g2.setPaint(fillPaint); + g2.fill(path); + } + if (outlinePaint != null) { + g2.setPaint(outlinePaint); + g2.draw(path); + } + path.transform(AffineTransform.getTranslateInstance(-x, -y)); + } + + @Override + public int getIconWidth() { + return width; + } + + @Override + public int getIconHeight() { + return height; + } + }; + } + + /** + * Returns an icon from a shape. + * + * @param shape the shape. + * @param fill the fill flag. + * @param outline the outline flag. + * + * @return The icon. + */ + private Icon getIcon(Shape shape, final boolean fill, + final boolean outline) { + final int width = shape.getBounds().width; + final int height = shape.getBounds().height; + final GeneralPath path = new GeneralPath(shape); + return new Icon() { + @Override + public void paintIcon(Component c, Graphics g, int x, int y) { + Graphics2D g2 = (Graphics2D) g; + path.transform(AffineTransform.getTranslateInstance(x, y)); + if (fill) { + g2.fill(path); + } + if (outline) { + g2.draw(path); + } + path.transform(AffineTransform.getTranslateInstance(-x, -y)); + } + + @Override + public int getIconWidth() { + return width; + } + + @Override + public int getIconHeight() { + return height; + } + }; + } + + /** + * 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.writeStroke(this.groupStroke, stream); + SerialUtilities.writePaint(this.groupPaint, 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.groupStroke = SerialUtilities.readStroke(stream); + this.groupPaint = SerialUtilities.readPaint(stream); + + this.minIcon = getIcon(new Arc2D.Double(-4, -4, 8, 8, 0, 360, + Arc2D.OPEN), null, Color.black); + this.maxIcon = getIcon(new Arc2D.Double(-4, -4, 8, 8, 0, 360, + Arc2D.OPEN), null, Color.black); + this.objectIcon = getIcon(new Line2D.Double(-4, 0, 4, 0), false, true); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/ScatterRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/ScatterRenderer.java new file mode 100755 index 0000000..9c9993b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/ScatterRenderer.java @@ -0,0 +1,597 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * ScatterRenderer.java + * -------------------- + * (C) Copyright 2007-2009, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): David Forslund; + * Peter Kolb (patches 2497611, 2791407); + * + * Changes + * ------- + * 08-Oct-2007 : Version 1, based on patch 1780779 by David Forslund (DG); + * 11-Oct-2007 : Renamed ScatterRenderer (DG); + * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * 14-Jan-2009 : Added support for seriesVisible flags (PK); + * 16-May-2009 : Patch 2791407 - findRangeBounds() override (PK); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +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 java.util.List; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.statistics.MultiValueCategoryDataset; +import org.jfree.util.BooleanList; +import org.jfree.util.BooleanUtilities; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A renderer that handles the multiple values from a + * {@link MultiValueCategoryDataset} by plotting a shape for each value for + * each given item in the dataset. The example shown here is generated by + * the ScatterRendererDemo1.java program included in the + * JFreeChart Demo Collection: + *

+ * ScatterRendererSample.png + * + * @since 1.0.7 + */ +public class ScatterRenderer extends AbstractCategoryItemRenderer + implements Cloneable, PublicCloneable, Serializable { + + /** + * A table of flags that control (per series) whether or not shapes are + * filled. + */ + private BooleanList seriesShapesFilled; + + /** + * The default value returned by the getShapeFilled() method. + */ + private boolean baseShapesFilled; + + /** + * A flag that controls whether the fill paint is used for filling + * shapes. + */ + private boolean useFillPaint; + + /** + * A flag that controls whether outlines are drawn for shapes. + */ + private boolean drawOutlines; + + /** + * A flag that controls whether the outline paint is used for drawing shape + * outlines - if not, the regular series paint is used. + */ + private boolean useOutlinePaint; + + /** + * A flag that controls whether or not the x-position for each item is + * offset within the category according to the series. + */ + private boolean useSeriesOffset; + + /** + * The item margin used for series offsetting - this allows the positioning + * to match the bar positions of the {@link BarRenderer} class. + */ + private double itemMargin; + + /** + * Constructs a new renderer. + */ + public ScatterRenderer() { + this.seriesShapesFilled = new BooleanList(); + this.baseShapesFilled = true; + this.useFillPaint = false; + this.drawOutlines = false; + this.useOutlinePaint = false; + this.useSeriesOffset = true; + this.itemMargin = 0.20; + } + + /** + * Returns the flag that controls whether or not the x-position for each + * data item is offset within the category according to the series. + * + * @return A boolean. + * + * @see #setUseSeriesOffset(boolean) + */ + public boolean getUseSeriesOffset() { + return this.useSeriesOffset; + } + + /** + * Sets the flag that controls whether or not the x-position for each + * data item is offset within its category according to the series, and + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param offset the offset. + * + * @see #getUseSeriesOffset() + */ + public void setUseSeriesOffset(boolean offset) { + this.useSeriesOffset = offset; + fireChangeEvent(); + } + + /** + * Returns the item margin, which is the gap between items within a + * category (expressed as a percentage of the overall category width). + * This can be used to match the offset alignment with the bars drawn by + * a {@link BarRenderer}). + * + * @return The item margin. + * + * @see #setItemMargin(double) + * @see #getUseSeriesOffset() + */ + public double getItemMargin() { + return this.itemMargin; + } + + /** + * Sets the item margin, which is the gap between items within a category + * (expressed as a percentage of the overall category width), and sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param margin the margin (0.0 <= margin < 1.0). + * + * @see #getItemMargin() + * @see #getUseSeriesOffset() + */ + public void setItemMargin(double margin) { + if (margin < 0.0 || margin >= 1.0) { + throw new IllegalArgumentException("Requires 0.0 <= margin < 1.0."); + } + this.itemMargin = margin; + fireChangeEvent(); + } + + /** + * Returns true if outlines should be drawn for shapes, and + * false otherwise. + * + * @return A boolean. + * + * @see #setDrawOutlines(boolean) + */ + public boolean getDrawOutlines() { + return this.drawOutlines; + } + + /** + * Sets the flag that controls whether outlines are drawn for + * shapes, and sends a {@link RendererChangeEvent} to all registered + * listeners. + *

+ * In some cases, shapes look better if they do NOT have an outline, but + * this flag allows you to set your own preference. + * + * @param flag the flag. + * + * @see #getDrawOutlines() + */ + public void setDrawOutlines(boolean flag) { + this.drawOutlines = flag; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether the outline paint is used for + * shape outlines. If not, the regular series paint is used. + * + * @return A boolean. + * + * @see #setUseOutlinePaint(boolean) + */ + public boolean getUseOutlinePaint() { + return this.useOutlinePaint; + } + + /** + * Sets the flag that controls whether the outline paint is used for shape + * outlines, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param use the flag. + * + * @see #getUseOutlinePaint() + */ + public void setUseOutlinePaint(boolean use) { + this.useOutlinePaint = use; + fireChangeEvent(); + } + + // SHAPES FILLED + + /** + * Returns the flag used to control whether or not the shape for an item + * is filled. The default implementation passes control to the + * getSeriesShapesFilled method. You can override this method + * if you require different behaviour. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @return A boolean. + */ + public boolean getItemShapeFilled(int series, int item) { + return getSeriesShapesFilled(series); + } + + /** + * Returns the flag used to control whether or not the shapes for a series + * are filled. + * + * @param series the series index (zero-based). + * @return A boolean. + */ + public boolean getSeriesShapesFilled(int series) { + Boolean flag = this.seriesShapesFilled.getBoolean(series); + if (flag != null) { + return flag.booleanValue(); + } + else { + return this.baseShapesFilled; + } + + } + + /** + * Sets the 'shapes filled' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param filled the flag. + */ + public void setSeriesShapesFilled(int series, Boolean filled) { + this.seriesShapesFilled.setBoolean(series, filled); + fireChangeEvent(); + } + + /** + * Sets the 'shapes filled' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param filled the flag. + */ + public void setSeriesShapesFilled(int series, boolean filled) { + this.seriesShapesFilled.setBoolean(series, + BooleanUtilities.valueOf(filled)); + fireChangeEvent(); + } + + /** + * Returns the base 'shape filled' attribute. + * + * @return The base flag. + */ + public boolean getBaseShapesFilled() { + return this.baseShapesFilled; + } + + /** + * Sets the base 'shapes filled' flag and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param flag the flag. + */ + public void setBaseShapesFilled(boolean flag) { + this.baseShapesFilled = flag; + fireChangeEvent(); + } + + /** + * Returns true if the renderer should use the fill paint + * setting to fill shapes, and false if it should just + * use the regular paint. + * + * @return A boolean. + */ + public boolean getUseFillPaint() { + return this.useFillPaint; + } + + /** + * Sets the flag that controls whether the fill paint is used to fill + * shapes, and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param flag the flag. + */ + public void setUseFillPaint(boolean flag) { + this.useFillPaint = flag; + fireChangeEvent(); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. This takes into account the range + * between the min/max values, possibly ignoring invisible series. + * + * @param dataset the dataset (null permitted). + * + * @return The range (or null if the dataset is + * null or empty). + */ + @Override + public Range findRangeBounds(CategoryDataset dataset) { + return findRangeBounds(dataset, true); + } + + /** + * Draw a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area in which the data is drawn. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, + int pass) { + + // do nothing if item is not visible + if (!getItemVisible(row, column)) { + return; + } + int visibleRow = state.getVisibleSeriesIndex(row); + if (visibleRow < 0) { + return; + } + int visibleRowCount = state.getVisibleSeriesCount(); + + PlotOrientation orientation = plot.getOrientation(); + + MultiValueCategoryDataset d = (MultiValueCategoryDataset) dataset; + List values = d.getValues(row, column); + if (values == null) { + return; + } + int valueCount = values.size(); + for (int i = 0; i < valueCount; i++) { + // current data point... + double x1; + if (this.useSeriesOffset) { + x1 = domainAxis.getCategorySeriesMiddle(column, + dataset.getColumnCount(), visibleRow, visibleRowCount, + this.itemMargin, dataArea, plot.getDomainAxisEdge()); + } + else { + x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()); + } + Number n = (Number) values.get(i); + double value = n.doubleValue(); + double y1 = rangeAxis.valueToJava2D(value, dataArea, + plot.getRangeAxisEdge()); + + Shape shape = getItemShape(row, column); + if (orientation == PlotOrientation.HORIZONTAL) { + shape = ShapeUtilities.createTranslatedShape(shape, y1, x1); + } + else if (orientation == PlotOrientation.VERTICAL) { + shape = ShapeUtilities.createTranslatedShape(shape, x1, y1); + } + if (getItemShapeFilled(row, column)) { + if (this.useFillPaint) { + g2.setPaint(getItemFillPaint(row, column)); + } + else { + g2.setPaint(getItemPaint(row, column)); + } + g2.fill(shape); + } + if (this.drawOutlines) { + if (this.useOutlinePaint) { + g2.setPaint(getItemOutlinePaint(row, column)); + } + else { + g2.setPaint(getItemPaint(row, column)); + } + g2.setStroke(getItemOutlineStroke(row, column)); + g2.draw(shape); + } + } + + } + + /** + * Returns a legend item for a series. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return The legend item. + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + + CategoryPlot cp = getPlot(); + if (cp == null) { + return null; + } + + if (isSeriesVisible(series) && isSeriesVisibleInLegend(series)) { + CategoryDataset dataset = cp.getDataset(datasetIndex); + String label = getLegendItemLabelGenerator().generateLabel( + dataset, series); + String description = label; + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel( + dataset, series); + } + Shape shape = lookupLegendShape(series); + Paint paint = lookupSeriesPaint(series); + Paint fillPaint = (this.useFillPaint + ? getItemFillPaint(series, 0) : paint); + boolean shapeOutlineVisible = this.drawOutlines; + Paint outlinePaint = (this.useOutlinePaint + ? getItemOutlinePaint(series, 0) : paint); + Stroke outlineStroke = lookupSeriesOutlineStroke(series); + LegendItem result = new LegendItem(label, description, toolTipText, + urlText, true, shape, getItemShapeFilled(series, 0), + fillPaint, shapeOutlineVisible, outlinePaint, outlineStroke, + false, new Line2D.Double(-7.0, 0.0, 7.0, 0.0), + getItemStroke(series, 0), getItemPaint(series, 0)); + result.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + result.setLabelPaint(labelPaint); + } + result.setDataset(dataset); + result.setDatasetIndex(datasetIndex); + result.setSeriesKey(dataset.getRowKey(series)); + result.setSeriesIndex(series); + return result; + } + return null; + + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ScatterRenderer)) { + return false; + } + ScatterRenderer that = (ScatterRenderer) obj; + if (!ObjectUtilities.equal(this.seriesShapesFilled, + that.seriesShapesFilled)) { + return false; + } + if (this.baseShapesFilled != that.baseShapesFilled) { + return false; + } + if (this.useFillPaint != that.useFillPaint) { + return false; + } + if (this.drawOutlines != that.drawOutlines) { + return false; + } + if (this.useOutlinePaint != that.useOutlinePaint) { + return false; + } + if (this.useSeriesOffset != that.useSeriesOffset) { + return false; + } + if (this.itemMargin != that.itemMargin) { + return false; + } + return super.equals(obj); + } + + /** + * Returns an independent copy of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException should not happen. + */ + @Override + public Object clone() throws CloneNotSupportedException { + ScatterRenderer clone = (ScatterRenderer) super.clone(); + clone.seriesShapesFilled + = (BooleanList) this.seriesShapesFilled.clone(); + return clone; + } + + /** + * Provides serialization support. + * + * @param stream the output stream. + * @throws java.io.IOException if there is an I/O error. + */ + private void writeObject(ObjectOutputStream stream) throws IOException { + stream.defaultWriteObject(); + + } + + /** + * Provides serialization support. + * + * @param stream the input stream. + * @throws java.io.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(); + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StackedAreaRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StackedAreaRenderer.java new file mode 100755 index 0000000..8f5a456 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StackedAreaRenderer.java @@ -0,0 +1,549 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * StackedAreaRenderer.java + * ------------------------ + * (C) Copyright 2002-2009, by Dan Rivett (d.rivett@ukonline.co.uk) and + * Contributors. + * + * Original Author: Dan Rivett (adapted from AreaRenderer); + * Contributor(s): Jon Iles; + * David Gilbert (for Object Refinery Limited); + * Christian W. Zuckschwerdt; + * Peter Kolb (patch 2511330); + * + * Changes: + * -------- + * 20-Sep-2002 : Version 1, contributed by Dan Rivett; + * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and + * CategoryToolTipGenerator interface (DG); + * 01-Nov-2002 : Added tooltips (DG); + * 06-Nov-2002 : Renamed drawCategoryItem() --> drawItem() and now using axis + * for category spacing. Renamed StackedAreaCategoryItemRenderer + * --> StackedAreaRenderer (DG); + * 26-Nov-2002 : Switched CategoryDataset --> TableDataset (DG); + * 26-Nov-2002 : Replaced isStacked() method with getRangeType() method (DG); + * 17-Jan-2003 : Moved plot classes to a separate package (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 13-May-2003 : Modified to take into account the plot orientation (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 07-Oct-2003 : Added renderer state (DG); + * 29-Apr-2004 : Added getRangeExtent() override (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds() (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 11-Oct-2006 : Added support for rendering data values as percentages, + * and added a second pass for drawing item labels (DG); + * 04-Feb-2009 : Fixed support for hidden series, and bug in findRangeBounds() + * method for null dataset (PK/DG); + * 04-Feb-2009 : Added item label support, and generate entities only in first + * pass (DG); + * 04-Feb-2009 : Fixed bug for renderAsPercentages == true (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.geom.GeneralPath; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.data.DataUtilities; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PublicCloneable; + +/** + * A renderer that draws stacked area charts for a {@link CategoryPlot}. + * The example shown here is generated by the + * StackedAreaChartDemo1.java program included in the + * JFreeChart Demo Collection: + *

+ * StackedAreaRendererSample.png + */ +public class StackedAreaRenderer extends AreaRenderer + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -3595635038460823663L; + + /** A flag that controls whether the areas display values or percentages. */ + private boolean renderAsPercentages; + + /** + * Creates a new renderer. + */ + public StackedAreaRenderer() { + this(false); + } + + /** + * Creates a new renderer. + * + * @param renderAsPercentages a flag that controls whether the data values + * are rendered as percentages. + */ + public StackedAreaRenderer(boolean renderAsPercentages) { + super(); + this.renderAsPercentages = renderAsPercentages; + } + + /** + * Returns true if the renderer displays each item value as + * a percentage (so that the stacked areas add to 100%), and + * false otherwise. + * + * @return A boolean. + * + * @since 1.0.3 + */ + public boolean getRenderAsPercentages() { + return this.renderAsPercentages; + } + + /** + * Sets the flag that controls whether the renderer displays each item + * value as a percentage (so that the stacked areas add to 100%), and sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param asPercentages the flag. + * + * @since 1.0.3 + */ + public void setRenderAsPercentages(boolean asPercentages) { + this.renderAsPercentages = asPercentages; + fireChangeEvent(); + } + + /** + * Returns the number of passes (2) required by this renderer. + * The first pass is used to draw the areas, the second pass is used to + * draw the item labels (if visible). + * + * @return The number of passes required by the renderer. + */ + @Override + public int getPassCount() { + return 2; + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null not permitted). + * + * @return The range (or null if the dataset is empty). + */ + @Override + public Range findRangeBounds(CategoryDataset dataset) { + if (dataset == null) { + return null; + } + if (this.renderAsPercentages) { + return new Range(0.0, 1.0); + } + else { + return DatasetUtilities.findStackedRangeBounds(dataset); + } + } + + /** + * Draw a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data plot area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the data. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, + int pass) { + + if (!isSeriesVisible(row)) { + return; + } + + // setup for collecting optional entity info... + Shape entityArea; + EntityCollection entities = state.getEntityCollection(); + + double y1 = 0.0; + Number n = dataset.getValue(row, column); + if (n != null) { + y1 = n.doubleValue(); + if (this.renderAsPercentages) { + double total = DataUtilities.calculateColumnTotal(dataset, + column, state.getVisibleSeriesArray()); + y1 = y1 / total; + } + } + double[] stack1 = getStackValues(dataset, row, column, + state.getVisibleSeriesArray()); + + + // leave the y values (y1, y0) untranslated as it is going to be be + // stacked up later by previous series values, after this it will be + // translated. + double xx1 = domainAxis.getCategoryMiddle(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()); + + + // get the previous point and the next point so we can calculate a + // "hot spot" for the area (used by the chart entity)... + double y0 = 0.0; + n = dataset.getValue(row, Math.max(column - 1, 0)); + if (n != null) { + y0 = n.doubleValue(); + if (this.renderAsPercentages) { + double total = DataUtilities.calculateColumnTotal(dataset, + Math.max(column - 1, 0), state.getVisibleSeriesArray()); + y0 = y0 / total; + } + } + double[] stack0 = getStackValues(dataset, row, Math.max(column - 1, 0), + state.getVisibleSeriesArray()); + + // FIXME: calculate xx0 + double xx0 = domainAxis.getCategoryStart(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()); + + int itemCount = dataset.getColumnCount(); + double y2 = 0.0; + n = dataset.getValue(row, Math.min(column + 1, itemCount - 1)); + if (n != null) { + y2 = n.doubleValue(); + if (this.renderAsPercentages) { + double total = DataUtilities.calculateColumnTotal(dataset, + Math.min(column + 1, itemCount - 1), + state.getVisibleSeriesArray()); + y2 = y2 / total; + } + } + double[] stack2 = getStackValues(dataset, row, Math.min(column + 1, + itemCount - 1), state.getVisibleSeriesArray()); + + double xx2 = domainAxis.getCategoryEnd(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()); + + // FIXME: calculate xxLeft and xxRight + double xxLeft = xx0; + double xxRight = xx2; + + double[] stackLeft = averageStackValues(stack0, stack1); + double[] stackRight = averageStackValues(stack1, stack2); + double[] adjStackLeft = adjustedStackValues(stack0, stack1); + double[] adjStackRight = adjustedStackValues(stack1, stack2); + + float transY1; + + RectangleEdge edge1 = plot.getRangeAxisEdge(); + + GeneralPath left = new GeneralPath(); + GeneralPath right = new GeneralPath(); + if (y1 >= 0.0) { // handle positive value + transY1 = (float) rangeAxis.valueToJava2D(y1 + stack1[1], dataArea, + edge1); + float transStack1 = (float) rangeAxis.valueToJava2D(stack1[1], + dataArea, edge1); + float transStackLeft = (float) rangeAxis.valueToJava2D( + adjStackLeft[1], dataArea, edge1); + + // LEFT POLYGON + if (y0 >= 0.0) { + double yleft = (y0 + y1) / 2.0 + stackLeft[1]; + float transYLeft + = (float) rangeAxis.valueToJava2D(yleft, dataArea, edge1); + left.moveTo((float) xx1, transY1); + left.lineTo((float) xx1, transStack1); + left.lineTo((float) xxLeft, transStackLeft); + left.lineTo((float) xxLeft, transYLeft); + left.closePath(); + } + else { + left.moveTo((float) xx1, transStack1); + left.lineTo((float) xx1, transY1); + left.lineTo((float) xxLeft, transStackLeft); + left.closePath(); + } + + float transStackRight = (float) rangeAxis.valueToJava2D( + adjStackRight[1], dataArea, edge1); + // RIGHT POLYGON + if (y2 >= 0.0) { + double yright = (y1 + y2) / 2.0 + stackRight[1]; + float transYRight + = (float) rangeAxis.valueToJava2D(yright, dataArea, edge1); + right.moveTo((float) xx1, transStack1); + right.lineTo((float) xx1, transY1); + right.lineTo((float) xxRight, transYRight); + right.lineTo((float) xxRight, transStackRight); + right.closePath(); + } + else { + right.moveTo((float) xx1, transStack1); + right.lineTo((float) xx1, transY1); + right.lineTo((float) xxRight, transStackRight); + right.closePath(); + } + } + else { // handle negative value + transY1 = (float) rangeAxis.valueToJava2D(y1 + stack1[0], dataArea, + edge1); + float transStack1 = (float) rangeAxis.valueToJava2D(stack1[0], + dataArea, edge1); + float transStackLeft = (float) rangeAxis.valueToJava2D( + adjStackLeft[0], dataArea, edge1); + + // LEFT POLYGON + if (y0 >= 0.0) { + left.moveTo((float) xx1, transStack1); + left.lineTo((float) xx1, transY1); + left.lineTo((float) xxLeft, transStackLeft); + left.clone(); + } + else { + double yleft = (y0 + y1) / 2.0 + stackLeft[0]; + float transYLeft = (float) rangeAxis.valueToJava2D(yleft, + dataArea, edge1); + left.moveTo((float) xx1, transY1); + left.lineTo((float) xx1, transStack1); + left.lineTo((float) xxLeft, transStackLeft); + left.lineTo((float) xxLeft, transYLeft); + left.closePath(); + } + float transStackRight = (float) rangeAxis.valueToJava2D( + adjStackRight[0], dataArea, edge1); + + // RIGHT POLYGON + if (y2 >= 0.0) { + right.moveTo((float) xx1, transStack1); + right.lineTo((float) xx1, transY1); + right.lineTo((float) xxRight, transStackRight); + right.closePath(); + } + else { + double yright = (y1 + y2) / 2.0 + stackRight[0]; + float transYRight = (float) rangeAxis.valueToJava2D(yright, + dataArea, edge1); + right.moveTo((float) xx1, transStack1); + right.lineTo((float) xx1, transY1); + right.lineTo((float) xxRight, transYRight); + right.lineTo((float) xxRight, transStackRight); + right.closePath(); + } + } + + if (pass == 0) { + Paint itemPaint = getItemPaint(row, column); + g2.setPaint(itemPaint); + g2.fill(left); + g2.fill(right); + + // add an entity for the item... + if (entities != null) { + GeneralPath gp = new GeneralPath(left); + gp.append(right, false); + entityArea = gp; + addItemEntity(entities, dataset, row, column, entityArea); + } + } + else if (pass == 1) { + drawItemLabel(g2, plot.getOrientation(), dataset, row, column, + xx1, transY1, y1 < 0.0); + } + + } + + /** + * Calculates the stacked values (one positive and one negative) of all + * series up to, but not including, series for the specified + * item. It returns [0.0, 0.0] if series is the first series. + * + * @param dataset the dataset (null not permitted). + * @param series the series index. + * @param index the item index. + * @param validRows the valid rows. + * + * @return An array containing the cumulative negative and positive values + * for all series values up to but excluding series + * for index. + */ + protected double[] getStackValues(CategoryDataset dataset, + int series, int index, int[] validRows) { + double[] result = new double[2]; + double total = 0.0; + if (this.renderAsPercentages) { + total = DataUtilities.calculateColumnTotal(dataset, index, + validRows); + } + for (int i = 0; i < series; i++) { + if (isSeriesVisible(i)) { + double v = 0.0; + Number n = dataset.getValue(i, index); + if (n != null) { + v = n.doubleValue(); + if (this.renderAsPercentages) { + v = v / total; + } + } + if (!Double.isNaN(v)) { + if (v >= 0.0) { + result[1] += v; + } + else { + result[0] += v; + } + } + } + } + return result; + } + + /** + * Returns a pair of "stack" values calculated as the mean of the two + * specified stack value pairs. + * + * @param stack1 the first stack pair. + * @param stack2 the second stack pair. + * + * @return A pair of average stack values. + */ + private double[] averageStackValues(double[] stack1, double[] stack2) { + double[] result = new double[2]; + result[0] = (stack1[0] + stack2[0]) / 2.0; + result[1] = (stack1[1] + stack2[1]) / 2.0; + return result; + } + + /** + * Calculates adjusted stack values from the supplied values. The value is + * the mean of the supplied values, unless either of the supplied values + * is zero, in which case the adjusted value is zero also. + * + * @param stack1 the first stack pair. + * @param stack2 the second stack pair. + * + * @return A pair of average stack values. + */ + private double[] adjustedStackValues(double[] stack1, double[] stack2) { + double[] result = new double[2]; + if (stack1[0] == 0.0 || stack2[0] == 0.0) { + result[0] = 0.0; + } + else { + result[0] = (stack1[0] + stack2[0]) / 2.0; + } + if (stack1[1] == 0.0 || stack2[1] == 0.0) { + result[1] = 0.0; + } + else { + result[1] = (stack1[1] + stack2[1]) / 2.0; + } + return result; + } + + /** + * Checks this instance for equality with an arbitrary object. + * + * @param obj the object (null not permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StackedAreaRenderer)) { + return false; + } + StackedAreaRenderer that = (StackedAreaRenderer) obj; + if (this.renderAsPercentages != that.renderAsPercentages) { + return false; + } + return super.equals(obj); + } + + /** + * Calculates the stacked value of the all series up to, but not including + * series for the specified category, category. + * It returns 0.0 if series is the first series, i.e. 0. + * + * @param dataset the dataset (null not permitted). + * @param series the series. + * @param category the category. + * + * @return double returns a cumulative value for all series' values up to + * but excluding series for Object + * category. + * + * @deprecated As of 1.0.13, as the method is never used internally. + */ + protected double getPreviousHeight(CategoryDataset dataset, + int series, int category) { + + double result = 0.0; + Number n; + double total = 0.0; + if (this.renderAsPercentages) { + total = DataUtilities.calculateColumnTotal(dataset, category); + } + for (int i = 0; i < series; i++) { + n = dataset.getValue(i, category); + if (n != null) { + double v = n.doubleValue(); + if (this.renderAsPercentages) { + v = v / total; + } + result += v; + } + } + return result; + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StackedBarRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StackedBarRenderer.java new file mode 100755 index 0000000..37be69b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StackedBarRenderer.java @@ -0,0 +1,431 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * StackedBarRenderer.java + * ----------------------- + * (C) Copyright 2000-2009, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Richard Atkinson; + * Thierry Saura; + * Christian W. Zuckschwerdt; + * Peter Kolb (patch 2511330); + * + * Changes + * ------- + * 19-Oct-2001 : Version 1 (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * 23-Oct-2001 : Changed intro and trail gaps on bar plots to use percentage of + * available space rather than a fixed number of units (DG); + * 15-Nov-2001 : Modified to allow for null data values (DG); + * 22-Nov-2001 : Modified to allow for negative data values (DG); + * 13-Dec-2001 : Added tooltips (DG); + * 16-Jan-2002 : Fixed bug for single category datasets (DG); + * 15-Feb-2002 : Added isStacked() method (DG); + * 14-Mar-2002 : Modified to implement the CategoryItemRenderer interface (DG); + * 24-May-2002 : Incorporated tooltips into chart entities (DG); + * 11-Jun-2002 : Added check for (permitted) null info object, bug and fix + * reported by David Basten. Also updated Javadocs. (DG); + * 25-Jun-2002 : Removed redundant import (DG); + * 26-Jun-2002 : Small change to entity (DG); + * 05-Aug-2002 : Small modification to drawCategoryItem method to support URLs + * for HTML image maps (RA); + * 08-Aug-2002 : Added optional linking lines, contributed by Thierry + * Saura (DG); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and + * CategoryToolTipGenerator interface (DG); + * 05-Nov-2002 : Replaced references to CategoryDataset with TableDataset (DG); + * 26-Nov-2002 : Replaced isStacked() method with getRangeType() method (DG); + * 17-Jan-2003 : Moved plot classes to a separate package (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 12-May-2003 : Merged horizontal and vertical stacked bar renderers (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 08-Sep-2003 : Fixed bug 799668 (isBarOutlineDrawn() ignored) (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 21-Oct-2003 : Moved bar width into renderer state (DG); + * 26-Nov-2003 : Added code to respect maxBarWidth attribute (DG); + * 05-Nov-2004 : Changed to a two-pass renderer so that item labels are not + * overwritten by other bars (DG); + * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds() (DG); + * 29-Mar-2005 : Modified drawItem() method so that a zero value is handled + * within the code for positive rather than negative values (DG); + * 20-Apr-2005 : Renamed CategoryLabelGenerator + * --> CategoryItemLabelGenerator (DG); + * 17-May-2005 : Added flag to allow rendering values as percentages - inspired + * by patch 1200886 submitted by John Xiao (DG); + * 09-Jun-2005 : Added accessor methods for the renderAsPercentages flag, + * provided equals() method, and use addItemEntity from + * superclass (DG); + * 09-Jun-2005 : Added support for GradientPaint - see bug report 1215670 (DG); + * 22-Sep-2005 : Renamed getMaxBarWidth() --> getMaximumBarWidth() (DG); + * 29-Sep-2005 : Use outline stroke in drawItem method - see bug report + * 1304139 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 11-Oct-2006 : Source reformatting (DG); + * 24-Jun-2008 : Added new barPainter mechanism (DG); + * 04-Feb-2009 : Added support for hidden series (PK); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.CategoryItemLabelGenerator; +import org.jfree.chart.labels.ItemLabelAnchor; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.DataUtilities; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.TextAnchor; +import org.jfree.util.PublicCloneable; + +/** + * A stacked bar renderer for use with the {@link CategoryPlot} class. + * The example shown here is generated by the + * StackedBarChartDemo1.java program included in the + * JFreeChart Demo Collection: + *

+ * StackedBarRendererSample.png + */ +public class StackedBarRenderer extends BarRenderer + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + static final long serialVersionUID = 6402943811500067531L; + + /** A flag that controls whether the bars display values or percentages. */ + private boolean renderAsPercentages; + + /** + * Creates a new renderer. By default, the renderer has no tool tip + * generator and no URL generator. These defaults have been chosen to + * minimise the processing required to generate a default chart. If you + * require tool tips or URLs, then you can easily add the required + * generators. + */ + public StackedBarRenderer() { + this(false); + } + + /** + * Creates a new renderer. + * + * @param renderAsPercentages a flag that controls whether the data values + * are rendered as percentages. + */ + public StackedBarRenderer(boolean renderAsPercentages) { + super(); + this.renderAsPercentages = renderAsPercentages; + + // set the default item label positions, which will only be used if + // the user requests visible item labels... + ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, + TextAnchor.CENTER); + setBasePositiveItemLabelPosition(p); + setBaseNegativeItemLabelPosition(p); + setPositiveItemLabelPositionFallback(null); + setNegativeItemLabelPositionFallback(null); + } + + /** + * Returns true if the renderer displays each item value as + * a percentage (so that the stacked bars add to 100%), and + * false otherwise. + * + * @return A boolean. + * + * @see #setRenderAsPercentages(boolean) + */ + public boolean getRenderAsPercentages() { + return this.renderAsPercentages; + } + + /** + * Sets the flag that controls whether the renderer displays each item + * value as a percentage (so that the stacked bars add to 100%), and sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param asPercentages the flag. + * + * @see #getRenderAsPercentages() + */ + public void setRenderAsPercentages(boolean asPercentages) { + this.renderAsPercentages = asPercentages; + fireChangeEvent(); + } + + /** + * Returns the number of passes (3) required by this renderer. + * The first pass is used to draw the bar shadows, the second pass is used + * to draw the bars, and the third pass is used to draw the item labels + * (if visible). + * + * @return The number of passes required by the renderer. + */ + @Override + public int getPassCount() { + return 3; + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (or null if the dataset is empty). + */ + @Override + public Range findRangeBounds(CategoryDataset dataset) { + if (dataset == null) { + return null; + } + if (this.renderAsPercentages) { + return new Range(0.0, 1.0); + } + else { + return DatasetUtilities.findStackedRangeBounds(dataset, getBase()); + } + } + + /** + * Calculates the bar width and stores it in the renderer state. + * + * @param plot the plot. + * @param dataArea the data area. + * @param rendererIndex the renderer index. + * @param state the renderer state. + */ + @Override + protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, + int rendererIndex, CategoryItemRendererState state) { + + // calculate the bar width + CategoryAxis xAxis = plot.getDomainAxisForDataset(rendererIndex); + CategoryDataset data = plot.getDataset(rendererIndex); + if (data != null) { + PlotOrientation orientation = plot.getOrientation(); + double space = 0.0; + if (orientation == PlotOrientation.HORIZONTAL) { + space = dataArea.getHeight(); + } + else if (orientation == PlotOrientation.VERTICAL) { + space = dataArea.getWidth(); + } + double maxWidth = space * getMaximumBarWidth(); + int columns = data.getColumnCount(); + double categoryMargin = 0.0; + if (columns > 1) { + categoryMargin = xAxis.getCategoryMargin(); + } + + double used = space * (1 - xAxis.getLowerMargin() + - xAxis.getUpperMargin() + - categoryMargin); + if (columns > 0) { + state.setBarWidth(Math.min(used / columns, maxWidth)); + } + else { + state.setBarWidth(Math.min(used, maxWidth)); + } + } + + } + + /** + * Draws a stacked bar for a specific item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the plot area. + * @param plot the plot. + * @param domainAxis the domain (category) axis. + * @param rangeAxis the range (value) axis. + * @param dataset the data. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, + int column, int pass) { + + if (!isSeriesVisible(row)) { + return; + } + + // nothing is drawn for null values... + Number dataValue = dataset.getValue(row, column); + if (dataValue == null) { + return; + } + + double value = dataValue.doubleValue(); + double total = 0.0; // only needed if calculating percentages + if (this.renderAsPercentages) { + total = DataUtilities.calculateColumnTotal(dataset, column, + state.getVisibleSeriesArray()); + value = value / total; + } + + PlotOrientation orientation = plot.getOrientation(); + double barW0 = domainAxis.getCategoryMiddle(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()) + - state.getBarWidth() / 2.0; + + double positiveBase = getBase(); + double negativeBase = positiveBase; + + for (int i = 0; i < row; i++) { + Number v = dataset.getValue(i, column); + if (v != null && isSeriesVisible(i)) { + double d = v.doubleValue(); + if (this.renderAsPercentages) { + d = d / total; + } + if (d > 0) { + positiveBase = positiveBase + d; + } + else { + negativeBase = negativeBase + d; + } + } + } + + double translatedBase; + double translatedValue; + boolean positive = (value > 0.0); + boolean inverted = rangeAxis.isInverted(); + RectangleEdge barBase; + if (orientation == PlotOrientation.HORIZONTAL) { + if (positive && inverted || !positive && !inverted) { + barBase = RectangleEdge.RIGHT; + } + else { + barBase = RectangleEdge.LEFT; + } + } + else { + if (positive && !inverted || !positive && inverted) { + barBase = RectangleEdge.BOTTOM; + } + else { + barBase = RectangleEdge.TOP; + } + } + + RectangleEdge location = plot.getRangeAxisEdge(); + if (positive) { + translatedBase = rangeAxis.valueToJava2D(positiveBase, dataArea, + location); + translatedValue = rangeAxis.valueToJava2D(positiveBase + value, + dataArea, location); + } + else { + translatedBase = rangeAxis.valueToJava2D(negativeBase, dataArea, + location); + translatedValue = rangeAxis.valueToJava2D(negativeBase + value, + dataArea, location); + } + double barL0 = Math.min(translatedBase, translatedValue); + double barLength = Math.max(Math.abs(translatedValue - translatedBase), + getMinimumBarLength()); + + Rectangle2D bar; + if (orientation == PlotOrientation.HORIZONTAL) { + bar = new Rectangle2D.Double(barL0, barW0, barLength, + state.getBarWidth()); + } + else { + bar = new Rectangle2D.Double(barW0, barL0, state.getBarWidth(), + barLength); + } + if (pass == 0) { + if (getShadowsVisible()) { + boolean pegToBase = (positive && (positiveBase == getBase())) + || (!positive && (negativeBase == getBase())); + getBarPainter().paintBarShadow(g2, this, row, column, bar, + barBase, pegToBase); + } + } + else if (pass == 1) { + getBarPainter().paintBar(g2, this, row, column, bar, barBase); + + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, bar); + } + } + else if (pass == 2) { + CategoryItemLabelGenerator generator = getItemLabelGenerator(row, + column); + if (generator != null && isItemLabelVisible(row, column)) { + drawItemLabel(g2, dataset, row, column, plot, generator, bar, + (value < 0.0)); + } + } + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StackedBarRenderer)) { + return false; + } + StackedBarRenderer that = (StackedBarRenderer) obj; + if (this.renderAsPercentages != that.renderAsPercentages) { + return false; + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java new file mode 100755 index 0000000..e2e32a2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StackedBarRenderer3D.java @@ -0,0 +1,882 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * StackedBarRenderer3D.java + * ------------------------- + * (C) Copyright 2000-2013, by Serge V. Grachov and Contributors. + * + * Original Author: Serge V. Grachov; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Richard Atkinson; + * Christian W. Zuckschwerdt; + * Max Herfort (patch 1459313); + * DaveLaw (dave ATT davelaw DOTT de) (patch 3204823); + * + * Changes + * ------- + * 31-Oct-2001 : Version 1, contributed by Serge V. Grachov (DG); + * 15-Nov-2001 : Modified to allow for null data values (DG); + * 13-Dec-2001 : Added tooltips (DG); + * 15-Feb-2002 : Added isStacked() method (DG); + * 24-May-2002 : Incorporated tooltips into chart entities (DG); + * 19-Jun-2002 : Added check for null info in drawCategoryItem method (DG); + * 25-Jun-2002 : Removed redundant imports (DG); + * 26-Jun-2002 : Small change to entity (DG); + * 05-Aug-2002 : Small modification to drawCategoryItem method to support URLs + * for HTML image maps (RA); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and + * CategoryToolTipGenerator interface (DG); + * 05-Nov-2002 : Replaced references to CategoryDataset with TableDataset (DG); + * 26-Nov-2002 : Replaced isStacked() method with getRangeType() method (DG); + * 17-Jan-2003 : Moved plot classes to a separate package (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Added default constructor (bug 726235) and fixed bug + * 726260) (DG); + * 13-May-2003 : Renamed StackedVerticalBarRenderer3D + * --> StackedBarRenderer3D (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 07-Oct-2003 : Added renderer state (DG); + * 21-Nov-2003 : Added a new constructor (DG); + * 27-Nov-2003 : Modified code to respect maxBarWidth setting (DG); + * 11-Aug-2004 : Fixed bug where isDrawBarOutline() was ignored (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds (DG); + * 18-Mar-2005 : Override for getPassCount() method (DG); + * 20-Apr-2005 : Renamed CategoryLabelGenerator + * --> CategoryItemLabelGenerator (DG); + * 09-Jun-2005 : Use addItemEntity() method from superclass (DG); + * 22-Sep-2005 : Renamed getMaxBarWidth() --> getMaximumBarWidth() (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 31-Mar-2006 : Added renderAsPercentages option - see patch 1459313 submitted + * by Max Herfort (DG); + * 16-Jan-2007 : Replaced rendering code to draw whole stack at once (DG); + * 18-Jan-2007 : Fixed bug handling null values in createStackedValueList() + * method (DG); + * 18-Jan-2007 : Updated block drawing code to take account of inverted axes, + * see bug report 1599652 (DG); + * 08-May-2007 : Fixed bugs 1713401 (drawBarOutlines flag) and 1713474 + * (shading) (DG); + * 15-Aug-2008 : Fixed bug 2031407 - no negative zero for stack encoding (DG); + * 03-Feb-2009 : Fixed regression in findRangeBounds() method for null + * dataset (DG); + * 04-Feb-2009 : Handle seriesVisible flag (DG); + * 07-Jul-2009 : Added flag for handling zero values (DG); + * 11-Jun-2012 : Use new PaintAlpha class (patch 3204823 from DaveLaw) (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.geom.GeneralPath; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.CategoryItemLabelGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.util.PaintAlpha; +import org.jfree.data.DataUtilities; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.util.BooleanUtilities; +import org.jfree.util.PublicCloneable; + +/** + * Renders stacked bars with 3D-effect, for use with the {@link CategoryPlot} + * class. The example shown here is generated by the + * StackedBarChart3DDemo1.java program included in the + * JFreeChart Demo Collection: + *

+ * StackedBarRenderer3DSample.png + */ +public class StackedBarRenderer3D extends BarRenderer3D + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -5832945916493247123L; + + /** A flag that controls whether the bars display values or percentages. */ + private boolean renderAsPercentages; + + /** + * A flag that controls whether or not zero values are drawn by the + * renderer. + * + * @since 1.0.14 + */ + private boolean ignoreZeroValues; + + /** + * Creates a new renderer with no tool tip generator and no URL generator. + *

+ * The defaults (no tool tip or URL generators) have been chosen to + * minimise the processing required to generate a default chart. If you + * require tool tips or URLs, then you can easily add the required + * generators. + */ + public StackedBarRenderer3D() { + this(false); + } + + /** + * Constructs a new renderer with the specified '3D effect'. + * + * @param xOffset the x-offset for the 3D effect. + * @param yOffset the y-offset for the 3D effect. + */ + public StackedBarRenderer3D(double xOffset, double yOffset) { + super(xOffset, yOffset); + } + + /** + * Creates a new renderer. + * + * @param renderAsPercentages a flag that controls whether the data values + * are rendered as percentages. + * + * @since 1.0.2 + */ + public StackedBarRenderer3D(boolean renderAsPercentages) { + super(); + this.renderAsPercentages = renderAsPercentages; + } + + /** + * Constructs a new renderer with the specified '3D effect'. + * + * @param xOffset the x-offset for the 3D effect. + * @param yOffset the y-offset for the 3D effect. + * @param renderAsPercentages a flag that controls whether the data values + * are rendered as percentages. + * + * @since 1.0.2 + */ + public StackedBarRenderer3D(double xOffset, double yOffset, + boolean renderAsPercentages) { + super(xOffset, yOffset); + this.renderAsPercentages = renderAsPercentages; + } + + /** + * Returns true if the renderer displays each item value as + * a percentage (so that the stacked bars add to 100%), and + * false otherwise. + * + * @return A boolean. + * + * @since 1.0.2 + */ + public boolean getRenderAsPercentages() { + return this.renderAsPercentages; + } + + /** + * Sets the flag that controls whether the renderer displays each item + * value as a percentage (so that the stacked bars add to 100%), and sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param asPercentages the flag. + * + * @since 1.0.2 + */ + public void setRenderAsPercentages(boolean asPercentages) { + this.renderAsPercentages = asPercentages; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not zero values are drawn + * by the renderer. + * + * @return A boolean. + * + * @since 1.0.14 + */ + public boolean getIgnoreZeroValues() { + return this.ignoreZeroValues; + } + + /** + * Sets a flag that controls whether or not zero values are drawn by the + * renderer, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param ignore the new flag value. + * + * @since 1.0.14 + */ + public void setIgnoreZeroValues(boolean ignore) { + this.ignoreZeroValues = ignore; + notifyListeners(new RendererChangeEvent(this)); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null not permitted). + * + * @return The range (or null if the dataset is empty). + */ + @Override + public Range findRangeBounds(CategoryDataset dataset) { + if (dataset == null) { + return null; + } + if (this.renderAsPercentages) { + return new Range(0.0, 1.0); + } + return DatasetUtilities.findStackedRangeBounds(dataset); + } + + /** + * Calculates the bar width and stores it in the renderer state. + * + * @param plot the plot. + * @param dataArea the data area. + * @param rendererIndex the renderer index. + * @param state the renderer state. + */ + @Override + protected void calculateBarWidth(CategoryPlot plot, Rectangle2D dataArea, + int rendererIndex, CategoryItemRendererState state) { + + // calculate the bar width + CategoryAxis domainAxis = getDomainAxis(plot, rendererIndex); + CategoryDataset data = plot.getDataset(rendererIndex); + if (data != null) { + PlotOrientation orientation = plot.getOrientation(); + double space = 0.0; + if (orientation == PlotOrientation.HORIZONTAL) { + space = dataArea.getHeight(); + } + else if (orientation == PlotOrientation.VERTICAL) { + space = dataArea.getWidth(); + } + double maxWidth = space * getMaximumBarWidth(); + int columns = data.getColumnCount(); + double categoryMargin = 0.0; + if (columns > 1) { + categoryMargin = domainAxis.getCategoryMargin(); + } + + double used = space * (1 - domainAxis.getLowerMargin() + - domainAxis.getUpperMargin() + - categoryMargin); + if (columns > 0) { + state.setBarWidth(Math.min(used / columns, maxWidth)); + } + else { + state.setBarWidth(Math.min(used, maxWidth)); + } + } + + } + + /** + * Returns a list containing the stacked values for the specified series + * in the given dataset, plus the supplied base value. + * + * @param dataset the dataset (null not permitted). + * @param category the category key (null not permitted). + * @param base the base value. + * @param asPercentages a flag that controls whether the values in the + * list are converted to percentages of the total. + * + * @return The value list. + * + * @since 1.0.4 + * + * @deprecated As of 1.0.13, use {@link #createStackedValueList( + * CategoryDataset, Comparable, int[], double, boolean)}. + */ + protected List createStackedValueList(CategoryDataset dataset, + Comparable category, double base, boolean asPercentages) { + int[] rows = new int[dataset.getRowCount()]; + for (int i = 0; i < rows.length; i++) { + rows[i] = i; + } + return createStackedValueList(dataset, category, rows, base, + asPercentages); + } + + /** + * Returns a list containing the stacked values for the specified series + * in the given dataset, plus the supplied base value. + * + * @param dataset the dataset (null not permitted). + * @param category the category key (null not permitted). + * @param includedRows the included rows. + * @param base the base value. + * @param asPercentages a flag that controls whether the values in the + * list are converted to percentages of the total. + * + * @return The value list. + * + * @since 1.0.13 + */ + protected List createStackedValueList(CategoryDataset dataset, + Comparable category, int[] includedRows, double base, + boolean asPercentages) { + + List result = new ArrayList(); + double posBase = base; + double negBase = base; + double total = 0.0; + if (asPercentages) { + total = DataUtilities.calculateColumnTotal(dataset, + dataset.getColumnIndex(category), includedRows); + } + + int baseIndex = -1; + int rowCount = includedRows.length; + for (int i = 0; i < rowCount; i++) { + int r = includedRows[i]; + Number n = dataset.getValue(dataset.getRowKey(r), category); + if (n == null) { + continue; + } + double v = n.doubleValue(); + if (asPercentages) { + v = v / total; + } + if ((v > 0.0) || (!this.ignoreZeroValues && v >= 0.0)) { + if (baseIndex < 0) { + result.add(new Object[] {null, new Double(base)}); + baseIndex = 0; + } + posBase = posBase + v; + result.add(new Object[] {new Integer(r), new Double(posBase)}); + } + else if (v < 0.0) { + if (baseIndex < 0) { + result.add(new Object[] {null, new Double(base)}); + baseIndex = 0; + } + negBase = negBase + v; // '+' because v is negative + result.add(0, new Object[] {new Integer(-r - 1), + new Double(negBase)}); + baseIndex++; + } + } + return result; + + } + + /** + * Draws the visual representation of one data item from the chart (in + * fact, this method does nothing until it reaches the last item for each + * category, at which point it draws all the items for that category). + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the plot area. + * @param plot the plot. + * @param domainAxis the domain (category) axis. + * @param rangeAxis the range (value) axis. + * @param dataset the data. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, + int pass) { + + // wait till we are at the last item for the row then draw the + // whole stack at once + if (row < dataset.getRowCount() - 1) { + return; + } + Comparable category = dataset.getColumnKey(column); + + List values = createStackedValueList(dataset, + dataset.getColumnKey(column), state.getVisibleSeriesArray(), + getBase(), this.renderAsPercentages); + + Rectangle2D adjusted = new Rectangle2D.Double(dataArea.getX(), + dataArea.getY() + getYOffset(), + dataArea.getWidth() - getXOffset(), + dataArea.getHeight() - getYOffset()); + + + PlotOrientation orientation = plot.getOrientation(); + + // handle rendering separately for the two plot orientations... + if (orientation == PlotOrientation.HORIZONTAL) { + drawStackHorizontal(values, category, g2, state, adjusted, plot, + domainAxis, rangeAxis, dataset); + } + else { + drawStackVertical(values, category, g2, state, adjusted, plot, + domainAxis, rangeAxis, dataset); + } + + } + + /** + * Draws a stack of bars for one category, with a horizontal orientation. + * + * @param values the value list. + * @param category the category. + * @param g2 the graphics device. + * @param state the state. + * @param dataArea the data area (adjusted for the 3D effect). + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * + * @since 1.0.4 + */ + protected void drawStackHorizontal(List values, Comparable category, + Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, + CategoryAxis domainAxis, ValueAxis rangeAxis, + CategoryDataset dataset) { + + int column = dataset.getColumnIndex(category); + double barX0 = domainAxis.getCategoryMiddle(column, + dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge()) + - state.getBarWidth() / 2.0; + double barW = state.getBarWidth(); + + // a list to store the series index and bar region, so we can draw + // all the labels at the end... + List itemLabelList = new ArrayList(); + + // draw the blocks + boolean inverted = rangeAxis.isInverted(); + int blockCount = values.size() - 1; + for (int k = 0; k < blockCount; k++) { + int index = (inverted ? blockCount - k - 1 : k); + Object[] prev = (Object[]) values.get(index); + Object[] curr = (Object[]) values.get(index + 1); + int series; + if (curr[0] == null) { + series = -((Integer) prev[0]).intValue() - 1; + } + else { + series = ((Integer) curr[0]).intValue(); + if (series < 0) { + series = -((Integer) prev[0]).intValue() - 1; + } + } + double v0 = ((Double) prev[1]).doubleValue(); + double vv0 = rangeAxis.valueToJava2D(v0, dataArea, + plot.getRangeAxisEdge()); + + double v1 = ((Double) curr[1]).doubleValue(); + double vv1 = rangeAxis.valueToJava2D(v1, dataArea, + plot.getRangeAxisEdge()); + + Shape[] faces = createHorizontalBlock(barX0, barW, vv0, vv1, + inverted); + Paint fillPaint = getItemPaint(series, column); + Paint fillPaintDark = PaintAlpha.darker(fillPaint); + boolean drawOutlines = isDrawBarOutline(); + Paint outlinePaint = fillPaint; + if (drawOutlines) { + outlinePaint = getItemOutlinePaint(series, column); + g2.setStroke(getItemOutlineStroke(series, column)); + } + for (int f = 0; f < 6; f++) { + if (f == 5) { + g2.setPaint(fillPaint); + } + else { + g2.setPaint(fillPaintDark); + } + g2.fill(faces[f]); + if (drawOutlines) { + g2.setPaint(outlinePaint); + g2.draw(faces[f]); + } + } + + itemLabelList.add(new Object[] {new Integer(series), + faces[5].getBounds2D(), + BooleanUtilities.valueOf(v0 < getBase())}); + + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, series, column, faces[5]); + } + + } + + for (int i = 0; i < itemLabelList.size(); i++) { + Object[] record = (Object[]) itemLabelList.get(i); + int series = ((Integer) record[0]).intValue(); + Rectangle2D bar = (Rectangle2D) record[1]; + boolean neg = ((Boolean) record[2]).booleanValue(); + CategoryItemLabelGenerator generator + = getItemLabelGenerator(series, column); + if (generator != null && isItemLabelVisible(series, column)) { + drawItemLabel(g2, dataset, series, column, plot, generator, + bar, neg); + } + + } + } + + /** + * Creates an array of shapes representing the six sides of a block in a + * horizontal stack. + * + * @param x0 left edge of bar (in Java2D space). + * @param width the width of the bar (in Java2D units). + * @param y0 the base of the block (in Java2D space). + * @param y1 the top of the block (in Java2D space). + * @param inverted a flag indicating whether or not the block is inverted + * (this changes the order of the faces of the block). + * + * @return The sides of the block. + */ + private Shape[] createHorizontalBlock(double x0, double width, double y0, + double y1, boolean inverted) { + Shape[] result = new Shape[6]; + Point2D p00 = new Point2D.Double(y0, x0); + Point2D p01 = new Point2D.Double(y0, x0 + width); + Point2D p02 = new Point2D.Double(p01.getX() + getXOffset(), + p01.getY() - getYOffset()); + Point2D p03 = new Point2D.Double(p00.getX() + getXOffset(), + p00.getY() - getYOffset()); + + Point2D p0 = new Point2D.Double(y1, x0); + Point2D p1 = new Point2D.Double(y1, x0 + width); + Point2D p2 = new Point2D.Double(p1.getX() + getXOffset(), + p1.getY() - getYOffset()); + Point2D p3 = new Point2D.Double(p0.getX() + getXOffset(), + p0.getY() - getYOffset()); + + GeneralPath bottom = new GeneralPath(); + bottom.moveTo((float) p1.getX(), (float) p1.getY()); + bottom.lineTo((float) p01.getX(), (float) p01.getY()); + bottom.lineTo((float) p02.getX(), (float) p02.getY()); + bottom.lineTo((float) p2.getX(), (float) p2.getY()); + bottom.closePath(); + + GeneralPath top = new GeneralPath(); + top.moveTo((float) p0.getX(), (float) p0.getY()); + top.lineTo((float) p00.getX(), (float) p00.getY()); + top.lineTo((float) p03.getX(), (float) p03.getY()); + top.lineTo((float) p3.getX(), (float) p3.getY()); + top.closePath(); + + GeneralPath back = new GeneralPath(); + back.moveTo((float) p2.getX(), (float) p2.getY()); + back.lineTo((float) p02.getX(), (float) p02.getY()); + back.lineTo((float) p03.getX(), (float) p03.getY()); + back.lineTo((float) p3.getX(), (float) p3.getY()); + back.closePath(); + + GeneralPath front = new GeneralPath(); + front.moveTo((float) p0.getX(), (float) p0.getY()); + front.lineTo((float) p1.getX(), (float) p1.getY()); + front.lineTo((float) p01.getX(), (float) p01.getY()); + front.lineTo((float) p00.getX(), (float) p00.getY()); + front.closePath(); + + GeneralPath left = new GeneralPath(); + left.moveTo((float) p0.getX(), (float) p0.getY()); + left.lineTo((float) p1.getX(), (float) p1.getY()); + left.lineTo((float) p2.getX(), (float) p2.getY()); + left.lineTo((float) p3.getX(), (float) p3.getY()); + left.closePath(); + + GeneralPath right = new GeneralPath(); + right.moveTo((float) p00.getX(), (float) p00.getY()); + right.lineTo((float) p01.getX(), (float) p01.getY()); + right.lineTo((float) p02.getX(), (float) p02.getY()); + right.lineTo((float) p03.getX(), (float) p03.getY()); + right.closePath(); + result[0] = bottom; + result[1] = back; + if (inverted) { + result[2] = right; + result[3] = left; + } + else { + result[2] = left; + result[3] = right; + } + result[4] = top; + result[5] = front; + return result; + } + + /** + * Draws a stack of bars for one category, with a vertical orientation. + * + * @param values the value list. + * @param category the category. + * @param g2 the graphics device. + * @param state the state. + * @param dataArea the data area (adjusted for the 3D effect). + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * + * @since 1.0.4 + */ + protected void drawStackVertical(List values, Comparable category, + Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, + CategoryAxis domainAxis, ValueAxis rangeAxis, + CategoryDataset dataset) { + + int column = dataset.getColumnIndex(category); + double barX0 = domainAxis.getCategoryMiddle(column, + dataset.getColumnCount(), dataArea, plot.getDomainAxisEdge()) + - state.getBarWidth() / 2.0; + double barW = state.getBarWidth(); + + // a list to store the series index and bar region, so we can draw + // all the labels at the end... + List itemLabelList = new ArrayList(); + + // draw the blocks + boolean inverted = rangeAxis.isInverted(); + int blockCount = values.size() - 1; + for (int k = 0; k < blockCount; k++) { + int index = (inverted ? blockCount - k - 1 : k); + Object[] prev = (Object[]) values.get(index); + Object[] curr = (Object[]) values.get(index + 1); + int series; + if (curr[0] == null) { + series = -((Integer) prev[0]).intValue() - 1; + } + else { + series = ((Integer) curr[0]).intValue(); + if (series < 0) { + series = -((Integer) prev[0]).intValue() - 1; + } + } + double v0 = ((Double) prev[1]).doubleValue(); + double vv0 = rangeAxis.valueToJava2D(v0, dataArea, + plot.getRangeAxisEdge()); + + double v1 = ((Double) curr[1]).doubleValue(); + double vv1 = rangeAxis.valueToJava2D(v1, dataArea, + plot.getRangeAxisEdge()); + + Shape[] faces = createVerticalBlock(barX0, barW, vv0, vv1, + inverted); + Paint fillPaint = getItemPaint(series, column); + Paint fillPaintDark = PaintAlpha.darker(fillPaint); + boolean drawOutlines = isDrawBarOutline(); + Paint outlinePaint = fillPaint; + if (drawOutlines) { + outlinePaint = getItemOutlinePaint(series, column); + g2.setStroke(getItemOutlineStroke(series, column)); + } + + for (int f = 0; f < 6; f++) { + if (f == 5) { + g2.setPaint(fillPaint); + } + else { + g2.setPaint(fillPaintDark); + } + g2.fill(faces[f]); + if (drawOutlines) { + g2.setPaint(outlinePaint); + g2.draw(faces[f]); + } + } + + itemLabelList.add(new Object[] {new Integer(series), + faces[5].getBounds2D(), + BooleanUtilities.valueOf(v0 < getBase())}); + + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, series, column, faces[5]); + } + + } + + for (int i = 0; i < itemLabelList.size(); i++) { + Object[] record = (Object[]) itemLabelList.get(i); + int series = ((Integer) record[0]).intValue(); + Rectangle2D bar = (Rectangle2D) record[1]; + boolean neg = ((Boolean) record[2]).booleanValue(); + CategoryItemLabelGenerator generator + = getItemLabelGenerator(series, column); + if (generator != null && isItemLabelVisible(series, column)) { + drawItemLabel(g2, dataset, series, column, plot, generator, + bar, neg); + } + + } + } + + /** + * Creates an array of shapes representing the six sides of a block in a + * vertical stack. + * + * @param x0 left edge of bar (in Java2D space). + * @param width the width of the bar (in Java2D units). + * @param y0 the base of the block (in Java2D space). + * @param y1 the top of the block (in Java2D space). + * @param inverted a flag indicating whether or not the block is inverted + * (this changes the order of the faces of the block). + * + * @return The sides of the block. + */ + private Shape[] createVerticalBlock(double x0, double width, double y0, + double y1, boolean inverted) { + Shape[] result = new Shape[6]; + Point2D p00 = new Point2D.Double(x0, y0); + Point2D p01 = new Point2D.Double(x0 + width, y0); + Point2D p02 = new Point2D.Double(p01.getX() + getXOffset(), + p01.getY() - getYOffset()); + Point2D p03 = new Point2D.Double(p00.getX() + getXOffset(), + p00.getY() - getYOffset()); + + + Point2D p0 = new Point2D.Double(x0, y1); + Point2D p1 = new Point2D.Double(x0 + width, y1); + Point2D p2 = new Point2D.Double(p1.getX() + getXOffset(), + p1.getY() - getYOffset()); + Point2D p3 = new Point2D.Double(p0.getX() + getXOffset(), + p0.getY() - getYOffset()); + + GeneralPath right = new GeneralPath(); + right.moveTo((float) p1.getX(), (float) p1.getY()); + right.lineTo((float) p01.getX(), (float) p01.getY()); + right.lineTo((float) p02.getX(), (float) p02.getY()); + right.lineTo((float) p2.getX(), (float) p2.getY()); + right.closePath(); + + GeneralPath left = new GeneralPath(); + left.moveTo((float) p0.getX(), (float) p0.getY()); + left.lineTo((float) p00.getX(), (float) p00.getY()); + left.lineTo((float) p03.getX(), (float) p03.getY()); + left.lineTo((float) p3.getX(), (float) p3.getY()); + left.closePath(); + + GeneralPath back = new GeneralPath(); + back.moveTo((float) p2.getX(), (float) p2.getY()); + back.lineTo((float) p02.getX(), (float) p02.getY()); + back.lineTo((float) p03.getX(), (float) p03.getY()); + back.lineTo((float) p3.getX(), (float) p3.getY()); + back.closePath(); + + GeneralPath front = new GeneralPath(); + front.moveTo((float) p0.getX(), (float) p0.getY()); + front.lineTo((float) p1.getX(), (float) p1.getY()); + front.lineTo((float) p01.getX(), (float) p01.getY()); + front.lineTo((float) p00.getX(), (float) p00.getY()); + front.closePath(); + + GeneralPath top = new GeneralPath(); + top.moveTo((float) p0.getX(), (float) p0.getY()); + top.lineTo((float) p1.getX(), (float) p1.getY()); + top.lineTo((float) p2.getX(), (float) p2.getY()); + top.lineTo((float) p3.getX(), (float) p3.getY()); + top.closePath(); + + GeneralPath bottom = new GeneralPath(); + bottom.moveTo((float) p00.getX(), (float) p00.getY()); + bottom.lineTo((float) p01.getX(), (float) p01.getY()); + bottom.lineTo((float) p02.getX(), (float) p02.getY()); + bottom.lineTo((float) p03.getX(), (float) p03.getY()); + bottom.closePath(); + + result[0] = bottom; + result[1] = back; + result[2] = left; + result[3] = right; + result[4] = top; + result[5] = front; + if (inverted) { + result[0] = top; + result[4] = bottom; + } + return result; + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StackedBarRenderer3D)) { + return false; + } + StackedBarRenderer3D that = (StackedBarRenderer3D) obj; + if (this.renderAsPercentages != that.getRenderAsPercentages()) { + return false; + } + if (this.ignoreZeroValues != that.ignoreZeroValues) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = HashUtilities.hashCode(hash, this.renderAsPercentages); + hash = HashUtilities.hashCode(hash, this.ignoreZeroValues); + return hash; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StandardBarPainter.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StandardBarPainter.java new file mode 100755 index 0000000..548f518 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StandardBarPainter.java @@ -0,0 +1,226 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * StandardBarPainter.java + * ----------------------- + * (C) Copyright 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 19-Jun-2008 : Version 1 (DG); + * 15-Aug-2008 : Use renderer's shadow paint (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Stroke; +import java.awt.geom.Rectangle2D; +import java.awt.geom.RectangularShape; +import java.io.Serializable; + +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.RectangleEdge; + +/** + * An implementation of the {@link BarPainter} interface that preserves the + * behaviour of bar painting that existed prior to the introduction of the + * {@link BarPainter} interface. + * + * @see GradientBarPainter + * + * @since 1.0.11 + */ +public class StandardBarPainter implements BarPainter, Serializable { + + /** + * Creates a new instance. + */ + public StandardBarPainter() { + } + + /** + * Paints a single bar instance. + * + * @param g2 the graphics target. + * @param renderer the renderer. + * @param row the row index. + * @param column the column index. + * @param bar the bar + * @param base indicates which side of the rectangle is the base of the + * bar. + */ + @Override + public void paintBar(Graphics2D g2, BarRenderer renderer, int row, + int column, RectangularShape bar, RectangleEdge base) { + + Paint itemPaint = renderer.getItemPaint(row, column); + GradientPaintTransformer t = renderer.getGradientPaintTransformer(); + if (t != null && itemPaint instanceof GradientPaint) { + itemPaint = t.transform((GradientPaint) itemPaint, bar); + } + g2.setPaint(itemPaint); + g2.fill(bar); + + // draw the outline... + if (renderer.isDrawBarOutline()) { + // && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { + Stroke stroke = renderer.getItemOutlineStroke(row, column); + Paint paint = renderer.getItemOutlinePaint(row, column); + if (stroke != null && paint != null) { + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(bar); + } + } + + } + + /** + * Paints a single bar instance. + * + * @param g2 the graphics target. + * @param renderer the renderer. + * @param row the row index. + * @param column the column index. + * @param bar the bar + * @param base indicates which side of the rectangle is the base of the + * bar. + * @param pegShadow peg the shadow to the base of the bar? + */ + @Override + public void paintBarShadow(Graphics2D g2, BarRenderer renderer, int row, + int column, RectangularShape bar, RectangleEdge base, + boolean pegShadow) { + + // handle a special case - if the bar colour has alpha == 0, it is + // invisible so we shouldn't draw any shadow + Paint itemPaint = renderer.getItemPaint(row, column); + if (itemPaint instanceof Color) { + Color c = (Color) itemPaint; + if (c.getAlpha() == 0) { + return; + } + } + + RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(), + renderer.getShadowYOffset(), base, pegShadow); + g2.setPaint(renderer.getShadowPaint()); + g2.fill(shadow); + + } + + /** + * Creates a shadow for the bar. + * + * @param bar the bar shape. + * @param xOffset the x-offset for the shadow. + * @param yOffset the y-offset for the shadow. + * @param base the edge that is the base of the bar. + * @param pegShadow peg the shadow to the base? + * + * @return A rectangle for the shadow. + */ + private Rectangle2D createShadow(RectangularShape bar, double xOffset, + double yOffset, RectangleEdge base, boolean pegShadow) { + double x0 = bar.getMinX(); + double x1 = bar.getMaxX(); + double y0 = bar.getMinY(); + double y1 = bar.getMaxY(); + if (base == RectangleEdge.TOP) { + x0 += xOffset; + x1 += xOffset; + if (!pegShadow) { + y0 += yOffset; + } + y1 += yOffset; + } + else if (base == RectangleEdge.BOTTOM) { + x0 += xOffset; + x1 += xOffset; + y0 += yOffset; + if (!pegShadow) { + y1 += yOffset; + } + } + else if (base == RectangleEdge.LEFT) { + if (!pegShadow) { + x0 += xOffset; + } + x1 += xOffset; + y0 += yOffset; + y1 += yOffset; + } + else if (base == RectangleEdge.RIGHT) { + x0 += xOffset; + if (!pegShadow) { + x1 += xOffset; + } + y0 += yOffset; + y1 += yOffset; + } + return new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the obj (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardBarPainter)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int hash = 37; + // no fields to compute... + return hash; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java new file mode 100755 index 0000000..f3f67d2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StatisticalBarRenderer.java @@ -0,0 +1,596 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * StatisticalBarRenderer.java + * --------------------------- + * (C) Copyright 2002-2011, by Pascal Collet and Contributors. + * + * Original Author: Pascal Collet; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Christian W. Zuckschwerdt; + * Peter Kolb (patches 2497611, 2791407); + * Martin Hoeller; + * + * Changes + * ------- + * 21-Aug-2002 : Version 1, contributed by Pascal Collet (DG); + * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 24-Oct-2002 : Changes to dataset interface (DG); + * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG); + * 05-Feb-2003 : Updates for new DefaultStatisticalCategoryDataset (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 06-Oct-2003 : Corrected typo in exception message (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 15-Jun-2005 : Added errorIndicatorPaint attribute (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 19-May-2006 : Added support for tooltips and URLs (DG); + * 12-Jul-2006 : Added support for item labels (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 28-Aug-2007 : Fixed NullPointerException - see bug 1779941 (DG); + * 14-Nov-2007 : Added errorIndicatorStroke, and fixed bugs with drawBarOutline + * and gradientPaintTransformer attributes being ignored (DG); + * 14-Jan-2009 : Added support for seriesVisible flags (PK); + * 16-May-2009 : Added findRangeBounds() override to take into account the + * dataset interval (PK); + * 28-Oct-2011 : Fixed problem with maximalBarWidth, bug #2810220 (MH); + * 30-Oct-2011 : Additional change for bug #2810220 (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; +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.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.CategoryItemLabelGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.statistics.StatisticalCategoryDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A renderer that handles the drawing a bar plot where + * each bar has a mean value and a standard deviation line. The example shown + * here is generated by the StatisticalBarChartDemo1.java program + * included in the JFreeChart Demo Collection: + *

+ * StatisticalBarRendererSample.png + */ +public class StatisticalBarRenderer extends BarRenderer + implements CategoryItemRenderer, Cloneable, PublicCloneable, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -4986038395414039117L; + + /** The paint used to show the error indicator. */ + private transient Paint errorIndicatorPaint; + + /** + * The stroke used to draw the error indicators. + * + * @since 1.0.8 + */ + private transient Stroke errorIndicatorStroke; + + /** + * Default constructor. + */ + public StatisticalBarRenderer() { + super(); + this.errorIndicatorPaint = Color.gray; + this.errorIndicatorStroke = new BasicStroke(1.0f); + } + + /** + * Returns the paint used for the error indicators. + * + * @return The paint used for the error indicators (possibly + * null). + * + * @see #setErrorIndicatorPaint(Paint) + */ + public Paint getErrorIndicatorPaint() { + return this.errorIndicatorPaint; + } + + /** + * Sets the paint used for the error indicators (if null, + * the item outline paint is used instead) and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @see #getErrorIndicatorPaint() + */ + public void setErrorIndicatorPaint(Paint paint) { + this.errorIndicatorPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the stroke used to draw the error indicators. If this is + * null, the renderer will use the item outline stroke). + * + * @return The stroke (possibly null). + * + * @see #setErrorIndicatorStroke(Stroke) + * + * @since 1.0.8 + */ + public Stroke getErrorIndicatorStroke() { + return this.errorIndicatorStroke; + } + + /** + * Sets the stroke used to draw the error indicators, and sends a + * {@link RendererChangeEvent} to all registered listeners. If you set + * this to null, the renderer will use the item outline + * stroke. + * + * @param stroke the stroke (null permitted). + * + * @see #getErrorIndicatorStroke() + * + * @since 1.0.8 + */ + public void setErrorIndicatorStroke(Stroke stroke) { + this.errorIndicatorStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. This takes into account the range + * between the min/max values, possibly ignoring invisible series. + * + * @param dataset the dataset (null permitted). + * + * @return The range (or null if the dataset is + * null or empty). + */ + @Override + public Range findRangeBounds(CategoryDataset dataset) { + return findRangeBounds(dataset, true); + } + + /** + * Draws the bar with its standard deviation line range for a single + * (series, category) data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param data the data. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset data, int row, int column, + int pass) { + + int visibleRow = state.getVisibleSeriesIndex(row); + if (visibleRow < 0) { + return; + } + // defensive check + if (!(data instanceof StatisticalCategoryDataset)) { + throw new IllegalArgumentException( + "Requires StatisticalCategoryDataset."); + } + StatisticalCategoryDataset statData = (StatisticalCategoryDataset) data; + + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + drawHorizontalItem(g2, state, dataArea, plot, domainAxis, + rangeAxis, statData, visibleRow, row, column); + } + else if (orientation == PlotOrientation.VERTICAL) { + drawVerticalItem(g2, state, dataArea, plot, domainAxis, rangeAxis, + statData, visibleRow, row, column); + } + } + + /** + * Draws an item for a plot with a horizontal orientation. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the data. + * @param visibleRow the visible row index. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + */ + protected void drawHorizontalItem(Graphics2D g2, + CategoryItemRendererState state, + Rectangle2D dataArea, + CategoryPlot plot, + CategoryAxis domainAxis, + ValueAxis rangeAxis, + StatisticalCategoryDataset dataset, + int visibleRow, + int row, + int column) { + + // BAR Y + double rectY = calculateBarW0(plot, PlotOrientation.HORIZONTAL, + dataArea, domainAxis, state, visibleRow, column); + + // BAR X + Number meanValue = dataset.getMeanValue(row, column); + if (meanValue == null) { + return; + } + double value = meanValue.doubleValue(); + double base = 0.0; + double lclip = getLowerClip(); + double uclip = getUpperClip(); + + if (uclip <= 0.0) { // cases 1, 2, 3 and 4 + if (value >= uclip) { + return; // bar is not visible + } + base = uclip; + if (value <= lclip) { + value = lclip; + } + } + else if (lclip <= 0.0) { // cases 5, 6, 7 and 8 + if (value >= uclip) { + value = uclip; + } + else { + if (value <= lclip) { + value = lclip; + } + } + } + else { // cases 9, 10, 11 and 12 + if (value <= lclip) { + return; // bar is not visible + } + base = getLowerClip(); + if (value >= uclip) { + value = uclip; + } + } + + RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); + double transY1 = rangeAxis.valueToJava2D(base, dataArea, yAxisLocation); + double transY2 = rangeAxis.valueToJava2D(value, dataArea, + yAxisLocation); + double rectX = Math.min(transY2, transY1); + + double rectHeight = state.getBarWidth(); + double rectWidth = Math.abs(transY2 - transY1); + + Rectangle2D bar = new Rectangle2D.Double(rectX, rectY, rectWidth, + rectHeight); + Paint itemPaint = getItemPaint(row, column); + GradientPaintTransformer t = getGradientPaintTransformer(); + if (t != null && itemPaint instanceof GradientPaint) { + itemPaint = t.transform((GradientPaint) itemPaint, bar); + } + g2.setPaint(itemPaint); + g2.fill(bar); + + // draw the outline... + if (isDrawBarOutline() + && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { + Stroke stroke = getItemOutlineStroke(row, column); + Paint paint = getItemOutlinePaint(row, column); + if (stroke != null && paint != null) { + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(bar); + } + } + + // standard deviation lines + Number n = dataset.getStdDevValue(row, column); + if (n != null) { + double valueDelta = n.doubleValue(); + double highVal = rangeAxis.valueToJava2D(meanValue.doubleValue() + + valueDelta, dataArea, yAxisLocation); + double lowVal = rangeAxis.valueToJava2D(meanValue.doubleValue() + - valueDelta, dataArea, yAxisLocation); + + if (this.errorIndicatorPaint != null) { + g2.setPaint(this.errorIndicatorPaint); + } + else { + g2.setPaint(getItemOutlinePaint(row, column)); + } + if (this.errorIndicatorStroke != null) { + g2.setStroke(this.errorIndicatorStroke); + } + else { + g2.setStroke(getItemOutlineStroke(row, column)); + } + Line2D line; + line = new Line2D.Double(lowVal, rectY + rectHeight / 2.0d, + highVal, rectY + rectHeight / 2.0d); + g2.draw(line); + line = new Line2D.Double(highVal, rectY + rectHeight * 0.25, + highVal, rectY + rectHeight * 0.75); + g2.draw(line); + line = new Line2D.Double(lowVal, rectY + rectHeight * 0.25, + lowVal, rectY + rectHeight * 0.75); + g2.draw(line); + } + + CategoryItemLabelGenerator generator = getItemLabelGenerator(row, + column); + if (generator != null && isItemLabelVisible(row, column)) { + drawItemLabel(g2, dataset, row, column, plot, generator, bar, + (value < 0.0)); + } + + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, bar); + } + + } + + /** + * Draws an item for a plot with a vertical orientation. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the data. + * @param visibleRow the visible row index. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + */ + protected void drawVerticalItem(Graphics2D g2, + CategoryItemRendererState state, + Rectangle2D dataArea, + CategoryPlot plot, + CategoryAxis domainAxis, + ValueAxis rangeAxis, + StatisticalCategoryDataset dataset, + int visibleRow, + int row, + int column) { + + // BAR X + double rectX = calculateBarW0(plot, PlotOrientation.VERTICAL, dataArea, + domainAxis, state, visibleRow, column); + + // BAR Y + Number meanValue = dataset.getMeanValue(row, column); + if (meanValue == null) { + return; + } + + double value = meanValue.doubleValue(); + double base = 0.0; + double lclip = getLowerClip(); + double uclip = getUpperClip(); + + if (uclip <= 0.0) { // cases 1, 2, 3 and 4 + if (value >= uclip) { + return; // bar is not visible + } + base = uclip; + if (value <= lclip) { + value = lclip; + } + } + else if (lclip <= 0.0) { // cases 5, 6, 7 and 8 + if (value >= uclip) { + value = uclip; + } + else { + if (value <= lclip) { + value = lclip; + } + } + } + else { // cases 9, 10, 11 and 12 + if (value <= lclip) { + return; // bar is not visible + } + base = getLowerClip(); + if (value >= uclip) { + value = uclip; + } + } + + RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); + double transY1 = rangeAxis.valueToJava2D(base, dataArea, yAxisLocation); + double transY2 = rangeAxis.valueToJava2D(value, dataArea, + yAxisLocation); + double rectY = Math.min(transY2, transY1); + + double rectWidth = state.getBarWidth(); + double rectHeight = Math.abs(transY2 - transY1); + + Rectangle2D bar = new Rectangle2D.Double(rectX, rectY, rectWidth, + rectHeight); + Paint itemPaint = getItemPaint(row, column); + GradientPaintTransformer t = getGradientPaintTransformer(); + if (t != null && itemPaint instanceof GradientPaint) { + itemPaint = t.transform((GradientPaint) itemPaint, bar); + } + g2.setPaint(itemPaint); + g2.fill(bar); + // draw the outline... + if (isDrawBarOutline() + && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { + Stroke stroke = getItemOutlineStroke(row, column); + Paint paint = getItemOutlinePaint(row, column); + if (stroke != null && paint != null) { + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(bar); + } + } + + // standard deviation lines + Number n = dataset.getStdDevValue(row, column); + if (n != null) { + double valueDelta = n.doubleValue(); + double highVal = rangeAxis.valueToJava2D(meanValue.doubleValue() + + valueDelta, dataArea, yAxisLocation); + double lowVal = rangeAxis.valueToJava2D(meanValue.doubleValue() + - valueDelta, dataArea, yAxisLocation); + + if (this.errorIndicatorPaint != null) { + g2.setPaint(this.errorIndicatorPaint); + } + else { + g2.setPaint(getItemOutlinePaint(row, column)); + } + if (this.errorIndicatorStroke != null) { + g2.setStroke(this.errorIndicatorStroke); + } + else { + g2.setStroke(getItemOutlineStroke(row, column)); + } + + Line2D line; + line = new Line2D.Double(rectX + rectWidth / 2.0d, lowVal, + rectX + rectWidth / 2.0d, highVal); + g2.draw(line); + line = new Line2D.Double(rectX + rectWidth / 2.0d - 5.0d, highVal, + rectX + rectWidth / 2.0d + 5.0d, highVal); + g2.draw(line); + line = new Line2D.Double(rectX + rectWidth / 2.0d - 5.0d, lowVal, + rectX + rectWidth / 2.0d + 5.0d, lowVal); + g2.draw(line); + } + + CategoryItemLabelGenerator generator = getItemLabelGenerator(row, + column); + if (generator != null && isItemLabelVisible(row, column)) { + drawItemLabel(g2, dataset, row, column, plot, generator, bar, + (value < 0.0)); + } + + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, bar); + } + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StatisticalBarRenderer)) { + return false; + } + StatisticalBarRenderer that = (StatisticalBarRenderer) obj; + if (!PaintUtilities.equal(this.errorIndicatorPaint, + that.errorIndicatorPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.errorIndicatorStroke, + that.errorIndicatorStroke)) { + return false; + } + return super.equals(obj); + } + + /** + * 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.errorIndicatorPaint, stream); + SerialUtilities.writeStroke(this.errorIndicatorStroke, 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.errorIndicatorPaint = SerialUtilities.readPaint(stream); + this.errorIndicatorStroke = SerialUtilities.readStroke(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java new file mode 100755 index 0000000..81f7bc1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/StatisticalLineAndShapeRenderer.java @@ -0,0 +1,491 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------ + * StatisticalLineAndShapeRenderer.java + * ------------------------------------ + * (C) Copyright 2005-2009, by Object Refinery Limited and Contributors. + * + * Original Author: Mofeed Shahin; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Peter Kolb (patch 2497611); + * + * Changes + * ------- + * 01-Feb-2005 : Version 1, contributed by Mofeed Shahin (DG); + * 16-Jun-2005 : Added errorIndicatorPaint to be consistent with + * StatisticalBarRenderer (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 11-Apr-2006 : Fixed bug 1468794, error bars drawn incorrectly when rendering + * plots with horizontal orientation (DG); + * 25-Sep-2006 : Fixed bug 1562759, constructor ignoring arguments (DG); + * 01-Jun-2007 : Return early from drawItem() method if item is not + * visible (DG); + * 14-Jun-2007 : If the dataset is not a StatisticalCategoryDataset, revert + * to the drawing behaviour of LineAndShapeRenderer (DG); + * 27-Sep-2007 : Added offset option to match new option in + * LineAndShapeRenderer (DG); + * 14-Jan-2009 : Added support for seriesVisible flags (PK); + * 23-Jan-2009 : Observe useFillPaint and drawOutlines flags (PK); + * 23-Jan-2009 : In drawItem, divide code into passes (DG); + * 05-Feb-2009 : Added errorIndicatorStroke field (DG); + * 01-Apr-2009 : Added override for findRangeBounds(), and fixed NPE in + * creating item entities (DG); + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +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.HashUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.statistics.StatisticalCategoryDataset; +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 renderer that draws shapes for each data item, and lines between data + * items. Each point has a mean value and a standard deviation line. For use + * with the {@link CategoryPlot} class. The example shown + * here is generated by the StatisticalLineChartDemo1.java program + * included in the JFreeChart Demo Collection: + *

+ * StatisticalLineRendererSample.png + */ +public class StatisticalLineAndShapeRenderer extends LineAndShapeRenderer + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -3557517173697777579L; + + /** The paint used to show the error indicator. */ + private transient Paint errorIndicatorPaint; + + /** + * The stroke used to draw the error indicators. If null, the renderer + * will use the itemOutlineStroke. + * + * @since 1.0.13 + */ + private transient Stroke errorIndicatorStroke; + + /** + * Constructs a default renderer (draws shapes and lines). + */ + public StatisticalLineAndShapeRenderer() { + this(true, true); + } + + /** + * Constructs a new renderer. + * + * @param linesVisible draw lines? + * @param shapesVisible draw shapes? + */ + public StatisticalLineAndShapeRenderer(boolean linesVisible, + boolean shapesVisible) { + super(linesVisible, shapesVisible); + this.errorIndicatorPaint = null; + this.errorIndicatorStroke = null; + } + + /** + * Returns the paint used for the error indicators. + * + * @return The paint used for the error indicators (possibly + * null). + * + * @see #setErrorIndicatorPaint(Paint) + */ + public Paint getErrorIndicatorPaint() { + return this.errorIndicatorPaint; + } + + /** + * Sets the paint used for the error indicators (if null, + * the item paint is used instead) and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @see #getErrorIndicatorPaint() + */ + public void setErrorIndicatorPaint(Paint paint) { + this.errorIndicatorPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the stroke used for the error indicators. + * + * @return The stroke used for the error indicators (possibly + * null). + * + * @see #setErrorIndicatorStroke(Stroke) + * + * @since 1.0.13 + */ + public Stroke getErrorIndicatorStroke() { + return this.errorIndicatorStroke; + } + + /** + * Sets the stroke used for the error indicators (if null, + * the item outline stroke is used instead) and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null permitted). + * + * @see #getErrorIndicatorStroke() + * + * @since 1.0.13 + */ + public void setErrorIndicatorStroke(Stroke stroke) { + this.errorIndicatorStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (or null if the dataset is + * null or empty). + */ + @Override + public Range findRangeBounds(CategoryDataset dataset) { + return findRangeBounds(dataset, true); + } + + /** + * Draw a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area in which the data is drawn. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset (a {@link StatisticalCategoryDataset} is + * required). + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, + int pass) { + + // do nothing if item is not visible + if (!getItemVisible(row, column)) { + return; + } + + // if the dataset is not a StatisticalCategoryDataset then just revert + // to the superclass (LineAndShapeRenderer) behaviour... + if (!(dataset instanceof StatisticalCategoryDataset)) { + super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, + dataset, row, column, pass); + return; + } + + int visibleRow = state.getVisibleSeriesIndex(row); + if (visibleRow < 0) { + return; + } + int visibleRowCount = state.getVisibleSeriesCount(); + + StatisticalCategoryDataset statDataset + = (StatisticalCategoryDataset) dataset; + Number meanValue = statDataset.getMeanValue(row, column); + if (meanValue == null) { + return; + } + PlotOrientation orientation = plot.getOrientation(); + + // current data point... + double x1; + if (getUseSeriesOffset()) { + x1 = domainAxis.getCategorySeriesMiddle(column, + dataset.getColumnCount(), + visibleRow, visibleRowCount, + getItemMargin(), dataArea, plot.getDomainAxisEdge()); + } + else { + x1 = domainAxis.getCategoryMiddle(column, getColumnCount(), + dataArea, plot.getDomainAxisEdge()); + } + double y1 = rangeAxis.valueToJava2D(meanValue.doubleValue(), dataArea, + plot.getRangeAxisEdge()); + + // draw the standard deviation lines *before* the shapes (if they're + // visible) - it looks better if the shape fill colour is different to + // the line colour + Number sdv = statDataset.getStdDevValue(row, column); + if (pass == 1 && sdv != null) { + //standard deviation lines + RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); + double valueDelta = sdv.doubleValue(); + double highVal, lowVal; + if ((meanValue.doubleValue() + valueDelta) + > rangeAxis.getRange().getUpperBound()) { + highVal = rangeAxis.valueToJava2D( + rangeAxis.getRange().getUpperBound(), dataArea, + yAxisLocation); + } + else { + highVal = rangeAxis.valueToJava2D(meanValue.doubleValue() + + valueDelta, dataArea, yAxisLocation); + } + + if ((meanValue.doubleValue() + valueDelta) + < rangeAxis.getRange().getLowerBound()) { + lowVal = rangeAxis.valueToJava2D( + rangeAxis.getRange().getLowerBound(), dataArea, + yAxisLocation); + } + else { + lowVal = rangeAxis.valueToJava2D(meanValue.doubleValue() + - valueDelta, dataArea, yAxisLocation); + } + + if (this.errorIndicatorPaint != null) { + g2.setPaint(this.errorIndicatorPaint); + } + else { + g2.setPaint(getItemPaint(row, column)); + } + if (this.errorIndicatorStroke != null) { + g2.setStroke(this.errorIndicatorStroke); + } + else { + g2.setStroke(getItemOutlineStroke(row, column)); + } + Line2D line = new Line2D.Double(); + if (orientation == PlotOrientation.HORIZONTAL) { + line.setLine(lowVal, x1, highVal, x1); + g2.draw(line); + line.setLine(lowVal, x1 - 5.0d, lowVal, x1 + 5.0d); + g2.draw(line); + line.setLine(highVal, x1 - 5.0d, highVal, x1 + 5.0d); + g2.draw(line); + } + else { // PlotOrientation.VERTICAL + line.setLine(x1, lowVal, x1, highVal); + g2.draw(line); + line.setLine(x1 - 5.0d, highVal, x1 + 5.0d, highVal); + g2.draw(line); + line.setLine(x1 - 5.0d, lowVal, x1 + 5.0d, lowVal); + g2.draw(line); + } + + } + + Shape hotspot = null; + if (pass == 1 && getItemShapeVisible(row, column)) { + Shape shape = getItemShape(row, column); + if (orientation == PlotOrientation.HORIZONTAL) { + shape = ShapeUtilities.createTranslatedShape(shape, y1, x1); + } + else if (orientation == PlotOrientation.VERTICAL) { + shape = ShapeUtilities.createTranslatedShape(shape, x1, y1); + } + hotspot = shape; + + if (getItemShapeFilled(row, column)) { + if (getUseFillPaint()) { + g2.setPaint(getItemFillPaint(row, column)); + } + else { + g2.setPaint(getItemPaint(row, column)); + } + g2.fill(shape); + } + if (getDrawOutlines()) { + if (getUseOutlinePaint()) { + g2.setPaint(getItemOutlinePaint(row, column)); + } + else { + g2.setPaint(getItemPaint(row, column)); + } + g2.setStroke(getItemOutlineStroke(row, column)); + g2.draw(shape); + } + // draw the item label if there is one... + if (isItemLabelVisible(row, column)) { + if (orientation == PlotOrientation.HORIZONTAL) { + drawItemLabel(g2, orientation, dataset, row, column, + y1, x1, (meanValue.doubleValue() < 0.0)); + } + else if (orientation == PlotOrientation.VERTICAL) { + drawItemLabel(g2, orientation, dataset, row, column, + x1, y1, (meanValue.doubleValue() < 0.0)); + } + } + } + + if (pass == 0 && getItemLineVisible(row, column)) { + if (column != 0) { + + Number previousValue = statDataset.getValue(row, column - 1); + if (previousValue != null) { + + // previous data point... + double previous = previousValue.doubleValue(); + double x0; + if (getUseSeriesOffset()) { + x0 = domainAxis.getCategorySeriesMiddle( + column - 1, dataset.getColumnCount(), + visibleRow, visibleRowCount, + getItemMargin(), dataArea, + plot.getDomainAxisEdge()); + } + else { + x0 = domainAxis.getCategoryMiddle(column - 1, + getColumnCount(), dataArea, + plot.getDomainAxisEdge()); + } + double y0 = rangeAxis.valueToJava2D(previous, dataArea, + plot.getRangeAxisEdge()); + + Line2D line = null; + if (orientation == PlotOrientation.HORIZONTAL) { + line = new Line2D.Double(y0, x0, y1, x1); + } + else if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(x0, y0, x1, y1); + } + g2.setPaint(getItemPaint(row, column)); + g2.setStroke(getItemStroke(row, column)); + g2.draw(line); + } + } + } + + if (pass == 1) { + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addEntity(entities, hotspot, dataset, row, column, x1, y1); + } + } + + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StatisticalLineAndShapeRenderer)) { + return false; + } + StatisticalLineAndShapeRenderer that + = (StatisticalLineAndShapeRenderer) obj; + if (!PaintUtilities.equal(this.errorIndicatorPaint, + that.errorIndicatorPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.errorIndicatorStroke, + that.errorIndicatorStroke)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int hash = super.hashCode(); + hash = HashUtilities.hashCode(hash, this.errorIndicatorPaint); + return hash; + } + + /** + * 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.errorIndicatorPaint, stream); + SerialUtilities.writeStroke(this.errorIndicatorStroke, 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.errorIndicatorPaint = SerialUtilities.readPaint(stream); + this.errorIndicatorStroke = SerialUtilities.readStroke(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/WaterfallBarRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/WaterfallBarRenderer.java new file mode 100755 index 0000000..6b5f508 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/WaterfallBarRenderer.java @@ -0,0 +1,498 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * WaterfallBarRenderer.java + * ------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: Darshan Shah; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 20-Oct-2003 : Version 1, contributed by Darshan Shah (DG); + * 06-Nov-2003 : Changed order of parameters in constructor, and added support + * for GradientPaint (DG); + * 10-Feb-2004 : Updated drawItem() method to make cut-and-paste overriding + * easier. Also fixed a bug that meant the minimum bar length + * was being ignored (DG); + * 04-Oct-2004 : Reworked equals() method and renamed PaintUtils + * --> PaintUtilities (DG); + * 05-Nov-2004 : Modified drawItem() signature (DG); + * 07-Jan-2005 : Renamed getRangeExtent() --> findRangeBounds (DG); + * 23-Feb-2005 : Added argument checking (DG); + * 20-Apr-2005 : Renamed CategoryLabelGenerator + * --> CategoryItemLabelGenerator (DG); + * 09-Jun-2005 : Use addItemEntity() from superclass (DG); + * 27-Mar-2008 : Fixed error in findRangeBounds() method (DG); + * 26-Sep-2008 : Fixed bug with bar alignment when maximumBarWidth is + * applied (DG); + * 04-Feb-2009 : Updated findRangeBounds to handle null dataset consistently + * with other renderers (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import java.awt.Color; +import java.awt.GradientPaint; +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 org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.CategoryItemLabelGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.renderer.AbstractRenderer; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.GradientPaintTransformType; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.StandardGradientPaintTransformer; +import org.jfree.util.PaintUtilities; + +/** + * A renderer that handles the drawing of waterfall bar charts, for use with + * the {@link CategoryPlot} class. Some quirks to note: + *

    + *
  • the value in the last category of the dataset should be (redundantly) + * specified as the sum of the items in the preceding categories - otherwise + * the final bar in the plot will be incorrectly plotted;
  • + *
  • the bar colors are defined using special methods in this class - the + * inherited methods (for example, + * {@link AbstractRenderer#setSeriesPaint(int, Paint)}) are ignored;
  • + *
+ * The example shown here is generated by the + * WaterfallChartDemo1.java program included in the JFreeChart + * Demo Collection: + *

+ * WaterfallBarRendererSample.png + */ +public class WaterfallBarRenderer extends BarRenderer { + + /** For serialization. */ + private static final long serialVersionUID = -2482910643727230911L; + + /** The paint used to draw the first bar. */ + private transient Paint firstBarPaint; + + /** The paint used to draw the last bar. */ + private transient Paint lastBarPaint; + + /** The paint used to draw bars having positive values. */ + private transient Paint positiveBarPaint; + + /** The paint used to draw bars having negative values. */ + private transient Paint negativeBarPaint; + + /** + * Constructs a new renderer with default values for the bar colors. + */ + public WaterfallBarRenderer() { + this(new GradientPaint(0.0f, 0.0f, new Color(0x22, 0x22, 0xFF), + 0.0f, 0.0f, new Color(0x66, 0x66, 0xFF)), + new GradientPaint(0.0f, 0.0f, new Color(0x22, 0xFF, 0x22), + 0.0f, 0.0f, new Color(0x66, 0xFF, 0x66)), + new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0x22, 0x22), + 0.0f, 0.0f, new Color(0xFF, 0x66, 0x66)), + new GradientPaint(0.0f, 0.0f, new Color(0xFF, 0xFF, 0x22), + 0.0f, 0.0f, new Color(0xFF, 0xFF, 0x66))); + } + + /** + * Constructs a new waterfall renderer. + * + * @param firstBarPaint the color of the first bar (null not + * permitted). + * @param positiveBarPaint the color for bars with positive values + * (null not permitted). + * @param negativeBarPaint the color for bars with negative values + * (null not permitted). + * @param lastBarPaint the color of the last bar (null not + * permitted). + */ + public WaterfallBarRenderer(Paint firstBarPaint, Paint positiveBarPaint, + Paint negativeBarPaint, Paint lastBarPaint) { + super(); + ParamChecks.nullNotPermitted(firstBarPaint, "firstBarPaint"); + ParamChecks.nullNotPermitted(positiveBarPaint, "positiveBarPaint"); + ParamChecks.nullNotPermitted(negativeBarPaint, "negativeBarPaint"); + ParamChecks.nullNotPermitted(lastBarPaint, "lastBarPaint"); + this.firstBarPaint = firstBarPaint; + this.lastBarPaint = lastBarPaint; + this.positiveBarPaint = positiveBarPaint; + this.negativeBarPaint = negativeBarPaint; + setGradientPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_VERTICAL)); + setMinimumBarLength(1.0); + } + + /** + * Returns the paint used to draw the first bar. + * + * @return The paint (never null). + */ + public Paint getFirstBarPaint() { + return this.firstBarPaint; + } + + /** + * Sets the paint that will be used to draw the first bar and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + */ + public void setFirstBarPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.firstBarPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw the last bar. + * + * @return The paint (never null). + */ + public Paint getLastBarPaint() { + return this.lastBarPaint; + } + + /** + * Sets the paint that will be used to draw the last bar and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + */ + public void setLastBarPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.lastBarPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw bars with positive values. + * + * @return The paint (never null). + */ + public Paint getPositiveBarPaint() { + return this.positiveBarPaint; + } + + /** + * Sets the paint that will be used to draw bars having positive values. + * + * @param paint the paint (null not permitted). + */ + public void setPositiveBarPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.positiveBarPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw bars with negative values. + * + * @return The paint (never null). + */ + public Paint getNegativeBarPaint() { + return this.negativeBarPaint; + } + + /** + * Sets the paint that will be used to draw bars having negative values, + * and sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + */ + public void setNegativeBarPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.negativeBarPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null not permitted). + * + * @return The range (or null if the dataset is empty). + */ + @Override + public Range findRangeBounds(CategoryDataset dataset) { + if (dataset == null) { + return null; + } + boolean allItemsNull = true; // we'll set this to false if there is at + // least one non-null data item... + double minimum = 0.0; + double maximum = 0.0; + int columnCount = dataset.getColumnCount(); + for (int row = 0; row < dataset.getRowCount(); row++) { + double runningTotal = 0.0; + for (int column = 0; column <= columnCount - 1; column++) { + Number n = dataset.getValue(row, column); + if (n != null) { + allItemsNull = false; + double value = n.doubleValue(); + if (column == columnCount - 1) { + // treat the last column value as an absolute + runningTotal = value; + } + else { + runningTotal = runningTotal + value; + } + minimum = Math.min(minimum, runningTotal); + maximum = Math.max(maximum, runningTotal); + } + } + + } + if (!allItemsNull) { + return new Range(minimum, maximum); + } + else { + return null; + } + + } + + /** + * Draws the bar for a single (series, category) data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data area. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, CategoryItemRendererState state, + Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, + ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, + int pass) { + + double previous = state.getSeriesRunningTotal(); + if (column == dataset.getColumnCount() - 1) { + previous = 0.0; + } + double current = 0.0; + Number n = dataset.getValue(row, column); + if (n != null) { + current = previous + n.doubleValue(); + } + state.setSeriesRunningTotal(current); + + int categoryCount = getColumnCount(); + PlotOrientation orientation = plot.getOrientation(); + + double rectX = 0.0; + double rectY = 0.0; + + RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); + + // Y0 + double j2dy0 = rangeAxis.valueToJava2D(previous, dataArea, + rangeAxisLocation); + + // Y1 + double j2dy1 = rangeAxis.valueToJava2D(current, dataArea, + rangeAxisLocation); + + double valDiff = current - previous; + if (j2dy1 < j2dy0) { + double temp = j2dy1; + j2dy1 = j2dy0; + j2dy0 = temp; + } + + // BAR WIDTH + double rectWidth = state.getBarWidth(); + + // BAR HEIGHT + double rectHeight = Math.max(getMinimumBarLength(), + Math.abs(j2dy1 - j2dy0)); + + Comparable seriesKey = dataset.getRowKey(row); + Comparable categoryKey = dataset.getColumnKey(column); + if (orientation == PlotOrientation.HORIZONTAL) { + rectY = domainAxis.getCategorySeriesMiddle(categoryKey, seriesKey, + dataset, getItemMargin(), dataArea, RectangleEdge.LEFT); + + rectX = j2dy0; + rectHeight = state.getBarWidth(); + rectY = rectY - rectHeight / 2.0; + rectWidth = Math.max(getMinimumBarLength(), + Math.abs(j2dy1 - j2dy0)); + + } + else if (orientation == PlotOrientation.VERTICAL) { + rectX = domainAxis.getCategorySeriesMiddle(categoryKey, seriesKey, + dataset, getItemMargin(), dataArea, RectangleEdge.TOP); + rectX = rectX - rectWidth / 2.0; + rectY = j2dy0; + } + Rectangle2D bar = new Rectangle2D.Double(rectX, rectY, rectWidth, + rectHeight); + Paint seriesPaint; + if (column == 0) { + seriesPaint = getFirstBarPaint(); + } + else if (column == categoryCount - 1) { + seriesPaint = getLastBarPaint(); + } + else { + if (valDiff >= 0.0) { + seriesPaint = getPositiveBarPaint(); + } else { + seriesPaint = getNegativeBarPaint(); + } + } + if (getGradientPaintTransformer() != null + && seriesPaint instanceof GradientPaint) { + GradientPaint gp = (GradientPaint) seriesPaint; + seriesPaint = getGradientPaintTransformer().transform(gp, bar); + } + g2.setPaint(seriesPaint); + g2.fill(bar); + + // draw the outline... + if (isDrawBarOutline() + && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { + Stroke stroke = getItemOutlineStroke(row, column); + Paint paint = getItemOutlinePaint(row, column); + if (stroke != null && paint != null) { + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(bar); + } + } + + CategoryItemLabelGenerator generator + = getItemLabelGenerator(row, column); + if (generator != null && isItemLabelVisible(row, column)) { + drawItemLabel(g2, dataset, row, column, plot, generator, bar, + (valDiff < 0.0)); + } + + // add an item entity, if this information is being collected + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addItemEntity(entities, dataset, row, column, bar); + } + + } + + /** + * Tests an object for equality with this instance. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + + if (obj == this) { + return true; + } + if (!super.equals(obj)) { + return false; + } + if (!(obj instanceof WaterfallBarRenderer)) { + return false; + } + WaterfallBarRenderer that = (WaterfallBarRenderer) obj; + if (!PaintUtilities.equal(this.firstBarPaint, that.firstBarPaint)) { + return false; + } + if (!PaintUtilities.equal(this.lastBarPaint, that.lastBarPaint)) { + return false; + } + if (!PaintUtilities.equal(this.positiveBarPaint, + that.positiveBarPaint)) { + return false; + } + if (!PaintUtilities.equal(this.negativeBarPaint, + that.negativeBarPaint)) { + return false; + } + return true; + + } + + /** + * 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.firstBarPaint, stream); + SerialUtilities.writePaint(this.lastBarPaint, stream); + SerialUtilities.writePaint(this.positiveBarPaint, stream); + SerialUtilities.writePaint(this.negativeBarPaint, 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.firstBarPaint = SerialUtilities.readPaint(stream); + this.lastBarPaint = SerialUtilities.readPaint(stream); + this.positiveBarPaint = SerialUtilities.readPaint(stream); + this.negativeBarPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/package.html new file mode 100755 index 0000000..6a1693c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/category/package.html @@ -0,0 +1,6 @@ + + + +Plug-in renderers for the {@link org.jfree.chart.plot.CategoryPlot} class. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/package.html new file mode 100755 index 0000000..2af5acb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/package.html @@ -0,0 +1,6 @@ + + + +Core support for the plug-in renderers used by the {@link org.jfree.chart.plot.CategoryPlot} and {@link org.jfree.chart.plot.XYPlot} classes. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java new file mode 100755 index 0000000..06e0cd0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/AbstractXYItemRenderer.java @@ -0,0 +1,1931 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * AbstractXYItemRenderer.java + * --------------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Richard Atkinson; + * Focus Computer Services Limited; + * Tim Bardzil; + * Sergei Ivanov; + * Peter Kolb (patch 2809117); + * Martin Krauskopf; + * + * Changes: + * -------- + * 15-Mar-2002 : Version 1 (DG); + * 09-Apr-2002 : Added a getToolTipGenerator() method reflecting the change in + * the XYItemRenderer interface (DG); + * 05-Aug-2002 : Added a urlGenerator member variable to support HTML image + * maps (RA); + * 20-Aug-2002 : Added property change events for the tooltip and URL + * generators (DG); + * 22-Aug-2002 : Moved property change support into AbstractRenderer class (DG); + * 23-Sep-2002 : Fixed errors reported by Checkstyle tool (DG); + * 18-Nov-2002 : Added methods for drawing grid lines (DG); + * 17-Jan-2003 : Moved plot classes into a separate package (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Modified initialise() return type and drawItem() method + * signature (DG); + * 15-May-2003 : Modified to take into account the plot orientation (DG); + * 21-May-2003 : Added labels to markers (DG); + * 05-Jun-2003 : Added domain and range grid bands (sponsored by Focus Computer + * Services Ltd) (DG); + * 27-Jul-2003 : Added getRangeType() to support stacked XY area charts (RA); + * 31-Jul-2003 : Deprecated all but the default constructor (DG); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 29-Oct-2003 : Added workaround for font alignment in PDF output (DG); + * 05-Nov-2003 : Fixed marker rendering bug (833623) (DG); + * 11-Feb-2004 : Updated labelling for markers (DG); + * 25-Feb-2004 : Added updateCrosshairValues() method. Moved deprecated code + * to bottom of source file (DG); + * 16-Apr-2004 : Added support for IntervalMarker in drawRangeMarker() method + * - thanks to Tim Bardzil (DG); + * 05-May-2004 : Fixed bug (948310) where interval markers extend beyond axis + * range (DG); + * 03-Jun-2004 : Fixed more bugs in drawing interval markers (DG); + * 26-Aug-2004 : Added the addEntity() method (DG); + * 29-Sep-2004 : Added annotation support (with layers) (DG); + * 30-Sep-2004 : Moved drawRotatedString() from RefineryUtilities --> + * TextUtilities (DG); + * 06-Oct-2004 : Added findDomainBounds() method and renamed + * getRangeExtent() --> findRangeBounds() (DG); + * 07-Jan-2005 : Removed deprecated code (DG); + * 27-Jan-2005 : Modified getLegendItem() to omit hidden series (DG); + * 24-Feb-2005 : Added getLegendItems() method (DG); + * 08-Mar-2005 : Fixed positioning of marker labels (DG); + * 20-Apr-2005 : Renamed XYLabelGenerator --> XYItemLabelGenerator and + * added generators for legend labels, tooltips and URLs (DG); + * 01-Jun-2005 : Handle one dimension of the marker label adjustment + * automatically (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 20-Jul-2006 : Set dataset and series indices in LegendItem (DG); + * 24-Oct-2006 : Respect alpha setting in markers (see patch 1567843 by Sergei + * Ivanov) (DG); + * 24-Oct-2006 : Added code to draw outlines for interval markers (DG); + * 24-Nov-2006 : Fixed cloning for legend item generators (DG); + * 06-Feb-2007 : Added new updateCrosshairValues() method that takes into + * account multiple axis plots (see bug 1086307) (DG); + * 20-Feb-2007 : Fixed equals() method implementation (DG); + * 01-Mar-2007 : Fixed interval marker drawing (patch 1670686 thanks to + * Sergei Ivanov) (DG); + * 22-Mar-2007 : Modified the tool tip generator look up (DG); + * 23-Mar-2007 : Added drawDomainLine() method (DG); + * 20-Apr-2007 : Updated getLegendItem() for renderer change, and deprecated + * itemLabelGenerator and toolTipGenerator override fields (DG); + * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); + * 12-Nov-2007 : Fixed domain and range band drawing methods (DG); + * 07-Apr-2008 : Minor API doc update (DG); + * 14-May-2008 : Updated addEntity() method to take plot orientation into + * account when the incoming area is null (DG); + * 02-Jun-2008 : Added isPointInRect() method (DG); + * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * 09-Mar-2009 : Added getAnnotations() method (DG); + * 27-Mar-2009 : Added new findDomainBounds() and findRangeBounds() methods to + * take account of hidden series (DG); + * 01-Apr-2009 : Moved defaultEntityRadius up to superclass (DG); + * 28-Apr-2009 : Updated getLegendItem() method to observe new + * 'treatLegendShapeAsLine' flag (DG); + * 24-Jun-2009 : Added support for annotation events - see patch 2809117 + * by PK (DG); + * 01-Sep-2009 : Bug 2840132 - set renderer index when drawing + * annotations (DG); + * 06-Oct-2011 : Add utility methods to work with 1.4 API in GeneralPath (MK) + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.AlphaComposite; +import java.awt.Composite; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Ellipse2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.annotations.Annotation; +import org.jfree.chart.annotations.XYAnnotation; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.entity.XYItemEntity; +import org.jfree.chart.event.AnnotationChangeEvent; +import org.jfree.chart.event.AnnotationChangeListener; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.labels.StandardXYSeriesLabelGenerator; +import org.jfree.chart.labels.XYItemLabelGenerator; +import org.jfree.chart.labels.XYSeriesLabelGenerator; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.DrawingSupplier; +import org.jfree.chart.plot.IntervalMarker; +import org.jfree.chart.plot.Marker; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.ValueMarker; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.AbstractRenderer; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.xy.XYDataset; +import org.jfree.text.TextUtilities; +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.Layer; +import org.jfree.ui.LengthAdjustmentType; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.ObjectList; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A base class that can be used to create new {@link XYItemRenderer} + * implementations. + */ +public abstract class AbstractXYItemRenderer extends AbstractRenderer + implements XYItemRenderer, AnnotationChangeListener, + Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 8019124836026607990L; + + /** The plot. */ + private XYPlot plot; + + /** A list of item label generators (one per series). */ + private ObjectList itemLabelGeneratorList; + + /** The base item label generator. */ + private XYItemLabelGenerator baseItemLabelGenerator; + + /** A list of tool tip generators (one per series). */ + private ObjectList toolTipGeneratorList; + + /** The base tool tip generator. */ + private XYToolTipGenerator baseToolTipGenerator; + + /** The URL text generator. */ + private XYURLGenerator urlGenerator; + + /** + * Annotations to be drawn in the background layer ('underneath' the data + * items). + */ + private List backgroundAnnotations; + + /** + * Annotations to be drawn in the foreground layer ('on top' of the data + * items). + */ + private List foregroundAnnotations; + + /** The legend item label generator. */ + private XYSeriesLabelGenerator legendItemLabelGenerator; + + /** The legend item tool tip generator. */ + private XYSeriesLabelGenerator legendItemToolTipGenerator; + + /** The legend item URL generator. */ + private XYSeriesLabelGenerator legendItemURLGenerator; + + /** + * Creates a renderer where the tooltip generator and the URL generator are + * both null. + */ + protected AbstractXYItemRenderer() { + super(); + this.itemLabelGenerator = null; + this.itemLabelGeneratorList = new ObjectList(); + this.toolTipGenerator = null; + this.toolTipGeneratorList = new ObjectList(); + this.urlGenerator = null; + this.backgroundAnnotations = new java.util.ArrayList(); + this.foregroundAnnotations = new java.util.ArrayList(); + this.legendItemLabelGenerator = new StandardXYSeriesLabelGenerator( + "{0}"); + } + + /** + * Returns the number of passes through the data that the renderer requires + * in order to draw the chart. Most charts will require a single pass, but + * some require two passes. + * + * @return The pass count. + */ + @Override + public int getPassCount() { + return 1; + } + + /** + * Returns the plot that the renderer is assigned to. + * + * @return The plot (possibly null). + */ + @Override + public XYPlot getPlot() { + return this.plot; + } + + /** + * Sets the plot that the renderer is assigned to. + * + * @param plot the plot (null permitted). + */ + @Override + public void setPlot(XYPlot plot) { + this.plot = plot; + } + + /** + * Initialises the renderer and returns a state object that should be + * passed to all subsequent calls to the drawItem() method. + *

+ * This method will be called before the first item is rendered, giving the + * renderer an opportunity to initialise any state information it wants to + * maintain. The renderer can do nothing if it chooses. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param data the data. + * @param info an optional info collection object to return data back to + * the caller. + * + * @return The renderer state (never null). + */ + @Override + public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, + XYPlot plot, XYDataset data, PlotRenderingInfo info) { + return new XYItemRendererState(info); + } + + // ITEM LABEL GENERATOR + + /** + * Returns the label generator for a data item. This implementation simply + * passes control to the {@link #getSeriesItemLabelGenerator(int)} method. + * If, for some reason, you want a different generator for individual + * items, you can override this method. + * + * @param series the series index (zero based). + * @param item the item index (zero based). + * + * @return The generator (possibly null). + */ + @Override + public XYItemLabelGenerator getItemLabelGenerator(int series, int item) { + // return the generator for ALL series, if there is one... + if (this.itemLabelGenerator != null) { + return this.itemLabelGenerator; + } + + // otherwise look up the generator table + XYItemLabelGenerator generator + = (XYItemLabelGenerator) this.itemLabelGeneratorList.get(series); + if (generator == null) { + generator = this.baseItemLabelGenerator; + } + return generator; + } + + /** + * Returns the item label generator for a series. + * + * @param series the series index (zero based). + * + * @return The generator (possibly null). + */ + @Override + public XYItemLabelGenerator getSeriesItemLabelGenerator(int series) { + return (XYItemLabelGenerator) this.itemLabelGeneratorList.get(series); + } + + /** + * Sets the item label generator for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero based). + * @param generator the generator (null permitted). + */ + @Override + public void setSeriesItemLabelGenerator(int series, + XYItemLabelGenerator generator) { + this.itemLabelGeneratorList.set(series, generator); + fireChangeEvent(); + } + + /** + * Returns the base item label generator. + * + * @return The generator (possibly null). + */ + @Override + public XYItemLabelGenerator getBaseItemLabelGenerator() { + return this.baseItemLabelGenerator; + } + + /** + * Sets the base item label generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + */ + @Override + public void setBaseItemLabelGenerator(XYItemLabelGenerator generator) { + this.baseItemLabelGenerator = generator; + fireChangeEvent(); + } + + // TOOL TIP GENERATOR + + /** + * Returns the tool tip generator for a data item. If, for some reason, + * you want a different generator for individual items, you can override + * this method. + * + * @param series the series index (zero based). + * @param item the item index (zero based). + * + * @return The generator (possibly null). + */ + @Override + public XYToolTipGenerator getToolTipGenerator(int series, int item) { + // return the generator for ALL series, if there is one... + if (this.toolTipGenerator != null) { + return this.toolTipGenerator; + } + + // otherwise look up the generator table + XYToolTipGenerator generator + = (XYToolTipGenerator) this.toolTipGeneratorList.get(series); + if (generator == null) { + generator = this.baseToolTipGenerator; + } + return generator; + } + + /** + * Returns the tool tip generator for a series. + * + * @param series the series index (zero based). + * + * @return The generator (possibly null). + */ + @Override + public XYToolTipGenerator getSeriesToolTipGenerator(int series) { + return (XYToolTipGenerator) this.toolTipGeneratorList.get(series); + } + + /** + * Sets the tool tip generator for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero based). + * @param generator the generator (null permitted). + */ + @Override + public void setSeriesToolTipGenerator(int series, + XYToolTipGenerator generator) { + this.toolTipGeneratorList.set(series, generator); + fireChangeEvent(); + } + + /** + * Returns the base tool tip generator. + * + * @return The generator (possibly null). + * + * @see #setBaseToolTipGenerator(XYToolTipGenerator) + */ + @Override + public XYToolTipGenerator getBaseToolTipGenerator() { + return this.baseToolTipGenerator; + } + + /** + * Sets the base tool tip generator and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getBaseToolTipGenerator() + */ + @Override + public void setBaseToolTipGenerator(XYToolTipGenerator generator) { + this.baseToolTipGenerator = generator; + fireChangeEvent(); + } + + // URL GENERATOR + + /** + * Returns the URL generator for HTML image maps. + * + * @return The URL generator (possibly null). + */ + @Override + public XYURLGenerator getURLGenerator() { + return this.urlGenerator; + } + + /** + * Sets the URL generator for HTML image maps and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param urlGenerator the URL generator (null permitted). + */ + @Override + public void setURLGenerator(XYURLGenerator urlGenerator) { + this.urlGenerator = urlGenerator; + fireChangeEvent(); + } + + /** + * Adds an annotation and sends a {@link RendererChangeEvent} to all + * registered listeners. The annotation is added to the foreground + * layer. + * + * @param annotation the annotation (null not permitted). + */ + @Override + public void addAnnotation(XYAnnotation annotation) { + // defer argument checking + addAnnotation(annotation, Layer.FOREGROUND); + } + + /** + * Adds an annotation to the specified layer and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param annotation the annotation (null not permitted). + * @param layer the layer (null not permitted). + */ + @Override + public void addAnnotation(XYAnnotation annotation, Layer layer) { + ParamChecks.nullNotPermitted(annotation, "annotation"); + if (layer.equals(Layer.FOREGROUND)) { + this.foregroundAnnotations.add(annotation); + annotation.addChangeListener(this); + fireChangeEvent(); + } + else if (layer.equals(Layer.BACKGROUND)) { + this.backgroundAnnotations.add(annotation); + annotation.addChangeListener(this); + fireChangeEvent(); + } + else { + // should never get here + throw new RuntimeException("Unknown layer."); + } + } + /** + * Removes the specified annotation and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param annotation the annotation to remove (null not + * permitted). + * + * @return A boolean to indicate whether or not the annotation was + * successfully removed. + */ + @Override + public boolean removeAnnotation(XYAnnotation annotation) { + boolean removed = this.foregroundAnnotations.remove(annotation); + removed = removed & this.backgroundAnnotations.remove(annotation); + annotation.removeChangeListener(this); + fireChangeEvent(); + return removed; + } + + /** + * Removes all annotations and sends a {@link RendererChangeEvent} + * to all registered listeners. + */ + @Override + public void removeAnnotations() { + for(int i = 0; i < this.foregroundAnnotations.size(); i++){ + XYAnnotation annotation + = (XYAnnotation) this.foregroundAnnotations.get(i); + annotation.removeChangeListener(this); + } + for(int i = 0; i < this.backgroundAnnotations.size(); i++){ + XYAnnotation annotation + = (XYAnnotation) this.backgroundAnnotations.get(i); + annotation.removeChangeListener(this); + } + this.foregroundAnnotations.clear(); + this.backgroundAnnotations.clear(); + fireChangeEvent(); + } + + + /** + * Receives notification of a change to an {@link Annotation} added to + * this renderer. + * + * @param event information about the event (not used here). + * + * @since 1.0.14 + */ + @Override + public void annotationChanged(AnnotationChangeEvent event) { + fireChangeEvent(); + } + + /** + * Returns a collection of the annotations that are assigned to the + * renderer. + * + * @return A collection of annotations (possibly empty but never + * null). + * + * @since 1.0.13 + */ + public Collection getAnnotations() { + List result = new java.util.ArrayList(this.foregroundAnnotations); + result.addAll(this.backgroundAnnotations); + return result; + } + + /** + * Returns the legend item label generator. + * + * @return The label generator (never null). + * + * @see #setLegendItemLabelGenerator(XYSeriesLabelGenerator) + */ + @Override + public XYSeriesLabelGenerator getLegendItemLabelGenerator() { + return this.legendItemLabelGenerator; + } + + /** + * Sets the legend item label generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null not permitted). + * + * @see #getLegendItemLabelGenerator() + */ + @Override + public void setLegendItemLabelGenerator(XYSeriesLabelGenerator generator) { + ParamChecks.nullNotPermitted(generator, "generator"); + this.legendItemLabelGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the legend item tool tip generator. + * + * @return The tool tip generator (possibly null). + * + * @see #setLegendItemToolTipGenerator(XYSeriesLabelGenerator) + */ + public XYSeriesLabelGenerator getLegendItemToolTipGenerator() { + return this.legendItemToolTipGenerator; + } + + /** + * Sets the legend item tool tip generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getLegendItemToolTipGenerator() + */ + public void setLegendItemToolTipGenerator( + XYSeriesLabelGenerator generator) { + this.legendItemToolTipGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the legend item URL generator. + * + * @return The URL generator (possibly null). + * + * @see #setLegendItemURLGenerator(XYSeriesLabelGenerator) + */ + public XYSeriesLabelGenerator getLegendItemURLGenerator() { + return this.legendItemURLGenerator; + } + + /** + * Sets the legend item URL generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getLegendItemURLGenerator() + */ + public void setLegendItemURLGenerator(XYSeriesLabelGenerator generator) { + this.legendItemURLGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the lower and upper bounds (range) of the x-values in the + * specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + * + * @see #findRangeBounds(XYDataset) + */ + @Override + public Range findDomainBounds(XYDataset dataset) { + return findDomainBounds(dataset, false); + } + + /** + * Returns the lower and upper bounds (range) of the x-values in the + * specified dataset. + * + * @param dataset the dataset (null permitted). + * @param includeInterval include the interval (if any) for the dataset? + * + * @return The range (null if the dataset is null + * or empty). + * + * @since 1.0.13 + */ + protected Range findDomainBounds(XYDataset dataset, + boolean includeInterval) { + if (dataset == null) { + return null; + } + if (getDataBoundsIncludesVisibleSeriesOnly()) { + List visibleSeriesKeys = new ArrayList(); + int seriesCount = dataset.getSeriesCount(); + for (int s = 0; s < seriesCount; s++) { + if (isSeriesVisible(s)) { + visibleSeriesKeys.add(dataset.getSeriesKey(s)); + } + } + return DatasetUtilities.findDomainBounds(dataset, + visibleSeriesKeys, includeInterval); + } + return DatasetUtilities.findDomainBounds(dataset, includeInterval); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + * + * @see #findDomainBounds(XYDataset) + */ + @Override + public Range findRangeBounds(XYDataset dataset) { + return findRangeBounds(dataset, false); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * @param includeInterval include the interval (if any) for the dataset? + * + * @return The range (null if the dataset is null + * or empty). + * + * @since 1.0.13 + */ + protected Range findRangeBounds(XYDataset dataset, + boolean includeInterval) { + if (dataset == null) { + return null; + } + if (getDataBoundsIncludesVisibleSeriesOnly()) { + List visibleSeriesKeys = new ArrayList(); + int seriesCount = dataset.getSeriesCount(); + for (int s = 0; s < seriesCount; s++) { + if (isSeriesVisible(s)) { + visibleSeriesKeys.add(dataset.getSeriesKey(s)); + } + } + // the bounds should be calculated using just the items within + // the current range of the x-axis...if there is one + Range xRange = null; + XYPlot p = getPlot(); + if (p != null) { + ValueAxis xAxis = null; + int index = p.getIndexOf(this); + if (index >= 0) { + xAxis = this.plot.getDomainAxisForDataset(index); + } + if (xAxis != null) { + xRange = xAxis.getRange(); + } + } + if (xRange == null) { + xRange = new Range(Double.NEGATIVE_INFINITY, + Double.POSITIVE_INFINITY); + } + return DatasetUtilities.findRangeBounds(dataset, + visibleSeriesKeys, xRange, includeInterval); + } + return DatasetUtilities.findRangeBounds(dataset, includeInterval); + } + + /** + * Returns a (possibly empty) collection of legend items for the series + * that this renderer is responsible for drawing. + * + * @return The legend item collection (never null). + */ + @Override + public LegendItemCollection getLegendItems() { + if (this.plot == null) { + return new LegendItemCollection(); + } + LegendItemCollection result = new LegendItemCollection(); + int index = this.plot.getIndexOf(this); + XYDataset dataset = this.plot.getDataset(index); + if (dataset != null) { + int seriesCount = dataset.getSeriesCount(); + for (int i = 0; i < seriesCount; i++) { + if (isSeriesVisibleInLegend(i)) { + LegendItem item = getLegendItem(index, i); + if (item != null) { + result.add(item); + } + } + } + + } + return result; + } + + /** + * Returns a default legend item for the specified series. Subclasses + * should override this method to generate customised items. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return A legend item for the series. + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + XYPlot xyplot = getPlot(); + if (xyplot == null) { + return null; + } + XYDataset dataset = xyplot.getDataset(datasetIndex); + if (dataset == null) { + return null; + } + String label = this.legendItemLabelGenerator.generateLabel(dataset, + series); + String description = label; + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel(dataset, + series); + } + Shape shape = lookupLegendShape(series); + Paint paint = lookupSeriesPaint(series); + LegendItem item = new LegendItem(label, paint); + item.setToolTipText(toolTipText); + item.setURLText(urlText); + item.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + item.setLabelPaint(labelPaint); + } + item.setSeriesKey(dataset.getSeriesKey(series)); + item.setSeriesIndex(series); + item.setDataset(dataset); + item.setDatasetIndex(datasetIndex); + + if (getTreatLegendShapeAsLine()) { + item.setLineVisible(true); + item.setLine(shape); + item.setLinePaint(paint); + item.setShapeVisible(false); + } + else { + Paint outlinePaint = lookupSeriesOutlinePaint(series); + Stroke outlineStroke = lookupSeriesOutlineStroke(series); + item.setOutlinePaint(outlinePaint); + item.setOutlineStroke(outlineStroke); + } + return item; + } + + /** + * Fills a band between two values on the axis. This can be used to color + * bands between the grid lines. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the domain axis. + * @param dataArea the data area. + * @param start the start value. + * @param end the end value. + */ + @Override + public void fillDomainGridBand(Graphics2D g2, XYPlot plot, ValueAxis axis, + Rectangle2D dataArea, double start, double end) { + + double x1 = axis.valueToJava2D(start, dataArea, + plot.getDomainAxisEdge()); + double x2 = axis.valueToJava2D(end, dataArea, + plot.getDomainAxisEdge()); + Rectangle2D band; + if (plot.getOrientation() == PlotOrientation.VERTICAL) { + band = new Rectangle2D.Double(Math.min(x1, x2), dataArea.getMinY(), + Math.abs(x2 - x1), dataArea.getWidth()); + } + else { + band = new Rectangle2D.Double(dataArea.getMinX(), Math.min(x1, x2), + dataArea.getWidth(), Math.abs(x2 - x1)); + } + Paint paint = plot.getDomainTickBandPaint(); + + if (paint != null) { + g2.setPaint(paint); + g2.fill(band); + } + + } + + /** + * Fills a band between two values on the range axis. This can be used to + * color bands between the grid lines. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the range axis. + * @param dataArea the data area. + * @param start the start value. + * @param end the end value. + */ + @Override + public void fillRangeGridBand(Graphics2D g2, XYPlot plot, ValueAxis axis, + Rectangle2D dataArea, double start, double end) { + + double y1 = axis.valueToJava2D(start, dataArea, + plot.getRangeAxisEdge()); + double y2 = axis.valueToJava2D(end, dataArea, plot.getRangeAxisEdge()); + Rectangle2D band; + if (plot.getOrientation() == PlotOrientation.VERTICAL) { + band = new Rectangle2D.Double(dataArea.getMinX(), Math.min(y1, y2), + dataArea.getWidth(), Math.abs(y2 - y1)); + } + else { + band = new Rectangle2D.Double(Math.min(y1, y2), dataArea.getMinY(), + Math.abs(y2 - y1), dataArea.getHeight()); + } + Paint paint = plot.getRangeTickBandPaint(); + + if (paint != null) { + g2.setPaint(paint); + g2.fill(band); + } + + } + + /** + * Draws a grid line against the range axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param dataArea the area for plotting data (not yet adjusted for any + * 3D effect). + * @param value the value at which the grid line should be drawn. + */ + @Override + public void drawDomainGridLine(Graphics2D g2, XYPlot plot, ValueAxis axis, + Rectangle2D dataArea, double value) { + + Range range = axis.getRange(); + if (!range.contains(value)) { + return; + } + + PlotOrientation orientation = plot.getOrientation(); + double v = axis.valueToJava2D(value, dataArea, + plot.getDomainAxisEdge()); + Line2D line = null; + if (orientation == PlotOrientation.HORIZONTAL) { + line = new Line2D.Double(dataArea.getMinX(), v, + dataArea.getMaxX(), v); + } + else if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(v, dataArea.getMinY(), v, + dataArea.getMaxY()); + } + + Paint paint = plot.getDomainGridlinePaint(); + Stroke stroke = plot.getDomainGridlineStroke(); + g2.setPaint(paint != null ? paint : Plot.DEFAULT_OUTLINE_PAINT); + g2.setStroke(stroke != null ? stroke : Plot.DEFAULT_OUTLINE_STROKE); + g2.draw(line); + + } + + /** + * Draws a line perpendicular to the domain axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param dataArea the area for plotting data (not yet adjusted for any 3D + * effect). + * @param value the value at which the grid line should be drawn. + * @param paint the paint (null not permitted). + * @param stroke the stroke (null not permitted). + * + * @since 1.0.5 + */ + public void drawDomainLine(Graphics2D g2, XYPlot plot, ValueAxis axis, + Rectangle2D dataArea, double value, Paint paint, Stroke stroke) { + + Range range = axis.getRange(); + if (!range.contains(value)) { + return; + } + + PlotOrientation orientation = plot.getOrientation(); + Line2D line = null; + double v = axis.valueToJava2D(value, dataArea, + plot.getDomainAxisEdge()); + if (orientation == PlotOrientation.HORIZONTAL) { + line = new Line2D.Double(dataArea.getMinX(), v, dataArea.getMaxX(), + v); + } + else if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(v, dataArea.getMinY(), v, + dataArea.getMaxY()); + } + + g2.setPaint(paint); + g2.setStroke(stroke); + g2.draw(line); + + } + + /** + * Draws a line perpendicular to the range axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param dataArea the area for plotting data (not yet adjusted for any 3D + * effect). + * @param value the value at which the grid line should be drawn. + * @param paint the paint. + * @param stroke the stroke. + */ + @Override + public void drawRangeLine(Graphics2D g2, XYPlot plot, ValueAxis axis, + Rectangle2D dataArea, double value, Paint paint, Stroke stroke) { + + Range range = axis.getRange(); + if (!range.contains(value)) { + return; + } + + PlotOrientation orientation = plot.getOrientation(); + Line2D line = null; + double v = axis.valueToJava2D(value, dataArea, plot.getRangeAxisEdge()); + if (orientation == PlotOrientation.HORIZONTAL) { + line = new Line2D.Double(v, dataArea.getMinY(), v, + dataArea.getMaxY()); + } + else if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(dataArea.getMinX(), v, + dataArea.getMaxX(), v); + } + + g2.setPaint(paint); + g2.setStroke(stroke); + g2.draw(line); + + } + + /** + * Draws a vertical line on the chart to represent a 'range marker'. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param marker the marker line. + * @param dataArea the axis data area. + */ + @Override + public void drawDomainMarker(Graphics2D g2, XYPlot plot, + ValueAxis domainAxis, Marker marker, Rectangle2D dataArea) { + + if (marker instanceof ValueMarker) { + ValueMarker vm = (ValueMarker) marker; + double value = vm.getValue(); + Range range = domainAxis.getRange(); + if (!range.contains(value)) { + return; + } + + double v = domainAxis.valueToJava2D(value, dataArea, + plot.getDomainAxisEdge()); + + PlotOrientation orientation = plot.getOrientation(); + Line2D line = null; + if (orientation == PlotOrientation.HORIZONTAL) { + line = new Line2D.Double(dataArea.getMinX(), v, + dataArea.getMaxX(), v); + } + else if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(v, dataArea.getMinY(), v, + dataArea.getMaxY()); + } else { + throw new IllegalStateException(); + } + + final Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance( + AlphaComposite.SRC_OVER, marker.getAlpha())); + g2.setPaint(marker.getPaint()); + g2.setStroke(marker.getStroke()); + g2.draw(line); + + String label = marker.getLabel(); + RectangleAnchor anchor = marker.getLabelAnchor(); + if (label != null) { + Font labelFont = marker.getLabelFont(); + g2.setFont(labelFont); + g2.setPaint(marker.getLabelPaint()); + Point2D coordinates = calculateDomainMarkerTextAnchorPoint( + g2, orientation, dataArea, line.getBounds2D(), + marker.getLabelOffset(), + LengthAdjustmentType.EXPAND, anchor); + TextUtilities.drawAlignedString(label, g2, + (float) coordinates.getX(), (float) coordinates.getY(), + marker.getLabelTextAnchor()); + } + g2.setComposite(originalComposite); + } + else if (marker instanceof IntervalMarker) { + IntervalMarker im = (IntervalMarker) marker; + double start = im.getStartValue(); + double end = im.getEndValue(); + Range range = domainAxis.getRange(); + if (!(range.intersects(start, end))) { + return; + } + + double start2d = domainAxis.valueToJava2D(start, dataArea, + plot.getDomainAxisEdge()); + double end2d = domainAxis.valueToJava2D(end, dataArea, + plot.getDomainAxisEdge()); + double low = Math.min(start2d, end2d); + double high = Math.max(start2d, end2d); + + PlotOrientation orientation = plot.getOrientation(); + Rectangle2D rect = null; + if (orientation == PlotOrientation.HORIZONTAL) { + // clip top and bottom bounds to data area + low = Math.max(low, dataArea.getMinY()); + high = Math.min(high, dataArea.getMaxY()); + rect = new Rectangle2D.Double(dataArea.getMinX(), + low, dataArea.getWidth(), + high - low); + } + else if (orientation == PlotOrientation.VERTICAL) { + // clip left and right bounds to data area + low = Math.max(low, dataArea.getMinX()); + high = Math.min(high, dataArea.getMaxX()); + rect = new Rectangle2D.Double(low, + dataArea.getMinY(), high - low, + dataArea.getHeight()); + } + + final Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance( + AlphaComposite.SRC_OVER, marker.getAlpha())); + Paint p = marker.getPaint(); + if (p instanceof GradientPaint) { + GradientPaint gp = (GradientPaint) p; + GradientPaintTransformer t = im.getGradientPaintTransformer(); + if (t != null) { + gp = t.transform(gp, rect); + } + g2.setPaint(gp); + } + else { + g2.setPaint(p); + } + g2.fill(rect); + + // now draw the outlines, if visible... + if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) { + if (orientation == PlotOrientation.VERTICAL) { + Line2D line = new Line2D.Double(); + double y0 = dataArea.getMinY(); + double y1 = dataArea.getMaxY(); + g2.setPaint(im.getOutlinePaint()); + g2.setStroke(im.getOutlineStroke()); + if (range.contains(start)) { + line.setLine(start2d, y0, start2d, y1); + g2.draw(line); + } + if (range.contains(end)) { + line.setLine(end2d, y0, end2d, y1); + g2.draw(line); + } + } + else { // PlotOrientation.HORIZONTAL + Line2D line = new Line2D.Double(); + double x0 = dataArea.getMinX(); + double x1 = dataArea.getMaxX(); + g2.setPaint(im.getOutlinePaint()); + g2.setStroke(im.getOutlineStroke()); + if (range.contains(start)) { + line.setLine(x0, start2d, x1, start2d); + g2.draw(line); + } + if (range.contains(end)) { + line.setLine(x0, end2d, x1, end2d); + g2.draw(line); + } + } + } + + String label = marker.getLabel(); + RectangleAnchor anchor = marker.getLabelAnchor(); + if (label != null) { + Font labelFont = marker.getLabelFont(); + g2.setFont(labelFont); + g2.setPaint(marker.getLabelPaint()); + Point2D coordinates = calculateDomainMarkerTextAnchorPoint( + g2, orientation, dataArea, rect, + marker.getLabelOffset(), marker.getLabelOffsetType(), + anchor); + TextUtilities.drawAlignedString(label, g2, + (float) coordinates.getX(), (float) coordinates.getY(), + marker.getLabelTextAnchor()); + } + g2.setComposite(originalComposite); + + } + + } + + /** + * Calculates the (x, y) coordinates for drawing a marker label. + * + * @param g2 the graphics device. + * @param orientation the plot orientation. + * @param dataArea the data area. + * @param markerArea the rectangle surrounding the marker area. + * @param markerOffset the marker label offset. + * @param labelOffsetType the label offset type. + * @param anchor the label anchor. + * + * @return The coordinates for drawing the marker label. + */ + protected Point2D calculateDomainMarkerTextAnchorPoint(Graphics2D g2, + PlotOrientation orientation, Rectangle2D dataArea, + Rectangle2D markerArea, RectangleInsets markerOffset, + LengthAdjustmentType labelOffsetType, RectangleAnchor anchor) { + + Rectangle2D anchorRect = null; + if (orientation == PlotOrientation.HORIZONTAL) { + anchorRect = markerOffset.createAdjustedRectangle(markerArea, + LengthAdjustmentType.CONTRACT, labelOffsetType); + } + else if (orientation == PlotOrientation.VERTICAL) { + anchorRect = markerOffset.createAdjustedRectangle(markerArea, + labelOffsetType, LengthAdjustmentType.CONTRACT); + } + return RectangleAnchor.coordinates(anchorRect, anchor); + + } + + /** + * Draws a horizontal line across the chart to represent a 'range marker'. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param rangeAxis the range axis. + * @param marker the marker line. + * @param dataArea the axis data area. + */ + @Override + public void drawRangeMarker(Graphics2D g2, XYPlot plot, ValueAxis rangeAxis, + Marker marker, Rectangle2D dataArea) { + + if (marker instanceof ValueMarker) { + ValueMarker vm = (ValueMarker) marker; + double value = vm.getValue(); + Range range = rangeAxis.getRange(); + if (!range.contains(value)) { + return; + } + + double v = rangeAxis.valueToJava2D(value, dataArea, + plot.getRangeAxisEdge()); + PlotOrientation orientation = plot.getOrientation(); + Line2D line = null; + if (orientation == PlotOrientation.HORIZONTAL) { + line = new Line2D.Double(v, dataArea.getMinY(), v, + dataArea.getMaxY()); + } + else if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(dataArea.getMinX(), v, + dataArea.getMaxX(), v); + } + else { + throw new IllegalStateException("Unknown orientation."); + } + + final Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance( + AlphaComposite.SRC_OVER, marker.getAlpha())); + g2.setPaint(marker.getPaint()); + g2.setStroke(marker.getStroke()); + g2.draw(line); + + String label = marker.getLabel(); + RectangleAnchor anchor = marker.getLabelAnchor(); + if (label != null) { + Font labelFont = marker.getLabelFont(); + g2.setFont(labelFont); + g2.setPaint(marker.getLabelPaint()); + Point2D coordinates = calculateRangeMarkerTextAnchorPoint( + g2, orientation, dataArea, line.getBounds2D(), + marker.getLabelOffset(), + LengthAdjustmentType.EXPAND, anchor); + TextUtilities.drawAlignedString(label, g2, + (float) coordinates.getX(), (float) coordinates.getY(), + marker.getLabelTextAnchor()); + } + g2.setComposite(originalComposite); + } + else if (marker instanceof IntervalMarker) { + IntervalMarker im = (IntervalMarker) marker; + double start = im.getStartValue(); + double end = im.getEndValue(); + Range range = rangeAxis.getRange(); + if (!(range.intersects(start, end))) { + return; + } + + double start2d = rangeAxis.valueToJava2D(start, dataArea, + plot.getRangeAxisEdge()); + double end2d = rangeAxis.valueToJava2D(end, dataArea, + plot.getRangeAxisEdge()); + double low = Math.min(start2d, end2d); + double high = Math.max(start2d, end2d); + + PlotOrientation orientation = plot.getOrientation(); + Rectangle2D rect = null; + if (orientation == PlotOrientation.HORIZONTAL) { + // clip left and right bounds to data area + low = Math.max(low, dataArea.getMinX()); + high = Math.min(high, dataArea.getMaxX()); + rect = new Rectangle2D.Double(low, + dataArea.getMinY(), high - low, + dataArea.getHeight()); + } + else if (orientation == PlotOrientation.VERTICAL) { + // clip top and bottom bounds to data area + low = Math.max(low, dataArea.getMinY()); + high = Math.min(high, dataArea.getMaxY()); + rect = new Rectangle2D.Double(dataArea.getMinX(), + low, dataArea.getWidth(), + high - low); + } + + final Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance( + AlphaComposite.SRC_OVER, marker.getAlpha())); + Paint p = marker.getPaint(); + if (p instanceof GradientPaint) { + GradientPaint gp = (GradientPaint) p; + GradientPaintTransformer t = im.getGradientPaintTransformer(); + if (t != null) { + gp = t.transform(gp, rect); + } + g2.setPaint(gp); + } + else { + g2.setPaint(p); + } + g2.fill(rect); + + // now draw the outlines, if visible... + if (im.getOutlinePaint() != null && im.getOutlineStroke() != null) { + if (orientation == PlotOrientation.VERTICAL) { + Line2D line = new Line2D.Double(); + double x0 = dataArea.getMinX(); + double x1 = dataArea.getMaxX(); + g2.setPaint(im.getOutlinePaint()); + g2.setStroke(im.getOutlineStroke()); + if (range.contains(start)) { + line.setLine(x0, start2d, x1, start2d); + g2.draw(line); + } + if (range.contains(end)) { + line.setLine(x0, end2d, x1, end2d); + g2.draw(line); + } + } + else { // PlotOrientation.HORIZONTAL + Line2D line = new Line2D.Double(); + double y0 = dataArea.getMinY(); + double y1 = dataArea.getMaxY(); + g2.setPaint(im.getOutlinePaint()); + g2.setStroke(im.getOutlineStroke()); + if (range.contains(start)) { + line.setLine(start2d, y0, start2d, y1); + g2.draw(line); + } + if (range.contains(end)) { + line.setLine(end2d, y0, end2d, y1); + g2.draw(line); + } + } + } + + String label = marker.getLabel(); + RectangleAnchor anchor = marker.getLabelAnchor(); + if (label != null) { + Font labelFont = marker.getLabelFont(); + g2.setFont(labelFont); + g2.setPaint(marker.getLabelPaint()); + Point2D coordinates = calculateRangeMarkerTextAnchorPoint( + g2, orientation, dataArea, rect, + marker.getLabelOffset(), marker.getLabelOffsetType(), + anchor); + TextUtilities.drawAlignedString(label, g2, + (float) coordinates.getX(), (float) coordinates.getY(), + marker.getLabelTextAnchor()); + } + g2.setComposite(originalComposite); + } + } + + /** + * Calculates the (x, y) coordinates for drawing a marker label. + * + * @param g2 the graphics device. + * @param orientation the plot orientation. + * @param dataArea the data area. + * @param markerArea the marker area. + * @param markerOffset the marker offset. + * @param labelOffsetForRange ?? + * @param anchor the label anchor. + * + * @return The coordinates for drawing the marker label. + */ + private Point2D calculateRangeMarkerTextAnchorPoint(Graphics2D g2, + PlotOrientation orientation, Rectangle2D dataArea, + Rectangle2D markerArea, RectangleInsets markerOffset, + LengthAdjustmentType labelOffsetForRange, RectangleAnchor anchor) { + + Rectangle2D anchorRect = null; + if (orientation == PlotOrientation.HORIZONTAL) { + anchorRect = markerOffset.createAdjustedRectangle(markerArea, + labelOffsetForRange, LengthAdjustmentType.CONTRACT); + } + else if (orientation == PlotOrientation.VERTICAL) { + anchorRect = markerOffset.createAdjustedRectangle(markerArea, + LengthAdjustmentType.CONTRACT, labelOffsetForRange); + } + return RectangleAnchor.coordinates(anchorRect, anchor); + + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer does not support + * cloning. + */ + @Override + protected Object clone() throws CloneNotSupportedException { + AbstractXYItemRenderer clone = (AbstractXYItemRenderer) super.clone(); + // 'plot' : just retain reference, not a deep copy + + if (this.itemLabelGenerator != null + && this.itemLabelGenerator instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.itemLabelGenerator; + clone.itemLabelGenerator = (XYItemLabelGenerator) pc.clone(); + } + clone.itemLabelGeneratorList + = (ObjectList) this.itemLabelGeneratorList.clone(); + if (this.baseItemLabelGenerator != null + && this.baseItemLabelGenerator instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.baseItemLabelGenerator; + clone.baseItemLabelGenerator = (XYItemLabelGenerator) pc.clone(); + } + + if (this.toolTipGenerator != null + && this.toolTipGenerator instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.toolTipGenerator; + clone.toolTipGenerator = (XYToolTipGenerator) pc.clone(); + } + clone.toolTipGeneratorList + = (ObjectList) this.toolTipGeneratorList.clone(); + if (this.baseToolTipGenerator != null + && this.baseToolTipGenerator instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.baseToolTipGenerator; + clone.baseToolTipGenerator = (XYToolTipGenerator) pc.clone(); + } + + if (this.legendItemLabelGenerator instanceof PublicCloneable) { + clone.legendItemLabelGenerator = (XYSeriesLabelGenerator) + ObjectUtilities.clone(this.legendItemLabelGenerator); + } + if (this.legendItemToolTipGenerator instanceof PublicCloneable) { + clone.legendItemToolTipGenerator = (XYSeriesLabelGenerator) + ObjectUtilities.clone(this.legendItemToolTipGenerator); + } + if (this.legendItemURLGenerator instanceof PublicCloneable) { + clone.legendItemURLGenerator = (XYSeriesLabelGenerator) + ObjectUtilities.clone(this.legendItemURLGenerator); + } + + clone.foregroundAnnotations = (List) ObjectUtilities.deepClone( + this.foregroundAnnotations); + clone.backgroundAnnotations = (List) ObjectUtilities.deepClone( + this.backgroundAnnotations); + + return clone; + } + + /** + * Tests this renderer for equality with another object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof AbstractXYItemRenderer)) { + return false; + } + AbstractXYItemRenderer that = (AbstractXYItemRenderer) obj; + if (!ObjectUtilities.equal(this.itemLabelGenerator, + that.itemLabelGenerator)) { + return false; + } + if (!this.itemLabelGeneratorList.equals(that.itemLabelGeneratorList)) { + return false; + } + if (!ObjectUtilities.equal(this.baseItemLabelGenerator, + that.baseItemLabelGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.toolTipGenerator, + that.toolTipGenerator)) { + return false; + } + if (!this.toolTipGeneratorList.equals(that.toolTipGeneratorList)) { + return false; + } + if (!ObjectUtilities.equal(this.baseToolTipGenerator, + that.baseToolTipGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.urlGenerator, that.urlGenerator)) { + return false; + } + if (!this.foregroundAnnotations.equals(that.foregroundAnnotations)) { + return false; + } + if (!this.backgroundAnnotations.equals(that.backgroundAnnotations)) { + return false; + } + if (!ObjectUtilities.equal(this.legendItemLabelGenerator, + that.legendItemLabelGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.legendItemToolTipGenerator, + that.legendItemToolTipGenerator)) { + return false; + } + if (!ObjectUtilities.equal(this.legendItemURLGenerator, + that.legendItemURLGenerator)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns the drawing supplier from the plot. + * + * @return The drawing supplier (possibly null). + */ + @Override + public DrawingSupplier getDrawingSupplier() { + DrawingSupplier result = null; + XYPlot p = getPlot(); + if (p != null) { + result = p.getDrawingSupplier(); + } + return result; + } + + /** + * Considers the current (x, y) coordinate and updates the crosshair point + * if it meets the criteria (usually means the (x, y) coordinate is the + * closest to the anchor point so far). + * + * @param crosshairState the crosshair state (null permitted, + * but the method does nothing in that case). + * @param x the x-value (in data space). + * @param y the y-value (in data space). + * @param domainAxisIndex the index of the domain axis for the point. + * @param rangeAxisIndex the index of the range axis for the point. + * @param transX the x-value translated to Java2D space. + * @param transY the y-value translated to Java2D space. + * @param orientation the plot orientation (null not + * permitted). + * + * @since 1.0.4 + */ + protected void updateCrosshairValues(CrosshairState crosshairState, + double x, double y, int domainAxisIndex, int rangeAxisIndex, + double transX, double transY, PlotOrientation orientation) { + + ParamChecks.nullNotPermitted(orientation, "orientation"); + if (crosshairState != null) { + // do we need to update the crosshair values? + if (this.plot.isDomainCrosshairLockedOnData()) { + if (this.plot.isRangeCrosshairLockedOnData()) { + // both axes + crosshairState.updateCrosshairPoint(x, y, domainAxisIndex, + rangeAxisIndex, transX, transY, orientation); + } + else { + // just the domain axis... + crosshairState.updateCrosshairX(x, domainAxisIndex); + } + } + else { + if (this.plot.isRangeCrosshairLockedOnData()) { + // just the range axis... + crosshairState.updateCrosshairY(y, rangeAxisIndex); + } + } + } + + } + + /** + * Draws an item label. + * + * @param g2 the graphics device. + * @param orientation the orientation. + * @param dataset the dataset. + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @param x the x coordinate (in Java2D space). + * @param y the y coordinate (in Java2D space). + * @param negative indicates a negative value (which affects the item + * label position). + */ + protected void drawItemLabel(Graphics2D g2, PlotOrientation orientation, + XYDataset dataset, int series, int item, double x, double y, + boolean negative) { + + XYItemLabelGenerator generator = getItemLabelGenerator(series, item); + if (generator != null) { + Font labelFont = getItemLabelFont(series, item); + Paint paint = getItemLabelPaint(series, item); + g2.setFont(labelFont); + g2.setPaint(paint); + String label = generator.generateLabel(dataset, series, item); + + // get the label position.. + ItemLabelPosition position; + if (!negative) { + position = getPositiveItemLabelPosition(series, item); + } + else { + position = getNegativeItemLabelPosition(series, item); + } + + // work out the label anchor point... + Point2D anchorPoint = calculateLabelAnchorPoint( + position.getItemLabelAnchor(), x, y, orientation); + TextUtilities.drawRotatedString(label, g2, + (float) anchorPoint.getX(), (float) anchorPoint.getY(), + position.getTextAnchor(), position.getAngle(), + position.getRotationAnchor()); + } + + } + + /** + * Draws all the annotations for the specified layer. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param layer the layer. + * @param info the plot rendering info. + */ + @Override + public void drawAnnotations(Graphics2D g2, Rectangle2D dataArea, + ValueAxis domainAxis, ValueAxis rangeAxis, Layer layer, + PlotRenderingInfo info) { + + Iterator iterator = null; + if (layer.equals(Layer.FOREGROUND)) { + iterator = this.foregroundAnnotations.iterator(); + } + else if (layer.equals(Layer.BACKGROUND)) { + iterator = this.backgroundAnnotations.iterator(); + } + else { + // should not get here + throw new RuntimeException("Unknown layer."); + } + while (iterator.hasNext()) { + XYAnnotation annotation = (XYAnnotation) iterator.next(); + int index = this.plot.getIndexOf(this); + annotation.draw(g2, this.plot, dataArea, domainAxis, rangeAxis, + index, info); + } + + } + + /** + * Adds an entity to the collection. + * + * @param entities the entity collection being populated. + * @param area the entity area (if null a default will be + * used). + * @param dataset the dataset. + * @param series the series. + * @param item the item. + * @param entityX the entity's center x-coordinate in user space (only + * used if area is null). + * @param entityY the entity's center y-coordinate in user space (only + * used if area is null). + */ + protected void addEntity(EntityCollection entities, Shape area, + XYDataset dataset, int series, int item, + double entityX, double entityY) { + if (!getItemCreateEntity(series, item)) { + return; + } + Shape hotspot = area; + if (hotspot == null) { + double r = getDefaultEntityRadius(); + double w = r * 2; + if (getPlot().getOrientation() == PlotOrientation.VERTICAL) { + hotspot = new Ellipse2D.Double(entityX - r, entityY - r, w, w); + } + else { + hotspot = new Ellipse2D.Double(entityY - r, entityX - r, w, w); + } + } + String tip = null; + XYToolTipGenerator generator = getToolTipGenerator(series, item); + if (generator != null) { + tip = generator.generateToolTip(dataset, series, item); + } + String url = null; + if (getURLGenerator() != null) { + url = getURLGenerator().generateURL(dataset, series, item); + } + XYItemEntity entity = new XYItemEntity(hotspot, dataset, series, item, + tip, url); + entities.add(entity); + } + + /** + * Returns true if the specified point (x, y) falls within or + * on the boundary of the specified rectangle. + * + * @param rect the rectangle (null not permitted). + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @return A boolean. + * + * @since 1.0.10 + */ + public static boolean isPointInRect(Rectangle2D rect, double x, double y) { + // TODO: For JFreeChart 1.2.0, this method should go in the + // ShapeUtilities class + return (x >= rect.getMinX() && x <= rect.getMaxX() + && y >= rect.getMinY() && y <= rect.getMaxY()); + } + + /** + * Utility method delegating to {@link GeneralPath#moveTo} taking double as + * parameters. + * + * @param hotspot the region under construction (null not + * permitted); + * @param x the x coordinate; + * @param y the y coordinate; + * + * @since 1.0.14 + */ + protected static void moveTo(GeneralPath hotspot, double x, double y) { + hotspot.moveTo((float) x, (float) y); + } + + /** + * Utility method delegating to {@link GeneralPath#lineTo} taking double as + * parameters. + * + * @param hotspot the region under construction (null not + * permitted); + * @param x the x coordinate; + * @param y the y coordinate; + * + * @since 1.0.14 + */ + protected static void lineTo(GeneralPath hotspot, double x, double y) { + hotspot.lineTo((float) x, (float) y); + } + + // === DEPRECATED CODE === + + /** + * The item label generator for ALL series. + * + * @deprecated This field is redundant, use itemLabelGeneratorList and + * baseItemLabelGenerator instead. Deprecated as of version 1.0.6. + */ + private XYItemLabelGenerator itemLabelGenerator; + + /** + * The tool tip generator for ALL series. + * + * @deprecated This field is redundant, use tooltipGeneratorList and + * baseToolTipGenerator instead. Deprecated as of version 1.0.6. + */ + private XYToolTipGenerator toolTipGenerator; + + /** + * Returns the item label generator override. + * + * @return The generator (possibly null). + * + * @since 1.0.5 + * + * @see #setItemLabelGenerator(XYItemLabelGenerator) + * + * @deprecated As of version 1.0.6, this override setting should not be + * used. You can use the base setting instead + * ({@link #getBaseItemLabelGenerator()}). + */ + public XYItemLabelGenerator getItemLabelGenerator() { + return this.itemLabelGenerator; + } + + /** + * Sets the item label generator for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getItemLabelGenerator() + * + * @deprecated As of version 1.0.6, this override setting should not be + * used. You can use the base setting instead + * ({@link #setBaseItemLabelGenerator(XYItemLabelGenerator)}). + */ + @Override + public void setItemLabelGenerator(XYItemLabelGenerator generator) { + this.itemLabelGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the override tool tip generator. + * + * @return The tool tip generator (possible null). + * + * @since 1.0.5 + * + * @see #setToolTipGenerator(XYToolTipGenerator) + * + * @deprecated As of version 1.0.6, this override setting should not be + * used. You can use the base setting instead + * ({@link #getBaseToolTipGenerator()}). + */ + public XYToolTipGenerator getToolTipGenerator() { + return this.toolTipGenerator; + } + + /** + * Sets the tool tip generator for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getToolTipGenerator() + * + * @deprecated As of version 1.0.6, this override setting should not be + * used. You can use the base setting instead + * ({@link #setBaseToolTipGenerator(XYToolTipGenerator)}). + */ + @Override + public void setToolTipGenerator(XYToolTipGenerator generator) { + this.toolTipGenerator = generator; + fireChangeEvent(); + } + + /** + * Considers the current (x, y) coordinate and updates the crosshair point + * if it meets the criteria (usually means the (x, y) coordinate is the + * closest to the anchor point so far). + * + * @param crosshairState the crosshair state (null permitted, + * but the method does nothing in that case). + * @param x the x-value (in data space). + * @param y the y-value (in data space). + * @param transX the x-value translated to Java2D space. + * @param transY the y-value translated to Java2D space. + * @param orientation the plot orientation (null not + * permitted). + * + * @deprecated Use {@link #updateCrosshairValues(CrosshairState, double, + * double, int, int, double, double, PlotOrientation)} -- see bug + * report 1086307. + */ + protected void updateCrosshairValues(CrosshairState crosshairState, + double x, double y, double transX, double transY, + PlotOrientation orientation) { + updateCrosshairValues(crosshairState, x, y, 0, 0, transX, transY, + orientation); + } + + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/CandlestickRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/CandlestickRenderer.java new file mode 100755 index 0000000..bff8fb9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/CandlestickRenderer.java @@ -0,0 +1,977 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * CandlestickRenderer.java + * ------------------------ + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Authors: David Gilbert (for Object Refinery Limited); + * Sylvain Vieujot; + * Contributor(s): Richard Atkinson; + * Christian W. Zuckschwerdt; + * Jerome Fisher; + * + * Changes + * ------- + * 13-Dec-2001 : Version 1. Based on code in the (now redundant) + * CandlestickPlot class, written by Sylvain Vieujot (DG); + * 23-Jan-2002 : Added DrawInfo parameter to drawItem() method (DG); + * 28-Mar-2002 : Added a property change listener mechanism so that renderers + * no longer need to be immutable. Added properties for up and + * down colors (DG); + * 04-Apr-2002 : Updated with new automatic width calculation and optional + * volume display, contributed by Sylvain Vieujot (DG); + * 09-Apr-2002 : Removed translatedRangeZero from the drawItem() method, and + * changed the return type of the drawItem method to void, + * reflecting a change in the XYItemRenderer interface. Added + * tooltip code to drawItem() method (DG); + * 25-Jun-2002 : Removed redundant code (DG); + * 05-Aug-2002 : Small modification to drawItem method to support URLs for HTML + * image maps (RA); + * 19-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Modified drawItem() method signature (DG); + * 30-Jun-2003 : Added support for PlotOrientation (for completeness, this + * renderer is unlikely to be used with a HORIZONTAL + * orientation) (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 29-Aug-2003 : Moved maxVolume calculation to initialise method (see bug + * report 796619) (DG); + * 02-Sep-2003 : Added maxCandleWidthInMilliseconds as workaround for bug + * 796621 (DG); + * 08-Sep-2003 : Changed ValueAxis API (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 13-Oct-2003 : Applied patch from Jerome Fisher to improve auto width + * calculations (DG); + * 23-Dec-2003 : Fixed bug where up and down paint are used incorrectly (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 06-Jul-2006 : Swapped calls to getX() --> getXValue(), and the same for the + * other data values (DG); + * 17-Aug-2006 : Corrections to the equals() method (DG); + * 05-Mar-2007 : Added flag to allow optional use of outline paint (DG); + * 08-Oct-2007 : Added new volumePaint field (DG); + * 08-Apr-2008 : Added findRangeBounds() method override (DG); + * 13-May-2008 : Fixed chart entity bugs (1962467 and 1962472) (DG); + * 27-Mar-2009 : Updated findRangeBounds() to call new method in + * superclass (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.AlphaComposite; +import java.awt.Color; +import java.awt.Composite; +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.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.HighLowItemLabelGenerator; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.OHLCDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A renderer that draws candlesticks on an {@link XYPlot} (requires a + * {@link OHLCDataset}). The example shown here is generated + * by the CandlestickChartDemo1.java program included in the + * JFreeChart demo collection: + *

+ * CandlestickRendererSample.png + *

+ * This renderer does not include code to calculate the crosshair point for the + * plot. + */ +public class CandlestickRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 50390395841817121L; + + /** The average width method. */ + public static final int WIDTHMETHOD_AVERAGE = 0; + + /** The smallest width method. */ + public static final int WIDTHMETHOD_SMALLEST = 1; + + /** The interval data method. */ + public static final int WIDTHMETHOD_INTERVALDATA = 2; + + /** The method of automatically calculating the candle width. */ + private int autoWidthMethod = WIDTHMETHOD_AVERAGE; + + /** + * The number (generally between 0.0 and 1.0) by which the available space + * automatically calculated for the candles will be multiplied to determine + * the actual width to use. + */ + private double autoWidthFactor = 4.5 / 7; + + /** The minimum gap between one candle and the next */ + private double autoWidthGap = 0.0; + + /** The candle width. */ + private double candleWidth; + + /** The maximum candlewidth in milliseconds. */ + private double maxCandleWidthInMilliseconds = 1000.0 * 60.0 * 60.0 * 20.0; + + /** Temporary storage for the maximum candle width. */ + private double maxCandleWidth; + + /** + * The paint used to fill the candle when the price moved up from open to + * close. + */ + private transient Paint upPaint; + + /** + * The paint used to fill the candle when the price moved down from open + * to close. + */ + private transient Paint downPaint; + + /** A flag controlling whether or not volume bars are drawn on the chart. */ + private boolean drawVolume; + + /** + * The paint used to fill the volume bars (if they are visible). Once + * initialised, this field should never be set to null. + * + * @since 1.0.7 + */ + private transient Paint volumePaint; + + /** Temporary storage for the maximum volume. */ + private transient double maxVolume; + + /** + * A flag that controls whether or not the renderer's outline paint is + * used to draw the outline of the candlestick. The default value is + * false to avoid a change of behaviour for existing code. + * + * @since 1.0.5 + */ + private boolean useOutlinePaint; + + /** + * Creates a new renderer for candlestick charts. + */ + public CandlestickRenderer() { + this(-1.0); + } + + /** + * Creates a new renderer for candlestick charts. + *

+ * Use -1 for the candle width if you prefer the width to be calculated + * automatically. + * + * @param candleWidth The candle width. + */ + public CandlestickRenderer(double candleWidth) { + this(candleWidth, true, new HighLowItemLabelGenerator()); + } + + /** + * Creates a new renderer for candlestick charts. + *

+ * Use -1 for the candle width if you prefer the width to be calculated + * automatically. + * + * @param candleWidth the candle width. + * @param drawVolume a flag indicating whether or not volume bars should + * be drawn. + * @param toolTipGenerator the tool tip generator. null is + * none. + */ + public CandlestickRenderer(double candleWidth, boolean drawVolume, + XYToolTipGenerator toolTipGenerator) { + super(); + setBaseToolTipGenerator(toolTipGenerator); + this.candleWidth = candleWidth; + this.drawVolume = drawVolume; + this.volumePaint = Color.gray; + this.upPaint = Color.green; + this.downPaint = Color.red; + this.useOutlinePaint = false; // false preserves the old behaviour + // prior to introducing this flag + } + + /** + * Returns the width of each candle. + * + * @return The candle width. + * + * @see #setCandleWidth(double) + */ + public double getCandleWidth() { + return this.candleWidth; + } + + /** + * Sets the candle width and sends a {@link RendererChangeEvent} to all + * registered listeners. + *

+ * If you set the width to a negative value, the renderer will calculate + * the candle width automatically based on the space available on the chart. + * + * @param width The width. + * @see #setAutoWidthMethod(int) + * @see #setAutoWidthGap(double) + * @see #setAutoWidthFactor(double) + * @see #setMaxCandleWidthInMilliseconds(double) + */ + public void setCandleWidth(double width) { + if (width != this.candleWidth) { + this.candleWidth = width; + fireChangeEvent(); + } + } + + /** + * Returns the maximum width (in milliseconds) of each candle. + * + * @return The maximum candle width in milliseconds. + * + * @see #setMaxCandleWidthInMilliseconds(double) + */ + public double getMaxCandleWidthInMilliseconds() { + return this.maxCandleWidthInMilliseconds; + } + + /** + * Sets the maximum candle width (in milliseconds) and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param millis The maximum width. + * + * @see #getMaxCandleWidthInMilliseconds() + * @see #setCandleWidth(double) + * @see #setAutoWidthMethod(int) + * @see #setAutoWidthGap(double) + * @see #setAutoWidthFactor(double) + */ + public void setMaxCandleWidthInMilliseconds(double millis) { + this.maxCandleWidthInMilliseconds = millis; + fireChangeEvent(); + } + + /** + * Returns the method of automatically calculating the candle width. + * + * @return The method of automatically calculating the candle width. + * + * @see #setAutoWidthMethod(int) + */ + public int getAutoWidthMethod() { + return this.autoWidthMethod; + } + + /** + * Sets the method of automatically calculating the candle width and + * sends a {@link RendererChangeEvent} to all registered listeners. + *

+ * WIDTHMETHOD_AVERAGE: Divides the entire display (ignoring + * scale factor) by the number of items, and uses this as the available + * width.
+ * WIDTHMETHOD_SMALLEST: Checks the interval between each + * item, and uses the smallest as the available width.
+ * WIDTHMETHOD_INTERVALDATA: Assumes that the dataset supports + * the IntervalXYDataset interface, and uses the startXValue - endXValue as + * the available width. + *
+ * + * @param autoWidthMethod The method of automatically calculating the + * candle width. + * + * @see #WIDTHMETHOD_AVERAGE + * @see #WIDTHMETHOD_SMALLEST + * @see #WIDTHMETHOD_INTERVALDATA + * @see #getAutoWidthMethod() + * @see #setCandleWidth(double) + * @see #setAutoWidthGap(double) + * @see #setAutoWidthFactor(double) + * @see #setMaxCandleWidthInMilliseconds(double) + */ + public void setAutoWidthMethod(int autoWidthMethod) { + if (this.autoWidthMethod != autoWidthMethod) { + this.autoWidthMethod = autoWidthMethod; + fireChangeEvent(); + } + } + + /** + * Returns the factor by which the available space automatically + * calculated for the candles will be multiplied to determine the actual + * width to use. + * + * @return The width factor (generally between 0.0 and 1.0). + * + * @see #setAutoWidthFactor(double) + */ + public double getAutoWidthFactor() { + return this.autoWidthFactor; + } + + /** + * Sets the factor by which the available space automatically calculated + * for the candles will be multiplied to determine the actual width to use. + * + * @param autoWidthFactor The width factor (generally between 0.0 and 1.0). + * + * @see #getAutoWidthFactor() + * @see #setCandleWidth(double) + * @see #setAutoWidthMethod(int) + * @see #setAutoWidthGap(double) + * @see #setMaxCandleWidthInMilliseconds(double) + */ + public void setAutoWidthFactor(double autoWidthFactor) { + if (this.autoWidthFactor != autoWidthFactor) { + this.autoWidthFactor = autoWidthFactor; + fireChangeEvent(); + } + } + + /** + * Returns the amount of space to leave on the left and right of each + * candle when automatically calculating widths. + * + * @return The gap. + * + * @see #setAutoWidthGap(double) + */ + public double getAutoWidthGap() { + return this.autoWidthGap; + } + + /** + * Sets the amount of space to leave on the left and right of each candle + * when automatically calculating widths and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param autoWidthGap The gap. + * + * @see #getAutoWidthGap() + * @see #setCandleWidth(double) + * @see #setAutoWidthMethod(int) + * @see #setAutoWidthFactor(double) + * @see #setMaxCandleWidthInMilliseconds(double) + */ + public void setAutoWidthGap(double autoWidthGap) { + if (this.autoWidthGap != autoWidthGap) { + this.autoWidthGap = autoWidthGap; + fireChangeEvent(); + } + } + + /** + * Returns the paint used to fill candles when the price moves up from open + * to close. + * + * @return The paint (possibly null). + * + * @see #setUpPaint(Paint) + */ + public Paint getUpPaint() { + return this.upPaint; + } + + /** + * Sets the paint used to fill candles when the price moves up from open + * to close and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param paint the paint (null permitted). + * + * @see #getUpPaint() + */ + public void setUpPaint(Paint paint) { + this.upPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint used to fill candles when the price moves down from + * open to close. + * + * @return The paint (possibly null). + * + * @see #setDownPaint(Paint) + */ + public Paint getDownPaint() { + return this.downPaint; + } + + /** + * Sets the paint used to fill candles when the price moves down from open + * to close and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param paint The paint (null permitted). + */ + public void setDownPaint(Paint paint) { + this.downPaint = paint; + fireChangeEvent(); + } + + /** + * Returns a flag indicating whether or not volume bars are drawn on the + * chart. + * + * @return A boolean. + * + * @since 1.0.5 + * + * @see #setDrawVolume(boolean) + */ + public boolean getDrawVolume() { + return this.drawVolume; + } + + /** + * Sets a flag that controls whether or not volume bars are drawn in the + * background and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param flag the flag. + * + * @see #getDrawVolume() + */ + public void setDrawVolume(boolean flag) { + if (this.drawVolume != flag) { + this.drawVolume = flag; + fireChangeEvent(); + } + } + + /** + * Returns the paint that is used to fill the volume bars if they are + * visible. + * + * @return The paint (never null). + * + * @see #setVolumePaint(Paint) + * + * @since 1.0.7 + */ + public Paint getVolumePaint() { + return this.volumePaint; + } + + /** + * Sets the paint used to fill the volume bars, and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getVolumePaint() + * @see #getDrawVolume() + * + * @since 1.0.7 + */ + public void setVolumePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.volumePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not the renderer's outline + * paint is used to draw the candlestick outline. The default value is + * false. + * + * @return A boolean. + * + * @since 1.0.5 + * + * @see #setUseOutlinePaint(boolean) + */ + public boolean getUseOutlinePaint() { + return this.useOutlinePaint; + } + + /** + * Sets the flag that controls whether or not the renderer's outline + * paint is used to draw the candlestick outline, and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param use the new flag value. + * + * @since 1.0.5 + * + * @see #getUseOutlinePaint() + */ + public void setUseOutlinePaint(boolean use) { + if (this.useOutlinePaint != use) { + this.useOutlinePaint = use; + fireChangeEvent(); + } + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + */ + @Override + public Range findRangeBounds(XYDataset dataset) { + return findRangeBounds(dataset, true); + } + + /** + * Initialises the renderer then returns the number of 'passes' through the + * data that the renderer will require (usually just one). This method + * will be called before the first item is rendered, giving the renderer + * an opportunity to initialise any state information it wants to maintain. + * The renderer can do nothing if it chooses. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param dataset the data. + * @param info an optional info collection object to return data back to + * the caller. + * + * @return The number of passes the renderer requires. + */ + @Override + public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, + XYPlot plot, XYDataset dataset, PlotRenderingInfo info) { + + // calculate the maximum allowed candle width from the axis... + ValueAxis axis = plot.getDomainAxis(); + double x1 = axis.getLowerBound(); + double x2 = x1 + this.maxCandleWidthInMilliseconds; + RectangleEdge edge = plot.getDomainAxisEdge(); + double xx1 = axis.valueToJava2D(x1, dataArea, edge); + double xx2 = axis.valueToJava2D(x2, dataArea, edge); + this.maxCandleWidth = Math.abs(xx2 - xx1); + // Absolute value, since the relative x + // positions are reversed for horizontal orientation + + // calculate the highest volume in the dataset... + if (this.drawVolume) { + OHLCDataset highLowDataset = (OHLCDataset) dataset; + this.maxVolume = 0.0; + for (int series = 0; series < highLowDataset.getSeriesCount(); + series++) { + for (int item = 0; item < highLowDataset.getItemCount(series); + item++) { + double volume = highLowDataset.getVolumeValue(series, item); + if (volume > this.maxVolume) { + this.maxVolume = volume; + } + + } + } + } + + return new XYItemRendererState(info); + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the plot is being drawn. + * @param info collects info about the drawing. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + boolean horiz; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + horiz = true; + } + else if (orientation == PlotOrientation.VERTICAL) { + horiz = false; + } + else { + return; + } + + // setup for collecting optional entity info... + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + } + + OHLCDataset highLowData = (OHLCDataset) dataset; + + double x = highLowData.getXValue(series, item); + double yHigh = highLowData.getHighValue(series, item); + double yLow = highLowData.getLowValue(series, item); + double yOpen = highLowData.getOpenValue(series, item); + double yClose = highLowData.getCloseValue(series, item); + + RectangleEdge domainEdge = plot.getDomainAxisEdge(); + double xx = domainAxis.valueToJava2D(x, dataArea, domainEdge); + + RectangleEdge edge = plot.getRangeAxisEdge(); + double yyHigh = rangeAxis.valueToJava2D(yHigh, dataArea, edge); + double yyLow = rangeAxis.valueToJava2D(yLow, dataArea, edge); + double yyOpen = rangeAxis.valueToJava2D(yOpen, dataArea, edge); + double yyClose = rangeAxis.valueToJava2D(yClose, dataArea, edge); + + double volumeWidth; + double stickWidth; + if (this.candleWidth > 0) { + // These are deliberately not bounded to minimums/maxCandleWidth to + // retain old behaviour. + volumeWidth = this.candleWidth; + stickWidth = this.candleWidth; + } + else { + double xxWidth = 0; + int itemCount; + switch (this.autoWidthMethod) { + + case WIDTHMETHOD_AVERAGE: + itemCount = highLowData.getItemCount(series); + if (horiz) { + xxWidth = dataArea.getHeight() / itemCount; + } + else { + xxWidth = dataArea.getWidth() / itemCount; + } + break; + + case WIDTHMETHOD_SMALLEST: + // Note: It would be nice to pre-calculate this per series + itemCount = highLowData.getItemCount(series); + double lastPos = -1; + xxWidth = dataArea.getWidth(); + for (int i = 0; i < itemCount; i++) { + double pos = domainAxis.valueToJava2D( + highLowData.getXValue(series, i), dataArea, + domainEdge); + if (lastPos != -1) { + xxWidth = Math.min(xxWidth, + Math.abs(pos - lastPos)); + } + lastPos = pos; + } + break; + + case WIDTHMETHOD_INTERVALDATA: + IntervalXYDataset intervalXYData + = (IntervalXYDataset) dataset; + double startPos = domainAxis.valueToJava2D( + intervalXYData.getStartXValue(series, item), + dataArea, plot.getDomainAxisEdge()); + double endPos = domainAxis.valueToJava2D( + intervalXYData.getEndXValue(series, item), + dataArea, plot.getDomainAxisEdge()); + xxWidth = Math.abs(endPos - startPos); + break; + + } + xxWidth -= 2 * this.autoWidthGap; + xxWidth *= this.autoWidthFactor; + xxWidth = Math.min(xxWidth, this.maxCandleWidth); + volumeWidth = Math.max(Math.min(1, this.maxCandleWidth), xxWidth); + stickWidth = Math.max(Math.min(3, this.maxCandleWidth), xxWidth); + } + + Paint p = getItemPaint(series, item); + Paint outlinePaint = null; + if (this.useOutlinePaint) { + outlinePaint = getItemOutlinePaint(series, item); + } + Stroke s = getItemStroke(series, item); + + g2.setStroke(s); + + if (this.drawVolume) { + int volume = (int) highLowData.getVolumeValue(series, item); + double volumeHeight = volume / this.maxVolume; + + double min, max; + if (horiz) { + min = dataArea.getMinX(); + max = dataArea.getMaxX(); + } + else { + min = dataArea.getMinY(); + max = dataArea.getMaxY(); + } + + double zzVolume = volumeHeight * (max - min); + + g2.setPaint(getVolumePaint()); + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance( + AlphaComposite.SRC_OVER, 0.3f)); + + if (horiz) { + g2.fill(new Rectangle2D.Double(min, xx - volumeWidth / 2, + zzVolume, volumeWidth)); + } + else { + g2.fill(new Rectangle2D.Double(xx - volumeWidth / 2, + max - zzVolume, volumeWidth, zzVolume)); + } + + g2.setComposite(originalComposite); + } + + if (this.useOutlinePaint) { + g2.setPaint(outlinePaint); + } + else { + g2.setPaint(p); + } + + double yyMaxOpenClose = Math.max(yyOpen, yyClose); + double yyMinOpenClose = Math.min(yyOpen, yyClose); + double maxOpenClose = Math.max(yOpen, yClose); + double minOpenClose = Math.min(yOpen, yClose); + + // draw the upper shadow + if (yHigh > maxOpenClose) { + if (horiz) { + g2.draw(new Line2D.Double(yyHigh, xx, yyMaxOpenClose, xx)); + } + else { + g2.draw(new Line2D.Double(xx, yyHigh, xx, yyMaxOpenClose)); + } + } + + // draw the lower shadow + if (yLow < minOpenClose) { + if (horiz) { + g2.draw(new Line2D.Double(yyLow, xx, yyMinOpenClose, xx)); + } + else { + g2.draw(new Line2D.Double(xx, yyLow, xx, yyMinOpenClose)); + } + } + + // draw the body + Rectangle2D body; + Rectangle2D hotspot; + double length = Math.abs(yyHigh - yyLow); + double base = Math.min(yyHigh, yyLow); + if (horiz) { + body = new Rectangle2D.Double(yyMinOpenClose, xx - stickWidth / 2, + yyMaxOpenClose - yyMinOpenClose, stickWidth); + hotspot = new Rectangle2D.Double(base, xx - stickWidth / 2, + length, stickWidth); + } + else { + body = new Rectangle2D.Double(xx - stickWidth / 2, yyMinOpenClose, + stickWidth, yyMaxOpenClose - yyMinOpenClose); + hotspot = new Rectangle2D.Double(xx - stickWidth / 2, + base, stickWidth, length); + } + if (yClose > yOpen) { + if (this.upPaint != null) { + g2.setPaint(this.upPaint); + } + else { + g2.setPaint(p); + } + g2.fill(body); + } + else { + if (this.downPaint != null) { + g2.setPaint(this.downPaint); + } + else { + g2.setPaint(p); + } + g2.fill(body); + } + if (this.useOutlinePaint) { + g2.setPaint(outlinePaint); + } + else { + g2.setPaint(p); + } + g2.draw(body); + + // add an entity for the item... + if (entities != null) { + addEntity(entities, hotspot, dataset, series, item, 0.0, 0.0); + } + + } + + /** + * Tests this renderer for equality with another object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CandlestickRenderer)) { + return false; + } + CandlestickRenderer that = (CandlestickRenderer) obj; + if (this.candleWidth != that.candleWidth) { + return false; + } + if (!PaintUtilities.equal(this.upPaint, that.upPaint)) { + return false; + } + if (!PaintUtilities.equal(this.downPaint, that.downPaint)) { + return false; + } + if (this.drawVolume != that.drawVolume) { + return false; + } + if (this.maxCandleWidthInMilliseconds + != that.maxCandleWidthInMilliseconds) { + return false; + } + if (this.autoWidthMethod != that.autoWidthMethod) { + return false; + } + if (this.autoWidthFactor != that.autoWidthFactor) { + return false; + } + if (this.autoWidthGap != that.autoWidthGap) { + return false; + } + if (this.useOutlinePaint != that.useOutlinePaint) { + return false; + } + if (!PaintUtilities.equal(this.volumePaint, that.volumePaint)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + 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.upPaint, stream); + SerialUtilities.writePaint(this.downPaint, stream); + SerialUtilities.writePaint(this.volumePaint, 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.upPaint = SerialUtilities.readPaint(stream); + this.downPaint = SerialUtilities.readPaint(stream); + this.volumePaint = SerialUtilities.readPaint(stream); + } + + // --- DEPRECATED CODE ---------------------------------------------------- + + /** + * Returns a flag indicating whether or not volume bars are drawn on the + * chart. + * + * @return true if volume bars are drawn on the chart. + * + * @deprecated As of 1.0.5, you should use the {@link #getDrawVolume()} + * method. + */ + public boolean drawVolume() { + return this.drawVolume; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/ClusteredXYBarRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/ClusteredXYBarRenderer.java new file mode 100755 index 0000000..b50f45d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/ClusteredXYBarRenderer.java @@ -0,0 +1,381 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * ClusteredXYBarRenderer.java + * --------------------------- + * (C) Copyright 2003-2013, by Paolo Cova and Contributors. + * + * Original Author: Paolo Cova; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Christian W. Zuckschwerdt; + * Matthias Rose; + * + * Changes + * ------- + * 24-Jan-2003 : Version 1, contributed by Paolo Cova (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Modified drawItem() method signature (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 07-Oct-2003 : Added renderer state (DG); + * 03-Nov-2003 : In draw method added state parameter and y==null value + * handling (MR); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 01-Oct-2004 : Fixed bug where 'drawBarOutline' flag is ignored (DG); + * 16-May-2005 : Fixed to used outline stroke for bar outlines. Removed some + * redundant code with the result that the renderer now respects + * the 'base' setting from the super-class. Added an equals() + * method (DG); + * 19-May-2005 : Added minimal item label implementation - needs improving (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 11-Dec-2006 : Added support for GradientPaint (DG); + * 12-Jun-2007 : Added override to findDomainBounds() to handle cluster offset, + * fixed rendering to handle inverted axes, and simplified + * entity generation code (DG); + * 24-Jun-2008 : Added new barPainter mechanism (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.labels.XYItemLabelGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PublicCloneable; + +/** + * An extension of {@link XYBarRenderer} that displays bars for different + * series values at the same x next to each other. The assumption here is + * that for each x (time or else) there is a y value for each series. If + * this is not the case, there will be spaces between bars for a given x. + * The example shown here is generated by the + * ClusteredXYBarRendererDemo1.java program included in the + * JFreeChart demo collection: + *

+ * ClusteredXYBarRendererSample.png + *

+ * This renderer does not include code to calculate the crosshair point for the + * plot. + */ +public class ClusteredXYBarRenderer extends XYBarRenderer + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 5864462149177133147L; + + /** Determines whether bar center should be interval start. */ + private boolean centerBarAtStartValue; + + /** + * Default constructor. Bar margin is set to 0.0. + */ + public ClusteredXYBarRenderer() { + this(0.0, false); + } + + /** + * Constructs a new XY clustered bar renderer. + * + * @param margin the percentage amount to trim from the width of each bar. + * @param centerBarAtStartValue if true, bars will be centered on the + * start of the time period. + */ + public ClusteredXYBarRenderer(double margin, + boolean centerBarAtStartValue) { + super(margin); + this.centerBarAtStartValue = centerBarAtStartValue; + } + + /** + * Returns the number of passes through the dataset that this renderer + * requires. In this case, two passes are required, the first for drawing + * the shadows (if visible), and the second for drawing the bars. + * + * @return 2. + */ + @Override + public int getPassCount() { + return 2; + } + + /** + * Returns the x-value bounds for the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The bounds (possibly null). + */ + @Override + public Range findDomainBounds(XYDataset dataset) { + if (dataset == null) { + return null; + } + // need to handle cluster centering as a special case + if (this.centerBarAtStartValue) { + return findDomainBoundsWithOffset((IntervalXYDataset) dataset); + } + else { + return super.findDomainBounds(dataset); + } + } + + /** + * Iterates over the items in an {@link IntervalXYDataset} to find + * the range of x-values including the interval OFFSET so that it centers + * the interval around the start value. + * + * @param dataset the dataset (null not permitted). + * + * @return The range (possibly null). + */ + protected Range findDomainBoundsWithOffset(IntervalXYDataset dataset) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + double minimum = Double.POSITIVE_INFINITY; + double maximum = Double.NEGATIVE_INFINITY; + int seriesCount = dataset.getSeriesCount(); + double lvalue; + double uvalue; + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + lvalue = dataset.getStartXValue(series, item); + uvalue = dataset.getEndXValue(series, item); + double offset = (uvalue - lvalue) / 2.0; + lvalue = lvalue - offset; + uvalue = uvalue - offset; + minimum = Math.min(minimum, lvalue); + maximum = Math.max(maximum, uvalue); + } + } + + if (minimum > maximum) { + return null; + } + else { + return new Range(minimum, maximum); + } + } + + /** + * Draws the visual representation of a single data item. This method + * is mostly copied from the superclass, the change is that in the + * calculated space for a singe bar we draw bars for each series next to + * each other. The width of each bar is the available width divided by + * the number of series. Bars for each series are drawn in order left to + * right. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the plot is being drawn. + * @param info collects information about the drawing. + * @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 series the series index. + * @param item the item index. + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset; + + double y0; + double y1; + if (getUseYInterval()) { + y0 = intervalDataset.getStartYValue(series, item); + y1 = intervalDataset.getEndYValue(series, item); + } + else { + y0 = getBase(); + y1 = intervalDataset.getYValue(series, item); + } + if (Double.isNaN(y0) || Double.isNaN(y1)) { + return; + } + + double yy0 = rangeAxis.valueToJava2D(y0, dataArea, + plot.getRangeAxisEdge()); + double yy1 = rangeAxis.valueToJava2D(y1, dataArea, + plot.getRangeAxisEdge()); + + RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); + double x0 = intervalDataset.getStartXValue(series, item); + double xx0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation); + + double x1 = intervalDataset.getEndXValue(series, item); + double xx1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); + + double intervalW = xx1 - xx0; // this may be negative + double baseX = xx0; + if (this.centerBarAtStartValue) { + baseX = baseX - intervalW / 2.0; + } + double m = getMargin(); + if (m > 0.0) { + double cut = intervalW * getMargin(); + intervalW = intervalW - cut; + baseX = baseX + (cut / 2); + } + + double intervalH = Math.abs(yy0 - yy1); // we don't need the sign + + PlotOrientation orientation = plot.getOrientation(); + + int numSeries = dataset.getSeriesCount(); + double seriesBarWidth = intervalW / numSeries; // may be negative + + Rectangle2D bar = null; + if (orientation == PlotOrientation.HORIZONTAL) { + double barY0 = baseX + (seriesBarWidth * series); + double barY1 = barY0 + seriesBarWidth; + double rx = Math.min(yy0, yy1); + double rw = intervalH; + double ry = Math.min(barY0, barY1); + double rh = Math.abs(barY1 - barY0); + bar = new Rectangle2D.Double(rx, ry, rw, rh); + } + else if (orientation == PlotOrientation.VERTICAL) { + double barX0 = baseX + (seriesBarWidth * series); + double barX1 = barX0 + seriesBarWidth; + double rx = Math.min(barX0, barX1); + double rw = Math.abs(barX1 - barX0); + double ry = Math.min(yy0, yy1); + double rh = intervalH; + bar = new Rectangle2D.Double(rx, ry, rw, rh); + } else { + throw new IllegalStateException(); + } + boolean positive = (y1 > 0.0); + boolean inverted = rangeAxis.isInverted(); + RectangleEdge barBase; + if (orientation == PlotOrientation.HORIZONTAL) { + if (positive && inverted || !positive && !inverted) { + barBase = RectangleEdge.RIGHT; + } + else { + barBase = RectangleEdge.LEFT; + } + } + else { + if (positive && !inverted || !positive && inverted) { + barBase = RectangleEdge.BOTTOM; + } + else { + barBase = RectangleEdge.TOP; + } + } + if (pass == 0 && getShadowsVisible()) { + getBarPainter().paintBarShadow(g2, this, series, item, bar, barBase, + !getUseYInterval()); + } + if (pass == 1) { + getBarPainter().paintBar(g2, this, series, item, bar, barBase); + + if (isItemLabelVisible(series, item)) { + XYItemLabelGenerator generator = getItemLabelGenerator(series, + item); + drawItemLabel(g2, dataset, series, item, plot, generator, bar, + y1 < 0.0); + } + + // add an entity for the item... + if (info != null) { + EntityCollection entities + = info.getOwner().getEntityCollection(); + if (entities != null) { + addEntity(entities, bar, dataset, series, item, + bar.getCenterX(), bar.getCenterY()); + } + } + } + + } + + /** + * Tests this renderer for equality with an arbitrary object, returning + * true if obj is a + * ClusteredXYBarRenderer with the same settings as this + * renderer, and false otherwise. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ClusteredXYBarRenderer)) { + return false; + } + ClusteredXYBarRenderer that = (ClusteredXYBarRenderer) obj; + if (this.centerBarAtStartValue != that.centerBarAtStartValue) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/CyclicXYItemRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/CyclicXYItemRenderer.java new file mode 100755 index 0000000..dcb7cdb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/CyclicXYItemRenderer.java @@ -0,0 +1,513 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * CyclicXYItemRenderer.java + * --------------------------- + * (C) Copyright 2003-2008, by Nicolas Brodu and Contributors. + * + * Original Author: Nicolas Brodu; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 19-Nov-2003 : Initial import to JFreeChart from the JSynoptic project (NB); + * 23-Dec-2003 : Added missing Javadocs (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * ------------- JFREECHART 1.0.0 --------------------------------------------- + * 06-Jul-2006 : Modified to call only dataset methods that return double + * primitives (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.axis.CyclicNumberAxis; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.data.DomainOrder; +import org.jfree.data.general.DatasetChangeListener; +import org.jfree.data.general.DatasetGroup; +import org.jfree.data.xy.XYDataset; + +/** + * The Cyclic XY item renderer is specially designed to handle cyclic axis. + * While the standard renderer would draw a line across the plot when a cycling + * occurs, the cyclic renderer splits the line at each cycle end instead. This + * is done by interpolating new points at cycle boundary. Thus, correct + * appearance is restored. + * + * The Cyclic XY item renderer works exactly like a standard XY item renderer + * with non-cyclic axis. + */ +public class CyclicXYItemRenderer extends StandardXYItemRenderer + implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 4035912243303764892L; + + /** + * Default constructor. + */ + public CyclicXYItemRenderer() { + super(); + } + + /** + * Creates a new renderer. + * + * @param type the renderer type. + */ + public CyclicXYItemRenderer(int type) { + super(type); + } + + /** + * Creates a new renderer. + * + * @param type the renderer type. + * @param labelGenerator the tooltip generator. + */ + public CyclicXYItemRenderer(int type, XYToolTipGenerator labelGenerator) { + super(type, labelGenerator); + } + + /** + * Creates a new renderer. + * + * @param type the renderer type. + * @param labelGenerator the tooltip generator. + * @param urlGenerator the url generator. + */ + public CyclicXYItemRenderer(int type, + XYToolTipGenerator labelGenerator, + XYURLGenerator urlGenerator) { + super(type, labelGenerator, urlGenerator); + } + + + /** + * Draws the visual representation of a single data item. + * When using cyclic axis, do not draw a line from right to left when + * cycling as would a standard XY item renderer, but instead draw a line + * from the previous point to the cycle bound in the last cycle, and a line + * from the cycle bound to current point in the current cycle. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the data area. + * @param info the plot rendering info. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param series the series index. + * @param item the item index. + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the current pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + if ((!getPlotLines()) || ((!(domainAxis instanceof CyclicNumberAxis)) + && (!(rangeAxis instanceof CyclicNumberAxis))) || (item <= 0)) { + super.drawItem(g2, state, dataArea, info, plot, domainAxis, + rangeAxis, dataset, series, item, crosshairState, pass); + return; + } + + // get the previous data point... + double xn = dataset.getXValue(series, item - 1); + double yn = dataset.getYValue(series, item - 1); + // If null, don't draw line => then delegate to parent + if (Double.isNaN(yn)) { + super.drawItem(g2, state, dataArea, info, plot, domainAxis, + rangeAxis, dataset, series, item, crosshairState, pass); + return; + } + double[] x = new double[2]; + double[] y = new double[2]; + x[0] = xn; + y[0] = yn; + + // get the data point... + xn = dataset.getXValue(series, item); + yn = dataset.getYValue(series, item); + // If null, don't draw line at all + if (Double.isNaN(yn)) { + return; + } + x[1] = xn; + y[1] = yn; + + // Now split the segment as needed + double xcycleBound = Double.NaN; + double ycycleBound = Double.NaN; + boolean xBoundMapping = false, yBoundMapping = false; + CyclicNumberAxis cnax = null, cnay = null; + + if (domainAxis instanceof CyclicNumberAxis) { + cnax = (CyclicNumberAxis) domainAxis; + xcycleBound = cnax.getCycleBound(); + xBoundMapping = cnax.isBoundMappedToLastCycle(); + // If the segment must be splitted, insert a new point + // Strict test forces to have real segments (not 2 equal points) + // and avoids division by 0 + if ((x[0] != x[1]) + && ((xcycleBound >= x[0]) + && (xcycleBound <= x[1]) + || (xcycleBound >= x[1]) + && (xcycleBound <= x[0]))) { + double[] nx = new double[3]; + double[] ny = new double[3]; + nx[0] = x[0]; nx[2] = x[1]; ny[0] = y[0]; ny[2] = y[1]; + nx[1] = xcycleBound; + ny[1] = (y[1] - y[0]) * (xcycleBound - x[0]) + / (x[1] - x[0]) + y[0]; + x = nx; y = ny; + } + } + + if (rangeAxis instanceof CyclicNumberAxis) { + cnay = (CyclicNumberAxis) rangeAxis; + ycycleBound = cnay.getCycleBound(); + yBoundMapping = cnay.isBoundMappedToLastCycle(); + // The split may occur in either x splitted segments, if any, but + // not in both + if ((y[0] != y[1]) && ((ycycleBound >= y[0]) + && (ycycleBound <= y[1]) + || (ycycleBound >= y[1]) && (ycycleBound <= y[0]))) { + double[] nx = new double[x.length + 1]; + double[] ny = new double[y.length + 1]; + nx[0] = x[0]; nx[2] = x[1]; ny[0] = y[0]; ny[2] = y[1]; + ny[1] = ycycleBound; + nx[1] = (x[1] - x[0]) * (ycycleBound - y[0]) + / (y[1] - y[0]) + x[0]; + if (x.length == 3) { + nx[3] = x[2]; ny[3] = y[2]; + } + x = nx; y = ny; + } + else if ((x.length == 3) && (y[1] != y[2]) && ((ycycleBound >= y[1]) + && (ycycleBound <= y[2]) + || (ycycleBound >= y[2]) && (ycycleBound <= y[1]))) { + double[] nx = new double[4]; + double[] ny = new double[4]; + nx[0] = x[0]; nx[1] = x[1]; nx[3] = x[2]; + ny[0] = y[0]; ny[1] = y[1]; ny[3] = y[2]; + ny[2] = ycycleBound; + nx[2] = (x[2] - x[1]) * (ycycleBound - y[1]) + / (y[2] - y[1]) + x[1]; + x = nx; y = ny; + } + } + + // If the line is not wrapping, then parent is OK + if (x.length == 2) { + super.drawItem(g2, state, dataArea, info, plot, domainAxis, + rangeAxis, dataset, series, item, crosshairState, pass); + return; + } + + OverwriteDataSet newset = new OverwriteDataSet(x, y, dataset); + + if (cnax != null) { + if (xcycleBound == x[0]) { + cnax.setBoundMappedToLastCycle(x[1] <= xcycleBound); + } + if (xcycleBound == x[1]) { + cnax.setBoundMappedToLastCycle(x[0] <= xcycleBound); + } + } + if (cnay != null) { + if (ycycleBound == y[0]) { + cnay.setBoundMappedToLastCycle(y[1] <= ycycleBound); + } + if (ycycleBound == y[1]) { + cnay.setBoundMappedToLastCycle(y[0] <= ycycleBound); + } + } + super.drawItem( + g2, state, dataArea, info, plot, domainAxis, rangeAxis, + newset, series, 1, crosshairState, pass + ); + + if (cnax != null) { + if (xcycleBound == x[1]) { + cnax.setBoundMappedToLastCycle(x[2] <= xcycleBound); + } + if (xcycleBound == x[2]) { + cnax.setBoundMappedToLastCycle(x[1] <= xcycleBound); + } + } + if (cnay != null) { + if (ycycleBound == y[1]) { + cnay.setBoundMappedToLastCycle(y[2] <= ycycleBound); + } + if (ycycleBound == y[2]) { + cnay.setBoundMappedToLastCycle(y[1] <= ycycleBound); + } + } + super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, + newset, series, 2, crosshairState, pass); + + if (x.length == 4) { + if (cnax != null) { + if (xcycleBound == x[2]) { + cnax.setBoundMappedToLastCycle(x[3] <= xcycleBound); + } + if (xcycleBound == x[3]) { + cnax.setBoundMappedToLastCycle(x[2] <= xcycleBound); + } + } + if (cnay != null) { + if (ycycleBound == y[2]) { + cnay.setBoundMappedToLastCycle(y[3] <= ycycleBound); + } + if (ycycleBound == y[3]) { + cnay.setBoundMappedToLastCycle(y[2] <= ycycleBound); + } + } + super.drawItem(g2, state, dataArea, info, plot, domainAxis, + rangeAxis, newset, series, 3, crosshairState, pass); + } + + if (cnax != null) { + cnax.setBoundMappedToLastCycle(xBoundMapping); + } + if (cnay != null) { + cnay.setBoundMappedToLastCycle(yBoundMapping); + } + } + + /** + * A dataset to hold the interpolated points when drawing new lines. + */ + protected static class OverwriteDataSet implements XYDataset { + + /** The delegate dataset. */ + protected XYDataset delegateSet; + + /** Storage for the x and y values. */ + Double[] x, y; + + /** + * Creates a new dataset. + * + * @param x the x values. + * @param y the y values. + * @param delegateSet the dataset. + */ + public OverwriteDataSet(double [] x, double[] y, + XYDataset delegateSet) { + this.delegateSet = delegateSet; + this.x = new Double[x.length]; this.y = new Double[y.length]; + for (int i = 0; i < x.length; ++i) { + this.x[i] = new Double(x[i]); + this.y[i] = new Double(y[i]); + } + } + + /** + * Returns the order of the domain (X) values. + * + * @return The domain order. + */ + @Override + public DomainOrder getDomainOrder() { + return DomainOrder.NONE; + } + + /** + * Returns the number of items for the given series. + * + * @param series the series index (zero-based). + * + * @return The item count. + */ + @Override + public int getItemCount(int series) { + return this.x.length; + } + + /** + * Returns the x-value. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The x-value. + */ + @Override + public Number getX(int series, int item) { + return this.x[item]; + } + + /** + * Returns the x-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The x-value. + */ + @Override + public double getXValue(int series, int item) { + double result = Double.NaN; + Number xx = getX(series, item); + if (xx != null) { + result = xx.doubleValue(); + } + return result; + } + + /** + * Returns the y-value. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The y-value. + */ + @Override + public Number getY(int series, int item) { + return this.y[item]; + } + + /** + * Returns the y-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The y-value. + */ + @Override + public double getYValue(int series, int item) { + double result = Double.NaN; + Number yy = getY(series, item); + if (yy != null) { + result = yy.doubleValue(); + } + return result; + } + + /** + * Returns the number of series in the dataset. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.delegateSet.getSeriesCount(); + } + + /** + * Returns the name of the given series. + * + * @param series the series index (zero-based). + * + * @return The series name. + */ + @Override + public Comparable getSeriesKey(int series) { + return this.delegateSet.getSeriesKey(series); + } + + /** + * Returns the index of the named series, or -1. + * + * @param seriesName the series name. + * + * @return The index. + */ + @Override + public int indexOf(Comparable seriesName) { + return this.delegateSet.indexOf(seriesName); + } + + /** + * Does nothing. + * + * @param listener ignored. + */ + @Override + public void addChangeListener(DatasetChangeListener listener) { + // unused in parent + } + + /** + * Does nothing. + * + * @param listener ignored. + */ + @Override + public void removeChangeListener(DatasetChangeListener listener) { + // unused in parent + } + + /** + * Returns the dataset group. + * + * @return The dataset group. + */ + @Override + public DatasetGroup getGroup() { + // unused but must return something, so while we are at it... + return this.delegateSet.getGroup(); + } + + /** + * Does nothing. + * + * @param group ignored. + */ + @Override + public void setGroup(DatasetGroup group) { + // unused in parent + } + + } + +} + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/DefaultXYItemRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/DefaultXYItemRenderer.java new file mode 100755 index 0000000..5588856 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/DefaultXYItemRenderer.java @@ -0,0 +1,58 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * DefaultXYItemRenderer.java + * -------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Jul-2003 : Version 1 (DG); + * 22-Feb-2005 : Now extends XYLineAndShapeRenderer (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.io.Serializable; + +/** + * A default renderer for the {@link org.jfree.chart.plot.XYPlot} class. This + * is an alias for the {@link XYLineAndShapeRenderer} class. + */ +public class DefaultXYItemRenderer extends XYLineAndShapeRenderer + implements Serializable { + + /** For serialization. */ + static final long serialVersionUID = 3450423530996888074L; + + // no new methods + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/DeviationRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/DeviationRenderer.java new file mode 100755 index 0000000..e619f65 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/DeviationRenderer.java @@ -0,0 +1,390 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * DeviationRenderer.java + * ---------------------- + * (C) Copyright 2007-2012, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Feb-2007 : Version 1 (DG); + * 04-May-2007 : Set processVisibleItemsOnly flag to false (DG); + * 11-Apr-2008 : New override for findRangeBounds() (DG); + * 27-Mar-2009 : Updated findRangeBounds() to call new inherited method (DG); + * 01-Jul-2012 : Provide initial size for GeneralPath in drawItem(), as + * suggested by Milan Ramaiya in bug 3521736 (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.AlphaComposite; +import java.awt.Composite; +import java.awt.Graphics2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Rectangle2D; +import java.util.List; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.Range; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.ui.RectangleEdge; + +/** + * A specialised subclass of the {@link XYLineAndShapeRenderer} that requires + * an {@link IntervalXYDataset} and represents the y-interval by shading an + * area behind the y-values on the chart. + * The example shown here is generated by the + * DeviationRendererDemo1.java program included in the + * JFreeChart demo collection: + *

+ * DeviationRendererSample.png + * + * @since 1.0.5 + */ +public class DeviationRenderer extends XYLineAndShapeRenderer { + + /** + * A state object that is passed to each call to drawItem. + */ + public static class State extends XYLineAndShapeRenderer.State { + + /** + * A list of coordinates for the upper y-values in the current series + * (after translation into Java2D space). + */ + public List upperCoordinates; + + /** + * A list of coordinates for the lower y-values in the current series + * (after translation into Java2D space). + */ + public List lowerCoordinates; + + /** + * Creates a new state instance. + * + * @param info the plot rendering info. + */ + public State(PlotRenderingInfo info) { + super(info); + this.lowerCoordinates = new java.util.ArrayList(); + this.upperCoordinates = new java.util.ArrayList(); + } + + } + + /** The alpha transparency for the interval shading. */ + private float alpha; + + /** + * Creates a new renderer that displays lines and shapes for the data + * items, as well as the shaded area for the y-interval. + */ + public DeviationRenderer() { + this(true, true); + } + + /** + * Creates a new renderer. + * + * @param lines show lines between data items? + * @param shapes show a shape for each data item? + */ + public DeviationRenderer(boolean lines, boolean shapes) { + super(lines, shapes); + super.setDrawSeriesLineAsPath(true); + this.alpha = 0.5f; + } + + /** + * Returns the alpha transparency for the background shading. + * + * @return The alpha transparency. + * + * @see #setAlpha(float) + */ + public float getAlpha() { + return this.alpha; + } + + /** + * Sets the alpha transparency for the background shading, and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param alpha the alpha (in the range 0.0f to 1.0f). + * + * @see #getAlpha() + */ + public void setAlpha(float alpha) { + if (alpha < 0.0f || alpha > 1.0f) { + throw new IllegalArgumentException( + "Requires 'alpha' in the range 0.0 to 1.0."); + } + this.alpha = alpha; + fireChangeEvent(); + } + + /** + * This method is overridden so that this flag cannot be changed---it is + * set to true for this renderer. + * + * @param flag ignored. + */ + @Override + public void setDrawSeriesLineAsPath(boolean flag) { + // ignore + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + */ + @Override + public Range findRangeBounds(XYDataset dataset) { + return findRangeBounds(dataset, true); + } + + /** + * Initialises and returns a state object that can be passed to each + * invocation of the {@link #drawItem} method. + * + * @param g2 the graphics target. + * @param dataArea the data area. + * @param plot the plot. + * @param dataset the dataset. + * @param info the plot rendering info. + * + * @return A newly initialised state object. + */ + @Override + public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, + XYPlot plot, XYDataset dataset, PlotRenderingInfo info) { + State state = new State(info); + state.seriesPath = new GeneralPath(); + state.setProcessVisibleItemsOnly(false); + return state; + } + + /** + * Returns the number of passes (through the dataset) used by this + * renderer. + * + * @return 3. + */ + @Override + public int getPassCount() { + return 3; + } + + /** + * Returns true if this is the pass where the shapes are + * drawn. + * + * @param pass the pass index. + * + * @return A boolean. + * + * @see #isLinePass(int) + */ + @Override + protected boolean isItemPass(int pass) { + return (pass == 2); + } + + /** + * Returns true if this is the pass where the lines are + * drawn. + * + * @param pass the pass index. + * + * @return A boolean. + * + * @see #isItemPass(int) + */ + @Override + protected boolean isLinePass(int pass) { + return (pass == 1); + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + // do nothing if item is not visible + if (!getItemVisible(series, item)) { + return; + } + + // first pass draws the shading + if (pass == 0) { + IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset; + State drState = (State) state; + + double x = intervalDataset.getXValue(series, item); + double yLow = intervalDataset.getStartYValue(series, item); + double yHigh = intervalDataset.getEndYValue(series, item); + + RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); + RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); + + double xx = domainAxis.valueToJava2D(x, dataArea, xAxisLocation); + double yyLow = rangeAxis.valueToJava2D(yLow, dataArea, + yAxisLocation); + double yyHigh = rangeAxis.valueToJava2D(yHigh, dataArea, + yAxisLocation); + + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + drState.lowerCoordinates.add(new double[] {yyLow, xx}); + drState.upperCoordinates.add(new double[] {yyHigh, xx}); + } + else if (orientation == PlotOrientation.VERTICAL) { + drState.lowerCoordinates.add(new double[] {xx, yyLow}); + drState.upperCoordinates.add(new double[] {xx, yyHigh}); + } + + if (item == (dataset.getItemCount(series) - 1)) { + // last item in series, draw the lot... + // set up the alpha-transparency... + Composite originalComposite = g2.getComposite(); + g2.setComposite(AlphaComposite.getInstance( + AlphaComposite.SRC_OVER, this.alpha)); + g2.setPaint(getItemFillPaint(series, item)); + GeneralPath area = new GeneralPath(GeneralPath.WIND_NON_ZERO, + drState.lowerCoordinates.size() + + drState.upperCoordinates.size()); + double[] coords = (double[]) drState.lowerCoordinates.get(0); + area.moveTo((float) coords[0], (float) coords[1]); + for (int i = 1; i < drState.lowerCoordinates.size(); i++) { + coords = (double[]) drState.lowerCoordinates.get(i); + area.lineTo((float) coords[0], (float) coords[1]); + } + int count = drState.upperCoordinates.size(); + coords = (double[]) drState.upperCoordinates.get(count - 1); + area.lineTo((float) coords[0], (float) coords[1]); + for (int i = count - 2; i >= 0; i--) { + coords = (double[]) drState.upperCoordinates.get(i); + area.lineTo((float) coords[0], (float) coords[1]); + } + area.closePath(); + g2.fill(area); + g2.setComposite(originalComposite); + + drState.lowerCoordinates.clear(); + drState.upperCoordinates.clear(); + } + } + if (isLinePass(pass)) { + + // the following code handles the line for the y-values...it's + // all done by code in the super class + if (item == 0) { + State s = (State) state; + s.seriesPath.reset(); + s.setLastPointGood(false); + } + + if (getItemLineVisible(series, item)) { + drawPrimaryLineAsPath(state, g2, plot, dataset, pass, + series, item, domainAxis, rangeAxis, dataArea); + } + } + + // second pass adds shapes where the items are .. + else if (isItemPass(pass)) { + + // setup for collecting optional entity info... + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + } + + drawSecondaryPass(g2, plot, dataset, pass, series, item, + domainAxis, dataArea, rangeAxis, crosshairState, entities); + } + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DeviationRenderer)) { + return false; + } + DeviationRenderer that = (DeviationRenderer) obj; + if (this.alpha != that.alpha) { + return false; + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/GradientXYBarPainter.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/GradientXYBarPainter.java new file mode 100755 index 0000000..ff649d9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/GradientXYBarPainter.java @@ -0,0 +1,379 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * GradientXYBarPainter.java + * ------------------------- + * (C) Copyright 2008, 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 19-Jun-2008 : Version 1 (DG); + * 22-Feb-2009 : Fixed bug drawing outlines (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Stroke; +import java.awt.geom.Rectangle2D; +import java.awt.geom.RectangularShape; +import java.io.Serializable; + +import org.jfree.chart.HashUtilities; +import org.jfree.ui.RectangleEdge; + +/** + * An implementation of the {@link XYBarPainter} interface that uses several + * gradient fills to enrich the appearance of the bars. + * + * @since 1.0.11 + */ +public class GradientXYBarPainter implements XYBarPainter, Serializable { + + /** The division point between the first and second gradient regions. */ + private double g1; + + /** The division point between the second and third gradient regions. */ + private double g2; + + /** The division point between the third and fourth gradient regions. */ + private double g3; + + /** + * Creates a new instance. + */ + public GradientXYBarPainter() { + this(0.10, 0.20, 0.80); + } + + /** + * Creates a new instance. + * + * @param g1 the division between regions 1 and 2. + * @param g2 the division between regions 2 and 3. + * @param g3 the division between regions 3 and 4. + */ + public GradientXYBarPainter(double g1, double g2, double g3) { + this.g1 = g1; + this.g2 = g2; + this.g3 = g3; + } + + /** + * Paints a single bar instance. + * + * @param g2 the graphics target. + * @param renderer the renderer. + * @param row the row index. + * @param column the column index. + * @param bar the bar + * @param base indicates which side of the rectangle is the base of the + * bar. + */ + @Override + public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, + int column, RectangularShape bar, RectangleEdge base) { + + Paint itemPaint = renderer.getItemPaint(row, column); + + Color c0, c1; + if (itemPaint instanceof Color) { + c0 = (Color) itemPaint; + c1 = c0.brighter(); + } + else if (itemPaint instanceof GradientPaint) { + GradientPaint gp = (GradientPaint) itemPaint; + c0 = gp.getColor1(); + c1 = gp.getColor2(); + } + else { + c0 = Color.blue; + c1 = Color.blue.brighter(); + } + + // as a special case, if the bar colour has alpha == 0, we draw + // nothing. + if (c0.getAlpha() == 0) { + return; + } + + if (base == RectangleEdge.TOP || base == RectangleEdge.BOTTOM) { + Rectangle2D[] regions = splitVerticalBar(bar, this.g1, this.g2, + this.g3); + GradientPaint gp = new GradientPaint((float) regions[0].getMinX(), + 0.0f, c0, (float) regions[0].getMaxX(), 0.0f, Color.white); + g2.setPaint(gp); + g2.fill(regions[0]); + + gp = new GradientPaint((float) regions[1].getMinX(), 0.0f, + Color.white, (float) regions[1].getMaxX(), 0.0f, c0); + g2.setPaint(gp); + g2.fill(regions[1]); + + gp = new GradientPaint((float) regions[2].getMinX(), 0.0f, c0, + (float) regions[2].getMaxX(), 0.0f, c1); + g2.setPaint(gp); + g2.fill(regions[2]); + + gp = new GradientPaint((float) regions[3].getMinX(), 0.0f, c1, + (float) regions[3].getMaxX(), 0.0f, c0); + g2.setPaint(gp); + g2.fill(regions[3]); + } + else if (base == RectangleEdge.LEFT || base == RectangleEdge.RIGHT) { + Rectangle2D[] regions = splitHorizontalBar(bar, this.g1, this.g2, + this.g3); + GradientPaint gp = new GradientPaint(0.0f, + (float) regions[0].getMinY(), c0, 0.0f, + (float) regions[0].getMaxX(), Color.white); + g2.setPaint(gp); + g2.fill(regions[0]); + + gp = new GradientPaint(0.0f, (float) regions[1].getMinY(), + Color.white, 0.0f, (float) regions[1].getMaxY(), c0); + g2.setPaint(gp); + g2.fill(regions[1]); + + gp = new GradientPaint(0.0f, (float) regions[2].getMinY(), c0, + 0.0f, (float) regions[2].getMaxY(), c1); + g2.setPaint(gp); + g2.fill(regions[2]); + + gp = new GradientPaint(0.0f, (float) regions[3].getMinY(), c1, + 0.0f, (float) regions[3].getMaxY(), c0); + g2.setPaint(gp); + g2.fill(regions[3]); + + } + + // draw the outline... + if (renderer.isDrawBarOutline()) { + Stroke stroke = renderer.getItemOutlineStroke(row, column); + Paint paint = renderer.getItemOutlinePaint(row, column); + if (stroke != null && paint != null) { + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(bar); + } + } + + } + + /** + * Paints a single bar instance. + * + * @param g2 the graphics target. + * @param renderer the renderer. + * @param row the row index. + * @param column the column index. + * @param bar the bar + * @param base indicates which side of the rectangle is the base of the + * bar. + * @param pegShadow peg the shadow to the base of the bar? + */ + @Override + public void paintBarShadow(Graphics2D g2, XYBarRenderer renderer, int row, + int column, RectangularShape bar, RectangleEdge base, + boolean pegShadow) { + + // handle a special case - if the bar colour has alpha == 0, it is + // invisible so we shouldn't draw any shadow + Paint itemPaint = renderer.getItemPaint(row, column); + if (itemPaint instanceof Color) { + Color c = (Color) itemPaint; + if (c.getAlpha() == 0) { + return; + } + } + + RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(), + renderer.getShadowYOffset(), base, pegShadow); + g2.setPaint(Color.gray); + g2.fill(shadow); + + } + + /** + * Creates a shadow for the bar. + * + * @param bar the bar shape. + * @param xOffset the x-offset for the shadow. + * @param yOffset the y-offset for the shadow. + * @param base the edge that is the base of the bar. + * @param pegShadow peg the shadow to the base? + * + * @return A rectangle for the shadow. + */ + private Rectangle2D createShadow(RectangularShape bar, double xOffset, + double yOffset, RectangleEdge base, boolean pegShadow) { + double x0 = bar.getMinX(); + double x1 = bar.getMaxX(); + double y0 = bar.getMinY(); + double y1 = bar.getMaxY(); + if (base == RectangleEdge.TOP) { + x0 += xOffset; + x1 += xOffset; + if (!pegShadow) { + y0 += yOffset; + } + y1 += yOffset; + } + else if (base == RectangleEdge.BOTTOM) { + x0 += xOffset; + x1 += xOffset; + y0 += yOffset; + if (!pegShadow) { + y1 += yOffset; + } + } + else if (base == RectangleEdge.LEFT) { + if (!pegShadow) { + x0 += xOffset; + } + x1 += xOffset; + y0 += yOffset; + y1 += yOffset; + } + else if (base == RectangleEdge.RIGHT) { + x0 += xOffset; + if (!pegShadow) { + x1 += xOffset; + } + y0 += yOffset; + y1 += yOffset; + } + return new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); + } + + /** + * Splits a bar into subregions (elsewhere, these subregions will have + * different gradients applied to them). + * + * @param bar the bar shape. + * @param a the first division. + * @param b the second division. + * @param c the third division. + * + * @return An array containing four subregions. + */ + private Rectangle2D[] splitVerticalBar(RectangularShape bar, double a, + double b, double c) { + Rectangle2D[] result = new Rectangle2D[4]; + double x0 = bar.getMinX(); + double x1 = Math.rint(x0 + (bar.getWidth() * a)); + double x2 = Math.rint(x0 + (bar.getWidth() * b)); + double x3 = Math.rint(x0 + (bar.getWidth() * c)); + result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), + x1 - x0, bar.getHeight()); + result[1] = new Rectangle2D.Double(x1, bar.getMinY(), x2 - x1, + bar.getHeight()); + result[2] = new Rectangle2D.Double(x2, bar.getMinY(), x3 - x2, + bar.getHeight()); + result[3] = new Rectangle2D.Double(x3, bar.getMinY(), + bar.getMaxX() - x3, bar.getHeight()); + return result; + } + + /** + * Splits a bar into subregions (elsewhere, these subregions will have + * different gradients applied to them). + * + * @param bar the bar shape. + * @param a the first division. + * @param b the second division. + * @param c the third division. + * + * @return An array containing four subregions. + */ + private Rectangle2D[] splitHorizontalBar(RectangularShape bar, double a, + double b, double c) { + Rectangle2D[] result = new Rectangle2D[4]; + double y0 = bar.getMinY(); + double y1 = Math.rint(y0 + (bar.getHeight() * a)); + double y2 = Math.rint(y0 + (bar.getHeight() * b)); + double y3 = Math.rint(y0 + (bar.getHeight() * c)); + result[0] = new Rectangle2D.Double(bar.getMinX(), bar.getMinY(), + bar.getWidth(), y1 - y0); + result[1] = new Rectangle2D.Double(bar.getMinX(), y1, bar.getWidth(), + y2 - y1); + result[2] = new Rectangle2D.Double(bar.getMinX(), y2, bar.getWidth(), + y3 - y2); + result[3] = new Rectangle2D.Double(bar.getMinX(), y3, bar.getWidth(), + bar.getMaxY() - y3); + return result; + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the obj (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof GradientXYBarPainter)) { + return false; + } + GradientXYBarPainter that = (GradientXYBarPainter) obj; + if (this.g1 != that.g1) { + return false; + } + if (this.g2 != that.g2) { + return false; + } + if (this.g3 != that.g3) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int hash = 37; + hash = HashUtilities.hashCode(hash, this.g1); + hash = HashUtilities.hashCode(hash, this.g2); + hash = HashUtilities.hashCode(hash, this.g3); + return hash; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/HighLowRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/HighLowRenderer.java new file mode 100755 index 0000000..b92fec9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/HighLowRenderer.java @@ -0,0 +1,526 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * HighLowRenderer.java + * -------------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Richard Atkinson; + * Christian W. Zuckschwerdt; + * + * Changes + * ------- + * 13-Dec-2001 : Version 1 (DG); + * 23-Jan-2002 : Added DrawInfo parameter to drawItem() method (DG); + * 28-Mar-2002 : Added a property change listener mechanism so that renderers + * no longer need to be immutable (DG); + * 09-Apr-2002 : Removed translatedRangeZero from the drawItem() method, and + * changed the return type of the drawItem method to void, + * reflecting a change in the XYItemRenderer interface. Added + * tooltip code to drawItem() method (DG); + * 05-Aug-2002 : Small modification to drawItem method to support URLs for + * HTML image maps (RA); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Modified drawItem() method signature (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 31-Jul-2003 : Deprecated constructor (DG); + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 29-Jan-2004 : Fixed bug (882392) when rendering with + * PlotOrientation.HORIZONTAL (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed + * XYToolTipGenerator --> XYItemLabelGenerator (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 01-Nov-2005 : Added optional openTickPaint and closeTickPaint settings (DG); + * ------------- JFREECHART 1.0.0 --------------------------------------------- + * 06-Jul-2006 : Replace dataset methods getX() --> getXValue() (DG); + * 08-Apr-2008 : Added findRangeBounds() override (DG); + * 29-Apr-2008 : Added tickLength field (DG); + * 25-Sep-2008 : Check for non-null entity collection (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +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.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.Range; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.xy.OHLCDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A renderer that draws high/low/open/close markers on an {@link XYPlot} + * (requires a {@link OHLCDataset}). This renderer does not include code to + * calculate the crosshair point for the plot. + * + * The example shown here is generated by the + * HighLowChartDemo1.java program included in the JFreeChart Demo + * Collection: + *

+ * HighLowRendererSample.png + */ +public class HighLowRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -8135673815876552516L; + + /** A flag that controls whether the open ticks are drawn. */ + private boolean drawOpenTicks; + + /** A flag that controls whether the close ticks are drawn. */ + private boolean drawCloseTicks; + + /** + * The paint used for the open ticks (if null, the series + * paint is used instead). + */ + private transient Paint openTickPaint; + + /** + * The paint used for the close ticks (if null, the series + * paint is used instead). + */ + private transient Paint closeTickPaint; + + /** + * The tick length (in Java2D units). + * + * @since 1.0.10 + */ + private double tickLength; + + /** + * The default constructor. + */ + public HighLowRenderer() { + super(); + this.drawOpenTicks = true; + this.drawCloseTicks = true; + this.tickLength = 2.0; + } + + /** + * Returns the flag that controls whether open ticks are drawn. + * + * @return A boolean. + * + * @see #getDrawCloseTicks() + * @see #setDrawOpenTicks(boolean) + */ + public boolean getDrawOpenTicks() { + return this.drawOpenTicks; + } + + /** + * Sets the flag that controls whether open ticks are drawn, and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param draw the flag. + * + * @see #getDrawOpenTicks() + */ + public void setDrawOpenTicks(boolean draw) { + this.drawOpenTicks = draw; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether close ticks are drawn. + * + * @return A boolean. + * + * @see #getDrawOpenTicks() + * @see #setDrawCloseTicks(boolean) + */ + public boolean getDrawCloseTicks() { + return this.drawCloseTicks; + } + + /** + * Sets the flag that controls whether close ticks are drawn, and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param draw the flag. + * + * @see #getDrawCloseTicks() + */ + public void setDrawCloseTicks(boolean draw) { + this.drawCloseTicks = draw; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw the ticks for the open values. + * + * @return The paint used to draw the ticks for the open values (possibly + * null). + * + * @see #setOpenTickPaint(Paint) + */ + public Paint getOpenTickPaint() { + return this.openTickPaint; + } + + /** + * Sets the paint used to draw the ticks for the open values and sends a + * {@link RendererChangeEvent} to all registered listeners. If you set + * this to null (the default), the series paint is used + * instead. + * + * @param paint the paint (null permitted). + * + * @see #getOpenTickPaint() + */ + public void setOpenTickPaint(Paint paint) { + this.openTickPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw the ticks for the close values. + * + * @return The paint used to draw the ticks for the close values (possibly + * null). + * + * @see #setCloseTickPaint(Paint) + */ + public Paint getCloseTickPaint() { + return this.closeTickPaint; + } + + /** + * Sets the paint used to draw the ticks for the close values and sends a + * {@link RendererChangeEvent} to all registered listeners. If you set + * this to null (the default), the series paint is used + * instead. + * + * @param paint the paint (null permitted). + * + * @see #getCloseTickPaint() + */ + public void setCloseTickPaint(Paint paint) { + this.closeTickPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the tick length (in Java2D units). + * + * @return The tick length. + * + * @since 1.0.10 + * + * @see #setTickLength(double) + */ + public double getTickLength() { + return this.tickLength; + } + + /** + * Sets the tick length (in Java2D units) and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param length the length. + * + * @since 1.0.10 + * + * @see #getTickLength() + */ + public void setTickLength(double length) { + this.tickLength = length; + fireChangeEvent(); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + */ + @Override + public Range findRangeBounds(XYDataset dataset) { + if (dataset != null) { + return DatasetUtilities.findRangeBounds(dataset, true); + } + else { + return null; + } + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the plot is being drawn. + * @param info collects information about the drawing. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + double x = dataset.getXValue(series, item); + if (!domainAxis.getRange().contains(x)) { + return; // the x value is not within the axis range + } + double xx = domainAxis.valueToJava2D(x, dataArea, + plot.getDomainAxisEdge()); + + // setup for collecting optional entity info... + Shape entityArea = null; + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + } + + PlotOrientation orientation = plot.getOrientation(); + RectangleEdge location = plot.getRangeAxisEdge(); + + Paint itemPaint = getItemPaint(series, item); + Stroke itemStroke = getItemStroke(series, item); + g2.setPaint(itemPaint); + g2.setStroke(itemStroke); + + if (dataset instanceof OHLCDataset) { + OHLCDataset hld = (OHLCDataset) dataset; + + double yHigh = hld.getHighValue(series, item); + double yLow = hld.getLowValue(series, item); + if (!Double.isNaN(yHigh) && !Double.isNaN(yLow)) { + double yyHigh = rangeAxis.valueToJava2D(yHigh, dataArea, + location); + double yyLow = rangeAxis.valueToJava2D(yLow, dataArea, + location); + if (orientation == PlotOrientation.HORIZONTAL) { + g2.draw(new Line2D.Double(yyLow, xx, yyHigh, xx)); + entityArea = new Rectangle2D.Double(Math.min(yyLow, yyHigh), + xx - 1.0, Math.abs(yyHigh - yyLow), 2.0); + } + else if (orientation == PlotOrientation.VERTICAL) { + g2.draw(new Line2D.Double(xx, yyLow, xx, yyHigh)); + entityArea = new Rectangle2D.Double(xx - 1.0, + Math.min(yyLow, yyHigh), 2.0, + Math.abs(yyHigh - yyLow)); + } + } + + double delta = getTickLength(); + if (domainAxis.isInverted()) { + delta = -delta; + } + if (getDrawOpenTicks()) { + double yOpen = hld.getOpenValue(series, item); + if (!Double.isNaN(yOpen)) { + double yyOpen = rangeAxis.valueToJava2D(yOpen, dataArea, + location); + if (this.openTickPaint != null) { + g2.setPaint(this.openTickPaint); + } + else { + g2.setPaint(itemPaint); + } + if (orientation == PlotOrientation.HORIZONTAL) { + g2.draw(new Line2D.Double(yyOpen, xx + delta, yyOpen, + xx)); + } + else if (orientation == PlotOrientation.VERTICAL) { + g2.draw(new Line2D.Double(xx - delta, yyOpen, xx, + yyOpen)); + } + } + } + + if (getDrawCloseTicks()) { + double yClose = hld.getCloseValue(series, item); + if (!Double.isNaN(yClose)) { + double yyClose = rangeAxis.valueToJava2D( + yClose, dataArea, location); + if (this.closeTickPaint != null) { + g2.setPaint(this.closeTickPaint); + } + else { + g2.setPaint(itemPaint); + } + if (orientation == PlotOrientation.HORIZONTAL) { + g2.draw(new Line2D.Double(yyClose, xx, yyClose, + xx - delta)); + } + else if (orientation == PlotOrientation.VERTICAL) { + g2.draw(new Line2D.Double(xx, yyClose, xx + delta, + yyClose)); + } + } + } + + } + else { + // not a HighLowDataset, so just draw a line connecting this point + // with the previous point... + if (item > 0) { + double x0 = dataset.getXValue(series, item - 1); + double y0 = dataset.getYValue(series, item - 1); + double y = dataset.getYValue(series, item); + if (Double.isNaN(x0) || Double.isNaN(y0) || Double.isNaN(y)) { + return; + } + double xx0 = domainAxis.valueToJava2D(x0, dataArea, + plot.getDomainAxisEdge()); + double yy0 = rangeAxis.valueToJava2D(y0, dataArea, location); + double yy = rangeAxis.valueToJava2D(y, dataArea, location); + if (orientation == PlotOrientation.HORIZONTAL) { + g2.draw(new Line2D.Double(yy0, xx0, yy, xx)); + } + else if (orientation == PlotOrientation.VERTICAL) { + g2.draw(new Line2D.Double(xx0, yy0, xx, yy)); + } + } + } + + if (entities != null) { + addEntity(entities, entityArea, dataset, series, item, 0.0, 0.0); + } + + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof HighLowRenderer)) { + return false; + } + HighLowRenderer that = (HighLowRenderer) obj; + if (this.drawOpenTicks != that.drawOpenTicks) { + return false; + } + if (this.drawCloseTicks != that.drawCloseTicks) { + return false; + } + if (!PaintUtilities.equal(this.openTickPaint, that.openTickPaint)) { + return false; + } + if (!PaintUtilities.equal(this.closeTickPaint, that.closeTickPaint)) { + return false; + } + if (this.tickLength != that.tickLength) { + return false; + } + if (!super.equals(obj)) { + return false; + } + return true; + } + + /** + * 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.openTickPaint = SerialUtilities.readPaint(stream); + this.closeTickPaint = SerialUtilities.readPaint(stream); + } + + /** + * 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.openTickPaint, stream); + SerialUtilities.writePaint(this.closeTickPaint, stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/SamplingXYLineRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/SamplingXYLineRenderer.java new file mode 100755 index 0000000..e2b5d3f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/SamplingXYLineRenderer.java @@ -0,0 +1,408 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * SamplingXYLineRenderer.java + * --------------------------- + * (C) Copyright 2008-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 02-Oct-2008 : Version 1 (DG); + * 28-Apr-2009 : Fixed bug in legend shape display, and deprecated + * getLegendLine() and setLegendLine() - these methods + * are unnecessary because a mechanism already exists in the + * superclass for specifying a custom legend shape (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; +import java.awt.geom.PathIterator; +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.event.RendererChangeEvent; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A renderer that draws line charts. The renderer doesn't necessarily plot + * every data item - instead, it tries to plot only those data items that + * make a difference to the visual output (the other data items are skipped). + * This renderer is designed for use with the {@link XYPlot} class. + * + * @since 1.0.13 + */ +public class SamplingXYLineRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { + + /** The shape that is used to represent a line in the legend. */ + private transient Shape legendLine; + + /** + * Creates a new renderer. + */ + public SamplingXYLineRenderer() { + this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0); + setBaseLegendShape(this.legendLine); + setTreatLegendShapeAsLine(true); + } + + /** + * Returns the shape used to represent a line in the legend. + * + * @return The legend line (never null). + * + * @see #setLegendLine(Shape) + * + * @deprecated As of version 1.0.14, this method is deprecated. You + * should use the {@link #getBaseLegendShape()} method instead. + */ + public Shape getLegendLine() { + return this.legendLine; + } + + /** + * Sets the shape used as a line in each legend item and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param line the line (null not permitted). + * + * @see #getLegendLine() + * + * @deprecated As of version 1.0.14, this method is deprecated. You should + * use the {@link #setBaseLegendShape(java.awt.Shape)} method instead. + */ + public void setLegendLine(Shape line) { + ParamChecks.nullNotPermitted(line, "line"); + this.legendLine = line; + fireChangeEvent(); + } + + /** + * Returns the number of passes through the data that the renderer requires + * in order to draw the chart. Most charts will require a single pass, but + * some require two passes. + * + * @return The pass count. + */ + @Override + public int getPassCount() { + return 1; + } + + /** + * Records the state for the renderer. This is used to preserve state + * information between calls to the drawItem() method for a single chart + * drawing. + */ + public static class State extends XYItemRendererState { + + /** The path for the current series. */ + GeneralPath seriesPath; + + /** + * A second path that draws vertical intervals to cover any extreme + * values. + */ + GeneralPath intervalPath; + + /** + * The minimum change in the x-value needed to trigger an update to + * the seriesPath. + */ + double dX = 1.0; + + /** The last x-coordinate visited by the seriesPath. */ + double lastX; + + /** The initial y-coordinate for the current x-coordinate. */ + double openY = 0.0; + + /** The highest y-coordinate for the current x-coordinate. */ + double highY = 0.0; + + /** The lowest y-coordinate for the current x-coordinate. */ + double lowY = 0.0; + + /** The final y-coordinate for the current x-coordinate. */ + double closeY = 0.0; + + /** + * A flag that indicates if the last (x, y) point was 'good' + * (non-null). + */ + boolean lastPointGood; + + /** + * Creates a new state instance. + * + * @param info the plot rendering info. + */ + public State(PlotRenderingInfo info) { + super(info); + } + + /** + * This method is called by the {@link XYPlot} at the start of each + * series pass. We reset the state for the current series. + * + * @param dataset the dataset. + * @param series the series index. + * @param firstItem the first item index for this pass. + * @param lastItem the last item index for this pass. + * @param pass the current pass index. + * @param passCount the number of passes. + */ + @Override + public void startSeriesPass(XYDataset dataset, int series, + int firstItem, int lastItem, int pass, int passCount) { + this.seriesPath.reset(); + this.intervalPath.reset(); + this.lastPointGood = false; + super.startSeriesPass(dataset, series, firstItem, lastItem, pass, + passCount); + } + + } + + /** + * Initialises the renderer. + *

+ * This method will be called before the first item is rendered, giving the + * renderer an opportunity to initialise any state information it wants to + * maintain. The renderer can do nothing if it chooses. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param data the data. + * @param info an optional info collection object to return data back to + * the caller. + * + * @return The renderer state. + */ + @Override + public XYItemRendererState initialise(Graphics2D g2, + Rectangle2D dataArea, XYPlot plot, XYDataset data, + PlotRenderingInfo info) { + + double dpi = 72; + // Integer dpiVal = (Integer) g2.getRenderingHint(HintKey.DPI); + // if (dpiVal != null) { + // dpi = dpiVal.intValue(); + // } + State state = new State(info); + state.seriesPath = new GeneralPath(); + state.intervalPath = new GeneralPath(); + state.dX = 72.0 / dpi; + return state; + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + // do nothing if item is not visible + if (!getItemVisible(series, item)) { + return; + } + RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); + RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); + + // get the data point... + double x1 = dataset.getXValue(series, item); + double y1 = dataset.getYValue(series, item); + double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); + double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); + + State s = (State) state; + // update path to reflect latest point + if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) { + float x = (float) transX1; + float y = (float) transY1; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + x = (float) transY1; + y = (float) transX1; + } + if (s.lastPointGood) { + if ((Math.abs(x - s.lastX) > s.dX)) { + s.seriesPath.lineTo(x, y); + if (s.lowY < s.highY) { + s.intervalPath.moveTo((float) s.lastX, (float) s.lowY); + s.intervalPath.lineTo((float) s.lastX, (float) s.highY); + } + s.lastX = x; + s.openY = y; + s.highY = y; + s.lowY = y; + s.closeY = y; + } + else { + s.highY = Math.max(s.highY, y); + s.lowY = Math.min(s.lowY, y); + s.closeY = y; + } + } + else { + s.seriesPath.moveTo(x, y); + s.lastX = x; + s.openY = y; + s.highY = y; + s.lowY = y; + s.closeY = y; + } + s.lastPointGood = true; + } + else { + s.lastPointGood = false; + } + // if this is the last item, draw the path ... + if (item == s.getLastItemIndex()) { + // draw path + PathIterator pi = s.seriesPath.getPathIterator(null); + int count = 0; + while (!pi.isDone()) { + count++; + pi.next(); + } + g2.setStroke(getItemStroke(series, item)); + g2.setPaint(getItemPaint(series, item)); + g2.draw(s.seriesPath); + g2.draw(s.intervalPath); + } + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the clone cannot be created. + */ + @Override + public Object clone() throws CloneNotSupportedException { + SamplingXYLineRenderer clone = (SamplingXYLineRenderer) super.clone(); + if (this.legendLine != null) { + clone.legendLine = ShapeUtilities.clone(this.legendLine); + } + return clone; + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SamplingXYLineRenderer)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + SamplingXYLineRenderer that = (SamplingXYLineRenderer) obj; + if (!ShapeUtilities.equal(this.legendLine, that.legendLine)) { + return false; + } + return true; + } + + /** + * 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.legendLine = SerialUtilities.readShape(stream); + } + + /** + * 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.legendLine, stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java new file mode 100755 index 0000000..cf92c49 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer.java @@ -0,0 +1,696 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * StackedXYAreaRenderer.java + * -------------------------- + * (C) Copyright 2003-2008, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): Christian W. Zuckschwerdt; + * David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 27-Jul-2003 : Initial version (RA); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 18-Aug-2003 : Now handles null values (RA); + * 20-Aug-2003 : Implemented Cloneable, PublicCloneable and Serializable (DG); + * 22-Sep-2003 : Changed to be a two pass renderer with optional shape Paint + * and Stroke (RA); + * 07-Oct-2003 : Added renderer state (DG); + * 10-Feb-2004 : Updated state object and changed drawItem() method to make + * overriding easier (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed + * XYToolTipGenerator --> XYItemLabelGenerator (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 10-Sep-2004 : Removed getRangeType() method (DG); + * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); + * 06-Jan-2005 : Override equals() (DG); + * 07-Jan-2005 : Update for method name changes in DatasetUtilities (DG); + * 28-Mar-2005 : Use getXValue() and getYValue() from dataset (DG); + * 06-Jun-2005 : Fixed null pointer exception, plus problems with equals() and + * serialization (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 10-Nov-2006 : Fixed bug 1593156, NullPointerException with line + * plotting (DG); + * 02-Feb-2007 : Fixed bug 1649686, crosshairs don't stack y-values (DG); + * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); + * 22-Mar-2007 : Fire change events in setShapePaint() and setShapeStroke() + * methods (DG); + * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Point; +import java.awt.Polygon; +import java.awt.Shape; +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 java.util.Stack; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.entity.XYItemEntity; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.data.Range; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.xy.TableXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A stacked area renderer for the {@link XYPlot} class. + *

+ * The example shown here is generated by the + * StackedXYAreaRendererDemo1.java program included in the + * JFreeChart demo collection: + *

+ * StackedXYAreaRendererSample.png + *

+ * SPECIAL NOTE: This renderer does not currently handle negative data values + * correctly. This should get fixed at some point, but the current workaround + * is to use the {@link StackedXYAreaRenderer2} class instead. + */ +public class StackedXYAreaRenderer extends XYAreaRenderer + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 5217394318178570889L; + + /** + * A state object for use by this renderer. + */ + static class StackedXYAreaRendererState extends XYItemRendererState { + + /** The area for the current series. */ + private Polygon seriesArea; + + /** The line. */ + private Line2D line; + + /** The points from the last series. */ + private Stack lastSeriesPoints; + + /** The points for the current series. */ + private Stack currentSeriesPoints; + + /** + * Creates a new state for the renderer. + * + * @param info the plot rendering info. + */ + public StackedXYAreaRendererState(PlotRenderingInfo info) { + super(info); + this.seriesArea = null; + this.line = new Line2D.Double(); + this.lastSeriesPoints = new Stack(); + this.currentSeriesPoints = new Stack(); + } + + /** + * Returns the series area. + * + * @return The series area. + */ + public Polygon getSeriesArea() { + return this.seriesArea; + } + + /** + * Sets the series area. + * + * @param area the area. + */ + public void setSeriesArea(Polygon area) { + this.seriesArea = area; + } + + /** + * Returns the working line. + * + * @return The working line. + */ + public Line2D getLine() { + return this.line; + } + + /** + * Returns the current series points. + * + * @return The current series points. + */ + public Stack getCurrentSeriesPoints() { + return this.currentSeriesPoints; + } + + /** + * Sets the current series points. + * + * @param points the points. + */ + public void setCurrentSeriesPoints(Stack points) { + this.currentSeriesPoints = points; + } + + /** + * Returns the last series points. + * + * @return The last series points. + */ + public Stack getLastSeriesPoints() { + return this.lastSeriesPoints; + } + + /** + * Sets the last series points. + * + * @param points the points. + */ + public void setLastSeriesPoints(Stack points) { + this.lastSeriesPoints = points; + } + + } + + /** + * Custom Paint for drawing all shapes, if null defaults to series shapes + */ + private transient Paint shapePaint = null; + + /** + * Custom Stroke for drawing all shapes, if null defaults to series + * strokes. + */ + private transient Stroke shapeStroke = null; + + /** + * Creates a new renderer. + */ + public StackedXYAreaRenderer() { + this(AREA); + } + + /** + * Constructs a new renderer. + * + * @param type the type of the renderer. + */ + public StackedXYAreaRenderer(int type) { + this(type, null, null); + } + + /** + * Constructs a new renderer. To specify the type of renderer, use one of + * the constants: SHAPES, LINES, + * SHAPES_AND_LINES, AREA or + * AREA_AND_SHAPES. + * + * @param type the type of renderer. + * @param labelGenerator the tool tip generator to use (null + * is none). + * @param urlGenerator the URL generator (null permitted). + */ + public StackedXYAreaRenderer(int type, XYToolTipGenerator labelGenerator, + XYURLGenerator urlGenerator) { + super(type, labelGenerator, urlGenerator); + } + + /** + * Returns the paint used for rendering shapes, or null if + * using series paints. + * + * @return The paint (possibly null). + * + * @see #setShapePaint(Paint) + */ + public Paint getShapePaint() { + return this.shapePaint; + } + + /** + * Sets the paint for rendering shapes and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param shapePaint the paint (null permitted). + * + * @see #getShapePaint() + */ + public void setShapePaint(Paint shapePaint) { + this.shapePaint = shapePaint; + fireChangeEvent(); + } + + /** + * Returns the stroke used for rendering shapes, or null if + * using series strokes. + * + * @return The stroke (possibly null). + * + * @see #setShapeStroke(Stroke) + */ + public Stroke getShapeStroke() { + return this.shapeStroke; + } + + /** + * Sets the stroke for rendering shapes and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param shapeStroke the stroke (null permitted). + * + * @see #getShapeStroke() + */ + public void setShapeStroke(Stroke shapeStroke) { + this.shapeStroke = shapeStroke; + fireChangeEvent(); + } + + /** + * Initialises the renderer. This method will be called before the first + * item is rendered, giving the renderer an opportunity to initialise any + * state information it wants to maintain. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param data the data. + * @param info an optional info collection object to return data back to + * the caller. + * + * @return A state object that should be passed to subsequent calls to the + * drawItem() method. + */ + @Override + public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, + XYPlot plot, XYDataset data, PlotRenderingInfo info) { + + XYItemRendererState state = new StackedXYAreaRendererState(info); + // in the rendering process, there is special handling for item + // zero, so we can't support processing of visible data items only + state.setProcessVisibleItemsOnly(false); + return state; + } + + /** + * Returns the number of passes required by the renderer. + * + * @return 2. + */ + @Override + public int getPassCount() { + return 2; + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range ([0.0, 0.0] if the dataset contains no values, and + * null if the dataset is null). + * + * @throws ClassCastException if dataset is not an instance + * of {@link TableXYDataset}. + */ + @Override + public Range findRangeBounds(XYDataset dataset) { + if (dataset != null) { + return DatasetUtilities.findStackedRangeBounds( + (TableXYDataset) dataset); + } + else { + return null; + } + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState information about crosshairs on a plot. + * @param pass the pass index. + * + * @throws ClassCastException if state is not an instance of + * StackedXYAreaRendererState or dataset + * is not an instance of {@link TableXYDataset}. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + PlotOrientation orientation = plot.getOrientation(); + StackedXYAreaRendererState areaState + = (StackedXYAreaRendererState) state; + // Get the item count for the series, so that we can know which is the + // end of the series. + TableXYDataset tdataset = (TableXYDataset) dataset; + int itemCount = tdataset.getItemCount(); + + // get the data point... + double x1 = dataset.getXValue(series, item); + double y1 = dataset.getYValue(series, item); + boolean nullPoint = false; + if (Double.isNaN(y1)) { + y1 = 0.0; + nullPoint = true; + } + + // Get height adjustment based on stack and translate to Java2D values + double ph1 = getPreviousHeight(tdataset, series, item); + double transX1 = domainAxis.valueToJava2D(x1, dataArea, + plot.getDomainAxisEdge()); + double transY1 = rangeAxis.valueToJava2D(y1 + ph1, dataArea, + plot.getRangeAxisEdge()); + + // Get series Paint and Stroke + Paint seriesPaint = getItemPaint(series, item); + Paint seriesFillPaint = seriesPaint; + if (getUseFillPaint()) { + seriesFillPaint = getItemFillPaint(series, item); + } + Stroke seriesStroke = getItemStroke(series, item); + + if (pass == 0) { + // On first pass render the areas, line and outlines + + if (item == 0) { + // Create a new Area for the series + areaState.setSeriesArea(new Polygon()); + areaState.setLastSeriesPoints( + areaState.getCurrentSeriesPoints()); + areaState.setCurrentSeriesPoints(new Stack()); + + // start from previous height (ph1) + double transY2 = rangeAxis.valueToJava2D(ph1, dataArea, + plot.getRangeAxisEdge()); + + // The first point is (x, 0) + if (orientation == PlotOrientation.VERTICAL) { + areaState.getSeriesArea().addPoint((int) transX1, + (int) transY2); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + areaState.getSeriesArea().addPoint((int) transY2, + (int) transX1); + } + } + + // Add each point to Area (x, y) + if (orientation == PlotOrientation.VERTICAL) { + Point point = new Point((int) transX1, (int) transY1); + areaState.getSeriesArea().addPoint((int) point.getX(), + (int) point.getY()); + areaState.getCurrentSeriesPoints().push(point); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + areaState.getSeriesArea().addPoint((int) transY1, + (int) transX1); + } + + if (getPlotLines()) { + if (item > 0) { + // get the previous data point... + double x0 = dataset.getXValue(series, item - 1); + double y0 = dataset.getYValue(series, item - 1); + double ph0 = getPreviousHeight(tdataset, series, item - 1); + double transX0 = domainAxis.valueToJava2D(x0, dataArea, + plot.getDomainAxisEdge()); + double transY0 = rangeAxis.valueToJava2D(y0 + ph0, + dataArea, plot.getRangeAxisEdge()); + + if (orientation == PlotOrientation.VERTICAL) { + areaState.getLine().setLine(transX0, transY0, transX1, + transY1); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + areaState.getLine().setLine(transY0, transX0, transY1, + transX1); + } + g2.setPaint(seriesPaint); + g2.setStroke(seriesStroke); + g2.draw(areaState.getLine()); + } + } + + // Check if the item is the last item for the series and number of + // items > 0. We can't draw an area for a single point. + if (getPlotArea() && item > 0 && item == (itemCount - 1)) { + + double transY2 = rangeAxis.valueToJava2D(ph1, dataArea, + plot.getRangeAxisEdge()); + + if (orientation == PlotOrientation.VERTICAL) { + // Add the last point (x,0) + areaState.getSeriesArea().addPoint((int) transX1, + (int) transY2); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + // Add the last point (x,0) + areaState.getSeriesArea().addPoint((int) transY2, + (int) transX1); + } + + // Add points from last series to complete the base of the + // polygon + if (series != 0) { + Stack points = areaState.getLastSeriesPoints(); + while (!points.empty()) { + Point point = (Point) points.pop(); + areaState.getSeriesArea().addPoint((int) point.getX(), + (int) point.getY()); + } + } + + // Fill the polygon + g2.setPaint(seriesFillPaint); + g2.setStroke(seriesStroke); + g2.fill(areaState.getSeriesArea()); + + // Draw an outline around the Area. + if (isOutline()) { + g2.setStroke(lookupSeriesOutlineStroke(series)); + g2.setPaint(lookupSeriesOutlinePaint(series)); + g2.draw(areaState.getSeriesArea()); + } + } + + int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); + int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); + updateCrosshairValues(crosshairState, x1, ph1 + y1, domainAxisIndex, + rangeAxisIndex, transX1, transY1, orientation); + + } + else if (pass == 1) { + // On second pass render shapes and collect entity and tooltip + // information + + Shape shape = null; + if (getPlotShapes()) { + shape = getItemShape(series, item); + if (plot.getOrientation() == PlotOrientation.VERTICAL) { + shape = ShapeUtilities.createTranslatedShape(shape, + transX1, transY1); + } + else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { + shape = ShapeUtilities.createTranslatedShape(shape, + transY1, transX1); + } + if (!nullPoint) { + if (getShapePaint() != null) { + g2.setPaint(getShapePaint()); + } + else { + g2.setPaint(seriesPaint); + } + if (getShapeStroke() != null) { + g2.setStroke(getShapeStroke()); + } + else { + g2.setStroke(seriesStroke); + } + g2.draw(shape); + } + } + else { + if (plot.getOrientation() == PlotOrientation.VERTICAL) { + shape = new Rectangle2D.Double(transX1 - 3, transY1 - 3, + 6.0, 6.0); + } + else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { + shape = new Rectangle2D.Double(transY1 - 3, transX1 - 3, + 6.0, 6.0); + } + } + + // collect entity and tool tip information... + if (state.getInfo() != null) { + EntityCollection entities = state.getEntityCollection(); + if (entities != null && shape != null && !nullPoint) { + String tip = null; + XYToolTipGenerator generator + = getToolTipGenerator(series, item); + if (generator != null) { + tip = generator.generateToolTip(dataset, series, item); + } + String url = null; + if (getURLGenerator() != null) { + url = getURLGenerator().generateURL(dataset, series, + item); + } + XYItemEntity entity = new XYItemEntity(shape, dataset, + series, item, tip, url); + entities.add(entity); + } + } + + } + } + + /** + * Calculates the stacked value of the all series up to, but not including + * series for the specified item. It returns 0.0 if + * series is the first series, i.e. 0. + * + * @param dataset the dataset. + * @param series the series. + * @param index the index. + * + * @return The cumulative value for all series' values up to but excluding + * series for index. + */ + protected double getPreviousHeight(TableXYDataset dataset, + int series, int index) { + double result = 0.0; + for (int i = 0; i < series; i++) { + double value = dataset.getYValue(i, index); + if (!Double.isNaN(value)) { + result += value; + } + } + return result; + } + + /** + * Tests the renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StackedXYAreaRenderer) || !super.equals(obj)) { + return false; + } + StackedXYAreaRenderer that = (StackedXYAreaRenderer) obj; + if (!PaintUtilities.equal(this.shapePaint, that.shapePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.shapeStroke, that.shapeStroke)) { + return false; + } + return true; + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * 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.shapePaint = SerialUtilities.readPaint(stream); + this.shapeStroke = SerialUtilities.readStroke(stream); + } + + /** + * 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.shapePaint, stream); + SerialUtilities.writeStroke(this.shapeStroke, stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java new file mode 100755 index 0000000..cc9acb0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2.java @@ -0,0 +1,564 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * StackedXYAreaRenderer2.java + * --------------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited), based on + * the StackedXYAreaRenderer class by Richard Atkinson; + * Contributor(s): -; + * + * Changes: + * -------- + * 30-Apr-2004 : Version 1 (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 10-Sep-2004 : Removed getRangeType() method (DG); + * 06-Jan-2004 : Renamed getRangeExtent() --> findRangeBounds (DG); + * 28-Mar-2005 : Use getXValue() and getYValue() from dataset (DG); + * 03-Oct-2005 : Add entity generation to drawItem() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 22-Aug-2006 : Handle null and empty datasets correctly in the + * findRangeBounds() method (DG); + * 22-Sep-2006 : Added a flag to allow rounding of x-coordinates (after + * translation to Java2D space) in order to avoid the striping + * that can result from anti-aliasing (thanks to Doug + * Clayton) (DG); + * 30-Nov-2006 : Added accessor methods for the roundXCoordinates flag (DG); + * 02-Jun-2008 : Fixed bug with PlotOrientation.HORIZONTAL (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.geom.GeneralPath; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.data.Range; +import org.jfree.data.xy.TableXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PublicCloneable; + +/** + * A stacked area renderer for the {@link XYPlot} class. + * The example shown here is generated by the + * StackedXYAreaChartDemo2.java program included in the + * JFreeChart demo collection: + *

+ * StackedXYAreaRenderer2Sample.png + */ +public class StackedXYAreaRenderer2 extends XYAreaRenderer2 + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7752676509764539182L; + + /** + * This flag controls whether or not the x-coordinates (in Java2D space) + * are rounded to integers. When set to true, this can avoid the vertical + * striping that anti-aliasing can generate. However, the rounding may not + * be appropriate for output in high resolution formats (for example, + * vector graphics formats such as SVG and PDF). + * + * @since 1.0.3 + */ + private boolean roundXCoordinates; + + /** + * Creates a new renderer. + */ + public StackedXYAreaRenderer2() { + this(null, null); + } + + /** + * Constructs a new renderer. + * + * @param labelGenerator the tool tip generator to use. null + * is none. + * @param urlGenerator the URL generator (null permitted). + */ + public StackedXYAreaRenderer2(XYToolTipGenerator labelGenerator, + XYURLGenerator urlGenerator) { + super(labelGenerator, urlGenerator); + this.roundXCoordinates = true; + } + + /** + * Returns the flag that controls whether or not the x-coordinates (in + * Java2D space) are rounded to integer values. + * + * @return The flag. + * + * @since 1.0.4 + * + * @see #setRoundXCoordinates(boolean) + */ + public boolean getRoundXCoordinates() { + return this.roundXCoordinates; + } + + /** + * Sets the flag that controls whether or not the x-coordinates (in + * Java2D space) are rounded to integer values, and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param round the new flag value. + * + * @since 1.0.4 + * + * @see #getRoundXCoordinates() + */ + public void setRoundXCoordinates(boolean round) { + this.roundXCoordinates = round; + fireChangeEvent(); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (or null if the dataset is + * null or empty). + */ + @Override + public Range findRangeBounds(XYDataset dataset) { + if (dataset == null) { + return null; + } + double min = Double.POSITIVE_INFINITY; + double max = Double.NEGATIVE_INFINITY; + TableXYDataset d = (TableXYDataset) dataset; + int itemCount = d.getItemCount(); + for (int i = 0; i < itemCount; i++) { + double[] stackValues = getStackValues((TableXYDataset) dataset, + d.getSeriesCount(), i); + min = Math.min(min, stackValues[0]); + max = Math.max(max, stackValues[1]); + } + if (min == Double.POSITIVE_INFINITY) { + return null; + } + return new Range(min, max); + } + + /** + * Returns the number of passes required by the renderer. + * + * @return 1. + */ + @Override + public int getPassCount() { + return 1; + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState information about crosshairs on a plot. + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + // setup for collecting optional entity info... + Shape entityArea; + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + } + + TableXYDataset tdataset = (TableXYDataset) dataset; + PlotOrientation orientation = plot.getOrientation(); + + // get the data point... + double x1 = dataset.getXValue(series, item); + double y1 = dataset.getYValue(series, item); + if (Double.isNaN(y1)) { + y1 = 0.0; + } + double[] stack1 = getStackValues(tdataset, series, item); + + // get the previous point and the next point so we can calculate a + // "hot spot" for the area (used by the chart entity)... + double x0 = dataset.getXValue(series, Math.max(item - 1, 0)); + double y0 = dataset.getYValue(series, Math.max(item - 1, 0)); + if (Double.isNaN(y0)) { + y0 = 0.0; + } + double[] stack0 = getStackValues(tdataset, series, Math.max(item - 1, + 0)); + + int itemCount = dataset.getItemCount(series); + double x2 = dataset.getXValue(series, Math.min(item + 1, + itemCount - 1)); + double y2 = dataset.getYValue(series, Math.min(item + 1, + itemCount - 1)); + if (Double.isNaN(y2)) { + y2 = 0.0; + } + double[] stack2 = getStackValues(tdataset, series, Math.min(item + 1, + itemCount - 1)); + + double xleft = (x0 + x1) / 2.0; + double xright = (x1 + x2) / 2.0; + double[] stackLeft = averageStackValues(stack0, stack1); + double[] stackRight = averageStackValues(stack1, stack2); + double[] adjStackLeft = adjustedStackValues(stack0, stack1); + double[] adjStackRight = adjustedStackValues(stack1, stack2); + + RectangleEdge edge0 = plot.getDomainAxisEdge(); + + float transX1 = (float) domainAxis.valueToJava2D(x1, dataArea, edge0); + float transXLeft = (float) domainAxis.valueToJava2D(xleft, dataArea, + edge0); + float transXRight = (float) domainAxis.valueToJava2D(xright, dataArea, + edge0); + + if (this.roundXCoordinates) { + transX1 = Math.round(transX1); + transXLeft = Math.round(transXLeft); + transXRight = Math.round(transXRight); + } + float transY1; + + RectangleEdge edge1 = plot.getRangeAxisEdge(); + + GeneralPath left = new GeneralPath(); + GeneralPath right = new GeneralPath(); + if (y1 >= 0.0) { // handle positive value + transY1 = (float) rangeAxis.valueToJava2D(y1 + stack1[1], dataArea, + edge1); + float transStack1 = (float) rangeAxis.valueToJava2D(stack1[1], + dataArea, edge1); + float transStackLeft = (float) rangeAxis.valueToJava2D( + adjStackLeft[1], dataArea, edge1); + + // LEFT POLYGON + if (y0 >= 0.0) { + double yleft = (y0 + y1) / 2.0 + stackLeft[1]; + float transYLeft + = (float) rangeAxis.valueToJava2D(yleft, dataArea, edge1); + if (orientation == PlotOrientation.VERTICAL) { + left.moveTo(transX1, transY1); + left.lineTo(transX1, transStack1); + left.lineTo(transXLeft, transStackLeft); + left.lineTo(transXLeft, transYLeft); + } + else { + left.moveTo(transY1, transX1); + left.lineTo(transStack1, transX1); + left.lineTo(transStackLeft, transXLeft); + left.lineTo(transYLeft, transXLeft); + } + left.closePath(); + } + else { + if (orientation == PlotOrientation.VERTICAL) { + left.moveTo(transX1, transStack1); + left.lineTo(transX1, transY1); + left.lineTo(transXLeft, transStackLeft); + } + else { + left.moveTo(transStack1, transX1); + left.lineTo(transY1, transX1); + left.lineTo(transStackLeft, transXLeft); + } + left.closePath(); + } + + float transStackRight = (float) rangeAxis.valueToJava2D( + adjStackRight[1], dataArea, edge1); + // RIGHT POLYGON + if (y2 >= 0.0) { + double yright = (y1 + y2) / 2.0 + stackRight[1]; + float transYRight + = (float) rangeAxis.valueToJava2D(yright, dataArea, edge1); + if (orientation == PlotOrientation.VERTICAL) { + right.moveTo(transX1, transStack1); + right.lineTo(transX1, transY1); + right.lineTo(transXRight, transYRight); + right.lineTo(transXRight, transStackRight); + } + else { + right.moveTo(transStack1, transX1); + right.lineTo(transY1, transX1); + right.lineTo(transYRight, transXRight); + right.lineTo(transStackRight, transXRight); + } + right.closePath(); + } + else { + if (orientation == PlotOrientation.VERTICAL) { + right.moveTo(transX1, transStack1); + right.lineTo(transX1, transY1); + right.lineTo(transXRight, transStackRight); + } + else { + right.moveTo(transStack1, transX1); + right.lineTo(transY1, transX1); + right.lineTo(transStackRight, transXRight); + } + right.closePath(); + } + } + else { // handle negative value + transY1 = (float) rangeAxis.valueToJava2D(y1 + stack1[0], dataArea, + edge1); + float transStack1 = (float) rangeAxis.valueToJava2D(stack1[0], + dataArea, edge1); + float transStackLeft = (float) rangeAxis.valueToJava2D( + adjStackLeft[0], dataArea, edge1); + + // LEFT POLYGON + if (y0 >= 0.0) { + if (orientation == PlotOrientation.VERTICAL) { + left.moveTo(transX1, transStack1); + left.lineTo(transX1, transY1); + left.lineTo(transXLeft, transStackLeft); + } + else { + left.moveTo(transStack1, transX1); + left.lineTo(transY1, transX1); + left.lineTo(transStackLeft, transXLeft); + } + left.clone(); + } + else { + double yleft = (y0 + y1) / 2.0 + stackLeft[0]; + float transYLeft = (float) rangeAxis.valueToJava2D(yleft, + dataArea, edge1); + if (orientation == PlotOrientation.VERTICAL) { + left.moveTo(transX1, transY1); + left.lineTo(transX1, transStack1); + left.lineTo(transXLeft, transStackLeft); + left.lineTo(transXLeft, transYLeft); + } + else { + left.moveTo(transY1, transX1); + left.lineTo(transStack1, transX1); + left.lineTo(transStackLeft, transXLeft); + left.lineTo(transYLeft, transXLeft); + } + left.closePath(); + } + float transStackRight = (float) rangeAxis.valueToJava2D( + adjStackRight[0], dataArea, edge1); + + // RIGHT POLYGON + if (y2 >= 0.0) { + if (orientation == PlotOrientation.VERTICAL) { + right.moveTo(transX1, transStack1); + right.lineTo(transX1, transY1); + right.lineTo(transXRight, transStackRight); + } + else { + right.moveTo(transStack1, transX1); + right.lineTo(transY1, transX1); + right.lineTo(transStackRight, transXRight); + } + right.closePath(); + } + else { + double yright = (y1 + y2) / 2.0 + stackRight[0]; + float transYRight = (float) rangeAxis.valueToJava2D(yright, + dataArea, edge1); + if (orientation == PlotOrientation.VERTICAL) { + right.moveTo(transX1, transStack1); + right.lineTo(transX1, transY1); + right.lineTo(transXRight, transYRight); + right.lineTo(transXRight, transStackRight); + } + else { + right.moveTo(transStack1, transX1); + right.lineTo(transY1, transX1); + right.lineTo(transYRight, transXRight); + right.lineTo(transStackRight, transXRight); + } + right.closePath(); + } + } + + // Get series Paint and Stroke + Paint itemPaint = getItemPaint(series, item); + if (pass == 0) { + g2.setPaint(itemPaint); + g2.fill(left); + g2.fill(right); + } + + // add an entity for the item... + if (entities != null) { + GeneralPath gp = new GeneralPath(left); + gp.append(right, false); + entityArea = gp; + addEntity(entities, entityArea, dataset, series, item, + transX1, transY1); + } + + } + + /** + * Calculates the stacked values (one positive and one negative) of all + * series up to, but not including, series for the specified + * item. It returns [0.0, 0.0] if series is the first series. + * + * @param dataset the dataset (null not permitted). + * @param series the series index. + * @param index the item index. + * + * @return An array containing the cumulative negative and positive values + * for all series values up to but excluding series + * for index. + */ + private double[] getStackValues(TableXYDataset dataset, + int series, int index) { + double[] result = new double[2]; + for (int i = 0; i < series; i++) { + double v = dataset.getYValue(i, index); + if (!Double.isNaN(v)) { + if (v >= 0.0) { + result[1] += v; + } + else { + result[0] += v; + } + } + } + return result; + } + + /** + * Returns a pair of "stack" values calculated as the mean of the two + * specified stack value pairs. + * + * @param stack1 the first stack pair. + * @param stack2 the second stack pair. + * + * @return A pair of average stack values. + */ + private double[] averageStackValues(double[] stack1, double[] stack2) { + double[] result = new double[2]; + result[0] = (stack1[0] + stack2[0]) / 2.0; + result[1] = (stack1[1] + stack2[1]) / 2.0; + return result; + } + + /** + * Calculates adjusted stack values from the supplied values. The value is + * the mean of the supplied values, unless either of the supplied values + * is zero, in which case the adjusted value is zero also. + * + * @param stack1 the first stack pair. + * @param stack2 the second stack pair. + * + * @return A pair of average stack values. + */ + private double[] adjustedStackValues(double[] stack1, double[] stack2) { + double[] result = new double[2]; + if (stack1[0] == 0.0 || stack2[0] == 0.0) { + result[0] = 0.0; + } + else { + result[0] = (stack1[0] + stack2[0]) / 2.0; + } + if (stack1[1] == 0.0 || stack2[1] == 0.0) { + result[1] = 0.0; + } + else { + result[1] = (stack1[1] + stack2[1]) / 2.0; + } + return result; + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StackedXYAreaRenderer2)) { + return false; + } + StackedXYAreaRenderer2 that = (StackedXYAreaRenderer2) obj; + if (this.roundXCoordinates != that.roundXCoordinates) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java new file mode 100755 index 0000000..5e10de0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StackedXYBarRenderer.java @@ -0,0 +1,442 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * StackedXYBarRenderer.java + * ------------------------- + * (C) Copyright 2004-2011, by Andreas Schroeder and Contributors. + * + * Original Author: Andreas Schroeder; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 01-Apr-2004 : Version 1 (AS); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 15-Aug-2004 : Added drawBarOutline to control draw/don't-draw bar + * outlines (BN); + * 10-Sep-2004 : drawBarOutline attribute is now inherited from XYBarRenderer + * and double primitives are retrieved from the dataset rather + * than Number objects (DG); + * 07-Jan-2005 : Updated for method name change in DatasetUtilities (DG); + * 25-Jan-2005 : Modified to handle negative values correctly (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 06-Dec-2006 : Added support for GradientPaint (DG); + * 15-Mar-2007 : Added renderAsPercentages option (DG); + * 24-Jun-2008 : Added new barPainter mechanism (DG); + * 23-Sep-2008 : Check shadow visibility before drawing shadow (DG); + * 28-May-2009 : Fixed bar positioning with inverted domain axis (DG); + * 07-Act-2011 : Fix for Bug #3035289: Patch #3035325 (MH); + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.ItemLabelAnchor; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.labels.XYItemLabelGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.Range; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.TableXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.TextAnchor; + +/** + * A bar renderer that displays the series items stacked. + * The dataset used together with this renderer must be a + * {@link org.jfree.data.xy.IntervalXYDataset} and a + * {@link org.jfree.data.xy.TableXYDataset}. For example, the + * dataset class {@link org.jfree.data.xy.CategoryTableXYDataset} + * implements both interfaces. + * + * The example shown here is generated by the + * StackedXYBarChartDemo2.java program included in the + * JFreeChart demo collection: + *

+ * StackedXYBarRendererSample.png + + */ +public class StackedXYBarRenderer extends XYBarRenderer { + + /** For serialization. */ + private static final long serialVersionUID = -7049101055533436444L; + + /** A flag that controls whether the bars display values or percentages. */ + private boolean renderAsPercentages; + + /** + * Creates a new renderer. + */ + public StackedXYBarRenderer() { + this(0.0); + } + + /** + * Creates a new renderer. + * + * @param margin the percentual amount of the bars that are cut away. + */ + public StackedXYBarRenderer(double margin) { + super(margin); + this.renderAsPercentages = false; + + // set the default item label positions, which will only be used if + // the user requests visible item labels... + ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.CENTER, + TextAnchor.CENTER); + setBasePositiveItemLabelPosition(p); + setBaseNegativeItemLabelPosition(p); + setPositiveItemLabelPositionFallback(null); + setNegativeItemLabelPositionFallback(null); + } + + /** + * Returns true if the renderer displays each item value as + * a percentage (so that the stacked bars add to 100%), and + * false otherwise. + * + * @return A boolean. + * + * @see #setRenderAsPercentages(boolean) + * + * @since 1.0.5 + */ + public boolean getRenderAsPercentages() { + return this.renderAsPercentages; + } + + /** + * Sets the flag that controls whether the renderer displays each item + * value as a percentage (so that the stacked bars add to 100%), and sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param asPercentages the flag. + * + * @see #getRenderAsPercentages() + * + * @since 1.0.5 + */ + public void setRenderAsPercentages(boolean asPercentages) { + this.renderAsPercentages = asPercentages; + fireChangeEvent(); + } + + /** + * Returns 3 to indicate that this renderer requires three + * passes for drawing (shadows are drawn in the first pass, the bars in the + * second, and item labels are drawn in the third pass so that + * they always appear in front of all the bars). + * + * @return 2. + */ + @Override + public int getPassCount() { + return 3; + } + + /** + * Initialises the renderer and returns a state object that should be + * passed to all subsequent calls to the drawItem() method. Here there is + * nothing to do. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param data the data. + * @param info an optional info collection object to return data back to + * the caller. + * + * @return A state object. + */ + @Override + public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, + XYPlot plot, XYDataset data, PlotRenderingInfo info) { + return new XYBarRendererState(info); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + */ + @Override + public Range findRangeBounds(XYDataset dataset) { + if (dataset != null) { + if (this.renderAsPercentages) { + return new Range(0.0, 1.0); + } + else { + return DatasetUtilities.findStackedRangeBounds( + (TableXYDataset) dataset); + } + } + else { + return null; + } + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the plot is being drawn. + * @param info collects information about the drawing. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + if (!getItemVisible(series, item)) { + return; + } + + if (!(dataset instanceof IntervalXYDataset + && dataset instanceof TableXYDataset)) { + String message = "dataset (type " + dataset.getClass().getName() + + ") has wrong type:"; + boolean and = false; + if (!IntervalXYDataset.class.isAssignableFrom(dataset.getClass())) { + message += " it is no IntervalXYDataset"; + and = true; + } + if (!TableXYDataset.class.isAssignableFrom(dataset.getClass())) { + if (and) { + message += " and"; + } + message += " it is no TableXYDataset"; + } + + throw new IllegalArgumentException(message); + } + + IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset; + double value = intervalDataset.getYValue(series, item); + if (Double.isNaN(value)) { + return; + } + + // if we are rendering the values as percentages, we need to calculate + // the total for the current item. Unfortunately here we end up + // repeating the calculation more times than is strictly necessary - + // hopefully I'll come back to this and find a way to add the + // total(s) to the renderer state. The other problem is we implicitly + // assume the dataset has no negative values...perhaps that can be + // fixed too. + double total = 0.0; + if (this.renderAsPercentages) { + total = DatasetUtilities.calculateStackTotal( + (TableXYDataset) dataset, item); + value = value / total; + } + + double positiveBase = 0.0; + double negativeBase = 0.0; + + for (int i = 0; i < series; i++) { + double v = dataset.getYValue(i, item); + if (!Double.isNaN(v) && isSeriesVisible(i)) { + if (this.renderAsPercentages) { + v = v / total; + } + if (v > 0) { + positiveBase = positiveBase + v; + } + else { + negativeBase = negativeBase + v; + } + } + } + + double translatedBase; + double translatedValue; + RectangleEdge edgeR = plot.getRangeAxisEdge(); + if (value > 0.0) { + translatedBase = rangeAxis.valueToJava2D(positiveBase, dataArea, + edgeR); + translatedValue = rangeAxis.valueToJava2D(positiveBase + value, + dataArea, edgeR); + } + else { + translatedBase = rangeAxis.valueToJava2D(negativeBase, dataArea, + edgeR); + translatedValue = rangeAxis.valueToJava2D(negativeBase + value, + dataArea, edgeR); + } + + RectangleEdge edgeD = plot.getDomainAxisEdge(); + double startX = intervalDataset.getStartXValue(series, item); + if (Double.isNaN(startX)) { + return; + } + double translatedStartX = domainAxis.valueToJava2D(startX, dataArea, + edgeD); + + double endX = intervalDataset.getEndXValue(series, item); + if (Double.isNaN(endX)) { + return; + } + double translatedEndX = domainAxis.valueToJava2D(endX, dataArea, edgeD); + + double translatedWidth = Math.max(1, Math.abs(translatedEndX + - translatedStartX)); + double translatedHeight = Math.abs(translatedValue - translatedBase); + if (getMargin() > 0.0) { + double cut = translatedWidth * getMargin(); + translatedWidth = translatedWidth - cut; + translatedStartX = translatedStartX + cut / 2; + } + + Rectangle2D bar = null; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + bar = new Rectangle2D.Double(Math.min(translatedBase, + translatedValue), Math.min(translatedEndX, + translatedStartX), translatedHeight, translatedWidth); + } + else if (orientation == PlotOrientation.VERTICAL) { + bar = new Rectangle2D.Double(Math.min(translatedStartX, + translatedEndX), Math.min(translatedBase, translatedValue), + translatedWidth, translatedHeight); + } else { + throw new IllegalStateException(); + } + boolean positive = (value > 0.0); + boolean inverted = rangeAxis.isInverted(); + RectangleEdge barBase; + if (orientation == PlotOrientation.HORIZONTAL) { + if (positive && inverted || !positive && !inverted) { + barBase = RectangleEdge.RIGHT; + } + else { + barBase = RectangleEdge.LEFT; + } + } + else { + if (positive && !inverted || !positive && inverted) { + barBase = RectangleEdge.BOTTOM; + } + else { + barBase = RectangleEdge.TOP; + } + } + + if (pass == 0) { + if (getShadowsVisible()) { + getBarPainter().paintBarShadow(g2, this, series, item, bar, + barBase, false); + } + } + else if (pass == 1) { + getBarPainter().paintBar(g2, this, series, item, bar, barBase); + + // add an entity for the item... + if (info != null) { + EntityCollection entities = info.getOwner() + .getEntityCollection(); + if (entities != null) { + addEntity(entities, bar, dataset, series, item, + bar.getCenterX(), bar.getCenterY()); + } + } + } + else if (pass == 2) { + // handle item label drawing, now that we know all the bars have + // been drawn... + if (isItemLabelVisible(series, item)) { + XYItemLabelGenerator generator = getItemLabelGenerator(series, + item); + drawItemLabel(g2, dataset, series, item, plot, generator, bar, + value < 0.0); + } + } + + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StackedXYBarRenderer)) { + return false; + } + StackedXYBarRenderer that = (StackedXYBarRenderer) obj; + if (this.renderAsPercentages != that.renderAsPercentages) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = super.hashCode(); + result = result * 37 + (this.renderAsPercentages ? 1 : 0); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StandardXYBarPainter.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StandardXYBarPainter.java new file mode 100755 index 0000000..14ed36c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StandardXYBarPainter.java @@ -0,0 +1,225 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * StandardXYBarPainter.java + * ------------------------- + * (C) Copyright 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 19-Jun-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Stroke; +import java.awt.geom.Rectangle2D; +import java.awt.geom.RectangularShape; +import java.io.Serializable; + +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.RectangleEdge; + +/** + * An implementation of the {@link XYBarPainter} interface that preserves the + * behaviour of bar painting that existed prior to the introduction of the + * {@link XYBarPainter} interface. + * + * @see GradientXYBarPainter + * + * @since 1.0.11 + */ +public class StandardXYBarPainter implements XYBarPainter, Serializable { + + /** + * Creates a new instance. + */ + public StandardXYBarPainter() { + } + + /** + * Paints a single bar instance. + * + * @param g2 the graphics target. + * @param renderer the renderer. + * @param row the row index. + * @param column the column index. + * @param bar the bar + * @param base indicates which side of the rectangle is the base of the + * bar. + */ + @Override + public void paintBar(Graphics2D g2, XYBarRenderer renderer, int row, + int column, RectangularShape bar, RectangleEdge base) { + + Paint itemPaint = renderer.getItemPaint(row, column); + GradientPaintTransformer t = renderer.getGradientPaintTransformer(); + if (t != null && itemPaint instanceof GradientPaint) { + itemPaint = t.transform((GradientPaint) itemPaint, bar); + } + g2.setPaint(itemPaint); + g2.fill(bar); + + // draw the outline... + if (renderer.isDrawBarOutline()) { + // && state.getBarWidth() > BAR_OUTLINE_WIDTH_THRESHOLD) { + Stroke stroke = renderer.getItemOutlineStroke(row, column); + Paint paint = renderer.getItemOutlinePaint(row, column); + if (stroke != null && paint != null) { + g2.setStroke(stroke); + g2.setPaint(paint); + g2.draw(bar); + } + } + + } + + /** + * Paints a single bar instance. + * + * @param g2 the graphics target. + * @param renderer the renderer. + * @param row the row index. + * @param column the column index. + * @param bar the bar + * @param base indicates which side of the rectangle is the base of the + * bar. + * @param pegShadow peg the shadow to the base of the bar? + */ + @Override + public void paintBarShadow(Graphics2D g2, XYBarRenderer renderer, int row, + int column, RectangularShape bar, RectangleEdge base, + boolean pegShadow) { + + // handle a special case - if the bar colour has alpha == 0, it is + // invisible so we shouldn't draw any shadow + Paint itemPaint = renderer.getItemPaint(row, column); + if (itemPaint instanceof Color) { + Color c = (Color) itemPaint; + if (c.getAlpha() == 0) { + return; + } + } + + RectangularShape shadow = createShadow(bar, renderer.getShadowXOffset(), + renderer.getShadowYOffset(), base, pegShadow); + g2.setPaint(Color.gray); + g2.fill(shadow); + + } + + /** + * Creates a shadow for the bar. + * + * @param bar the bar shape. + * @param xOffset the x-offset for the shadow. + * @param yOffset the y-offset for the shadow. + * @param base the edge that is the base of the bar. + * @param pegShadow peg the shadow to the base? + * + * @return A rectangle for the shadow. + */ + private Rectangle2D createShadow(RectangularShape bar, double xOffset, + double yOffset, RectangleEdge base, boolean pegShadow) { + double x0 = bar.getMinX(); + double x1 = bar.getMaxX(); + double y0 = bar.getMinY(); + double y1 = bar.getMaxY(); + if (base == RectangleEdge.TOP) { + x0 += xOffset; + x1 += xOffset; + if (!pegShadow) { + y0 += yOffset; + } + y1 += yOffset; + } + else if (base == RectangleEdge.BOTTOM) { + x0 += xOffset; + x1 += xOffset; + y0 += yOffset; + if (!pegShadow) { + y1 += yOffset; + } + } + else if (base == RectangleEdge.LEFT) { + if (!pegShadow) { + x0 += xOffset; + } + x1 += xOffset; + y0 += yOffset; + y1 += yOffset; + } + else if (base == RectangleEdge.RIGHT) { + x0 += xOffset; + if (!pegShadow) { + x1 += xOffset; + } + y0 += yOffset; + y1 += yOffset; + } + return new Rectangle2D.Double(x0, y0, (x1 - x0), (y1 - y0)); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the obj (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardXYBarPainter)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int hash = 37; + // no fields to compute... + return hash; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java new file mode 100755 index 0000000..425100e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/StandardXYItemRenderer.java @@ -0,0 +1,1142 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * StandardXYItemRenderer.java + * --------------------------- + * (C) Copyright 2001-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Mark Watson (www.markwatson.com); + * Jonathan Nash; + * Andreas Schneider; + * Norbert Kiesel (for TBD Networks); + * Christian W. Zuckschwerdt; + * Bill Kelemen; + * Nicolas Brodu (for Astrium and EADS Corporate Research + * Center); + * + * Changes: + * -------- + * 19-Oct-2001 : Version 1, based on code by Mark Watson (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * 21-Dec-2001 : Added working line instance to improve performance (DG); + * 22-Jan-2002 : Added code to lock crosshairs to data points. Based on code + * by Jonathan Nash (DG); + * 23-Jan-2002 : Added DrawInfo parameter to drawItem() method (DG); + * 28-Mar-2002 : Added a property change listener mechanism so that the + * renderer no longer needs to be immutable (DG); + * 02-Apr-2002 : Modified to handle null values (DG); + * 09-Apr-2002 : Modified draw method to return void. Removed the translated + * zero from the drawItem method. Override the initialise() + * method to calculate it (DG); + * 13-May-2002 : Added code from Andreas Schneider to allow changing + * shapes/colors per item (DG); + * 24-May-2002 : Incorporated tooltips into chart entities (DG); + * 25-Jun-2002 : Removed redundant code (DG); + * 05-Aug-2002 : Incorporated URLs for HTML image maps into chart entities (RA); + * 08-Aug-2002 : Added discontinuous lines option contributed by + * Norbert Kiesel (DG); + * 20-Aug-2002 : Added user definable default values to be returned by + * protected methods unless overridden by a subclass (DG); + * 23-Sep-2002 : Updated for changes in the XYItemRenderer interface (DG); + * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Modified drawItem() method signature (DG); + * 15-May-2003 : Modified to take into account the plot orientation (DG); + * 29-Jul-2003 : Amended code that doesn't compile with JDK 1.2.2 (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 24-Aug-2003 : Added null/NaN checks in drawItem (BK); + * 08-Sep-2003 : Fixed serialization (NB); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 21-Jan-2004 : Override for getLegendItem() method (DG); + * 27-Jan-2004 : Moved working line into state object (DG); + * 10-Feb-2004 : Changed drawItem() method to make cut-and-paste overriding + * easier (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed + * XYToolTipGenerator --> XYItemLabelGenerator (DG); + * 08-Jun-2004 : Modified to use getX() and getY() methods (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 25-Aug-2004 : Created addEntity() method in superclass (DG); + * 08-Oct-2004 : Added 'gapThresholdType' as suggested by Mike Watts (DG); + * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); + * 23-Feb-2005 : Fixed getLegendItem() method to show lines. Fixed bug + * 1077108 (shape not visible for first item in series) (DG); + * 10-Apr-2005 : Fixed item label positioning with horizontal orientation (DG); + * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG); + * 27-Apr-2005 : Use generator for series label in legend (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 15-Jun-2006 : Fixed bug (1380480) for rendering series as path (DG); + * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); + * 14-Mar-2007 : Fixed problems with the equals() and clone() methods (DG); + * 23-Mar-2007 : Clean-up of shapesFilled attributes (DG); + * 20-Apr-2007 : Updated getLegendItem() and drawItem() for renderer + * change (DG); + * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() + * method (DG); + * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); + * 08-Jun-2007 : Fixed bug in entity creation (DG); + * 21-Nov-2007 : Deprecated override flag methods (DG); + * 02-Jun-2008 : Fixed tooltips for data items at lower edges of data area (DG); + * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.Paint; +import java.awt.Point; +import java.awt.Shape; +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.LegendItem; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.CrosshairState; +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.urls.XYURLGenerator; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.BooleanList; +import org.jfree.util.BooleanUtilities; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; +import org.jfree.util.UnitType; + +/** + * Standard item renderer for an {@link XYPlot}. This class can draw (a) + * shapes at each point, or (b) lines between points, or (c) both shapes and + * lines. + *

+ * This renderer has been retained for historical reasons and, in general, you + * should use the {@link XYLineAndShapeRenderer} class instead. + */ +public class StandardXYItemRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -3271351259436865995L; + + /** Constant for the type of rendering (shapes only). */ + public static final int SHAPES = 1; + + /** Constant for the type of rendering (lines only). */ + public static final int LINES = 2; + + /** Constant for the type of rendering (shapes and lines). */ + public static final int SHAPES_AND_LINES = SHAPES | LINES; + + /** Constant for the type of rendering (images only). */ + public static final int IMAGES = 4; + + /** Constant for the type of rendering (discontinuous lines). */ + public static final int DISCONTINUOUS = 8; + + /** Constant for the type of rendering (discontinuous lines). */ + public static final int DISCONTINUOUS_LINES = LINES | DISCONTINUOUS; + + /** A flag indicating whether or not shapes are drawn at each XY point. */ + private boolean baseShapesVisible; + + /** A flag indicating whether or not lines are drawn between XY points. */ + private boolean plotLines; + + /** A flag indicating whether or not images are drawn between XY points. */ + private boolean plotImages; + + /** A flag controlling whether or not discontinuous lines are used. */ + private boolean plotDiscontinuous; + + /** Specifies how the gap threshold value is interpreted. */ + private UnitType gapThresholdType = UnitType.RELATIVE; + + /** Threshold for deciding when to discontinue a line. */ + private double gapThreshold = 1.0; + + /** + * A flag that controls whether or not shapes are filled for ALL series. + * + * @deprecated As of 1.0.8, this override should not be used. + */ + private Boolean shapesFilled; + + /** + * A table of flags that control (per series) whether or not shapes are + * filled. + */ + private BooleanList seriesShapesFilled; + + /** The default value returned by the getShapeFilled() method. */ + private boolean baseShapesFilled; + + /** + * A flag that controls whether or not each series is drawn as a single + * path. + */ + private boolean drawSeriesLineAsPath; + + /** + * The shape that is used to represent a line in the legend. + * This should never be set to null. + */ + private transient Shape legendLine; + + /** + * Constructs a new renderer. + */ + public StandardXYItemRenderer() { + this(LINES, null); + } + + /** + * Constructs a new renderer. To specify the type of renderer, use one of + * the constants: {@link #SHAPES}, {@link #LINES} or + * {@link #SHAPES_AND_LINES}. + * + * @param type the type. + */ + public StandardXYItemRenderer(int type) { + this(type, null); + } + + /** + * Constructs a new renderer. To specify the type of renderer, use one of + * the constants: {@link #SHAPES}, {@link #LINES} or + * {@link #SHAPES_AND_LINES}. + * + * @param type the type of renderer. + * @param toolTipGenerator the item label generator (null + * permitted). + */ + public StandardXYItemRenderer(int type, + XYToolTipGenerator toolTipGenerator) { + this(type, toolTipGenerator, null); + } + + /** + * Constructs a new renderer. To specify the type of renderer, use one of + * the constants: {@link #SHAPES}, {@link #LINES} or + * {@link #SHAPES_AND_LINES}. + * + * @param type the type of renderer. + * @param toolTipGenerator the item label generator (null + * permitted). + * @param urlGenerator the URL generator. + */ + public StandardXYItemRenderer(int type, + XYToolTipGenerator toolTipGenerator, + XYURLGenerator urlGenerator) { + + super(); + setBaseToolTipGenerator(toolTipGenerator); + setURLGenerator(urlGenerator); + if ((type & SHAPES) != 0) { + this.baseShapesVisible = true; + } + if ((type & LINES) != 0) { + this.plotLines = true; + } + if ((type & IMAGES) != 0) { + this.plotImages = true; + } + if ((type & DISCONTINUOUS) != 0) { + this.plotDiscontinuous = true; + } + + this.shapesFilled = null; + this.seriesShapesFilled = new BooleanList(); + this.baseShapesFilled = true; + this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0); + this.drawSeriesLineAsPath = false; + } + + /** + * Returns true if shapes are being plotted by the renderer. + * + * @return true if shapes are being plotted by the renderer. + * + * @see #setBaseShapesVisible + */ + public boolean getBaseShapesVisible() { + return this.baseShapesVisible; + } + + /** + * Sets the flag that controls whether or not a shape is plotted at each + * data point. + * + * @param flag the flag. + * + * @see #getBaseShapesVisible + */ + public void setBaseShapesVisible(boolean flag) { + if (this.baseShapesVisible != flag) { + this.baseShapesVisible = flag; + fireChangeEvent(); + } + } + + // SHAPES FILLED + + /** + * Returns the flag used to control whether or not the shape for an item is + * filled. + *

+ * The default implementation passes control to the + * getSeriesShapesFilled method. You can override this method + * if you require different behaviour. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return A boolean. + * + * @see #getSeriesShapesFilled(int) + */ + public boolean getItemShapeFilled(int series, int item) { + // return the overall setting, if there is one... + if (this.shapesFilled != null) { + return this.shapesFilled.booleanValue(); + } + + // otherwise look up the paint table + Boolean flag = this.seriesShapesFilled.getBoolean(series); + if (flag != null) { + return flag.booleanValue(); + } + else { + return this.baseShapesFilled; + } + } + + /** + * Returns the override flag that controls whether or not shapes are filled + * for ALL series. + * + * @return The flag (possibly null). + * + * @since 1.0.5 + * + * @deprecated As of 1.0.8, you should avoid using this method and rely + * on just the per-series ({@link #getSeriesShapesFilled(int)}) + * and base-level ({@link #getBaseShapesFilled()}) settings. + */ + public Boolean getShapesFilled() { + return this.shapesFilled; + } + + /** + * Sets the override flag that controls whether or not shapes are filled + * for ALL series and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param filled the flag. + * + * @see #setShapesFilled(Boolean) + * + * @deprecated As of 1.0.8, you should avoid using this method and rely + * on just the per-series ({@link #setSeriesShapesFilled(int, + * Boolean)}) and base-level ({@link #setBaseShapesVisible( + * boolean)}) settings. + */ + public void setShapesFilled(boolean filled) { + // here we use BooleanUtilities to remain compatible with JDKs < 1.4 + setShapesFilled(BooleanUtilities.valueOf(filled)); + } + + /** + * Sets the override flag that controls whether or not shapes are filled + * for ALL series and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param filled the flag (null permitted). + * + * @see #setShapesFilled(boolean) + * + * @deprecated As of 1.0.8, you should avoid using this method and rely + * on just the per-series ({@link #setSeriesShapesFilled(int, + * Boolean)}) and base-level ({@link #setBaseShapesVisible( + * boolean)}) settings. + */ + public void setShapesFilled(Boolean filled) { + this.shapesFilled = filled; + fireChangeEvent(); + } + + /** + * Returns the flag used to control whether or not the shapes for a series + * are filled. + * + * @param series the series index (zero-based). + * + * @return A boolean. + */ + public Boolean getSeriesShapesFilled(int series) { + return this.seriesShapesFilled.getBoolean(series); + } + + /** + * Sets the 'shapes filled' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param flag the flag. + * + * @see #getSeriesShapesFilled(int) + */ + public void setSeriesShapesFilled(int series, Boolean flag) { + this.seriesShapesFilled.setBoolean(series, flag); + fireChangeEvent(); + } + + /** + * Returns the base 'shape filled' attribute. + * + * @return The base flag. + * + * @see #setBaseShapesFilled(boolean) + */ + public boolean getBaseShapesFilled() { + return this.baseShapesFilled; + } + + /** + * Sets the base 'shapes filled' flag and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param flag the flag. + * + * @see #getBaseShapesFilled() + */ + public void setBaseShapesFilled(boolean flag) { + this.baseShapesFilled = flag; + } + + /** + * Returns true if lines are being plotted by the renderer. + * + * @return true if lines are being plotted by the renderer. + * + * @see #setPlotLines(boolean) + */ + public boolean getPlotLines() { + return this.plotLines; + } + + /** + * Sets the flag that controls whether or not a line is plotted between + * each data point and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param flag the flag. + * + * @see #getPlotLines() + */ + public void setPlotLines(boolean flag) { + if (this.plotLines != flag) { + this.plotLines = flag; + fireChangeEvent(); + } + } + + /** + * Returns the gap threshold type (relative or absolute). + * + * @return The type. + * + * @see #setGapThresholdType(UnitType) + */ + public UnitType getGapThresholdType() { + return this.gapThresholdType; + } + + /** + * Sets the gap threshold type and sends a {@link RendererChangeEvent} to + * all registered listeners. + * + * @param thresholdType the type (null not permitted). + * + * @see #getGapThresholdType() + */ + public void setGapThresholdType(UnitType thresholdType) { + ParamChecks.nullNotPermitted(thresholdType, "thresholdType"); + this.gapThresholdType = thresholdType; + fireChangeEvent(); + } + + /** + * Returns the gap threshold for discontinuous lines. + * + * @return The gap threshold. + * + * @see #setGapThreshold(double) + */ + public double getGapThreshold() { + return this.gapThreshold; + } + + /** + * Sets the gap threshold for discontinuous lines and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param t the threshold. + * + * @see #getGapThreshold() + */ + public void setGapThreshold(double t) { + this.gapThreshold = t; + fireChangeEvent(); + } + + /** + * Returns true if images are being plotted by the renderer. + * + * @return true if images are being plotted by the renderer. + * + * @see #setPlotImages(boolean) + */ + public boolean getPlotImages() { + return this.plotImages; + } + + /** + * Sets the flag that controls whether or not an image is drawn at each + * data point and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param flag the flag. + * + * @see #getPlotImages() + */ + public void setPlotImages(boolean flag) { + if (this.plotImages != flag) { + this.plotImages = flag; + fireChangeEvent(); + } + } + + /** + * Returns a flag that controls whether or not the renderer shows + * discontinuous lines. + * + * @return true if lines should be discontinuous. + */ + public boolean getPlotDiscontinuous() { + return this.plotDiscontinuous; + } + + /** + * Sets the flag that controls whether or not the renderer shows + * discontinuous lines, and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param flag the new flag value. + * + * @since 1.0.5 + */ + public void setPlotDiscontinuous(boolean flag) { + if (this.plotDiscontinuous != flag) { + this.plotDiscontinuous = flag; + fireChangeEvent(); + } + } + + /** + * Returns a flag that controls whether or not each series is drawn as a + * single path. + * + * @return A boolean. + * + * @see #setDrawSeriesLineAsPath(boolean) + */ + public boolean getDrawSeriesLineAsPath() { + return this.drawSeriesLineAsPath; + } + + /** + * Sets the flag that controls whether or not each series is drawn as a + * single path. + * + * @param flag the flag. + * + * @see #getDrawSeriesLineAsPath() + */ + public void setDrawSeriesLineAsPath(boolean flag) { + this.drawSeriesLineAsPath = flag; + } + + /** + * Returns the shape used to represent a line in the legend. + * + * @return The legend line (never null). + * + * @see #setLegendLine(Shape) + */ + public Shape getLegendLine() { + return this.legendLine; + } + + /** + * Sets the shape used as a line in each legend item and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param line the line (null not permitted). + * + * @see #getLegendLine() + */ + public void setLegendLine(Shape line) { + ParamChecks.nullNotPermitted(line, "line"); + this.legendLine = line; + fireChangeEvent(); + } + + /** + * Returns a legend item for a series. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return A legend item for the series. + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + XYPlot plot = getPlot(); + if (plot == null) { + return null; + } + LegendItem result = null; + XYDataset dataset = plot.getDataset(datasetIndex); + if (dataset != null) { + if (getItemVisible(series, 0)) { + String label = getLegendItemLabelGenerator().generateLabel( + dataset, series); + String description = label; + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel( + dataset, series); + } + Shape shape = lookupLegendShape(series); + boolean shapeFilled = getItemShapeFilled(series, 0); + Paint paint = lookupSeriesPaint(series); + Paint linePaint = paint; + Stroke lineStroke = lookupSeriesStroke(series); + result = new LegendItem(label, description, toolTipText, + urlText, this.baseShapesVisible, shape, shapeFilled, + paint, !shapeFilled, paint, lineStroke, + this.plotLines, this.legendLine, lineStroke, linePaint); + result.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + result.setLabelPaint(labelPaint); + } + result.setDataset(dataset); + result.setDatasetIndex(datasetIndex); + result.setSeriesKey(dataset.getSeriesKey(series)); + result.setSeriesIndex(series); + } + } + return result; + } + + /** + * Records the state for the renderer. This is used to preserve state + * information between calls to the drawItem() method for a single chart + * drawing. + */ + public static class State extends XYItemRendererState { + + /** The path for the current series. */ + public GeneralPath seriesPath; + + /** The series index. */ + private int seriesIndex; + + /** + * A flag that indicates if the last (x, y) point was 'good' + * (non-null). + */ + private boolean lastPointGood; + + /** + * Creates a new state instance. + * + * @param info the plot rendering info. + */ + public State(PlotRenderingInfo info) { + super(info); + } + + /** + * Returns a flag that indicates if the last point drawn (in the + * current series) was 'good' (non-null). + * + * @return A boolean. + */ + public boolean isLastPointGood() { + return this.lastPointGood; + } + + /** + * Sets a flag that indicates if the last point drawn (in the current + * series) was 'good' (non-null). + * + * @param good the flag. + */ + public void setLastPointGood(boolean good) { + this.lastPointGood = good; + } + + /** + * Returns the series index for the current path. + * + * @return The series index for the current path. + */ + public int getSeriesIndex() { + return this.seriesIndex; + } + + /** + * Sets the series index for the current path. + * + * @param index the index. + */ + public void setSeriesIndex(int index) { + this.seriesIndex = index; + } + } + + /** + * Initialises the renderer. + *

+ * This method will be called before the first item is rendered, giving the + * renderer an opportunity to initialise any state information it wants to + * maintain. The renderer can do nothing if it chooses. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param data the data. + * @param info an optional info collection object to return data back to + * the caller. + * + * @return The renderer state. + */ + @Override + public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, + XYPlot plot, XYDataset data, PlotRenderingInfo info) { + + State state = new State(info); + state.seriesPath = new GeneralPath(); + state.seriesIndex = -1; + return state; + + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + boolean itemVisible = getItemVisible(series, item); + + // setup for collecting optional entity info... + Shape entityArea = null; + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + } + + PlotOrientation orientation = plot.getOrientation(); + Paint paint = getItemPaint(series, item); + Stroke seriesStroke = getItemStroke(series, item); + g2.setPaint(paint); + g2.setStroke(seriesStroke); + + // get the data point... + double x1 = dataset.getXValue(series, item); + double y1 = dataset.getYValue(series, item); + if (Double.isNaN(x1) || Double.isNaN(y1)) { + itemVisible = false; + } + + RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); + RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); + double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); + double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); + + if (getPlotLines()) { + if (this.drawSeriesLineAsPath) { + State s = (State) state; + if (s.getSeriesIndex() != series) { + // we are starting a new series path + s.seriesPath.reset(); + s.lastPointGood = false; + s.setSeriesIndex(series); + } + + // update path to reflect latest point + if (itemVisible && !Double.isNaN(transX1) + && !Double.isNaN(transY1)) { + float x = (float) transX1; + float y = (float) transY1; + if (orientation == PlotOrientation.HORIZONTAL) { + x = (float) transY1; + y = (float) transX1; + } + if (s.isLastPointGood()) { + // TODO: check threshold + s.seriesPath.lineTo(x, y); + } + else { + s.seriesPath.moveTo(x, y); + } + s.setLastPointGood(true); + } + else { + s.setLastPointGood(false); + } + if (item == dataset.getItemCount(series) - 1) { + if (s.seriesIndex == series) { + // draw path + g2.setStroke(lookupSeriesStroke(series)); + g2.setPaint(lookupSeriesPaint(series)); + g2.draw(s.seriesPath); + } + } + } + + else if (item != 0 && itemVisible) { + // get the previous data point... + double x0 = dataset.getXValue(series, item - 1); + double y0 = dataset.getYValue(series, item - 1); + if (!Double.isNaN(x0) && !Double.isNaN(y0)) { + boolean drawLine = true; + if (getPlotDiscontinuous()) { + // only draw a line if the gap between the current and + // previous data point is within the threshold + int numX = dataset.getItemCount(series); + double minX = dataset.getXValue(series, 0); + double maxX = dataset.getXValue(series, numX - 1); + if (this.gapThresholdType == UnitType.ABSOLUTE) { + drawLine = Math.abs(x1 - x0) <= this.gapThreshold; + } + else { + drawLine = Math.abs(x1 - x0) <= ((maxX - minX) + / numX * getGapThreshold()); + } + } + if (drawLine) { + double transX0 = domainAxis.valueToJava2D(x0, dataArea, + xAxisLocation); + double transY0 = rangeAxis.valueToJava2D(y0, dataArea, + yAxisLocation); + + // only draw if we have good values + if (Double.isNaN(transX0) || Double.isNaN(transY0) + || Double.isNaN(transX1) || Double.isNaN(transY1)) { + return; + } + + 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)) { + g2.draw(state.workingLine); + } + } + } + } + } + + // we needed to get this far even for invisible items, to ensure that + // seriesPath updates happened, but now there is nothing more we need + // to do for non-visible items... + if (!itemVisible) { + return; + } + + if (getBaseShapesVisible()) { + + Shape shape = getItemShape(series, item); + if (orientation == PlotOrientation.HORIZONTAL) { + shape = ShapeUtilities.createTranslatedShape(shape, transY1, + transX1); + } + else if (orientation == PlotOrientation.VERTICAL) { + shape = ShapeUtilities.createTranslatedShape(shape, transX1, + transY1); + } + if (shape.intersects(dataArea)) { + if (getItemShapeFilled(series, item)) { + g2.fill(shape); + } + else { + g2.draw(shape); + } + } + entityArea = shape; + + } + + if (getPlotImages()) { + Image image = getImage(plot, series, item, transX1, transY1); + if (image != null) { + Point hotspot = getImageHotspot(plot, series, item, transX1, + transY1, image); + g2.drawImage(image, (int) (transX1 - hotspot.getX()), + (int) (transY1 - hotspot.getY()), null); + entityArea = new Rectangle2D.Double(transX1 - hotspot.getX(), + transY1 - hotspot.getY(), image.getWidth(null), + image.getHeight(null)); + } + + } + + double xx = transX1; + double yy = transY1; + if (orientation == PlotOrientation.HORIZONTAL) { + xx = transY1; + yy = transX1; + } + + // draw the item label if there is one... + if (isItemLabelVisible(series, item)) { + drawItemLabel(g2, orientation, dataset, series, item, xx, yy, + (y1 < 0.0)); + } + + int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); + int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); + updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, + rangeAxisIndex, transX1, transY1, orientation); + + // add an entity for the item... + if (entities != null && isPointInRect(dataArea, xx, yy)) { + addEntity(entities, entityArea, dataset, series, item, xx, yy); + } + + } + + /** + * Tests this renderer for equality with another object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof StandardXYItemRenderer)) { + return false; + } + StandardXYItemRenderer that = (StandardXYItemRenderer) obj; + if (this.baseShapesVisible != that.baseShapesVisible) { + return false; + } + if (this.plotLines != that.plotLines) { + return false; + } + if (this.plotImages != that.plotImages) { + return false; + } + if (this.plotDiscontinuous != that.plotDiscontinuous) { + return false; + } + if (this.gapThresholdType != that.gapThresholdType) { + return false; + } + if (this.gapThreshold != that.gapThreshold) { + return false; + } + if (!ObjectUtilities.equal(this.shapesFilled, that.shapesFilled)) { + return false; + } + if (!this.seriesShapesFilled.equals(that.seriesShapesFilled)) { + return false; + } + if (this.baseShapesFilled != that.baseShapesFilled) { + return false; + } + if (this.drawSeriesLineAsPath != that.drawSeriesLineAsPath) { + return false; + } + if (!ShapeUtilities.equal(this.legendLine, that.legendLine)) { + return false; + } + return super.equals(obj); + + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + StandardXYItemRenderer clone = (StandardXYItemRenderer) super.clone(); + clone.seriesShapesFilled + = (BooleanList) this.seriesShapesFilled.clone(); + clone.legendLine = ShapeUtilities.clone(this.legendLine); + return clone; + } + + //////////////////////////////////////////////////////////////////////////// + // PROTECTED METHODS + // These provide the opportunity to subclass the standard renderer and + // create custom effects. + //////////////////////////////////////////////////////////////////////////// + + /** + * Returns the image used to draw a single data item. + * + * @param plot the plot (can be used to obtain standard color information + * etc). + * @param series the series index. + * @param item the item index. + * @param x the x value of the item. + * @param y the y value of the item. + * + * @return The image. + * + * @see #getPlotImages() + */ + protected Image getImage(Plot plot, int series, int item, + double x, double y) { + // this method must be overridden if you want to display images + return null; + } + + /** + * Returns the hotspot of the image used to draw a single data item. + * The hotspot is the point relative to the top left of the image + * that should indicate the data item. The default is the center of the + * image. + * + * @param plot the plot (can be used to obtain standard color information + * etc). + * @param image the image (can be used to get size information about the + * image) + * @param series the series index + * @param item the item index + * @param x the x value of the item + * @param y the y value of the item + * + * @return The hotspot used to draw the data item. + */ + protected Point getImageHotspot(Plot plot, int series, int item, + double x, double y, Image image) { + + int height = image.getHeight(null); + int width = image.getWidth(null); + return new Point(width / 2, height / 2); + + } + + /** + * 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.legendLine = SerialUtilities.readShape(stream); + } + + /** + * 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.legendLine, stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/VectorRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/VectorRenderer.java new file mode 100755 index 0000000..e63bad0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/VectorRenderer.java @@ -0,0 +1,349 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * VectorRenderer.java + * ------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jan-2007 : Version 1 (DG); + * 24-May-2007 : Updated for method name changes (DG); + * 25-May-2007 : Moved from experimental to the main source tree (DG); + * 18-Feb-2008 : Fixed bug 1880114, arrows for horizontal plot + * orientation (DG); + * 22-Apr-2008 : Implemented PublicCloneable (DG); + * 26-Sep-2008 : Added chart entity support (tooltips etc) (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Graphics2D; +import java.awt.geom.GeneralPath; +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +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.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.xy.VectorXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.util.PublicCloneable; + +/** + * A renderer that represents data from an {@link VectorXYDataset} by drawing a + * line with an arrow at each (x, y) point. + * The example shown here is generated by the VectorPlotDemo1.java + * program included in the JFreeChart demo collection: + *

+ * VectorRendererSample.png + * + * @since 1.0.6 + */ +public class VectorRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { + + /** The length of the base. */ + private double baseLength = 0.10; + + /** The length of the head. */ + private double headLength = 0.14; + + /** + * Creates a new XYBlockRenderer instance with default + * attributes. + */ + public VectorRenderer() { + } + + /** + * Returns the lower and upper bounds (range) of the x-values in the + * specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + */ + @Override + public Range findDomainBounds(XYDataset dataset) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + double minimum = Double.POSITIVE_INFINITY; + double maximum = Double.NEGATIVE_INFINITY; + int seriesCount = dataset.getSeriesCount(); + double lvalue; + double uvalue; + if (dataset instanceof VectorXYDataset) { + VectorXYDataset vdataset = (VectorXYDataset) dataset; + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double delta = vdataset.getVectorXValue(series, item); + if (delta < 0.0) { + uvalue = vdataset.getXValue(series, item); + lvalue = uvalue + delta; + } + else { + lvalue = vdataset.getXValue(series, item); + uvalue = lvalue + delta; + } + minimum = Math.min(minimum, lvalue); + maximum = Math.max(maximum, uvalue); + } + } + } + else { + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + lvalue = dataset.getXValue(series, item); + uvalue = lvalue; + minimum = Math.min(minimum, lvalue); + maximum = Math.max(maximum, uvalue); + } + } + } + if (minimum > maximum) { + return null; + } + else { + return new Range(minimum, maximum); + } + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + */ + @Override + public Range findRangeBounds(XYDataset dataset) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + double minimum = Double.POSITIVE_INFINITY; + double maximum = Double.NEGATIVE_INFINITY; + int seriesCount = dataset.getSeriesCount(); + double lvalue; + double uvalue; + if (dataset instanceof VectorXYDataset) { + VectorXYDataset vdataset = (VectorXYDataset) dataset; + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double delta = vdataset.getVectorYValue(series, item); + if (delta < 0.0) { + uvalue = vdataset.getYValue(series, item); + lvalue = uvalue + delta; + } + else { + lvalue = vdataset.getYValue(series, item); + uvalue = lvalue + delta; + } + minimum = Math.min(minimum, lvalue); + maximum = Math.max(maximum, uvalue); + } + } + } + else { + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + lvalue = dataset.getYValue(series, item); + uvalue = lvalue; + minimum = Math.min(minimum, lvalue); + maximum = Math.max(maximum, uvalue); + } + } + } + if (minimum > maximum) { + return null; + } + else { + return new Range(minimum, maximum); + } + } + + /** + * Draws the block representing the specified item. + * + * @param g2 the graphics device. + * @param state the state. + * @param dataArea the data area. + * @param info the plot rendering info. + * @param plot the plot. + * @param domainAxis the x-axis. + * @param rangeAxis the y-axis. + * @param dataset the dataset. + * @param series the series index. + * @param item the item index. + * @param crosshairState the crosshair state. + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + double x = dataset.getXValue(series, item); + double y = dataset.getYValue(series, item); + double dx = 0.0; + double dy = 0.0; + if (dataset instanceof VectorXYDataset) { + dx = ((VectorXYDataset) dataset).getVectorXValue(series, item); + dy = ((VectorXYDataset) dataset).getVectorYValue(series, item); + } + double xx0 = domainAxis.valueToJava2D(x, dataArea, + plot.getDomainAxisEdge()); + double yy0 = rangeAxis.valueToJava2D(y, dataArea, + plot.getRangeAxisEdge()); + double xx1 = domainAxis.valueToJava2D(x + dx, dataArea, + plot.getDomainAxisEdge()); + double yy1 = rangeAxis.valueToJava2D(y + dy, dataArea, + plot.getRangeAxisEdge()); + Line2D line; + PlotOrientation orientation = plot.getOrientation(); + if (orientation.equals(PlotOrientation.HORIZONTAL)) { + line = new Line2D.Double(yy0, xx0, yy1, xx1); + } + else { + line = new Line2D.Double(xx0, yy0, xx1, yy1); + } + g2.setPaint(getItemPaint(series, item)); + g2.setStroke(getItemStroke(series, item)); + g2.draw(line); + + // calculate the arrow head and draw it... + double dxx = (xx1 - xx0); + double dyy = (yy1 - yy0); + double bx = xx0 + (1.0 - this.baseLength) * dxx; + double by = yy0 + (1.0 - this.baseLength) * dyy; + + double cx = xx0 + (1.0 - this.headLength) * dxx; + double cy = yy0 + (1.0 - this.headLength) * dyy; + + double angle = 0.0; + if (dxx != 0.0) { + angle = Math.PI / 2.0 - Math.atan(dyy / dxx); + } + double deltaX = 2.0 * Math.cos(angle); + double deltaY = 2.0 * Math.sin(angle); + + double leftx = cx + deltaX; + double lefty = cy - deltaY; + double rightx = cx - deltaX; + double righty = cy + deltaY; + + GeneralPath p = new GeneralPath(); + if (orientation == PlotOrientation.VERTICAL) { + p.moveTo((float) xx1, (float) yy1); + p.lineTo((float) rightx, (float) righty); + p.lineTo((float) bx, (float) by); + p.lineTo((float) leftx, (float) lefty); + } + else { // orientation is HORIZONTAL + p.moveTo((float) yy1, (float) xx1); + p.lineTo((float) righty, (float) rightx); + p.lineTo((float) by, (float) bx); + p.lineTo((float) lefty, (float) leftx); + } + p.closePath(); + g2.draw(p); + + // setup for collecting optional entity info... + EntityCollection entities; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + if (entities != null) { + addEntity(entities, line.getBounds(), dataset, series, item, + 0.0, 0.0); + } + } + + } + + /** + * Tests this VectorRenderer for equality with an arbitrary + * object. This method returns true if and only if: + *

    + *
  • obj is an instance of VectorRenderer (not + * null);
  • + *
  • obj has the same field values as this + * VectorRenderer;
  • + *
+ * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof VectorRenderer)) { + return false; + } + VectorRenderer that = (VectorRenderer) obj; + if (this.baseLength != that.baseLength) { + return false; + } + if (this.headLength != that.headLength) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of this renderer. + * + * @return A clone of this renderer. + * + * @throws CloneNotSupportedException if there is a problem creating the + * clone. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/WindItemRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/WindItemRenderer.java new file mode 100755 index 0000000..5edd1f6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/WindItemRenderer.java @@ -0,0 +1,208 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * WindItemRenderer.java + * --------------------- + * (C) Copyright 2001-2008, by Achilleus Mantzios and Contributors. + * + * Original Author: Achilleus Mantzios; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 06-Feb-2002 : Version 1, based on code contributed by Achilleus + * Mantzios (DG); + * 28-Mar-2002 : Added a property change listener mechanism so that renderers + * no longer need to be immutable. Changed StrictMath --> Math + * to retain JDK1.2 compatibility (DG); + * 09-Apr-2002 : Changed return type of the drawItem method to void, reflecting + * the change in the XYItemRenderer method (DG); + * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 21-Jan-2003 : Added new constructor (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Modified drawItem() method signature (DG); + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Color; +import java.awt.Font; +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.Serializable; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.xy.WindDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PublicCloneable; + +/** + * A specialised renderer for displaying wind intensity/direction data. + * The example shown here is generated by the WindChartDemo1.java + * program included in the JFreeChart demo collection: + *

+ * WindItemRendererSample.png + */ +public class WindItemRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 8078914101916976844L; + + /** + * Creates a new renderer. + */ + public WindItemRenderer() { + super(); + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param plotArea the area within which the plot is being drawn. + * @param info optional information collection. + * @param plot the plot (can be used to obtain standard color + * information etc). + * @param domainAxis the horizontal axis. + * @param rangeAxis the vertical axis. + * @param dataset the dataset. + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D plotArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + WindDataset windData = (WindDataset) dataset; + + Paint seriesPaint = getItemPaint(series, item); + Stroke seriesStroke = getItemStroke(series, item); + g2.setPaint(seriesPaint); + g2.setStroke(seriesStroke); + + // get the data point... + + Number x = windData.getX(series, item); + Number windDir = windData.getWindDirection(series, item); + Number wforce = windData.getWindForce(series, item); + double windForce = wforce.doubleValue(); + + double wdirt = Math.toRadians(windDir.doubleValue() * (-30.0) - 90.0); + + double ax1, ax2, ay1, ay2, rax2, ray2; + + RectangleEdge domainAxisLocation = plot.getDomainAxisEdge(); + RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); + ax1 = domainAxis.valueToJava2D(x.doubleValue(), plotArea, + domainAxisLocation); + ay1 = rangeAxis.valueToJava2D(0.0, plotArea, rangeAxisLocation); + + rax2 = x.doubleValue() + (windForce * Math.cos(wdirt) * 8000000.0); + ray2 = windForce * Math.sin(wdirt); + + ax2 = domainAxis.valueToJava2D(rax2, plotArea, domainAxisLocation); + ay2 = rangeAxis.valueToJava2D(ray2, plotArea, rangeAxisLocation); + + int diri = windDir.intValue(); + int forcei = wforce.intValue(); + String dirforce = diri + "-" + forcei; + Line2D line = new Line2D.Double(ax1, ay1, ax2, ay2); + + g2.draw(line); + g2.setPaint(Color.blue); + g2.setFont(new Font("Dialog", 1, 9)); + + g2.drawString(dirforce, (float) ax1, (float) ay1); + + g2.setPaint(seriesPaint); + g2.setStroke(seriesStroke); + + double alx2, aly2, arx2, ary2; + double ralx2, raly2, rarx2, rary2; + + double aldir = Math.toRadians(windDir.doubleValue() + * (-30.0) - 90.0 - 5.0); + ralx2 = wforce.doubleValue() * Math.cos(aldir) * 8000000 * 0.8 + + x.doubleValue(); + raly2 = wforce.doubleValue() * Math.sin(aldir) * 0.8; + + alx2 = domainAxis.valueToJava2D(ralx2, plotArea, domainAxisLocation); + aly2 = rangeAxis.valueToJava2D(raly2, plotArea, rangeAxisLocation); + + line = new Line2D.Double(alx2, aly2, ax2, ay2); + g2.draw(line); + + double ardir = Math.toRadians(windDir.doubleValue() + * (-30.0) - 90.0 + 5.0); + rarx2 = wforce.doubleValue() * Math.cos(ardir) * 8000000 * 0.8 + + x.doubleValue(); + rary2 = wforce.doubleValue() * Math.sin(ardir) * 0.8; + + arx2 = domainAxis.valueToJava2D(rarx2, plotArea, domainAxisLocation); + ary2 = rangeAxis.valueToJava2D(rary2, plotArea, rangeAxisLocation); + + line = new Line2D.Double(arx2, ary2, ax2, ay2); + g2.draw(line); + + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYAreaRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYAreaRenderer.java new file mode 100755 index 0000000..2fc7a26 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYAreaRenderer.java @@ -0,0 +1,779 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * XYAreaRenderer.java + * ------------------- + * (C) Copyright 2002-2013, by Hari and Contributors. + * + * Original Author: Hari (ourhari@hotmail.com); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Richard Atkinson; + * Christian W. Zuckschwerdt; + * Martin Krauskopf; + * + * Changes: + * -------- + * 03-Apr-2002 : Version 1, contributed by Hari. This class is based on the + * StandardXYItemRenderer class (DG); + * 09-Apr-2002 : Removed the translated zero from the drawItem method - + * overridden the initialise() method to calculate it (DG); + * 30-May-2002 : Added tool tip generator to constructor to match super + * class (DG); + * 25-Jun-2002 : Removed unnecessary local variable (DG); + * 05-Aug-2002 : Small modification to drawItem method to support URLs for HTML + * image maps (RA); + * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 07-Nov-2002 : Renamed AreaXYItemRenderer --> XYAreaRenderer (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Modified drawItem() method signature (DG); + * 27-Jul-2003 : Made line and polygon properties protected rather than + * private (RA); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 07-Oct-2003 : Added renderer state (DG); + * 08-Dec-2003 : Modified hotspot for chart entity (DG); + * 10-Feb-2004 : Changed the drawItem() method to make cut-and-paste overriding + * easier. Also moved state class into this class (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed + * XYToolTipGenerator --> XYItemLabelGenerator (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); + * 19-Jan-2005 : Now accesses primitives only from dataset (DG); + * 21-Mar-2005 : Override getLegendItem() and equals() methods (DG); + * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); + * 14-Feb-2007 : Fixed bug in clone() (DG); + * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); + * 04-May-2007 : Set processVisibleItemsOnly flag to false (DG); + * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); + * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); + * 17-Jun-2008 : Apply legend font and paint attributes (DG); + * 31-Dec-2008 : Fix for bug 2471906 - dashed outlines performance issue (DG); + * 11-Jun-2009 : Added a useFillPaint flag and a GradientPaintTransformer for + * the paint under the series (DG); + * 06-Oct-2011 : Avoid GeneralPath methods requiring Java 1.5 (MK); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.BasicStroke; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Area; +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 org.jfree.chart.HashUtilities; +import org.jfree.chart.LegendItem; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.XYSeriesLabelGenerator; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.StandardGradientPaintTransformer; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * Area item renderer for an {@link XYPlot}. This class can draw (a) shapes at + * each point, or (b) lines between points, or (c) both shapes and lines, + * or (d) filled areas, or (e) filled areas and shapes. The example shown here + * is generated by the XYAreaRendererDemo1.java program included + * in the JFreeChart demo collection: + *

+ * XYAreaRendererSample.png + */ +public class XYAreaRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, PublicCloneable { + + /** For serialization. */ + private static final long serialVersionUID = -4481971353973876747L; + + /** + * A state object used by this renderer. + */ + static class XYAreaRendererState extends XYItemRendererState { + + /** Working storage for the area under one series. */ + public GeneralPath area; + + /** Working line that can be recycled. */ + public Line2D line; + + /** + * Creates a new state. + * + * @param info the plot rendering info. + */ + public XYAreaRendererState(PlotRenderingInfo info) { + super(info); + this.area = new GeneralPath(); + this.line = new Line2D.Double(); + } + + } + + /** Useful constant for specifying the type of rendering (shapes only). */ + public static final int SHAPES = 1; + + /** Useful constant for specifying the type of rendering (lines only). */ + public static final int LINES = 2; + + /** + * Useful constant for specifying the type of rendering (shapes and lines). + */ + public static final int SHAPES_AND_LINES = 3; + + /** Useful constant for specifying the type of rendering (area only). */ + public static final int AREA = 4; + + /** + * Useful constant for specifying the type of rendering (area and shapes). + */ + public static final int AREA_AND_SHAPES = 5; + + /** A flag indicating whether or not shapes are drawn at each XY point. */ + private boolean plotShapes; + + /** A flag indicating whether or not lines are drawn between XY points. */ + private boolean plotLines; + + /** A flag indicating whether or not Area are drawn at each XY point. */ + private boolean plotArea; + + /** A flag that controls whether or not the outline is shown. */ + private boolean showOutline; + + /** + * The shape used to represent an area in each legend item (this should + * never be null). + */ + private transient Shape legendArea; + + /** + * A flag that can be set to specify that the fill paint should be used + * to fill the area under the renderer. + * + * @since 1.0.14 + */ + private boolean useFillPaint; + + /** + * A transformer that is applied to the paint used to fill under the + * area *if* it is an instance of GradientPaint. + * + * @since 1.0.14 + */ + private GradientPaintTransformer gradientTransformer; + + /** + * Constructs a new renderer. + */ + public XYAreaRenderer() { + this(AREA); + } + + /** + * Constructs a new renderer. + * + * @param type the type of the renderer. + */ + public XYAreaRenderer(int type) { + this(type, null, null); + } + + /** + * Constructs a new renderer. To specify the type of renderer, use one of + * the constants: SHAPES, LINES, + * SHAPES_AND_LINES, AREA or + * AREA_AND_SHAPES. + * + * @param type the type of renderer. + * @param toolTipGenerator the tool tip generator to use + * (null permitted). + * @param urlGenerator the URL generator (null permitted). + */ + public XYAreaRenderer(int type, XYToolTipGenerator toolTipGenerator, + XYURLGenerator urlGenerator) { + + super(); + setBaseToolTipGenerator(toolTipGenerator); + setURLGenerator(urlGenerator); + + if (type == SHAPES) { + this.plotShapes = true; + } + if (type == LINES) { + this.plotLines = true; + } + if (type == SHAPES_AND_LINES) { + this.plotShapes = true; + this.plotLines = true; + } + if (type == AREA) { + this.plotArea = true; + } + if (type == AREA_AND_SHAPES) { + this.plotArea = true; + this.plotShapes = true; + } + this.showOutline = false; + GeneralPath area = new GeneralPath(); + area.moveTo(0.0f, -4.0f); + area.lineTo(3.0f, -2.0f); + area.lineTo(4.0f, 4.0f); + area.lineTo(-4.0f, 4.0f); + area.lineTo(-3.0f, -2.0f); + area.closePath(); + this.legendArea = area; + this.useFillPaint = false; + this.gradientTransformer = new StandardGradientPaintTransformer(); + } + + /** + * Returns true if shapes are being plotted by the renderer. + * + * @return true if shapes are being plotted by the renderer. + */ + public boolean getPlotShapes() { + return this.plotShapes; + } + + /** + * Returns true if lines are being plotted by the renderer. + * + * @return true if lines are being plotted by the renderer. + */ + public boolean getPlotLines() { + return this.plotLines; + } + + /** + * Returns true if Area is being plotted by the renderer. + * + * @return true if Area is being plotted by the renderer. + */ + public boolean getPlotArea() { + return this.plotArea; + } + + /** + * Returns a flag that controls whether or not outlines of the areas are + * drawn. + * + * @return The flag. + * + * @see #setOutline(boolean) + */ + public boolean isOutline() { + return this.showOutline; + } + + /** + * Sets a flag that controls whether or not outlines of the areas are drawn + * and sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param show the flag. + * + * @see #isOutline() + */ + public void setOutline(boolean show) { + this.showOutline = show; + fireChangeEvent(); + } + + /** + * Returns the shape used to represent an area in the legend. + * + * @return The legend area (never null). + */ + public Shape getLegendArea() { + return this.legendArea; + } + + /** + * Sets the shape used as an area in each legend item and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param area the area (null not permitted). + */ + public void setLegendArea(Shape area) { + ParamChecks.nullNotPermitted(area, "area"); + this.legendArea = area; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether the series fill paint is used to + * fill the area under the line. + * + * @return A boolean. + * + * @since 1.0.14 + */ + public boolean getUseFillPaint() { + return this.useFillPaint; + } + + /** + * Sets the flag that controls whether or not the series fill paint is + * used to fill the area under the line and sends a + * {@link RendererChangeEvent} to all listeners. + * + * @param use the new flag value. + * + * @since 1.0.14 + */ + public void setUseFillPaint(boolean use) { + this.useFillPaint = use; + fireChangeEvent(); + } + + /** + * Returns the gradient paint transformer. + * + * @return The gradient paint transformer (never null). + * + * @since 1.0.14 + */ + public GradientPaintTransformer getGradientTransformer() { + return this.gradientTransformer; + } + + /** + * Sets the gradient paint transformer and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param transformer the transformer (null not permitted). + * + * @since 1.0.14 + */ + public void setGradientTransformer(GradientPaintTransformer transformer) { + ParamChecks.nullNotPermitted(transformer, "transformer"); + this.gradientTransformer = transformer; + fireChangeEvent(); + } + + /** + * Initialises the renderer and returns a state object that should be + * passed to all subsequent calls to the drawItem() method. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param data the data. + * @param info an optional info collection object to return data back to + * the caller. + * + * @return A state object for use by the renderer. + */ + @Override + public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, + XYPlot plot, XYDataset data, PlotRenderingInfo info) { + XYAreaRendererState state = new XYAreaRendererState(info); + + // in the rendering process, there is special handling for item + // zero, so we can't support processing of visible data items only + state.setProcessVisibleItemsOnly(false); + return state; + } + + /** + * Returns a default legend item for the specified series. Subclasses + * should override this method to generate customised items. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return A legend item for the series. + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + LegendItem result = null; + XYPlot xyplot = getPlot(); + if (xyplot != null) { + XYDataset dataset = xyplot.getDataset(datasetIndex); + if (dataset != null) { + XYSeriesLabelGenerator lg = getLegendItemLabelGenerator(); + String label = lg.generateLabel(dataset, series); + String description = label; + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel( + dataset, series); + } + Paint paint = lookupSeriesPaint(series); + result = new LegendItem(label, description, toolTipText, + urlText, this.legendArea, paint); + result.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + result.setLabelPaint(labelPaint); + } + result.setDataset(dataset); + result.setDatasetIndex(datasetIndex); + result.setSeriesKey(dataset.getSeriesKey(series)); + result.setSeriesIndex(series); + } + } + return result; + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + if (!getItemVisible(series, item)) { + return; + } + XYAreaRendererState areaState = (XYAreaRendererState) state; + + // get the data point... + double x1 = dataset.getXValue(series, item); + double y1 = dataset.getYValue(series, item); + if (Double.isNaN(y1)) { + y1 = 0.0; + } + double transX1 = domainAxis.valueToJava2D(x1, dataArea, + plot.getDomainAxisEdge()); + double transY1 = rangeAxis.valueToJava2D(y1, dataArea, + plot.getRangeAxisEdge()); + + // get the previous point and the next point so we can calculate a + // "hot spot" for the area (used by the chart entity)... + int itemCount = dataset.getItemCount(series); + double x0 = dataset.getXValue(series, Math.max(item - 1, 0)); + double y0 = dataset.getYValue(series, Math.max(item - 1, 0)); + if (Double.isNaN(y0)) { + y0 = 0.0; + } + double transX0 = domainAxis.valueToJava2D(x0, dataArea, + plot.getDomainAxisEdge()); + double transY0 = rangeAxis.valueToJava2D(y0, dataArea, + plot.getRangeAxisEdge()); + + double x2 = dataset.getXValue(series, Math.min(item + 1, + itemCount - 1)); + double y2 = dataset.getYValue(series, Math.min(item + 1, + itemCount - 1)); + if (Double.isNaN(y2)) { + y2 = 0.0; + } + double transX2 = domainAxis.valueToJava2D(x2, dataArea, + plot.getDomainAxisEdge()); + double transY2 = rangeAxis.valueToJava2D(y2, dataArea, + plot.getRangeAxisEdge()); + + double transZero = rangeAxis.valueToJava2D(0.0, dataArea, + plot.getRangeAxisEdge()); + GeneralPath hotspot = new GeneralPath(); + if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { + moveTo(hotspot, transZero, ((transX0 + transX1) / 2.0)); + lineTo(hotspot, ((transY0 + transY1) / 2.0), + ((transX0 + transX1) / 2.0)); + lineTo(hotspot, transY1, transX1); + lineTo(hotspot, ((transY1 + transY2) / 2.0), + ((transX1 + transX2) / 2.0)); + lineTo(hotspot, transZero, ((transX1 + transX2) / 2.0)); + } + else { // vertical orientation + moveTo(hotspot, ((transX0 + transX1) / 2.0), transZero); + lineTo(hotspot, ((transX0 + transX1) / 2.0), + ((transY0 + transY1) / 2.0)); + lineTo(hotspot, transX1, transY1); + lineTo(hotspot, ((transX1 + transX2) / 2.0), + ((transY1 + transY2) / 2.0)); + lineTo(hotspot, ((transX1 + transX2) / 2.0), transZero); + } + hotspot.closePath(); + + if (item == 0) { // create a new area polygon for the series + areaState.area = new GeneralPath(); + // the first point is (x, 0) + double zero = rangeAxis.valueToJava2D(0.0, dataArea, + plot.getRangeAxisEdge()); + if (plot.getOrientation() == PlotOrientation.VERTICAL) { + moveTo(areaState.area, transX1, zero); + } + else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { + moveTo(areaState.area, zero, transX1); + } + } + + // Add each point to Area (x, y) + if (plot.getOrientation() == PlotOrientation.VERTICAL) { + lineTo(areaState.area, transX1, transY1); + } + else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { + lineTo(areaState.area, transY1, transX1); + } + + PlotOrientation orientation = plot.getOrientation(); + Paint paint = getItemPaint(series, item); + Stroke stroke = getItemStroke(series, item); + g2.setPaint(paint); + g2.setStroke(stroke); + + Shape shape; + if (getPlotShapes()) { + shape = getItemShape(series, item); + if (orientation == PlotOrientation.VERTICAL) { + shape = ShapeUtilities.createTranslatedShape(shape, transX1, + transY1); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + shape = ShapeUtilities.createTranslatedShape(shape, transY1, + transX1); + } + g2.draw(shape); + } + + if (getPlotLines()) { + if (item > 0) { + if (plot.getOrientation() == PlotOrientation.VERTICAL) { + areaState.line.setLine(transX0, transY0, transX1, transY1); + } + else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { + areaState.line.setLine(transY0, transX0, transY1, transX1); + } + g2.draw(areaState.line); + } + } + + // Check if the item is the last item for the series. + // and number of items > 0. We can't draw an area for a single point. + if (getPlotArea() && item > 0 && item == (itemCount - 1)) { + + if (orientation == PlotOrientation.VERTICAL) { + // Add the last point (x,0) + lineTo(areaState.area, transX1, transZero); + areaState.area.closePath(); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + // Add the last point (x,0) + lineTo(areaState.area, transZero, transX1); + areaState.area.closePath(); + } + + if (this.useFillPaint) { + paint = lookupSeriesFillPaint(series); + } + if (paint instanceof GradientPaint) { + GradientPaint gp = (GradientPaint) paint; + GradientPaint adjGP = this.gradientTransformer.transform(gp, + dataArea); + g2.setPaint(adjGP); + } + g2.fill(areaState.area); + + // draw an outline around the Area. + if (isOutline()) { + Shape area = areaState.area; + + // Java2D has some issues drawing dashed lines around "large" + // geometrical shapes - for example, see bug 6620013 in the + // Java bug database. So, we'll check if the outline is + // dashed and, if it is, do our own clipping before drawing + // the outline... + Stroke outlineStroke = lookupSeriesOutlineStroke(series); + if (outlineStroke instanceof BasicStroke) { + BasicStroke bs = (BasicStroke) outlineStroke; + if (bs.getDashArray() != null) { + Area poly = new Area(areaState.area); + // we make the clip region slightly larger than the + // dataArea so that the clipped edges don't show lines + // on the chart + Area clip = new Area(new Rectangle2D.Double( + dataArea.getX() - 5.0, dataArea.getY() - 5.0, + dataArea.getWidth() + 10.0, + dataArea.getHeight() + 10.0)); + poly.intersect(clip); + area = poly; + } + } // end of workaround + + g2.setStroke(outlineStroke); + g2.setPaint(lookupSeriesOutlinePaint(series)); + g2.draw(area); + } + } + + int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); + int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); + updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, + rangeAxisIndex, transX1, transY1, orientation); + + // collect entity and tool tip information... + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addEntity(entities, hotspot, dataset, series, item, 0.0, 0.0); + } + + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + XYAreaRenderer clone = (XYAreaRenderer) super.clone(); + clone.legendArea = ShapeUtilities.clone(this.legendArea); + return clone; + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYAreaRenderer)) { + return false; + } + XYAreaRenderer that = (XYAreaRenderer) obj; + if (this.plotArea != that.plotArea) { + return false; + } + if (this.plotLines != that.plotLines) { + return false; + } + if (this.plotShapes != that.plotShapes) { + return false; + } + if (this.showOutline != that.showOutline) { + return false; + } + if (this.useFillPaint != that.useFillPaint) { + return false; + } + if (!this.gradientTransformer.equals(that.gradientTransformer)) { + return false; + } + if (!ShapeUtilities.equal(this.legendArea, that.legendArea)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = super.hashCode(); + result = HashUtilities.hashCode(result, this.plotArea); + result = HashUtilities.hashCode(result, this.plotLines); + result = HashUtilities.hashCode(result, this.plotShapes); + result = HashUtilities.hashCode(result, this.useFillPaint); + return result; + } + + /** + * 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.legendArea = SerialUtilities.readShape(stream); + } + + /** + * 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.legendArea, stream); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java new file mode 100755 index 0000000..de3ef02 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYAreaRenderer2.java @@ -0,0 +1,473 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * XYAreaRenderer2.java + * -------------------- + * (C) Copyright 2004-2013, by Hari and Contributors. + * + * Original Author: Hari (ourhari@hotmail.com); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Richard Atkinson; + * Christian W. Zuckschwerdt; + * Martin Krauskopf; + * + * Changes: + * -------- + * 03-Apr-2002 : Version 1, contributed by Hari. This class is based on the + * StandardXYItemRenderer class (DG); + * 09-Apr-2002 : Removed the translated zero from the drawItem method - + * overridden the initialise() method to calculate it (DG); + * 30-May-2002 : Added tool tip generator to constructor to match super + * class (DG); + * 25-Jun-2002 : Removed unnecessary local variable (DG); + * 05-Aug-2002 : Small modification to drawItem method to support URLs for + * HTML image maps (RA); + * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 07-Nov-2002 : Renamed AreaXYItemRenderer --> XYAreaRenderer (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Modified drawItem() method signature (DG); + * 27-Jul-2003 : Made line and polygon properties protected rather than + * private (RA); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 07-Oct-2003 : Added renderer state (DG); + * 08-Dec-2003 : Modified hotspot for chart entity (DG); + * 10-Feb-2004 : Changed the drawItem() method to make cut-and-paste + * overriding easier. Also moved state class into this + * class (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed + * XYToolTipGenerator --> XYItemLabelGenerator (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); + * 19-Jan-2005 : Now accesses only primitives from the dataset (DG); + * 21-Mar-2005 : Override getLegendItem() (DG); + * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 30-Nov-2006 : Fixed equals() and clone() implementations (DG); + * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); + * 20-Apr-2007 : Updated getLegendItem() and drawItem() for renderer + * change (DG); + * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); + * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); + * 17-Jun-2008 : Apply legend font and paint attributes (DG); + * 06-Oct-2011 : Avoid GeneralPath methods requiring Java 1.5 (MK); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +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 org.jfree.chart.LegendItem; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.entity.XYItemEntity; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.XYSeriesLabelGenerator; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * Area item renderer for an {@link XYPlot}. The example shown here is + * generated by the XYAreaRenderer2Demo1.java program included in + * the JFreeChart demo collection: + *

+ * XYAreaRenderer2Sample.png + */ +public class XYAreaRenderer2 extends AbstractXYItemRenderer + implements XYItemRenderer, PublicCloneable { + + /** For serialization. */ + private static final long serialVersionUID = -7378069681579984133L; + + /** A flag that controls whether or not the outline is shown. */ + private boolean showOutline; + + /** + * The shape used to represent an area in each legend item (this should + * never be null). + */ + private transient Shape legendArea; + + /** + * Constructs a new renderer. + */ + public XYAreaRenderer2() { + this(null, null); + } + + /** + * Constructs a new renderer. + * + * @param labelGenerator the tool tip generator to use. null + * is none. + * @param urlGenerator the URL generator (null permitted). + */ + public XYAreaRenderer2(XYToolTipGenerator labelGenerator, + XYURLGenerator urlGenerator) { + super(); + this.showOutline = false; + setBaseToolTipGenerator(labelGenerator); + setURLGenerator(urlGenerator); + GeneralPath area = new GeneralPath(); + area.moveTo(0.0f, -4.0f); + area.lineTo(3.0f, -2.0f); + area.lineTo(4.0f, 4.0f); + area.lineTo(-4.0f, 4.0f); + area.lineTo(-3.0f, -2.0f); + area.closePath(); + this.legendArea = area; + } + + /** + * Returns a flag that controls whether or not outlines of the areas are + * drawn. + * + * @return The flag. + * + * @see #setOutline(boolean) + */ + public boolean isOutline() { + return this.showOutline; + } + + /** + * Sets a flag that controls whether or not outlines of the areas are + * drawn, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param show the flag. + * + * @see #isOutline() + */ + public void setOutline(boolean show) { + this.showOutline = show; + fireChangeEvent(); + } + + /** + * This method should not be used. + * + * @return false always. + * + * @deprecated This method was included in the API by mistake and serves + * no useful purpose. It has always returned false. + * + */ + public boolean getPlotLines() { + return false; + } + + /** + * Returns the shape used to represent an area in the legend. + * + * @return The legend area (never null). + * + * @see #setLegendArea(Shape) + */ + public Shape getLegendArea() { + return this.legendArea; + } + + /** + * Sets the shape used as an area in each legend item and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param area the area (null not permitted). + * + * @see #getLegendArea() + */ + public void setLegendArea(Shape area) { + ParamChecks.nullNotPermitted(area, "area"); + this.legendArea = area; + fireChangeEvent(); + } + + /** + * Returns a default legend item for the specified series. Subclasses + * should override this method to generate customised items. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return A legend item for the series. + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + LegendItem result = null; + XYPlot xyplot = getPlot(); + if (xyplot != null) { + XYDataset dataset = xyplot.getDataset(datasetIndex); + if (dataset != null) { + XYSeriesLabelGenerator lg = getLegendItemLabelGenerator(); + String label = lg.generateLabel(dataset, series); + String description = label; + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel( + dataset, series); + } + Paint paint = lookupSeriesPaint(series); + result = new LegendItem(label, description, toolTipText, + urlText, this.legendArea, paint); + result.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + result.setLabelPaint(labelPaint); + } + result.setDataset(dataset); + result.setDatasetIndex(datasetIndex); + result.setSeriesKey(dataset.getSeriesKey(series)); + result.setSeriesIndex(series); + } + } + return result; + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + if (!getItemVisible(series, item)) { + return; + } + // get the data point... + double x1 = dataset.getXValue(series, item); + double y1 = dataset.getYValue(series, item); + if (Double.isNaN(y1)) { + y1 = 0.0; + } + + double transX1 = domainAxis.valueToJava2D(x1, dataArea, + plot.getDomainAxisEdge()); + double transY1 = rangeAxis.valueToJava2D(y1, dataArea, + plot.getRangeAxisEdge()); + + // get the previous point and the next point so we can calculate a + // "hot spot" for the area (used by the chart entity)... + double x0 = dataset.getXValue(series, Math.max(item - 1, 0)); + double y0 = dataset.getYValue(series, Math.max(item - 1, 0)); + if (Double.isNaN(y0)) { + y0 = 0.0; + } + double transX0 = domainAxis.valueToJava2D(x0, dataArea, + plot.getDomainAxisEdge()); + double transY0 = rangeAxis.valueToJava2D(y0, dataArea, + plot.getRangeAxisEdge()); + + int itemCount = dataset.getItemCount(series); + double x2 = dataset.getXValue(series, Math.min(item + 1, + itemCount - 1)); + double y2 = dataset.getYValue(series, Math.min(item + 1, + itemCount - 1)); + if (Double.isNaN(y2)) { + y2 = 0.0; + } + double transX2 = domainAxis.valueToJava2D(x2, dataArea, + plot.getDomainAxisEdge()); + double transY2 = rangeAxis.valueToJava2D(y2, dataArea, + plot.getRangeAxisEdge()); + + double transZero = rangeAxis.valueToJava2D(0.0, dataArea, + plot.getRangeAxisEdge()); + GeneralPath hotspot = new GeneralPath(); + if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { + moveTo(hotspot, transZero, ((transX0 + transX1) / 2.0)); + lineTo(hotspot, ((transY0 + transY1) / 2.0), + ((transX0 + transX1) / 2.0)); + lineTo(hotspot, transY1, transX1); + lineTo(hotspot, ((transY1 + transY2) / 2.0), + ((transX1 + transX2) / 2.0)); + lineTo(hotspot, transZero, ((transX1 + transX2) / 2.0)); + } + else { // vertical orientation + moveTo(hotspot, ((transX0 + transX1) / 2.0), transZero); + lineTo(hotspot, ((transX0 + transX1) / 2.0), + ((transY0 + transY1) / 2.0)); + lineTo(hotspot, transX1, transY1); + lineTo(hotspot, ((transX1 + transX2) / 2.0), + ((transY1 + transY2) / 2.0)); + lineTo(hotspot, ((transX1 + transX2) / 2.0), transZero); + } + hotspot.closePath(); + + PlotOrientation orientation = plot.getOrientation(); + Paint paint = getItemPaint(series, item); + Stroke stroke = getItemStroke(series, item); + g2.setPaint(paint); + g2.setStroke(stroke); + + // Check if the item is the last item for the series. + // and number of items > 0. We can't draw an area for a single point. + g2.fill(hotspot); + + // draw an outline around the Area. + if (isOutline()) { + g2.setStroke(lookupSeriesOutlineStroke(series)); + g2.setPaint(lookupSeriesOutlinePaint(series)); + g2.draw(hotspot); + } + int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); + int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); + updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, + rangeAxisIndex, transX1, transY1, orientation); + + // collect entity and tool tip information... + if (state.getInfo() != null) { + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + String tip = null; + XYToolTipGenerator generator = getToolTipGenerator(series, + item); + if (generator != null) { + tip = generator.generateToolTip(dataset, series, item); + } + String url = null; + if (getURLGenerator() != null) { + url = getURLGenerator().generateURL(dataset, series, item); + } + XYItemEntity entity = new XYItemEntity(hotspot, dataset, + series, item, tip, url); + entities.add(entity); + } + } + + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null not permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYAreaRenderer2)) { + return false; + } + XYAreaRenderer2 that = (XYAreaRenderer2) obj; + if (this.showOutline != that.showOutline) { + return false; + } + if (!ShapeUtilities.equal(this.legendArea, that.legendArea)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + XYAreaRenderer2 clone = (XYAreaRenderer2) super.clone(); + clone.legendArea = ShapeUtilities.clone(this.legendArea); + return clone; + } + + /** + * 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.legendArea = SerialUtilities.readShape(stream); + } + + /** + * 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.legendArea, stream); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBarPainter.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBarPainter.java new file mode 100755 index 0000000..95ff7c5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBarPainter.java @@ -0,0 +1,93 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * XYBarPainter.java + * ----------------- + * (C) Copyright 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 19-Jun-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Graphics2D; +import java.awt.geom.RectangularShape; + +import org.jfree.ui.RectangleEdge; + +/** + * The interface for plugin painter for the {@link XYBarRenderer} class. When + * developing a class that implements this interface, bear in mind the + * following: + *
    + *
  • the equals(Object) method should be overridden;
  • + *
  • instances of the class should be immutable OR implement the + * PublicCloneable interface, so that a renderer using the + * painter can be cloned reliably; + *
  • the class should be Serializable, otherwise chart + * serialization will not be supported.
  • + *
+ * + * @since 1.0.11 + */ +public interface XYBarPainter { + + /** + * Paints a single bar on behalf of a renderer. + * + * @param g2 the graphics target. + * @param renderer the renderer. + * @param row the row index for the item. + * @param column the column index for the item. + * @param bar the bounds for the bar. + * @param base the base of the bar. + */ + public void paintBar(Graphics2D g2, XYBarRenderer renderer, + int row, int column, RectangularShape bar, RectangleEdge base); + + /** + * Paints the shadow for a single bar on behalf of a renderer. + * + * @param g2 the graphics target. + * @param renderer the renderer. + * @param row the row index for the item. + * @param column the column index for the item. + * @param bar the bounds for the bar. + * @param base the base of the bar. + * @param pegShadow peg the shadow to the base of the bar? + */ + public void paintBarShadow(Graphics2D g2, XYBarRenderer renderer, + int row, int column, RectangularShape bar, RectangleEdge base, + boolean pegShadow); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBarRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBarRenderer.java new file mode 100755 index 0000000..e3d98bc --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBarRenderer.java @@ -0,0 +1,1298 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * XYBarRenderer.java + * ------------------ + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Richard Atkinson; + * Christian W. Zuckschwerdt; + * Bill Kelemen; + * Marc van Glabbeek (bug 1775452); + * Richard West, Advanced Micro Devices, Inc.; + * + * Changes + * ------- + * 13-Dec-2001 : Version 1, makes VerticalXYBarPlot class redundant (DG); + * 23-Jan-2002 : Added DrawInfo parameter to drawItem() method (DG); + * 09-Apr-2002 : Removed the translated zero from the drawItem method. Override + * the initialise() method to calculate it (DG); + * 24-May-2002 : Incorporated tooltips into chart entities (DG); + * 25-Jun-2002 : Removed redundant import (DG); + * 05-Aug-2002 : Small modification to drawItem method to support URLs for HTML + * image maps (RA); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Modified drawItem() method signature (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 24-Aug-2003 : Added null checks in drawItem (BK); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 07-Oct-2003 : Added renderer state (DG); + * 05-Dec-2003 : Changed call to obtain outline paint (DG); + * 10-Feb-2004 : Added state class, updated drawItem() method to make + * cut-and-paste overriding easier, and replaced property change + * with RendererChangeEvent (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); + * 26-Apr-2004 : Added gradient paint transformer (DG); + * 19-May-2004 : Fixed bug (879709) with bar zero value for secondary axis (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 01-Sep-2004 : Added a flag to control whether or not the bar outlines are + * drawn (DG); + * 03-Sep-2004 : Added option to use y-interval from dataset to determine the + * length of the bars (DG); + * 08-Sep-2004 : Added equals() method and updated clone() method (DG); + * 26-Jan-2005 : Added override for getLegendItem() method (DG); + * 20-Apr-2005 : Use generators for label tooltips and URLs (DG); + * 19-May-2005 : Added minimal item label implementation - needs improving (DG); + * 14-Oct-2005 : Fixed rendering problem with inverted axes (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 21-Jun-2006 : Improved item label handling - see bug 1501768 (DG); + * 24-Aug-2006 : Added crosshair support (DG); + * 13-Dec-2006 : Updated getLegendItems() to return gradient paint + * transformer (DG); + * 02-Feb-2007 : Changed setUseYInterval() to only notify when the flag + * changes (DG); + * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); + * 09-Feb-2007 : Updated getLegendItem() to observe drawBarOutline flag (DG); + * 05-Mar-2007 : Applied patch 1671126 by Sergei Ivanov, to fix rendering with + * LogarithmicAxis (DG); + * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); + * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); + * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); + * 15-Jun-2007 : Changed default for drawBarOutline to false (DG); + * 26-Sep-2007 : Fixed bug 1775452, problem with bar margins for inverted + * axes, thanks to Marc van Glabbeek (DG); + * 12-Nov-2007 : Fixed NPE in drawItemLabel() method, thanks to Richard West + * (see patch 1827829) (DG); + * 17-Jun-2008 : Apply legend font and paint attributes (DG); + * 19-Jun-2008 : Added findRangeBounds() method override to fix bug in default + * axis range (DG); + * 24-Jun-2008 : Added new barPainter mechanism (DG); + * 03-Feb-2009 : Added defaultShadowsVisible flag (DG); + * 05-Feb-2009 : Added barAlignmentFactor (DG); + * 10-May-2012 : Fix findDomainBounds() and findRangeBounds() to account for + * non-visible series (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +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.LegendItem; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.ItemLabelAnchor; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.labels.XYItemLabelGenerator; +import org.jfree.chart.labels.XYSeriesLabelGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.text.TextUtilities; +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.StandardGradientPaintTransformer; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A renderer that draws bars on an {@link XYPlot} (requires an + * {@link IntervalXYDataset}). The example shown here is generated by the + * XYBarChartDemo1.java program included in the JFreeChart + * demo collection: + *

+ * XYBarRendererSample.png + */ +public class XYBarRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 770559577251370036L; + + /** + * The default bar painter assigned to each new instance of this renderer. + * + * @since 1.0.11 + */ + private static XYBarPainter defaultBarPainter = new GradientXYBarPainter(); + + /** + * Returns the default bar painter. + * + * @return The default bar painter. + * + * @since 1.0.11 + */ + public static XYBarPainter getDefaultBarPainter() { + return XYBarRenderer.defaultBarPainter; + } + + /** + * Sets the default bar painter. + * + * @param painter the painter (null not permitted). + * + * @since 1.0.11 + */ + public static void setDefaultBarPainter(XYBarPainter painter) { + ParamChecks.nullNotPermitted(painter, "painter"); + XYBarRenderer.defaultBarPainter = painter; + } + + /** + * The default value for the initialisation of the shadowsVisible flag. + */ + private static boolean defaultShadowsVisible = true; + + /** + * Returns the default value for the shadowsVisible flag. + * + * @return A boolean. + * + * @see #setDefaultShadowsVisible(boolean) + * + * @since 1.0.13 + */ + public static boolean getDefaultShadowsVisible() { + return XYBarRenderer.defaultShadowsVisible; + } + + /** + * Sets the default value for the shadows visible flag. + * + * @param visible the new value for the default. + * + * @see #getDefaultShadowsVisible() + * + * @since 1.0.13 + */ + public static void setDefaultShadowsVisible(boolean visible) { + XYBarRenderer.defaultShadowsVisible = visible; + } + + /** + * The state class used by this renderer. + */ + protected class XYBarRendererState extends XYItemRendererState { + + /** Base for bars against the range axis, in Java 2D space. */ + private double g2Base; + + /** + * Creates a new state object. + * + * @param info the plot rendering info. + */ + public XYBarRendererState(PlotRenderingInfo info) { + super(info); + } + + /** + * Returns the base (range) value in Java 2D space. + * + * @return The base value. + */ + public double getG2Base() { + return this.g2Base; + } + + /** + * Sets the range axis base in Java2D space. + * + * @param value the value. + */ + public void setG2Base(double value) { + this.g2Base = value; + } + } + + /** The default base value for the bars. */ + private double base; + + /** + * A flag that controls whether the bars use the y-interval supplied by the + * dataset. + */ + private boolean useYInterval; + + /** Percentage margin (to reduce the width of bars). */ + private double margin; + + /** A flag that controls whether or not bar outlines are drawn. */ + private boolean drawBarOutline; + + /** + * An optional class used to transform gradient paint objects to fit each + * bar. + */ + private GradientPaintTransformer gradientPaintTransformer; + + /** + * The shape used to represent a bar in each legend item (this should never + * be null). + */ + private transient Shape legendBar; + + /** + * The fallback position if a positive item label doesn't fit inside the + * bar. + */ + private ItemLabelPosition positiveItemLabelPositionFallback; + + /** + * The fallback position if a negative item label doesn't fit inside the + * bar. + */ + private ItemLabelPosition negativeItemLabelPositionFallback; + + /** + * The bar painter (never null). + * + * @since 1.0.11 + */ + private XYBarPainter barPainter; + + /** + * The flag that controls whether or not shadows are drawn for the bars. + * + * @since 1.0.11 + */ + private boolean shadowsVisible; + + /** + * The x-offset for the shadow effect. + * + * @since 1.0.11 + */ + private double shadowXOffset; + + /** + * The y-offset for the shadow effect. + * + * @since 1.0.11 + */ + private double shadowYOffset; + + /** + * A factor used to align the bars about the x-value. + * + * @since 1.0.13 + */ + private double barAlignmentFactor; + + /** + * The default constructor. + */ + public XYBarRenderer() { + this(0.0); + } + + /** + * Constructs a new renderer. + * + * @param margin the percentage amount to trim from the width of each bar. + */ + public XYBarRenderer(double margin) { + super(); + this.margin = margin; + this.base = 0.0; + this.useYInterval = false; + this.gradientPaintTransformer = new StandardGradientPaintTransformer(); + this.drawBarOutline = false; + this.legendBar = new Rectangle2D.Double(-3.0, -5.0, 6.0, 10.0); + this.barPainter = getDefaultBarPainter(); + this.shadowsVisible = getDefaultShadowsVisible(); + this.shadowXOffset = 4.0; + this.shadowYOffset = 4.0; + this.barAlignmentFactor = -1.0; + } + + /** + * Returns the base value for the bars. + * + * @return The base value for the bars. + * + * @see #setBase(double) + */ + public double getBase() { + return this.base; + } + + /** + * Sets the base value for the bars and sends a {@link RendererChangeEvent} + * to all registered listeners. The base value is not used if the dataset's + * y-interval is being used to determine the bar length. + * + * @param base the new base value. + * + * @see #getBase() + * @see #getUseYInterval() + */ + public void setBase(double base) { + this.base = base; + fireChangeEvent(); + } + + /** + * Returns a flag that determines whether the y-interval from the dataset is + * used to calculate the length of each bar. + * + * @return A boolean. + * + * @see #setUseYInterval(boolean) + */ + public boolean getUseYInterval() { + return this.useYInterval; + } + + /** + * Sets the flag that determines whether the y-interval from the dataset is + * used to calculate the length of each bar, and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param use the flag. + * + * @see #getUseYInterval() + */ + public void setUseYInterval(boolean use) { + if (this.useYInterval != use) { + this.useYInterval = use; + fireChangeEvent(); + } + } + + /** + * Returns the margin which is a percentage amount by which the bars are + * trimmed. + * + * @return The margin. + * + * @see #setMargin(double) + */ + public double getMargin() { + return this.margin; + } + + /** + * Sets the percentage amount by which the bars are trimmed and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param margin the new margin. + * + * @see #getMargin() + */ + public void setMargin(double margin) { + this.margin = margin; + fireChangeEvent(); + } + + /** + * Returns a flag that controls whether or not bar outlines are drawn. + * + * @return A boolean. + * + * @see #setDrawBarOutline(boolean) + */ + public boolean isDrawBarOutline() { + return this.drawBarOutline; + } + + /** + * Sets the flag that controls whether or not bar outlines are drawn and + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param draw the flag. + * + * @see #isDrawBarOutline() + */ + public void setDrawBarOutline(boolean draw) { + this.drawBarOutline = draw; + fireChangeEvent(); + } + + /** + * Returns the gradient paint transformer (an object used to transform + * gradient paint objects to fit each bar). + * + * @return A transformer (null possible). + * + * @see #setGradientPaintTransformer(GradientPaintTransformer) + */ + public GradientPaintTransformer getGradientPaintTransformer() { + return this.gradientPaintTransformer; + } + + /** + * Sets the gradient paint transformer and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param transformer the transformer (null permitted). + * + * @see #getGradientPaintTransformer() + */ + public void setGradientPaintTransformer( + GradientPaintTransformer transformer) { + this.gradientPaintTransformer = transformer; + fireChangeEvent(); + } + + /** + * Returns the shape used to represent bars in each legend item. + * + * @return The shape used to represent bars in each legend item (never + * null). + * + * @see #setLegendBar(Shape) + */ + public Shape getLegendBar() { + return this.legendBar; + } + + /** + * Sets the shape used to represent bars in each legend item and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param bar the bar shape (null not permitted). + * + * @see #getLegendBar() + */ + public void setLegendBar(Shape bar) { + ParamChecks.nullNotPermitted(bar, "bar"); + this.legendBar = bar; + fireChangeEvent(); + } + + /** + * Returns the fallback position for positive item labels that don't fit + * within a bar. + * + * @return The fallback position (null possible). + * + * @see #setPositiveItemLabelPositionFallback(ItemLabelPosition) + * @since 1.0.2 + */ + public ItemLabelPosition getPositiveItemLabelPositionFallback() { + return this.positiveItemLabelPositionFallback; + } + + /** + * Sets the fallback position for positive item labels that don't fit + * within a bar, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param position the position (null permitted). + * + * @see #getPositiveItemLabelPositionFallback() + * @since 1.0.2 + */ + public void setPositiveItemLabelPositionFallback( + ItemLabelPosition position) { + this.positiveItemLabelPositionFallback = position; + fireChangeEvent(); + } + + /** + * Returns the fallback position for negative item labels that don't fit + * within a bar. + * + * @return The fallback position (null possible). + * + * @see #setNegativeItemLabelPositionFallback(ItemLabelPosition) + * @since 1.0.2 + */ + public ItemLabelPosition getNegativeItemLabelPositionFallback() { + return this.negativeItemLabelPositionFallback; + } + + /** + * Sets the fallback position for negative item labels that don't fit + * within a bar, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param position the position (null permitted). + * + * @see #getNegativeItemLabelPositionFallback() + * @since 1.0.2 + */ + public void setNegativeItemLabelPositionFallback( + ItemLabelPosition position) { + this.negativeItemLabelPositionFallback = position; + fireChangeEvent(); + } + + /** + * Returns the bar painter. + * + * @return The bar painter (never null). + * + * @since 1.0.11 + */ + public XYBarPainter getBarPainter() { + return this.barPainter; + } + + /** + * Sets the bar painter and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param painter the painter (null not permitted). + * + * @since 1.0.11 + */ + public void setBarPainter(XYBarPainter painter) { + ParamChecks.nullNotPermitted(painter, "painter"); + this.barPainter = painter; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not shadows are drawn for + * the bars. + * + * @return A boolean. + * + * @since 1.0.11 + */ + public boolean getShadowsVisible() { + return this.shadowsVisible; + } + + /** + * Sets the flag that controls whether or not the renderer + * draws shadows for the bars, and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the new flag value. + * + * @since 1.0.11 + */ + public void setShadowVisible(boolean visible) { + this.shadowsVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the shadow x-offset. + * + * @return The shadow x-offset. + * + * @since 1.0.11 + */ + public double getShadowXOffset() { + return this.shadowXOffset; + } + + /** + * Sets the x-offset for the bar shadow and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param offset the offset. + * + * @since 1.0.11 + */ + public void setShadowXOffset(double offset) { + this.shadowXOffset = offset; + fireChangeEvent(); + } + + /** + * Returns the shadow y-offset. + * + * @return The shadow y-offset. + * + * @since 1.0.11 + */ + public double getShadowYOffset() { + return this.shadowYOffset; + } + + /** + * Sets the y-offset for the bar shadow and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param offset the offset. + * + * @since 1.0.11 + */ + public void setShadowYOffset(double offset) { + this.shadowYOffset = offset; + fireChangeEvent(); + } + + /** + * Returns the bar alignment factor. + * + * @return The bar alignment factor. + * + * @since 1.0.13 + */ + public double getBarAlignmentFactor() { + return this.barAlignmentFactor; + } + + /** + * Sets the bar alignment factor and sends a {@link RendererChangeEvent} + * to all registered listeners. If the alignment factor is outside the + * range 0.0 to 1.0, no alignment will be performed by the renderer. + * + * @param factor the factor. + * + * @since 1.0.13 + */ + public void setBarAlignmentFactor(double factor) { + this.barAlignmentFactor = factor; + fireChangeEvent(); + } + + /** + * Initialises the renderer and returns a state object that should be + * passed to all subsequent calls to the drawItem() method. Here we + * calculate the Java2D y-coordinate for zero, since all the bars have + * their bases fixed at zero. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param dataset the data. + * @param info an optional info collection object to return data back to + * the caller. + * + * @return A state object. + */ + @Override + public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, + XYPlot plot, XYDataset dataset, PlotRenderingInfo info) { + + XYBarRendererState state = new XYBarRendererState(info); + ValueAxis rangeAxis = plot.getRangeAxisForDataset(plot.indexOf( + dataset)); + state.setG2Base(rangeAxis.valueToJava2D(this.base, dataArea, + plot.getRangeAxisEdge())); + return state; + + } + + /** + * Returns a default legend item for the specified series. Subclasses + * should override this method to generate customised items. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return A legend item for the series. + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + XYPlot xyplot = getPlot(); + if (xyplot == null) { + return null; + } + XYDataset dataset = xyplot.getDataset(datasetIndex); + if (dataset == null) { + return null; + } + LegendItem result; + XYSeriesLabelGenerator lg = getLegendItemLabelGenerator(); + String label = lg.generateLabel(dataset, series); + String description = label; + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel(dataset, + series); + } + Shape shape = this.legendBar; + Paint paint = lookupSeriesPaint(series); + Paint outlinePaint = lookupSeriesOutlinePaint(series); + Stroke outlineStroke = lookupSeriesOutlineStroke(series); + if (this.drawBarOutline) { + result = new LegendItem(label, description, toolTipText, + urlText, shape, paint, outlineStroke, outlinePaint); + } + else { + result = new LegendItem(label, description, toolTipText, urlText, + shape, paint); + } + result.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + result.setLabelPaint(labelPaint); + } + result.setDataset(dataset); + result.setDatasetIndex(datasetIndex); + result.setSeriesKey(dataset.getSeriesKey(series)); + result.setSeriesIndex(series); + if (getGradientPaintTransformer() != null) { + result.setFillPaintTransformer(getGradientPaintTransformer()); + } + return result; + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the plot is being drawn. + * @param info collects information about the drawing. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + if (!getItemVisible(series, item)) { + return; + } + IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset; + + double value0; + double value1; + if (this.useYInterval) { + value0 = intervalDataset.getStartYValue(series, item); + value1 = intervalDataset.getEndYValue(series, item); + } + else { + value0 = this.base; + value1 = intervalDataset.getYValue(series, item); + } + if (Double.isNaN(value0) || Double.isNaN(value1)) { + return; + } + if (value0 <= value1) { + if (!rangeAxis.getRange().intersects(value0, value1)) { + return; + } + } + else { + if (!rangeAxis.getRange().intersects(value1, value0)) { + return; + } + } + + double translatedValue0 = rangeAxis.valueToJava2D(value0, dataArea, + plot.getRangeAxisEdge()); + double translatedValue1 = rangeAxis.valueToJava2D(value1, dataArea, + plot.getRangeAxisEdge()); + double bottom = Math.min(translatedValue0, translatedValue1); + double top = Math.max(translatedValue0, translatedValue1); + + double startX = intervalDataset.getStartXValue(series, item); + if (Double.isNaN(startX)) { + return; + } + double endX = intervalDataset.getEndXValue(series, item); + if (Double.isNaN(endX)) { + return; + } + if (startX <= endX) { + if (!domainAxis.getRange().intersects(startX, endX)) { + return; + } + } + else { + if (!domainAxis.getRange().intersects(endX, startX)) { + return; + } + } + + // is there an alignment adjustment to be made? + if (this.barAlignmentFactor >= 0.0 && this.barAlignmentFactor <= 1.0) { + double x = intervalDataset.getXValue(series, item); + double interval = endX - startX; + startX = x - interval * this.barAlignmentFactor; + endX = startX + interval; + } + + RectangleEdge location = plot.getDomainAxisEdge(); + double translatedStartX = domainAxis.valueToJava2D(startX, dataArea, + location); + double translatedEndX = domainAxis.valueToJava2D(endX, dataArea, + location); + + double translatedWidth = Math.max(1, Math.abs(translatedEndX + - translatedStartX)); + + double left = Math.min(translatedStartX, translatedEndX); + if (getMargin() > 0.0) { + double cut = translatedWidth * getMargin(); + translatedWidth = translatedWidth - cut; + left = left + cut / 2; + } + + Rectangle2D bar = null; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + // clip left and right bounds to data area + bottom = Math.max(bottom, dataArea.getMinX()); + top = Math.min(top, dataArea.getMaxX()); + bar = new Rectangle2D.Double( + bottom, left, top - bottom, translatedWidth); + } + else if (orientation == PlotOrientation.VERTICAL) { + // clip top and bottom bounds to data area + bottom = Math.max(bottom, dataArea.getMinY()); + top = Math.min(top, dataArea.getMaxY()); + bar = new Rectangle2D.Double(left, bottom, translatedWidth, + top - bottom); + } + + boolean positive = (value1 > 0.0); + boolean inverted = rangeAxis.isInverted(); + RectangleEdge barBase; + if (orientation == PlotOrientation.HORIZONTAL) { + if (positive && inverted || !positive && !inverted) { + barBase = RectangleEdge.RIGHT; + } + else { + barBase = RectangleEdge.LEFT; + } + } + else { + if (positive && !inverted || !positive && inverted) { + barBase = RectangleEdge.BOTTOM; + } + else { + barBase = RectangleEdge.TOP; + } + } + if (getShadowsVisible()) { + this.barPainter.paintBarShadow(g2, this, series, item, bar, barBase, + !this.useYInterval); + } + this.barPainter.paintBar(g2, this, series, item, bar, barBase); + + if (isItemLabelVisible(series, item)) { + XYItemLabelGenerator generator = getItemLabelGenerator(series, + item); + drawItemLabel(g2, dataset, series, item, plot, generator, bar, + value1 < 0.0); + } + + // update the crosshair point + double x1 = (startX + endX) / 2.0; + double y1 = dataset.getYValue(series, item); + double transX1 = domainAxis.valueToJava2D(x1, dataArea, location); + double transY1 = rangeAxis.valueToJava2D(y1, dataArea, + plot.getRangeAxisEdge()); + int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); + int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); + updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, + rangeAxisIndex, transX1, transY1, plot.getOrientation()); + + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addEntity(entities, bar, dataset, series, item, 0.0, 0.0); + } + + } + + /** + * Draws an item label. This method is provided as an alternative to + * {@link #drawItemLabel(Graphics2D, PlotOrientation, XYDataset, int, int, + * double, double, boolean)} so that the bar can be used to calculate the + * label anchor point. + * + * @param g2 the graphics device. + * @param dataset the dataset. + * @param series the series index. + * @param item the item index. + * @param plot the plot. + * @param generator the label generator (null permitted, in + * which case the method does nothing, just returns). + * @param bar the bar. + * @param negative a flag indicating a negative value. + */ + protected void drawItemLabel(Graphics2D g2, XYDataset dataset, + int series, int item, XYPlot plot, XYItemLabelGenerator generator, + Rectangle2D bar, boolean negative) { + + if (generator == null) { + return; // nothing to do + } + String label = generator.generateLabel(dataset, series, item); + if (label == null) { + return; // nothing to do + } + + Font labelFont = getItemLabelFont(series, item); + g2.setFont(labelFont); + Paint paint = getItemLabelPaint(series, item); + g2.setPaint(paint); + + // find out where to place the label... + ItemLabelPosition position; + if (!negative) { + position = getPositiveItemLabelPosition(series, item); + } + else { + position = getNegativeItemLabelPosition(series, item); + } + + // work out the label anchor point... + Point2D anchorPoint = calculateLabelAnchorPoint( + position.getItemLabelAnchor(), bar, plot.getOrientation()); + + if (isInternalAnchor(position.getItemLabelAnchor())) { + Shape bounds = TextUtilities.calculateRotatedStringBounds(label, + g2, (float) anchorPoint.getX(), (float) anchorPoint.getY(), + position.getTextAnchor(), position.getAngle(), + position.getRotationAnchor()); + + if (bounds != null) { + if (!bar.contains(bounds.getBounds2D())) { + if (!negative) { + position = getPositiveItemLabelPositionFallback(); + } + else { + position = getNegativeItemLabelPositionFallback(); + } + if (position != null) { + anchorPoint = calculateLabelAnchorPoint( + position.getItemLabelAnchor(), bar, + plot.getOrientation()); + } + } + } + + } + + if (position != null) { + TextUtilities.drawRotatedString(label, g2, + (float) anchorPoint.getX(), (float) anchorPoint.getY(), + position.getTextAnchor(), position.getAngle(), + position.getRotationAnchor()); + } + } + + /** + * Calculates the item label anchor point. + * + * @param anchor the anchor. + * @param bar the bar. + * @param orientation the plot orientation. + * + * @return The anchor point. + */ + private Point2D calculateLabelAnchorPoint(ItemLabelAnchor anchor, + Rectangle2D bar, PlotOrientation orientation) { + + Point2D result = null; + double offset = getItemLabelAnchorOffset(); + double x0 = bar.getX() - offset; + double x1 = bar.getX(); + double x2 = bar.getX() + offset; + double x3 = bar.getCenterX(); + double x4 = bar.getMaxX() - offset; + double x5 = bar.getMaxX(); + double x6 = bar.getMaxX() + offset; + + double y0 = bar.getMaxY() + offset; + double y1 = bar.getMaxY(); + double y2 = bar.getMaxY() - offset; + double y3 = bar.getCenterY(); + double y4 = bar.getMinY() + offset; + double y5 = bar.getMinY(); + double y6 = bar.getMinY() - offset; + + if (anchor == ItemLabelAnchor.CENTER) { + result = new Point2D.Double(x3, y3); + } + else if (anchor == ItemLabelAnchor.INSIDE1) { + result = new Point2D.Double(x4, y4); + } + else if (anchor == ItemLabelAnchor.INSIDE2) { + result = new Point2D.Double(x4, y4); + } + else if (anchor == ItemLabelAnchor.INSIDE3) { + result = new Point2D.Double(x4, y3); + } + else if (anchor == ItemLabelAnchor.INSIDE4) { + result = new Point2D.Double(x4, y2); + } + else if (anchor == ItemLabelAnchor.INSIDE5) { + result = new Point2D.Double(x4, y2); + } + else if (anchor == ItemLabelAnchor.INSIDE6) { + result = new Point2D.Double(x3, y2); + } + else if (anchor == ItemLabelAnchor.INSIDE7) { + result = new Point2D.Double(x2, y2); + } + else if (anchor == ItemLabelAnchor.INSIDE8) { + result = new Point2D.Double(x2, y2); + } + else if (anchor == ItemLabelAnchor.INSIDE9) { + result = new Point2D.Double(x2, y3); + } + else if (anchor == ItemLabelAnchor.INSIDE10) { + result = new Point2D.Double(x2, y4); + } + else if (anchor == ItemLabelAnchor.INSIDE11) { + result = new Point2D.Double(x2, y4); + } + else if (anchor == ItemLabelAnchor.INSIDE12) { + result = new Point2D.Double(x3, y4); + } + else if (anchor == ItemLabelAnchor.OUTSIDE1) { + result = new Point2D.Double(x5, y6); + } + else if (anchor == ItemLabelAnchor.OUTSIDE2) { + result = new Point2D.Double(x6, y5); + } + else if (anchor == ItemLabelAnchor.OUTSIDE3) { + result = new Point2D.Double(x6, y3); + } + else if (anchor == ItemLabelAnchor.OUTSIDE4) { + result = new Point2D.Double(x6, y1); + } + else if (anchor == ItemLabelAnchor.OUTSIDE5) { + result = new Point2D.Double(x5, y0); + } + else if (anchor == ItemLabelAnchor.OUTSIDE6) { + result = new Point2D.Double(x3, y0); + } + else if (anchor == ItemLabelAnchor.OUTSIDE7) { + result = new Point2D.Double(x1, y0); + } + else if (anchor == ItemLabelAnchor.OUTSIDE8) { + result = new Point2D.Double(x0, y1); + } + else if (anchor == ItemLabelAnchor.OUTSIDE9) { + result = new Point2D.Double(x0, y3); + } + else if (anchor == ItemLabelAnchor.OUTSIDE10) { + result = new Point2D.Double(x0, y5); + } + else if (anchor == ItemLabelAnchor.OUTSIDE11) { + result = new Point2D.Double(x1, y6); + } + else if (anchor == ItemLabelAnchor.OUTSIDE12) { + result = new Point2D.Double(x3, y6); + } + + return result; + + } + + /** + * Returns true if the specified anchor point is inside a bar. + * + * @param anchor the anchor point. + * + * @return A boolean. + */ + private boolean isInternalAnchor(ItemLabelAnchor anchor) { + return anchor == ItemLabelAnchor.CENTER + || anchor == ItemLabelAnchor.INSIDE1 + || anchor == ItemLabelAnchor.INSIDE2 + || anchor == ItemLabelAnchor.INSIDE3 + || anchor == ItemLabelAnchor.INSIDE4 + || anchor == ItemLabelAnchor.INSIDE5 + || anchor == ItemLabelAnchor.INSIDE6 + || anchor == ItemLabelAnchor.INSIDE7 + || anchor == ItemLabelAnchor.INSIDE8 + || anchor == ItemLabelAnchor.INSIDE9 + || anchor == ItemLabelAnchor.INSIDE10 + || anchor == ItemLabelAnchor.INSIDE11 + || anchor == ItemLabelAnchor.INSIDE12; + } + + /** + * Returns the lower and upper bounds (range) of the x-values in the + * specified dataset. Since this renderer uses the x-interval in the + * dataset, this is taken into account for the range. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is + * null or empty). + */ + @Override + public Range findDomainBounds(XYDataset dataset) { + return findDomainBounds(dataset, true); + } + + /** + * Returns the lower and upper bounds (range) of the y-values in the + * specified dataset. If the renderer is plotting the y-interval from the + * dataset, this is taken into account for the range. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is + * null or empty). + */ + @Override + public Range findRangeBounds(XYDataset dataset) { + return findRangeBounds(dataset, this.useYInterval); + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + XYBarRenderer result = (XYBarRenderer) super.clone(); + if (this.gradientPaintTransformer != null) { + result.gradientPaintTransformer = (GradientPaintTransformer) + ObjectUtilities.clone(this.gradientPaintTransformer); + } + result.legendBar = ShapeUtilities.clone(this.legendBar); + return result; + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYBarRenderer)) { + return false; + } + XYBarRenderer that = (XYBarRenderer) obj; + if (this.base != that.base) { + return false; + } + if (this.drawBarOutline != that.drawBarOutline) { + return false; + } + if (this.margin != that.margin) { + return false; + } + if (this.useYInterval != that.useYInterval) { + return false; + } + if (!ObjectUtilities.equal(this.gradientPaintTransformer, + that.gradientPaintTransformer)) { + return false; + } + if (!ShapeUtilities.equal(this.legendBar, that.legendBar)) { + return false; + } + if (!ObjectUtilities.equal(this.positiveItemLabelPositionFallback, + that.positiveItemLabelPositionFallback)) { + return false; + } + if (!ObjectUtilities.equal(this.negativeItemLabelPositionFallback, + that.negativeItemLabelPositionFallback)) { + return false; + } + if (!this.barPainter.equals(that.barPainter)) { + return false; + } + if (this.shadowsVisible != that.shadowsVisible) { + return false; + } + if (this.shadowXOffset != that.shadowXOffset) { + return false; + } + if (this.shadowYOffset != that.shadowYOffset) { + return false; + } + if (this.barAlignmentFactor != that.barAlignmentFactor) { + return false; + } + return super.equals(obj); + } + + /** + * 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.legendBar = SerialUtilities.readShape(stream); + } + + /** + * 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.legendBar, stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBlockRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBlockRenderer.java new file mode 100755 index 0000000..3514e6a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBlockRenderer.java @@ -0,0 +1,448 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * XYBlockRenderer.java + * -------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Jul-2006 : Version 1 (DG); + * 02-Feb-2007 : Added getPaintScale() method (DG); + * 09-Mar-2007 : Fixed cloning (DG); + * 03-Aug-2007 : Fix for bug 1766646 (DG); + * 07-Apr-2008 : Added entity collection code (DG); + * 22-Apr-2008 : Implemented PublicCloneable (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.BasicStroke; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.LookupPaintScale; +import org.jfree.chart.renderer.PaintScale; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYZDataset; +import org.jfree.ui.RectangleAnchor; +import org.jfree.util.PublicCloneable; + +/** + * A renderer that represents data from an {@link XYZDataset} by drawing a + * color block at each (x, y) point, where the color is a function of the + * z-value from the dataset. The example shown here is generated by the + * XYBlockChartDemo1.java program included in the JFreeChart + * demo collection: + *

+ * XYBlockRendererSample.png + * + * @since 1.0.4 + */ +public class XYBlockRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { + + /** + * The block width (defaults to 1.0). + */ + private double blockWidth = 1.0; + + /** + * The block height (defaults to 1.0). + */ + private double blockHeight = 1.0; + + /** + * The anchor point used to align each block to its (x, y) location. The + * default value is RectangleAnchor.CENTER. + */ + private RectangleAnchor blockAnchor = RectangleAnchor.CENTER; + + /** Temporary storage for the x-offset used to align the block anchor. */ + private double xOffset; + + /** Temporary storage for the y-offset used to align the block anchor. */ + private double yOffset; + + /** The paint scale. */ + private PaintScale paintScale; + + /** + * Creates a new XYBlockRenderer instance with default + * attributes. + */ + public XYBlockRenderer() { + updateOffsets(); + this.paintScale = new LookupPaintScale(); + } + + /** + * Returns the block width, in data/axis units. + * + * @return The block width. + * + * @see #setBlockWidth(double) + */ + public double getBlockWidth() { + return this.blockWidth; + } + + /** + * Sets the width of the blocks used to represent each data item and + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param width the new width, in data/axis units (must be > 0.0). + * + * @see #getBlockWidth() + */ + public void setBlockWidth(double width) { + if (width <= 0.0) { + throw new IllegalArgumentException( + "The 'width' argument must be > 0.0"); + } + this.blockWidth = width; + updateOffsets(); + fireChangeEvent(); + } + + /** + * Returns the block height, in data/axis units. + * + * @return The block height. + * + * @see #setBlockHeight(double) + */ + public double getBlockHeight() { + return this.blockHeight; + } + + /** + * Sets the height of the blocks used to represent each data item and + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param height the new height, in data/axis units (must be > 0.0). + * + * @see #getBlockHeight() + */ + public void setBlockHeight(double height) { + if (height <= 0.0) { + throw new IllegalArgumentException( + "The 'height' argument must be > 0.0"); + } + this.blockHeight = height; + updateOffsets(); + fireChangeEvent(); + } + + /** + * Returns the anchor point used to align a block at its (x, y) location. + * The default values is {@link RectangleAnchor#CENTER}. + * + * @return The anchor point (never null). + * + * @see #setBlockAnchor(RectangleAnchor) + */ + public RectangleAnchor getBlockAnchor() { + return this.blockAnchor; + } + + /** + * Sets the anchor point used to align a block at its (x, y) location and + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param anchor the anchor. + * + * @see #getBlockAnchor() + */ + public void setBlockAnchor(RectangleAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + if (this.blockAnchor.equals(anchor)) { + return; // no change + } + this.blockAnchor = anchor; + updateOffsets(); + fireChangeEvent(); + } + + /** + * Returns the paint scale used by the renderer. + * + * @return The paint scale (never null). + * + * @see #setPaintScale(PaintScale) + * @since 1.0.4 + */ + public PaintScale getPaintScale() { + return this.paintScale; + } + + /** + * Sets the paint scale used by the renderer and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param scale the scale (null not permitted). + * + * @see #getPaintScale() + * @since 1.0.4 + */ + public void setPaintScale(PaintScale scale) { + ParamChecks.nullNotPermitted(scale, "scale"); + this.paintScale = scale; + fireChangeEvent(); + } + + /** + * Updates the offsets to take into account the block width, height and + * anchor. + */ + private void updateOffsets() { + if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_LEFT)) { + this.xOffset = 0.0; + this.yOffset = 0.0; + } + else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM)) { + this.xOffset = -this.blockWidth / 2.0; + this.yOffset = 0.0; + } + else if (this.blockAnchor.equals(RectangleAnchor.BOTTOM_RIGHT)) { + this.xOffset = -this.blockWidth; + this.yOffset = 0.0; + } + else if (this.blockAnchor.equals(RectangleAnchor.LEFT)) { + this.xOffset = 0.0; + this.yOffset = -this.blockHeight / 2.0; + } + else if (this.blockAnchor.equals(RectangleAnchor.CENTER)) { + this.xOffset = -this.blockWidth / 2.0; + this.yOffset = -this.blockHeight / 2.0; + } + else if (this.blockAnchor.equals(RectangleAnchor.RIGHT)) { + this.xOffset = -this.blockWidth; + this.yOffset = -this.blockHeight / 2.0; + } + else if (this.blockAnchor.equals(RectangleAnchor.TOP_LEFT)) { + this.xOffset = 0.0; + this.yOffset = -this.blockHeight; + } + else if (this.blockAnchor.equals(RectangleAnchor.TOP)) { + this.xOffset = -this.blockWidth / 2.0; + this.yOffset = -this.blockHeight; + } + else if (this.blockAnchor.equals(RectangleAnchor.TOP_RIGHT)) { + this.xOffset = -this.blockWidth; + this.yOffset = -this.blockHeight; + } + } + + /** + * Returns the lower and upper bounds (range) of the x-values in the + * specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + * + * @see #findRangeBounds(XYDataset) + */ + @Override + public Range findDomainBounds(XYDataset dataset) { + if (dataset == null) { + return null; + } + Range r = DatasetUtilities.findDomainBounds(dataset, false); + if (r == null) { + return null; + } + return new Range(r.getLowerBound() + this.xOffset, + r.getUpperBound() + this.blockWidth + this.xOffset); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + * + * @see #findDomainBounds(XYDataset) + */ + @Override + public Range findRangeBounds(XYDataset dataset) { + if (dataset != null) { + Range r = DatasetUtilities.findRangeBounds(dataset, false); + if (r == null) { + return null; + } + else { + return new Range(r.getLowerBound() + this.yOffset, + r.getUpperBound() + this.blockHeight + this.yOffset); + } + } + else { + return null; + } + } + + /** + * Draws the block representing the specified item. + * + * @param g2 the graphics device. + * @param state the state. + * @param dataArea the data area. + * @param info the plot rendering info. + * @param plot the plot. + * @param domainAxis the x-axis. + * @param rangeAxis the y-axis. + * @param dataset the dataset. + * @param series the series index. + * @param item the item index. + * @param crosshairState the crosshair state. + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + double x = dataset.getXValue(series, item); + double y = dataset.getYValue(series, item); + double z = 0.0; + if (dataset instanceof XYZDataset) { + z = ((XYZDataset) dataset).getZValue(series, item); + } + Paint p = this.paintScale.getPaint(z); + double xx0 = domainAxis.valueToJava2D(x + this.xOffset, dataArea, + plot.getDomainAxisEdge()); + double yy0 = rangeAxis.valueToJava2D(y + this.yOffset, dataArea, + plot.getRangeAxisEdge()); + double xx1 = domainAxis.valueToJava2D(x + this.blockWidth + + this.xOffset, dataArea, plot.getDomainAxisEdge()); + double yy1 = rangeAxis.valueToJava2D(y + this.blockHeight + + this.yOffset, dataArea, plot.getRangeAxisEdge()); + Rectangle2D block; + PlotOrientation orientation = plot.getOrientation(); + if (orientation.equals(PlotOrientation.HORIZONTAL)) { + block = new Rectangle2D.Double(Math.min(yy0, yy1), + Math.min(xx0, xx1), Math.abs(yy1 - yy0), + Math.abs(xx0 - xx1)); + } + else { + block = new Rectangle2D.Double(Math.min(xx0, xx1), + Math.min(yy0, yy1), Math.abs(xx1 - xx0), + Math.abs(yy1 - yy0)); + } + g2.setPaint(p); + g2.fill(block); + g2.setStroke(new BasicStroke(1.0f)); + g2.draw(block); + + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addEntity(entities, block, dataset, series, item, 0.0, 0.0); + } + + } + + /** + * Tests this XYBlockRenderer for equality with an arbitrary + * object. This method returns true if and only if: + *
    + *
  • obj is an instance of XYBlockRenderer (not + * null);
  • + *
  • obj has the same field values as this + * XYBlockRenderer;
  • + *
+ * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYBlockRenderer)) { + return false; + } + XYBlockRenderer that = (XYBlockRenderer) obj; + if (this.blockHeight != that.blockHeight) { + return false; + } + if (this.blockWidth != that.blockWidth) { + return false; + } + if (!this.blockAnchor.equals(that.blockAnchor)) { + return false; + } + if (!this.paintScale.equals(that.paintScale)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of this renderer. + * + * @return A clone of this renderer. + * + * @throws CloneNotSupportedException if there is a problem creating the + * clone. + */ + @Override + public Object clone() throws CloneNotSupportedException { + XYBlockRenderer clone = (XYBlockRenderer) super.clone(); + if (this.paintScale instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.paintScale; + clone.paintScale = (PaintScale) pc.clone(); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java new file mode 100755 index 0000000..ac280bb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRenderer.java @@ -0,0 +1,854 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * XYBoxAndWhiskerRenderer.java + * ---------------------------- + * (C) Copyright 2003-2013, by David Browning and Contributors. + * + * Original Author: David Browning (for Australian Institute of Marine + * Science); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 05-Aug-2003 : Version 1, contributed by David Browning. Based on code in the + * CandlestickRenderer class. Additional modifications by David + * Gilbert to make the code work with 0.9.10 changes (DG); + * 08-Aug-2003 : Updated some of the Javadoc + * Allowed BoxAndwhiskerDataset Average value to be null - the + * average value is an AIMS requirement + * Allow the outlier and farout coefficients to be set - though + * at the moment this only affects the calculation of farouts. + * Added artifactPaint variable and setter/getter + * 12-Aug-2003 Rewrote code to sort out and process outliers to take + * advantage of changes in DefaultBoxAndWhiskerDataset + * Added a limit of 10% for width of box should no width be + * specified...maybe this should be setable??? + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 08-Sep-2003 : Changed ValueAxis API (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); + * 23-Apr-2004 : Added fillBox attribute, extended equals() method and fixed + * serialization issue (DG); + * 29-Apr-2004 : Fixed problem with drawing upper and lower shadows - bug id + * 944011 (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 01-Oct-2004 : Renamed 'paint' --> 'boxPaint' to avoid conflict with + * inherited attribute (DG); + * 10-Jun-2005 : Updated equals() to handle GradientPaint (DG); + * 06-Oct-2005 : Removed setPaint() call in drawItem(), it is causing a + * loop (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * 05-Feb-2007 : Added event notifications and fixed drawing for horizontal + * plot orientation (DG); + * 13-Jun-2007 : Replaced deprecated method call (DG); + * 03-Jan-2008 : Check visibility of average marker before drawing it (DG); + * 27-Mar-2008 : If boxPaint is null, revert to itemPaint (DG); + * 27-Mar-2009 : Added findRangeBounds() method override (DG); + * 08-Dec-2009 : Fix for bug 2909215, NullPointerException for null + * outliers (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Line2D; +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 java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.BoxAndWhiskerXYToolTipGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.Outlier; +import org.jfree.chart.renderer.OutlierList; +import org.jfree.chart.renderer.OutlierListCollection; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.statistics.BoxAndWhiskerXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A renderer that draws box-and-whisker items on an {@link XYPlot}. This + * renderer requires a {@link BoxAndWhiskerXYDataset}). The example shown here + * is generated by the BoxAndWhiskerChartDemo2.java program + * included in the JFreeChart demo collection: + *

+ * XYBoxAndWhiskerRendererSample.png + *

+ * This renderer does not include any code to calculate the crosshair point. + */ +public class XYBoxAndWhiskerRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -8020170108532232324L; + + /** The box width. */ + private double boxWidth; + + /** The paint used to fill the box. */ + private transient Paint boxPaint; + + /** A flag that controls whether or not the box is filled. */ + private boolean fillBox; + + /** + * The paint used to draw various artifacts such as outliers, farout + * symbol, average ellipse and median line. + */ + private transient Paint artifactPaint = Color.black; + + /** + * Creates a new renderer for box and whisker charts. + */ + public XYBoxAndWhiskerRenderer() { + this(-1.0); + } + + /** + * Creates a new renderer for box and whisker charts. + *

+ * Use -1 for the box width if you prefer the width to be calculated + * automatically. + * + * @param boxWidth the box width. + */ + public XYBoxAndWhiskerRenderer(double boxWidth) { + super(); + this.boxWidth = boxWidth; + this.boxPaint = Color.green; + this.fillBox = true; + setBaseToolTipGenerator(new BoxAndWhiskerXYToolTipGenerator()); + } + + /** + * Returns the width of each box. + * + * @return The box width. + * + * @see #setBoxWidth(double) + */ + public double getBoxWidth() { + return this.boxWidth; + } + + /** + * Sets the box width and sends a {@link RendererChangeEvent} to all + * registered listeners. + *

+ * If you set the width to a negative value, the renderer will calculate + * the box width automatically based on the space available on the chart. + * + * @param width the width. + * + * @see #getBoxWidth() + */ + public void setBoxWidth(double width) { + if (width != this.boxWidth) { + this.boxWidth = width; + fireChangeEvent(); + } + } + + /** + * Returns the paint used to fill boxes. + * + * @return The paint (possibly null). + * + * @see #setBoxPaint(Paint) + */ + public Paint getBoxPaint() { + return this.boxPaint; + } + + /** + * Sets the paint used to fill boxes and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @see #getBoxPaint() + */ + public void setBoxPaint(Paint paint) { + this.boxPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not the box is filled. + * + * @return A boolean. + * + * @see #setFillBox(boolean) + */ + public boolean getFillBox() { + return this.fillBox; + } + + /** + * Sets the flag that controls whether or not the box is filled and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param flag the flag. + * + * @see #setFillBox(boolean) + */ + public void setFillBox(boolean flag) { + this.fillBox = flag; + fireChangeEvent(); + } + + /** + * Returns the paint used to paint the various artifacts such as outliers, + * farout symbol, median line and the averages ellipse. + * + * @return The paint (never null). + * + * @see #setArtifactPaint(Paint) + */ + public Paint getArtifactPaint() { + return this.artifactPaint; + } + + /** + * Sets the paint used to paint the various artifacts such as outliers, + * farout symbol, median line and the averages ellipse, and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getArtifactPaint() + */ + public void setArtifactPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.artifactPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + * + * @see #findDomainBounds(XYDataset) + */ + @Override + public Range findRangeBounds(XYDataset dataset) { + return findRangeBounds(dataset, true); + } + + /** + * Returns the box paint or, if this is null, the item + * paint. + * + * @param series the series index. + * @param item the item index. + * + * @return The paint used to fill the box for the specified item (never + * null). + * + * @since 1.0.10 + */ + protected Paint lookupBoxPaint(int series, int item) { + Paint p = getBoxPaint(); + if (p != null) { + return p; + } + else { + // TODO: could change this to itemFillPaint(). For backwards + // compatibility, it might require a useFillPaint flag. + return getItemPaint(series, item); + } + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the plot is being drawn. + * @param info collects info about the drawing. + * @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 (must be an instance of + * {@link BoxAndWhiskerXYDataset}). + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + PlotOrientation orientation = plot.getOrientation(); + + if (orientation == PlotOrientation.HORIZONTAL) { + drawHorizontalItem(g2, dataArea, info, plot, domainAxis, rangeAxis, + dataset, series, item, crosshairState, pass); + } + else if (orientation == PlotOrientation.VERTICAL) { + drawVerticalItem(g2, dataArea, info, plot, domainAxis, rangeAxis, + dataset, series, item, crosshairState, pass); + } + + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param dataArea the area within which the plot is being drawn. + * @param info collects info about the drawing. + * @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 (must be an instance of + * {@link BoxAndWhiskerXYDataset}). + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + public void drawHorizontalItem(Graphics2D g2, Rectangle2D dataArea, + PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, + ValueAxis rangeAxis, XYDataset dataset, int series, + int item, CrosshairState crosshairState, int pass) { + + // setup for collecting optional entity info... + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + } + + BoxAndWhiskerXYDataset boxAndWhiskerData + = (BoxAndWhiskerXYDataset) dataset; + + Number x = boxAndWhiskerData.getX(series, item); + Number yMax = boxAndWhiskerData.getMaxRegularValue(series, item); + Number yMin = boxAndWhiskerData.getMinRegularValue(series, item); + Number yMedian = boxAndWhiskerData.getMedianValue(series, item); + Number yAverage = boxAndWhiskerData.getMeanValue(series, item); + Number yQ1Median = boxAndWhiskerData.getQ1Value(series, item); + Number yQ3Median = boxAndWhiskerData.getQ3Value(series, item); + + double xx = domainAxis.valueToJava2D(x.doubleValue(), dataArea, + plot.getDomainAxisEdge()); + + RectangleEdge location = plot.getRangeAxisEdge(); + double yyMax = rangeAxis.valueToJava2D(yMax.doubleValue(), dataArea, + location); + double yyMin = rangeAxis.valueToJava2D(yMin.doubleValue(), dataArea, + location); + double yyMedian = rangeAxis.valueToJava2D(yMedian.doubleValue(), + dataArea, location); + double yyAverage = 0.0; + if (yAverage != null) { + yyAverage = rangeAxis.valueToJava2D(yAverage.doubleValue(), + dataArea, location); + } + double yyQ1Median = rangeAxis.valueToJava2D(yQ1Median.doubleValue(), + dataArea, location); + double yyQ3Median = rangeAxis.valueToJava2D(yQ3Median.doubleValue(), + dataArea, location); + + double exactBoxWidth = getBoxWidth(); + double width = exactBoxWidth; + double dataAreaX = dataArea.getHeight(); + double maxBoxPercent = 0.1; + double maxBoxWidth = dataAreaX * maxBoxPercent; + if (exactBoxWidth <= 0.0) { + int itemCount = boxAndWhiskerData.getItemCount(series); + exactBoxWidth = dataAreaX / itemCount * 4.5 / 7; + if (exactBoxWidth < 3) { + width = 3; + } + else if (exactBoxWidth > maxBoxWidth) { + width = maxBoxWidth; + } + else { + width = exactBoxWidth; + } + } + + g2.setPaint(getItemPaint(series, item)); + Stroke s = getItemStroke(series, item); + g2.setStroke(s); + + // draw the upper shadow + g2.draw(new Line2D.Double(yyMax, xx, yyQ3Median, xx)); + g2.draw(new Line2D.Double(yyMax, xx - width / 2, yyMax, + xx + width / 2)); + + // draw the lower shadow + g2.draw(new Line2D.Double(yyMin, xx, yyQ1Median, xx)); + g2.draw(new Line2D.Double(yyMin, xx - width / 2, yyMin, + xx + width / 2)); + + // draw the body + Shape box; + if (yyQ1Median < yyQ3Median) { + box = new Rectangle2D.Double(yyQ1Median, xx - width / 2, + yyQ3Median - yyQ1Median, width); + } + else { + box = new Rectangle2D.Double(yyQ3Median, xx - width / 2, + yyQ1Median - yyQ3Median, width); + } + if (this.fillBox) { + g2.setPaint(lookupBoxPaint(series, item)); + g2.fill(box); + } + g2.setStroke(getItemOutlineStroke(series, item)); + g2.setPaint(getItemOutlinePaint(series, item)); + g2.draw(box); + + // draw median + g2.setPaint(getArtifactPaint()); + g2.draw(new Line2D.Double(yyMedian, + xx - width / 2, yyMedian, xx + width / 2)); + + // draw average - SPECIAL AIMS REQUIREMENT + if (yAverage != null) { + double aRadius = width / 4; + // here we check that the average marker will in fact be visible + // before drawing it... + if ((yyAverage > (dataArea.getMinX() - aRadius)) + && (yyAverage < (dataArea.getMaxX() + aRadius))) { + Ellipse2D.Double avgEllipse = new Ellipse2D.Double( + yyAverage - aRadius, xx - aRadius, aRadius * 2, + aRadius * 2); + g2.fill(avgEllipse); + g2.draw(avgEllipse); + } + } + + // FIXME: draw outliers + + // add an entity for the item... + if (entities != null && box.intersects(dataArea)) { + addEntity(entities, box, dataset, series, item, yyAverage, xx); + } + + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param dataArea the area within which the plot is being drawn. + * @param info collects info about the drawing. + * @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 (must be an instance of + * {@link BoxAndWhiskerXYDataset}). + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + public void drawVerticalItem(Graphics2D g2, Rectangle2D dataArea, + PlotRenderingInfo info, XYPlot plot, ValueAxis domainAxis, + ValueAxis rangeAxis, XYDataset dataset, int series, + int item, CrosshairState crosshairState, int pass) { + + // setup for collecting optional entity info... + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + } + + BoxAndWhiskerXYDataset boxAndWhiskerData + = (BoxAndWhiskerXYDataset) dataset; + + Number x = boxAndWhiskerData.getX(series, item); + Number yMax = boxAndWhiskerData.getMaxRegularValue(series, item); + Number yMin = boxAndWhiskerData.getMinRegularValue(series, item); + Number yMedian = boxAndWhiskerData.getMedianValue(series, item); + Number yAverage = boxAndWhiskerData.getMeanValue(series, item); + Number yQ1Median = boxAndWhiskerData.getQ1Value(series, item); + Number yQ3Median = boxAndWhiskerData.getQ3Value(series, item); + List yOutliers = boxAndWhiskerData.getOutliers(series, item); + // yOutliers can be null, but we'd prefer it to be an empty list in + // that case... + if (yOutliers == null) { + yOutliers = Collections.EMPTY_LIST; + } + + double xx = domainAxis.valueToJava2D(x.doubleValue(), dataArea, + plot.getDomainAxisEdge()); + + RectangleEdge location = plot.getRangeAxisEdge(); + double yyMax = rangeAxis.valueToJava2D(yMax.doubleValue(), dataArea, + location); + double yyMin = rangeAxis.valueToJava2D(yMin.doubleValue(), dataArea, + location); + double yyMedian = rangeAxis.valueToJava2D(yMedian.doubleValue(), + dataArea, location); + double yyAverage = 0.0; + if (yAverage != null) { + yyAverage = rangeAxis.valueToJava2D(yAverage.doubleValue(), + dataArea, location); + } + double yyQ1Median = rangeAxis.valueToJava2D(yQ1Median.doubleValue(), + dataArea, location); + double yyQ3Median = rangeAxis.valueToJava2D(yQ3Median.doubleValue(), + dataArea, location); + double yyOutlier; + + double exactBoxWidth = getBoxWidth(); + double width = exactBoxWidth; + double dataAreaX = dataArea.getMaxX() - dataArea.getMinX(); + double maxBoxPercent = 0.1; + double maxBoxWidth = dataAreaX * maxBoxPercent; + if (exactBoxWidth <= 0.0) { + int itemCount = boxAndWhiskerData.getItemCount(series); + exactBoxWidth = dataAreaX / itemCount * 4.5 / 7; + if (exactBoxWidth < 3) { + width = 3; + } + else if (exactBoxWidth > maxBoxWidth) { + width = maxBoxWidth; + } + else { + width = exactBoxWidth; + } + } + + g2.setPaint(getItemPaint(series, item)); + Stroke s = getItemStroke(series, item); + g2.setStroke(s); + + // draw the upper shadow + g2.draw(new Line2D.Double(xx, yyMax, xx, yyQ3Median)); + g2.draw(new Line2D.Double(xx - width / 2, yyMax, xx + width / 2, + yyMax)); + + // draw the lower shadow + g2.draw(new Line2D.Double(xx, yyMin, xx, yyQ1Median)); + g2.draw(new Line2D.Double(xx - width / 2, yyMin, xx + width / 2, + yyMin)); + + // draw the body + Shape box; + if (yyQ1Median > yyQ3Median) { + box = new Rectangle2D.Double(xx - width / 2, yyQ3Median, width, + yyQ1Median - yyQ3Median); + } + else { + box = new Rectangle2D.Double(xx - width / 2, yyQ1Median, width, + yyQ3Median - yyQ1Median); + } + if (this.fillBox) { + g2.setPaint(lookupBoxPaint(series, item)); + g2.fill(box); + } + g2.setStroke(getItemOutlineStroke(series, item)); + g2.setPaint(getItemOutlinePaint(series, item)); + g2.draw(box); + + // draw median + g2.setPaint(getArtifactPaint()); + g2.draw(new Line2D.Double(xx - width / 2, yyMedian, xx + width / 2, + yyMedian)); + + double aRadius = 0; // average radius + double oRadius = width / 3; // outlier radius + + // draw average - SPECIAL AIMS REQUIREMENT + if (yAverage != null) { + aRadius = width / 4; + // here we check that the average marker will in fact be visible + // before drawing it... + if ((yyAverage > (dataArea.getMinY() - aRadius)) + && (yyAverage < (dataArea.getMaxY() + aRadius))) { + Ellipse2D.Double avgEllipse = new Ellipse2D.Double(xx - aRadius, + yyAverage - aRadius, aRadius * 2, aRadius * 2); + g2.fill(avgEllipse); + g2.draw(avgEllipse); + } + } + + List outliers = new ArrayList(); + OutlierListCollection outlierListCollection + = new OutlierListCollection(); + + /* From outlier array sort out which are outliers and put these into + * an arraylist. If there are any farouts, set the flag on the + * OutlierListCollection + */ + for (int i = 0; i < yOutliers.size(); i++) { + double outlier = ((Number) yOutliers.get(i)).doubleValue(); + if (outlier > boxAndWhiskerData.getMaxOutlier(series, + item).doubleValue()) { + outlierListCollection.setHighFarOut(true); + } + else if (outlier < boxAndWhiskerData.getMinOutlier(series, + item).doubleValue()) { + outlierListCollection.setLowFarOut(true); + } + else if (outlier > boxAndWhiskerData.getMaxRegularValue(series, + item).doubleValue()) { + yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, + location); + outliers.add(new Outlier(xx, yyOutlier, oRadius)); + } + else if (outlier < boxAndWhiskerData.getMinRegularValue(series, + item).doubleValue()) { + yyOutlier = rangeAxis.valueToJava2D(outlier, dataArea, + location); + outliers.add(new Outlier(xx, yyOutlier, oRadius)); + } + Collections.sort(outliers); + } + + // Process outliers. Each outlier is either added to the appropriate + // outlier list or a new outlier list is made + for (Iterator iterator = outliers.iterator(); iterator.hasNext();) { + Outlier outlier = (Outlier) iterator.next(); + outlierListCollection.add(outlier); + } + + // draw yOutliers + double maxAxisValue = rangeAxis.valueToJava2D(rangeAxis.getUpperBound(), + dataArea, location) + aRadius; + double minAxisValue = rangeAxis.valueToJava2D(rangeAxis.getLowerBound(), + dataArea, location) - aRadius; + + // draw outliers + for (Iterator iterator = outlierListCollection.iterator(); + iterator.hasNext();) { + OutlierList list = (OutlierList) iterator.next(); + Outlier outlier = list.getAveragedOutlier(); + Point2D point = outlier.getPoint(); + + if (list.isMultiple()) { + drawMultipleEllipse(point, width, oRadius, g2); + } + else { + drawEllipse(point, oRadius, g2); + } + } + + // draw farout + if (outlierListCollection.isHighFarOut()) { + drawHighFarOut(aRadius, g2, xx, maxAxisValue); + } + + if (outlierListCollection.isLowFarOut()) { + drawLowFarOut(aRadius, g2, xx, minAxisValue); + } + + // add an entity for the item... + if (entities != null && box.intersects(dataArea)) { + addEntity(entities, box, dataset, series, item, xx, yyAverage); + } + + } + + /** + * Draws an ellipse to represent an outlier. + * + * @param point the location. + * @param oRadius the radius. + * @param g2 the graphics device. + */ + protected void drawEllipse(Point2D point, double oRadius, Graphics2D g2) { + Ellipse2D.Double dot = new Ellipse2D.Double(point.getX() + oRadius / 2, + point.getY(), oRadius, oRadius); + g2.draw(dot); + } + + /** + * Draws two ellipses to represent overlapping outliers. + * + * @param point the location. + * @param boxWidth the box width. + * @param oRadius the radius. + * @param g2 the graphics device. + */ + protected void drawMultipleEllipse(Point2D point, double boxWidth, + double oRadius, Graphics2D g2) { + + Ellipse2D.Double dot1 = new Ellipse2D.Double(point.getX() + - (boxWidth / 2) + oRadius, point.getY(), oRadius, oRadius); + Ellipse2D.Double dot2 = new Ellipse2D.Double(point.getX() + + (boxWidth / 2), point.getY(), oRadius, oRadius); + g2.draw(dot1); + g2.draw(dot2); + + } + + /** + * Draws a triangle to indicate the presence of far out values. + * + * @param aRadius the radius. + * @param g2 the graphics device. + * @param xx the x value. + * @param m the max y value. + */ + protected void drawHighFarOut(double aRadius, Graphics2D g2, double xx, + double m) { + double side = aRadius * 2; + g2.draw(new Line2D.Double(xx - side, m + side, xx + side, m + side)); + g2.draw(new Line2D.Double(xx - side, m + side, xx, m)); + g2.draw(new Line2D.Double(xx + side, m + side, xx, m)); + } + + /** + * Draws a triangle to indicate the presence of far out values. + * + * @param aRadius the radius. + * @param g2 the graphics device. + * @param xx the x value. + * @param m the min y value. + */ + protected void drawLowFarOut(double aRadius, Graphics2D g2, double xx, + double m) { + double side = aRadius * 2; + g2.draw(new Line2D.Double(xx - side, m - side, xx + side, m - side)); + g2.draw(new Line2D.Double(xx - side, m - side, xx, m)); + g2.draw(new Line2D.Double(xx + side, m - side, xx, m)); + } + + /** + * Tests this renderer for equality with another object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYBoxAndWhiskerRenderer)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + XYBoxAndWhiskerRenderer that = (XYBoxAndWhiskerRenderer) obj; + if (this.boxWidth != that.getBoxWidth()) { + return false; + } + if (!PaintUtilities.equal(this.boxPaint, that.boxPaint)) { + return false; + } + if (!PaintUtilities.equal(this.artifactPaint, that.artifactPaint)) { + return false; + } + if (this.fillBox != that.fillBox) { + return false; + } + return true; + + } + + /** + * 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.boxPaint, stream); + SerialUtilities.writePaint(this.artifactPaint, 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.boxPaint = SerialUtilities.readPaint(stream); + this.artifactPaint = SerialUtilities.readPaint(stream); + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java new file mode 100755 index 0000000..831f796 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYBubbleRenderer.java @@ -0,0 +1,366 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * XYBubbleRenderer.java + * --------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Christian W. Zuckschwerdt; + * + * Changes + * ------- + * 28-Jan-2003 : Version 1 (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Modified drawItem() method signature (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 10-Feb-2004 : Small change to drawItem() method to make cut-and-paste + * overriding easier (DG); + * 15-Jul-2004 : Switched getZ() and getZValue() methods (DG); + * 19-Jan-2005 : Now accesses only primitives from dataset (DG); + * 28-Feb-2005 : Modify renderer to use circles in legend (DG); + * 17-Mar-2005 : Fixed bug in bubble bounds calculation (DG); + * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 13-Dec-2005 : Added support for item labels (bug 1373371) (DG); + * 20-Jan-2006 : Check flag for drawing item labels (DG); + * 21-Sep-2006 : Respect the outline paint and stroke settings (DG); + * 24-Jan-2007 : Added new equals() override (DG); + * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); + * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); + * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); + * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); + * 13-Jun-2007 : Fixed seriesVisibility bug (DG); + * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.LegendItem; +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.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYZDataset; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PublicCloneable; + +/** + * A renderer that draws a circle at each data point with a diameter that is + * determined by the z-value in the dataset (the renderer requires the dataset + * to be an instance of {@link XYZDataset}. The example shown here + * is generated by the XYBubbleChartDemo1.java program + * included in the JFreeChart demo collection: + *

+ * XYBubbleRendererSample.png + */ +public class XYBubbleRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, PublicCloneable { + + /** For serialization. */ + public static final long serialVersionUID = -5221991598674249125L; + + /** + * A constant to specify that the bubbles drawn by this renderer should be + * scaled on both axes (see {@link #XYBubbleRenderer(int)}). + */ + public static final int SCALE_ON_BOTH_AXES = 0; + + /** + * A constant to specify that the bubbles drawn by this renderer should be + * scaled on the domain axis (see {@link #XYBubbleRenderer(int)}). + */ + public static final int SCALE_ON_DOMAIN_AXIS = 1; + + /** + * A constant to specify that the bubbles drawn by this renderer should be + * scaled on the range axis (see {@link #XYBubbleRenderer(int)}). + */ + public static final int SCALE_ON_RANGE_AXIS = 2; + + /** Controls how the width and height of the bubble are scaled. */ + private int scaleType; + + /** + * Constructs a new renderer. + */ + public XYBubbleRenderer() { + this(SCALE_ON_BOTH_AXES); + } + + /** + * Constructs a new renderer with the specified type of scaling. + * + * @param scaleType the type of scaling (must be one of: + * {@link #SCALE_ON_BOTH_AXES}, {@link #SCALE_ON_DOMAIN_AXIS}, + * {@link #SCALE_ON_RANGE_AXIS}). + */ + public XYBubbleRenderer(int scaleType) { + super(); + if (scaleType < 0 || scaleType > 2) { + throw new IllegalArgumentException("Invalid 'scaleType'."); + } + this.scaleType = scaleType; + setBaseLegendShape(new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0)); + } + + /** + * Returns the scale type that was set when the renderer was constructed. + * + * @return The scale type (one of: {@link #SCALE_ON_BOTH_AXES}, + * {@link #SCALE_ON_DOMAIN_AXIS}, {@link #SCALE_ON_RANGE_AXIS}). + */ + public int getScaleType() { + return this.scaleType; + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @param plot the plot (can be used to obtain standard color + * information etc). + * @param domainAxis the domain (horizontal) axis. + * @param rangeAxis the range (vertical) axis. + * @param dataset the dataset (an {@link XYZDataset} is expected). + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + // return straight away if the item is not visible + if (!getItemVisible(series, item)) { + return; + } + + PlotOrientation orientation = plot.getOrientation(); + + // get the data point... + double x = dataset.getXValue(series, item); + double y = dataset.getYValue(series, item); + double z = Double.NaN; + if (dataset instanceof XYZDataset) { + XYZDataset xyzData = (XYZDataset) dataset; + z = xyzData.getZValue(series, item); + } + if (!Double.isNaN(z)) { + RectangleEdge domainAxisLocation = plot.getDomainAxisEdge(); + RectangleEdge rangeAxisLocation = plot.getRangeAxisEdge(); + double transX = domainAxis.valueToJava2D(x, dataArea, + domainAxisLocation); + double transY = rangeAxis.valueToJava2D(y, dataArea, + rangeAxisLocation); + + double transDomain; + double transRange; + double zero; + + switch(getScaleType()) { + case SCALE_ON_DOMAIN_AXIS: + zero = domainAxis.valueToJava2D(0.0, dataArea, + domainAxisLocation); + transDomain = domainAxis.valueToJava2D(z, dataArea, + domainAxisLocation) - zero; + transRange = transDomain; + break; + case SCALE_ON_RANGE_AXIS: + zero = rangeAxis.valueToJava2D(0.0, dataArea, + rangeAxisLocation); + transRange = zero - rangeAxis.valueToJava2D(z, dataArea, + rangeAxisLocation); + transDomain = transRange; + break; + default: + double zero1 = domainAxis.valueToJava2D(0.0, dataArea, + domainAxisLocation); + double zero2 = rangeAxis.valueToJava2D(0.0, dataArea, + rangeAxisLocation); + transDomain = domainAxis.valueToJava2D(z, dataArea, + domainAxisLocation) - zero1; + transRange = zero2 - rangeAxis.valueToJava2D(z, dataArea, + rangeAxisLocation); + } + transDomain = Math.abs(transDomain); + transRange = Math.abs(transRange); + Ellipse2D circle = null; + if (orientation == PlotOrientation.VERTICAL) { + circle = new Ellipse2D.Double(transX - transDomain / 2.0, + transY - transRange / 2.0, transDomain, transRange); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + circle = new Ellipse2D.Double(transY - transRange / 2.0, + transX - transDomain / 2.0, transRange, transDomain); + } else { + throw new IllegalStateException(); + } + g2.setPaint(getItemPaint(series, item)); + g2.fill(circle); + g2.setStroke(getItemOutlineStroke(series, item)); + g2.setPaint(getItemOutlinePaint(series, item)); + g2.draw(circle); + + if (isItemLabelVisible(series, item)) { + if (orientation == PlotOrientation.VERTICAL) { + drawItemLabel(g2, orientation, dataset, series, item, + transX, transY, false); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + drawItemLabel(g2, orientation, dataset, series, item, + transY, transX, false); + } + } + + // add an entity if this info is being collected + if (info != null) { + EntityCollection entities + = info.getOwner().getEntityCollection(); + if (entities != null && circle.intersects(dataArea)) { + addEntity(entities, circle, dataset, series, item, + circle.getCenterX(), circle.getCenterY()); + } + } + + int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); + int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); + updateCrosshairValues(crosshairState, x, y, domainAxisIndex, + rangeAxisIndex, transX, transY, orientation); + } + + } + + /** + * Returns a legend item for the specified series. The default method + * is overridden so that the legend displays circles for all series. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return A legend item for the series. + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + LegendItem result = null; + XYPlot plot = getPlot(); + if (plot == null) { + return null; + } + + XYDataset dataset = plot.getDataset(datasetIndex); + if (dataset != null) { + if (getItemVisible(series, 0)) { + String label = getLegendItemLabelGenerator().generateLabel( + dataset, series); + String description = label; + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel( + dataset, series); + } + Shape shape = lookupLegendShape(series); + Paint paint = lookupSeriesPaint(series); + Paint outlinePaint = lookupSeriesOutlinePaint(series); + Stroke outlineStroke = lookupSeriesOutlineStroke(series); + result = new LegendItem(label, description, toolTipText, + urlText, shape, paint, outlineStroke, outlinePaint); + result.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + result.setLabelPaint(labelPaint); + } + result.setDataset(dataset); + result.setDatasetIndex(datasetIndex); + result.setSeriesKey(dataset.getSeriesKey(series)); + result.setSeriesIndex(series); + } + } + return result; + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYBubbleRenderer)) { + return false; + } + XYBubbleRenderer that = (XYBubbleRenderer) obj; + if (this.scaleType != that.scaleType) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java new file mode 100755 index 0000000..ac53b6f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYDifferenceRenderer.java @@ -0,0 +1,1243 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * XYDifferenceRenderer.java + * ------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Richard West, Advanced Micro Devices, Inc. (major rewrite + * of difference drawing algorithm); + * Patrick Schlott + * Christoph Schroeder + * Martin Hoeller + * + * Changes: + * -------- + * 30-Apr-2003 : Version 1 (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 09-Feb-2004 : Updated to support horizontal plot orientation (DG); + * 10-Feb-2004 : Added default constructor, setter methods and updated + * Javadocs (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); + * 30-Mar-2004 : Fixed bug in getNegativePaint() method (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 25-Aug-2004 : Fixed a bug preventing the use of crosshairs (DG); + * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); + * 19-Jan-2005 : Now accesses only primitive values from dataset (DG); + * 22-Feb-2005 : Override getLegendItem(int, int) to return "line" items (DG); + * 13-Apr-2005 : Fixed shape positioning bug (id = 1182062) (DG); + * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG); + * 04-May-2005 : Override equals() method, renamed get/setPlotShapes() --> + * get/setShapesVisible (DG); + * 09-Jun-2005 : Updated equals() to handle GradientPaint (DG); + * 16-Jun-2005 : Fix bug (1221021) affecting stroke used for each series (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 24-Jan-2007 : Added flag to allow rounding of x-coordinates, and fixed + * bug in clone() (DG); + * 05-Feb-2007 : Added an extra call to updateCrosshairValues() in + * drawItemPass1(), to fix bug 1564967 (DG); + * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); + * 08-Mar-2007 : Fixed entity generation (DG); + * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); + * 23-Apr-2007 : Rewrite of difference drawing algorithm to allow use of + * series with disjoint x-values (RW); + * 04-May-2007 : Set processVisibleItemsOnly flag to false (DG); + * 17-May-2007 : Set datasetIndex and seriesIndex in getLegendItem() (DG); + * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); + * 05-Nov-2007 : Draw item labels if visible (RW); + * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * 13-Feb-2012 : Applied patch 3450234 for bug 3425881 by Patrick Schlott and + * Christoph Schroeder (MH); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +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.util.Collections; +import java.util.LinkedList; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.entity.XYItemEntity; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A renderer for an {@link XYPlot} that highlights the differences between two + * series. The example shown here is generated by the + * DifferenceChartDemo1.java program included in the JFreeChart + * demo collection: + *

+ * XYDifferenceRendererSample.png + */ +public class XYDifferenceRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, PublicCloneable { + + /** For serialization. */ + private static final long serialVersionUID = -8447915602375584857L; + + /** The paint used to highlight positive differences (y(0) > y(1)). */ + private transient Paint positivePaint; + + /** The paint used to highlight negative differences (y(0) < y(1)). */ + private transient Paint negativePaint; + + /** Display shapes at each point? */ + private boolean shapesVisible; + + /** The shape to display in the legend item. */ + private transient Shape legendLine; + + /** + * This flag controls whether or not the x-coordinates (in Java2D space) + * are rounded to integers. When set to true, this can avoid the vertical + * striping that anti-aliasing can generate. However, the rounding may not + * be appropriate for output in high resolution formats (for example, + * vector graphics formats such as SVG and PDF). + * + * @since 1.0.4 + */ + private boolean roundXCoordinates; + + /** + * Creates a new renderer with default attributes. + */ + public XYDifferenceRenderer() { + this(Color.green, Color.red, false); + } + + /** + * Creates a new renderer. + * + * @param positivePaint the highlight color for positive differences + * (null not permitted). + * @param negativePaint the highlight color for negative differences + * (null not permitted). + * @param shapes draw shapes? + */ + public XYDifferenceRenderer(Paint positivePaint, Paint negativePaint, + boolean shapes) { + ParamChecks.nullNotPermitted(positivePaint, "positivePaint"); + ParamChecks.nullNotPermitted(negativePaint, "negativePaint"); + this.positivePaint = positivePaint; + this.negativePaint = negativePaint; + this.shapesVisible = shapes; + this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0); + this.roundXCoordinates = false; + } + + /** + * Returns the paint used to highlight positive differences. + * + * @return The paint (never null). + * + * @see #setPositivePaint(Paint) + */ + public Paint getPositivePaint() { + return this.positivePaint; + } + + /** + * Sets the paint used to highlight positive differences and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getPositivePaint() + */ + public void setPositivePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.positivePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint used to highlight negative differences. + * + * @return The paint (never null). + * + * @see #setNegativePaint(Paint) + */ + public Paint getNegativePaint() { + return this.negativePaint; + } + + /** + * Sets the paint used to highlight negative differences. + * + * @param paint the paint (null not permitted). + * + * @see #getNegativePaint() + */ + public void setNegativePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.negativePaint = paint; + notifyListeners(new RendererChangeEvent(this)); + } + + /** + * Returns a flag that controls whether or not shapes are drawn for each + * data value. + * + * @return A boolean. + * + * @see #setShapesVisible(boolean) + */ + public boolean getShapesVisible() { + return this.shapesVisible; + } + + /** + * Sets a flag that controls whether or not shapes are drawn for each + * data value, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param flag the flag. + * + * @see #getShapesVisible() + */ + public void setShapesVisible(boolean flag) { + this.shapesVisible = flag; + fireChangeEvent(); + } + + /** + * Returns the shape used to represent a line in the legend. + * + * @return The legend line (never null). + * + * @see #setLegendLine(Shape) + */ + public Shape getLegendLine() { + return this.legendLine; + } + + /** + * Sets the shape used as a line in each legend item and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param line the line (null not permitted). + * + * @see #getLegendLine() + */ + public void setLegendLine(Shape line) { + ParamChecks.nullNotPermitted(line, "line"); + this.legendLine = line; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not the x-coordinates (in + * Java2D space) are rounded to integer values. + * + * @return The flag. + * + * @since 1.0.4 + * + * @see #setRoundXCoordinates(boolean) + */ + public boolean getRoundXCoordinates() { + return this.roundXCoordinates; + } + + /** + * Sets the flag that controls whether or not the x-coordinates (in + * Java2D space) are rounded to integer values, and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param round the new flag value. + * + * @since 1.0.4 + * + * @see #getRoundXCoordinates() + */ + public void setRoundXCoordinates(boolean round) { + this.roundXCoordinates = round; + fireChangeEvent(); + } + + /** + * Initialises the renderer and returns a state object that should be + * passed to subsequent calls to the drawItem() method. This method will + * be called before the first item is rendered, giving the renderer an + * opportunity to initialise any state information it wants to maintain. + * The renderer can do nothing if it chooses. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param data the data. + * @param info an optional info collection object to return data back to + * the caller. + * + * @return A state object. + */ + @Override + public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, + XYPlot plot, XYDataset data, PlotRenderingInfo info) { + XYItemRendererState state = super.initialise(g2, dataArea, plot, data, + info); + state.setProcessVisibleItemsOnly(false); + return state; + } + + /** + * Returns 2, the number of passes required by the renderer. + * The {@link XYPlot} will run through the dataset this number of times. + * + * @return The number of passes required by the renderer. + */ + @Override + public int getPassCount() { + return 2; + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @param plot the plot (can be used to obtain standard color + * information etc). + * @param domainAxis the domain (horizontal) axis. + * @param rangeAxis the range (vertical) axis. + * @param dataset the dataset. + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + if (pass == 0) { + drawItemPass0(g2, dataArea, info, plot, domainAxis, rangeAxis, + dataset, series, item, crosshairState); + } + else if (pass == 1) { + drawItemPass1(g2, dataArea, info, plot, domainAxis, rangeAxis, + dataset, series, item, crosshairState); + } + + } + + /** + * Draws the visual representation of a single data item, first pass. + * + * @param x_graphics the graphics device. + * @param x_dataArea the area within which the data is being drawn. + * @param x_info collects information about the drawing. + * @param x_plot the plot (can be used to obtain standard color + * information etc). + * @param x_domainAxis the domain (horizontal) axis. + * @param x_rangeAxis the range (vertical) axis. + * @param x_dataset the dataset. + * @param x_series the series index (zero-based). + * @param x_item the item index (zero-based). + * @param x_crosshairState crosshair information for the plot + * (null permitted). + */ + protected void drawItemPass0(Graphics2D x_graphics, + Rectangle2D x_dataArea, + PlotRenderingInfo x_info, + XYPlot x_plot, + ValueAxis x_domainAxis, + ValueAxis x_rangeAxis, + XYDataset x_dataset, + int x_series, + int x_item, + CrosshairState x_crosshairState) { + + if (!((0 == x_series) && (0 == x_item))) { + return; + } + + boolean b_impliedZeroSubtrahend = (1 == x_dataset.getSeriesCount()); + + // check if either series is a degenerate case (i.e. less than 2 points) + if (isEitherSeriesDegenerate(x_dataset, b_impliedZeroSubtrahend)) { + return; + } + + // check if series are disjoint (i.e. domain-spans do not overlap) + if (!b_impliedZeroSubtrahend && areSeriesDisjoint(x_dataset)) { + return; + } + + // polygon definitions + LinkedList l_minuendXs = new LinkedList(); + LinkedList l_minuendYs = new LinkedList(); + LinkedList l_subtrahendXs = new LinkedList(); + LinkedList l_subtrahendYs = new LinkedList(); + LinkedList l_polygonXs = new LinkedList(); + LinkedList l_polygonYs = new LinkedList(); + + // state + int l_minuendItem = 0; + int l_minuendItemCount = x_dataset.getItemCount(0); + Double l_minuendCurX = null; + Double l_minuendNextX = null; + Double l_minuendCurY = null; + Double l_minuendNextY = null; + double l_minuendMaxY = Double.NEGATIVE_INFINITY; + double l_minuendMinY = Double.POSITIVE_INFINITY; + + int l_subtrahendItem = 0; + int l_subtrahendItemCount = 0; // actual value set below + Double l_subtrahendCurX = null; + Double l_subtrahendNextX = null; + Double l_subtrahendCurY = null; + Double l_subtrahendNextY = null; + double l_subtrahendMaxY = Double.NEGATIVE_INFINITY; + double l_subtrahendMinY = Double.POSITIVE_INFINITY; + + // if a subtrahend is not specified, assume it is zero + if (b_impliedZeroSubtrahend) { + l_subtrahendItem = 0; + l_subtrahendItemCount = 2; + l_subtrahendCurX = new Double(x_dataset.getXValue(0, 0)); + l_subtrahendNextX = new Double(x_dataset.getXValue(0, + (l_minuendItemCount - 1))); + l_subtrahendCurY = new Double(0.0); + l_subtrahendNextY = new Double(0.0); + l_subtrahendMaxY = 0.0; + l_subtrahendMinY = 0.0; + + l_subtrahendXs.add(l_subtrahendCurX); + l_subtrahendYs.add(l_subtrahendCurY); + } + else { + l_subtrahendItemCount = x_dataset.getItemCount(1); + } + + boolean b_minuendDone = false; + boolean b_minuendAdvanced = true; + boolean b_minuendAtIntersect = false; + boolean b_minuendFastForward = false; + boolean b_subtrahendDone = false; + boolean b_subtrahendAdvanced = true; + boolean b_subtrahendAtIntersect = false; + boolean b_subtrahendFastForward = false; + boolean b_colinear = false; + + boolean b_positive; + + // coordinate pairs + double l_x1 = 0.0, l_y1 = 0.0; // current minuend point + double l_x2 = 0.0, l_y2 = 0.0; // next minuend point + double l_x3 = 0.0, l_y3 = 0.0; // current subtrahend point + double l_x4 = 0.0, l_y4 = 0.0; // next subtrahend point + + // fast-forward through leading tails + boolean b_fastForwardDone = false; + while (!b_fastForwardDone) { + // get the x and y coordinates + l_x1 = x_dataset.getXValue(0, l_minuendItem); + l_y1 = x_dataset.getYValue(0, l_minuendItem); + l_x2 = x_dataset.getXValue(0, l_minuendItem + 1); + l_y2 = x_dataset.getYValue(0, l_minuendItem + 1); + + l_minuendCurX = new Double(l_x1); + l_minuendCurY = new Double(l_y1); + l_minuendNextX = new Double(l_x2); + l_minuendNextY = new Double(l_y2); + + if (b_impliedZeroSubtrahend) { + l_x3 = l_subtrahendCurX.doubleValue(); + l_y3 = l_subtrahendCurY.doubleValue(); + l_x4 = l_subtrahendNextX.doubleValue(); + l_y4 = l_subtrahendNextY.doubleValue(); + } + else { + l_x3 = x_dataset.getXValue(1, l_subtrahendItem); + l_y3 = x_dataset.getYValue(1, l_subtrahendItem); + l_x4 = x_dataset.getXValue(1, l_subtrahendItem + 1); + l_y4 = x_dataset.getYValue(1, l_subtrahendItem + 1); + + l_subtrahendCurX = new Double(l_x3); + l_subtrahendCurY = new Double(l_y3); + l_subtrahendNextX = new Double(l_x4); + l_subtrahendNextY = new Double(l_y4); + } + + if (l_x2 <= l_x3) { + // minuend needs to be fast forwarded + l_minuendItem++; + b_minuendFastForward = true; + continue; + } + + if (l_x4 <= l_x1) { + // subtrahend needs to be fast forwarded + l_subtrahendItem++; + b_subtrahendFastForward = true; + continue; + } + + // check if initial polygon needs to be clipped + if ((l_x3 < l_x1) && (l_x1 < l_x4)) { + // project onto subtrahend + double l_slope = (l_y4 - l_y3) / (l_x4 - l_x3); + l_subtrahendCurX = l_minuendCurX; + l_subtrahendCurY = new Double((l_slope * l_x1) + + (l_y3 - (l_slope * l_x3))); + + l_subtrahendXs.add(l_subtrahendCurX); + l_subtrahendYs.add(l_subtrahendCurY); + } + + if ((l_x1 < l_x3) && (l_x3 < l_x2)) { + // project onto minuend + double l_slope = (l_y2 - l_y1) / (l_x2 - l_x1); + l_minuendCurX = l_subtrahendCurX; + l_minuendCurY = new Double((l_slope * l_x3) + + (l_y1 - (l_slope * l_x1))); + + l_minuendXs.add(l_minuendCurX); + l_minuendYs.add(l_minuendCurY); + } + + l_minuendMaxY = l_minuendCurY.doubleValue(); + l_minuendMinY = l_minuendCurY.doubleValue(); + l_subtrahendMaxY = l_subtrahendCurY.doubleValue(); + l_subtrahendMinY = l_subtrahendCurY.doubleValue(); + + b_fastForwardDone = true; + } + + // start of algorithm + while (!b_minuendDone && !b_subtrahendDone) { + if (!b_minuendDone && !b_minuendFastForward && b_minuendAdvanced) { + l_x1 = x_dataset.getXValue(0, l_minuendItem); + l_y1 = x_dataset.getYValue(0, l_minuendItem); + l_minuendCurX = new Double(l_x1); + l_minuendCurY = new Double(l_y1); + + if (!b_minuendAtIntersect) { + l_minuendXs.add(l_minuendCurX); + l_minuendYs.add(l_minuendCurY); + } + + l_minuendMaxY = Math.max(l_minuendMaxY, l_y1); + l_minuendMinY = Math.min(l_minuendMinY, l_y1); + + l_x2 = x_dataset.getXValue(0, l_minuendItem + 1); + l_y2 = x_dataset.getYValue(0, l_minuendItem + 1); + l_minuendNextX = new Double(l_x2); + l_minuendNextY = new Double(l_y2); + } + + // never updated the subtrahend if it is implied to be zero + if (!b_impliedZeroSubtrahend && !b_subtrahendDone + && !b_subtrahendFastForward && b_subtrahendAdvanced) { + l_x3 = x_dataset.getXValue(1, l_subtrahendItem); + l_y3 = x_dataset.getYValue(1, l_subtrahendItem); + l_subtrahendCurX = new Double(l_x3); + l_subtrahendCurY = new Double(l_y3); + + if (!b_subtrahendAtIntersect) { + l_subtrahendXs.add(l_subtrahendCurX); + l_subtrahendYs.add(l_subtrahendCurY); + } + + l_subtrahendMaxY = Math.max(l_subtrahendMaxY, l_y3); + l_subtrahendMinY = Math.min(l_subtrahendMinY, l_y3); + + l_x4 = x_dataset.getXValue(1, l_subtrahendItem + 1); + l_y4 = x_dataset.getYValue(1, l_subtrahendItem + 1); + l_subtrahendNextX = new Double(l_x4); + l_subtrahendNextY = new Double(l_y4); + } + + // deassert b_*FastForward (only matters for 1st time through loop) + b_minuendFastForward = false; + b_subtrahendFastForward = false; + + Double l_intersectX = null; + Double l_intersectY = null; + boolean b_intersect = false; + + b_minuendAtIntersect = false; + b_subtrahendAtIntersect = false; + + // check for intersect + if ((l_x2 == l_x4) && (l_y2 == l_y4)) { + // check if line segments are colinear + if ((l_x1 == l_x3) && (l_y1 == l_y3)) { + b_colinear = true; + } + else { + // the intersect is at the next point for both the minuend + // and subtrahend + l_intersectX = new Double(l_x2); + l_intersectY = new Double(l_y2); + + b_intersect = true; + b_minuendAtIntersect = true; + b_subtrahendAtIntersect = true; + } + } + else { + // compute common denominator + double l_denominator = ((l_y4 - l_y3) * (l_x2 - l_x1)) + - ((l_x4 - l_x3) * (l_y2 - l_y1)); + + // compute common deltas + double l_deltaY = l_y1 - l_y3; + double l_deltaX = l_x1 - l_x3; + + // compute numerators + double l_numeratorA = ((l_x4 - l_x3) * l_deltaY) + - ((l_y4 - l_y3) * l_deltaX); + double l_numeratorB = ((l_x2 - l_x1) * l_deltaY) + - ((l_y2 - l_y1) * l_deltaX); + + // check if line segments are colinear + if ((0 == l_numeratorA) && (0 == l_numeratorB) + && (0 == l_denominator)) { + b_colinear = true; + } + else { + // check if previously colinear + if (b_colinear) { + // clear colinear points and flag + l_minuendXs.clear(); + l_minuendYs.clear(); + l_subtrahendXs.clear(); + l_subtrahendYs.clear(); + l_polygonXs.clear(); + l_polygonYs.clear(); + + b_colinear = false; + + // set new starting point for the polygon + boolean b_useMinuend = ((l_x3 <= l_x1) + && (l_x1 <= l_x4)); + l_polygonXs.add(b_useMinuend ? l_minuendCurX + : l_subtrahendCurX); + l_polygonYs.add(b_useMinuend ? l_minuendCurY + : l_subtrahendCurY); + } + } + + // compute slope components + double l_slopeA = l_numeratorA / l_denominator; + double l_slopeB = l_numeratorB / l_denominator; + + // test if both grahphs have a vertical rise at the same x-value + boolean b_vertical = (l_x1 == l_x2) && (l_x3 == l_x4) && (l_x2 == l_x4); + + // check if the line segments intersect + if (((0 < l_slopeA) && (l_slopeA <= 1) && (0 < l_slopeB) + && (l_slopeB <= 1))|| b_vertical) { + + // compute the point of intersection + double l_xi; + double l_yi; + if(b_vertical){ + b_colinear = false; + l_xi = l_x2; + l_yi = l_x4; + } + else{ + l_xi = l_x1 + (l_slopeA * (l_x2 - l_x1)); + l_yi = l_y1 + (l_slopeA * (l_y2 - l_y1)); + } + + l_intersectX = new Double(l_xi); + l_intersectY = new Double(l_yi); + b_intersect = true; + b_minuendAtIntersect = ((l_xi == l_x2) + && (l_yi == l_y2)); + b_subtrahendAtIntersect = ((l_xi == l_x4) + && (l_yi == l_y4)); + + // advance minuend and subtrahend to intesect + l_minuendCurX = l_intersectX; + l_minuendCurY = l_intersectY; + l_subtrahendCurX = l_intersectX; + l_subtrahendCurY = l_intersectY; + } + } + + if (b_intersect) { + // create the polygon + // add the minuend's points to polygon + l_polygonXs.addAll(l_minuendXs); + l_polygonYs.addAll(l_minuendYs); + + // add intersection point to the polygon + l_polygonXs.add(l_intersectX); + l_polygonYs.add(l_intersectY); + + // add the subtrahend's points to the polygon in reverse + Collections.reverse(l_subtrahendXs); + Collections.reverse(l_subtrahendYs); + l_polygonXs.addAll(l_subtrahendXs); + l_polygonYs.addAll(l_subtrahendYs); + + // create an actual polygon + b_positive = (l_subtrahendMaxY <= l_minuendMaxY) + && (l_subtrahendMinY <= l_minuendMinY); + createPolygon(x_graphics, x_dataArea, x_plot, x_domainAxis, + x_rangeAxis, b_positive, l_polygonXs, l_polygonYs); + + // clear the point vectors + l_minuendXs.clear(); + l_minuendYs.clear(); + l_subtrahendXs.clear(); + l_subtrahendYs.clear(); + l_polygonXs.clear(); + l_polygonYs.clear(); + + // set the maxY and minY values to intersect y-value + double l_y = l_intersectY.doubleValue(); + l_minuendMaxY = l_y; + l_subtrahendMaxY = l_y; + l_minuendMinY = l_y; + l_subtrahendMinY = l_y; + + // add interection point to new polygon + l_polygonXs.add(l_intersectX); + l_polygonYs.add(l_intersectY); + } + + // advance the minuend if needed + if (l_x2 <= l_x4) { + l_minuendItem++; + b_minuendAdvanced = true; + } + else { + b_minuendAdvanced = false; + } + + // advance the subtrahend if needed + if (l_x4 <= l_x2) { + l_subtrahendItem++; + b_subtrahendAdvanced = true; + } + else { + b_subtrahendAdvanced = false; + } + + b_minuendDone = (l_minuendItem == (l_minuendItemCount - 1)); + b_subtrahendDone = (l_subtrahendItem == (l_subtrahendItemCount + - 1)); + } + + // check if the final polygon needs to be clipped + if (b_minuendDone && (l_x3 < l_x2) && (l_x2 < l_x4)) { + // project onto subtrahend + double l_slope = (l_y4 - l_y3) / (l_x4 - l_x3); + l_subtrahendNextX = l_minuendNextX; + l_subtrahendNextY = new Double((l_slope * l_x2) + + (l_y3 - (l_slope * l_x3))); + } + + if (b_subtrahendDone && (l_x1 < l_x4) && (l_x4 < l_x2)) { + // project onto minuend + double l_slope = (l_y2 - l_y1) / (l_x2 - l_x1); + l_minuendNextX = l_subtrahendNextX; + l_minuendNextY = new Double((l_slope * l_x4) + + (l_y1 - (l_slope * l_x1))); + } + + // consider last point of minuend and subtrahend for determining + // positivity + l_minuendMaxY = Math.max(l_minuendMaxY, + l_minuendNextY.doubleValue()); + l_subtrahendMaxY = Math.max(l_subtrahendMaxY, + l_subtrahendNextY.doubleValue()); + l_minuendMinY = Math.min(l_minuendMinY, + l_minuendNextY.doubleValue()); + l_subtrahendMinY = Math.min(l_subtrahendMinY, + l_subtrahendNextY.doubleValue()); + + // add the last point of the minuned and subtrahend + l_minuendXs.add(l_minuendNextX); + l_minuendYs.add(l_minuendNextY); + l_subtrahendXs.add(l_subtrahendNextX); + l_subtrahendYs.add(l_subtrahendNextY); + + // create the polygon + // add the minuend's points to polygon + l_polygonXs.addAll(l_minuendXs); + l_polygonYs.addAll(l_minuendYs); + + // add the subtrahend's points to the polygon in reverse + Collections.reverse(l_subtrahendXs); + Collections.reverse(l_subtrahendYs); + l_polygonXs.addAll(l_subtrahendXs); + l_polygonYs.addAll(l_subtrahendYs); + + // create an actual polygon + b_positive = (l_subtrahendMaxY <= l_minuendMaxY) + && (l_subtrahendMinY <= l_minuendMinY); + createPolygon(x_graphics, x_dataArea, x_plot, x_domainAxis, + x_rangeAxis, b_positive, l_polygonXs, l_polygonYs); + } + + /** + * Draws the visual representation of a single data item, second pass. In + * the second pass, the renderer draws the lines and shapes for the + * individual points in the two series. + * + * @param x_graphics the graphics device. + * @param x_dataArea the area within which the data is being drawn. + * @param x_info collects information about the drawing. + * @param x_plot the plot (can be used to obtain standard color + * information etc). + * @param x_domainAxis the domain (horizontal) axis. + * @param x_rangeAxis the range (vertical) axis. + * @param x_dataset the dataset. + * @param x_series the series index (zero-based). + * @param x_item the item index (zero-based). + * @param x_crosshairState crosshair information for the plot + * (null permitted). + */ + protected void drawItemPass1(Graphics2D x_graphics, + Rectangle2D x_dataArea, + PlotRenderingInfo x_info, + XYPlot x_plot, + ValueAxis x_domainAxis, + ValueAxis x_rangeAxis, + XYDataset x_dataset, + int x_series, + int x_item, + CrosshairState x_crosshairState) { + + Shape l_entityArea = null; + EntityCollection l_entities = null; + if (null != x_info) { + l_entities = x_info.getOwner().getEntityCollection(); + } + + Paint l_seriesPaint = getItemPaint(x_series, x_item); + Stroke l_seriesStroke = getItemStroke(x_series, x_item); + x_graphics.setPaint(l_seriesPaint); + x_graphics.setStroke(l_seriesStroke); + + PlotOrientation l_orientation = x_plot.getOrientation(); + RectangleEdge l_domainAxisLocation = x_plot.getDomainAxisEdge(); + RectangleEdge l_rangeAxisLocation = x_plot.getRangeAxisEdge(); + + double l_x0 = x_dataset.getXValue(x_series, x_item); + double l_y0 = x_dataset.getYValue(x_series, x_item); + double l_x1 = x_domainAxis.valueToJava2D(l_x0, x_dataArea, + l_domainAxisLocation); + double l_y1 = x_rangeAxis.valueToJava2D(l_y0, x_dataArea, + l_rangeAxisLocation); + + if (getShapesVisible()) { + Shape l_shape = getItemShape(x_series, x_item); + if (l_orientation == PlotOrientation.HORIZONTAL) { + l_shape = ShapeUtilities.createTranslatedShape(l_shape, + l_y1, l_x1); + } + else { + l_shape = ShapeUtilities.createTranslatedShape(l_shape, + l_x1, l_y1); + } + if (l_shape.intersects(x_dataArea)) { + x_graphics.setPaint(getItemPaint(x_series, x_item)); + x_graphics.fill(l_shape); + } + l_entityArea = l_shape; + } + + // add an entity for the item... + if (null != l_entities) { + if (null == l_entityArea) { + l_entityArea = new Rectangle2D.Double((l_x1 - 2), (l_y1 - 2), + 4, 4); + } + String l_tip = null; + XYToolTipGenerator l_tipGenerator = getToolTipGenerator(x_series, + x_item); + if (null != l_tipGenerator) { + l_tip = l_tipGenerator.generateToolTip(x_dataset, x_series, + x_item); + } + String l_url = null; + XYURLGenerator l_urlGenerator = getURLGenerator(); + if (null != l_urlGenerator) { + l_url = l_urlGenerator.generateURL(x_dataset, x_series, + x_item); + } + XYItemEntity l_entity = new XYItemEntity(l_entityArea, x_dataset, + x_series, x_item, l_tip, l_url); + l_entities.add(l_entity); + } + + // draw the item label if there is one... + if (isItemLabelVisible(x_series, x_item)) { + drawItemLabel(x_graphics, l_orientation, x_dataset, x_series, + x_item, l_x1, l_y1, (l_y1 < 0.0)); + } + + int l_domainAxisIndex = x_plot.getDomainAxisIndex(x_domainAxis); + int l_rangeAxisIndex = x_plot.getRangeAxisIndex(x_rangeAxis); + updateCrosshairValues(x_crosshairState, l_x0, l_y0, l_domainAxisIndex, + l_rangeAxisIndex, l_x1, l_y1, l_orientation); + + if (0 == x_item) { + return; + } + + double l_x2 = x_domainAxis.valueToJava2D(x_dataset.getXValue(x_series, + (x_item - 1)), x_dataArea, l_domainAxisLocation); + double l_y2 = x_rangeAxis.valueToJava2D(x_dataset.getYValue(x_series, + (x_item - 1)), x_dataArea, l_rangeAxisLocation); + + Line2D l_line = null; + if (PlotOrientation.HORIZONTAL == l_orientation) { + l_line = new Line2D.Double(l_y1, l_x1, l_y2, l_x2); + } + else if (PlotOrientation.VERTICAL == l_orientation) { + l_line = new Line2D.Double(l_x1, l_y1, l_x2, l_y2); + } + + if ((null != l_line) && l_line.intersects(x_dataArea)) { + x_graphics.setPaint(getItemPaint(x_series, x_item)); + x_graphics.setStroke(getItemStroke(x_series, x_item)); + x_graphics.draw(l_line); + } + } + + /** + * Determines if a dataset is degenerate. A degenerate dataset is a + * dataset where either series has less than two (2) points. + * + * @param x_dataset the dataset. + * @param x_impliedZeroSubtrahend if false, do not check the subtrahend + * + * @return true if the dataset is degenerate. + */ + private boolean isEitherSeriesDegenerate(XYDataset x_dataset, + boolean x_impliedZeroSubtrahend) { + + if (x_impliedZeroSubtrahend) { + return (x_dataset.getItemCount(0) < 2); + } + + return ((x_dataset.getItemCount(0) < 2) + || (x_dataset.getItemCount(1) < 2)); + } + + /** + * Determines if the two (2) series are disjoint. + * Disjoint series do not overlap in the domain space. + * + * @param x_dataset the dataset. + * + * @return true if the dataset is degenerate. + */ + private boolean areSeriesDisjoint(XYDataset x_dataset) { + + int l_minuendItemCount = x_dataset.getItemCount(0); + double l_minuendFirst = x_dataset.getXValue(0, 0); + double l_minuendLast = x_dataset.getXValue(0, l_minuendItemCount - 1); + + int l_subtrahendItemCount = x_dataset.getItemCount(1); + double l_subtrahendFirst = x_dataset.getXValue(1, 0); + double l_subtrahendLast = x_dataset.getXValue(1, + l_subtrahendItemCount - 1); + + return ((l_minuendLast < l_subtrahendFirst) + || (l_subtrahendLast < l_minuendFirst)); + } + + /** + * Draws the visual representation of a polygon + * + * @param x_graphics the graphics device. + * @param x_dataArea the area within which the data is being drawn. + * @param x_plot the plot (can be used to obtain standard color + * information etc). + * @param x_domainAxis the domain (horizontal) axis. + * @param x_rangeAxis the range (vertical) axis. + * @param x_positive indicates if the polygon is positive (true) or + * negative (false). + * @param x_xValues a linked list of the x values (expects values to be + * of type Double). + * @param x_yValues a linked list of the y values (expects values to be + * of type Double). + */ + private void createPolygon (Graphics2D x_graphics, + Rectangle2D x_dataArea, + XYPlot x_plot, + ValueAxis x_domainAxis, + ValueAxis x_rangeAxis, + boolean x_positive, + LinkedList x_xValues, + LinkedList x_yValues) { + + PlotOrientation l_orientation = x_plot.getOrientation(); + RectangleEdge l_domainAxisLocation = x_plot.getDomainAxisEdge(); + RectangleEdge l_rangeAxisLocation = x_plot.getRangeAxisEdge(); + + Object[] l_xValues = x_xValues.toArray(); + Object[] l_yValues = x_yValues.toArray(); + + GeneralPath l_path = new GeneralPath(); + + if (PlotOrientation.VERTICAL == l_orientation) { + double l_x = x_domainAxis.valueToJava2D(( + (Double) l_xValues[0]).doubleValue(), x_dataArea, + l_domainAxisLocation); + if (this.roundXCoordinates) { + l_x = Math.rint(l_x); + } + + double l_y = x_rangeAxis.valueToJava2D(( + (Double) l_yValues[0]).doubleValue(), x_dataArea, + l_rangeAxisLocation); + + l_path.moveTo((float) l_x, (float) l_y); + for (int i = 1; i < l_xValues.length; i++) { + l_x = x_domainAxis.valueToJava2D(( + (Double) l_xValues[i]).doubleValue(), x_dataArea, + l_domainAxisLocation); + if (this.roundXCoordinates) { + l_x = Math.rint(l_x); + } + + l_y = x_rangeAxis.valueToJava2D(( + (Double) l_yValues[i]).doubleValue(), x_dataArea, + l_rangeAxisLocation); + l_path.lineTo((float) l_x, (float) l_y); + } + l_path.closePath(); + } + else { + double l_x = x_domainAxis.valueToJava2D(( + (Double) l_xValues[0]).doubleValue(), x_dataArea, + l_domainAxisLocation); + if (this.roundXCoordinates) { + l_x = Math.rint(l_x); + } + + double l_y = x_rangeAxis.valueToJava2D(( + (Double) l_yValues[0]).doubleValue(), x_dataArea, + l_rangeAxisLocation); + + l_path.moveTo((float) l_y, (float) l_x); + for (int i = 1; i < l_xValues.length; i++) { + l_x = x_domainAxis.valueToJava2D(( + (Double) l_xValues[i]).doubleValue(), x_dataArea, + l_domainAxisLocation); + if (this.roundXCoordinates) { + l_x = Math.rint(l_x); + } + + l_y = x_rangeAxis.valueToJava2D(( + (Double) l_yValues[i]).doubleValue(), x_dataArea, + l_rangeAxisLocation); + l_path.lineTo((float) l_y, (float) l_x); + } + l_path.closePath(); + } + + if (l_path.intersects(x_dataArea)) { + x_graphics.setPaint(x_positive ? getPositivePaint() + : getNegativePaint()); + x_graphics.fill(l_path); + } + } + + /** + * Returns a default legend item for the specified series. Subclasses + * should override this method to generate customised items. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return A legend item for the series. + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + LegendItem result = null; + XYPlot p = getPlot(); + if (p != null) { + XYDataset dataset = p.getDataset(datasetIndex); + if (dataset != null) { + if (getItemVisible(series, 0)) { + String label = getLegendItemLabelGenerator().generateLabel( + dataset, series); + String description = label; + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText + = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel( + dataset, series); + } + Paint paint = lookupSeriesPaint(series); + Stroke stroke = lookupSeriesStroke(series); + Shape line = getLegendLine(); + result = new LegendItem(label, description, + toolTipText, urlText, line, stroke, paint); + result.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + result.setLabelPaint(labelPaint); + } + result.setDataset(dataset); + result.setDatasetIndex(datasetIndex); + result.setSeriesKey(dataset.getSeriesKey(series)); + result.setSeriesIndex(series); + } + } + + } + + return result; + + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYDifferenceRenderer)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + XYDifferenceRenderer that = (XYDifferenceRenderer) obj; + if (!PaintUtilities.equal(this.positivePaint, that.positivePaint)) { + return false; + } + if (!PaintUtilities.equal(this.negativePaint, that.negativePaint)) { + return false; + } + if (this.shapesVisible != that.shapesVisible) { + return false; + } + if (!ShapeUtilities.equal(this.legendLine, that.legendLine)) { + return false; + } + if (this.roundXCoordinates != that.roundXCoordinates) { + return false; + } + return true; + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + XYDifferenceRenderer clone = (XYDifferenceRenderer) super.clone(); + clone.legendLine = ShapeUtilities.clone(this.legendLine); + 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.positivePaint, stream); + SerialUtilities.writePaint(this.negativePaint, stream); + SerialUtilities.writeShape(this.legendLine, 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.positivePaint = SerialUtilities.readPaint(stream); + this.negativePaint = SerialUtilities.readPaint(stream); + this.legendLine = SerialUtilities.readShape(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYDotRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYDotRenderer.java new file mode 100755 index 0000000..06a0236 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYDotRenderer.java @@ -0,0 +1,398 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * XYDotRenderer.java + * ------------------ + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Christian W. Zuckschwerdt; + * + * Changes (from 29-Oct-2002) + * -------------------------- + * 29-Oct-2002 : Added standard header (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Modified drawItem() method signature (DG); + * 30-Jul-2003 : Modified entity constructor (CZ); + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); + * 19-Jan-2005 : Now uses only primitives from dataset (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 10-Jul-2006 : Added dotWidth and dotHeight attributes (DG); + * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); + * 09-Nov-2007 : Added legend shape attribute, plus override for + * getLegendItem() (DG); + * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +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 org.jfree.chart.LegendItem; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A renderer that draws a small dot at each data point for an {@link XYPlot}. + * The example shown here is generated by the + * ScatterPlotDemo4.java program included in the JFreeChart + * demo collection: + *

+ * XYDotRendererSample.png + */ +public class XYDotRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, PublicCloneable { + + /** For serialization. */ + private static final long serialVersionUID = -2764344339073566425L; + + /** The dot width. */ + private int dotWidth; + + /** The dot height. */ + private int dotHeight; + + /** + * The shape that is used to represent an item in the legend. + * + * @since 1.0.7 + */ + private transient Shape legendShape; + + /** + * Constructs a new renderer. + */ + public XYDotRenderer() { + super(); + this.dotWidth = 1; + this.dotHeight = 1; + this.legendShape = new Rectangle2D.Double(-3.0, -3.0, 6.0, 6.0); + } + + /** + * Returns the dot width (the default value is 1). + * + * @return The dot width. + * + * @since 1.0.2 + * @see #setDotWidth(int) + */ + public int getDotWidth() { + return this.dotWidth; + } + + /** + * Sets the dot width and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param w the new width (must be greater than zero). + * + * @throws IllegalArgumentException if w is less than one. + * + * @since 1.0.2 + * @see #getDotWidth() + */ + public void setDotWidth(int w) { + if (w < 1) { + throw new IllegalArgumentException("Requires w > 0."); + } + this.dotWidth = w; + fireChangeEvent(); + } + + /** + * Returns the dot height (the default value is 1). + * + * @return The dot height. + * + * @since 1.0.2 + * @see #setDotHeight(int) + */ + public int getDotHeight() { + return this.dotHeight; + } + + /** + * Sets the dot height and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param h the new height (must be greater than zero). + * + * @throws IllegalArgumentException if h is less than one. + * + * @since 1.0.2 + * @see #getDotHeight() + */ + public void setDotHeight(int h) { + if (h < 1) { + throw new IllegalArgumentException("Requires h > 0."); + } + this.dotHeight = h; + fireChangeEvent(); + } + + /** + * Returns the shape used to represent an item in the legend. + * + * @return The legend shape (never null). + * + * @see #setLegendShape(Shape) + * + * @since 1.0.7 + */ + public Shape getLegendShape() { + return this.legendShape; + } + + /** + * Sets the shape used as a line in each legend item and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param shape the shape (null not permitted). + * + * @see #getLegendShape() + * + * @since 1.0.7 + */ + public void setLegendShape(Shape shape) { + ParamChecks.nullNotPermitted(shape, "shape"); + this.legendShape = shape; + fireChangeEvent(); + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @param plot the plot (can be used to obtain standard color + * information etc). + * @param domainAxis the domain (horizontal) axis. + * @param rangeAxis the range (vertical) axis. + * @param dataset the dataset. + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + // do nothing if item is not visible + if (!getItemVisible(series, item)) { + return; + } + + // get the data point... + double x = dataset.getXValue(series, item); + double y = dataset.getYValue(series, item); + double adjx = (this.dotWidth - 1) / 2.0; + double adjy = (this.dotHeight - 1) / 2.0; + if (!Double.isNaN(y)) { + RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); + RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); + double transX = domainAxis.valueToJava2D(x, dataArea, + xAxisLocation) - adjx; + double transY = rangeAxis.valueToJava2D(y, dataArea, yAxisLocation) + - adjy; + + g2.setPaint(getItemPaint(series, item)); + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + g2.fillRect((int) transY, (int) transX, this.dotHeight, + this.dotWidth); + } + else if (orientation == PlotOrientation.VERTICAL) { + g2.fillRect((int) transX, (int) transY, this.dotWidth, + this.dotHeight); + } + + int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); + int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); + updateCrosshairValues(crosshairState, x, y, domainAxisIndex, + rangeAxisIndex, transX, transY, orientation); + } + + } + + /** + * Returns a legend item for the specified series. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return A legend item for the series (possibly null). + */ + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + + // if the renderer isn't assigned to a plot, then we don't have a + // dataset... + XYPlot plot = getPlot(); + if (plot == null) { + return null; + } + + XYDataset dataset = plot.getDataset(datasetIndex); + if (dataset == null) { + return null; + } + + LegendItem result = null; + if (getItemVisible(series, 0)) { + String label = getLegendItemLabelGenerator().generateLabel(dataset, + series); + String description = label; + String toolTipText = null; + if (getLegendItemToolTipGenerator() != null) { + toolTipText = getLegendItemToolTipGenerator().generateLabel( + dataset, series); + } + String urlText = null; + if (getLegendItemURLGenerator() != null) { + urlText = getLegendItemURLGenerator().generateLabel( + dataset, series); + } + Paint fillPaint = lookupSeriesPaint(series); + result = new LegendItem(label, description, toolTipText, urlText, + getLegendShape(), fillPaint); + result.setLabelFont(lookupLegendTextFont(series)); + Paint labelPaint = lookupLegendTextPaint(series); + if (labelPaint != null) { + result.setLabelPaint(labelPaint); + } + result.setSeriesKey(dataset.getSeriesKey(series)); + result.setSeriesIndex(series); + result.setDataset(dataset); + result.setDatasetIndex(datasetIndex); + } + + return result; + + } + + /** + * Tests this renderer for equality with an arbitrary object. This method + * returns true if and only if: + * + *

    + *
  • obj is not null;
  • + *
  • obj is an instance of XYDotRenderer;
  • + *
  • both renderers have the same attribute values. + *
+ * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYDotRenderer)) { + return false; + } + XYDotRenderer that = (XYDotRenderer) obj; + if (this.dotWidth != that.dotWidth) { + return false; + } + if (this.dotHeight != that.dotHeight) { + return false; + } + if (!ShapeUtilities.equal(this.legendShape, that.legendShape)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * 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.legendShape = SerialUtilities.readShape(stream); + } + + /** + * 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.legendShape, stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYErrorRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYErrorRenderer.java new file mode 100755 index 0000000..e755bca --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYErrorRenderer.java @@ -0,0 +1,460 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * XYErrorRenderer.java + * -------------------- + * (C) Copyright 2006-2011, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Oct-2006 : Version 1 (DG); + * 23-Mar-2007 : Check item visibility before drawing error bars - see bug + * 1686178 (DG); + * 28-Jan-2009 : Added stroke options for error indicators (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +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 org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.Range; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; + +/** + * A line and shape renderer that can also display x and/or y-error values. + * This renderer expects an {@link IntervalXYDataset}, otherwise it reverts + * to the behaviour of the super class. The example shown here is generated by + * the XYErrorRendererDemo1.java program included in the + * JFreeChart demo collection: + *

+ * XYErrorRendererSample.png + * + * @since 1.0.3 + */ +public class XYErrorRenderer extends XYLineAndShapeRenderer { + + /** For serialization. */ + static final long serialVersionUID = 5162283570955172424L; + + /** A flag that controls whether or not the x-error bars are drawn. */ + private boolean drawXError; + + /** A flag that controls whether or not the y-error bars are drawn. */ + private boolean drawYError; + + /** The length of the cap at the end of the error bars. */ + private double capLength; + + /** + * The paint used to draw the error bars (if null we use the + * series paint). + */ + private transient Paint errorPaint; + + /** + * The stroke used to draw the error bars (if null we use the + * series outline stroke). + * + * @since 1.0.13 + */ + private transient Stroke errorStroke; + + /** + * Creates a new XYErrorRenderer instance. + */ + public XYErrorRenderer() { + super(false, true); + this.drawXError = true; + this.drawYError = true; + this.errorPaint = null; + this.errorStroke = null; + this.capLength = 4.0; + } + + /** + * Returns the flag that controls whether or not the renderer draws error + * bars for the x-values. + * + * @return A boolean. + * + * @see #setDrawXError(boolean) + */ + public boolean getDrawXError() { + return this.drawXError; + } + + /** + * Sets the flag that controls whether or not the renderer draws error + * bars for the x-values and, if the flag changes, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param draw the flag value. + * + * @see #getDrawXError() + */ + public void setDrawXError(boolean draw) { + if (this.drawXError != draw) { + this.drawXError = draw; + fireChangeEvent(); + } + } + + /** + * Returns the flag that controls whether or not the renderer draws error + * bars for the y-values. + * + * @return A boolean. + * + * @see #setDrawYError(boolean) + */ + public boolean getDrawYError() { + return this.drawYError; + } + + /** + * Sets the flag that controls whether or not the renderer draws error + * bars for the y-values and, if the flag changes, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param draw the flag value. + * + * @see #getDrawYError() + */ + public void setDrawYError(boolean draw) { + if (this.drawYError != draw) { + this.drawYError = draw; + fireChangeEvent(); + } + } + + /** + * Returns the length (in Java2D units) of the cap at the end of the error + * bars. + * + * @return The cap length. + * + * @see #setCapLength(double) + */ + public double getCapLength() { + return this.capLength; + } + + /** + * Sets the length of the cap at the end of the error bars, and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param length the length (in Java2D units). + * + * @see #getCapLength() + */ + public void setCapLength(double length) { + this.capLength = length; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw the error bars. If this is + * null (the default), the item paint is used instead. + * + * @return The paint (possibly null). + * + * @see #setErrorPaint(Paint) + */ + public Paint getErrorPaint() { + return this.errorPaint; + } + + /** + * Sets the paint used to draw the error bars and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @see #getErrorPaint() + */ + public void setErrorPaint(Paint paint) { + this.errorPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the stroke used to draw the error bars. If this is + * null (the default), the item outline stroke is used + * instead. + * + * @return The stroke (possibly null). + * + * @see #setErrorStroke(Stroke) + * + * @since 1.0.13 + */ + public Stroke getErrorStroke() { + return this.errorStroke; + } + + /** + * Sets the stroke used to draw the error bars and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null permitted). + * + * @see #getErrorStroke() + * + * @since 1.0.13 + */ + public void setErrorStroke(Stroke stroke) { + this.errorStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the range required by this renderer to display all the domain + * values in the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range, or null if the dataset is + * null. + */ + @Override + public Range findDomainBounds(XYDataset dataset) { + // include the interval if there is one + return findDomainBounds(dataset, true); + } + + /** + * Returns the range required by this renderer to display all the range + * values in the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range, or null if the dataset is + * null. + */ + @Override + public Range findRangeBounds(XYDataset dataset) { + // include the interval if there is one + return findRangeBounds(dataset, true); + } + + /** + * Draws the visual representation for one data item. + * + * @param g2 the graphics output target. + * @param state the renderer state. + * @param dataArea the data area. + * @param info the plot rendering info. + * @param plot the plot. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataset the dataset. + * @param series the series index. + * @param item the item index. + * @param crosshairState the crosshair state. + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + if (pass == 0 && dataset instanceof IntervalXYDataset + && getItemVisible(series, item)) { + IntervalXYDataset ixyd = (IntervalXYDataset) dataset; + PlotOrientation orientation = plot.getOrientation(); + if (this.drawXError) { + // draw the error bar for the x-interval + double x0 = ixyd.getStartXValue(series, item); + double x1 = ixyd.getEndXValue(series, item); + double y = ixyd.getYValue(series, item); + RectangleEdge edge = plot.getDomainAxisEdge(); + double xx0 = domainAxis.valueToJava2D(x0, dataArea, edge); + double xx1 = domainAxis.valueToJava2D(x1, dataArea, edge); + double yy = rangeAxis.valueToJava2D(y, dataArea, + plot.getRangeAxisEdge()); + Line2D line; + Line2D cap1; + Line2D cap2; + double adj = this.capLength / 2.0; + if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(xx0, yy, xx1, yy); + cap1 = new Line2D.Double(xx0, yy - adj, xx0, yy + adj); + cap2 = new Line2D.Double(xx1, yy - adj, xx1, yy + adj); + } + else { // PlotOrientation.HORIZONTAL + line = new Line2D.Double(yy, xx0, yy, xx1); + cap1 = new Line2D.Double(yy - adj, xx0, yy + adj, xx0); + cap2 = new Line2D.Double(yy - adj, xx1, yy + adj, xx1); + } + if (this.errorPaint != null) { + g2.setPaint(this.errorPaint); + } + else { + g2.setPaint(getItemPaint(series, item)); + } + if (this.errorStroke != null) { + g2.setStroke(this.errorStroke); + } + else { + g2.setStroke(getItemStroke(series, item)); + } + g2.draw(line); + g2.draw(cap1); + g2.draw(cap2); + } + if (this.drawYError) { + // draw the error bar for the y-interval + double y0 = ixyd.getStartYValue(series, item); + double y1 = ixyd.getEndYValue(series, item); + double x = ixyd.getXValue(series, item); + RectangleEdge edge = plot.getRangeAxisEdge(); + double yy0 = rangeAxis.valueToJava2D(y0, dataArea, edge); + double yy1 = rangeAxis.valueToJava2D(y1, dataArea, edge); + double xx = domainAxis.valueToJava2D(x, dataArea, + plot.getDomainAxisEdge()); + Line2D line; + Line2D cap1; + Line2D cap2; + double adj = this.capLength / 2.0; + if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(xx, yy0, xx, yy1); + cap1 = new Line2D.Double(xx - adj, yy0, xx + adj, yy0); + cap2 = new Line2D.Double(xx - adj, yy1, xx + adj, yy1); + } + else { // PlotOrientation.HORIZONTAL + line = new Line2D.Double(yy0, xx, yy1, xx); + cap1 = new Line2D.Double(yy0, xx - adj, yy0, xx + adj); + cap2 = new Line2D.Double(yy1, xx - adj, yy1, xx + adj); + } + if (this.errorPaint != null) { + g2.setPaint(this.errorPaint); + } + else { + g2.setPaint(getItemPaint(series, item)); + } + if (this.errorStroke != null) { + g2.setStroke(this.errorStroke); + } + else { + g2.setStroke(getItemStroke(series, item)); + } + g2.draw(line); + g2.draw(cap1); + g2.draw(cap2); + } + } + super.drawItem(g2, state, dataArea, info, plot, domainAxis, rangeAxis, + dataset, series, item, crosshairState, pass); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYErrorRenderer)) { + return false; + } + XYErrorRenderer that = (XYErrorRenderer) obj; + if (this.drawXError != that.drawXError) { + return false; + } + if (this.drawYError != that.drawYError) { + return false; + } + if (this.capLength != that.capLength) { + return false; + } + if (!PaintUtilities.equal(this.errorPaint, that.errorPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.errorStroke, that.errorStroke)) { + return false; + } + return super.equals(obj); + } + + /** + * 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.errorPaint = SerialUtilities.readPaint(stream); + this.errorStroke = SerialUtilities.readStroke(stream); + } + + /** + * 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.errorPaint, stream); + SerialUtilities.writeStroke(this.errorStroke, stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYItemRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYItemRenderer.java new file mode 100755 index 0000000..326811a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYItemRenderer.java @@ -0,0 +1,1765 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * XYItemRenderer.java + * ------------------- + * (C) Copyright 2001-2011, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Mark Watson (www.markwatson.com); + * Sylvain Vieujot; + * Focus Computer Services Limited; + * Richard Atkinson; + * + * Changes + * ------- + * 19-Oct-2001 : Version 1, based on code by Mark Watson (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * 13-Dec-2001 : Changed return type of drawItem from void --> Shape. The area + * returned can be used as the tooltip region. + * 23-Jan-2002 : Added DrawInfo parameter to drawItem() method (DG); + * 28-Mar-2002 : Added a property change listener mechanism. Now renderers do + * not have to be immutable (DG); + * 04-Apr-2002 : Added the initialise() method (DG); + * 09-Apr-2002 : Removed the translated zero from the drawItem method, it can + * be calculated inside the initialise method if it is required. + * Added a new getToolTipGenerator() method. Changed the return + * type for drawItem() to void (DG); + * 24-May-2002 : Added ChartRenderingInfo the initialise method API (DG); + * 25-Jun-2002 : Removed redundant import (DG); + * 20-Aug-2002 : Added get/setURLGenerator methods to interface (DG); + * 02-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 18-Nov-2002 : Added methods for drawing grid lines (DG); + * 17-Jan-2003 : Moved plot classes into a separate package (DG); + * 27-Jan-2003 : Added shape lookup table (DG); + * 05-Jun-2003 : Added domain and range grid bands (sponsored by Focus Computer + * Services Ltd) (DG); + * 27-Jul-2003 : Added getRangeType() to support stacked XY area charts (RA); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed + * XYToolTipGenerator --> XYItemLabelGenerator (DG); + * 26-Feb-2004 : Added lots of new methods (DG); + * 30-Apr-2004 : Added getRangeExtent() method (DG); + * 06-May-2004 : Added methods for controlling item label visibility (DG); + * 13-May-2004 : Removed property change listener mechanism (DG); + * 18-May-2004 : Added item label font and paint methods (DG); + * 10-Sep-2004 : Removed redundant getRangeType() method (DG); + * 06-Oct-2004 : Replaced getRangeExtent() with findRangeBounds() and added + * findDomainBounds (DG); + * 23-Nov-2004 : Changed drawRangeGridLine() --> drawRangeLine() (DG); + * 07-Jan-2005 : Removed deprecated method (DG); + * 24-Feb-2005 : Now extends LegendItemSource (DG); + * 20-Apr-2005 : Renamed XYLabelGenerator --> XYItemLabelGenerator (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 19-Apr-2007 : Deprecated seriesVisible and seriesVisibleInLegend flags (DG); + * 20-Apr-2007 : Deprecated paint, fillPaint, outlinePaint, stroke, + * outlineStroke, shape, itemLabelsVisible, itemLabelFont, + * itemLabelPaint, positiveItemLabelPosition, + * negativeItemLabelPosition and createEntities override + * fields (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemSource; +import org.jfree.chart.annotations.XYAnnotation; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.event.RendererChangeListener; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.labels.XYItemLabelGenerator; +import org.jfree.chart.labels.XYSeriesLabelGenerator; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.Marker; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.data.Range; +import org.jfree.data.xy.XYDataset; +import org.jfree.ui.Layer; + +/** + * Interface for rendering the visual representation of a single (x, y) item on + * an {@link XYPlot}. + *

+ * To support cloning charts, it is recommended that renderers implement both + * the {@link Cloneable} and PublicCloneable interfaces. + */ +public interface XYItemRenderer extends LegendItemSource { + + /** + * Returns the plot that this renderer has been assigned to. + * + * @return The plot. + */ + public XYPlot getPlot(); + + /** + * Sets the plot that this renderer is assigned to. This method will be + * called by the plot class...you do not need to call it yourself. + * + * @param plot the plot. + */ + public void setPlot(XYPlot plot); + + /** + * Returns the number of passes through the data required by the renderer. + * + * @return The pass count. + */ + public int getPassCount(); + + /** + * Returns the lower and upper bounds (range) of the x-values in the + * specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range. + */ + public Range findDomainBounds(XYDataset dataset); + + /** + * Returns the lower and upper bounds (range) of the y-values in the + * specified dataset. The implementation of this method will take + * into account the presentation used by the renderers (for example, + * a renderer that "stacks" values will return a bigger range than + * a renderer that doesn't). + * + * @param dataset the dataset (null permitted). + * + * @return The range (or null if the dataset is + * null or empty). + */ + public Range findRangeBounds(XYDataset dataset); + + /** + * Add a renderer change listener. + * + * @param listener the listener. + * + * @see #removeChangeListener(RendererChangeListener) + */ + public void addChangeListener(RendererChangeListener listener); + + /** + * Removes a change listener. + * + * @param listener the listener. + * + * @see #addChangeListener(RendererChangeListener) + */ + public void removeChangeListener(RendererChangeListener listener); + + + //// VISIBLE ////////////////////////////////////////////////////////////// + + /** + * Returns a boolean that indicates whether or not the specified item + * should be drawn (this is typically used to hide an entire series). + * + * @param series the series index. + * @param item the item index. + * + * @return A boolean. + */ + public boolean getItemVisible(int series, int item); + + /** + * Returns a boolean that indicates whether or not the specified series + * should be drawn (this is typically used to hide an entire series). + * + * @param series the series index. + * + * @return A boolean. + */ + public boolean isSeriesVisible(int series); + + /** + * Returns the flag that controls whether a series is visible. + * + * @param series the series index (zero-based). + * + * @return The flag (possibly null). + * + * @see #setSeriesVisible(int, Boolean) + */ + public Boolean getSeriesVisible(int series); + + /** + * Sets the flag that controls whether a series is visible and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the flag (null permitted). + * + * @see #getSeriesVisible(int) + */ + public void setSeriesVisible(int series, Boolean visible); + + /** + * Sets the flag that controls whether a series is visible and, if + * requested, sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index. + * @param visible the flag (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesVisible(int) + */ + public void setSeriesVisible(int series, Boolean visible, boolean notify); + + /** + * Returns the base visibility for all series. + * + * @return The base visibility. + * + * @see #setBaseSeriesVisible(boolean) + */ + public boolean getBaseSeriesVisible(); + + /** + * Sets the base visibility and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param visible the flag. + * + * @see #getBaseSeriesVisible() + */ + public void setBaseSeriesVisible(boolean visible); + + /** + * Sets the base visibility and, if requested, sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the visibility. + * @param notify notify listeners? + * + * @see #getBaseSeriesVisible() + */ + public void setBaseSeriesVisible(boolean visible, boolean notify); + + // SERIES VISIBLE IN LEGEND (not yet respected by all renderers) + + /** + * Returns true if the series should be shown in the legend, + * and false otherwise. + * + * @param series the series index. + * + * @return A boolean. + */ + public boolean isSeriesVisibleInLegend(int series); + + /** + * Returns the flag that controls whether a series is visible in the + * legend. This method returns only the "per series" settings - to + * incorporate the override and base settings as well, you need to use the + * {@link #isSeriesVisibleInLegend(int)} method. + * + * @param series the series index (zero-based). + * + * @return The flag (possibly null). + * + * @see #setSeriesVisibleInLegend(int, Boolean) + */ + public Boolean getSeriesVisibleInLegend(int series); + + /** + * Sets the flag that controls whether a series is visible in the legend + * and sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the flag (null permitted). + * + * @see #getSeriesVisibleInLegend(int) + */ + public void setSeriesVisibleInLegend(int series, Boolean visible); + + /** + * Sets the flag that controls whether a series is visible in the legend + * and, if requested, sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index. + * @param visible the flag (null permitted). + * @param notify notify listeners? + * + * @see #getSeriesVisibleInLegend(int) + */ + public void setSeriesVisibleInLegend(int series, Boolean visible, + boolean notify); + + /** + * Returns the base visibility in the legend for all series. + * + * @return The base visibility. + * + * @see #setBaseSeriesVisibleInLegend(boolean) + */ + public boolean getBaseSeriesVisibleInLegend(); + + /** + * Sets the base visibility in the legend and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the flag. + * + * @see #getBaseSeriesVisibleInLegend() + */ + public void setBaseSeriesVisibleInLegend(boolean visible); + + /** + * Sets the base visibility in the legend and, if requested, sends + * a {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the visibility. + * @param notify notify listeners? + * + * @see #getBaseSeriesVisibleInLegend() + */ + public void setBaseSeriesVisibleInLegend(boolean visible, boolean notify); + + + //// PAINT //////////////////////////////////////////////////////////////// + + /** + * Returns the paint used to color data items as they are drawn. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The paint (never null). + */ + public Paint getItemPaint(int row, int column); + + /** + * Returns the paint used to color an item drawn by the renderer. + * + * @param series the series index (zero-based). + * + * @return The paint (possibly null). + * + * @see #setSeriesPaint(int, Paint) + */ + public Paint getSeriesPaint(int series); + + /** + * Sets the paint used for a series and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param series the series index (zero-based). + * @param paint the paint (null permitted). + * + * @see #getSeriesPaint(int) + */ + public void setSeriesPaint(int series, Paint paint); + + // FIXME: add setSeriesPaint(int, Paint, boolean)? + + /** + * Returns the base (or default) paint. + * + * @return The base paint (never null). + * + * @see #setBasePaint(Paint) + */ + public Paint getBasePaint(); + + /** + * Sets the base paint and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getBasePaint() + */ + public void setBasePaint(Paint paint); + + // FIXME: add setBasePaint(int, Paint, boolean)? + +// // FILL PAINT +// +// /** +// * Returns the paint used to fill data items as they are drawn. +// * +// * @param row the row (or series) index (zero-based). +// * @param column the column (or category) index (zero-based). +// * +// * @return The paint (never null). +// */ +// public Paint getItemFillPaint(int row, int column); +// +// /** +// * Returns the paint used to fill an item drawn by the renderer. +// * +// * @param series the series index (zero-based). +// * +// * @return The paint (possibly null). +// */ +// public Paint getSeriesFillPaint(int series); +// +// /** +// * Sets the paint used for a series and sends a +// * {@link RendererChangeEvent} to all registered listeners. +// * +// * @param series the series index (zero-based). +// * @param paint the paint (null permitted). +// */ +// public void setSeriesFillPaint(int series, Paint paint); +// +// // FIXME: add setSeriesFillPaint(int, Paint, boolean)? +// +// /** +// * Returns the base paint. +// * +// * @return The base paint (never null). +// */ +// public Paint getBaseFillPaint(); +// +// /** +// * Sets the base paint and sends a {@link RendererChangeEvent} to all +// * registered listeners. +// * +// * @param paint the paint (null not permitted). +// */ +// public void setBaseFillPaint(Paint paint); +// +// // FIXME: add setBaseFillPaint(int, Paint, boolean)? + + //// OUTLINE PAINT //////////////////////////////////////////////////////// + + /** + * Returns the paint used to outline data items as they are drawn. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The paint (never null). + */ + public Paint getItemOutlinePaint(int row, int column); + + /** + * Returns the paint used to outline an item drawn by the renderer. + * + * @param series the series (zero-based index). + * + * @return The paint (possibly null). + * + * @see #setSeriesOutlinePaint(int, Paint) + */ + public Paint getSeriesOutlinePaint(int series); + + /** + * Sets the paint used for a series outline and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param paint the paint (null permitted). + * + * @see #getSeriesOutlinePaint(int) + */ + public void setSeriesOutlinePaint(int series, Paint paint); + + // FIXME: add setSeriesOutlinePaint(int, Paint, boolean)? + + /** + * Returns the base (or default) outline paint. + * + * @return The paint (never null). + * + * @see #setBaseOutlinePaint(Paint) + */ + public Paint getBaseOutlinePaint(); + + /** + * Sets the base outline paint and sends a {@link RendererChangeEvent} to + * all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getBaseOutlinePaint() + */ + public void setBaseOutlinePaint(Paint paint); + + // FIXME: add setBaseOutlinePaint(Paint, boolean)? + + //// STROKE /////////////////////////////////////////////////////////////// + + /** + * Returns the stroke used to draw data items. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The stroke (never null). + */ + public Stroke getItemStroke(int row, int column); + + /** + * Returns the stroke used to draw the items in a series. + * + * @param series the series (zero-based index). + * + * @return The stroke (possibly null). + * + * @see #setSeriesStroke(int, Stroke) + */ + public Stroke getSeriesStroke(int series); + + /** + * Sets the stroke used for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param stroke the stroke (null permitted). + * + * @see #getSeriesStroke(int) + */ + public void setSeriesStroke(int series, Stroke stroke); + + // FIXME: add setSeriesStroke(int, Stroke, boolean) ? + + /** + * Returns the base (or default) stroke. + * + * @return The base stroke (never null). + * + * @see #setBaseStroke(Stroke) + */ + public Stroke getBaseStroke(); + + /** + * Sets the base stroke and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getBaseStroke() + */ + public void setBaseStroke(Stroke stroke); + + // FIXME: add setBaseStroke(Stroke, boolean) ? + + //// OUTLINE STROKE /////////////////////////////////////////////////////// + + /** + * Returns the stroke used to outline data items. The default + * implementation passes control to the lookupSeriesOutlineStroke method. + * You can override this method if you require different behaviour. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The stroke (never null). + */ + public Stroke getItemOutlineStroke(int row, int column); + + /** + * Returns the stroke used to outline the items in a series. + * + * @param series the series (zero-based index). + * + * @return The stroke (possibly null). + * + * @see #setSeriesOutlineStroke(int, Stroke) + */ + public Stroke getSeriesOutlineStroke(int series); + + /** + * Sets the outline stroke used for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param stroke the stroke (null permitted). + * + * @see #getSeriesOutlineStroke(int) + */ + public void setSeriesOutlineStroke(int series, Stroke stroke); + + // FIXME: add setSeriesOutlineStroke(int, Stroke, boolean) ? + + /** + * Returns the base outline stroke. + * + * @return The stroke (never null). + * + * @see #setBaseOutlineStroke(Stroke) + */ + public Stroke getBaseOutlineStroke(); + + /** + * Sets the base outline stroke and sends a {@link RendererChangeEvent} to + * all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getBaseOutlineStroke() + */ + public void setBaseOutlineStroke(Stroke stroke); + + // FIXME: add setBaseOutlineStroke(Stroke, boolean) ? + + //// SHAPE //////////////////////////////////////////////////////////////// + + /** + * Returns a shape used to represent a data item. + * + * @param row the row (or series) index (zero-based). + * @param column the column (or category) index (zero-based). + * + * @return The shape (never null). + */ + public Shape getItemShape(int row, int column); + + /** + * Returns a shape used to represent the items in a series. + * + * @param series the series (zero-based index). + * + * @return The shape (possibly null). + * + * @see #setSeriesShape(int, Shape) + */ + public Shape getSeriesShape(int series); + + /** + * Sets the shape used for a series and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param series the series index (zero-based). + * @param shape the shape (null permitted). + * + * @see #getSeriesShape(int) + */ + public void setSeriesShape(int series, Shape shape); + + // FIXME: add setSeriesShape(int, Shape, boolean) ? + + /** + * Returns the base shape. + * + * @return The shape (never null). + * + * @see #setBaseShape(Shape) + */ + public Shape getBaseShape(); + + /** + * Sets the base shape and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param shape the shape (null not permitted). + * + * @see #getBaseShape() + */ + public void setBaseShape(Shape shape); + + // FIXME: add setBaseShape(Shape, boolean) ? + + + //// LEGEND ITEMS ///////////////////////////////////////////////////////// + + /** + * Returns a legend item for a series from a dataset. + * + * @param datasetIndex the dataset index. + * @param series the series (zero-based index). + * + * @return The legend item (possibly null). + */ + public LegendItem getLegendItem(int datasetIndex, int series); + + + //// LEGEND ITEM LABEL GENERATOR ////////////////////////////////////////// + + /** + * Returns the legend item label generator. + * + * @return The legend item label generator (never null). + * + * @see #setLegendItemLabelGenerator(XYSeriesLabelGenerator) + */ + public XYSeriesLabelGenerator getLegendItemLabelGenerator(); + + /** + * Sets the legend item label generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null not permitted). + */ + public void setLegendItemLabelGenerator(XYSeriesLabelGenerator generator); + + + //// TOOL TIP GENERATOR /////////////////////////////////////////////////// + + /** + * Returns the tool tip generator for a data item. + * + * @param row the row index (zero based). + * @param column the column index (zero based). + * + * @return The generator (possibly null). + */ + public XYToolTipGenerator getToolTipGenerator(int row, int column); + + /** + * Returns the tool tip generator for a series. + * + * @param series the series index (zero based). + * + * @return The generator (possibly null). + * + * @see #setSeriesToolTipGenerator(int, XYToolTipGenerator) + */ + public XYToolTipGenerator getSeriesToolTipGenerator(int series); + + /** + * Sets the tool tip generator for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero based). + * @param generator the generator (null permitted). + * + * @see #getSeriesToolTipGenerator(int) + */ + public void setSeriesToolTipGenerator(int series, + XYToolTipGenerator generator); + + /** + * Returns the base tool tip generator. + * + * @return The generator (possibly null). + * + * @see #setBaseToolTipGenerator(XYToolTipGenerator) + */ + public XYToolTipGenerator getBaseToolTipGenerator(); + + /** + * Sets the base tool tip generator and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getBaseToolTipGenerator() + */ + public void setBaseToolTipGenerator(XYToolTipGenerator generator); + + //// URL GENERATOR //////////////////////////////////////////////////////// + + + /** + * Returns the URL generator for HTML image maps. + * + * @return The URL generator (possibly null). + */ + public XYURLGenerator getURLGenerator(); + + /** + * Sets the URL generator for HTML image maps. + * + * @param urlGenerator the URL generator (null permitted). + */ + public void setURLGenerator(XYURLGenerator urlGenerator); + + //// ITEM LABELS VISIBLE ////////////////////////////////////////////////// + + /** + * Returns true if an item label is visible, and + * false otherwise. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return A boolean. + */ + public boolean isItemLabelVisible(int row, int column); + + /** + * Returns true if the item labels for a series are visible, + * and false otherwise. + * + * @param series the series index (zero-based). + * + * @return A boolean. + */ + public boolean isSeriesItemLabelsVisible(int series); + + /** + * Sets a flag that controls the visibility of the item labels for a + * series and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index (zero-based). + * @param visible the flag. + * + * @see #isSeriesItemLabelsVisible(int) + */ + public void setSeriesItemLabelsVisible(int series, boolean visible); + + /** + * Sets a flag that controls the visibility of the item labels for a series. + * + * @param series the series index (zero-based). + * @param visible the flag (null permitted). + * + * @see #isSeriesItemLabelsVisible(int) + */ + public void setSeriesItemLabelsVisible(int series, Boolean visible); + + /** + * Sets the visibility of item labels for a series and, if requested, + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the visible flag. + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @see #isSeriesItemLabelsVisible(int) + */ + public void setSeriesItemLabelsVisible(int series, Boolean visible, + boolean notify); + + /** + * Returns the base setting for item label visibility. + * + * @return A flag (possibly null). + * + * @see #setBaseItemLabelsVisible(boolean) + */ + public Boolean getBaseItemLabelsVisible(); + + /** + * Sets the base flag that controls whether or not item labels are visible. + * + * @param visible the flag. + * + * @see #getBaseItemLabelsVisible() + */ + public void setBaseItemLabelsVisible(boolean visible); + + /** + * Sets the base setting for item label visibility. + * + * @param visible the flag (null permitted). + * + * @see #getBaseItemLabelsVisible() + */ + public void setBaseItemLabelsVisible(Boolean visible); + + /** + * Sets the base visibility for item labels and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the visibility flag. + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @see #getBaseItemLabelsVisible() + */ + public void setBaseItemLabelsVisible(Boolean visible, boolean notify); + + + //// ITEM LABEL GENERATOR ///////////////////////////////////////////////// + + /** + * Returns the item label generator for a data item. + * + * @param row the row index (zero based). + * @param column the column index (zero based). + * + * @return The generator (possibly null). + */ + public XYItemLabelGenerator getItemLabelGenerator(int row, int column); + + /** + * Returns the item label generator for a series. + * + * @param series the series index (zero based). + * + * @return The generator (possibly null). + * + * @see #setSeriesItemLabelGenerator(int, XYItemLabelGenerator) + */ + public XYItemLabelGenerator getSeriesItemLabelGenerator(int series); + + /** + * Sets the item label generator for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero based). + * @param generator the generator (null permitted). + * + * @see #getSeriesItemLabelGenerator(int) + */ + public void setSeriesItemLabelGenerator(int series, + XYItemLabelGenerator generator); + + // FIXME: + + /** + * Returns the base item label generator. + * + * @return The generator (possibly null). + * + * @see #setBaseItemLabelGenerator(XYItemLabelGenerator) + */ + public XYItemLabelGenerator getBaseItemLabelGenerator(); + + /** + * Sets the base item label generator and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @see #getBaseItemLabelGenerator() + */ + public void setBaseItemLabelGenerator(XYItemLabelGenerator generator); + + //// ITEM LABEL FONT /////////////////////////////////////////////////////// + + /** + * Returns the font for an item label. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The font (never null). + */ + public Font getItemLabelFont(int row, int column); + + /** + * Returns the font for all the item labels in a series. + * + * @param series the series index (zero-based). + * + * @return The font (possibly null). + */ + public Font getSeriesItemLabelFont(int series); + + /** + * Sets the item label font for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param font the font (null permitted). + * + * @see #getSeriesItemLabelFont(int) + */ + public void setSeriesItemLabelFont(int series, Font font); + + /** + * Returns the base item label font (this is used when no other font + * setting is available). + * + * @return The font (never null). + * + * @see #setBaseItemLabelFont(Font) + */ + public Font getBaseItemLabelFont(); + + /** + * Sets the base item label font and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param font the font (null not permitted). + * + * @see #getBaseItemLabelFont() + */ + public void setBaseItemLabelFont(Font font); + + //// ITEM LABEL PAINT ///////////////////////////////////////////////////// + + /** + * Returns the paint used to draw an item label. + * + * @param row the row index (zero based). + * @param column the column index (zero based). + * + * @return The paint (never null). + */ + public Paint getItemLabelPaint(int row, int column); + + /** + * Returns the paint used to draw the item labels for a series. + * + * @param series the series index (zero based). + * + * @return The paint (possibly null). + * + * @see #setSeriesItemLabelPaint(int, Paint) + */ + public Paint getSeriesItemLabelPaint(int series); + + /** + * Sets the item label paint for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series (zero based index). + * @param paint the paint (null permitted). + * + * @see #getSeriesItemLabelPaint(int) + */ + public void setSeriesItemLabelPaint(int series, Paint paint); + + /** + * Returns the base item label paint. + * + * @return The paint (never null). + */ + public Paint getBaseItemLabelPaint(); + + /** + * Sets the base item label paint and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param paint the paint (null not permitted). + */ + public void setBaseItemLabelPaint(Paint paint); + + // POSITIVE ITEM LABEL POSITION... + + /** + * Returns the item label position for positive values. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The item label position (never null). + */ + public ItemLabelPosition getPositiveItemLabelPosition(int row, int column); + + /** + * Returns the item label position for all positive values in a series. + * + * @param series the series index (zero-based). + * + * @return The item label position (never null). + */ + public ItemLabelPosition getSeriesPositiveItemLabelPosition(int series); + + /** + * Sets the item label position for all positive values in a series and + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param position the position (null permitted). + */ + public void setSeriesPositiveItemLabelPosition(int series, + ItemLabelPosition position); + + /** + * Sets the item label position for all positive values in a series and (if + * requested) sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index (zero-based). + * @param position the position (null permitted). + * @param notify notify registered listeners? + */ + public void setSeriesPositiveItemLabelPosition(int series, + ItemLabelPosition position, + boolean notify); + + /** + * Returns the base positive item label position. + * + * @return The position (never null). + */ + public ItemLabelPosition getBasePositiveItemLabelPosition(); + + /** + * Sets the base positive item label position. + * + * @param position the position (null not permitted). + */ + public void setBasePositiveItemLabelPosition(ItemLabelPosition position); + + /** + * Sets the base positive item label position and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param position the position (null not permitted). + * @param notify notify registered listeners? + */ + public void setBasePositiveItemLabelPosition(ItemLabelPosition position, + boolean notify); + + + // NEGATIVE ITEM LABEL POSITION... + + /** + * Returns the item label position for negative values. This method can be + * overridden to provide customisation of the item label position for + * individual data items. + * + * @param row the row index (zero-based). + * @param column the column (zero-based). + * + * @return The item label position (never null). + */ + public ItemLabelPosition getNegativeItemLabelPosition(int row, int column); + + /** + * Returns the item label position for all negative values in a series. + * + * @param series the series index (zero-based). + * + * @return The item label position (never null). + */ + public ItemLabelPosition getSeriesNegativeItemLabelPosition(int series); + + /** + * Sets the item label position for negative values in a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param position the position (null permitted). + */ + public void setSeriesNegativeItemLabelPosition(int series, + ItemLabelPosition position); + + /** + * Sets the item label position for negative values in a series and (if + * requested) sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param series the series index (zero-based). + * @param position the position (null permitted). + * @param notify notify registered listeners? + */ + public void setSeriesNegativeItemLabelPosition(int series, + ItemLabelPosition position, + boolean notify); + + /** + * Returns the base item label position for negative values. + * + * @return The position (never null). + */ + public ItemLabelPosition getBaseNegativeItemLabelPosition(); + + /** + * Sets the base item label position for negative values and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param position the position (null not permitted). + */ + public void setBaseNegativeItemLabelPosition(ItemLabelPosition position); + + /** + * Sets the base negative item label position and, if requested, sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param position the position (null not permitted). + * @param notify notify registered listeners? + */ + public void setBaseNegativeItemLabelPosition(ItemLabelPosition position, + boolean notify); + + + // CREATE ENTITIES + // FIXME: these methods should be defined + +// public boolean getItemCreateEntity(int series, int item); +// +// public Boolean getSeriesCreateEntities(int series); +// +// public void setSeriesCreateEntities(int series, Boolean create); +// +// public void setSeriesCreateEntities(int series, Boolean create, +// boolean notify); +// +// public boolean getBaseCreateEntities(); +// +// public void setBaseCreateEntities(boolean create); +// +// public void setBaseCreateEntities(boolean create, boolean notify); + + //// ANNOTATIONS ////////////////////////////////////////////////////////// + + /** + * Adds an annotation and sends a {@link RendererChangeEvent} to all + * registered listeners. The annotation is added to the foreground + * layer. + * + * @param annotation the annotation (null not permitted). + */ + public void addAnnotation(XYAnnotation annotation); + + /** + * Adds an annotation to the specified layer. + * + * @param annotation the annotation (null not permitted). + * @param layer the layer (null not permitted). + */ + public void addAnnotation(XYAnnotation annotation, Layer layer); + + /** + * Removes the specified annotation and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param annotation the annotation to remove (null not + * permitted). + * + * @return A boolean to indicate whether or not the annotation was + * successfully removed. + */ + public boolean removeAnnotation(XYAnnotation annotation); + + /** + * Removes all annotations and sends a {@link RendererChangeEvent} + * to all registered listeners. + */ + public void removeAnnotations(); + + /** + * Draws all the annotations for the specified layer. + * + * @param g2 the graphics device. + * @param dataArea the data area. + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param layer the layer. + * @param info the plot rendering info. + */ + public void drawAnnotations(Graphics2D g2, + Rectangle2D dataArea, + ValueAxis domainAxis, + ValueAxis rangeAxis, + Layer layer, + PlotRenderingInfo info); + + //// DRAWING ////////////////////////////////////////////////////////////// + + /** + * Initialises the renderer then returns the number of 'passes' through the + * data that the renderer will require (usually just one). This method + * will be called before the first item is rendered, giving the renderer + * an opportunity to initialise any state information it wants to maintain. + * The renderer can do nothing if it chooses. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param dataset the dataset. + * @param info an optional info collection object to return data back to + * the caller. + * + * @return The number of passes the renderer requires. + */ + public XYItemRendererState initialise(Graphics2D g2, + Rectangle2D dataArea, + XYPlot plot, + XYDataset dataset, + PlotRenderingInfo info); + + /** + * Called for each item to be plotted. + *

+ * The {@link XYPlot} can make multiple passes through the dataset, + * depending on the value returned by the renderer's initialise() method. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the data is being rendered. + * @param info collects drawing info. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + public void drawItem(Graphics2D g2, + XYItemRendererState state, + Rectangle2D dataArea, + PlotRenderingInfo info, + XYPlot plot, + ValueAxis domainAxis, + ValueAxis rangeAxis, + XYDataset dataset, + int series, + int item, + CrosshairState crosshairState, + int pass); + + /** + * Fills a band between two values on the axis. This can be used to color + * bands between the grid lines. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the domain axis. + * @param dataArea the data area. + * @param start the start value. + * @param end the end value. + */ + public void fillDomainGridBand(Graphics2D g2, + XYPlot plot, + ValueAxis axis, + Rectangle2D dataArea, + double start, double end); + + /** + * Fills a band between two values on the range axis. This can be used to + * color bands between the grid lines. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the range axis. + * @param dataArea the data area. + * @param start the start value. + * @param end the end value. + */ + public void fillRangeGridBand(Graphics2D g2, + XYPlot plot, + ValueAxis axis, + Rectangle2D dataArea, + double start, double end); + + /** + * Draws a grid line against the domain axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param dataArea the area for plotting data (not yet adjusted for any + * 3D effect). + * @param value the value. + */ + public void drawDomainGridLine(Graphics2D g2, + XYPlot plot, + ValueAxis axis, + Rectangle2D dataArea, + double value); + + /** + * Draws a line perpendicular to the range axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param dataArea the area for plotting data. + * @param value the data value. + * @param paint the paint (null not permitted). + * @param stroke the stroke (null not permitted). + */ + public void drawRangeLine(Graphics2D g2, XYPlot plot, ValueAxis axis, + Rectangle2D dataArea, double value, Paint paint, Stroke stroke); + + /** + * Draws the specified marker against the domain axis. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param marker the marker. + * @param dataArea the axis data area. + */ + public void drawDomainMarker(Graphics2D g2, XYPlot plot, ValueAxis axis, + Marker marker, Rectangle2D dataArea); + + /** + * Draws a horizontal line across the chart to represent a 'range marker'. + * + * @param g2 the graphics device. + * @param plot the plot. + * @param axis the value axis. + * @param marker the marker line. + * @param dataArea the axis data area. + */ + public void drawRangeMarker(Graphics2D g2, XYPlot plot, ValueAxis axis, + Marker marker, Rectangle2D dataArea); + + // DEPRECATED METHODS + + /** + * Returns the flag that controls the visibility of ALL series. This flag + * overrides the per series and default settings - you must set it to + * null if you want the other settings to apply. + * + * @return The flag (possibly null). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesVisible(int)} and + * {@link #getBaseSeriesVisible()}. + */ + public Boolean getSeriesVisible(); + + /** + * Sets the flag that controls the visibility of ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. This flag + * overrides the per series and default settings - you must set it to + * null if you want the other settings to apply. + * + * @param visible the flag (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesVisible(int, Boolean)} + * and {@link #setBaseSeriesVisible(boolean)}. + */ + public void setSeriesVisible(Boolean visible); + + /** + * Sets the flag that controls the visibility of ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. This flag + * overrides the per series and default settings - you must set it to + * null if you want the other settings to apply. + * + * @param visible the flag (null permitted). + * @param notify notify listeners? + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesVisible(int, Boolean, + * boolean)} and {@link #setBaseSeriesVisible(boolean, boolean)}. + */ + public void setSeriesVisible(Boolean visible, boolean notify); + + /** + * Returns the flag that controls the visibility of ALL series in the + * legend. This flag overrides the per series and default settings - you + * must set it to null if you want the other settings to + * apply. + * + * @return The flag (possibly null). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesVisibleInLegend(int)} + * and {@link #getBaseSeriesVisibleInLegend()}. + */ + public Boolean getSeriesVisibleInLegend(); + + /** + * Sets the flag that controls the visibility of ALL series in the legend + * and sends a {@link RendererChangeEvent} to all registered listeners. + * This flag overrides the per series and default settings - you must set + * it to null if you want the other settings to apply. + * + * @param visible the flag (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesVisibleInLegend(int, + * Boolean)} and {@link #setBaseSeriesVisibleInLegend(boolean)}. + */ + public void setSeriesVisibleInLegend(Boolean visible); + + /** + * Sets the flag that controls the visibility of ALL series in the legend + * and sends a {@link RendererChangeEvent} to all registered listeners. + * This flag overrides the per series and default settings - you must set + * it to null if you want the other settings to apply. + * + * @param visible the flag (null permitted). + * @param notify notify listeners? + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesVisibleInLegend(int, + * Boolean, boolean)} and {@link #setBaseSeriesVisibleInLegend(boolean, + * boolean)}. + */ + public void setSeriesVisibleInLegend(Boolean visible, boolean notify); + + /** + * Sets the paint to be used for ALL series, and sends a + * {@link RendererChangeEvent} to all registered listeners. If this is + * null, the renderer will use the paint for the series. + * + * @param paint the paint (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesPaint(int, Paint)} and + * {@link #setBasePaint(Paint)}. + */ + public void setPaint(Paint paint); + + /** + * Sets the outline paint for ALL series (optional). + * + * @param paint the paint (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesOutlinePaint(int, + * Paint)} and {@link #setBaseOutlinePaint(Paint)}. + */ + public void setOutlinePaint(Paint paint); + + /** + * Sets the stroke for ALL series and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param stroke the stroke (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesStroke(int, Stroke)} + * and {@link #setBaseStroke(Stroke)}. + */ + public void setStroke(Stroke stroke); + + /** + * Sets the outline stroke for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesOutlineStroke(int, + * Stroke)} and {@link #setBaseOutlineStroke(Stroke)}. + */ + public void setOutlineStroke(Stroke stroke); + + /** + * Sets the shape for ALL series (optional) and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param shape the shape (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesShape(int, Shape)} and + * {@link #setBaseShape(Shape)}. + */ + public void setShape(Shape shape); + + /** + * Sets a flag that controls whether or not the item labels for ALL series + * are visible. + * + * @param visible the flag. + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, + * Boolean)} and {@link #setBaseItemLabelsVisible(boolean)}. + */ + public void setItemLabelsVisible(boolean visible); + + /** + * Sets a flag that controls whether or not the item labels for ALL series + * are visible. + * + * @param visible the flag (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, + * Boolean)} and {@link #setBaseItemLabelsVisible(boolean)}. + */ + public void setItemLabelsVisible(Boolean visible); + + /** + * Sets the visibility of item labels for ALL series and, if requested, + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param visible a flag that controls whether or not the item labels are + * visible (null permitted). + * @param notify a flag that controls whether or not listeners are + * notified. + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelsVisible(int, + * Boolean, boolean)} and {@link #setBaseItemLabelsVisible(Boolean, + * boolean)}. + */ + public void setItemLabelsVisible(Boolean visible, boolean notify); + + /** + * Sets the item label generator for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @deprecated As of version 1.0.6, this override setting should not be + * used. You can use the base setting instead + * ({@link #setBaseItemLabelGenerator(XYItemLabelGenerator)}). + */ + public void setItemLabelGenerator(XYItemLabelGenerator generator); + + /** + * Sets the tool tip generator for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param generator the generator (null permitted). + * + * @deprecated As of version 1.0.6, this override setting should not be + * used. You can use the base setting instead + * ({@link #setBaseToolTipGenerator(XYToolTipGenerator)}). + */ + public void setToolTipGenerator(XYToolTipGenerator generator); + + /** + * Returns the font used for all item labels. This may be + * null, in which case the per series font settings will apply. + * + * @return The font (possibly null). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesItemLabelFont(int)} and + * {@link #getBaseItemLabelFont()}. + */ + public Font getItemLabelFont(); + + /** + * Sets the item label font for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. You can set + * this to null if you prefer to set the font on a per series + * basis. + * + * @param font the font (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelFont(int, + * Font)} and {@link #setBaseItemLabelFont(Font)}. + */ + public void setItemLabelFont(Font font); + + /** + * Returns the paint used for all item labels. This may be + * null, in which case the per series paint settings will + * apply. + * + * @return The paint (possibly null). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #getSeriesItemLabelPaint(int)} + * and {@link #getBaseItemLabelPaint()}. + */ + public Paint getItemLabelPaint(); + + /** + * Sets the item label paint for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on {@link #setSeriesItemLabelPaint(int, + * Paint)} and {@link #setBaseItemLabelPaint(Paint)}. + */ + public void setItemLabelPaint(Paint paint); + + /** + * Returns the item label position for positive values in ALL series. + * + * @return The item label position (possibly null). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #getSeriesPositiveItemLabelPosition(int)} + * and {@link #getBasePositiveItemLabelPosition()}. + */ + public ItemLabelPosition getPositiveItemLabelPosition(); + + /** + * Sets the item label position for positive values in ALL series, and + * sends a {@link RendererChangeEvent} to all registered listeners. You + * need to set this to null to expose the settings for + * individual series. + * + * @param position the position (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition)} + * and {@link #setBasePositiveItemLabelPosition(ItemLabelPosition)}. + */ + public void setPositiveItemLabelPosition(ItemLabelPosition position); + + /** + * Sets the positive item label position for ALL series and (if requested) + * sends a {@link RendererChangeEvent} to all registered listeners. + * + * @param position the position (null permitted). + * @param notify notify registered listeners? + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #setSeriesPositiveItemLabelPosition(int, ItemLabelPosition, + * boolean)} and {@link #setBasePositiveItemLabelPosition( + * ItemLabelPosition, boolean)}. + */ + public void setPositiveItemLabelPosition(ItemLabelPosition position, + boolean notify); + + /** + * Returns the item label position for negative values in ALL series. + * + * @return The item label position (possibly null). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #getSeriesNegativeItemLabelPosition(int)} + * and {@link #getBaseNegativeItemLabelPosition()}. + */ + public ItemLabelPosition getNegativeItemLabelPosition(); + + /** + * Sets the item label position for negative values in ALL series, and + * sends a {@link RendererChangeEvent} to all registered listeners. You + * need to set this to null to expose the settings for + * individual series. + * + * @param position the position (null permitted). + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition)} + * and {@link #setBaseNegativeItemLabelPosition(ItemLabelPosition)}. + */ + public void setNegativeItemLabelPosition(ItemLabelPosition position); + + /** + * Sets the item label position for negative values in ALL series and (if + * requested) sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param position the position (null permitted). + * @param notify notify registered listeners? + * + * @deprecated This method should no longer be used (as of version 1.0.6). + * It is sufficient to rely on + * {@link #setSeriesNegativeItemLabelPosition(int, ItemLabelPosition, + * boolean)} and {@link #setBaseNegativeItemLabelPosition( + * ItemLabelPosition, boolean)}. + */ + public void setNegativeItemLabelPosition(ItemLabelPosition position, + boolean notify); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYItemRendererState.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYItemRendererState.java new file mode 100755 index 0000000..2e03580 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYItemRendererState.java @@ -0,0 +1,198 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * XYItemRendererState.java + * ------------------------ + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Ulrich Voigt; + * Greg Darke; + * + * Changes: + * -------- + * 07-Oct-2003 : Version 1 (DG); + * 27-Jan-2004 : Added workingLine attribute (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 04-May-2007 : Added processVisibleItemsOnly flag (DG); + * 09-Jul-2008 : Added start/endSeriesPass() methods - see patch 1997549 by + * Ulrich Voigt (DG); + * 19-Sep-2008 : Added first and last item indices, based on patch by Greg + * Darke (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.geom.Line2D; + +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.RendererState; +import org.jfree.data.xy.XYDataset; + +/** + * The state for an {@link XYItemRenderer}. + */ +public class XYItemRendererState extends RendererState { + + /** + * The first item in the series that will be displayed. + * + * @since 1.0.11 + */ + private int firstItemIndex; + + /** + * The last item in the current series that will be displayed. + * + * @since 1.0.11 + */ + private int lastItemIndex; + + /** + * A line object that the renderer can reuse to save instantiating a lot + * of objects. + */ + public Line2D workingLine; + + /** + * A flag that controls whether the plot should pass ALL data items to the + * renderer, or just the items that will be visible. + * + * @since 1.0.6 + */ + private boolean processVisibleItemsOnly; + + /** + * Creates a new state. + * + * @param info the plot rendering info. + */ + public XYItemRendererState(PlotRenderingInfo info) { + super(info); + this.workingLine = new Line2D.Double(); + this.processVisibleItemsOnly = true; + } + + /** + * Returns the flag that controls whether the plot passes all data + * items in each series to the renderer, or just the visible items. The + * default value is true. + * + * @return A boolean. + * + * @since 1.0.6 + * + * @see #setProcessVisibleItemsOnly(boolean) + */ + public boolean getProcessVisibleItemsOnly() { + return this.processVisibleItemsOnly; + } + + /** + * Sets the flag that controls whether the plot passes all data + * items in each series to the renderer, or just the visible items. + * + * @param flag the new flag value. + * + * @since 1.0.6 + */ + public void setProcessVisibleItemsOnly(boolean flag) { + this.processVisibleItemsOnly = flag; + } + + /** + * Returns the first item index (this is updated with each call to + * {@link #startSeriesPass(XYDataset, int, int, int, int, int)}. + * + * @return The first item index. + * + * @since 1.0.11 + */ + public int getFirstItemIndex() { + return this.firstItemIndex; + } + + /** + * Returns the last item index (this is updated with each call to + * {@link #startSeriesPass(XYDataset, int, int, int, int, int)}. + * + * @return The last item index. + * + * @since 1.0.11 + */ + public int getLastItemIndex() { + return this.lastItemIndex; + } + + /** + * This method is called by the {@link XYPlot} when it starts a pass + * through the (visible) items in a series. The default implementation + * records the first and last item indices - override this method to + * implement additional specialised behaviour. + * + * @param dataset the dataset. + * @param series the series index. + * @param firstItem the index of the first item in the series. + * @param lastItem the index of the last item in the series. + * @param pass the pass index. + * @param passCount the number of passes. + * + * @see #endSeriesPass(XYDataset, int, int, int, int, int) + * + * @since 1.0.11 + */ + public void startSeriesPass(XYDataset dataset, int series, int firstItem, + int lastItem, int pass, int passCount) { + this.firstItemIndex = firstItem; + this.lastItemIndex = lastItem; + } + + /** + * This method is called by the {@link XYPlot} when it ends a pass + * through the (visible) items in a series. The default implementation + * does nothing, but you can override this method to implement specialised + * behaviour. + * + * @param dataset the dataset. + * @param series the series index. + * @param firstItem the index of the first item in the series. + * @param lastItem the index of the last item in the series. + * @param pass the pass index. + * @param passCount the number of passes. + * + * @see #startSeriesPass(XYDataset, int, int, int, int, int) + * + * @since 1.0.11 + */ + public void endSeriesPass(XYDataset dataset, int series, int firstItem, + int lastItem, int pass, int passCount) { + // do nothing...this is just a hook for subclasses + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYLine3DRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYLine3DRenderer.java new file mode 100755 index 0000000..fadadc0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYLine3DRenderer.java @@ -0,0 +1,287 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * XYLine3DRenderer.java + * --------------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: Thomas Morgner; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 14-Jan-2005 : Added standard header (DG); + * 01-May-2007 : Fixed equals() and serialization bugs (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +import org.jfree.chart.Effect3D; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.io.SerialUtilities; +import org.jfree.util.PaintUtilities; + +/** + * A XYLineAndShapeRenderer that adds a shadow line to the graph + * to emulate a 3D-effect. + */ +public class XYLine3DRenderer extends XYLineAndShapeRenderer + implements Effect3D, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 588933208243446087L; + + /** The default x-offset for the 3D effect. */ + public static final double DEFAULT_X_OFFSET = 12.0; + + /** The default y-offset for the 3D effect. */ + public static final double DEFAULT_Y_OFFSET = 8.0; + + /** The default wall paint. */ + public static final Paint DEFAULT_WALL_PAINT = new Color(0xDD, 0xDD, 0xDD); + + /** The size of x-offset for the 3D effect. */ + private double xOffset; + + /** The size of y-offset for the 3D effect. */ + private double yOffset; + + /** The paint used to shade the left and lower 3D wall. */ + private transient Paint wallPaint; + + /** + * Creates a new renderer. + */ + public XYLine3DRenderer() { + this.wallPaint = DEFAULT_WALL_PAINT; + this.xOffset = DEFAULT_X_OFFSET; + this.yOffset = DEFAULT_Y_OFFSET; + } + + /** + * Returns the x-offset for the 3D effect. + * + * @return The 3D effect. + */ + @Override + public double getXOffset() { + return this.xOffset; + } + + /** + * Returns the y-offset for the 3D effect. + * + * @return The 3D effect. + */ + @Override + public double getYOffset() { + return this.yOffset; + } + + /** + * Sets the x-offset and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param xOffset the x-offset. + */ + public void setXOffset(double xOffset) { + this.xOffset = xOffset; + fireChangeEvent(); + } + + /** + * Sets the y-offset and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param yOffset the y-offset. + */ + public void setYOffset(double yOffset) { + this.yOffset = yOffset; + fireChangeEvent(); + } + + /** + * Returns the paint used to highlight the left and bottom wall in the plot + * background. + * + * @return The paint. + */ + public Paint getWallPaint() { + return this.wallPaint; + } + + /** + * Sets the paint used to hightlight the left and bottom walls in the plot + * background and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param paint the paint. + */ + public void setWallPaint(Paint paint) { + this.wallPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the number of passes through the data that the renderer requires + * in order to draw the chart. Most charts will require a single pass, + * but some require two passes. + * + * @return The pass count. + */ + @Override + public int getPassCount() { + return 3; + } + + /** + * Returns true if the specified pass involves drawing lines. + * + * @param pass the pass. + * + * @return A boolean. + */ + @Override + protected boolean isLinePass(int pass) { + return pass == 0 || pass == 1; + } + + /** + * Returns true if the specified pass involves drawing items. + * + * @param pass the pass. + * + * @return A boolean. + */ + @Override + protected boolean isItemPass(int pass) { + return pass == 2; + } + + /** + * Returns true if the specified pass involves drawing shadows. + * + * @param pass the pass. + * + * @return A boolean. + */ + protected boolean isShadowPass (int pass) { + return pass == 0; + } + + /** + * Overrides the method in the subclass to draw a shadow in the first pass. + * + * @param g2 the graphics device. + * @param pass the pass. + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @param shape the shape. + */ + @Override + protected void drawFirstPassShape(Graphics2D g2, int pass, int series, + int item, Shape shape) { + if (isShadowPass(pass)) { + if (getWallPaint() != null) { + g2.setStroke(getItemStroke(series, item)); + g2.setPaint(getWallPaint()); + g2.translate(getXOffset(), getYOffset()); + g2.draw(shape); + g2.translate(-getXOffset(), -getYOffset()); + } + } + else { + // now draw the real shape + super.drawFirstPassShape(g2, pass, series, item, shape); + } + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYLine3DRenderer)) { + return false; + } + XYLine3DRenderer that = (XYLine3DRenderer) obj; + if (this.xOffset != that.xOffset) { + return false; + } + if (this.yOffset != that.yOffset) { + return false; + } + if (!PaintUtilities.equal(this.wallPaint, that.wallPaint)) { + return false; + } + return super.equals(obj); + } + + /** + * 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.wallPaint = SerialUtilities.readPaint(stream); + } + + /** + * 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.wallPaint, stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java new file mode 100755 index 0000000..dfe2213 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYLineAndShapeRenderer.java @@ -0,0 +1,1376 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * XYLineAndShapeRenderer.java + * --------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 27-Jan-2004 : Version 1 (DG); + * 10-Feb-2004 : Minor change to drawItem() method to make cut-and-paste + * overriding easier (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); + * 25-Aug-2004 : Added support for chart entities (required for tooltips) (DG); + * 24-Sep-2004 : Added flag to allow whole series to be drawn as a path + * (necessary when using a dashed stroke with many data + * items) (DG); + * 04-Oct-2004 : Renamed BooleanUtils --> BooleanUtilities (DG); + * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); + * 27-Jan-2005 : The getLegendItem() method now omits hidden series (DG); + * 28-Jan-2005 : Added new constructor (DG); + * 09-Mar-2005 : Added fillPaint settings (DG); + * 20-Apr-2005 : Use generators for legend tooltips and URLs (DG); + * 22-Jul-2005 : Renamed defaultLinesVisible --> baseLinesVisible, + * defaultShapesVisible --> baseShapesVisible and + * defaultShapesFilled --> baseShapesFilled (DG); + * 29-Jul-2005 : Added code to draw item labels (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 20-Jul-2006 : Set dataset and series indices in LegendItem (DG); + * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); + * 21-Feb-2007 : Fixed bugs in clone() and equals() (DG); + * 20-Apr-2007 : Updated getLegendItem() for renderer change (DG); + * 18-May-2007 : Set dataset and seriesKey for LegendItem (DG); + * 08-Jun-2007 : Fix for bug 1731912 where entities are created even for data + * items that are not displayed (DG); + * 26-Oct-2007 : Deprecated override attributes (DG); + * 02-Jun-2008 : Fixed tooltips at lower edges of data area (DG); + * 17-Jun-2008 : Apply legend shape, font and paint attributes (DG); + * 19-Sep-2008 : Fixed bug with drawSeriesLineAsPath - patch by Greg Darke (DG); + * 18-May-2009 : Clip lines in drawPrimaryLine() (DG); + * 05-Jul-2012 : Removed JDK 1.3.1 code (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +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.LegendItem; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CrosshairState; +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.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.BooleanList; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A renderer that connects data points with lines and/or draws shapes at each + * data point. This renderer is designed for use with the {@link XYPlot} + * class. The example shown here is generated by + * the XYLineAndShapeRendererDemo2.java program included in the + * JFreeChart demo collection: + *

+ * XYLineAndShapeRendererSample.png + * + */ +public class XYLineAndShapeRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -7435246895986425885L; + + /** + * A flag that controls whether or not lines are visible for ALL series. + * + * @deprecated As of 1.0.7. + */ + private Boolean linesVisible; + + /** + * A table of flags that control (per series) whether or not lines are + * visible. + */ + private BooleanList seriesLinesVisible; + + /** The default value returned by the getLinesVisible() method. */ + private boolean baseLinesVisible; + + /** The shape that is used to represent a line in the legend. */ + private transient Shape legendLine; + + /** + * A flag that controls whether or not shapes are visible for ALL series. + * + * @deprecated As of 1.0.7. + */ + private Boolean shapesVisible; + + /** + * A table of flags that control (per series) whether or not shapes are + * visible. + */ + private BooleanList seriesShapesVisible; + + /** The default value returned by the getShapeVisible() method. */ + private boolean baseShapesVisible; + + /** + * A flag that controls whether or not shapes are filled for ALL series. + * + * @deprecated As of 1.0.7. + */ + private Boolean shapesFilled; + + /** + * A table of flags that control (per series) whether or not shapes are + * filled. + */ + private BooleanList seriesShapesFilled; + + /** The default value returned by the getShapeFilled() method. */ + private boolean baseShapesFilled; + + /** A flag that controls whether outlines are drawn for shapes. */ + private boolean drawOutlines; + + /** + * A flag that controls whether the fill paint is used for filling + * shapes. + */ + private boolean useFillPaint; + + /** + * A flag that controls whether the outline paint is used for drawing shape + * outlines. + */ + private boolean useOutlinePaint; + + /** + * A flag that controls whether or not each series is drawn as a single + * path. + */ + private boolean drawSeriesLineAsPath; + + /** + * Creates a new renderer with both lines and shapes visible. + */ + public XYLineAndShapeRenderer() { + this(true, true); + } + + /** + * Creates a new renderer. + * + * @param lines lines visible? + * @param shapes shapes visible? + */ + public XYLineAndShapeRenderer(boolean lines, boolean shapes) { + this.linesVisible = null; + this.seriesLinesVisible = new BooleanList(); + this.baseLinesVisible = lines; + this.legendLine = new Line2D.Double(-7.0, 0.0, 7.0, 0.0); + + this.shapesVisible = null; + this.seriesShapesVisible = new BooleanList(); + this.baseShapesVisible = shapes; + + this.shapesFilled = null; + this.useFillPaint = false; // use item paint for fills by default + this.seriesShapesFilled = new BooleanList(); + this.baseShapesFilled = true; + + this.drawOutlines = true; + this.useOutlinePaint = false; // use item paint for outlines by + // default, not outline paint + + this.drawSeriesLineAsPath = false; + } + + /** + * Returns a flag that controls whether or not each series is drawn as a + * single path. + * + * @return A boolean. + * + * @see #setDrawSeriesLineAsPath(boolean) + */ + public boolean getDrawSeriesLineAsPath() { + return this.drawSeriesLineAsPath; + } + + /** + * Sets the flag that controls whether or not each series is drawn as a + * single path and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param flag the flag. + * + * @see #getDrawSeriesLineAsPath() + */ + public void setDrawSeriesLineAsPath(boolean flag) { + if (this.drawSeriesLineAsPath != flag) { + this.drawSeriesLineAsPath = flag; + fireChangeEvent(); + } + } + + /** + * Returns the number of passes through the data that the renderer requires + * in order to draw the chart. Most charts will require a single pass, but + * some require two passes. + * + * @return The pass count. + */ + @Override + public int getPassCount() { + return 2; + } + + // LINES VISIBLE + + /** + * Returns the flag used to control whether or not the shape for an item is + * visible. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return A boolean. + */ + public boolean getItemLineVisible(int series, int item) { + Boolean flag = this.linesVisible; + if (flag == null) { + flag = getSeriesLinesVisible(series); + } + if (flag != null) { + return flag.booleanValue(); + } + else { + return this.baseLinesVisible; + } + } + + /** + * Returns a flag that controls whether or not lines are drawn for ALL + * series. If this flag is null, then the "per series" + * settings will apply. + * + * @return A flag (possibly null). + * + * @see #setLinesVisible(Boolean) + * + * @deprecated As of 1.0.7, use the per-series and base level settings. + */ + public Boolean getLinesVisible() { + return this.linesVisible; + } + + /** + * Sets a flag that controls whether or not lines are drawn between the + * items in ALL series, and sends a {@link RendererChangeEvent} to all + * registered listeners. You need to set this to null if you + * want the "per series" settings to apply. + * + * @param visible the flag (null permitted). + * + * @see #getLinesVisible() + * + * @deprecated As of 1.0.7, use the per-series and base level settings. + */ + public void setLinesVisible(Boolean visible) { + this.linesVisible = visible; + fireChangeEvent(); + } + + /** + * Sets a flag that controls whether or not lines are drawn between the + * items in ALL series, and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param visible the flag. + * + * @see #getLinesVisible() + * + * @deprecated As of 1.0.7, use the per-series and base level settings. + */ + public void setLinesVisible(boolean visible) { + setLinesVisible(Boolean.valueOf(visible)); + } + + /** + * Returns the flag used to control whether or not the lines for a series + * are visible. + * + * @param series the series index (zero-based). + * + * @return The flag (possibly null). + * + * @see #setSeriesLinesVisible(int, Boolean) + */ + public Boolean getSeriesLinesVisible(int series) { + return this.seriesLinesVisible.getBoolean(series); + } + + /** + * Sets the 'lines visible' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param flag the flag (null permitted). + * + * @see #getSeriesLinesVisible(int) + */ + public void setSeriesLinesVisible(int series, Boolean flag) { + this.seriesLinesVisible.setBoolean(series, flag); + fireChangeEvent(); + } + + /** + * Sets the 'lines visible' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the flag. + * + * @see #getSeriesLinesVisible(int) + */ + public void setSeriesLinesVisible(int series, boolean visible) { + setSeriesLinesVisible(series, Boolean.valueOf(visible)); + } + + /** + * Returns the base 'lines visible' attribute. + * + * @return The base flag. + * + * @see #setBaseLinesVisible(boolean) + */ + public boolean getBaseLinesVisible() { + return this.baseLinesVisible; + } + + /** + * Sets the base 'lines visible' flag and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param flag the flag. + * + * @see #getBaseLinesVisible() + */ + public void setBaseLinesVisible(boolean flag) { + this.baseLinesVisible = flag; + fireChangeEvent(); + } + + /** + * Returns the shape used to represent a line in the legend. + * + * @return The legend line (never null). + * + * @see #setLegendLine(Shape) + */ + public Shape getLegendLine() { + return this.legendLine; + } + + /** + * Sets the shape used as a line in each legend item and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param line the line (null not permitted). + * + * @see #getLegendLine() + */ + public void setLegendLine(Shape line) { + ParamChecks.nullNotPermitted(line, "line"); + this.legendLine = line; + fireChangeEvent(); + } + + // SHAPES VISIBLE + + /** + * Returns the flag used to control whether or not the shape for an item is + * visible. + *

+ * The default implementation passes control to the + * getSeriesShapesVisible method. You can override this method + * if you require different behaviour. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return A boolean. + */ + public boolean getItemShapeVisible(int series, int item) { + Boolean flag = this.shapesVisible; + if (flag == null) { + flag = getSeriesShapesVisible(series); + } + if (flag != null) { + return flag.booleanValue(); + } + else { + return this.baseShapesVisible; + } + } + + /** + * Returns the flag that controls whether the shapes are visible for the + * items in ALL series. + * + * @return The flag (possibly null). + * + * @see #setShapesVisible(Boolean) + * + * @deprecated As of 1.0.7, use the per-series and base level settings. + */ + public Boolean getShapesVisible() { + return this.shapesVisible; + } + + /** + * Sets the 'shapes visible' for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the flag (null permitted). + * + * @see #getShapesVisible() + * + * @deprecated As of 1.0.7, use the per-series and base level settings. + */ + public void setShapesVisible(Boolean visible) { + this.shapesVisible = visible; + fireChangeEvent(); + } + + /** + * Sets the 'shapes visible' for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param visible the flag. + * + * @see #getShapesVisible() + * + * @deprecated As of 1.0.7, use the per-series and base level settings. + */ + public void setShapesVisible(boolean visible) { + setShapesVisible(Boolean.valueOf(visible)); + } + + /** + * Returns the flag used to control whether or not the shapes for a series + * are visible. + * + * @param series the series index (zero-based). + * + * @return A boolean. + * + * @see #setSeriesShapesVisible(int, Boolean) + */ + public Boolean getSeriesShapesVisible(int series) { + return this.seriesShapesVisible.getBoolean(series); + } + + /** + * Sets the 'shapes visible' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param visible the flag. + * + * @see #getSeriesShapesVisible(int) + */ + public void setSeriesShapesVisible(int series, boolean visible) { + setSeriesShapesVisible(series, Boolean.valueOf(visible)); + } + + /** + * Sets the 'shapes visible' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param flag the flag. + * + * @see #getSeriesShapesVisible(int) + */ + public void setSeriesShapesVisible(int series, Boolean flag) { + this.seriesShapesVisible.setBoolean(series, flag); + fireChangeEvent(); + } + + /** + * Returns the base 'shape visible' attribute. + * + * @return The base flag. + * + * @see #setBaseShapesVisible(boolean) + */ + public boolean getBaseShapesVisible() { + return this.baseShapesVisible; + } + + /** + * Sets the base 'shapes visible' flag and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param flag the flag. + * + * @see #getBaseShapesVisible() + */ + public void setBaseShapesVisible(boolean flag) { + this.baseShapesVisible = flag; + fireChangeEvent(); + } + + // SHAPES FILLED + + /** + * Returns the flag used to control whether or not the shape for an item + * is filled. + *

+ * The default implementation passes control to the + * getSeriesShapesFilled method. You can override this method + * if you require different behaviour. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return A boolean. + */ + public boolean getItemShapeFilled(int series, int item) { + Boolean flag = this.shapesFilled; + if (flag == null) { + flag = getSeriesShapesFilled(series); + } + if (flag != null) { + return flag.booleanValue(); + } + else { + return this.baseShapesFilled; + } + } + + /** + * Sets the 'shapes filled' for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param filled the flag. + * + * @deprecated As of 1.0.7, use the per-series and base level settings. + */ + public void setShapesFilled(boolean filled) { + setShapesFilled(Boolean.valueOf(filled)); + } + + /** + * Sets the 'shapes filled' for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param filled the flag (null permitted). + * + * @deprecated As of 1.0.7, use the per-series and base level settings. + */ + public void setShapesFilled(Boolean filled) { + this.shapesFilled = filled; + fireChangeEvent(); + } + + /** + * Returns the flag used to control whether or not the shapes for a series + * are filled. + * + * @param series the series index (zero-based). + * + * @return A boolean. + * + * @see #setSeriesShapesFilled(int, Boolean) + */ + public Boolean getSeriesShapesFilled(int series) { + return this.seriesShapesFilled.getBoolean(series); + } + + /** + * Sets the 'shapes filled' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param flag the flag. + * + * @see #getSeriesShapesFilled(int) + */ + public void setSeriesShapesFilled(int series, boolean flag) { + setSeriesShapesFilled(series, Boolean.valueOf(flag)); + } + + /** + * Sets the 'shapes filled' flag for a series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * @param flag the flag. + * + * @see #getSeriesShapesFilled(int) + */ + public void setSeriesShapesFilled(int series, Boolean flag) { + this.seriesShapesFilled.setBoolean(series, flag); + fireChangeEvent(); + } + + /** + * Returns the base 'shape filled' attribute. + * + * @return The base flag. + * + * @see #setBaseShapesFilled(boolean) + */ + public boolean getBaseShapesFilled() { + return this.baseShapesFilled; + } + + /** + * Sets the base 'shapes filled' flag and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param flag the flag. + * + * @see #getBaseShapesFilled() + */ + public void setBaseShapesFilled(boolean flag) { + this.baseShapesFilled = flag; + fireChangeEvent(); + } + + /** + * Returns true if outlines should be drawn for shapes, and + * false otherwise. + * + * @return A boolean. + * + * @see #setDrawOutlines(boolean) + */ + public boolean getDrawOutlines() { + return this.drawOutlines; + } + + /** + * Sets the flag that controls whether outlines are drawn for + * shapes, and sends a {@link RendererChangeEvent} to all registered + * listeners. + *

+ * In some cases, shapes look better if they do NOT have an outline, but + * this flag allows you to set your own preference. + * + * @param flag the flag. + * + * @see #getDrawOutlines() + */ + public void setDrawOutlines(boolean flag) { + this.drawOutlines = flag; + fireChangeEvent(); + } + + /** + * Returns true if the renderer should use the fill paint + * setting to fill shapes, and false if it should just + * use the regular paint. + *

+ * Refer to XYLineAndShapeRendererDemo2.java to see the + * effect of this flag. + * + * @return A boolean. + * + * @see #setUseFillPaint(boolean) + * @see #getUseOutlinePaint() + */ + public boolean getUseFillPaint() { + return this.useFillPaint; + } + + /** + * Sets the flag that controls whether the fill paint is used to fill + * shapes, and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param flag the flag. + * + * @see #getUseFillPaint() + */ + public void setUseFillPaint(boolean flag) { + this.useFillPaint = flag; + fireChangeEvent(); + } + + /** + * Returns true if the renderer should use the outline paint + * setting to draw shape outlines, and false if it should just + * use the regular paint. + * + * @return A boolean. + * + * @see #setUseOutlinePaint(boolean) + * @see #getUseFillPaint() + */ + public boolean getUseOutlinePaint() { + return this.useOutlinePaint; + } + + /** + * Sets the flag that controls whether the outline paint is used to draw + * shape outlines, and sends a {@link RendererChangeEvent} to all + * registered listeners. + *

+ * Refer to XYLineAndShapeRendererDemo2.java to see the + * effect of this flag. + * + * @param flag the flag. + * + * @see #getUseOutlinePaint() + */ + public void setUseOutlinePaint(boolean flag) { + this.useOutlinePaint = flag; + fireChangeEvent(); + } + + /** + * Records the state for the renderer. This is used to preserve state + * information between calls to the drawItem() method for a single chart + * drawing. + */ + public static class State extends XYItemRendererState { + + /** The path for the current series. */ + public GeneralPath seriesPath; + + /** + * A flag that indicates if the last (x, y) point was 'good' + * (non-null). + */ + private boolean lastPointGood; + + /** + * Creates a new state instance. + * + * @param info the plot rendering info. + */ + public State(PlotRenderingInfo info) { + super(info); + this.seriesPath = new GeneralPath(); + } + + /** + * Returns a flag that indicates if the last point drawn (in the + * current series) was 'good' (non-null). + * + * @return A boolean. + */ + public boolean isLastPointGood() { + return this.lastPointGood; + } + + /** + * Sets a flag that indicates if the last point drawn (in the current + * series) was 'good' (non-null). + * + * @param good the flag. + */ + public void setLastPointGood(boolean good) { + this.lastPointGood = good; + } + + /** + * This method is called by the {@link XYPlot} at the start of each + * series pass. We reset the state for the current series. + * + * @param dataset the dataset. + * @param series the series index. + * @param firstItem the first item index for this pass. + * @param lastItem the last item index for this pass. + * @param pass the current pass index. + * @param passCount the number of passes. + */ + @Override + public void startSeriesPass(XYDataset dataset, int series, + int firstItem, int lastItem, int pass, int passCount) { + this.seriesPath.reset(); + this.lastPointGood = false; + super.startSeriesPass(dataset, series, firstItem, lastItem, pass, + passCount); + } + + } + + /** + * Initialises the renderer. + *

+ * This method will be called before the first item is rendered, giving the + * renderer an opportunity to initialise any state information it wants to + * maintain. The renderer can do nothing if it chooses. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param data the data. + * @param info an optional info collection object to return data back to + * the caller. + * + * @return The renderer state. + */ + @Override + public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, + XYPlot plot, XYDataset data, PlotRenderingInfo info) { + return new State(info); + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + // do nothing if item is not visible + if (!getItemVisible(series, item)) { + return; + } + + // first pass draws the background (lines, for instance) + if (isLinePass(pass)) { + if (getItemLineVisible(series, item)) { + if (this.drawSeriesLineAsPath) { + drawPrimaryLineAsPath(state, g2, plot, dataset, pass, + series, item, domainAxis, rangeAxis, dataArea); + } + else { + drawPrimaryLine(state, g2, plot, dataset, pass, series, + item, domainAxis, rangeAxis, dataArea); + } + } + } + // second pass adds shapes where the items are .. + else if (isItemPass(pass)) { + + // setup for collecting optional entity info... + EntityCollection entities = null; + if (info != null && info.getOwner() != null) { + entities = info.getOwner().getEntityCollection(); + } + + drawSecondaryPass(g2, plot, dataset, pass, series, item, + domainAxis, dataArea, rangeAxis, crosshairState, entities); + } + } + + /** + * Returns true if the specified pass is the one for drawing + * lines. + * + * @param pass the pass. + * + * @return A boolean. + */ + protected boolean isLinePass(int pass) { + return pass == 0; + } + + /** + * Returns true if the specified pass is the one for drawing + * items. + * + * @param pass the pass. + * + * @return A boolean. + */ + protected boolean isItemPass(int pass) { + return pass == 1; + } + + /** + * 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; + } + + PlotOrientation orientation = plot.getOrientation(); + boolean visible; + if (orientation == PlotOrientation.HORIZONTAL) { + state.workingLine.setLine(transY0, transX0, transY1, transX1); + } + else if (orientation == PlotOrientation.VERTICAL) { + state.workingLine.setLine(transX0, transY0, transX1, transY1); + } + visible = LineUtilities.clipLine(state.workingLine, dataArea); + if (visible) { + drawFirstPassShape(g2, pass, series, item, state.workingLine); + } + } + + /** + * Draws the first pass shape. + * + * @param g2 the graphics device. + * @param pass the pass. + * @param series the series index. + * @param item the item index. + * @param shape the shape. + */ + protected void drawFirstPassShape(Graphics2D g2, int pass, int series, + int item, Shape shape) { + g2.setStroke(getItemStroke(series, item)); + g2.setPaint(getItemPaint(series, item)); + g2.draw(shape); + } + + + /** + * Draws the item (first pass). This method draws the lines + * connecting the items. Instead of drawing separate lines, + * a GeneralPath is constructed and drawn at the end of + * the series painting. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param plot the plot (can be used to obtain standard color information + * etc). + * @param dataset the dataset. + * @param pass the pass. + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @param domainAxis the domain axis. + * @param rangeAxis the range axis. + * @param dataArea the area within which the data is being drawn. + */ + protected void drawPrimaryLineAsPath(XYItemRendererState state, + Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, + int series, int item, ValueAxis domainAxis, ValueAxis rangeAxis, + Rectangle2D dataArea) { + + RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); + RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); + + // get the data point... + double x1 = dataset.getXValue(series, item); + double y1 = dataset.getYValue(series, item); + double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); + double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); + + State s = (State) state; + // update path to reflect latest point + if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) { + float x = (float) transX1; + float y = (float) transY1; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + x = (float) transY1; + y = (float) transX1; + } + if (s.isLastPointGood()) { + s.seriesPath.lineTo(x, y); + } + else { + s.seriesPath.moveTo(x, y); + } + s.setLastPointGood(true); + } + else { + s.setLastPointGood(false); + } + // if this is the last item, draw the path ... + if (item == s.getLastItemIndex()) { + // draw path + drawFirstPassShape(g2, pass, series, item, s.seriesPath); + } + } + + /** + * Draws the item shapes and adds chart entities (second pass). This method + * draws the shapes which mark the item positions. If entities + * is not null 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) { + + Shape entityArea = null; + + // get the data point... + double x1 = dataset.getXValue(series, item); + double y1 = dataset.getYValue(series, item); + if (Double.isNaN(y1) || Double.isNaN(x1)) { + return; + } + + PlotOrientation orientation = plot.getOrientation(); + RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); + RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); + double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); + double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); + + if (getItemShapeVisible(series, item)) { + Shape shape = getItemShape(series, item); + if (orientation == PlotOrientation.HORIZONTAL) { + shape = ShapeUtilities.createTranslatedShape(shape, transY1, + transX1); + } + else if (orientation == PlotOrientation.VERTICAL) { + shape = ShapeUtilities.createTranslatedShape(shape, transX1, + transY1); + } + entityArea = shape; + if (shape.intersects(dataArea)) { + if (getItemShapeFilled(series, item)) { + if (this.useFillPaint) { + g2.setPaint(getItemFillPaint(series, item)); + } + else { + g2.setPaint(getItemPaint(series, item)); + } + g2.fill(shape); + } + if (this.drawOutlines) { + if (getUseOutlinePaint()) { + g2.setPaint(getItemOutlinePaint(series, item)); + } + else { + g2.setPaint(getItemPaint(series, item)); + } + g2.setStroke(getItemOutlineStroke(series, item)); + g2.draw(shape); + } + } + } + + double xx = transX1; + double yy = transY1; + if (orientation == PlotOrientation.HORIZONTAL) { + xx = transY1; + yy = transX1; + } + + // draw the item label if there is one... + if (isItemLabelVisible(series, item)) { + drawItemLabel(g2, orientation, dataset, series, item, xx, yy, + (y1 < 0.0)); + } + + int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); + int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); + updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, + rangeAxisIndex, transX1, transY1, orientation); + + // add an entity for the item, but only if it falls within the data + // area... + if (entities != null && isPointInRect(dataArea, xx, yy)) { + addEntity(entities, entityArea, dataset, series, item, xx, yy); + } + } + + + /** + * Returns a legend item for the specified series. + * + * @param datasetIndex the dataset index (zero-based). + * @param series the series index (zero-based). + * + * @return A legend item for the series (possibly nullnull permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYLineAndShapeRenderer)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + XYLineAndShapeRenderer that = (XYLineAndShapeRenderer) obj; + if (!ObjectUtilities.equal(this.linesVisible, that.linesVisible)) { + return false; + } + if (!ObjectUtilities.equal( + this.seriesLinesVisible, that.seriesLinesVisible) + ) { + return false; + } + if (this.baseLinesVisible != that.baseLinesVisible) { + return false; + } + if (!ShapeUtilities.equal(this.legendLine, that.legendLine)) { + return false; + } + if (!ObjectUtilities.equal(this.shapesVisible, that.shapesVisible)) { + return false; + } + if (!ObjectUtilities.equal( + this.seriesShapesVisible, that.seriesShapesVisible) + ) { + return false; + } + if (this.baseShapesVisible != that.baseShapesVisible) { + return false; + } + if (!ObjectUtilities.equal(this.shapesFilled, that.shapesFilled)) { + return false; + } + if (!ObjectUtilities.equal( + this.seriesShapesFilled, that.seriesShapesFilled) + ) { + return false; + } + if (this.baseShapesFilled != that.baseShapesFilled) { + return false; + } + if (this.drawOutlines != that.drawOutlines) { + return false; + } + if (this.useOutlinePaint != that.useOutlinePaint) { + return false; + } + if (this.useFillPaint != that.useFillPaint) { + return false; + } + if (this.drawSeriesLineAsPath != that.drawSeriesLineAsPath) { + return false; + } + return true; + } + + /** + * 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.legendLine = SerialUtilities.readShape(stream); + } + + /** + * 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.legendLine, stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYShapeRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYShapeRenderer.java new file mode 100755 index 0000000..98cb14c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYShapeRenderer.java @@ -0,0 +1,623 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * XYShapeRenderer.java + * -------------------- + * (C) Copyright 2008-2013 by Andreas Haumer, xS+S and Contributors. + * + * Original Author: Martin Hoeller (x Software + Systeme xS+S - Andreas + * Haumer); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 17-Sep-2008 : Version 1, based on a contribution from Martin Hoeller with + * amendments by David Gilbert (DG); + * 16-Feb-2010 : Added findZBounds() (patch 2952086) (MH); + * 19-Oct-2011 : Fixed NPE in findRangeBounds() (bug 3026341) (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +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.Ellipse2D; +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.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.LookupPaintScale; +import org.jfree.chart.renderer.PaintScale; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYZDataset; +import org.jfree.io.SerialUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A renderer that draws shapes at (x, y) coordinates and, if the dataset + * is an instance of {@link XYZDataset}, fills the shapes with a paint that + * is based on the z-value (the paint is obtained from a lookup table). The + * renderer also allows for optional guidelines, horizontal and vertical lines + * connecting the shape to the edges of the plot. + *

+ * The example shown here is generated by the + * XYShapeRendererDemo1.java program included in the JFreeChart + * demo collection: + *

+ * XYShapeRendererSample.png + *

+ * This renderer has similarities to, but also differences from, the + * {@link XYLineAndShapeRenderer}. + * + * @since 1.0.11 + */ +public class XYShapeRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, Cloneable, Serializable { + + /** Auto generated serial version id. */ + private static final long serialVersionUID = 8320552104211173221L; + + /** The paint scale (never null). */ + private PaintScale paintScale; + + /** A flag that controls whether or not the shape outlines are drawn. */ + private boolean drawOutlines; + + /** + * A flag that controls whether or not the outline paint is used (if not, + * the regular paint is used). + */ + private boolean useOutlinePaint; + + /** + * A flag that controls whether or not the fill paint is used (if not, + * the fill paint is used). + */ + private boolean useFillPaint; + + /** Flag indicating if guide lines should be drawn for every item. */ + private boolean guideLinesVisible; + + /** The paint used for drawing the guide lines (never null). */ + private transient Paint guideLinePaint; + + /** The stroke used for drawing the guide lines (never null). */ + private transient Stroke guideLineStroke; + + /** + * Creates a new XYShapeRenderer instance with default + * attributes. + */ + public XYShapeRenderer() { + this.paintScale = new LookupPaintScale(); + this.useFillPaint = false; + this.drawOutlines = false; + this.useOutlinePaint = true; + this.guideLinesVisible = false; + this.guideLinePaint = Color.darkGray; + this.guideLineStroke = new BasicStroke(); + setBaseShape(new Ellipse2D.Double(-5.0, -5.0, 10.0, 10.0)); + setAutoPopulateSeriesShape(false); + } + + /** + * Returns the paint scale used by the renderer. + * + * @return The paint scale (never null). + * + * @see #setPaintScale(PaintScale) + */ + public PaintScale getPaintScale() { + return this.paintScale; + } + + /** + * Sets the paint scale used by the renderer and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param scale the scale (null not permitted). + * + * @see #getPaintScale() + */ + public void setPaintScale(PaintScale scale) { + ParamChecks.nullNotPermitted(scale, "scale"); + this.paintScale = scale; + notifyListeners(new RendererChangeEvent(this)); + } + + /** + * Returns true if outlines should be drawn for shapes, and + * false otherwise. + * + * @return A boolean. + * + * @see #setDrawOutlines(boolean) + */ + public boolean getDrawOutlines() { + return this.drawOutlines; + } + + /** + * Sets the flag that controls whether outlines are drawn for + * shapes, and sends a {@link RendererChangeEvent} to all registered + * listeners. + *

+ * In some cases, shapes look better if they do NOT have an outline, but + * this flag allows you to set your own preference. + * + * @param flag the flag. + * + * @see #getDrawOutlines() + */ + public void setDrawOutlines(boolean flag) { + this.drawOutlines = flag; + fireChangeEvent(); + } + + /** + * Returns true if the renderer should use the fill paint + * setting to fill shapes, and false if it should just + * use the regular paint. + *

+ * Refer to XYLineAndShapeRendererDemo2.java to see the + * effect of this flag. + * + * @return A boolean. + * + * @see #setUseFillPaint(boolean) + * @see #getUseOutlinePaint() + */ + public boolean getUseFillPaint() { + return this.useFillPaint; + } + + /** + * Sets the flag that controls whether the fill paint is used to fill + * shapes, and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param flag the flag. + * + * @see #getUseFillPaint() + */ + public void setUseFillPaint(boolean flag) { + this.useFillPaint = flag; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether the outline paint is used for + * shape outlines. If not, the regular series paint is used. + * + * @return A boolean. + * + * @see #setUseOutlinePaint(boolean) + */ + public boolean getUseOutlinePaint() { + return this.useOutlinePaint; + } + + /** + * Sets the flag that controls whether the outline paint is used for shape + * outlines, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param use the flag. + * + * @see #getUseOutlinePaint() + */ + public void setUseOutlinePaint(boolean use) { + this.useOutlinePaint = use; + fireChangeEvent(); + } + + /** + * Returns a flag that controls whether or not guide lines are drawn for + * each data item (the lines are horizontal and vertical "crosshairs" + * linking the data point to the axes). + * + * @return A boolean. + * + * @see #setGuideLinesVisible(boolean) + */ + public boolean isGuideLinesVisible() { + return this.guideLinesVisible; + } + + /** + * Sets the flag that controls whether or not guide lines are drawn for + * each data item and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param visible the new flag value. + * + * @see #isGuideLinesVisible() + */ + public void setGuideLinesVisible(boolean visible) { + this.guideLinesVisible = visible; + fireChangeEvent(); + } + + /** + * Returns the paint used to draw the guide lines. + * + * @return The paint (never null). + * + * @see #setGuideLinePaint(Paint) + */ + public Paint getGuideLinePaint() { + return this.guideLinePaint; + } + + /** + * Sets the paint used to draw the guide lines and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getGuideLinePaint() + */ + public void setGuideLinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.guideLinePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the stroke used to draw the guide lines. + * + * @return The stroke. + * + * @see #setGuideLineStroke(Stroke) + */ + public Stroke getGuideLineStroke() { + return this.guideLineStroke; + } + + /** + * Sets the stroke used to draw the guide lines and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getGuideLineStroke() + */ + public void setGuideLineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.guideLineStroke = stroke; + fireChangeEvent(); + } + + /** + * Returns the lower and upper bounds (range) of the x-values in the + * specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + */ + @Override + public Range findDomainBounds(XYDataset dataset) { + if (dataset == null) { + return null; + } + Range r = DatasetUtilities.findDomainBounds(dataset, false); + if (r == null) { + return null; + } + double offset = 0; // TODO getSeriesShape(n).getBounds().width / 2; + return new Range(r.getLowerBound() + offset, + r.getUpperBound() + offset); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + */ + @Override + public Range findRangeBounds(XYDataset dataset) { + if (dataset == null) { + return null; + } + Range r = DatasetUtilities.findRangeBounds(dataset, false); + if (r == null) { + return null; + } + double offset = 0; // TODO getSeriesShape(n).getBounds().height / 2; + return new Range(r.getLowerBound() + offset, r.getUpperBound() + + offset); + } + + /** + * Return the range of z-values in the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + */ + public Range findZBounds(XYZDataset dataset) { + if (dataset != null) { + return DatasetUtilities.findZBounds(dataset); + } + else { + return null; + } + } + + /** + * Returns the number of passes required by this renderer. + * + * @return 2. + */ + @Override + public int getPassCount() { + return 2; + } + + /** + * Draws the block representing the specified item. + * + * @param g2 the graphics device. + * @param state the state. + * @param dataArea the data area. + * @param info the plot rendering info. + * @param plot the plot. + * @param domainAxis the x-axis. + * @param rangeAxis the y-axis. + * @param dataset the dataset. + * @param series the series index. + * @param item the item index. + * @param crosshairState the crosshair state. + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + Shape hotspot; + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + } + + double x = dataset.getXValue(series, item); + double y = dataset.getYValue(series, item); + if (Double.isNaN(x) || Double.isNaN(y)) { + // can't draw anything + return; + } + + double transX = domainAxis.valueToJava2D(x, dataArea, + plot.getDomainAxisEdge()); + double transY = rangeAxis.valueToJava2D(y, dataArea, + plot.getRangeAxisEdge()); + + PlotOrientation orientation = plot.getOrientation(); + + // draw optional guide lines + if ((pass == 0) && this.guideLinesVisible) { + g2.setStroke(this.guideLineStroke); + g2.setPaint(this.guideLinePaint); + if (orientation == PlotOrientation.HORIZONTAL) { + g2.draw(new Line2D.Double(transY, dataArea.getMinY(), transY, + dataArea.getMaxY())); + g2.draw(new Line2D.Double(dataArea.getMinX(), transX, + dataArea.getMaxX(), transX)); + } + else { + g2.draw(new Line2D.Double(transX, dataArea.getMinY(), transX, + dataArea.getMaxY())); + g2.draw(new Line2D.Double(dataArea.getMinX(), transY, + dataArea.getMaxX(), transY)); + } + } + else if (pass == 1) { + Shape shape = getItemShape(series, item); + if (orientation == PlotOrientation.HORIZONTAL) { + shape = ShapeUtilities.createTranslatedShape(shape, transY, + transX); + } + else if (orientation == PlotOrientation.VERTICAL) { + shape = ShapeUtilities.createTranslatedShape(shape, transX, + transY); + } + hotspot = shape; + if (shape.intersects(dataArea)) { + //if (getItemShapeFilled(series, item)) { + g2.setPaint(getPaint(dataset, series, item)); + g2.fill(shape); + //} + if (this.drawOutlines) { + if (getUseOutlinePaint()) { + g2.setPaint(getItemOutlinePaint(series, item)); + } + else { + g2.setPaint(getItemPaint(series, item)); + } + g2.setStroke(getItemOutlineStroke(series, item)); + g2.draw(shape); + } + } + + // add an entity for the item... + if (entities != null) { + addEntity(entities, hotspot, dataset, series, item, transX, + transY); + } + } + } + + /** + * Get the paint for a given series and item from a dataset. + * + * @param dataset the dataset.. + * @param series the series index. + * @param item the item index. + * + * @return The paint. + */ + protected Paint getPaint(XYDataset dataset, int series, int item) { + Paint p; + if (dataset instanceof XYZDataset) { + double z = ((XYZDataset) dataset).getZValue(series, item); + p = this.paintScale.getPaint(z); + } + else { + if (this.useFillPaint) { + p = getItemFillPaint(series, item); + } + else { + p = getItemPaint(series, item); + } + } + return p; + } + + /** + * Tests this instance for equality with an arbitrary object. This method + * returns true if and only if: + *

    + *
  • obj is an instance of XYShapeRenderer (not + * null);
  • + *
  • obj has the same field values as this + * XYShapeRenderer;
  • + *
+ * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYShapeRenderer)) { + return false; + } + XYShapeRenderer that = (XYShapeRenderer) obj; + if (!this.paintScale.equals(that.paintScale)) { + return false; + } + if (this.drawOutlines != that.drawOutlines) { + return false; + } + if (this.useOutlinePaint != that.useOutlinePaint) { + return false; + } + if (this.useFillPaint != that.useFillPaint) { + return false; + } + if (this.guideLinesVisible != that.guideLinesVisible) { + return false; + } + if (!this.guideLinePaint.equals(that.guideLinePaint)) { + return false; + } + if (!this.guideLineStroke.equals(that.guideLineStroke)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of this renderer. + * + * @return A clone of this renderer. + * + * @throws CloneNotSupportedException if there is a problem creating the + * clone. + */ + @Override + public Object clone() throws CloneNotSupportedException { + XYShapeRenderer clone = (XYShapeRenderer) super.clone(); + if (this.paintScale instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.paintScale; + clone.paintScale = (PaintScale) pc.clone(); + } + return clone; + } + + /** + * 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.guideLinePaint = SerialUtilities.readPaint(stream); + this.guideLineStroke = SerialUtilities.readStroke(stream); + } + + /** + * 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.guideLinePaint, stream); + SerialUtilities.writeStroke(this.guideLineStroke, stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYSplineRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYSplineRenderer.java new file mode 100755 index 0000000..b3a3afb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYSplineRenderer.java @@ -0,0 +1,512 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * XYSplineRenderer.java + * --------------------- + * (C) Copyright 2007-2013, by Klaus Rheinwald and Contributors. + * + * Original Author: Klaus Rheinwald; + * Contributor(s): Tobias von Petersdorff (tvp@math.umd.edu, + * http://www.wam.umd.edu/~petersd/); + * David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 25-Jul-2007 : Version 1, contributed by Klaus Rheinwald (DG); + * 03-Aug-2007 : Added new constructor (KR); + * 25-Oct-2007 : Prevent duplicate control points (KR); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * 14-Sep-2013 : Replaced Vector with List, general cleanup (KR); + * 15-Sep-2013 : Added support to fill the area 'under' (between '0' and) the + * spline(KR); + * 15-Sep-2013 : Replaced ControlPoint with Point2D.Float (KR); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.geom.GeneralPath; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.util.ArrayList; +import java.util.List; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.StandardGradientPaintTransformer; +import org.jfree.util.ObjectUtilities; + +/** + * A renderer that connects data points with natural cubic splines and/or + * draws shapes at each data point. This renderer is designed for use with + * the {@link XYPlot} class. The example shown here is generated by the + * XYSplineRendererDemo1.java program included in the JFreeChart + * demo collection: + *

+ * XYSplineRendererSample.png + * + * @since 1.0.7 + */ +public class XYSplineRenderer extends XYLineAndShapeRenderer { + + /** + * An enumeration of the fill types for the renderer. + * + * @since 1.0.17 + */ + public static enum FillType { + NONE, + TO_ZERO, + TO_LOWER_BOUND, + TO_UPPER_BOUND + } + + /** + * Represents state information that applies to a single rendering of + * a chart. + */ + public static class XYSplineState extends State { + + /** The area to fill under the curve. */ + public GeneralPath fillArea; + + /** The points. */ + public List points; + + /** + * Creates a new state instance. + * + * @param info the plot rendering info. + */ + public XYSplineState(PlotRenderingInfo info) { + super(info); + this.fillArea = new GeneralPath(); + this.points = new ArrayList(); + } + } + + /** + * Resolution of splines (number of line segments between points) + */ + private int precision; + + /** + * A flag that can be set to specify + * to fill the area under the spline. + */ + private FillType fillType; + + private GradientPaintTransformer gradientPaintTransformer; + + /** + * Creates a new instance with the precision attribute defaulting to 5 + * and no fill of the area 'under' the spline. + */ + public XYSplineRenderer() { + this(5, FillType.NONE); + } + + /** + * Creates a new renderer with the specified precision + * and no fill of the area 'under' (between '0' and) the spline. + * + * @param precision the number of points between data items. + */ + public XYSplineRenderer(int precision) { + this(precision, FillType.NONE); + } + + /** + * Creates a new renderer with the specified precision + * and specified fill of the area 'under' (between '0' and) the spline. + * + * @param precision the number of points between data items. + * @param fillType the type of fill beneath the curve (null + * not permitted). + * + * @since 1.0.17 + */ + public XYSplineRenderer(int precision, FillType fillType) { + super(); + if (precision <= 0) { + throw new IllegalArgumentException("Requires precision > 0."); + } + ParamChecks.nullNotPermitted(fillType, "fillType"); + this.precision = precision; + this.fillType = fillType; + this.gradientPaintTransformer = new StandardGradientPaintTransformer(); + } + + /** + * Returns the number of line segments used to approximate the spline + * curve between data points. + * + * @return The number of line segments. + * + * @see #setPrecision(int) + */ + public int getPrecision() { + return this.precision; + } + + /** + * Set the resolution of splines and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param p number of line segments between points (must be > 0). + * + * @see #getPrecision() + */ + public void setPrecision(int p) { + if (p <= 0) { + throw new IllegalArgumentException("Requires p > 0."); + } + this.precision = p; + fireChangeEvent(); + } + + /** + * Returns the type of fill that the renderer draws beneath the curve. + * + * @return The type of fill (never null). + * + * @see #setFillType(FillType) + * + * @since 1.0.17 + */ + public FillType getFillType() { + return this.fillType; + } + + /** + * Set the fill type and sends a {@link RendererChangeEvent} + * to all registered listeners. + * + * @param fillType the fill type (null not permitted). + * + * @see #getFillType() + * + * @since 1.0.17 + */ + public void setFillType(FillType fillType) { + this.fillType = fillType; + fireChangeEvent(); + } + + /** + * Returns the gradient paint transformer, or null. + * + * @return The gradient paint transformer (possibly null). + * + * @since 1.0.17 + */ + public GradientPaintTransformer getGradientPaintTransformer() { + return this.gradientPaintTransformer; + } + + /** + * Sets the gradient paint transformer and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param gpt the transformer (null permitted). + * + * @since 1.0.17 + */ + public void setGradientPaintTransformer(GradientPaintTransformer gpt) { + this.gradientPaintTransformer = gpt; + fireChangeEvent(); + } + + /** + * Initialises the renderer. + *

+ * This method will be called before the first item is rendered, giving the + * renderer an opportunity to initialise any state information it wants to + * maintain. The renderer can do nothing if it chooses. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param data the data. + * @param info an optional info collection object to return data back to + * the caller. + * + * @return The renderer state. + */ + @Override + public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, + XYPlot plot, XYDataset data, PlotRenderingInfo info) { + + setDrawSeriesLineAsPath(true); + XYSplineState state = new XYSplineState(info); + state.setProcessVisibleItemsOnly(false); + return state; + } + + /** + * Draws the item (first pass). This method draws the lines + * connecting the items. Instead of drawing separate lines, + * a GeneralPath is constructed and drawn at the end of + * the series painting. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param plot the plot (can be used to obtain standard color information + * etc). + * @param dataset the dataset. + * @param pass the pass. + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @param xAxis the domain axis. + * @param yAxis the range axis. + * @param dataArea the area within which the data is being drawn. + */ + @Override + protected void drawPrimaryLineAsPath(XYItemRendererState state, + Graphics2D g2, XYPlot plot, XYDataset dataset, int pass, + int series, int item, ValueAxis xAxis, ValueAxis yAxis, + Rectangle2D dataArea) { + + XYSplineState s = (XYSplineState) state; + RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); + RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); + + // get the data points + double x1 = dataset.getXValue(series, item); + double y1 = dataset.getYValue(series, item); + double transX1 = xAxis.valueToJava2D(x1, dataArea, xAxisLocation); + double transY1 = yAxis.valueToJava2D(y1, dataArea, yAxisLocation); + + // Collect points + if (!Double.isNaN(transX1) && !Double.isNaN(transY1)) { + Point2D p = plot.getOrientation() == PlotOrientation.HORIZONTAL + ? new Point2D.Float((float) transY1, (float) transX1) + : new Point2D.Float((float) transX1, (float) transY1); + if (!s.points.contains(p)) + s.points.add(p); + } + + if (item == dataset.getItemCount(series) - 1) { // construct path + if (s.points.size() > 1) { + Point2D origin; + if (this.fillType == FillType.TO_ZERO) { + float xz = (float) xAxis.valueToJava2D(0, dataArea, + yAxisLocation); + float yz = (float) yAxis.valueToJava2D(0, dataArea, + yAxisLocation); + origin = plot.getOrientation() == PlotOrientation.HORIZONTAL + ? new Point2D.Float(yz, xz) + : new Point2D.Float(xz, yz); + } else if (this.fillType == FillType.TO_LOWER_BOUND) { + float xlb = (float) xAxis.valueToJava2D( + xAxis.getLowerBound(), dataArea, xAxisLocation); + float ylb = (float) yAxis.valueToJava2D( + yAxis.getLowerBound(), dataArea, yAxisLocation); + origin = plot.getOrientation() == PlotOrientation.HORIZONTAL + ? new Point2D.Float(ylb, xlb) + : new Point2D.Float(xlb, ylb); + } else {// fillType == TO_UPPER_BOUND + float xub = (float) xAxis.valueToJava2D( + xAxis.getUpperBound(), dataArea, xAxisLocation); + float yub = (float) yAxis.valueToJava2D( + yAxis.getUpperBound(), dataArea, yAxisLocation); + origin = plot.getOrientation() == PlotOrientation.HORIZONTAL + ? new Point2D.Float(yub, xub) + : new Point2D.Float(xub, yub); + } + + // we need at least two points to draw something + Point2D cp0 = s.points.get(0); + s.seriesPath.moveTo(cp0.getX(), cp0.getY()); + if (this.fillType != FillType.NONE) { + if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { + s.fillArea.moveTo(origin.getX(), cp0.getY()); + } else { + s.fillArea.moveTo(cp0.getX(), origin.getY()); + } + s.fillArea.lineTo(cp0.getX(), cp0.getY()); + } + if (s.points.size() == 2) { + // we need at least 3 points to spline. Draw simple line + // for two points + Point2D cp1 = s.points.get(1); + if (this.fillType != FillType.NONE) { + s.fillArea.lineTo(cp1.getX(), cp1.getY()); + s.fillArea.lineTo(cp1.getX(), origin.getY()); + s.fillArea.closePath(); + } + s.seriesPath.lineTo(cp1.getX(), cp1.getY()); + } else { + // construct spline + int np = s.points.size(); // number of points + float[] d = new float[np]; // Newton form coefficients + float[] x = new float[np]; // x-coordinates of nodes + float y, oldy; + float t, oldt; + + float[] a = new float[np]; + float t1; + float t2; + float[] h = new float[np]; + + for (int i = 0; i < np; i++) { + Point2D.Float cpi = (Point2D.Float) s.points.get(i); + x[i] = cpi.x; + d[i] = cpi.y; + } + + for (int i = 1; i <= np - 1; i++) + h[i] = x[i] - x[i - 1]; + + float[] sub = new float[np - 1]; + float[] diag = new float[np - 1]; + float[] sup = new float[np - 1]; + + for (int i = 1; i <= np - 2; i++) { + diag[i] = (h[i] + h[i + 1]) / 3; + sup[i] = h[i + 1] / 6; + sub[i] = h[i] / 6; + a[i] = (d[i + 1] - d[i]) / h[i + 1] + - (d[i] - d[i - 1]) / h[i]; + } + solveTridiag(sub, diag, sup, a, np - 2); + + // note that a[0]=a[np-1]=0 + oldt = x[0]; + oldy = d[0]; + for (int i = 1; i <= np - 1; i++) { + // loop over intervals between nodes + for (int j = 1; j <= this.precision; j++) { + t1 = (h[i] * j) / this.precision; + t2 = h[i] - t1; + y = ((-a[i - 1] / 6 * (t2 + h[i]) * t1 + d[i - 1]) + * t2 + (-a[i] / 6 * (t1 + h[i]) * t2 + + d[i]) * t1) / h[i]; + t = x[i - 1] + t1; + s.seriesPath.lineTo(t, y); + if (this.fillType != FillType.NONE) { + s.fillArea.lineTo(t, y); + } + } + } + } + // Add last point @ y=0 for fillPath and close path + if (this.fillType != FillType.NONE) { + if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { + s.fillArea.lineTo(origin.getX(), s.points.get( + s.points.size() - 1).getY()); + } else { + s.fillArea.lineTo(s.points.get( + s.points.size() - 1).getX(), origin.getY()); + } + s.fillArea.closePath(); + } + + // fill under the curve... + if (this.fillType != FillType.NONE) { + Paint fp = getSeriesFillPaint(series); + if (this.gradientPaintTransformer != null + && fp instanceof GradientPaint) { + GradientPaint gp = this.gradientPaintTransformer + .transform((GradientPaint) fp, s.fillArea); + g2.setPaint(gp); + } else { + g2.setPaint(fp); + } + g2.fill(s.fillArea); + s.fillArea.reset(); + } + // then draw the line... + drawFirstPassShape(g2, pass, series, item, s.seriesPath); + } + // reset points vector + s.points = new ArrayList(); + } + } + + private void solveTridiag(float[] sub, float[] diag, float[] sup, + float[] b, int n) { +/* solve linear system with tridiagonal n by n matrix a + using Gaussian elimination *without* pivoting + where a(i,i-1) = sub[i] for 2<=i<=n + a(i,i) = diag[i] for 1<=i<=n + a(i,i+1) = sup[i] for 1<=i<=n-1 + (the values sub[1], sup[n] are ignored) + right hand side vector b[1:n] is overwritten with solution + NOTE: 1...n is used in all arrays, 0 is unused */ + int i; +/* factorization and forward substitution */ + for (i = 2; i <= n; i++) { + sub[i] /= diag[i - 1]; + diag[i] -= sub[i] * sup[i - 1]; + b[i] -= sub[i] * b[i - 1]; + } + b[n] /= diag[n]; + for (i = n - 1; i >= 1; i--) + b[i] = (b[i] - sup[i] * b[i + 1]) / diag[i]; + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYSplineRenderer)) { + return false; + } + XYSplineRenderer that = (XYSplineRenderer) obj; + if (this.precision != that.precision) { + return false; + } + if (this.fillType != that.fillType) { + return false; + } + if (!ObjectUtilities.equal(this.gradientPaintTransformer, + that.gradientPaintTransformer)) { + return false; + } + return super.equals(obj); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java new file mode 100755 index 0000000..2480e7d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYStepAreaRenderer.java @@ -0,0 +1,608 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * XYStepAreaRenderer.java + * ----------------------- + * (C) Copyright 2003-2009, by Matthias Rose and Contributors. + * + * Original Author: Matthias Rose (based on XYAreaRenderer.java); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 07-Oct-2003 : Version 1, contributed by Matthias Rose (DG); + * 10-Feb-2004 : Added some getter and setter methods (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed + * XYToolTipGenerator --> XYItemLabelGenerator (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); + * 06-Jul-2005 : Renamed get/setPlotShapes() --> get/setShapesVisible() (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 06-Jul-2006 : Modified to call dataset methods that return double + * primitives only (DG); + * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); + * 14-Feb-2007 : Added equals() method override (DG); + * 04-May-2007 : Set processVisibleItemsOnly flag to false (DG); + * 14-May-2008 : Call addEntity() from within drawItem() (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Polygon; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.data.xy.XYDataset; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A step chart renderer that fills the area between the step and the x-axis. + * The example shown here is generated by the + * XYStepAreaRendererDemo1.java program included in the JFreeChart + * demo collection: + *

+ * XYStepAreaRendererSample.png + */ +public class XYStepAreaRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -7311560779702649635L; + + /** Useful constant for specifying the type of rendering (shapes only). */ + public static final int SHAPES = 1; + + /** Useful constant for specifying the type of rendering (area only). */ + public static final int AREA = 2; + + /** + * Useful constant for specifying the type of rendering (area and shapes). + */ + public static final int AREA_AND_SHAPES = 3; + + /** A flag indicating whether or not shapes are drawn at each XY point. */ + private boolean shapesVisible; + + /** A flag that controls whether or not shapes are filled for ALL series. */ + private boolean shapesFilled; + + /** A flag indicating whether or not Area are drawn at each XY point. */ + private boolean plotArea; + + /** A flag that controls whether or not the outline is shown. */ + private boolean showOutline; + + /** Area of the complete series */ + protected transient Polygon pArea = null; + + /** + * The value on the range axis which defines the 'lower' border of the + * area. + */ + private double rangeBase; + + /** + * Constructs a new renderer. + */ + public XYStepAreaRenderer() { + this(AREA); + } + + /** + * Constructs a new renderer. + * + * @param type the type of the renderer. + */ + public XYStepAreaRenderer(int type) { + this(type, null, null); + } + + /** + * Constructs a new renderer. + *

+ * To specify the type of renderer, use one of the constants: + * AREA, SHAPES or AREA_AND_SHAPES. + * + * @param type the type of renderer. + * @param toolTipGenerator the tool tip generator to use + * (null permitted). + * @param urlGenerator the URL generator (null permitted). + */ + public XYStepAreaRenderer(int type, + XYToolTipGenerator toolTipGenerator, + XYURLGenerator urlGenerator) { + + super(); + setBaseToolTipGenerator(toolTipGenerator); + setURLGenerator(urlGenerator); + + if (type == AREA) { + this.plotArea = true; + } + else if (type == SHAPES) { + this.shapesVisible = true; + } + else if (type == AREA_AND_SHAPES) { + this.plotArea = true; + this.shapesVisible = true; + } + this.showOutline = false; + } + + /** + * Returns a flag that controls whether or not outlines of the areas are + * drawn. + * + * @return The flag. + * + * @see #setOutline(boolean) + */ + public boolean isOutline() { + return this.showOutline; + } + + /** + * Sets a flag that controls whether or not outlines of the areas are + * drawn, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param show the flag. + * + * @see #isOutline() + */ + public void setOutline(boolean show) { + this.showOutline = show; + fireChangeEvent(); + } + + /** + * Returns true if shapes are being plotted by the renderer. + * + * @return true if shapes are being plotted by the renderer. + * + * @see #setShapesVisible(boolean) + */ + public boolean getShapesVisible() { + return this.shapesVisible; + } + + /** + * Sets the flag that controls whether or not shapes are displayed for each + * data item, and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param flag the flag. + * + * @see #getShapesVisible() + */ + public void setShapesVisible(boolean flag) { + this.shapesVisible = flag; + fireChangeEvent(); + } + + /** + * Returns the flag that controls whether or not the shapes are filled. + * + * @return A boolean. + * + * @see #setShapesFilled(boolean) + */ + public boolean isShapesFilled() { + return this.shapesFilled; + } + + /** + * Sets the 'shapes filled' for ALL series and sends a + * {@link RendererChangeEvent} to all registered listeners. + * + * @param filled the flag. + * + * @see #isShapesFilled() + */ + public void setShapesFilled(boolean filled) { + this.shapesFilled = filled; + fireChangeEvent(); + } + + /** + * Returns true if Area is being plotted by the renderer. + * + * @return true if Area is being plotted by the renderer. + * + * @see #setPlotArea(boolean) + */ + public boolean getPlotArea() { + return this.plotArea; + } + + /** + * Sets a flag that controls whether or not areas are drawn for each data + * item and sends a {@link RendererChangeEvent} to all registered + * listeners. + * + * @param flag the flag. + * + * @see #getPlotArea() + */ + public void setPlotArea(boolean flag) { + this.plotArea = flag; + fireChangeEvent(); + } + + /** + * Returns the value on the range axis which defines the 'lower' border of + * the area. + * + * @return double the value on the range axis which defines + * the 'lower' border of the area. + * + * @see #setRangeBase(double) + */ + public double getRangeBase() { + return this.rangeBase; + } + + /** + * Sets the value on the range axis which defines the default border of the + * area, and sends a {@link RendererChangeEvent} to all registered + * listeners. E.g. setRangeBase(Double.NEGATIVE_INFINITY) lets areas always + * reach the lower border of the plotArea. + * + * @param val the value on the range axis which defines the default border + * of the area. + * + * @see #getRangeBase() + */ + public void setRangeBase(double val) { + this.rangeBase = val; + fireChangeEvent(); + } + + /** + * Initialises the renderer. Here we calculate the Java2D y-coordinate for + * zero, since all the bars have their bases fixed at zero. + * + * @param g2 the graphics device. + * @param dataArea the area inside the axes. + * @param plot the plot. + * @param data the data. + * @param info an optional info collection object to return data back to + * the caller. + * + * @return The number of passes required by the renderer. + */ + @Override + public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, + XYPlot plot, XYDataset data, PlotRenderingInfo info) { + + XYItemRendererState state = super.initialise(g2, dataArea, plot, data, + info); + // disable visible items optimisation - it doesn't work for this + // renderer... + state.setProcessVisibleItemsOnly(false); + return state; + + } + + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + PlotOrientation orientation = plot.getOrientation(); + + // Get the item count for the series, so that we can know which is the + // end of the series. + int itemCount = dataset.getItemCount(series); + + Paint paint = getItemPaint(series, item); + Stroke seriesStroke = getItemStroke(series, item); + g2.setPaint(paint); + g2.setStroke(seriesStroke); + + // get the data point... + double x1 = dataset.getXValue(series, item); + double y1 = dataset.getYValue(series, item); + double x = x1; + double y = Double.isNaN(y1) ? getRangeBase() : y1; + double transX1 = domainAxis.valueToJava2D(x, dataArea, + plot.getDomainAxisEdge()); + double transY1 = rangeAxis.valueToJava2D(y, dataArea, + plot.getRangeAxisEdge()); + + // avoid possible sun.dc.pr.PRException: endPath: bad path + transY1 = restrictValueToDataArea(transY1, plot, dataArea); + + if (this.pArea == null && !Double.isNaN(y1)) { + + // Create a new Area for the series + this.pArea = new Polygon(); + + // start from Y = rangeBase + double transY2 = rangeAxis.valueToJava2D(getRangeBase(), dataArea, + plot.getRangeAxisEdge()); + + // avoid possible sun.dc.pr.PRException: endPath: bad path + transY2 = restrictValueToDataArea(transY2, plot, dataArea); + + // The first point is (x, this.baseYValue) + if (orientation == PlotOrientation.VERTICAL) { + this.pArea.addPoint((int) transX1, (int) transY2); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + this.pArea.addPoint((int) transY2, (int) transX1); + } + } + + double transX0; + double transY0; + + double x0; + double y0; + if (item > 0) { + // get the previous data point... + x0 = dataset.getXValue(series, item - 1); + y0 = Double.isNaN(y1) ? y1 : dataset.getYValue(series, item - 1); + + x = x0; + y = Double.isNaN(y0) ? getRangeBase() : y0; + transX0 = domainAxis.valueToJava2D(x, dataArea, + plot.getDomainAxisEdge()); + transY0 = rangeAxis.valueToJava2D(y, dataArea, + plot.getRangeAxisEdge()); + + // avoid possible sun.dc.pr.PRException: endPath: bad path + transY0 = restrictValueToDataArea(transY0, plot, dataArea); + + if (Double.isNaN(y1)) { + // NULL value -> insert point on base line + // instead of 'step point' + transX1 = transX0; + transY0 = transY1; + } + if (transY0 != transY1) { + // not just a horizontal bar but need to perform a 'step'. + if (orientation == PlotOrientation.VERTICAL) { + this.pArea.addPoint((int) transX1, (int) transY0); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + this.pArea.addPoint((int) transY0, (int) transX1); + } + } + } + + Shape shape = null; + if (!Double.isNaN(y1)) { + // Add each point to Area (x, y) + if (orientation == PlotOrientation.VERTICAL) { + this.pArea.addPoint((int) transX1, (int) transY1); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + this.pArea.addPoint((int) transY1, (int) transX1); + } + + if (getShapesVisible()) { + shape = getItemShape(series, item); + if (orientation == PlotOrientation.VERTICAL) { + shape = ShapeUtilities.createTranslatedShape(shape, + transX1, transY1); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + shape = ShapeUtilities.createTranslatedShape(shape, + transY1, transX1); + } + if (isShapesFilled()) { + g2.fill(shape); + } + else { + g2.draw(shape); + } + } + else { + if (orientation == PlotOrientation.VERTICAL) { + shape = new Rectangle2D.Double(transX1 - 2, transY1 - 2, + 4.0, 4.0); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + shape = new Rectangle2D.Double(transY1 - 2, transX1 - 2, + 4.0, 4.0); + } + } + } + + // Check if the item is the last item for the series or if it + // is a NULL value and number of items > 0. We can't draw an area for + // a single point. + if (getPlotArea() && item > 0 && this.pArea != null + && (item == (itemCount - 1) || Double.isNaN(y1))) { + + double transY2 = rangeAxis.valueToJava2D(getRangeBase(), dataArea, + plot.getRangeAxisEdge()); + + // avoid possible sun.dc.pr.PRException: endPath: bad path + transY2 = restrictValueToDataArea(transY2, plot, dataArea); + + if (orientation == PlotOrientation.VERTICAL) { + // Add the last point (x,0) + this.pArea.addPoint((int) transX1, (int) transY2); + } + else if (orientation == PlotOrientation.HORIZONTAL) { + // Add the last point (x,0) + this.pArea.addPoint((int) transY2, (int) transX1); + } + + // fill the polygon + g2.fill(this.pArea); + + // draw an outline around the Area. + if (isOutline()) { + g2.setStroke(plot.getOutlineStroke()); + g2.setPaint(plot.getOutlinePaint()); + g2.draw(this.pArea); + } + + // start new area when needed (see above) + this.pArea = null; + } + + // do we need to update the crosshair values? + if (!Double.isNaN(y1)) { + int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); + int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); + updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, + rangeAxisIndex, transX1, transY1, orientation); + } + + // collect entity and tool tip information... + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addEntity(entities, shape, dataset, series, item, transX1, transY1); + } + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYStepAreaRenderer)) { + return false; + } + XYStepAreaRenderer that = (XYStepAreaRenderer) obj; + if (this.showOutline != that.showOutline) { + return false; + } + if (this.shapesVisible != that.shapesVisible) { + return false; + } + if (this.shapesFilled != that.shapesFilled) { + return false; + } + if (this.plotArea != that.plotArea) { + return false; + } + if (this.rangeBase != that.rangeBase) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Helper method which returns a value if it lies + * inside the visible dataArea and otherwise the corresponding + * coordinate on the border of the dataArea. The PlotOrientation + * is taken into account. + * Useful to avoid possible sun.dc.pr.PRException: endPath: bad path + * which occurs when trying to draw lines/shapes which in large part + * lie outside of the visible dataArea. + * + * @param value the value which shall be + * @param dataArea the area within which the data is being drawn. + * @param plot the plot (can be used to obtain standard color + * information etc). + * @return double value inside the data area. + */ + protected static double restrictValueToDataArea(double value, + XYPlot plot, + Rectangle2D dataArea) { + double min = 0; + double max = 0; + if (plot.getOrientation() == PlotOrientation.VERTICAL) { + min = dataArea.getMinY(); + max = dataArea.getMaxY(); + } + else if (plot.getOrientation() == PlotOrientation.HORIZONTAL) { + min = dataArea.getMinX(); + max = dataArea.getMaxX(); + } + if (value < min) { + value = min; + } + else if (value > max) { + value = max; + } + return value; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYStepRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYStepRenderer.java new file mode 100755 index 0000000..5f066da --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/XYStepRenderer.java @@ -0,0 +1,366 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * XYStepRenderer.java + * ------------------- + * (C) Copyright 2002-2009, by Roger Studner and Contributors. + * + * Original Author: Roger Studner; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Matthias Rose; + * Gerald Struck (fix for bug 1569094); + * Ulrich Voigt (patch 1874890); + * Martin Hoeller (contribution to patch 1874890); + * + * Changes + * ------- + * 13-May-2002 : Version 1, contributed by Roger Studner (DG); + * 25-Jun-2002 : Updated import statements (DG); + * 22-Jul-2002 : Added check for null data items (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Modified drawItem() method signature (DG); + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 28-Oct-2003 : Added tooltips, code contributed by Matthias Rose + * (RFE 824857) (DG); + * 10-Feb-2004 : Removed working line (use line from state object instead) (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState. Renamed + * XYToolTipGenerator --> XYItemLabelGenerator (DG); + * 19-Jan-2005 : Now accesses only primitives from dataset (DG); + * 15-Mar-2005 : Fix silly bug in drawItem() method (DG); + * 19-Sep-2005 : Extend XYLineAndShapeRenderer (fixes legend shapes), added + * support for series visibility, and use getDefaultEntityRadius() + * for entity hotspot size (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 15-Jun-2006 : Added basic support for item labels (DG); + * 11-Oct-2006 : Fixed rendering with horizontal orientation (see bug 1569094), + * thanks to Gerald Struck (DG); + * 06-Feb-2007 : Fixed bug 1086307, crosshairs with multiple axes (DG); + * 14-Feb-2008 : Applied patch 1874890 by Ulrich Voigt (with contribution from + * Martin Hoeller) (DG); + * 14-May-2008 : Call addEntity() in drawItem() (DG); + * 24-Sep-2008 : Fixed bug 2113627 by utilising second pass to draw item + * labels (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +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.Serializable; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.urls.XYURLGenerator; +import org.jfree.data.xy.XYDataset; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.PublicCloneable; + +/** + * Line/Step item renderer for an {@link XYPlot}. This class draws lines + * between data points, only allowing horizontal or vertical lines (steps). + * The example shown here is generated by the + * XYStepRendererDemo1.java program included in the JFreeChart + * demo collection: + *

+ * XYStepRendererSample.png + */ +public class XYStepRenderer extends XYLineAndShapeRenderer + implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -8918141928884796108L; + + /** + * The factor (from 0.0 to 1.0) that determines the position of the + * step. + * + * @since 1.0.10. + */ + private double stepPoint = 1.0d; + + /** + * Constructs a new renderer with no tooltip or URL generation. + */ + public XYStepRenderer() { + this(null, null); + } + + /** + * Constructs a new renderer with the specified tool tip and URL + * generators. + * + * @param toolTipGenerator the item label generator (null + * permitted). + * @param urlGenerator the URL generator (null permitted). + */ + public XYStepRenderer(XYToolTipGenerator toolTipGenerator, + XYURLGenerator urlGenerator) { + super(); + setBaseToolTipGenerator(toolTipGenerator); + setURLGenerator(urlGenerator); + setBaseShapesVisible(false); + } + + /** + * Returns the fraction of the domain position between two points on which + * the step is drawn. The default is 1.0d, which means the step is drawn + * at the domain position of the second`point. If the stepPoint is 0.5d the + * step is drawn at half between the two points. + * + * @return The fraction of the domain position between two points where the + * step is drawn. + * + * @see #setStepPoint(double) + * + * @since 1.0.10 + */ + public double getStepPoint() { + return this.stepPoint; + } + + /** + * Sets the step point and sends a {@link RendererChangeEvent} to all + * registered listeners. + * + * @param stepPoint the step point (in the range 0.0 to 1.0) + * + * @see #getStepPoint() + * + * @since 1.0.10 + */ + public void setStepPoint(double stepPoint) { + if (stepPoint < 0.0d || stepPoint > 1.0d) { + throw new IllegalArgumentException( + "Requires stepPoint in [0.0;1.0]"); + } + this.stepPoint = stepPoint; + fireChangeEvent(); + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the data is being drawn. + * @param info collects information about the drawing. + * @param plot the plot (can be used to obtain standard color + * information etc). + * @param domainAxis the domain axis. + * @param rangeAxis the vertical axis. + * @param dataset the dataset. + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index. + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + // do nothing if item is not visible + if (!getItemVisible(series, item)) { + return; + } + + PlotOrientation orientation = plot.getOrientation(); + + Paint seriesPaint = getItemPaint(series, item); + Stroke seriesStroke = getItemStroke(series, item); + g2.setPaint(seriesPaint); + g2.setStroke(seriesStroke); + + // get the data point... + double x1 = dataset.getXValue(series, item); + double y1 = dataset.getYValue(series, item); + + RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); + RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); + double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); + double transY1 = (Double.isNaN(y1) ? Double.NaN + : rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation)); + + if (pass == 0 && item > 0) { + // get the previous data point... + double x0 = dataset.getXValue(series, item - 1); + double y0 = dataset.getYValue(series, item - 1); + double transX0 = domainAxis.valueToJava2D(x0, dataArea, + xAxisLocation); + double transY0 = (Double.isNaN(y0) ? Double.NaN + : rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation)); + + if (orientation == PlotOrientation.HORIZONTAL) { + if (transY0 == transY1) { + // this represents the situation + // for drawing a horizontal bar. + drawLine(g2, state.workingLine, transY0, transX0, transY1, + transX1); + } + else { //this handles the need to perform a 'step'. + + // calculate the step point + double transXs = transX0 + (getStepPoint() + * (transX1 - transX0)); + drawLine(g2, state.workingLine, transY0, transX0, transY0, + transXs); + drawLine(g2, state.workingLine, transY0, transXs, transY1, + transXs); + drawLine(g2, state.workingLine, transY1, transXs, transY1, + transX1); + } + } + else if (orientation == PlotOrientation.VERTICAL) { + if (transY0 == transY1) { // this represents the situation + // for drawing a horizontal bar. + drawLine(g2, state.workingLine, transX0, transY0, transX1, + transY1); + } + else { //this handles the need to perform a 'step'. + // calculate the step point + double transXs = transX0 + (getStepPoint() + * (transX1 - transX0)); + drawLine(g2, state.workingLine, transX0, transY0, transXs, + transY0); + drawLine(g2, state.workingLine, transXs, transY0, transXs, + transY1); + drawLine(g2, state.workingLine, transXs, transY1, transX1, + transY1); + } + } + + // submit this data item as a candidate for the crosshair point + int domainAxisIndex = plot.getDomainAxisIndex(domainAxis); + int rangeAxisIndex = plot.getRangeAxisIndex(rangeAxis); + updateCrosshairValues(crosshairState, x1, y1, domainAxisIndex, + rangeAxisIndex, transX1, transY1, orientation); + + // collect entity and tool tip information... + EntityCollection entities = state.getEntityCollection(); + if (entities != null) { + addEntity(entities, null, dataset, series, item, transX1, + transY1); + } + + } + + if (pass == 1) { + // draw the item label if there is one... + if (isItemLabelVisible(series, item)) { + double xx = transX1; + double yy = transY1; + if (orientation == PlotOrientation.HORIZONTAL) { + xx = transY1; + yy = transX1; + } + drawItemLabel(g2, orientation, dataset, series, item, xx, yy, + (y1 < 0.0)); + } + } + } + + /** + * A utility method that draws a line but only if none of the coordinates + * are NaN values. + * + * @param g2 the graphics target. + * @param line the line object. + * @param x0 the x-coordinate for the starting point of the line. + * @param y0 the y-coordinate for the starting point of the line. + * @param x1 the x-coordinate for the ending point of the line. + * @param y1 the y-coordinate for the ending point of the line. + */ + private void drawLine(Graphics2D g2, Line2D line, double x0, double y0, + double x1, double y1) { + if (Double.isNaN(x0) || Double.isNaN(x1) || Double.isNaN(y0) + || Double.isNaN(y1)) { + return; + } + line.setLine(x0, y0, x1, y1); + g2.draw(line); + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYLineAndShapeRenderer)) { + return false; + } + XYStepRenderer that = (XYStepRenderer) obj; + if (this.stepPoint != that.stepPoint) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return HashUtilities.hashCode(super.hashCode(), this.stepPoint); + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/YIntervalRenderer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/YIntervalRenderer.java new file mode 100755 index 0000000..bbe1e52 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/YIntervalRenderer.java @@ -0,0 +1,318 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * YIntervalRenderer.java + * ---------------------- + * (C) Copyright 2002-2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Nov-2002 : Version 1 (DG); + * 25-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Modified drawItem() method signature (DG); + * 20-Aug-2003 : Implemented Cloneable and PublicCloneable (DG); + * 16-Sep-2003 : Changed ChartRenderingInfo --> PlotRenderingInfo (DG); + * 25-Feb-2004 : Replaced CrosshairInfo with CrosshairState (DG); + * 27-Sep-2004 : Access double values from dataset (DG); + * 11-Nov-2004 : Now uses ShapeUtilities to translate shapes (DG); + * 11-Apr-2008 : New override for findRangeBounds() (DG); + * 26-May-2008 : Added item label support (DG); + * 27-Mar-2009 : Updated findRangeBounds() (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Line2D; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.labels.XYItemLabelGenerator; +import org.jfree.chart.plot.CrosshairState; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.Range; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.text.TextUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * A renderer that draws a line connecting the start and end Y values for an + * {@link XYPlot}. The example shown here is generated by the + * YIntervalRendererDemo1.java program included in the JFreeChart + * demo collection: + *

+ * YIntervalRendererSample.png + */ +public class YIntervalRenderer extends AbstractXYItemRenderer + implements XYItemRenderer, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -2951586537224143260L; + + /** + * An additional item label generator. If this is non-null, the item + * label generated will be displayed near the lower y-value at the + * position given by getNegativeItemLabelPosition(). + * + * @since 1.0.10 + */ + private XYItemLabelGenerator additionalItemLabelGenerator; + + /** + * The default constructor. + */ + public YIntervalRenderer() { + super(); + this.additionalItemLabelGenerator = null; + } + + /** + * Returns the generator for the item labels that appear near the lower + * y-value. + * + * @return The generator (possibly null). + * + * @see #setAdditionalItemLabelGenerator(XYItemLabelGenerator) + * + * @since 1.0.10 + */ + public XYItemLabelGenerator getAdditionalItemLabelGenerator() { + return this.additionalItemLabelGenerator; + } + + /** + * Sets the generator for the item labels that appear near the lower + * y-value and sends a {@link RendererChangeEvent} to all registered + * listeners. If this is set to null, no item labels will be + * drawn. + * + * @param generator the generator (null permitted). + * + * @see #getAdditionalItemLabelGenerator() + * + * @since 1.0.10 + */ + public void setAdditionalItemLabelGenerator( + XYItemLabelGenerator generator) { + this.additionalItemLabelGenerator = generator; + fireChangeEvent(); + } + + /** + * Returns the range of values the renderer requires to display all the + * items from the specified dataset. + * + * @param dataset the dataset (null permitted). + * + * @return The range (null if the dataset is null + * or empty). + */ + @Override + public Range findRangeBounds(XYDataset dataset) { + return findRangeBounds(dataset, true); + } + + /** + * Draws the visual representation of a single data item. + * + * @param g2 the graphics device. + * @param state the renderer state. + * @param dataArea the area within which the plot is being drawn. + * @param info collects information about the drawing. + * @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 series the series index (zero-based). + * @param item the item index (zero-based). + * @param crosshairState crosshair information for the plot + * (null permitted). + * @param pass the pass index (ignored here). + */ + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, + Rectangle2D dataArea, PlotRenderingInfo info, XYPlot plot, + ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, + int series, int item, CrosshairState crosshairState, int pass) { + + // setup for collecting optional entity info... + EntityCollection entities = null; + if (info != null) { + entities = info.getOwner().getEntityCollection(); + } + + IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset; + + double x = intervalDataset.getXValue(series, item); + double yLow = intervalDataset.getStartYValue(series, item); + double yHigh = intervalDataset.getEndYValue(series, item); + + RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); + RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); + + double xx = domainAxis.valueToJava2D(x, dataArea, xAxisLocation); + double yyLow = rangeAxis.valueToJava2D(yLow, dataArea, yAxisLocation); + double yyHigh = rangeAxis.valueToJava2D(yHigh, dataArea, yAxisLocation); + + Paint p = getItemPaint(series, item); + Stroke s = getItemStroke(series, item); + + Line2D line = null; + Shape shape = getItemShape(series, item); + Shape top = null; + Shape bottom = null; + PlotOrientation orientation = plot.getOrientation(); + if (orientation == PlotOrientation.HORIZONTAL) { + line = new Line2D.Double(yyLow, xx, yyHigh, xx); + top = ShapeUtilities.createTranslatedShape(shape, yyHigh, xx); + bottom = ShapeUtilities.createTranslatedShape(shape, yyLow, xx); + } + else if (orientation == PlotOrientation.VERTICAL) { + line = new Line2D.Double(xx, yyLow, xx, yyHigh); + top = ShapeUtilities.createTranslatedShape(shape, xx, yyHigh); + bottom = ShapeUtilities.createTranslatedShape(shape, xx, yyLow); + } else { + throw new IllegalStateException(); + } + g2.setPaint(p); + g2.setStroke(s); + g2.draw(line); + + g2.fill(top); + g2.fill(bottom); + + // for item labels, we have a special case because there is the + // possibility to draw (a) the regular item label near to just the + // upper y-value, or (b) the regular item label near the upper y-value + // PLUS an additional item label near the lower y-value. + if (isItemLabelVisible(series, item)) { + drawItemLabel(g2, orientation, dataset, series, item, xx, yyHigh, + false); + drawAdditionalItemLabel(g2, orientation, dataset, series, item, + xx, yyLow); + } + + // add an entity for the item... + if (entities != null) { + addEntity(entities, line.getBounds(), dataset, series, item, 0.0, + 0.0); + } + + } + + /** + * Draws an item label. + * + * @param g2 the graphics device. + * @param orientation the orientation. + * @param dataset the dataset. + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * @param x the x coordinate (in Java2D space). + * @param y the y coordinate (in Java2D space). + */ + private void drawAdditionalItemLabel(Graphics2D g2, + PlotOrientation orientation, XYDataset dataset, int series, + int item, double x, double y) { + + if (this.additionalItemLabelGenerator == null) { + return; + } + + Font labelFont = getItemLabelFont(series, item); + Paint paint = getItemLabelPaint(series, item); + g2.setFont(labelFont); + g2.setPaint(paint); + String label = this.additionalItemLabelGenerator.generateLabel(dataset, + series, item); + + ItemLabelPosition position = getNegativeItemLabelPosition(series, item); + Point2D anchorPoint = calculateLabelAnchorPoint( + position.getItemLabelAnchor(), x, y, orientation); + TextUtilities.drawRotatedString(label, g2, + (float) anchorPoint.getX(), (float) anchorPoint.getY(), + position.getTextAnchor(), position.getAngle(), + position.getRotationAnchor()); + } + + /** + * Tests this renderer for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof YIntervalRenderer)) { + return false; + } + YIntervalRenderer that = (YIntervalRenderer) obj; + if (!ObjectUtilities.equal(this.additionalItemLabelGenerator, + that.additionalItemLabelGenerator)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of the renderer. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the renderer cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/package.html new file mode 100755 index 0000000..3b716fd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/renderer/xy/package.html @@ -0,0 +1,6 @@ + + + +Plug-in renderers for the {@link org.jfree.chart.plot.XYPlot} class. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/resources/JFreeChartResources.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/resources/JFreeChartResources.java new file mode 100755 index 0000000..12e1b50 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/resources/JFreeChartResources.java @@ -0,0 +1,65 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * JFreeChartResources.java + * ------------------------ + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + */ + +package org.jfree.chart.resources; + +import java.util.ListResourceBundle; + +/** + * Localised resources for JFreeChart. + */ +public class JFreeChartResources extends ListResourceBundle { + + /** + * Returns the array of strings in the resource bundle. + * + * @return The resources. + */ + @Override + public Object[][] getContents() { + return CONTENTS; + } + + /** The resources to be localised. */ + private static final Object[][] CONTENTS = { + {"project.name", "JFreeChart"}, + {"project.version", "1.0.17"}, + {"project.info", "http://www.jfree.org/jfreechart/index.html"}, + {"project.copyright", + "(C)opyright 2000-2013, by Object Refinery Limited and Contributors"} + }; + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/resources/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/resources/package.html new file mode 100755 index 0000000..6c8a912 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/resources/package.html @@ -0,0 +1,6 @@ + + + +Localised resources for the JFreeChart class library. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/servlet/ChartDeleter.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/servlet/ChartDeleter.java new file mode 100755 index 0000000..c3f9581 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/servlet/ChartDeleter.java @@ -0,0 +1,123 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * ChartDeleter.java + * ----------------- + * (C) Copyright 2002-2013, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): -; + * + * Changes + * ------- + * 19-Aug-2002 : Version 1; + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.servlet; + +import java.io.File; +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; + +import javax.servlet.http.HttpSessionBindingEvent; +import javax.servlet.http.HttpSessionBindingListener; + +/** + * Used for deleting charts from the temporary directory when the users session + * expires. + */ +public class ChartDeleter implements HttpSessionBindingListener, Serializable { + + /** The chart names. */ + private List chartNames = new java.util.ArrayList(); + + /** + * Blank constructor. + */ + public ChartDeleter() { + super(); + } + + /** + * Add a chart to be deleted when the session expires + * + * @param filename the name of the chart in the temporary directory to be + * deleted. + */ + public void addChart(String filename) { + this.chartNames.add(filename); + } + + /** + * Checks to see if a chart is in the list of charts to be deleted + * + * @param filename the name of the chart in the temporary directory. + * + * @return A boolean value indicating whether the chart is present in the + * list. + */ + public boolean isChartAvailable(String filename) { + return (this.chartNames.contains(filename)); + } + + /** + * Binding this object to the session has no additional effects. + * + * @param event the session bind event. + */ + @Override + public void valueBound(HttpSessionBindingEvent event) { + // nothing to do + } + + /** + * When this object is unbound from the session (including upon session + * expiry) the files that have been added to the ArrayList are iterated + * and deleted. + * + * @param event the session unbind event. + */ + @Override + public void valueUnbound(HttpSessionBindingEvent event) { + Iterator iter = this.chartNames.listIterator(); + while (iter.hasNext()) { + String filename = (String) iter.next(); + File file = new File( + System.getProperty("java.io.tmpdir"), filename + ); + if (file.exists()) { + file.delete(); + } + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/servlet/DisplayChart.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/servlet/DisplayChart.java new file mode 100755 index 0000000..50f8a29 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/servlet/DisplayChart.java @@ -0,0 +1,157 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * DisplayChart.java + * ----------------- + * (C) Copyright 2002-2013, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 19-Aug-2002 : Version 1; + * 09-Mar-2005 : Added facility to serve up "one time" charts - see + * ServletUtilities.java (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 03-Dec-2011 : Fixed path disclosure vulnerability - see bug 2879650 (DG); + * + */ + +package org.jfree.chart.servlet; + +import java.io.File; +import java.io.IOException; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +/** + * Servlet used for streaming charts to the client browser from the temporary + * directory. You need to add this servlet and mapping to your deployment + * descriptor (web.xml) in order to get it to work. The syntax is as follows: + *

+ * <servlet> + * <servlet-name>DisplayChart</servlet-name> + * <servlet-class>org.jfree.chart.servlet.DisplayChart</servlet-class> + * </servlet> + * <servlet-mapping> + * <servlet-name>DisplayChart</servlet-name> + * <url-pattern>/servlet/DisplayChart</url-pattern> + * </servlet-mapping> + * + */ +public class DisplayChart extends HttpServlet { + + /** + * Default constructor. + */ + public DisplayChart() { + super(); + } + + /** + * Init method. + * + * @throws ServletException never. + */ + @Override + public void init() throws ServletException { + // nothing to do + } + + /** + * Service method. + * + * @param request the request. + * @param response the response. + * + * @throws ServletException ??. + * @throws IOException ??. + */ + @Override + public void service(HttpServletRequest request, + HttpServletResponse response) + throws ServletException, IOException { + + HttpSession session = request.getSession(); + String filename = request.getParameter("filename"); + + if (filename == null) { + throw new ServletException("Parameter 'filename' must be supplied"); + } + + // Replace ".." with "" + // This is to prevent access to the rest of the file system + filename = ServletUtilities.searchReplace(filename, "..", ""); + + // Check the file exists + File file = new File(System.getProperty("java.io.tmpdir"), filename); + if (!file.exists()) { + throw new ServletException( + "Unable to display the chart with the filename '" + + filename + "'."); + } + + // Check that the graph being served was created by the current user + // or that it begins with "public" + boolean isChartInUserList = false; + ChartDeleter chartDeleter = (ChartDeleter) session.getAttribute( + "JFreeChart_Deleter"); + if (chartDeleter != null) { + isChartInUserList = chartDeleter.isChartAvailable(filename); + } + + boolean isChartPublic = false; + if (filename.length() >= 6) { + if (filename.substring(0, 6).equals("public")) { + isChartPublic = true; + } + } + + boolean isOneTimeChart = false; + if (filename.startsWith(ServletUtilities.getTempOneTimeFilePrefix())) { + isOneTimeChart = true; + } + + if (isChartInUserList || isChartPublic || isOneTimeChart) { + // Serve it up + ServletUtilities.sendTempFile(file, response); + if (isOneTimeChart) { + file.delete(); + } + } + else { + throw new ServletException("Chart image not found"); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/servlet/ServletUtilities.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/servlet/ServletUtilities.java new file mode 100755 index 0000000..f37d985 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/servlet/ServletUtilities.java @@ -0,0 +1,432 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * ServletUtilities.java + * --------------------- + * (C) Copyright 2002-2013, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): J?rgen Hoffman; + * David Gilbert (for Object Refinery Limited); + * Douglas Clayton; + * + * Changes + * ------- + * 19-Aug-2002 : Version 1; + * 20-Apr-2003 : Added additional sendTempFile method to allow MIME type + * specification and modified original sendTempFile method to + * automatically set MIME type for JPEG and PNG files + * 23-Jun-2003 : Added additional sendTempFile method at the request of + * J?rgen Hoffman; + * 07-Jul-2003 : Added more header information to streamed images; + * 19-Aug-2003 : Forced images to be stored in the temporary directory defined + * by System property java.io.tmpdir, rather than default (RA); + * 24-Mar-2004 : Added temp filename prefix attribute (DG); + * 09-Mar-2005 : Added "one time" file option (DG); + * ------------- JFREECHART 1.0.x RELEASED ------------------------------------ + * 10-Jan-2006 : Updated API docs and reformatted (DG); + * 13-Sep-2006 : Format date in response header in English, not locale default + * (see bug 1557141) (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.servlet; + +import java.io.BufferedInputStream; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +import javax.servlet.http.HttpServletResponse; +import javax.servlet.http.HttpSession; + +import org.jfree.chart.ChartRenderingInfo; +import org.jfree.chart.ChartUtilities; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.util.ParamChecks; + +/** + * Utility class used for servlet related JFreeChart operations. + */ +public class ServletUtilities { + + /** The filename prefix. */ + private static String tempFilePrefix = "jfreechart-"; + + /** A prefix for "one time" charts. */ + private static String tempOneTimeFilePrefix = "jfreechart-onetime-"; + + /** + * Returns the prefix for the temporary file names generated by this class. + * + * @return The prefix (never null). + */ + public static String getTempFilePrefix() { + return ServletUtilities.tempFilePrefix; + } + + /** + * Sets the prefix for the temporary file names generated by this class. + * + * @param prefix the prefix (null not permitted). + */ + public static void setTempFilePrefix(String prefix) { + ParamChecks.nullNotPermitted(prefix, "prefix"); + ServletUtilities.tempFilePrefix = prefix; + } + + /** + * Returns the prefix for "one time" temporary file names generated by + * this class. + * + * @return The prefix. + */ + public static String getTempOneTimeFilePrefix() { + return ServletUtilities.tempOneTimeFilePrefix; + } + + /** + * Sets the prefix for the "one time" temporary file names generated by + * this class. + * + * @param prefix the prefix (null not permitted). + */ + public static void setTempOneTimeFilePrefix(String prefix) { + ParamChecks.nullNotPermitted(prefix, "prefix"); + ServletUtilities.tempOneTimeFilePrefix = prefix; + } + + /** + * Saves the chart as a PNG format file in the temporary directory. + * + * @param chart the JFreeChart to be saved. + * @param width the width of the chart. + * @param height the height of the chart. + * @param session the HttpSession of the client (if null, the + * temporary file is marked as "one-time" and deleted by + * the {@link DisplayChart} servlet right after it is + * streamed to the client). + * + * @return The filename of the chart saved in the temporary directory. + * + * @throws IOException if there is a problem saving the file. + */ + public static String saveChartAsPNG(JFreeChart chart, int width, int height, + HttpSession session) throws IOException { + + return ServletUtilities.saveChartAsPNG(chart, width, height, null, + session); + + } + + /** + * Saves the chart as a PNG format file in the temporary directory and + * populates the {@link ChartRenderingInfo} object which can be used to + * generate an HTML image map. + * + * @param chart the chart to be saved (null not permitted). + * @param width the width of the chart. + * @param height the height of the chart. + * @param info the ChartRenderingInfo object to be populated + * (null permitted). + * @param session the HttpSession of the client (if null, the + * temporary file is marked as "one-time" and deleted by + * the {@link DisplayChart} servlet right after it is + * streamed to the client). + * + * @return The filename of the chart saved in the temporary directory. + * + * @throws IOException if there is a problem saving the file. + */ + public static String saveChartAsPNG(JFreeChart chart, int width, int height, + ChartRenderingInfo info, HttpSession session) throws IOException { + + ParamChecks.nullNotPermitted(chart, "chart"); + ServletUtilities.createTempDir(); + String prefix = ServletUtilities.tempFilePrefix; + if (session == null) { + prefix = ServletUtilities.tempOneTimeFilePrefix; + } + File tempFile = File.createTempFile(prefix, ".png", + new File(System.getProperty("java.io.tmpdir"))); + ChartUtilities.saveChartAsPNG(tempFile, chart, width, height, info); + if (session != null) { + ServletUtilities.registerChartForDeletion(tempFile, session); + } + return tempFile.getName(); + + } + + /** + * Saves the chart as a JPEG format file in the temporary directory. + *

+ * SPECIAL NOTE: Please avoid using JPEG as an image format for charts, + * it is a "lossy" format that introduces visible distortions in the + * resulting image - use PNG instead. In addition, note that JPEG output + * is supported by JFreeChart only for JRE 1.4.2 or later. + * + * @param chart the JFreeChart to be saved. + * @param width the width of the chart. + * @param height the height of the chart. + * @param session the HttpSession of the client (if null, the + * temporary file is marked as "one-time" and deleted by + * the {@link DisplayChart} servlet right after it is + * streamed to the client). + * + * @return The filename of the chart saved in the temporary directory. + * + * @throws IOException if there is a problem saving the file. + */ + public static String saveChartAsJPEG(JFreeChart chart, int width, + int height, HttpSession session) + throws IOException { + + return ServletUtilities.saveChartAsJPEG(chart, width, height, null, + session); + + } + + /** + * Saves the chart as a JPEG format file in the temporary directory and + * populates the ChartRenderingInfo object which can be used + * to generate an HTML image map. + *

+ * SPECIAL NOTE: Please avoid using JPEG as an image format for charts, + * it is a "lossy" format that introduces visible distortions in the + * resulting image - use PNG instead. In addition, note that JPEG output + * is supported by JFreeChart only for JRE 1.4.2 or later. + * + * @param chart the chart to be saved (null not permitted). + * @param width the width of the chart + * @param height the height of the chart + * @param info the ChartRenderingInfo object to be populated + * @param session the HttpSession of the client (if null, the + * temporary file is marked as "one-time" and deleted by + * the {@link DisplayChart} servlet right after it is + * streamed to the client). + * + * @return The filename of the chart saved in the temporary directory + * + * @throws IOException if there is a problem saving the file. + */ + public static String saveChartAsJPEG(JFreeChart chart, int width, + int height, ChartRenderingInfo info, HttpSession session) + throws IOException { + + ParamChecks.nullNotPermitted(chart, "chart"); + ServletUtilities.createTempDir(); + String prefix = ServletUtilities.tempFilePrefix; + if (session == null) { + prefix = ServletUtilities.tempOneTimeFilePrefix; + } + File tempFile = File.createTempFile(prefix, ".jpeg", + new File(System.getProperty("java.io.tmpdir"))); + ChartUtilities.saveChartAsJPEG(tempFile, chart, width, height, info); + if (session != null) { + ServletUtilities.registerChartForDeletion(tempFile, session); + } + return tempFile.getName(); + + } + + /** + * Creates the temporary directory if it does not exist. Throws a + * RuntimeException if the temporary directory is + * null. Uses the system property java.io.tmpdir + * as the temporary directory. This sounds like a strange thing to do but + * my temporary directory was not created on my default Tomcat 4.0.3 + * installation. Could save some questions on the forum if it is created + * when not present. + */ + protected static void createTempDir() { + String tempDirName = System.getProperty("java.io.tmpdir"); + if (tempDirName == null) { + throw new RuntimeException("Temporary directory system property " + + "(java.io.tmpdir) is null."); + } + + // create the temporary directory if it doesn't exist + File tempDir = new File(tempDirName); + if (!tempDir.exists()) { + tempDir.mkdirs(); + } + } + + /** + * Adds a {@link ChartDeleter} object to the session object with the name + * JFreeChart_Deleter if there is not already one bound to the + * session and adds the filename to the list of charts to be deleted. + * + * @param tempFile the file to be deleted. + * @param session the HTTP session of the client. + */ + protected static void registerChartForDeletion(File tempFile, + HttpSession session) { + + // Add chart to deletion list in session + if (session != null) { + ChartDeleter chartDeleter + = (ChartDeleter) session.getAttribute("JFreeChart_Deleter"); + if (chartDeleter == null) { + chartDeleter = new ChartDeleter(); + session.setAttribute("JFreeChart_Deleter", chartDeleter); + } + chartDeleter.addChart(tempFile.getName()); + } + else { + System.out.println("Session is null - chart will not be deleted"); + } + } + + /** + * Binary streams the specified file in the temporary directory to the + * HTTP response in 1KB chunks. + * + * @param filename the name of the file in the temporary directory. + * @param response the HTTP response object. + * + * @throws IOException if there is an I/O problem. + */ + public static void sendTempFile(String filename, + HttpServletResponse response) throws IOException { + + File file = new File(System.getProperty("java.io.tmpdir"), filename); + ServletUtilities.sendTempFile(file, response); + } + + /** + * Binary streams the specified file to the HTTP response in 1KB chunks. + * + * @param file the file to be streamed. + * @param response the HTTP response object. + * + * @throws IOException if there is an I/O problem. + */ + public static void sendTempFile(File file, HttpServletResponse response) + throws IOException { + + String mimeType = null; + String filename = file.getName(); + if (filename.length() > 5) { + if (filename.substring(filename.length() - 5, + filename.length()).equals(".jpeg")) { + mimeType = "image/jpeg"; + } + else if (filename.substring(filename.length() - 4, + filename.length()).equals(".png")) { + mimeType = "image/png"; + } + } + ServletUtilities.sendTempFile(file, response, mimeType); + } + + /** + * Binary streams the specified file to the HTTP response in 1KB chunks. + * + * @param file the file to be streamed. + * @param response the HTTP response object. + * @param mimeType the mime type of the file, null allowed. + * + * @throws IOException if there is an I/O problem. + */ + public static void sendTempFile(File file, HttpServletResponse response, + String mimeType) throws IOException { + + if (file.exists()) { + BufferedInputStream bis = new BufferedInputStream( + new FileInputStream(file)); + + // Set HTTP headers + if (mimeType != null) { + response.setHeader("Content-Type", mimeType); + } + response.setHeader("Content-Length", String.valueOf(file.length())); + SimpleDateFormat sdf = new SimpleDateFormat( + "EEE, dd MMM yyyy HH:mm:ss z", Locale.ENGLISH); + sdf.setTimeZone(TimeZone.getTimeZone("GMT")); + response.setHeader("Last-Modified", + sdf.format(new Date(file.lastModified()))); + + BufferedOutputStream bos = new BufferedOutputStream( + response.getOutputStream()); + byte[] input = new byte[1024]; + boolean eof = false; + while (!eof) { + int length = bis.read(input); + if (length == -1) { + eof = true; + } + else { + bos.write(input, 0, length); + } + } + bos.flush(); + bis.close(); + bos.close(); + } + else { + throw new FileNotFoundException(file.getAbsolutePath()); + } + } + + /** + * Perform a search/replace operation on a String + * There are String methods to do this since (JDK 1.4) + * + * @param inputString the String to have the search/replace operation. + * @param searchString the search String. + * @param replaceString the replace String. + * + * @return The String with the replacements made. + */ + public static String searchReplace(String inputString, + String searchString, + String replaceString) { + + int i = inputString.indexOf(searchString); + if (i == -1) { + return inputString; + } + + String r = ""; + r += inputString.substring(0, i) + replaceString; + if (i + searchString.length() < inputString.length()) { + r += searchReplace(inputString.substring(i + searchString.length()), + searchString, replaceString); + } + + return r; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/servlet/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/servlet/package.html new file mode 100755 index 0000000..9dc5e06 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/servlet/package.html @@ -0,0 +1,6 @@ + + + +Classes for providing useful servlet and JSP functionality. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/CompositeTitle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/CompositeTitle.java new file mode 100755 index 0000000..72aa2b7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/CompositeTitle.java @@ -0,0 +1,250 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * CompositeTitle.java + * ------------------- + * (C) Copyright 2005-2013, by David Gilbert and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Eric Penfold (patch 2006826); + * + * Changes + * ------- + * 19-Nov-2004 : Version 1 (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); + * 04-Feb-2005 : Implemented MAXIMUM_WIDTH in calculateSize (DG); + * 20-Apr-2005 : Added new draw() method (DG); + * 03-May-2005 : Implemented equals() method (DG); + * 02-Jul-2008 : Applied patch 2006826 by Eric Penfold, to enable chart + * entities to be generated (DG); + * 09-Jul-2008 : Added backgroundPaint field (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.title; + +import java.awt.Graphics2D; +import java.awt.Paint; +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.block.BlockContainer; +import org.jfree.chart.block.BorderArrangement; +import org.jfree.chart.block.RectangleConstraint; +import org.jfree.chart.event.TitleChangeEvent; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.Size2D; +import org.jfree.util.PaintUtilities; + +/** + * A title that contains multiple titles within a {@link BlockContainer}. + */ +public class CompositeTitle extends Title implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -6770854036232562290L; + + /** + * The background paint. + * + * @since 1.0.11 + */ + private transient Paint backgroundPaint; + + /** A container for the individual titles. */ + private BlockContainer container; + + /** + * Creates a new composite title with a default border arrangement. + */ + public CompositeTitle() { + this(new BlockContainer(new BorderArrangement())); + } + + /** + * Creates a new title using the specified container. + * + * @param container the container (null not permitted). + */ + public CompositeTitle(BlockContainer container) { + ParamChecks.nullNotPermitted(container, "container"); + this.container = container; + this.backgroundPaint = null; + } + + /** + * Returns the background paint. + * + * @return The paint (possibly null). + * + * @since 1.0.11 + */ + public Paint getBackgroundPaint() { + return this.backgroundPaint; + } + + /** + * Sets the background paint and sends a {@link TitleChangeEvent} to all + * registered listeners. If you set this attribute to null, + * no background is painted (which makes the title background transparent). + * + * @param paint the background paint (null permitted). + * + * @since 1.0.11 + */ + public void setBackgroundPaint(Paint paint) { + this.backgroundPaint = paint; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the container holding the titles. + * + * @return The title container (never null). + */ + public BlockContainer getContainer() { + return this.container; + } + + /** + * Sets the title container. + * + * @param container the container (null not permitted). + */ + public void setTitleContainer(BlockContainer container) { + ParamChecks.nullNotPermitted(container, "container"); + this.container = container; + } + + /** + * Arranges the contents of the block, within the given constraints, and + * returns the block size. + * + * @param g2 the graphics device. + * @param constraint the constraint (null not permitted). + * + * @return The block size (in Java2D units, never null). + */ + @Override + public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { + RectangleConstraint contentConstraint = toContentConstraint(constraint); + Size2D contentSize = this.container.arrange(g2, contentConstraint); + return new Size2D(calculateTotalWidth(contentSize.getWidth()), + calculateTotalHeight(contentSize.getHeight())); + } + + /** + * Draws the title on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device. + * @param area the area allocated for the title. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + draw(g2, area, null); + } + + /** + * Draws the block within the specified area. + * + * @param g2 the graphics device. + * @param area the area. + * @param params ignored (null permitted). + * + * @return Always null. + */ + @Override + public Object draw(Graphics2D g2, Rectangle2D area, Object params) { + area = trimMargin(area); + drawBorder(g2, area); + area = trimBorder(area); + if (this.backgroundPaint != null) { + g2.setPaint(this.backgroundPaint); + g2.fill(area); + } + area = trimPadding(area); + return this.container.draw(g2, area, params); + } + + /** + * Tests this title for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CompositeTitle)) { + return false; + } + CompositeTitle that = (CompositeTitle) obj; + if (!this.container.equals(that.container)) { + return false; + } + if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { + return false; + } + return super.equals(obj); + } + + /** + * 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.backgroundPaint, 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.backgroundPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/DateTitle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/DateTitle.java new file mode 100755 index 0000000..4ff36e9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/DateTitle.java @@ -0,0 +1,178 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * DateTitle.java + * -------------- + * (C) Copyright 2000-2008, by David Berry and Contributors. + * + * Original Author: David Berry; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes (from 18-Sep-2001) + * -------------------------- + * 18-Sep-2001 : Added standard header (DG); + * 09-Jan-2002 : Updated Javadoc comments (DG); + * 07-Feb-2002 : Changed blank space around title from Insets --> Spacer, to + * allow for relative or absolute spacing (DG); + * 26-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 31-Jan-2005 : Updated for changes to super class (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.title; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Paint; +import java.io.Serializable; +import java.text.DateFormat; +import java.util.Date; +import java.util.Locale; + +import org.jfree.ui.HorizontalAlignment; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.VerticalAlignment; + +/** + * A chart title that displays the date. + *

+ * Keep in mind that a chart can have several titles, and that they can appear + * at the top, left, right or bottom of the chart - a DateTitle + * will commonly appear at the bottom of a chart, although you can place it + * anywhere. + *

+ * By specifying the locale, dates are formatted to the correct standard for + * the given locale. For example, a date would appear as "January 17, 2000" in + * the US, but "17 January 2000" in most European locales. + */ +public class DateTitle extends TextTitle implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -465434812763159881L; + + /** + * Creates a new chart title that displays the current date in the default + * (LONG) format for the locale, positioned to the bottom right of the + * chart. + *

+ * The color will be black in 12 point, plain Helvetica font (maps to Arial + * on Win32 systems without Helvetica). + */ + public DateTitle() { + this(DateFormat.LONG); + } + + /** + * Creates a new chart title that displays the current date with the + * specified style (for the default locale). + *

+ * The date style should be one of: SHORT, + * MEDIUM, LONG or FULL + * (defined in java.util.DateFormat). + * + * @param style the date style. + */ + public DateTitle(int style) { + this(style, Locale.getDefault(), new Font("Dialog", Font.PLAIN, 12), + Color.black); + } + + /** + * Creates a new chart title that displays the current date. + *

+ * The date style should be one of: SHORT, + * MEDIUM, LONG or FULL (defined + * in java.util.DateFormat). + *

+ * For the locale, you can use Locale.getDefault() for the + * default locale. + * + * @param style the date style. + * @param locale the locale. + * @param font the font. + * @param paint the text color. + */ + public DateTitle(int style, Locale locale, Font font, Paint paint) { + this(style, locale, font, paint, RectangleEdge.BOTTOM, + HorizontalAlignment.RIGHT, VerticalAlignment.CENTER, + Title.DEFAULT_PADDING); + } + + /** + * Creates a new chart title that displays the current date. + *

+ * The date style should be one of: SHORT, + * MEDIUM, LONG or FULL (defined + * in java.util.DateFormat). + *

+ * For the locale, you can use Locale.getDefault() for the + * default locale. + * + * @param style the date style. + * @param locale the locale. + * @param font the font (not null). + * @param paint the text color (not null). + * @param position the relative location of this title (use constants in + * Title). + * @param horizontalAlignment the horizontal text alignment of this title + * (use constants in Title). + * @param verticalAlignment the vertical text alignment of this title (use + * constants in Title). + * @param padding determines the blank space around the outside of the + * title (not null). + */ + public DateTitle(int style, Locale locale, Font font, Paint paint, + RectangleEdge position, + HorizontalAlignment horizontalAlignment, + VerticalAlignment verticalAlignment, + RectangleInsets padding) { + super(DateFormat.getDateInstance(style, locale).format(new Date()), + font, paint, position, horizontalAlignment, verticalAlignment, + padding); + } + + /** + * Set the format of the date. + *

+ * The date style should be one of: SHORT, + * MEDIUM, LONG or FULL (defined + * in java.util.DateFormat). + *

+ * For the locale, you can use Locale.getDefault() for the + * default locale. + * + * @param style the date style. + * @param locale the locale. + */ + public void setDateFormat(int style, Locale locale) { + setText(DateFormat.getDateInstance(style, locale).format(new Date())); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/ImageTitle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/ImageTitle.java new file mode 100755 index 0000000..7e4ea79 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/ImageTitle.java @@ -0,0 +1,368 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * ImageTitle.java + * --------------- + * (C) Copyright 2000-2008, by David Berry and Contributors; + * + * Original Author: David Berry; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes (from 18-Sep-2001) + * -------------------------- + * 18-Sep-2001 : Added standard header (DG); + * 07-Nov-2001 : Separated the JCommon Class Library classes, JFreeChart now + * requires jcommon.jar (DG); + * 09-Jan-2002 : Updated Javadoc comments (DG); + * 07-Feb-2002 : Changed blank space around title from Insets --> Spacer, to + * allow for relative or absolute spacing (DG); + * 25-Jun-2002 : Updated import statements (DG); + * 23-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 26-Nov-2002 : Added method for drawing images at left or right (DG); + * 22-Sep-2003 : Added checks that the Image can never be null (TM). + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * 02-Feb-2005 : Changed padding mechanism for all titles (DG); + * 20-Apr-2005 : Added new draw() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 11-Apr-2008 : Added arrange() method override to account for margin, border + * and padding (DG); + * 21-Apr-2008 : Added equals() method override (DG); + * + */ + +package org.jfree.chart.title; + +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.block.RectangleConstraint; +import org.jfree.chart.event.TitleChangeEvent; +import org.jfree.ui.HorizontalAlignment; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.Size2D; +import org.jfree.ui.VerticalAlignment; +import org.jfree.util.ObjectUtilities; + +/** + * A chart title that displays an image. This is useful, for example, if you + * have an image of your corporate logo and want to use as a footnote or part + * of a title in a chart you create. + *

+ * ImageTitle needs an image passed to it in the constructor. For ImageTitle + * to work, you must have already loaded this image from its source (disk or + * URL). It is recommended you use something like + * Toolkit.getDefaultToolkit().getImage() to get the image. Then, use + * MediaTracker or some other message to make sure the image is fully loaded + * from disk. + *

+ * SPECIAL NOTE: this class fails to serialize, so if you are + * relying on your charts to be serializable, please avoid using this class. + */ +public class ImageTitle extends Title { + + /** The title image. */ + private Image image; + + /** + * Creates a new image title. + * + * @param image the image (null not permitted). + */ + public ImageTitle(Image image) { + this(image, image.getHeight(null), image.getWidth(null), + Title.DEFAULT_POSITION, Title.DEFAULT_HORIZONTAL_ALIGNMENT, + Title.DEFAULT_VERTICAL_ALIGNMENT, Title.DEFAULT_PADDING); + } + + /** + * Creates a new image title. + * + * @param image the image (null not permitted). + * @param position the title position. + * @param horizontalAlignment the horizontal alignment. + * @param verticalAlignment the vertical alignment. + */ + public ImageTitle(Image image, RectangleEdge position, + HorizontalAlignment horizontalAlignment, + VerticalAlignment verticalAlignment) { + + this(image, image.getHeight(null), image.getWidth(null), + position, horizontalAlignment, verticalAlignment, + Title.DEFAULT_PADDING); + } + + /** + * Creates a new image title with the given image scaled to the given + * width and height in the given location. + * + * @param image the image (null not permitted). + * @param height the height used to draw the image. + * @param width the width used to draw the image. + * @param position the title position. + * @param horizontalAlignment the horizontal alignment. + * @param verticalAlignment the vertical alignment. + * @param padding the amount of space to leave around the outside of the + * title. + */ + public ImageTitle(Image image, int height, int width, + RectangleEdge position, + HorizontalAlignment horizontalAlignment, + VerticalAlignment verticalAlignment, + RectangleInsets padding) { + + super(position, horizontalAlignment, verticalAlignment, padding); + if (image == null) { + throw new NullPointerException("Null 'image' argument."); + } + this.image = image; + setHeight(height); + setWidth(width); + + } + + /** + * Returns the image for the title. + * + * @return The image for the title (never null). + */ + public Image getImage() { + return this.image; + } + + /** + * Sets the image for the title and notifies registered listeners that the + * title has been modified. + * + * @param image the new image (null not permitted). + */ + public void setImage(Image image) { + if (image == null) { + throw new NullPointerException("Null 'image' argument."); + } + this.image = image; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Arranges the contents of the block, within the given constraints, and + * returns the block size. + * + * @param g2 the graphics device. + * @param constraint the constraint (null not permitted). + * + * @return The block size (in Java2D units, never null). + */ + @Override + public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { + Size2D s = new Size2D(this.image.getWidth(null), + this.image.getHeight(null)); + return new Size2D(calculateTotalWidth(s.getWidth()), + calculateTotalHeight(s.getHeight())); + } + + /** + * Draws the title on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device. + * @param area the area allocated for the title. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + RectangleEdge position = getPosition(); + if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) { + drawHorizontal(g2, area); + } + else if (position == RectangleEdge.LEFT + || position == RectangleEdge.RIGHT) { + drawVertical(g2, area); + } + else { + throw new RuntimeException("Invalid title position."); + } + } + + /** + * Draws the title on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device. + * @param chartArea the area within which the title (and plot) should be + * drawn. + * + * @return The size of the area used by the title. + */ + protected Size2D drawHorizontal(Graphics2D g2, Rectangle2D chartArea) { + double startY; + double topSpace; + double bottomSpace; + double leftSpace; + double rightSpace; + + double w = getWidth(); + double h = getHeight(); + RectangleInsets padding = getPadding(); + topSpace = padding.calculateTopOutset(h); + bottomSpace = padding.calculateBottomOutset(h); + leftSpace = padding.calculateLeftOutset(w); + rightSpace = padding.calculateRightOutset(w); + + if (getPosition() == RectangleEdge.TOP) { + startY = chartArea.getY() + topSpace; + } + else { + startY = chartArea.getY() + chartArea.getHeight() - bottomSpace - h; + } + + // what is our alignment? + HorizontalAlignment horizontalAlignment = getHorizontalAlignment(); + double startX = 0.0; + if (horizontalAlignment == HorizontalAlignment.CENTER) { + startX = chartArea.getX() + leftSpace + chartArea.getWidth() / 2.0 + - w / 2.0; + } + else if (horizontalAlignment == HorizontalAlignment.LEFT) { + startX = chartArea.getX() + leftSpace; + } + else if (horizontalAlignment == HorizontalAlignment.RIGHT) { + startX = chartArea.getX() + chartArea.getWidth() - rightSpace - w; + } + g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h, + null); + + return new Size2D(chartArea.getWidth() + leftSpace + rightSpace, + h + topSpace + bottomSpace); + + } + + /** + * Draws the title on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device. + * @param chartArea the area within which the title (and plot) should be + * drawn. + * + * @return The size of the area used by the title. + */ + protected Size2D drawVertical(Graphics2D g2, Rectangle2D chartArea) { + + double startX; + double topSpace = 0.0; + double bottomSpace = 0.0; + double leftSpace = 0.0; + double rightSpace = 0.0; + + double w = getWidth(); + double h = getHeight(); + + RectangleInsets padding = getPadding(); + if (padding != null) { + topSpace = padding.calculateTopOutset(h); + bottomSpace = padding.calculateBottomOutset(h); + leftSpace = padding.calculateLeftOutset(w); + rightSpace = padding.calculateRightOutset(w); + } + + if (getPosition() == RectangleEdge.LEFT) { + startX = chartArea.getX() + leftSpace; + } + else { + startX = chartArea.getMaxX() - rightSpace - w; + } + + // what is our alignment? + VerticalAlignment alignment = getVerticalAlignment(); + double startY = 0.0; + if (alignment == VerticalAlignment.CENTER) { + startY = chartArea.getMinY() + topSpace + + chartArea.getHeight() / 2.0 - h / 2.0; + } + else if (alignment == VerticalAlignment.TOP) { + startY = chartArea.getMinY() + topSpace; + } + else if (alignment == VerticalAlignment.BOTTOM) { + startY = chartArea.getMaxY() - bottomSpace - h; + } + + g2.drawImage(this.image, (int) startX, (int) startY, (int) w, (int) h, + null); + + return new Size2D(chartArea.getWidth() + leftSpace + rightSpace, + h + topSpace + bottomSpace); + + } + + /** + * Draws the block within the specified area. + * + * @param g2 the graphics device. + * @param area the area. + * @param params ignored (null permitted). + * + * @return Always null. + */ + @Override + public Object draw(Graphics2D g2, Rectangle2D area, Object params) { + draw(g2, area); + return null; + } + + /** + * Tests this ImageTitle for equality with an arbitrary + * object. Returns true if: + *

    + *
  • obj is an instance of ImageTitle; + *
  • obj references the same image as this + * ImageTitle; + *
  • super.equals(obj) returns true; + *
+ * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ImageTitle)) { + return false; + } + ImageTitle that = (ImageTitle) obj; + if (!ObjectUtilities.equal(this.image, that.image)) { + return false; + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/LegendGraphic.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/LegendGraphic.java new file mode 100755 index 0000000..1738601 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/LegendGraphic.java @@ -0,0 +1,756 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * LegendGraphic.java + * ------------------ + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Oct-2004 : Version 1 (DG); + * 21-Jan-2005 : Modified return type of RectangleAnchor.coordinates() + * method (DG); + * 20-Apr-2005 : Added new draw() method (DG); + * 13-May-2005 : Fixed to respect margin, border and padding settings (DG); + * 01-Sep-2005 : Implemented PublicCloneable (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 13-Dec-2006 : Added fillPaintTransformer attribute, so legend graphics can + * display gradient paint correctly, updated equals() and + * corrected clone() (DG); + * 01-Aug-2007 : Updated API docs (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.title; + +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; + +import org.jfree.chart.block.AbstractBlock; +import org.jfree.chart.block.Block; +import org.jfree.chart.block.LengthConstraintType; +import org.jfree.chart.block.RectangleConstraint; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.Size2D; +import org.jfree.ui.StandardGradientPaintTransformer; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.ShapeUtilities; + +/** + * The graphical item within a legend item. + */ +public class LegendGraphic extends AbstractBlock + implements Block, PublicCloneable { + + /** For serialization. */ + static final long serialVersionUID = -1338791523854985009L; + + /** + * A flag that controls whether or not the shape is visible - see also + * lineVisible. + */ + private boolean shapeVisible; + + /** + * The shape to display. To allow for accurate positioning, the center + * of the shape should be at (0, 0). + */ + private transient Shape shape; + + /** + * Defines the location within the block to which the shape will be aligned. + */ + private RectangleAnchor shapeLocation; + + /** + * Defines the point on the shape's bounding rectangle that will be + * aligned to the drawing location when the shape is rendered. + */ + private RectangleAnchor shapeAnchor; + + /** A flag that controls whether or not the shape is filled. */ + private boolean shapeFilled; + + /** The fill paint for the shape. */ + private transient Paint fillPaint; + + /** + * The fill paint transformer (used if the fillPaint is an instance of + * GradientPaint). + * + * @since 1.0.4 + */ + private GradientPaintTransformer fillPaintTransformer; + + /** A flag that controls whether or not the shape outline is visible. */ + private boolean shapeOutlineVisible; + + /** The outline paint for the shape. */ + private transient Paint outlinePaint; + + /** The outline stroke for the shape. */ + private transient Stroke outlineStroke; + + /** + * A flag that controls whether or not the line is visible - see also + * shapeVisible. + */ + private boolean lineVisible; + + /** The line. */ + private transient Shape line; + + /** The line stroke. */ + private transient Stroke lineStroke; + + /** The line paint. */ + private transient Paint linePaint; + + /** + * Creates a new legend graphic. + * + * @param shape the shape (null not permitted). + * @param fillPaint the fill paint (null not permitted). + */ + public LegendGraphic(Shape shape, Paint fillPaint) { + ParamChecks.nullNotPermitted(shape, "shape"); + ParamChecks.nullNotPermitted(fillPaint, "fillPaint"); + this.shapeVisible = true; + this.shape = shape; + this.shapeAnchor = RectangleAnchor.CENTER; + this.shapeLocation = RectangleAnchor.CENTER; + this.shapeFilled = true; + this.fillPaint = fillPaint; + this.fillPaintTransformer = new StandardGradientPaintTransformer(); + setPadding(2.0, 2.0, 2.0, 2.0); + } + + /** + * Returns a flag that controls whether or not the shape + * is visible. + * + * @return A boolean. + * + * @see #setShapeVisible(boolean) + */ + public boolean isShapeVisible() { + return this.shapeVisible; + } + + /** + * Sets a flag that controls whether or not the shape is + * visible. + * + * @param visible the flag. + * + * @see #isShapeVisible() + */ + public void setShapeVisible(boolean visible) { + this.shapeVisible = visible; + } + + /** + * Returns the shape. + * + * @return The shape. + * + * @see #setShape(Shape) + */ + public Shape getShape() { + return this.shape; + } + + /** + * Sets the shape. + * + * @param shape the shape. + * + * @see #getShape() + */ + public void setShape(Shape shape) { + this.shape = shape; + } + + /** + * Returns a flag that controls whether or not the shapes + * are filled. + * + * @return A boolean. + * + * @see #setShapeFilled(boolean) + */ + public boolean isShapeFilled() { + return this.shapeFilled; + } + + /** + * Sets a flag that controls whether or not the shape is + * filled. + * + * @param filled the flag. + * + * @see #isShapeFilled() + */ + public void setShapeFilled(boolean filled) { + this.shapeFilled = filled; + } + + /** + * Returns the paint used to fill the shape. + * + * @return The fill paint. + * + * @see #setFillPaint(Paint) + */ + public Paint getFillPaint() { + return this.fillPaint; + } + + /** + * Sets the paint used to fill the shape. + * + * @param paint the paint. + * + * @see #getFillPaint() + */ + public void setFillPaint(Paint paint) { + this.fillPaint = paint; + } + + /** + * Returns the transformer used when the fill paint is an instance of + * GradientPaint. + * + * @return The transformer (never null). + * + * @since 1.0.4. + * + * @see #setFillPaintTransformer(GradientPaintTransformer) + */ + public GradientPaintTransformer getFillPaintTransformer() { + return this.fillPaintTransformer; + } + + /** + * Sets the transformer used when the fill paint is an instance of + * GradientPaint. + * + * @param transformer the transformer (null not permitted). + * + * @since 1.0.4 + * + * @see #getFillPaintTransformer() + */ + public void setFillPaintTransformer(GradientPaintTransformer transformer) { + ParamChecks.nullNotPermitted(transformer, "transformer"); + this.fillPaintTransformer = transformer; + } + + /** + * Returns a flag that controls whether the shape outline is visible. + * + * @return A boolean. + * + * @see #setShapeOutlineVisible(boolean) + */ + public boolean isShapeOutlineVisible() { + return this.shapeOutlineVisible; + } + + /** + * Sets a flag that controls whether or not the shape outline + * is visible. + * + * @param visible the flag. + * + * @see #isShapeOutlineVisible() + */ + public void setShapeOutlineVisible(boolean visible) { + this.shapeOutlineVisible = visible; + } + + /** + * Returns the outline paint. + * + * @return The paint. + * + * @see #setOutlinePaint(Paint) + */ + public Paint getOutlinePaint() { + return this.outlinePaint; + } + + /** + * Sets the outline paint. + * + * @param paint the paint. + * + * @see #getOutlinePaint() + */ + public void setOutlinePaint(Paint paint) { + this.outlinePaint = paint; + } + + /** + * Returns the outline stroke. + * + * @return The stroke. + * + * @see #setOutlineStroke(Stroke) + */ + public Stroke getOutlineStroke() { + return this.outlineStroke; + } + + /** + * Sets the outline stroke. + * + * @param stroke the stroke. + * + * @see #getOutlineStroke() + */ + public void setOutlineStroke(Stroke stroke) { + this.outlineStroke = stroke; + } + + /** + * Returns the shape anchor. + * + * @return The shape anchor. + * + * @see #getShapeAnchor() + */ + public RectangleAnchor getShapeAnchor() { + return this.shapeAnchor; + } + + /** + * Sets the shape anchor. This defines a point on the shapes bounding + * rectangle that will be used to align the shape to a location. + * + * @param anchor the anchor (null not permitted). + * + * @see #setShapeAnchor(RectangleAnchor) + */ + public void setShapeAnchor(RectangleAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.shapeAnchor = anchor; + } + + /** + * Returns the shape location. + * + * @return The shape location. + * + * @see #setShapeLocation(RectangleAnchor) + */ + public RectangleAnchor getShapeLocation() { + return this.shapeLocation; + } + + /** + * Sets the shape location. This defines a point within the drawing + * area that will be used to align the shape to. + * + * @param location the location (null not permitted). + * + * @see #getShapeLocation() + */ + public void setShapeLocation(RectangleAnchor location) { + ParamChecks.nullNotPermitted(location, "location"); + this.shapeLocation = location; + } + + /** + * Returns the flag that controls whether or not the line is visible. + * + * @return A boolean. + * + * @see #setLineVisible(boolean) + */ + public boolean isLineVisible() { + return this.lineVisible; + } + + /** + * Sets the flag that controls whether or not the line is visible. + * + * @param visible the flag. + * + * @see #isLineVisible() + */ + public void setLineVisible(boolean visible) { + this.lineVisible = visible; + } + + /** + * Returns the line centered about (0, 0). + * + * @return The line. + * + * @see #setLine(Shape) + */ + public Shape getLine() { + return this.line; + } + + /** + * Sets the line. A Shape is used here, because then you can use Line2D, + * GeneralPath or any other Shape to represent the line. + * + * @param line the line. + * + * @see #getLine() + */ + public void setLine(Shape line) { + this.line = line; + } + + /** + * Returns the line paint. + * + * @return The paint. + * + * @see #setLinePaint(Paint) + */ + public Paint getLinePaint() { + return this.linePaint; + } + + /** + * Sets the line paint. + * + * @param paint the paint. + * + * @see #getLinePaint() + */ + public void setLinePaint(Paint paint) { + this.linePaint = paint; + } + + /** + * Returns the line stroke. + * + * @return The stroke. + * + * @see #setLineStroke(Stroke) + */ + public Stroke getLineStroke() { + return this.lineStroke; + } + + /** + * Sets the line stroke. + * + * @param stroke the stroke. + * + * @see #getLineStroke() + */ + public void setLineStroke(Stroke stroke) { + this.lineStroke = stroke; + } + + /** + * Arranges the contents of the block, within the given constraints, and + * returns the block size. + * + * @param g2 the graphics device. + * @param constraint the constraint (null not permitted). + * + * @return The block size (in Java2D units, never null). + */ + @Override + public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { + RectangleConstraint contentConstraint = toContentConstraint(constraint); + LengthConstraintType w = contentConstraint.getWidthConstraintType(); + LengthConstraintType h = contentConstraint.getHeightConstraintType(); + Size2D contentSize = null; + if (w == LengthConstraintType.NONE) { + if (h == LengthConstraintType.NONE) { + contentSize = arrangeNN(g2); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not yet implemented."); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not yet implemented."); + } + } + else if (w == LengthConstraintType.RANGE) { + if (h == LengthConstraintType.NONE) { + throw new RuntimeException("Not yet implemented."); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not yet implemented."); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not yet implemented."); + } + } + else if (w == LengthConstraintType.FIXED) { + if (h == LengthConstraintType.NONE) { + throw new RuntimeException("Not yet implemented."); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not yet implemented."); + } + else if (h == LengthConstraintType.FIXED) { + contentSize = new Size2D(contentConstraint.getWidth(), + contentConstraint.getHeight()); + } + } + assert contentSize != null; + return new Size2D(calculateTotalWidth(contentSize.getWidth()), + calculateTotalHeight(contentSize.getHeight())); + } + + /** + * Performs the layout with no constraint, so the content size is + * determined by the bounds of the shape and/or line drawn to represent + * the series. + * + * @param g2 the graphics device. + * + * @return The content size. + */ + protected Size2D arrangeNN(Graphics2D g2) { + Rectangle2D contentSize = new Rectangle2D.Double(); + if (this.line != null) { + contentSize.setRect(this.line.getBounds2D()); + } + if (this.shape != null) { + contentSize = contentSize.createUnion(this.shape.getBounds2D()); + } + return new Size2D(contentSize.getWidth(), contentSize.getHeight()); + } + + /** + * Draws the graphic item within the specified area. + * + * @param g2 the graphics device. + * @param area the area. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + + area = trimMargin(area); + drawBorder(g2, area); + area = trimBorder(area); + area = trimPadding(area); + + if (this.lineVisible) { + Point2D location = RectangleAnchor.coordinates(area, + this.shapeLocation); + Shape aLine = ShapeUtilities.createTranslatedShape(getLine(), + this.shapeAnchor, location.getX(), location.getY()); + g2.setPaint(this.linePaint); + g2.setStroke(this.lineStroke); + g2.draw(aLine); + } + + if (this.shapeVisible) { + Point2D location = RectangleAnchor.coordinates(area, + this.shapeLocation); + + Shape s = ShapeUtilities.createTranslatedShape(this.shape, + this.shapeAnchor, location.getX(), location.getY()); + if (this.shapeFilled) { + Paint p = this.fillPaint; + if (p instanceof GradientPaint) { + GradientPaint gp = (GradientPaint) this.fillPaint; + p = this.fillPaintTransformer.transform(gp, s); + } + g2.setPaint(p); + g2.fill(s); + } + if (this.shapeOutlineVisible) { + g2.setPaint(this.outlinePaint); + g2.setStroke(this.outlineStroke); + g2.draw(s); + } + } + } + + /** + * Draws the block within the specified area. + * + * @param g2 the graphics device. + * @param area the area. + * @param params ignored (null permitted). + * + * @return Always null. + */ + @Override + public Object draw(Graphics2D g2, Rectangle2D area, Object params) { + draw(g2, area); + return null; + } + + /** + * Tests this LegendGraphic instance for equality with an + * arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (!(obj instanceof LegendGraphic)) { + return false; + } + LegendGraphic that = (LegendGraphic) obj; + if (this.shapeVisible != that.shapeVisible) { + return false; + } + if (!ShapeUtilities.equal(this.shape, that.shape)) { + return false; + } + if (this.shapeFilled != that.shapeFilled) { + return false; + } + if (!PaintUtilities.equal(this.fillPaint, that.fillPaint)) { + return false; + } + if (!ObjectUtilities.equal(this.fillPaintTransformer, + that.fillPaintTransformer)) { + return false; + } + if (this.shapeOutlineVisible != that.shapeOutlineVisible) { + return false; + } + if (!PaintUtilities.equal(this.outlinePaint, that.outlinePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.outlineStroke, that.outlineStroke)) { + return false; + } + if (this.shapeAnchor != that.shapeAnchor) { + return false; + } + if (this.shapeLocation != that.shapeLocation) { + return false; + } + if (this.lineVisible != that.lineVisible) { + return false; + } + if (!ShapeUtilities.equal(this.line, that.line)) { + return false; + } + if (!PaintUtilities.equal(this.linePaint, that.linePaint)) { + return false; + } + if (!ObjectUtilities.equal(this.lineStroke, that.lineStroke)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 193; + result = 37 * result + ObjectUtilities.hashCode(this.fillPaint); + // FIXME: use other fields too + return result; + } + + /** + * Returns a clone of this LegendGraphic instance. + * + * @return A clone of this LegendGraphic instance. + * + * @throws CloneNotSupportedException if there is a problem cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + LegendGraphic clone = (LegendGraphic) super.clone(); + clone.shape = ShapeUtilities.clone(this.shape); + clone.line = ShapeUtilities.clone(this.line); + 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.shape, stream); + SerialUtilities.writePaint(this.fillPaint, stream); + SerialUtilities.writePaint(this.outlinePaint, stream); + SerialUtilities.writeStroke(this.outlineStroke, stream); + SerialUtilities.writeShape(this.line, stream); + SerialUtilities.writePaint(this.linePaint, stream); + SerialUtilities.writeStroke(this.lineStroke, 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.fillPaint = SerialUtilities.readPaint(stream); + this.outlinePaint = SerialUtilities.readPaint(stream); + this.outlineStroke = SerialUtilities.readStroke(stream); + this.line = SerialUtilities.readShape(stream); + this.linePaint = SerialUtilities.readPaint(stream); + this.lineStroke = SerialUtilities.readStroke(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/LegendItemBlockContainer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/LegendItemBlockContainer.java new file mode 100755 index 0000000..0f6e51f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/LegendItemBlockContainer.java @@ -0,0 +1,243 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * LegendItemBlockContainer.java + * ----------------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Jul-2006 : Version 1 (DG); + * 06-Oct-2006 : Added tooltip and URL text fields (DG); + * 18-May-2007 : Added seriesKey and dataset fields (DG); + * + */ + +package org.jfree.chart.title; + +import java.awt.Graphics2D; +import java.awt.Shape; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.block.Arrangement; +import org.jfree.chart.block.BlockContainer; +import org.jfree.chart.block.BlockResult; +import org.jfree.chart.block.EntityBlockParams; +import org.jfree.chart.block.EntityBlockResult; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.entity.LegendItemEntity; +import org.jfree.chart.entity.StandardEntityCollection; +import org.jfree.data.general.Dataset; + +/** + * A container that holds all the pieces of a single legend item. + * + * @since 1.0.2 + */ +public class LegendItemBlockContainer extends BlockContainer { + + /** + * The dataset. + * + * @since 1.0.6 + */ + private Dataset dataset; + + /** + * The series key. + * + * @since 1.0.6 + */ + private Comparable seriesKey; + + /** The dataset index. */ + private int datasetIndex; + + /** The series index. */ + private int series; + + /** The tool tip text (can be null). */ + private String toolTipText; + + /** The URL text (can be null). */ + private String urlText; + + /** + * Creates a new legend item block. + * + * @param arrangement the arrangement. + * @param datasetIndex the dataset index. + * @param series the series index. + * + * @deprecated As of 1.0.6, use the other constructor. + */ + public LegendItemBlockContainer(Arrangement arrangement, int datasetIndex, + int series) { + super(arrangement); + this.datasetIndex = datasetIndex; + this.series = series; + } + + /** + * Creates a new legend item block. + * + * @param arrangement the arrangement. + * @param dataset the dataset. + * @param seriesKey the series key. + * + * @since 1.0.6 + */ + public LegendItemBlockContainer(Arrangement arrangement, Dataset dataset, + Comparable seriesKey) { + super(arrangement); + this.dataset = dataset; + this.seriesKey = seriesKey; + } + + /** + * Returns a reference to the dataset for the associated legend item. + * + * @return A dataset reference. + * + * @since 1.0.6 + */ + public Dataset getDataset() { + return this.dataset; + } + + /** + * Returns the series key. + * + * @return The series key. + * + * @since 1.0.6 + */ + public Comparable getSeriesKey() { + return this.seriesKey; + } + + /** + * Returns the dataset index. + * + * @return The dataset index. + * + * @deprecated As of 1.0.6, use the {@link #getDataset()} method. + */ + public int getDatasetIndex() { + return this.datasetIndex; + } + + /** + * Returns the series index. + * + * @return The series index. + */ + public int getSeriesIndex() { + return this.series; + } + + /** + * Returns the tool tip text. + * + * @return The tool tip text (possibly null). + * + * @since 1.0.3 + */ + public String getToolTipText() { + return this.toolTipText; + } + + /** + * Sets the tool tip text. + * + * @param text the text (null permitted). + * + * @since 1.0.3 + */ + public void setToolTipText(String text) { + this.toolTipText = text; + } + + /** + * Returns the URL text. + * + * @return The URL text (possibly null). + * + * @since 1.0.3 + */ + public String getURLText() { + return this.urlText; + } + + /** + * Sets the URL text. + * + * @param text the text (null permitted). + * + * @since 1.0.3 + */ + public void setURLText(String text) { + this.urlText = text; + } + + /** + * Draws the block within the specified area. + * + * @param g2 the graphics device. + * @param area the area. + * @param params passed on to blocks within the container + * (null permitted). + * + * @return An instance of {@link EntityBlockResult}, or null. + */ + @Override + public Object draw(Graphics2D g2, Rectangle2D area, Object params) { + // draw the block without collecting entities + super.draw(g2, area, null); + EntityBlockParams ebp; + BlockResult r = new BlockResult(); + if (params instanceof EntityBlockParams) { + ebp = (EntityBlockParams) params; + if (ebp.getGenerateEntities()) { + EntityCollection ec = new StandardEntityCollection(); + LegendItemEntity entity = new LegendItemEntity( + (Shape) area.clone()); + entity.setSeriesIndex(this.series); + entity.setSeriesKey(this.seriesKey); + entity.setDataset(this.dataset); + entity.setToolTipText(getToolTipText()); + entity.setURLText(getURLText()); + ec.add(entity); + r.setEntityCollection(ec); + } + } + return r; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/LegendTitle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/LegendTitle.java new file mode 100755 index 0000000..68cb249 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/LegendTitle.java @@ -0,0 +1,699 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * LegendTitle.java + * ---------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Pierre-Marie Le Biot; + * + * Changes + * ------- + * 25-Nov-2004 : First working version (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); + * 08-Feb-2005 : Updated for changes in RectangleConstraint class (DG); + * 11-Feb-2005 : Implemented PublicCloneable (DG); + * 23-Feb-2005 : Replaced chart reference with LegendItemSource (DG); + * 16-Mar-2005 : Added itemFont attribute (DG); + * 17-Mar-2005 : Fixed missing fillShape setting (DG); + * 20-Apr-2005 : Added new draw() method (DG); + * 03-May-2005 : Modified equals() method to ignore sources (DG); + * 13-May-2005 : Added settings for legend item label and graphic padding (DG); + * 09-Jun-2005 : Fixed serialization bug (DG); + * 01-Sep-2005 : Added itemPaint attribute (PMLB); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 20-Jul-2006 : Use new LegendItemBlockContainer to restore support for + * LegendItemEntities (DG); + * 06-Oct-2006 : Add tooltip and URL text to legend item (DG); + * 13-Dec-2006 : Added support for GradientPaint in legend items (DG); + * 16-Mar-2007 : Updated border drawing for changes in AbstractBlock (DG); + * 18-May-2007 : Pass seriesKey and dataset to legend item block (DG); + * 15-Aug-2008 : Added getWrapper() method (DG); + * 19-Mar-2009 : Added entity support - see patch 2603321 by Peter Kolb (DG); + * 11-Mar-2012 : Added sort-order support - patch 3500621 by Simon Kaczor (MH); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.title; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +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.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.LegendItemSource; +import org.jfree.chart.block.Arrangement; +import org.jfree.chart.block.Block; +import org.jfree.chart.block.BlockContainer; +import org.jfree.chart.block.BlockFrame; +import org.jfree.chart.block.BlockResult; +import org.jfree.chart.block.BorderArrangement; +import org.jfree.chart.block.CenterArrangement; +import org.jfree.chart.block.ColumnArrangement; +import org.jfree.chart.block.EntityBlockParams; +import org.jfree.chart.block.FlowArrangement; +import org.jfree.chart.block.LabelBlock; +import org.jfree.chart.block.RectangleConstraint; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.entity.StandardEntityCollection; +import org.jfree.chart.entity.TitleEntity; +import org.jfree.chart.event.TitleChangeEvent; +import org.jfree.chart.util.ParamChecks; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.Size2D; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; +import org.jfree.util.SortOrder; + +/** + * A chart title that displays a legend for the data in the chart. + *

+ * The title can be populated with legend items manually, or you can assign a + * reference to the plot, in which case the legend items will be automatically + * created to match the dataset(s). + */ +public class LegendTitle extends Title + implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 2644010518533854633L; + + /** The default item font. */ + public static final Font DEFAULT_ITEM_FONT + = new Font("SansSerif", Font.PLAIN, 12); + + /** The default item paint. */ + public static final Paint DEFAULT_ITEM_PAINT = Color.black; + + /** The sources for legend items. */ + private LegendItemSource[] sources; + + /** The background paint (possibly null). */ + private transient Paint backgroundPaint; + + /** The edge for the legend item graphic relative to the text. */ + private RectangleEdge legendItemGraphicEdge; + + /** The anchor point for the legend item graphic. */ + private RectangleAnchor legendItemGraphicAnchor; + + /** The legend item graphic location. */ + private RectangleAnchor legendItemGraphicLocation; + + /** The padding for the legend item graphic. */ + private RectangleInsets legendItemGraphicPadding; + + /** The item font. */ + private Font itemFont; + + /** The item paint. */ + private transient Paint itemPaint; + + /** The padding for the item labels. */ + private RectangleInsets itemLabelPadding; + + /** + * A container that holds and displays the legend items. + */ + private BlockContainer items; + + /** + * The layout for the legend when it is positioned at the top or bottom + * of the chart. + */ + private Arrangement hLayout; + + /** + * The layout for the legend when it is positioned at the left or right + * of the chart. + */ + private Arrangement vLayout; + + /** + * An optional container for wrapping the legend items (allows for adding + * a title or other text to the legend). + */ + private BlockContainer wrapper; + + /** + * Whether to render legend items in ascending or descending order. + * @since 1.0.15 + */ + private SortOrder sortOrder; + + /** + * Constructs a new (empty) legend for the specified source. + * + * @param source the source. + */ + public LegendTitle(LegendItemSource source) { + this(source, new FlowArrangement(), new ColumnArrangement()); + } + + /** + * Creates a new legend title with the specified arrangement. + * + * @param source the source. + * @param hLayout the horizontal item arrangement (null not + * permitted). + * @param vLayout the vertical item arrangement (null not + * permitted). + */ + public LegendTitle(LegendItemSource source, + Arrangement hLayout, Arrangement vLayout) { + this.sources = new LegendItemSource[] {source}; + this.items = new BlockContainer(hLayout); + this.hLayout = hLayout; + this.vLayout = vLayout; + this.backgroundPaint = null; + this.legendItemGraphicEdge = RectangleEdge.LEFT; + this.legendItemGraphicAnchor = RectangleAnchor.CENTER; + this.legendItemGraphicLocation = RectangleAnchor.CENTER; + this.legendItemGraphicPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0); + this.itemFont = DEFAULT_ITEM_FONT; + this.itemPaint = DEFAULT_ITEM_PAINT; + this.itemLabelPadding = new RectangleInsets(2.0, 2.0, 2.0, 2.0); + this.sortOrder = SortOrder.ASCENDING; + } + + /** + * Returns the legend item sources. + * + * @return The sources. + */ + public LegendItemSource[] getSources() { + return this.sources; + } + + /** + * Sets the legend item sources and sends a {@link TitleChangeEvent} to + * all registered listeners. + * + * @param sources the sources (null not permitted). + */ + public void setSources(LegendItemSource[] sources) { + ParamChecks.nullNotPermitted(sources, "sources"); + this.sources = sources; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the background paint. + * + * @return The background paint (possibly null). + */ + public Paint getBackgroundPaint() { + return this.backgroundPaint; + } + + /** + * Sets the background paint for the legend and sends a + * {@link TitleChangeEvent} to all registered listeners. + * + * @param paint the paint (null permitted). + */ + public void setBackgroundPaint(Paint paint) { + this.backgroundPaint = paint; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the location of the shape within each legend item. + * + * @return The location (never null). + */ + public RectangleEdge getLegendItemGraphicEdge() { + return this.legendItemGraphicEdge; + } + + /** + * Sets the location of the shape within each legend item. + * + * @param edge the edge (null not permitted). + */ + public void setLegendItemGraphicEdge(RectangleEdge edge) { + ParamChecks.nullNotPermitted(edge, "edge"); + this.legendItemGraphicEdge = edge; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the legend item graphic anchor. + * + * @return The graphic anchor (never null). + */ + public RectangleAnchor getLegendItemGraphicAnchor() { + return this.legendItemGraphicAnchor; + } + + /** + * Sets the anchor point used for the graphic in each legend item. + * + * @param anchor the anchor point (null not permitted). + */ + public void setLegendItemGraphicAnchor(RectangleAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.legendItemGraphicAnchor = anchor; + } + + /** + * Returns the legend item graphic location. + * + * @return The location (never null). + */ + public RectangleAnchor getLegendItemGraphicLocation() { + return this.legendItemGraphicLocation; + } + + /** + * Sets the legend item graphic location. + * + * @param anchor the anchor (null not permitted). + */ + public void setLegendItemGraphicLocation(RectangleAnchor anchor) { + this.legendItemGraphicLocation = anchor; + } + + /** + * Returns the padding that will be applied to each item graphic. + * + * @return The padding (never null). + */ + public RectangleInsets getLegendItemGraphicPadding() { + return this.legendItemGraphicPadding; + } + + /** + * Sets the padding that will be applied to each item graphic in the + * legend and sends a {@link TitleChangeEvent} to all registered listeners. + * + * @param padding the padding (null not permitted). + */ + public void setLegendItemGraphicPadding(RectangleInsets padding) { + ParamChecks.nullNotPermitted(padding, "padding"); + this.legendItemGraphicPadding = padding; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the item font. + * + * @return The font (never null). + */ + public Font getItemFont() { + return this.itemFont; + } + + /** + * Sets the item font and sends a {@link TitleChangeEvent} to + * all registered listeners. + * + * @param font the font (null not permitted). + */ + public void setItemFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + this.itemFont = font; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the item paint. + * + * @return The paint (never null). + */ + public Paint getItemPaint() { + return this.itemPaint; + } + + /** + * Sets the item paint. + * + * @param paint the paint (null not permitted). + */ + public void setItemPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.itemPaint = paint; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the padding used for the items labels. + * + * @return The padding (never null). + */ + public RectangleInsets getItemLabelPadding() { + return this.itemLabelPadding; + } + + /** + * Sets the padding used for the item labels in the legend. + * + * @param padding the padding (null not permitted). + */ + public void setItemLabelPadding(RectangleInsets padding) { + ParamChecks.nullNotPermitted(padding, "padding"); + this.itemLabelPadding = padding; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Gets the order used to display legend items. + * + * @return The order (never null). + * @since 1.0.15 + */ + public SortOrder getSortOrder() { + return this.sortOrder; + } + + /** + * Sets the order used to display legend items. + * + * @param order Specifies ascending or descending order (null + * not permitted). + * @since 1.0.15 + */ + public void setSortOrder(SortOrder order) { + ParamChecks.nullNotPermitted(order, "order"); + this.sortOrder = order; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Fetches the latest legend items. + */ + protected void fetchLegendItems() { + this.items.clear(); + RectangleEdge p = getPosition(); + if (RectangleEdge.isTopOrBottom(p)) { + this.items.setArrangement(this.hLayout); + } + else { + this.items.setArrangement(this.vLayout); + } + + if (this.sortOrder.equals(SortOrder.ASCENDING)) { + for (int s = 0; s < this.sources.length; s++) { + LegendItemCollection legendItems = + this.sources[s].getLegendItems(); + if (legendItems != null) { + for (int i = 0; i < legendItems.getItemCount(); i++) { + addItemBlock(legendItems.get(i)); + } + } + } + } + else { + for (int s = this.sources.length - 1; s >= 0; s--) { + LegendItemCollection legendItems = + this.sources[s].getLegendItems(); + if (legendItems != null) { + for (int i = legendItems.getItemCount()-1; i >= 0; i--) { + addItemBlock(legendItems.get(i)); + } + } + } + } + } + + private void addItemBlock(LegendItem item) { + Block block = createLegendItemBlock(item); + this.items.add(block); + } + + /** + * Creates a legend item block. + * + * @param item the legend item. + * + * @return The block. + */ + protected Block createLegendItemBlock(LegendItem item) { + BlockContainer result; + LegendGraphic lg = new LegendGraphic(item.getShape(), + item.getFillPaint()); + lg.setFillPaintTransformer(item.getFillPaintTransformer()); + lg.setShapeFilled(item.isShapeFilled()); + lg.setLine(item.getLine()); + lg.setLineStroke(item.getLineStroke()); + lg.setLinePaint(item.getLinePaint()); + lg.setLineVisible(item.isLineVisible()); + lg.setShapeVisible(item.isShapeVisible()); + lg.setShapeOutlineVisible(item.isShapeOutlineVisible()); + lg.setOutlinePaint(item.getOutlinePaint()); + lg.setOutlineStroke(item.getOutlineStroke()); + lg.setPadding(this.legendItemGraphicPadding); + + LegendItemBlockContainer legendItem = new LegendItemBlockContainer( + new BorderArrangement(), item.getDataset(), + item.getSeriesKey()); + lg.setShapeAnchor(getLegendItemGraphicAnchor()); + lg.setShapeLocation(getLegendItemGraphicLocation()); + legendItem.add(lg, this.legendItemGraphicEdge); + Font textFont = item.getLabelFont(); + if (textFont == null) { + textFont = this.itemFont; + } + Paint textPaint = item.getLabelPaint(); + if (textPaint == null) { + textPaint = this.itemPaint; + } + LabelBlock labelBlock = new LabelBlock(item.getLabel(), textFont, + textPaint); + labelBlock.setPadding(this.itemLabelPadding); + legendItem.add(labelBlock); + legendItem.setToolTipText(item.getToolTipText()); + legendItem.setURLText(item.getURLText()); + + result = new BlockContainer(new CenterArrangement()); + result.add(legendItem); + + return result; + } + + /** + * Returns the container that holds the legend items. + * + * @return The container for the legend items. + */ + public BlockContainer getItemContainer() { + return this.items; + } + + /** + * Arranges the contents of the block, within the given constraints, and + * returns the block size. + * + * @param g2 the graphics device. + * @param constraint the constraint (null not permitted). + * + * @return The block size (in Java2D units, never null). + */ + @Override + public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { + Size2D result = new Size2D(); + fetchLegendItems(); + if (this.items.isEmpty()) { + return result; + } + BlockContainer container = this.wrapper; + if (container == null) { + container = this.items; + } + RectangleConstraint c = toContentConstraint(constraint); + Size2D size = container.arrange(g2, c); + result.height = calculateTotalHeight(size.height); + result.width = calculateTotalWidth(size.width); + return result; + } + + /** + * Draws the title on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device. + * @param area the available area for the title. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + draw(g2, area, null); + } + + /** + * Draws the block within the specified area. + * + * @param g2 the graphics device. + * @param area the area. + * @param params ignored (null permitted). + * + * @return An {@link org.jfree.chart.block.EntityBlockResult} or + * null. + */ + @Override + public Object draw(Graphics2D g2, Rectangle2D area, Object params) { + Rectangle2D target = (Rectangle2D) area.clone(); + Rectangle2D hotspot = (Rectangle2D) area.clone(); + StandardEntityCollection sec = null; + if (params instanceof EntityBlockParams + && ((EntityBlockParams) params).getGenerateEntities()) { + sec = new StandardEntityCollection(); + sec.add(new TitleEntity(hotspot, this)); + } + target = trimMargin(target); + if (this.backgroundPaint != null) { + g2.setPaint(this.backgroundPaint); + g2.fill(target); + } + BlockFrame border = getFrame(); + border.draw(g2, target); + border.getInsets().trim(target); + BlockContainer container = this.wrapper; + if (container == null) { + container = this.items; + } + target = trimPadding(target); + Object val = container.draw(g2, target, params); + if (val instanceof BlockResult) { + EntityCollection ec = ((BlockResult) val).getEntityCollection(); + if (ec != null && sec != null) { + sec.addAll(ec); + ((BlockResult) val).setEntityCollection(sec); + } + } + return val; + } + + /** + * Returns the wrapper container, if any. + * + * @return The wrapper container (possibly null). + * + * @since 1.0.11 + */ + public BlockContainer getWrapper() { + return this.wrapper; + } + + /** + * Sets the wrapper container for the legend. + * + * @param wrapper the wrapper container. + */ + public void setWrapper(BlockContainer wrapper) { + this.wrapper = wrapper; + } + + /** + * Tests this title for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof LegendTitle)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + LegendTitle that = (LegendTitle) obj; + if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { + return false; + } + if (this.legendItemGraphicEdge != that.legendItemGraphicEdge) { + return false; + } + if (this.legendItemGraphicAnchor != that.legendItemGraphicAnchor) { + return false; + } + if (this.legendItemGraphicLocation != that.legendItemGraphicLocation) { + return false; + } + if (!this.itemFont.equals(that.itemFont)) { + return false; + } + if (!this.itemPaint.equals(that.itemPaint)) { + return false; + } + if (!this.hLayout.equals(that.hLayout)) { + return false; + } + if (!this.vLayout.equals(that.vLayout)) { + return false; + } + if (!this.sortOrder.equals(that.sortOrder)) { + return false; + } + return true; + } + + /** + * 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.backgroundPaint, stream); + SerialUtilities.writePaint(this.itemPaint, 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.backgroundPaint = SerialUtilities.readPaint(stream); + this.itemPaint = SerialUtilities.readPaint(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/PaintScaleLegend.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/PaintScaleLegend.java new file mode 100755 index 0000000..ead4459 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/PaintScaleLegend.java @@ -0,0 +1,730 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * PaintScaleLegend.java + * --------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb - see patch 2686872; + * + * Changes + * ------- + * 22-Jan-2007 : Version 1 (DG); + * 18-Jun-2008 : Fixed bug drawing scale with log axis (DG); + * 16-Apr-2009 : Patch 2686872 implementing AxisChangeListener, and fix for + * ignored stripOutlineVisible flag (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.title; + +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 org.jfree.chart.axis.AxisLocation; +import org.jfree.chart.axis.AxisSpace; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.block.LengthConstraintType; +import org.jfree.chart.block.RectangleConstraint; +import org.jfree.chart.event.AxisChangeEvent; +import org.jfree.chart.event.AxisChangeListener; +import org.jfree.chart.event.TitleChangeEvent; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.renderer.PaintScale; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.io.SerialUtilities; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.Size2D; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A legend that shows a range of values and their associated colors, driven + * by an underlying {@link PaintScale} implementation. + * + * @since 1.0.4 + */ +public class PaintScaleLegend extends Title implements AxisChangeListener, + PublicCloneable { + + /** For serialization. */ + static final long serialVersionUID = -1365146490993227503L; + + /** The paint scale (never null). */ + private PaintScale scale; + + /** The value axis (never null). */ + private ValueAxis axis; + + /** + * The axis location (handles both orientations, never + * null). + */ + private AxisLocation axisLocation; + + /** The offset between the axis and the paint strip (in Java2D units). */ + private double axisOffset; + + /** The thickness of the paint strip (in Java2D units). */ + private double stripWidth; + + /** + * A flag that controls whether or not an outline is drawn around the + * paint strip. + */ + private boolean stripOutlineVisible; + + /** The paint used to draw an outline around the paint strip. */ + private transient Paint stripOutlinePaint; + + /** The stroke used to draw an outline around the paint strip. */ + private transient Stroke stripOutlineStroke; + + /** The background paint (never null). */ + private transient Paint backgroundPaint; + + /** + * The number of subdivisions for the scale when rendering. + * + * @since 1.0.11 + */ + private int subdivisions; + + /** + * Creates a new instance. + * + * @param scale the scale (null not permitted). + * @param axis the axis (null not permitted). + */ + public PaintScaleLegend(PaintScale scale, ValueAxis axis) { + ParamChecks.nullNotPermitted(axis, "axis"); + this.scale = scale; + this.axis = axis; + this.axis.addChangeListener(this); + this.axisLocation = AxisLocation.BOTTOM_OR_LEFT; + this.axisOffset = 0.0; + this.axis.setRange(scale.getLowerBound(), scale.getUpperBound()); + this.stripWidth = 15.0; + this.stripOutlineVisible = true; + this.stripOutlinePaint = Color.gray; + this.stripOutlineStroke = new BasicStroke(0.5f); + this.backgroundPaint = Color.white; + this.subdivisions = 100; + } + + /** + * Returns the scale used to convert values to colors. + * + * @return The scale (never null). + * + * @see #setScale(PaintScale) + */ + public PaintScale getScale() { + return this.scale; + } + + /** + * Sets the scale and sends a {@link TitleChangeEvent} to all registered + * listeners. + * + * @param scale the scale (null not permitted). + * + * @see #getScale() + */ + public void setScale(PaintScale scale) { + ParamChecks.nullNotPermitted(scale, "scale"); + this.scale = scale; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the axis for the paint scale. + * + * @return The axis (never null). + * + * @see #setAxis(ValueAxis) + */ + public ValueAxis getAxis() { + return this.axis; + } + + /** + * Sets the axis for the paint scale and sends a {@link TitleChangeEvent} + * to all registered listeners. + * + * @param axis the axis (null not permitted). + * + * @see #getAxis() + */ + public void setAxis(ValueAxis axis) { + ParamChecks.nullNotPermitted(axis, "axis"); + this.axis.removeChangeListener(this); + this.axis = axis; + this.axis.addChangeListener(this); + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the axis location. + * + * @return The axis location (never null). + * + * @see #setAxisLocation(AxisLocation) + */ + public AxisLocation getAxisLocation() { + return this.axisLocation; + } + + /** + * Sets the axis location and sends a {@link TitleChangeEvent} to all + * registered listeners. + * + * @param location the location (null not permitted). + * + * @see #getAxisLocation() + */ + public void setAxisLocation(AxisLocation location) { + ParamChecks.nullNotPermitted(location, "location"); + this.axisLocation = location; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the offset between the axis and the paint strip. + * + * @return The offset between the axis and the paint strip. + * + * @see #setAxisOffset(double) + */ + public double getAxisOffset() { + return this.axisOffset; + } + + /** + * Sets the offset between the axis and the paint strip and sends a + * {@link TitleChangeEvent} to all registered listeners. + * + * @param offset the offset. + */ + public void setAxisOffset(double offset) { + this.axisOffset = offset; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the width of the paint strip, in Java2D units. + * + * @return The width of the paint strip. + * + * @see #setStripWidth(double) + */ + public double getStripWidth() { + return this.stripWidth; + } + + /** + * Sets the width of the paint strip and sends a {@link TitleChangeEvent} + * to all registered listeners. + * + * @param width the width. + * + * @see #getStripWidth() + */ + public void setStripWidth(double width) { + this.stripWidth = width; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the flag that controls whether or not an outline is drawn + * around the paint strip. + * + * @return A boolean. + * + * @see #setStripOutlineVisible(boolean) + */ + public boolean isStripOutlineVisible() { + return this.stripOutlineVisible; + } + + /** + * Sets the flag that controls whether or not an outline is drawn around + * the paint strip, and sends a {@link TitleChangeEvent} to all registered + * listeners. + * + * @param visible the flag. + * + * @see #isStripOutlineVisible() + */ + public void setStripOutlineVisible(boolean visible) { + this.stripOutlineVisible = visible; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the paint used to draw the outline of the paint strip. + * + * @return The paint (never null). + * + * @see #setStripOutlinePaint(Paint) + */ + public Paint getStripOutlinePaint() { + return this.stripOutlinePaint; + } + + /** + * Sets the paint used to draw the outline of the paint strip, and sends + * a {@link TitleChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getStripOutlinePaint() + */ + public void setStripOutlinePaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + this.stripOutlinePaint = paint; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the stroke used to draw the outline around the paint strip. + * + * @return The stroke (never null). + * + * @see #setStripOutlineStroke(Stroke) + */ + public Stroke getStripOutlineStroke() { + return this.stripOutlineStroke; + } + + /** + * Sets the stroke used to draw the outline around the paint strip and + * sends a {@link TitleChangeEvent} to all registered listeners. + * + * @param stroke the stroke (null not permitted). + * + * @see #getStripOutlineStroke() + */ + public void setStripOutlineStroke(Stroke stroke) { + ParamChecks.nullNotPermitted(stroke, "stroke"); + this.stripOutlineStroke = stroke; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the background paint. + * + * @return The background paint. + */ + public Paint getBackgroundPaint() { + return this.backgroundPaint; + } + + /** + * Sets the background paint and sends a {@link TitleChangeEvent} to all + * registered listeners. + * + * @param paint the paint (null permitted). + */ + public void setBackgroundPaint(Paint paint) { + this.backgroundPaint = paint; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the number of subdivisions used to draw the scale. + * + * @return The subdivision count. + * + * @since 1.0.11 + */ + public int getSubdivisionCount() { + return this.subdivisions; + } + + /** + * Sets the subdivision count and sends a {@link TitleChangeEvent} to + * all registered listeners. + * + * @param count the count. + * + * @since 1.0.11 + */ + public void setSubdivisionCount(int count) { + if (count <= 0) { + throw new IllegalArgumentException("Requires 'count' > 0."); + } + this.subdivisions = count; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Receives notification of an axis change event and responds by firing + * a title change event. + * + * @param event the event. + * + * @since 1.0.13 + */ + @Override + public void axisChanged(AxisChangeEvent event) { + if (this.axis == event.getAxis()) { + notifyListeners(new TitleChangeEvent(this)); + } + } + + /** + * Arranges the contents of the block, within the given constraints, and + * returns the block size. + * + * @param g2 the graphics device. + * @param constraint the constraint (null not permitted). + * + * @return The block size (in Java2D units, never null). + */ + @Override + public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { + RectangleConstraint cc = toContentConstraint(constraint); + LengthConstraintType w = cc.getWidthConstraintType(); + LengthConstraintType h = cc.getHeightConstraintType(); + Size2D contentSize = null; + if (w == LengthConstraintType.NONE) { + if (h == LengthConstraintType.NONE) { + contentSize = new Size2D(getWidth(), getHeight()); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not yet implemented."); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not yet implemented."); + } + } + else if (w == LengthConstraintType.RANGE) { + if (h == LengthConstraintType.NONE) { + throw new RuntimeException("Not yet implemented."); + } + else if (h == LengthConstraintType.RANGE) { + contentSize = arrangeRR(g2, cc.getWidthRange(), + cc.getHeightRange()); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not yet implemented."); + } + } + else if (w == LengthConstraintType.FIXED) { + if (h == LengthConstraintType.NONE) { + throw new RuntimeException("Not yet implemented."); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not yet implemented."); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not yet implemented."); + } + } + assert contentSize != null; // suppress compiler warning + return new Size2D(calculateTotalWidth(contentSize.getWidth()), + calculateTotalHeight(contentSize.getHeight())); + } + + /** + * Returns the content size for the title. This will reflect the fact that + * a text title positioned on the left or right of a chart will be rotated + * 90 degrees. + * + * @param g2 the graphics device. + * @param widthRange the width range. + * @param heightRange the height range. + * + * @return The content size. + */ + protected Size2D arrangeRR(Graphics2D g2, Range widthRange, + Range heightRange) { + + RectangleEdge position = getPosition(); + if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) { + + + float maxWidth = (float) widthRange.getUpperBound(); + + // determine the space required for the axis + AxisSpace space = this.axis.reserveSpace(g2, null, + new Rectangle2D.Double(0, 0, maxWidth, 100), + RectangleEdge.BOTTOM, null); + + return new Size2D(maxWidth, this.stripWidth + this.axisOffset + + space.getTop() + space.getBottom()); + } + else if (position == RectangleEdge.LEFT || position + == RectangleEdge.RIGHT) { + float maxHeight = (float) heightRange.getUpperBound(); + AxisSpace space = this.axis.reserveSpace(g2, null, + new Rectangle2D.Double(0, 0, 100, maxHeight), + RectangleEdge.RIGHT, null); + return new Size2D(this.stripWidth + this.axisOffset + + space.getLeft() + space.getRight(), maxHeight); + } + else { + throw new RuntimeException("Unrecognised position."); + } + } + + /** + * Draws the legend within the specified area. + * + * @param g2 the graphics target (null not permitted). + * @param area the drawing area (null not permitted). + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + draw(g2, area, null); + } + + /** + * Draws the legend within the specified area. + * + * @param g2 the graphics target (null not permitted). + * @param area the drawing area (null not permitted). + * @param params drawing parameters (ignored here). + * + * @return null. + */ + @Override + public Object draw(Graphics2D g2, Rectangle2D area, Object params) { + Rectangle2D target = (Rectangle2D) area.clone(); + target = trimMargin(target); + if (this.backgroundPaint != null) { + g2.setPaint(this.backgroundPaint); + g2.fill(target); + } + getFrame().draw(g2, target); + getFrame().getInsets().trim(target); + target = trimPadding(target); + double base = this.axis.getLowerBound(); + double increment = this.axis.getRange().getLength() / this.subdivisions; + Rectangle2D r = new Rectangle2D.Double(); + + if (RectangleEdge.isTopOrBottom(getPosition())) { + RectangleEdge axisEdge = Plot.resolveRangeAxisLocation( + this.axisLocation, PlotOrientation.HORIZONTAL); + if (axisEdge == RectangleEdge.TOP) { + for (int i = 0; i < this.subdivisions; i++) { + double v = base + (i * increment); + Paint p = this.scale.getPaint(v); + double vv0 = this.axis.valueToJava2D(v, target, + RectangleEdge.TOP); + double vv1 = this.axis.valueToJava2D(v + increment, target, + RectangleEdge.TOP); + double ww = Math.abs(vv1 - vv0) + 1.0; + r.setRect(Math.min(vv0, vv1), target.getMaxY() + - this.stripWidth, ww, this.stripWidth); + g2.setPaint(p); + g2.fill(r); + } + if (isStripOutlineVisible()) { + g2.setPaint(this.stripOutlinePaint); + g2.setStroke(this.stripOutlineStroke); + g2.draw(new Rectangle2D.Double(target.getMinX(), + target.getMaxY() - this.stripWidth, + target.getWidth(), this.stripWidth)); + } + this.axis.draw(g2, target.getMaxY() - this.stripWidth + - this.axisOffset, target, target, RectangleEdge.TOP, + null); + } + else if (axisEdge == RectangleEdge.BOTTOM) { + for (int i = 0; i < this.subdivisions; i++) { + double v = base + (i * increment); + Paint p = this.scale.getPaint(v); + double vv0 = this.axis.valueToJava2D(v, target, + RectangleEdge.BOTTOM); + double vv1 = this.axis.valueToJava2D(v + increment, target, + RectangleEdge.BOTTOM); + double ww = Math.abs(vv1 - vv0) + 1.0; + r.setRect(Math.min(vv0, vv1), target.getMinY(), ww, + this.stripWidth); + g2.setPaint(p); + g2.fill(r); + } + if (isStripOutlineVisible()) { + g2.setPaint(this.stripOutlinePaint); + g2.setStroke(this.stripOutlineStroke); + g2.draw(new Rectangle2D.Double(target.getMinX(), + target.getMinY(), target.getWidth(), + this.stripWidth)); + } + this.axis.draw(g2, target.getMinY() + this.stripWidth + + this.axisOffset, target, target, + RectangleEdge.BOTTOM, null); + } + } + else { + RectangleEdge axisEdge = Plot.resolveRangeAxisLocation( + this.axisLocation, PlotOrientation.VERTICAL); + if (axisEdge == RectangleEdge.LEFT) { + for (int i = 0; i < this.subdivisions; i++) { + double v = base + (i * increment); + Paint p = this.scale.getPaint(v); + double vv0 = this.axis.valueToJava2D(v, target, + RectangleEdge.LEFT); + double vv1 = this.axis.valueToJava2D(v + increment, target, + RectangleEdge.LEFT); + double hh = Math.abs(vv1 - vv0) + 1.0; + r.setRect(target.getMaxX() - this.stripWidth, + Math.min(vv0, vv1), this.stripWidth, hh); + g2.setPaint(p); + g2.fill(r); + } + if (isStripOutlineVisible()) { + g2.setPaint(this.stripOutlinePaint); + g2.setStroke(this.stripOutlineStroke); + g2.draw(new Rectangle2D.Double(target.getMaxX() + - this.stripWidth, target.getMinY(), + this.stripWidth, target.getHeight())); + } + this.axis.draw(g2, target.getMaxX() - this.stripWidth + - this.axisOffset, target, target, RectangleEdge.LEFT, + null); + } + else if (axisEdge == RectangleEdge.RIGHT) { + for (int i = 0; i < this.subdivisions; i++) { + double v = base + (i * increment); + Paint p = this.scale.getPaint(v); + double vv0 = this.axis.valueToJava2D(v, target, + RectangleEdge.LEFT); + double vv1 = this.axis.valueToJava2D(v + increment, target, + RectangleEdge.LEFT); + double hh = Math.abs(vv1 - vv0) + 1.0; + r.setRect(target.getMinX(), Math.min(vv0, vv1), + this.stripWidth, hh); + g2.setPaint(p); + g2.fill(r); + } + if (isStripOutlineVisible()) { + g2.setPaint(this.stripOutlinePaint); + g2.setStroke(this.stripOutlineStroke); + g2.draw(new Rectangle2D.Double(target.getMinX(), + target.getMinY(), this.stripWidth, + target.getHeight())); + } + this.axis.draw(g2, target.getMinX() + this.stripWidth + + this.axisOffset, target, target, RectangleEdge.RIGHT, + null); + } + } + return null; + } + + /** + * Tests this legend for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (!(obj instanceof PaintScaleLegend)) { + return false; + } + PaintScaleLegend that = (PaintScaleLegend) obj; + if (!this.scale.equals(that.scale)) { + return false; + } + if (!this.axis.equals(that.axis)) { + return false; + } + if (!this.axisLocation.equals(that.axisLocation)) { + return false; + } + if (this.axisOffset != that.axisOffset) { + return false; + } + if (this.stripWidth != that.stripWidth) { + return false; + } + if (this.stripOutlineVisible != that.stripOutlineVisible) { + return false; + } + if (!PaintUtilities.equal(this.stripOutlinePaint, + that.stripOutlinePaint)) { + return false; + } + if (!this.stripOutlineStroke.equals(that.stripOutlineStroke)) { + return false; + } + if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { + return false; + } + if (this.subdivisions != that.subdivisions) { + return false; + } + return super.equals(obj); + } + + /** + * 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.backgroundPaint, stream); + SerialUtilities.writePaint(this.stripOutlinePaint, stream); + SerialUtilities.writeStroke(this.stripOutlineStroke, 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.backgroundPaint = SerialUtilities.readPaint(stream); + this.stripOutlinePaint = SerialUtilities.readPaint(stream); + this.stripOutlineStroke = SerialUtilities.readStroke(stream); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/ShortTextTitle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/ShortTextTitle.java new file mode 100755 index 0000000..41a7939 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/ShortTextTitle.java @@ -0,0 +1,242 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * ShortTextTitle.java + * ------------------- + * (C) Copyright 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 28-Apr-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.title; + +import java.awt.FontMetrics; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.block.LengthConstraintType; +import org.jfree.chart.block.RectangleConstraint; +import org.jfree.data.Range; +import org.jfree.text.TextUtilities; +import org.jfree.ui.Size2D; +import org.jfree.ui.TextAnchor; + +/** + * A text title that is only displayed if the entire text will be visible + * without line wrapping. It is only intended for use with short titles - for + * general purpose titles, you should use the {@link TextTitle} class. + * + * @since 1.0.10 + * + * @see TextTitle + */ +public class ShortTextTitle extends TextTitle { + + /** + * Creates a new title. + * + * @param text the text (null not permitted). + */ + public ShortTextTitle(String text) { + setText(text); + } + + /** + * Performs a layout for this title, subject to the supplied constraint, + * and returns the dimensions required for the title (if the title + * cannot be displayed in the available space, this method will return + * zero width and height for the dimensions). + * + * @param g2 the graphics target. + * @param constraint the layout constraints. + * + * @return The dimensions for the title. + */ + @Override + public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { + RectangleConstraint cc = toContentConstraint(constraint); + LengthConstraintType w = cc.getWidthConstraintType(); + LengthConstraintType h = cc.getHeightConstraintType(); + Size2D contentSize = null; + if (w == LengthConstraintType.NONE) { + if (h == LengthConstraintType.NONE) { + contentSize = arrangeNN(g2); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not yet implemented."); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not yet implemented."); + } + } + else if (w == LengthConstraintType.RANGE) { + if (h == LengthConstraintType.NONE) { + contentSize = arrangeRN(g2, cc.getWidthRange()); + } + else if (h == LengthConstraintType.RANGE) { + contentSize = arrangeRR(g2, cc.getWidthRange(), + cc.getHeightRange()); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not yet implemented."); + } + } + else if (w == LengthConstraintType.FIXED) { + if (h == LengthConstraintType.NONE) { + contentSize = arrangeFN(g2, cc.getWidth()); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not yet implemented."); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not yet implemented."); + } + } + assert contentSize != null; + if (contentSize.width <= 0.0 || contentSize.height <= 0.0) { + return new Size2D(0.0, 0.0); + } + else { + return new Size2D(calculateTotalWidth(contentSize.getWidth()), + calculateTotalHeight(contentSize.getHeight())); + } + } + + /** + * Arranges the content for this title assuming no bounds on the width + * or the height, and returns the required size. + * + * @param g2 the graphics target. + * + * @return The content size. + */ + @Override + protected Size2D arrangeNN(Graphics2D g2) { + Range max = new Range(0.0, Float.MAX_VALUE); + return arrangeRR(g2, max, max); + } + + /** + * Arranges the content for this title assuming a range constraint for the + * width and no bounds on the height, and returns the required size. + * + * @param g2 the graphics target. + * @param widthRange the range for the width. + * + * @return The content size. + */ + @Override + protected Size2D arrangeRN(Graphics2D g2, Range widthRange) { + Size2D s = arrangeNN(g2); + if (widthRange.contains(s.getWidth())) { + return s; + } + double ww = widthRange.constrain(s.getWidth()); + return arrangeFN(g2, ww); + } + + /** + * Arranges the content for this title assuming a fixed width and no bounds + * on the height, and returns the required size. This will reflect the + * fact that a text title positioned on the left or right of a chart will + * be rotated by 90 degrees. + * + * @param g2 the graphics target. + * @param w the width. + * + * @return The content size. + */ + @Override + protected Size2D arrangeFN(Graphics2D g2, double w) { + g2.setFont(getFont()); + FontMetrics fm = g2.getFontMetrics(getFont()); + Rectangle2D bounds = TextUtilities.getTextBounds(getText(), g2, fm); + if (bounds.getWidth() <= w) { + return new Size2D(w, bounds.getHeight()); + } + else { + return new Size2D(0.0, 0.0); + } + } + + /** + * Returns the content size for the title. + * + * @param g2 the graphics device. + * @param widthRange the width range. + * @param heightRange the height range. + * + * @return The content size. + */ + @Override + protected Size2D arrangeRR(Graphics2D g2, Range widthRange, + Range heightRange) { + + g2.setFont(getFont()); + FontMetrics fm = g2.getFontMetrics(getFont()); + Rectangle2D bounds = TextUtilities.getTextBounds(getText(), g2, fm); + if (bounds.getWidth() <= widthRange.getUpperBound() + && bounds.getHeight() <= heightRange.getUpperBound()) { + return new Size2D(bounds.getWidth(), bounds.getHeight()); + } + else { + return new Size2D(0.0, 0.0); + } + } + + /** + * Draws the title using the current font and paint. + * + * @param g2 the graphics target. + * @param area the title area. + * @param params optional parameters (ignored here). + * + * @return null. + */ + @Override + public Object draw(Graphics2D g2, Rectangle2D area, Object params) { + if (area.isEmpty()) { + return null; + } + area = trimMargin(area); + drawBorder(g2, area); + area = trimBorder(area); + area = trimPadding(area); + g2.setFont(getFont()); + g2.setPaint(getPaint()); + TextUtilities.drawAlignedString(getText(), g2, (float) area.getMinX(), + (float) area.getMinY(), TextAnchor.TOP_LEFT); + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/TextTitle.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/TextTitle.java new file mode 100755 index 0000000..45aebb2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/TextTitle.java @@ -0,0 +1,925 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * TextTitle.java + * -------------- + * (C) Copyright 2000-2013, by David Berry and Contributors. + * + * Original Author: David Berry; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Nicolas Brodu; + * Peter Kolb - patch 2603321; + * + * Changes (from 18-Sep-2001) + * -------------------------- + * 18-Sep-2001 : Added standard header (DG); + * 07-Nov-2001 : Separated the JCommon Class Library classes, JFreeChart now + * requires jcommon.jar (DG); + * 09-Jan-2002 : Updated Javadoc comments (DG); + * 07-Feb-2002 : Changed Insets --> Spacer in AbstractTitle.java (DG); + * 06-Mar-2002 : Updated import statements (DG); + * 25-Jun-2002 : Removed redundant imports (DG); + * 18-Sep-2002 : Fixed errors reported by Checkstyle (DG); + * 28-Oct-2002 : Small modifications while changing JFreeChart class (DG); + * 13-Mar-2003 : Changed width used for relative spacing to fix bug 703050 (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 15-Jul-2003 : Fixed null pointer exception (DG); + * 11-Sep-2003 : Implemented Cloneable (NB) + * 22-Sep-2003 : Added checks for null values and throw nullpointer + * exceptions (TM); + * Background paint was not serialized. + * 07-Oct-2003 : Added fix for exception caused by empty string in title (DG); + * 29-Oct-2003 : Added workaround for text alignment in PDF output (DG); + * 03-Feb-2004 : Fixed bug in getPreferredWidth() method (DG); + * 17-Feb-2004 : Added clone() method and fixed bug in equals() method (DG); + * 01-Apr-2004 : Changed java.awt.geom.Dimension2D to org.jfree.ui.Size2D + * because of JDK bug 4976448 which persists on JDK 1.3.1. Also + * fixed bug in getPreferredHeight() method (DG); + * 29-Apr-2004 : Fixed bug in getPreferredWidth() method - see bug id + * 944173 (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * 08-Feb-2005 : Updated for changes in RectangleConstraint class (DG); + * 11-Feb-2005 : Implemented PublicCloneable (DG); + * 20-Apr-2005 : Added support for tooltips (DG); + * 26-Apr-2005 : Removed LOGGER (DG); + * 06-Jun-2005 : Modified equals() to handle GradientPaint (DG); + * 06-Jul-2005 : Added flag to control whether or not the title expands to + * fit the available space (DG); + * 07-Oct-2005 : Added textAlignment attribute (DG); + * ------------- JFREECHART 1.0.x RELEASED ------------------------------------ + * 13-Dec-2005 : Fixed bug 1379331 - incorrect drawing with LEFT or RIGHT + * title placement (DG); + * 19-Dec-2007 : Implemented some of the missing arrangement options (DG); + * 28-Apr-2008 : Added option for maximum lines, and fixed minor bugs in + * equals() method (DG); + * 19-Mar-2009 : Changed ChartEntity to TitleEntity - see patch 2603321 by + * Peter Kolb (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.title; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.Paint; +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.block.BlockResult; +import org.jfree.chart.block.EntityBlockParams; +import org.jfree.chart.block.LengthConstraintType; +import org.jfree.chart.block.RectangleConstraint; +import org.jfree.chart.entity.ChartEntity; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.entity.StandardEntityCollection; +import org.jfree.chart.entity.TitleEntity; +import org.jfree.chart.event.TitleChangeEvent; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.Range; +import org.jfree.io.SerialUtilities; +import org.jfree.text.G2TextMeasurer; +import org.jfree.text.TextBlock; +import org.jfree.text.TextBlockAnchor; +import org.jfree.text.TextUtilities; +import org.jfree.ui.HorizontalAlignment; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.Size2D; +import org.jfree.ui.VerticalAlignment; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PaintUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A chart title that displays a text string with automatic wrapping as + * required. + */ +public class TextTitle extends Title + implements Serializable, Cloneable, PublicCloneable { + + /** For serialization. */ + private static final long serialVersionUID = 8372008692127477443L; + + /** The default font. */ + public static final Font DEFAULT_FONT = new Font("SansSerif", Font.BOLD, + 12); + + /** The default text color. */ + public static final Paint DEFAULT_TEXT_PAINT = Color.black; + + /** The title text. */ + private String text; + + /** The font used to display the title. */ + private Font font; + + /** The text alignment. */ + private HorizontalAlignment textAlignment; + + /** The paint used to display the title text. */ + private transient Paint paint; + + /** The background paint. */ + private transient Paint backgroundPaint; + + /** The tool tip text (can be null). */ + private String toolTipText; + + /** The URL text (can be null). */ + private String urlText; + + /** The content. */ + private TextBlock content; + + /** + * A flag that controls whether the title expands to fit the available + * space.. + */ + private boolean expandToFitSpace = false; + + /** + * The maximum number of lines to display. + * + * @since 1.0.10 + */ + private int maximumLinesToDisplay = Integer.MAX_VALUE; + + /** + * Creates a new title, using default attributes where necessary. + */ + public TextTitle() { + this(""); + } + + /** + * Creates a new title, using default attributes where necessary. + * + * @param text the title text (null not permitted). + */ + public TextTitle(String text) { + this(text, TextTitle.DEFAULT_FONT, TextTitle.DEFAULT_TEXT_PAINT, + Title.DEFAULT_POSITION, Title.DEFAULT_HORIZONTAL_ALIGNMENT, + Title.DEFAULT_VERTICAL_ALIGNMENT, Title.DEFAULT_PADDING); + } + + /** + * Creates a new title, using default attributes where necessary. + * + * @param text the title text (null not permitted). + * @param font the title font (null not permitted). + */ + public TextTitle(String text, Font font) { + this(text, font, TextTitle.DEFAULT_TEXT_PAINT, Title.DEFAULT_POSITION, + Title.DEFAULT_HORIZONTAL_ALIGNMENT, + Title.DEFAULT_VERTICAL_ALIGNMENT, Title.DEFAULT_PADDING); + } + + /** + * Creates a new title. + * + * @param text the text for the title (null not permitted). + * @param font the title font (null not permitted). + * @param paint the title paint (null not permitted). + * @param position the title position (null not permitted). + * @param horizontalAlignment the horizontal alignment (null + * not permitted). + * @param verticalAlignment the vertical alignment (null not + * permitted). + * @param padding the space to leave around the outside of the title. + */ + public TextTitle(String text, Font font, Paint paint, + RectangleEdge position, + HorizontalAlignment horizontalAlignment, + VerticalAlignment verticalAlignment, + RectangleInsets padding) { + + super(position, horizontalAlignment, verticalAlignment, padding); + + if (text == null) { + throw new NullPointerException("Null 'text' argument."); + } + if (font == null) { + throw new NullPointerException("Null 'font' argument."); + } + if (paint == null) { + throw new NullPointerException("Null 'paint' argument."); + } + this.text = text; + this.font = font; + this.paint = paint; + // the textAlignment and the horizontalAlignment are separate things, + // but it makes sense for the default textAlignment to match the + // title's horizontal alignment... + this.textAlignment = horizontalAlignment; + this.backgroundPaint = null; + this.content = null; + this.toolTipText = null; + this.urlText = null; + + } + + /** + * Returns the title text. + * + * @return The text (never null). + * + * @see #setText(String) + */ + public String getText() { + return this.text; + } + + /** + * Sets the title to the specified text and sends a + * {@link TitleChangeEvent} to all registered listeners. + * + * @param text the text (null not permitted). + */ + public void setText(String text) { + ParamChecks.nullNotPermitted(text, "text"); + if (!this.text.equals(text)) { + this.text = text; + notifyListeners(new TitleChangeEvent(this)); + } + } + + /** + * Returns the text alignment. This controls how the text is aligned + * within the title's bounds, whereas the title's horizontal alignment + * controls how the title's bounding rectangle is aligned within the + * drawing space. + * + * @return The text alignment. + */ + public HorizontalAlignment getTextAlignment() { + return this.textAlignment; + } + + /** + * Sets the text alignment and sends a {@link TitleChangeEvent} to + * all registered listeners. + * + * @param alignment the alignment (null not permitted). + */ + public void setTextAlignment(HorizontalAlignment alignment) { + ParamChecks.nullNotPermitted(alignment, "alignment"); + this.textAlignment = alignment; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the font used to display the title string. + * + * @return The font (never null). + * + * @see #setFont(Font) + */ + public Font getFont() { + return this.font; + } + + /** + * Sets the font used to display the title string. Registered listeners + * are notified that the title has been modified. + * + * @param font the new font (null not permitted). + * + * @see #getFont() + */ + public void setFont(Font font) { + ParamChecks.nullNotPermitted(font, "font"); + if (!this.font.equals(font)) { + this.font = font; + notifyListeners(new TitleChangeEvent(this)); + } + } + + /** + * Returns the paint used to display the title string. + * + * @return The paint (never null). + * + * @see #setPaint(Paint) + */ + public Paint getPaint() { + return this.paint; + } + + /** + * Sets the paint used to display the title string. Registered listeners + * are notified that the title has been modified. + * + * @param paint the new paint (null not permitted). + * + * @see #getPaint() + */ + public void setPaint(Paint paint) { + ParamChecks.nullNotPermitted(paint, "paint"); + if (!this.paint.equals(paint)) { + this.paint = paint; + notifyListeners(new TitleChangeEvent(this)); + } + } + + /** + * Returns the background paint. + * + * @return The paint (possibly null). + */ + public Paint getBackgroundPaint() { + return this.backgroundPaint; + } + + /** + * Sets the background paint and sends a {@link TitleChangeEvent} to all + * registered listeners. If you set this attribute to null, + * no background is painted (which makes the title background transparent). + * + * @param paint the background paint (null permitted). + */ + public void setBackgroundPaint(Paint paint) { + this.backgroundPaint = paint; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the tool tip text. + * + * @return The tool tip text (possibly null). + */ + public String getToolTipText() { + return this.toolTipText; + } + + /** + * Sets the tool tip text to the specified text and sends a + * {@link TitleChangeEvent} to all registered listeners. + * + * @param text the text (null permitted). + */ + public void setToolTipText(String text) { + this.toolTipText = text; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the URL text. + * + * @return The URL text (possibly null). + */ + public String getURLText() { + return this.urlText; + } + + /** + * Sets the URL text to the specified text and sends a + * {@link TitleChangeEvent} to all registered listeners. + * + * @param text the text (null permitted). + */ + public void setURLText(String text) { + this.urlText = text; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the flag that controls whether or not the title expands to fit + * the available space. + * + * @return The flag. + */ + public boolean getExpandToFitSpace() { + return this.expandToFitSpace; + } + + /** + * Sets the flag that controls whether the title expands to fit the + * available space, and sends a {@link TitleChangeEvent} to all registered + * listeners. + * + * @param expand the flag. + */ + public void setExpandToFitSpace(boolean expand) { + this.expandToFitSpace = expand; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the maximum number of lines to display. + * + * @return The maximum. + * + * @since 1.0.10 + * + * @see #setMaximumLinesToDisplay(int) + */ + public int getMaximumLinesToDisplay() { + return this.maximumLinesToDisplay; + } + + /** + * Sets the maximum number of lines to display and sends a + * {@link TitleChangeEvent} to all registered listeners. + * + * @param max the maximum. + * + * @since 1.0.10. + * + * @see #getMaximumLinesToDisplay() + */ + public void setMaximumLinesToDisplay(int max) { + this.maximumLinesToDisplay = max; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Arranges the contents of the block, within the given constraints, and + * returns the block size. + * + * @param g2 the graphics device. + * @param constraint the constraint (null not permitted). + * + * @return The block size (in Java2D units, never null). + */ + @Override + public Size2D arrange(Graphics2D g2, RectangleConstraint constraint) { + RectangleConstraint cc = toContentConstraint(constraint); + LengthConstraintType w = cc.getWidthConstraintType(); + LengthConstraintType h = cc.getHeightConstraintType(); + Size2D contentSize = null; + if (w == LengthConstraintType.NONE) { + if (h == LengthConstraintType.NONE) { + contentSize = arrangeNN(g2); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not yet implemented."); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not yet implemented."); + } + } + else if (w == LengthConstraintType.RANGE) { + if (h == LengthConstraintType.NONE) { + contentSize = arrangeRN(g2, cc.getWidthRange()); + } + else if (h == LengthConstraintType.RANGE) { + contentSize = arrangeRR(g2, cc.getWidthRange(), + cc.getHeightRange()); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not yet implemented."); + } + } + else if (w == LengthConstraintType.FIXED) { + if (h == LengthConstraintType.NONE) { + contentSize = arrangeFN(g2, cc.getWidth()); + } + else if (h == LengthConstraintType.RANGE) { + throw new RuntimeException("Not yet implemented."); + } + else if (h == LengthConstraintType.FIXED) { + throw new RuntimeException("Not yet implemented."); + } + } + assert contentSize != null; // suppress compiler warning + return new Size2D(calculateTotalWidth(contentSize.getWidth()), + calculateTotalHeight(contentSize.getHeight())); + } + + /** + * Arranges the content for this title assuming no bounds on the width + * or the height, and returns the required size. This will reflect the + * fact that a text title positioned on the left or right of a chart will + * be rotated by 90 degrees. + * + * @param g2 the graphics target. + * + * @return The content size. + * + * @since 1.0.9 + */ + protected Size2D arrangeNN(Graphics2D g2) { + Range max = new Range(0.0, Float.MAX_VALUE); + return arrangeRR(g2, max, max); + } + + /** + * Arranges the content for this title assuming a fixed width and no bounds + * on the height, and returns the required size. This will reflect the + * fact that a text title positioned on the left or right of a chart will + * be rotated by 90 degrees. + * + * @param g2 the graphics target. + * @param w the width. + * + * @return The content size. + * + * @since 1.0.9 + */ + protected Size2D arrangeFN(Graphics2D g2, double w) { + RectangleEdge position = getPosition(); + if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) { + float maxWidth = (float) w; + g2.setFont(this.font); + this.content = TextUtilities.createTextBlock(this.text, this.font, + this.paint, maxWidth, this.maximumLinesToDisplay, + new G2TextMeasurer(g2)); + this.content.setLineAlignment(this.textAlignment); + Size2D contentSize = this.content.calculateDimensions(g2); + if (this.expandToFitSpace) { + return new Size2D(maxWidth, contentSize.getHeight()); + } + else { + return contentSize; + } + } + else if (position == RectangleEdge.LEFT || position + == RectangleEdge.RIGHT) { + float maxWidth = Float.MAX_VALUE; + g2.setFont(this.font); + this.content = TextUtilities.createTextBlock(this.text, this.font, + this.paint, maxWidth, this.maximumLinesToDisplay, + new G2TextMeasurer(g2)); + this.content.setLineAlignment(this.textAlignment); + Size2D contentSize = this.content.calculateDimensions(g2); + + // transpose the dimensions, because the title is rotated + if (this.expandToFitSpace) { + return new Size2D(contentSize.getHeight(), maxWidth); + } + else { + return new Size2D(contentSize.height, contentSize.width); + } + } + else { + throw new RuntimeException("Unrecognised exception."); + } + } + + /** + * Arranges the content for this title assuming a range constraint for the + * width and no bounds on the height, and returns the required size. This + * will reflect the fact that a text title positioned on the left or right + * of a chart will be rotated by 90 degrees. + * + * @param g2 the graphics target. + * @param widthRange the range for the width. + * + * @return The content size. + * + * @since 1.0.9 + */ + protected Size2D arrangeRN(Graphics2D g2, Range widthRange) { + Size2D s = arrangeNN(g2); + if (widthRange.contains(s.getWidth())) { + return s; + } + double ww = widthRange.constrain(s.getWidth()); + return arrangeFN(g2, ww); + } + + /** + * Returns the content size for the title. This will reflect the fact that + * a text title positioned on the left or right of a chart will be rotated + * 90 degrees. + * + * @param g2 the graphics device. + * @param widthRange the width range. + * @param heightRange the height range. + * + * @return The content size. + */ + protected Size2D arrangeRR(Graphics2D g2, Range widthRange, + Range heightRange) { + RectangleEdge position = getPosition(); + if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) { + float maxWidth = (float) widthRange.getUpperBound(); + g2.setFont(this.font); + this.content = TextUtilities.createTextBlock(this.text, this.font, + this.paint, maxWidth, this.maximumLinesToDisplay, + new G2TextMeasurer(g2)); + this.content.setLineAlignment(this.textAlignment); + Size2D contentSize = this.content.calculateDimensions(g2); + if (this.expandToFitSpace) { + return new Size2D(maxWidth, contentSize.getHeight()); + } + else { + return contentSize; + } + } + else if (position == RectangleEdge.LEFT || position + == RectangleEdge.RIGHT) { + float maxWidth = (float) heightRange.getUpperBound(); + g2.setFont(this.font); + this.content = TextUtilities.createTextBlock(this.text, this.font, + this.paint, maxWidth, this.maximumLinesToDisplay, + new G2TextMeasurer(g2)); + this.content.setLineAlignment(this.textAlignment); + Size2D contentSize = this.content.calculateDimensions(g2); + + // transpose the dimensions, because the title is rotated + if (this.expandToFitSpace) { + return new Size2D(contentSize.getHeight(), maxWidth); + } + else { + return new Size2D(contentSize.height, contentSize.width); + } + } + else { + throw new RuntimeException("Unrecognised exception."); + } + } + + /** + * Draws the title on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device. + * @param area the area allocated for the title. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + draw(g2, area, null); + } + + /** + * Draws the block within the specified area. + * + * @param g2 the graphics device. + * @param area the area. + * @param params if this is an instance of {@link EntityBlockParams} it + * is used to determine whether or not an + * {@link EntityCollection} is returned by this method. + * + * @return An {@link EntityCollection} containing a chart entity for the + * title, or null. + */ + @Override + public Object draw(Graphics2D g2, Rectangle2D area, Object params) { + if (this.content == null) { + return null; + } + area = trimMargin(area); + drawBorder(g2, area); + if (this.text.equals("")) { + return null; + } + ChartEntity entity = null; + if (params instanceof EntityBlockParams) { + EntityBlockParams p = (EntityBlockParams) params; + if (p.getGenerateEntities()) { + entity = new TitleEntity(area, this, this.toolTipText, + this.urlText); + } + } + area = trimBorder(area); + if (this.backgroundPaint != null) { + g2.setPaint(this.backgroundPaint); + g2.fill(area); + } + area = trimPadding(area); + RectangleEdge position = getPosition(); + if (position == RectangleEdge.TOP || position == RectangleEdge.BOTTOM) { + drawHorizontal(g2, area); + } + else if (position == RectangleEdge.LEFT + || position == RectangleEdge.RIGHT) { + drawVertical(g2, area); + } + BlockResult result = new BlockResult(); + if (entity != null) { + StandardEntityCollection sec = new StandardEntityCollection(); + sec.add(entity); + result.setEntityCollection(sec); + } + return result; + } + + /** + * Draws a the title horizontally within the specified area. This method + * will be called from the {@link #draw(Graphics2D, Rectangle2D) draw} + * method. + * + * @param g2 the graphics device. + * @param area the area for the title. + */ + protected void drawHorizontal(Graphics2D g2, Rectangle2D area) { + Rectangle2D titleArea = (Rectangle2D) area.clone(); + g2.setFont(this.font); + g2.setPaint(this.paint); + TextBlockAnchor anchor = null; + float x = 0.0f; + HorizontalAlignment horizontalAlignment = getHorizontalAlignment(); + if (horizontalAlignment == HorizontalAlignment.LEFT) { + x = (float) titleArea.getX(); + anchor = TextBlockAnchor.TOP_LEFT; + } + else if (horizontalAlignment == HorizontalAlignment.RIGHT) { + x = (float) titleArea.getMaxX(); + anchor = TextBlockAnchor.TOP_RIGHT; + } + else if (horizontalAlignment == HorizontalAlignment.CENTER) { + x = (float) titleArea.getCenterX(); + anchor = TextBlockAnchor.TOP_CENTER; + } + float y = 0.0f; + RectangleEdge position = getPosition(); + if (position == RectangleEdge.TOP) { + y = (float) titleArea.getY(); + } + else if (position == RectangleEdge.BOTTOM) { + y = (float) titleArea.getMaxY(); + if (horizontalAlignment == HorizontalAlignment.LEFT) { + anchor = TextBlockAnchor.BOTTOM_LEFT; + } + else if (horizontalAlignment == HorizontalAlignment.CENTER) { + anchor = TextBlockAnchor.BOTTOM_CENTER; + } + else if (horizontalAlignment == HorizontalAlignment.RIGHT) { + anchor = TextBlockAnchor.BOTTOM_RIGHT; + } + } + this.content.draw(g2, x, y, anchor); + } + + /** + * Draws a the title vertically within the specified area. This method + * will be called from the {@link #draw(Graphics2D, Rectangle2D) draw} + * method. + * + * @param g2 the graphics device. + * @param area the area for the title. + */ + protected void drawVertical(Graphics2D g2, Rectangle2D area) { + Rectangle2D titleArea = (Rectangle2D) area.clone(); + g2.setFont(this.font); + g2.setPaint(this.paint); + TextBlockAnchor anchor = null; + float y = 0.0f; + VerticalAlignment verticalAlignment = getVerticalAlignment(); + if (verticalAlignment == VerticalAlignment.TOP) { + y = (float) titleArea.getY(); + anchor = TextBlockAnchor.TOP_RIGHT; + } + else if (verticalAlignment == VerticalAlignment.BOTTOM) { + y = (float) titleArea.getMaxY(); + anchor = TextBlockAnchor.TOP_LEFT; + } + else if (verticalAlignment == VerticalAlignment.CENTER) { + y = (float) titleArea.getCenterY(); + anchor = TextBlockAnchor.TOP_CENTER; + } + float x = 0.0f; + RectangleEdge position = getPosition(); + if (position == RectangleEdge.LEFT) { + x = (float) titleArea.getX(); + } + else if (position == RectangleEdge.RIGHT) { + x = (float) titleArea.getMaxX(); + if (verticalAlignment == VerticalAlignment.TOP) { + anchor = TextBlockAnchor.BOTTOM_RIGHT; + } + else if (verticalAlignment == VerticalAlignment.CENTER) { + anchor = TextBlockAnchor.BOTTOM_CENTER; + } + else if (verticalAlignment == VerticalAlignment.BOTTOM) { + anchor = TextBlockAnchor.BOTTOM_LEFT; + } + } + this.content.draw(g2, x, y, anchor, x, y, -Math.PI / 2.0); + } + + /** + * Tests this title for equality with another object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TextTitle)) { + return false; + } + TextTitle that = (TextTitle) obj; + if (!ObjectUtilities.equal(this.text, that.text)) { + return false; + } + if (!ObjectUtilities.equal(this.font, that.font)) { + return false; + } + if (!PaintUtilities.equal(this.paint, that.paint)) { + return false; + } + if (this.textAlignment != that.textAlignment) { + return false; + } + if (!PaintUtilities.equal(this.backgroundPaint, that.backgroundPaint)) { + return false; + } + if (this.maximumLinesToDisplay != that.maximumLinesToDisplay) { + return false; + } + if (this.expandToFitSpace != that.expandToFitSpace) { + return false; + } + if (!ObjectUtilities.equal(this.toolTipText, that.toolTipText)) { + return false; + } + if (!ObjectUtilities.equal(this.urlText, that.urlText)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = super.hashCode(); + result = 29 * result + (this.text != null ? this.text.hashCode() : 0); + result = 29 * result + (this.font != null ? this.font.hashCode() : 0); + result = 29 * result + (this.paint != null ? this.paint.hashCode() : 0); + result = 29 * result + (this.backgroundPaint != null + ? this.backgroundPaint.hashCode() : 0); + return result; + } + + /** + * Returns a clone of this object. + * + * @return A clone. + * + * @throws CloneNotSupportedException never. + */ + @Override + 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.writePaint(this.backgroundPaint, 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.backgroundPaint = SerialUtilities.readPaint(stream); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/Title.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/Title.java new file mode 100755 index 0000000..2437e75 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/Title.java @@ -0,0 +1,462 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------- + * Title.java + * ---------- + * (C) Copyright 2000-2013, by David Berry and Contributors. + * + * Original Author: David Berry; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Nicolas Brodu; + * + * Changes (from 21-Aug-2001) + * -------------------------- + * 21-Aug-2001 : Added standard header (DG); + * 18-Sep-2001 : Updated header (DG); + * 14-Nov-2001 : Package com.jrefinery.common.ui.* changed to + * com.jrefinery.ui.* (DG); + * 07-Feb-2002 : Changed blank space around title from Insets --> Spacer, to + * allow for relative or absolute spacing (DG); + * 25-Jun-2002 : Removed unnecessary imports (DG); + * 01-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 14-Oct-2002 : Changed the event listener storage structure (DG); + * 11-Sep-2003 : Took care of listeners while cloning (NB); + * 22-Sep-2003 : Spacer cannot be null. Added nullpointer checks for this (TM); + * 08-Jan-2003 : Renamed AbstractTitle --> Title and moved to separate + * package (DG); + * 26-Oct-2004 : Refactored to implement Block interface, and removed redundant + * constants (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * 02-Feb-2005 : Changed Spacer --> RectangleInsets for padding (DG); + * 03-May-2005 : Fixed problem in equals() method (DG); + * 19-Sep-2008 : Added visibility flag (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.title; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.IOException; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.io.Serializable; + +import javax.swing.event.EventListenerList; + +import org.jfree.chart.block.AbstractBlock; +import org.jfree.chart.block.Block; +import org.jfree.chart.event.TitleChangeEvent; +import org.jfree.chart.event.TitleChangeListener; +import org.jfree.chart.util.ParamChecks; +import org.jfree.ui.HorizontalAlignment; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.VerticalAlignment; +import org.jfree.util.ObjectUtilities; + +/** + * The base class for all chart titles. A chart can have multiple titles, + * appearing at the top, bottom, left or right of the chart. + *

+ * Concrete implementations of this class will render text and images, and + * hence do the actual work of drawing titles. + */ +public abstract class Title extends AbstractBlock + implements Block, Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -6675162505277817221L; + + /** The default title position. */ + public static final RectangleEdge DEFAULT_POSITION = RectangleEdge.TOP; + + /** The default horizontal alignment. */ + public static final HorizontalAlignment + DEFAULT_HORIZONTAL_ALIGNMENT = HorizontalAlignment.CENTER; + + /** The default vertical alignment. */ + public static final VerticalAlignment + DEFAULT_VERTICAL_ALIGNMENT = VerticalAlignment.CENTER; + + /** Default title padding. */ + public static final RectangleInsets DEFAULT_PADDING = new RectangleInsets( + 1, 1, 1, 1); + + /** + * A flag that controls whether or not the title is visible. + * + * @since 1.0.11 + */ + public boolean visible; + + /** The title position. */ + private RectangleEdge position; + + /** The horizontal alignment of the title content. */ + private HorizontalAlignment horizontalAlignment; + + /** The vertical alignment of the title content. */ + private VerticalAlignment verticalAlignment; + + /** Storage for registered change listeners. */ + private transient EventListenerList listenerList; + + /** + * A flag that can be used to temporarily disable the listener mechanism. + */ + private boolean notify; + + /** + * Creates a new title, using default attributes where necessary. + */ + protected Title() { + this(Title.DEFAULT_POSITION, + Title.DEFAULT_HORIZONTAL_ALIGNMENT, + Title.DEFAULT_VERTICAL_ALIGNMENT, Title.DEFAULT_PADDING); + } + + /** + * Creates a new title, using default attributes where necessary. + * + * @param position the position of the title (null not + * permitted). + * @param horizontalAlignment the horizontal alignment of the title + * (null not permitted). + * @param verticalAlignment the vertical alignment of the title + * (null not permitted). + */ + protected Title(RectangleEdge position, + HorizontalAlignment horizontalAlignment, + VerticalAlignment verticalAlignment) { + + this(position, horizontalAlignment, verticalAlignment, + Title.DEFAULT_PADDING); + + } + + /** + * Creates a new title. + * + * @param position the position of the title (null not + * permitted). + * @param horizontalAlignment the horizontal alignment of the title (LEFT, + * CENTER or RIGHT, null not + * permitted). + * @param verticalAlignment the vertical alignment of the title (TOP, + * MIDDLE or BOTTOM, null not + * permitted). + * @param padding the amount of space to leave around the outside of the + * title (null not permitted). + */ + protected Title(RectangleEdge position, + HorizontalAlignment horizontalAlignment, + VerticalAlignment verticalAlignment, RectangleInsets padding) { + + ParamChecks.nullNotPermitted(position, "position"); + ParamChecks.nullNotPermitted(horizontalAlignment, "horizontalAlignment"); + ParamChecks.nullNotPermitted(verticalAlignment, "verticalAlignment"); + ParamChecks.nullNotPermitted(padding, "padding"); + + this.visible = true; + this.position = position; + this.horizontalAlignment = horizontalAlignment; + this.verticalAlignment = verticalAlignment; + setPadding(padding); + this.listenerList = new EventListenerList(); + this.notify = true; + } + + /** + * Returns a flag that controls whether or not the title should be + * drawn. The default value is true. + * + * @return A boolean. + * + * @see #setVisible(boolean) + * + * @since 1.0.11 + */ + public boolean isVisible() { + return this.visible; + } + + /** + * Sets a flag that controls whether or not the title should be drawn, and + * sends a {@link TitleChangeEvent} to all registered listeners. + * + * @param visible the new flag value. + * + * @see #isVisible() + * + * @since 1.0.11 + */ + public void setVisible(boolean visible) { + this.visible = visible; + notifyListeners(new TitleChangeEvent(this)); + } + + /** + * Returns the position of the title. + * + * @return The title position (never null). + */ + public RectangleEdge getPosition() { + return this.position; + } + + /** + * Sets the position for the title and sends a {@link TitleChangeEvent} to + * all registered listeners. + * + * @param position the position (null not permitted). + */ + public void setPosition(RectangleEdge position) { + ParamChecks.nullNotPermitted(position, "position"); + if (this.position != position) { + this.position = position; + notifyListeners(new TitleChangeEvent(this)); + } + } + + /** + * Returns the horizontal alignment of the title. + * + * @return The horizontal alignment (never null). + */ + public HorizontalAlignment getHorizontalAlignment() { + return this.horizontalAlignment; + } + + /** + * Sets the horizontal alignment for the title and sends a + * {@link TitleChangeEvent} to all registered listeners. + * + * @param alignment the horizontal alignment (null not + * permitted). + */ + public void setHorizontalAlignment(HorizontalAlignment alignment) { + ParamChecks.nullNotPermitted(alignment, "alignment"); + if (this.horizontalAlignment != alignment) { + this.horizontalAlignment = alignment; + notifyListeners(new TitleChangeEvent(this)); + } + } + + /** + * Returns the vertical alignment of the title. + * + * @return The vertical alignment (never null). + */ + public VerticalAlignment getVerticalAlignment() { + return this.verticalAlignment; + } + + /** + * Sets the vertical alignment for the title, and notifies any registered + * listeners of the change. + * + * @param alignment the new vertical alignment (TOP, MIDDLE or BOTTOM, + * null not permitted). + */ + public void setVerticalAlignment(VerticalAlignment alignment) { + ParamChecks.nullNotPermitted(alignment, "alignment"); + if (this.verticalAlignment != alignment) { + this.verticalAlignment = alignment; + notifyListeners(new TitleChangeEvent(this)); + } + } + + /** + * Returns the flag that indicates whether or not the notification + * mechanism is enabled. + * + * @return The flag. + */ + public boolean getNotify() { + return this.notify; + } + + /** + * Sets the flag that indicates whether or not the notification mechanism + * is enabled. There are certain situations (such as cloning) where you + * want to turn notification off temporarily. + * + * @param flag the new value of the flag. + */ + public void setNotify(boolean flag) { + this.notify = flag; + if (flag) { + notifyListeners(new TitleChangeEvent(this)); + } + } + + /** + * Draws the title on a Java 2D graphics device (such as the screen or a + * printer). + * + * @param g2 the graphics device. + * @param area the area allocated for the title (subclasses should not + * draw outside this area). + */ + @Override + public abstract void draw(Graphics2D g2, Rectangle2D area); + + /** + * Returns a clone of the title. + *

+ * One situation when this is useful is when editing the title properties - + * you can edit a clone, and then it is easier to cancel the changes if + * necessary. + * + * @return A clone of the title. + * + * @throws CloneNotSupportedException not thrown by this class, but it may + * be thrown by subclasses. + */ + @Override + public Object clone() throws CloneNotSupportedException { + Title duplicate = (Title) super.clone(); + duplicate.listenerList = new EventListenerList(); + // RectangleInsets is immutable => same reference in clone OK + return duplicate; + } + + /** + * Registers an object for notification of changes to the title. + * + * @param listener the object that is being registered. + */ + public void addChangeListener(TitleChangeListener listener) { + this.listenerList.add(TitleChangeListener.class, listener); + } + + /** + * Unregisters an object for notification of changes to the chart title. + * + * @param listener the object that is being unregistered. + */ + public void removeChangeListener(TitleChangeListener listener) { + this.listenerList.remove(TitleChangeListener.class, listener); + } + + /** + * Notifies all registered listeners that the chart title has changed in + * some way. + * + * @param event an object that contains information about the change to + * the title. + */ + protected void notifyListeners(TitleChangeEvent event) { + if (this.notify) { + Object[] listeners = this.listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == TitleChangeListener.class) { + ((TitleChangeListener) listeners[i + 1]).titleChanged( + event); + } + } + } + } + + /** + * Tests an object for equality with this title. + * + * @param obj the object (null not permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Title)) { + return false; + } + Title that = (Title) obj; + if (this.visible != that.visible) { + return false; + } + if (this.position != that.position) { + return false; + } + if (this.horizontalAlignment != that.horizontalAlignment) { + return false; + } + if (this.verticalAlignment != that.verticalAlignment) { + return false; + } + if (this.notify != that.notify) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hashcode for the title. + * + * @return The hashcode. + */ + @Override + public int hashCode() { + int result = 193; + result = 37 * result + ObjectUtilities.hashCode(this.position); + result = 37 * result + + ObjectUtilities.hashCode(this.horizontalAlignment); + result = 37 * result + ObjectUtilities.hashCode(this.verticalAlignment); + 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(); + } + + /** + * 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.listenerList = new EventListenerList(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/package.html new file mode 100755 index 0000000..8f2cb86 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/title/package.html @@ -0,0 +1,6 @@ + + + +Classes used to display chart titles and subtitles. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/CategoryURLGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/CategoryURLGenerator.java new file mode 100755 index 0000000..fa8d628 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/CategoryURLGenerator.java @@ -0,0 +1,78 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * CategoryURLGenerator.java + * ------------------------- + * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributors: David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 05-Aug-2002 : Version 1, contributed by Richard Atkinson; + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 10-Apr-2003 : Replaced reference to CategoryDataset with + * KeyedValues2DDataset (DG); + * 23-Apr-2003 : Switched around CategoryDataset and KeyedValues2DDataset + * (again) (DG); + * 13-Aug-2003 : Added clone() method (DG); + * 14-Jun-2004 : Removed clone() method - classes that implement the interface + * should implement the PublicCloneable interface instead, + * wherever possible (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * 13-Dec-2007 : Updated API docs (DG); + * + */ + +package org.jfree.chart.urls; + +import org.jfree.data.category.CategoryDataset; + +/** + * A URL generator for items in a {@link CategoryDataset}. + */ +public interface CategoryURLGenerator { + + /** + * Returns a URL for one item in a dataset. As a guideline, the URL + * should be valid within the context of an XHTML 1.0 document. Classes + * that implement this interface are responsible for correctly escaping + * any text that is derived from the dataset, as this may be user-specified + * and could pose a security risk. + * + * @param dataset the dataset. + * @param series the series (zero-based index). + * @param category the category. + * + * @return A string containing the URL. + */ + public String generateURL(CategoryDataset dataset, int series, + int category); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/CustomCategoryURLGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/CustomCategoryURLGenerator.java new file mode 100755 index 0000000..863fc6b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/CustomCategoryURLGenerator.java @@ -0,0 +1,200 @@ +/* ====================================== + * JFreeChart : a free Java chart library + * ====================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * CustomCategoryURLGenerator.java + * ------------------------------- + * (C) Copyright 2008, by Diego Pierangeli and Contributors. + * + * Original Author: Diego Pierangeli; + * Contributors: David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 23-Apr-2008 : Version 1, contributed by Diego Pierangeli based on + * CustomXYURLGenerator by Richard Atkinson, with some + * modifications by David Gilbert(DG); + * + */ +package org.jfree.chart.urls; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.jfree.data.category.CategoryDataset; +import org.jfree.util.PublicCloneable; + +/** + * A custom URL generator. + */ +public class CustomCategoryURLGenerator implements CategoryURLGenerator, + Cloneable, PublicCloneable, Serializable { + + /** Storage for the URLs. */ + private ArrayList urlSeries = new ArrayList(); + + /** + * Default constructor. + */ + public CustomCategoryURLGenerator() { + super(); + } + + /** + * Returns the number of URL lists stored by the renderer. + * + * @return The list count. + */ + public int getListCount() { + return this.urlSeries.size(); + } + + /** + * Returns the number of URLs in a given list. + * + * @param list the list index (zero based). + * + * @return The URL count. + */ + public int getURLCount(int list) { + int result = 0; + List urls = (List) this.urlSeries.get(list); + if (urls != null) { + result = urls.size(); + } + return result; + } + + /** + * Returns the URL for an item. + * + * @param series the series index. + * @param item the item index. + * + * @return The URL (possibly null). + */ + public String getURL(int series, int item) { + String result = null; + if (series < getListCount()) { + List urls = (List) this.urlSeries.get(series); + if (urls != null) { + if (item < urls.size()) { + result = (String) urls.get(item); + } + } + } + return result; + } + + /** + * Generates a URL. + * + * @param dataset the dataset (ignored in this implementation). + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return A string containing the URL (possibly null). + */ + @Override + public String generateURL(CategoryDataset dataset, int series, int item) { + return getURL(series, item); + } + + /** + * Adds a list of URLs. + * + * @param urls the list of URLs (null permitted). + */ + public void addURLSeries(List urls) { + List listToAdd = null; + if (urls != null) { + listToAdd = new java.util.ArrayList(urls); + } + this.urlSeries.add(listToAdd); + } + + /** + * Tests if this object is equal to another. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CustomCategoryURLGenerator)) { + return false; + } + CustomCategoryURLGenerator generator = (CustomCategoryURLGenerator) obj; + int listCount = getListCount(); + if (listCount != generator.getListCount()) { + return false; + } + + for (int series = 0; series < listCount; series++) { + int urlCount = getURLCount(series); + if (urlCount != generator.getURLCount(series)) { + return false; + } + + for (int item = 0; item < urlCount; item++) { + String u1 = getURL(series, item); + String u2 = generator.getURL(series, item); + if (u1 != null) { + if (!u1.equals(u2)) { + return false; + } + } else { + if (u2 != null) { + return false; + } + } + } + } + return true; + } + + /** + * Returns a new generator that is a copy of, and independent from, this + * generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem with cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + CustomCategoryURLGenerator clone + = (CustomCategoryURLGenerator) super.clone(); + clone.urlSeries = new java.util.ArrayList(this.urlSeries); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/CustomPieURLGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/CustomPieURLGenerator.java new file mode 100755 index 0000000..b4419e4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/CustomPieURLGenerator.java @@ -0,0 +1,226 @@ +/* ====================================== + * JFreeChart : a free Java chart library + * ====================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * CustomPieURLGenerator.java + * -------------------------- + * (C) Copyright 2004-2008, by David Basten and Contributors. + * + * Original Author: David Basten; + * Contributors: -; + * + * Changes: + * -------- + * 04-Feb-2004 : Version 1, contributed by David Basten based on + * CustomXYURLGenerator by Richard Atkinson (added to main source + * tree on 25-May-2004); + * + */ + +package org.jfree.chart.urls; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; +import java.util.Set; + +import org.jfree.chart.plot.MultiplePiePlot; +import org.jfree.data.general.PieDataset; +import org.jfree.util.PublicCloneable; + +/** + * A custom URL generator for pie charts. + */ +public class CustomPieURLGenerator implements PieURLGenerator, + Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7100607670144900503L; + + /** Storage for the URLs. */ + private ArrayList urls; + + /** + * Creates a new CustomPieURLGenerator instance, initially + * empty. Call {@link #addURLs(Map)} to specify the URL fragments to be + * used. + */ + public CustomPieURLGenerator() { + this.urls = new ArrayList(); + } + + /** + * Generates a URL fragment. + * + * @param dataset the dataset (ignored). + * @param key the item key. + * @param pieIndex the pie index. + * + * @return A string containing the generated URL. + * + * @see #getURL(Comparable, int) + */ + @Override + public String generateURL(PieDataset dataset, Comparable key, + int pieIndex) { + return getURL(key, pieIndex); + } + + /** + * Returns the number of URL maps stored by the renderer. + * + * @return The list count. + * + * @see #addURLs(Map) + */ + public int getListCount() { + return this.urls.size(); + } + + /** + * Returns the number of URLs in a given map (specified by its position + * in the map list). + * + * @param list the list index (zero based). + * + * @return The URL count. + * + * @see #getListCount() + */ + public int getURLCount(int list) { + int result = 0; + Map urlMap = (Map) this.urls.get(list); + if (urlMap != null) { + result = urlMap.size(); + } + return result; + } + + /** + * Returns the URL for a section in the specified map. + * + * @param key the key. + * @param mapIndex the map index. + * + * @return The URL. + */ + public String getURL(Comparable key, int mapIndex) { + String result = null; + if (mapIndex < getListCount()) { + Map urlMap = (Map) this.urls.get(mapIndex); + if (urlMap != null) { + result = (String) urlMap.get(key); + } + } + return result; + } + + /** + * Adds a map containing (key, URL) mappings where each + * key is an instance of Comparable + * (corresponding to the key for an item in a pie dataset) and each + * URL is a String representing a URL fragment. + *

+ * The map is appended to an internal list...you can add multiple maps + * if you are working with, say, a {@link MultiplePiePlot}. + * + * @param urlMap the URLs (null permitted). + */ + public void addURLs(Map urlMap) { + this.urls.add(urlMap); + } + + /** + * Tests if this object is equal to another. + * + * @param o the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object o) { + + if (o == this) { + return true; + } + + if (o instanceof CustomPieURLGenerator) { + CustomPieURLGenerator generator = (CustomPieURLGenerator) o; + if (getListCount() != generator.getListCount()) { + return false; + } + Set keySet; + for (int pieItem = 0; pieItem < getListCount(); pieItem++) { + if (getURLCount(pieItem) != generator.getURLCount(pieItem)) { + return false; + } + keySet = ((HashMap) this.urls.get(pieItem)).keySet(); + String key; + for (Iterator i = keySet.iterator(); i.hasNext();) { + key = (String) i.next(); + if (!getURL(key, pieItem).equals( + generator.getURL(key, pieItem))) { + return false; + } + } + } + return true; + } + return false; + } + + /** + * Returns a clone of the generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException if cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + CustomPieURLGenerator urlGen = new CustomPieURLGenerator(); + Map map; + Map newMap; + String key; + + for (Iterator i = this.urls.iterator(); i.hasNext();) { + map = (Map) i.next(); + + newMap = new HashMap(); + for (Iterator j = map.keySet().iterator(); j.hasNext();) { + key = (String) j.next(); + newMap.put(key, map.get(key)); + } + + urlGen.addURLs(newMap); + } + + return urlGen; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/CustomXYURLGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/CustomXYURLGenerator.java new file mode 100755 index 0000000..68edb9d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/CustomXYURLGenerator.java @@ -0,0 +1,211 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * CustomXYURLGenerator.java + * ------------------------- + * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributors: David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 05-Aug-2002 : Version 1, contributed by Richard Atkinson; + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 23-Mar-2003 : Implemented Serializable (DG); + * 20-Jan-2005 : Minor Javadoc update (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * 11-Apr-2008 : Implemented Cloneable, otherwise charts using this URL + * generator will fail to clone (DG); + * + */ + +package org.jfree.chart.urls; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.jfree.data.xy.XYDataset; +import org.jfree.util.PublicCloneable; + +/** + * A custom URL generator. + */ +public class CustomXYURLGenerator implements XYURLGenerator, Cloneable, + PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -8565933356596551832L; + + /** Storage for the URLs. */ + private ArrayList urlSeries = new ArrayList(); + + /** + * Default constructor. + */ + public CustomXYURLGenerator() { + super(); + } + + /** + * Returns the number of URL lists stored by the renderer. + * + * @return The list count. + */ + public int getListCount() { + return this.urlSeries.size(); + } + + /** + * Returns the number of URLs in a given list. + * + * @param list the list index (zero based). + * + * @return The URL count. + */ + public int getURLCount(int list) { + int result = 0; + List urls = (List) this.urlSeries.get(list); + if (urls != null) { + result = urls.size(); + } + return result; + } + + /** + * Returns the URL for an item. + * + * @param series the series index. + * @param item the item index. + * + * @return The URL (possibly null). + */ + public String getURL(int series, int item) { + String result = null; + if (series < getListCount()) { + List urls = (List) this.urlSeries.get(series); + if (urls != null) { + if (item < urls.size()) { + result = (String) urls.get(item); + } + } + } + return result; + } + + /** + * Generates a URL. + * + * @param dataset the dataset. + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return A string containing the URL (possibly null). + */ + @Override + public String generateURL(XYDataset dataset, int series, int item) { + return getURL(series, item); + } + + /** + * Adds a list of URLs. + * + * @param urls the list of URLs (null permitted, the list + * is copied). + */ + public void addURLSeries(List urls) { + List listToAdd = null; + if (urls != null) { + listToAdd = new java.util.ArrayList(urls); + } + this.urlSeries.add(listToAdd); + } + + /** + * Tests this generator for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CustomXYURLGenerator)) { + return false; + } + CustomXYURLGenerator that = (CustomXYURLGenerator) obj; + int listCount = getListCount(); + if (listCount != that.getListCount()) { + return false; + } + + for (int series = 0; series < listCount; series++) { + int urlCount = getURLCount(series); + if (urlCount != that.getURLCount(series)) { + return false; + } + + for (int item = 0; item < urlCount; item++) { + String u1 = getURL(series, item); + String u2 = that.getURL(series, item); + if (u1 != null) { + if (!u1.equals(u2)) { + return false; + } + } + else { + if (u2 != null) { + return false; + } + } + } + } + return true; + + } + + /** + * Returns a new generator that is a copy of, and independent from, this + * generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem with cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + CustomXYURLGenerator clone = (CustomXYURLGenerator) super.clone(); + clone.urlSeries = new java.util.ArrayList(this.urlSeries); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/PieURLGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/PieURLGenerator.java new file mode 100755 index 0000000..a1c4a92 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/PieURLGenerator.java @@ -0,0 +1,80 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * PieURLGenerator.java + * -------------------- + * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributors: David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 05-Aug-2002 : Version 1, contributed by Richard Atkinson; + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 07-Mar-2003 : Modified to use KeyedValuesDataset and added pieIndex + * parameter (DG); + * 24-Apr-2003 : Switched around PieDataset and KeyedValuesDataset (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 24-Nov-2006 : Updated API docs (DG); + * 13-Dec-2007 : Updated API docs (DG); + * + */ + +package org.jfree.chart.urls; + +import org.jfree.data.general.PieDataset; + +/** + * Interface for a URL generator for plots that use data from a + * {@link PieDataset}. Classes that implement this interface: + *

    + *
  • are responsible for correctly escaping any text that is derived from the + * dataset, as this may be user-specified and could pose a security + * risk;
  • + *
  • should be either (a) immutable, or (b) cloneable via the + * PublicCloneable interface (defined in the JCommon class + * library). This provides a mechanism for the referring plot to clone + * the generator if necessary.
  • + *
+ */ +public interface PieURLGenerator { + + /** + * Generates a URL for one item in a {@link PieDataset}. As a guideline, + * the URL should be valid within the context of an XHTML 1.0 document. + * + * @param dataset the dataset (null not permitted). + * @param key the item key (null not permitted). + * @param pieIndex the pie index (differentiates between pies in a + * 'multi' pie chart). + * + * @return A string containing the URL. + */ + public String generateURL(PieDataset dataset, Comparable key, int pieIndex); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/StandardCategoryURLGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/StandardCategoryURLGenerator.java new file mode 100755 index 0000000..e18a9b6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/StandardCategoryURLGenerator.java @@ -0,0 +1,210 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * StandardCategoryURLGenerator.java + * --------------------------------- + * (C) Copyright 2002-2013, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributors: David Gilbert (for Object Refinery Limited); + * Cleland Early; + * + * Changes: + * -------- + * 05-Aug-2002 : Version 1, contributed by Richard Atkinson; + * 29-Aug-2002 : Reversed seriesParameterName and itemParameterName in + * constructor. Never should have been the other way round. + * Also updated JavaDoc (RA); + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 05-Nov-2002 : Base dataset is now TableDataset not CategoryDataset (DG); + * 23-Mar-2003 : Implemented Serializable (DG); + * 13-Aug-2003 : Implemented Cloneable (DG); + * 23-Dec-2003 : Added fix for bug 861282 (DG); + * 21-May-2004 : Added URL encoding - see patch 947854 (DG); + * 13-Jan-2004 : Fixed for compliance with XHTML 1.0 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * 17-Apr-2007 : Use new URLUtilities class to encode URLs (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.urls; + +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.category.CategoryDataset; +import org.jfree.util.ObjectUtilities; + +/** + * A URL generator that can be assigned to a + * {@link org.jfree.chart.renderer.category.CategoryItemRenderer}. + */ +public class StandardCategoryURLGenerator implements CategoryURLGenerator, + Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 2276668053074881909L; + + /** Prefix to the URL */ + private String prefix = "index.html"; + + /** Series parameter name to go in each URL */ + private String seriesParameterName = "series"; + + /** Category parameter name to go in each URL */ + private String categoryParameterName = "category"; + + /** + * Creates a new generator with default settings. + */ + public StandardCategoryURLGenerator() { + super(); + } + + /** + * Constructor that overrides default prefix to the URL. + * + * @param prefix the prefix to the URL (null not permitted). + */ + public StandardCategoryURLGenerator(String prefix) { + ParamChecks.nullNotPermitted(prefix, "prefix"); + this.prefix = prefix; + } + + /** + * Constructor that overrides all the defaults. + * + * @param prefix the prefix to the URL (null not permitted). + * @param seriesParameterName the name of the series parameter to go in + * each URL (null not permitted). + * @param categoryParameterName the name of the category parameter to go in + * each URL (null not permitted). + */ + public StandardCategoryURLGenerator(String prefix, + String seriesParameterName, String categoryParameterName) { + + ParamChecks.nullNotPermitted(prefix, "prefix"); + ParamChecks.nullNotPermitted(seriesParameterName, "seriesParameterName"); + ParamChecks.nullNotPermitted(categoryParameterName, "categoryParameterName"); + this.prefix = prefix; + this.seriesParameterName = seriesParameterName; + this.categoryParameterName = categoryParameterName; + + } + + /** + * Generates a URL for a particular item within a series. + * + * @param dataset the dataset. + * @param series the series index (zero-based). + * @param category the category index (zero-based). + * + * @return The generated URL. + */ + @Override + public String generateURL(CategoryDataset dataset, int series, + int category) { + String url = this.prefix; + Comparable seriesKey = dataset.getRowKey(series); + Comparable categoryKey = dataset.getColumnKey(category); + boolean firstParameter = url.indexOf("?") == -1; + url += firstParameter ? "?" : "&"; + url += this.seriesParameterName + "=" + URLUtilities.encode( + seriesKey.toString(), "UTF-8"); + url += "&" + this.categoryParameterName + "=" + + URLUtilities.encode(categoryKey.toString(), "UTF-8"); + return url; + } + + /** + * Returns an independent copy of the URL generator. + * + * @return A clone. + * + * @throws CloneNotSupportedException not thrown by this class, but + * subclasses (if any) might. + */ + @Override + public Object clone() throws CloneNotSupportedException { + // all attributes are immutable, so we can just return the super.clone() + // FIXME: in fact, the generator itself is immutable, so cloning is + // not necessary + return super.clone(); + } + + /** + * Tests the generator for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardCategoryURLGenerator)) { + return false; + } + StandardCategoryURLGenerator that = (StandardCategoryURLGenerator) obj; + if (!ObjectUtilities.equal(this.prefix, that.prefix)) { + return false; + } + + if (!ObjectUtilities.equal(this.seriesParameterName, + that.seriesParameterName)) { + return false; + } + if (!ObjectUtilities.equal(this.categoryParameterName, + that.categoryParameterName)) { + return false; + } + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result; + result = (this.prefix != null ? this.prefix.hashCode() : 0); + result = 29 * result + + (this.seriesParameterName != null + ? this.seriesParameterName.hashCode() : 0); + result = 29 * result + + (this.categoryParameterName != null + ? this.categoryParameterName.hashCode() : 0); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/StandardPieURLGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/StandardPieURLGenerator.java new file mode 100755 index 0000000..f0788f5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/StandardPieURLGenerator.java @@ -0,0 +1,179 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * StandardPieURLGenerator.java + * ---------------------------- + * (C) Copyright 2002-2013, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributors: David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 05-Aug-2002 : Version 1, contributed by Richard Atkinson; + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 07-Mar-2003 : Modified to use KeyedValuesDataset and added pieIndex + * parameter (DG); + * 21-Mar-2003 : Implemented Serializable (DG); + * 24-Apr-2003 : Switched around PieDataset and KeyedValuesDataset (DG); + * 31-Mar-2004 : Added an optional 'pieIndex' parameter (DG); + * 13-Jan-2005 : Fixed for compliance with XHTML 1.0 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 24-Nov-2006 : Fixed equals() method and added argument checks (DG); + * 17-Apr-2007 : Encode section key in generateURL() (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.urls; + +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.general.PieDataset; +import org.jfree.util.ObjectUtilities; + +/** + * A URL generator for pie charts. Instances of this class are immutable. + */ +public class StandardPieURLGenerator implements PieURLGenerator, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 1626966402065883419L; + + /** The prefix. */ + private String prefix = "index.html"; + + /** The category parameter name. */ + private String categoryParameterName = "category"; + + /** The pie index parameter name. */ + private String indexParameterName = "pieIndex"; + + /** + * Default constructor. + */ + public StandardPieURLGenerator() { + this("index.html"); + } + + /** + * Creates a new generator. + * + * @param prefix the prefix (null not permitted). + */ + public StandardPieURLGenerator(String prefix) { + this(prefix, "category"); + } + + /** + * Creates a new generator. + * + * @param prefix the prefix (null not permitted). + * @param categoryParameterName the category parameter name + * (null not permitted). + */ + public StandardPieURLGenerator(String prefix, + String categoryParameterName) { + this(prefix, categoryParameterName, "pieIndex"); + } + + /** + * Creates a new generator. + * + * @param prefix the prefix (null not permitted). + * @param categoryParameterName the category parameter name + * (null not permitted). + * @param indexParameterName the index parameter name (null + * permitted). + */ + public StandardPieURLGenerator(String prefix, String categoryParameterName, + String indexParameterName) { + ParamChecks.nullNotPermitted(prefix, "prefix"); + ParamChecks.nullNotPermitted(categoryParameterName, "categoryParameterName"); + this.prefix = prefix; + this.categoryParameterName = categoryParameterName; + this.indexParameterName = indexParameterName; + } + + /** + * Generates a URL. + * + * @param dataset the dataset (ignored). + * @param key the item key (null not permitted). + * @param pieIndex the pie index. + * + * @return A string containing the generated URL. + */ + @Override + public String generateURL(PieDataset dataset, Comparable key, + int pieIndex) { + String url = this.prefix; + if (url.indexOf("?") > -1) { + url += "&" + this.categoryParameterName + "=" + + URLUtilities.encode(key.toString(), "UTF-8"); + } + else { + url += "?" + this.categoryParameterName + "=" + + URLUtilities.encode(key.toString(), "UTF-8"); + } + if (this.indexParameterName != null) { + url += "&" + this.indexParameterName + "=" + + String.valueOf(pieIndex); + } + return url; + } + + /** + * Tests if this object is equal to another. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardPieURLGenerator)) { + return false; + } + StandardPieURLGenerator that = (StandardPieURLGenerator) obj; + if (!this.prefix.equals(that.prefix)) { + return false; + } + if (!this.categoryParameterName.equals(that.categoryParameterName)) { + return false; + } + if (!ObjectUtilities.equal(this.indexParameterName, + that.indexParameterName)) { + return false; + } + return true; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/StandardXYURLGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/StandardXYURLGenerator.java new file mode 100755 index 0000000..02495e9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/StandardXYURLGenerator.java @@ -0,0 +1,173 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * StandardXYURLGenerator.java + * --------------------------- + * (C) Copyright 2002-2013, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributors: David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 05-Aug-2002 : Version 1, contributed by Richard Atkinson; + * 29-Aug-2002 : New constructor and member variables to customise series and + * item parameter names (RA); + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 23-Mar-2003 : Implemented Serializable (DG); + * 01-Mar-2004 : Added equals() method (DG); + * 13-Jan-2005 : Modified for XHTML 1.0 compliance (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.urls; + +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.xy.XYDataset; +import org.jfree.util.ObjectUtilities; + +/** + * A URL generator. + */ +public class StandardXYURLGenerator implements XYURLGenerator, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -1771624523496595382L; + + /** The default prefix. */ + public static final String DEFAULT_PREFIX = "index.html"; + + /** The default series parameter. */ + public static final String DEFAULT_SERIES_PARAMETER = "series"; + + /** The default item parameter. */ + public static final String DEFAULT_ITEM_PARAMETER = "item"; + + /** Prefix to the URL */ + private String prefix; + + /** Series parameter name to go in each URL */ + private String seriesParameterName; + + /** Item parameter name to go in each URL */ + private String itemParameterName; + + /** + * Creates a new default generator. This constructor is equivalent to + * calling StandardXYURLGenerator("index.html", "series", "item"); + * . + */ + public StandardXYURLGenerator() { + this(DEFAULT_PREFIX, DEFAULT_SERIES_PARAMETER, DEFAULT_ITEM_PARAMETER); + } + + /** + * Creates a new generator with the specified prefix. This constructor + * is equivalent to calling + * StandardXYURLGenerator(prefix, "series", "item");. + * + * @param prefix the prefix to the URL (null not permitted). + */ + public StandardXYURLGenerator(String prefix) { + this(prefix, DEFAULT_SERIES_PARAMETER, DEFAULT_ITEM_PARAMETER); + } + + /** + * Constructor that overrides all the defaults + * + * @param prefix the prefix to the URL (null not permitted). + * @param seriesParameterName the name of the series parameter to go in + * each URL (null not permitted). + * @param itemParameterName the name of the item parameter to go in each + * URL (null not permitted). + */ + public StandardXYURLGenerator(String prefix, String seriesParameterName, + String itemParameterName) { + ParamChecks.nullNotPermitted(prefix, "prefix"); + ParamChecks.nullNotPermitted(seriesParameterName, "seriesParameterName"); + ParamChecks.nullNotPermitted(itemParameterName, "itemParameterName"); + this.prefix = prefix; + this.seriesParameterName = seriesParameterName; + this.itemParameterName = itemParameterName; + } + + /** + * Generates a URL for a particular item within a series. + * + * @param dataset the dataset. + * @param series the series number (zero-based index). + * @param item the item number (zero-based index). + * + * @return The generated URL. + */ + @Override + public String generateURL(XYDataset dataset, int series, int item) { + // TODO: URLEncode? + String url = this.prefix; + boolean firstParameter = url.indexOf("?") == -1; + url += firstParameter ? "?" : "&"; + url += this.seriesParameterName + "=" + series + + "&" + this.itemParameterName + "=" + item; + return url; + } + + /** + * Tests this generator for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof StandardXYURLGenerator)) { + return false; + } + StandardXYURLGenerator that = (StandardXYURLGenerator) obj; + if (!ObjectUtilities.equal(that.prefix, this.prefix)) { + return false; + } + if (!ObjectUtilities.equal(that.seriesParameterName, + this.seriesParameterName)) { + return false; + } + if (!ObjectUtilities.equal(that.itemParameterName, + this.itemParameterName)) { + return false; + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/StandardXYZURLGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/StandardXYZURLGenerator.java new file mode 100755 index 0000000..d041174 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/StandardXYZURLGenerator.java @@ -0,0 +1,65 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * StandardXYZURLGenerator.java + * ---------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributors: -; + * + * Changes: + * -------- + * 03-Feb-2003 : Version 1 (DG); + * + */ + +package org.jfree.chart.urls; + +import org.jfree.data.xy.XYZDataset; + +/** + * A URL generator. + */ +public class StandardXYZURLGenerator extends StandardXYURLGenerator + implements XYZURLGenerator { + + /** + * Generates a URL for a particular item within a series. + * + * @param dataset the dataset. + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return A string containing the generated URL. + */ + @Override + public String generateURL(XYZDataset dataset, int series, int item) { + return super.generateURL(dataset, series, item); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/TimeSeriesURLGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/TimeSeriesURLGenerator.java new file mode 100755 index 0000000..9bb9bae --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/TimeSeriesURLGenerator.java @@ -0,0 +1,217 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * TimeSeriesURLGenerator.java + * --------------------------- + * (C) Copyright 2002-2013, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributors: David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 29-Aug-2002 : Initial version (RA); + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 23-Mar-2003 : Implemented Serializable (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 13-Jan-2005 : Modified for XHTML 1.0 compliance (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 06-Jul-2006 : Swap call to dataset's getX() --> getXValue() (DG); + * 17-Apr-2007 : Added null argument checks to constructor, new accessor + * methods, added equals() override and used new URLUtilities + * class to encode series key and date (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.urls; + +import java.io.Serializable; +import java.text.DateFormat; +import java.util.Date; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.xy.XYDataset; + +/** + * A URL generator for time series charts. + */ +public class TimeSeriesURLGenerator implements XYURLGenerator, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -9122773175671182445L; + + /** A formatter for the date. */ + private DateFormat dateFormat = DateFormat.getInstance(); + + /** Prefix to the URL */ + private String prefix = "index.html"; + + /** Name to use to identify the series */ + private String seriesParameterName = "series"; + + /** Name to use to identify the item */ + private String itemParameterName = "item"; + + /** + * Default constructor. + */ + public TimeSeriesURLGenerator() { + super(); + } + + /** + * Construct TimeSeriesURLGenerator overriding defaults. + * + * @param dateFormat a formatter for the date (null not + * permitted). + * @param prefix the prefix of the URL (null not permitted). + * @param seriesParameterName the name of the series parameter in the URL + * (null not permitted). + * @param itemParameterName the name of the item parameter in the URL + * (null not permitted). + */ + public TimeSeriesURLGenerator(DateFormat dateFormat, String prefix, + String seriesParameterName, String itemParameterName) { + + ParamChecks.nullNotPermitted(dateFormat, "dateFormat"); + ParamChecks.nullNotPermitted(prefix, "prefix"); + ParamChecks.nullNotPermitted(seriesParameterName, "seriesParameterName"); + ParamChecks.nullNotPermitted(itemParameterName, "itemParameterName"); + this.dateFormat = (DateFormat) dateFormat.clone(); + this.prefix = prefix; + this.seriesParameterName = seriesParameterName; + this.itemParameterName = itemParameterName; + } + + /** + * Returns a clone of the date format assigned to this URL generator. + * + * @return The date format (never null). + * + * @since 1.0.6 + */ + public DateFormat getDateFormat() { + return (DateFormat) this.dateFormat.clone(); + } + + /** + * Returns the prefix string. + * + * @return The prefix string (never null). + * + * @since 1.0.6 + */ + public String getPrefix() { + return this.prefix; + } + + /** + * Returns the series parameter name. + * + * @return The series parameter name (never null). + * + * @since 1.0.6 + */ + public String getSeriesParameterName() { + return this.seriesParameterName; + } + + /** + * Returns the item parameter name. + * + * @return The item parameter name (never null). + * + * @since 1.0.6 + */ + public String getItemParameterName() { + return this.itemParameterName; + } + + /** + * Generates a URL for a particular item within a series. + * + * @param dataset the dataset (null not permitted). + * @param series the series number (zero-based index). + * @param item the item number (zero-based index). + * + * @return The generated URL. + */ + @Override + public String generateURL(XYDataset dataset, int series, int item) { + String result = this.prefix; + boolean firstParameter = result.indexOf("?") == -1; + Comparable seriesKey = dataset.getSeriesKey(series); + if (seriesKey != null) { + result += firstParameter ? "?" : "&"; + result += this.seriesParameterName + "=" + URLUtilities.encode( + seriesKey.toString(), "UTF-8"); + firstParameter = false; + } + + long x = (long) dataset.getXValue(series, item); + String xValue = this.dateFormat.format(new Date(x)); + result += firstParameter ? "?" : "&"; + result += this.itemParameterName + "=" + URLUtilities.encode(xValue, + "UTF-8"); + + return result; + } + + /** + * Tests this generator for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TimeSeriesURLGenerator)) { + return false; + } + TimeSeriesURLGenerator that = (TimeSeriesURLGenerator) obj; + if (!this.dateFormat.equals(that.dateFormat)) { + return false; + } + if (!this.itemParameterName.equals(that.itemParameterName)) { + return false; + } + if (!this.prefix.equals(that.prefix)) { + return false; + } + if (!this.seriesParameterName.equals(that.seriesParameterName)) { + return false; + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/URLUtilities.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/URLUtilities.java new file mode 100755 index 0000000..9ee6263 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/URLUtilities.java @@ -0,0 +1,92 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * URLUtilities.java + * ----------------- + * (C) Copyright 2007, 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributors: -; + * + * Changes: + * -------- + * 17-Apr-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.urls; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.net.URLEncoder; + +/** + * General utility methods for URLs. + * + * @since 1.0.6 + */ +public class URLUtilities { + + /** Constant used by {@link #encode(String, String)}. */ + private static final Class[] STRING_ARGS_2 = new Class[] {String.class, + String.class}; + + /** + * Calls java.net.URLEncoder.encode(String, String) via + * reflection, if we are running on JRE 1.4 or later, otherwise reverts to + * the deprecated URLEncoder.encode(String) method. + * + * @param s the string to encode. + * @param encoding the encoding. + * + * @return The encoded string. + * + * @since 1.0.6 + */ + public static String encode(String s, String encoding) { + Class c = URLEncoder.class; + String result = null; + try { + Method m = c.getDeclaredMethod("encode", STRING_ARGS_2); + try { + result = (String) m.invoke(null, new Object[] {s, encoding}); + } + catch (InvocationTargetException e) { + e.printStackTrace(); + } + catch (IllegalAccessException e) { + e.printStackTrace(); + } + } + catch (NoSuchMethodException e) { + // we're running on JRE 1.3.1 so this is the best we have... + result = URLEncoder.encode(s); + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/XYURLGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/XYURLGenerator.java new file mode 100755 index 0000000..6c83c68 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/XYURLGenerator.java @@ -0,0 +1,71 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * XYURLGenerator.java + * ------------------- + * (C) Copyright 2002-2008, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributors: David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 05-Aug-2002 : Version 1, contributed by Richard Atkinson; + * 09-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 20-Jan-2005 : Minor Javadoc update (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * 13-Dec-2007 : Updated API docs (DG); + * + */ + +package org.jfree.chart.urls; + +import org.jfree.data.xy.XYDataset; + +/** + * Interface for a URL generator for plots that uses data from an + * {@link XYDataset}. Classes that implement this interface are responsible + * for correctly escaping any text that is derived from the dataset, as this + * may be user-specified and could pose a security risk. + */ +public interface XYURLGenerator { + + /** + * Generates a URL for a particular item within a series. As a guideline, + * the URL should be valid within the context of an XHTML 1.0 document. + * + * @param dataset the dataset (null not permitted). + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return A string containing the generated URL (possibly + * null). + */ + public String generateURL(XYDataset dataset, int series, int item); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/XYZURLGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/XYZURLGenerator.java new file mode 100755 index 0000000..76a5fab --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/XYZURLGenerator.java @@ -0,0 +1,66 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * XYZURLGenerator.java + * -------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributors: -; + * + * Changes: + * -------- + * 03-Feb-2003 : Version 1 (DG); + * 13-Dec-2007 : Updated API docs (DG); + * + */ + +package org.jfree.chart.urls; + +import org.jfree.data.xy.XYZDataset; + +/** + * Interface for a URL generator for plots that uses data from an + * {@link XYZDataset}. Classes that implement this interface are responsible + * for correctly escaping any text that is derived from the dataset, as this + * may be user-specified and could pose a security risk. + */ +public interface XYZURLGenerator extends XYURLGenerator { + + /** + * Generates a URL for a particular item within a series. As a guideline, + * the URL should be valid within the context of an XHTML 1.0 document. + * + * @param dataset the dataset (null not permitted). + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return A string containing the generated URL. + */ + public String generateURL(XYZDataset dataset, int series, int item); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/package.html new file mode 100755 index 0000000..9e077db --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/urls/package.html @@ -0,0 +1,6 @@ + + + +Classes for adding URLS to charts for HTML image map generation. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/AttrStringUtils.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/AttrStringUtils.java new file mode 100755 index 0000000..e816e83 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/AttrStringUtils.java @@ -0,0 +1,314 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * AttrStringUtils.java + * -------------------- + * (C) Copyright 2013 by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 01-Aug-2013 : Version 1, backported from JFreeChart-FSE (DG); + * + */ + +package org.jfree.chart.util; + +import java.awt.Graphics2D; +import java.awt.font.TextLayout; +import java.awt.geom.AffineTransform; +import java.awt.geom.Rectangle2D; +import java.text.AttributedString; +import org.jfree.ui.TextAnchor; + +/** + * Some AttributedString utilities. + * + * @since 1.0.16 + */ +public class AttrStringUtils { + + private AttrStringUtils() { + // no need to instantiate this class + } + + /** + * Draws the attributed string at (x, y), rotated by the + * specified angle about (x, y). + * + * @param text the attributed string (null not permitted). + * @param g2 the graphics output target. + * @param angle the angle. + * @param x the x-coordinate. + * @param y the y-coordinate. + * + * @since 1.0.16 + */ + public static void drawRotatedString(AttributedString text, Graphics2D g2, + double angle, float x, float y) { + drawRotatedString(text, g2, x, y, angle, x, y); + } + + /** + * Draws the attributed string at (textX, textY), rotated by + * the specified angle about (rotateX, rotateY). + * + * @param text the attributed string (null not permitted). + * @param g2 the graphics output target. + * @param textX the x-coordinate for the text. + * @param textY the y-coordinate for the text. + * @param angle the rotation angle (in radians). + * @param rotateX the x-coordinate for the rotation point. + * @param rotateY the y-coordinate for the rotation point. + * + * @since 1.0.16 + */ + public static void drawRotatedString(AttributedString text, Graphics2D g2, + float textX, float textY, double angle, float rotateX, + float rotateY) { + ParamChecks.nullNotPermitted(text, "text"); + + AffineTransform saved = g2.getTransform(); + AffineTransform rotate = AffineTransform.getRotateInstance(angle, + rotateX, rotateY); + g2.transform(rotate); + TextLayout tl = new TextLayout(text.getIterator(), + g2.getFontRenderContext()); + tl.draw(g2, textX, textY); + + g2.setTransform(saved); + } + + /** + * Draws the string anchored to (x, y), rotated by the + * specified angle about (rotationX, rotationY). + * + * @param text the text (null not permitted). + * @param g2 the graphics target. + * @param x the x-coordinate for the text location. + * @param y the y-coordinate for the text location. + * @param textAnchor the text anchor point. + * @param angle the rotation (in radians). + * @param rotationX the x-coordinate for the rotation point. + * @param rotationY the y-coordinate for the rotation point. + * + * @since 1.0.16 + */ + public static void drawRotatedString(AttributedString text, Graphics2D g2, + float x, float y, TextAnchor textAnchor, + double angle, float rotationX, float rotationY) { + ParamChecks.nullNotPermitted(text, "text"); + float[] textAdj = deriveTextBoundsAnchorOffsets(g2, text, textAnchor, + null); + drawRotatedString(text, g2, x + textAdj[0], y + textAdj[1], angle, + rotationX, rotationY); + } + + /** + * Draws a rotated string. + * + * @param text the text to draw. + * @param g2 the graphics target. + * @param x the x-coordinate for the text location. + * @param y the y-coordinate for the text location. + * @param textAnchor the text anchor point. + * @param angle the rotation (in radians). + * @param rotationAnchor the rotation anchor point. + * + * @since 1.0.16 + */ + public static void drawRotatedString(AttributedString text, Graphics2D g2, + float x, float y, TextAnchor textAnchor, + double angle, TextAnchor rotationAnchor) { + ParamChecks.nullNotPermitted(text, "text"); + float[] textAdj = deriveTextBoundsAnchorOffsets(g2, text, textAnchor, + null); + float[] rotateAdj = deriveRotationAnchorOffsets(g2, text, + rotationAnchor); + drawRotatedString(text, g2, x + textAdj[0], y + textAdj[1], + angle, x + textAdj[0] + rotateAdj[0], + y + textAdj[1] + rotateAdj[1]); + } + + private static float[] deriveTextBoundsAnchorOffsets(Graphics2D g2, + AttributedString text, TextAnchor anchor, Rectangle2D textBounds) { + + TextLayout layout = new TextLayout(text.getIterator(), g2.getFontRenderContext()); + Rectangle2D bounds = layout.getBounds(); + + float[] result = new float[3]; + float ascent = layout.getAscent(); + result[2] = -ascent; + float halfAscent = ascent / 2.0f; + float descent = layout.getDescent(); + float leading = layout.getLeading(); + float xAdj = 0.0f; + float yAdj = 0.0f; + + if (isHorizontalCenter(anchor)) { + xAdj = (float) -bounds.getWidth() / 2.0f; + } + else if (isHorizontalRight(anchor)) { + xAdj = (float) -bounds.getWidth(); + } + + if (isTop(anchor)) { + yAdj = -descent - leading + (float) bounds.getHeight(); + } + else if (isHalfAscent(anchor)) { + yAdj = halfAscent; + } + else if (isHalfHeight(anchor)) { + yAdj = -descent - leading + (float) (bounds.getHeight() / 2.0); + } + else if (isBaseline(anchor)) { + yAdj = 0.0f; + } + else if (isBottom(anchor)) { + yAdj = -descent - leading; + } + if (textBounds != null) { + textBounds.setRect(bounds); + } + result[0] = xAdj; + result[1] = yAdj; + return result; + } + + /** + * A utility method that calculates the rotation anchor offsets for a + * string. These offsets are relative to the text starting coordinate + * (BASELINE_LEFT). + * + * @param g2 the graphics device. + * @param text the text. + * @param anchor the anchor point. + * + * @return The offsets. + */ + private static float[] deriveRotationAnchorOffsets(Graphics2D g2, + AttributedString text, TextAnchor anchor) { + + float[] result = new float[2]; + + TextLayout layout = new TextLayout(text.getIterator(), + g2.getFontRenderContext()); + Rectangle2D bounds = layout.getBounds(); + float ascent = layout.getAscent(); + float halfAscent = ascent / 2.0f; + float descent = layout.getDescent(); + float leading = layout.getLeading(); + float xAdj = 0.0f; + float yAdj = 0.0f; + + if (isHorizontalLeft(anchor)) { + xAdj = 0.0f; + } + else if (isHorizontalCenter(anchor)) { + xAdj = (float) bounds.getWidth() / 2.0f; + } + else if (isHorizontalRight(anchor)) { + xAdj = (float) bounds.getWidth(); + } + + if (isTop(anchor)) { + yAdj = descent + leading - (float) bounds.getHeight(); + } + else if (isHalfHeight(anchor)) { + yAdj = descent + leading - (float) (bounds.getHeight() / 2.0); + } + else if (isHalfAscent(anchor)) { + yAdj = -halfAscent; + } + else if (isBaseline(anchor)) { + yAdj = 0.0f; + } + else if (isBottom(anchor)) { + yAdj = descent + leading; + } + result[0] = xAdj; + result[1] = yAdj; + return result; + + } + + private static boolean isTop(TextAnchor anchor) { + return anchor.equals(TextAnchor.TOP_LEFT) + || anchor.equals(TextAnchor.TOP_CENTER) + || anchor.equals(TextAnchor.TOP_RIGHT); + } + + private static boolean isBaseline(TextAnchor anchor) { + return anchor.equals(TextAnchor.BASELINE_LEFT) + || anchor.equals(TextAnchor.BASELINE_CENTER) + || anchor.equals(TextAnchor.BASELINE_RIGHT); + } + + private static boolean isHalfAscent(TextAnchor anchor) { + return anchor.equals(TextAnchor.HALF_ASCENT_LEFT) + || anchor.equals(TextAnchor.HALF_ASCENT_CENTER) + || anchor.equals(TextAnchor.HALF_ASCENT_RIGHT); + } + + private static boolean isHalfHeight(TextAnchor anchor) { + return anchor.equals(TextAnchor.CENTER_LEFT) + || anchor.equals(TextAnchor.CENTER) + || anchor.equals(TextAnchor.CENTER_RIGHT); + } + + private static boolean isBottom(TextAnchor anchor) { + return anchor.equals(TextAnchor.BOTTOM_LEFT) + || anchor.equals(TextAnchor.BOTTOM_CENTER) + || anchor.equals(TextAnchor.BOTTOM_RIGHT); + } + + private static boolean isHorizontalLeft(TextAnchor anchor) { + return anchor.equals(TextAnchor.TOP_LEFT) + || anchor.equals(TextAnchor.CENTER_LEFT) + || anchor.equals(TextAnchor.HALF_ASCENT_LEFT) + || anchor.equals(TextAnchor.BASELINE_LEFT) + || anchor.equals(TextAnchor.BOTTOM_LEFT); + } + + private static boolean isHorizontalCenter(TextAnchor anchor) { + return anchor.equals(TextAnchor.TOP_CENTER) + || anchor.equals(TextAnchor.CENTER) + || anchor.equals(TextAnchor.HALF_ASCENT_CENTER) + || anchor.equals(TextAnchor.BASELINE_CENTER) + || anchor.equals(TextAnchor.BOTTOM_CENTER); + } + + private static boolean isHorizontalRight(TextAnchor anchor) { + return anchor.equals(TextAnchor.TOP_RIGHT) + || anchor.equals(TextAnchor.CENTER_RIGHT) + || anchor.equals(TextAnchor.HALF_ASCENT_RIGHT) + || anchor.equals(TextAnchor.BASELINE_RIGHT) + || anchor.equals(TextAnchor.BOTTOM_RIGHT); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/DefaultShadowGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/DefaultShadowGenerator.java new file mode 100755 index 0000000..e0abb1e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/DefaultShadowGenerator.java @@ -0,0 +1,333 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * DefaultShadowGenerator.java + * --------------------------- + * (C) Copyright 2009-2013 by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 10-Jul-2009 : Version 1 (DG); + * 29-Oct-2011 : Fixed Eclipse warnings (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.util; + +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; +import java.awt.image.DataBufferInt; +import java.io.Serializable; +import org.jfree.chart.HashUtilities; + +/** + * A default implementation of the {@link ShadowGenerator} interface, based on + * code in a + * blog + * post by Romain Guy. + * + * @since 1.0.14 + */ +public class DefaultShadowGenerator implements ShadowGenerator, Serializable { + + private static final long serialVersionUID = 2732993885591386064L; + + /** The shadow size. */ + private int shadowSize; + + /** The shadow color. */ + private Color shadowColor; + + /** The shadow opacity. */ + private float shadowOpacity; + + /** The shadow offset angle (in radians). */ + private double angle; + + /** The shadow offset distance (in Java2D units). */ + private int distance; + + /** + * Creates a new instance with default attributes. + */ + public DefaultShadowGenerator() { + this(5, Color.black, 0.5f, 5, -Math.PI / 4); + } + + /** + * Creates a new instance with the specified attributes. + * + * @param size the shadow size. + * @param color the shadow color. + * @param opacity the shadow opacity. + * @param distance the shadow offset distance. + * @param angle the shadow offset angle (in radians). + */ + public DefaultShadowGenerator(int size, Color color, float opacity, + int distance, double angle) { + ParamChecks.nullNotPermitted(color, "color"); + this.shadowSize = size; + this.shadowColor = color; + this.shadowOpacity = opacity; + this.distance = distance; + this.angle = angle; + } + + /** + * Returns the shadow size. + * + * @return The shadow size. + */ + public int getShadowSize() { + return this.shadowSize; + } + + /** + * Returns the shadow color. + * + * @return The shadow color (never null). + */ + public Color getShadowColor() { + return this.shadowColor; + } + + /** + * Returns the shadow opacity. + * + * @return The shadow opacity. + */ + public float getShadowOpacity() { + return this.shadowOpacity; + } + + /** + * Returns the shadow offset distance. + * + * @return The shadow offset distance (in Java2D units). + */ + public int getDistance() { + return this.distance; + } + + /** + * Returns the shadow offset angle (in radians). + * + * @return The angle (in radians). + */ + public double getAngle() { + return this.angle; + } + + /** + * Calculates the x-offset for drawing the shadow image relative to the + * source. + * + * @return The x-offset. + */ + @Override + public int calculateOffsetX() { + return (int) (Math.cos(this.angle) * this.distance) - this.shadowSize; + } + + /** + * Calculates the y-offset for drawing the shadow image relative to the + * source. + * + * @return The y-offset. + */ + @Override + public int calculateOffsetY() { + return -(int) (Math.sin(this.angle) * this.distance) - this.shadowSize; + } + + /** + * Creates and returns an image containing the drop shadow for the + * specified source image. + * + * @param source the source image. + * + * @return A new image containing the shadow. + */ + @Override + public BufferedImage createDropShadow(BufferedImage source) { + BufferedImage subject = new BufferedImage( + source.getWidth() + this.shadowSize * 2, + source.getHeight() + this.shadowSize * 2, + BufferedImage.TYPE_INT_ARGB); + + Graphics2D g2 = subject.createGraphics(); + g2.drawImage(source, null, this.shadowSize, this.shadowSize); + g2.dispose(); + applyShadow(subject); + return subject; + } + + /** + * Applies a shadow to the image. + * + * @param image the image. + */ + protected void applyShadow(BufferedImage image) { + int dstWidth = image.getWidth(); + int dstHeight = image.getHeight(); + + int left = (this.shadowSize - 1) >> 1; + int right = this.shadowSize - left; + int xStart = left; + int xStop = dstWidth - right; + int yStart = left; + int yStop = dstHeight - right; + + int shadowRgb = this.shadowColor.getRGB() & 0x00FFFFFF; + + int[] aHistory = new int[this.shadowSize]; + int historyIdx; + + int aSum; + + int[] dataBuffer = ((DataBufferInt) image.getRaster().getDataBuffer()).getData(); + int lastPixelOffset = right * dstWidth; + float sumDivider = this.shadowOpacity / this.shadowSize; + + // horizontal pass + + for (int y = 0, bufferOffset = 0; y < dstHeight; y++, bufferOffset = y * dstWidth) { + aSum = 0; + historyIdx = 0; + for (int x = 0; x < this.shadowSize; x++, bufferOffset++) { + int a = dataBuffer[bufferOffset] >>> 24; + aHistory[x] = a; + aSum += a; + } + + bufferOffset -= right; + + for (int x = xStart; x < xStop; x++, bufferOffset++) { + int a = (int) (aSum * sumDivider); + dataBuffer[bufferOffset] = a << 24 | shadowRgb; + + // substract the oldest pixel from the sum + aSum -= aHistory[historyIdx]; + + // get the lastest pixel + a = dataBuffer[bufferOffset + right] >>> 24; + aHistory[historyIdx] = a; + aSum += a; + + if (++historyIdx >= this.shadowSize) { + historyIdx -= this.shadowSize; + } + } + } + + // vertical pass + for (int x = 0, bufferOffset = 0; x < dstWidth; x++, bufferOffset = x) { + aSum = 0; + historyIdx = 0; + for (int y = 0; y < this.shadowSize; y++, + bufferOffset += dstWidth) { + int a = dataBuffer[bufferOffset] >>> 24; + aHistory[y] = a; + aSum += a; + } + + bufferOffset -= lastPixelOffset; + + for (int y = yStart; y < yStop; y++, bufferOffset += dstWidth) { + int a = (int) (aSum * sumDivider); + dataBuffer[bufferOffset] = a << 24 | shadowRgb; + + // substract the oldest pixel from the sum + aSum -= aHistory[historyIdx]; + + // get the lastest pixel + a = dataBuffer[bufferOffset + lastPixelOffset] >>> 24; + aHistory[historyIdx] = a; + aSum += a; + + if (++historyIdx >= this.shadowSize) { + historyIdx -= this.shadowSize; + } + } + } + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return The object. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DefaultShadowGenerator)) { + return false; + } + DefaultShadowGenerator that = (DefaultShadowGenerator) obj; + if (this.shadowSize != that.shadowSize) { + return false; + } + if (!this.shadowColor.equals(that.shadowColor)) { + return false; + } + if (this.shadowOpacity != that.shadowOpacity) { + return false; + } + if (this.distance != that.distance) { + return false; + } + if (this.angle != that.angle) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return The hash code. + */ + @Override + public int hashCode() { + int hash = HashUtilities.hashCode(17, this.shadowSize); + hash = HashUtilities.hashCode(hash, this.shadowColor); + hash = HashUtilities.hashCode(hash, this.shadowOpacity); + hash = HashUtilities.hashCode(hash, this.distance); + hash = HashUtilities.hashCode(hash, this.angle); + return hash; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/DirectionalGradientPaintTransformer.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/DirectionalGradientPaintTransformer.java new file mode 100755 index 0000000..888cd66 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/DirectionalGradientPaintTransformer.java @@ -0,0 +1,140 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------------- + * DirectionalGradientPaintTransformer.java + * ---------------------------------------- + * (C) Copyright 2013 by Peter Kolb and Contributors. + * + * Original Author: Peter Kolb; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 21-Nov-2013 : Version 1, with modifications by DG (PK); + * + */ + +package org.jfree.chart.util; + +import java.awt.GradientPaint; +import java.awt.geom.Rectangle2D; +import java.awt.Shape; +import org.jfree.ui.GradientPaintTransformer; + +/** + * Transforms a GradientPaint to range over the width of a target + * shape. The orientation of the resulting GradientPaint + * depend on the coordinates of the original paint: + *

+ *

    + *
  • If the original paint starts at 0,0 and ends at a point 0, y != 0, + * the resulting paint will have a vertical orientation. + *
  • If the original paint starts at 0,0 and ends at a point x !=0, 0, + * the resulting paint will have a horizontal orientation. + *
  • If the original paint starts at 0,0 and ends at a point x != 0, y != 0, + * the resulting paint will have a diagonal orientation from the upper left to + * the lower right edge. Lines of equal color will have a 45 ∞ angle, + * pointing upwards from left to right. + *
  • If the original paint starts at a point x != 0, y != 0, + * the resulting paint will have a diagonal orientation from the lower left to + * the upper right edge. Lines of equal color will have a 45 ∞ angle, + * pointing downwards from left to right. + *
+ *

+ * In all cases, the cyclic flag of the original paint will be taken into + * account. + * + * @author Peter Kolb + * @since 1.0.17 + */ +public class DirectionalGradientPaintTransformer + implements GradientPaintTransformer { + + /** + * Default constructor. + */ + public DirectionalGradientPaintTransformer() { + super(); + } + + /** + * Transforms a GradientPaint instance to fit some target + * shape. + * + * @param paint the original paint (not null). + * @param target the reference area (not null). + * + * @return A transformed paint. + */ + @Override + public GradientPaint transform(GradientPaint paint, Shape target) { + //get the coordinates of the original GradientPaint + final double px1 = paint.getPoint1().getX(); + final double py1 = paint.getPoint1().getY(); + final double px2 = paint.getPoint2().getX(); + final double py2 = paint.getPoint2().getY(); + //get the coordinates of the shape that is to be filled + final Rectangle2D bounds = target.getBounds(); + final float bx = (float)bounds.getX(); + final float by = (float)bounds.getY(); + final float bw = (float)bounds.getWidth(); + final float bh = (float)bounds.getHeight(); + //reserve variables to store the coordinates of the resulting GradientPaint + float rx1, ry1, rx2, ry2; + if (px1 == 0 && py1 == 0) { + //start point is upper left corner + rx1 = bx; + ry1 = by; + if (px2 != 0.0f && py2 != 0.0f) { + //end point is lower right corner --> diagonal gradient + float offset = (paint.isCyclic()) ? (bw + bh) / 4.0f + : (bw + bh) / 2.0f ; + rx2 = bx + offset; + ry2 = by + offset; + } + else { + //end point is either lower left corner --> vertical gradient + //or end point is upper right corner --> horizontal gradient + rx2 = (px2 == 0) ? rx1 : (paint.isCyclic() ? (rx1 + bw / 2.0f) + : (rx1 + bw)); + ry2 = (py2 == 0) ? ry1 : (paint.isCyclic() ? (ry1 + bh / 2.0f) + : (ry1 + bh)); + } + } + else { + //start point is lower left right corner --> diagonal gradient + rx1 = bx; + ry1 = by + bh; + float offset = (paint.isCyclic()) ? (bw + bh) / 4.0f + : (bw + bh) / 2.0f; + rx2 = bx + offset; + ry2 = by + bh - offset; + } + return new GradientPaint(rx1, ry1, paint.getColor1(), rx2, ry2, + paint.getColor2(), paint.isCyclic()); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/HMSNumberFormat.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/HMSNumberFormat.java new file mode 100755 index 0000000..3b4edb8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/HMSNumberFormat.java @@ -0,0 +1,120 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * HMSNumberFormat.java + * -------------------- + * (C) Copyright 2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 28-Sep-2013 : Version 1 (RW); + * + */ + +package org.jfree.chart.util; + +import java.text.DecimalFormat; +import java.text.FieldPosition; +import java.text.NumberFormat; +import java.text.ParsePosition; + +/** + * A custom number formatter that formats numbers (in seconds) as HH:MM:SS. + * Created in response to: + * + * http://stackoverflow.com/questions/19028908/jfreechart-need-to-customize-y-axis-just-for-printing + * + * @since 1.0.17 + */ +public class HMSNumberFormat extends NumberFormat { + + private NumberFormat formatter = new DecimalFormat("00"); + + /** + * Creates a new instance. + */ + public HMSNumberFormat() { + // nothing to do + } + + /** + * Formats the specified number as a string of the form HH:MM:SS. The + * decimal fraction is ignored. + * + * @param number the number to format. + * @param toAppendTo the buffer to append to (ignored here). + * @param pos the field position (ignored here). + * + * @return The string buffer. + */ + @Override + public StringBuffer format(double number, StringBuffer toAppendTo, + FieldPosition pos) { + return format((long) number, toAppendTo, pos); + } + + /** + * Formats the specified number as a string of the form HH:MM:SS. + * + * @param number the number to format. + * @param toAppendTo the buffer to append to (ignored here). + * @param pos the field position (ignored here). + * + * @return The string buffer. + */ + @Override + public StringBuffer format(long number, StringBuffer toAppendTo, + FieldPosition pos) { + StringBuffer sb = new StringBuffer(); + long hours = number / 3600; + sb.append(this.formatter.format(hours)).append(":"); + long remaining = number - (hours * 3600); + long minutes = remaining / 60; + sb.append(this.formatter.format(minutes)).append(":"); + long seconds = remaining - (minutes * 60); + sb.append(this.formatter.format(seconds)); + return sb; + } + + /** + * Parsing is not implemented, so this method always returns + * null. + * + * @param source ignored. + * @param parsePosition ignored. + * + * @return Always null. + */ + @Override + public Number parse (String source, ParsePosition parsePosition) { + return null; // don't bother with parsing + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/HexNumberFormat.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/HexNumberFormat.java new file mode 100755 index 0000000..d3442c4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/HexNumberFormat.java @@ -0,0 +1,162 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * HexNumberFormat.java + * -------------------- + * (C) Copyright 2007, 2008, by Richard West and Contributors. + * + * Original Author: Richard West, Advanced Micro Devices, Inc.; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 14-Jun-2007 : Version 1 (RW); + * + */ + +package org.jfree.chart.util; + +import java.text.FieldPosition; +import java.text.NumberFormat; +import java.text.ParsePosition; + +/** + * A custom number formatter that formats numbers as hexadecimal strings. + * There are some limitations, so be careful using this class. + * + * @since 1.0.6 + */ +public class HexNumberFormat extends NumberFormat { + + /** Number of hexadecimal digits for a byte. */ + public static final int BYTE = 2; + + /** Number of hexadecimal digits for a word. */ + public static final int WORD = 4; + + /** Number of hexadecimal digits for a double word. */ + public static final int DWORD = 8; + + /** Number of hexadecimal digits for a quad word. */ + public static final int QWORD = 16; + + /** The number of digits (shorter strings will be left padded). */ + private int m_numDigits = DWORD; + + /** + * Creates a new instance with 8 digits. + */ + public HexNumberFormat() { + this(DWORD); + } + + /** + * Creates a new instance with the specified number of digits. + + * @param digits the digits. + */ + public HexNumberFormat(int digits) { + super(); + this.m_numDigits = digits; + } + + /** + * Returns the number of digits. + * + * @return The number of digits. + */ + public final int getNumberOfDigits() { + return this.m_numDigits; + } + + /** + * Sets the number of digits. + * + * @param digits the number of digits. + */ + public void setNumberOfDigits(int digits) { + this.m_numDigits = digits; + } + + /** + * Formats the specified number as a hexadecimal string. The decimal + * fraction is ignored. + * + * @param number the number to format. + * @param toAppendTo the buffer to append to (ignored here). + * @param pos the field position (ignored here). + * + * @return The string buffer. + */ + @Override + public StringBuffer format(double number, StringBuffer toAppendTo, + FieldPosition pos) { + return format((long) number, toAppendTo, pos); + } + + /** + * Formats the specified number as a hexadecimal string. The decimal + * fraction is ignored. + * + * @param number the number to format. + * @param toAppendTo the buffer to append to (ignored here). + * @param pos the field position (ignored here). + * + * @return The string buffer. + */ + @Override + public StringBuffer format(long number, StringBuffer toAppendTo, + FieldPosition pos) { + String l_hex = Long.toHexString(number).toUpperCase(); + + int l_pad = this.m_numDigits - l_hex.length(); + l_pad = (0 < l_pad) ? l_pad : 0; + + StringBuffer l_extended = new StringBuffer("0x"); + for (int i = 0; i < l_pad; i++) { + l_extended.append(0); + } + l_extended.append(l_hex); + + return l_extended; + } + + /** + * Parsing is not implemented, so this method always returns + * null. + * + * @param source ignored. + * @param parsePosition ignored. + * + * @return Always null. + */ + @Override + public Number parse (String source, ParsePosition parsePosition) { + return null; // don't bother with parsing + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/LineUtilities.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/LineUtilities.java new file mode 100755 index 0000000..5726142 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/LineUtilities.java @@ -0,0 +1,142 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * LineUtilities.java + * ------------------ + * (C) Copyright 2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Nov-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.util; + +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; + +/** + * Some utility methods for {@link Line2D} objects. + * + * @since 1.0.12 + */ +public class LineUtilities { + + /** + * Clips the specified line to the given rectangle. + * + * @param line the line (null not permitted). + * @param rect the clipping rectangle (null not permitted). + * + * @return true if the clipped line is visible, and + * false otherwise. + */ + public static boolean clipLine(Line2D line, Rectangle2D rect) { + + double x1 = line.getX1(); + double y1 = line.getY1(); + double x2 = line.getX2(); + double y2 = line.getY2(); + + double minX = rect.getMinX(); + double maxX = rect.getMaxX(); + double minY = rect.getMinY(); + double maxY = rect.getMaxY(); + + int f1 = rect.outcode(x1, y1); + int f2 = rect.outcode(x2, y2); + + while ((f1 | f2) != 0) { + if ((f1 & f2) != 0) { + return false; + } + double dx = (x2 - x1); + double dy = (y2 - y1); + // update (x1, y1), (x2, y2) and f1 and f2 using intersections + // then recheck + if (f1 != 0) { + // first point is outside, so we update it against one of the + // four sides then continue + if ((f1 & Rectangle2D.OUT_LEFT) == Rectangle2D.OUT_LEFT + && dx != 0.0) { + y1 = y1 + (minX - x1) * dy / dx; + x1 = minX; + } + else if ((f1 & Rectangle2D.OUT_RIGHT) == Rectangle2D.OUT_RIGHT + && dx != 0.0) { + y1 = y1 + (maxX - x1) * dy / dx; + x1 = maxX; + } + else if ((f1 & Rectangle2D.OUT_BOTTOM) == Rectangle2D.OUT_BOTTOM + && dy != 0.0) { + x1 = x1 + (maxY - y1) * dx / dy; + y1 = maxY; + } + else if ((f1 & Rectangle2D.OUT_TOP) == Rectangle2D.OUT_TOP + && dy != 0.0) { + x1 = x1 + (minY - y1) * dx / dy; + y1 = minY; + } + f1 = rect.outcode(x1, y1); + } + else if (f2 != 0) { + // second point is outside, so we update it against one of the + // four sides then continue + if ((f2 & Rectangle2D.OUT_LEFT) == Rectangle2D.OUT_LEFT + && dx != 0.0) { + y2 = y2 + (minX - x2) * dy / dx; + x2 = minX; + } + else if ((f2 & Rectangle2D.OUT_RIGHT) == Rectangle2D.OUT_RIGHT + && dx != 0.0) { + y2 = y2 + (maxX - x2) * dy / dx; + x2 = maxX; + } + else if ((f2 & Rectangle2D.OUT_BOTTOM) == Rectangle2D.OUT_BOTTOM + && dy != 0.0) { + x2 = x2 + (maxY - y2) * dx / dy; + y2 = maxY; + } + else if ((f2 & Rectangle2D.OUT_TOP) == Rectangle2D.OUT_TOP + && dy != 0.0) { + x2 = x2 + (minY - y2) * dx / dy; + y2 = minY; + } + f2 = rect.outcode(x2, y2); + } + } + + line.setLine(x1, y1, x2, y2); + return true; // the line is visible - if it wasn't, we'd have + // returned false from within the while loop above + + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/LogFormat.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/LogFormat.java new file mode 100755 index 0000000..a226941 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/LogFormat.java @@ -0,0 +1,263 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * LogFormat.java + * -------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 02-Aug-2007 : Version 1 (DG); + * 19-Feb-2008 : Implemented equals() and clone(), and added new powerLabel + * attribute as per Feature Request 1886036 (DG); + * 14-Jan-2009 : Added default constructor, and accessor methods for + * exponent formatter (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.chart.util; + +import java.text.DecimalFormat; +import java.text.FieldPosition; +import java.text.NumberFormat; +import java.text.ParsePosition; + +/** + * A number formatter for logarithmic values. This formatter does not support + * parsing. + * + * @since 1.0.7 + */ +public class LogFormat extends NumberFormat { + + /** The log base value. */ + private double base; + + /** The natural logarithm of the base value. */ + private double baseLog; + + /** The label for the log base (for example, "e"). */ + private String baseLabel; + + /** + * The label for the power symbol. + * + * @since 1.0.10 + */ + private String powerLabel; + + /** A flag that controls whether or not the base is shown. */ + private boolean showBase; + + /** The number formatter for the exponent. */ + private NumberFormat formatter = new DecimalFormat("0.0#"); + + /** + * Creates a new instance using base 10. + * + * @since 1.0.13 + */ + public LogFormat() { + this(10.0, "10", true); + } + + /** + * Creates a new instance. + * + * @param base the base. + * @param baseLabel the base label (null not permitted). + * @param showBase a flag that controls whether or not the base value is + * shown. + */ + public LogFormat(double base, String baseLabel, boolean showBase) { + this(base, baseLabel, "^", showBase); + } + + /** + * Creates a new instance. + * + * @param base the base. + * @param baseLabel the base label (null not permitted). + * @param powerLabel the power label (null not permitted). + * @param showBase a flag that controls whether or not the base value is + * shown. + * + * @since 1.0.10 + */ + public LogFormat(double base, String baseLabel, String powerLabel, + boolean showBase) { + ParamChecks.nullNotPermitted(baseLabel, "baseLabel"); + ParamChecks.nullNotPermitted(powerLabel, "powerLabel"); + this.base = base; + this.baseLog = Math.log(this.base); + this.baseLabel = baseLabel; + this.showBase = showBase; + this.powerLabel = powerLabel; + } + + /** + * Returns the number format used for the exponent. + * + * @return The number format (never null). + * + * @since 1.0.13. + */ + public NumberFormat getExponentFormat() { + return (NumberFormat) this.formatter.clone(); + } + + /** + * Sets the number format used for the exponent. + * + * @param format the formatter (null not permitted). + * + * @since 1.0.13 + */ + public void setExponentFormat(NumberFormat format) { + ParamChecks.nullNotPermitted(format, "format"); + this.formatter = format; + } + + /** + * Calculates the log of a given value. + * + * @param value the value. + * + * @return The log of the value. + */ + private double calculateLog(double value) { + return Math.log(value) / this.baseLog; + } + + /** + * Returns a formatted representation of the specified number. + * + * @param number the number. + * @param toAppendTo the string buffer to append to. + * @param pos the position. + * + * @return A string buffer containing the formatted value. + */ + @Override + public StringBuffer format(double number, StringBuffer toAppendTo, + FieldPosition pos) { + StringBuffer result = new StringBuffer(); + if (this.showBase) { + result.append(this.baseLabel); + result.append(this.powerLabel); + } + result.append(this.formatter.format(calculateLog(number))); + return result; + } + + /** + * Formats the specified number as a hexadecimal string. The decimal + * fraction is ignored. + * + * @param number the number to format. + * @param toAppendTo the buffer to append to (ignored here). + * @param pos the field position (ignored here). + * + * @return The string buffer. + */ + @Override + public StringBuffer format(long number, StringBuffer toAppendTo, + FieldPosition pos) { + StringBuffer result = new StringBuffer(); + if (this.showBase) { + result.append(this.baseLabel); + result.append(this.powerLabel); + } + result.append(this.formatter.format(calculateLog(number))); + return result; + } + + /** + * Parsing is not implemented, so this method always returns + * null. + * + * @param source ignored. + * @param parsePosition ignored. + * + * @return Always null. + */ + @Override + public Number parse (String source, ParsePosition parsePosition) { + return null; // don't bother with parsing + } + + /** + * Tests this formatter for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof LogFormat)) { + return false; + } + LogFormat that = (LogFormat) obj; + if (this.base != that.base) { + return false; + } + if (!this.baseLabel.equals(that.baseLabel)) { + return false; + } + if (this.baseLog != that.baseLog) { + return false; + } + if (this.showBase != that.showBase) { + return false; + } + if (!this.formatter.equals(that.formatter)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + */ + @Override + public Object clone() { + LogFormat clone = (LogFormat) super.clone(); + clone.formatter = (NumberFormat) this.formatter.clone(); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/PaintAlpha.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/PaintAlpha.java new file mode 100755 index 0000000..298baf1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/PaintAlpha.java @@ -0,0 +1,400 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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.] + * + * --------------- + * PaintAlpha.java + * --------------- + * (C) Copyright 2011-2013 by DaveLaw and Contributors. + * + * Original Author: DaveLaw (dave ATT davelaw D0TT de); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 09-Mar-2011 : Written (DaveLaw) + * 03-Jul-2012 : JDK 1.6 References made reflective for JDK 1.3 compatibility + * (DaveLaw); + * 16-Sep-2013 : Removed reflection since we are requiring JDK 1.6 now (DG) + * + */ + +package org.jfree.chart.util; + +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.LinearGradientPaint; +import java.awt.Paint; +import java.awt.RadialGradientPaint; +import java.awt.TexturePaint; +import java.awt.image.BufferedImage; +import java.awt.image.IndexColorModel; +import java.awt.image.WritableRaster; +import java.util.Hashtable; + +/** + * This class contains static methods for the manipulation + * of objects of type Paint + *

+ * The intention is to honour the alpha-channel in the process. + * PaintAlpha was originally conceived to improve the + * rendering of 3D Shapes with transparent colours and to allow + * invisible bars by making them completely transparent. + *

+ * In, for example + * {@link org.jfree.chart.renderer.category.StackedBarRenderer3D StackedBarRenderer3D}, + * bars are rendered with 6 faces. The front face is rendered with + * the Paint requested. The other 5 faces are rendered + * darker to achieve the 3D effect. + *

+ * Previously {@link Color#darker()} was used for this, + * which always returns an opaque colour. + *

+ * Additionally there are methods to control the behaviour and + * in particular a {@link PaintAlpha#cloneImage(BufferedImage) cloneImage(..)} + * method which is needed to darken objects of type {@link TexturePaint}. + * + * @author DaveLaw + * + * @since 1.0.15 + */ +public class PaintAlpha { + // TODO Revert to SVN revision 2469 in JFreeChart 1.0.16 + // (MultipleGradientPaint's / JDK issues) + // TODO THEN: change visibility of ALL darker(...) Methods EXCEPT + // darker(Paint) to private! + + /** + * Multiplier for the darker Methods.
+ * (taken from {@link java.awt.Color}.FACTOR) + */ + private static final double FACTOR = 0.7; + + private static boolean legacyAlpha = false; + + /** + * Per default PaintAlpha will try to honour alpha-channel + * information. In the past this was not the case. + * If you wish legacy functionality for your application you can request + * this here. + * + * @param legacyAlpha boolean + * + * @return the previous setting + */ + public static boolean setLegacyAlpha(boolean legacyAlpha) { + boolean old = PaintAlpha.legacyAlpha; + PaintAlpha.legacyAlpha = legacyAlpha; + return old; + } + + /** + * Create a new (if possible, darker) Paint of the same Type. + * If the Type is not supported, the original Paint is returned. + *

+ * @param paint a Paint implementation + * (e.g. {@link Color}, {@link GradientPaint}, {@link TexturePaint},..) + *

+ * @return a (usually new, see above) Paint + */ + public static Paint darker(Paint paint) { + + if (paint instanceof Color) { + return darker((Color) paint); + } + if (legacyAlpha == true) { + /* + * Legacy? Just return the original Paint. + * (this corresponds EXACTLY to how Paints used to be darkened) + */ + return paint; + } + if (paint instanceof GradientPaint) { + return darker((GradientPaint) paint); + } + if (paint instanceof LinearGradientPaint) { + return darkerLinearGradientPaint((LinearGradientPaint) paint); + } + if (paint instanceof RadialGradientPaint) { + return darkerRadialGradientPaint((RadialGradientPaint) paint); + } + if (paint instanceof TexturePaint) { + try { + return darkerTexturePaint((TexturePaint) paint); + } + catch (Exception e) { + /* + * Lots can go wrong while fiddling with Images, Color Models + * & such! If anything at all goes awry, just return the original + * TexturePaint. (TexturePaint's are immutable anyway, so no harm + * done) + */ + return paint; + } + } + return paint; + } + + /** + * Similar to {@link Color#darker()}. + *

+ * The essential difference is that this method + * maintains the alpha-channel unchanged
+ * + * @param paint a Color + * + * @return a darker version of the Color + */ + private static Color darker(Color paint) { + return new Color( + (int)(paint.getRed () * FACTOR), + (int)(paint.getGreen() * FACTOR), + (int)(paint.getBlue () * FACTOR), paint.getAlpha()); + } + + /** + * Create a new GradientPaint with its colors darkened. + * + * @param paint the gradient paint (null not permitted). + * + * @return a darker version of the GradientPaint + */ + private static GradientPaint darker(GradientPaint paint) { + return new GradientPaint( + paint.getPoint1(), darker(paint.getColor1()), + paint.getPoint2(), darker(paint.getColor2()), + paint.isCyclic()); + } + + /** + * Create a new Gradient with its colours darkened. + * + * @param paint a LinearGradientPaint + * + * @return a darker version of the LinearGradientPaint + */ + private static Paint darkerLinearGradientPaint(LinearGradientPaint paint) { + final Color[] paintColors = paint.getColors(); + for (int i = 0; i < paintColors.length; i++) { + paintColors[i] = darker(paintColors[i]); + } + return new LinearGradientPaint(paint.getStartPoint(), + paint.getEndPoint(), paint.getFractions(), paintColors, + paint.getCycleMethod(), paint.getColorSpace(), + paint.getTransform()); + } + + /** + * Create a new Gradient with its colours darkened. + * + * @param paint a RadialGradientPaint + * + * @return a darker version of the RadialGradientPaint + */ + private static Paint darkerRadialGradientPaint(RadialGradientPaint paint) { + final Color[] paintColors = paint.getColors(); + for (int i = 0; i < paintColors.length; i++) { + paintColors[i] = darker(paintColors[i]); + } + return new RadialGradientPaint(paint.getCenterPoint(), + paint.getRadius(), paint.getFocusPoint(), + paint.getFractions(), paintColors, paint.getCycleMethod(), + paint.getColorSpace(), paint.getTransform()); + } + + /** + * Create a new TexturePaint with its colors darkened. + *

+ * This entails cloning the underlying BufferedImage, + * then darkening each color-pixel individually! + * + * @param paint a TexturePaint + * + * @return a darker version of the TexturePaint + */ + private static TexturePaint darkerTexturePaint(TexturePaint paint) { + /** + * Color Models with pre-multiplied Alpha tested OK without any + * special logic + * + * BufferedImage.TYPE_INT_ARGB_PRE: // Type 03: tested OK 2011.02.27 + * BufferedImage.TYPE_4BYTE_ABGR_PRE: // Type 07: tested OK 2011.02.27 + */ + if (paint.getImage().getColorModel().isAlphaPremultiplied()) { + /* Placeholder */ + } + + BufferedImage img = cloneImage(paint.getImage()); + + WritableRaster ras = img.copyData(null); + + final int miX = ras.getMinX(); + final int miY = ras.getMinY(); + final int maY = ras.getMinY() + ras.getHeight(); + + final int wid = ras.getWidth(); + + /**/ int[] pix = new int[wid * img.getSampleModel().getNumBands()]; + /* (pix-buffer is large enough for all pixels of one row) */ + + /** + * Indexed Color Models (sort of a Palette) CANNOT be simply + * multiplied (the pixel-value is just an index into the Palette). + * + * Fortunately, IndexColorModel.getComponents(..) resolves the colors. + * The resolved colors can then be multiplied by our FACTOR. + * IndexColorModel.getDataElement(..) then tries to map the computed + * color to the "nearest" in the Palette. + * + * It is quite possible that the "nearest" color is the ORIGINAL + * color! In the worst case, the returned Image will be identical to + * the original. + * + * Applies to following Image Types: + * + * BufferedImage.TYPE_BYTE_BINARY: // Type 12: tested OK 2011.02.27 + * BufferedImage.TYPE_BYTE_INDEXED: // Type 13: tested OK 2011.02.27 + */ + if (img.getColorModel() instanceof IndexColorModel) { + + int[] nco = new int[4]; // RGB (+ optional Alpha which we leave + // unchanged) + + for (int y = miY; y < maY; y++) { + + pix = ras.getPixels(miX, y, wid, 1, pix); + + for (int p = 0; p < pix.length; p++) { + nco = img.getColorModel().getComponents(pix[p], nco, 0); + nco[0] *= FACTOR; // Red + nco[1] *= FACTOR; // Green + nco[2] *= FACTOR; // Blue. Now map computed colour to + // nearest in Palette... + pix[p] = img.getColorModel().getDataElement(nco, 0); + } + /**/ ras.setPixels(miX, y, wid, 1, pix); + } + img.setData(ras); + + return new TexturePaint(img, paint.getAnchorRect()); + } + + /** + * For the other 2 Color Models, java.awt.image.ComponentColorModel and + * java.awt.image.DirectColorModel, the order of subpixels returned by + * ras.getPixels(..) was observed to correspond to the following... + */ + if (img.getSampleModel().getNumBands() == 4) { + /** + * The following Image Types have an Alpha-channel which we will + * leave unchanged: + * + * BufferedImage.TYPE_INT_ARGB: // Type 02: tested OK 2011.02.27 + * BufferedImage.TYPE_4BYTE_ABGR: // Type 06: tested OK 2011.02.27 + */ + for (int y = miY; y < maY; y++) { + + pix = ras.getPixels(miX, y, wid, 1, pix); + + for (int p = 0; p < pix.length;) { + pix[p] = (int)(pix[p++] * FACTOR); // Red + pix[p] = (int)(pix[p++] * FACTOR); // Green + pix[p] = (int)(pix[p++] * FACTOR); // Blue + /* Ignore alpha-channel -> */p++; + } + /**/ ras.setPixels(miX, y, wid, 1, pix); + } + img.setData(ras); + return new TexturePaint(img, paint.getAnchorRect()); + } else { + for (int y = miY; y < maY; y++) { + + pix = ras.getPixels(miX, y, wid, 1, pix); + + for (int p = 0; p < pix.length; p++) { + pix[p] = (int)(pix[p] * FACTOR); + } + /**/ ras.setPixels(miX, y, wid, 1, pix); + } + img.setData(ras); + return new TexturePaint(img, paint.getAnchorRect()); + /** + * Above, we multiplied every pixel by our FACTOR because the + * applicable Image Types consist only of color or grey channels: + * + * BufferedImage.TYPE_INT_RGB: // Type 01: tested OK 2011.02.27 + * BufferedImage.TYPE_INT_BGR: // Type 04: tested OK 2011.02.27 + * BufferedImage.TYPE_3BYTE_BGR: // Type 05: tested OK 2011.02.27 + * BufferedImage.TYPE_BYTE_GRAY: // Type 10: tested OK 2011.02.27 + * BufferedImage.TYPE_USHORT_GRAY: // Type 11: tested OK 2011.02.27 + * BufferedImage.TYPE_USHORT_565_RGB: // Type 08: tested OK 2011.02.27 + * BufferedImage.TYPE_USHORT_555_RGB: // Type 09: tested OK 2011.02.27 + * + * Note: as ras.getPixels(..) returned colours in the order R, G, B, A (optional) + * for both TYPE_4BYTE_ABGR & TYPE_3BYTE_BGR, + * it is assumed that TYPE_INT_BGR will behave similarly. + */ + } + } + + /** + * Clone a {@link BufferedImage}. + *

+ * Note: when constructing the clone, the original Color Model Object is + * reused.
That keeps things simple & should not be a problem, as all + * known Color Models
+ * ({@link java.awt.image.IndexColorModel IndexColorModel}, + * {@link java.awt.image.DirectColorModel DirectColorModel}, + * {@link java.awt.image.ComponentColorModel ComponentColorModel}) are + * immutable. + * + * @param image original BufferedImage to clone + * + * @return a new BufferedImage reusing the original's Color Model & + * containing a clone of its pixels + */ + public static BufferedImage cloneImage(BufferedImage image) { + + WritableRaster rin = image.getRaster(); + WritableRaster ras = rin.createCompatibleWritableRaster(); + /**/ ras.setRect(rin); // <- this is the code that actually COPIES the pixels + + /* + * Buffered Images may have properties, but NEVER disclose them! + * Nevertheless, just in case someone implements getPropertyNames() + * one day... + */ + Hashtable props = null; + String[] propNames = image.getPropertyNames(); + if (propNames != null) { // ALWAYS null + props = new Hashtable(); + for (int i = 0; i < propNames.length; i++) { + props.put(propNames[i], image.getProperty(propNames[i])); + } + } + return new BufferedImage(image.getColorModel(), ras, + image.isAlphaPremultiplied(), props); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/ParamChecks.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/ParamChecks.java new file mode 100755 index 0000000..7cd7af1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/ParamChecks.java @@ -0,0 +1,68 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * ParamChecks.java + * ---------------- + * (C) Copyright 2011, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Oct-2011 : Version 1 (DG); + * + */ + +package org.jfree.chart.util; + +/** + * A utility class for checking parameters. + * + * @since 1.0.14 + */ +public class ParamChecks { + + /** + * Throws an IllegalArgumentException if the supplied + * param is null. + * + * @param param the parameter to check (null permitted). + * @param name the name of the parameter (to use in the exception message + * if param is null). + * + * @throws IllegalArgumentException if param is + * null. + * + * @since 1.0.14 + */ + public static void nullNotPermitted(Object param, String name) { + if (param == null) { + throw new IllegalArgumentException("Null '" + name + "' argument."); + } + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/RelativeDateFormat.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/RelativeDateFormat.java new file mode 100755 index 0000000..74f436f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/RelativeDateFormat.java @@ -0,0 +1,619 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * RelativeDateFormat.java + * ----------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Michael Siemer; + * + * Changes: + * -------- + * 01-Nov-2006 : Version 1 (DG); + * 23-Nov-2006 : Added argument checks, updated equals(), added clone() and + * hashCode() (DG); + * 15-Feb-2008 : Applied patch 1873328 by Michael Siemer, with minor + * modifications (DG); + * 01-Sep-2008 : Added new fields for hour and minute formatting, based on + * patch 2033092 (DG); + * 02-Jul-2013 : Use ParamChecks, and fix NB warnings (DG); + * + */ + +package org.jfree.chart.util; + +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.FieldPosition; +import java.text.NumberFormat; +import java.text.ParsePosition; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; + +/** + * A formatter that formats dates to show the elapsed time relative to some + * base date. + * + * @since 1.0.3 + */ +public class RelativeDateFormat extends DateFormat { + + /** The base milliseconds for the elapsed time calculation. */ + private long baseMillis; + + /** + * A flag that controls whether or not a zero day count is displayed. + */ + private boolean showZeroDays; + + /** + * A flag that controls whether or not a zero hour count is displayed. + * + * @since 1.0.10 + */ + private boolean showZeroHours; + + /** + * A formatter for the day count (most likely not critical until the + * day count exceeds 999). + */ + private NumberFormat dayFormatter; + + /** + * A prefix prepended to the start of the format if the relative date is + * positive. + * + * @since 1.0.10 + */ + private String positivePrefix; + + /** + * A string appended after the day count. + */ + private String daySuffix; + + /** + * A formatter for the hours. + * + * @since 1.0.11 + */ + private NumberFormat hourFormatter; + + /** + * A string appended after the hours. + */ + private String hourSuffix; + + /** + * A formatter for the minutes. + * + * @since 1.0.11 + */ + private NumberFormat minuteFormatter; + + /** + * A string appended after the minutes. + */ + private String minuteSuffix; + + /** + * A formatter for the seconds (and milliseconds). + */ + private NumberFormat secondFormatter; + + /** + * A string appended after the seconds. + */ + private String secondSuffix; + + /** + * A constant for the number of milliseconds in one hour. + */ + private static final long MILLISECONDS_IN_ONE_HOUR = 60 * 60 * 1000L; + + /** + * A constant for the number of milliseconds in one day. + */ + private static final long MILLISECONDS_IN_ONE_DAY + = 24 * MILLISECONDS_IN_ONE_HOUR; + + /** + * Creates a new instance with base milliseconds set to zero. + */ + public RelativeDateFormat() { + this(0L); + } + + /** + * Creates a new instance. + * + * @param time the date/time (null not permitted). + */ + public RelativeDateFormat(Date time) { + this(time.getTime()); + } + + /** + * Creates a new instance. + * + * @param baseMillis the time zone (null not permitted). + */ + public RelativeDateFormat(long baseMillis) { + super(); + this.baseMillis = baseMillis; + this.showZeroDays = false; + this.showZeroHours = true; + this.positivePrefix = ""; + this.dayFormatter = NumberFormat.getNumberInstance(); + this.daySuffix = "d"; + this.hourFormatter = NumberFormat.getNumberInstance(); + this.hourSuffix = "h"; + this.minuteFormatter = NumberFormat.getNumberInstance(); + this.minuteSuffix = "m"; + this.secondFormatter = NumberFormat.getNumberInstance(); + this.secondFormatter.setMaximumFractionDigits(3); + this.secondFormatter.setMinimumFractionDigits(3); + this.secondSuffix = "s"; + + // we don't use the calendar or numberFormat fields, but equals(Object) + // is failing without them being non-null + this.calendar = new GregorianCalendar(); + this.numberFormat = new DecimalFormat("0"); + } + + /** + * Returns the base date/time used to calculate the elapsed time for + * display. + * + * @return The base date/time in milliseconds since 1-Jan-1970. + * + * @see #setBaseMillis(long) + */ + public long getBaseMillis() { + return this.baseMillis; + } + + /** + * Sets the base date/time used to calculate the elapsed time for display. + * This should be specified in milliseconds using the same encoding as + * java.util.Date. + * + * @param baseMillis the base date/time in milliseconds. + * + * @see #getBaseMillis() + */ + public void setBaseMillis(long baseMillis) { + this.baseMillis = baseMillis; + } + + /** + * Returns the flag that controls whether or not zero day counts are + * shown in the formatted output. + * + * @return The flag. + * + * @see #setShowZeroDays(boolean) + */ + public boolean getShowZeroDays() { + return this.showZeroDays; + } + + /** + * Sets the flag that controls whether or not zero day counts are shown + * in the formatted output. + * + * @param show the flag. + * + * @see #getShowZeroDays() + */ + public void setShowZeroDays(boolean show) { + this.showZeroDays = show; + } + + /** + * Returns the flag that controls whether or not zero hour counts are + * shown in the formatted output. + * + * @return The flag. + * + * @see #setShowZeroHours(boolean) + * + * @since 1.0.10 + */ + public boolean getShowZeroHours() { + return this.showZeroHours; + } + + /** + * Sets the flag that controls whether or not zero hour counts are shown + * in the formatted output. + * + * @param show the flag. + * + * @see #getShowZeroHours() + * + * @since 1.0.10 + */ + public void setShowZeroHours(boolean show) { + this.showZeroHours = show; + } + + /** + * Returns the string that is prepended to the format if the relative time + * is positive. + * + * @return The string (never null). + * + * @see #setPositivePrefix(String) + * + * @since 1.0.10 + */ + public String getPositivePrefix() { + return this.positivePrefix; + } + + /** + * Sets the string that is prepended to the format if the relative time is + * positive. + * + * @param prefix the prefix (null not permitted). + * + * @see #getPositivePrefix() + * + * @since 1.0.10 + */ + public void setPositivePrefix(String prefix) { + ParamChecks.nullNotPermitted(prefix, "prefix"); + this.positivePrefix = prefix; + } + + /** + * Sets the formatter for the days. + * + * @param formatter the formatter (null not permitted). + * + * @since 1.0.11 + */ + public void setDayFormatter(NumberFormat formatter) { + ParamChecks.nullNotPermitted(formatter, "formatter"); + this.dayFormatter = formatter; + } + + /** + * Returns the string that is appended to the day count. + * + * @return The string. + * + * @see #setDaySuffix(String) + */ + public String getDaySuffix() { + return this.daySuffix; + } + + /** + * Sets the string that is appended to the day count. + * + * @param suffix the suffix (null not permitted). + * + * @see #getDaySuffix() + */ + public void setDaySuffix(String suffix) { + ParamChecks.nullNotPermitted(suffix, "suffix"); + this.daySuffix = suffix; + } + + /** + * Sets the formatter for the hours. + * + * @param formatter the formatter (null not permitted). + * + * @since 1.0.11 + */ + public void setHourFormatter(NumberFormat formatter) { + ParamChecks.nullNotPermitted(formatter, "formatter"); + this.hourFormatter = formatter; + } + + /** + * Returns the string that is appended to the hour count. + * + * @return The string. + * + * @see #setHourSuffix(String) + */ + public String getHourSuffix() { + return this.hourSuffix; + } + + /** + * Sets the string that is appended to the hour count. + * + * @param suffix the suffix (null not permitted). + * + * @see #getHourSuffix() + */ + public void setHourSuffix(String suffix) { + ParamChecks.nullNotPermitted(suffix, "suffix"); + this.hourSuffix = suffix; + } + + /** + * Sets the formatter for the minutes. + * + * @param formatter the formatter (null not permitted). + * + * @since 1.0.11 + */ + public void setMinuteFormatter(NumberFormat formatter) { + ParamChecks.nullNotPermitted(formatter, "formatter"); + this.minuteFormatter = formatter; + } + + /** + * Returns the string that is appended to the minute count. + * + * @return The string. + * + * @see #setMinuteSuffix(String) + */ + public String getMinuteSuffix() { + return this.minuteSuffix; + } + + /** + * Sets the string that is appended to the minute count. + * + * @param suffix the suffix (null not permitted). + * + * @see #getMinuteSuffix() + */ + public void setMinuteSuffix(String suffix) { + ParamChecks.nullNotPermitted(suffix, "suffix"); + this.minuteSuffix = suffix; + } + + /** + * Returns the string that is appended to the second count. + * + * @return The string. + * + * @see #setSecondSuffix(String) + */ + public String getSecondSuffix() { + return this.secondSuffix; + } + + /** + * Sets the string that is appended to the second count. + * + * @param suffix the suffix (null not permitted). + * + * @see #getSecondSuffix() + */ + public void setSecondSuffix(String suffix) { + ParamChecks.nullNotPermitted(suffix, "suffix"); + this.secondSuffix = suffix; + } + + /** + * Sets the formatter for the seconds and milliseconds. + * + * @param formatter the formatter (null not permitted). + */ + public void setSecondFormatter(NumberFormat formatter) { + ParamChecks.nullNotPermitted(formatter, "formatter"); + this.secondFormatter = formatter; + } + + /** + * Formats the given date as the amount of elapsed time (relative to the + * base date specified in the constructor). + * + * @param date the date. + * @param toAppendTo the string buffer. + * @param fieldPosition the field position. + * + * @return The formatted date. + */ + @Override + public StringBuffer format(Date date, StringBuffer toAppendTo, + FieldPosition fieldPosition) { + long currentMillis = date.getTime(); + long elapsed = currentMillis - this.baseMillis; + String signPrefix; + if (elapsed < 0) { + elapsed *= -1L; + signPrefix = "-"; + } + else { + signPrefix = this.positivePrefix; + } + + long days = elapsed / MILLISECONDS_IN_ONE_DAY; + elapsed = elapsed - (days * MILLISECONDS_IN_ONE_DAY); + long hours = elapsed / MILLISECONDS_IN_ONE_HOUR; + elapsed = elapsed - (hours * MILLISECONDS_IN_ONE_HOUR); + long minutes = elapsed / 60000L; + elapsed = elapsed - (minutes * 60000L); + double seconds = elapsed / 1000.0; + + toAppendTo.append(signPrefix); + if (days != 0 || this.showZeroDays) { + toAppendTo.append(this.dayFormatter.format(days)) + .append(getDaySuffix()); + } + if (hours != 0 || this.showZeroHours) { + toAppendTo.append(this.hourFormatter.format(hours)) + .append(getHourSuffix()); + } + toAppendTo.append(this.minuteFormatter.format(minutes)) + .append(getMinuteSuffix()); + toAppendTo.append(this.secondFormatter.format(seconds)) + .append(getSecondSuffix()); + return toAppendTo; + } + + /** + * Parses the given string (not implemented). + * + * @param source the date string. + * @param pos the parse position. + * + * @return null, as this method has not been implemented. + */ + @Override + public Date parse(String source, ParsePosition pos) { + return null; + } + + /** + * Tests this formatter for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof RelativeDateFormat)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + RelativeDateFormat that = (RelativeDateFormat) obj; + if (this.baseMillis != that.baseMillis) { + return false; + } + if (this.showZeroDays != that.showZeroDays) { + return false; + } + if (this.showZeroHours != that.showZeroHours) { + return false; + } + if (!this.positivePrefix.equals(that.positivePrefix)) { + return false; + } + if (!this.daySuffix.equals(that.daySuffix)) { + return false; + } + if (!this.hourSuffix.equals(that.hourSuffix)) { + return false; + } + if (!this.minuteSuffix.equals(that.minuteSuffix)) { + return false; + } + if (!this.secondSuffix.equals(that.secondSuffix)) { + return false; + } + if (!this.dayFormatter.equals(that.dayFormatter)) { + return false; + } + if (!this.hourFormatter.equals(that.hourFormatter)) { + return false; + } + if (!this.minuteFormatter.equals(that.minuteFormatter)) { + return false; + } + if (!this.secondFormatter.equals(that.secondFormatter)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 193; + result = 37 * result + + (int) (this.baseMillis ^ (this.baseMillis >>> 32)); + result = 37 * result + this.positivePrefix.hashCode(); + result = 37 * result + this.daySuffix.hashCode(); + result = 37 * result + this.hourSuffix.hashCode(); + result = 37 * result + this.minuteSuffix.hashCode(); + result = 37 * result + this.secondSuffix.hashCode(); + result = 37 * result + this.secondFormatter.hashCode(); + return result; + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + */ + @Override + public Object clone() { + RelativeDateFormat clone = (RelativeDateFormat) super.clone(); + clone.dayFormatter = (NumberFormat) this.dayFormatter.clone(); + clone.secondFormatter = (NumberFormat) this.secondFormatter.clone(); + return clone; + } + + /** + * Some test code. + * + * @param args ignored. + */ + public static void main(String[] args) { + GregorianCalendar c0 = new GregorianCalendar(2006, 10, 1, 0, 0, 0); + GregorianCalendar c1 = new GregorianCalendar(2006, 10, 1, 11, 37, 43); + c1.set(Calendar.MILLISECOND, 123); + + System.out.println("Default: "); + RelativeDateFormat rdf = new RelativeDateFormat(c0.getTime().getTime()); + System.out.println(rdf.format(c1.getTime())); + System.out.println(); + + System.out.println("Hide milliseconds: "); + rdf.setSecondFormatter(new DecimalFormat("0")); + System.out.println(rdf.format(c1.getTime())); + System.out.println(); + + System.out.println("Show zero day output: "); + rdf.setShowZeroDays(true); + System.out.println(rdf.format(c1.getTime())); + System.out.println(); + + System.out.println("Alternative suffixes: "); + rdf.setShowZeroDays(false); + rdf.setDaySuffix(":"); + rdf.setHourSuffix(":"); + rdf.setMinuteSuffix(":"); + rdf.setSecondSuffix(""); + System.out.println(rdf.format(c1.getTime())); + System.out.println(); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/ResourceBundleWrapper.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/ResourceBundleWrapper.java new file mode 100755 index 0000000..a5f7dfc --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/ResourceBundleWrapper.java @@ -0,0 +1,170 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * ResourceBundleWrapper.java + * -------------------------- + * (C)opyright 2008, 2009, by Jess Thrysoee and Contributors. + * + * Original Author: Jess Thrysoee; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 18-Dec-2008 : Version 1 (JT); + * + */ + +package org.jfree.chart.util; + +import java.net.URL; +import java.net.URLClassLoader; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.ResourceBundle; + +/** + * Wrapper of ResourceBundle.getBundle() methods. This wrapper is introduced to + * avoid a dramatic performance penalty by superfluous resource (and classes + * loaded by Class.forName) lookups on web server in applets. + * + *

+ * public class AppletC extends javax.swing.JApplet {
+ *    public void init() {
+ *       ResourceBundleWrapper.removeCodeBase(getCodeBase(),
+ *               (URLClassLoader) getClass().getClassLoader());
+ *    ...
+ * 
+ * + * @see + * Bug ID: 4243379 + * @see + * Bug ID: 4668479 + * + * @since 1.0.12 + */ +public class ResourceBundleWrapper { + + /** + * A special class loader with no code base lookup. This field may be + * null (the field is only initialised if removeCodeBase() is + * called from an applet). + */ + private static URLClassLoader noCodeBaseClassLoader; + + /** + * Private constructor. + */ + private ResourceBundleWrapper() { + // all methods are static, no need to instantiate + } + + /** + * Instantiate a {@link URLClassLoader} for resource lookups where the + * codeBase URL is removed. This method is typically called from an + * applet's init() method. If this method is never called, the + * getBundle() methods map to the standard + * {@link ResourceBundle} lookup methods. + * + * @param codeBase the codeBase URL. + * @param urlClassLoader the class loader. + */ + public static void removeCodeBase(URL codeBase, + URLClassLoader urlClassLoader) { + List urlsNoBase = new ArrayList(); + + URL[] urls = urlClassLoader.getURLs(); + for (int i = 0; i < urls.length; i++) { + if (!urls[i].sameFile(codeBase)) { + urlsNoBase.add(urls[i]); + } + } + // substitute the filtered URL list + URL[] urlsNoBaseArray = (URL[]) urlsNoBase.toArray(new URL[0]); + noCodeBaseClassLoader = URLClassLoader.newInstance(urlsNoBaseArray); + } + + /** + * Finds and returns the specified resource bundle. + * + * @param baseName the base name. + * + * @return The resource bundle. + */ + public static ResourceBundle getBundle(String baseName) { + // the noCodeBaseClassLoader is configured by a call to the + // removeCodeBase() method, typically in the init() method of an + // applet... + if (noCodeBaseClassLoader != null) { + return ResourceBundle.getBundle(baseName, Locale.getDefault(), + noCodeBaseClassLoader); + } + else { + // standard ResourceBundle behaviour + return ResourceBundle.getBundle(baseName); + } + } + + /** + * Finds and returns the specified resource bundle. + * + * @param baseName the base name. + * @param locale the locale. + * + * @return The resource bundle. + */ + public static ResourceBundle getBundle(String baseName, Locale locale) { + + // the noCodeBaseClassLoader is configured by a call to the + // removeCodeBase() method, typically in the init() method of an + // applet... + if (noCodeBaseClassLoader != null) { + return ResourceBundle.getBundle(baseName, locale, + noCodeBaseClassLoader); + } + else { + // standard ResourceBundle behaviour + return ResourceBundle.getBundle(baseName, locale); + } + } + + /** + * Maps directly to ResourceBundle.getBundle(baseName, locale, + * loader). + * + * @param baseName the base name. + * @param locale the locale. + * @param loader the class loader. + * + * @return The resource bundle. + */ + public static ResourceBundle getBundle(String baseName, Locale locale, + ClassLoader loader) { + return ResourceBundle.getBundle(baseName, locale, loader); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/ShadowGenerator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/ShadowGenerator.java new file mode 100755 index 0000000..73e9d35 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/ShadowGenerator.java @@ -0,0 +1,79 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * ShadowGenerator.java + * -------------------- + * (C) Copyright 2009, 2011, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 10-Jul-2009 : Version 1 (DG); + * + */ + +package org.jfree.chart.util; + +import java.awt.image.BufferedImage; + +/** + * An interface that defines the API for a shadow generator. Some plot + * classes use this to create drop shadows. + * + * @since 1.0.14 + */ +public interface ShadowGenerator { + + /** + * Creates and returns an image containing the drop shadow for the + * specified source image. + * + * @param source the source image. + * + * @return A new image containing the shadow. + */ + public BufferedImage createDropShadow(BufferedImage source); + + /** + * Calculates the x-offset for drawing the shadow image relative to the + * source. + * + * @return The x-offset. + */ + public int calculateOffsetX(); + + /** + * Calculates the y-offset for drawing the shadow image relative to the + * source. + * + * @return The y-offset. + */ + public int calculateOffsetY(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/XYCoordinateType.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/XYCoordinateType.java new file mode 100755 index 0000000..014e446 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/XYCoordinateType.java @@ -0,0 +1,137 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * XYCoordinateType.java + * --------------------- + * (C) Copyright 2007, 2008 by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 02-Feb-2007 : Version 1 (DG); + * 03-Sep-2008 : Moved from experimental to main (DG); + * + */ + +package org.jfree.chart.util; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Represents several possible interpretations for an (x, y) coordinate. + * + * @since 1.0.11 + */ +public final class XYCoordinateType implements Serializable { + + /** The (x, y) coordinates represent a point in the data space. */ + public static final XYCoordinateType DATA + = new XYCoordinateType("XYCoordinateType.DATA"); + + /** + * The (x, y) coordinates represent a relative position in the data space. + * In this case, the values should be in the range (0.0 to 1.0). + */ + public static final XYCoordinateType RELATIVE + = new XYCoordinateType("XYCoordinateType.RELATIVE"); + + /** + * The (x, y) coordinates represent indices in a dataset. + * In this case, the values should be in the range (0.0 to 1.0). + */ + public static final XYCoordinateType INDEX + = new XYCoordinateType("XYCoordinateType.INDEX"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private XYCoordinateType(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof XYCoordinateType)) { + return false; + } + XYCoordinateType order = (XYCoordinateType) 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(XYCoordinateType.DATA)) { + return XYCoordinateType.DATA; + } + else if (this.equals(XYCoordinateType.RELATIVE)) { + return XYCoordinateType.RELATIVE; + } + else if (this.equals(XYCoordinateType.INDEX)) { + return XYCoordinateType.INDEX; + } + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/package.html new file mode 100755 index 0000000..b46855c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/chart/util/package.html @@ -0,0 +1,6 @@ + + + +Utility classes used by JFreeChart. Some of these will be candidates for addition to JCommon, but we keep them here so that our dependency is only JCommon 1.0.0 or later. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/ComparableObjectItem.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/ComparableObjectItem.java new file mode 100755 index 0000000..0a66612 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/ComparableObjectItem.java @@ -0,0 +1,194 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * ComparableObjectItem.java + * ------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Oct-2006 : New class, based on XYDataItem (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data; + +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.util.ObjectUtilities; + +/** + * Represents one (Comparable, Object) data item for use in a + * {@link ComparableObjectSeries}. + * + * @since 1.0.3 + */ +public class ComparableObjectItem implements Cloneable, Comparable, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 2751513470325494890L; + + /** The x-value. */ + private Comparable x; + + /** The y-value. */ + private Object obj; + + /** + * Constructs a new data item. + * + * @param x the x-value (null NOT permitted). + * @param y the y-value (null permitted). + */ + public ComparableObjectItem(Comparable x, Object y) { + ParamChecks.nullNotPermitted(x, "x"); + this.x = x; + this.obj = y; + } + + /** + * Returns the x-value. + * + * @return The x-value (never null). + */ + protected Comparable getComparable() { + return this.x; + } + + /** + * Returns the y-value. + * + * @return The y-value (possibly null). + */ + protected Object getObject() { + return this.obj; + } + + /** + * Sets the y-value for this data item. Note that there is no + * corresponding method to change the x-value. + * + * @param y the new y-value (null permitted). + */ + protected void setObject(Object y) { + this.obj = y; + } + + /** + * Returns an integer indicating the order of this object relative to + * another object. + *

+ * For the order we consider only the x-value: + * negative == "less-than", zero == "equal", positive == "greater-than". + * + * @param o1 the object being compared to. + * + * @return An integer indicating the order of this data pair object + * relative to another object. + */ + @Override + public int compareTo(Object o1) { + + int result; + + // CASE 1 : Comparing to another ComparableObjectItem object + // --------------------------------------------------------- + if (o1 instanceof ComparableObjectItem) { + ComparableObjectItem that = (ComparableObjectItem) o1; + return this.x.compareTo(that.x); + } + + // CASE 2 : Comparing to a general object + // --------------------------------------------- + else { + // consider these to be ordered after general objects + result = 1; + } + + return result; + + } + + /** + * Returns a clone of this object. + * + * @return A clone. + * + * @throws CloneNotSupportedException not thrown by this class, but + * subclasses may differ. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Tests if this object is equal to another. + * + * @param obj the object to test against for equality (null + * permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ComparableObjectItem)) { + return false; + } + ComparableObjectItem that = (ComparableObjectItem) obj; + if (!this.x.equals(that.x)) { + return false; + } + if (!ObjectUtilities.equal(this.obj, that.obj)) { + return false; + } + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result; + result = this.x.hashCode(); + result = 29 * result + (this.obj != null ? this.obj.hashCode() : 0); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/ComparableObjectSeries.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/ComparableObjectSeries.java new file mode 100755 index 0000000..7288140 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/ComparableObjectSeries.java @@ -0,0 +1,451 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * ComparableObjectSeries.java + * --------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Oct-2006 : New class (DG); + * 31-Oct-2007 : Implemented faster hashCode() (DG); + * 27-Nov-2007 : Changed clear() from protected to public (DG); + * + */ + +package org.jfree.data; + +import java.io.Serializable; +import java.util.Collections; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.general.Series; +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.data.general.SeriesException; +import org.jfree.util.ObjectUtilities; + +/** + * A (possibly ordered) list of (Comparable, Object) data items. + * + * @since 1.0.3 + */ +public class ComparableObjectSeries extends Series + implements Cloneable, Serializable { + + /** Storage for the data items in the series. */ + protected List data; + + /** The maximum number of items for the series. */ + private int maximumItemCount = Integer.MAX_VALUE; + + /** A flag that controls whether the items are automatically sorted. */ + private boolean autoSort; + + /** A flag that controls whether or not duplicate x-values are allowed. */ + private boolean allowDuplicateXValues; + + /** + * Creates a new empty series. By default, items added to the series will + * be sorted into ascending order by x-value, and duplicate x-values will + * be allowed (these defaults can be modified with another constructor. + * + * @param key the series key (null not permitted). + */ + public ComparableObjectSeries(Comparable key) { + this(key, true, true); + } + + /** + * Constructs a new series that contains no data. You can specify + * whether or not duplicate x-values are allowed for the series. + * + * @param key the series key (null not permitted). + * @param autoSort a flag that controls whether or not the items in the + * series are sorted. + * @param allowDuplicateXValues a flag that controls whether duplicate + * x-values are allowed. + */ + public ComparableObjectSeries(Comparable key, boolean autoSort, + boolean allowDuplicateXValues) { + super(key); + this.data = new java.util.ArrayList(); + this.autoSort = autoSort; + this.allowDuplicateXValues = allowDuplicateXValues; + } + + /** + * Returns the flag that controls whether the items in the series are + * automatically sorted. There is no setter for this flag, it must be + * defined in the series constructor. + * + * @return A boolean. + */ + public boolean getAutoSort() { + return this.autoSort; + } + + /** + * Returns a flag that controls whether duplicate x-values are allowed. + * This flag can only be set in the constructor. + * + * @return A boolean. + */ + public boolean getAllowDuplicateXValues() { + return this.allowDuplicateXValues; + } + + /** + * Returns the number of items in the series. + * + * @return The item count. + */ + @Override + public int getItemCount() { + return this.data.size(); + } + + /** + * Returns the maximum number of items that will be retained in the series. + * The default value is Integer.MAX_VALUE. + * + * @return The maximum item count. + * @see #setMaximumItemCount(int) + */ + public int getMaximumItemCount() { + return this.maximumItemCount; + } + + /** + * Sets the maximum number of items that will be retained in the series. + * If you add a new item to the series such that the number of items will + * exceed the maximum item count, then the first element in the series is + * automatically removed, ensuring that the maximum item count is not + * exceeded. + *

+ * Typically this value is set before the series is populated with data, + * but if it is applied later, it may cause some items to be removed from + * the series (in which case a {@link SeriesChangeEvent} will be sent to + * all registered listeners. + * + * @param maximum the maximum number of items for the series. + */ + public void setMaximumItemCount(int maximum) { + this.maximumItemCount = maximum; + boolean dataRemoved = false; + while (this.data.size() > maximum) { + this.data.remove(0); + dataRemoved = true; + } + if (dataRemoved) { + fireSeriesChanged(); + } + } + + /** + * Adds new data to the series and sends a {@link SeriesChangeEvent} to + * all registered listeners. + *

+ * Throws an exception if the x-value is a duplicate AND the + * allowDuplicateXValues flag is false. + * + * @param x the x-value (null not permitted). + * @param y the y-value (null permitted). + */ + protected void add(Comparable x, Object y) { + // argument checking delegated... + add(x, y, true); + } + + /** + * Adds new data to the series and, if requested, sends a + * {@link SeriesChangeEvent} to all registered listeners. + *

+ * Throws an exception if the x-value is a duplicate AND the + * allowDuplicateXValues flag is false. + * + * @param x the x-value (null not permitted). + * @param y the y-value (null permitted). + * @param notify a flag the controls whether or not a + * {@link SeriesChangeEvent} is sent to all registered + * listeners. + */ + protected void add(Comparable x, Object y, boolean notify) { + // delegate argument checking to XYDataItem... + ComparableObjectItem item = new ComparableObjectItem(x, y); + add(item, notify); + } + + /** + * Adds a data item to the series and, if requested, sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param item the (x, y) item (null not permitted). + * @param notify a flag that controls whether or not a + * {@link SeriesChangeEvent} is sent to all registered + * listeners. + */ + protected void add(ComparableObjectItem item, boolean notify) { + + ParamChecks.nullNotPermitted(item, "item"); + if (this.autoSort) { + int index = Collections.binarySearch(this.data, item); + if (index < 0) { + this.data.add(-index - 1, item); + } + else { + if (this.allowDuplicateXValues) { + // need to make sure we are adding *after* any duplicates + int size = this.data.size(); + while (index < size + && item.compareTo(this.data.get(index)) == 0) { + index++; + } + if (index < this.data.size()) { + this.data.add(index, item); + } + else { + this.data.add(item); + } + } + else { + throw new SeriesException("X-value already exists."); + } + } + } + else { + if (!this.allowDuplicateXValues) { + // can't allow duplicate values, so we need to check whether + // there is an item with the given x-value already + int index = indexOf(item.getComparable()); + if (index >= 0) { + throw new SeriesException("X-value already exists."); + } + } + this.data.add(item); + } + if (getItemCount() > this.maximumItemCount) { + this.data.remove(0); + } + if (notify) { + fireSeriesChanged(); + } + } + + /** + * Returns the index of the item with the specified x-value, or a negative + * index if the series does not contain an item with that x-value. Be + * aware that for an unsorted series, the index is found by iterating + * through all items in the series. + * + * @param x the x-value (null not permitted). + * + * @return The index. + */ + public int indexOf(Comparable x) { + if (this.autoSort) { + return Collections.binarySearch(this.data, new ComparableObjectItem( + x, null)); + } + else { + for (int i = 0; i < this.data.size(); i++) { + ComparableObjectItem item = (ComparableObjectItem) + this.data.get(i); + if (item.getComparable().equals(x)) { + return i; + } + } + return -1; + } + } + + /** + * Updates an item in the series. + * + * @param x the x-value (null not permitted). + * @param y the y-value (null permitted). + * + * @throws SeriesException if there is no existing item with the specified + * x-value. + */ + protected void update(Comparable x, Object y) { + int index = indexOf(x); + if (index < 0) { + throw new SeriesException("No observation for x = " + x); + } + else { + ComparableObjectItem item = getDataItem(index); + item.setObject(y); + fireSeriesChanged(); + } + } + + /** + * Updates the value of an item in the series and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param index the item (zero based index). + * @param y the new value (null permitted). + */ + protected void updateByIndex(int index, Object y) { + ComparableObjectItem item = getDataItem(index); + item.setObject(y); + fireSeriesChanged(); + } + + /** + * Return the data item with the specified index. + * + * @param index the index. + * + * @return The data item with the specified index. + */ + protected ComparableObjectItem getDataItem(int index) { + return (ComparableObjectItem) this.data.get(index); + } + + /** + * Deletes a range of items from the series and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param start the start index (zero-based). + * @param end the end index (zero-based). + */ + protected void delete(int start, int end) { + for (int i = start; i <= end; i++) { + this.data.remove(start); + } + fireSeriesChanged(); + } + + /** + * Removes all data items from the series and, unless the series is + * already empty, sends a {@link SeriesChangeEvent} to all registered + * listeners. + */ + public void clear() { + if (this.data.size() > 0) { + this.data.clear(); + fireSeriesChanged(); + } + } + + /** + * Removes the item at the specified index and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param index the index. + * + * @return The item removed. + */ + protected ComparableObjectItem remove(int index) { + ComparableObjectItem result = (ComparableObjectItem) this.data.remove( + index); + fireSeriesChanged(); + return result; + } + + /** + * Removes the item with the specified x-value and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param x the x-value. + + * @return The item removed. + */ + public ComparableObjectItem remove(Comparable x) { + return remove(indexOf(x)); + } + + /** + * Tests this series for equality with an arbitrary object. + * + * @param obj the object to test against for equality + * (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof ComparableObjectSeries)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + ComparableObjectSeries that = (ComparableObjectSeries) obj; + if (this.maximumItemCount != that.maximumItemCount) { + return false; + } + if (this.autoSort != that.autoSort) { + return false; + } + if (this.allowDuplicateXValues != that.allowDuplicateXValues) { + return false; + } + if (!ObjectUtilities.equal(this.data, that.data)) { + return false; + } + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = super.hashCode(); + // it is too slow to look at every data item, so let's just look at + // the first, middle and last items... + int count = getItemCount(); + if (count > 0) { + ComparableObjectItem item = getDataItem(0); + result = 29 * result + item.hashCode(); + } + if (count > 1) { + ComparableObjectItem item = getDataItem(count - 1); + result = 29 * result + item.hashCode(); + } + if (count > 2) { + ComparableObjectItem item = getDataItem(count / 2); + result = 29 * result + item.hashCode(); + } + result = 29 * result + this.maximumItemCount; + result = 29 * result + (this.autoSort ? 1 : 0); + result = 29 * result + (this.allowDuplicateXValues ? 1 : 0); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DataUtilities.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DataUtilities.java new file mode 100755 index 0000000..cc75d05 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DataUtilities.java @@ -0,0 +1,282 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * DataUtilities.java + * ------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (patch 2511330); + * + * Changes + * ------- + * 05-Mar-2003 : Version 1 (DG); + * 03-Mar-2005 : Moved createNumberArray() and createNumberArray2D() methods + * from the DatasetUtilities class (DG); + * 17-May-2005 : Added calculateColumnTotal() and calculateRowTotal() + * methods (DG); + * 28-Jan-2009 : Added equal(double[][], double[][]) method (DG); + * 28-Jan-2009 : Added clone(double[][]) method (DG); + * 04-Feb-2009 : Added calculateColumnTotal/RowTotal variants (PK); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data; + +import java.util.Arrays; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.general.DatasetUtilities; + +/** + * Utility methods for use with some of the data classes (but not the datasets, + * see {@link DatasetUtilities}). + */ +public abstract class DataUtilities { + + /** + * Tests two arrays for equality. To be considered equal, the arrays must + * have exactly the same dimensions, and the values in each array must also + * match (two values that qre both NaN or both INF are considered equal + * in this test). + * + * @param a the first array (null permitted). + * @param b the second array (null permitted). + * + * @return A boolean. + * + * @since 1.0.13 + */ + public static boolean equal(double[][] a, double[][] b) { + if (a == null) { + return (b == null); + } + if (b == null) { + return false; // already know 'a' isn't null + } + if (a.length != b.length) { + return false; + } + for (int i = 0; i < a.length; i++) { + if (!Arrays.equals(a[i], b[i])) { + return false; + } + } + return true; + } + + /** + * Returns a clone of the specified array. + * + * @param source the source array (null not permitted). + * + * @return A clone of the array. + * + * @since 1.0.13 + */ + public static double[][] clone(double[][] source) { + ParamChecks.nullNotPermitted(source, "source"); + double[][] clone = new double[source.length][]; + for (int i = 0; i < source.length; i++) { + if (source[i] != null) { + double[] row = new double[source[i].length]; + System.arraycopy(source[i], 0, row, 0, source[i].length); + clone[i] = row; + } + } + return clone; + } + + /** + * Returns the total of the values in one column of the supplied data + * table. + * + * @param data the table of values (null not permitted). + * @param column the column index (zero-based). + * + * @return The total of the values in the specified column. + */ + public static double calculateColumnTotal(Values2D data, int column) { + ParamChecks.nullNotPermitted(data, "data"); + double total = 0.0; + int rowCount = data.getRowCount(); + for (int r = 0; r < rowCount; r++) { + Number n = data.getValue(r, column); + if (n != null) { + total += n.doubleValue(); + } + } + return total; + } + + /** + * Returns the total of the values in one column of the supplied data + * table by taking only the row numbers in the array into account. + * + * @param data the table of values (null not permitted). + * @param column the column index (zero-based). + * @param validRows the array with valid rows (zero-based). + * + * @return The total of the valid values in the specified column. + * + * @since 1.0.13 + */ + public static double calculateColumnTotal(Values2D data, int column, + int[] validRows) { + ParamChecks.nullNotPermitted(data, "data"); + double total = 0.0; + int rowCount = data.getRowCount(); + for (int v = 0; v < validRows.length; v++) { + int row = validRows[v]; + if (row < rowCount) { + Number n = data.getValue(row, column); + if (n != null) { + total += n.doubleValue(); + } + } + } + return total; + } + + /** + * Returns the total of the values in one row of the supplied data + * table. + * + * @param data the table of values (null not permitted). + * @param row the row index (zero-based). + * + * @return The total of the values in the specified row. + */ + public static double calculateRowTotal(Values2D data, int row) { + ParamChecks.nullNotPermitted(data, "data"); + double total = 0.0; + int columnCount = data.getColumnCount(); + for (int c = 0; c < columnCount; c++) { + Number n = data.getValue(row, c); + if (n != null) { + total += n.doubleValue(); + } + } + return total; + } + + /** + * Returns the total of the values in one row of the supplied data + * table by taking only the column numbers in the array into account. + * + * @param data the table of values (null not permitted). + * @param row the row index (zero-based). + * @param validCols the array with valid cols (zero-based). + * + * @return The total of the valid values in the specified row. + * + * @since 1.0.13 + */ + public static double calculateRowTotal(Values2D data, int row, + int[] validCols) { + ParamChecks.nullNotPermitted(data, "data"); + double total = 0.0; + int colCount = data.getColumnCount(); + for (int v = 0; v < validCols.length; v++) { + int col = validCols[v]; + if (col < colCount) { + Number n = data.getValue(row, col); + if (n != null) { + total += n.doubleValue(); + } + } + } + return total; + } + + /** + * Constructs an array of Number objects from an array of + * double primitives. + * + * @param data the data (null not permitted). + * + * @return An array of Double. + */ + public static Number[] createNumberArray(double[] data) { + ParamChecks.nullNotPermitted(data, "data"); + Number[] result = new Number[data.length]; + for (int i = 0; i < data.length; i++) { + result[i] = new Double(data[i]); + } + return result; + } + + /** + * Constructs an array of arrays of Number objects from a + * corresponding structure containing double primitives. + * + * @param data the data (null not permitted). + * + * @return An array of Double. + */ + public static Number[][] createNumberArray2D(double[][] data) { + ParamChecks.nullNotPermitted(data, "data"); + int l1 = data.length; + Number[][] result = new Number[l1][]; + for (int i = 0; i < l1; i++) { + result[i] = createNumberArray(data[i]); + } + return result; + } + + /** + * Returns a {@link KeyedValues} instance that contains the cumulative + * percentage values for the data in another {@link KeyedValues} instance. + *

+ * The percentages are values between 0.0 and 1.0 (where 1.0 = 100%). + * + * @param data the data (null not permitted). + * + * @return The cumulative percentages. + */ + public static KeyedValues getCumulativePercentages(KeyedValues data) { + ParamChecks.nullNotPermitted(data, "data"); + DefaultKeyedValues result = new DefaultKeyedValues(); + double total = 0.0; + for (int i = 0; i < data.getItemCount(); i++) { + Number v = data.getValue(i); + if (v != null) { + total = total + v.doubleValue(); + } + } + double runningTotal = 0.0; + for (int i = 0; i < data.getItemCount(); i++) { + Number v = data.getValue(i); + if (v != null) { + runningTotal = runningTotal + v.doubleValue(); + } + result.addValue(data.getKey(i), new Double(runningTotal / total)); + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DefaultKeyedValue.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DefaultKeyedValue.java new file mode 100755 index 0000000..c327789 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DefaultKeyedValue.java @@ -0,0 +1,181 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * DefaultKeyedValue.java + * ---------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 31-Oct-2002 : Version 1 (DG); + * 13-Mar-2003 : Added equals() method, and implemented Serializable (DG); + * 18-Aug-2003 : Implemented Cloneable (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.base (DG); + * 15-Sep-2004 : Added PublicCloneable interface (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 11-Jun-2007 : Added toString() method to help with debugging (DG); + * 15-Feb-2008 : Prevent null key (DG); + * 07-Apr-2008 : Removed to-do item (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data; + +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.util.PublicCloneable; + +/** + * A (key, value) pair. This class provides a default implementation + * of the {@link KeyedValue} interface. + */ +public class DefaultKeyedValue implements KeyedValue, Cloneable, + PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -7388924517460437712L; + + /** The key. */ + private Comparable key; + + /** The value. */ + private Number value; + + /** + * Creates a new (key, value) item. + * + * @param key the key (should be immutable, null not + * permitted). + * @param value the value (null permitted). + */ + public DefaultKeyedValue(Comparable key, Number value) { + ParamChecks.nullNotPermitted(key, "key"); + this.key = key; + this.value = value; + } + + /** + * Returns the key. + * + * @return The key (never null). + */ + @Override + public Comparable getKey() { + return this.key; + } + + /** + * Returns the value. + * + * @return The value (possibly null). + */ + @Override + public Number getValue() { + return this.value; + } + + /** + * Sets the value. + * + * @param value the value (null permitted). + */ + public synchronized void setValue(Number value) { + this.value = value; + } + + /** + * Tests this key-value pair for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DefaultKeyedValue)) { + return false; + } + DefaultKeyedValue that = (DefaultKeyedValue) obj; + + if (!this.key.equals(that.key)) { + return false; + } + if (this.value != null + ? !this.value.equals(that.value) : that.value != null) { + return false; + } + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result; + result = (this.key != null ? this.key.hashCode() : 0); + result = 29 * result + (this.value != null ? this.value.hashCode() : 0); + return result; + } + + /** + * Returns a clone. It is assumed that both the key and value are + * immutable objects, so only the references are cloned, not the objects + * themselves. + * + * @return A clone. + * + * @throws CloneNotSupportedException Not thrown by this class, but + * subclasses (if any) might. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return (DefaultKeyedValue) super.clone(); + } + + /** + * Returns a string representing this instance, primarily useful for + * debugging. + * + * @return A string. + */ + @Override + public String toString() { + return "(" + this.key.toString() + ", " + this.value.toString() + ")"; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DefaultKeyedValues.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DefaultKeyedValues.java new file mode 100755 index 0000000..b65634c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DefaultKeyedValues.java @@ -0,0 +1,474 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * DefaultKeyedValues.java + * ----------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Thomas Morgner; + * + * Changes: + * -------- + * 31-Oct-2002 : Version 1 (DG); + * 11-Feb-2003 : Fixed bug in getValue(key) method for unrecognised key (DG); + * 05-Mar-2003 : Added methods to sort stored data 'by key' or 'by value' (DG); + * 13-Mar-2003 : Implemented Serializable (DG); + * 08-Apr-2003 : Modified removeValue(Comparable) method to fix bug 717049 (DG); + * 18-Aug-2003 : Implemented Cloneable (DG); + * 27-Aug-2003 : Moved SortOrder from org.jfree.data --> org.jfree.util (DG); + * 09-Feb-2004 : Modified getIndex() method - see bug report 893256 (DG); + * 15-Sep-2004 : Updated clone() method and added PublicCloneable + * interface (DG); + * 25-Nov-2004 : Small update to the clone() implementation (DG); + * 24-Feb-2005 : Added methods addValue(Comparable, double) and + * setValue(Comparable, double) for convenience (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 31-Jul-2006 : Added a clear() method (DG); + * 01-Aug-2006 : Added argument check to getIndex() method (DG); + * 30-Apr-2007 : Added insertValue() methods (DG); + * 31-Oct-2007 : Performance improvements by using separate lists for keys and + * values (TM); + * 21-Nov-2007 : Fixed bug in removeValue() method from previous patch (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.util.PublicCloneable; +import org.jfree.util.SortOrder; + +/** + * An ordered list of (key, value) items. This class provides a default + * implementation of the {@link KeyedValues} interface. + */ +public class DefaultKeyedValues implements KeyedValues, Cloneable, + PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 8468154364608194797L; + + /** Storage for the keys. */ + private ArrayList keys; + + /** Storage for the values. */ + private ArrayList values; + + /** + * Contains (key, Integer) mappings, where the Integer is the index for + * the key in the list. + */ + private HashMap indexMap; + + /** + * Creates a new collection (initially empty). + */ + public DefaultKeyedValues() { + this.keys = new ArrayList(); + this.values = new ArrayList(); + this.indexMap = new HashMap(); + } + + /** + * Returns the number of items (values) in the collection. + * + * @return The item count. + */ + @Override + public int getItemCount() { + return this.indexMap.size(); + } + + /** + * Returns a value. + * + * @param item the item of interest (zero-based index). + * + * @return The value (possibly null). + * + * @throws IndexOutOfBoundsException if item is out of bounds. + */ + @Override + public Number getValue(int item) { + return (Number) this.values.get(item); + } + + /** + * Returns a key. + * + * @param index the item index (zero-based). + * + * @return The row key. + * + * @throws IndexOutOfBoundsException if item is out of bounds. + */ + @Override + public Comparable getKey(int index) { + return (Comparable) this.keys.get(index); + } + + /** + * Returns the index for a given key. + * + * @param key the key (null not permitted). + * + * @return The index, or -1 if the key is not recognised. + * + * @throws IllegalArgumentException if key is + * null. + */ + @Override + public int getIndex(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + final Integer i = (Integer) this.indexMap.get(key); + if (i == null) { + return -1; // key not found + } + return i.intValue(); + } + + /** + * Returns the keys for the values in the collection. + * + * @return The keys (never null). + */ + @Override + public List getKeys() { + return (List) this.keys.clone(); + } + + /** + * Returns the value for a given key. + * + * @param key the key (null not permitted). + * + * @return The value (possibly null). + * + * @throws UnknownKeyException if the key is not recognised. + * + * @see #getValue(int) + */ + @Override + public Number getValue(Comparable key) { + int index = getIndex(key); + if (index < 0) { + throw new UnknownKeyException("Key not found: " + key); + } + return getValue(index); + } + + /** + * Updates an existing value, or adds a new value to the collection. + * + * @param key the key (null not permitted). + * @param value the value. + * + * @see #addValue(Comparable, Number) + */ + public void addValue(Comparable key, double value) { + addValue(key, new Double(value)); + } + + /** + * Adds a new value to the collection, or updates an existing value. + * This method passes control directly to the + * {@link #setValue(Comparable, Number)} method. + * + * @param key the key (null not permitted). + * @param value the value (null permitted). + */ + public void addValue(Comparable key, Number value) { + setValue(key, value); + } + + /** + * Updates an existing value, or adds a new value to the collection. + * + * @param key the key (null not permitted). + * @param value the value. + */ + public void setValue(Comparable key, double value) { + setValue(key, new Double(value)); + } + + /** + * Updates an existing value, or adds a new value to the collection. + * + * @param key the key (null not permitted). + * @param value the value (null permitted). + */ + public void setValue(Comparable key, Number value) { + ParamChecks.nullNotPermitted(key, "key"); + int keyIndex = getIndex(key); + if (keyIndex >= 0) { + this.keys.set(keyIndex, key); + this.values.set(keyIndex, value); + } + else { + this.keys.add(key); + this.values.add(value); + this.indexMap.put(key, new Integer(this.keys.size() - 1)); + } + } + + /** + * Inserts a new value at the specified position in the dataset or, if + * there is an existing item with the specified key, updates the value + * for that item and moves it to the specified position. + * + * @param position the position (in the range 0 to getItemCount()). + * @param key the key (null not permitted). + * @param value the value. + * + * @since 1.0.6 + */ + public void insertValue(int position, Comparable key, double value) { + insertValue(position, key, new Double(value)); + } + + /** + * Inserts a new value at the specified position in the dataset or, if + * there is an existing item with the specified key, updates the value + * for that item and moves it to the specified position. + * + * @param position the position (in the range 0 to getItemCount()). + * @param key the key (null not permitted). + * @param value the value (null permitted). + * + * @since 1.0.6 + */ + public void insertValue(int position, Comparable key, Number value) { + if (position < 0 || position > getItemCount()) { + throw new IllegalArgumentException("'position' out of bounds."); + } + ParamChecks.nullNotPermitted(key, "key"); + int pos = getIndex(key); + if (pos == position) { + this.keys.set(pos, key); + this.values.set(pos, value); + } + else { + if (pos >= 0) { + this.keys.remove(pos); + this.values.remove(pos); + } + + this.keys.add(position, key); + this.values.add(position, value); + rebuildIndex(); + } + } + + /** + * Rebuilds the key to indexed-position mapping after an positioned insert + * or a remove operation. + */ + private void rebuildIndex () { + this.indexMap.clear(); + for (int i = 0; i < this.keys.size(); i++) { + final Object key = this.keys.get(i); + this.indexMap.put(key, new Integer(i)); + } + } + + /** + * Removes a value from the collection. + * + * @param index the index of the item to remove (in the range + * 0 to getItemCount() - 1). + * + * @throws IndexOutOfBoundsException if index is not within + * the specified range. + */ + public void removeValue(int index) { + this.keys.remove(index); + this.values.remove(index); + rebuildIndex(); + } + + /** + * Removes a value from the collection. + * + * @param key the item key (null not permitted). + * + * @throws IllegalArgumentException if key is + * null. + * @throws UnknownKeyException if key is not recognised. + */ + public void removeValue(Comparable key) { + int index = getIndex(key); + if (index < 0) { + throw new UnknownKeyException("The key (" + key + + ") is not recognised."); + } + removeValue(index); + } + + /** + * Clears all values from the collection. + * + * @since 1.0.2 + */ + public void clear() { + this.keys.clear(); + this.values.clear(); + this.indexMap.clear(); + } + + /** + * Sorts the items in the list by key. + * + * @param order the sort order (null not permitted). + */ + public void sortByKeys(SortOrder order) { + final int size = this.keys.size(); + final DefaultKeyedValue[] data = new DefaultKeyedValue[size]; + + for (int i = 0; i < size; i++) { + data[i] = new DefaultKeyedValue((Comparable) this.keys.get(i), + (Number) this.values.get(i)); + } + + Comparator comparator = new KeyedValueComparator( + KeyedValueComparatorType.BY_KEY, order); + Arrays.sort(data, comparator); + clear(); + + for (int i = 0; i < data.length; i++) { + final DefaultKeyedValue value = data[i]; + addValue(value.getKey(), value.getValue()); + } + } + + /** + * Sorts the items in the list by value. If the list contains + * null values, they will sort to the end of the list, + * irrespective of the sort order. + * + * @param order the sort order (null not permitted). + */ + public void sortByValues(SortOrder order) { + final int size = this.keys.size(); + final DefaultKeyedValue[] data = new DefaultKeyedValue[size]; + for (int i = 0; i < size; i++) { + data[i] = new DefaultKeyedValue((Comparable) this.keys.get(i), + (Number) this.values.get(i)); + } + + Comparator comparator = new KeyedValueComparator( + KeyedValueComparatorType.BY_VALUE, order); + Arrays.sort(data, comparator); + + clear(); + for (int i = 0; i < data.length; i++) { + final DefaultKeyedValue value = data[i]; + addValue(value.getKey(), value.getValue()); + } + } + + /** + * Tests if this object is equal to another. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + + if (!(obj instanceof KeyedValues)) { + return false; + } + + KeyedValues that = (KeyedValues) obj; + int count = getItemCount(); + if (count != that.getItemCount()) { + return false; + } + + for (int i = 0; i < count; i++) { + Comparable k1 = getKey(i); + Comparable k2 = that.getKey(i); + if (!k1.equals(k2)) { + return false; + } + Number v1 = getValue(i); + Number v2 = that.getValue(i); + if (v1 == null) { + if (v2 != null) { + return false; + } + } + else { + if (!v1.equals(v2)) { + return false; + } + } + } + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return (this.keys != null ? this.keys.hashCode() : 0); + } + + /** + * Returns a clone. + * + * @return A clone. + * + * @throws CloneNotSupportedException this class will not throw this + * exception, but subclasses might. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultKeyedValues clone = (DefaultKeyedValues) super.clone(); + clone.keys = (ArrayList) this.keys.clone(); + clone.values = (ArrayList) this.values.clone(); + clone.indexMap = (HashMap) this.indexMap.clone(); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DefaultKeyedValues2D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DefaultKeyedValues2D.java new file mode 100755 index 0000000..3d969f5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DefaultKeyedValues2D.java @@ -0,0 +1,584 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * DefaultKeyedValues2D.java + * ------------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Andreas Schroeder; + * + * Changes + * ------- + * 28-Oct-2002 : Version 1 (DG); + * 21-Jan-2003 : Updated Javadocs (DG); + * 13-Mar-2003 : Implemented Serializable (DG); + * 18-Aug-2003 : Implemented Cloneable (DG); + * 31-Mar-2004 : Made the rows optionally sortable by a flag (AS); + * 01-Apr-2004 : Implemented remove method (AS); + * 05-Apr-2004 : Added clear() method (DG); + * 15-Sep-2004 : Fixed clone() method (DG); + * 12-Jan-2005 : Fixed bug in getValue() method (DG); + * 23-Mar-2005 : Implemented PublicCloneable (DG); + * 09-Jun-2005 : Modified getValue() method to throw exception for unknown + * keys (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 18-Jan-2007 : Fixed bug in getValue() method (DG); + * 30-Mar-2007 : Fixed bug 1690654, problem with removeValue() (DG); + * 21-Nov-2007 : Fixed bug (1835955) in removeColumn(Comparable) method (DG); + * 23-Nov-2007 : Added argument checks to removeRow(Comparable) to make it + * consistent with the removeRow(Comparable) method (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data; + +import java.io.Serializable; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A data structure that stores zero, one or many values, where each value + * is associated with two keys (a 'row' key and a 'column' key). The keys + * should be (a) instances of {@link Comparable} and (b) immutable. + */ +public class DefaultKeyedValues2D implements KeyedValues2D, PublicCloneable, + Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -5514169970951994748L; + + /** The row keys. */ + private List rowKeys; + + /** The column keys. */ + private List columnKeys; + + /** The row data. */ + private List rows; + + /** If the row keys should be sorted by their comparable order. */ + private boolean sortRowKeys; + + /** + * Creates a new instance (initially empty). + */ + public DefaultKeyedValues2D() { + this(false); + } + + /** + * Creates a new instance (initially empty). + * + * @param sortRowKeys if the row keys should be sorted. + */ + public DefaultKeyedValues2D(boolean sortRowKeys) { + this.rowKeys = new java.util.ArrayList(); + this.columnKeys = new java.util.ArrayList(); + this.rows = new java.util.ArrayList(); + this.sortRowKeys = sortRowKeys; + } + + /** + * Returns the row count. + * + * @return The row count. + * + * @see #getColumnCount() + */ + @Override + public int getRowCount() { + return this.rowKeys.size(); + } + + /** + * Returns the column count. + * + * @return The column count. + * + * @see #getRowCount() + */ + @Override + public int getColumnCount() { + return this.columnKeys.size(); + } + + /** + * Returns the value for a given row and column. + * + * @param row the row index. + * @param column the column index. + * + * @return The value. + * + * @see #getValue(Comparable, Comparable) + */ + @Override + public Number getValue(int row, int column) { + Number result = null; + DefaultKeyedValues rowData = (DefaultKeyedValues) this.rows.get(row); + if (rowData != null) { + Comparable columnKey = (Comparable) this.columnKeys.get(column); + // the row may not have an entry for this key, in which case the + // return value is null + int index = rowData.getIndex(columnKey); + if (index >= 0) { + result = rowData.getValue(index); + } + } + return result; + } + + /** + * Returns the key for a given row. + * + * @param row the row index (in the range 0 to {@link #getRowCount()} - 1). + * + * @return The row key. + * + * @see #getRowIndex(Comparable) + * @see #getColumnKey(int) + */ + @Override + public Comparable getRowKey(int row) { + return (Comparable) this.rowKeys.get(row); + } + + /** + * Returns the row index for a given key. + * + * @param key the key (null not permitted). + * + * @return The row index. + * + * @see #getRowKey(int) + * @see #getColumnIndex(Comparable) + */ + @Override + public int getRowIndex(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + if (this.sortRowKeys) { + return Collections.binarySearch(this.rowKeys, key); + } + else { + return this.rowKeys.indexOf(key); + } + } + + /** + * Returns the row keys in an unmodifiable list. + * + * @return The row keys. + * + * @see #getColumnKeys() + */ + @Override + public List getRowKeys() { + return Collections.unmodifiableList(this.rowKeys); + } + + /** + * Returns the key for a given column. + * + * @param column the column (in the range 0 to {@link #getColumnCount()} + * - 1). + * + * @return The key. + * + * @see #getColumnIndex(Comparable) + * @see #getRowKey(int) + */ + @Override + public Comparable getColumnKey(int column) { + return (Comparable) this.columnKeys.get(column); + } + + /** + * Returns the column index for a given key. + * + * @param key the key (null not permitted). + * + * @return The column index. + * + * @see #getColumnKey(int) + * @see #getRowIndex(Comparable) + */ + @Override + public int getColumnIndex(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + return this.columnKeys.indexOf(key); + } + + /** + * Returns the column keys in an unmodifiable list. + * + * @return The column keys. + * + * @see #getRowKeys() + */ + @Override + public List getColumnKeys() { + return Collections.unmodifiableList(this.columnKeys); + } + + /** + * Returns the value for the given row and column keys. This method will + * throw an {@link UnknownKeyException} if either key is not defined in the + * data structure. + * + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @return The value (possibly null). + * + * @see #addValue(Number, Comparable, Comparable) + * @see #removeValue(Comparable, Comparable) + */ + @Override + public Number getValue(Comparable rowKey, Comparable columnKey) { + ParamChecks.nullNotPermitted(rowKey, "rowKey"); + ParamChecks.nullNotPermitted(columnKey, "columnKey"); + + // check that the column key is defined in the 2D structure + if (!(this.columnKeys.contains(columnKey))) { + throw new UnknownKeyException("Unrecognised columnKey: " + + columnKey); + } + + // now fetch the row data - need to bear in mind that the row + // structure may not have an entry for the column key, but that we + // have already checked that the key is valid for the 2D structure + int row = getRowIndex(rowKey); + if (row >= 0) { + DefaultKeyedValues rowData + = (DefaultKeyedValues) this.rows.get(row); + int col = rowData.getIndex(columnKey); + return (col >= 0 ? rowData.getValue(col) : null); + } + else { + throw new UnknownKeyException("Unrecognised rowKey: " + rowKey); + } + } + + /** + * Adds a value to the table. Performs the same function as + * #setValue(Number, Comparable, Comparable). + * + * @param value the value (null permitted). + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @see #setValue(Number, Comparable, Comparable) + * @see #removeValue(Comparable, Comparable) + */ + public void addValue(Number value, Comparable rowKey, + Comparable columnKey) { + // defer argument checking + setValue(value, rowKey, columnKey); + } + + /** + * Adds or updates a value. + * + * @param value the value (null permitted). + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @see #addValue(Number, Comparable, Comparable) + * @see #removeValue(Comparable, Comparable) + */ + public void setValue(Number value, Comparable rowKey, + Comparable columnKey) { + + DefaultKeyedValues row; + int rowIndex = getRowIndex(rowKey); + + if (rowIndex >= 0) { + row = (DefaultKeyedValues) this.rows.get(rowIndex); + } + else { + row = new DefaultKeyedValues(); + if (this.sortRowKeys) { + rowIndex = -rowIndex - 1; + this.rowKeys.add(rowIndex, rowKey); + this.rows.add(rowIndex, row); + } + else { + this.rowKeys.add(rowKey); + this.rows.add(row); + } + } + row.setValue(columnKey, value); + + int columnIndex = this.columnKeys.indexOf(columnKey); + if (columnIndex < 0) { + this.columnKeys.add(columnKey); + } + } + + /** + * Removes a value from the table by setting it to null. If + * all the values in the specified row and/or column are now + * null, the row and/or column is removed from the table. + * + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @see #addValue(Number, Comparable, Comparable) + */ + public void removeValue(Comparable rowKey, Comparable columnKey) { + setValue(null, rowKey, columnKey); + + // 1. check whether the row is now empty. + boolean allNull = true; + int rowIndex = getRowIndex(rowKey); + DefaultKeyedValues row = (DefaultKeyedValues) this.rows.get(rowIndex); + + for (int item = 0, itemCount = row.getItemCount(); item < itemCount; + item++) { + if (row.getValue(item) != null) { + allNull = false; + break; + } + } + + if (allNull) { + this.rowKeys.remove(rowIndex); + this.rows.remove(rowIndex); + } + + // 2. check whether the column is now empty. + allNull = true; + //int columnIndex = getColumnIndex(columnKey); + + for (int item = 0, itemCount = this.rows.size(); item < itemCount; + item++) { + row = (DefaultKeyedValues) this.rows.get(item); + int columnIndex = row.getIndex(columnKey); + if (columnIndex >= 0 && row.getValue(columnIndex) != null) { + allNull = false; + break; + } + } + + if (allNull) { + for (int item = 0, itemCount = this.rows.size(); item < itemCount; + item++) { + row = (DefaultKeyedValues) this.rows.get(item); + int columnIndex = row.getIndex(columnKey); + if (columnIndex >= 0) { + row.removeValue(columnIndex); + } + } + this.columnKeys.remove(columnKey); + } + } + + /** + * Removes a row. + * + * @param rowIndex the row index. + * + * @see #removeRow(Comparable) + * @see #removeColumn(int) + */ + public void removeRow(int rowIndex) { + this.rowKeys.remove(rowIndex); + this.rows.remove(rowIndex); + } + + /** + * Removes a row from the table. + * + * @param rowKey the row key (null not permitted). + * + * @see #removeRow(int) + * @see #removeColumn(Comparable) + * + * @throws UnknownKeyException if rowKey is not defined in the + * table. + */ + public void removeRow(Comparable rowKey) { + ParamChecks.nullNotPermitted(rowKey, "rowKey"); + int index = getRowIndex(rowKey); + if (index >= 0) { + removeRow(index); + } + else { + throw new UnknownKeyException("Unknown key: " + rowKey); + } + } + + /** + * Removes a column. + * + * @param columnIndex the column index. + * + * @see #removeColumn(Comparable) + * @see #removeRow(int) + */ + public void removeColumn(int columnIndex) { + Comparable columnKey = getColumnKey(columnIndex); + removeColumn(columnKey); + } + + /** + * Removes a column from the table. + * + * @param columnKey the column key (null not permitted). + * + * @throws UnknownKeyException if the table does not contain a column with + * the specified key. + * @throws IllegalArgumentException if columnKey is + * null. + * + * @see #removeColumn(int) + * @see #removeRow(Comparable) + */ + public void removeColumn(Comparable columnKey) { + ParamChecks.nullNotPermitted(columnKey, "columnKey"); + if (!this.columnKeys.contains(columnKey)) { + throw new UnknownKeyException("Unknown key: " + columnKey); + } + Iterator iterator = this.rows.iterator(); + while (iterator.hasNext()) { + DefaultKeyedValues rowData = (DefaultKeyedValues) iterator.next(); + int index = rowData.getIndex(columnKey); + if (index >= 0) { + rowData.removeValue(columnKey); + } + } + this.columnKeys.remove(columnKey); + } + + /** + * Clears all the data and associated keys. + */ + public void clear() { + this.rowKeys.clear(); + this.columnKeys.clear(); + this.rows.clear(); + } + + /** + * Tests if this object is equal to another. + * + * @param o the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object o) { + + if (o == null) { + return false; + } + if (o == this) { + return true; + } + + if (!(o instanceof KeyedValues2D)) { + return false; + } + KeyedValues2D kv2D = (KeyedValues2D) o; + if (!getRowKeys().equals(kv2D.getRowKeys())) { + return false; + } + if (!getColumnKeys().equals(kv2D.getColumnKeys())) { + return false; + } + int rowCount = getRowCount(); + if (rowCount != kv2D.getRowCount()) { + return false; + } + + int colCount = getColumnCount(); + if (colCount != kv2D.getColumnCount()) { + return false; + } + + for (int r = 0; r < rowCount; r++) { + for (int c = 0; c < colCount; c++) { + Number v1 = getValue(r, c); + Number v2 = kv2D.getValue(r, c); + if (v1 == null) { + if (v2 != null) { + return false; + } + } + else { + if (!v1.equals(v2)) { + return false; + } + } + } + } + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result; + result = this.rowKeys.hashCode(); + result = 29 * result + this.columnKeys.hashCode(); + result = 29 * result + this.rows.hashCode(); + return result; + } + + /** + * Returns a clone. + * + * @return A clone. + * + * @throws CloneNotSupportedException this class will not throw this + * exception, but subclasses (if any) might. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultKeyedValues2D clone = (DefaultKeyedValues2D) super.clone(); + // for the keys, a shallow copy should be fine because keys + // should be immutable... + clone.columnKeys = new java.util.ArrayList(this.columnKeys); + clone.rowKeys = new java.util.ArrayList(this.rowKeys); + + // but the row data requires a deep copy + clone.rows = (List) ObjectUtilities.deepClone(this.rows); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DomainInfo.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DomainInfo.java new file mode 100755 index 0000000..bc36dfe --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DomainInfo.java @@ -0,0 +1,93 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * DomainInfo.java + * --------------- + * (C) Copyright 2000-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 18-Sep-2001) + * -------------------------- + * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); + * 15-Nov-2001 : Moved to package com.jrefinery.data.* (DG); + * Updated Javadoc comments (DG); + * 22-Apr-2002 : Added getValueRange() method (DG); + * 12-Jul-2002 : Renamed getValueRange() --> getDomainRange() (DG); + * 06-Oct-2004 : Renamed getDomainRange() --> getDomainBounds() (DG); + * 17-Nov-2004 : Added 'includeInterval' argument to all methods (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * 02-Aug-2013 : Updated Javadocs from David Tonhofer (bug 1117) (DG); + * + */ + +package org.jfree.data; + +/** + * An interface (optional) that can be implemented by a dataset to assist in + * determining the minimum and maximum values. If not present, + * {@link org.jfree.data.general.DatasetUtilities} will iterate over all the + * values in the dataset to get the bounds. + */ +public interface DomainInfo { + + /** + * Returns the minimum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The minimum value or Double.NaN if there are no + * values. + */ + public double getDomainLowerBound(boolean includeInterval); + + /** + * Returns the maximum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The maximum value or Double.NaN if there are no + * values. + */ + public double getDomainUpperBound(boolean includeInterval); + + /** + * Returns the range of the values in this dataset's domain. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The range (or null if the dataset contains no + * values). + */ + public Range getDomainBounds(boolean includeInterval); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DomainOrder.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DomainOrder.java new file mode 100755 index 0000000..a19204a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/DomainOrder.java @@ -0,0 +1,140 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * DomainOrder.java + * ---------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 29-Jul-2004 : Version 1 (DG); + * + */ + +package org.jfree.data; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Used to indicate sorting order if any (ascending, descending or none). + */ +public final class DomainOrder implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 4902774943512072627L; + + /** No order. */ + public static final DomainOrder NONE = new DomainOrder("DomainOrder.NONE"); + + /** Ascending order. */ + public static final DomainOrder ASCENDING + = new DomainOrder("DomainOrder.ASCENDING"); + + /** Descending order. */ + public static final DomainOrder DESCENDING + = new DomainOrder("DomainOrder.DESCENDING"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private DomainOrder(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof DomainOrder)) { + return false; + } + DomainOrder that = (DomainOrder) obj; + if (!this.name.equals(that.toString())) { + return false; + } + return true; + } + + /** + * Returns a hash code value for the object. + * + * @return The hashcode + */ + @Override + public int hashCode() { + return this.name.hashCode(); + } + + /** + * 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(DomainOrder.ASCENDING)) { + return DomainOrder.ASCENDING; + } + else if (this.equals(DomainOrder.DESCENDING)) { + return DomainOrder.DESCENDING; + } + else if (this.equals(DomainOrder.NONE)) { + return DomainOrder.NONE; + } + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyToGroupMap.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyToGroupMap.java new file mode 100755 index 0000000..9766de7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyToGroupMap.java @@ -0,0 +1,320 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * KeyToGroupMap.java + * ------------------ + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Apr-2004 : Version 1 (DG); + * 07-Jul-2004 : Added a group list to ensure group index is consistent, fixed + * cloning problem (DG); + * 18-Aug-2005 : Added casts in clone() method to suppress 1.5 compiler + * warnings - see patch 1260587 (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data; + +import java.io.Serializable; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.util.ArrayList; +import java.util.Collection; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A class that maps keys (instances of Comparable) to groups. + */ +public class KeyToGroupMap implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -2228169345475318082L; + + /** The default group. */ + private Comparable defaultGroup; + + /** The groups. */ + private List groups; + + /** A mapping between keys and groups. */ + private Map keyToGroupMap; + + /** + * Creates a new map with a default group named 'Default Group'. + */ + public KeyToGroupMap() { + this("Default Group"); + } + + /** + * Creates a new map with the specified default group. + * + * @param defaultGroup the default group (null not permitted). + */ + public KeyToGroupMap(Comparable defaultGroup) { + ParamChecks.nullNotPermitted(defaultGroup, "defaultGroup"); + this.defaultGroup = defaultGroup; + this.groups = new ArrayList(); + this.keyToGroupMap = new HashMap(); + } + + /** + * Returns the number of groups in the map. + * + * @return The number of groups in the map. + */ + public int getGroupCount() { + return this.groups.size() + 1; + } + + /** + * Returns a list of the groups (always including the default group) in the + * map. The returned list is independent of the map, so altering the list + * will have no effect. + * + * @return The groups (never null). + */ + public List getGroups() { + List result = new ArrayList(); + result.add(this.defaultGroup); + Iterator iterator = this.groups.iterator(); + while (iterator.hasNext()) { + Comparable group = (Comparable) iterator.next(); + if (!result.contains(group)) { + result.add(group); + } + } + return result; + } + + /** + * Returns the index for the group. + * + * @param group the group. + * + * @return The group index (or -1 if the group is not represented within + * the map). + */ + public int getGroupIndex(Comparable group) { + int result = this.groups.indexOf(group); + if (result < 0) { + if (this.defaultGroup.equals(group)) { + result = 0; + } + } + else { + result = result + 1; + } + return result; + } + + /** + * Returns the group that a key is mapped to. + * + * @param key the key (null not permitted). + * + * @return The group (never null, returns the default group if + * there is no mapping for the specified key). + */ + public Comparable getGroup(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + Comparable result = this.defaultGroup; + Comparable group = (Comparable) this.keyToGroupMap.get(key); + if (group != null) { + result = group; + } + return result; + } + + /** + * Maps a key to a group. + * + * @param key the key (null not permitted). + * @param group the group (null permitted, clears any + * existing mapping). + */ + public void mapKeyToGroup(Comparable key, Comparable group) { + ParamChecks.nullNotPermitted(key, "key"); + Comparable currentGroup = getGroup(key); + if (!currentGroup.equals(this.defaultGroup)) { + if (!currentGroup.equals(group)) { + int count = getKeyCount(currentGroup); + if (count == 1) { + this.groups.remove(currentGroup); + } + } + } + if (group == null) { + this.keyToGroupMap.remove(key); + } + else { + if (!this.groups.contains(group)) { + if (!this.defaultGroup.equals(group)) { + this.groups.add(group); + } + } + this.keyToGroupMap.put(key, group); + } + } + + /** + * Returns the number of keys mapped to the specified group. This method + * won't always return an accurate result for the default group, since + * explicit mappings are not required for this group. + * + * @param group the group (null not permitted). + * + * @return The key count. + */ + public int getKeyCount(Comparable group) { + ParamChecks.nullNotPermitted(group, "group"); + int result = 0; + Iterator iterator = this.keyToGroupMap.values().iterator(); + while (iterator.hasNext()) { + Comparable g = (Comparable) iterator.next(); + if (group.equals(g)) { + result++; + } + } + return result; + } + + /** + * Tests the map for equality against an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof KeyToGroupMap)) { + return false; + } + KeyToGroupMap that = (KeyToGroupMap) obj; + if (!ObjectUtilities.equal(this.defaultGroup, that.defaultGroup)) { + return false; + } + if (!this.keyToGroupMap.equals(that.keyToGroupMap)) { + return false; + } + return true; + } + + /** + * Returns a clone of the map. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning the + * map. + */ + @Override + public Object clone() throws CloneNotSupportedException { + KeyToGroupMap result = (KeyToGroupMap) super.clone(); + result.defaultGroup + = (Comparable) KeyToGroupMap.clone(this.defaultGroup); + result.groups = (List) KeyToGroupMap.clone(this.groups); + result.keyToGroupMap = (Map) KeyToGroupMap.clone(this.keyToGroupMap); + return result; + } + + /** + * Attempts to clone the specified object using reflection. + * + * @param object the object (null permitted). + * + * @return The cloned object, or the original object if cloning failed. + */ + private static Object clone(Object object) { + if (object == null) { + return null; + } + Class c = object.getClass(); + Object result = null; + try { + Method m = c.getMethod("clone", (Class[]) null); + if (Modifier.isPublic(m.getModifiers())) { + try { + result = m.invoke(object, (Object[]) null); + } + catch (Exception e) { + e.printStackTrace(); + } + } + } + catch (NoSuchMethodException e) { + result = object; + } + return result; + } + + /** + * Returns a clone of the list. + * + * @param list the list. + * + * @return A clone of the list. + * + * @throws CloneNotSupportedException if the list could not be cloned. + */ + private static Collection clone(Collection list) + throws CloneNotSupportedException { + Collection result = null; + if (list != null) { + try { + List clone = (List) list.getClass().newInstance(); + Iterator iterator = list.iterator(); + while (iterator.hasNext()) { + clone.add(KeyToGroupMap.clone(iterator.next())); + } + result = clone; + } + catch (Exception e) { + throw new CloneNotSupportedException("Exception."); + } + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedObject.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedObject.java new file mode 100755 index 0000000..3114aec --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedObject.java @@ -0,0 +1,151 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * KeyedObject.java + * ---------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 05-Feb-2003 : Version 1 (DG); + * 27-Jan-2003 : Implemented Cloneable and Serializable, and added an equals() + * method (DG); + * + */ + +package org.jfree.data; + +import java.io.Serializable; + +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A (key, object) pair. + */ +public class KeyedObject implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 2677930479256885863L; + + /** The key. */ + private Comparable key; + + /** The object. */ + private Object object; + + /** + * Creates a new (key, object) pair. + * + * @param key the key. + * @param object the object (null permitted). + */ + public KeyedObject(Comparable key, Object object) { + this.key = key; + this.object = object; + } + + /** + * Returns the key. + * + * @return The key. + */ + public Comparable getKey() { + return this.key; + } + + /** + * Returns the object. + * + * @return The object (possibly null). + */ + public Object getObject() { + return this.object; + } + + /** + * Sets the object. + * + * @param object the object (null permitted). + */ + public void setObject(Object object) { + this.object = object; + } + + /** + * Returns a clone of this object. It is assumed that the key is an + * immutable object, so it is not deep-cloned. The object is deep-cloned + * if it implements {@link PublicCloneable}, otherwise a shallow clone is + * made. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + KeyedObject clone = (KeyedObject) super.clone(); + if (this.object instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.object; + clone.object = pc.clone(); + } + return clone; + } + + /** + * Tests if this object is equal to another. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + + if (obj == this) { + return true; + } + + if (!(obj instanceof KeyedObject)) { + return false; + } + KeyedObject that = (KeyedObject) obj; + if (!ObjectUtilities.equal(this.key, that.key)) { + return false; + } + + if (!ObjectUtilities.equal(this.object, that.object)) { + return false; + } + + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedObjects.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedObjects.java new file mode 100755 index 0000000..c7af758 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedObjects.java @@ -0,0 +1,356 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * KeyedObjects.java + * ----------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 31-Oct-2002 : Version 1 (DG); + * 11-Jan-2005 : Minor tidy up (DG); + * 28-Sep-2007 : Clean up equals() method (DG); + * 03-Oct-2007 : Make method behaviour consistent with DefaultKeyedValues (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.util.PublicCloneable; + +/** + * A collection of (key, object) pairs. + */ +public class KeyedObjects implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 1321582394193530984L; + + /** Storage for the data. */ + private List data; + + /** + * Creates a new collection (initially empty). + */ + public KeyedObjects() { + this.data = new java.util.ArrayList(); + } + + /** + * Returns the number of items (values) in the collection. + * + * @return The item count. + */ + public int getItemCount() { + return this.data.size(); + } + + /** + * Returns an object from the list. + * + * @param item the item index (zero-based). + * + * @return The object (possibly null). + * + * @throws IndexOutOfBoundsException if item is out of bounds. + */ + public Object getObject(int item) { + Object result = null; + KeyedObject kobj = (KeyedObject) this.data.get(item); + if (kobj != null) { + result = kobj.getObject(); + } + return result; + } + + /** + * Returns the key at the specified position in the list. + * + * @param index the item index (zero-based). + * + * @return The row key. + * + * @throws IndexOutOfBoundsException if item is out of bounds. + * + * @see #getIndex(Comparable) + */ + public Comparable getKey(int index) { + Comparable result = null; + KeyedObject item = (KeyedObject) this.data.get(index); + if (item != null) { + result = item.getKey(); + } + return result; + } + + /** + * Returns the index for a given key, or -1. + * + * @param key the key (null not permitted). + * + * @return The index, or -1 if the key is unrecognised. + * + * @see #getKey(int) + */ + public int getIndex(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + int i = 0; + Iterator iterator = this.data.iterator(); + while (iterator.hasNext()) { + KeyedObject ko = (KeyedObject) iterator.next(); + if (ko.getKey().equals(key)) { + return i; + } + i++; + } + return -1; + } + + /** + * Returns a list containing all the keys in the list. + * + * @return The keys (never null). + */ + public List getKeys() { + List result = new java.util.ArrayList(); + Iterator iterator = this.data.iterator(); + while (iterator.hasNext()) { + KeyedObject ko = (KeyedObject) iterator.next(); + result.add(ko.getKey()); + } + return result; + } + + /** + * Returns the object for a given key. If the key is not recognised, the + * method should return null. + * + * @param key the key. + * + * @return The object (possibly null). + * + * @see #addObject(Comparable, Object) + */ + public Object getObject(Comparable key) { + int index = getIndex(key); + if (index < 0) { + throw new UnknownKeyException("The key (" + key + + ") is not recognised."); + } + return getObject(index); + } + + /** + * Adds a new object to the collection, or overwrites an existing object. + * This is the same as the {@link #setObject(Comparable, Object)} method. + * + * @param key the key. + * @param object the object. + * + * @see #getObject(Comparable) + */ + public void addObject(Comparable key, Object object) { + setObject(key, object); + } + + /** + * Replaces an existing object, or adds a new object to the collection. + * This is the same as the {@link #addObject(Comparable, Object)} + * method. + * + * @param key the key (null not permitted). + * @param object the object. + * + * @see #getObject(Comparable) + */ + public void setObject(Comparable key, Object object) { + int keyIndex = getIndex(key); + if (keyIndex >= 0) { + KeyedObject ko = (KeyedObject) this.data.get(keyIndex); + ko.setObject(object); + } + else { + KeyedObject ko = new KeyedObject(key, object); + this.data.add(ko); + } + } + + /** + * Inserts a new value at the specified position in the dataset or, if + * there is an existing item with the specified key, updates the value + * for that item and moves it to the specified position. + * + * @param position the position (in the range 0 to + * getItemCount()). + * @param key the key (null not permitted). + * @param value the value (null permitted). + * + * @since 1.0.7 + */ + public void insertValue(int position, Comparable key, Object value) { + if (position < 0 || position > this.data.size()) { + throw new IllegalArgumentException("'position' out of bounds."); + } + ParamChecks.nullNotPermitted(key, "key"); + int pos = getIndex(key); + if (pos >= 0) { + this.data.remove(pos); + } + KeyedObject item = new KeyedObject(key, value); + if (position <= this.data.size()) { + this.data.add(position, item); + } + else { + this.data.add(item); + } + } + + /** + * Removes a value from the collection. + * + * @param index the index of the item to remove. + * + * @see #removeValue(Comparable) + */ + public void removeValue(int index) { + this.data.remove(index); + } + + /** + * Removes a value from the collection. + * + * @param key the key (null not permitted). + * + * @see #removeValue(int) + * + * @throws UnknownKeyException if the key is not recognised. + */ + public void removeValue(Comparable key) { + // defer argument checking + int index = getIndex(key); + if (index < 0) { + throw new UnknownKeyException("The key (" + key.toString() + + ") is not recognised."); + } + removeValue(index); + } + + /** + * Clears all values from the collection. + * + * @since 1.0.7 + */ + public void clear() { + this.data.clear(); + } + + /** + * Returns a clone of this object. Keys in the list should be immutable + * and are not cloned. Objects in the list are cloned only if they + * implement {@link PublicCloneable}. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + KeyedObjects clone = (KeyedObjects) super.clone(); + clone.data = new java.util.ArrayList(); + Iterator iterator = this.data.iterator(); + while (iterator.hasNext()) { + KeyedObject ko = (KeyedObject) iterator.next(); + clone.data.add(ko.clone()); + } + return clone; + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof KeyedObjects)) { + return false; + } + KeyedObjects that = (KeyedObjects) obj; + int count = getItemCount(); + if (count != that.getItemCount()) { + return false; + } + + for (int i = 0; i < count; i++) { + Comparable k1 = getKey(i); + Comparable k2 = that.getKey(i); + if (!k1.equals(k2)) { + return false; + } + Object o1 = getObject(i); + Object o2 = that.getObject(i); + if (o1 == null) { + if (o2 != null) { + return false; + } + } + else { + if (!o1.equals(o2)) { + return false; + } + } + } + return true; + + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return (this.data != null ? this.data.hashCode() : 0); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedObjects2D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedObjects2D.java new file mode 100755 index 0000000..2892b7a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedObjects2D.java @@ -0,0 +1,513 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * KeyedObject2D.java + * ------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Feb-2003 : Version 1 (DG); + * 01-Mar-2004 : Added equals() and clone() methods and implemented + * Serializable (DG); + * 03-Oct-2007 : Updated getObject() to handle modified behaviour in + * KeyedObjects class, added clear() method (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data; + +import java.io.Serializable; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +/** + * A data structure that stores zero, one or many objects, where each object is + * associated with two keys (a 'row' key and a 'column' key). + */ +public class KeyedObjects2D implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -1015873563138522374L; + + /** The row keys. */ + private List rowKeys; + + /** The column keys. */ + private List columnKeys; + + /** The row data. */ + private List rows; + + /** + * Creates a new instance (initially empty). + */ + public KeyedObjects2D() { + this.rowKeys = new java.util.ArrayList(); + this.columnKeys = new java.util.ArrayList(); + this.rows = new java.util.ArrayList(); + } + + /** + * Returns the row count. + * + * @return The row count. + * + * @see #getColumnCount() + */ + public int getRowCount() { + return this.rowKeys.size(); + } + + /** + * Returns the column count. + * + * @return The column count. + * + * @see #getRowCount() + */ + public int getColumnCount() { + return this.columnKeys.size(); + } + + /** + * Returns the object for a given row and column. + * + * @param row the row index (in the range 0 to getRowCount() - 1). + * @param column the column index (in the range 0 to getColumnCount() - 1). + * + * @return The object (possibly null). + * + * @see #getObject(Comparable, Comparable) + */ + public Object getObject(int row, int column) { + Object result = null; + KeyedObjects rowData = (KeyedObjects) this.rows.get(row); + if (rowData != null) { + Comparable columnKey = (Comparable) this.columnKeys.get(column); + if (columnKey != null) { + int index = rowData.getIndex(columnKey); + if (index >= 0) { + result = rowData.getObject(columnKey); + } + } + } + return result; + } + + /** + * Returns the key for a given row. + * + * @param row the row index (zero based). + * + * @return The row index. + * + * @see #getRowIndex(Comparable) + */ + public Comparable getRowKey(int row) { + return (Comparable) this.rowKeys.get(row); + } + + /** + * Returns the row index for a given key, or -1 if the key + * is not recognised. + * + * @param key the key (null not permitted). + * + * @return The row index. + * + * @see #getRowKey(int) + */ + public int getRowIndex(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + return this.rowKeys.indexOf(key); + } + + /** + * Returns the row keys. + * + * @return The row keys (never null). + * + * @see #getRowKeys() + */ + public List getRowKeys() { + return Collections.unmodifiableList(this.rowKeys); + } + + /** + * Returns the key for a given column. + * + * @param column the column. + * + * @return The key. + * + * @see #getColumnIndex(Comparable) + */ + public Comparable getColumnKey(int column) { + return (Comparable) this.columnKeys.get(column); + } + + /** + * Returns the column index for a given key, or -1 if the key + * is not recognised. + * + * @param key the key (null not permitted). + * + * @return The column index. + * + * @see #getColumnKey(int) + */ + public int getColumnIndex(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + return this.columnKeys.indexOf(key); + } + + /** + * Returns the column keys. + * + * @return The column keys (never null). + * + * @see #getRowKeys() + */ + public List getColumnKeys() { + return Collections.unmodifiableList(this.columnKeys); + } + + /** + * Returns the object for the given row and column keys. + * + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @return The object (possibly null). + * + * @throws IllegalArgumentException if rowKey or + * columnKey is null. + * @throws UnknownKeyException if rowKey or + * columnKey is not recognised. + */ + public Object getObject(Comparable rowKey, Comparable columnKey) { + ParamChecks.nullNotPermitted(rowKey, "rowKey"); + ParamChecks.nullNotPermitted(columnKey, "columnKey"); + int row = this.rowKeys.indexOf(rowKey); + if (row < 0) { + throw new UnknownKeyException("Row key (" + rowKey + + ") not recognised."); + } + int column = this.columnKeys.indexOf(columnKey); + if (column < 0) { + throw new UnknownKeyException("Column key (" + columnKey + + ") not recognised."); + } + KeyedObjects rowData = (KeyedObjects) this.rows.get(row); + int index = rowData.getIndex(columnKey); + if (index >= 0) { + return rowData.getObject(index); + } + else { + return null; + } + } + + /** + * Adds an object to the table. Performs the same function as setObject(). + * + * @param object the object. + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + */ + public void addObject(Object object, Comparable rowKey, + Comparable columnKey) { + setObject(object, rowKey, columnKey); + } + + /** + * Adds or updates an object. + * + * @param object the object. + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + */ + public void setObject(Object object, Comparable rowKey, + Comparable columnKey) { + ParamChecks.nullNotPermitted(rowKey, "rowKey"); + ParamChecks.nullNotPermitted(columnKey, "columnKey"); + KeyedObjects row; + int rowIndex = this.rowKeys.indexOf(rowKey); + if (rowIndex >= 0) { + row = (KeyedObjects) this.rows.get(rowIndex); + } + else { + this.rowKeys.add(rowKey); + row = new KeyedObjects(); + this.rows.add(row); + } + row.setObject(columnKey, object); + int columnIndex = this.columnKeys.indexOf(columnKey); + if (columnIndex < 0) { + this.columnKeys.add(columnKey); + } + } + + /** + * Removes an object from the table by setting it to null. If + * all the objects in the specified row and/or column are now + * null, the row and/or column is removed from the table. + * + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @see #addObject(Object, Comparable, Comparable) + */ + public void removeObject(Comparable rowKey, Comparable columnKey) { + int rowIndex = getRowIndex(rowKey); + if (rowIndex < 0) { + throw new UnknownKeyException("Row key (" + rowKey + + ") not recognised."); + } + int columnIndex = getColumnIndex(columnKey); + if (columnIndex < 0) { + throw new UnknownKeyException("Column key (" + columnKey + + ") not recognised."); + } + setObject(null, rowKey, columnKey); + + // 1. check whether the row is now empty. + boolean allNull = true; + KeyedObjects row = (KeyedObjects) this.rows.get(rowIndex); + + for (int item = 0, itemCount = row.getItemCount(); item < itemCount; + item++) { + if (row.getObject(item) != null) { + allNull = false; + break; + } + } + + if (allNull) { + this.rowKeys.remove(rowIndex); + this.rows.remove(rowIndex); + } + + // 2. check whether the column is now empty. + allNull = true; + + for (int item = 0, itemCount = this.rows.size(); item < itemCount; + item++) { + row = (KeyedObjects) this.rows.get(item); + int colIndex = row.getIndex(columnKey); + if (colIndex >= 0 && row.getObject(colIndex) != null) { + allNull = false; + break; + } + } + + if (allNull) { + for (int item = 0, itemCount = this.rows.size(); item < itemCount; + item++) { + row = (KeyedObjects) this.rows.get(item); + int colIndex = row.getIndex(columnKey); + if (colIndex >= 0) { + row.removeValue(colIndex); + } + } + this.columnKeys.remove(columnKey); + } + } + + /** + * Removes an entire row from the table. + * + * @param rowIndex the row index. + * + * @see #removeColumn(int) + */ + public void removeRow(int rowIndex) { + this.rowKeys.remove(rowIndex); + this.rows.remove(rowIndex); + } + + /** + * Removes an entire row from the table. + * + * @param rowKey the row key (null not permitted). + * + * @throws UnknownKeyException if rowKey is not recognised. + * + * @see #removeColumn(Comparable) + */ + public void removeRow(Comparable rowKey) { + int index = getRowIndex(rowKey); + if (index < 0) { + throw new UnknownKeyException("Row key (" + rowKey + + ") not recognised."); + } + removeRow(index); + } + + /** + * Removes an entire column from the table. + * + * @param columnIndex the column index. + * + * @see #removeRow(int) + */ + public void removeColumn(int columnIndex) { + Comparable columnKey = getColumnKey(columnIndex); + removeColumn(columnKey); + } + + /** + * Removes an entire column from the table. + * + * @param columnKey the column key (null not permitted). + * + * @throws UnknownKeyException if rowKey is not recognised. + * + * @see #removeRow(Comparable) + */ + public void removeColumn(Comparable columnKey) { + int index = getColumnIndex(columnKey); + if (index < 0) { + throw new UnknownKeyException("Column key (" + columnKey + + ") not recognised."); + } + Iterator iterator = this.rows.iterator(); + while (iterator.hasNext()) { + KeyedObjects rowData = (KeyedObjects) iterator.next(); + int i = rowData.getIndex(columnKey); + if (i >= 0) { + rowData.removeValue(i); + } + } + this.columnKeys.remove(columnKey); + } + + /** + * Clears all the data and associated keys. + * + * @since 1.0.7 + */ + public void clear() { + this.rowKeys.clear(); + this.columnKeys.clear(); + this.rows.clear(); + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the object to test (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof KeyedObjects2D)) { + return false; + } + + KeyedObjects2D that = (KeyedObjects2D) obj; + if (!getRowKeys().equals(that.getRowKeys())) { + return false; + } + if (!getColumnKeys().equals(that.getColumnKeys())) { + return false; + } + int rowCount = getRowCount(); + if (rowCount != that.getRowCount()) { + return false; + } + int colCount = getColumnCount(); + if (colCount != that.getColumnCount()) { + return false; + } + for (int r = 0; r < rowCount; r++) { + for (int c = 0; c < colCount; c++) { + Object v1 = getObject(r, c); + Object v2 = that.getObject(r, c); + if (v1 == null) { + if (v2 != null) { + return false; + } + } + else { + if (!v1.equals(v2)) { + return false; + } + } + } + } + return true; + } + + /** + * Returns a hashcode for this object. + * + * @return A hashcode. + */ + @Override + public int hashCode() { + int result; + result = this.rowKeys.hashCode(); + result = 29 * result + this.columnKeys.hashCode(); + result = 29 * result + this.rows.hashCode(); + return result; + } + + /** + * Returns a clone. + * + * @return A clone. + * + * @throws CloneNotSupportedException this class will not throw this + * exception, but subclasses (if any) might. + */ + @Override + public Object clone() throws CloneNotSupportedException { + KeyedObjects2D clone = (KeyedObjects2D) super.clone(); + clone.columnKeys = new java.util.ArrayList(this.columnKeys); + clone.rowKeys = new java.util.ArrayList(this.rowKeys); + clone.rows = new java.util.ArrayList(this.rows.size()); + Iterator iterator = this.rows.iterator(); + while (iterator.hasNext()) { + KeyedObjects row = (KeyedObjects) iterator.next(); + clone.rows.add(row.clone()); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValue.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValue.java new file mode 100755 index 0000000..09310c4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValue.java @@ -0,0 +1,59 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * KeyedValue.java + * --------------- + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 31-Oct-2002 : Version 1 (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.base (DG); + * + */ + +package org.jfree.data; + +/** + * A (key, value) pair. + * + * @see DefaultKeyedValue + */ +public interface KeyedValue extends Value { + + /** + * Returns the key associated with the value. The key returned by this + * method should be immutable. + * + * @return The key (never null). + */ + public Comparable getKey(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValueComparator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValueComparator.java new file mode 100755 index 0000000..6737bd3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValueComparator.java @@ -0,0 +1,176 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * KeyedValueComparator.java + * ------------------------- + * (C) Copyright 2003-2012, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 05-Mar-2003 : Version 1 (DG); + * 27-Aug-2003 : Moved SortOrder from org.jfree.data --> org.jfree.util (DG); + * 12-Jan-2005 : Added accessor methods (DG); + * 23-Sep-2012 : Make this class serializable (DG); + * + */ + +package org.jfree.data; + +import java.io.Serializable; +import java.util.Comparator; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.util.SortOrder; + +/** + * A utility class that can compare and order two {@link KeyedValue} instances + * and sort them into ascending or descending order by key or by value. + */ +public class KeyedValueComparator implements Comparator, Serializable { + + /** The comparator type. */ + private KeyedValueComparatorType type; + + /** The sort order. */ + private SortOrder order; + + /** + * Creates a new comparator. + * + * @param type the type (BY_KEY or BY_VALUE, + * null not permitted). + * @param order the order (null not permitted). + */ + public KeyedValueComparator(KeyedValueComparatorType type, + SortOrder order) { + ParamChecks.nullNotPermitted(type, "type"); + ParamChecks.nullNotPermitted(order, "order"); + this.type = type; + this.order = order; + } + + /** + * Returns the type. + * + * @return The type (never null). + */ + public KeyedValueComparatorType getType() { + return this.type; + } + + /** + * Returns the sort order. + * + * @return The sort order (never null). + */ + public SortOrder getOrder() { + return this.order; + } + + /** + * Compares two {@link KeyedValue} instances and returns an + * int that indicates the relative order of the two objects. + * + * @param o1 object 1. + * @param o2 object 2. + * + * @return An int indicating the relative order of the objects. + */ + @Override + public int compare(Object o1, Object o2) { + + if (o2 == null) { + return -1; + } + if (o1 == null) { + return 1; + } + + int result; + + KeyedValue kv1 = (KeyedValue) o1; + KeyedValue kv2 = (KeyedValue) o2; + + if (this.type == KeyedValueComparatorType.BY_KEY) { + if (this.order.equals(SortOrder.ASCENDING)) { + result = kv1.getKey().compareTo(kv2.getKey()); + } + else if (this.order.equals(SortOrder.DESCENDING)) { + result = kv2.getKey().compareTo(kv1.getKey()); + } + else { + throw new IllegalArgumentException("Unrecognised sort order."); + } + } + else if (this.type == KeyedValueComparatorType.BY_VALUE) { + Number n1 = kv1.getValue(); + Number n2 = kv2.getValue(); + if (n2 == null) { + return -1; + } + if (n1 == null) { + return 1; + } + double d1 = n1.doubleValue(); + double d2 = n2.doubleValue(); + if (this.order.equals(SortOrder.ASCENDING)) { + if (d1 > d2) { + result = 1; + } + else if (d1 < d2) { + result = -1; + } + else { + result = 0; + } + } + else if (this.order.equals(SortOrder.DESCENDING)) { + if (d1 > d2) { + result = -1; + } + else if (d1 < d2) { + result = 1; + } + else { + result = 0; + } + } + else { + throw new IllegalArgumentException("Unrecognised sort order."); + } + } + else { + throw new IllegalArgumentException("Unrecognised type."); + } + + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValueComparatorType.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValueComparatorType.java new file mode 100755 index 0000000..d50b81b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValueComparatorType.java @@ -0,0 +1,117 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * KeyedValueComparatorType.java + * ----------------------------- + * (C) Copyright 2003-2012, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 05-Mar-2003 : Version 1 (DG); + * 23-Sep-2012 : Make this class serializable (DG); + * + */ + +package org.jfree.data; + +import java.io.Serializable; + +/** + * Used to indicate the type of a {@link KeyedValueComparator} : 'by key' or + * 'by value'. + */ +public final class KeyedValueComparatorType implements Serializable { + + /** An object representing 'by key' sorting. */ + public static final KeyedValueComparatorType BY_KEY + = new KeyedValueComparatorType("KeyedValueComparatorType.BY_KEY"); + + /** An object representing 'by value' sorting. */ + public static final KeyedValueComparatorType BY_VALUE + = new KeyedValueComparatorType("KeyedValueComparatorType.BY_VALUE"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private KeyedValueComparatorType(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param o the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (!(o instanceof KeyedValueComparatorType)) { + return false; + } + + KeyedValueComparatorType type = (KeyedValueComparatorType) o; + if (!this.name.equals(type.name)) { + return false; + } + + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return this.name.hashCode(); + } +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValues.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValues.java new file mode 100755 index 0000000..d4e3dd1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValues.java @@ -0,0 +1,106 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * KeyedValues.java + * ---------------- + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 23-Oct-2002 : Version 1 (DG); + * 12-Jan-2005 : Updated Javadocs to specify new behaviour when key + * is not recognised (DG); + * ------------- JFREECHART 1.0.0 --------------------------------------------- + * 02-May-2006 : Updated API docs (DG); + * + */ + +package org.jfree.data; + +import java.util.List; + +/** + * An ordered list of (key, value) items where the keys are unique and + * non-null. + * + * @see Values + * @see DefaultKeyedValues + */ +public interface KeyedValues extends Values { + + /** + * Returns the key associated with the item at a given position. Note + * that some implementations allow re-ordering of the data items, so the + * result may be transient. + * + * @param index the item index (in the range 0 to + * getItemCount() - 1). + * + * @return The key (never null). + * + * @throws IndexOutOfBoundsException if index is not in the + * specified range. + */ + public Comparable getKey(int index); + + /** + * Returns the index for a given key. + * + * @param key the key (null not permitted). + * + * @return The index, or -1 if the key is unrecognised. + * + * @throws IllegalArgumentException if key is + * null. + */ + public int getIndex(Comparable key); + + /** + * Returns the keys for the values in the collection. Note that you can + * access the values in this collection by key or by index. For this + * reason, the key order is important - this method should return the keys + * in order. The returned list may be unmodifiable. + * + * @return The keys (never null). + */ + public List getKeys(); + + /** + * Returns the value for a given key. + * + * @param key the key. + * + * @return The value (possibly null). + * + * @throws UnknownKeyException if the key is not recognised. + */ + public Number getValue(Comparable key); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValues2D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValues2D.java new file mode 100755 index 0000000..253c7c5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/KeyedValues2D.java @@ -0,0 +1,118 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * KeyedValues2D.java + * ------------------ + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 28-Oct-2002 : Version 1 (DG); + * 12-Jan-2005 : Updated Javadocs (DG); + * + */ + +package org.jfree.data; + +import java.util.List; + +/** + * An extension of the {@link Values2D} interface where a unique key is + * associated with the row and column indices. + */ +public interface KeyedValues2D extends Values2D { + + /** + * Returns the row key for a given index. + * + * @param row the row index (zero-based). + * + * @return The row key. + * + * @throws IndexOutOfBoundsException if row is out of bounds. + */ + public Comparable getRowKey(int row); + + /** + * Returns the row index for a given key. + * + * @param key the row key. + * + * @return The row index, or -1 if the key is unrecognised. + */ + public int getRowIndex(Comparable key); + + /** + * Returns the row keys. + * + * @return The keys. + */ + public List getRowKeys(); + + /** + * Returns the column key for a given index. + * + * @param column the column index (zero-based). + * + * @return The column key. + * + * @throws IndexOutOfBoundsException if row is out of bounds. + */ + public Comparable getColumnKey(int column); + + /** + * Returns the column index for a given key. + * + * @param key the column key. + * + * @return The column index, or -1 if the key is unrecognised. + */ + public int getColumnIndex(Comparable key); + + /** + * Returns the column keys. + * + * @return The keys. + */ + public List getColumnKeys(); + + /** + * Returns the value associated with the specified keys. + * + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @return The value. + * + * @throws UnknownKeyException if either key is not recognised. + */ + public Number getValue(Comparable rowKey, Comparable columnKey); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/Range.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/Range.java new file mode 100755 index 0000000..4de5c32 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/Range.java @@ -0,0 +1,445 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------- + * Range.java + * ---------- + * (C) Copyright 2002-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Chuanhao Chiu; + * Bill Kelemen; + * Nicolas Brodu; + * Sergei Ivanov; + * + * Changes (from 23-Jun-2001) + * -------------------------- + * 22-Apr-2002 : Version 1, loosely based by code by Bill Kelemen (DG); + * 30-Apr-2002 : Added getLength() and getCentralValue() methods. Changed + * argument check in constructor (DG); + * 13-Jun-2002 : Added contains(double) method (DG); + * 22-Aug-2002 : Added fix to combine method where both ranges are null, thanks + * to Chuanhao Chiu for reporting and fixing this (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 14-Aug-2003 : Added equals() method (DG); + * 27-Aug-2003 : Added toString() method (BK); + * 11-Sep-2003 : Added Clone Support (NB); + * 23-Sep-2003 : Fixed Checkstyle issues (DG); + * 25-Sep-2003 : Oops, Range immutable, clone not necessary (NB); + * 05-May-2004 : Added constrain() and intersects() methods (DG); + * 18-May-2004 : Added expand() method (DG); + * ------------- JFreeChart 1.0.x --------------------------------------------- + * 11-Jan-2006 : Added new method expandToInclude(Range, double) (DG); + * 18-Dec-2007 : New methods intersects(Range) and scale(...) thanks to Sergei + * Ivanov (DG); + * 08-Jan-2012 : New method combineIgnoringNaN() (DG); + * + */ + +package org.jfree.data; + +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +/** + * Represents an immutable range of values. + */ +public strictfp class Range implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -906333695431863380L; + + /** The lower bound of the range. */ + private double lower; + + /** The upper bound of the range. */ + private double upper; + + /** + * Creates a new range. + * + * @param lower the lower bound (must be <= upper bound). + * @param upper the upper bound (must be >= lower bound). + */ + public Range(double lower, double upper) { + if (lower > upper) { + String msg = "Range(double, double): require lower (" + lower + + ") <= upper (" + upper + ")."; + throw new IllegalArgumentException(msg); + } + this.lower = lower; + this.upper = upper; + } + + /** + * Returns the lower bound for the range. + * + * @return The lower bound. + */ + public double getLowerBound() { + return this.lower; + } + + /** + * Returns the upper bound for the range. + * + * @return The upper bound. + */ + public double getUpperBound() { + return this.upper; + } + + /** + * Returns the length of the range. + * + * @return The length. + */ + public double getLength() { + return this.upper - this.lower; + } + + /** + * Returns the central value for the range. + * + * @return The central value. + */ + public double getCentralValue() { + return this.lower / 2.0 + this.upper / 2.0; + } + + /** + * Returns true if the range contains the specified value and + * false otherwise. + * + * @param value the value to lookup. + * + * @return true if the range contains the specified value. + */ + public boolean contains(double value) { + return (value >= this.lower && value <= this.upper); + } + + /** + * Returns true if the range intersects with the specified + * range, and false otherwise. + * + * @param b0 the lower bound (should be <= b1). + * @param b1 the upper bound (should be >= b0). + * + * @return A boolean. + */ + public boolean intersects(double b0, double b1) { + if (b0 <= this.lower) { + return (b1 > this.lower); + } + else { + return (b0 < this.upper && b1 >= b0); + } + } + + /** + * Returns true if the range intersects with the specified + * range, and false otherwise. + * + * @param range another range (null not permitted). + * + * @return A boolean. + * + * @since 1.0.9 + */ + public boolean intersects(Range range) { + return intersects(range.getLowerBound(), range.getUpperBound()); + } + + /** + * Returns the value within the range that is closest to the specified + * value. + * + * @param value the value. + * + * @return The constrained value. + */ + public double constrain(double value) { + double result = value; + if (!contains(value)) { + if (value > this.upper) { + result = this.upper; + } + else if (value < this.lower) { + result = this.lower; + } + } + return result; + } + + /** + * Creates a new range by combining two existing ranges. + *

+ * Note that: + *

    + *
  • either range can be null, in which case the other + * range is returned;
  • + *
  • if both ranges are null the return value is + * null.
  • + *
+ * + * @param range1 the first range (null permitted). + * @param range2 the second range (null permitted). + * + * @return A new range (possibly null). + */ + public static Range combine(Range range1, Range range2) { + if (range1 == null) { + return range2; + } + if (range2 == null) { + return range1; + } + double l = Math.min(range1.getLowerBound(), range2.getLowerBound()); + double u = Math.max(range1.getUpperBound(), range2.getUpperBound()); + return new Range(l, u); + } + + /** + * Combines two ranges. This method has a special handling for Double.NaN. + * + * @param range1 the first range (null permitted). + * @param range2 the second range (null permitted). + * + * @return A new range (possibly null). + * + * @since 1.0.15 + */ + public static Range combineIgnoringNaN(Range range1, Range range2) { + if (range1 == null) { + return range2; + } + if (range2 == null) { + return range1; + } + double l = min(range1.getLowerBound(), range2.getLowerBound()); + double u = max(range1.getUpperBound(), range2.getUpperBound()); + return new Range(l, u); + } + + private static double min(double d1, double d2) { + if (Double.isNaN(d1)) { + return d2; + } + if (Double.isNaN(d2)) { + return d1; + } + return Math.min(d1, d2); + } + + private static double max(double d1, double d2) { + if (Double.isNaN(d1)) { + return d2; + } + if (Double.isNaN(d2)) { + return d1; + } + return Math.max(d1, d2); + } + + /** + * Returns a range that includes all the values in the specified + * range AND the specified value. + * + * @param range the range (null permitted). + * @param value the value that must be included. + * + * @return A range. + * + * @since 1.0.1 + */ + public static Range expandToInclude(Range range, double value) { + if (range == null) { + return new Range(value, value); + } + if (value < range.getLowerBound()) { + return new Range(value, range.getUpperBound()); + } + else if (value > range.getUpperBound()) { + return new Range(range.getLowerBound(), value); + } + else { + return range; + } + } + + /** + * Creates a new range by adding margins to an existing range. + * + * @param range the range (null not permitted). + * @param lowerMargin the lower margin (expressed as a percentage of the + * range length). + * @param upperMargin the upper margin (expressed as a percentage of the + * range length). + * + * @return The expanded range. + */ + public static Range expand(Range range, + double lowerMargin, double upperMargin) { + ParamChecks.nullNotPermitted(range, "range"); + double length = range.getLength(); + double lower = range.getLowerBound() - length * lowerMargin; + double upper = range.getUpperBound() + length * upperMargin; + if (lower > upper) { + lower = lower / 2.0 + upper / 2.0; + upper = lower; + } + return new Range(lower, upper); + } + + /** + * Shifts the range by the specified amount. + * + * @param base the base range (null not permitted). + * @param delta the shift amount. + * + * @return A new range. + */ + public static Range shift(Range base, double delta) { + return shift(base, delta, false); + } + + /** + * Shifts the range by the specified amount. + * + * @param base the base range (null not permitted). + * @param delta the shift amount. + * @param allowZeroCrossing a flag that determines whether or not the + * bounds of the range are allowed to cross + * zero after adjustment. + * + * @return A new range. + */ + public static Range shift(Range base, double delta, + boolean allowZeroCrossing) { + ParamChecks.nullNotPermitted(base, "base"); + if (allowZeroCrossing) { + return new Range(base.getLowerBound() + delta, + base.getUpperBound() + delta); + } + else { + return new Range(shiftWithNoZeroCrossing(base.getLowerBound(), + delta), shiftWithNoZeroCrossing(base.getUpperBound(), + delta)); + } + } + + /** + * Returns the given value adjusted by delta but + * with a check to prevent the result from crossing 0.0. + * + * @param value the value. + * @param delta the adjustment. + * + * @return The adjusted value. + */ + private static double shiftWithNoZeroCrossing(double value, double delta) { + if (value > 0.0) { + return Math.max(value + delta, 0.0); + } + else if (value < 0.0) { + return Math.min(value + delta, 0.0); + } + else { + return value + delta; + } + } + + /** + * Scales the range by the specified factor. + * + * @param base the base range (null not permitted). + * @param factor the scaling factor (must be non-negative). + * + * @return A new range. + * + * @since 1.0.9 + */ + public static Range scale(Range base, double factor) { + ParamChecks.nullNotPermitted(base, "base"); + if (factor < 0) { + throw new IllegalArgumentException("Negative 'factor' argument."); + } + return new Range(base.getLowerBound() * factor, + base.getUpperBound() * factor); + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (!(obj instanceof Range)) { + return false; + } + Range range = (Range) obj; + if (!(this.lower == range.lower)) { + return false; + } + if (!(this.upper == range.upper)) { + return false; + } + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result; + long temp; + temp = Double.doubleToLongBits(this.lower); + result = (int) (temp ^ (temp >>> 32)); + temp = Double.doubleToLongBits(this.upper); + result = 29 * result + (int) (temp ^ (temp >>> 32)); + return result; + } + + /** + * Returns a string representation of this Range. + * + * @return A String "Range[lower,upper]" where lower=lower range and + * upper=upper range. + */ + @Override + public String toString() { + return ("Range[" + this.lower + "," + this.upper + "]"); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/RangeInfo.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/RangeInfo.java new file mode 100755 index 0000000..5868f2c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/RangeInfo.java @@ -0,0 +1,88 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * RangeInfo.java + * -------------- + * (C) Copyright 2000-2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 18-Sep-2001) + * -------------------------- + * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); + * 15-Nov-2001 : Moved to package com.jrefinery.data.* (DG); + * Updated Javadoc comments (DG); + * 22-Apr-2002 : Added getValueRange() method (DG); + * 17-Nov-2004 : Replaced getMinimumRangeValue() --> getRangeLowerBound(), + * getMaximumRangeValue() --> getRangeUpperBound(), + * getValueRange() --> getRangeBounds(). + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * + */ + +package org.jfree.data; + +/** + * An interface (optional) that can be implemented by a dataset to assist in + * determining the minimum and maximum values. See also {@link DomainInfo}. + */ +public interface RangeInfo { + + /** + * Returns the minimum y-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The minimum value. + */ + public double getRangeLowerBound(boolean includeInterval); + + /** + * Returns the maximum y-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The maximum value. + */ + public double getRangeUpperBound(boolean includeInterval); + + /** + * Returns the range of the values in this dataset's range. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The range (or null if the dataset contains no + * values). + */ + public Range getRangeBounds(boolean includeInterval); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/RangeType.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/RangeType.java new file mode 100755 index 0000000..eec2080 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/RangeType.java @@ -0,0 +1,142 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * RangeType.java + * -------------- + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 24-Feb-2005 : Version 1 (DG); + * + */ + +package org.jfree.data; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Used to indicate the type of range to display on an axis (full, positive or + * negative). + */ +public final class RangeType implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -9073319010650549239L; + + /** Full range (positive and negative). */ + public static final RangeType FULL = new RangeType("RangeType.FULL"); + + /** Positive range. */ + public static final RangeType POSITIVE + = new RangeType("RangeType.POSITIVE"); + + /** Negative range. */ + public static final RangeType NEGATIVE + = new RangeType("RangeType.NEGATIVE"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private RangeType(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + + if (this == obj) { + return true; + } + if (!(obj instanceof RangeType)) { + return false; + } + RangeType that = (RangeType) obj; + if (!this.name.equals(that.toString())) { + return false; + } + return true; + } + + /** + * Returns a hash code value for the object. + * + * @return The hashcode + */ + @Override + public int hashCode() { + return this.name.hashCode(); + } + + /** + * 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(RangeType.FULL)) { + return RangeType.FULL; + } + else if (this.equals(RangeType.POSITIVE)) { + return RangeType.POSITIVE; + } + else if (this.equals(RangeType.NEGATIVE)) { + return RangeType.NEGATIVE; + } + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/UnknownKeyException.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/UnknownKeyException.java new file mode 100755 index 0000000..39e5385 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/UnknownKeyException.java @@ -0,0 +1,57 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * UnknownKeyException.java + * ------------------------ + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 12-Jan-2005 : Version 1 (DG); + * + */ + +package org.jfree.data; + +/** + * An exception that indicates an unknown key value. + */ +public class UnknownKeyException extends IllegalArgumentException { + + /** + * Creates a new exception. + * + * @param message a message describing the exception. + */ + public UnknownKeyException(String message) { + super(message); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/Value.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/Value.java new file mode 100755 index 0000000..eefb303 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/Value.java @@ -0,0 +1,56 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------- + * Value.java + * ---------- + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 28-Oct-2002 : Version 1 (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.base (DG); + * + */ + +package org.jfree.data; + +/** + * A general purpose interface for accessing a value. + */ +public interface Value { + + /** + * Returns the value. + * + * @return The value (possibly null). + */ + public Number getValue(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/Values.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/Values.java new file mode 100755 index 0000000..8d9a04b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/Values.java @@ -0,0 +1,71 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------- + * Values.java + * ----------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 08-Nov-2001 : Version 1 (DG); + * 23-Oct-2002 : Renamed getValueCount --> getItemCount (DG);# + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-May-2006 : Updated API docs (DG); + * + */ + +package org.jfree.data; + +/** + * An interface through which (single-dimension) data values can be accessed. + */ +public interface Values { + + /** + * Returns the number of items (values) in the collection. + * + * @return The item count (possibly zero). + */ + public int getItemCount(); + + /** + * Returns the value with the specified index. + * + * @param index the item index (in the range 0 to + * getItemCount() - 1). + * + * @return The value (possibly null). + * + * @throws IndexOutOfBoundsException if index is not in the + * specified range. + */ + public Number getValue(int index); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/Values2D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/Values2D.java new file mode 100755 index 0000000..1ffdc1e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/Values2D.java @@ -0,0 +1,75 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * Values2D.java + * ------------- + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 28-Oct-2002 : Version 1 (DG); + * + */ + +package org.jfree.data; + +/** + * A general purpose interface that can be used to access a table of values. + */ +public interface Values2D { + + /** + * Returns the number of rows in the table. + * + * @return The row count. + */ + public int getRowCount(); + + /** + * Returns the number of columns in the table. + * + * @return The column count. + */ + public int getColumnCount(); + + /** + * Returns a value from the table. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The value (possibly null). + * + * @throws IndexOutOfBoundsException if the row + * or column is out of bounds. + */ + public Number getValue(int row, int column); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/CategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/CategoryDataset.java new file mode 100755 index 0000000..02a5ac5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/CategoryDataset.java @@ -0,0 +1,69 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * CategoryDataset.java + * -------------------- + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 21-Aug-2001) + * -------------------------- + * 21-Aug-2001 : Added standard header. Fixed DOS encoding problem (DG); + * 18-Sep-2001 : Updated e-mail address in header (DG); + * 15-Oct-2001 : Moved to new package (com.jrefinery.data.*) (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * 17-Nov-2001 : Updated Javadoc comments (DG); + * 04-Mar-2002 : Updated import statement (DG); + * 23-Oct-2002 : Reorganised code (DG); + * 10-Jan-2003 : Updated Javadocs (DG); + * 21-Jan-2003 : Merged with TableDataset (which only existed in CVS) (DG); + * 13-Mar-2003 : Added KeyedValues2DDataset interface (DG); + * 23-Apr-2003 : Switched CategoryDataset and KeyedValues2DDataset so that + * CategoryDataset is the super interface (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.category (DG); + * + */ + +package org.jfree.data.category; + +import org.jfree.data.KeyedValues2D; +import org.jfree.data.general.Dataset; + +/** + * The interface for a dataset with one or more series, and values associated + * with categories. + *

+ * The categories are represented by Comparable instance, with the + * category label being provided by the toString method. + */ +public interface CategoryDataset extends KeyedValues2D, Dataset { + + // no additional methods required + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/CategoryRangeInfo.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/CategoryRangeInfo.java new file mode 100755 index 0000000..51bbbf1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/CategoryRangeInfo.java @@ -0,0 +1,67 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * CategoryRangeInfo.java + * ---------------------- + * (C) Copyright 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Mar-2009 : Version 1 (DG); + * + */ + +package org.jfree.data.category; + +import java.util.List; +import org.jfree.data.Range; + +/** + * An interface that can (optionally) be implemented by a dataset to assist in + * determining the minimum and maximum y-values. + * + * @since 1.0.13 + */ +public interface CategoryRangeInfo { + + /** + * Returns the range of the values in this dataset's range. + * + * @param visibleSeriesKeys the keys of the visible series. + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The range (or null if the dataset contains no + * values). + */ + public Range getRangeBounds(List visibleSeriesKeys, + boolean includeInterval); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/CategoryToPieDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/CategoryToPieDataset.java new file mode 100755 index 0000000..bf39d93 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/CategoryToPieDataset.java @@ -0,0 +1,337 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * CategoryToPieDataset.java + * ------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Christian W. Zuckschwerdt; + * + * Changes + * ------- + * 23-Jan-2003 : Version 1 (DG); + * 30-Jul-2003 : Pass through DatasetChangeEvent (CZ); + * 29-Jan-2004 : Replaced 'extract' int with TableOrder (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * ------------- JFREECHART 1.0.0 RELEASED ------------------------------------ + * 26-Jul-2006 : Added serialVersionUID, changed constructor to allow null + * for source, and added getSource(), getExtractType() and + * getExtractIndex() methods - see feature request 1477915 (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.category; + +import java.util.Collections; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.general.AbstractDataset; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetChangeListener; +import org.jfree.data.general.PieDataset; +import org.jfree.util.TableOrder; + +/** + * A {@link PieDataset} implementation that obtains its data from one row or + * column of a {@link CategoryDataset}. + */ +public class CategoryToPieDataset extends AbstractDataset + implements PieDataset, DatasetChangeListener { + + /** For serialization. */ + static final long serialVersionUID = 5516396319762189617L; + + /** The source. */ + private CategoryDataset source; + + /** The extract type. */ + private TableOrder extract; + + /** The row or column index. */ + private int index; + + /** + * An adaptor class that converts any {@link CategoryDataset} into a + * {@link PieDataset}, by taking the values from a single row or column. + *

+ * If source is null, the created dataset will + * be empty. + * + * @param source the source dataset (null permitted). + * @param extract extract data from rows or columns? (null + * not permitted). + * @param index the row or column index. + */ + public CategoryToPieDataset(CategoryDataset source, TableOrder extract, + int index) { + ParamChecks.nullNotPermitted(extract, "extract"); + this.source = source; + if (this.source != null) { + this.source.addChangeListener(this); + } + this.extract = extract; + this.index = index; + } + + /** + * Returns the underlying dataset. + * + * @return The underlying dataset (possibly null). + * + * @since 1.0.2 + */ + public CategoryDataset getUnderlyingDataset() { + return this.source; + } + + /** + * Returns the extract type, which determines whether data is read from + * one row or one column of the underlying dataset. + * + * @return The extract type. + * + * @since 1.0.2 + */ + public TableOrder getExtractType() { + return this.extract; + } + + /** + * Returns the index of the row or column from which to extract the data. + * + * @return The extract index. + * + * @since 1.0.2 + */ + public int getExtractIndex() { + return this.index; + } + + /** + * Returns the number of items (values) in the collection. If the + * underlying dataset is null, this method returns zero. + * + * @return The item count. + */ + @Override + public int getItemCount() { + int result = 0; + if (this.source != null) { + if (this.extract == TableOrder.BY_ROW) { + result = this.source.getColumnCount(); + } + else if (this.extract == TableOrder.BY_COLUMN) { + result = this.source.getRowCount(); + } + } + return result; + } + + /** + * Returns a value from the dataset. + * + * @param item the item index (zero-based). + * + * @return The value (possibly null). + * + * @throws IndexOutOfBoundsException if item is not in the + * range 0 to getItemCount() - 1. + */ + @Override + public Number getValue(int item) { + Number result = null; + if (item < 0 || item >= getItemCount()) { + // this will include the case where the underlying dataset is null + throw new IndexOutOfBoundsException( + "The 'item' index is out of bounds."); + } + if (this.extract == TableOrder.BY_ROW) { + result = this.source.getValue(this.index, item); + } + else if (this.extract == TableOrder.BY_COLUMN) { + result = this.source.getValue(item, this.index); + } + return result; + } + + /** + * Returns the key at the specified index. + * + * @param index the item index (in the range 0 to + * getItemCount() - 1). + * + * @return The key. + * + * @throws IndexOutOfBoundsException if index is not in the + * specified range. + */ + @Override + public Comparable getKey(int index) { + Comparable result = null; + if (index < 0 || index >= getItemCount()) { + // this includes the case where the underlying dataset is null + throw new IndexOutOfBoundsException("Invalid 'index': " + index); + } + if (this.extract == TableOrder.BY_ROW) { + result = this.source.getColumnKey(index); + } + else if (this.extract == TableOrder.BY_COLUMN) { + result = this.source.getRowKey(index); + } + return result; + } + + /** + * Returns the index for a given key, or -1 if there is no + * such key. + * + * @param key the key. + * + * @return The index for the key, or -1. + */ + @Override + public int getIndex(Comparable key) { + int result = -1; + if (this.source != null) { + if (this.extract == TableOrder.BY_ROW) { + result = this.source.getColumnIndex(key); + } + else if (this.extract == TableOrder.BY_COLUMN) { + result = this.source.getRowIndex(key); + } + } + return result; + } + + /** + * Returns the keys for the dataset. + *

+ * If the underlying dataset is null, this method returns an + * empty list. + * + * @return The keys. + */ + @Override + public List getKeys() { + List result = Collections.EMPTY_LIST; + if (this.source != null) { + if (this.extract == TableOrder.BY_ROW) { + result = this.source.getColumnKeys(); + } + else if (this.extract == TableOrder.BY_COLUMN) { + result = this.source.getRowKeys(); + } + } + return result; + } + + /** + * Returns the value for a given key. If the key is not recognised, the + * method should return null (but note that null + * can be associated with a valid key also). + * + * @param key the key. + * + * @return The value (possibly null). + */ + @Override + public Number getValue(Comparable key) { + Number result = null; + int keyIndex = getIndex(key); + if (keyIndex != -1) { + if (this.extract == TableOrder.BY_ROW) { + result = this.source.getValue(this.index, keyIndex); + } + else if (this.extract == TableOrder.BY_COLUMN) { + result = this.source.getValue(keyIndex, this.index); + } + } + return result; + } + + /** + * Sends a {@link DatasetChangeEvent} to all registered listeners, with + * this (not the underlying) dataset as the source. + * + * @param event the event (ignored, a new event with this dataset as the + * source is sent to the listeners). + */ + @Override + public void datasetChanged(DatasetChangeEvent event) { + fireDatasetChanged(); + } + + /** + * Tests this dataset for equality with an arbitrary object, returning + * true if obj is a dataset containing the same + * keys and values in the same order as this dataset. + * + * @param obj the object to test (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof PieDataset)) { + return false; + } + PieDataset that = (PieDataset) obj; + int count = getItemCount(); + if (that.getItemCount() != count) { + return false; + } + for (int i = 0; i < count; i++) { + Comparable k1 = getKey(i); + Comparable k2 = that.getKey(i); + if (!k1.equals(k2)) { + return false; + } + + Number v1 = getValue(i); + Number v2 = that.getValue(i); + if (v1 == null) { + if (v2 != null) { + return false; + } + } + else { + if (!v1.equals(v2)) { + return false; + } + } + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/DefaultCategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/DefaultCategoryDataset.java new file mode 100755 index 0000000..0d6ced0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/DefaultCategoryDataset.java @@ -0,0 +1,446 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * DefaultCategoryDataset.java + * --------------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Jan-2003 : Added standard header, and renamed DefaultCategoryDataset (DG); + * 13-Mar-2003 : Inserted DefaultKeyedValues2DDataset into class hierarchy (DG); + * 06-Oct-2003 : Added incrementValue() method (DG); + * 05-Apr-2004 : Added clear() method (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.category (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 26-Feb-2007 : Updated API docs (DG); + * 08-Mar-2007 : Implemented clone() (DG); + * 09-May-2008 : Implemented PublicCloneable (DG); + * + */ + +package org.jfree.data.category; + +import java.io.Serializable; +import java.util.List; + +import org.jfree.data.DefaultKeyedValues2D; +import org.jfree.data.UnknownKeyException; +import org.jfree.data.general.AbstractDataset; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.util.PublicCloneable; + +/** + * A default implementation of the {@link CategoryDataset} interface. + */ +public class DefaultCategoryDataset extends AbstractDataset + implements CategoryDataset, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -8168173757291644622L; + + /** A storage structure for the data. */ + private DefaultKeyedValues2D data; + + /** + * Creates a new (empty) dataset. + */ + public DefaultCategoryDataset() { + this.data = new DefaultKeyedValues2D(); + } + + /** + * Returns the number of rows in the table. + * + * @return The row count. + * + * @see #getColumnCount() + */ + @Override + public int getRowCount() { + return this.data.getRowCount(); + } + + /** + * Returns the number of columns in the table. + * + * @return The column count. + * + * @see #getRowCount() + */ + @Override + public int getColumnCount() { + return this.data.getColumnCount(); + } + + /** + * Returns a value from the table. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The value (possibly null). + * + * @see #addValue(Number, Comparable, Comparable) + * @see #removeValue(Comparable, Comparable) + */ + @Override + public Number getValue(int row, int column) { + return this.data.getValue(row, column); + } + + /** + * Returns the key for the specified row. + * + * @param row the row index (zero-based). + * + * @return The row key. + * + * @see #getRowIndex(Comparable) + * @see #getRowKeys() + * @see #getColumnKey(int) + */ + @Override + public Comparable getRowKey(int row) { + return this.data.getRowKey(row); + } + + /** + * Returns the row index for a given key. + * + * @param key the row key (null not permitted). + * + * @return The row index. + * + * @see #getRowKey(int) + */ + @Override + public int getRowIndex(Comparable key) { + // defer null argument check + return this.data.getRowIndex(key); + } + + /** + * Returns the row keys. + * + * @return The keys. + * + * @see #getRowKey(int) + */ + @Override + public List getRowKeys() { + return this.data.getRowKeys(); + } + + /** + * Returns a column key. + * + * @param column the column index (zero-based). + * + * @return The column key. + * + * @see #getColumnIndex(Comparable) + */ + @Override + public Comparable getColumnKey(int column) { + return this.data.getColumnKey(column); + } + + /** + * Returns the column index for a given key. + * + * @param key the column key (null not permitted). + * + * @return The column index. + * + * @see #getColumnKey(int) + */ + @Override + public int getColumnIndex(Comparable key) { + // defer null argument check + return this.data.getColumnIndex(key); + } + + /** + * Returns the column keys. + * + * @return The keys. + * + * @see #getColumnKey(int) + */ + @Override + public List getColumnKeys() { + return this.data.getColumnKeys(); + } + + /** + * Returns the value for a pair of keys. + * + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @return The value (possibly null). + * + * @throws UnknownKeyException if either key is not defined in the dataset. + * + * @see #addValue(Number, Comparable, Comparable) + */ + @Override + public Number getValue(Comparable rowKey, Comparable columnKey) { + return this.data.getValue(rowKey, columnKey); + } + + /** + * Adds a value to the table. Performs the same function as setValue(). + * + * @param value the value. + * @param rowKey the row key. + * @param columnKey the column key. + * + * @see #getValue(Comparable, Comparable) + * @see #removeValue(Comparable, Comparable) + */ + public void addValue(Number value, Comparable rowKey, + Comparable columnKey) { + this.data.addValue(value, rowKey, columnKey); + fireDatasetChanged(); + } + + /** + * Adds a value to the table. + * + * @param value the value. + * @param rowKey the row key. + * @param columnKey the column key. + * + * @see #getValue(Comparable, Comparable) + */ + public void addValue(double value, Comparable rowKey, + Comparable columnKey) { + addValue(new Double(value), rowKey, columnKey); + } + + /** + * Adds or updates a value in the table and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param value the value (null permitted). + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @see #getValue(Comparable, Comparable) + */ + public void setValue(Number value, Comparable rowKey, + Comparable columnKey) { + this.data.setValue(value, rowKey, columnKey); + fireDatasetChanged(); + } + + /** + * Adds or updates a value in the table and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param value the value. + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @see #getValue(Comparable, Comparable) + */ + public void setValue(double value, Comparable rowKey, + Comparable columnKey) { + setValue(new Double(value), rowKey, columnKey); + } + + /** + * Adds the specified value to an existing value in the dataset (if the + * existing value is null, it is treated as if it were 0.0). + * + * @param value the value. + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @throws UnknownKeyException if either key is not defined in the dataset. + */ + public void incrementValue(double value, + Comparable rowKey, + Comparable columnKey) { + double existing = 0.0; + Number n = getValue(rowKey, columnKey); + if (n != null) { + existing = n.doubleValue(); + } + setValue(existing + value, rowKey, columnKey); + } + + /** + * Removes a value from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @see #addValue(Number, Comparable, Comparable) + */ + public void removeValue(Comparable rowKey, Comparable columnKey) { + this.data.removeValue(rowKey, columnKey); + fireDatasetChanged(); + } + + /** + * Removes a row from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param rowIndex the row index. + * + * @see #removeColumn(int) + */ + public void removeRow(int rowIndex) { + this.data.removeRow(rowIndex); + fireDatasetChanged(); + } + + /** + * Removes a row from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param rowKey the row key. + * + * @see #removeColumn(Comparable) + */ + public void removeRow(Comparable rowKey) { + this.data.removeRow(rowKey); + fireDatasetChanged(); + } + + /** + * Removes a column from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param columnIndex the column index. + * + * @see #removeRow(int) + */ + public void removeColumn(int columnIndex) { + this.data.removeColumn(columnIndex); + fireDatasetChanged(); + } + + /** + * Removes a column from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param columnKey the column key (null not permitted). + * + * @see #removeRow(Comparable) + * + * @throws UnknownKeyException if columnKey is not defined + * in the dataset. + */ + public void removeColumn(Comparable columnKey) { + this.data.removeColumn(columnKey); + fireDatasetChanged(); + } + + /** + * Clears all data from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + */ + public void clear() { + this.data.clear(); + fireDatasetChanged(); + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof CategoryDataset)) { + return false; + } + CategoryDataset that = (CategoryDataset) obj; + if (!getRowKeys().equals(that.getRowKeys())) { + return false; + } + if (!getColumnKeys().equals(that.getColumnKeys())) { + return false; + } + int rowCount = getRowCount(); + int colCount = getColumnCount(); + for (int r = 0; r < rowCount; r++) { + for (int c = 0; c < colCount; c++) { + Number v1 = getValue(r, c); + Number v2 = that.getValue(r, c); + if (v1 == null) { + if (v2 != null) { + return false; + } + } + else if (!v1.equals(v2)) { + return false; + } + } + } + return true; + } + + /** + * Returns a hash code for the dataset. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return this.data.hashCode(); + } + + /** + * Returns a clone of the dataset. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning the + * dataset. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultCategoryDataset clone = (DefaultCategoryDataset) super.clone(); + clone.data = (DefaultKeyedValues2D) this.data.clone(); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/DefaultIntervalCategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/DefaultIntervalCategoryDataset.java new file mode 100755 index 0000000..47ec1b1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/DefaultIntervalCategoryDataset.java @@ -0,0 +1,855 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------- + * DefaultIntervalCategoryDataset.java + * ----------------------------------- + * (C) Copyright 2002-2013, by Jeremy Bowman and Contributors. + * + * Original Author: Jeremy Bowman; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 29-Apr-2002 : Version 1, contributed by Jeremy Bowman (DG); + * 24-Oct-2002 : Amendments for changes made to the dataset interface (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 08-Mar-2007 : Added equals() and clone() overrides (DG); + * 25-Feb-2008 : Fix for the special case where the dataset is empty, see bug + * 1897580 (DG) + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.category; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.ResourceBundle; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.data.DataUtilities; +import org.jfree.data.UnknownKeyException; +import org.jfree.data.general.AbstractSeriesDataset; + +/** + * A convenience class that provides a default implementation of the + * {@link IntervalCategoryDataset} interface. + *

+ * The standard constructor accepts data in a two dimensional array where the + * first dimension is the series, and the second dimension is the category. + */ +public class DefaultIntervalCategoryDataset extends AbstractSeriesDataset + implements IntervalCategoryDataset { + + /** The series keys. */ + private Comparable[] seriesKeys; + + /** The category keys. */ + private Comparable[] categoryKeys; + + /** Storage for the start value data. */ + private Number[][] startData; + + /** Storage for the end value data. */ + private Number[][] endData; + + /** + * Creates a new dataset using the specified data values and automatically + * generated series and category keys. + * + * @param starts the starting values for the intervals (null + * not permitted). + * @param ends the ending values for the intervals (null not + * permitted). + */ + public DefaultIntervalCategoryDataset(double[][] starts, double[][] ends) { + this(DataUtilities.createNumberArray2D(starts), + DataUtilities.createNumberArray2D(ends)); + } + + /** + * Constructs a dataset and populates it with data from the array. + *

+ * The arrays are indexed as data[series][category]. Series and category + * names are automatically generated - you can change them using the + * {@link #setSeriesKeys(Comparable[])} and + * {@link #setCategoryKeys(Comparable[])} methods. + * + * @param starts the start values data. + * @param ends the end values data. + */ + public DefaultIntervalCategoryDataset(Number[][] starts, Number[][] ends) { + this(null, null, starts, ends); + } + + /** + * Constructs a DefaultIntervalCategoryDataset, populates it with data + * from the arrays, and uses the supplied names for the series. + *

+ * Category names are generated automatically ("Category 1", "Category 2", + * etc). + * + * @param seriesNames the series names (if null, series names + * will be generated automatically). + * @param starts the start values data, indexed as data[series][category]. + * @param ends the end values data, indexed as data[series][category]. + */ + public DefaultIntervalCategoryDataset(String[] seriesNames, + Number[][] starts, + Number[][] ends) { + + this(seriesNames, null, starts, ends); + + } + + /** + * Constructs a DefaultIntervalCategoryDataset, populates it with data + * from the arrays, and uses the supplied names for the series and the + * supplied objects for the categories. + * + * @param seriesKeys the series keys (if null, series keys + * will be generated automatically). + * @param categoryKeys the category keys (if null, category + * keys will be generated automatically). + * @param starts the start values data, indexed as data[series][category]. + * @param ends the end values data, indexed as data[series][category]. + */ + public DefaultIntervalCategoryDataset(Comparable[] seriesKeys, + Comparable[] categoryKeys, + Number[][] starts, + Number[][] ends) { + + this.startData = starts; + this.endData = ends; + + if (starts != null && ends != null) { + + String baseName = "org.jfree.data.resources.DataPackageResources"; + ResourceBundle resources = ResourceBundleWrapper.getBundle( + baseName); + + int seriesCount = starts.length; + if (seriesCount != ends.length) { + String errMsg = "DefaultIntervalCategoryDataset: the number " + + "of series in the start value dataset does " + + "not match the number of series in the end " + + "value dataset."; + throw new IllegalArgumentException(errMsg); + } + if (seriesCount > 0) { + + // set up the series names... + if (seriesKeys != null) { + + if (seriesKeys.length != seriesCount) { + throw new IllegalArgumentException( + "The number of series keys does not " + + "match the number of series in the data."); + } + + this.seriesKeys = seriesKeys; + } + else { + String prefix = resources.getString( + "series.default-prefix") + " "; + this.seriesKeys = generateKeys(seriesCount, prefix); + } + + // set up the category names... + int categoryCount = starts[0].length; + if (categoryCount != ends[0].length) { + String errMsg = "DefaultIntervalCategoryDataset: the " + + "number of categories in the start value " + + "dataset does not match the number of " + + "categories in the end value dataset."; + throw new IllegalArgumentException(errMsg); + } + if (categoryKeys != null) { + if (categoryKeys.length != categoryCount) { + throw new IllegalArgumentException( + "The number of category keys does not match " + + "the number of categories in the data."); + } + this.categoryKeys = categoryKeys; + } + else { + String prefix = resources.getString( + "categories.default-prefix") + " "; + this.categoryKeys = generateKeys(categoryCount, prefix); + } + + } + else { + this.seriesKeys = new Comparable[0]; + this.categoryKeys = new Comparable[0]; + } + } + + } + + /** + * Returns the number of series in the dataset (possibly zero). + * + * @return The number of series in the dataset. + * + * @see #getRowCount() + * @see #getCategoryCount() + */ + @Override + public int getSeriesCount() { + int result = 0; + if (this.startData != null) { + result = this.startData.length; + } + return result; + } + + /** + * Returns a series index. + * + * @param seriesKey the series key. + * + * @return The series index. + * + * @see #getRowIndex(Comparable) + * @see #getSeriesKey(int) + */ + public int getSeriesIndex(Comparable seriesKey) { + int result = -1; + for (int i = 0; i < this.seriesKeys.length; i++) { + if (seriesKey.equals(this.seriesKeys[i])) { + result = i; + break; + } + } + return result; + } + + /** + * Returns the name of the specified series. + * + * @param series the index of the required series (zero-based). + * + * @return The name of the specified series. + * + * @see #getSeriesIndex(Comparable) + */ + @Override + public Comparable getSeriesKey(int series) { + if ((series >= getSeriesCount()) || (series < 0)) { + throw new IllegalArgumentException("No such series : " + series); + } + return this.seriesKeys[series]; + } + + /** + * Sets the names of the series in the dataset. + * + * @param seriesKeys the new keys (null not permitted, the + * length of the array must match the number of series in the + * dataset). + * + * @see #setCategoryKeys(Comparable[]) + */ + public void setSeriesKeys(Comparable[] seriesKeys) { + ParamChecks.nullNotPermitted(seriesKeys, "seriesKeys"); + if (seriesKeys.length != getSeriesCount()) { + throw new IllegalArgumentException( + "The number of series keys does not match the data."); + } + this.seriesKeys = seriesKeys; + fireDatasetChanged(); + } + + /** + * Returns the number of categories in the dataset. + * + * @return The number of categories in the dataset. + * + * @see #getColumnCount() + */ + public int getCategoryCount() { + int result = 0; + if (this.startData != null) { + if (getSeriesCount() > 0) { + result = this.startData[0].length; + } + } + return result; + } + + /** + * Returns a list of the categories in the dataset. This method supports + * the {@link CategoryDataset} interface. + * + * @return A list of the categories in the dataset. + * + * @see #getRowKeys() + */ + @Override + public List getColumnKeys() { + // the CategoryDataset interface expects a list of categories, but + // we've stored them in an array... + if (this.categoryKeys == null) { + return new ArrayList(); + } + else { + return Collections.unmodifiableList(Arrays.asList( + this.categoryKeys)); + } + } + + /** + * Sets the categories for the dataset. + * + * @param categoryKeys an array of objects representing the categories in + * the dataset. + * + * @see #getRowKeys() + * @see #setSeriesKeys(Comparable[]) + */ + public void setCategoryKeys(Comparable[] categoryKeys) { + ParamChecks.nullNotPermitted(categoryKeys, "categoryKeys"); + if (categoryKeys.length != getCategoryCount()) { + throw new IllegalArgumentException( + "The number of categories does not match the data."); + } + for (int i = 0; i < categoryKeys.length; i++) { + if (categoryKeys[i] == null) { + throw new IllegalArgumentException( + "DefaultIntervalCategoryDataset.setCategoryKeys(): " + + "null category not permitted."); + } + } + this.categoryKeys = categoryKeys; + fireDatasetChanged(); + } + + /** + * Returns the data value for one category in a series. + *

+ * This method is part of the CategoryDataset interface. Not particularly + * meaningful for this class...returns the end value. + * + * @param series The required series (zero based index). + * @param category The required category. + * + * @return The data value for one category in a series (null possible). + * + * @see #getEndValue(Comparable, Comparable) + */ + @Override + public Number getValue(Comparable series, Comparable category) { + int seriesIndex = getSeriesIndex(series); + if (seriesIndex < 0) { + throw new UnknownKeyException("Unknown 'series' key."); + } + int itemIndex = getColumnIndex(category); + if (itemIndex < 0) { + throw new UnknownKeyException("Unknown 'category' key."); + } + return getValue(seriesIndex, itemIndex); + } + + /** + * Returns the data value for one category in a series. + *

+ * This method is part of the CategoryDataset interface. Not particularly + * meaningful for this class...returns the end value. + * + * @param series the required series (zero based index). + * @param category the required category. + * + * @return The data value for one category in a series (null possible). + * + * @see #getEndValue(int, int) + */ + @Override + public Number getValue(int series, int category) { + return getEndValue(series, category); + } + + /** + * Returns the start data value for one category in a series. + * + * @param series the required series. + * @param category the required category. + * + * @return The start data value for one category in a series + * (possibly null). + * + * @see #getStartValue(int, int) + */ + @Override + public Number getStartValue(Comparable series, Comparable category) { + int seriesIndex = getSeriesIndex(series); + if (seriesIndex < 0) { + throw new UnknownKeyException("Unknown 'series' key."); + } + int itemIndex = getColumnIndex(category); + if (itemIndex < 0) { + throw new UnknownKeyException("Unknown 'category' key."); + } + return getStartValue(seriesIndex, itemIndex); + } + + /** + * Returns the start data value for one category in a series. + * + * @param series the required series (zero based index). + * @param category the required category. + * + * @return The start data value for one category in a series + * (possibly null). + * + * @see #getStartValue(Comparable, Comparable) + */ + @Override + public Number getStartValue(int series, int category) { + + // check arguments... + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException( + "DefaultIntervalCategoryDataset.getValue(): " + + "series index out of range."); + } + + if ((category < 0) || (category >= getCategoryCount())) { + throw new IllegalArgumentException( + "DefaultIntervalCategoryDataset.getValue(): " + + "category index out of range."); + } + + // fetch the value... + return this.startData[series][category]; + + } + + /** + * Returns the end data value for one category in a series. + * + * @param series the required series. + * @param category the required category. + * + * @return The end data value for one category in a series (null possible). + * + * @see #getEndValue(int, int) + */ + @Override + public Number getEndValue(Comparable series, Comparable category) { + int seriesIndex = getSeriesIndex(series); + if (seriesIndex < 0) { + throw new UnknownKeyException("Unknown 'series' key."); + } + int itemIndex = getColumnIndex(category); + if (itemIndex < 0) { + throw new UnknownKeyException("Unknown 'category' key."); + } + return getEndValue(seriesIndex, itemIndex); + } + + /** + * Returns the end data value for one category in a series. + * + * @param series the required series (zero based index). + * @param category the required category. + * + * @return The end data value for one category in a series (null possible). + * + * @see #getEndValue(Comparable, Comparable) + */ + @Override + public Number getEndValue(int series, int category) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException( + "DefaultIntervalCategoryDataset.getValue(): " + + "series index out of range."); + } + + if ((category < 0) || (category >= getCategoryCount())) { + throw new IllegalArgumentException( + "DefaultIntervalCategoryDataset.getValue(): " + + "category index out of range."); + } + + return this.endData[series][category]; + } + + /** + * Sets the start data value for one category in a series. + * + * @param series the series (zero-based index). + * @param category the category. + * + * @param value The value. + * + * @see #setEndValue(int, Comparable, Number) + */ + public void setStartValue(int series, Comparable category, Number value) { + + // does the series exist? + if ((series < 0) || (series > getSeriesCount() - 1)) { + throw new IllegalArgumentException( + "DefaultIntervalCategoryDataset.setValue: " + + "series outside valid range."); + } + + // is the category valid? + int categoryIndex = getCategoryIndex(category); + if (categoryIndex < 0) { + throw new IllegalArgumentException( + "DefaultIntervalCategoryDataset.setValue: " + + "unrecognised category."); + } + + // update the data... + this.startData[series][categoryIndex] = value; + fireDatasetChanged(); + + } + + /** + * Sets the end data value for one category in a series. + * + * @param series the series (zero-based index). + * @param category the category. + * + * @param value the value. + * + * @see #setStartValue(int, Comparable, Number) + */ + public void setEndValue(int series, Comparable category, Number value) { + + // does the series exist? + if ((series < 0) || (series > getSeriesCount() - 1)) { + throw new IllegalArgumentException( + "DefaultIntervalCategoryDataset.setValue: " + + "series outside valid range."); + } + + // is the category valid? + int categoryIndex = getCategoryIndex(category); + if (categoryIndex < 0) { + throw new IllegalArgumentException( + "DefaultIntervalCategoryDataset.setValue: " + + "unrecognised category."); + } + + // update the data... + this.endData[series][categoryIndex] = value; + fireDatasetChanged(); + + } + + /** + * Returns the index for the given category. + * + * @param category the category (null not permitted). + * + * @return The index. + * + * @see #getColumnIndex(Comparable) + */ + public int getCategoryIndex(Comparable category) { + int result = -1; + for (int i = 0; i < this.categoryKeys.length; i++) { + if (category.equals(this.categoryKeys[i])) { + result = i; + break; + } + } + return result; + } + + /** + * Generates an array of keys, by appending a space plus an integer + * (starting with 1) to the supplied prefix string. + * + * @param count the number of keys required. + * @param prefix the name prefix. + * + * @return An array of prefixN with N = { 1 .. count}. + */ + private Comparable[] generateKeys(int count, String prefix) { + Comparable[] result = new Comparable[count]; + String name; + for (int i = 0; i < count; i++) { + name = prefix + (i + 1); + result[i] = name; + } + return result; + } + + /** + * Returns a column key. + * + * @param column the column index. + * + * @return The column key. + * + * @see #getRowKey(int) + */ + @Override + public Comparable getColumnKey(int column) { + return this.categoryKeys[column]; + } + + /** + * Returns a column index. + * + * @param columnKey the column key (null not permitted). + * + * @return The column index. + * + * @see #getCategoryIndex(Comparable) + */ + @Override + public int getColumnIndex(Comparable columnKey) { + ParamChecks.nullNotPermitted(columnKey, "columnKey"); + return getCategoryIndex(columnKey); + } + + /** + * Returns a row index. + * + * @param rowKey the row key. + * + * @return The row index. + * + * @see #getSeriesIndex(Comparable) + */ + @Override + public int getRowIndex(Comparable rowKey) { + return getSeriesIndex(rowKey); + } + + /** + * Returns a list of the series in the dataset. This method supports the + * {@link CategoryDataset} interface. + * + * @return A list of the series in the dataset. + * + * @see #getColumnKeys() + */ + @Override + public List getRowKeys() { + // the CategoryDataset interface expects a list of series, but + // we've stored them in an array... + if (this.seriesKeys == null) { + return new java.util.ArrayList(); + } + else { + return Collections.unmodifiableList(Arrays.asList(this.seriesKeys)); + } + } + + /** + * Returns the name of the specified series. + * + * @param row the index of the required row/series (zero-based). + * + * @return The name of the specified series. + * + * @see #getColumnKey(int) + */ + @Override + public Comparable getRowKey(int row) { + if ((row >= getRowCount()) || (row < 0)) { + throw new IllegalArgumentException( + "The 'row' argument is out of bounds."); + } + return this.seriesKeys[row]; + } + + /** + * Returns the number of categories in the dataset. This method is part of + * the {@link CategoryDataset} interface. + * + * @return The number of categories in the dataset. + * + * @see #getCategoryCount() + * @see #getRowCount() + */ + @Override + public int getColumnCount() { + return this.categoryKeys.length; + } + + /** + * Returns the number of series in the dataset (possibly zero). + * + * @return The number of series in the dataset. + * + * @see #getSeriesCount() + * @see #getColumnCount() + */ + @Override + public int getRowCount() { + return this.seriesKeys.length; + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DefaultIntervalCategoryDataset)) { + return false; + } + DefaultIntervalCategoryDataset that + = (DefaultIntervalCategoryDataset) obj; + if (!Arrays.equals(this.seriesKeys, that.seriesKeys)) { + return false; + } + if (!Arrays.equals(this.categoryKeys, that.categoryKeys)) { + return false; + } + if (!equal(this.startData, that.startData)) { + return false; + } + if (!equal(this.endData, that.endData)) { + return false; + } + // seem to be the same... + return true; + } + + /** + * Returns a clone of this dataset. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning the + * dataset. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultIntervalCategoryDataset clone + = (DefaultIntervalCategoryDataset) super.clone(); + clone.categoryKeys = (Comparable[]) this.categoryKeys.clone(); + clone.seriesKeys = (Comparable[]) this.seriesKeys.clone(); + clone.startData = clone(this.startData); + clone.endData = clone(this.endData); + return clone; + } + + /** + * Tests two double[][] arrays for equality. + * + * @param array1 the first array (null permitted). + * @param array2 the second arrray (null permitted). + * + * @return A boolean. + */ + private static boolean equal(Number[][] array1, Number[][] array2) { + if (array1 == null) { + return (array2 == null); + } + if (array2 == null) { + return false; + } + if (array1.length != array2.length) { + return false; + } + for (int i = 0; i < array1.length; i++) { + if (!Arrays.equals(array1[i], array2[i])) { + return false; + } + } + return true; + } + + /** + * Clones a two dimensional array of Number objects. + * + * @param array the array (null not permitted). + * + * @return A clone of the array. + */ + private static Number[][] clone(Number[][] array) { + ParamChecks.nullNotPermitted(array, "array"); + Number[][] result = new Number[array.length][]; + for (int i = 0; i < array.length; i++) { + Number[] child = array[i]; + Number[] copychild = new Number[child.length]; + System.arraycopy(child, 0, copychild, 0, child.length); + result[i] = copychild; + } + return result; + } + + /** + * Returns a list of the series in the dataset. + * + * @return A list of the series in the dataset. + * + * @deprecated Use {@link #getRowKeys()} instead. + */ + public List getSeries() { + if (this.seriesKeys == null) { + return new java.util.ArrayList(); + } + else { + return Collections.unmodifiableList(Arrays.asList(this.seriesKeys)); + } + } + + /** + * Returns a list of the categories in the dataset. + * + * @return A list of the categories in the dataset. + * + * @deprecated Use {@link #getColumnKeys()} instead. + */ + public List getCategories() { + return getColumnKeys(); + } + + /** + * Returns the item count. + * + * @return The item count. + * + * @deprecated Use {@link #getCategoryCount()} instead. + */ + public int getItemCount() { + return this.categoryKeys.length; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/IntervalCategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/IntervalCategoryDataset.java new file mode 100755 index 0000000..0381385 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/IntervalCategoryDataset.java @@ -0,0 +1,103 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * IntervalCategoryDataset.java + * ---------------------------- + * (C) Copyright 2002-2008, by Eduard Martinescu and Contributors. + * + * Original Author: Eduard Martinescu; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 19-Mar-2002 : Version 1 contributed by Eduard Martinescu. The interface + * name and method names have been renamed to be consistent with + * existing interfaces (DG); + * 06-Jun-2002 : Updated Javadoc comments (DG); + * 24-Oct-2002 : Categories and series are now indexed by int or Comparable, + * following changes made to the CategoryDataset interface (DG); + * 12-May-2008 : Updated API docs (DG); + * + */ + +package org.jfree.data.category; + +/** + * A category dataset that defines a value range for each series/category + * combination. + */ +public interface IntervalCategoryDataset extends CategoryDataset { + + /** + * Returns the start value for the interval for a given series and category. + * + * @param series the series (zero-based index). + * @param category the category (zero-based index). + * + * @return The start value (possibly null). + * + * @see #getEndValue(int, int) + */ + public Number getStartValue(int series, int category); + + /** + * Returns the start value for the interval for a given series and category. + * + * @param series the series key. + * @param category the category key. + * + * @return The start value (possibly null). + * + * @see #getEndValue(Comparable, Comparable) + */ + public Number getStartValue(Comparable series, Comparable category); + + /** + * Returns the end value for the interval for a given series and category. + * + * @param series the series (zero-based index). + * @param category the category (zero-based index). + * + * @return The end value (possibly null). + * + * @see #getStartValue(int, int) + */ + public Number getEndValue(int series, int category); + + /** + * Returns the end value for the interval for a given series and category. + * + * @param series the series key. + * @param category the category key. + * + * @return The end value (possibly null). + * + * @see #getStartValue(Comparable, Comparable) + */ + public Number getEndValue(Comparable series, Comparable category); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/SlidingCategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/SlidingCategoryDataset.java new file mode 100755 index 0000000..dee9554 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/SlidingCategoryDataset.java @@ -0,0 +1,362 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * SlidingCategoryDataset.java + * --------------------------- + * (C) Copyright 2008, 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-May-2008 : Version 1 (DG); + * 15-Mar-2009 : Fixed bug in getColumnKeys() method (DG); + * + */ + +package org.jfree.data.category; + +import java.util.Collections; +import java.util.List; + +import org.jfree.data.UnknownKeyException; +import org.jfree.data.general.AbstractDataset; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.util.PublicCloneable; + +/** + * A {@link CategoryDataset} implementation that presents a subset of the + * categories in an underlying dataset. The index of the first "visible" + * category can be modified, which provides a means of "sliding" through + * the categories in the underlying dataset. + * + * @since 1.0.10 + */ +public class SlidingCategoryDataset extends AbstractDataset + implements CategoryDataset { + + /** The underlying dataset. */ + private CategoryDataset underlying; + + /** The index of the first category to present. */ + private int firstCategoryIndex; + + /** The maximum number of categories to present. */ + private int maximumCategoryCount; + + /** + * Creates a new instance. + * + * @param underlying the underlying dataset (null not + * permitted). + * @param firstColumn the index of the first visible column from the + * underlying dataset. + * @param maxColumns the maximumColumnCount. + */ + public SlidingCategoryDataset(CategoryDataset underlying, int firstColumn, + int maxColumns) { + this.underlying = underlying; + this.firstCategoryIndex = firstColumn; + this.maximumCategoryCount = maxColumns; + } + + /** + * Returns the underlying dataset that was supplied to the constructor. + * + * @return The underlying dataset (never null). + */ + public CategoryDataset getUnderlyingDataset() { + return this.underlying; + } + + /** + * Returns the index of the first visible category. + * + * @return The index. + * + * @see #setFirstCategoryIndex(int) + */ + public int getFirstCategoryIndex() { + return this.firstCategoryIndex; + } + + /** + * Sets the index of the first category that should be used from the + * underlying dataset, and sends a {@link DatasetChangeEvent} to all + * registered listeners. + * + * @param first the index. + * + * @see #getFirstCategoryIndex() + */ + public void setFirstCategoryIndex(int first) { + if (first < 0 || first >= this.underlying.getColumnCount()) { + throw new IllegalArgumentException("Invalid index."); + } + this.firstCategoryIndex = first; + fireDatasetChanged(); + } + + /** + * Returns the maximum category count. + * + * @return The maximum category count. + * + * @see #setMaximumCategoryCount(int) + */ + public int getMaximumCategoryCount() { + return this.maximumCategoryCount; + } + + /** + * Sets the maximum category count and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param max the maximum. + * + * @see #getMaximumCategoryCount() + */ + public void setMaximumCategoryCount(int max) { + if (max < 0) { + throw new IllegalArgumentException("Requires 'max' >= 0."); + } + this.maximumCategoryCount = max; + fireDatasetChanged(); + } + + /** + * Returns the index of the last column for this dataset, or -1. + * + * @return The index. + */ + private int lastCategoryIndex() { + if (this.maximumCategoryCount == 0) { + return -1; + } + return Math.min(this.firstCategoryIndex + this.maximumCategoryCount, + this.underlying.getColumnCount()) - 1; + } + + /** + * Returns the index for the specified column key. + * + * @param key the key. + * + * @return The column index, or -1 if the key is not recognised. + */ + @Override + public int getColumnIndex(Comparable key) { + int index = this.underlying.getColumnIndex(key); + if (index >= this.firstCategoryIndex && index <= lastCategoryIndex()) { + return index - this.firstCategoryIndex; + } + return -1; // we didn't find the key + } + + /** + * Returns the column key for a given index. + * + * @param column the column index (zero-based). + * + * @return The column key. + * + * @throws IndexOutOfBoundsException if row is out of bounds. + */ + @Override + public Comparable getColumnKey(int column) { + return this.underlying.getColumnKey(column + this.firstCategoryIndex); + } + + /** + * Returns the column keys. + * + * @return The keys. + * + * @see #getColumnKey(int) + */ + @Override + public List getColumnKeys() { + List result = new java.util.ArrayList(); + int last = lastCategoryIndex(); + for (int i = this.firstCategoryIndex; i <= last; i++) { + result.add(this.underlying.getColumnKey(i)); + } + return Collections.unmodifiableList(result); + } + + /** + * Returns the row index for a given key. + * + * @param key the row key. + * + * @return The row index, or -1 if the key is unrecognised. + */ + @Override + public int getRowIndex(Comparable key) { + return this.underlying.getRowIndex(key); + } + + /** + * Returns the row key for a given index. + * + * @param row the row index (zero-based). + * + * @return The row key. + * + * @throws IndexOutOfBoundsException if row is out of bounds. + */ + @Override + public Comparable getRowKey(int row) { + return this.underlying.getRowKey(row); + } + + /** + * Returns the row keys. + * + * @return The keys. + */ + @Override + public List getRowKeys() { + return this.underlying.getRowKeys(); + } + + /** + * Returns the value for a pair of keys. + * + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @return The value (possibly null). + * + * @throws UnknownKeyException if either key is not defined in the dataset. + */ + @Override + public Number getValue(Comparable rowKey, Comparable columnKey) { + int r = getRowIndex(rowKey); + int c = getColumnIndex(columnKey); + if (c != -1) { + return this.underlying.getValue(r, c + this.firstCategoryIndex); + } + else { + throw new UnknownKeyException("Unknown columnKey: " + columnKey); + } + } + + /** + * Returns the number of columns in the table. + * + * @return The column count. + */ + @Override + public int getColumnCount() { + int last = lastCategoryIndex(); + if (last == -1) { + return 0; + } + else { + return Math.max(last - this.firstCategoryIndex + 1, 0); + } + } + + /** + * Returns the number of rows in the table. + * + * @return The row count. + */ + @Override + public int getRowCount() { + return this.underlying.getRowCount(); + } + + /** + * Returns a value from the table. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The value (possibly null). + */ + @Override + public Number getValue(int row, int column) { + return this.underlying.getValue(row, column + this.firstCategoryIndex); + } + + /** + * Tests this SlidingCategoryDataset for equality with an + * arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SlidingCategoryDataset)) { + return false; + } + SlidingCategoryDataset that = (SlidingCategoryDataset) obj; + if (this.firstCategoryIndex != that.firstCategoryIndex) { + return false; + } + if (this.maximumCategoryCount != that.maximumCategoryCount) { + return false; + } + if (!this.underlying.equals(that.underlying)) { + return false; + } + return true; + } + + /** + * Returns an independent copy of the dataset. Note that: + *

    + *
  • the underlying dataset is only cloned if it implements the + * {@link PublicCloneable} interface;
  • + *
  • the listeners registered with this dataset are not carried over to + * the cloned dataset.
  • + *
+ * + * @return An independent copy of the dataset. + * + * @throws CloneNotSupportedException if the dataset cannot be cloned for + * any reason. + */ + @Override + public Object clone() throws CloneNotSupportedException { + SlidingCategoryDataset clone = (SlidingCategoryDataset) super.clone(); + if (this.underlying instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.underlying; + clone.underlying = (CategoryDataset) pc.clone(); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/package.html new file mode 100755 index 0000000..bd09cf5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/category/package.html @@ -0,0 +1,6 @@ + + + +A package containing the {@link org.jfree.data.category.CategoryDataset} interface and related classes. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/contour/ContourDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/contour/ContourDataset.java new file mode 100755 index 0000000..264e2e4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/contour/ContourDataset.java @@ -0,0 +1,130 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * ContourDataset.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 (from 23-Jan-2003) + * -------------------------- + * 23-Jan-2003 : Added standard header (DG); + * 17-Jan-2004 : Added methods from DefaultContourDataset that are referenced + * by ContourPlot. See bug 741048 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 31-Jan-2007 : Deprecated (DG); + * + */ + +package org.jfree.data.contour; + +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYBlockRenderer; +import org.jfree.data.Range; +import org.jfree.data.xy.XYZDataset; + +/** + * The interface through which JFreeChart obtains data in the form of (x, y, z) + * items - used for XY and XYZ plots. + * + * @deprecated This interface 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 interface ContourDataset extends XYZDataset { + + /** + * Returns the smallest Z data value. + * + * @return The minimum Z value. + */ + public double getMinZValue(); + + /** + * Returns the largest Z data value. + * + * @return The maximum Z value. + */ + public double getMaxZValue(); + + /** + * Returns the array of Numbers representing the x data values. + * + * @return The array of x values. + */ + public Number[] getXValues(); + + /** + * Returns the array of Numbers representing the y data values. + * + * @return The array of y values. + */ + public Number[] getYValues(); + + /** + * Returns the array of Numbers representing the z data values. + * + * @return The array of z values. + */ + public Number[] getZValues(); + + /** + * Returns an int array contain the index into the x values. + * + * @return The X values. + */ + public int[] indexX(); + + /** + * Returns the index of the xvalues. + * + * @return The x values. + */ + public int[] getXIndices(); + + /** + * Returns the maximum z-value within visible region of plot. + * + * @param x the x-value. + * @param y the y-value. + * + * @return The maximum z-value. + */ + public Range getZValueRange(Range x, Range y); + + /** + * Returns true if axis are dates. + * + * @param axisNumber the axis where 0-x, 1-y, and 2-z. + * + * @return true or false. + */ + public boolean isDateAxis(int axisNumber); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/contour/DefaultContourDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/contour/DefaultContourDataset.java new file mode 100755 index 0000000..ebfce55 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/contour/DefaultContourDataset.java @@ -0,0 +1,534 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * DefaultContourDataset.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 (from 23-Jan-2003) + * -------------------------- + * 23-Jan-2003 : Added standard header (DG); + * 20-May-2003 : removed member vars numX and numY, which were never used (TM); + * 06-May-2004 : Now extends AbstractXYZDataset (DG); + * 15-Jul-2004 : Switched getX() with getXValue(), getY() with getYValue() and + * getZ() with getZValue() methods (DG); + * ------------- JFREECHART 1.0.x -------------------------------------------- + * 31-Jan-2007 : Deprecated (DG); + * + */ + +package org.jfree.data.contour; + +import java.util.Arrays; +import java.util.Date; +import java.util.Vector; + +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYBlockRenderer; +import org.jfree.data.Range; +import org.jfree.data.xy.AbstractXYZDataset; +import org.jfree.data.xy.XYDataset; + +/** + * A convenience class that provides a default implementation of the + * {@link ContourDataset} interface. + * + * @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 DefaultContourDataset extends AbstractXYZDataset + implements ContourDataset { + + /** The series name (this dataset supports only one series). */ + protected Comparable seriesKey = null; + + /** Storage for the x values. */ + protected Number[] xValues = null; + + /** Storage for the y values. */ + protected Number[] yValues = null; + + /** Storage for the z values. */ + protected Number[] zValues = null; + + /** The index for the start of each column in the data. */ + protected int[] xIndex = null; + + /** Flags that track whether x, y and z are dates. */ + boolean[] dateAxis = new boolean[3]; + + /** + * Creates a new dataset, initially empty. + */ + public DefaultContourDataset() { + super(); + } + + /** + * Constructs a new dataset with the given data. + * + * @param seriesKey the series key. + * @param xData the x values. + * @param yData the y values. + * @param zData the z values. + */ + public DefaultContourDataset(Comparable seriesKey, + Object[] xData, + Object[] yData, + Object[] zData) { + + this.seriesKey = seriesKey; + initialize(xData, yData, zData); + } + + /** + * Initialises the dataset. + * + * @param xData the x values. + * @param yData the y values. + * @param zData the z values. + */ + public void initialize(Object[] xData, + Object[] yData, + Object[] zData) { + + this.xValues = new Double[xData.length]; + this.yValues = new Double[yData.length]; + this.zValues = new Double[zData.length]; + + // We organise the data with the following assumption: + // 1) the data are sorted by x then y + // 2) that the data will be represented by a rectangle formed by + // using x[i+1], x, y[j+1], and y. + // 3) we march along the y-axis at the same value of x until a new + // value x is found at which point we will flag the index + // where x[i+1]<>x[i] + + Vector tmpVector = new Vector(); //create a temporary vector + double x = 1.123452e31; // set x to some arbitary value (used below) + for (int k = 0; k < this.xValues.length; k++) { + if (xData[k] != null) { + Number xNumber; + if (xData[k] instanceof Number) { + xNumber = (Number) xData[k]; + } + else if (xData[k] instanceof Date) { + this.dateAxis[0] = true; + Date xDate = (Date) xData[k]; + xNumber = new Long(xDate.getTime()); //store data as Long + } + else { + xNumber = new Integer(0); + } + this.xValues[k] = new Double(xNumber.doubleValue()); + // store Number as Double + + // check if starting new column + if (x != this.xValues[k].doubleValue()) { + tmpVector.add(new Integer(k)); //store index where new + //column starts + x = this.xValues[k].doubleValue(); + // set x to most recent value + } + } + } + + Object[] inttmp = tmpVector.toArray(); + this.xIndex = new int[inttmp.length]; // create array xIndex to hold + // new column indices + + for (int i = 0; i < inttmp.length; i++) { + this.xIndex[i] = ((Integer) inttmp[i]).intValue(); + } + for (int k = 0; k < this.yValues.length; k++) { // store y and z axes + // as Doubles + this.yValues[k] = (Double) yData[k]; + if (zData[k] != null) { + this.zValues[k] = (Double) zData[k]; + } + } + } + + /** + * Creates an object array from an array of doubles. + * + * @param data the data. + * + * @return An array of Double objects. + */ + public static Object[][] formObjectArray(double[][] data) { + Object[][] object = new Double[data.length][data[0].length]; + + for (int i = 0; i < object.length; i++) { + for (int j = 0; j < object[i].length; j++) { + object[i][j] = new Double(data[i][j]); + } + } + return object; + } + + /** + * Creates an object array from an array of doubles. + * + * @param data the data. + * + * @return An array of Double objects. + */ + public static Object[] formObjectArray(double[] data) { + Object[] object = new Double[data.length]; + for (int i = 0; i < object.length; i++) { + object[i] = new Double(data[i]); + } + return object; + } + + /** + * Returns the number of items in the specified series. This method + * is provided to satisfy the {@link XYDataset} interface implementation. + * + * @param series must be zero, as this dataset only supports one series. + * + * @return The item count. + */ + @Override + public int getItemCount(int series) { + if (series > 0) { + throw new IllegalArgumentException("Only one series for contour"); + } + return this.zValues.length; + } + + /** + * Returns the maximum z-value. + * + * @return The maximum z-value. + */ + @Override + public double getMaxZValue() { + double zMax = -1.e20; + for (int k = 0; k < this.zValues.length; k++) { + if (this.zValues[k] != null) { + zMax = Math.max(zMax, this.zValues[k].doubleValue()); + } + } + return zMax; + } + + /** + * Returns the minimum z-value. + * + * @return The minimum z-value. + */ + @Override + public double getMinZValue() { + double zMin = 1.e20; + for (int k = 0; k < this.zValues.length; k++) { + if (this.zValues[k] != null) { + zMin = Math.min(zMin, this.zValues[k].doubleValue()); + } + } + return zMin; + } + + /** + * Returns the maximum z-value within visible region of plot. + * + * @param x the x range. + * @param y the y range. + * + * @return The z range. + */ + @Override + public Range getZValueRange(Range x, Range y) { + + double minX = x.getLowerBound(); + double minY = y.getLowerBound(); + double maxX = x.getUpperBound(); + double maxY = y.getUpperBound(); + + double zMin = 1.e20; + double zMax = -1.e20; + for (int k = 0; k < this.zValues.length; k++) { + if (this.xValues[k].doubleValue() >= minX + && this.xValues[k].doubleValue() <= maxX + && this.yValues[k].doubleValue() >= minY + && this.yValues[k].doubleValue() <= maxY) { + if (this.zValues[k] != null) { + zMin = Math.min(zMin, this.zValues[k].doubleValue()); + zMax = Math.max(zMax, this.zValues[k].doubleValue()); + } + } + } + + return new Range(zMin, zMax); + } + + /** + * Returns the minimum z-value. + * + * @param minX the minimum x value. + * @param minY the minimum y value. + * @param maxX the maximum x value. + * @param maxY the maximum y value. + * + * @return The minimum z-value. + */ + public double getMinZValue(double minX, + double minY, + double maxX, + double maxY) { + + double zMin = 1.e20; + for (int k = 0; k < this.zValues.length; k++) { + if (this.zValues[k] != null) { + zMin = Math.min(zMin, this.zValues[k].doubleValue()); + } + } + return zMin; + + } + + /** + * Returns the number of series. + *

+ * Required by XYDataset interface (this will always return 1) + * + * @return 1. + */ + @Override + public int getSeriesCount() { + return 1; + } + + /** + * Returns the name of the specified series. + * + * Method provided to satisfy the XYDataset interface implementation + * + * @param series must be zero. + * + * @return The series name. + */ + @Override + public Comparable getSeriesKey(int series) { + if (series > 0) { + throw new IllegalArgumentException("Only one series for contour"); + } + return this.seriesKey; + } + + /** + * Returns the index of the xvalues. + * + * @return The x values. + */ + @Override + public int[] getXIndices() { + return this.xIndex; + } + + /** + * Returns the x values. + * + * @return The x values. + */ + @Override + public Number[] getXValues() { + return this.xValues; + } + + /** + * Returns the x value for the specified series and index (zero-based + * indices). Required by the {@link XYDataset}. + * + * @param series must be zero; + * @param item the item index (zero-based). + * + * @return The x value. + */ + @Override + public Number getX(int series, int item) { + if (series > 0) { + throw new IllegalArgumentException("Only one series for contour"); + } + return this.xValues[item]; + } + + /** + * Returns an x value. + * + * @param item the item index (zero-based). + * + * @return The X value. + */ + public Number getXValue(int item) { + return this.xValues[item]; + } + + /** + * Returns a Number array containing all y values. + * + * @return The Y values. + */ + @Override + public Number[] getYValues() { + return this.yValues; + } + + /** + * Returns the y value for the specified series and index (zero-based + * indices). Required by the {@link XYDataset}. + * + * @param series the series index (must be zero for this dataset). + * @param item the item index (zero-based). + * + * @return The Y value. + */ + @Override + public Number getY(int series, int item) { + if (series > 0) { + throw new IllegalArgumentException("Only one series for contour"); + } + return this.yValues[item]; + } + + /** + * Returns a Number array containing all z values. + * + * @return The Z values. + */ + @Override + public Number[] getZValues() { + return this.zValues; + } + + /** + * Returns the z value for the specified series and index (zero-based + * indices). Required by the {@link XYDataset} + * + * @param series the series index (must be zero for this dataset). + * @param item the item index (zero-based). + * + * @return The Z value. + */ + @Override + public Number getZ(int series, int item) { + if (series > 0) { + throw new IllegalArgumentException("Only one series for contour"); + } + return this.zValues[item]; + } + + /** + * Returns an int array contain the index into the x values. + * + * @return The X values. + */ + @Override + public int[] indexX() { + int[] index = new int[this.xValues.length]; + for (int k = 0; k < index.length; k++) { + index[k] = indexX(k); + } + return index; + } + + /** + * Given index k, returns the column index containing k. + * + * @param k index of interest. + * + * @return The column index. + */ + public int indexX(int k) { + int i = Arrays.binarySearch(this.xIndex, k); + if (i >= 0) { + return i; + } + else { + return -1 * i - 2; + } + } + + + /** + * Given index k, return the row index containing k. + * + * @param k index of interest. + * + * @return The row index. + */ + public int indexY(int k) { // this may be obsolete (not used anywhere) + return (k / this.xValues.length); + } + + /** + * Given column and row indices, returns the k index. + * + * @param i index of along x-axis. + * @param j index of along y-axis. + * + * @return The Z index. + */ + public int indexZ(int i, int j) { + return this.xValues.length * j + i; + } + + /** + * Returns true if axis are dates. + * + * @param axisNumber The axis where 0-x, 1-y, and 2-z. + * + * @return A boolean. + */ + @Override + public boolean isDateAxis(int axisNumber) { + if (axisNumber < 0 || axisNumber > 2) { + return false; // bad axisNumber + } + return this.dateAxis[axisNumber]; + } + + /** + * Sets the names of the series in the data source. + * + * @param seriesKeys the keys of the series in the data source. + */ + public void setSeriesKeys(Comparable[] seriesKeys) { + if (seriesKeys.length > 1) { + throw new IllegalArgumentException( + "Contours only support one series"); + } + this.seriesKey = seriesKeys[0]; + fireDatasetChanged(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/contour/NonGridContourDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/contour/NonGridContourDataset.java new file mode 100755 index 0000000..a72eb3e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/contour/NonGridContourDataset.java @@ -0,0 +1,237 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * NonGridContourDataset.java + * -------------------------- + * (C) Copyright 2002-2008, by David M. O'Donnell. + * + * Original Author: David M. O'Donnell; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes (from 24-Jul-2003) + * -------------------------- + * 24-Jul-2003 : Added standard header (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 31-Jan-2007 : Deprecated (DG); + * + */ + +package org.jfree.data.contour; + +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYBlockRenderer; +import org.jfree.data.Range; + +/** + * A convenience class that extends the {@link DefaultContourDataset} to + * accommodate non-grid data. + * + * @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 NonGridContourDataset extends DefaultContourDataset { + + /** Default number of x values. */ + static final int DEFAULT_NUM_X = 50; + + /** Default number of y values. */ + static final int DEFAULT_NUM_Y = 50; + + /** Default power. */ + static final int DEFAULT_POWER = 4; + + /** + * Default constructor. + */ + public NonGridContourDataset() { + super(); + } + + /** + * Constructor for NonGridContourDataset. Uses default values for grid + * dimensions and weighting. + * + * @param seriesName the series name. + * @param xData the x values. + * @param yData the y values. + * @param zData the z values. + */ + public NonGridContourDataset(String seriesName, + Object[] xData, Object[] yData, + Object[] zData) { + super(seriesName, xData, yData, zData); + buildGrid(DEFAULT_NUM_X, DEFAULT_NUM_Y, DEFAULT_POWER); + } + + /** + * Constructor for NonGridContourDataset. + * + * @param seriesName the series name. + * @param xData the x values. + * @param yData the y values. + * @param zData the z values. + * @param numX number grid cells in along the x-axis + * @param numY number grid cells in along the y-axis + * @param power exponent for inverse distance weighting + */ + public NonGridContourDataset(String seriesName, + Object[] xData, Object[] yData, + Object[] zData, + int numX, int numY, int power) { + super(seriesName, xData, yData, zData); + buildGrid(numX, numY, power); + } + + /** + * Builds a regular grid. Maps the non-grid data into the regular grid + * using an inverse distance between grid and non-grid points. Weighting + * of distance can be controlled by setting through the power parameter + * that controls the exponent used on the distance weighting + * (e.g., distance^power). + * + * @param numX number grid points in along the x-axis + * @param numY number grid points in along the y-axis + * @param power exponent for inverse distance weighting + */ + protected void buildGrid(int numX, int numY, int power) { + + int numValues = numX * numY; + double[] xGrid = new double[numValues]; + double[] yGrid = new double [numValues]; + double[] zGrid = new double [numValues]; + + // Find min, max for the x and y axes + double xMin = 1.e20; + for (int k = 0; k < this.xValues.length; k++) { + xMin = Math.min(xMin, this.xValues[k].doubleValue()); + } + + double xMax = -1.e20; + for (int k = 0; k < this.xValues.length; k++) { + xMax = Math.max(xMax, this.xValues[k].doubleValue()); + } + + double yMin = 1.e20; + for (int k = 0; k < this.yValues.length; k++) { + yMin = Math.min(yMin, this.yValues[k].doubleValue()); + } + + double yMax = -1.e20; + for (int k = 0; k < this.yValues.length; k++) { + yMax = Math.max(yMax, this.yValues[k].doubleValue()); + } + + Range xRange = new Range(xMin, xMax); + Range yRange = new Range(yMin, yMax); + + xRange.getLength(); + yRange.getLength(); + + // Determine the cell size + double dxGrid = xRange.getLength() / (numX - 1); + double dyGrid = yRange.getLength() / (numY - 1); + + // Generate the grid + double x = 0.0; + for (int i = 0; i < numX; i++) { + if (i == 0) { + x = xMin; + } + else { + x += dxGrid; + } + double y = 0.0; + for (int j = 0; j < numY; j++) { + int k = numY * i + j; + xGrid[k] = x; + if (j == 0) { + y = yMin; + } + else { + y += dyGrid; + } + yGrid[k] = y; + } + } + + // Map the nongrid data into the new regular grid + for (int kGrid = 0; kGrid < xGrid.length; kGrid++) { + double dTotal = 0.0; + zGrid[kGrid] = 0.0; + for (int k = 0; k < this.xValues.length; k++) { + double xPt = this.xValues[k].doubleValue(); + double yPt = this.yValues[k].doubleValue(); + double d = distance(xPt, yPt, xGrid[kGrid], yGrid[kGrid]); + if (power != 1) { + d = Math.pow(d, power); + } + d = Math.sqrt(d); + if (d > 0.0) { + d = 1.0 / d; + } + else { // if d is real small set the inverse to a large number + // to avoid INF + d = 1.e20; + } + if (this.zValues[k] != null) { + // scale by the inverse of distance^power + zGrid[kGrid] += this.zValues[k].doubleValue() * d; + } + dTotal += d; + } + zGrid[kGrid] = zGrid[kGrid] / dTotal; //remove distance of the sum + } + + //initalize xValues, yValues, and zValues arrays. + initialize( + formObjectArray(xGrid), formObjectArray(yGrid), + formObjectArray(zGrid) + ); + + } + + /** + * Calculates the distance between two points. + * + * @param xDataPt the x coordinate. + * @param yDataPt the y coordinate. + * @param xGrdPt the x grid coordinate. + * @param yGrdPt the y grid coordinate. + * + * @return The distance between two points. + */ + protected double distance(double xDataPt, + double yDataPt, + double xGrdPt, + double yGrdPt) { + double dx = xDataPt - xGrdPt; + double dy = yDataPt - yGrdPt; + return Math.sqrt(dx * dx + dy * dy); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/contour/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/contour/package.html new file mode 100755 index 0000000..7493287 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/contour/package.html @@ -0,0 +1,7 @@ + + + +Datasets used by the {@link org.jfree.chart.plot.ContourPlot} class. All +classes/interfaces in this package are now deprecated. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/Function2D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/Function2D.java new file mode 100755 index 0000000..0f261b3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/Function2D.java @@ -0,0 +1,58 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * Function2D.java + * --------------- + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 01-Oct-2002 : Version 1 (DG); + * 20-Jan-2005 : Minor Javadoc update (DG); + * + */ + +package org.jfree.data.function; + +/** + * A function of the form y = f(x). + */ +public interface Function2D { + + /** + * Returns the value of the function ('y') for a given input ('x'). + * + * @param x the x-value. + * + * @return The function value. + */ + public double getValue(double x); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/LineFunction2D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/LineFunction2D.java new file mode 100755 index 0000000..d09ac7f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/LineFunction2D.java @@ -0,0 +1,139 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * LineFunction2D.java + * ------------------- + * (C) Copyright 2002-2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 01-Oct-2002 : Version 1 (DG); + * 28-May-2009 : Added accessor methods for co-efficients, implemented + * equals() and hashCode(), and added Serialization support (DG); + * + */ + +package org.jfree.data.function; + +import java.io.Serializable; + +import org.jfree.chart.HashUtilities; + +/** + * A function in the form y = a + bx. + */ +public class LineFunction2D implements Function2D, Serializable { + + /** The intercept. */ + private double a; + + /** The slope of the line. */ + private double b; + + /** + * Constructs a new line function. + * + * @param a the intercept. + * @param b the slope. + */ + public LineFunction2D(double a, double b) { + this.a = a; + this.b = b; + } + + /** + * Returns the 'a' coefficient that was specified in the constructor. + * + * @return The 'a' coefficient. + * + * @since 1.0.14 + */ + public double getIntercept() { + return this.a; + } + + /** + * Returns the 'b' coefficient that was specified in the constructor. + * + * @return The 'b' coefficient. + * + * @since 1.0.14 + */ + public double getSlope() { + return this.b; + } + + /** + * Returns the function value. + * + * @param x the x-value. + * + * @return The value. + */ + @Override + public double getValue(double x) { + return this.a + this.b * x; + } + + /** + * Tests this function for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (!(obj instanceof LineFunction2D)) { + return false; + } + LineFunction2D that = (LineFunction2D) obj; + if (this.a != that.a) { + return false; + } + if (this.b != that.b) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 29; + result = HashUtilities.hashCode(result, this.a); + result = HashUtilities.hashCode(result, this.b); + return result; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/NormalDistributionFunction2D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/NormalDistributionFunction2D.java new file mode 100755 index 0000000..646d6a3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/NormalDistributionFunction2D.java @@ -0,0 +1,153 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * NormalDistributionFunction2D.java + * --------------------------------- + * (C)opyright 2004-2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-May-2004 : Version 1 (DG); + * 21-Nov-2005 : Added getters for the mean and standard deviation (DG); + * 12-Feb-2009 : Precompute some constants from the function - see bug + * 2572016 (DG); + * 28-May-2009 : Implemented equals() and hashCode(), and added serialization + * support (DG); + * + */ + +package org.jfree.data.function; + +import java.io.Serializable; + +import org.jfree.chart.HashUtilities; + +/** + * A normal distribution function. See + * http://en.wikipedia.org/wiki/Normal_distribution. + */ +public class NormalDistributionFunction2D implements Function2D, Serializable { + + /** The mean. */ + private double mean; + + /** The standard deviation. */ + private double std; + + /** Precomputed factor for the function value. */ + private double factor; + + /** Precomputed denominator for the function value. */ + private double denominator; + + /** + * Constructs a new normal distribution function. + * + * @param mean the mean. + * @param std the standard deviation (> 0). + */ + public NormalDistributionFunction2D(double mean, double std) { + if (std <= 0) { + throw new IllegalArgumentException("Requires 'std' > 0."); + } + this.mean = mean; + this.std = std; + // calculate constant values + this.factor = 1 / (std * Math.sqrt(2.0 * Math.PI)); + this.denominator = 2 * std * std; + } + + /** + * Returns the mean for the function. + * + * @return The mean. + */ + public double getMean() { + return this.mean; + } + + /** + * Returns the standard deviation for the function. + * + * @return The standard deviation. + */ + public double getStandardDeviation() { + return this.std; + } + + /** + * Returns the function value. + * + * @param x the x-value. + * + * @return The value. + */ + @Override + public double getValue(double x) { + double z = x - this.mean; + return this.factor * Math.exp(-z * z / this.denominator); + } + + /** + * Tests this function for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (!(obj instanceof NormalDistributionFunction2D)) { + return false; + } + NormalDistributionFunction2D that = (NormalDistributionFunction2D) obj; + if (this.mean != that.mean) { + return false; + } + if (this.std != that.std) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 29; + result = HashUtilities.hashCode(result, this.mean); + result = HashUtilities.hashCode(result, this.std); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/PolynomialFunction2D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/PolynomialFunction2D.java new file mode 100755 index 0000000..141f0bc --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/PolynomialFunction2D.java @@ -0,0 +1,134 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * PolynomialFunction2D.java + * ------------------------- + * (C) Copyright 2009-2013, by Object Refinery Limited. + * + * Original Author: Peter Kolb; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes: + * -------- + * 23-Mar-2009 : Version 1, patch 2795746 (PK); + * 28-May-2009 : Integrated in JFreeChart with modifications (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.function; + +import java.io.Serializable; +import java.util.Arrays; +import org.jfree.chart.HashUtilities; +import org.jfree.chart.util.ParamChecks; + +/** + * A function in the form y = a0 + a1 * x + a2 * x^2 + ... + an * + * x^n. Instances of this class are immutable. + * + * @since 1.0.14 + */ +public class PolynomialFunction2D implements Function2D, Serializable { + + /** The coefficients. */ + private double[] coefficients; + + /** + * Constructs a new polynomial function y = a0 + a1 * x + a2 * x^2 + + * ... + an * x^n + * + * @param coefficients an array with the coefficients [a0, a1, ..., an] + * (null not permitted). + */ + public PolynomialFunction2D(double[] coefficients) { + ParamChecks.nullNotPermitted(coefficients, "coefficients"); + this.coefficients = (double[]) coefficients.clone(); + } + + /** + * Returns a copy of the coefficients array that was specified in the + * constructor. + * + * @return The coefficients array. + */ + public double[] getCoefficients() { + return (double[]) this.coefficients.clone(); + } + + /** + * Returns the order of the polynomial. + * + * @return The order. + */ + public int getOrder() { + return this.coefficients.length - 1; + } + + /** + * Returns the function value. + * + * @param x the x-value. + * + * @return The value. + */ + @Override + public double getValue(double x) { + double y = 0; + for(int i = 0; i < coefficients.length; i++){ + y += coefficients[i] * Math.pow(x, i); + } + return y; + } + + /** + * Tests this function for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (!(obj instanceof PolynomialFunction2D)) { + return false; + } + PolynomialFunction2D that = (PolynomialFunction2D) obj; + return Arrays.equals(this.coefficients, that.coefficients); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return HashUtilities.hashCodeForDoubleArray(this.coefficients); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/PowerFunction2D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/PowerFunction2D.java new file mode 100755 index 0000000..639c813 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/PowerFunction2D.java @@ -0,0 +1,139 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * PowerFunction2D.java + * -------------------- + * (C) Copyright 2002-2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 01-Oct-2002 : Version 1 (DG); + * 28-May-2009 : Added accessor methods for co-efficients, implemented + * equals() and hashCode(), and added Serialization support (DG); + * + */ + +package org.jfree.data.function; + +import java.io.Serializable; +import org.jfree.chart.HashUtilities; + +/** + * A function of the form y = a * x ^ b. + */ +public class PowerFunction2D implements Function2D, Serializable { + + /** The 'a' coefficient. */ + private double a; + + /** The 'b' coefficient. */ + private double b; + + /** + * Creates a new power function. + * + * @param a the 'a' coefficient. + * @param b the 'b' coefficient. + */ + public PowerFunction2D(double a, double b) { + this.a = a; + this.b = b; + } + + /** + * Returns the 'a' coefficient that was specified in the constructor. + * + * @return The 'a' coefficient. + * + * @since 1.0.14 + */ + public double getA() { + return this.a; + } + + /** + * Returns the 'b' coefficient that was specified in the constructor. + * + * @return The 'b' coefficient. + * + * @since 1.0.14 + */ + public double getB() { + return this.b; + } + + /** + * Returns the value of the function for a given input ('x'). + * + * @param x the x-value. + * + * @return The value. + */ + @Override + public double getValue(double x) { + return this.a * Math.pow(x, this.b); + } + + /** + * Tests this function for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (!(obj instanceof PowerFunction2D)) { + return false; + } + PowerFunction2D that = (PowerFunction2D) obj; + if (this.a != that.a) { + return false; + } + if (this.b != that.b) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 29; + result = HashUtilities.hashCode(result, this.a); + result = HashUtilities.hashCode(result, this.b); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/package.html new file mode 100755 index 0000000..edc4e76 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/function/package.html @@ -0,0 +1,6 @@ + + + +Representation for simple functions. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/GanttCategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/GanttCategoryDataset.java new file mode 100755 index 0000000..640496d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/GanttCategoryDataset.java @@ -0,0 +1,182 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * GanttCategoryDataset.java + * ------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Sep-2003 : Version 1, based on MultiIntervalCategoryDataset (DG); + * 23-Sep-2003 : Fixed Checkstyle issues (DG); + * 12-May-2008 : Updated API docs (DG); + * + */ + + package org.jfree.data.gantt; + +import org.jfree.data.category.IntervalCategoryDataset; + +/** + * An extension of the {@link IntervalCategoryDataset} interface that adds + * support for multiple sub-intervals. + */ +public interface GanttCategoryDataset extends IntervalCategoryDataset { + + /** + * Returns the percent complete for a given item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The percent complete. + * + * @see #getPercentComplete(Comparable, Comparable) + */ + public Number getPercentComplete(int row, int column); + + /** + * Returns the percent complete for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return The percent complete. + * + * @see #getPercentComplete(int, int) + */ + public Number getPercentComplete(Comparable rowKey, Comparable columnKey); + + /** + * Returns the number of sub-intervals for a given item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The sub-interval count. + * + * @see #getSubIntervalCount(Comparable, Comparable) + */ + public int getSubIntervalCount(int row, int column); + + /** + * Returns the number of sub-intervals for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return The sub-interval count. + * + * @see #getSubIntervalCount(int, int) + */ + public int getSubIntervalCount(Comparable rowKey, Comparable columnKey); + + /** + * Returns the start value of a sub-interval for a given item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param subinterval the sub-interval index (zero-based). + * + * @return The start value (possibly null). + * + * @see #getEndValue(int, int, int) + */ + public Number getStartValue(int row, int column, int subinterval); + + /** + * Returns the start value of a sub-interval for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param subinterval the sub-interval. + * + * @return The start value (possibly null). + * + * @see #getEndValue(Comparable, Comparable, int) + */ + public Number getStartValue(Comparable rowKey, Comparable columnKey, + int subinterval); + + /** + * Returns the end value of a sub-interval for a given item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param subinterval the sub-interval. + * + * @return The end value (possibly null). + * + * @see #getStartValue(int, int, int) + */ + public Number getEndValue(int row, int column, int subinterval); + + /** + * Returns the end value of a sub-interval for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param subinterval the sub-interval. + * + * @return The end value (possibly null). + * + * @see #getStartValue(Comparable, Comparable, int) + */ + public Number getEndValue(Comparable rowKey, Comparable columnKey, + int subinterval); + + /** + * Returns the percentage complete value of a sub-interval for a given item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param subinterval the sub-interval. + * + * @return The percent complete value (possibly null). + * + * @see #getPercentComplete(Comparable, Comparable, int) + */ + public Number getPercentComplete(int row, int column, int subinterval); + + /** + * Returns the percentage complete value of a sub-interval for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param subinterval the sub-interval. + * + * @return The percent complete value (possibly null). + * + * @see #getPercentComplete(int, int, int) + */ + public Number getPercentComplete(Comparable rowKey, Comparable columnKey, + int subinterval); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/SlidingGanttCategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/SlidingGanttCategoryDataset.java new file mode 100755 index 0000000..6025605 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/SlidingGanttCategoryDataset.java @@ -0,0 +1,637 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------- + * SlidingGanttCategoryDataset.java + * -------------------------------- + * (C) Copyright 2008, 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 09-May-2008 : Version 1 (DG); + * + */ + +package org.jfree.data.gantt; + +import java.util.Collections; +import java.util.List; + +import org.jfree.data.UnknownKeyException; +import org.jfree.data.general.AbstractDataset; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.util.PublicCloneable; + +/** + * A {@link GanttCategoryDataset} implementation that presents a subset of the + * categories in an underlying dataset. The index of the first "visible" + * category can be modified, which provides a means of "sliding" through + * the categories in the underlying dataset. + * + * @since 1.0.10 + */ +public class SlidingGanttCategoryDataset extends AbstractDataset + implements GanttCategoryDataset { + + /** The underlying dataset. */ + private GanttCategoryDataset underlying; + + /** The index of the first category to present. */ + private int firstCategoryIndex; + + /** The maximum number of categories to present. */ + private int maximumCategoryCount; + + /** + * Creates a new instance. + * + * @param underlying the underlying dataset (null not + * permitted). + * @param firstColumn the index of the first visible column from the + * underlying dataset. + * @param maxColumns the maximumColumnCount. + */ + public SlidingGanttCategoryDataset(GanttCategoryDataset underlying, + int firstColumn, int maxColumns) { + this.underlying = underlying; + this.firstCategoryIndex = firstColumn; + this.maximumCategoryCount = maxColumns; + } + + /** + * Returns the underlying dataset that was supplied to the constructor. + * + * @return The underlying dataset (never null). + */ + public GanttCategoryDataset getUnderlyingDataset() { + return this.underlying; + } + + /** + * Returns the index of the first visible category. + * + * @return The index. + * + * @see #setFirstCategoryIndex(int) + */ + public int getFirstCategoryIndex() { + return this.firstCategoryIndex; + } + + /** + * Sets the index of the first category that should be used from the + * underlying dataset, and sends a {@link DatasetChangeEvent} to all + * registered listeners. + * + * @param first the index. + * + * @see #getFirstCategoryIndex() + */ + public void setFirstCategoryIndex(int first) { + if (first < 0 || first >= this.underlying.getColumnCount()) { + throw new IllegalArgumentException("Invalid index."); + } + this.firstCategoryIndex = first; + fireDatasetChanged(); + } + + /** + * Returns the maximum category count. + * + * @return The maximum category count. + * + * @see #setMaximumCategoryCount(int) + */ + public int getMaximumCategoryCount() { + return this.maximumCategoryCount; + } + + /** + * Sets the maximum category count and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param max the maximum. + * + * @see #getMaximumCategoryCount() + */ + public void setMaximumCategoryCount(int max) { + if (max < 0) { + throw new IllegalArgumentException("Requires 'max' >= 0."); + } + this.maximumCategoryCount = max; + fireDatasetChanged(); + } + + /** + * Returns the index of the last column for this dataset, or -1. + * + * @return The index. + */ + private int lastCategoryIndex() { + if (this.maximumCategoryCount == 0) { + return -1; + } + return Math.min(this.firstCategoryIndex + this.maximumCategoryCount, + this.underlying.getColumnCount()) - 1; + } + + /** + * Returns the index for the specified column key. + * + * @param key the key. + * + * @return The column index, or -1 if the key is not recognised. + */ + @Override + public int getColumnIndex(Comparable key) { + int index = this.underlying.getColumnIndex(key); + if (index >= this.firstCategoryIndex && index <= lastCategoryIndex()) { + return index - this.firstCategoryIndex; + } + return -1; // we didn't find the key + } + + /** + * Returns the column key for a given index. + * + * @param column the column index (zero-based). + * + * @return The column key. + * + * @throws IndexOutOfBoundsException if row is out of bounds. + */ + @Override + public Comparable getColumnKey(int column) { + return this.underlying.getColumnKey(column + this.firstCategoryIndex); + } + + /** + * Returns the column keys. + * + * @return The keys. + * + * @see #getColumnKey(int) + */ + @Override + public List getColumnKeys() { + List result = new java.util.ArrayList(); + int last = lastCategoryIndex(); + for (int i = this.firstCategoryIndex; i < last; i++) { + result.add(this.underlying.getColumnKey(i)); + } + return Collections.unmodifiableList(result); + } + + /** + * Returns the row index for a given key. + * + * @param key the row key. + * + * @return The row index, or -1 if the key is unrecognised. + */ + @Override + public int getRowIndex(Comparable key) { + return this.underlying.getRowIndex(key); + } + + /** + * Returns the row key for a given index. + * + * @param row the row index (zero-based). + * + * @return The row key. + * + * @throws IndexOutOfBoundsException if row is out of bounds. + */ + @Override + public Comparable getRowKey(int row) { + return this.underlying.getRowKey(row); + } + + /** + * Returns the row keys. + * + * @return The keys. + */ + @Override + public List getRowKeys() { + return this.underlying.getRowKeys(); + } + + /** + * Returns the value for a pair of keys. + * + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @return The value (possibly null). + * + * @throws UnknownKeyException if either key is not defined in the dataset. + */ + @Override + public Number getValue(Comparable rowKey, Comparable columnKey) { + int r = getRowIndex(rowKey); + int c = getColumnIndex(columnKey); + if (c != -1) { + return this.underlying.getValue(r, c + this.firstCategoryIndex); + } + else { + throw new UnknownKeyException("Unknown columnKey: " + columnKey); + } + } + + /** + * Returns the number of columns in the table. + * + * @return The column count. + */ + @Override + public int getColumnCount() { + int last = lastCategoryIndex(); + if (last == -1) { + return 0; + } + else { + return Math.max(last - this.firstCategoryIndex + 1, 0); + } + } + + /** + * Returns the number of rows in the table. + * + * @return The row count. + */ + @Override + public int getRowCount() { + return this.underlying.getRowCount(); + } + + /** + * Returns a value from the table. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The value (possibly null). + */ + @Override + public Number getValue(int row, int column) { + return this.underlying.getValue(row, column + this.firstCategoryIndex); + } + + /** + * Returns the percent complete for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return The percent complete. + */ + @Override + public Number getPercentComplete(Comparable rowKey, Comparable columnKey) { + int r = getRowIndex(rowKey); + int c = getColumnIndex(columnKey); + if (c != -1) { + return this.underlying.getPercentComplete(r, + c + this.firstCategoryIndex); + } + else { + throw new UnknownKeyException("Unknown columnKey: " + columnKey); + } + } + + /** + * Returns the percentage complete value of a sub-interval for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param subinterval the sub-interval. + * + * @return The percent complete value (possibly null). + * + * @see #getPercentComplete(int, int, int) + */ + @Override + public Number getPercentComplete(Comparable rowKey, Comparable columnKey, + int subinterval) { + int r = getRowIndex(rowKey); + int c = getColumnIndex(columnKey); + if (c != -1) { + return this.underlying.getPercentComplete(r, + c + this.firstCategoryIndex, subinterval); + } + else { + throw new UnknownKeyException("Unknown columnKey: " + columnKey); + } + } + + /** + * Returns the end value of a sub-interval for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param subinterval the sub-interval. + * + * @return The end value (possibly null). + * + * @see #getStartValue(Comparable, Comparable, int) + */ + @Override + public Number getEndValue(Comparable rowKey, Comparable columnKey, + int subinterval) { + int r = getRowIndex(rowKey); + int c = getColumnIndex(columnKey); + if (c != -1) { + return this.underlying.getEndValue(r, + c + this.firstCategoryIndex, subinterval); + } + else { + throw new UnknownKeyException("Unknown columnKey: " + columnKey); + } + } + + /** + * Returns the end value of a sub-interval for a given item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param subinterval the sub-interval. + * + * @return The end value (possibly null). + * + * @see #getStartValue(int, int, int) + */ + @Override + public Number getEndValue(int row, int column, int subinterval) { + return this.underlying.getEndValue(row, + column + this.firstCategoryIndex, subinterval); + } + + /** + * Returns the percent complete for a given item. + * + * @param series the row index (zero-based). + * @param category the column index (zero-based). + * + * @return The percent complete. + */ + @Override + public Number getPercentComplete(int series, int category) { + return this.underlying.getPercentComplete(series, + category + this.firstCategoryIndex); + } + + /** + * Returns the percentage complete value of a sub-interval for a given item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param subinterval the sub-interval. + * + * @return The percent complete value (possibly null). + * + * @see #getPercentComplete(Comparable, Comparable, int) + */ + @Override + public Number getPercentComplete(int row, int column, int subinterval) { + return this.underlying.getPercentComplete(row, + column + this.firstCategoryIndex, subinterval); + } + + /** + * Returns the start value of a sub-interval for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param subinterval the sub-interval. + * + * @return The start value (possibly null). + * + * @see #getEndValue(Comparable, Comparable, int) + */ + @Override + public Number getStartValue(Comparable rowKey, Comparable columnKey, + int subinterval) { + int r = getRowIndex(rowKey); + int c = getColumnIndex(columnKey); + if (c != -1) { + return this.underlying.getStartValue(r, + c + this.firstCategoryIndex, subinterval); + } + else { + throw new UnknownKeyException("Unknown columnKey: " + columnKey); + } + } + + /** + * Returns the start value of a sub-interval for a given item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param subinterval the sub-interval index (zero-based). + * + * @return The start value (possibly null). + * + * @see #getEndValue(int, int, int) + */ + @Override + public Number getStartValue(int row, int column, int subinterval) { + return this.underlying.getStartValue(row, + column + this.firstCategoryIndex, subinterval); + } + + /** + * Returns the number of sub-intervals for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return The sub-interval count. + * + * @see #getSubIntervalCount(int, int) + */ + @Override + public int getSubIntervalCount(Comparable rowKey, Comparable columnKey) { + int r = getRowIndex(rowKey); + int c = getColumnIndex(columnKey); + if (c != -1) { + return this.underlying.getSubIntervalCount(r, + c + this.firstCategoryIndex); + } + else { + throw new UnknownKeyException("Unknown columnKey: " + columnKey); + } + } + + /** + * Returns the number of sub-intervals for a given item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The sub-interval count. + * + * @see #getSubIntervalCount(Comparable, Comparable) + */ + @Override + public int getSubIntervalCount(int row, int column) { + return this.underlying.getSubIntervalCount(row, + column + this.firstCategoryIndex); + } + + /** + * Returns the start value for the interval for a given series and category. + * + * @param rowKey the series key. + * @param columnKey the category key. + * + * @return The start value (possibly null). + * + * @see #getEndValue(Comparable, Comparable) + */ + @Override + public Number getStartValue(Comparable rowKey, Comparable columnKey) { + int r = getRowIndex(rowKey); + int c = getColumnIndex(columnKey); + if (c != -1) { + return this.underlying.getStartValue(r, + c + this.firstCategoryIndex); + } + else { + throw new UnknownKeyException("Unknown columnKey: " + columnKey); + } + } + + /** + * Returns the start value for the interval for a given series and category. + * + * @param row the series (zero-based index). + * @param column the category (zero-based index). + * + * @return The start value (possibly null). + * + * @see #getEndValue(int, int) + */ + @Override + public Number getStartValue(int row, int column) { + return this.underlying.getStartValue(row, + column + this.firstCategoryIndex); + } + + /** + * Returns the end value for the interval for a given series and category. + * + * @param rowKey the series key. + * @param columnKey the category key. + * + * @return The end value (possibly null). + * + * @see #getStartValue(Comparable, Comparable) + */ + @Override + public Number getEndValue(Comparable rowKey, Comparable columnKey) { + int r = getRowIndex(rowKey); + int c = getColumnIndex(columnKey); + if (c != -1) { + return this.underlying.getEndValue(r, c + this.firstCategoryIndex); + } + else { + throw new UnknownKeyException("Unknown columnKey: " + columnKey); + } + } + + /** + * Returns the end value for the interval for a given series and category. + * + * @param series the series (zero-based index). + * @param category the category (zero-based index). + * + * @return The end value (possibly null). + */ + @Override + public Number getEndValue(int series, int category) { + return this.underlying.getEndValue(series, + category + this.firstCategoryIndex); + } + + /** + * Tests this SlidingCategoryDataset for equality with an + * arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SlidingGanttCategoryDataset)) { + return false; + } + SlidingGanttCategoryDataset that = (SlidingGanttCategoryDataset) obj; + if (this.firstCategoryIndex != that.firstCategoryIndex) { + return false; + } + if (this.maximumCategoryCount != that.maximumCategoryCount) { + return false; + } + if (!this.underlying.equals(that.underlying)) { + return false; + } + return true; + } + + /** + * Returns an independent copy of the dataset. Note that: + *

    + *
  • the underlying dataset is only cloned if it implements the + * {@link PublicCloneable} interface;
  • + *
  • the listeners registered with this dataset are not carried over to + * the cloned dataset.
  • + *
+ * + * @return An independent copy of the dataset. + * + * @throws CloneNotSupportedException if the dataset cannot be cloned for + * any reason. + */ + @Override + public Object clone() throws CloneNotSupportedException { + SlidingGanttCategoryDataset clone + = (SlidingGanttCategoryDataset) super.clone(); + if (this.underlying instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.underlying; + clone.underlying = (GanttCategoryDataset) pc.clone(); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/Task.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/Task.java new file mode 100755 index 0000000..a9fa63c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/Task.java @@ -0,0 +1,254 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------- + * Task.java + * --------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-Jan-2003 : Version 1 (DG); + * 16-Sep-2003 : Added percentage complete (DG); + * 30-Jul-2004 : Added clone() and equals() methods and implemented + * Serializable (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.gantt; + +import java.io.Serializable; +import java.util.Date; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.time.SimpleTimePeriod; +import org.jfree.data.time.TimePeriod; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A simple representation of a task. The task has a description and a + * duration. You can add sub-tasks to the task. + */ +public class Task implements Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 1094303785346988894L; + + /** The task description. */ + private String description; + + /** The time period for the task (estimated or actual). */ + private TimePeriod duration; + + /** The percent complete (null is permitted). */ + private Double percentComplete; + + /** Storage for the sub-tasks (if any). */ + private List subtasks; + + /** + * Creates a new task. + * + * @param description the task description (null not + * permitted). + * @param duration the task duration (null permitted). + */ + public Task(String description, TimePeriod duration) { + ParamChecks.nullNotPermitted(description, "description"); + this.description = description; + this.duration = duration; + this.percentComplete = null; + this.subtasks = new java.util.ArrayList(); + } + + /** + * Creates a new task. + * + * @param description the task description (null not + * permitted). + * @param start the start date (null not permitted). + * @param end the end date (null not permitted). + */ + public Task(String description, Date start, Date end) { + this(description, new SimpleTimePeriod(start, end)); + } + + /** + * Returns the task description. + * + * @return The task description (never null). + */ + public String getDescription() { + return this.description; + } + + /** + * Sets the task description. + * + * @param description the description (null not permitted). + */ + public void setDescription(String description) { + ParamChecks.nullNotPermitted(description, "description"); + this.description = description; + } + + /** + * Returns the duration (actual or estimated) of the task. + * + * @return The task duration (possibly null). + */ + public TimePeriod getDuration() { + return this.duration; + } + + /** + * Sets the task duration (actual or estimated). + * + * @param duration the duration (null permitted). + */ + public void setDuration(TimePeriod duration) { + this.duration = duration; + } + + /** + * Returns the percentage complete for this task. + * + * @return The percentage complete (possibly null). + */ + public Double getPercentComplete() { + return this.percentComplete; + } + + /** + * Sets the percentage complete for the task. + * + * @param percent the percentage (null permitted). + */ + public void setPercentComplete(Double percent) { + this.percentComplete = percent; + } + + /** + * Sets the percentage complete for the task. + * + * @param percent the percentage. + */ + public void setPercentComplete(double percent) { + setPercentComplete(new Double(percent)); + } + + /** + * Adds a sub-task to the task. + * + * @param subtask the subtask (null not permitted). + */ + public void addSubtask(Task subtask) { + ParamChecks.nullNotPermitted(subtask, "subtask"); + this.subtasks.add(subtask); + } + + /** + * Removes a sub-task from the task. + * + * @param subtask the subtask. + */ + public void removeSubtask(Task subtask) { + this.subtasks.remove(subtask); + } + + /** + * Returns the sub-task count. + * + * @return The sub-task count. + */ + public int getSubtaskCount() { + return this.subtasks.size(); + } + + /** + * Returns a sub-task. + * + * @param index the index. + * + * @return The sub-task. + */ + public Task getSubtask(int index) { + return (Task) this.subtasks.get(index); + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param object the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object object) { + if (object == this) { + return true; + } + if (!(object instanceof Task)) { + return false; + } + Task that = (Task) object; + if (!ObjectUtilities.equal(this.description, that.description)) { + return false; + } + if (!ObjectUtilities.equal(this.duration, that.duration)) { + return false; + } + if (!ObjectUtilities.equal(this.percentComplete, + that.percentComplete)) { + return false; + } + if (!ObjectUtilities.equal(this.subtasks, that.subtasks)) { + return false; + } + return true; + } + + /** + * Returns a clone of the task. + * + * @return A clone. + * + * @throws CloneNotSupportedException never thrown by this class, but + * subclasses may not support cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + Task clone = (Task) super.clone(); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/TaskSeries.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/TaskSeries.java new file mode 100755 index 0000000..b865561 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/TaskSeries.java @@ -0,0 +1,202 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * TaskSeries.java + * --------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 06-Jun-2002 : Version 1 (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 24-Oct-2002 : Added methods to get TimeAllocation by task index (DG); + * 10-Jan-2003 : Renamed GanttSeries --> TaskSeries (DG); + * 30-Jul-2004 : Added equals() method (DG); + * 09-May-2008 : Fixed cloning bug (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.gantt; + +import java.util.Collections; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.general.Series; +import org.jfree.util.ObjectUtilities; + +/** + * A series that contains zero, one or many {@link Task} objects. + *

+ * This class is used as a building block for the {@link TaskSeriesCollection} + * class that can be used to construct basic Gantt charts. + */ +public class TaskSeries extends Series { + + /** Storage for the tasks in the series. */ + private List tasks; + + /** + * Constructs a new series with the specified name. + * + * @param name the series name (null not permitted). + */ + public TaskSeries(String name) { + super(name); + this.tasks = new java.util.ArrayList(); + } + + /** + * Adds a task to the series and sends a + * {@link org.jfree.data.general.SeriesChangeEvent} to all registered + * listeners. + * + * @param task the task (null not permitted). + */ + public void add(Task task) { + ParamChecks.nullNotPermitted(task, "task"); + this.tasks.add(task); + fireSeriesChanged(); + } + + /** + * Removes a task from the series and sends + * a {@link org.jfree.data.general.SeriesChangeEvent} + * to all registered listeners. + * + * @param task the task. + */ + public void remove(Task task) { + this.tasks.remove(task); + fireSeriesChanged(); + } + + /** + * Removes all tasks from the series and sends + * a {@link org.jfree.data.general.SeriesChangeEvent} + * to all registered listeners. + */ + public void removeAll() { + this.tasks.clear(); + fireSeriesChanged(); + } + + /** + * Returns the number of items in the series. + * + * @return The item count. + */ + @Override + public int getItemCount() { + return this.tasks.size(); + } + + /** + * Returns a task from the series. + * + * @param index the task index (zero-based). + * + * @return The task. + */ + public Task get(int index) { + return (Task) this.tasks.get(index); + } + + /** + * Returns the task in the series that has the specified description. + * + * @param description the name (null not permitted). + * + * @return The task (possibly null). + */ + public Task get(String description) { + Task result = null; + int count = this.tasks.size(); + for (int i = 0; i < count; i++) { + Task t = (Task) this.tasks.get(i); + if (t.getDescription().equals(description)) { + result = t; + break; + } + } + return result; + } + + /** + * Returns an unmodifialble list of the tasks in the series. + * + * @return The tasks. + */ + public List getTasks() { + return Collections.unmodifiableList(this.tasks); + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TaskSeries)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + TaskSeries that = (TaskSeries) obj; + if (!this.tasks.equals(that.tasks)) { + return false; + } + return true; + } + + /** + * Returns an independent copy of this series. + * + * @return A clone of the series. + * + * @throws CloneNotSupportedException if there is some problem cloning + * the dataset. + */ + @Override + public Object clone() throws CloneNotSupportedException { + TaskSeries clone = (TaskSeries) super.clone(); + clone.tasks = (List) ObjectUtilities.deepClone(this.tasks); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/TaskSeriesCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/TaskSeriesCollection.java new file mode 100755 index 0000000..490ef86 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/TaskSeriesCollection.java @@ -0,0 +1,705 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * TaskSeriesCollection.java + * ------------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Thomas Schuster; + * + * Changes + * ------- + * 06-Jun-2002 : Version 1 (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 24-Oct-2002 : Amendments for changes in CategoryDataset interface and + * CategoryToolTipGenerator interface (DG); + * 10-Jan-2003 : Renamed GanttSeriesCollection --> TaskSeriesCollection (DG); + * 04-Sep-2003 : Fixed bug 800324 (DG); + * 16-Sep-2003 : Implemented GanttCategoryDataset (DG); + * 12-Jan-2005 : Fixed bug 1099331 (DG); + * 18-Jan-2006 : Added new methods getSeries(int) and + * getSeries(Comparable) (DG); + * 09-May-2008 : Fixed cloning bug (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.gantt; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.general.AbstractSeriesDataset; +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.data.time.TimePeriod; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A collection of {@link TaskSeries} objects. This class provides one + * implementation of the {@link GanttCategoryDataset} interface. + */ +public class TaskSeriesCollection extends AbstractSeriesDataset + implements GanttCategoryDataset, Cloneable, PublicCloneable, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -2065799050738449903L; + + /** + * Storage for aggregate task keys (the task description is used as the + * key). + */ + private List keys; + + /** Storage for the series. */ + private List data; + + /** + * Default constructor. + */ + public TaskSeriesCollection() { + this.keys = new java.util.ArrayList(); + this.data = new java.util.ArrayList(); + } + + /** + * Returns a series from the collection. + * + * @param key the series key (null not permitted). + * + * @return The series. + * + * @since 1.0.1 + */ + public TaskSeries getSeries(Comparable key) { + if (key == null) { + throw new NullPointerException("Null 'key' argument."); + } + TaskSeries result = null; + int index = getRowIndex(key); + if (index >= 0) { + result = getSeries(index); + } + return result; + } + + /** + * Returns a series from the collection. + * + * @param series the series index (zero-based). + * + * @return The series. + * + * @since 1.0.1 + */ + public TaskSeries getSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + return (TaskSeries) this.data.get(series); + } + + /** + * Returns the number of series in the collection. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return getRowCount(); + } + + /** + * Returns the name of a series. + * + * @param series the series index (zero-based). + * + * @return The name of a series. + */ + @Override + public Comparable getSeriesKey(int series) { + TaskSeries ts = (TaskSeries) this.data.get(series); + return ts.getKey(); + } + + /** + * Returns the number of rows (series) in the collection. + * + * @return The series count. + */ + @Override + public int getRowCount() { + return this.data.size(); + } + + /** + * Returns the row keys. In this case, each series is a key. + * + * @return The row keys. + */ + @Override + public List getRowKeys() { + return this.data; + } + + /** + * Returns the number of column in the dataset. + * + * @return The column count. + */ + @Override + public int getColumnCount() { + return this.keys.size(); + } + + /** + * Returns a list of the column keys in the dataset. + * + * @return The category list. + */ + @Override + public List getColumnKeys() { + return this.keys; + } + + /** + * Returns a column key. + * + * @param index the column index. + * + * @return The column key. + */ + @Override + public Comparable getColumnKey(int index) { + return (Comparable) this.keys.get(index); + } + + /** + * Returns the column index for a column key. + * + * @param columnKey the column key (null not permitted). + * + * @return The column index. + */ + @Override + public int getColumnIndex(Comparable columnKey) { + ParamChecks.nullNotPermitted(columnKey, "columnKey"); + return this.keys.indexOf(columnKey); + } + + /** + * Returns the row index for the given row key. + * + * @param rowKey the row key. + * + * @return The index. + */ + @Override + public int getRowIndex(Comparable rowKey) { + int result = -1; + int count = this.data.size(); + for (int i = 0; i < count; i++) { + TaskSeries s = (TaskSeries) this.data.get(i); + if (s.getKey().equals(rowKey)) { + result = i; + break; + } + } + return result; + } + + /** + * Returns the key for a row. + * + * @param index the row index (zero-based). + * + * @return The key. + */ + @Override + public Comparable getRowKey(int index) { + TaskSeries series = (TaskSeries) this.data.get(index); + return series.getKey(); + } + + /** + * Adds a series to the dataset and sends a + * {@link org.jfree.data.general.DatasetChangeEvent} to all registered + * listeners. + * + * @param series the series (null not permitted). + */ + public void add(TaskSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + this.data.add(series); + series.addChangeListener(this); + + // look for any keys that we don't already know about... + Iterator iterator = series.getTasks().iterator(); + while (iterator.hasNext()) { + Task task = (Task) iterator.next(); + String key = task.getDescription(); + int index = this.keys.indexOf(key); + if (index < 0) { + this.keys.add(key); + } + } + fireDatasetChanged(); + } + + /** + * Removes a series from the collection and sends + * a {@link org.jfree.data.general.DatasetChangeEvent} + * to all registered listeners. + * + * @param series the series. + */ + public void remove(TaskSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + if (this.data.contains(series)) { + series.removeChangeListener(this); + this.data.remove(series); + fireDatasetChanged(); + } + } + + /** + * Removes a series from the collection and sends + * a {@link org.jfree.data.general.DatasetChangeEvent} + * to all registered listeners. + * + * @param series the series (zero based index). + */ + public void remove(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException( + "TaskSeriesCollection.remove(): index outside valid range."); + } + + // fetch the series, remove the change listener, then remove the series. + TaskSeries ts = (TaskSeries) this.data.get(series); + ts.removeChangeListener(this); + this.data.remove(series); + fireDatasetChanged(); + + } + + /** + * Removes all the series from the collection and sends + * a {@link org.jfree.data.general.DatasetChangeEvent} + * to all registered listeners. + */ + public void removeAll() { + + // deregister the collection as a change listener to each series in + // the collection. + Iterator iterator = this.data.iterator(); + while (iterator.hasNext()) { + TaskSeries series = (TaskSeries) iterator.next(); + series.removeChangeListener(this); + } + + // remove all the series from the collection and notify listeners. + this.data.clear(); + fireDatasetChanged(); + + } + + /** + * Returns the value for an item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return The item value. + */ + @Override + public Number getValue(Comparable rowKey, Comparable columnKey) { + return getStartValue(rowKey, columnKey); + } + + /** + * Returns the value for a task. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The start value. + */ + @Override + public Number getValue(int row, int column) { + return getStartValue(row, column); + } + + /** + * Returns the start value for a task. This is a date/time value, measured + * in milliseconds since 1-Jan-1970. + * + * @param rowKey the series. + * @param columnKey the category. + * + * @return The start value (possibly null). + */ + @Override + public Number getStartValue(Comparable rowKey, Comparable columnKey) { + Number result = null; + int row = getRowIndex(rowKey); + TaskSeries series = (TaskSeries) this.data.get(row); + Task task = series.get(columnKey.toString()); + if (task != null) { + TimePeriod duration = task.getDuration(); + if (duration != null) { + result = new Long(duration.getStart().getTime()); + } + } + return result; + } + + /** + * Returns the start value for a task. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The start value. + */ + @Override + public Number getStartValue(int row, int column) { + Comparable rowKey = getRowKey(row); + Comparable columnKey = getColumnKey(column); + return getStartValue(rowKey, columnKey); + } + + /** + * Returns the end value for a task. This is a date/time value, measured + * in milliseconds since 1-Jan-1970. + * + * @param rowKey the series. + * @param columnKey the category. + * + * @return The end value (possibly null). + */ + @Override + public Number getEndValue(Comparable rowKey, Comparable columnKey) { + Number result = null; + int row = getRowIndex(rowKey); + TaskSeries series = (TaskSeries) this.data.get(row); + Task task = series.get(columnKey.toString()); + if (task != null) { + TimePeriod duration = task.getDuration(); + if (duration != null) { + result = new Long(duration.getEnd().getTime()); + } + } + return result; + } + + /** + * Returns the end value for a task. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The end value. + */ + @Override + public Number getEndValue(int row, int column) { + Comparable rowKey = getRowKey(row); + Comparable columnKey = getColumnKey(column); + return getEndValue(rowKey, columnKey); + } + + /** + * Returns the percent complete for a given item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The percent complete (possibly null). + */ + @Override + public Number getPercentComplete(int row, int column) { + Comparable rowKey = getRowKey(row); + Comparable columnKey = getColumnKey(column); + return getPercentComplete(rowKey, columnKey); + } + + /** + * Returns the percent complete for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return The percent complete. + */ + @Override + public Number getPercentComplete(Comparable rowKey, Comparable columnKey) { + Number result = null; + int row = getRowIndex(rowKey); + TaskSeries series = (TaskSeries) this.data.get(row); + Task task = series.get(columnKey.toString()); + if (task != null) { + result = task.getPercentComplete(); + } + return result; + } + + /** + * Returns the number of sub-intervals for a given item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The sub-interval count. + */ + @Override + public int getSubIntervalCount(int row, int column) { + Comparable rowKey = getRowKey(row); + Comparable columnKey = getColumnKey(column); + return getSubIntervalCount(rowKey, columnKey); + } + + /** + * Returns the number of sub-intervals for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return The sub-interval count. + */ + @Override + public int getSubIntervalCount(Comparable rowKey, Comparable columnKey) { + int result = 0; + int row = getRowIndex(rowKey); + TaskSeries series = (TaskSeries) this.data.get(row); + Task task = series.get(columnKey.toString()); + if (task != null) { + result = task.getSubtaskCount(); + } + return result; + } + + /** + * Returns the start value of a sub-interval for a given item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param subinterval the sub-interval index (zero-based). + * + * @return The start value (possibly null). + */ + @Override + public Number getStartValue(int row, int column, int subinterval) { + Comparable rowKey = getRowKey(row); + Comparable columnKey = getColumnKey(column); + return getStartValue(rowKey, columnKey, subinterval); + } + + /** + * Returns the start value of a sub-interval for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param subinterval the subinterval. + * + * @return The start value (possibly null). + */ + @Override + public Number getStartValue(Comparable rowKey, Comparable columnKey, + int subinterval) { + Number result = null; + int row = getRowIndex(rowKey); + TaskSeries series = (TaskSeries) this.data.get(row); + Task task = series.get(columnKey.toString()); + if (task != null) { + Task sub = task.getSubtask(subinterval); + if (sub != null) { + TimePeriod duration = sub.getDuration(); + result = new Long(duration.getStart().getTime()); + } + } + return result; + } + + /** + * Returns the end value of a sub-interval for a given item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param subinterval the subinterval. + * + * @return The end value (possibly null). + */ + @Override + public Number getEndValue(int row, int column, int subinterval) { + Comparable rowKey = getRowKey(row); + Comparable columnKey = getColumnKey(column); + return getEndValue(rowKey, columnKey, subinterval); + } + + /** + * Returns the end value of a sub-interval for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param subinterval the subinterval. + * + * @return The end value (possibly null). + */ + @Override + public Number getEndValue(Comparable rowKey, Comparable columnKey, + int subinterval) { + Number result = null; + int row = getRowIndex(rowKey); + TaskSeries series = (TaskSeries) this.data.get(row); + Task task = series.get(columnKey.toString()); + if (task != null) { + Task sub = task.getSubtask(subinterval); + if (sub != null) { + TimePeriod duration = sub.getDuration(); + result = new Long(duration.getEnd().getTime()); + } + } + return result; + } + + /** + * Returns the percentage complete value of a sub-interval for a given item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * @param subinterval the sub-interval. + * + * @return The percent complete value (possibly null). + */ + @Override + public Number getPercentComplete(int row, int column, int subinterval) { + Comparable rowKey = getRowKey(row); + Comparable columnKey = getColumnKey(column); + return getPercentComplete(rowKey, columnKey, subinterval); + } + + /** + * Returns the percentage complete value of a sub-interval for a given item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param subinterval the sub-interval. + * + * @return The percent complete value (possibly null). + */ + @Override + public Number getPercentComplete(Comparable rowKey, Comparable columnKey, + int subinterval) { + Number result = null; + int row = getRowIndex(rowKey); + TaskSeries series = (TaskSeries) this.data.get(row); + Task task = series.get(columnKey.toString()); + if (task != null) { + Task sub = task.getSubtask(subinterval); + if (sub != null) { + result = sub.getPercentComplete(); + } + } + return result; + } + + /** + * Called when a series belonging to the dataset changes. + * + * @param event information about the change. + */ + @Override + public void seriesChanged(SeriesChangeEvent event) { + refreshKeys(); + fireDatasetChanged(); + } + + /** + * Refreshes the keys. + */ + private void refreshKeys() { + + this.keys.clear(); + for (int i = 0; i < getSeriesCount(); i++) { + TaskSeries series = (TaskSeries) this.data.get(i); + // look for any keys that we don't already know about... + Iterator iterator = series.getTasks().iterator(); + while (iterator.hasNext()) { + Task task = (Task) iterator.next(); + String key = task.getDescription(); + int index = this.keys.indexOf(key); + if (index < 0) { + this.keys.add(key); + } + } + } + + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TaskSeriesCollection)) { + return false; + } + TaskSeriesCollection that = (TaskSeriesCollection) obj; + if (!ObjectUtilities.equal(this.data, that.data)) { + return false; + } + return true; + } + + /** + * Returns an independent copy of this dataset. + * + * @return A clone of the dataset. + * + * @throws CloneNotSupportedException if there is some problem cloning + * the dataset. + */ + @Override + public Object clone() throws CloneNotSupportedException { + TaskSeriesCollection clone = (TaskSeriesCollection) super.clone(); + clone.data = (List) ObjectUtilities.deepClone(this.data); + clone.keys = new java.util.ArrayList(this.keys); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/XYTaskDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/XYTaskDataset.java new file mode 100755 index 0000000..49aeca4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/XYTaskDataset.java @@ -0,0 +1,479 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * XYTaskDataset.java + * ------------------ + * (C) Copyright 2008-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 17-Sep-2008 : Version 1 (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.gantt; + +import java.util.Date; + +import org.jfree.chart.axis.SymbolAxis; +import org.jfree.chart.renderer.xy.XYBarRenderer; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetChangeListener; +import org.jfree.data.time.TimePeriod; +import org.jfree.data.xy.AbstractXYDataset; +import org.jfree.data.xy.IntervalXYDataset; + +/** + * A dataset implementation that wraps a {@link TaskSeriesCollection} and + * presents it as an {@link IntervalXYDataset}, allowing a set of tasks to + * be displayed using an {@link XYBarRenderer} (and usually a + * {@link SymbolAxis}). This is a very specialised dataset implementation + * ---before using it, you should take some time to understand the use-cases + * that it is designed for. + * + * @since 1.0.11 + */ +public class XYTaskDataset extends AbstractXYDataset + implements IntervalXYDataset, DatasetChangeListener { + + /** The underlying tasks. */ + private TaskSeriesCollection underlying; + + /** The series interval width (typically 0.0 < w <= 1.0). */ + private double seriesWidth; + + /** A flag that controls whether or not the data values are transposed. */ + private boolean transposed; + + /** + * Creates a new dataset based on the supplied collection of tasks. + * + * @param tasks the underlying dataset (null not permitted). + */ + public XYTaskDataset(TaskSeriesCollection tasks) { + ParamChecks.nullNotPermitted(tasks, "tasks"); + this.underlying = tasks; + this.seriesWidth = 0.8; + this.underlying.addChangeListener(this); + } + + /** + * Returns the underlying task series collection that was supplied to the + * constructor. + * + * @return The underlying collection (never null). + */ + public TaskSeriesCollection getTasks() { + return this.underlying; + } + + /** + * Returns the width of the interval for each series this dataset. + * + * @return The width of the series interval. + * + * @see #setSeriesWidth(double) + */ + public double getSeriesWidth() { + return this.seriesWidth; + } + + /** + * Sets the series interval width and sends a {@link DatasetChangeEvent} to + * all registered listeners. + * + * @param w the width. + * + * @see #getSeriesWidth() + */ + public void setSeriesWidth(double w) { + if (w <= 0.0) { + throw new IllegalArgumentException("Requires 'w' > 0.0."); + } + this.seriesWidth = w; + fireDatasetChanged(); + } + + /** + * Returns a flag that indicates whether or not the dataset is transposed. + * The default is false which means the x-values are integers + * corresponding to the series indices, and the y-values are millisecond + * values corresponding to the task date/time intervals. If the flag + * is set to true, the x and y-values are reversed. + * + * @return The flag. + * + * @see #setTransposed(boolean) + */ + public boolean isTransposed() { + return this.transposed; + } + + /** + * Sets the flag that controls whether or not the dataset is transposed + * and sends a {@link DatasetChangeEvent} to all registered listeners. + * + * @param transposed the new flag value. + * + * @see #isTransposed() + */ + public void setTransposed(boolean transposed) { + this.transposed = transposed; + fireDatasetChanged(); + } + + /** + * Returns the number of series in the dataset. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.underlying.getSeriesCount(); + } + + /** + * Returns the name of a series. + * + * @param series the series index (zero-based). + * + * @return The name of a series. + */ + @Override + public Comparable getSeriesKey(int series) { + return this.underlying.getSeriesKey(series); + } + + /** + * Returns the number of items (tasks) in the specified series. + * + * @param series the series index (zero-based). + * + * @return The item count. + */ + @Override + public int getItemCount(int series) { + return this.underlying.getSeries(series).getItemCount(); + } + + /** + * Returns the x-value (as a double primitive) for an item within a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getXValue(int series, int item) { + if (!this.transposed) { + return getSeriesValue(series); + } + else { + return getItemValue(series, item); + } + } + + /** + * Returns the starting date/time for the specified item (task) in the + * given series, measured in milliseconds since 1-Jan-1970 (as in + * java.util.Date). + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The start date/time. + */ + @Override + public double getStartXValue(int series, int item) { + if (!this.transposed) { + return getSeriesStartValue(series); + } + else { + return getItemStartValue(series, item); + } + } + + /** + * Returns the ending date/time for the specified item (task) in the + * given series, measured in milliseconds since 1-Jan-1970 (as in + * java.util.Date). + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The end date/time. + */ + @Override + public double getEndXValue(int series, int item) { + if (!this.transposed) { + return getSeriesEndValue(series); + } + else { + return getItemEndValue(series, item); + } + } + + /** + * Returns the x-value for the specified series. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value (in milliseconds). + */ + @Override + public Number getX(int series, int item) { + return new Double(getXValue(series, item)); + } + + /** + * Returns the starting date/time for the specified item (task) in the + * given series, measured in milliseconds since 1-Jan-1970 (as in + * java.util.Date). + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The start date/time. + */ + @Override + public Number getStartX(int series, int item) { + return new Double(getStartXValue(series, item)); + } + + /** + * Returns the ending date/time for the specified item (task) in the + * given series, measured in milliseconds since 1-Jan-1970 (as in + * java.util.Date). + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The end date/time. + */ + @Override + public Number getEndX(int series, int item) { + return new Double(getEndXValue(series, item)); + } + + /** + * Returns the y-value (as a double primitive) for an item within a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getYValue(int series, int item) { + if (!this.transposed) { + return getItemValue(series, item); + } + else { + return getSeriesValue(series); + } + } + + /** + * Returns the starting value of the y-interval for an item in the + * given series. + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The y-interval start. + */ + @Override + public double getStartYValue(int series, int item) { + if (!this.transposed) { + return getItemStartValue(series, item); + } + else { + return getSeriesStartValue(series); + } + } + + /** + * Returns the ending value of the y-interval for an item in the + * given series. + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The y-interval end. + */ + @Override + public double getEndYValue(int series, int item) { + if (!this.transposed) { + return getItemEndValue(series, item); + } + else { + return getSeriesEndValue(series); + } + } + + /** + * Returns the y-value for the specified series/item. In this + * implementation, we return the series index as the y-value (this means + * that every item in the series has a constant integer value). + * + * @param series the series index. + * @param item the item index. + * + * @return The y-value. + */ + @Override + public Number getY(int series, int item) { + return new Double(getYValue(series, item)); + } + + /** + * Returns the starting value of the y-interval for an item in the + * given series. + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The y-interval start. + */ + @Override + public Number getStartY(int series, int item) { + return new Double(getStartYValue(series, item)); + } + + /** + * Returns the ending value of the y-interval for an item in the + * given series. + * + * @param series the series index. + * @param item the item (or task) index. + * + * @return The y-interval end. + */ + @Override + public Number getEndY(int series, int item) { + return new Double(getEndYValue(series, item)); + } + + private double getSeriesValue(int series) { + return series; + } + + private double getSeriesStartValue(int series) { + return series - this.seriesWidth / 2.0; + } + + private double getSeriesEndValue(int series) { + return series + this.seriesWidth / 2.0; + } + + private double getItemValue(int series, int item) { + TaskSeries s = this.underlying.getSeries(series); + Task t = s.get(item); + TimePeriod duration = t.getDuration(); + Date start = duration.getStart(); + Date end = duration.getEnd(); + return (start.getTime() + end.getTime()) / 2.0; + } + + private double getItemStartValue(int series, int item) { + TaskSeries s = this.underlying.getSeries(series); + Task t = s.get(item); + TimePeriod duration = t.getDuration(); + Date start = duration.getStart(); + return start.getTime(); + } + + private double getItemEndValue(int series, int item) { + TaskSeries s = this.underlying.getSeries(series); + Task t = s.get(item); + TimePeriod duration = t.getDuration(); + Date end = duration.getEnd(); + return end.getTime(); + } + + + /** + * Receives a change event from the underlying dataset and responds by + * firing a change event for this dataset. + * + * @param event the event. + */ + @Override + public void datasetChanged(DatasetChangeEvent event) { + fireDatasetChanged(); + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYTaskDataset)) { + return false; + } + XYTaskDataset that = (XYTaskDataset) obj; + if (this.seriesWidth != that.seriesWidth) { + return false; + } + if (this.transposed != that.transposed) { + return false; + } + if (!this.underlying.equals(that.underlying)) { + return false; + } + return true; + } + + /** + * Returns a clone of this dataset. + * + * @return A clone of this dataset. + * + * @throws CloneNotSupportedException if there is a problem cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + XYTaskDataset clone = (XYTaskDataset) super.clone(); + clone.underlying = (TaskSeriesCollection) this.underlying.clone(); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/package.html new file mode 100755 index 0000000..1d969f8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/gantt/package.html @@ -0,0 +1,6 @@ + + + +Data interfaces and classes for Gantt charts. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/AbstractDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/AbstractDataset.java new file mode 100755 index 0000000..1b42aa8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/AbstractDataset.java @@ -0,0 +1,304 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * AbstractDataset.java + * -------------------- + * (C)opyright 2000-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Nicolas Brodu (for Astrium and EADS Corporate Research + * Center); + * + * Changes (from 21-Aug-2001) + * -------------------------- + * 21-Aug-2001 : Added standard header. Fixed DOS encoding problem (DG); + * 18-Sep-2001 : Updated e-mail address in header (DG); + * 15-Oct-2001 : Moved to new package (com.jrefinery.data.*) (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * 17-Nov-2001 : Changed constructor from public to protected, created new + * AbstractSeriesDataset class and transferred series-related + * methods, updated Javadoc comments (DG); + * 04-Mar-2002 : Updated import statements (DG); + * 11-Jun-2002 : Updated for change in the event constructor (DG); + * 07-Aug-2002 : Changed listener list to use + * javax.swing.event.EventListenerList (DG); + * 04-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 27-Mar-2003 : Implemented Serializable (DG); + * 18-Aug-2003 : Implemented Cloneable (DG); + * 08-Sep-2003 : Serialization fixes (NB); + * 11-Sep-2003 : Cloning Fixes (NB); + * 01-Jun-2005 : Added hasListener() method for unit testing (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * 21-Nov-2013 : Added notify flag to allow suppressing change events + * temporarily (DG); + * + */ + +package org.jfree.data.general; + +import java.io.IOException; +import java.io.InvalidObjectException; +import java.io.ObjectInputStream; +import java.io.ObjectInputValidation; +import java.io.ObjectOutputStream; +import java.io.Serializable; +import java.util.Arrays; +import java.util.EventListener; +import java.util.List; + +import javax.swing.event.EventListenerList; +import org.jfree.chart.util.ParamChecks; + +/** + * An abstract implementation of the {@link Dataset} interface, containing a + * mechanism for registering change listeners. + */ +public abstract class AbstractDataset implements Dataset, Cloneable, + Serializable, ObjectInputValidation { + + /** For serialization. */ + private static final long serialVersionUID = 1918768939869230744L; + + /** The group that the dataset belongs to. */ + private DatasetGroup group; + + /** Storage for registered change listeners. */ + private transient EventListenerList listenerList; + + /** + * A flag that can be used to temporarily suppress dataset change event + * notifications. + */ + private boolean notify; + + /** + * Constructs a dataset. By default, the dataset is assigned to its own + * group. + */ + protected AbstractDataset() { + this.group = new DatasetGroup(); + this.listenerList = new EventListenerList(); + this.notify = true; + } + + /** + * Returns the dataset group for the dataset. + * + * @return The group (never null). + * + * @see #setGroup(DatasetGroup) + */ + @Override + public DatasetGroup getGroup() { + return this.group; + } + + /** + * Sets the dataset group for the dataset. + * + * @param group the group (null not permitted). + * + * @see #getGroup() + */ + @Override + public void setGroup(DatasetGroup group) { + ParamChecks.nullNotPermitted(group, "group"); + this.group = group; + } + + /** + * Returns the value of the notify flag. The default value is + * true. If this is false, calls to the + * {@link #fireDatasetChanged()} method will NOT trigger a dataset + * change event. + * + * @return A boolean. + * + * @since 1.0.17 + */ + public boolean getNotify() { + return this.notify; + } + + /** + * Sets the notify flag, which controls whether or not the {@link #fireDatasetChanged()} + * method notifies listeners. Setting this flag to true will + * trigger a DatasetChangeEvent because there may be + * queued up changes. + * + * @param notify the new flag value. + * + * @since 1.0.17 + */ + public void setNotify(boolean notify) { + this.notify = notify; + if (notify) { + fireDatasetChanged(); + } + } + + /** + * Registers an object to receive notification of changes to the dataset. + * + * @param listener the object to register. + * + * @see #removeChangeListener(DatasetChangeListener) + */ + @Override + public void addChangeListener(DatasetChangeListener listener) { + this.listenerList.add(DatasetChangeListener.class, listener); + } + + /** + * Deregisters an object so that it no longer receives notification of + * changes to the dataset. + * + * @param listener the object to deregister. + * + * @see #addChangeListener(DatasetChangeListener) + */ + @Override + public void removeChangeListener(DatasetChangeListener listener) { + this.listenerList.remove(DatasetChangeListener.class, listener); + } + + /** + * Returns true if the specified object is registered with + * the dataset as a listener. Most applications won't need to call this + * method, it exists mainly for use by unit testing code. + * + * @param listener the listener. + * + * @return A boolean. + * + * @see #addChangeListener(DatasetChangeListener) + * @see #removeChangeListener(DatasetChangeListener) + */ + public boolean hasListener(EventListener listener) { + List list = Arrays.asList(this.listenerList.getListenerList()); + return list.contains(listener); + } + + /** + * Notifies all registered listeners that the dataset has changed, + * provided that the notify flag has not been set to + * false. + * + * @see #addChangeListener(DatasetChangeListener) + */ + protected void fireDatasetChanged() { + if (this.notify) { + notifyListeners(new DatasetChangeEvent(this, this)); + } + } + + /** + * Notifies all registered listeners that the dataset has changed. + * + * @param event contains information about the event that triggered the + * notification. + * + * @see #addChangeListener(DatasetChangeListener) + * @see #removeChangeListener(DatasetChangeListener) + */ + protected void notifyListeners(DatasetChangeEvent event) { + Object[] listeners = this.listenerList.getListenerList(); + for (int i = listeners.length - 2; i >= 0; i -= 2) { + if (listeners[i] == DatasetChangeListener.class) { + ((DatasetChangeListener) listeners[i + 1]).datasetChanged( + event); + } + } + } + + /** + * Returns a clone of the dataset. The cloned dataset will NOT include the + * {@link DatasetChangeListener} references that have been registered with + * this dataset. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the dataset does not support + * cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + AbstractDataset clone = (AbstractDataset) super.clone(); + clone.listenerList = new EventListenerList(); + return clone; + } + + /** + * Handles serialization. + * + * @param stream the output stream. + * + * @throws IOException if there is an I/O problem. + */ + private void writeObject(ObjectOutputStream stream) throws IOException { + stream.defaultWriteObject(); + } + + /** + * Restores a serialized object. + * + * @param stream the input stream. + * + * @throws IOException if there is an I/O problem. + * @throws ClassNotFoundException if there is a problem loading a class. + */ + private void readObject(ObjectInputStream stream) + throws IOException, ClassNotFoundException { + stream.defaultReadObject(); + this.listenerList = new EventListenerList(); + stream.registerValidation(this, 10); // see comments about priority of + // 10 in validateObject() + } + + /** + * Validates the object. We use this opportunity to call listeners who have + * registered during the deserialization process, as listeners are not + * serialized. This method is called by the serialization system after the + * entire graph is read. + * + * This object has registered itself to the system with a priority of 10. + * Other callbacks may register with a higher priority number to be called + * before this object, or with a lower priority number to be called after + * the listeners were notified. + * + * All listeners are supposed to have register by now, either in their + * readObject or validateObject methods. Notify them that this dataset has + * changed. + * + * @exception InvalidObjectException If the object cannot validate itself. + */ + @Override + public void validateObject() throws InvalidObjectException { + fireDatasetChanged(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/AbstractSeriesDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/AbstractSeriesDataset.java new file mode 100755 index 0000000..c6da991 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/AbstractSeriesDataset.java @@ -0,0 +1,117 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * AbstractSeriesDataset.java + * -------------------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 17-Nov-2001 : Version 1 (DG); + * 28-Mar-2002 : Implemented SeriesChangeListener interface (DG); + * 04-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 04-Feb-2003 : Removed redundant methods (DG); + * 27-Mar-2003 : Implemented Serializable (DG); + * + */ + +package org.jfree.data.general; + +import java.io.Serializable; + +/** + * An abstract implementation of the {@link SeriesDataset} interface, + * containing a mechanism for registering change listeners. + */ +public abstract class AbstractSeriesDataset extends AbstractDataset + implements SeriesDataset, SeriesChangeListener, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -6074996219705033171L; + + /** + * Creates a new dataset. + */ + protected AbstractSeriesDataset() { + super(); + } + + /** + * Returns the number of series in the dataset. + * + * @return The series count. + */ + @Override + public abstract int getSeriesCount(); + + /** + * Returns the key for a series. + *

+ * If series is not within the specified range, the + * implementing method should throw an {@link IndexOutOfBoundsException} + * (preferred) or an {@link IllegalArgumentException}. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The series key. + */ + @Override + public abstract Comparable getSeriesKey(int series); + + /** + * Returns the index of the named series, or -1. + * + * @param seriesKey the series key (null permitted). + * + * @return The index. + */ + @Override + public int indexOf(Comparable seriesKey) { + int seriesCount = getSeriesCount(); + for (int s = 0; s < seriesCount; s++) { + if (getSeriesKey(s).equals(seriesKey)) { + return s; + } + } + return -1; + } + + /** + * Called when a series belonging to the dataset changes. + * + * @param event information about the change. + */ + @Override + public void seriesChanged(SeriesChangeEvent event) { + fireDatasetChanged(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/CombinationDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/CombinationDataset.java new file mode 100755 index 0000000..638b3e1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/CombinationDataset.java @@ -0,0 +1,74 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * CombinationDataset.java + * ----------------------- + * (C) Copyright 2001-2009, by Bill Kelemen. + * + * Original Author: Bill Kelemen; + * Contributor(s): -; + * + * Changes + * ------- + * 06-Dec-2001 : Version 1 (BK); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.general; + +/** + * Interface that describes the new methods that any combined dataset needs to + * implement. A combined dataset object will combine one or more datasets and + * expose a sub-set or union of the combined datasets. + * + * @deprecated 1.0.13 + */ +public interface CombinationDataset { + + /////////////////////////////////////////////////////////////////////////// + // New methods from CombinationDataset + /////////////////////////////////////////////////////////////////////////// + + /** + * Returns the parent Dataset of this combination. If there is more than + * one parent, or a child is found that is not a combination, then returns + * null. + * + * @return The parent Dataset of this combination. + */ + public SeriesDataset getParent(); + + /** + * Returns a map or indirect indexing form our series into parent's series. + * + * @return A map or indirect indexing form our series into parent's series. + */ + public int[] getMap(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/CombinedDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/CombinedDataset.java new file mode 100755 index 0000000..633c282 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/CombinedDataset.java @@ -0,0 +1,653 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * CombinedDataset.java + * -------------------- + * (C) Copyright 2001-2009, by Bill Kelemen and Contributors. + * + * Original Author: Bill Kelemen; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 06-Dec-2001 : Version 1 (BK); + * 27-Dec-2001 : Fixed bug in getChildPosition method (BK); + * 29-Dec-2001 : Fixed bug in getChildPosition method with complex + * CombinePlot (BK); + * 05-Feb-2002 : Small addition to the interface HighLowDataset, as requested + * by Sylvain Vieujot (DG); + * 14-Feb-2002 : Added bug fix for IntervalXYDataset methods, submitted by + * Gyula Kun-Szabo (DG); + * 11-Jun-2002 : Updated for change in event constructor (DG); + * 04-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 06-May-2004 : Now extends AbstractIntervalXYDataset and added other methods + * that return double primitives (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * 04-Feb-2009 : Deprecated the class (DG); + * + */ + +package org.jfree.data.general; + +import java.util.List; + +import org.jfree.data.xy.AbstractIntervalXYDataset; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.OHLCDataset; +import org.jfree.data.xy.XYDataset; + +/** + * This class can combine instances of {@link XYDataset}, {@link OHLCDataset} + * and {@link IntervalXYDataset} together exposing the union of all the series + * under one dataset. + * + * @deprecated As of version 1.0.13. This class will be removed from + * JFreeChart 1.2.0 onwards. Anyone needing this facility will need to + * maintain it outside of JFreeChart. + */ +public class CombinedDataset extends AbstractIntervalXYDataset + implements XYDataset, OHLCDataset, IntervalXYDataset, + CombinationDataset { + + /** Storage for the datasets we combine. */ + private List datasetInfo = new java.util.ArrayList(); + + /** + * Default constructor for an empty combination. + */ + public CombinedDataset() { + super(); + } + + /** + * Creates a CombinedDataset initialized with an array of SeriesDatasets. + * + * @param data array of SeriesDataset that contains the SeriesDatasets to + * combine. + */ + public CombinedDataset(SeriesDataset[] data) { + add(data); + } + + /** + * Adds one SeriesDataset to the combination. Listeners are notified of the + * change. + * + * @param data the SeriesDataset to add. + */ + public void add(SeriesDataset data) { + fastAdd(data); + DatasetChangeEvent event = new DatasetChangeEvent(this, this); + notifyListeners(event); + } + + /** + * Adds an array of SeriesDataset's to the combination. Listeners are + * notified of the change. + * + * @param data array of SeriesDataset to add + */ + public void add(SeriesDataset[] data) { + + for (int i = 0; i < data.length; i++) { + fastAdd(data[i]); + } + DatasetChangeEvent event = new DatasetChangeEvent(this, this); + notifyListeners(event); + + } + + /** + * Adds one series from a SeriesDataset to the combination. Listeners are + * notified of the change. + * + * @param data the SeriesDataset where series is contained + * @param series series to add + */ + public void add(SeriesDataset data, int series) { + add(new SubSeriesDataset(data, series)); + } + + /** + * Fast add of a SeriesDataset. Does not notify listeners of the change. + * + * @param data SeriesDataset to add + */ + private void fastAdd(SeriesDataset data) { + for (int i = 0; i < data.getSeriesCount(); i++) { + this.datasetInfo.add(new DatasetInfo(data, i)); + } + } + + /////////////////////////////////////////////////////////////////////////// + // From SeriesDataset + /////////////////////////////////////////////////////////////////////////// + + /** + * Returns the number of series in the dataset. + * + * @return The number of series in the dataset. + */ + @Override + public int getSeriesCount() { + return this.datasetInfo.size(); + } + + /** + * Returns the key for a series. + * + * @param series the series (zero-based index). + * + * @return The key for a series. + */ + @Override + public Comparable getSeriesKey(int series) { + DatasetInfo di = getDatasetInfo(series); + return di.data.getSeriesKey(di.series); + } + + /////////////////////////////////////////////////////////////////////////// + // From XYDataset + /////////////////////////////////////////////////////////////////////////// + + /** + * Returns the X-value for the specified series and item. + *

+ * Note: throws ClassCastException if the series is not from + * a {@link XYDataset}. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The X-value for the specified series and item. + */ + @Override + public Number getX(int series, int item) { + DatasetInfo di = getDatasetInfo(series); + return ((XYDataset) di.data).getX(di.series, item); + } + + /** + * Returns the Y-value for the specified series and item. + *

+ * Note: throws ClassCastException if the series is not from + * a {@link XYDataset}. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The Y-value for the specified series and item. + */ + @Override + public Number getY(int series, int item) { + DatasetInfo di = getDatasetInfo(series); + return ((XYDataset) di.data).getY(di.series, item); + } + + /** + * Returns the number of items in a series. + *

+ * Note: throws ClassCastException if the series is not from + * a {@link XYDataset}. + * + * @param series the index of the series of interest (zero-based). + * + * @return The number of items in a series. + */ + @Override + public int getItemCount(int series) { + DatasetInfo di = getDatasetInfo(series); + return ((XYDataset) di.data).getItemCount(di.series); + } + + /////////////////////////////////////////////////////////////////////////// + // From HighLowDataset + /////////////////////////////////////////////////////////////////////////// + + /** + * Returns the high-value for the specified series and item. + *

+ * Note: throws ClassCastException if the series is not from a + * {@link OHLCDataset}. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The high-value for the specified series and item. + */ + @Override + public Number getHigh(int series, int item) { + DatasetInfo di = getDatasetInfo(series); + return ((OHLCDataset) di.data).getHigh(di.series, item); + } + + /** + * Returns the high-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The high-value. + */ + @Override + public double getHighValue(int series, int item) { + double result = Double.NaN; + Number high = getHigh(series, item); + if (high != null) { + result = high.doubleValue(); + } + return result; + } + + /** + * Returns the low-value for the specified series and item. + *

+ * Note: throws ClassCastException if the series is not from a + * {@link OHLCDataset}. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The low-value for the specified series and item. + */ + @Override + public Number getLow(int series, int item) { + DatasetInfo di = getDatasetInfo(series); + return ((OHLCDataset) di.data).getLow(di.series, item); + } + + /** + * Returns the low-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The low-value. + */ + @Override + public double getLowValue(int series, int item) { + double result = Double.NaN; + Number low = getLow(series, item); + if (low != null) { + result = low.doubleValue(); + } + return result; + } + + /** + * Returns the open-value for the specified series and item. + *

+ * Note: throws ClassCastException if the series is not from a + * {@link OHLCDataset}. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The open-value for the specified series and item. + */ + @Override + public Number getOpen(int series, int item) { + DatasetInfo di = getDatasetInfo(series); + return ((OHLCDataset) di.data).getOpen(di.series, item); + } + + /** + * Returns the open-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The open-value. + */ + @Override + public double getOpenValue(int series, int item) { + double result = Double.NaN; + Number open = getOpen(series, item); + if (open != null) { + result = open.doubleValue(); + } + return result; + } + + /** + * Returns the close-value for the specified series and item. + *

+ * Note: throws ClassCastException if the series is not from a + * {@link OHLCDataset}. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The close-value for the specified series and item. + */ + @Override + public Number getClose(int series, int item) { + DatasetInfo di = getDatasetInfo(series); + return ((OHLCDataset) di.data).getClose(di.series, item); + } + + /** + * Returns the close-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The close-value. + */ + @Override + public double getCloseValue(int series, int item) { + double result = Double.NaN; + Number close = getClose(series, item); + if (close != null) { + result = close.doubleValue(); + } + return result; + } + + /** + * Returns the volume value for the specified series and item. + *

+ * Note: throws ClassCastException if the series is not from a + * {@link OHLCDataset}. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The volume value for the specified series and item. + */ + @Override + public Number getVolume(int series, int item) { + DatasetInfo di = getDatasetInfo(series); + return ((OHLCDataset) di.data).getVolume(di.series, item); + } + + /** + * Returns the volume-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The volume-value. + */ + @Override + public double getVolumeValue(int series, int item) { + double result = Double.NaN; + Number volume = getVolume(series, item); + if (volume != null) { + result = volume.doubleValue(); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////// + // From IntervalXYDataset + /////////////////////////////////////////////////////////////////////////// + + /** + * Returns the starting X value for the specified series and item. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The value. + */ + @Override + public Number getStartX(int series, int item) { + DatasetInfo di = getDatasetInfo(series); + if (di.data instanceof IntervalXYDataset) { + return ((IntervalXYDataset) di.data).getStartX(di.series, item); + } + else { + return getX(series, item); + } + } + + /** + * Returns the ending X value for the specified series and item. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The value. + */ + @Override + public Number getEndX(int series, int item) { + DatasetInfo di = getDatasetInfo(series); + if (di.data instanceof IntervalXYDataset) { + return ((IntervalXYDataset) di.data).getEndX(di.series, item); + } + else { + return getX(series, item); + } + } + + /** + * Returns the starting Y value for the specified series and item. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The starting Y value for the specified series and item. + */ + @Override + public Number getStartY(int series, int item) { + DatasetInfo di = getDatasetInfo(series); + if (di.data instanceof IntervalXYDataset) { + return ((IntervalXYDataset) di.data).getStartY(di.series, item); + } + else { + return getY(series, item); + } + } + + /** + * Returns the ending Y value for the specified series and item. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The ending Y value for the specified series and item. + */ + @Override + public Number getEndY(int series, int item) { + DatasetInfo di = getDatasetInfo(series); + if (di.data instanceof IntervalXYDataset) { + return ((IntervalXYDataset) di.data).getEndY(di.series, item); + } + else { + return getY(series, item); + } + } + + /////////////////////////////////////////////////////////////////////////// + // New methods from CombinationDataset + /////////////////////////////////////////////////////////////////////////// + + /** + * Returns the parent Dataset of this combination. If there is more than + * one parent, or a child is found that is not a CombinationDataset, then + * returns null. + * + * @return The parent Dataset of this combination or null. + */ + @Override + public SeriesDataset getParent() { + + SeriesDataset parent = null; + for (int i = 0; i < this.datasetInfo.size(); i++) { + SeriesDataset child = getDatasetInfo(i).data; + if (child instanceof CombinationDataset) { + SeriesDataset childParent + = ((CombinationDataset) child).getParent(); + if (parent == null) { + parent = childParent; + } + else if (parent != childParent) { + return null; + } + } + else { + return null; + } + } + return parent; + + } + + /** + * Returns a map or indirect indexing form our series into parent's series. + * Prior to calling this method, the client should check getParent() to make + * sure the CombinationDataset uses the same parent. If not, the map + * returned by this method will be invalid or null. + * + * @return A map or indirect indexing form our series into parent's series. + * + * @see #getParent() + */ + @Override + public int[] getMap() { + + int[] map = null; + for (int i = 0; i < this.datasetInfo.size(); i++) { + SeriesDataset child = getDatasetInfo(i).data; + if (child instanceof CombinationDataset) { + int[] childMap = ((CombinationDataset) child).getMap(); + if (childMap == null) { + return null; + } + map = joinMap(map, childMap); + } + else { + return null; + } + } + return map; + } + + /////////////////////////////////////////////////////////////////////////// + // New Methods + /////////////////////////////////////////////////////////////////////////// + + /** + * Returns the child position. + * + * @param child the child dataset. + * + * @return The position. + */ + public int getChildPosition(Dataset child) { + + int n = 0; + for (int i = 0; i < this.datasetInfo.size(); i++) { + SeriesDataset childDataset = getDatasetInfo(i).data; + if (childDataset instanceof CombinedDataset) { + int m = ((CombinedDataset) childDataset) + .getChildPosition(child); + if (m >= 0) { + return n + m; + } + n++; + } + else { + if (child == childDataset) { + return n; + } + n++; + } + } + return -1; + } + + /////////////////////////////////////////////////////////////////////////// + // Private + /////////////////////////////////////////////////////////////////////////// + + /** + * Returns the DatasetInfo object associated with the series. + * + * @param series the index of the series. + * + * @return The DatasetInfo object associated with the series. + */ + private DatasetInfo getDatasetInfo(int series) { + return (DatasetInfo) this.datasetInfo.get(series); + } + + /** + * Joins two map arrays (int[]) together. + * + * @param a the first array. + * @param b the second array. + * + * @return A copy of { a[], b[] }. + */ + private int[] joinMap(int[] a, int[] b) { + if (a == null) { + return b; + } + if (b == null) { + return a; + } + int[] result = new int[a.length + b.length]; + System.arraycopy(a, 0, result, 0, a.length); + System.arraycopy(b, 0, result, a.length, b.length); + return result; + } + + /** + * Private class to store as pairs (SeriesDataset, series) for all combined + * series. + */ + private class DatasetInfo { + + /** The dataset. */ + private SeriesDataset data; + + /** The series. */ + private int series; + + /** + * Creates a new dataset info record. + * + * @param data the dataset. + * @param series the series. + */ + DatasetInfo(SeriesDataset data, int series) { + this.data = data; + this.series = series; + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/Dataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/Dataset.java new file mode 100755 index 0000000..3823dd2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/Dataset.java @@ -0,0 +1,93 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------ + * Dataset.java + * ------------ + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 18-Sep-2001) + * -------------------------- + * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); + * 15-Oct-2001 : Moved to a new package (com.jrefinery.data.*) (DG); + * 22-Oct-2001 : Changed name to Dataset.java (DG); + * 17-Nov-2001 : Added getLegendItemCount() and getLegendItemLabels() methods, + * created SeriesDataset interface and transferred series related + * methods out (DG); + * 22-Jan-2002 : Reconsidered (and removed) the getLegendItemCount() and + * getLegendItemLabels() methods...leave this to client code (DG); + * 27-Sep-2002 : Added get/setDatasetGroup() methods (DG); + * 10-Jan-2003 : Updated Javadocs (DG); + * + */ + +package org.jfree.data.general; + +/** + * The base interface for data sets. + *

+ * All datasets are required to support the {@link DatasetChangeEvent} + * mechanism by allowing listeners to register and receive notification of any + * changes to the dataset. + *

+ * In addition, all datasets must belong to one (and only one) + * {@link DatasetGroup}. The group object maintains a reader-writer lock + * which provides synchronised access to the datasets in multi-threaded code. + */ +public interface Dataset { + + /** + * Registers an object for notification of changes to the dataset. + * + * @param listener the object to register. + */ + public void addChangeListener(DatasetChangeListener listener); + + /** + * Deregisters an object for notification of changes to the dataset. + * + * @param listener the object to deregister. + */ + public void removeChangeListener(DatasetChangeListener listener); + + /** + * Returns the dataset group. + * + * @return The dataset group. + */ + public DatasetGroup getGroup(); + + /** + * Sets the dataset group. + * + * @param group the dataset group. + */ + public void setGroup(DatasetGroup group); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DatasetChangeEvent.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DatasetChangeEvent.java new file mode 100755 index 0000000..5567ebc --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DatasetChangeEvent.java @@ -0,0 +1,86 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * DatasetChangeEvent.java + * ----------------------- + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 24-Aug-2001) + * -------------------------- + * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); + * 15-Oct-2001 : Move to new package (com.jrefinery.data.*) (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * 11-Jun-2002 : Separated the event source from the dataset to cover the case + * where the dataset is changed to null in the Plot class. + * Updated Javadocs (DG); + * 04-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 05-Oct-2004 : Minor Javadoc updates (DG); + * + */ + +package org.jfree.data.general; + +/** + * A change event that encapsulates information about a change to a dataset. + */ +public class DatasetChangeEvent extends java.util.EventObject { + + /** + * The dataset that generated the change event. + */ + private Dataset dataset; + + /** + * Constructs a new event. The source is either the dataset or the + * {@link org.jfree.chart.plot.Plot} class. The dataset can be + * null (in this case the source will be the + * {@link org.jfree.chart.plot.Plot} class). + * + * @param source the source of the event. + * @param dataset the dataset that generated the event (null + * permitted). + */ + public DatasetChangeEvent(Object source, Dataset dataset) { + super(source); + this.dataset = dataset; + } + + /** + * Returns the dataset that generated the event. Note that the dataset + * may be null since adding a null dataset to a + * plot will generated a change event. + * + * @return The dataset (possibly null). + */ + public Dataset getDataset() { + return this.dataset; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DatasetChangeListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DatasetChangeListener.java new file mode 100755 index 0000000..4775423 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DatasetChangeListener.java @@ -0,0 +1,62 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * DatasetChangeListener.java + * -------------------------- + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 24-Aug-2001) + * -------------------------- + * 24-Aug-2001 : Added standard source header. Fixed DOS encoding problem (DG); + * 15-Oct-2001 : Moved to new package (com.jrefinery.data.*) (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * 07-Aug-2002 : Now extends EventListener (DG); + * 04-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * + */ + +package org.jfree.data.general; + +import java.util.EventListener; + +/** + * The interface that must be supported by classes that wish to receive + * notification of changes to a dataset. + */ +public interface DatasetChangeListener extends EventListener { + + /** + * Receives notification of an dataset change event. + * + * @param event information about the event. + */ + public void datasetChanged(DatasetChangeEvent event); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DatasetGroup.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DatasetGroup.java new file mode 100755 index 0000000..089a2cd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DatasetGroup.java @@ -0,0 +1,122 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * DatasetGroup.java + * ----------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 07-Oct-2002 : Version 1 (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 20-Aug-2003 : Implemented Cloneable (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.general; + +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +/** + * A class that is used to group datasets (currently not used for any specific + * purpose). + */ +public class DatasetGroup implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -3640642179674185688L; + + /** The group id. */ + private String id; + + /** + * Constructs a new group. + */ + public DatasetGroup() { + super(); + this.id = "NOID"; + } + + /** + * Creates a new group with the specified id. + * + * @param id the identification for the group. + */ + public DatasetGroup(String id) { + ParamChecks.nullNotPermitted(id, "id"); + this.id = id; + } + + /** + * Returns the identification string for this group. + * + * @return The identification string. + */ + public String getID() { + return this.id; + } + + /** + * Clones the group. + * + * @return A clone. + * + * @throws CloneNotSupportedException not by this class. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DatasetGroup)) { + return false; + } + DatasetGroup that = (DatasetGroup) obj; + if (!this.id.equals(that.id)) { + return false; + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DatasetUtilities.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DatasetUtilities.java new file mode 100755 index 0000000..590516c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DatasetUtilities.java @@ -0,0 +1,2404 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * DatasetUtilities.java + * --------------------- + * (C) Copyright 2000-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Andrzej Porebski (bug fix); + * Jonathan Nash (bug fix); + * Richard Atkinson; + * Andreas Schroeder; + * Rafal Skalny (patch 1925366); + * Jerome David (patch 2131001); + * Peter Kolb (patch 2791407); + * Martin Hoeller (patch 2952086); + * + * Changes (from 18-Sep-2001) + * -------------------------- + * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * 15-Nov-2001 : Moved to package com.jrefinery.data.* in the JCommon class + * library (DG); + * Changed to handle null values from datasets (DG); + * Bug fix (thanks to Andrzej Porebski) - initial value now set + * to positive or negative infinity when iterating (DG); + * 22-Nov-2001 : Datasets with containing no data now return null for min and + * max calculations (DG); + * 13-Dec-2001 : Extended to handle HighLowDataset and IntervalXYDataset (DG); + * 15-Feb-2002 : Added getMinimumStackedRangeValue() and + * getMaximumStackedRangeValue() (DG); + * 28-Feb-2002 : Renamed Datasets.java --> DatasetUtilities.java (DG); + * 18-Mar-2002 : Fixed bug in min/max domain calculation for datasets that + * implement the CategoryDataset interface AND the XYDataset + * interface at the same time. Thanks to Jonathan Nash for the + * fix (DG); + * 23-Apr-2002 : Added getDomainExtent() and getRangeExtent() methods (DG); + * 13-Jun-2002 : Modified range measurements to handle + * IntervalCategoryDataset (DG); + * 12-Jul-2002 : Method name change in DomainInfo interface (DG); + * 30-Jul-2002 : Added pie dataset summation method (DG); + * 01-Oct-2002 : Added a method for constructing an XYDataset from a Function2D + * instance (DG); + * 24-Oct-2002 : Amendments required following changes to the CategoryDataset + * interface (DG); + * 18-Nov-2002 : Changed CategoryDataset to TableDataset (DG); + * 04-Mar-2003 : Added isEmpty(XYDataset) method (DG); + * 05-Mar-2003 : Added a method for creating a CategoryDataset from a + * KeyedValues instance (DG); + * 15-May-2003 : Renamed isEmpty --> isEmptyOrNull (DG); + * 25-Jun-2003 : Added limitPieDataset methods (RA); + * 26-Jun-2003 : Modified getDomainExtent() method to accept null datasets (DG); + * 27-Jul-2003 : Added getStackedRangeExtent(TableXYDataset data) (RA); + * 18-Aug-2003 : getStackedRangeExtent(TableXYDataset data) now handles null + * values (RA); + * 02-Sep-2003 : Added method to check for null or empty PieDataset (DG); + * 18-Sep-2003 : Fix for bug 803660 (getMaximumRangeValue for + * CategoryDataset) (DG); + * 20-Oct-2003 : Added getCumulativeRangeExtent() method (DG); + * 09-Jan-2003 : Added argument checking code to the createCategoryDataset() + * method (DG); + * 23-Mar-2004 : Fixed bug in getMaximumStackedRangeValue() method (DG); + * 31-Mar-2004 : Exposed the extent iteration algorithms to use one of them and + * applied noninstantiation pattern (AS); + * 11-May-2004 : Renamed getPieDatasetTotal --> calculatePieDatasetTotal (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with getYValue(); + * 24-Aug-2004 : Added argument checks to createCategoryDataset() method (DG); + * 04-Oct-2004 : Renamed ArrayUtils --> ArrayUtilities (DG); + * 06-Oct-2004 : Renamed findDomainExtent() --> findDomainBounds(), + * findRangeExtent() --> findRangeBounds() (DG); + * 07-Jan-2005 : Renamed findStackedRangeExtent() --> findStackedRangeBounds(), + * findCumulativeRangeExtent() --> findCumulativeRangeBounds(), + * iterateXYRangeExtent() --> iterateXYRangeBounds(), + * removed deprecated methods (DG); + * 03-Feb-2005 : The findStackedRangeBounds() methods now return null for + * empty datasets (DG); + * 03-Mar-2005 : Moved createNumberArray() and createNumberArray2D() methods + * from DatasetUtilities --> DataUtilities (DG); + * 22-Sep-2005 : Added new findStackedRangeBounds() method that takes base + * argument (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 15-Mar-2007 : Added calculateStackTotal() method (DG); + * 27-Mar-2008 : Fixed bug in findCumulativeRangeBounds() method (DG); + * 28-Mar-2008 : Fixed sample count in sampleFunction2D() method, renamed + * iterateXYRangeBounds() --> iterateRangeBounds(XYDataset), and + * fixed a bug in findRangeBounds(XYDataset, false) (DG); + * 28-Mar-2008 : Applied a variation of patch 1925366 (from Rafal Skalny) for + * slightly more efficient iterateRangeBounds() methods (DG); + * 08-Apr-2008 : Fixed typo in iterateRangeBounds() (DG); + * 08-Oct-2008 : Applied patch 2131001 by Jerome David, with some modifications + * and additions and some new unit tests (DG); + * 12-Feb-2009 : Added sampleFunction2DToSeries() method (DG); + * 27-Mar-2009 : Added new methods to find domain and range bounds taking into + * account hidden series (DG); + * 01-Apr-2009 : Handle a StatisticalCategoryDataset in + * iterateToFindRangeBounds() (DG); + * 16-May-2009 : Patch 2791407 - fix iterateToFindRangeBounds for + * MultiValueCategoryDataset (PK); + * 10-Sep-2009 : Fix bug 2849731 for IntervalCategoryDataset (DG); + * 16-Feb-2010 : Patch 2952086 - find z-bounds (MH); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.general; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.DomainInfo; +import org.jfree.data.DomainOrder; +import org.jfree.data.KeyToGroupMap; +import org.jfree.data.KeyedValues; +import org.jfree.data.Range; +import org.jfree.data.RangeInfo; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.CategoryRangeInfo; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.data.category.IntervalCategoryDataset; +import org.jfree.data.function.Function2D; +import org.jfree.data.statistics.BoxAndWhiskerCategoryDataset; +import org.jfree.data.statistics.BoxAndWhiskerXYDataset; +import org.jfree.data.statistics.MultiValueCategoryDataset; +import org.jfree.data.statistics.StatisticalCategoryDataset; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.OHLCDataset; +import org.jfree.data.xy.TableXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYDomainInfo; +import org.jfree.data.xy.XYRangeInfo; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.data.xy.XYZDataset; +import org.jfree.util.ArrayUtilities; + +/** + * A collection of useful static methods relating to datasets. + */ +public final class DatasetUtilities { + + /** + * Private constructor for non-instanceability. + */ + private DatasetUtilities() { + // now try to instantiate this ;-) + } + + /** + * Calculates the total of all the values in a {@link PieDataset}. If + * the dataset contains negative or null values, they are + * ignored. + * + * @param dataset the dataset (null not permitted). + * + * @return The total. + */ + public static double calculatePieDatasetTotal(PieDataset dataset) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + List keys = dataset.getKeys(); + double totalValue = 0; + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Comparable current = (Comparable) iterator.next(); + if (current != null) { + Number value = dataset.getValue(current); + double v = 0.0; + if (value != null) { + v = value.doubleValue(); + } + if (v > 0) { + totalValue = totalValue + v; + } + } + } + return totalValue; + } + + /** + * Creates a pie dataset from a table dataset by taking all the values + * for a single row. + * + * @param dataset the dataset (null not permitted). + * @param rowKey the row key. + * + * @return A pie dataset. + */ + public static PieDataset createPieDatasetForRow(CategoryDataset dataset, + Comparable rowKey) { + int row = dataset.getRowIndex(rowKey); + return createPieDatasetForRow(dataset, row); + } + + /** + * Creates a pie dataset from a table dataset by taking all the values + * for a single row. + * + * @param dataset the dataset (null not permitted). + * @param row the row (zero-based index). + * + * @return A pie dataset. + */ + public static PieDataset createPieDatasetForRow(CategoryDataset dataset, + int row) { + DefaultPieDataset result = new DefaultPieDataset(); + int columnCount = dataset.getColumnCount(); + for (int current = 0; current < columnCount; current++) { + Comparable columnKey = dataset.getColumnKey(current); + result.setValue(columnKey, dataset.getValue(row, current)); + } + return result; + } + + /** + * Creates a pie dataset from a table dataset by taking all the values + * for a single column. + * + * @param dataset the dataset (null not permitted). + * @param columnKey the column key. + * + * @return A pie dataset. + */ + public static PieDataset createPieDatasetForColumn(CategoryDataset dataset, + Comparable columnKey) { + int column = dataset.getColumnIndex(columnKey); + return createPieDatasetForColumn(dataset, column); + } + + /** + * Creates a pie dataset from a {@link CategoryDataset} by taking all the + * values for a single column. + * + * @param dataset the dataset (null not permitted). + * @param column the column (zero-based index). + * + * @return A pie dataset. + */ + public static PieDataset createPieDatasetForColumn(CategoryDataset dataset, + int column) { + DefaultPieDataset result = new DefaultPieDataset(); + int rowCount = dataset.getRowCount(); + for (int i = 0; i < rowCount; i++) { + Comparable rowKey = dataset.getRowKey(i); + result.setValue(rowKey, dataset.getValue(i, column)); + } + return result; + } + + /** + * Creates a new pie dataset based on the supplied dataset, but modified + * by aggregating all the low value items (those whose value is lower + * than the percentThreshold) into a single item with the + * key "Other". + * + * @param source the source dataset (null not permitted). + * @param key a new key for the aggregated items (null not + * permitted). + * @param minimumPercent the percent threshold. + * + * @return The pie dataset with (possibly) aggregated items. + */ + public static PieDataset createConsolidatedPieDataset(PieDataset source, + Comparable key, double minimumPercent) { + return DatasetUtilities.createConsolidatedPieDataset(source, key, + minimumPercent, 2); + } + + /** + * Creates a new pie dataset based on the supplied dataset, but modified + * by aggregating all the low value items (those whose value is lower + * than the percentThreshold) into a single item. The + * aggregated items are assigned the specified key. Aggregation only + * occurs if there are at least minItems items to aggregate. + * + * @param source the source dataset (null not permitted). + * @param key the key to represent the aggregated items. + * @param minimumPercent the percent threshold (ten percent is 0.10). + * @param minItems only aggregate low values if there are at least this + * many. + * + * @return The pie dataset with (possibly) aggregated items. + */ + public static PieDataset createConsolidatedPieDataset(PieDataset source, + Comparable key, double minimumPercent, int minItems) { + + DefaultPieDataset result = new DefaultPieDataset(); + double total = DatasetUtilities.calculatePieDatasetTotal(source); + + // Iterate and find all keys below threshold percentThreshold + List keys = source.getKeys(); + ArrayList otherKeys = new ArrayList(); + Iterator iterator = keys.iterator(); + while (iterator.hasNext()) { + Comparable currentKey = (Comparable) iterator.next(); + Number dataValue = source.getValue(currentKey); + if (dataValue != null) { + double value = dataValue.doubleValue(); + if (value / total < minimumPercent) { + otherKeys.add(currentKey); + } + } + } + + // Create new dataset with keys above threshold percentThreshold + iterator = keys.iterator(); + double otherValue = 0; + while (iterator.hasNext()) { + Comparable currentKey = (Comparable) iterator.next(); + Number dataValue = source.getValue(currentKey); + if (dataValue != null) { + if (otherKeys.contains(currentKey) + && otherKeys.size() >= minItems) { + // Do not add key to dataset + otherValue += dataValue.doubleValue(); + } + else { + // Add key to dataset + result.setValue(currentKey, dataValue); + } + } + } + // Add other category if applicable + if (otherKeys.size() >= minItems) { + result.setValue(key, otherValue); + } + return result; + } + + /** + * Creates a {@link CategoryDataset} that contains a copy of the data in an + * array (instances of Double are created to represent the + * data items). + *

+ * Row and column keys are created by appending 0, 1, 2, ... to the + * supplied prefixes. + * + * @param rowKeyPrefix the row key prefix. + * @param columnKeyPrefix the column key prefix. + * @param data the data. + * + * @return The dataset. + */ + public static CategoryDataset createCategoryDataset(String rowKeyPrefix, + String columnKeyPrefix, double[][] data) { + + DefaultCategoryDataset result = new DefaultCategoryDataset(); + for (int r = 0; r < data.length; r++) { + String rowKey = rowKeyPrefix + (r + 1); + for (int c = 0; c < data[r].length; c++) { + String columnKey = columnKeyPrefix + (c + 1); + result.addValue(new Double(data[r][c]), rowKey, columnKey); + } + } + return result; + + } + + /** + * Creates a {@link CategoryDataset} that contains a copy of the data in + * an array. + *

+ * Row and column keys are created by appending 0, 1, 2, ... to the + * supplied prefixes. + * + * @param rowKeyPrefix the row key prefix. + * @param columnKeyPrefix the column key prefix. + * @param data the data. + * + * @return The dataset. + */ + public static CategoryDataset createCategoryDataset(String rowKeyPrefix, + String columnKeyPrefix, Number[][] data) { + + DefaultCategoryDataset result = new DefaultCategoryDataset(); + for (int r = 0; r < data.length; r++) { + String rowKey = rowKeyPrefix + (r + 1); + for (int c = 0; c < data[r].length; c++) { + String columnKey = columnKeyPrefix + (c + 1); + result.addValue(data[r][c], rowKey, columnKey); + } + } + return result; + + } + + /** + * Creates a {@link CategoryDataset} that contains a copy of the data in + * an array (instances of Double are created to represent the + * data items). + *

+ * Row and column keys are taken from the supplied arrays. + * + * @param rowKeys the row keys (null not permitted). + * @param columnKeys the column keys (null not permitted). + * @param data the data. + * + * @return The dataset. + */ + public static CategoryDataset createCategoryDataset(Comparable[] rowKeys, + Comparable[] columnKeys, double[][] data) { + + ParamChecks.nullNotPermitted(rowKeys, "rowKeys"); + ParamChecks.nullNotPermitted(columnKeys, "columnKeys"); + if (ArrayUtilities.hasDuplicateItems(rowKeys)) { + throw new IllegalArgumentException("Duplicate items in 'rowKeys'."); + } + if (ArrayUtilities.hasDuplicateItems(columnKeys)) { + throw new IllegalArgumentException( + "Duplicate items in 'columnKeys'."); + } + if (rowKeys.length != data.length) { + throw new IllegalArgumentException( + "The number of row keys does not match the number of rows in " + + "the data array."); + } + int columnCount = 0; + for (int r = 0; r < data.length; r++) { + columnCount = Math.max(columnCount, data[r].length); + } + if (columnKeys.length != columnCount) { + throw new IllegalArgumentException( + "The number of column keys does not match the number of " + + "columns in the data array."); + } + + // now do the work... + DefaultCategoryDataset result = new DefaultCategoryDataset(); + for (int r = 0; r < data.length; r++) { + Comparable rowKey = rowKeys[r]; + for (int c = 0; c < data[r].length; c++) { + Comparable columnKey = columnKeys[c]; + result.addValue(new Double(data[r][c]), rowKey, columnKey); + } + } + return result; + + } + + /** + * Creates a {@link CategoryDataset} by copying the data from the supplied + * {@link KeyedValues} instance. + * + * @param rowKey the row key (null not permitted). + * @param rowData the row data (null not permitted). + * + * @return A dataset. + */ + public static CategoryDataset createCategoryDataset(Comparable rowKey, + KeyedValues rowData) { + + ParamChecks.nullNotPermitted(rowKey, "rowKey"); + ParamChecks.nullNotPermitted(rowData, "rowData"); + DefaultCategoryDataset result = new DefaultCategoryDataset(); + for (int i = 0; i < rowData.getItemCount(); i++) { + result.addValue(rowData.getValue(i), rowKey, rowData.getKey(i)); + } + return result; + + } + + /** + * Creates an {@link XYDataset} by sampling the specified function over a + * fixed range. + * + * @param f the function (null not permitted). + * @param start the start value for the range. + * @param end the end value for the range. + * @param samples the number of sample points (must be > 1). + * @param seriesKey the key to give the resulting series + * (null not permitted). + * + * @return A dataset. + */ + public static XYDataset sampleFunction2D(Function2D f, double start, + double end, int samples, Comparable seriesKey) { + + // defer argument checking + XYSeries series = sampleFunction2DToSeries(f, start, end, samples, + seriesKey); + XYSeriesCollection collection = new XYSeriesCollection(series); + return collection; + } + + /** + * Creates an {@link XYSeries} by sampling the specified function over a + * fixed range. + * + * @param f the function (null not permitted). + * @param start the start value for the range. + * @param end the end value for the range. + * @param samples the number of sample points (must be > 1). + * @param seriesKey the key to give the resulting series + * (null not permitted). + * + * @return A series. + * + * @since 1.0.13 + */ + public static XYSeries sampleFunction2DToSeries(Function2D f, + double start, double end, int samples, Comparable seriesKey) { + + ParamChecks.nullNotPermitted(f, "f"); + ParamChecks.nullNotPermitted(seriesKey, "seriesKey"); + if (start >= end) { + throw new IllegalArgumentException("Requires 'start' < 'end'."); + } + if (samples < 2) { + throw new IllegalArgumentException("Requires 'samples' > 1"); + } + + XYSeries series = new XYSeries(seriesKey); + double step = (end - start) / (samples - 1); + for (int i = 0; i < samples; i++) { + double x = start + (step * i); + series.add(x, f.getValue(x)); + } + return series; + } + + /** + * Returns true if the dataset is empty (or null), + * and false otherwise. + * + * @param dataset the dataset (null permitted). + * + * @return A boolean. + */ + public static boolean isEmptyOrNull(PieDataset dataset) { + + if (dataset == null) { + return true; + } + + int itemCount = dataset.getItemCount(); + if (itemCount == 0) { + return true; + } + + for (int item = 0; item < itemCount; item++) { + Number y = dataset.getValue(item); + if (y != null) { + double yy = y.doubleValue(); + if (yy > 0.0) { + return false; + } + } + } + + return true; + + } + + /** + * Returns true if the dataset is empty (or null), + * and false otherwise. + * + * @param dataset the dataset (null permitted). + * + * @return A boolean. + */ + public static boolean isEmptyOrNull(CategoryDataset dataset) { + + if (dataset == null) { + return true; + } + + int rowCount = dataset.getRowCount(); + int columnCount = dataset.getColumnCount(); + if (rowCount == 0 || columnCount == 0) { + return true; + } + + for (int r = 0; r < rowCount; r++) { + for (int c = 0; c < columnCount; c++) { + if (dataset.getValue(r, c) != null) { + return false; + } + + } + } + + return true; + + } + + /** + * Returns true if the dataset is empty (or null), + * and false otherwise. + * + * @param dataset the dataset (null permitted). + * + * @return A boolean. + */ + public static boolean isEmptyOrNull(XYDataset dataset) { + if (dataset != null) { + for (int s = 0; s < dataset.getSeriesCount(); s++) { + if (dataset.getItemCount(s) > 0) { + return false; + } + } + } + return true; + } + + /** + * Returns the range of values in the domain (x-values) of a dataset. + * + * @param dataset the dataset (null not permitted). + * + * @return The range of values (possibly null). + */ + public static Range findDomainBounds(XYDataset dataset) { + return findDomainBounds(dataset, true); + } + + /** + * Returns the range of values in the domain (x-values) of a dataset. + * + * @param dataset the dataset (null not permitted). + * @param includeInterval determines whether or not the x-interval is taken + * into account (only applies if the dataset is an + * {@link IntervalXYDataset}). + * + * @return The range of values (possibly null). + */ + public static Range findDomainBounds(XYDataset dataset, + boolean includeInterval) { + + ParamChecks.nullNotPermitted(dataset, "dataset"); + + Range result; + // if the dataset implements DomainInfo, life is easier + if (dataset instanceof DomainInfo) { + DomainInfo info = (DomainInfo) dataset; + result = info.getDomainBounds(includeInterval); + } + else { + result = iterateDomainBounds(dataset, includeInterval); + } + return result; + + } + + /** + * Returns the bounds of the x-values in the specified dataset + * taking into account only the visible series and including any x-interval + * if requested. + * + * @param dataset the dataset (null not permitted). + * @param visibleSeriesKeys the visible series keys (null + * not permitted). + * @param includeInterval include the x-interval (if any)? + * + * @return The bounds (or null if the dataset contains no + * values. + * + * @since 1.0.13 + */ + public static Range findDomainBounds(XYDataset dataset, + List visibleSeriesKeys, boolean includeInterval) { + + ParamChecks.nullNotPermitted(dataset, "dataset"); + Range result; + if (dataset instanceof XYDomainInfo) { + XYDomainInfo info = (XYDomainInfo) dataset; + result = info.getDomainBounds(visibleSeriesKeys, includeInterval); + } + else { + result = iterateToFindDomainBounds(dataset, visibleSeriesKeys, + includeInterval); + } + return result; + } + + /** + * Iterates over the items in an {@link XYDataset} to find + * the range of x-values. If the dataset is an instance of + * {@link IntervalXYDataset}, the starting and ending x-values + * will be used for the bounds calculation. + * + * @param dataset the dataset (null not permitted). + * + * @return The range (possibly null). + */ + public static Range iterateDomainBounds(XYDataset dataset) { + return iterateDomainBounds(dataset, true); + } + + /** + * Iterates over the items in an {@link XYDataset} to find + * the range of x-values. + * + * @param dataset the dataset (null not permitted). + * @param includeInterval a flag that determines, for an + * {@link IntervalXYDataset}, whether the x-interval or just the + * x-value is used to determine the overall range. + * + * @return The range (possibly null). + */ + public static Range iterateDomainBounds(XYDataset dataset, + boolean includeInterval) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + double minimum = Double.POSITIVE_INFINITY; + double maximum = Double.NEGATIVE_INFINITY; + int seriesCount = dataset.getSeriesCount(); + double lvalue, uvalue; + if (includeInterval && dataset instanceof IntervalXYDataset) { + IntervalXYDataset intervalXYData = (IntervalXYDataset) dataset; + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double value = intervalXYData.getXValue(series, item); + lvalue = intervalXYData.getStartXValue(series, item); + uvalue = intervalXYData.getEndXValue(series, item); + if (!Double.isNaN(value)) { + minimum = Math.min(minimum, value); + maximum = Math.max(maximum, value); + } + if (!Double.isNaN(lvalue)) { + minimum = Math.min(minimum, lvalue); + maximum = Math.max(maximum, lvalue); + } + if (!Double.isNaN(uvalue)) { + minimum = Math.min(minimum, uvalue); + maximum = Math.max(maximum, uvalue); + } + } + } + } + else { + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + lvalue = dataset.getXValue(series, item); + uvalue = lvalue; + if (!Double.isNaN(lvalue)) { + minimum = Math.min(minimum, lvalue); + maximum = Math.max(maximum, uvalue); + } + } + } + } + if (minimum > maximum) { + return null; + } + else { + return new Range(minimum, maximum); + } + } + + /** + * Returns the range of values in the range for the dataset. + * + * @param dataset the dataset (null not permitted). + * + * @return The range (possibly null). + */ + public static Range findRangeBounds(CategoryDataset dataset) { + return findRangeBounds(dataset, true); + } + + /** + * Returns the range of values in the range for the dataset. + * + * @param dataset the dataset (null not permitted). + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The range (possibly null). + */ + public static Range findRangeBounds(CategoryDataset dataset, + boolean includeInterval) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + Range result; + if (dataset instanceof RangeInfo) { + RangeInfo info = (RangeInfo) dataset; + result = info.getRangeBounds(includeInterval); + } + else { + result = iterateRangeBounds(dataset, includeInterval); + } + return result; + } + + /** + * Finds the bounds of the y-values in the specified dataset, including + * only those series that are listed in visibleSeriesKeys. + * + * @param dataset the dataset (null not permitted). + * @param visibleSeriesKeys the keys for the visible series + * (null not permitted). + * @param includeInterval include the y-interval (if the dataset has a + * y-interval). + * + * @return The data bounds. + * + * @since 1.0.13 + */ + public static Range findRangeBounds(CategoryDataset dataset, + List visibleSeriesKeys, boolean includeInterval) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + Range result; + if (dataset instanceof CategoryRangeInfo) { + CategoryRangeInfo info = (CategoryRangeInfo) dataset; + result = info.getRangeBounds(visibleSeriesKeys, includeInterval); + } + else { + result = iterateToFindRangeBounds(dataset, visibleSeriesKeys, + includeInterval); + } + return result; + } + + /** + * Returns the range of values in the range for the dataset. This method + * is the partner for the {@link #findDomainBounds(XYDataset)} method. + * + * @param dataset the dataset (null not permitted). + * + * @return The range (possibly null). + */ + public static Range findRangeBounds(XYDataset dataset) { + return findRangeBounds(dataset, true); + } + + /** + * Returns the range of values in the range for the dataset. This method + * is the partner for the {@link #findDomainBounds(XYDataset, boolean)} + * method. + * + * @param dataset the dataset (null not permitted). + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The range (possibly null). + */ + public static Range findRangeBounds(XYDataset dataset, + boolean includeInterval) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + Range result; + if (dataset instanceof RangeInfo) { + RangeInfo info = (RangeInfo) dataset; + result = info.getRangeBounds(includeInterval); + } + else { + result = iterateRangeBounds(dataset, includeInterval); + } + return result; + } + + /** + * Finds the bounds of the y-values in the specified dataset, including + * only those series that are listed in visibleSeriesKeys, and those items + * whose x-values fall within the specified range. + * + * @param dataset the dataset (null not permitted). + * @param visibleSeriesKeys the keys for the visible series + * (null not permitted). + * @param xRange the x-range (null not permitted). + * @param includeInterval include the y-interval (if the dataset has a + * y-interval). + * + * @return The data bounds. + * + * @since 1.0.13 + */ + public static Range findRangeBounds(XYDataset dataset, + List visibleSeriesKeys, Range xRange, boolean includeInterval) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + Range result; + if (dataset instanceof XYRangeInfo) { + XYRangeInfo info = (XYRangeInfo) dataset; + result = info.getRangeBounds(visibleSeriesKeys, xRange, + includeInterval); + } + else { + result = iterateToFindRangeBounds(dataset, visibleSeriesKeys, + xRange, includeInterval); + } + return result; + } + + /** + * Iterates over the data item of the category dataset to find + * the range bounds. + * + * @param dataset the dataset (null not permitted). + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The range (possibly null). + * + * @deprecated As of 1.0.10, use + * {@link #iterateRangeBounds(CategoryDataset, boolean)}. + */ + public static Range iterateCategoryRangeBounds(CategoryDataset dataset, + boolean includeInterval) { + return iterateRangeBounds(dataset, includeInterval); + } + + /** + * Iterates over the data item of the category dataset to find + * the range bounds. + * + * @param dataset the dataset (null not permitted). + * + * @return The range (possibly null). + * + * @since 1.0.10 + */ + public static Range iterateRangeBounds(CategoryDataset dataset) { + return iterateRangeBounds(dataset, true); + } + + /** + * Iterates over the data item of the category dataset to find + * the range bounds. + * + * @param dataset the dataset (null not permitted). + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The range (possibly null). + * + * @since 1.0.10 + */ + public static Range iterateRangeBounds(CategoryDataset dataset, + boolean includeInterval) { + double minimum = Double.POSITIVE_INFINITY; + double maximum = Double.NEGATIVE_INFINITY; + int rowCount = dataset.getRowCount(); + int columnCount = dataset.getColumnCount(); + if (includeInterval && dataset instanceof IntervalCategoryDataset) { + // handle the special case where the dataset has y-intervals that + // we want to measure + IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; + Number value, lvalue, uvalue; + for (int row = 0; row < rowCount; row++) { + for (int column = 0; column < columnCount; column++) { + value = icd.getValue(row, column); + double v; + if ((value != null) + && !Double.isNaN(v = value.doubleValue())) { + minimum = Math.min(v, minimum); + maximum = Math.max(v, maximum); + } + lvalue = icd.getStartValue(row, column); + if (lvalue != null + && !Double.isNaN(v = lvalue.doubleValue())) { + minimum = Math.min(v, minimum); + maximum = Math.max(v, maximum); + } + uvalue = icd.getEndValue(row, column); + if (uvalue != null + && !Double.isNaN(v = uvalue.doubleValue())) { + minimum = Math.min(v, minimum); + maximum = Math.max(v, maximum); + } + } + } + } + else { + // handle the standard case (plain CategoryDataset) + for (int row = 0; row < rowCount; row++) { + for (int column = 0; column < columnCount; column++) { + Number value = dataset.getValue(row, column); + if (value != null) { + double v = value.doubleValue(); + if (!Double.isNaN(v)) { + minimum = Math.min(minimum, v); + maximum = Math.max(maximum, v); + } + } + } + } + } + if (minimum == Double.POSITIVE_INFINITY) { + return null; + } + else { + return new Range(minimum, maximum); + } + } + + /** + * Iterates over the data item of the category dataset to find + * the range bounds. + * + * @param dataset the dataset (null not permitted). + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * @param visibleSeriesKeys the visible series keys. + * + * @return The range (possibly null). + * + * @since 1.0.13 + */ + public static Range iterateToFindRangeBounds(CategoryDataset dataset, + List visibleSeriesKeys, boolean includeInterval) { + + ParamChecks.nullNotPermitted(dataset, "dataset"); + ParamChecks.nullNotPermitted(visibleSeriesKeys, "visibleSeriesKeys"); + + double minimum = Double.POSITIVE_INFINITY; + double maximum = Double.NEGATIVE_INFINITY; + int columnCount = dataset.getColumnCount(); + if (includeInterval + && dataset instanceof BoxAndWhiskerCategoryDataset) { + // handle special case of BoxAndWhiskerDataset + BoxAndWhiskerCategoryDataset bx + = (BoxAndWhiskerCategoryDataset) dataset; + Iterator iterator = visibleSeriesKeys.iterator(); + while (iterator.hasNext()) { + Comparable seriesKey = (Comparable) iterator.next(); + int series = dataset.getRowIndex(seriesKey); + int itemCount = dataset.getColumnCount(); + for (int item = 0; item < itemCount; item++) { + Number lvalue = bx.getMinRegularValue(series, item); + if (lvalue == null) { + lvalue = bx.getValue(series, item); + } + Number uvalue = bx.getMaxRegularValue(series, item); + if (uvalue == null) { + uvalue = bx.getValue(series, item); + } + if (lvalue != null) { + minimum = Math.min(minimum, lvalue.doubleValue()); + } + if (uvalue != null) { + maximum = Math.max(maximum, uvalue.doubleValue()); + } + } + } + } + else if (includeInterval + && dataset instanceof IntervalCategoryDataset) { + // handle the special case where the dataset has y-intervals that + // we want to measure + IntervalCategoryDataset icd = (IntervalCategoryDataset) dataset; + Number lvalue, uvalue; + Iterator iterator = visibleSeriesKeys.iterator(); + while (iterator.hasNext()) { + Comparable seriesKey = (Comparable) iterator.next(); + int series = dataset.getRowIndex(seriesKey); + for (int column = 0; column < columnCount; column++) { + lvalue = icd.getStartValue(series, column); + uvalue = icd.getEndValue(series, column); + if (lvalue != null && !Double.isNaN(lvalue.doubleValue())) { + minimum = Math.min(minimum, lvalue.doubleValue()); + } + if (uvalue != null && !Double.isNaN(uvalue.doubleValue())) { + maximum = Math.max(maximum, uvalue.doubleValue()); + } + } + } + } + else if (includeInterval + && dataset instanceof MultiValueCategoryDataset) { + // handle the special case where the dataset has y-intervals that + // we want to measure + MultiValueCategoryDataset mvcd + = (MultiValueCategoryDataset) dataset; + Iterator iterator = visibleSeriesKeys.iterator(); + while (iterator.hasNext()) { + Comparable seriesKey = (Comparable) iterator.next(); + int series = dataset.getRowIndex(seriesKey); + for (int column = 0; column < columnCount; column++) { + List values = mvcd.getValues(series, column); + Iterator valueIterator = values.iterator(); + while (valueIterator.hasNext()) { + Object o = valueIterator.next(); + if (o instanceof Number){ + double v = ((Number) o).doubleValue(); + if (!Double.isNaN(v)){ + minimum = Math.min(minimum, v); + maximum = Math.max(maximum, v); + } + } + } + } + } + } + else if (includeInterval + && dataset instanceof StatisticalCategoryDataset) { + // handle the special case where the dataset has y-intervals that + // we want to measure + StatisticalCategoryDataset scd + = (StatisticalCategoryDataset) dataset; + Iterator iterator = visibleSeriesKeys.iterator(); + while (iterator.hasNext()) { + Comparable seriesKey = (Comparable) iterator.next(); + int series = dataset.getRowIndex(seriesKey); + for (int column = 0; column < columnCount; column++) { + Number meanN = scd.getMeanValue(series, column); + if (meanN != null) { + double std = 0.0; + Number stdN = scd.getStdDevValue(series, column); + if (stdN != null) { + std = stdN.doubleValue(); + if (Double.isNaN(std)) { + std = 0.0; + } + } + double mean = meanN.doubleValue(); + if (!Double.isNaN(mean)) { + minimum = Math.min(minimum, mean - std); + maximum = Math.max(maximum, mean + std); + } + } + } + } + } + else { + // handle the standard case (plain CategoryDataset) + Iterator iterator = visibleSeriesKeys.iterator(); + while (iterator.hasNext()) { + Comparable seriesKey = (Comparable) iterator.next(); + int series = dataset.getRowIndex(seriesKey); + for (int column = 0; column < columnCount; column++) { + Number value = dataset.getValue(series, column); + if (value != null) { + double v = value.doubleValue(); + if (!Double.isNaN(v)) { + minimum = Math.min(minimum, v); + maximum = Math.max(maximum, v); + } + } + } + } + } + if (minimum == Double.POSITIVE_INFINITY) { + return null; + } + else { + return new Range(minimum, maximum); + } + } + + /** + * Iterates over the data item of the xy dataset to find + * the range bounds. + * + * @param dataset the dataset (null not permitted). + * + * @return The range (possibly null). + * + * @deprecated As of 1.0.10, use {@link #iterateRangeBounds(XYDataset)}. + */ + public static Range iterateXYRangeBounds(XYDataset dataset) { + return iterateRangeBounds(dataset); + } + + /** + * Iterates over the data item of the xy dataset to find + * the range bounds. + * + * @param dataset the dataset (null not permitted). + * + * @return The range (possibly null). + * + * @since 1.0.10 + */ + public static Range iterateRangeBounds(XYDataset dataset) { + return iterateRangeBounds(dataset, true); + } + + /** + * Iterates over the data items of the xy dataset to find + * the range bounds. + * + * @param dataset the dataset (null not permitted). + * @param includeInterval a flag that determines, for an + * {@link IntervalXYDataset}, whether the y-interval or just the + * y-value is used to determine the overall range. + * + * @return The range (possibly null). + * + * @since 1.0.10 + */ + public static Range iterateRangeBounds(XYDataset dataset, + boolean includeInterval) { + double minimum = Double.POSITIVE_INFINITY; + double maximum = Double.NEGATIVE_INFINITY; + int seriesCount = dataset.getSeriesCount(); + + // handle three cases by dataset type + if (includeInterval && dataset instanceof IntervalXYDataset) { + // handle special case of IntervalXYDataset + IntervalXYDataset ixyd = (IntervalXYDataset) dataset; + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double value = ixyd.getYValue(series, item); + double lvalue = ixyd.getStartYValue(series, item); + double uvalue = ixyd.getEndYValue(series, item); + if (!Double.isNaN(value)) { + minimum = Math.min(minimum, value); + maximum = Math.max(maximum, value); + } + if (!Double.isNaN(lvalue)) { + minimum = Math.min(minimum, lvalue); + maximum = Math.max(maximum, lvalue); + } + if (!Double.isNaN(uvalue)) { + minimum = Math.min(minimum, uvalue); + maximum = Math.max(maximum, uvalue); + } + } + } + } + else if (includeInterval && dataset instanceof OHLCDataset) { + // handle special case of OHLCDataset + OHLCDataset ohlc = (OHLCDataset) dataset; + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double lvalue = ohlc.getLowValue(series, item); + double uvalue = ohlc.getHighValue(series, item); + if (!Double.isNaN(lvalue)) { + minimum = Math.min(minimum, lvalue); + } + if (!Double.isNaN(uvalue)) { + maximum = Math.max(maximum, uvalue); + } + } + } + } + else { + // standard case - plain XYDataset + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double value = dataset.getYValue(series, item); + if (!Double.isNaN(value)) { + minimum = Math.min(minimum, value); + maximum = Math.max(maximum, value); + } + } + } + } + if (minimum == Double.POSITIVE_INFINITY) { + return null; + } + else { + return new Range(minimum, maximum); + } + } + + /** + * Returns the range of values in the z-dimension for the dataset. This + * method is the partner for the {@link #findRangeBounds(XYDataset)} + * and {@link #findDomainBounds(XYDataset)} methods. + * + * @param dataset the dataset (null not permitted). + * + * @return The range (possibly null). + */ + public static Range findZBounds(XYZDataset dataset) { + return findZBounds(dataset, true); + } + + /** + * Returns the range of values in the z-dimension for the dataset. This + * method is the partner for the + * {@link #findRangeBounds(XYDataset, boolean)} and + * {@link #findDomainBounds(XYDataset, boolean)} methods. + * + * @param dataset the dataset (null not permitted). + * @param includeInterval a flag that determines whether or not the + * z-interval is taken into account. + * + * @return The range (possibly null). + */ + public static Range findZBounds(XYZDataset dataset, + boolean includeInterval) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + Range result = iterateZBounds(dataset, includeInterval); + return result; + } + + /** + * Finds the bounds of the z-values in the specified dataset, including + * only those series that are listed in visibleSeriesKeys, and those items + * whose x-values fall within the specified range. + * + * @param dataset the dataset (null not permitted). + * @param visibleSeriesKeys the keys for the visible series + * (null not permitted). + * @param xRange the x-range (null not permitted). + * @param includeInterval include the z-interval (if the dataset has a + * z-interval). + * + * @return The data bounds. + */ + public static Range findZBounds(XYZDataset dataset, + List visibleSeriesKeys, Range xRange, boolean includeInterval) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + Range result = iterateToFindZBounds(dataset, visibleSeriesKeys, + xRange, includeInterval); + return result; + } + + /** + * Iterates over the data item of the xyz dataset to find + * the z-dimension bounds. + * + * @param dataset the dataset (null not permitted). + * + * @return The range (possibly null). + */ + public static Range iterateZBounds(XYZDataset dataset) { + return iterateZBounds(dataset, true); + } + + /** + * Iterates over the data items of the xyz dataset to find + * the z-dimension bounds. + * + * @param dataset the dataset (null not permitted). + * @param includeInterval include the z-interval (if the dataset has a + * z-interval. + * + * @return The range (possibly null). + */ + public static Range iterateZBounds(XYZDataset dataset, + boolean includeInterval) { + double minimum = Double.POSITIVE_INFINITY; + double maximum = Double.NEGATIVE_INFINITY; + int seriesCount = dataset.getSeriesCount(); + + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double value = dataset.getZValue(series, item); + if (!Double.isNaN(value)) { + minimum = Math.min(minimum, value); + maximum = Math.max(maximum, value); + } + } + } + + if (minimum == Double.POSITIVE_INFINITY) { + return null; + } + else { + return new Range(minimum, maximum); + } + } + + /** + * Returns the range of x-values in the specified dataset for the + * data items belonging to the visible series. + * + * @param dataset the dataset (null not permitted). + * @param visibleSeriesKeys the visible series keys (null not + * permitted). + * @param includeInterval a flag that determines whether or not the + * y-interval for the dataset is included (this only applies if the + * dataset is an instance of IntervalXYDataset). + * + * @return The x-range (possibly null). + * + * @since 1.0.13 + */ + public static Range iterateToFindDomainBounds(XYDataset dataset, + List visibleSeriesKeys, boolean includeInterval) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + ParamChecks.nullNotPermitted(visibleSeriesKeys, "visibleSeriesKeys"); + + double minimum = Double.POSITIVE_INFINITY; + double maximum = Double.NEGATIVE_INFINITY; + + if (includeInterval && dataset instanceof IntervalXYDataset) { + // handle special case of IntervalXYDataset + IntervalXYDataset ixyd = (IntervalXYDataset) dataset; + Iterator iterator = visibleSeriesKeys.iterator(); + while (iterator.hasNext()) { + Comparable seriesKey = (Comparable) iterator.next(); + int series = dataset.indexOf(seriesKey); + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double lvalue = ixyd.getStartXValue(series, item); + double uvalue = ixyd.getEndXValue(series, item); + if (!Double.isNaN(lvalue)) { + minimum = Math.min(minimum, lvalue); + } + if (!Double.isNaN(uvalue)) { + maximum = Math.max(maximum, uvalue); + } + } + } + } + else { + // standard case - plain XYDataset + Iterator iterator = visibleSeriesKeys.iterator(); + while (iterator.hasNext()) { + Comparable seriesKey = (Comparable) iterator.next(); + int series = dataset.indexOf(seriesKey); + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double x = dataset.getXValue(series, item); + if (!Double.isNaN(x)) { + minimum = Math.min(minimum, x); + maximum = Math.max(maximum, x); + } + } + } + } + + if (minimum == Double.POSITIVE_INFINITY) { + return null; + } + else { + return new Range(minimum, maximum); + } + } + + /** + * Returns the range of y-values in the specified dataset for the + * data items belonging to the visible series and with x-values in the + * given range. + * + * @param dataset the dataset (null not permitted). + * @param visibleSeriesKeys the visible series keys (null not + * permitted). + * @param xRange the x-range (null not permitted). + * @param includeInterval a flag that determines whether or not the + * y-interval for the dataset is included (this only applies if the + * dataset is an instance of IntervalXYDataset). + * + * @return The y-range (possibly null). + * + * @since 1.0.13 + */ + public static Range iterateToFindRangeBounds(XYDataset dataset, + List visibleSeriesKeys, Range xRange, boolean includeInterval) { + + ParamChecks.nullNotPermitted(dataset, "dataset"); + ParamChecks.nullNotPermitted(visibleSeriesKeys, "visibleSeriesKeys"); + ParamChecks.nullNotPermitted(xRange, "xRange"); + + double minimum = Double.POSITIVE_INFINITY; + double maximum = Double.NEGATIVE_INFINITY; + + // handle three cases by dataset type + if (includeInterval && dataset instanceof OHLCDataset) { + // handle special case of OHLCDataset + OHLCDataset ohlc = (OHLCDataset) dataset; + Iterator iterator = visibleSeriesKeys.iterator(); + while (iterator.hasNext()) { + Comparable seriesKey = (Comparable) iterator.next(); + int series = dataset.indexOf(seriesKey); + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double x = ohlc.getXValue(series, item); + if (xRange.contains(x)) { + double lvalue = ohlc.getLowValue(series, item); + double uvalue = ohlc.getHighValue(series, item); + if (!Double.isNaN(lvalue)) { + minimum = Math.min(minimum, lvalue); + } + if (!Double.isNaN(uvalue)) { + maximum = Math.max(maximum, uvalue); + } + } + } + } + } + else if (includeInterval && dataset instanceof BoxAndWhiskerXYDataset) { + // handle special case of BoxAndWhiskerXYDataset + BoxAndWhiskerXYDataset bx = (BoxAndWhiskerXYDataset) dataset; + Iterator iterator = visibleSeriesKeys.iterator(); + while (iterator.hasNext()) { + Comparable seriesKey = (Comparable) iterator.next(); + int series = dataset.indexOf(seriesKey); + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double x = bx.getXValue(series, item); + if (xRange.contains(x)) { + Number lvalue = bx.getMinRegularValue(series, item); + Number uvalue = bx.getMaxRegularValue(series, item); + if (lvalue != null) { + minimum = Math.min(minimum, lvalue.doubleValue()); + } + if (uvalue != null) { + maximum = Math.max(maximum, uvalue.doubleValue()); + } + } + } + } + } + else if (includeInterval && dataset instanceof IntervalXYDataset) { + // handle special case of IntervalXYDataset + IntervalXYDataset ixyd = (IntervalXYDataset) dataset; + Iterator iterator = visibleSeriesKeys.iterator(); + while (iterator.hasNext()) { + Comparable seriesKey = (Comparable) iterator.next(); + int series = dataset.indexOf(seriesKey); + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double x = ixyd.getXValue(series, item); + if (xRange.contains(x)) { + double lvalue = ixyd.getStartYValue(series, item); + double uvalue = ixyd.getEndYValue(series, item); + if (!Double.isNaN(lvalue)) { + minimum = Math.min(minimum, lvalue); + } + if (!Double.isNaN(uvalue)) { + maximum = Math.max(maximum, uvalue); + } + } + } + } + } + else { + // standard case - plain XYDataset + Iterator iterator = visibleSeriesKeys.iterator(); + while (iterator.hasNext()) { + Comparable seriesKey = (Comparable) iterator.next(); + int series = dataset.indexOf(seriesKey); + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double x = dataset.getXValue(series, item); + double y = dataset.getYValue(series, item); + if (xRange.contains(x)) { + if (!Double.isNaN(y)) { + minimum = Math.min(minimum, y); + maximum = Math.max(maximum, y); + } + } + } + } + } + if (minimum == Double.POSITIVE_INFINITY) { + return null; + } + else { + return new Range(minimum, maximum); + } + } + + /** + * Returns the range of z-values in the specified dataset for the + * data items belonging to the visible series and with x-values in the + * given range. + * + * @param dataset the dataset (null not permitted). + * @param visibleSeriesKeys the visible series keys (null not + * permitted). + * @param xRange the x-range (null not permitted). + * @param includeInterval a flag that determines whether or not the + * z-interval for the dataset is included (this only applies if the + * dataset has an interval, which is currently not supported). + * + * @return The y-range (possibly null). + */ + public static Range iterateToFindZBounds(XYZDataset dataset, + List visibleSeriesKeys, Range xRange, boolean includeInterval) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + ParamChecks.nullNotPermitted(visibleSeriesKeys, "visibleSeriesKeys"); + ParamChecks.nullNotPermitted(xRange, "xRange"); + + double minimum = Double.POSITIVE_INFINITY; + double maximum = Double.NEGATIVE_INFINITY; + + Iterator iterator = visibleSeriesKeys.iterator(); + while (iterator.hasNext()) { + Comparable seriesKey = (Comparable) iterator.next(); + int series = dataset.indexOf(seriesKey); + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double x = dataset.getXValue(series, item); + double z = dataset.getZValue(series, item); + if (xRange.contains(x)) { + if (!Double.isNaN(z)) { + minimum = Math.min(minimum, z); + maximum = Math.max(maximum, z); + } + } + } + } + + if (minimum == Double.POSITIVE_INFINITY) { + return null; + } + else { + return new Range(minimum, maximum); + } + } + + /** + * Finds the minimum domain (or X) value for the specified dataset. This + * is easy if the dataset implements the {@link DomainInfo} interface (a + * good idea if there is an efficient way to determine the minimum value). + * Otherwise, it involves iterating over the entire data-set. + *

+ * Returns null if all the data values in the dataset are + * null. + * + * @param dataset the dataset (null not permitted). + * + * @return The minimum value (possibly null). + */ + public static Number findMinimumDomainValue(XYDataset dataset) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + Number result; + // if the dataset implements DomainInfo, life is easy + if (dataset instanceof DomainInfo) { + DomainInfo info = (DomainInfo) dataset; + return new Double(info.getDomainLowerBound(true)); + } + else { + double minimum = Double.POSITIVE_INFINITY; + int seriesCount = dataset.getSeriesCount(); + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + + double value; + if (dataset instanceof IntervalXYDataset) { + IntervalXYDataset intervalXYData + = (IntervalXYDataset) dataset; + value = intervalXYData.getStartXValue(series, item); + } + else { + value = dataset.getXValue(series, item); + } + if (!Double.isNaN(value)) { + minimum = Math.min(minimum, value); + } + + } + } + if (minimum == Double.POSITIVE_INFINITY) { + result = null; + } + else { + result = new Double(minimum); + } + } + + return result; + } + + /** + * Returns the maximum domain value for the specified dataset. This is + * easy if the dataset implements the {@link DomainInfo} interface (a good + * idea if there is an efficient way to determine the maximum value). + * Otherwise, it involves iterating over the entire data-set. Returns + * null if all the data values in the dataset are + * null. + * + * @param dataset the dataset (null not permitted). + * + * @return The maximum value (possibly null). + */ + public static Number findMaximumDomainValue(XYDataset dataset) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + Number result; + // if the dataset implements DomainInfo, life is easy + if (dataset instanceof DomainInfo) { + DomainInfo info = (DomainInfo) dataset; + return new Double(info.getDomainUpperBound(true)); + } + + // hasn't implemented DomainInfo, so iterate... + else { + double maximum = Double.NEGATIVE_INFINITY; + int seriesCount = dataset.getSeriesCount(); + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + + double value; + if (dataset instanceof IntervalXYDataset) { + IntervalXYDataset intervalXYData + = (IntervalXYDataset) dataset; + value = intervalXYData.getEndXValue(series, item); + } + else { + value = dataset.getXValue(series, item); + } + if (!Double.isNaN(value)) { + maximum = Math.max(maximum, value); + } + } + } + if (maximum == Double.NEGATIVE_INFINITY) { + result = null; + } + else { + result = new Double(maximum); + } + + } + + return result; + } + + /** + * Returns the minimum range value for the specified dataset. This is + * easy if the dataset implements the {@link RangeInfo} interface (a good + * idea if there is an efficient way to determine the minimum value). + * Otherwise, it involves iterating over the entire data-set. Returns + * null if all the data values in the dataset are + * null. + * + * @param dataset the dataset (null not permitted). + * + * @return The minimum value (possibly null). + */ + public static Number findMinimumRangeValue(CategoryDataset dataset) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + if (dataset instanceof RangeInfo) { + RangeInfo info = (RangeInfo) dataset; + return new Double(info.getRangeLowerBound(true)); + } + + // hasn't implemented RangeInfo, so we'll have to iterate... + else { + double minimum = Double.POSITIVE_INFINITY; + int seriesCount = dataset.getRowCount(); + int itemCount = dataset.getColumnCount(); + for (int series = 0; series < seriesCount; series++) { + for (int item = 0; item < itemCount; item++) { + Number value; + if (dataset instanceof IntervalCategoryDataset) { + IntervalCategoryDataset icd + = (IntervalCategoryDataset) dataset; + value = icd.getStartValue(series, item); + } + else { + value = dataset.getValue(series, item); + } + if (value != null) { + minimum = Math.min(minimum, value.doubleValue()); + } + } + } + if (minimum == Double.POSITIVE_INFINITY) { + return null; + } + else { + return new Double(minimum); + } + + } + + } + + /** + * Returns the minimum range value for the specified dataset. This is + * easy if the dataset implements the {@link RangeInfo} interface (a good + * idea if there is an efficient way to determine the minimum value). + * Otherwise, it involves iterating over the entire data-set. Returns + * null if all the data values in the dataset are + * null. + * + * @param dataset the dataset (null not permitted). + * + * @return The minimum value (possibly null). + */ + public static Number findMinimumRangeValue(XYDataset dataset) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + + // work out the minimum value... + if (dataset instanceof RangeInfo) { + RangeInfo info = (RangeInfo) dataset; + return new Double(info.getRangeLowerBound(true)); + } + + // hasn't implemented RangeInfo, so we'll have to iterate... + else { + double minimum = Double.POSITIVE_INFINITY; + int seriesCount = dataset.getSeriesCount(); + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + + double value; + if (dataset instanceof IntervalXYDataset) { + IntervalXYDataset intervalXYData + = (IntervalXYDataset) dataset; + value = intervalXYData.getStartYValue(series, item); + } + else if (dataset instanceof OHLCDataset) { + OHLCDataset highLowData = (OHLCDataset) dataset; + value = highLowData.getLowValue(series, item); + } + else { + value = dataset.getYValue(series, item); + } + if (!Double.isNaN(value)) { + minimum = Math.min(minimum, value); + } + + } + } + if (minimum == Double.POSITIVE_INFINITY) { + return null; + } + else { + return new Double(minimum); + } + + } + + } + + /** + * Returns the maximum range value for the specified dataset. This is easy + * if the dataset implements the {@link RangeInfo} interface (a good idea + * if there is an efficient way to determine the maximum value). + * Otherwise, it involves iterating over the entire data-set. Returns + * null if all the data values are null. + * + * @param dataset the dataset (null not permitted). + * + * @return The maximum value (possibly null). + */ + public static Number findMaximumRangeValue(CategoryDataset dataset) { + + ParamChecks.nullNotPermitted(dataset, "dataset"); + + // work out the minimum value... + if (dataset instanceof RangeInfo) { + RangeInfo info = (RangeInfo) dataset; + return new Double(info.getRangeUpperBound(true)); + } + + // hasn't implemented RangeInfo, so we'll have to iterate... + else { + + double maximum = Double.NEGATIVE_INFINITY; + int seriesCount = dataset.getRowCount(); + int itemCount = dataset.getColumnCount(); + for (int series = 0; series < seriesCount; series++) { + for (int item = 0; item < itemCount; item++) { + Number value; + if (dataset instanceof IntervalCategoryDataset) { + IntervalCategoryDataset icd + = (IntervalCategoryDataset) dataset; + value = icd.getEndValue(series, item); + } + else { + value = dataset.getValue(series, item); + } + if (value != null) { + maximum = Math.max(maximum, value.doubleValue()); + } + } + } + if (maximum == Double.NEGATIVE_INFINITY) { + return null; + } + else { + return new Double(maximum); + } + + } + + } + + /** + * Returns the maximum range value for the specified dataset. This is + * easy if the dataset implements the {@link RangeInfo} interface (a good + * idea if there is an efficient way to determine the maximum value). + * Otherwise, it involves iterating over the entire data-set. Returns + * null if all the data values are null. + * + * @param dataset the dataset (null not permitted). + * + * @return The maximum value (possibly null). + */ + public static Number findMaximumRangeValue(XYDataset dataset) { + + ParamChecks.nullNotPermitted(dataset, "dataset"); + + // work out the minimum value... + if (dataset instanceof RangeInfo) { + RangeInfo info = (RangeInfo) dataset; + return new Double(info.getRangeUpperBound(true)); + } + + // hasn't implemented RangeInfo, so we'll have to iterate... + else { + + double maximum = Double.NEGATIVE_INFINITY; + int seriesCount = dataset.getSeriesCount(); + for (int series = 0; series < seriesCount; series++) { + int itemCount = dataset.getItemCount(series); + for (int item = 0; item < itemCount; item++) { + double value; + if (dataset instanceof IntervalXYDataset) { + IntervalXYDataset intervalXYData + = (IntervalXYDataset) dataset; + value = intervalXYData.getEndYValue(series, item); + } + else if (dataset instanceof OHLCDataset) { + OHLCDataset highLowData = (OHLCDataset) dataset; + value = highLowData.getHighValue(series, item); + } + else { + value = dataset.getYValue(series, item); + } + if (!Double.isNaN(value)) { + maximum = Math.max(maximum, value); + } + } + } + if (maximum == Double.NEGATIVE_INFINITY) { + return null; + } + else { + return new Double(maximum); + } + + } + + } + + /** + * Returns the minimum and maximum values for the dataset's range + * (y-values), assuming that the series in one category are stacked. + * + * @param dataset the dataset (null not permitted). + * + * @return The range (null if the dataset contains no values). + */ + public static Range findStackedRangeBounds(CategoryDataset dataset) { + return findStackedRangeBounds(dataset, 0.0); + } + + /** + * Returns the minimum and maximum values for the dataset's range + * (y-values), assuming that the series in one category are stacked. + * + * @param dataset the dataset (null not permitted). + * @param base the base value for the bars. + * + * @return The range (null if the dataset contains no values). + */ + public static Range findStackedRangeBounds(CategoryDataset dataset, + double base) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + Range result = null; + double minimum = Double.POSITIVE_INFINITY; + double maximum = Double.NEGATIVE_INFINITY; + int categoryCount = dataset.getColumnCount(); + for (int item = 0; item < categoryCount; item++) { + double positive = base; + double negative = base; + int seriesCount = dataset.getRowCount(); + for (int series = 0; series < seriesCount; series++) { + Number number = dataset.getValue(series, item); + if (number != null) { + double value = number.doubleValue(); + if (value > 0.0) { + positive = positive + value; + } + if (value < 0.0) { + negative = negative + value; + // '+', remember value is negative + } + } + } + minimum = Math.min(minimum, negative); + maximum = Math.max(maximum, positive); + } + if (minimum <= maximum) { + result = new Range(minimum, maximum); + } + return result; + + } + + /** + * Returns the minimum and maximum values for the dataset's range + * (y-values), assuming that the series in one category are stacked. + * + * @param dataset the dataset. + * @param map a structure that maps series to groups. + * + * @return The value range (null if the dataset contains no + * values). + */ + public static Range findStackedRangeBounds(CategoryDataset dataset, + KeyToGroupMap map) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + boolean hasValidData = false; + Range result = null; + + // create an array holding the group indices for each series... + int[] groupIndex = new int[dataset.getRowCount()]; + for (int i = 0; i < dataset.getRowCount(); i++) { + groupIndex[i] = map.getGroupIndex(map.getGroup( + dataset.getRowKey(i))); + } + + // minimum and maximum for each group... + int groupCount = map.getGroupCount(); + double[] minimum = new double[groupCount]; + double[] maximum = new double[groupCount]; + + int categoryCount = dataset.getColumnCount(); + for (int item = 0; item < categoryCount; item++) { + double[] positive = new double[groupCount]; + double[] negative = new double[groupCount]; + int seriesCount = dataset.getRowCount(); + for (int series = 0; series < seriesCount; series++) { + Number number = dataset.getValue(series, item); + if (number != null) { + hasValidData = true; + double value = number.doubleValue(); + if (value > 0.0) { + positive[groupIndex[series]] + = positive[groupIndex[series]] + value; + } + if (value < 0.0) { + negative[groupIndex[series]] + = negative[groupIndex[series]] + value; + // '+', remember value is negative + } + } + } + for (int g = 0; g < groupCount; g++) { + minimum[g] = Math.min(minimum[g], negative[g]); + maximum[g] = Math.max(maximum[g], positive[g]); + } + } + if (hasValidData) { + for (int j = 0; j < groupCount; j++) { + result = Range.combine(result, new Range(minimum[j], + maximum[j])); + } + } + return result; + } + + /** + * Returns the minimum value in the dataset range, assuming that values in + * each category are "stacked". + * + * @param dataset the dataset (null not permitted). + * + * @return The minimum value. + * + * @see #findMaximumStackedRangeValue(CategoryDataset) + */ + public static Number findMinimumStackedRangeValue(CategoryDataset dataset) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + Number result = null; + boolean hasValidData = false; + double minimum = 0.0; + int categoryCount = dataset.getColumnCount(); + for (int item = 0; item < categoryCount; item++) { + double total = 0.0; + int seriesCount = dataset.getRowCount(); + for (int series = 0; series < seriesCount; series++) { + Number number = dataset.getValue(series, item); + if (number != null) { + hasValidData = true; + double value = number.doubleValue(); + if (value < 0.0) { + total = total + value; + // '+', remember value is negative + } + } + } + minimum = Math.min(minimum, total); + } + if (hasValidData) { + result = new Double(minimum); + } + return result; + } + + /** + * Returns the maximum value in the dataset range, assuming that values in + * each category are "stacked". + * + * @param dataset the dataset (null not permitted). + * + * @return The maximum value (possibly null). + * + * @see #findMinimumStackedRangeValue(CategoryDataset) + */ + public static Number findMaximumStackedRangeValue(CategoryDataset dataset) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + Number result = null; + boolean hasValidData = false; + double maximum = 0.0; + int categoryCount = dataset.getColumnCount(); + for (int item = 0; item < categoryCount; item++) { + double total = 0.0; + int seriesCount = dataset.getRowCount(); + for (int series = 0; series < seriesCount; series++) { + Number number = dataset.getValue(series, item); + if (number != null) { + hasValidData = true; + double value = number.doubleValue(); + if (value > 0.0) { + total = total + value; + } + } + } + maximum = Math.max(maximum, total); + } + if (hasValidData) { + result = new Double(maximum); + } + return result; + } + + /** + * Returns the minimum and maximum values for the dataset's range, + * assuming that the series are stacked. + * + * @param dataset the dataset (null not permitted). + * + * @return The range ([0.0, 0.0] if the dataset contains no values). + */ + public static Range findStackedRangeBounds(TableXYDataset dataset) { + return findStackedRangeBounds(dataset, 0.0); + } + + /** + * Returns the minimum and maximum values for the dataset's range, + * assuming that the series are stacked, using the specified base value. + * + * @param dataset the dataset (null not permitted). + * @param base the base value. + * + * @return The range (null if the dataset contains no values). + */ + public static Range findStackedRangeBounds(TableXYDataset dataset, + double base) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + double minimum = base; + double maximum = base; + for (int itemNo = 0; itemNo < dataset.getItemCount(); itemNo++) { + double positive = base; + double negative = base; + int seriesCount = dataset.getSeriesCount(); + for (int seriesNo = 0; seriesNo < seriesCount; seriesNo++) { + double y = dataset.getYValue(seriesNo, itemNo); + if (!Double.isNaN(y)) { + if (y > 0.0) { + positive += y; + } + else { + negative += y; + } + } + } + if (positive > maximum) { + maximum = positive; + } + if (negative < minimum) { + minimum = negative; + } + } + if (minimum <= maximum) { + return new Range(minimum, maximum); + } + else { + return null; + } + } + + /** + * Calculates the total for the y-values in all series for a given item + * index. + * + * @param dataset the dataset. + * @param item the item index. + * + * @return The total. + * + * @since 1.0.5 + */ + public static double calculateStackTotal(TableXYDataset dataset, int item) { + double total = 0.0; + int seriesCount = dataset.getSeriesCount(); + for (int s = 0; s < seriesCount; s++) { + double value = dataset.getYValue(s, item); + if (!Double.isNaN(value)) { + total = total + value; + } + } + return total; + } + + /** + * Calculates the range of values for a dataset where each item is the + * running total of the items for the current series. + * + * @param dataset the dataset (null not permitted). + * + * @return The range. + * + * @see #findRangeBounds(CategoryDataset) + */ + public static Range findCumulativeRangeBounds(CategoryDataset dataset) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + boolean allItemsNull = true; // we'll set this to false if there is at + // least one non-null data item... + double minimum = 0.0; + double maximum = 0.0; + for (int row = 0; row < dataset.getRowCount(); row++) { + double runningTotal = 0.0; + for (int column = 0; column <= dataset.getColumnCount() - 1; + column++) { + Number n = dataset.getValue(row, column); + if (n != null) { + allItemsNull = false; + double value = n.doubleValue(); + if (!Double.isNaN(value)) { + runningTotal = runningTotal + value; + minimum = Math.min(minimum, runningTotal); + maximum = Math.max(maximum, runningTotal); + } + } + } + } + if (!allItemsNull) { + return new Range(minimum, maximum); + } + else { + return null; + } + } + + /** + * Returns the interpolated value of y that corresponds to the specified + * x-value in the given series. If the x-value falls outside the range of + * x-values for the dataset, this method returns Double.NaN. + * + * @param dataset the dataset (null not permitted). + * @param series the series index. + * @param x the x-value. + * + * @return The y value. + * + * @since 1.0.16 + */ + public static double findYValue(XYDataset dataset, int series, double x) { + // delegate null check on dataset + int[] indices = findItemIndicesForX(dataset, series, x); + if (indices[0] == -1) { + return Double.NaN; + } + if (indices[0] == indices[1]) { + return dataset.getYValue(series, indices[0]); + } + double x0 = dataset.getXValue(series, indices[0]); + double x1 = dataset.getXValue(series, indices[1]); + double y0 = dataset.getYValue(series, indices[0]); + double y1 = dataset.getYValue(series, indices[1]); + return y0 + (y1 - y0) * (x - x0) / (x1 - x0); + } + + /** + * Finds the indices of the the items in the dataset that span the + * specified x-value. There are three cases for the return value: + *

    + *
  • there is an exact match for the x-value at index i + * (returns int[] {i, i});
  • + *
  • the x-value falls between two (adjacent) items at index i and i+1 + * (returns int[] {i, i+1});
  • + *
  • the x-value falls outside the domain bounds, in which case the + * method returns int[] {-1, -1}.
  • + *
+ * @param dataset the dataset (null not permitted). + * @param series the series index. + * @param x the x-value. + * + * @return The indices of the two items that span the x-value. + * + * @since 1.0.16 + * + * @see #findYValue(org.jfree.data.xy.XYDataset, int, double) + */ + public static int[] findItemIndicesForX(XYDataset dataset, int series, + double x) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + int itemCount = dataset.getItemCount(series); + if (itemCount == 0) { + return new int[] {-1, -1}; + } + if (itemCount == 1) { + if (x == dataset.getXValue(series, 0)) { + return new int[] {0, 0}; + } else { + return new int[] {-1, -1}; + } + } + if (dataset.getDomainOrder() == DomainOrder.ASCENDING) { + int low = 0; + int high = itemCount - 1; + double lowValue = dataset.getXValue(series, low); + if (lowValue > x) { + return new int[] {-1, -1}; + } + if (lowValue == x) { + return new int[] {low, low}; + } + double highValue = dataset.getXValue(series, high); + if (highValue < x) { + return new int[] {-1, -1}; + } + if (highValue == x) { + return new int[] {high, high}; + } + int mid = (low + high) / 2; + while (high - low > 1) { + double midV = dataset.getXValue(series, mid); + if (x == midV) { + return new int[] {mid, mid}; + } + if (midV < x) { + low = mid; + } + else { + high = mid; + } + mid = (low + high) / 2; + } + return new int[] {low, high}; + } + else if (dataset.getDomainOrder() == DomainOrder.DESCENDING) { + int high = 0; + int low = itemCount - 1; + double lowValue = dataset.getXValue(series, low); + if (lowValue > x) { + return new int[] {-1, -1}; + } + double highValue = dataset.getXValue(series, high); + if (highValue < x) { + return new int[] {-1, -1}; + } + int mid = (low + high) / 2; + while (high - low > 1) { + double midV = dataset.getXValue(series, mid); + if (x == midV) { + return new int[] {mid, mid}; + } + if (midV < x) { + low = mid; + } + else { + high = mid; + } + mid = (low + high) / 2; + } + return new int[] {low, high}; + } + else { + // we don't know anything about the ordering of the x-values, + // so we iterate until we find the first crossing of x (if any) + // we know there are at least 2 items in the series at this point + double prev = dataset.getXValue(series, 0); + if (x == prev) { + return new int[] {0, 0}; // exact match on first item + } + for (int i = 1; i < itemCount; i++) { + double next = dataset.getXValue(series, i); + if (x == next) { + return new int[] {i, i}; // exact match + } + if ((x > prev && x < next) || (x < prev && x > next)) { + return new int[] {i - 1, i}; // spanning match + } + } + return new int[] {-1, -1}; // no crossing of x + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultHeatMapDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultHeatMapDataset.java new file mode 100755 index 0000000..0b6fafb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultHeatMapDataset.java @@ -0,0 +1,334 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * DefaultHeatMapDataset.java + * -------------------------- + * (C) Copyright 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 28-Jan-2009 : Version 1 (DG); + * + */ + +package org.jfree.data.general; + +import java.io.Serializable; +import org.jfree.data.DataUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A default implementation of the {@link HeatMapDataset} interface. + * + * @since 1.0.13 + */ +public class DefaultHeatMapDataset extends AbstractDataset + implements HeatMapDataset, Cloneable, PublicCloneable, Serializable { + + /** The number of samples in this dataset for the x-dimension. */ + private int xSamples; + + /** The number of samples in this dataset for the y-dimension. */ + private int ySamples; + + /** The minimum x-value in the dataset. */ + private double minX; + + /** The maximum x-value in the dataset. */ + private double maxX; + + /** The minimum y-value in the dataset. */ + private double minY; + + /** The maximum y-value in the dataset. */ + private double maxY; + + /** Storage for the z-values. */ + private double[][] zValues; + + /** + * Creates a new dataset where all the z-values are initially 0. This is + * a fixed size array of z-values. + * + * @param xSamples the number of x-values. + * @param ySamples the number of y-values + * @param minX the minimum x-value in the dataset. + * @param maxX the maximum x-value in the dataset. + * @param minY the minimum y-value in the dataset. + * @param maxY the maximum y-value in the dataset. + */ + public DefaultHeatMapDataset(int xSamples, int ySamples, double minX, + double maxX, double minY, double maxY) { + + if (xSamples < 1) { + throw new IllegalArgumentException("Requires 'xSamples' > 0"); + } + if (ySamples < 1) { + throw new IllegalArgumentException("Requires 'ySamples' > 0"); + } + if (Double.isInfinite(minX) || Double.isNaN(minX)) { + throw new IllegalArgumentException("'minX' cannot be INF or NaN."); + } + if (Double.isInfinite(maxX) || Double.isNaN(maxX)) { + throw new IllegalArgumentException("'maxX' cannot be INF or NaN."); + } + if (Double.isInfinite(minY) || Double.isNaN(minY)) { + throw new IllegalArgumentException("'minY' cannot be INF or NaN."); + } + if (Double.isInfinite(maxY) || Double.isNaN(maxY)) { + throw new IllegalArgumentException("'maxY' cannot be INF or NaN."); + } + + this.xSamples = xSamples; + this.ySamples = ySamples; + this.minX = minX; + this.maxX = maxX; + this.minY = minY; + this.maxY = maxY; + this.zValues = new double[xSamples][]; + for (int x = 0; x < xSamples; x++) { + this.zValues[x] = new double[ySamples]; + } + } + + /** + * Returns the number of x values across the width of the dataset. The + * values are evenly spaced between {@link #getMinimumXValue()} and + * {@link #getMaximumXValue()}. + * + * @return The number of x-values (always > 0). + */ + @Override + public int getXSampleCount() { + return this.xSamples; + } + + /** + * Returns the number of y values (or samples) for the dataset. The + * values are evenly spaced between {@link #getMinimumYValue()} and + * {@link #getMaximumYValue()}. + * + * @return The number of y-values (always > 0). + */ + @Override + public int getYSampleCount() { + return this.ySamples; + } + + /** + * Returns the lowest x-value represented in this dataset. A requirement + * of this interface is that this method must never return infinite or + * Double.NAN values. + * + * @return The lowest x-value represented in this dataset. + */ + @Override + public double getMinimumXValue() { + return this.minX; + } + + /** + * Returns the highest x-value represented in this dataset. A requirement + * of this interface is that this method must never return infinite or + * Double.NAN values. + * + * @return The highest x-value represented in this dataset. + */ + @Override + public double getMaximumXValue() { + return this.maxX; + } + + /** + * Returns the lowest y-value represented in this dataset. A requirement + * of this interface is that this method must never return infinite or + * Double.NAN values. + * + * @return The lowest y-value represented in this dataset. + */ + @Override + public double getMinimumYValue() { + return this.minY; + } + + /** + * Returns the highest y-value represented in this dataset. A requirement + * of this interface is that this method must never return infinite or + * Double.NAN values. + * + * @return The highest y-value represented in this dataset. + */ + @Override + public double getMaximumYValue() { + return this.maxY; + } + + /** + * A convenience method that returns the x-value for the given index. + * + * @param xIndex the xIndex. + * + * @return The x-value. + */ + @Override + public double getXValue(int xIndex) { + double x = this.minX + + (this.maxX - this.minX) * (xIndex / (double) this.xSamples); + return x; + } + + /** + * A convenience method that returns the y-value for the given index. + * + * @param yIndex the yIndex. + * + * @return The y-value. + */ + @Override + public double getYValue(int yIndex) { + double y = this.minY + + (this.maxY - this.minY) * (yIndex / (double) this.ySamples); + return y; + } + + /** + * Returns the z-value at the specified sample position in the dataset. + * For a missing or unknown value, this method should return Double.NAN. + * + * @param xIndex the position of the x sample in the dataset. + * @param yIndex the position of the y sample in the dataset. + * + * @return The z-value. + */ + @Override + public double getZValue(int xIndex, int yIndex) { + return this.zValues[xIndex][yIndex]; + } + + /** + * Returns the z-value at the specified sample position in the dataset. + * In this implementation, where the underlying values are stored in an + * array of double primitives, you should avoid using this method and + * use {@link #getZValue(int, int)} instead. + * + * @param xIndex the position of the x sample in the dataset. + * @param yIndex the position of the y sample in the dataset. + * + * @return The z-value. + */ + @Override + public Number getZ(int xIndex, int yIndex) { + return new Double(getZValue(xIndex, yIndex)); + } + + /** + * Updates a z-value in the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param xIndex the x-index. + * @param yIndex the y-index. + * @param z the new z-value. + */ + public void setZValue(int xIndex, int yIndex, double z) { + setZValue(xIndex, yIndex, z, true); + } + + /** + * Updates a z-value in the dataset and, if requested, sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param xIndex the x-index. + * @param yIndex the y-index. + * @param z the new z-value. + * @param notify notify listeners? + */ + public void setZValue(int xIndex, int yIndex, double z, boolean notify) { + this.zValues[xIndex][yIndex] = z; + if (notify) { + fireDatasetChanged(); + } + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DefaultHeatMapDataset)) { + return false; + } + DefaultHeatMapDataset that = (DefaultHeatMapDataset) obj; + if (this.xSamples != that.xSamples) { + return false; + } + if (this.ySamples != that.ySamples) { + return false; + } + if (this.minX != that.minX) { + return false; + } + if (this.maxX != that.maxX) { + return false; + } + if (this.minY != that.minY) { + return false; + } + if (this.maxY != that.maxY) { + return false; + } + if (!DataUtilities.equal(this.zValues, that.zValues)) { + return false; + } + // can't find any differences + return true; + } + + /** + * Returns an independent copy of this dataset. + * + * @return A clone. + * + * @throws java.lang.CloneNotSupportedException + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultHeatMapDataset clone = (DefaultHeatMapDataset) super.clone(); + clone.zValues = DataUtilities.clone(this.zValues); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultKeyedValueDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultKeyedValueDataset.java new file mode 100755 index 0000000..ee14c8d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultKeyedValueDataset.java @@ -0,0 +1,198 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * DefaultKeyedValueDataset.java + * ----------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Mar-2003 : Version 1 (DG); + * 18-Aug-2003 : Implemented Cloneable (DG); + * + */ + +package org.jfree.data.general; + +import java.io.Serializable; + +import org.jfree.data.DefaultKeyedValue; +import org.jfree.data.KeyedValue; +import org.jfree.util.ObjectUtilities; + +/** + * A default implementation of the {@link KeyedValueDataset} interface. + */ +public class DefaultKeyedValueDataset extends AbstractDataset + implements KeyedValueDataset, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -8149484339560406750L; + + /** Storage for the data. */ + private KeyedValue data; + + /** + * Constructs a new dataset, initially empty. + */ + public DefaultKeyedValueDataset() { + this(null); + } + + /** + * Creates a new dataset with the specified initial value. + * + * @param key the key. + * @param value the value (null permitted). + */ + public DefaultKeyedValueDataset(Comparable key, Number value) { + this(new DefaultKeyedValue(key, value)); + } + + /** + * Creates a new dataset that uses the data from a {@link KeyedValue} + * instance. + * + * @param data the data (null permitted). + */ + public DefaultKeyedValueDataset(KeyedValue data) { + this.data = data; + } + + /** + * Returns the key associated with the value, or null if the + * dataset has no data item. + * + * @return The key. + */ + @Override + public Comparable getKey() { + Comparable result = null; + if (this.data != null) { + result = this.data.getKey(); + } + return result; + } + + /** + * Returns the value. + * + * @return The value (possibly null). + */ + @Override + public Number getValue() { + Number result = null; + if (this.data != null) { + result = this.data.getValue(); + } + return result; + } + + /** + * Updates the value. + * + * @param value the new value (null permitted). + */ + public void updateValue(Number value) { + if (this.data == null) { + throw new RuntimeException("updateValue: can't update null."); + } + setValue(this.data.getKey(), value); + } + + /** + * Sets the value for the dataset and sends a {@link DatasetChangeEvent} to + * all registered listeners. + * + * @param key the key. + * @param value the value (null permitted). + */ + public void setValue(Comparable key, Number value) { + this.data = new DefaultKeyedValue(key, value); + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof KeyedValueDataset)) { + return false; + } + KeyedValueDataset that = (KeyedValueDataset) obj; + if (this.data == null) { + if (that.getKey() != null || that.getValue() != null) { + return false; + } + return true; + } + if (!ObjectUtilities.equal(this.data.getKey(), that.getKey())) { + return false; + } + if (!ObjectUtilities.equal(this.data.getValue(), that.getValue())) { + return false; + } + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return (this.data != null ? this.data.hashCode() : 0); + } + + /** + * Creates a clone of the dataset. + * + * @return A clone. + * + * @throws CloneNotSupportedException This class will not throw this + * exception, but subclasses (if any) might. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultKeyedValueDataset clone + = (DefaultKeyedValueDataset) super.clone(); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultKeyedValues2DDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultKeyedValues2DDataset.java new file mode 100755 index 0000000..6030055 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultKeyedValues2DDataset.java @@ -0,0 +1,61 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------- + * DefaultKeyedValues2DDataset.java + * -------------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Mar-2003 : Version 1 (copied from DefaultCategoryDataset) (DG); + * 23-Apr-2003 : Moved implementation into the DefaultCategoryDataset + * class (DG); + * + */ + +package org.jfree.data.general; + +import java.io.Serializable; + +import org.jfree.data.category.DefaultCategoryDataset; + +/** + * A default implementation of the {@link KeyedValues2DDataset} interface. + * + */ +public class DefaultKeyedValues2DDataset extends DefaultCategoryDataset + implements KeyedValues2DDataset, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 4288210771905990424L; + + // no new methods + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultKeyedValuesDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultKeyedValuesDataset.java new file mode 100755 index 0000000..757a7c7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultKeyedValuesDataset.java @@ -0,0 +1,56 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * DefaultKeyedValuesDataset.java + * ------------------------------ + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Mar-2003 : Version 1 (DG); + * 13-Mar-2003 : Implemented Serializable (DG); + * + */ + +package org.jfree.data.general; + +/** + * A default implementation of the {@link KeyedValuesDataset} interface. + * This is an alias for {@link DefaultPieDataset}. + */ +public class DefaultKeyedValuesDataset extends DefaultPieDataset + implements KeyedValuesDataset { + + /** For serialization. */ + private static final long serialVersionUID = 306264413152815781L; + + // no new methods + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultPieDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultPieDataset.java new file mode 100755 index 0000000..61e417d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultPieDataset.java @@ -0,0 +1,375 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * DefaultPieDataset.java + * ---------------------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Sam (oldman); + * + * Changes + * ------- + * 17-Nov-2001 : Version 1 (DG); + * 22-Jan-2002 : Removed legend methods from dataset implementations (DG); + * 07-Apr-2002 : Modified implementation to guarantee data sequence to remain + * in the order categories are added (oldman); + * 23-Oct-2002 : Added getCategory(int) method and getItemCount() method, in + * line with changes to the PieDataset interface (DG); + * 04-Feb-2003 : Changed underlying data storage to DefaultKeyedValues (DG); + * 04-Mar-2003 : Inserted DefaultKeyedValuesDataset class into hierarchy (DG); + * 24-Apr-2003 : Switched places with DefaultKeyedValuesDataset (DG); + * 18-Aug-2003 : Implemented Cloneable (DG); + * 03-Mar-2005 : Implemented PublicCloneable (DG); + * 29-Jun-2005 : Added remove() method (DG); + * ------------- JFREECHART 1.0.0 --------------------------------------------- + * 31-Jul-2006 : Added a clear() method to clear all values from the + * dataset (DG); + * 28-Sep-2006 : Added sortByKeys() and sortByValues() methods (DG); + * 30-Apr-2007 : Added new insertValues() methods (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.general; + +import java.io.Serializable; +import java.util.Collections; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.DefaultKeyedValues; +import org.jfree.data.KeyedValues; +import org.jfree.data.UnknownKeyException; +import org.jfree.util.PublicCloneable; +import org.jfree.util.SortOrder; + +/** + * A default implementation of the {@link PieDataset} interface. + */ +public class DefaultPieDataset extends AbstractDataset + implements PieDataset, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 2904745139106540618L; + + /** Storage for the data. */ + private DefaultKeyedValues data; + + /** + * Constructs a new dataset, initially empty. + */ + public DefaultPieDataset() { + this.data = new DefaultKeyedValues(); + } + + /** + * Creates a new dataset by copying data from a {@link KeyedValues} + * instance. + * + * @param data the data (null not permitted). + */ + public DefaultPieDataset(KeyedValues data) { + ParamChecks.nullNotPermitted(data, "data"); + this.data = new DefaultKeyedValues(); + for (int i = 0; i < data.getItemCount(); i++) { + this.data.addValue(data.getKey(i), data.getValue(i)); + } + } + + /** + * Returns the number of items in the dataset. + * + * @return The item count. + */ + @Override + public int getItemCount() { + return this.data.getItemCount(); + } + + /** + * Returns the categories in the dataset. The returned list is + * unmodifiable. + * + * @return The categories in the dataset. + */ + @Override + public List getKeys() { + return Collections.unmodifiableList(this.data.getKeys()); + } + + /** + * Returns the key for the specified item, or null. + * + * @param item the item index (in the range 0 to + * getItemCount() - 1). + * + * @return The key, or null. + * + * @throws IndexOutOfBoundsException if item is not in the + * specified range. + */ + @Override + public Comparable getKey(int item) { + return this.data.getKey(item); + } + + /** + * Returns the index for a key, or -1 if the key is not recognised. + * + * @param key the key (null not permitted). + * + * @return The index, or -1 if the key is unrecognised. + * + * @throws IllegalArgumentException if key is + * null. + */ + @Override + public int getIndex(Comparable key) { + return this.data.getIndex(key); + } + + /** + * Returns a value. + * + * @param item the value index. + * + * @return The value (possibly null). + */ + @Override + public Number getValue(int item) { + Number result = null; + if (getItemCount() > item) { + result = this.data.getValue(item); + } + return result; + } + + /** + * Returns the data value associated with a key. + * + * @param key the key (null not permitted). + * + * @return The value (possibly null). + * + * @throws UnknownKeyException if the key is not recognised. + */ + @Override + public Number getValue(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + return this.data.getValue(key); + } + + /** + * Sets the data value for a key and sends a {@link DatasetChangeEvent} to + * all registered listeners. + * + * @param key the key (null not permitted). + * @param value the value. + * + * @throws IllegalArgumentException if key is + * null. + */ + public void setValue(Comparable key, Number value) { + this.data.setValue(key, value); + fireDatasetChanged(); + } + + /** + * Sets the data value for a key and sends a {@link DatasetChangeEvent} to + * all registered listeners. + * + * @param key the key (null not permitted). + * @param value the value. + * + * @throws IllegalArgumentException if key is + * null. + */ + public void setValue(Comparable key, double value) { + setValue(key, new Double(value)); + } + + /** + * Inserts a new value at the specified position in the dataset or, if + * there is an existing item with the specified key, updates the value + * for that item and moves it to the specified position. After the change + * is made, this methods sends a {@link DatasetChangeEvent} to all + * registered listeners. + * + * @param position the position (in the range 0 to getItemCount()). + * @param key the key (null not permitted). + * @param value the value (null permitted). + * + * @since 1.0.6 + */ + public void insertValue(int position, Comparable key, double value) { + insertValue(position, key, new Double(value)); + } + + /** + * Inserts a new value at the specified position in the dataset or, if + * there is an existing item with the specified key, updates the value + * for that item and moves it to the specified position. After the change + * is made, this methods sends a {@link DatasetChangeEvent} to all + * registered listeners. + * + * @param position the position (in the range 0 to getItemCount()). + * @param key the key (null not permitted). + * @param value the value (null permitted). + * + * @since 1.0.6 + */ + public void insertValue(int position, Comparable key, Number value) { + this.data.insertValue(position, key, value); + fireDatasetChanged(); + } + + /** + * Removes an item from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param key the key (null not permitted). + * + * @throws IllegalArgumentException if key is + * null. + */ + public void remove(Comparable key) { + this.data.removeValue(key); + fireDatasetChanged(); + } + + /** + * Clears all data from this dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners (unless the dataset was already empty). + * + * @since 1.0.2 + */ + public void clear() { + if (getItemCount() > 0) { + this.data.clear(); + fireDatasetChanged(); + } + } + + /** + * Sorts the dataset's items by key and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param order the sort order (null not permitted). + * + * @since 1.0.3 + */ + public void sortByKeys(SortOrder order) { + this.data.sortByKeys(order); + fireDatasetChanged(); + } + + /** + * Sorts the dataset's items by value and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param order the sort order (null not permitted). + * + * @since 1.0.3 + */ + public void sortByValues(SortOrder order) { + this.data.sortByValues(order); + fireDatasetChanged(); + } + + /** + * Tests if this object is equal to another. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + + if (!(obj instanceof PieDataset)) { + return false; + } + PieDataset that = (PieDataset) obj; + int count = getItemCount(); + if (that.getItemCount() != count) { + return false; + } + + for (int i = 0; i < count; i++) { + Comparable k1 = getKey(i); + Comparable k2 = that.getKey(i); + if (!k1.equals(k2)) { + return false; + } + + Number v1 = getValue(i); + Number v2 = that.getValue(i); + if (v1 == null) { + if (v2 != null) { + return false; + } + } + else { + if (!v1.equals(v2)) { + return false; + } + } + } + return true; + + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return this.data.hashCode(); + } + + /** + * Returns a clone of the dataset. + * + * @return A clone. + * + * @throws CloneNotSupportedException This class will not throw this + * exception, but subclasses (if any) might. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultPieDataset clone = (DefaultPieDataset) super.clone(); + clone.data = (DefaultKeyedValues) this.data.clone(); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultValueDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultValueDataset.java new file mode 100755 index 0000000..496ffdf --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/DefaultValueDataset.java @@ -0,0 +1,142 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * DefaultValueDataset.java + * ------------------------ + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Mar-2003 : Version 1 (DG); + * 18-Aug-2003 : Implemented Cloneable (DG); + * 03-Mar-2005 : Implemented PublicCloneable (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 30-Jan-2007 : Added explicit super() call in constructor (for clarity) (DG); + * + */ + +package org.jfree.data.general; + +import java.io.Serializable; + +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A dataset that stores a single value (that is possibly null). + * This class provides a default implementation of the {@link ValueDataset} + * interface. + */ +public class DefaultValueDataset extends AbstractDataset + implements ValueDataset, Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 8137521217249294891L; + + /** The value. */ + private Number value; + + /** + * Constructs a new dataset, initially empty. + */ + public DefaultValueDataset() { + this(null); + } + + /** + * Creates a new dataset with the specified value. + * + * @param value the value. + */ + public DefaultValueDataset(double value) { + this(new Double(value)); + } + + /** + * Creates a new dataset with the specified value. + * + * @param value the initial value (null permitted). + */ + public DefaultValueDataset(Number value) { + super(); + this.value = value; + } + + /** + * Returns the value. + * + * @return The value (possibly null). + */ + @Override + public Number getValue() { + return this.value; + } + + /** + * Sets the value and sends a {@link DatasetChangeEvent} to all registered + * listeners. + * + * @param value the new value (null permitted). + */ + public void setValue(Number value) { + this.value = value; + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof ValueDataset) { + ValueDataset vd = (ValueDataset) obj; + return ObjectUtilities.equal(this.value, vd.getValue()); + } + return false; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return (this.value != null ? this.value.hashCode() : 0); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/HeatMapDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/HeatMapDataset.java new file mode 100755 index 0000000..619f2ef --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/HeatMapDataset.java @@ -0,0 +1,154 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * HeatMapDataset.java + * ------------------- + * (C) Copyright 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 28-Jan-2009 : Version 1 (DG); + * + */ + +package org.jfree.data.general; + +/** + * A dataset that represents a rectangular grid of (x, y, z) values. The x + * and y values appear at regular intervals in the dataset, while the z-values + * can take any value (including null for unknown values). + * + * @since 1.0.13 + */ +public interface HeatMapDataset { + + /** + * Returns the number of x values across the width of the dataset. The + * values are evenly spaced between {@link #getMinimumXValue()} and + * {@link #getMaximumXValue()}. + * + * @return The number of x-values (always > 0). + */ + public int getXSampleCount(); + + /** + * Returns the number of y values (or samples) for the dataset. The + * values are evenly spaced between {@link #getMinimumYValue()} and + * {@link #getMaximumYValue()}. + * + * @return The number of y-values (always > 0). + */ + public int getYSampleCount(); + + /** + * Returns the lowest x-value represented in this dataset. A requirement + * of this interface is that this method must never return infinite or + * Double.NAN values. + * + * @return The lowest x-value represented in this dataset. + */ + public double getMinimumXValue(); + + /** + * Returns the highest x-value represented in this dataset. A requirement + * of this interface is that this method must never return infinite or + * Double.NAN values. + * + * @return The highest x-value represented in this dataset. + */ + public double getMaximumXValue(); + + /** + * Returns the lowest y-value represented in this dataset. A requirement + * of this interface is that this method must never return infinite or + * Double.NAN values. + * + * @return The lowest y-value represented in this dataset. + */ + public double getMinimumYValue(); + + /** + * Returns the highest y-value represented in this dataset. A requirement + * of this interface is that this method must never return infinite or + * Double.NAN values. + * + * @return The highest y-value represented in this dataset. + */ + public double getMaximumYValue(); + + /** + * A convenience method that returns the x-value for the given index. + * + * @param xIndex the xIndex. + * + * @return The x-value. + */ + public double getXValue(int xIndex); + + /** + * A convenience method that returns the y-value for the given index. + * + * @param yIndex the yIndex. + * + * @return The y-value. + */ + public double getYValue(int yIndex); + + /** + * Returns the z-value at the specified sample position in the dataset. + * For a missing or unknown value, this method should return Double.NAN. + * + * @param xIndex the position of the x sample in the dataset. + * @param yIndex the position of the y sample in the dataset. + * + * @return The z-value. + */ + public double getZValue(int xIndex, int yIndex); + + /** + * Returns the z-value at the specified sample position in the dataset. + * This method can return null to indicate a missing/unknown + * value. + *

+ * Bear in mind that the class implementing this interface may + * store its data using primitives rather than objects, so calling this + * method may require a new Number object to be allocated... + * for this reason, it is generally preferable to use the + * {@link #getZValue(int, int)} method unless you *know* that the dataset + * implementation stores the z-values using objects. + * + * @param xIndex the position of the x sample in the dataset. + * @param yIndex the position of the y sample in the dataset. + * + * @return The z-value (possibly null). + */ + public Number getZ(int xIndex, int yIndex); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/HeatMapUtilities.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/HeatMapUtilities.java new file mode 100755 index 0000000..b5316e3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/HeatMapUtilities.java @@ -0,0 +1,132 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * HeatMapUtilities.java + * --------------------- + * (C) Copyright 2009-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 28-Jan-2009 : Version 1 (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.general; + +import java.awt.Graphics2D; +import java.awt.Paint; +import java.awt.image.BufferedImage; +import org.jfree.chart.renderer.PaintScale; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; + +/** + * A utility class for the {@link HeatMapDataset}. + * + * @since 1.0.13 + */ +public abstract class HeatMapUtilities { + + /** + * Returns a dataset containing one series that holds a copy of the (x, z) + * data from one row (y-index) of the specified dataset. + * + * @param dataset the dataset (null not permitted). + * @param row the row (y) index. + * @param seriesName the series name/key (null not permitted). + * + * @return The dataset. + */ + public static XYDataset extractRowFromHeatMapDataset(HeatMapDataset dataset, + int row, Comparable seriesName) { + XYSeries series = new XYSeries(seriesName); + int cols = dataset.getXSampleCount(); + for (int c = 0; c < cols; c++) { + series.add(dataset.getXValue(c), dataset.getZValue(c, row)); + } + XYSeriesCollection result = new XYSeriesCollection(series); + return result; + } + + /** + * Returns a dataset containing one series that holds a copy of the (y, z) + * data from one column (x-index) of the specified dataset. + * + * @param dataset the dataset (null not permitted). + * @param column the column (x) index. + * @param seriesName the series name (null not permitted). + * + * @return The dataset. + */ + public static XYDataset extractColumnFromHeatMapDataset( + HeatMapDataset dataset, int column, Comparable seriesName) { + XYSeries series = new XYSeries(seriesName); + int rows = dataset.getYSampleCount(); + for (int r = 0; r < rows; r++) { + series.add(dataset.getYValue(r), dataset.getZValue(column, r)); + } + XYSeriesCollection result = new XYSeriesCollection(series); + return result; + } + + /** + * Creates an image that displays the values from the specified dataset. + * + * @param dataset the dataset (null not permitted). + * @param paintScale the paint scale for the z-values (null + * not permitted). + * + * @return A buffered image. + */ + public static BufferedImage createHeatMapImage(HeatMapDataset dataset, + PaintScale paintScale) { + + ParamChecks.nullNotPermitted(dataset, "dataset"); + ParamChecks.nullNotPermitted(paintScale, "paintScale"); + int xCount = dataset.getXSampleCount(); + int yCount = dataset.getYSampleCount(); + BufferedImage image = new BufferedImage(xCount, yCount, + BufferedImage.TYPE_INT_ARGB); + Graphics2D g2 = image.createGraphics(); + for (int xIndex = 0; xIndex < xCount; xIndex++) { + for (int yIndex = 0; yIndex < yCount; yIndex++) { + double z = dataset.getZValue(xIndex, yIndex); + Paint p = paintScale.getPaint(z); + g2.setPaint(p); + g2.fillRect(xIndex, yCount - yIndex - 1, 1, 1); + } + } + return image; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/KeyedValueDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/KeyedValueDataset.java new file mode 100755 index 0000000..c81d8c8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/KeyedValueDataset.java @@ -0,0 +1,52 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * KeyedValueDataset.java + * ---------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 13-Mar-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.general; + +import org.jfree.data.KeyedValue; + +/** + * A dataset containing a single value. + */ +public interface KeyedValueDataset extends KeyedValue, Dataset { + + // no new methods required + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/KeyedValues2DDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/KeyedValues2DDataset.java new file mode 100755 index 0000000..c9760ce --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/KeyedValues2DDataset.java @@ -0,0 +1,55 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * KeyedValues2DDataset.java + * ----------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 13-Mar-2003 : Version 1 (DG); + * 23-Apr-2003 : Switched CategoryDataset and KeyedValues2DDataset so that + * CategoryDataset is the super interface (DG); + * + */ + +package org.jfree.data.general; + +import org.jfree.data.category.CategoryDataset; + +/** + * A dataset containing (key, value) data items. This dataset is equivalent + * to a {@link CategoryDataset} and is included for completeness only. + */ +public interface KeyedValues2DDataset extends CategoryDataset { + + // no new methods required + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/KeyedValuesDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/KeyedValuesDataset.java new file mode 100755 index 0000000..da7da1b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/KeyedValuesDataset.java @@ -0,0 +1,51 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * KeyedValuesDataset.java + * ----------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 05-Mar-2003 : Version 1 (DG); + * 24-Apr-2003 : Switched places with PieDataset (DG); + * + */ + +package org.jfree.data.general; + +/** + * A dataset containing (key, value) data items. + */ +public interface KeyedValuesDataset extends PieDataset { + + // no new methods required + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/PieDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/PieDataset.java new file mode 100755 index 0000000..26d4ed5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/PieDataset.java @@ -0,0 +1,60 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * PieDataset.java + * --------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Sam (oldman); + * + * Changes + * ------- + * 17-Nov-2001 : Version 1 (DG); + * 22-Jan-2002 : Removed the getCategoryCount() method, updated Javadoc + * comments (DG); + * 18-Apr-2002 : getCategories() now returns List instead of Set (oldman); + * 23-Oct-2002 : Reorganised the code: PieDataset now extends KeyedValues + * interface (DG); + * 04-Mar-2003 : Now just replicates the KeyedValuesDataset interface (DG); + * + */ + +package org.jfree.data.general; + +import org.jfree.data.KeyedValues; + +/** + * A general purpose dataset where values are associated with keys. As the + * name suggests, you can use this dataset to supply data for pie charts (refer + * to the {@link org.jfree.chart.plot.PiePlot} class). + */ +public interface PieDataset extends KeyedValues, Dataset { + + // no new methods added. + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/Series.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/Series.java new file mode 100755 index 0000000..570c2a6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/Series.java @@ -0,0 +1,422 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------- + * Series.java + * ----------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 15-Nov-2001 : Version 1 (DG); + * 29-Nov-2001 : Added cloning and property change support (DG); + * 30-Jan-2002 : Added a description attribute and changed the constructors to + * protected (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 13-Mar-2003 : Implemented Serializable (DG); + * 01-May-2003 : Added equals() method (DG); + * 26-Jun-2003 : Changed listener list to use EventListenerList - see bug + * 757027 (DG); + * 15-Oct-2003 : Added a flag to control whether or not change events are sent + * to registered listeners (DG); + * 19-May-2005 : Made abstract (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 04-May-2006 : Updated API docs (DG); + * 26-Sep-2007 : Added isEmpty() and getItemCount() methods (DG); + * 16-Oct-2011 : Added vetoable property change support for series name (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.general; + +import java.beans.PropertyChangeListener; +import java.beans.PropertyChangeSupport; +import java.beans.PropertyVetoException; +import java.beans.VetoableChangeListener; +import java.beans.VetoableChangeSupport; +import java.io.Serializable; + +import javax.swing.event.EventListenerList; + +import org.jfree.chart.util.ParamChecks; +import org.jfree.util.ObjectUtilities; + +/** + * Base class representing a data series. Subclasses are left to implement the + * actual data structures. + *

+ * The series has two properties ("Key" and "Description") for which you can + * register a PropertyChangeListener. + *

+ * You can also register a {@link SeriesChangeListener} to receive notification + * of changes to the series data. + */ +public abstract class Series implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -6906561437538683581L; + + /** The key for the series. */ + private Comparable key; + + /** A description of the series. */ + private String description; + + /** Storage for registered change listeners. */ + private EventListenerList listeners; + + /** Object to support property change notification. */ + private PropertyChangeSupport propertyChangeSupport; + + /** Object to support property change notification. */ + private VetoableChangeSupport vetoableChangeSupport; + + /** A flag that controls whether or not changes are notified. */ + private boolean notify; + + /** + * Creates a new series with the specified key. + * + * @param key the series key (null not permitted). + */ + protected Series(Comparable key) { + this(key, null); + } + + /** + * Creates a new series with the specified key and description. + * + * @param key the series key (null NOT permitted). + * @param description the series description (null permitted). + */ + protected Series(Comparable key, String description) { + ParamChecks.nullNotPermitted(key, "key"); + this.key = key; + this.description = description; + this.listeners = new EventListenerList(); + this.propertyChangeSupport = new PropertyChangeSupport(this); + this.vetoableChangeSupport = new VetoableChangeSupport(this); + this.notify = true; + } + + /** + * Returns the key for the series. + * + * @return The series key (never null). + * + * @see #setKey(Comparable) + */ + public Comparable getKey() { + return this.key; + } + + /** + * Sets the key for the series and sends a VetoableChangeEvent + * (with the property name "Key") to all registered listeners. For + * backwards compatibility, this method also fires a regular + * PropertyChangeEvent. If the key change is vetoed this + * method will throw an IllegalArgumentException. + * + * @param key the key (null not permitted). + * + * @see #getKey() + */ + public void setKey(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + Comparable old = this.key; + try { + // if this series belongs to a dataset, the dataset might veto the + // change if it results in two series within the dataset having the + // same key + this.vetoableChangeSupport.fireVetoableChange("Key", old, key); + this.key = key; + // prior to 1.0.14, we just fired a PropertyChange - so we need to + // keep doing this + this.propertyChangeSupport.firePropertyChange("Key", old, key); + } catch (PropertyVetoException e) { + throw new IllegalArgumentException(e.getMessage()); + } + } + + /** + * Returns a description of the series. + * + * @return The series description (possibly null). + * + * @see #setDescription(String) + */ + public String getDescription() { + return this.description; + } + + /** + * Sets the description of the series and sends a + * PropertyChangeEvent to all registered listeners. + * + * @param description the description (null permitted). + * + * @see #getDescription() + */ + public void setDescription(String description) { + String old = this.description; + this.description = description; + this.propertyChangeSupport.firePropertyChange("Description", old, + description); + } + + /** + * Returns the flag that controls whether or not change events are sent to + * registered listeners. + * + * @return A boolean. + * + * @see #setNotify(boolean) + */ + public boolean getNotify() { + return this.notify; + } + + /** + * Sets the flag that controls whether or not change events are sent to + * registered listeners. + * + * @param notify the new value of the flag. + * + * @see #getNotify() + */ + public void setNotify(boolean notify) { + if (this.notify != notify) { + this.notify = notify; + fireSeriesChanged(); + } + } + + /** + * Returns true if the series contains no data items, and + * false otherwise. + * + * @return A boolean. + * + * @since 1.0.7 + */ + public boolean isEmpty() { + return (getItemCount() == 0); + } + + /** + * Returns the number of data items in the series. + * + * @return The number of data items in the series. + */ + public abstract int getItemCount(); + + /** + * Returns a clone of the series. + *

+ * Notes: + *

    + *
  • No need to clone the name or description, since String object is + * immutable.
  • + *
  • We set the listener list to empty, since the listeners did not + * register with the clone.
  • + *
  • Same applies to the PropertyChangeSupport instance.
  • + *
+ * + * @return A clone of the series. + * + * @throws CloneNotSupportedException not thrown by this class, but + * subclasses may differ. + */ + @Override + public Object clone() throws CloneNotSupportedException { + Series clone = (Series) super.clone(); + clone.listeners = new EventListenerList(); + clone.propertyChangeSupport = new PropertyChangeSupport(clone); + clone.vetoableChangeSupport = new VetoableChangeSupport(clone); + return clone; + } + + /** + * Tests the series for equality with another object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Series)) { + return false; + } + Series that = (Series) obj; + if (!getKey().equals(that.getKey())) { + return false; + } + if (!ObjectUtilities.equal(getDescription(), that.getDescription())) { + return false; + } + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result; + result = this.key.hashCode(); + result = 29 * result + (this.description != null + ? this.description.hashCode() : 0); + return result; + } + + /** + * Registers an object with this series, to receive notification whenever + * the series changes. + *

+ * Objects being registered must implement the {@link SeriesChangeListener} + * interface. + * + * @param listener the listener to register. + */ + public void addChangeListener(SeriesChangeListener listener) { + this.listeners.add(SeriesChangeListener.class, listener); + } + + /** + * Deregisters an object, so that it not longer receives notification + * whenever the series changes. + * + * @param listener the listener to deregister. + */ + public void removeChangeListener(SeriesChangeListener listener) { + this.listeners.remove(SeriesChangeListener.class, listener); + } + + /** + * General method for signalling to registered listeners that the series + * has been changed. + */ + public void fireSeriesChanged() { + if (this.notify) { + notifyListeners(new SeriesChangeEvent(this)); + } + } + + /** + * Sends a change event to all registered listeners. + * + * @param event contains information about the event that triggered the + * notification. + */ + protected void notifyListeners(SeriesChangeEvent event) { + + Object[] listenerList = this.listeners.getListenerList(); + for (int i = listenerList.length - 2; i >= 0; i -= 2) { + if (listenerList[i] == SeriesChangeListener.class) { + ((SeriesChangeListener) listenerList[i + 1]).seriesChanged( + event); + } + } + + } + + /** + * Adds a property change listener to the series. + * + * @param listener the listener. + */ + public void addPropertyChangeListener(PropertyChangeListener listener) { + this.propertyChangeSupport.addPropertyChangeListener(listener); + } + + /** + * Removes a property change listener from the series. + * + * @param listener the listener. + */ + public void removePropertyChangeListener(PropertyChangeListener listener) { + this.propertyChangeSupport.removePropertyChangeListener(listener); + } + + /** + * Fires a property change event. + * + * @param property the property key. + * @param oldValue the old value. + * @param newValue the new value. + */ + protected void firePropertyChange(String property, Object oldValue, + Object newValue) { + this.propertyChangeSupport.firePropertyChange(property, oldValue, + newValue); + } + + /** + * Adds a vetoable property change listener to the series. + * + * @param listener the listener. + * + * @since 1.0.14 + */ + public void addVetoableChangeListener(VetoableChangeListener listener) { + this.vetoableChangeSupport.addVetoableChangeListener(listener); + } + + /** + * Removes a vetoable property change listener from the series. + * + * @param listener the listener. + * + * @since 1.0.14 + */ + public void removeVetoableChangeListener(VetoableChangeListener listener) { + this.vetoableChangeSupport.removeVetoableChangeListener(listener); + } + + /** + * Fires a vetoable property change event. + * + * @param property the property key. + * @param oldValue the old value. + * @param newValue the new value. + */ + protected void fireVetoableChange(String property, Object oldValue, + Object newValue) throws PropertyVetoException { + this.vetoableChangeSupport.fireVetoableChange(property, oldValue, + newValue); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SeriesChangeEvent.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SeriesChangeEvent.java new file mode 100755 index 0000000..4683f34 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SeriesChangeEvent.java @@ -0,0 +1,64 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * SeriesChangeEvent.java + * ---------------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 15-Nov-2001 : Version 1 (DG); + * 18-Aug-2003 : Implemented Serializable (DG); + * + */ + +package org.jfree.data.general; + +import java.io.Serializable; +import java.util.EventObject; + +/** + * An event with details of a change to a series. + */ +public class SeriesChangeEvent extends EventObject implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 1593866085210089052L; + + /** + * Constructs a new event. + * + * @param source the source of the change event. + */ + public SeriesChangeEvent(Object source) { + super(source); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SeriesChangeListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SeriesChangeListener.java new file mode 100755 index 0000000..ee771bd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SeriesChangeListener.java @@ -0,0 +1,59 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * SeriesChangeListener.java + * ------------------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 15-Nov-2001 : Version 1 (DG); + * 26-Jun-2003 : Now extends EventListener so we can use the EventListenerList + * mechanism (DG); + * + */ + +package org.jfree.data.general; + +import java.util.EventListener; + +/** + * Methods for receiving notification of changes to a data series. + */ +public interface SeriesChangeListener extends EventListener { + + /** + * Called when an observed series changes in some way. + * + * @param event information about the change. + */ + public void seriesChanged(SeriesChangeEvent event); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SeriesDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SeriesDataset.java new file mode 100755 index 0000000..3c5fb0f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SeriesDataset.java @@ -0,0 +1,90 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * SeriesDataset.java + * ------------------ + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 17-Nov-2001 : Version 1 (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 19-May-2005 : Changed getSeriesName() --> getSeriesKey() and added indexOf() + * method (DG); + * + */ + +package org.jfree.data.general; + +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.IntervalXYZDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYZDataset; + +/** + * The interface for a dataset consisting of one or many series of data. + * + * @see CategoryDataset + * @see IntervalXYDataset + * @see IntervalXYZDataset + * @see XYDataset + * @see XYZDataset + */ +public interface SeriesDataset extends Dataset { + + /** + * Returns the number of series in the dataset. + * + * @return The series count. + */ + public int getSeriesCount(); + + /** + * Returns the key for a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The key for the series. + */ + public Comparable getSeriesKey(int series); + + /** + * Returns the index of the series with the specified key, or -1 if there + * is no such series in the dataset. + * + * @param seriesKey the series key (null permitted). + * + * @return The index, or -1. + */ + public int indexOf(Comparable seriesKey); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SeriesException.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SeriesException.java new file mode 100755 index 0000000..80194ac --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SeriesException.java @@ -0,0 +1,64 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * SeriesException.java + * -------------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 15-Nov-2001 : Version 1 (DG); + * 26-Mar-2002 : Modified to extend RuntimeException rather than Exception (DG); + * 18-Aug-2003 : Implemented Serializable (DG); + * + */ + +package org.jfree.data.general; + +import java.io.Serializable; + +/** + * A general purpose exception class for data series. + */ +public class SeriesException extends RuntimeException implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -3667048387550852940L; + + /** + * Constructs a new series exception. + * + * @param message a message describing the exception. + */ + public SeriesException(String message) { + super(message); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SubSeriesDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SubSeriesDataset.java new file mode 100755 index 0000000..8d93f21 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/SubSeriesDataset.java @@ -0,0 +1,466 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * SubseriesDataset.java + * --------------------- + * (C) Copyright 2001-2009, by Bill Kelemen and Contributors. + * + * Original Author: Bill Kelemen; + * Contributor(s): Sylvain Vieujot; + * David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 06-Dec-2001 : Version 1 (BK); + * 05-Feb-2002 : Added SignalsDataset (and small change to HighLowDataset + * interface) as requested by Sylvain Vieujot (DG); + * 28-Feb-2002 : Fixed bug: missing map[series] in IntervalXYDataset and + * SignalsDataset methods (BK); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 06-May-2004 : Now extends AbstractIntervalXYDataset (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 29-Nov-2005 : Removed SignalsDataset (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * 04-Feb-2009 : Deprecated, this class won't be supported in version + * 1.2.0 (DG); + * + */ + +package org.jfree.data.general; + +import org.jfree.data.xy.AbstractIntervalXYDataset; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.OHLCDataset; +import org.jfree.data.xy.XYDataset; + +/** + * This class will create a dataset with one or more series from another + * {@link SeriesDataset}. + * + * @deprecated As of version 1.0.13. This class will be removed from + * JFreeChart 1.2.0 onwards. Anyone needing this facility will need to + * maintain it outside of JFreeChart. + */ +public class SubSeriesDataset extends AbstractIntervalXYDataset + implements OHLCDataset, IntervalXYDataset, CombinationDataset { + + /** The parent dataset. */ + private SeriesDataset parent = null; + + /** Storage for map. */ + private int[] map; // maps our series into our parent's + + /** + * Creates a SubSeriesDataset using one or more series from + * parent. The series to use are passed as an array of int. + * + * @param parent underlying dataset + * @param map int[] of series from parent to include in this Dataset + */ + public SubSeriesDataset(SeriesDataset parent, int[] map) { + this.parent = parent; + this.map = map; + } + + /** + * Creates a SubSeriesDataset using one series from parent. + * The series to is passed as an int. + * + * @param parent underlying dataset + * @param series series from parent to include in this Dataset + */ + public SubSeriesDataset(SeriesDataset parent, int series) { + this(parent, new int[] {series}); + } + + /////////////////////////////////////////////////////////////////////////// + // From HighLowDataset + /////////////////////////////////////////////////////////////////////////// + + /** + * Returns the high-value for the specified series and item. + *

+ * Note: throws ClassCastException if the series if not from a + * {@link OHLCDataset}. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The high-value for the specified series and item. + */ + @Override + public Number getHigh(int series, int item) { + return ((OHLCDataset) this.parent).getHigh(this.map[series], item); + } + + /** + * Returns the high-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The high-value. + */ + @Override + public double getHighValue(int series, int item) { + double result = Double.NaN; + Number high = getHigh(series, item); + if (high != null) { + result = high.doubleValue(); + } + return result; + } + + /** + * Returns the low-value for the specified series and item. + *

+ * Note: throws ClassCastException if the series if not from a + * {@link OHLCDataset}. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The low-value for the specified series and item. + */ + @Override + public Number getLow(int series, int item) { + return ((OHLCDataset) this.parent).getLow(this.map[series], item); + } + + /** + * Returns the low-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The low-value. + */ + @Override + public double getLowValue(int series, int item) { + double result = Double.NaN; + Number low = getLow(series, item); + if (low != null) { + result = low.doubleValue(); + } + return result; + } + + /** + * Returns the open-value for the specified series and item. + *

+ * Note: throws ClassCastException if the series if not from a + * {@link OHLCDataset}. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The open-value for the specified series and item. + */ + @Override + public Number getOpen(int series, int item) { + return ((OHLCDataset) this.parent).getOpen(this.map[series], item); + } + + /** + * Returns the open-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The open-value. + */ + @Override + public double getOpenValue(int series, int item) { + double result = Double.NaN; + Number open = getOpen(series, item); + if (open != null) { + result = open.doubleValue(); + } + return result; + } + + /** + * Returns the close-value for the specified series and item. + *

+ * Note: throws ClassCastException if the series if not from a + * {@link OHLCDataset}. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The close-value for the specified series and item. + */ + @Override + public Number getClose(int series, int item) { + return ((OHLCDataset) this.parent).getClose(this.map[series], item); + } + + /** + * Returns the close-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The close-value. + */ + @Override + public double getCloseValue(int series, int item) { + double result = Double.NaN; + Number close = getClose(series, item); + if (close != null) { + result = close.doubleValue(); + } + return result; + } + + /** + * Returns the volume. + *

+ * Note: throws ClassCastException if the series if not from a + * {@link OHLCDataset}. + * + * @param series the series (zero based index). + * @param item the item (zero based index). + * + * @return The volume. + */ + @Override + public Number getVolume(int series, int item) { + return ((OHLCDataset) this.parent).getVolume(this.map[series], item); + } + + /** + * Returns the volume-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The volume-value. + */ + @Override + public double getVolumeValue(int series, int item) { + double result = Double.NaN; + Number volume = getVolume(series, item); + if (volume != null) { + result = volume.doubleValue(); + } + return result; + } + + /////////////////////////////////////////////////////////////////////////// + // From XYDataset + /////////////////////////////////////////////////////////////////////////// + + /** + * Returns the X-value for the specified series and item. + *

+ * Note: throws ClassCastException if the series if not from a + * {@link XYDataset}. + * + * @param series the index of the series of interest (zero-based); + * @param item the index of the item of interest (zero-based). + * + * @return The X-value for the specified series and item. + */ + @Override + public Number getX(int series, int item) { + return ((XYDataset) this.parent).getX(this.map[series], item); + } + + /** + * Returns the Y-value for the specified series and item. + *

+ * Note: throws ClassCastException if the series if not from a + * {@link XYDataset}. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The Y-value for the specified series and item. + */ + @Override + public Number getY(int series, int item) { + return ((XYDataset) this.parent).getY(this.map[series], item); + } + + /** + * Returns the number of items in a series. + *

+ * Note: throws ClassCastException if the series if not from a + * {@link XYDataset}. + * + * @param series the index of the series of interest (zero-based). + * + * @return The number of items in a series. + */ + @Override + public int getItemCount(int series) { + return ((XYDataset) this.parent).getItemCount(this.map[series]); + } + + /////////////////////////////////////////////////////////////////////////// + // From SeriesDataset + /////////////////////////////////////////////////////////////////////////// + + /** + * Returns the number of series in the dataset. + * + * @return The number of series in the dataset. + */ + @Override + public int getSeriesCount() { + return this.map.length; + } + + /** + * Returns the key for a series. + * + * @param series the series (zero-based index). + * + * @return The name of a series. + */ + @Override + public Comparable getSeriesKey(int series) { + return this.parent.getSeriesKey(this.map[series]); + } + + /////////////////////////////////////////////////////////////////////////// + // From IntervalXYDataset + /////////////////////////////////////////////////////////////////////////// + + /** + * Returns the starting X value for the specified series and item. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The starting X value for the specified series and item. + */ + @Override + public Number getStartX(int series, int item) { + if (this.parent instanceof IntervalXYDataset) { + return ((IntervalXYDataset) this.parent).getStartX( + this.map[series], item + ); + } + else { + return getX(series, item); + } + } + + /** + * Returns the ending X value for the specified series and item. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The ending X value for the specified series and item. + */ + @Override + public Number getEndX(int series, int item) { + if (this.parent instanceof IntervalXYDataset) { + return ((IntervalXYDataset) this.parent).getEndX( + this.map[series], item + ); + } + else { + return getX(series, item); + } + } + + /** + * Returns the starting Y value for the specified series and item. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The starting Y value for the specified series and item. + */ + @Override + public Number getStartY(int series, int item) { + if (this.parent instanceof IntervalXYDataset) { + return ((IntervalXYDataset) this.parent).getStartY( + this.map[series], item + ); + } + else { + return getY(series, item); + } + } + + /** + * Returns the ending Y value for the specified series and item. + * + * @param series the index of the series of interest (zero-based). + * @param item the index of the item of interest (zero-based). + * + * @return The ending Y value for the specified series and item. + */ + @Override + public Number getEndY(int series, int item) { + if (this.parent instanceof IntervalXYDataset) { + return ((IntervalXYDataset) this.parent).getEndY( + this.map[series], item + ); + } + else { + return getY(series, item); + } + } + + /////////////////////////////////////////////////////////////////////////// + // New methods from CombinationDataset + /////////////////////////////////////////////////////////////////////////// + + /** + * Returns the parent Dataset of this combination. + * + * @return The parent Dataset of this combination. + */ + @Override + public SeriesDataset getParent() { + return this.parent; + } + + /** + * Returns a map or indirect indexing form our series into parent's series. + * + * @return A map or indirect indexing form our series into parent's series. + */ + @Override + public int[] getMap() { + return (int[]) this.map.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/ValueDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/ValueDataset.java new file mode 100755 index 0000000..22ef566 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/ValueDataset.java @@ -0,0 +1,52 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * ValueDataset.java + * ----------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 27-Mar-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.general; + +import org.jfree.data.Value; + +/** + * An interface for a dataset that returns a single value. + */ +public interface ValueDataset extends Value, Dataset { + + // no additional methods required + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/WaferMapDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/WaferMapDataset.java new file mode 100755 index 0000000..df88e4d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/WaferMapDataset.java @@ -0,0 +1,314 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * WaferMapDataset.java + * -------------------- + * (C)opyright 2003-2008, by Robert Redburn and Contributors. + * + * Original Author: Robert Redburn; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 25-Nov-2003 : Version 1 contributed by Robert Redburn (with some + * modifications to match style conventions) (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.general; + +import java.util.Set; +import java.util.TreeSet; + +import org.jfree.data.DefaultKeyedValues2D; + +/** + * A dataset that can be used with the {@link org.jfree.chart.plot.WaferMapPlot} + * class. + */ +public class WaferMapDataset extends AbstractDataset { + + /** + * Storage structure for the data values (row key is chipx, column is + * chipy) + */ + private DefaultKeyedValues2D data; + + /** wafer x dimension */ + private int maxChipX; + + /** wafer y dimension */ + private int maxChipY; + + /** space to draw between chips */ + private double chipSpace; + + /** maximum value in this dataset */ + private Double maxValue; + + /** minimum value in this dataset */ + private Double minValue; + + /** default chip spacing */ + private static final double DEFAULT_CHIP_SPACE = 1d; + + /** + * Creates a new dataset using the default chipspace. + * + * @param maxChipX the wafer x-dimension. + * @param maxChipY the wafer y-dimension. + */ + public WaferMapDataset(int maxChipX, int maxChipY) { + this(maxChipX, maxChipY, null); + } + + /** + * Creates a new dataset. + * + * @param maxChipX the wafer x-dimension. + * @param maxChipY the wafer y-dimension. + * @param chipSpace the space between chips. + */ + public WaferMapDataset(int maxChipX, int maxChipY, Number chipSpace) { + + this.maxValue = new Double(Double.NEGATIVE_INFINITY); + this.minValue = new Double(Double.POSITIVE_INFINITY); + this.data = new DefaultKeyedValues2D(); + + this.maxChipX = maxChipX; + this.maxChipY = maxChipY; + if (chipSpace == null) { + this.chipSpace = DEFAULT_CHIP_SPACE; + } + else { + this.chipSpace = chipSpace.doubleValue(); + } + + } + + /** + * Sets a value in the dataset. + * + * @param value the value. + * @param chipx the x-index for the chip. + * @param chipy the y-index for the chip. + */ + public void addValue(Number value, Comparable chipx, Comparable chipy) { + setValue(value, chipx, chipy); + } + + /** + * Adds a value to the dataset. + * + * @param v the value. + * @param x the x-index. + * @param y the y-index. + */ + public void addValue(int v, int x, int y) { + setValue(new Double(v), new Integer(x), new Integer(y)); + } + + /** + * Sets a value in the dataset and updates min and max value entries. + * + * @param value the value. + * @param chipx the x-index. + * @param chipy the y-index. + */ + public void setValue(Number value, Comparable chipx, Comparable chipy) { + this.data.setValue(value, chipx, chipy); + if (isMaxValue(value)) { + this.maxValue = (Double) value; + } + if (isMinValue(value)) { + this.minValue = (Double) value; + } + } + + /** + * Returns the number of unique values. + * + * @return The number of unique values. + */ + public int getUniqueValueCount() { + return getUniqueValues().size(); + } + + /** + * Returns the set of unique values. + * + * @return The set of unique values. + */ + public Set getUniqueValues() { + Set unique = new TreeSet(); + //step through all the values and add them to the hash + for (int r = 0; r < this.data.getRowCount(); r++) { + for (int c = 0; c < this.data.getColumnCount(); c++) { + Number value = this.data.getValue(r, c); + if (value != null) { + unique.add(value); + } + } + } + return unique; + } + + /** + * Returns the data value for a chip. + * + * @param chipx the x-index. + * @param chipy the y-index. + * + * @return The data value. + */ + public Number getChipValue(int chipx, int chipy) { + return getChipValue(new Integer(chipx), new Integer(chipy)); + } + + /** + * Returns the value for a given chip x and y or null. + * + * @param chipx the x-index. + * @param chipy the y-index. + * + * @return The data value. + */ + public Number getChipValue(Comparable chipx, Comparable chipy) { + int rowIndex = this.data.getRowIndex(chipx); + if (rowIndex < 0) { + return null; + } + int colIndex = this.data.getColumnIndex(chipy); + if (colIndex < 0) { + return null; + } + return this.data.getValue(rowIndex, colIndex); + } + + /** + * Tests to see if the passed value is larger than the stored maxvalue. + * + * @param check the number to check. + * + * @return A boolean. + */ + public boolean isMaxValue(Number check) { + if (check.doubleValue() > this.maxValue.doubleValue()) { + return true; + } + return false; + } + + /** + * Tests to see if the passed value is smaller than the stored minvalue. + * + * @param check the number to check. + * + * @return A boolean. + */ + public boolean isMinValue(Number check) { + if (check.doubleValue() < this.minValue.doubleValue()) { + return true; + } + return false; + } + + /** + * Returns the maximum value stored in the dataset. + * + * @return The maximum value. + */ + public Number getMaxValue() { + return this.maxValue; + } + + /** + * Returns the minimum value stored in the dataset. + * + * @return The minimum value. + */ + public Number getMinValue() { + return this.minValue; + } + + /** + * Returns the wafer x-dimension. + * + * @return The number of chips in the x-dimension. + */ + public int getMaxChipX() { + return this.maxChipX; + } + + /** + * Sets wafer x dimension. + * + * @param maxChipX the number of chips in the x-dimension. + */ + public void setMaxChipX(int maxChipX) { + this.maxChipX = maxChipX; + } + + /** + * Returns the number of chips in the y-dimension. + * + * @return The number of chips. + */ + public int getMaxChipY() { + return this.maxChipY; + } + + /** + * Sets the number of chips in the y-dimension. + * + * @param maxChipY the number of chips. + */ + public void setMaxChipY(int maxChipY) { + this.maxChipY = maxChipY; + } + + /** + * Returns the space to draw between chips. + * + * @return The space. + */ + public double getChipSpace() { + return this.chipSpace; + } + + /** + * Sets the space to draw between chips. + * + * @param space the space. + */ + public void setChipSpace(double space) { + this.chipSpace = space; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/package.html new file mode 100755 index 0000000..252a71d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/general/package.html @@ -0,0 +1,6 @@ + + + +Data interfaces and classes. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/io/CSV.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/io/CSV.java new file mode 100755 index 0000000..d7b8111 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/io/CSV.java @@ -0,0 +1,201 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------- + * CSV.java + * -------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 24-Nov-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.io; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.Reader; +import java.util.List; + +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.DefaultCategoryDataset; + +/** + * A utility class for reading {@link CategoryDataset} data from a CSV file. + * This initial version is very basic, and won't handle errors in the data + * file very gracefully. + */ +public class CSV { + + /** The field delimiter. */ + private char fieldDelimiter; + + /** The text delimiter. */ + private char textDelimiter; + + /** + * Creates a new CSV reader where the field delimiter is a comma, and the + * text delimiter is a double-quote. + */ + public CSV() { + this(',', '"'); + } + + /** + * Creates a new reader with the specified field and text delimiters. + * + * @param fieldDelimiter the field delimiter (usually a comma, semi-colon, + * colon, tab or space). + * @param textDelimiter the text delimiter (usually a single or double + * quote). + */ + public CSV(char fieldDelimiter, char textDelimiter) { + this.fieldDelimiter = fieldDelimiter; + this.textDelimiter = textDelimiter; + } + + /** + * Reads a {@link CategoryDataset} from a CSV file or input source. + * + * @param in the input source. + * + * @return A category dataset. + * + * @throws IOException if there is an I/O problem. + */ + public CategoryDataset readCategoryDataset(Reader in) throws IOException { + + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + BufferedReader reader = new BufferedReader(in); + List columnKeys = null; + int lineIndex = 0; + String line = reader.readLine(); + while (line != null) { + if (lineIndex == 0) { // first line contains column keys + columnKeys = extractColumnKeys(line); + } + else { // remaining lines contain a row key and data values + extractRowKeyAndData(line, dataset, columnKeys); + } + line = reader.readLine(); + lineIndex++; + } + return dataset; + + } + + /** + * Extracts the column keys from a string. + * + * @param line a line from the input file. + * + * @return A list of column keys. + */ + private List extractColumnKeys(String line) { + List keys = new java.util.ArrayList(); + int fieldIndex = 0; + int start = 0; + for (int i = 0; i < line.length(); i++) { + if (line.charAt(i) == this.fieldDelimiter) { + if (fieldIndex > 0) { // first field is ignored, since + // column 0 is for row keys + String key = line.substring(start, i); + keys.add(removeStringDelimiters(key)); + } + start = i + 1; + fieldIndex++; + } + } + String key = line.substring(start, line.length()); + keys.add(removeStringDelimiters(key)); + return keys; + } + + /** + * Extracts the row key and data for a single line from the input source. + * + * @param line the line from the input source. + * @param dataset the dataset to be populated. + * @param columnKeys the column keys. + */ + private void extractRowKeyAndData(String line, + DefaultCategoryDataset dataset, + List columnKeys) { + Comparable rowKey = null; + int fieldIndex = 0; + int start = 0; + for (int i = 0; i < line.length(); i++) { + if (line.charAt(i) == this.fieldDelimiter) { + if (fieldIndex == 0) { // first field contains the row key + String key = line.substring(start, i); + rowKey = removeStringDelimiters(key); + } + else { // remaining fields contain values + Double value = Double.valueOf( + removeStringDelimiters(line.substring(start, i)) + ); + dataset.addValue( + value, rowKey, + (Comparable) columnKeys.get(fieldIndex - 1) + ); + } + start = i + 1; + fieldIndex++; + } + } + Double value = Double.valueOf( + removeStringDelimiters(line.substring(start, line.length())) + ); + dataset.addValue( + value, rowKey, (Comparable) columnKeys.get(fieldIndex - 1) + ); + } + + /** + * Removes the string delimiters from a key (as well as any white space + * outside the delimiters). + * + * @param key the key (including delimiters). + * + * @return The key without delimiters. + */ + private String removeStringDelimiters(String key) { + String k = key.trim(); + if (k.charAt(0) == this.textDelimiter) { + k = k.substring(1); + } + if (k.charAt(k.length() - 1) == this.textDelimiter) { + k = k.substring(0, k.length() - 1); + } + return k; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/io/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/io/package.html new file mode 100755 index 0000000..a079f33 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/io/package.html @@ -0,0 +1,6 @@ + + + +Miscellaneous support for input/output of data. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/jdbc/JDBCCategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/jdbc/JDBCCategoryDataset.java new file mode 100755 index 0000000..742e4b4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/jdbc/JDBCCategoryDataset.java @@ -0,0 +1,318 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * JDBCCategoryDataset.java + * ------------------------ + * (C) Copyright 2002-2008, by Bryan Scott and Contributors. + * + * Original Author: Bryan Scott; Andy; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Thomas Morgner; + * + * Changes + * ------- + * 26-Apr-2002 : Creation based on JdbcXYDataSet, using code contributed from + * Andy; + * 13-Aug-2002 : Updated Javadocs, import statements and formatting (DG); + * 03-Sep-2002 : Added fix for bug 591385 (DG); + * 18-Sep-2002 : Updated to support BIGINT (BS); + * 16-Oct-2002 : Added fix for bug 586667 (DG); + * 03-Feb-2003 : Added Types.DECIMAL (see bug report 677814) (DG); + * 13-Jun-2003 : Added Types.TIME as suggest by Bryan Scott in the forum (DG); + * 30-Jun-2003 : CVS Write test (BS); + * 30-Jul-2003 : Added empty contructor and executeQuery(connection,string) + * method (BS); + * 29-Aug-2003 : Added a 'transpose' flag, so that data can be easily + * transposed if required (DG); + * 10-Sep-2003 : Added support for additional JDBC types (DG); + * 24-Sep-2003 : Added clearing results from previous queries to executeQuery + * following being highlighted on online forum (BS); + * 02-Dec-2003 : Throwing exceptions allows to handle errors, removed default + * constructor, as without a connection, a query can never be + * executed (TM); + * 04-Dec-2003 : Added missing Javadocs (DG); + * ------------- JFREECHART 1.0.0 --------------------------------------------- + * 08-Mar-2006 : Fixed bug 1445748 where an exception is thrown if + * executeQuery() is called more than once (DG); + * + */ + +package org.jfree.data.jdbc; + +import java.sql.Connection; +import java.sql.Date; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Types; + +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.DefaultCategoryDataset; + +/** + * A {@link CategoryDataset} implementation over a database JDBC result set. + * The dataset is populated via a call to {@link #executeQuery(String)} with + * the string SQL query. The SQL query must return at least two columns. The + * first column will be the category name and remaining columns values (each + * column represents a series). Subsequent calls to + * {@link #executeQuery(String)} will refresh the dataset. + *

+ * The database connection is read-only and no write back facility exists. + *

+ * NOTE: Many people have found this class too restrictive in general use. + * For the greatest flexibility, please consider writing your own code to read + * data from a ResultSet and populate a + * {@link DefaultCategoryDataset} directly. + */ +public class JDBCCategoryDataset extends DefaultCategoryDataset { + + /** For serialization. */ + static final long serialVersionUID = -3080395327918844965L; + + /** The database connection. */ + private transient Connection connection; + + /** + * A flag the controls whether or not the table is transposed. The default + * is 'true' because this provides the behaviour described in the + * documentation. + */ + private boolean transpose = true; + + + /** + * Creates a new dataset with a database connection. + * + * @param url the URL of the database connection. + * @param driverName the database driver class name. + * @param user the database user. + * @param passwd the database user's password. + * + * @throws ClassNotFoundException if the driver cannot be found. + * @throws SQLException if there is an error obtaining a connection to the + * database. + */ + public JDBCCategoryDataset(String url, + String driverName, + String user, + String passwd) + throws ClassNotFoundException, SQLException { + + Class.forName(driverName); + this.connection = DriverManager.getConnection(url, user, passwd); + } + + /** + * Create a new dataset with the given database connection. + * + * @param connection the database connection. + */ + public JDBCCategoryDataset(Connection connection) { + if (connection == null) { + throw new NullPointerException("A connection must be supplied."); + } + this.connection = connection; + } + + /** + * Creates a new dataset with the given database connection, and executes + * the supplied query to populate the dataset. + * + * @param connection the connection. + * @param query the query. + * + * @throws SQLException if there is a problem executing the query. + */ + public JDBCCategoryDataset(Connection connection, String query) + throws SQLException { + this(connection); + executeQuery(query); + } + + /** + * Returns a flag that controls whether or not the table values are + * transposed when added to the dataset. + * + * @return A boolean. + */ + public boolean getTranspose() { + return this.transpose; + } + + /** + * Sets a flag that controls whether or not the table values are transposed + * when added to the dataset. + * + * @param transpose the flag. + */ + public void setTranspose(boolean transpose) { + this.transpose = transpose; + } + + /** + * Populates the dataset by executing the supplied query against the + * existing database connection. If no connection exists then no action + * is taken. + *

+ * The results from the query are extracted and cached locally, thus + * applying an upper limit on how many rows can be retrieved successfully. + * + * @param query the query. + * + * @throws SQLException if there is a problem executing the query. + */ + public void executeQuery(String query) throws SQLException { + executeQuery(this.connection, query); + } + + /** + * Populates the dataset by executing the supplied query against the + * existing database connection. If no connection exists then no action + * is taken. + *

+ * The results from the query are extracted and cached locally, thus + * applying an upper limit on how many rows can be retrieved successfully. + * + * @param con the connection. + * @param query the query. + * + * @throws SQLException if there is a problem executing the query. + */ + public void executeQuery(Connection con, String query) throws SQLException { + + Statement statement = null; + ResultSet resultSet = null; + try { + statement = con.createStatement(); + resultSet = statement.executeQuery(query); + ResultSetMetaData metaData = resultSet.getMetaData(); + + int columnCount = metaData.getColumnCount(); + + if (columnCount < 2) { + throw new SQLException( + "JDBCCategoryDataset.executeQuery() : insufficient columns " + + "returned from the database."); + } + + // Remove any previous old data + int i = getRowCount(); + while (--i >= 0) { + removeRow(i); + } + + while (resultSet.next()) { + // first column contains the row key... + Comparable rowKey = resultSet.getString(1); + for (int column = 2; column <= columnCount; column++) { + + Comparable columnKey = metaData.getColumnName(column); + int columnType = metaData.getColumnType(column); + + switch (columnType) { + case Types.TINYINT: + case Types.SMALLINT: + case Types.INTEGER: + case Types.BIGINT: + case Types.FLOAT: + case Types.DOUBLE: + case Types.DECIMAL: + case Types.NUMERIC: + case Types.REAL: { + Number value = (Number) resultSet.getObject(column); + if (this.transpose) { + setValue(value, columnKey, rowKey); + } + else { + setValue(value, rowKey, columnKey); + } + break; + } + case Types.DATE: + case Types.TIME: + case Types.TIMESTAMP: { + Date date = (Date) resultSet.getObject(column); + Number value = new Long(date.getTime()); + if (this.transpose) { + setValue(value, columnKey, rowKey); + } + else { + setValue(value, rowKey, columnKey); + } + break; + } + case Types.CHAR: + case Types.VARCHAR: + case Types.LONGVARCHAR: { + String string + = (String) resultSet.getObject(column); + try { + Number value = Double.valueOf(string); + if (this.transpose) { + setValue(value, columnKey, rowKey); + } + else { + setValue(value, rowKey, columnKey); + } + } + catch (NumberFormatException e) { + // suppress (value defaults to null) + } + break; + } + default: + // not a value, can't use it (defaults to null) + break; + } + } + } + + fireDatasetChanged(); + } + finally { + if (resultSet != null) { + try { + resultSet.close(); + } + catch (Exception e) { + // report this? + } + } + if (statement != null) { + try { + statement.close(); + } + catch (Exception e) { + // report this? + } + } + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/jdbc/JDBCPieDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/jdbc/JDBCPieDataset.java new file mode 100755 index 0000000..2f473c4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/jdbc/JDBCPieDataset.java @@ -0,0 +1,250 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * JDBCPieDataset.java + * ------------------- + * (C) Copyright 2002-2009, by Bryan Scott and Contributors. + * + * Original Author: Bryan Scott; Andy + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Thomas Morgner; + * + * Changes + * ------- + * 26-Apr-2002 : Creation based on JdbcXYDataSet, but extending + * DefaultPieDataset (BS); + * 24-Jun-2002 : Removed unnecessary import and local variable (DG); + * 13-Aug-2002 : Updated Javadoc comments and imports, removed default + * constructor (DG); + * 18-Sep-2002 : Updated to support BIGINT (BS); + * 21-Jan-2003 : Renamed JdbcPieDataset --> JDBCPieDataset (DG); + * 03-Feb-2003 : Added Types.DECIMAL (see bug report 677814) (DG); + * 05-Jun-2003 : Updated to support TIME, optimised executeQuery method (BS); + * 30-Jul-2003 : Added empty contructor and executeQuery(connection,string) + * method (BS); + * 02-Dec-2003 : Throwing exceptions allows to handle errors, removed default + * constructor, as without a connection, a query can never be + * executed (TM); + * 04-Dec-2003 : Added missing Javadocs (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * + */ + +package org.jfree.data.jdbc; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Timestamp; +import java.sql.Types; + +import org.jfree.data.general.DefaultPieDataset; +import org.jfree.data.general.PieDataset; + +/** + * A {@link PieDataset} that reads data from a database via JDBC. + *

+ * A query should be supplied that returns data in two columns, the first + * containing VARCHAR data, and the second containing numerical data. The + * data is cached in-memory and can be refreshed at any time. + */ +public class JDBCPieDataset extends DefaultPieDataset { + + /** For serialization. */ + static final long serialVersionUID = -8753216855496746108L; + + /** The database connection. */ + private transient Connection connection; + + /** + * Creates a new JDBCPieDataset and establishes a new database connection. + * + * @param url the URL of the database connection. + * @param driverName the database driver class name. + * @param user the database user. + * @param password the database users password. + * + * @throws ClassNotFoundException if the driver cannot be found. + * @throws SQLException if there is a problem obtaining a database + * connection. + */ + public JDBCPieDataset(String url, + String driverName, + String user, + String password) + throws SQLException, ClassNotFoundException { + + Class.forName(driverName); + this.connection = DriverManager.getConnection(url, user, password); + } + + /** + * Creates a new JDBCPieDataset using a pre-existing database connection. + *

+ * The dataset is initially empty, since no query has been supplied yet. + * + * @param con the database connection. + */ + public JDBCPieDataset(Connection con) { + if (con == null) { + throw new NullPointerException("A connection must be supplied."); + } + this.connection = con; + } + + + /** + * Creates a new JDBCPieDataset using a pre-existing database connection. + *

+ * The dataset is initialised with the supplied query. + * + * @param con the database connection. + * @param query the database connection. + * + * @throws SQLException if there is a problem executing the query. + */ + public JDBCPieDataset(Connection con, String query) throws SQLException { + this(con); + executeQuery(query); + } + + /** + * ExecuteQuery will attempt execute the query passed to it against the + * existing database connection. If no connection exists then no action + * is taken. + * The results from the query are extracted and cached locally, thus + * applying an upper limit on how many rows can be retrieved successfully. + * + * @param query the query to be executed. + * + * @throws SQLException if there is a problem executing the query. + */ + public void executeQuery(String query) throws SQLException { + executeQuery(this.connection, query); + } + + /** + * ExecuteQuery will attempt execute the query passed to it against the + * existing database connection. If no connection exists then no action + * is taken. + * The results from the query are extracted and cached locally, thus + * applying an upper limit on how many rows can be retrieved successfully. + * + * @param query the query to be executed + * @param con the connection the query is to be executed against + * + * @throws SQLException if there is a problem executing the query. + */ + public void executeQuery(Connection con, String query) throws SQLException { + + Statement statement = null; + ResultSet resultSet = null; + + try { + statement = con.createStatement(); + resultSet = statement.executeQuery(query); + ResultSetMetaData metaData = resultSet.getMetaData(); + + int columnCount = metaData.getColumnCount(); + if (columnCount != 2) { + throw new SQLException( + "Invalid sql generated. PieDataSet requires 2 columns only" + ); + } + + int columnType = metaData.getColumnType(2); + double value; + while (resultSet.next()) { + Comparable key = resultSet.getString(1); + switch (columnType) { + case Types.NUMERIC: + case Types.REAL: + case Types.INTEGER: + case Types.DOUBLE: + case Types.FLOAT: + case Types.DECIMAL: + case Types.BIGINT: + value = resultSet.getDouble(2); + setValue(key, value); + break; + + case Types.DATE: + case Types.TIME: + case Types.TIMESTAMP: + Timestamp date = resultSet.getTimestamp(2); + value = date.getTime(); + setValue(key, value); + break; + + default: + System.err.println( + "JDBCPieDataset - unknown data type"); + break; + } + } + + fireDatasetChanged(); + + } + finally { + if (resultSet != null) { + try { + resultSet.close(); + } + catch (Exception e) { + System.err.println("JDBCPieDataset: swallowing exception."); + } + } + if (statement != null) { + try { + statement.close(); + } + catch (Exception e) { + System.err.println("JDBCPieDataset: swallowing exception."); + } + } + } + } + + + /** + * Close the database connection + */ + public void close() { + try { + this.connection.close(); + } + catch (Exception e) { + System.err.println("JdbcXYDataset: swallowing exception."); + } + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/jdbc/JDBCXYDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/jdbc/JDBCXYDataset.java new file mode 100755 index 0000000..7b0854c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/jdbc/JDBCXYDataset.java @@ -0,0 +1,594 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * JDBCXYDataset.java + * ------------------ + * (C) Copyright 2002-2009, by Bryan Scott and Contributors. + * + * Original Author: Bryan Scott; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Eric Alexander; + * + * + * Changes + * ------- + * 14-Mar-2002 : Version 1 contributed by Bryan Scott (DG); + * 19-Apr-2002 : Updated executeQuery, to close cursors and to improve support + * for types. + * 26-Apr-2002 : Renamed JdbcXYDataset to better fit in with the existing data + * source conventions. + * 26-Apr-2002 : Changed to extend AbstractDataset. + * 13-Aug-2002 : Updated Javadoc comments and imports (DG); + * 18-Sep-2002 : Updated to support BIGINT (BS); + * 21-Jan-2003 : Renamed JdbcXYDataset --> JDBCXYDataset (DG); + * 01-Jul-2003 : Added support to query whether a timeseries (BS); + * 30-Jul-2003 : Added empty contructor and executeQuery(connection,string) + * method (BS); + * 24-Sep-2003 : Added a check to ensure at least two valid columns are + * returned by the query in executeQuery as suggest in online + * forum by anonymous (BS); + * 02-Dec-2003 : Throwing exceptions allows to handle errors, removed default + * constructor, as without a connection, a query can never be + * executed. + * 16-Mar-2004 : Added check for null values (EA); + * 05-May-2004 : Now extends AbstractXYDataset (DG); + * 21-May-2004 : Implemented TableXYDataset, added support for SMALLINT and + * fixed bug in code that determines the min and max values (see + * bug id 938138) (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 18-Nov-2004 : Updated for changes in RangeInfo interface (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 17-Oct-2006 : Deprecated unused methods - see bug 1578293 (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * + */ + +package org.jfree.data.jdbc; + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.ResultSet; +import java.sql.ResultSetMetaData; +import java.sql.SQLException; +import java.sql.Statement; +import java.sql.Types; +import java.util.ArrayList; +import java.util.Date; + +import org.jfree.data.Range; +import org.jfree.data.RangeInfo; +import org.jfree.data.general.Dataset; +import org.jfree.data.xy.AbstractXYDataset; +import org.jfree.data.xy.TableXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.util.Log; + +/** + * This class provides an {@link XYDataset} implementation over a database + * JDBC result set. The dataset is populated via a call to executeQuery with + * the string sql query. The sql query must return at least two columns. + * The first column will be the x-axis and remaining columns y-axis values. + * executeQuery can be called a number of times. + * + * The database connection is read-only and no write back facility exists. + */ +public class JDBCXYDataset extends AbstractXYDataset + implements XYDataset, TableXYDataset, RangeInfo { + + /** The database connection. */ + private transient Connection connection; + + /** Column names. */ + private String[] columnNames = {}; + + /** Rows. */ + private ArrayList rows; + + /** The maximum y value of the returned result set */ + private double maxValue = 0.0; + + /** The minimum y value of the returned result set */ + private double minValue = 0.0; + + /** Is this dataset a timeseries ? */ + private boolean isTimeSeries = false; + + /** + * Creates a new JDBCXYDataset (initially empty) with no database + * connection. + */ + private JDBCXYDataset() { + this.rows = new ArrayList(); + } + + /** + * Creates a new dataset (initially empty) and establishes a new database + * connection. + * + * @param url URL of the database connection. + * @param driverName the database driver class name. + * @param user the database user. + * @param password the database user's password. + * + * @throws ClassNotFoundException if the driver cannot be found. + * @throws SQLException if there is a problem connecting to the database. + */ + public JDBCXYDataset(String url, + String driverName, + String user, + String password) + throws SQLException, ClassNotFoundException { + + this(); + Class.forName(driverName); + this.connection = DriverManager.getConnection(url, user, password); + } + + /** + * Creates a new dataset (initially empty) using the specified database + * connection. + * + * @param con the database connection. + * + * @throws SQLException if there is a problem connecting to the database. + */ + public JDBCXYDataset(Connection con) throws SQLException { + this(); + this.connection = con; + } + + /** + * Creates a new dataset using the specified database connection, and + * populates it using data obtained with the supplied query. + * + * @param con the connection. + * @param query the SQL query. + * + * @throws SQLException if there is a problem executing the query. + */ + public JDBCXYDataset(Connection con, String query) throws SQLException { + this(con); + executeQuery(query); + } + + /** + * Returns true if the dataset represents time series data, + * and false otherwise. + * + * @return A boolean. + */ + public boolean isTimeSeries() { + return this.isTimeSeries; + } + + /** + * Sets a flag that indicates whether or not the data represents a time + * series. + * + * @param timeSeries the new value of the flag. + */ + public void setTimeSeries(boolean timeSeries) { + this.isTimeSeries = timeSeries; + } + + /** + * ExecuteQuery will attempt execute the query passed to it against the + * existing database connection. If no connection exists then no action + * is taken. + * + * The results from the query are extracted and cached locally, thus + * applying an upper limit on how many rows can be retrieved successfully. + * + * @param query the query to be executed. + * + * @throws SQLException if there is a problem executing the query. + */ + public void executeQuery(String query) throws SQLException { + executeQuery(this.connection, query); + } + + /** + * ExecuteQuery will attempt execute the query passed to it against the + * provided database connection. If connection is null then no action is + * taken. + * + * The results from the query are extracted and cached locally, thus + * applying an upper limit on how many rows can be retrieved successfully. + * + * @param query the query to be executed. + * @param con the connection the query is to be executed against. + * + * @throws SQLException if there is a problem executing the query. + */ + public void executeQuery(Connection con, String query) + throws SQLException { + + if (con == null) { + throw new SQLException( + "There is no database to execute the query." + ); + } + + ResultSet resultSet = null; + Statement statement = null; + try { + statement = con.createStatement(); + resultSet = statement.executeQuery(query); + ResultSetMetaData metaData = resultSet.getMetaData(); + + int numberOfColumns = metaData.getColumnCount(); + int numberOfValidColumns = 0; + int [] columnTypes = new int[numberOfColumns]; + for (int column = 0; column < numberOfColumns; column++) { + try { + int type = metaData.getColumnType(column + 1); + switch (type) { + + case Types.NUMERIC: + case Types.REAL: + case Types.INTEGER: + case Types.DOUBLE: + case Types.FLOAT: + case Types.DECIMAL: + case Types.BIT: + case Types.DATE: + case Types.TIME: + case Types.TIMESTAMP: + case Types.BIGINT: + case Types.SMALLINT: + ++numberOfValidColumns; + columnTypes[column] = type; + break; + default: + Log.warn( + "Unable to load column " + + column + " (" + type + "," + + metaData.getColumnClassName(column + 1) + + ")" + ); + columnTypes[column] = Types.NULL; + break; + } + } + catch (SQLException e) { + columnTypes[column] = Types.NULL; + throw e; + } + } + + + if (numberOfValidColumns <= 1) { + throw new SQLException( + "Not enough valid columns where generated by query." + ); + } + + /// First column is X data + this.columnNames = new String[numberOfValidColumns - 1]; + /// Get the column names and cache them. + int currentColumn = 0; + for (int column = 1; column < numberOfColumns; column++) { + if (columnTypes[column] != Types.NULL) { + this.columnNames[currentColumn] + = metaData.getColumnLabel(column + 1); + ++currentColumn; + } + } + + // Might need to add, to free memory from any previous result sets + if (this.rows != null) { + for (int column = 0; column < this.rows.size(); column++) { + ArrayList row = (ArrayList) this.rows.get(column); + row.clear(); + } + this.rows.clear(); + } + + // Are we working with a time series. + switch (columnTypes[0]) { + case Types.DATE: + case Types.TIME: + case Types.TIMESTAMP: + this.isTimeSeries = true; + break; + default : + this.isTimeSeries = false; + break; + } + + // Get all rows. + // rows = new ArrayList(); + while (resultSet.next()) { + ArrayList newRow = new ArrayList(); + for (int column = 0; column < numberOfColumns; column++) { + Object xObject = resultSet.getObject(column + 1); + switch (columnTypes[column]) { + case Types.NUMERIC: + case Types.REAL: + case Types.INTEGER: + case Types.DOUBLE: + case Types.FLOAT: + case Types.DECIMAL: + case Types.BIGINT: + case Types.SMALLINT: + newRow.add(xObject); + break; + + case Types.DATE: + case Types.TIME: + case Types.TIMESTAMP: + newRow.add(new Long(((Date) xObject).getTime())); + break; + case Types.NULL: + break; + default: + System.err.println("Unknown data"); + columnTypes[column] = Types.NULL; + break; + } + } + this.rows.add(newRow); + } + + /// a kludge to make everything work when no rows returned + if (this.rows.isEmpty()) { + ArrayList newRow = new ArrayList(); + for (int column = 0; column < numberOfColumns; column++) { + if (columnTypes[column] != Types.NULL) { + newRow.add(new Integer(0)); + } + } + this.rows.add(newRow); + } + + /// Determine max and min values. + if (this.rows.size() < 1) { + this.maxValue = 0.0; + this.minValue = 0.0; + } + else { + this.maxValue = Double.NEGATIVE_INFINITY; + this.minValue = Double.POSITIVE_INFINITY; + for (int rowNum = 0; rowNum < this.rows.size(); ++rowNum) { + ArrayList row = (ArrayList) this.rows.get(rowNum); + for (int column = 1; column < numberOfColumns; column++) { + Object testValue = row.get(column); + if (testValue != null) { + double test = ((Number) testValue).doubleValue(); + + if (test < this.minValue) { + this.minValue = test; + } + if (test > this.maxValue) { + this.maxValue = test; + } + } + } + } + } + + fireDatasetChanged(); // Tell the listeners a new table has arrived. + } + finally { + if (resultSet != null) { + try { + resultSet.close(); + } + catch (Exception e) { + // TODO: is this a good idea? + } + } + if (statement != null) { + try { + statement.close(); + } + catch (Exception e) { + // TODO: is this a good idea? + } + } + } + + } + + /** + * Returns the x-value for the specified series and item. The + * implementation is responsible for ensuring that the x-values are + * presented in ascending order. + * + * @param seriesIndex the series (zero-based index). + * @param itemIndex the item (zero-based index). + * + * @return The x-value + * + * @see XYDataset + */ + @Override + public Number getX(int seriesIndex, int itemIndex) { + ArrayList row = (ArrayList) this.rows.get(itemIndex); + return (Number) row.get(0); + } + + /** + * Returns the y-value for the specified series and item. + * + * @param seriesIndex the series (zero-based index). + * @param itemIndex the item (zero-based index). + * + * @return The yValue value + * + * @see XYDataset + */ + @Override + public Number getY(int seriesIndex, int itemIndex) { + ArrayList row = (ArrayList) this.rows.get(itemIndex); + return (Number) row.get(seriesIndex + 1); + } + + /** + * Returns the number of items in the specified series. + * + * @param seriesIndex the series (zero-based index). + * + * @return The itemCount value + * + * @see XYDataset + */ + @Override + public int getItemCount(int seriesIndex) { + return this.rows.size(); + } + + /** + * Returns the number of items in all series. This method is defined by + * the {@link TableXYDataset} interface. + * + * @return The item count. + */ + @Override + public int getItemCount() { + return getItemCount(0); + } + + /** + * Returns the number of series in the dataset. + * + * @return The seriesCount value + * + * @see XYDataset + * @see Dataset + */ + @Override + public int getSeriesCount() { + return this.columnNames.length; + } + + /** + * Returns the key for the specified series. + * + * @param seriesIndex the series (zero-based index). + * + * @return The seriesName value + * + * @see XYDataset + * @see Dataset + */ + @Override + public Comparable getSeriesKey(int seriesIndex) { + + if ((seriesIndex < this.columnNames.length) + && (this.columnNames[seriesIndex] != null)) { + return this.columnNames[seriesIndex]; + } + else { + return ""; + } + + } + + /** + * Returns the number of items that should be displayed in the legend. + * + * @return The legendItemCount value + * + * @deprecated This method is not used in JFreeChart 1.0.x (it was left in + * the API by mistake and is officially deprecated from version 1.0.3 + * onwards). + */ + public int getLegendItemCount() { + return getSeriesCount(); + } + + /** + * Returns the legend item labels. + * + * @return The legend item labels. + * + * @deprecated This method is not used in JFreeChart 1.0.x (it was left in + * the API by mistake and is officially deprecated from version 1.0.3 + * onwards). + */ + public String[] getLegendItemLabels() { + return this.columnNames; + } + + /** + * Close the database connection + */ + public void close() { + + try { + this.connection.close(); + } + catch (Exception e) { + System.err.println("JdbcXYDataset: swallowing exception."); + } + + } + + /** + * Returns the minimum y-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The minimum value. + */ + @Override + public double getRangeLowerBound(boolean includeInterval) { + return this.minValue; + } + + /** + * Returns the maximum y-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The maximum value. + */ + @Override + public double getRangeUpperBound(boolean includeInterval) { + return this.maxValue; + } + + /** + * Returns the range of the values in this dataset's range. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The range. + */ + @Override + public Range getRangeBounds(boolean includeInterval) { + return new Range(this.minValue, this.maxValue); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/jdbc/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/jdbc/package.html new file mode 100755 index 0000000..668d3c8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/jdbc/package.html @@ -0,0 +1,6 @@ + + + +Dataset classes that fetch data from a database via JDBC. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/package.html new file mode 100755 index 0000000..2390b97 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/package.html @@ -0,0 +1,6 @@ + + + +The base package for classes that represent various types of data. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources.java new file mode 100755 index 0000000..7172df7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources.java @@ -0,0 +1,70 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * DataPackageResources.java + * ------------------------- + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Mar-2002 : Version 1 (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * + */ + +package org.jfree.data.resources; + +import java.util.ListResourceBundle; + +/** + * A resource bundle that stores all the items that might need localisation. + * + */ +public class DataPackageResources extends ListResourceBundle { + + /** + * Returns the array of strings in the resource bundle. + * + * @return The localised resources. + */ + @Override + public Object[][] getContents() { + return CONTENTS; + } + + /** The resources to be localised. */ + private static final Object[][] CONTENTS = { + + {"series.default-prefix", "Series"}, + {"categories.default-prefix", "Category"}, + + }; + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_de.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_de.java new file mode 100755 index 0000000..a42e411 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_de.java @@ -0,0 +1,70 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * DataPackageResources_de.java + * ---------------------------- + * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. + * + * Original Author: Thomas Meier; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 04-Apr-2002 : Version 1, translation by Thomas Meier (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.resources; + +import java.util.ListResourceBundle; + +/** + * A resource bundle that stores all the items that might need localisation. + */ +public class DataPackageResources_de extends ListResourceBundle { + + /** + * Returns the array of strings in the resource bundle. + * + * @return The localised resources. + */ + @Override + public Object[][] getContents() { + return CONTENTS; + } + + /** The resources to be localised. */ + private static final Object[][] CONTENTS = { + + {"series.default-prefix", "Reihen"}, + {"categories.default-prefix", "Kategorien"}, + + }; + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_es.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_es.java new file mode 100755 index 0000000..2850098 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_es.java @@ -0,0 +1,71 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * DataPackageResources_es.java + * ---------------------------- + * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Hans-Jurgen Greiner; + * + * Changes + * ------- + * 26-Mar-2002 : Version 1, translation by Hans-Jurgen Greiner (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.resources; + +import java.util.ListResourceBundle; + +/** + * A resource bundle that stores all the items that might need localisation. + */ +public class DataPackageResources_es extends ListResourceBundle { + + /** + * Returns the array of strings in the resource bundle. + * + * @return The localised resources. + */ + @Override + public Object[][] getContents() { + return CONTENTS; + } + + /** The resources to be localised. */ + private static final Object[][] CONTENTS = { + + {"series.default-prefix", "Series"}, + {"categories.default-prefix", "Categor?a"}, + + }; + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_fr.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_fr.java new file mode 100755 index 0000000..6fca8d1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_fr.java @@ -0,0 +1,69 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * DataPackageResources_fr.java + * ---------------------------- + * + * Original Author: Anthony Boulestreau; + * Contributor(s): -; + * + * Changes + * ------- + * 26-Mar-2002 : Version 1 (AB); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.resources; + +import java.util.ListResourceBundle; + +/** + * A resource bundle that stores all the items that might need localisation. + */ +public class DataPackageResources_fr extends ListResourceBundle { + + /** + * Returns the array of strings in the resource bundle. + * + * @return The localised resources. + */ + @Override + public Object[][] getContents() { + return CONTENTS; + } + + /** The resources to be localised. */ + private static final Object[][] CONTENTS = { + + {"series.default-prefix", "S?ries"}, + {"categories.default-prefix", "Cat?gorie"}, + + }; + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_pl.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_pl.java new file mode 100755 index 0000000..b8b53ea --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_pl.java @@ -0,0 +1,71 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * DataPackageResources_pl.java + * ---------------------------- + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * Polish translation: Krzysztof Pa? (kpaz@samorzad.pw.edu.pl) + * + * Changes + * ------- + * 21-Mar-2002 : Version 1 (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.resources; + +import java.util.ListResourceBundle; + +/** + * A resource bundle that stores all the items that might need localisation. + */ +public class DataPackageResources_pl extends ListResourceBundle { + + /** + * Returns the array of strings in the resource bundle. + * + * @return The localised resources. + */ + @Override + public Object[][] getContents() { + return CONTENTS; + } + + /** The resources to be localised. */ + private static final Object[][] CONTENTS = { + + {"series.default-prefix", "Serie"}, + {"categories.default-prefix", "Kategorie"}, + + }; + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_ru.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_ru.java new file mode 100755 index 0000000..30d50fb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/DataPackageResources_ru.java @@ -0,0 +1,67 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * DataPackageResources_ru.java + * ---------------------------- + * + * Original Author: Sergey Bondarenko; + * Contributor(s): -; + * + * Changes + * ------- + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.resources; + +import java.util.ListResourceBundle; + +/** + * A resource bundle that stores all the items that might need localisation. + */ +public class DataPackageResources_ru extends ListResourceBundle { + + /** + * Returns the array of strings in the resource bundle. + * + * @return The localised resources. + */ + @Override + public Object[][] getContents() { + return CONTENTS; + } + + /** The resources to be localised. */ + private static final Object[][] CONTENTS = { + + {"series.default-prefix", "?????"}, + {"categories.default-prefix", "?????????"}, + + }; + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/package.html new file mode 100755 index 0000000..b895676 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/resources/package.html @@ -0,0 +1,6 @@ + + + +Resource bundles for items that require localisation. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/BoxAndWhiskerCalculator.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/BoxAndWhiskerCalculator.java new file mode 100755 index 0000000..b5fff3a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/BoxAndWhiskerCalculator.java @@ -0,0 +1,236 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * BoxAndWhiskerCalculator.java + * ---------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 28-Aug-2003 : Version 1 (DG); + * 17-Nov-2003 : Fixed bug in calculations of outliers and median (DG); + * 10-Jan-2005 : Removed deprecated methods in preparation for 1.0.0 + * release (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 15-Nov-2006 : Cleaned up handling of null arguments, and null or NaN items + * in the list (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.statistics; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +/** + * A utility class that calculates the mean, median, quartiles Q1 and Q3, plus + * a list of outlier values...all from an arbitrary list of + * Number objects. + */ +public abstract class BoxAndWhiskerCalculator { + + /** + * Calculates the statistics required for a {@link BoxAndWhiskerItem} + * from a list of Number objects. Any items in the list + * that are null, not an instance of Number, or + * equivalent to Double.NaN, will be ignored. + * + * @param values a list of numbers (a null list is not + * permitted). + * + * @return A box-and-whisker item. + */ + public static BoxAndWhiskerItem calculateBoxAndWhiskerStatistics( + List values) { + return calculateBoxAndWhiskerStatistics(values, true); + } + + /** + * Calculates the statistics required for a {@link BoxAndWhiskerItem} + * from a list of Number objects. Any items in the list + * that are null, not an instance of Number, or + * equivalent to Double.NaN, will be ignored. + * + * @param values a list of numbers (a null list is not + * permitted). + * @param stripNullAndNaNItems a flag that controls the handling of null + * and NaN items. + * + * @return A box-and-whisker item. + * + * @since 1.0.3 + */ + public static BoxAndWhiskerItem calculateBoxAndWhiskerStatistics( + List values, boolean stripNullAndNaNItems) { + + ParamChecks.nullNotPermitted(values, "values"); + + List vlist; + if (stripNullAndNaNItems) { + vlist = new ArrayList(values.size()); + Iterator iterator = values.listIterator(); + while (iterator.hasNext()) { + Object obj = iterator.next(); + if (obj instanceof Number) { + Number n = (Number) obj; + double v = n.doubleValue(); + if (!Double.isNaN(v)) { + vlist.add(n); + } + } + } + } + else { + vlist = values; + } + Collections.sort(vlist); + + double mean = Statistics.calculateMean(vlist, false); + double median = Statistics.calculateMedian(vlist, false); + double q1 = calculateQ1(vlist); + double q3 = calculateQ3(vlist); + + double interQuartileRange = q3 - q1; + + double upperOutlierThreshold = q3 + (interQuartileRange * 1.5); + double lowerOutlierThreshold = q1 - (interQuartileRange * 1.5); + + double upperFaroutThreshold = q3 + (interQuartileRange * 2.0); + double lowerFaroutThreshold = q1 - (interQuartileRange * 2.0); + + double minRegularValue = Double.POSITIVE_INFINITY; + double maxRegularValue = Double.NEGATIVE_INFINITY; + double minOutlier = Double.POSITIVE_INFINITY; + double maxOutlier = Double.NEGATIVE_INFINITY; + List outliers = new ArrayList(); + + Iterator iterator = vlist.iterator(); + while (iterator.hasNext()) { + Number number = (Number) iterator.next(); + double value = number.doubleValue(); + if (value > upperOutlierThreshold) { + outliers.add(number); + if (value > maxOutlier && value <= upperFaroutThreshold) { + maxOutlier = value; + } + } + else if (value < lowerOutlierThreshold) { + outliers.add(number); + if (value < minOutlier && value >= lowerFaroutThreshold) { + minOutlier = value; + } + } + else { + minRegularValue = Math.min(minRegularValue, value); + maxRegularValue = Math.max(maxRegularValue, value); + } + minOutlier = Math.min(minOutlier, minRegularValue); + maxOutlier = Math.max(maxOutlier, maxRegularValue); + } + + return new BoxAndWhiskerItem(new Double(mean), new Double(median), + new Double(q1), new Double(q3), new Double(minRegularValue), + new Double(maxRegularValue), new Double(minOutlier), + new Double(maxOutlier), outliers); + + } + + /** + * Calculates the first quartile for a list of numbers in ascending order. + * If the items in the list are not in ascending order, the result is + * unspecified. If the list contains items that are null, not + * an instance of Number, or equivalent to + * Double.NaN, the result is unspecified. + * + * @param values the numbers in ascending order (null not + * permitted). + * + * @return The first quartile. + */ + public static double calculateQ1(List values) { + ParamChecks.nullNotPermitted(values, "values"); + + double result = Double.NaN; + int count = values.size(); + if (count > 0) { + if (count % 2 == 1) { + if (count > 1) { + result = Statistics.calculateMedian(values, 0, count / 2); + } + else { + result = Statistics.calculateMedian(values, 0, 0); + } + } + else { + result = Statistics.calculateMedian(values, 0, count / 2 - 1); + } + + } + return result; + } + + /** + * Calculates the third quartile for a list of numbers in ascending order. + * If the items in the list are not in ascending order, the result is + * unspecified. If the list contains items that are null, not + * an instance of Number, or equivalent to + * Double.NaN, the result is unspecified. + * + * @param values the list of values (null not permitted). + * + * @return The third quartile. + */ + public static double calculateQ3(List values) { + ParamChecks.nullNotPermitted(values, "values"); + double result = Double.NaN; + int count = values.size(); + if (count > 0) { + if (count % 2 == 1) { + if (count > 1) { + result = Statistics.calculateMedian(values, count / 2, + count - 1); + } + else { + result = Statistics.calculateMedian(values, 0, 0); + } + } + else { + result = Statistics.calculateMedian(values, count / 2, + count - 1); + } + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/BoxAndWhiskerCategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/BoxAndWhiskerCategoryDataset.java new file mode 100755 index 0000000..ca2efb0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/BoxAndWhiskerCategoryDataset.java @@ -0,0 +1,240 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * BoxAndWhiskerCategoryDataset.java + * --------------------------------- + * (C) Copyright 2003-2008, by David Browning and Contributors. + * + * Original Author: David Browning (for Australian Institute of Marine + * Science); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Aug-2003 : Version 1, contributed by David Browning (DG); + * 27-Aug-2003 : Renamed getAverageValue --> getMeanValue, changed + * getAllOutliers to return a List rather than an array (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.statistics; + +import java.util.List; + +import org.jfree.data.category.CategoryDataset; + +/** + * A category dataset that defines various medians, outliers and an average + * value for each item. + */ +public interface BoxAndWhiskerCategoryDataset extends CategoryDataset { + + /** + * Returns the mean value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The mean value. + */ + public Number getMeanValue(int row, int column); + + /** + * Returns the average value for an item. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The average value. + */ + public Number getMeanValue(Comparable rowKey, Comparable columnKey); + + /** + * Returns the median value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The median value. + */ + public Number getMedianValue(int row, int column); + + /** + * Returns the median value for an item. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The median value. + */ + public Number getMedianValue(Comparable rowKey, Comparable columnKey); + + /** + * Returns the q1median value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The q1median value. + */ + public Number getQ1Value(int row, int column); + + /** + * Returns the q1median value for an item. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The q1median value. + */ + public Number getQ1Value(Comparable rowKey, Comparable columnKey); + + /** + * Returns the q3median value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The q3median value. + */ + public Number getQ3Value(int row, int column); + + /** + * Returns the q3median value for an item. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The q3median value. + */ + public Number getQ3Value(Comparable rowKey, Comparable columnKey); + + /** + * Returns the minimum regular (non-outlier) value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The minimum regular value. + */ + public Number getMinRegularValue(int row, int column); + + /** + * Returns the minimum regular (non-outlier) value for an item. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The minimum regular value. + */ + public Number getMinRegularValue(Comparable rowKey, Comparable columnKey); + + /** + * Returns the maximum regular (non-outlier) value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The maximum regular value. + */ + public Number getMaxRegularValue(int row, int column); + + /** + * Returns the maximum regular (non-outlier) value for an item. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The maximum regular value. + */ + public Number getMaxRegularValue(Comparable rowKey, Comparable columnKey); + + /** + * Returns the minimum outlier (non-farout) for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The minimum outlier. + */ + public Number getMinOutlier(int row, int column); + + /** + * Returns the minimum outlier (non-farout) for an item. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The minimum outlier. + */ + public Number getMinOutlier(Comparable rowKey, Comparable columnKey); + + /** + * Returns the maximum outlier (non-farout) for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The maximum outlier. + */ + public Number getMaxOutlier(int row, int column); + + /** + * Returns the maximum outlier (non-farout) for an item. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The maximum outlier. + */ + public Number getMaxOutlier(Comparable rowKey, Comparable columnKey); + + /** + * Returns a list of outlier values for an item. The list may be empty, + * but should never be null. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return A list of outliers for an item. + */ + public List getOutliers(int row, int column); + + /** + * Returns a list of outlier values for an item. The list may be empty, + * but should never be null. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return A list of outlier values for an item. + */ + public List getOutliers(Comparable rowKey, Comparable columnKey); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/BoxAndWhiskerItem.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/BoxAndWhiskerItem.java new file mode 100755 index 0000000..4a5873e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/BoxAndWhiskerItem.java @@ -0,0 +1,298 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * BoxAndWhiskerItem.java + * ---------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Aug-2003 : Version 1 (DG); + * 01-Mar-2004 : Added equals() method and implemented Serializable (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 15-Nov-2006 : Added toString() method override (DG); + * 02-Oct-2007 : Added new constructor (for convenience) (DG); + * + */ + +package org.jfree.data.statistics; + +import java.io.Serializable; +import java.util.Collections; +import java.util.List; + +import org.jfree.util.ObjectUtilities; + +/** + * Represents one data item within a box-and-whisker dataset. Instances of + * this class are immutable. + */ +public class BoxAndWhiskerItem implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7329649623148167423L; + + /** The mean. */ + private Number mean; + + /** The median. */ + private Number median; + + /** The first quarter. */ + private Number q1; + + /** The third quarter. */ + private Number q3; + + /** The minimum regular value. */ + private Number minRegularValue; + + /** The maximum regular value. */ + private Number maxRegularValue; + + /** The minimum outlier. */ + private Number minOutlier; + + /** The maximum outlier. */ + private Number maxOutlier; + + /** The outliers. */ + private List outliers; + + /** + * Creates a new box-and-whisker item. + * + * @param mean the mean (null permitted). + * @param median the median (null permitted). + * @param q1 the first quartile (null permitted). + * @param q3 the third quartile (null permitted). + * @param minRegularValue the minimum regular value (null + * permitted). + * @param maxRegularValue the maximum regular value (null + * permitted). + * @param minOutlier the minimum outlier (null permitted). + * @param maxOutlier the maximum outlier (null permitted). + * @param outliers the outliers (null permitted). + */ + public BoxAndWhiskerItem(Number mean, + Number median, + Number q1, + Number q3, + Number minRegularValue, + Number maxRegularValue, + Number minOutlier, + Number maxOutlier, + List outliers) { + + this.mean = mean; + this.median = median; + this.q1 = q1; + this.q3 = q3; + this.minRegularValue = minRegularValue; + this.maxRegularValue = maxRegularValue; + this.minOutlier = minOutlier; + this.maxOutlier = maxOutlier; + this.outliers = outliers; + + } + + /** + * Creates a new box-and-whisker item. + * + * @param mean the mean. + * @param median the median + * @param q1 the first quartile. + * @param q3 the third quartile. + * @param minRegularValue the minimum regular value. + * @param maxRegularValue the maximum regular value. + * @param minOutlier the minimum outlier value. + * @param maxOutlier the maximum outlier value. + * @param outliers a list of the outliers. + * + * @since 1.0.7 + */ + public BoxAndWhiskerItem(double mean, double median, double q1, double q3, + double minRegularValue, double maxRegularValue, double minOutlier, + double maxOutlier, List outliers) { + + // pass values to other constructor + this(new Double(mean), new Double(median), new Double(q1), + new Double(q3), new Double(minRegularValue), + new Double(maxRegularValue), new Double(minOutlier), + new Double(maxOutlier), outliers); + + } + + /** + * Returns the mean. + * + * @return The mean (possibly null). + */ + public Number getMean() { + return this.mean; + } + + /** + * Returns the median. + * + * @return The median (possibly null). + */ + public Number getMedian() { + return this.median; + } + + /** + * Returns the first quartile. + * + * @return The first quartile (possibly null). + */ + public Number getQ1() { + return this.q1; + } + + /** + * Returns the third quartile. + * + * @return The third quartile (possibly null). + */ + public Number getQ3() { + return this.q3; + } + + /** + * Returns the minimum regular value. + * + * @return The minimum regular value (possibly null). + */ + public Number getMinRegularValue() { + return this.minRegularValue; + } + + /** + * Returns the maximum regular value. + * + * @return The maximum regular value (possibly null). + */ + public Number getMaxRegularValue() { + return this.maxRegularValue; + } + + /** + * Returns the minimum outlier. + * + * @return The minimum outlier (possibly null). + */ + public Number getMinOutlier() { + return this.minOutlier; + } + + /** + * Returns the maximum outlier. + * + * @return The maximum outlier (possibly null). + */ + public Number getMaxOutlier() { + return this.maxOutlier; + } + + /** + * Returns a list of outliers. + * + * @return A list of outliers (possibly null). + */ + public List getOutliers() { + if (this.outliers == null) { + return null; + } + return Collections.unmodifiableList(this.outliers); + } + + /** + * Returns a string representation of this instance, primarily for + * debugging purposes. + * + * @return A string representation of this instance. + */ + @Override + public String toString() { + return super.toString() + "[mean=" + this.mean + ",median=" + + this.median + ",q1=" + this.q1 + ",q3=" + this.q3 + "]"; + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof BoxAndWhiskerItem)) { + return false; + } + BoxAndWhiskerItem that = (BoxAndWhiskerItem) obj; + if (!ObjectUtilities.equal(this.mean, that.mean)) { + return false; + } + if (!ObjectUtilities.equal(this.median, that.median)) { + return false; + } + if (!ObjectUtilities.equal(this.q1, that.q1)) { + return false; + } + if (!ObjectUtilities.equal(this.q3, that.q3)) { + return false; + } + if (!ObjectUtilities.equal(this.minRegularValue, + that.minRegularValue)) { + return false; + } + if (!ObjectUtilities.equal(this.maxRegularValue, + that.maxRegularValue)) { + return false; + } + if (!ObjectUtilities.equal(this.minOutlier, that.minOutlier)) { + return false; + } + if (!ObjectUtilities.equal(this.maxOutlier, that.maxOutlier)) { + return false; + } + if (!ObjectUtilities.equal(this.outliers, that.outliers)) { + return false; + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/BoxAndWhiskerXYDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/BoxAndWhiskerXYDataset.java new file mode 100755 index 0000000..c135a3e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/BoxAndWhiskerXYDataset.java @@ -0,0 +1,180 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * BoxAndWhiskerXYDataset.java + * --------------------------- + * (C) Copyright 2003-2008, by David Browning and Contributors. + * + * Original Author: David Browning (for Australian Institute of Marine + * Science); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 05-Aug-2003 : Version 1, contributed by David Browning (DG); + * 12-Aug-2003 : Added new methods: getMaxNonOutlierValue + * getMaxNonFaroutValue + * getOutlierCoefficient + * setOutlierCoefficient + * getFaroutCoefficient + * setFaroutCoefficient + * getInterquartileRange (DB) + * 27-Aug-2003 : Renamed BoxAndWhiskerDataset --> BoxAndWhiskerXYDataset, and + * cut down methods (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.statistics; + +import java.util.List; + +import org.jfree.data.xy.XYDataset; + +/** + * An interface that defines data in the form of (x, max, min, average, median) + * tuples. + *

+ * Example: JFreeChart uses this interface to obtain data for AIMS + * max-min-average-median plots. + */ +public interface BoxAndWhiskerXYDataset extends XYDataset { + + /** + * Returns the mean for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The mean for the specified series and item. + */ + public Number getMeanValue(int series, int item); + + /** + * Returns the median-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The median-value for the specified series and item. + */ + public Number getMedianValue(int series, int item); + + /** + * Returns the Q1 median-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The Q1 median-value for the specified series and item. + */ + public Number getQ1Value(int series, int item); + + /** + * Returns the Q3 median-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The Q3 median-value for the specified series and item. + */ + public Number getQ3Value(int series, int item); + + /** + * Returns the min-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The min-value for the specified series and item. + */ + public Number getMinRegularValue(int series, int item); + + /** + * Returns the max-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The max-value for the specified series and item. + */ + public Number getMaxRegularValue(int series, int item); + + /** + * Returns the minimum value which is not a farout. + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return A Number representing the maximum non-farout value. + */ + public Number getMinOutlier(int series, int item); + + /** + * Returns the maximum value which is not a farout, ie Q3 + (interquartile + * range * farout coefficient). + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return A Number representing the maximum non-farout value. + */ + public Number getMaxOutlier(int series, int item); + + /** + * Returns a list of outliers for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The list of outliers for the specified series and item + * (possibly null). + */ + public List getOutliers(int series, int item); + + /** + * Returns the value used as the outlier coefficient. The outlier + * coefficient gives an indication of the degree of certainty in an + * unskewed distribution. Increasing the coefficient increases the number + * of values included. Currently only used to ensure farout coefficient + * is greater than the outlier coefficient + * + * @return A double representing the value used to calculate + * outliers + */ + public double getOutlierCoefficient(); + + /** + * Returns the value used as the farout coefficient. The farout coefficient + * allows the calculation of which values will be off the graph. + * + * @return A double representing the value used to calculate + * farouts + */ + public double getFaroutCoefficient(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java new file mode 100755 index 0000000..1438f4a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDataset.java @@ -0,0 +1,949 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------------- + * DefaultBoxAndWhiskerCategoryDataset.java + * ---------------------------------------- + * (C) Copyright 2003-2008, by David Browning and Contributors. + * + * Original Author: David Browning (for Australian Institute of Marine + * Science); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 05-Aug-2003 : Version 1, contributed by David Browning (DG); + * 27-Aug-2003 : Moved from org.jfree.data --> org.jfree.data.statistics (DG); + * 12-Nov-2003 : Changed 'data' from private to protected and added a new 'add' + * method as proposed by Tim Bardzil. Also removed old code (DG); + * 01-Mar-2004 : Added equals() method (DG); + * 18-Nov-2004 : Updates for changes in RangeInfo interface (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * 17-Apr-2007 : Fixed bug 1701822 (DG); + * 13-Jun-2007 : Fixed error in previous patch (DG); + * 28-Sep-2007 : Fixed cloning bug (DG); + * 02-Oct-2007 : Fixed bug in updating cached bounds (DG); + * 03-Oct-2007 : Fixed another bug in updating cached bounds, added removal + * methods (DG); + * + */ + +package org.jfree.data.statistics; + +import java.util.List; + +import org.jfree.data.KeyedObjects2D; +import org.jfree.data.Range; +import org.jfree.data.RangeInfo; +import org.jfree.data.general.AbstractDataset; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A convenience class that provides a default implementation of the + * {@link BoxAndWhiskerCategoryDataset} interface. + */ +public class DefaultBoxAndWhiskerCategoryDataset extends AbstractDataset + implements BoxAndWhiskerCategoryDataset, RangeInfo, PublicCloneable { + + /** Storage for the data. */ + protected KeyedObjects2D data; + + /** The minimum range value. */ + private double minimumRangeValue; + + /** The row index for the cell that the minimum range value comes from. */ + private int minimumRangeValueRow; + + /** + * The column index for the cell that the minimum range value comes from. + */ + private int minimumRangeValueColumn; + + /** The maximum range value. */ + private double maximumRangeValue; + + /** The row index for the cell that the maximum range value comes from. */ + private int maximumRangeValueRow; + + /** + * The column index for the cell that the maximum range value comes from. + */ + private int maximumRangeValueColumn; + + /** + * Creates a new dataset. + */ + public DefaultBoxAndWhiskerCategoryDataset() { + this.data = new KeyedObjects2D(); + this.minimumRangeValue = Double.NaN; + this.minimumRangeValueRow = -1; + this.minimumRangeValueColumn = -1; + this.maximumRangeValue = Double.NaN; + this.maximumRangeValueRow = -1; + this.maximumRangeValueColumn = -1; + } + + /** + * Adds a list of values relating to one box-and-whisker entity to the + * table. The various median values are calculated. + * + * @param list a collection of values from which the various medians will + * be calculated. + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @see #add(BoxAndWhiskerItem, Comparable, Comparable) + */ + public void add(List list, Comparable rowKey, Comparable columnKey) { + BoxAndWhiskerItem item = BoxAndWhiskerCalculator + .calculateBoxAndWhiskerStatistics(list); + add(item, rowKey, columnKey); + } + + /** + * Adds a list of values relating to one Box and Whisker entity to the + * table. The various median values are calculated. + * + * @param item a box and whisker item (null not permitted). + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @see #add(List, Comparable, Comparable) + */ + public void add(BoxAndWhiskerItem item, Comparable rowKey, + Comparable columnKey) { + + this.data.addObject(item, rowKey, columnKey); + + // update cached min and max values + int r = this.data.getRowIndex(rowKey); + int c = this.data.getColumnIndex(columnKey); + if ((this.maximumRangeValueRow == r && this.maximumRangeValueColumn + == c) || (this.minimumRangeValueRow == r + && this.minimumRangeValueColumn == c)) { + updateBounds(); + } + else { + + double minval = Double.NaN; + if (item.getMinOutlier() != null) { + minval = item.getMinOutlier().doubleValue(); + } + double maxval = Double.NaN; + if (item.getMaxOutlier() != null) { + maxval = item.getMaxOutlier().doubleValue(); + } + + if (Double.isNaN(this.maximumRangeValue)) { + this.maximumRangeValue = maxval; + this.maximumRangeValueRow = r; + this.maximumRangeValueColumn = c; + } + else if (maxval > this.maximumRangeValue) { + this.maximumRangeValue = maxval; + this.maximumRangeValueRow = r; + this.maximumRangeValueColumn = c; + } + + if (Double.isNaN(this.minimumRangeValue)) { + this.minimumRangeValue = minval; + this.minimumRangeValueRow = r; + this.minimumRangeValueColumn = c; + } + else if (minval < this.minimumRangeValue) { + this.minimumRangeValue = minval; + this.minimumRangeValueRow = r; + this.minimumRangeValueColumn = c; + } + } + + fireDatasetChanged(); + + } + + /** + * Removes an item from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @see #add(BoxAndWhiskerItem, Comparable, Comparable) + * + * @since 1.0.7 + */ + public void remove(Comparable rowKey, Comparable columnKey) { + // defer null argument checks + int r = getRowIndex(rowKey); + int c = getColumnIndex(columnKey); + this.data.removeObject(rowKey, columnKey); + + // if this cell held a maximum and/or minimum value, we'll need to + // update the cached bounds... + if ((this.maximumRangeValueRow == r && this.maximumRangeValueColumn + == c) || (this.minimumRangeValueRow == r + && this.minimumRangeValueColumn == c)) { + updateBounds(); + } + + fireDatasetChanged(); + } + + /** + * Removes a row from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param rowIndex the row index. + * + * @see #removeColumn(int) + * + * @since 1.0.7 + */ + public void removeRow(int rowIndex) { + this.data.removeRow(rowIndex); + updateBounds(); + fireDatasetChanged(); + } + + /** + * Removes a row from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param rowKey the row key. + * + * @see #removeColumn(Comparable) + * + * @since 1.0.7 + */ + public void removeRow(Comparable rowKey) { + this.data.removeRow(rowKey); + updateBounds(); + fireDatasetChanged(); + } + + /** + * Removes a column from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param columnIndex the column index. + * + * @see #removeRow(int) + * + * @since 1.0.7 + */ + public void removeColumn(int columnIndex) { + this.data.removeColumn(columnIndex); + updateBounds(); + fireDatasetChanged(); + } + + /** + * Removes a column from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param columnKey the column key. + * + * @see #removeRow(Comparable) + * + * @since 1.0.7 + */ + public void removeColumn(Comparable columnKey) { + this.data.removeColumn(columnKey); + updateBounds(); + fireDatasetChanged(); + } + + /** + * Clears all data from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @since 1.0.7 + */ + public void clear() { + this.data.clear(); + updateBounds(); + fireDatasetChanged(); + } + + /** + * Return an item from within the dataset. + * + * @param row the row index. + * @param column the column index. + * + * @return The item. + */ + public BoxAndWhiskerItem getItem(int row, int column) { + return (BoxAndWhiskerItem) this.data.getObject(row, column); + } + + /** + * Returns the value for an item. + * + * @param row the row index. + * @param column the column index. + * + * @return The value. + * + * @see #getMedianValue(int, int) + * @see #getValue(Comparable, Comparable) + */ + @Override + public Number getValue(int row, int column) { + return getMedianValue(row, column); + } + + /** + * Returns the value for an item. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The value. + * + * @see #getMedianValue(Comparable, Comparable) + * @see #getValue(int, int) + */ + @Override + public Number getValue(Comparable rowKey, Comparable columnKey) { + return getMedianValue(rowKey, columnKey); + } + + /** + * Returns the mean value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The mean value. + * + * @see #getItem(int, int) + */ + @Override + public Number getMeanValue(int row, int column) { + + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject(row, + column); + if (item != null) { + result = item.getMean(); + } + return result; + + } + + /** + * Returns the mean value for an item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return The mean value. + * + * @see #getItem(int, int) + */ + @Override + public Number getMeanValue(Comparable rowKey, Comparable columnKey) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + rowKey, columnKey); + if (item != null) { + result = item.getMean(); + } + return result; + } + + /** + * Returns the median value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The median value. + * + * @see #getItem(int, int) + */ + @Override + public Number getMedianValue(int row, int column) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject(row, + column); + if (item != null) { + result = item.getMedian(); + } + return result; + } + + /** + * Returns the median value for an item. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The median value. + * + * @see #getItem(int, int) + */ + @Override + public Number getMedianValue(Comparable rowKey, Comparable columnKey) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + rowKey, columnKey); + if (item != null) { + result = item.getMedian(); + } + return result; + } + + /** + * Returns the first quartile value. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The first quartile value. + * + * @see #getItem(int, int) + */ + @Override + public Number getQ1Value(int row, int column) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + row, column); + if (item != null) { + result = item.getQ1(); + } + return result; + } + + /** + * Returns the first quartile value. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return The first quartile value. + * + * @see #getItem(int, int) + */ + @Override + public Number getQ1Value(Comparable rowKey, Comparable columnKey) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + rowKey, columnKey); + if (item != null) { + result = item.getQ1(); + } + return result; + } + + /** + * Returns the third quartile value. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The third quartile value. + * + * @see #getItem(int, int) + */ + @Override + public Number getQ3Value(int row, int column) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + row, column); + if (item != null) { + result = item.getQ3(); + } + return result; + } + + /** + * Returns the third quartile value. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return The third quartile value. + * + * @see #getItem(int, int) + */ + @Override + public Number getQ3Value(Comparable rowKey, Comparable columnKey) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + rowKey, columnKey); + if (item != null) { + result = item.getQ3(); + } + return result; + } + + /** + * Returns the column index for a given key. + * + * @param key the column key (null not permitted). + * + * @return The column index. + * + * @see #getColumnKey(int) + */ + @Override + public int getColumnIndex(Comparable key) { + return this.data.getColumnIndex(key); + } + + /** + * Returns a column key. + * + * @param column the column index (zero-based). + * + * @return The column key. + * + * @see #getColumnIndex(Comparable) + */ + @Override + public Comparable getColumnKey(int column) { + return this.data.getColumnKey(column); + } + + /** + * Returns the column keys. + * + * @return The keys. + * + * @see #getRowKeys() + */ + @Override + public List getColumnKeys() { + return this.data.getColumnKeys(); + } + + /** + * Returns the row index for a given key. + * + * @param key the row key (null not permitted). + * + * @return The row index. + * + * @see #getRowKey(int) + */ + @Override + public int getRowIndex(Comparable key) { + // defer null argument check + return this.data.getRowIndex(key); + } + + /** + * Returns a row key. + * + * @param row the row index (zero-based). + * + * @return The row key. + * + * @see #getRowIndex(Comparable) + */ + @Override + public Comparable getRowKey(int row) { + return this.data.getRowKey(row); + } + + /** + * Returns the row keys. + * + * @return The keys. + * + * @see #getColumnKeys() + */ + @Override + public List getRowKeys() { + return this.data.getRowKeys(); + } + + /** + * Returns the number of rows in the table. + * + * @return The row count. + * + * @see #getColumnCount() + */ + @Override + public int getRowCount() { + return this.data.getRowCount(); + } + + /** + * Returns the number of columns in the table. + * + * @return The column count. + * + * @see #getRowCount() + */ + @Override + public int getColumnCount() { + return this.data.getColumnCount(); + } + + /** + * Returns the minimum y-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The minimum value. + * + * @see #getRangeUpperBound(boolean) + */ + @Override + public double getRangeLowerBound(boolean includeInterval) { + return this.minimumRangeValue; + } + + /** + * Returns the maximum y-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The maximum value. + * + * @see #getRangeLowerBound(boolean) + */ + @Override + public double getRangeUpperBound(boolean includeInterval) { + return this.maximumRangeValue; + } + + /** + * Returns the range of the values in this dataset's range. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The range. + */ + @Override + public Range getRangeBounds(boolean includeInterval) { + return new Range(this.minimumRangeValue, this.maximumRangeValue); + } + + /** + * Returns the minimum regular (non outlier) value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The minimum regular value. + * + * @see #getItem(int, int) + */ + @Override + public Number getMinRegularValue(int row, int column) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + row, column); + if (item != null) { + result = item.getMinRegularValue(); + } + return result; + } + + /** + * Returns the minimum regular (non outlier) value for an item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return The minimum regular value. + * + * @see #getItem(int, int) + */ + @Override + public Number getMinRegularValue(Comparable rowKey, Comparable columnKey) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + rowKey, columnKey); + if (item != null) { + result = item.getMinRegularValue(); + } + return result; + } + + /** + * Returns the maximum regular (non outlier) value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The maximum regular value. + * + * @see #getItem(int, int) + */ + @Override + public Number getMaxRegularValue(int row, int column) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + row, column); + if (item != null) { + result = item.getMaxRegularValue(); + } + return result; + } + + /** + * Returns the maximum regular (non outlier) value for an item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return The maximum regular value. + * + * @see #getItem(int, int) + */ + @Override + public Number getMaxRegularValue(Comparable rowKey, Comparable columnKey) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + rowKey, columnKey); + if (item != null) { + result = item.getMaxRegularValue(); + } + return result; + } + + /** + * Returns the minimum outlier (non farout) value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The minimum outlier. + * + * @see #getItem(int, int) + */ + @Override + public Number getMinOutlier(int row, int column) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + row, column); + if (item != null) { + result = item.getMinOutlier(); + } + return result; + } + + /** + * Returns the minimum outlier (non farout) value for an item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return The minimum outlier. + * + * @see #getItem(int, int) + */ + @Override + public Number getMinOutlier(Comparable rowKey, Comparable columnKey) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + rowKey, columnKey); + if (item != null) { + result = item.getMinOutlier(); + } + return result; + } + + /** + * Returns the maximum outlier (non farout) value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The maximum outlier. + * + * @see #getItem(int, int) + */ + @Override + public Number getMaxOutlier(int row, int column) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + row, column); + if (item != null) { + result = item.getMaxOutlier(); + } + return result; + } + + /** + * Returns the maximum outlier (non farout) value for an item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return The maximum outlier. + * + * @see #getItem(int, int) + */ + @Override + public Number getMaxOutlier(Comparable rowKey, Comparable columnKey) { + Number result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + rowKey, columnKey); + if (item != null) { + result = item.getMaxOutlier(); + } + return result; + } + + /** + * Returns a list of outlier values for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return A list of outlier values. + * + * @see #getItem(int, int) + */ + @Override + public List getOutliers(int row, int column) { + List result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + row, column); + if (item != null) { + result = item.getOutliers(); + } + return result; + } + + /** + * Returns a list of outlier values for an item. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @return A list of outlier values. + * + * @see #getItem(int, int) + */ + @Override + public List getOutliers(Comparable rowKey, Comparable columnKey) { + List result = null; + BoxAndWhiskerItem item = (BoxAndWhiskerItem) this.data.getObject( + rowKey, columnKey); + if (item != null) { + result = item.getOutliers(); + } + return result; + } + + /** + * Resets the cached bounds, by iterating over the entire dataset to find + * the current bounds. + */ + private void updateBounds() { + this.minimumRangeValue = Double.NaN; + this.minimumRangeValueRow = -1; + this.minimumRangeValueColumn = -1; + this.maximumRangeValue = Double.NaN; + this.maximumRangeValueRow = -1; + this.maximumRangeValueColumn = -1; + int rowCount = getRowCount(); + int columnCount = getColumnCount(); + for (int r = 0; r < rowCount; r++) { + for (int c = 0; c < columnCount; c++) { + BoxAndWhiskerItem item = getItem(r, c); + if (item != null) { + Number min = item.getMinOutlier(); + if (min != null) { + double minv = min.doubleValue(); + if (!Double.isNaN(minv)) { + if (minv < this.minimumRangeValue || Double.isNaN( + this.minimumRangeValue)) { + this.minimumRangeValue = minv; + this.minimumRangeValueRow = r; + this.minimumRangeValueColumn = c; + } + } + } + Number max = item.getMaxOutlier(); + if (max != null) { + double maxv = max.doubleValue(); + if (!Double.isNaN(maxv)) { + if (maxv > this.maximumRangeValue || Double.isNaN( + this.maximumRangeValue)) { + this.maximumRangeValue = maxv; + this.maximumRangeValueRow = r; + this.maximumRangeValueColumn = c; + } + } + } + } + } + } + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (obj instanceof DefaultBoxAndWhiskerCategoryDataset) { + DefaultBoxAndWhiskerCategoryDataset dataset + = (DefaultBoxAndWhiskerCategoryDataset) obj; + return ObjectUtilities.equal(this.data, dataset.data); + } + return false; + } + + /** + * Returns a clone of this dataset. + * + * @return A clone. + * + * @throws CloneNotSupportedException if cloning is not possible. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultBoxAndWhiskerCategoryDataset clone + = (DefaultBoxAndWhiskerCategoryDataset) super.clone(); + clone.data = (KeyedObjects2D) this.data.clone(); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/DefaultBoxAndWhiskerXYDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/DefaultBoxAndWhiskerXYDataset.java new file mode 100755 index 0000000..cf76b23 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/DefaultBoxAndWhiskerXYDataset.java @@ -0,0 +1,578 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------- + * DefaultBoxAndWhiskerXYDataset.java + * ---------------------------------- + * (C) Copyright 2003-2008, by David Browning and Contributors. + * + * Original Author: David Browning (for Australian Institute of Marine + * Science); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 05-Aug-2003 : Version 1, contributed by David Browning (DG); + * 08-Aug-2003 : Minor changes to comments (DB) + * Allow average to be null - average is a perculiar AIMS + * requirement which probably should be stripped out and overlaid + * if required... + * Added a number of methods to allow the max and min non-outlier + * and non-farout values to be calculated + * 12-Aug-2003 Changed the getYValue to return the highest outlier value + * Added getters and setters for outlier and farout coefficients + * 27-Aug-2003 : Renamed DefaultBoxAndWhiskerDataset + * --> DefaultBoxAndWhiskerXYDataset (DG); + * 06-May-2004 : Now extends AbstractXYDataset (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 18-Nov-2004 : Updated for changes in RangeInfo interface (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * 12-Nov-2007 : Implemented equals() and clone() (DG); + * + */ + +package org.jfree.data.statistics; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.jfree.data.Range; +import org.jfree.data.RangeInfo; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.xy.AbstractXYDataset; +import org.jfree.util.ObjectUtilities; + +/** + * A simple implementation of the {@link BoxAndWhiskerXYDataset} interface. + * This dataset implementation can hold only one series. + */ +public class DefaultBoxAndWhiskerXYDataset extends AbstractXYDataset + implements BoxAndWhiskerXYDataset, RangeInfo { + + /** The series key. */ + private Comparable seriesKey; + + /** Storage for the dates. */ + private List dates; + + /** Storage for the box and whisker statistics. */ + private List items; + + /** The minimum range value. */ + private Number minimumRangeValue; + + /** The maximum range value. */ + private Number maximumRangeValue; + + /** The range of values. */ + private Range rangeBounds; + + /** + * The coefficient used to calculate outliers. Tukey's default value is + * 1.5 (see EDA) Any value which is greater than Q3 + (interquartile range + * * outlier coefficient) is considered to be an outlier. Can be altered + * if the data is particularly skewed. + */ + private double outlierCoefficient = 1.5; + + /** + * The coefficient used to calculate farouts. Tukey's default value is 2 + * (see EDA) Any value which is greater than Q3 + (interquartile range * + * farout coefficient) is considered to be a farout. Can be altered if the + * data is particularly skewed. + */ + private double faroutCoefficient = 2.0; + + /** + * Constructs a new box and whisker dataset. + *

+ * The current implementation allows only one series in the dataset. + * This may be extended in a future version. + * + * @param seriesKey the key for the series. + */ + public DefaultBoxAndWhiskerXYDataset(Comparable seriesKey) { + this.seriesKey = seriesKey; + this.dates = new ArrayList(); + this.items = new ArrayList(); + this.minimumRangeValue = null; + this.maximumRangeValue = null; + this.rangeBounds = null; + } + + /** + * Returns the value used as the outlier coefficient. The outlier + * coefficient gives an indication of the degree of certainty in an + * unskewed distribution. Increasing the coefficient increases the number + * of values included. Currently only used to ensure farout coefficient is + * greater than the outlier coefficient + * + * @return A double representing the value used to calculate + * outliers. + * + * @see #setOutlierCoefficient(double) + */ + @Override + public double getOutlierCoefficient() { + return this.outlierCoefficient; + } + + /** + * Sets the value used as the outlier coefficient + * + * @param outlierCoefficient being a double representing the + * value used to calculate outliers. + * + * @see #getOutlierCoefficient() + */ + public void setOutlierCoefficient(double outlierCoefficient) { + this.outlierCoefficient = outlierCoefficient; + } + + /** + * Returns the value used as the farout coefficient. The farout coefficient + * allows the calculation of which values will be off the graph. + * + * @return A double representing the value used to calculate + * farouts. + * + * @see #setFaroutCoefficient(double) + */ + @Override + public double getFaroutCoefficient() { + return this.faroutCoefficient; + } + + /** + * Sets the value used as the farouts coefficient. The farout coefficient + * must b greater than the outlier coefficient. + * + * @param faroutCoefficient being a double representing the + * value used to calculate farouts. + * + * @see #getFaroutCoefficient() + */ + public void setFaroutCoefficient(double faroutCoefficient) { + + if (faroutCoefficient > getOutlierCoefficient()) { + this.faroutCoefficient = faroutCoefficient; + } + else { + throw new IllegalArgumentException("Farout value must be greater " + + "than the outlier value, which is currently set at: (" + + getOutlierCoefficient() + ")"); + } + } + + /** + * Returns the number of series in the dataset. + *

+ * This implementation only allows one series. + * + * @return The number of series. + */ + @Override + public int getSeriesCount() { + return 1; + } + + /** + * Returns the number of items in the specified series. + * + * @param series the index (zero-based) of the series. + * + * @return The number of items in the specified series. + */ + @Override + public int getItemCount(int series) { + return this.dates.size(); + } + + /** + * Adds an item to the dataset and sends a {@link DatasetChangeEvent} to + * all registered listeners. + * + * @param date the date (null not permitted). + * @param item the item (null not permitted). + */ + public void add(Date date, BoxAndWhiskerItem item) { + this.dates.add(date); + this.items.add(item); + if (this.minimumRangeValue == null) { + this.minimumRangeValue = item.getMinRegularValue(); + } + else { + if (item.getMinRegularValue().doubleValue() + < this.minimumRangeValue.doubleValue()) { + this.minimumRangeValue = item.getMinRegularValue(); + } + } + if (this.maximumRangeValue == null) { + this.maximumRangeValue = item.getMaxRegularValue(); + } + else { + if (item.getMaxRegularValue().doubleValue() + > this.maximumRangeValue.doubleValue()) { + this.maximumRangeValue = item.getMaxRegularValue(); + } + } + this.rangeBounds = new Range(this.minimumRangeValue.doubleValue(), + this.maximumRangeValue.doubleValue()); + fireDatasetChanged(); + } + + /** + * Returns the name of the series stored in this dataset. + * + * @param i the index of the series. Currently ignored. + * + * @return The name of this series. + */ + @Override + public Comparable getSeriesKey(int i) { + return this.seriesKey; + } + + /** + * Return an item from within the dataset. + * + * @param series the series index (ignored, since this dataset contains + * only one series). + * @param item the item within the series (zero-based index) + * + * @return The item. + */ + public BoxAndWhiskerItem getItem(int series, int item) { + return (BoxAndWhiskerItem) this.items.get(item); + } + + /** + * Returns the x-value for one item in a series. + *

+ * The value returned is a Long object generated from the underlying Date + * object. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The x-value. + */ + @Override + public Number getX(int series, int item) { + return new Long(((Date) this.dates.get(item)).getTime()); + } + + /** + * Returns the x-value for one item in a series, as a Date. + *

+ * This method is provided for convenience only. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The x-value as a Date. + */ + public Date getXDate(int series, int item) { + return (Date) this.dates.get(item); + } + + /** + * Returns the y-value for one item in a series. + *

+ * This method (from the XYDataset interface) is mapped to the + * getMeanValue() method. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The y-value. + */ + @Override + public Number getY(int series, int item) { + return getMeanValue(series, item); + } + + /** + * Returns the mean for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The mean for the specified series and item. + */ + @Override + public Number getMeanValue(int series, int item) { + Number result = null; + BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); + if (stats != null) { + result = stats.getMean(); + } + return result; + } + + /** + * Returns the median-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The median-value for the specified series and item. + */ + @Override + public Number getMedianValue(int series, int item) { + Number result = null; + BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); + if (stats != null) { + result = stats.getMedian(); + } + return result; + } + + /** + * Returns the Q1 median-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The Q1 median-value for the specified series and item. + */ + @Override + public Number getQ1Value(int series, int item) { + Number result = null; + BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); + if (stats != null) { + result = stats.getQ1(); + } + return result; + } + + /** + * Returns the Q3 median-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The Q3 median-value for the specified series and item. + */ + @Override + public Number getQ3Value(int series, int item) { + Number result = null; + BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); + if (stats != null) { + result = stats.getQ3(); + } + return result; + } + + /** + * Returns the min-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The min-value for the specified series and item. + */ + @Override + public Number getMinRegularValue(int series, int item) { + Number result = null; + BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); + if (stats != null) { + result = stats.getMinRegularValue(); + } + return result; + } + + /** + * Returns the max-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The max-value for the specified series and item. + */ + @Override + public Number getMaxRegularValue(int series, int item) { + Number result = null; + BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); + if (stats != null) { + result = stats.getMaxRegularValue(); + } + return result; + } + + /** + * Returns the minimum value which is not a farout. + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return A Number representing the maximum non-farout value. + */ + @Override + public Number getMinOutlier(int series, int item) { + Number result = null; + BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); + if (stats != null) { + result = stats.getMinOutlier(); + } + return result; + } + + /** + * Returns the maximum value which is not a farout, ie Q3 + (interquartile + * range * farout coefficient). + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return A Number representing the maximum non-farout value. + */ + @Override + public Number getMaxOutlier(int series, int item) { + Number result = null; + BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); + if (stats != null) { + result = stats.getMaxOutlier(); + } + return result; + } + + /** + * Returns a list of outliers for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The list of outliers for the specified series and item + * (possibly null). + */ + @Override + public List getOutliers(int series, int item) { + List result = null; + BoxAndWhiskerItem stats = (BoxAndWhiskerItem) this.items.get(item); + if (stats != null) { + result = stats.getOutliers(); + } + return result; + } + + /** + * Returns the minimum y-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The minimum value. + */ + @Override + public double getRangeLowerBound(boolean includeInterval) { + double result = Double.NaN; + if (this.minimumRangeValue != null) { + result = this.minimumRangeValue.doubleValue(); + } + return result; + } + + /** + * Returns the maximum y-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The maximum value. + */ + @Override + public double getRangeUpperBound(boolean includeInterval) { + double result = Double.NaN; + if (this.maximumRangeValue != null) { + result = this.maximumRangeValue.doubleValue(); + } + return result; + } + + /** + * Returns the range of the values in this dataset's range. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The range. + */ + @Override + public Range getRangeBounds(boolean includeInterval) { + return this.rangeBounds; + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DefaultBoxAndWhiskerXYDataset)) { + return false; + } + DefaultBoxAndWhiskerXYDataset that + = (DefaultBoxAndWhiskerXYDataset) obj; + if (!ObjectUtilities.equal(this.seriesKey, that.seriesKey)) { + return false; + } + if (!this.dates.equals(that.dates)) { + return false; + } + if (!this.items.equals(that.items)) { + return false; + } + return true; + } + + /** + * Returns a clone of the plot. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the cloning is not supported. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultBoxAndWhiskerXYDataset clone + = (DefaultBoxAndWhiskerXYDataset) super.clone(); + clone.dates = new java.util.ArrayList(this.dates); + clone.items = new java.util.ArrayList(this.items); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/DefaultMultiValueCategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/DefaultMultiValueCategoryDataset.java new file mode 100755 index 0000000..e56aa40 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/DefaultMultiValueCategoryDataset.java @@ -0,0 +1,417 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------- + * DefaultMultiValueCategoryDataset.java + * ------------------------------------- + * (C) Copyright 2007-2013, by David Forslund and Contributors. + * + * Original Author: David Forslund; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 08-Oct-2007 : Version 1, see patch 1780779 (DG); + * 06-Nov-2007 : Return EMPTY_LIST not null from getValues() (DG); + * 02-JUL-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.statistics; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.KeyedObjects2D; +import org.jfree.data.Range; +import org.jfree.data.RangeInfo; +import org.jfree.data.general.AbstractDataset; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.util.PublicCloneable; + +/** + * A category dataset that defines multiple values for each item. + * + * @since 1.0.7 + */ +public class DefaultMultiValueCategoryDataset extends AbstractDataset + implements MultiValueCategoryDataset, RangeInfo, PublicCloneable { + + /** + * Storage for the data. + */ + protected KeyedObjects2D data; + + /** + * The minimum range value. + */ + private Number minimumRangeValue; + + /** + * The maximum range value. + */ + private Number maximumRangeValue; + + /** + * The range of values. + */ + private Range rangeBounds; + + /** + * Creates a new dataset. + */ + public DefaultMultiValueCategoryDataset() { + this.data = new KeyedObjects2D(); + this.minimumRangeValue = null; + this.maximumRangeValue = null; + this.rangeBounds = new Range(0.0, 0.0); + } + + /** + * Adds a list of values to the dataset (null and Double.NaN + * items are automatically removed) and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param values a list of values (null not permitted). + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + */ + public void add(List values, Comparable rowKey, Comparable columnKey) { + + ParamChecks.nullNotPermitted(values, "values"); + ParamChecks.nullNotPermitted(rowKey, "rowKey"); + ParamChecks.nullNotPermitted(columnKey, "columnKey"); + List vlist = new ArrayList(values.size()); + Iterator iterator = values.listIterator(); + while (iterator.hasNext()) { + Object obj = iterator.next(); + if (obj instanceof Number) { + Number n = (Number) obj; + double v = n.doubleValue(); + if (!Double.isNaN(v)) { + vlist.add(n); + } + } + } + Collections.sort(vlist); + this.data.addObject(vlist, rowKey, columnKey); + + if (vlist.size() > 0) { + double maxval = Double.NEGATIVE_INFINITY; + double minval = Double.POSITIVE_INFINITY; + for (int i = 0; i < vlist.size(); i++) { + Number n = (Number) vlist.get(i); + double v = n.doubleValue(); + minval = Math.min(minval, v); + maxval = Math.max(maxval, v); + } + + // update the cached range values... + if (this.maximumRangeValue == null) { + this.maximumRangeValue = new Double(maxval); + } + else if (maxval > this.maximumRangeValue.doubleValue()) { + this.maximumRangeValue = new Double(maxval); + } + + if (this.minimumRangeValue == null) { + this.minimumRangeValue = new Double(minval); + } + else if (minval < this.minimumRangeValue.doubleValue()) { + this.minimumRangeValue = new Double(minval); + } + this.rangeBounds = new Range(this.minimumRangeValue.doubleValue(), + this.maximumRangeValue.doubleValue()); + } + + fireDatasetChanged(); + } + + /** + * Returns a list (possibly empty) of the values for the specified item. + * The returned list should be unmodifiable. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The list of values. + */ + @Override + public List getValues(int row, int column) { + List values = (List) this.data.getObject(row, column); + if (values != null) { + return Collections.unmodifiableList(values); + } + else { + return Collections.EMPTY_LIST; + } + } + + /** + * Returns a list (possibly empty) of the values for the specified item. + * The returned list should be unmodifiable. + * + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @return The list of values. + */ + @Override + public List getValues(Comparable rowKey, Comparable columnKey) { + return Collections.unmodifiableList((List) this.data.getObject(rowKey, + columnKey)); + } + + /** + * Returns the average value for the specified item. + * + * @param row the row key. + * @param column the column key. + * + * @return The average value. + */ + @Override + public Number getValue(Comparable row, Comparable column) { + List l = (List) this.data.getObject(row, column); + double average = 0.0d; + int count = 0; + if (l != null && l.size() > 0) { + for (int i = 0; i < l.size(); i++) { + Number n = (Number) l.get(i); + average += n.doubleValue(); + count += 1; + } + if (count > 0) { + average = average / count; + } + } + if (count == 0) { + return null; + } + return new Double(average); + } + + /** + * Returns the average value for the specified item. + * + * @param row the row index. + * @param column the column index. + * + * @return The average value. + */ + @Override + public Number getValue(int row, int column) { + List l = (List) this.data.getObject(row, column); + double average = 0.0d; + int count = 0; + if (l != null && l.size() > 0) { + for (int i = 0; i < l.size(); i++) { + Number n = (Number) l.get(i); + average += n.doubleValue(); + count += 1; + } + if (count > 0) { + average = average / count; + } + } + if (count == 0) { + return null; + } + return new Double(average); + } + + /** + * Returns the column index for a given key. + * + * @param key the column key. + * + * @return The column index. + */ + @Override + public int getColumnIndex(Comparable key) { + return this.data.getColumnIndex(key); + } + + /** + * Returns a column key. + * + * @param column the column index (zero-based). + * + * @return The column key. + */ + @Override + public Comparable getColumnKey(int column) { + return this.data.getColumnKey(column); + } + + /** + * Returns the column keys. + * + * @return The keys. + */ + @Override + public List getColumnKeys() { + return this.data.getColumnKeys(); + } + + /** + * Returns the row index for a given key. + * + * @param key the row key. + * + * @return The row index. + */ + @Override + public int getRowIndex(Comparable key) { + return this.data.getRowIndex(key); + } + + /** + * Returns a row key. + * + * @param row the row index (zero-based). + * + * @return The row key. + */ + @Override + public Comparable getRowKey(int row) { + return this.data.getRowKey(row); + } + + /** + * Returns the row keys. + * + * @return The keys. + */ + @Override + public List getRowKeys() { + return this.data.getRowKeys(); + } + + /** + * Returns the number of rows in the table. + * + * @return The row count. + */ + @Override + public int getRowCount() { + return this.data.getRowCount(); + } + + /** + * Returns the number of columns in the table. + * + * @return The column count. + */ + @Override + public int getColumnCount() { + return this.data.getColumnCount(); + } + + /** + * Returns the minimum y-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The minimum value. + */ + @Override + public double getRangeLowerBound(boolean includeInterval) { + double result = Double.NaN; + if (this.minimumRangeValue != null) { + result = this.minimumRangeValue.doubleValue(); + } + return result; + } + + /** + * Returns the maximum y-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The maximum value. + */ + @Override + public double getRangeUpperBound(boolean includeInterval) { + double result = Double.NaN; + if (this.maximumRangeValue != null) { + result = this.maximumRangeValue.doubleValue(); + } + return result; + } + + /** + * Returns the range of the values in this dataset's range. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * @return The range. + */ + @Override + public Range getRangeBounds(boolean includeInterval) { + return this.rangeBounds; + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DefaultMultiValueCategoryDataset)) { + return false; + } + DefaultMultiValueCategoryDataset that + = (DefaultMultiValueCategoryDataset) obj; + return this.data.equals(that.data); + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the dataset cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultMultiValueCategoryDataset clone + = (DefaultMultiValueCategoryDataset) super.clone(); + clone.data = (KeyedObjects2D) this.data.clone(); + return clone; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.java new file mode 100755 index 0000000..388f528 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/DefaultStatisticalCategoryDataset.java @@ -0,0 +1,735 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------------- + * DefaultStatisticalCategoryDataset.java + * -------------------------------------- + * (C) Copyright 2002-2011, by Pascal Collet and Contributors. + * + * Original Author: Pascal Collet; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 21-Aug-2002 : Version 1, contributed by Pascal Collet (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 05-Feb-2003 : Revised implementation to use KeyedObjects2D (DG); + * 28-Aug-2003 : Moved from org.jfree.data --> org.jfree.data.statistics (DG); + * 06-Oct-2003 : Removed incorrect Javadoc text (DG); + * 18-Nov-2004 : Updated for changes in RangeInfo interface (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * 01-Feb-2005 : Changed minimumRangeValue and maximumRangeValue from Double + * to double (DG); + * 05-Feb-2005 : Implemented equals() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 08-Aug-2006 : Reworked implementation of RangeInfo methods (DG); + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * 28-Sep-2007 : Fixed cloning bug (DG); + * 02-Oct-2007 : Fixed bug updating cached range values (DG); + * 19-May-2009 : Fixed FindBugs warnings, patch by Michal Wozniak (DG); + * 20-Oct-2011 : Fixed getRangeBounds() bug 3072674 (DG); + * + */ + +package org.jfree.data.statistics; + +import java.util.List; + +import org.jfree.data.KeyedObjects2D; +import org.jfree.data.Range; +import org.jfree.data.RangeInfo; +import org.jfree.data.general.AbstractDataset; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.util.PublicCloneable; + +/** + * A convenience class that provides a default implementation of the + * {@link StatisticalCategoryDataset} interface. + */ +public class DefaultStatisticalCategoryDataset extends AbstractDataset + implements StatisticalCategoryDataset, RangeInfo, PublicCloneable { + + /** Storage for the data. */ + private KeyedObjects2D data; + + /** The minimum range value. */ + private double minimumRangeValue; + + /** The row index for the minimum range value. */ + private int minimumRangeValueRow; + + /** The column index for the minimum range value. */ + private int minimumRangeValueColumn; + + /** The minimum range value including the standard deviation. */ + private double minimumRangeValueIncStdDev; + + /** + * The row index for the minimum range value (including the standard + * deviation). + */ + private int minimumRangeValueIncStdDevRow; + + /** + * The column index for the minimum range value (including the standard + * deviation). + */ + private int minimumRangeValueIncStdDevColumn; + + /** The maximum range value. */ + private double maximumRangeValue; + + /** The row index for the maximum range value. */ + private int maximumRangeValueRow; + + /** The column index for the maximum range value. */ + private int maximumRangeValueColumn; + + /** The maximum range value including the standard deviation. */ + private double maximumRangeValueIncStdDev; + + /** + * The row index for the maximum range value (including the standard + * deviation). + */ + private int maximumRangeValueIncStdDevRow; + + /** + * The column index for the maximum range value (including the standard + * deviation). + */ + private int maximumRangeValueIncStdDevColumn; + + /** + * Creates a new dataset. + */ + public DefaultStatisticalCategoryDataset() { + this.data = new KeyedObjects2D(); + this.minimumRangeValue = Double.NaN; + this.minimumRangeValueRow = -1; + this.minimumRangeValueColumn = -1; + this.maximumRangeValue = Double.NaN; + this.maximumRangeValueRow = -1; + this.maximumRangeValueColumn = -1; + this.minimumRangeValueIncStdDev = Double.NaN; + this.minimumRangeValueIncStdDevRow = -1; + this.minimumRangeValueIncStdDevColumn = -1; + this.maximumRangeValueIncStdDev = Double.NaN; + this.maximumRangeValueIncStdDevRow = -1; + this.maximumRangeValueIncStdDevColumn = -1; + } + + /** + * Returns the mean value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The mean value (possibly null). + */ + @Override + public Number getMeanValue(int row, int column) { + Number result = null; + MeanAndStandardDeviation masd = (MeanAndStandardDeviation) + this.data.getObject(row, column); + if (masd != null) { + result = masd.getMean(); + } + return result; + } + + /** + * Returns the value for an item (for this dataset, the mean value is + * returned). + * + * @param row the row index. + * @param column the column index. + * + * @return The value (possibly null). + */ + @Override + public Number getValue(int row, int column) { + return getMeanValue(row, column); + } + + /** + * Returns the value for an item (for this dataset, the mean value is + * returned). + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The value (possibly null). + */ + @Override + public Number getValue(Comparable rowKey, Comparable columnKey) { + return getMeanValue(rowKey, columnKey); + } + + /** + * Returns the mean value for an item. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The mean value (possibly null). + */ + @Override + public Number getMeanValue(Comparable rowKey, Comparable columnKey) { + Number result = null; + MeanAndStandardDeviation masd = (MeanAndStandardDeviation) + this.data.getObject(rowKey, columnKey); + if (masd != null) { + result = masd.getMean(); + } + return result; + } + + /** + * Returns the standard deviation value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The standard deviation (possibly null). + */ + @Override + public Number getStdDevValue(int row, int column) { + Number result = null; + MeanAndStandardDeviation masd = (MeanAndStandardDeviation) + this.data.getObject(row, column); + if (masd != null) { + result = masd.getStandardDeviation(); + } + return result; + } + + /** + * Returns the standard deviation value for an item. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The standard deviation (possibly null). + */ + @Override + public Number getStdDevValue(Comparable rowKey, Comparable columnKey) { + Number result = null; + MeanAndStandardDeviation masd = (MeanAndStandardDeviation) + this.data.getObject(rowKey, columnKey); + if (masd != null) { + result = masd.getStandardDeviation(); + } + return result; + } + + /** + * Returns the column index for a given key. + * + * @param key the column key (null not permitted). + * + * @return The column index. + */ + @Override + public int getColumnIndex(Comparable key) { + // defer null argument check + return this.data.getColumnIndex(key); + } + + /** + * Returns a column key. + * + * @param column the column index (zero-based). + * + * @return The column key. + */ + @Override + public Comparable getColumnKey(int column) { + return this.data.getColumnKey(column); + } + + /** + * Returns the column keys. + * + * @return The keys. + */ + @Override + public List getColumnKeys() { + return this.data.getColumnKeys(); + } + + /** + * Returns the row index for a given key. + * + * @param key the row key (null not permitted). + * + * @return The row index. + */ + @Override + public int getRowIndex(Comparable key) { + // defer null argument check + return this.data.getRowIndex(key); + } + + /** + * Returns a row key. + * + * @param row the row index (zero-based). + * + * @return The row key. + */ + @Override + public Comparable getRowKey(int row) { + return this.data.getRowKey(row); + } + + /** + * Returns the row keys. + * + * @return The keys. + */ + @Override + public List getRowKeys() { + return this.data.getRowKeys(); + } + + /** + * Returns the number of rows in the table. + * + * @return The row count. + * + * @see #getColumnCount() + */ + @Override + public int getRowCount() { + return this.data.getRowCount(); + } + + /** + * Returns the number of columns in the table. + * + * @return The column count. + * + * @see #getRowCount() + */ + @Override + public int getColumnCount() { + return this.data.getColumnCount(); + } + + /** + * Adds a mean and standard deviation to the table. + * + * @param mean the mean. + * @param standardDeviation the standard deviation. + * @param rowKey the row key. + * @param columnKey the column key. + */ + public void add(double mean, double standardDeviation, + Comparable rowKey, Comparable columnKey) { + add(new Double(mean), new Double(standardDeviation), rowKey, columnKey); + } + + /** + * Adds a mean and standard deviation to the table. + * + * @param mean the mean. + * @param standardDeviation the standard deviation. + * @param rowKey the row key. + * @param columnKey the column key. + */ + public void add(Number mean, Number standardDeviation, + Comparable rowKey, Comparable columnKey) { + MeanAndStandardDeviation item = new MeanAndStandardDeviation( + mean, standardDeviation); + this.data.addObject(item, rowKey, columnKey); + + double m = Double.NaN; + double sd = Double.NaN; + if (mean != null) { + m = mean.doubleValue(); + } + if (standardDeviation != null) { + sd = standardDeviation.doubleValue(); + } + + // update cached range values + int r = this.data.getColumnIndex(columnKey); + int c = this.data.getRowIndex(rowKey); + if ((r == this.maximumRangeValueRow && c + == this.maximumRangeValueColumn) || (r + == this.maximumRangeValueIncStdDevRow && c + == this.maximumRangeValueIncStdDevColumn) || (r + == this.minimumRangeValueRow && c + == this.minimumRangeValueColumn) || (r + == this.minimumRangeValueIncStdDevRow && c + == this.minimumRangeValueIncStdDevColumn)) { + + // iterate over all data items and update mins and maxes + updateBounds(); + } + else { + if (!Double.isNaN(m)) { + if (Double.isNaN(this.maximumRangeValue) + || m > this.maximumRangeValue) { + this.maximumRangeValue = m; + this.maximumRangeValueRow = r; + this.maximumRangeValueColumn = c; + } + } + + if (!Double.isNaN(m + sd)) { + if (Double.isNaN(this.maximumRangeValueIncStdDev) + || (m + sd) > this.maximumRangeValueIncStdDev) { + this.maximumRangeValueIncStdDev = m + sd; + this.maximumRangeValueIncStdDevRow = r; + this.maximumRangeValueIncStdDevColumn = c; + } + } + + if (!Double.isNaN(m)) { + if (Double.isNaN(this.minimumRangeValue) + || m < this.minimumRangeValue) { + this.minimumRangeValue = m; + this.minimumRangeValueRow = r; + this.minimumRangeValueColumn = c; + } + } + + if (!Double.isNaN(m - sd)) { + if (Double.isNaN(this.minimumRangeValueIncStdDev) + || (m - sd) < this.minimumRangeValueIncStdDev) { + this.minimumRangeValueIncStdDev = m - sd; + this.minimumRangeValueIncStdDevRow = r; + this.minimumRangeValueIncStdDevColumn = c; + } + } + } + fireDatasetChanged(); + } + + /** + * Removes an item from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @see #add(double, double, Comparable, Comparable) + * + * @since 1.0.7 + */ + public void remove(Comparable rowKey, Comparable columnKey) { + // defer null argument checks + int r = getRowIndex(rowKey); + int c = getColumnIndex(columnKey); + this.data.removeObject(rowKey, columnKey); + + // if this cell held a maximum and/or minimum value, we'll need to + // update the cached bounds... + if ((r == this.maximumRangeValueRow && c + == this.maximumRangeValueColumn) || (r + == this.maximumRangeValueIncStdDevRow && c + == this.maximumRangeValueIncStdDevColumn) || (r + == this.minimumRangeValueRow && c + == this.minimumRangeValueColumn) || (r + == this.minimumRangeValueIncStdDevRow && c + == this.minimumRangeValueIncStdDevColumn)) { + + // iterate over all data items and update mins and maxes + updateBounds(); + } + + fireDatasetChanged(); + } + + + /** + * Removes a row from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param rowIndex the row index. + * + * @see #removeColumn(int) + * + * @since 1.0.7 + */ + public void removeRow(int rowIndex) { + this.data.removeRow(rowIndex); + updateBounds(); + fireDatasetChanged(); + } + + /** + * Removes a row from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param rowKey the row key (null not permitted). + * + * @see #removeColumn(Comparable) + * + * @since 1.0.7 + */ + public void removeRow(Comparable rowKey) { + this.data.removeRow(rowKey); + updateBounds(); + fireDatasetChanged(); + } + + /** + * Removes a column from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param columnIndex the column index. + * + * @see #removeRow(int) + * + * @since 1.0.7 + */ + public void removeColumn(int columnIndex) { + this.data.removeColumn(columnIndex); + updateBounds(); + fireDatasetChanged(); + } + + /** + * Removes a column from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param columnKey the column key (null not permitted). + * + * @see #removeRow(Comparable) + * + * @since 1.0.7 + */ + public void removeColumn(Comparable columnKey) { + this.data.removeColumn(columnKey); + updateBounds(); + fireDatasetChanged(); + } + + /** + * Clears all data from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @since 1.0.7 + */ + public void clear() { + this.data.clear(); + updateBounds(); + fireDatasetChanged(); + } + + /** + * Iterate over all the data items and update the cached bound values. + */ + private void updateBounds() { + this.maximumRangeValue = Double.NaN; + this.maximumRangeValueRow = -1; + this.maximumRangeValueColumn = -1; + this.minimumRangeValue = Double.NaN; + this.minimumRangeValueRow = -1; + this.minimumRangeValueColumn = -1; + this.maximumRangeValueIncStdDev = Double.NaN; + this.maximumRangeValueIncStdDevRow = -1; + this.maximumRangeValueIncStdDevColumn = -1; + this.minimumRangeValueIncStdDev = Double.NaN; + this.minimumRangeValueIncStdDevRow = -1; + this.minimumRangeValueIncStdDevColumn = -1; + + int rowCount = this.data.getRowCount(); + int columnCount = this.data.getColumnCount(); + for (int r = 0; r < rowCount; r++) { + for (int c = 0; c < columnCount; c++) { + MeanAndStandardDeviation masd = (MeanAndStandardDeviation) + this.data.getObject(r, c); + if (masd == null) { + continue; + } + double m = masd.getMeanValue(); + double sd = masd.getStandardDeviationValue(); + + if (!Double.isNaN(m)) { + + // update the max value + if (Double.isNaN(this.maximumRangeValue)) { + this.maximumRangeValue = m; + this.maximumRangeValueRow = r; + this.maximumRangeValueColumn = c; + } + else { + if (m > this.maximumRangeValue) { + this.maximumRangeValue = m; + this.maximumRangeValueRow = r; + this.maximumRangeValueColumn = c; + } + } + + // update the min value + if (Double.isNaN(this.minimumRangeValue)) { + this.minimumRangeValue = m; + this.minimumRangeValueRow = r; + this.minimumRangeValueColumn = c; + } + else { + if (m < this.minimumRangeValue) { + this.minimumRangeValue = m; + this.minimumRangeValueRow = r; + this.minimumRangeValueColumn = c; + } + } + + if (!Double.isNaN(sd)) { + // update the max value + if (Double.isNaN(this.maximumRangeValueIncStdDev)) { + this.maximumRangeValueIncStdDev = m + sd; + this.maximumRangeValueIncStdDevRow = r; + this.maximumRangeValueIncStdDevColumn = c; + } + else { + if (m + sd > this.maximumRangeValueIncStdDev) { + this.maximumRangeValueIncStdDev = m + sd; + this.maximumRangeValueIncStdDevRow = r; + this.maximumRangeValueIncStdDevColumn = c; + } + } + + // update the min value + if (Double.isNaN(this.minimumRangeValueIncStdDev)) { + this.minimumRangeValueIncStdDev = m - sd; + this.minimumRangeValueIncStdDevRow = r; + this.minimumRangeValueIncStdDevColumn = c; + } + else { + if (m - sd < this.minimumRangeValueIncStdDev) { + this.minimumRangeValueIncStdDev = m - sd; + this.minimumRangeValueIncStdDevRow = r; + this.minimumRangeValueIncStdDevColumn = c; + } + } + } + } + } + } + } + + /** + * Returns the minimum y-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The minimum value. + * + * @see #getRangeUpperBound(boolean) + */ + @Override + public double getRangeLowerBound(boolean includeInterval) { + if (includeInterval && !Double.isNaN(this.minimumRangeValueIncStdDev)) { + return this.minimumRangeValueIncStdDev; + } + else { + return this.minimumRangeValue; + } + } + + /** + * Returns the maximum y-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The maximum value. + * + * @see #getRangeLowerBound(boolean) + */ + @Override + public double getRangeUpperBound(boolean includeInterval) { + if (includeInterval && !Double.isNaN(this.maximumRangeValueIncStdDev)) { + return this.maximumRangeValueIncStdDev; + } + else { + return this.maximumRangeValue; + } + } + + /** + * Returns the bounds of the values in this dataset's y-values. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The range. + */ + @Override + public Range getRangeBounds(boolean includeInterval) { + double lower = getRangeLowerBound(includeInterval); + double upper = getRangeUpperBound(includeInterval); + if (Double.isNaN(lower) && Double.isNaN(upper)) { + return null; + } + return new Range(lower, upper); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DefaultStatisticalCategoryDataset)) { + return false; + } + DefaultStatisticalCategoryDataset that + = (DefaultStatisticalCategoryDataset) obj; + if (!this.data.equals(that.data)) { + return false; + } + return true; + } + + /** + * Returns a clone of this dataset. + * + * @return A clone of this dataset. + * + * @throws CloneNotSupportedException if cloning cannot be completed. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultStatisticalCategoryDataset clone + = (DefaultStatisticalCategoryDataset) super.clone(); + clone.data = (KeyedObjects2D) this.data.clone(); + return clone; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/HistogramBin.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/HistogramBin.java new file mode 100755 index 0000000..e5d4ea1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/HistogramBin.java @@ -0,0 +1,162 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * HistogramBin.java + * ----------------- + * (C) Copyright 2003-2008, by Jelai Wang and Contributors. + * + * Original Author: Jelai Wang (jelaiw AT mindspring.com); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 06-Jul-2003 : Version 1, contributed by Jelai Wang (DG); + * 07-Jul-2003 : Changed package and added Javadocs (DG); + * 01-Mar-2004 : Moved from org.jfree.data --> org.jfree.data.statistics (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.statistics; + +import java.io.Serializable; + +/** + * A bin for the {@link HistogramDataset} class. + */ +public class HistogramBin implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7614685080015589931L; + + /** The number of items in the bin. */ + private int count; + + /** The start boundary. */ + private double startBoundary; + + /** The end boundary. */ + private double endBoundary; + + /** + * Creates a new bin. + * + * @param startBoundary the start boundary. + * @param endBoundary the end boundary. + */ + public HistogramBin(double startBoundary, double endBoundary) { + if (startBoundary > endBoundary) { + throw new IllegalArgumentException( + "HistogramBin(): startBoundary > endBoundary."); + } + this.count = 0; + this.startBoundary = startBoundary; + this.endBoundary = endBoundary; + } + + /** + * Returns the number of items in the bin. + * + * @return The item count. + */ + public int getCount() { + return this.count; + } + + /** + * Increments the item count. + */ + public void incrementCount() { + this.count++; + } + + /** + * Returns the start boundary. + * + * @return The start boundary. + */ + public double getStartBoundary() { + return this.startBoundary; + } + + /** + * Returns the end boundary. + * + * @return The end boundary. + */ + public double getEndBoundary() { + return this.endBoundary; + } + + /** + * Returns the bin width. + * + * @return The bin width. + */ + public double getBinWidth() { + return this.endBoundary - this.startBoundary; + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the object to test against. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (obj == this) { + return true; + } + if (obj instanceof HistogramBin) { + HistogramBin bin = (HistogramBin) obj; + boolean b0 = bin.startBoundary == this.startBoundary; + boolean b1 = bin.endBoundary == this.endBoundary; + boolean b2 = bin.count == this.count; + return b0 && b1 && b2; + } + return false; + } + + /** + * Returns a clone of the bin. + * + * @return A clone. + * + * @throws CloneNotSupportedException not thrown by this class. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/HistogramDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/HistogramDataset.java new file mode 100755 index 0000000..8a2646c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/HistogramDataset.java @@ -0,0 +1,514 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * HistogramDataset.java + * --------------------- + * (C) Copyright 2003-2013, by Jelai Wang and Contributors. + * + * Original Author: Jelai Wang (jelaiw AT mindspring.com); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Cameron Hayne; + * Rikard Bj?rklind; + * Thomas A Caswell (patch 2902842); + * + * Changes + * ------- + * 06-Jul-2003 : Version 1, contributed by Jelai Wang (DG); + * 07-Jul-2003 : Changed package and added Javadocs (DG); + * 15-Oct-2003 : Updated Javadocs and removed array sorting (JW); + * 09-Jan-2004 : Added fix by "Z." posted in the JFreeChart forum (DG); + * 01-Mar-2004 : Added equals() and clone() methods and implemented + * Serializable. Also added new addSeries() method (DG); + * 06-May-2004 : Now extends AbstractIntervalXYDataset (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 20-May-2005 : Speed up binning - see patch 1026151 contributed by Cameron + * Hayne (DG); + * 08-Jun-2005 : Fixed bug in getSeriesKey() method (DG); + * 22-Nov-2005 : Fixed cast in getSeriesKey() method - see patch 1329287 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 03-Aug-2006 : Improved precision of bin boundary calculation (DG); + * 07-Sep-2006 : Fixed bug 1553088 (DG); + * 22-May-2008 : Implemented clone() method override (DG); + * 08-Dec-2009 : Fire change event in addSeries() - see patch 2902842 + * contributed by Thomas A Caswell (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.statistics; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.xy.AbstractIntervalXYDataset; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A dataset that can be used for creating histograms. + * + * @see SimpleHistogramDataset + */ +public class HistogramDataset extends AbstractIntervalXYDataset + implements IntervalXYDataset, Cloneable, PublicCloneable, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -6341668077370231153L; + + /** A list of maps. */ + private List list; + + /** The histogram type. */ + private HistogramType type; + + /** + * Creates a new (empty) dataset with a default type of + * {@link HistogramType}.FREQUENCY. + */ + public HistogramDataset() { + this.list = new ArrayList(); + this.type = HistogramType.FREQUENCY; + } + + /** + * Returns the histogram type. + * + * @return The type (never null). + */ + public HistogramType getType() { + return this.type; + } + + /** + * Sets the histogram type and sends a {@link DatasetChangeEvent} to all + * registered listeners. + * + * @param type the type (null not permitted). + */ + public void setType(HistogramType type) { + ParamChecks.nullNotPermitted(type, "type"); + this.type = type; + fireDatasetChanged(); + } + + /** + * Adds a series to the dataset, using the specified number of bins, + * and sends a {@link DatasetChangeEvent} to all registered listeners. + * + * @param key the series key (null not permitted). + * @param values the values (null not permitted). + * @param bins the number of bins (must be at least 1). + */ + public void addSeries(Comparable key, double[] values, int bins) { + // defer argument checking... + double minimum = getMinimum(values); + double maximum = getMaximum(values); + addSeries(key, values, bins, minimum, maximum); + } + + /** + * Adds a series to the dataset. Any data value less than minimum will be + * assigned to the first bin, and any data value greater than maximum will + * be assigned to the last bin. Values falling on the boundary of + * adjacent bins will be assigned to the higher indexed bin. + * + * @param key the series key (null not permitted). + * @param values the raw observations. + * @param bins the number of bins (must be at least 1). + * @param minimum the lower bound of the bin range. + * @param maximum the upper bound of the bin range. + */ + public void addSeries(Comparable key, double[] values, int bins, + double minimum, double maximum) { + + ParamChecks.nullNotPermitted(key, "key"); + ParamChecks.nullNotPermitted(values, "values"); + if (bins < 1) { + throw new IllegalArgumentException( + "The 'bins' value must be at least 1."); + } + double binWidth = (maximum - minimum) / bins; + + double lower = minimum; + double upper; + List binList = new ArrayList(bins); + for (int i = 0; i < bins; i++) { + HistogramBin bin; + // make sure bins[bins.length]'s upper boundary ends at maximum + // to avoid the rounding issue. the bins[0] lower boundary is + // guaranteed start from min + if (i == bins - 1) { + bin = new HistogramBin(lower, maximum); + } + else { + upper = minimum + (i + 1) * binWidth; + bin = new HistogramBin(lower, upper); + lower = upper; + } + binList.add(bin); + } + // fill the bins + for (int i = 0; i < values.length; i++) { + int binIndex = bins - 1; + if (values[i] < maximum) { + double fraction = (values[i] - minimum) / (maximum - minimum); + if (fraction < 0.0) { + fraction = 0.0; + } + binIndex = (int) (fraction * bins); + // rounding could result in binIndex being equal to bins + // which will cause an IndexOutOfBoundsException - see bug + // report 1553088 + if (binIndex >= bins) { + binIndex = bins - 1; + } + } + HistogramBin bin = (HistogramBin) binList.get(binIndex); + bin.incrementCount(); + } + // generic map for each series + Map map = new HashMap(); + map.put("key", key); + map.put("bins", binList); + map.put("values.length", new Integer(values.length)); + map.put("bin width", new Double(binWidth)); + this.list.add(map); + fireDatasetChanged(); + } + + /** + * Returns the minimum value in an array of values. + * + * @param values the values (null not permitted and + * zero-length array not permitted). + * + * @return The minimum value. + */ + private double getMinimum(double[] values) { + if (values == null || values.length < 1) { + throw new IllegalArgumentException( + "Null or zero length 'values' argument."); + } + double min = Double.MAX_VALUE; + for (int i = 0; i < values.length; i++) { + if (values[i] < min) { + min = values[i]; + } + } + return min; + } + + /** + * Returns the maximum value in an array of values. + * + * @param values the values (null not permitted and + * zero-length array not permitted). + * + * @return The maximum value. + */ + private double getMaximum(double[] values) { + if (values == null || values.length < 1) { + throw new IllegalArgumentException( + "Null or zero length 'values' argument."); + } + double max = -Double.MAX_VALUE; + for (int i = 0; i < values.length; i++) { + if (values[i] > max) { + max = values[i]; + } + } + return max; + } + + /** + * Returns the bins for a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return A list of bins. + * + * @throws IndexOutOfBoundsException if series is outside the + * specified range. + */ + List getBins(int series) { + Map map = (Map) this.list.get(series); + return (List) map.get("bins"); + } + + /** + * Returns the total number of observations for a series. + * + * @param series the series index. + * + * @return The total. + */ + private int getTotal(int series) { + Map map = (Map) this.list.get(series); + return ((Integer) map.get("values.length")).intValue(); + } + + /** + * Returns the bin width for a series. + * + * @param series the series index (zero based). + * + * @return The bin width. + */ + private double getBinWidth(int series) { + Map map = (Map) this.list.get(series); + return ((Double) map.get("bin width")).doubleValue(); + } + + /** + * Returns the number of series in the dataset. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.list.size(); + } + + /** + * Returns the key for a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The series key. + * + * @throws IndexOutOfBoundsException if series is outside the + * specified range. + */ + @Override + public Comparable getSeriesKey(int series) { + Map map = (Map) this.list.get(series); + return (Comparable) map.get("key"); + } + + /** + * Returns the number of data items for a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The item count. + * + * @throws IndexOutOfBoundsException if series is outside the + * specified range. + */ + @Override + public int getItemCount(int series) { + return getBins(series).size(); + } + + /** + * Returns the X value for a bin. This value won't be used for plotting + * histograms, since the renderer will ignore it. But other renderers can + * use it (for example, you could use the dataset to create a line + * chart). + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (zero based). + * + * @return The start value. + * + * @throws IndexOutOfBoundsException if series is outside the + * specified range. + */ + @Override + public Number getX(int series, int item) { + List bins = getBins(series); + HistogramBin bin = (HistogramBin) bins.get(item); + double x = (bin.getStartBoundary() + bin.getEndBoundary()) / 2.; + return new Double(x); + } + + /** + * Returns the y-value for a bin (calculated to take into account the + * histogram type). + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (zero based). + * + * @return The y-value. + * + * @throws IndexOutOfBoundsException if series is outside the + * specified range. + */ + @Override + public Number getY(int series, int item) { + List bins = getBins(series); + HistogramBin bin = (HistogramBin) bins.get(item); + double total = getTotal(series); + double binWidth = getBinWidth(series); + + if (this.type == HistogramType.FREQUENCY) { + return new Double(bin.getCount()); + } + else if (this.type == HistogramType.RELATIVE_FREQUENCY) { + return new Double(bin.getCount() / total); + } + else if (this.type == HistogramType.SCALE_AREA_TO_1) { + return new Double(bin.getCount() / (binWidth * total)); + } + else { // pretty sure this shouldn't ever happen + throw new IllegalStateException(); + } + } + + /** + * Returns the start value for a bin. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (zero based). + * + * @return The start value. + * + * @throws IndexOutOfBoundsException if series is outside the + * specified range. + */ + @Override + public Number getStartX(int series, int item) { + List bins = getBins(series); + HistogramBin bin = (HistogramBin) bins.get(item); + return new Double(bin.getStartBoundary()); + } + + /** + * Returns the end value for a bin. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (zero based). + * + * @return The end value. + * + * @throws IndexOutOfBoundsException if series is outside the + * specified range. + */ + @Override + public Number getEndX(int series, int item) { + List bins = getBins(series); + HistogramBin bin = (HistogramBin) bins.get(item); + return new Double(bin.getEndBoundary()); + } + + /** + * Returns the start y-value for a bin (which is the same as the y-value, + * this method exists only to support the general form of the + * {@link IntervalXYDataset} interface). + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (zero based). + * + * @return The y-value. + * + * @throws IndexOutOfBoundsException if series is outside the + * specified range. + */ + @Override + public Number getStartY(int series, int item) { + return getY(series, item); + } + + /** + * Returns the end y-value for a bin (which is the same as the y-value, + * this method exists only to support the general form of the + * {@link IntervalXYDataset} interface). + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (zero based). + * + * @return The Y value. + * + * @throws IndexOutOfBoundsException if series is outside the + * specified range. + */ + @Override + public Number getEndY(int series, int item) { + return getY(series, item); + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof HistogramDataset)) { + return false; + } + HistogramDataset that = (HistogramDataset) obj; + if (!ObjectUtilities.equal(this.type, that.type)) { + return false; + } + if (!ObjectUtilities.equal(this.list, that.list)) { + return false; + } + return true; + } + + /** + * Returns a clone of the dataset. + * + * @return A clone of the dataset. + * + * @throws CloneNotSupportedException if the object cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + HistogramDataset clone = (HistogramDataset) super.clone(); + int seriesCount = getSeriesCount(); + clone.list = new java.util.ArrayList(seriesCount); + for (int i = 0; i < seriesCount; i++) { + clone.list.add(new HashMap((Map) this.list.get(i))); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/HistogramType.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/HistogramType.java new file mode 100755 index 0000000..a8aa8a2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/HistogramType.java @@ -0,0 +1,151 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * HistogramType.java + * ------------------ + * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Mar-2004 : Version 1 (DG); + * + */ + +package org.jfree.data.statistics; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * A class for creating constants to represent the histogram type. See Bloch's + * enum tip in 'Effective Java'. + */ +public class HistogramType implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 2618927186251997727L; + + /** Frequency histogram. */ + public static final HistogramType FREQUENCY + = new HistogramType("FREQUENCY"); + + /** Relative frequency. */ + public static final HistogramType RELATIVE_FREQUENCY + = new HistogramType("RELATIVE_FREQUENCY"); + + /** Scale area to one. */ + public static final HistogramType SCALE_AREA_TO_1 + = new HistogramType("SCALE_AREA_TO_1"); + + /** The type name. */ + private String name; + + /** + * Creates a new type. + * + * @param name the name. + */ + private HistogramType(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Tests this type for equality with an arbitrary object. + * + * @param obj the object to test against. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + + if (obj == null) { + return false; + } + + if (obj == this) { + return true; + } + + if (!(obj instanceof HistogramType)) { + return false; + } + + HistogramType t = (HistogramType) obj; + if (!this.name.equals(t.name)) { + return false; + } + + return true; + + } + + /** + * Returns a hash code value for the object. + * + * @return The hashcode + */ + @Override + public int hashCode() { + return this.name.hashCode(); + } + + /** + * 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(HistogramType.FREQUENCY)) { + return HistogramType.FREQUENCY; + } + else if (this.equals(HistogramType.RELATIVE_FREQUENCY)) { + return HistogramType.RELATIVE_FREQUENCY; + } + else if (this.equals(HistogramType.SCALE_AREA_TO_1)) { + return HistogramType.SCALE_AREA_TO_1; + } + return null; + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/MeanAndStandardDeviation.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/MeanAndStandardDeviation.java new file mode 100755 index 0000000..288394b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/MeanAndStandardDeviation.java @@ -0,0 +1,180 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * MeanAndStandardDeviation.java + * ----------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 05-Feb-2002 : Version 1 (DG); + * 05-Feb-2005 : Added equals() method and implemented Serializable (DG); + * 02-Oct-2007 : Added getMeanValue() and getStandardDeviationValue() methods + * for convenience, and toString() method for debugging (DG); + * + */ + +package org.jfree.data.statistics; + +import java.io.Serializable; + +import org.jfree.util.ObjectUtilities; + +/** + * A simple data structure that holds a mean value and a standard deviation + * value. This is used in the + * {@link org.jfree.data.statistics.DefaultStatisticalCategoryDataset} class. + */ +public class MeanAndStandardDeviation implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7413468697315721515L; + + /** The mean. */ + private Number mean; + + /** The standard deviation. */ + private Number standardDeviation; + + /** + * Creates a new mean and standard deviation record. + * + * @param mean the mean. + * @param standardDeviation the standard deviation. + */ + public MeanAndStandardDeviation(double mean, double standardDeviation) { + this(new Double(mean), new Double(standardDeviation)); + } + + /** + * Creates a new mean and standard deviation record. + * + * @param mean the mean (null permitted). + * @param standardDeviation the standard deviation (null + * permitted. + */ + public MeanAndStandardDeviation(Number mean, Number standardDeviation) { + this.mean = mean; + this.standardDeviation = standardDeviation; + } + + /** + * Returns the mean. + * + * @return The mean. + */ + public Number getMean() { + return this.mean; + } + + /** + * Returns the mean as a double primitive. If the underlying mean is + * null, this method will return Double.NaN. + * + * @return The mean. + * + * @see #getMean() + * + * @since 1.0.7 + */ + public double getMeanValue() { + double result = Double.NaN; + if (this.mean != null) { + result = this.mean.doubleValue(); + } + return result; + } + + /** + * Returns the standard deviation. + * + * @return The standard deviation. + */ + public Number getStandardDeviation() { + return this.standardDeviation; + } + + /** + * Returns the standard deviation as a double primitive. If the underlying + * standard deviation is null, this method will return + * Double.NaN. + * + * @return The standard deviation. + * + * @since 1.0.7 + */ + public double getStandardDeviationValue() { + double result = Double.NaN; + if (this.standardDeviation != null) { + result = this.standardDeviation.doubleValue(); + } + return result; + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof MeanAndStandardDeviation)) { + return false; + } + MeanAndStandardDeviation that = (MeanAndStandardDeviation) obj; + if (!ObjectUtilities.equal(this.mean, that.mean)) { + return false; + } + if (!ObjectUtilities.equal( + this.standardDeviation, that.standardDeviation) + ) { + return false; + } + return true; + } + + /** + * Returns a string representing this instance. + * + * @return A string. + * + * @since 1.0.7 + */ + @Override + public String toString() { + return "[" + this.mean + ", " + this.standardDeviation + "]"; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/MultiValueCategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/MultiValueCategoryDataset.java new file mode 100755 index 0000000..72cdab9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/MultiValueCategoryDataset.java @@ -0,0 +1,76 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * MultiValueCategoryDataset.java + * ------------------------------ + * (C) Copyright 2007, 2008, by David Forslund and Contributors. + * + * Original Author: David Forslund; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 08-Oct-2007 : Version 1, see patch 1780779 (DG); + * + */ + +package org.jfree.data.statistics; + +import java.util.List; + +import org.jfree.data.category.CategoryDataset; + +/** + * A category dataset that defines multiple values for each item. + * + * @since 1.0.7 + */ +public interface MultiValueCategoryDataset extends CategoryDataset { + + /** + * Returns a list (possibly empty) of the values for the specified item. + * The returned list should be unmodifiable. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The list of values. + */ + public List getValues(int row, int column); + + /** + * Returns a list (possibly empty) of the values for the specified item. + * The returned list should be unmodifiable. + * + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @return The list of values. + */ + public List getValues(Comparable rowKey, Comparable columnKey); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/Regression.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/Regression.java new file mode 100755 index 0000000..abe68ca --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/Regression.java @@ -0,0 +1,371 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * Regression.java + * --------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Peter Kolb (patch 2795746); + * + * Changes + * ------- + * 30-Sep-2002 : Version 1 (DG); + * 18-Aug-2003 : Added 'abstract' (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 29-May-2009 : Added support for polynomial regression, see patch 2795746 + * by Peter Kolb (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.statistics; + +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; + +/** + * A utility class for fitting regression curves to data. + */ +public abstract class Regression { + + /** + * Returns the parameters 'a' and 'b' for an equation y = a + bx, fitted to + * the data using ordinary least squares regression. The result is + * returned as a double[], where result[0] --> a, and result[1] --> b. + * + * @param data the data. + * + * @return The parameters. + */ + public static double[] getOLSRegression(double[][] data) { + + int n = data.length; + if (n < 2) { + throw new IllegalArgumentException("Not enough data."); + } + + double sumX = 0; + double sumY = 0; + double sumXX = 0; + double sumXY = 0; + for (int i = 0; i < n; i++) { + double x = data[i][0]; + double y = data[i][1]; + sumX += x; + sumY += y; + double xx = x * x; + sumXX += xx; + double xy = x * y; + sumXY += xy; + } + double sxx = sumXX - (sumX * sumX) / n; + double sxy = sumXY - (sumX * sumY) / n; + double xbar = sumX / n; + double ybar = sumY / n; + + double[] result = new double[2]; + result[1] = sxy / sxx; + result[0] = ybar - result[1] * xbar; + + return result; + + } + + /** + * Returns the parameters 'a' and 'b' for an equation y = a + bx, fitted to + * the data using ordinary least squares regression. The result is returned + * as a double[], where result[0] --> a, and result[1] --> b. + * + * @param data the data. + * @param series the series (zero-based index). + * + * @return The parameters. + */ + public static double[] getOLSRegression(XYDataset data, int series) { + + int n = data.getItemCount(series); + if (n < 2) { + throw new IllegalArgumentException("Not enough data."); + } + + double sumX = 0; + double sumY = 0; + double sumXX = 0; + double sumXY = 0; + for (int i = 0; i < n; i++) { + double x = data.getXValue(series, i); + double y = data.getYValue(series, i); + sumX += x; + sumY += y; + double xx = x * x; + sumXX += xx; + double xy = x * y; + sumXY += xy; + } + double sxx = sumXX - (sumX * sumX) / n; + double sxy = sumXY - (sumX * sumY) / n; + double xbar = sumX / n; + double ybar = sumY / n; + + double[] result = new double[2]; + result[1] = sxy / sxx; + result[0] = ybar - result[1] * xbar; + + return result; + + } + + /** + * Returns the parameters 'a' and 'b' for an equation y = ax^b, fitted to + * the data using a power regression equation. The result is returned as + * an array, where double[0] --> a, and double[1] --> b. + * + * @param data the data. + * + * @return The parameters. + */ + public static double[] getPowerRegression(double[][] data) { + + int n = data.length; + if (n < 2) { + throw new IllegalArgumentException("Not enough data."); + } + + double sumX = 0; + double sumY = 0; + double sumXX = 0; + double sumXY = 0; + for (int i = 0; i < n; i++) { + double x = Math.log(data[i][0]); + double y = Math.log(data[i][1]); + sumX += x; + sumY += y; + double xx = x * x; + sumXX += xx; + double xy = x * y; + sumXY += xy; + } + double sxx = sumXX - (sumX * sumX) / n; + double sxy = sumXY - (sumX * sumY) / n; + double xbar = sumX / n; + double ybar = sumY / n; + + double[] result = new double[2]; + result[1] = sxy / sxx; + result[0] = Math.pow(Math.exp(1.0), ybar - result[1] * xbar); + + return result; + + } + + /** + * Returns the parameters 'a' and 'b' for an equation y = ax^b, fitted to + * the data using a power regression equation. The result is returned as + * an array, where double[0] --> a, and double[1] --> b. + * + * @param data the data. + * @param series the series to fit the regression line against. + * + * @return The parameters. + */ + public static double[] getPowerRegression(XYDataset data, int series) { + + int n = data.getItemCount(series); + if (n < 2) { + throw new IllegalArgumentException("Not enough data."); + } + + double sumX = 0; + double sumY = 0; + double sumXX = 0; + double sumXY = 0; + for (int i = 0; i < n; i++) { + double x = Math.log(data.getXValue(series, i)); + double y = Math.log(data.getYValue(series, i)); + sumX += x; + sumY += y; + double xx = x * x; + sumXX += xx; + double xy = x * y; + sumXY += xy; + } + double sxx = sumXX - (sumX * sumX) / n; + double sxy = sumXY - (sumX * sumY) / n; + double xbar = sumX / n; + double ybar = sumY / n; + + double[] result = new double[2]; + result[1] = sxy / sxx; + result[0] = Math.pow(Math.exp(1.0), ybar - result[1] * xbar); + + return result; + + } + + /** + * Returns the parameters 'a0', 'a1', 'a2', ..., 'an' for a polynomial + * function of order n, y = a0 + a1 * x + a2 * x^2 + ... + an * x^n, + * fitted to the data using a polynomial regression equation. + * The result is returned as an array with a length of n + 2, + * where double[0] --> a0, double[1] --> a1, .., double[n] --> an. + * and double[n + 1] is the correlation coefficient R2 + * Reference: J. D. Faires, R. L. Burden, Numerische Methoden (german + * edition), pp. 243ff and 327ff. + * + * @param dataset the dataset (null not permitted). + * @param series the series to fit the regression line against (the series + * must have at least order + 1 non-NaN items). + * @param order the order of the function (> 0). + * + * @return The parameters. + * + * @since 1.0.14 + */ + public static double[] getPolynomialRegression(XYDataset dataset, + int series, int order) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + int itemCount = dataset.getItemCount(series); + if (itemCount < order + 1) { + throw new IllegalArgumentException("Not enough data."); + } + int validItems = 0; + double[][] data = new double[2][itemCount]; + for(int item = 0; item < itemCount; item++){ + double x = dataset.getXValue(series, item); + double y = dataset.getYValue(series, item); + if (!Double.isNaN(x) && !Double.isNaN(y)){ + data[0][validItems] = x; + data[1][validItems] = y; + validItems++; + } + } + if (validItems < order + 1) { + throw new IllegalArgumentException("Not enough data."); + } + int equations = order + 1; + int coefficients = order + 2; + double[] result = new double[equations + 1]; + double[][] matrix = new double[equations][coefficients]; + double sumX = 0.0; + double sumY = 0.0; + + for(int item = 0; item < validItems; item++){ + sumX += data[0][item]; + sumY += data[1][item]; + for(int eq = 0; eq < equations; eq++){ + for(int coe = 0; coe < coefficients - 1; coe++){ + matrix[eq][coe] += Math.pow(data[0][item],eq + coe); + } + matrix[eq][coefficients - 1] += data[1][item] + * Math.pow(data[0][item],eq); + } + } + double[][] subMatrix = calculateSubMatrix(matrix); + for (int eq = 1; eq < equations; eq++) { + matrix[eq][0] = 0; + for (int coe = 1; coe < coefficients; coe++) { + matrix[eq][coe] = subMatrix[eq - 1][coe - 1]; + } + } + for (int eq = equations - 1; eq > -1; eq--) { + double value = matrix[eq][coefficients - 1]; + for (int coe = eq; coe < coefficients -1; coe++) { + value -= matrix[eq][coe] * result[coe]; + } + result[eq] = value / matrix[eq][eq]; + } + double meanY = sumY / validItems; + double yObsSquare = 0.0; + double yRegSquare = 0.0; + for (int item = 0; item < validItems; item++) { + double yCalc = 0; + for (int eq = 0; eq < equations; eq++) { + yCalc += result[eq] * Math.pow(data[0][item],eq); + } + yRegSquare += Math.pow(yCalc - meanY, 2); + yObsSquare += Math.pow(data[1][item] - meanY, 2); + } + double rSquare = yRegSquare / yObsSquare; + result[equations] = rSquare; + return result; + } + + /** + * Returns a matrix with the following features: (1) the number of rows + * and columns is 1 less than that of the original matrix; (2)the matrix + * is triangular, i.e. all elements a (row, column) with column > row are + * zero. This method is used for calculating a polynomial regression. + * + * @param matrix the start matrix. + * + * @return The new matrix. + */ + private static double[][] calculateSubMatrix(double[][] matrix){ + int equations = matrix.length; + int coefficients = matrix[0].length; + double[][] result = new double[equations - 1][coefficients - 1]; + for (int eq = 1; eq < equations; eq++) { + double factor = matrix[0][0] / matrix[eq][0]; + for (int coe = 1; coe < coefficients; coe++) { + result[eq - 1][coe -1] = matrix[0][coe] - matrix[eq][coe] + * factor; + } + } + if (equations == 1) { + return result; + } + // check for zero pivot element + if (result[0][0] == 0) { + boolean found = false; + for (int i = 0; i < result.length; i ++) { + if (result[i][0] != 0) { + found = true; + double[] temp = result[0]; + System.arraycopy(result[i], 0, result[0], 0, + result[i].length); + System.arraycopy(temp, 0, result[i], 0, temp.length); + break; + } + } + if (!found) { + //System.out.println("Equation has no solution!"); + return new double[equations - 1][coefficients - 1]; + } + } + double[][] subMatrix = calculateSubMatrix(result); + for (int eq = 1; eq < equations - 1; eq++) { + result[eq][0] = 0; + for (int coe = 1; coe < coefficients - 1; coe++) { + result[eq][coe] = subMatrix[eq - 1][coe - 1]; + } + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/SimpleHistogramBin.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/SimpleHistogramBin.java new file mode 100755 index 0000000..ac2310d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/SimpleHistogramBin.java @@ -0,0 +1,269 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * SimpleHistogramBin.java + * ----------------------- + * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-Jan-2005 : Version 1 (DG); + * + */ + +package org.jfree.data.statistics; + +import java.io.Serializable; + +import org.jfree.util.PublicCloneable; + +/** + * A bin for the {@link SimpleHistogramDataset}. + */ +public class SimpleHistogramBin implements Comparable, + Cloneable, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 3480862537505941742L; + + /** The lower bound for the bin. */ + private double lowerBound; + + /** The upper bound for the bin. */ + private double upperBound; + + /** + * A flag that controls whether the lower bound is included in the bin + * range. + */ + private boolean includeLowerBound; + + /** + * A flag that controls whether the upper bound is included in the bin + * range. + */ + private boolean includeUpperBound; + + /** The item count. */ + private int itemCount; + + /** + * Creates a new bin. + * + * @param lowerBound the lower bound (inclusive). + * @param upperBound the upper bound (inclusive); + */ + public SimpleHistogramBin(double lowerBound, double upperBound) { + this(lowerBound, upperBound, true, true); + } + + /** + * Creates a new bin. + * + * @param lowerBound the lower bound. + * @param upperBound the upper bound. + * @param includeLowerBound include the lower bound? + * @param includeUpperBound include the upper bound? + */ + public SimpleHistogramBin(double lowerBound, double upperBound, + boolean includeLowerBound, + boolean includeUpperBound) { + if (lowerBound >= upperBound) { + throw new IllegalArgumentException("Invalid bounds"); + } + this.lowerBound = lowerBound; + this.upperBound = upperBound; + this.includeLowerBound = includeLowerBound; + this.includeUpperBound = includeUpperBound; + this.itemCount = 0; + } + + /** + * Returns the lower bound. + * + * @return The lower bound. + */ + public double getLowerBound() { + return this.lowerBound; + } + + /** + * Return the upper bound. + * + * @return The upper bound. + */ + public double getUpperBound() { + return this.upperBound; + } + + /** + * Returns the item count. + * + * @return The item count. + */ + public int getItemCount() { + return this.itemCount; + } + + /** + * Sets the item count. + * + * @param count the item count. + */ + public void setItemCount(int count) { + this.itemCount = count; + } + + /** + * Returns true if the specified value belongs in the bin, + * and false otherwise. + * + * @param value the value. + * + * @return A boolean. + */ + public boolean accepts(double value) { + if (Double.isNaN(value)) { + return false; + } + if (value < this.lowerBound) { + return false; + } + if (value > this.upperBound) { + return false; + } + if (value == this.lowerBound) { + return this.includeLowerBound; + } + if (value == this.upperBound) { + return this.includeUpperBound; + } + return true; + } + + /** + * Returns true if this bin overlaps with the specified bin, + * and false otherwise. + * + * @param bin the other bin (null not permitted). + * + * @return A boolean. + */ + public boolean overlapsWith(SimpleHistogramBin bin) { + if (this.upperBound < bin.lowerBound) { + return false; + } + if (this.lowerBound > bin.upperBound) { + return false; + } + if (this.upperBound == bin.lowerBound) { + return this.includeUpperBound && bin.includeLowerBound; + } + if (this.lowerBound == bin.upperBound) { + return this.includeLowerBound && bin.includeUpperBound; + } + return true; + } + + /** + * Compares the bin to an arbitrary object and returns the relative + * ordering. + * + * @param obj the object. + * + * @return An integer indicating the relative ordering of the this bin and + * the given object. + */ + @Override + public int compareTo(Object obj) { + if (!(obj instanceof SimpleHistogramBin)) { + return 0; + } + SimpleHistogramBin bin = (SimpleHistogramBin) obj; + if (this.lowerBound < bin.lowerBound) { + return -1; + } + if (this.lowerBound > bin.lowerBound) { + return 1; + } + // lower bounds are the same + if (this.upperBound < bin.upperBound) { + return -1; + } + if (this.upperBound > bin.upperBound) { + return 1; + } + return 0; + } + + /** + * Tests this bin for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (!(obj instanceof SimpleHistogramBin)) { + return false; + } + SimpleHistogramBin that = (SimpleHistogramBin) obj; + if (this.lowerBound != that.lowerBound) { + return false; + } + if (this.upperBound != that.upperBound) { + return false; + } + if (this.includeLowerBound != that.includeLowerBound) { + return false; + } + if (this.includeUpperBound != that.includeUpperBound) { + return false; + } + if (this.itemCount != that.itemCount) { + return false; + } + return true; + } + + /** + * Returns a clone of the bin. + * + * @return A clone. + * + * @throws CloneNotSupportedException not thrown by this class. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/SimpleHistogramDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/SimpleHistogramDataset.java new file mode 100755 index 0000000..d66fffa --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/SimpleHistogramDataset.java @@ -0,0 +1,491 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * SimpleHistogramDataset.java + * --------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Sergei Ivanov; + * + * Changes + * ------- + * 10-Jan-2005 : Version 1 (DG); + * 21-May-2007 : Added clearObservations() and removeAllBins() (SI); + * 10-Jul-2007 : Added null argument check to constructor (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.statistics; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.DomainOrder; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.xy.AbstractIntervalXYDataset; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A dataset used for creating simple histograms with custom defined bins. + * + * @see HistogramDataset + */ +public class SimpleHistogramDataset extends AbstractIntervalXYDataset + implements IntervalXYDataset, Cloneable, PublicCloneable, + Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7997996479768018443L; + + /** The series key. */ + private Comparable key; + + /** The bins. */ + private List bins; + + /** + * A flag that controls whether or not the bin count is divided by the + * bin size. + */ + private boolean adjustForBinSize; + + /** + * Creates a new histogram dataset. Note that the + * adjustForBinSize flag defaults to true. + * + * @param key the series key (null not permitted). + */ + public SimpleHistogramDataset(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + this.key = key; + this.bins = new ArrayList(); + this.adjustForBinSize = true; + } + + /** + * Returns a flag that controls whether or not the bin count is divided by + * the bin size in the {@link #getXValue(int, int)} method. + * + * @return A boolean. + * + * @see #setAdjustForBinSize(boolean) + */ + public boolean getAdjustForBinSize() { + return this.adjustForBinSize; + } + + /** + * Sets the flag that controls whether or not the bin count is divided by + * the bin size in the {@link #getYValue(int, int)} method, and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param adjust the flag. + * + * @see #getAdjustForBinSize() + */ + public void setAdjustForBinSize(boolean adjust) { + this.adjustForBinSize = adjust; + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Returns the number of series in the dataset (always 1 for this dataset). + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return 1; + } + + /** + * Returns the key for a series. Since this dataset only stores a single + * series, the series argument is ignored. + * + * @param series the series (zero-based index, ignored in this dataset). + * + * @return The key for the series. + */ + @Override + public Comparable getSeriesKey(int series) { + return this.key; + } + + /** + * Returns the order of the domain (or X) values returned by the dataset. + * + * @return The order (never null). + */ + @Override + public DomainOrder getDomainOrder() { + return DomainOrder.ASCENDING; + } + + /** + * Returns the number of items in a series. Since this dataset only stores + * a single series, the series argument is ignored. + * + * @param series the series index (zero-based, ignored in this dataset). + * + * @return The item count. + */ + @Override + public int getItemCount(int series) { + return this.bins.size(); + } + + /** + * Adds a bin to the dataset. An exception is thrown if the bin overlaps + * with any existing bin in the dataset. + * + * @param bin the bin (null not permitted). + * + * @see #removeAllBins() + */ + public void addBin(SimpleHistogramBin bin) { + // check that the new bin doesn't overlap with any existing bin + Iterator iterator = this.bins.iterator(); + while (iterator.hasNext()) { + SimpleHistogramBin existingBin + = (SimpleHistogramBin) iterator.next(); + if (bin.overlapsWith(existingBin)) { + throw new RuntimeException("Overlapping bin"); + } + } + this.bins.add(bin); + Collections.sort(this.bins); + } + + /** + * Adds an observation to the dataset (by incrementing the item count for + * the appropriate bin). A runtime exception is thrown if the value does + * not fit into any bin. + * + * @param value the value. + */ + public void addObservation(double value) { + addObservation(value, true); + } + + /** + * Adds an observation to the dataset (by incrementing the item count for + * the appropriate bin). A runtime exception is thrown if the value does + * not fit into any bin. + * + * @param value the value. + * @param notify send {@link DatasetChangeEvent} to listeners? + */ + public void addObservation(double value, boolean notify) { + boolean placed = false; + Iterator iterator = this.bins.iterator(); + while (iterator.hasNext() && !placed) { + SimpleHistogramBin bin = (SimpleHistogramBin) iterator.next(); + if (bin.accepts(value)) { + bin.setItemCount(bin.getItemCount() + 1); + placed = true; + } + } + if (!placed) { + throw new RuntimeException("No bin."); + } + if (notify) { + notifyListeners(new DatasetChangeEvent(this, this)); + } + } + + /** + * Adds a set of values to the dataset and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param values the values (null not permitted). + * + * @see #clearObservations() + */ + public void addObservations(double[] values) { + for (int i = 0; i < values.length; i++) { + addObservation(values[i], false); + } + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Removes all current observation data and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @since 1.0.6 + * + * @see #addObservations(double[]) + * @see #removeAllBins() + */ + public void clearObservations() { + Iterator iterator = this.bins.iterator(); + while (iterator.hasNext()) { + SimpleHistogramBin bin = (SimpleHistogramBin) iterator.next(); + bin.setItemCount(0); + } + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Removes all bins and sends a {@link DatasetChangeEvent} to all + * registered listeners. + * + * @since 1.0.6 + * + * @see #addBin(SimpleHistogramBin) + */ + public void removeAllBins() { + this.bins = new ArrayList(); + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Returns the x-value for an item within a series. The x-values may or + * may not be returned in ascending order, that is up to the class + * implementing the interface. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The x-value (never null). + */ + @Override + public Number getX(int series, int item) { + return new Double(getXValue(series, item)); + } + + /** + * Returns the x-value (as a double primitive) for an item within a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The x-value. + */ + @Override + public double getXValue(int series, int item) { + SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); + return (bin.getLowerBound() + bin.getUpperBound()) / 2.0; + } + + /** + * Returns the y-value for an item within a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The y-value (possibly null). + */ + @Override + public Number getY(int series, int item) { + return new Double(getYValue(series, item)); + } + + /** + * Returns the y-value (as a double primitive) for an item within a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The y-value. + * + * @see #getAdjustForBinSize() + */ + @Override + public double getYValue(int series, int item) { + SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); + if (this.adjustForBinSize) { + return bin.getItemCount() + / (bin.getUpperBound() - bin.getLowerBound()); + } + else { + return bin.getItemCount(); + } + } + + /** + * Returns the starting X value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public Number getStartX(int series, int item) { + return new Double(getStartXValue(series, item)); + } + + /** + * Returns the start x-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The start x-value. + */ + @Override + public double getStartXValue(int series, int item) { + SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); + return bin.getLowerBound(); + } + + /** + * Returns the ending X value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public Number getEndX(int series, int item) { + return new Double(getEndXValue(series, item)); + } + + /** + * Returns the end x-value (as a double primitive) for an item within a + * series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The end x-value. + */ + @Override + public double getEndXValue(int series, int item) { + SimpleHistogramBin bin = (SimpleHistogramBin) this.bins.get(item); + return bin.getUpperBound(); + } + + /** + * Returns the starting Y value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public Number getStartY(int series, int item) { + return getY(series, item); + } + + /** + * Returns the start y-value (as a double primitive) for an item within a + * series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The start y-value. + */ + @Override + public double getStartYValue(int series, int item) { + return getYValue(series, item); + } + + /** + * Returns the ending Y value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public Number getEndY(int series, int item) { + return getY(series, item); + } + + /** + * Returns the end y-value (as a double primitive) for an item within a + * series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The end y-value. + */ + @Override + public double getEndYValue(int series, int item) { + return getYValue(series, item); + } + + /** + * Compares the dataset for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof SimpleHistogramDataset)) { + return false; + } + SimpleHistogramDataset that = (SimpleHistogramDataset) obj; + if (!this.key.equals(that.key)) { + return false; + } + if (this.adjustForBinSize != that.adjustForBinSize) { + return false; + } + if (!this.bins.equals(that.bins)) { + return false; + } + return true; + } + + /** + * Returns a clone of the dataset. + * + * @return A clone. + * + * @throws CloneNotSupportedException not thrown by this class, but maybe + * by subclasses (if any). + */ + @Override + public Object clone() throws CloneNotSupportedException { + SimpleHistogramDataset clone = (SimpleHistogramDataset) super.clone(); + clone.bins = (List) ObjectUtilities.deepClone(this.bins); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/StatisticalCategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/StatisticalCategoryDataset.java new file mode 100755 index 0000000..6d09b22 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/StatisticalCategoryDataset.java @@ -0,0 +1,97 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * StatisticalCategoryDataset.java + * ------------------------------- + * (C) Copyright 2002-2009, by Pascal Collet and Contributors. + * + * Original Author: Pascal Collet; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 21-Aug-2002 : Version 1, contributed by Pascal Collet (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 24-Oct-2002 : Amendments in line with changes to the CategoryDataset + * interface (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 02-Feb-2007 : Removed author tags from all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.statistics; + +import org.jfree.data.category.CategoryDataset; + +/** + * A category dataset that defines a mean and standard deviation value for + * each item. + */ +public interface StatisticalCategoryDataset extends CategoryDataset { + + /** + * Returns the mean value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The mean value (possibly null). + */ + public Number getMeanValue(int row, int column); + + /** + * Returns the mean value for an item. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The mean value (possibly null). + */ + public Number getMeanValue(Comparable rowKey, Comparable columnKey); + + /** + * Returns the standard deviation value for an item. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The standard deviation (possibly null). + */ + public Number getStdDevValue(int row, int column); + + /** + * Returns the standard deviation value for an item. + * + * @param rowKey the row key. + * @param columnKey the columnKey. + * + * @return The standard deviation (possibly null). + */ + public Number getStdDevValue(Comparable rowKey, Comparable columnKey); + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/Statistics.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/Statistics.java new file mode 100755 index 0000000..f0e8a05 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/Statistics.java @@ -0,0 +1,471 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * Statistics.java + * --------------- + * (C) Copyright 2000-2013, by Matthew Wright and Contributors. + * + * Original Author: Matthew Wright; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes (from 08-Nov-2001) + * -------------------------- + * 08-Nov-2001 : Added standard header and tidied Javadoc comments (DG); + * Moved from JFreeChart to package com.jrefinery.data.* in + * JCommon class library (DG); + * 24-Jun-2002 : Removed unnecessary local variable (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 26-May-2004 : Moved calculateMean() method from BoxAndWhiskerCalculator (DG); + * 02-Jun-2004 : Fixed bug in calculateMedian() method (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.statistics; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +/** + * A utility class that provides some common statistical functions. + */ +public abstract class Statistics { + + /** + * Returns the mean of an array of numbers. This is equivalent to calling + * calculateMean(values, true). + * + * @param values the values (null not permitted). + * + * @return The mean. + */ + public static double calculateMean(Number[] values) { + return calculateMean(values, true); + } + + /** + * Returns the mean of an array of numbers. + * + * @param values the values (null not permitted). + * @param includeNullAndNaN a flag that controls whether or not + * null and Double.NaN values are included + * in the calculation (if either is present in the array, the result is + * {@link Double#NaN}). + * + * @return The mean. + * + * @since 1.0.3 + */ + public static double calculateMean(Number[] values, + boolean includeNullAndNaN) { + + ParamChecks.nullNotPermitted(values, "values"); + double sum = 0.0; + double current; + int counter = 0; + for (int i = 0; i < values.length; i++) { + // treat nulls the same as NaNs + if (values[i] != null) { + current = values[i].doubleValue(); + } + else { + current = Double.NaN; + } + // calculate the sum and count + if (includeNullAndNaN || !Double.isNaN(current)) { + sum = sum + current; + counter++; + } + } + double result = (sum / counter); + return result; + } + + /** + * Returns the mean of a collection of Number objects. + * + * @param values the values (null not permitted). + * + * @return The mean. + */ + public static double calculateMean(Collection values) { + return calculateMean(values, true); + } + + /** + * Returns the mean of a collection of Number objects. + * + * @param values the values (null not permitted). + * @param includeNullAndNaN a flag that controls whether or not + * null and Double.NaN values are included + * in the calculation (if either is present in the array, the result is + * {@link Double#NaN}). + * + * @return The mean. + * + * @since 1.0.3 + */ + public static double calculateMean(Collection values, + boolean includeNullAndNaN) { + + ParamChecks.nullNotPermitted(values, "values"); + int count = 0; + double total = 0.0; + Iterator iterator = values.iterator(); + while (iterator.hasNext()) { + Object object = iterator.next(); + if (object == null) { + if (includeNullAndNaN) { + return Double.NaN; + } + } + else { + if (object instanceof Number) { + Number number = (Number) object; + double value = number.doubleValue(); + if (Double.isNaN(value)) { + if (includeNullAndNaN) { + return Double.NaN; + } + } + else { + total = total + number.doubleValue(); + count = count + 1; + } + } + } + } + return total / count; + } + + /** + * Calculates the median for a list of values (Number objects). + * The list of values will be copied, and the copy sorted, before + * calculating the median. To avoid this step (if your list of values + * is already sorted), use the {@link #calculateMedian(List, boolean)} + * method. + * + * @param values the values (null permitted). + * + * @return The median. + */ + public static double calculateMedian(List values) { + return calculateMedian(values, true); + } + + /** + * Calculates the median for a list of values (Number objects). + * If copyAndSort is false, the list is assumed + * to be presorted in ascending order by value. + * + * @param values the values (null permitted). + * @param copyAndSort a flag that controls whether the list of values is + * copied and sorted. + * + * @return The median. + */ + public static double calculateMedian(List values, boolean copyAndSort) { + + double result = Double.NaN; + if (values != null) { + if (copyAndSort) { + int itemCount = values.size(); + List copy = new ArrayList(itemCount); + for (int i = 0; i < itemCount; i++) { + copy.add(i, values.get(i)); + } + Collections.sort(copy); + values = copy; + } + int count = values.size(); + if (count > 0) { + if (count % 2 == 1) { + if (count > 1) { + Number value = (Number) values.get((count - 1) / 2); + result = value.doubleValue(); + } + else { + Number value = (Number) values.get(0); + result = value.doubleValue(); + } + } + else { + Number value1 = (Number) values.get(count / 2 - 1); + Number value2 = (Number) values.get(count / 2); + result = (value1.doubleValue() + value2.doubleValue()) + / 2.0; + } + } + } + return result; + } + + /** + * Calculates the median for a sublist within a list of values + * (Number objects). + * + * @param values the values, in any order (null not + * permitted). + * @param start the start index. + * @param end the end index. + * + * @return The median. + */ + public static double calculateMedian(List values, int start, int end) { + return calculateMedian(values, start, end, true); + } + + /** + * Calculates the median for a sublist within a list of values + * (Number objects). The entire list will be sorted if the + * ascendingfalse. + * + * @param values the values (null not permitted). + * @param start the start index. + * @param end the end index. + * @param copyAndSort a flag that that controls whether the list of values + * is copied and sorted. + * + * @return The median. + */ + public static double calculateMedian(List values, int start, int end, + boolean copyAndSort) { + + double result = Double.NaN; + if (copyAndSort) { + List working = new ArrayList(end - start + 1); + for (int i = start; i <= end; i++) { + working.add(values.get(i)); + } + Collections.sort(working); + result = calculateMedian(working, false); + } + else { + int count = end - start + 1; + if (count > 0) { + if (count % 2 == 1) { + if (count > 1) { + Number value + = (Number) values.get(start + (count - 1) / 2); + result = value.doubleValue(); + } + else { + Number value = (Number) values.get(start); + result = value.doubleValue(); + } + } + else { + Number value1 = (Number) values.get(start + count / 2 - 1); + Number value2 = (Number) values.get(start + count / 2); + result + = (value1.doubleValue() + value2.doubleValue()) / 2.0; + } + } + } + return result; + + } + + /** + * Returns the standard deviation of a set of numbers. + * + * @param data the data (null or zero length array not + * permitted). + * + * @return The standard deviation of a set of numbers. + */ + public static double getStdDev(Number[] data) { + ParamChecks.nullNotPermitted(data, "data"); + if (data.length == 0) { + throw new IllegalArgumentException("Zero length 'data' array."); + } + double avg = calculateMean(data); + double sum = 0.0; + + for (int counter = 0; counter < data.length; counter++) { + double diff = data[counter].doubleValue() - avg; + sum = sum + diff * diff; + } + return Math.sqrt(sum / (data.length - 1)); + } + + /** + * Fits a straight line to a set of (x, y) data, returning the slope and + * intercept. + * + * @param xData the x-data (null not permitted). + * @param yData the y-data (null not permitted). + * + * @return A double array with the intercept in [0] and the slope in [1]. + */ + public static double[] getLinearFit(Number[] xData, Number[] yData) { + + ParamChecks.nullNotPermitted(xData, "xData"); + ParamChecks.nullNotPermitted(yData, "yData"); + if (xData.length != yData.length) { + throw new IllegalArgumentException( + "Statistics.getLinearFit(): array lengths must be equal."); + } + + double[] result = new double[2]; + // slope + result[1] = getSlope(xData, yData); + // intercept + result[0] = calculateMean(yData) - result[1] * calculateMean(xData); + + return result; + + } + + /** + * Finds the slope of a regression line using least squares. + * + * @param xData the x-values (null not permitted). + * @param yData the y-values (null not permitted). + * + * @return The slope. + */ + public static double getSlope(Number[] xData, Number[] yData) { + ParamChecks.nullNotPermitted(xData, "xData"); + ParamChecks.nullNotPermitted(yData, "yData"); + if (xData.length != yData.length) { + throw new IllegalArgumentException("Array lengths must be equal."); + } + + // ********* stat function for linear slope ******** + // y = a + bx + // a = ybar - b * xbar + // sum(x * y) - (sum (x) * sum(y)) / n + // b = ------------------------------------ + // sum (x^2) - (sum(x)^2 / n + // ************************************************* + + // sum of x, x^2, x * y, y + double sx = 0.0, sxx = 0.0, sxy = 0.0, sy = 0.0; + int counter; + for (counter = 0; counter < xData.length; counter++) { + sx = sx + xData[counter].doubleValue(); + sxx = sxx + Math.pow(xData[counter].doubleValue(), 2); + sxy = sxy + yData[counter].doubleValue() + * xData[counter].doubleValue(); + sy = sy + yData[counter].doubleValue(); + } + return (sxy - (sx * sy) / counter) / (sxx - (sx * sx) / counter); + + } + + /** + * Calculates the correlation between two datasets. Both arrays should + * contain the same number of items. Null values are treated as zero. + *

+ * Information about the correlation calculation was obtained from: + * + * http://trochim.human.cornell.edu/kb/statcorr.htm + * + * @param data1 the first dataset. + * @param data2 the second dataset. + * + * @return The correlation. + */ + public static double getCorrelation(Number[] data1, Number[] data2) { + ParamChecks.nullNotPermitted(data1, "data1"); + ParamChecks.nullNotPermitted(data2, "data2"); + if (data1.length != data2.length) { + throw new IllegalArgumentException( + "'data1' and 'data2' arrays must have same length." + ); + } + int n = data1.length; + double sumX = 0.0; + double sumY = 0.0; + double sumX2 = 0.0; + double sumY2 = 0.0; + double sumXY = 0.0; + for (int i = 0; i < n; i++) { + double x = 0.0; + if (data1[i] != null) { + x = data1[i].doubleValue(); + } + double y = 0.0; + if (data2[i] != null) { + y = data2[i].doubleValue(); + } + sumX = sumX + x; + sumY = sumY + y; + sumXY = sumXY + (x * y); + sumX2 = sumX2 + (x * x); + sumY2 = sumY2 + (y * y); + } + return (n * sumXY - sumX * sumY) / Math.pow((n * sumX2 - sumX * sumX) + * (n * sumY2 - sumY * sumY), 0.5); + } + + /** + * Returns a data set for a moving average on the data set passed in. + * + * @param xData an array of the x data. + * @param yData an array of the y data. + * @param period the number of data points to average + * + * @return A double[][] the length of the data set in the first dimension, + * with two doubles for x and y in the second dimension + */ + public static double[][] getMovingAverage(Number[] xData, Number[] yData, + int period) { + + // check arguments... + if (xData.length != yData.length) { + throw new IllegalArgumentException("Array lengths must be equal."); + } + + if (period > xData.length) { + throw new IllegalArgumentException( + "Period can't be longer than dataset."); + } + + double[][] result = new double[xData.length - period][2]; + for (int i = 0; i < result.length; i++) { + result[i][0] = xData[i + period].doubleValue(); + // holds the moving average sum + double sum = 0.0; + for (int j = 0; j < period; j++) { + sum += yData[i + j].doubleValue(); + } + sum = sum / period; + result[i][1] = sum; + } + return result; + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/package.html new file mode 100755 index 0000000..0141fcf --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/statistics/package.html @@ -0,0 +1,6 @@ + + + +Classes for representing statistical data. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/DateRange.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/DateRange.java new file mode 100755 index 0000000..069ba5f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/DateRange.java @@ -0,0 +1,172 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * DateRange.java + * -------------- + * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Bill Kelemen; + * + * Changes + * ------- + * 22-Apr-2002 : Version 1 based on code by Bill Kelemen (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 23-Sep-2003 : Minor Javadoc update (DG); + * 28-May-2008 : Fixed problem with immutability (DG); + * 01-Sep-2008 : Added getLowerMillis() and getUpperMillis() (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.text.DateFormat; +import java.util.Date; + +import org.jfree.data.Range; + +/** + * A range specified in terms of two java.util.Date objects. + * Instances of this class are immutable. + */ +public class DateRange extends Range implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -4705682568375418157L; + + /** The lower bound for the range. */ + private long lowerDate; + + /** The upper bound for the range. */ + private long upperDate; + + /** + * Default constructor. + */ + public DateRange() { + this(new Date(0), new Date(1)); + } + + /** + * Constructs a new range. + * + * @param lower the lower bound (null not permitted). + * @param upper the upper bound (null not permitted). + */ + public DateRange(Date lower, Date upper) { + super(lower.getTime(), upper.getTime()); + this.lowerDate = lower.getTime(); + this.upperDate = upper.getTime(); + } + + /** + * Constructs a new range using two values that will be interpreted as + * "milliseconds since midnight GMT, 1-Jan-1970". + * + * @param lower the lower (oldest) date. + * @param upper the upper (most recent) date. + */ + public DateRange(double lower, double upper) { + super(lower, upper); + this.lowerDate = (long) lower; + this.upperDate = (long) upper; + } + + /** + * Constructs a new range that is based on another {@link Range}. The + * other range does not have to be a {@link DateRange}. If it is not, the + * upper and lower bounds are evaluated as milliseconds since midnight + * GMT, 1-Jan-1970. + * + * @param other the other range (null not permitted). + */ + public DateRange(Range other) { + this(other.getLowerBound(), other.getUpperBound()); + } + + /** + * Returns the lower (earlier) date for the range. + * + * @return The lower date for the range. + * + * @see #getLowerMillis() + */ + public Date getLowerDate() { + return new Date(this.lowerDate); + } + + /** + * Returns the lower bound of the range in milliseconds. + * + * @return The lower bound. + * + * @see #getLowerDate() + * + * @since 1.0.11 + */ + public long getLowerMillis() { + return this.lowerDate; + } + + /** + * Returns the upper (later) date for the range. + * + * @return The upper date for the range. + * + * @see #getUpperMillis() + */ + public Date getUpperDate() { + return new Date(this.upperDate); + } + + /** + * Returns the upper bound of the range in milliseconds. + * + * @return The upper bound. + * + * @see #getUpperDate() + * + * @since 1.0.11 + */ + public long getUpperMillis() { + return this.upperDate; + } + + /** + * Returns a string representing the date range (useful for debugging). + * + * @return A string representing the date range. + */ + @Override + public String toString() { + DateFormat df = DateFormat.getDateTimeInstance(); + return "[" + df.format(getLowerDate()) + " --> " + + df.format(getUpperDate()) + "]"; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Day.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Day.java new file mode 100755 index 0000000..1a55692 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Day.java @@ -0,0 +1,483 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------- + * Day.java + * -------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-Oct-2001 : Version 1 (DG); + * 15-Nov-2001 : Updated Javadoc comments (DG); + * 04-Dec-2001 : Added static method to parse a string into a Day object (DG); + * 19-Dec-2001 : Added new constructor as suggested by Paul English (DG); + * 29-Jan-2002 : Changed getDay() method to getSerialDate() (DG); + * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to + * evaluate with reference to a particular time zone (DG); + * 19-Mar-2002 : Changed the API for the TimePeriod classes (DG); + * 29-May-2002 : Fixed bug in equals method (DG); + * 24-Jun-2002 : Removed unnecessary imports (DG); + * 10-Sep-2002 : Added getSerialIndex() method (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 10-Jan-2003 : Changed base class and method names (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package, and implemented + * Serializable (DG); + * 21-Oct-2003 : Added hashCode() method (DG); + * 30-Sep-2004 : Replaced getTime().getTime() with getTimeInMillis() (DG); + * 04-Nov-2004 : Reverted change of 30-Sep-2004, because it won't work for + * JDK 1.3 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 05-Oct-2006 : Updated API docs (DG); + * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); + * 02-Mar-2009 : Added new constructor with Locale (DG); + * 05-Jul-2012 : Replaced getTime().getTime() with getTimeInMillis() (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.date.SerialDate; + +/** + * Represents a single day in the range 1-Jan-1900 to 31-Dec-9999. This class + * is immutable, which is a requirement for all {@link RegularTimePeriod} + * subclasses. + */ +public class Day extends RegularTimePeriod implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -7082667380758962755L; + + /** A standard date formatter. */ + protected static final DateFormat DATE_FORMAT + = new SimpleDateFormat("yyyy-MM-dd"); + + /** A date formatter for the default locale. */ + protected static final DateFormat + DATE_FORMAT_SHORT = DateFormat.getDateInstance(DateFormat.SHORT); + + /** A date formatter for the default locale. */ + protected static final DateFormat + DATE_FORMAT_MEDIUM = DateFormat.getDateInstance(DateFormat.MEDIUM); + + /** A date formatter for the default locale. */ + protected static final DateFormat + DATE_FORMAT_LONG = DateFormat.getDateInstance(DateFormat.LONG); + + /** The day (uses SerialDate for convenience). */ + private SerialDate serialDate; + + /** The first millisecond. */ + private long firstMillisecond; + + /** The last millisecond. */ + private long lastMillisecond; + + /** + * Creates a new instance, derived from the system date/time (and assuming + * the default timezone). + */ + public Day() { + this(new Date()); + } + + /** + * Constructs a new one day time period. + * + * @param day the day-of-the-month. + * @param month the month (1 to 12). + * @param year the year (1900 <= year <= 9999). + */ + public Day(int day, int month, int year) { + this.serialDate = SerialDate.createInstance(day, month, year); + peg(Calendar.getInstance()); + } + + /** + * Constructs a new one day time period. + * + * @param serialDate the day (null not permitted). + */ + public Day(SerialDate serialDate) { + ParamChecks.nullNotPermitted(serialDate, "serialDate"); + this.serialDate = serialDate; + peg(Calendar.getInstance()); + } + + /** + * Constructs a new instance, based on a particular date/time and the + * default time zone. + * + * @param time the time (null not permitted). + * + * @see #Day(Date, TimeZone) + */ + public Day(Date time) { + // defer argument checking... + this(time, TimeZone.getDefault(), Locale.getDefault()); + } + + /** + * Constructs a new instance, based on a particular date/time and time zone. + * + * @param time the date/time. + * @param zone the time zone. + * + * @deprecated As of 1.0.13, use the constructor that specifies the locale + * also. + */ + public Day(Date time, TimeZone zone) { + this(time, zone, Locale.getDefault()); + } + + /** + * Constructs a new instance, based on a particular date/time and time zone. + * + * @param time the date/time (null not permitted). + * @param zone the time zone (null not permitted). + * @param locale the locale (null not permitted). + */ + public Day(Date time, TimeZone zone, Locale locale) { + ParamChecks.nullNotPermitted(time, "time"); + ParamChecks.nullNotPermitted(zone, "zone"); + ParamChecks.nullNotPermitted(locale, "locale"); + Calendar calendar = Calendar.getInstance(zone, locale); + calendar.setTime(time); + int d = calendar.get(Calendar.DAY_OF_MONTH); + int m = calendar.get(Calendar.MONTH) + 1; + int y = calendar.get(Calendar.YEAR); + this.serialDate = SerialDate.createInstance(d, m, y); + peg(calendar); + } + + /** + * Returns the day as a {@link SerialDate}. Note: the reference that is + * returned should be an instance of an immutable {@link SerialDate} + * (otherwise the caller could use the reference to alter the state of + * this Day instance, and Day is supposed + * to be immutable). + * + * @return The day as a {@link SerialDate}. + */ + public SerialDate getSerialDate() { + return this.serialDate; + } + + /** + * Returns the year. + * + * @return The year. + */ + public int getYear() { + return this.serialDate.getYYYY(); + } + + /** + * Returns the month. + * + * @return The month. + */ + public int getMonth() { + return this.serialDate.getMonth(); + } + + /** + * Returns the day of the month. + * + * @return The day of the month. + */ + public int getDayOfMonth() { + return this.serialDate.getDayOfMonth(); + } + + /** + * Returns the first millisecond of the day. This will be determined + * relative to the time zone specified in the constructor, or in the + * calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The first millisecond of the day. + * + * @see #getLastMillisecond() + */ + @Override + public long getFirstMillisecond() { + return this.firstMillisecond; + } + + /** + * Returns the last millisecond of the day. This will be + * determined relative to the time zone specified in the constructor, or + * in the calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The last millisecond of the day. + * + * @see #getFirstMillisecond() + */ + @Override + public long getLastMillisecond() { + return this.lastMillisecond; + } + + /** + * Recalculates the start date/time and end date/time for this time period + * relative to the supplied calendar (which incorporates a time zone). + * + * @param calendar the calendar (null not permitted). + * + * @since 1.0.3 + */ + @Override + public void peg(Calendar calendar) { + this.firstMillisecond = getFirstMillisecond(calendar); + this.lastMillisecond = getLastMillisecond(calendar); + } + + /** + * Returns the day preceding this one. + * + * @return The day preceding this one. + */ + @Override + public RegularTimePeriod previous() { + Day result; + int serial = this.serialDate.toSerial(); + if (serial > SerialDate.SERIAL_LOWER_BOUND) { + SerialDate yesterday = SerialDate.createInstance(serial - 1); + return new Day(yesterday); + } + else { + result = null; + } + return result; + } + + /** + * Returns the day following this one, or null if some limit + * has been reached. + * + * @return The day following this one, or null if some limit + * has been reached. + */ + @Override + public RegularTimePeriod next() { + Day result; + int serial = this.serialDate.toSerial(); + if (serial < SerialDate.SERIAL_UPPER_BOUND) { + SerialDate tomorrow = SerialDate.createInstance(serial + 1); + return new Day(tomorrow); + } + else { + result = null; + } + return result; + } + + /** + * Returns a serial index number for the day. + * + * @return The serial index number. + */ + @Override + public long getSerialIndex() { + return this.serialDate.toSerial(); + } + + /** + * Returns the first millisecond of the day, evaluated using the supplied + * calendar (which determines the time zone). + * + * @param calendar calendar to use (null not permitted). + * + * @return The start of the day as milliseconds since 01-01-1970. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getFirstMillisecond(Calendar calendar) { + int year = this.serialDate.getYYYY(); + int month = this.serialDate.getMonth(); + int day = this.serialDate.getDayOfMonth(); + calendar.clear(); + calendar.set(year, month - 1, day, 0, 0, 0); + calendar.set(Calendar.MILLISECOND, 0); + return calendar.getTimeInMillis(); + } + + /** + * Returns the last millisecond of the day, evaluated using the supplied + * calendar (which determines the time zone). + * + * @param calendar calendar to use (null not permitted). + * + * @return The end of the day as milliseconds since 01-01-1970. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getLastMillisecond(Calendar calendar) { + int year = this.serialDate.getYYYY(); + int month = this.serialDate.getMonth(); + int day = this.serialDate.getDayOfMonth(); + calendar.clear(); + calendar.set(year, month - 1, day, 23, 59, 59); + calendar.set(Calendar.MILLISECOND, 999); + return calendar.getTimeInMillis(); + } + + /** + * Tests the equality of this Day object to an arbitrary object. Returns + * true if the target is a Day instance or a SerialDate instance + * representing the same day as this object. In all other cases, + * returns false. + * + * @param obj the object (null permitted). + * + * @return A flag indicating whether or not an object is equal to this day. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Day)) { + return false; + } + Day that = (Day) obj; + if (!this.serialDate.equals(that.getSerialDate())) { + return false; + } + return true; + } + + /** + * Returns a hash code for this object instance. The approach described by + * Joshua Bloch in "Effective Java" has been used here: + *

+ * http://developer.java.sun.com/developer/Books/effectivejava + * /Chapter3.pdf + * + * @return A hash code. + */ + @Override + public int hashCode() { + return this.serialDate.hashCode(); + } + + /** + * Returns an integer indicating the order of this Day object relative to + * the specified object: + * + * negative == before, zero == same, positive == after. + * + * @param o1 the object to compare. + * + * @return negative == before, zero == same, positive == after. + */ + @Override + public int compareTo(Object o1) { + int result; + + // CASE 1 : Comparing to another Day object + // ---------------------------------------- + if (o1 instanceof Day) { + Day d = (Day) o1; + result = -d.getSerialDate().compare(this.serialDate); + } + + // CASE 2 : Comparing to another TimePeriod object + // ----------------------------------------------- + else if (o1 instanceof RegularTimePeriod) { + // more difficult case - evaluate later... + result = 0; + } + + // CASE 3 : Comparing to a non-TimePeriod object + // --------------------------------------------- + else { + // consider time periods to be ordered after general objects + result = 1; + } + + return result; + } + + /** + * Returns a string representing the day. + * + * @return A string representing the day. + */ + @Override + public String toString() { + return this.serialDate.toString(); + } + + /** + * Parses the string argument as a day. + *

+ * This method is required to recognise YYYY-MM-DD as a valid format. + * Anything else, for now, is a bonus. + * + * @param s the date string to parse. + * + * @return null if the string does not contain any parseable + * string, the day otherwise. + */ + public static Day parseDay(String s) { + try { + return new Day (Day.DATE_FORMAT.parse(s)); + } + catch (ParseException e1) { + try { + return new Day (Day.DATE_FORMAT_SHORT.parse(s)); + } + catch (ParseException e2) { + // ignore + } + } + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/DynamicTimeSeriesCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/DynamicTimeSeriesCollection.java new file mode 100755 index 0000000..164f78c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/DynamicTimeSeriesCollection.java @@ -0,0 +1,987 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------- + * DynamicTimeSeriesCollection.java + * -------------------------------- + * (C) Copyright 2002-2008, by I. H. Thomae and Contributors. + * + * Original Author: I. H. Thomae (ithomae@ists.dartmouth.edu); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 22-Nov-2002 : Initial version completed + * Jan 2003 : Optimized advanceTime(), added implemnt'n of RangeInfo intfc + * (using cached values for min, max, and range); also added + * getOldestIndex() and getNewestIndex() ftns so client classes + * can use this class as the master "index authority". + * 22-Jan-2003 : Made this class stand on its own, rather than extending + * class FastTimeSeriesCollection + * 31-Jan-2003 : Changed TimePeriod --> RegularTimePeriod (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package (DG); + * 29-Apr-2003 : Added small change to appendData method, from Irv Thomae (DG); + * 19-Sep-2003 : Added new appendData method, from Irv Thomae (DG); + * 05-May-2004 : Now extends AbstractIntervalXYDataset. This also required a + * change to the return type of the getY() method - I'm slightly + * unsure of the implications of this, so it might require some + * further amendment (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 11-Jan-2004 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.time; + +import java.util.Calendar; +import java.util.TimeZone; + +import org.jfree.data.DomainInfo; +import org.jfree.data.Range; +import org.jfree.data.RangeInfo; +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.data.xy.AbstractIntervalXYDataset; +import org.jfree.data.xy.IntervalXYDataset; + +/** + * A dynamic dataset. + *

+ * Like FastTimeSeriesCollection, this class is a functional replacement + * for JFreeChart's TimeSeriesCollection _and_ TimeSeries classes. + * FastTimeSeriesCollection is appropriate for a fixed time range; for + * real-time applications this subclass adds the ability to append new + * data and discard the oldest. + * In this class, the arrays used in FastTimeSeriesCollection become FIFO's. + * NOTE:As presented here, all data is assumed >= 0, an assumption which is + * embodied only in methods associated with interface RangeInfo. + */ +public class DynamicTimeSeriesCollection extends AbstractIntervalXYDataset + implements IntervalXYDataset, + DomainInfo, + RangeInfo { + + /** + * Useful constant for controlling the x-value returned for a time + * period. + */ + public static final int START = 0; + + /** + * Useful constant for controlling the x-value returned for a time period. + */ + public static final int MIDDLE = 1; + + /** + * Useful constant for controlling the x-value returned for a time period. + */ + public static final int END = 2; + + /** The maximum number of items for each series (can be overridden). */ + private int maximumItemCount = 2000; // an arbitrary safe default value + + /** The history count. */ + protected int historyCount; + + /** Storage for the series keys. */ + private Comparable[] seriesKeys; + + /** The time period class - barely used, and could be removed (DG). */ + private Class timePeriodClass = Minute.class; // default value; + + /** Storage for the x-values. */ + protected RegularTimePeriod[] pointsInTime; + + /** The number of series. */ + private int seriesCount; + + /** + * A wrapper for a fixed array of float values. + */ + protected class ValueSequence { + + /** Storage for the float values. */ + float[] dataPoints; + + /** + * Default constructor: + */ + public ValueSequence() { + this(DynamicTimeSeriesCollection.this.maximumItemCount); + } + + /** + * Creates a sequence with the specified length. + * + * @param length the length. + */ + public ValueSequence(int length) { + this.dataPoints = new float[length]; + for (int i = 0; i < length; i++) { + this.dataPoints[i] = 0.0f; + } + } + + /** + * Enters data into the storage array. + * + * @param index the index. + * @param value the value. + */ + public void enterData(int index, float value) { + this.dataPoints[index] = value; + } + + /** + * Returns a value from the storage array. + * + * @param index the index. + * + * @return The value. + */ + public float getData(int index) { + return this.dataPoints[index]; + } + } + + /** An array for storing the objects that represent each series. */ + protected ValueSequence[] valueHistory; + + /** A working calendar (to recycle) */ + protected Calendar workingCalendar; + + /** + * The position within a time period to return as the x-value (START, + * MIDDLE or END). + */ + private int position; + + /** + * A flag that indicates that the domain is 'points in time'. If this flag + * is true, only the x-value is used to determine the range of values in + * the domain, the start and end x-values are ignored. + */ + private boolean domainIsPointsInTime; + + /** index for mapping: points to the oldest valid time & data. */ + private int oldestAt; // as a class variable, initializes == 0 + + /** Index of the newest data item. */ + private int newestAt; + + // cached values used for interface DomainInfo: + + /** the # of msec by which time advances. */ + private long deltaTime; + + /** Cached domain start (for use by DomainInfo). */ + private Long domainStart; + + /** Cached domain end (for use by DomainInfo). */ + private Long domainEnd; + + /** Cached domain range (for use by DomainInfo). */ + private Range domainRange; + + // Cached values used for interface RangeInfo: (note minValue pinned at 0) + // A single set of extrema covers the entire SeriesCollection + + /** The minimum value. */ + private Float minValue = new Float(0.0f); + + /** The maximum value. */ + private Float maxValue = null; + + /** The value range. */ + private Range valueRange; // autoinit's to null. + + /** + * Constructs a dataset with capacity for N series, tied to default + * timezone. + * + * @param nSeries the number of series to be accommodated. + * @param nMoments the number of TimePeriods to be spanned. + */ + public DynamicTimeSeriesCollection(int nSeries, int nMoments) { + + this(nSeries, nMoments, new Millisecond(), TimeZone.getDefault()); + this.newestAt = nMoments - 1; + + } + + /** + * Constructs an empty dataset, tied to a specific timezone. + * + * @param nSeries the number of series to be accommodated + * @param nMoments the number of TimePeriods to be spanned + * @param zone the timezone. + */ + public DynamicTimeSeriesCollection(int nSeries, int nMoments, + TimeZone zone) { + this(nSeries, nMoments, new Millisecond(), zone); + this.newestAt = nMoments - 1; + } + + /** + * Creates a new dataset. + * + * @param nSeries the number of series. + * @param nMoments the number of items per series. + * @param timeSample a time period sample. + */ + public DynamicTimeSeriesCollection(int nSeries, + int nMoments, + RegularTimePeriod timeSample) { + this(nSeries, nMoments, timeSample, TimeZone.getDefault()); + } + + /** + * Creates a new dataset. + * + * @param nSeries the number of series. + * @param nMoments the number of items per series. + * @param timeSample a time period sample. + * @param zone the time zone. + */ + public DynamicTimeSeriesCollection(int nSeries, + int nMoments, + RegularTimePeriod timeSample, + TimeZone zone) { + + // the first initialization must precede creation of the ValueSet array: + this.maximumItemCount = nMoments; // establishes length of each array + this.historyCount = nMoments; + this.seriesKeys = new Comparable[nSeries]; + // initialize the members of "seriesNames" array so they won't be null: + for (int i = 0; i < nSeries; i++) { + this.seriesKeys[i] = ""; + } + this.newestAt = nMoments - 1; + this.valueHistory = new ValueSequence[nSeries]; + this.timePeriodClass = timeSample.getClass(); + + /// Expand the following for all defined TimePeriods: + if (this.timePeriodClass == Second.class) { + this.pointsInTime = new Second[nMoments]; + } + else if (this.timePeriodClass == Minute.class) { + this.pointsInTime = new Minute[nMoments]; + } + else if (this.timePeriodClass == Hour.class) { + this.pointsInTime = new Hour[nMoments]; + } + /// .. etc.... + this.workingCalendar = Calendar.getInstance(zone); + this.position = START; + this.domainIsPointsInTime = true; + } + + /** + * Fill the pointsInTime with times using TimePeriod.next(): + * Will silently return if the time array was already populated. + * + * Also computes the data cached for later use by + * methods implementing the DomainInfo interface: + * + * @param start the start. + * + * @return ??. + */ + public synchronized long setTimeBase(RegularTimePeriod start) { + + if (this.pointsInTime[0] == null) { + this.pointsInTime[0] = start; + for (int i = 1; i < this.historyCount; i++) { + this.pointsInTime[i] = this.pointsInTime[i - 1].next(); + } + } + long oldestL = this.pointsInTime[0].getFirstMillisecond( + this.workingCalendar + ); + long nextL = this.pointsInTime[1].getFirstMillisecond( + this.workingCalendar + ); + this.deltaTime = nextL - oldestL; + this.oldestAt = 0; + this.newestAt = this.historyCount - 1; + findDomainLimits(); + return this.deltaTime; + + } + + /** + * Finds the domain limits. Note: this doesn't need to be synchronized + * because it's called from within another method that already is. + */ + protected void findDomainLimits() { + + long startL = getOldestTime().getFirstMillisecond(this.workingCalendar); + long endL; + if (this.domainIsPointsInTime) { + endL = getNewestTime().getFirstMillisecond(this.workingCalendar); + } + else { + endL = getNewestTime().getLastMillisecond(this.workingCalendar); + } + this.domainStart = new Long(startL); + this.domainEnd = new Long(endL); + this.domainRange = new Range(startL, endL); + + } + + /** + * Returns the x position type (START, MIDDLE or END). + * + * @return The x position type. + */ + public int getPosition() { + return this.position; + } + + /** + * Sets the x position type (START, MIDDLE or END). + * + * @param position The x position type. + */ + public void setPosition(int position) { + this.position = position; + } + + /** + * Adds a series to the dataset. Only the y-values are supplied, the + * x-values are specified elsewhere. + * + * @param values the y-values. + * @param seriesNumber the series index (zero-based). + * @param seriesKey the series key. + * + * Use this as-is during setup only, or add the synchronized keyword around + * the copy loop. + */ + public void addSeries(float[] values, + int seriesNumber, Comparable seriesKey) { + + invalidateRangeInfo(); + int i; + if (values == null) { + throw new IllegalArgumentException("TimeSeriesDataset.addSeries(): " + + "cannot add null array of values."); + } + if (seriesNumber >= this.valueHistory.length) { + throw new IllegalArgumentException("TimeSeriesDataset.addSeries(): " + + "cannot add more series than specified in c'tor"); + } + if (this.valueHistory[seriesNumber] == null) { + this.valueHistory[seriesNumber] + = new ValueSequence(this.historyCount); + this.seriesCount++; + } + // But if that series array already exists, just overwrite its contents + + // Avoid IndexOutOfBoundsException: + int srcLength = values.length; + int copyLength = this.historyCount; + boolean fillNeeded = false; + if (srcLength < this.historyCount) { + fillNeeded = true; + copyLength = srcLength; + } + //{ + for (i = 0; i < copyLength; i++) { // deep copy from values[], caller + // can safely discard that array + this.valueHistory[seriesNumber].enterData(i, values[i]); + } + if (fillNeeded) { + for (i = copyLength; i < this.historyCount; i++) { + this.valueHistory[seriesNumber].enterData(i, 0.0f); + } + } + //} + if (seriesKey != null) { + this.seriesKeys[seriesNumber] = seriesKey; + } + fireSeriesChanged(); + + } + + /** + * Sets the name of a series. If planning to add values individually. + * + * @param seriesNumber the series. + * @param key the new key. + */ + public void setSeriesKey(int seriesNumber, Comparable key) { + this.seriesKeys[seriesNumber] = key; + } + + /** + * Adds a value to a series. + * + * @param seriesNumber the series index. + * @param index ??. + * @param value the value. + */ + public void addValue(int seriesNumber, int index, float value) { + + invalidateRangeInfo(); + if (seriesNumber >= this.valueHistory.length) { + throw new IllegalArgumentException( + "TimeSeriesDataset.addValue(): series #" + + seriesNumber + "unspecified in c'tor" + ); + } + if (this.valueHistory[seriesNumber] == null) { + this.valueHistory[seriesNumber] + = new ValueSequence(this.historyCount); + this.seriesCount++; + } + // But if that series array already exists, just overwrite its contents + //synchronized(this) + //{ + this.valueHistory[seriesNumber].enterData(index, value); + //} + fireSeriesChanged(); + } + + /** + * Returns the number of series in the collection. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.seriesCount; + } + + /** + * Returns the number of items in a series. + *

+ * For this implementation, all series have the same number of items. + * + * @param series the series index (zero-based). + * + * @return The item count. + */ + @Override + public int getItemCount(int series) { // all arrays equal length, + // so ignore argument: + return this.historyCount; + } + + // Methods for managing the FIFO's: + + /** + * Re-map an index, for use in retrieving data. + * + * @param toFetch the index. + * + * @return The translated index. + */ + protected int translateGet(int toFetch) { + if (this.oldestAt == 0) { + return toFetch; // no translation needed + } + // else [implicit here] + int newIndex = toFetch + this.oldestAt; + if (newIndex >= this.historyCount) { + newIndex -= this.historyCount; + } + return newIndex; + } + + /** + * Returns the actual index to a time offset by "delta" from newestAt. + * + * @param delta the delta. + * + * @return The offset. + */ + public int offsetFromNewest(int delta) { + return wrapOffset(this.newestAt + delta); + } + + /** + * ?? + * + * @param delta ?? + * + * @return The offset. + */ + public int offsetFromOldest(int delta) { + return wrapOffset(this.oldestAt + delta); + } + + /** + * ?? + * + * @param protoIndex the index. + * + * @return The offset. + */ + protected int wrapOffset(int protoIndex) { + int tmp = protoIndex; + if (tmp >= this.historyCount) { + tmp -= this.historyCount; + } + else if (tmp < 0) { + tmp += this.historyCount; + } + return tmp; + } + + /** + * Adjust the array offset as needed when a new time-period is added: + * Increments the indices "oldestAt" and "newestAt", mod(array length), + * zeroes the series values at newestAt, returns the new TimePeriod. + * + * @return The new time period. + */ + public synchronized RegularTimePeriod advanceTime() { + RegularTimePeriod nextInstant = this.pointsInTime[this.newestAt].next(); + this.newestAt = this.oldestAt; // newestAt takes value previously held + // by oldestAT + /*** + * The next 10 lines or so should be expanded if data can be negative + ***/ + // if the oldest data contained a maximum Y-value, invalidate the stored + // Y-max and Y-range data: + boolean extremaChanged = false; + float oldMax = 0.0f; + if (this.maxValue != null) { + oldMax = this.maxValue.floatValue(); + } + for (int s = 0; s < getSeriesCount(); s++) { + if (this.valueHistory[s].getData(this.oldestAt) == oldMax) { + extremaChanged = true; + } + if (extremaChanged) { + break; + } + } /*** If data can be < 0, add code here to check the minimum **/ + if (extremaChanged) { + invalidateRangeInfo(); + } + // wipe the next (about to be used) set of data slots + float wiper = (float) 0.0; + for (int s = 0; s < getSeriesCount(); s++) { + this.valueHistory[s].enterData(this.newestAt, wiper); + } + // Update the array of TimePeriods: + this.pointsInTime[this.newestAt] = nextInstant; + // Now advance "oldestAt", wrapping at end of the array + this.oldestAt++; + if (this.oldestAt >= this.historyCount) { + this.oldestAt = 0; + } + // Update the domain limits: + long startL = this.domainStart.longValue(); //(time is kept in msec) + this.domainStart = new Long(startL + this.deltaTime); + long endL = this.domainEnd.longValue(); + this.domainEnd = new Long(endL + this.deltaTime); + this.domainRange = new Range(startL, endL); + fireSeriesChanged(); + return nextInstant; + } + + // If data can be < 0, the next 2 methods should be modified + + /** + * Invalidates the range info. + */ + public void invalidateRangeInfo() { + this.maxValue = null; + this.valueRange = null; + } + + /** + * Returns the maximum value. + * + * @return The maximum value. + */ + protected double findMaxValue() { + double max = 0.0f; + for (int s = 0; s < getSeriesCount(); s++) { + for (int i = 0; i < this.historyCount; i++) { + double tmp = getYValue(s, i); + if (tmp > max) { + max = tmp; + } + } + } + return max; + } + + /** End, positive-data-only code **/ + + /** + * Returns the index of the oldest data item. + * + * @return The index. + */ + public int getOldestIndex() { + return this.oldestAt; + } + + /** + * Returns the index of the newest data item. + * + * @return The index. + */ + public int getNewestIndex() { + return this.newestAt; + } + + // appendData() writes new data at the index position given by newestAt/ + // When adding new data dynamically, use advanceTime(), followed by this: + /** + * Appends new data. + * + * @param newData the data. + */ + public void appendData(float[] newData) { + int nDataPoints = newData.length; + if (nDataPoints > this.valueHistory.length) { + throw new IllegalArgumentException( + "More data than series to put them in" + ); + } + int s; // index to select the "series" + for (s = 0; s < nDataPoints; s++) { + // check whether the "valueHistory" array member exists; if not, + // create them: + if (this.valueHistory[s] == null) { + this.valueHistory[s] = new ValueSequence(this.historyCount); + } + this.valueHistory[s].enterData(this.newestAt, newData[s]); + } + fireSeriesChanged(); + } + + /** + * Appends data at specified index, for loading up with data from file(s). + * + * @param newData the data + * @param insertionIndex the index value at which to put it + * @param refresh value of n in "refresh the display on every nth call" + * (ignored if <= 0 ) + */ + public void appendData(float[] newData, int insertionIndex, int refresh) { + int nDataPoints = newData.length; + if (nDataPoints > this.valueHistory.length) { + throw new IllegalArgumentException( + "More data than series to put them " + "in" + ); + } + for (int s = 0; s < nDataPoints; s++) { + if (this.valueHistory[s] == null) { + this.valueHistory[s] = new ValueSequence(this.historyCount); + } + this.valueHistory[s].enterData(insertionIndex, newData[s]); + } + if (refresh > 0) { + insertionIndex++; + if (insertionIndex % refresh == 0) { + fireSeriesChanged(); + } + } + } + + /** + * Returns the newest time. + * + * @return The newest time. + */ + public RegularTimePeriod getNewestTime() { + return this.pointsInTime[this.newestAt]; + } + + /** + * Returns the oldest time. + * + * @return The oldest time. + */ + public RegularTimePeriod getOldestTime() { + return this.pointsInTime[this.oldestAt]; + } + + /** + * Returns the x-value. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + // getXxx() ftns can ignore the "series" argument: + // Don't synchronize this!! Instead, synchronize the loop that calls it. + @Override + public Number getX(int series, int item) { + RegularTimePeriod tp = this.pointsInTime[translateGet(item)]; + return new Long(getX(tp)); + } + + /** + * Returns the y-value. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getYValue(int series, int item) { + // Don't synchronize this!! + // Instead, synchronize the loop that calls it. + ValueSequence values = this.valueHistory[series]; + return values.getData(translateGet(item)); + } + + /** + * Returns the y-value. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public Number getY(int series, int item) { + return new Float(getYValue(series, item)); + } + + /** + * Returns the start x-value. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public Number getStartX(int series, int item) { + RegularTimePeriod tp = this.pointsInTime[translateGet(item)]; + return new Long(tp.getFirstMillisecond(this.workingCalendar)); + } + + /** + * Returns the end x-value. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public Number getEndX(int series, int item) { + RegularTimePeriod tp = this.pointsInTime[translateGet(item)]; + return new Long(tp.getLastMillisecond(this.workingCalendar)); + } + + /** + * Returns the start y-value. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public Number getStartY(int series, int item) { + return getY(series, item); + } + + /** + * Returns the end y-value. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public Number getEndY(int series, int item) { + return getY(series, item); + } + + /* // "Extras" found useful when analyzing/verifying class behavior: + public Number getUntranslatedXValue(int series, int item) + { + return super.getXValue(series, item); + } + + public float getUntranslatedY(int series, int item) + { + return super.getY(series, item); + } */ + + /** + * Returns the key for a series. + * + * @param series the series index (zero-based). + * + * @return The key. + */ + @Override + public Comparable getSeriesKey(int series) { + return this.seriesKeys[series]; + } + + /** + * Sends a {@link SeriesChangeEvent} to all registered listeners. + */ + protected void fireSeriesChanged() { + seriesChanged(new SeriesChangeEvent(this)); + } + + // The next 3 functions override the base-class implementation of + // the DomainInfo interface. Using saved limits (updated by + // each updateTime() call), improves performance. + // + + /** + * Returns the minimum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The minimum value. + */ + @Override + public double getDomainLowerBound(boolean includeInterval) { + return this.domainStart.doubleValue(); + // a Long kept updated by advanceTime() + } + + /** + * Returns the maximum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The maximum value. + */ + @Override + public double getDomainUpperBound(boolean includeInterval) { + return this.domainEnd.doubleValue(); + // a Long kept updated by advanceTime() + } + + /** + * Returns the range of the values in this dataset's domain. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The range. + */ + @Override + public Range getDomainBounds(boolean includeInterval) { + if (this.domainRange == null) { + findDomainLimits(); + } + return this.domainRange; + } + + /** + * Returns the x-value for a time period. + * + * @param period the period. + * + * @return The x-value. + */ + private long getX(RegularTimePeriod period) { + switch (this.position) { + case (START) : + return period.getFirstMillisecond(this.workingCalendar); + case (MIDDLE) : + return period.getMiddleMillisecond(this.workingCalendar); + case (END) : + return period.getLastMillisecond(this.workingCalendar); + default: + return period.getMiddleMillisecond(this.workingCalendar); + } + } + + // The next 3 functions implement the RangeInfo interface. + // Using saved limits (updated by each updateTime() call) significantly + // improves performance. WARNING: this code makes the simplifying + // assumption that data is never negative. Expand as needed for the + // general case. + + /** + * Returns the minimum range value. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The minimum range value. + */ + @Override + public double getRangeLowerBound(boolean includeInterval) { + double result = Double.NaN; + if (this.minValue != null) { + result = this.minValue.doubleValue(); + } + return result; + } + + /** + * Returns the maximum range value. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The maximum range value. + */ + @Override + public double getRangeUpperBound(boolean includeInterval) { + double result = Double.NaN; + if (this.maxValue != null) { + result = this.maxValue.doubleValue(); + } + return result; + } + + /** + * Returns the value range. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The range. + */ + @Override + public Range getRangeBounds(boolean includeInterval) { + if (this.valueRange == null) { + double max = getRangeUpperBound(includeInterval); + this.valueRange = new Range(0.0, max); + } + return this.valueRange; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/FixedMillisecond.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/FixedMillisecond.java new file mode 100755 index 0000000..96273f7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/FixedMillisecond.java @@ -0,0 +1,303 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * FixedMillisecond.java + * --------------------- + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Mar-2002 : Version 1, based on original Millisecond implementation (DG); + * 24-Jun-2002 : Removed unnecessary imports (DG); + * 10-Sep-2002 : Added getSerialIndex() method (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package and implemented + * Serializable (DG); + * 21-Oct-2003 : Added hashCode() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 06-Oct-2006 : Added peg() method (DG); + * 28-May-2008 : Fixed immutability problem (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.Date; + +/** + * Wrapper for a java.util.Date object that allows it to be used + * as a {@link RegularTimePeriod}. This class is immutable, which is a + * requirement for all {@link RegularTimePeriod} subclasses. + */ +public class FixedMillisecond extends RegularTimePeriod + implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7867521484545646931L; + + /** The millisecond. */ + private long time; + + /** + * Constructs a millisecond based on the current system time. + */ + public FixedMillisecond() { + this(new Date()); + } + + /** + * Constructs a millisecond. + * + * @param millisecond the millisecond (same encoding as java.util.Date). + */ + public FixedMillisecond(long millisecond) { + this(new Date(millisecond)); + } + + /** + * Constructs a millisecond. + * + * @param time the time. + */ + public FixedMillisecond(Date time) { + this.time = time.getTime(); + } + + /** + * Returns the date/time. + * + * @return The date/time. + */ + public Date getTime() { + return new Date(this.time); + } + + /** + * This method is overridden to do nothing. + * + * @param calendar ignored + * + * @since 1.0.3 + */ + @Override + public void peg(Calendar calendar) { + // nothing to do + } + + /** + * Returns the millisecond preceding this one. + * + * @return The millisecond preceding this one. + */ + @Override + public RegularTimePeriod previous() { + RegularTimePeriod result = null; + long t = this.time; + if (t != Long.MIN_VALUE) { + result = new FixedMillisecond(t - 1); + } + return result; + } + + /** + * Returns the millisecond following this one. + * + * @return The millisecond following this one. + */ + @Override + public RegularTimePeriod next() { + RegularTimePeriod result = null; + long t = this.time; + if (t != Long.MAX_VALUE) { + result = new FixedMillisecond(t + 1); + } + return result; + } + + /** + * Tests the equality of this object against an arbitrary Object. + * + * @param object the object to compare + * + * @return A boolean. + */ + @Override + public boolean equals(Object object) { + if (object instanceof FixedMillisecond) { + FixedMillisecond m = (FixedMillisecond) object; + return this.time == m.getFirstMillisecond(); + } + else { + return false; + } + + } + + /** + * Returns a hash code for this object instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return (int) this.time; + } + + /** + * Returns an integer indicating the order of this Millisecond object + * relative to the specified + * object: negative == before, zero == same, positive == after. + * + * @param o1 the object to compare. + * + * @return negative == before, zero == same, positive == after. + */ + @Override + public int compareTo(Object o1) { + + int result; + long difference; + + // CASE 1 : Comparing to another Second object + // ------------------------------------------- + if (o1 instanceof FixedMillisecond) { + FixedMillisecond t1 = (FixedMillisecond) o1; + difference = this.time - t1.time; + if (difference > 0) { + result = 1; + } + else { + if (difference < 0) { + result = -1; + } + else { + result = 0; + } + } + } + + // CASE 2 : Comparing to another TimePeriod object + // ----------------------------------------------- + else if (o1 instanceof RegularTimePeriod) { + // more difficult case - evaluate later... + result = 0; + } + + // CASE 3 : Comparing to a non-TimePeriod object + // --------------------------------------------- + else { + // consider time periods to be ordered after general objects + result = 1; + } + + return result; + + } + + /** + * Returns the first millisecond of the time period. + * + * @return The first millisecond of the time period. + */ + @Override + public long getFirstMillisecond() { + return this.time; + } + + + /** + * Returns the first millisecond of the time period. + * + * @param calendar the calendar. + * + * @return The first millisecond of the time period. + */ + @Override + public long getFirstMillisecond(Calendar calendar) { + return this.time; + } + + /** + * Returns the last millisecond of the time period. + * + * @return The last millisecond of the time period. + */ + @Override + public long getLastMillisecond() { + return this.time; + } + + /** + * Returns the last millisecond of the time period. + * + * @param calendar the calendar. + * + * @return The last millisecond of the time period. + */ + @Override + public long getLastMillisecond(Calendar calendar) { + return this.time; + } + + /** + * Returns the millisecond closest to the middle of the time period. + * + * @return The millisecond closest to the middle of the time period. + */ + @Override + public long getMiddleMillisecond() { + return this.time; + } + + /** + * Returns the millisecond closest to the middle of the time period. + * + * @param calendar the calendar. + * + * @return The millisecond closest to the middle of the time period. + */ + @Override + public long getMiddleMillisecond(Calendar calendar) { + return this.time; + } + + /** + * Returns a serial index number for the millisecond. + * + * @return The serial index number. + */ + @Override + public long getSerialIndex() { + return this.time; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Hour.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Hour.java new file mode 100755 index 0000000..81fdff6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Hour.java @@ -0,0 +1,498 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------- + * Hour.java + * --------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-Oct-2001 : Version 1 (DG); + * 18-Dec-2001 : Changed order of parameters in constructor (DG); + * 19-Dec-2001 : Added a new constructor as suggested by Paul English (DG); + * 14-Feb-2002 : Fixed bug in Hour(Date) constructor (DG); + * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to + * evaluate with reference to a particular time zone (DG); + * 15-Mar-2002 : Changed API (DG); + * 16-Apr-2002 : Fixed small time zone bug in constructor (DG); + * 10-Sep-2002 : Added getSerialIndex() method (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 10-Jan-2003 : Changed base class and method names (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package, and implemented + * Serializable (DG); + * 21-Oct-2003 : Added hashCode() method, and new constructor for + * convenience (DG); + * 30-Sep-2004 : Replaced getTime().getTime() with getTimeInMillis() (DG); + * 04-Nov-2004 : Reverted change of 30-Sep-2004, because it won't work for + * JDK 1.3 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 05-Oct-2006 : Updated API docs (DG); + * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); + * 04-Apr-2007 : In Hour(Date, TimeZone), peg milliseconds using specified + * time zone (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); + * 02-Mar-2009 : Added new constructor with Locale (DG); + * 05-Jul-2012 : Replaced getTime().getTime() with getTimeInMillis() (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; +import org.jfree.chart.util.ParamChecks; + +/** + * Represents an hour in a specific day. This class is immutable, which is a + * requirement for all {@link RegularTimePeriod} subclasses. + */ +public class Hour extends RegularTimePeriod implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -835471579831937652L; + + /** Useful constant for the first hour in the day. */ + public static final int FIRST_HOUR_IN_DAY = 0; + + /** Useful constant for the last hour in the day. */ + public static final int LAST_HOUR_IN_DAY = 23; + + /** The day. */ + private Day day; + + /** The hour. */ + private byte hour; + + /** The first millisecond. */ + private long firstMillisecond; + + /** The last millisecond. */ + private long lastMillisecond; + + /** + * Constructs a new Hour, based on the system date/time. + */ + public Hour() { + this(new Date()); + } + + /** + * Constructs a new Hour. + * + * @param hour the hour (in the range 0 to 23). + * @param day the day (null not permitted). + */ + public Hour(int hour, Day day) { + ParamChecks.nullNotPermitted(day, "day"); + this.hour = (byte) hour; + this.day = day; + peg(Calendar.getInstance()); + } + + /** + * Creates a new hour. + * + * @param hour the hour (0-23). + * @param day the day (1-31). + * @param month the month (1-12). + * @param year the year (1900-9999). + */ + public Hour(int hour, int day, int month, int year) { + this(hour, new Day(day, month, year)); + } + + /** + * Constructs a new instance, based on the supplied date/time and + * the default time zone. + * + * @param time the date-time (null not permitted). + * + * @see #Hour(Date, TimeZone) + */ + public Hour(Date time) { + // defer argument checking... + this(time, TimeZone.getDefault(), Locale.getDefault()); + } + + /** + * Constructs a new instance, based on the supplied date/time evaluated + * in the specified time zone. + * + * @param time the date-time (null not permitted). + * @param zone the time zone (null not permitted). + * + * @deprecated As of 1.0.13, use the constructor that specifies the locale + * also. + */ + public Hour(Date time, TimeZone zone) { + this(time, zone, Locale.getDefault()); + } + + /** + * Constructs a new instance, based on the supplied date/time evaluated + * in the specified time zone. + * + * @param time the date-time (null not permitted). + * @param zone the time zone (null not permitted). + * @param locale the locale (null not permitted). + * + * @since 1.0.13 + */ + public Hour(Date time, TimeZone zone, Locale locale) { + ParamChecks.nullNotPermitted(time, "time"); + ParamChecks.nullNotPermitted(zone, "zone"); + ParamChecks.nullNotPermitted(locale, "locale"); + Calendar calendar = Calendar.getInstance(zone, locale); + calendar.setTime(time); + this.hour = (byte) calendar.get(Calendar.HOUR_OF_DAY); + this.day = new Day(time, zone, locale); + peg(calendar); + } + + /** + * Returns the hour. + * + * @return The hour (0 <= hour <= 23). + */ + public int getHour() { + return this.hour; + } + + /** + * Returns the day in which this hour falls. + * + * @return The day. + */ + public Day getDay() { + return this.day; + } + + /** + * Returns the year in which this hour falls. + * + * @return The year. + */ + public int getYear() { + return this.day.getYear(); + } + + /** + * Returns the month in which this hour falls. + * + * @return The month. + */ + public int getMonth() { + return this.day.getMonth(); + } + + /** + * Returns the day-of-the-month in which this hour falls. + * + * @return The day-of-the-month. + */ + public int getDayOfMonth() { + return this.day.getDayOfMonth(); + } + + /** + * Returns the first millisecond of the hour. This will be determined + * relative to the time zone specified in the constructor, or in the + * calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The first millisecond of the hour. + * + * @see #getLastMillisecond() + */ + @Override + public long getFirstMillisecond() { + return this.firstMillisecond; + } + + /** + * Returns the last millisecond of the hour. This will be + * determined relative to the time zone specified in the constructor, or + * in the calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The last millisecond of the hour. + * + * @see #getFirstMillisecond() + */ + @Override + public long getLastMillisecond() { + return this.lastMillisecond; + } + + /** + * Recalculates the start date/time and end date/time for this time period + * relative to the supplied calendar (which incorporates a time zone). + * + * @param calendar the calendar (null not permitted). + * + * @since 1.0.3 + */ + @Override + public void peg(Calendar calendar) { + this.firstMillisecond = getFirstMillisecond(calendar); + this.lastMillisecond = getLastMillisecond(calendar); + } + + /** + * Returns the hour preceding this one. + * + * @return The hour preceding this one. + */ + @Override + public RegularTimePeriod previous() { + Hour result; + if (this.hour != FIRST_HOUR_IN_DAY) { + result = new Hour(this.hour - 1, this.day); + } + else { // we are at the first hour in the day... + Day prevDay = (Day) this.day.previous(); + if (prevDay != null) { + result = new Hour(LAST_HOUR_IN_DAY, prevDay); + } + else { + result = null; + } + } + return result; + } + + /** + * Returns the hour following this one. + * + * @return The hour following this one. + */ + @Override + public RegularTimePeriod next() { + Hour result; + if (this.hour != LAST_HOUR_IN_DAY) { + result = new Hour(this.hour + 1, this.day); + } + else { // we are at the last hour in the day... + Day nextDay = (Day) this.day.next(); + if (nextDay != null) { + result = new Hour(FIRST_HOUR_IN_DAY, nextDay); + } + else { + result = null; + } + } + return result; + } + + /** + * Returns a serial index number for the hour. + * + * @return The serial index number. + */ + @Override + public long getSerialIndex() { + return this.day.getSerialIndex() * 24L + this.hour; + } + + /** + * Returns the first millisecond of the hour. + * + * @param calendar the calendar/timezone (null not permitted). + * + * @return The first millisecond. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getFirstMillisecond(Calendar calendar) { + int year = this.day.getYear(); + int month = this.day.getMonth() - 1; + int dom = this.day.getDayOfMonth(); + calendar.set(year, month, dom, this.hour, 0, 0); + calendar.set(Calendar.MILLISECOND, 0); + return calendar.getTimeInMillis(); + } + + /** + * Returns the last millisecond of the hour. + * + * @param calendar the calendar/timezone (null not permitted). + * + * @return The last millisecond. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getLastMillisecond(Calendar calendar) { + int year = this.day.getYear(); + int month = this.day.getMonth() - 1; + int dom = this.day.getDayOfMonth(); + calendar.set(year, month, dom, this.hour, 59, 59); + calendar.set(Calendar.MILLISECOND, 999); + return calendar.getTimeInMillis(); + } + + /** + * Tests the equality of this object against an arbitrary Object. + *

+ * This method will return true ONLY if the object is an Hour object + * representing the same hour as this instance. + * + * @param obj the object to compare (null permitted). + * + * @return true if the hour and day value of the object + * is the same as this. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Hour)) { + return false; + } + Hour that = (Hour) obj; + if (this.hour != that.hour) { + return false; + } + if (!this.day.equals(that.day)) { + return false; + } + return true; + } + + /** + * Returns a string representation of this instance, for debugging + * purposes. + * + * @return A string. + */ + @Override + public String toString() { + return "[" + this.hour + "," + getDayOfMonth() + "/" + getMonth() + "/" + + getYear() + "]"; + } + + /** + * Returns a hash code for this object instance. The approach described by + * Joshua Bloch in "Effective Java" has been used here: + *

+ * http://developer.java.sun.com/developer/Books/effectivejava + * /Chapter3.pdf + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 17; + result = 37 * result + this.hour; + result = 37 * result + this.day.hashCode(); + return result; + } + + /** + * Returns an integer indicating the order of this Hour object relative to + * the specified object: + * + * negative == before, zero == same, positive == after. + * + * @param o1 the object to compare. + * + * @return negative == before, zero == same, positive == after. + */ + @Override + public int compareTo(Object o1) { + int result; + + // CASE 1 : Comparing to another Hour object + // ----------------------------------------- + if (o1 instanceof Hour) { + Hour h = (Hour) o1; + result = getDay().compareTo(h.getDay()); + if (result == 0) { + result = this.hour - h.getHour(); + } + } + + // CASE 2 : Comparing to another TimePeriod object + // ----------------------------------------------- + else if (o1 instanceof RegularTimePeriod) { + // more difficult case - evaluate later... + result = 0; + } + + // CASE 3 : Comparing to a non-TimePeriod object + // --------------------------------------------- + else { + // consider time periods to be ordered after general objects + result = 1; + } + + return result; + } + + /** + * Creates an Hour instance by parsing a string. The string is assumed to + * be in the format "YYYY-MM-DD HH", perhaps with leading or trailing + * whitespace. + * + * @param s the hour string to parse. + * + * @return null if the string is not parseable, the hour + * otherwise. + */ + public static Hour parseHour(String s) { + Hour result = null; + s = s.trim(); + + String daystr = s.substring(0, Math.min(10, s.length())); + Day day = Day.parseDay(daystr); + if (day != null) { + String hourstr = s.substring( + Math.min(daystr.length() + 1, s.length()), s.length() + ); + hourstr = hourstr.trim(); + int hour = Integer.parseInt(hourstr); + // if the hour is 0 - 23 then create an hour + if ((hour >= FIRST_HOUR_IN_DAY) && (hour <= LAST_HOUR_IN_DAY)) { + result = new Hour(hour, day); + } + } + + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Millisecond.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Millisecond.java new file mode 100755 index 0000000..ab53005 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Millisecond.java @@ -0,0 +1,448 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * Millisecond.java + * ---------------- + * (C) Copyright 2001-2012, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-Oct-2001 : Version 1 (DG); + * 19-Dec-2001 : Added new constructors as suggested by Paul English (DG); + * 26-Feb-2002 : Added new getStart() and getEnd() methods (DG); + * 29-Mar-2002 : Fixed bug in getStart(), getEnd() and compareTo() methods (DG); + * 10-Sep-2002 : Added getSerialIndex() method (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 10-Jan-2003 : Changed base class and method names (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package and implemented + * Serializable (DG); + * 21-Oct-2003 : Added hashCode() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 05-Oct-2006 : Updated API docs (DG); + * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); + * 04-Apr-2007 : In Millisecond(Date, TimeZone), peg milliseconds to the + * specified zone (DG); + * 06-Jun-2008 : Added handling for general RegularTimePeriod in compareTo() + * method: + * see http://www.jfree.org/phpBB2/viewtopic.php?t=24805 (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); + * 02-Mar-2009 : Added new constructor with Locale (DG); + * 05-Jul-2012 : Replaced getTime().getTime() with getTimeInMillis() (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +/** + * Represents a millisecond. This class is immutable, which is a requirement + * for all {@link RegularTimePeriod} subclasses. + */ +public class Millisecond extends RegularTimePeriod implements Serializable { + + /** For serialization. */ + static final long serialVersionUID = -5316836467277638485L; + + /** A constant for the first millisecond in a second. */ + public static final int FIRST_MILLISECOND_IN_SECOND = 0; + + /** A constant for the last millisecond in a second. */ + public static final int LAST_MILLISECOND_IN_SECOND = 999; + + /** The day. */ + private Day day; + + /** The hour in the day. */ + private byte hour; + + /** The minute. */ + private byte minute; + + /** The second. */ + private byte second; + + /** The millisecond. */ + private int millisecond; + + /** + * The pegged millisecond. + */ + private long firstMillisecond; + + /** + * Constructs a millisecond based on the current system time. + */ + public Millisecond() { + this(new Date()); + } + + /** + * Constructs a millisecond. + * + * @param millisecond the millisecond (0-999). + * @param second the second. + */ + public Millisecond(int millisecond, Second second) { + this.millisecond = millisecond; + this.second = (byte) second.getSecond(); + this.minute = (byte) second.getMinute().getMinute(); + this.hour = (byte) second.getMinute().getHourValue(); + this.day = second.getMinute().getDay(); + peg(Calendar.getInstance()); + } + + /** + * Creates a new millisecond. + * + * @param millisecond the millisecond (0-999). + * @param second the second (0-59). + * @param minute the minute (0-59). + * @param hour the hour (0-23). + * @param day the day (1-31). + * @param month the month (1-12). + * @param year the year (1900-9999). + */ + public Millisecond(int millisecond, int second, int minute, int hour, + int day, int month, int year) { + + this(millisecond, new Second(second, minute, hour, day, month, year)); + + } + + /** + * Constructs a new millisecond using the default time zone. + * + * @param time the time. + * + * @see #Millisecond(Date, TimeZone) + */ + public Millisecond(Date time) { + this(time, TimeZone.getDefault(), Locale.getDefault()); + } + + /** + * Creates a millisecond. + * + * @param time the instant in time. + * @param zone the time zone. + * + * @deprecated As of 1.0.13, use the constructor that specifies the locale + * also. + */ + public Millisecond(Date time, TimeZone zone) { + this(time, zone, Locale.getDefault()); + } + + /** + * Creates a millisecond. + * + * @param time the date-time (null not permitted). + * @param zone the time zone (null not permitted). + * @param locale the locale (null not permitted). + * + * @since 1.0.13 + */ + public Millisecond(Date time, TimeZone zone, Locale locale) { + Calendar calendar = Calendar.getInstance(zone, locale); + calendar.setTime(time); + this.millisecond = calendar.get(Calendar.MILLISECOND); + this.second = (byte) calendar.get(Calendar.SECOND); + this.minute = (byte) calendar.get(Calendar.MINUTE); + this.hour = (byte) calendar.get(Calendar.HOUR_OF_DAY); + this.day = new Day(time, zone, locale); + peg(calendar); + } + + /** + * Returns the second. + * + * @return The second. + */ + public Second getSecond() { + return new Second(this.second, this.minute, this.hour, + this.day.getDayOfMonth(), this.day.getMonth(), + this.day.getYear()); + } + + /** + * Returns the millisecond. + * + * @return The millisecond. + */ + public long getMillisecond() { + return this.millisecond; + } + + /** + * Returns the first millisecond of the second. This will be determined + * relative to the time zone specified in the constructor, or in the + * calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The first millisecond of the second. + * + * @see #getLastMillisecond() + */ + @Override + public long getFirstMillisecond() { + return this.firstMillisecond; + } + + /** + * Returns the last millisecond of the second. This will be + * determined relative to the time zone specified in the constructor, or + * in the calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The last millisecond of the second. + * + * @see #getFirstMillisecond() + */ + @Override + public long getLastMillisecond() { + return this.firstMillisecond; + } + + /** + * Recalculates the start date/time and end date/time for this time period + * relative to the supplied calendar (which incorporates a time zone). + * + * @param calendar the calendar (null not permitted). + * + * @since 1.0.3 + */ + @Override + public void peg(Calendar calendar) { + this.firstMillisecond = getFirstMillisecond(calendar); + } + + /** + * Returns the millisecond preceding this one. + * + * @return The millisecond preceding this one. + */ + @Override + public RegularTimePeriod previous() { + RegularTimePeriod result = null; + if (this.millisecond != FIRST_MILLISECOND_IN_SECOND) { + result = new Millisecond(this.millisecond - 1, getSecond()); + } + else { + Second previous = (Second) getSecond().previous(); + if (previous != null) { + result = new Millisecond(LAST_MILLISECOND_IN_SECOND, previous); + } + } + return result; + } + + /** + * Returns the millisecond following this one. + * + * @return The millisecond following this one. + */ + @Override + public RegularTimePeriod next() { + RegularTimePeriod result = null; + if (this.millisecond != LAST_MILLISECOND_IN_SECOND) { + result = new Millisecond(this.millisecond + 1, getSecond()); + } + else { + Second next = (Second) getSecond().next(); + if (next != null) { + result = new Millisecond(FIRST_MILLISECOND_IN_SECOND, next); + } + } + return result; + } + + /** + * Returns a serial index number for the millisecond. + * + * @return The serial index number. + */ + @Override + public long getSerialIndex() { + long hourIndex = this.day.getSerialIndex() * 24L + this.hour; + long minuteIndex = hourIndex * 60L + this.minute; + long secondIndex = minuteIndex * 60L + this.second; + return secondIndex * 1000L + this.millisecond; + } + + /** + * Tests the equality of this object against an arbitrary Object. + *

+ * This method will return true ONLY if the object is a Millisecond object + * representing the same millisecond as this instance. + * + * @param obj the object to compare + * + * @return true if milliseconds and seconds of this and object + * are the same. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Millisecond)) { + return false; + } + Millisecond that = (Millisecond) obj; + if (this.millisecond != that.millisecond) { + return false; + } + if (this.second != that.second) { + return false; + } + if (this.minute != that.minute) { + return false; + } + if (this.hour != that.hour) { + return false; + } + if (!this.day.equals(that.day)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this object instance. The approach described by + * Joshua Bloch in "Effective Java" has been used here: + *

+ * http://developer.java.sun.com/developer/Books/effectivejava + * /Chapter3.pdf + * + * @return A hashcode. + */ + @Override + public int hashCode() { + int result = 17; + result = 37 * result + this.millisecond; + result = 37 * result + getSecond().hashCode(); + return result; + } + + /** + * Returns an integer indicating the order of this Millisecond object + * relative to the specified object: + * + * negative == before, zero == same, positive == after. + * + * @param obj the object to compare + * + * @return negative == before, zero == same, positive == after. + */ + @Override + public int compareTo(Object obj) { + int result; + long difference; + + // CASE 1 : Comparing to another Second object + // ------------------------------------------- + if (obj instanceof Millisecond) { + Millisecond ms = (Millisecond) obj; + difference = getFirstMillisecond() - ms.getFirstMillisecond(); + if (difference > 0) { + result = 1; + } + else { + if (difference < 0) { + result = -1; + } + else { + result = 0; + } + } + } + + // CASE 2 : Comparing to another TimePeriod object + // ----------------------------------------------- + else if (obj instanceof RegularTimePeriod) { + RegularTimePeriod rtp = (RegularTimePeriod) obj; + final long thisVal = this.getFirstMillisecond(); + final long anotherVal = rtp.getFirstMillisecond(); + result = (thisVal < anotherVal ? -1 + : (thisVal == anotherVal ? 0 : 1)); + } + + // CASE 3 : Comparing to a non-TimePeriod object + // --------------------------------------------- + else { + // consider time periods to be ordered after general objects + result = 1; + } + + return result; + } + + /** + * Returns the first millisecond of the time period. + * + * @param calendar the calendar (null not permitted). + * + * @return The first millisecond of the time period. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getFirstMillisecond(Calendar calendar) { + int year = this.day.getYear(); + int month = this.day.getMonth() - 1; + int d = this.day.getDayOfMonth(); + calendar.clear(); + calendar.set(year, month, d, this.hour, this.minute, this.second); + calendar.set(Calendar.MILLISECOND, this.millisecond); + return calendar.getTimeInMillis(); + } + + /** + * Returns the last millisecond of the time period. + * + * @param calendar the calendar (null not permitted). + * + * @return The last millisecond of the time period. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getLastMillisecond(Calendar calendar) { + return getFirstMillisecond(calendar); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Minute.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Minute.java new file mode 100755 index 0000000..576b647 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Minute.java @@ -0,0 +1,505 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------- + * Minute.java + * ----------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-Oct-2001 : Version 1 (DG); + * 18-Dec-2001 : Changed order of parameters in constructor (DG); + * 19-Dec-2001 : Added a new constructor as suggested by Paul English (DG); + * 14-Feb-2002 : Fixed bug in Minute(Date) constructor, and changed the range + * to start from zero instead of one (DG); + * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to + * evaluate with reference to a particular time zone (DG); + * 13-Mar-2002 : Added parseMinute() method (DG); + * 19-Mar-2002 : Changed API, the minute is now defined in relation to an + * Hour (DG); + * 10-Sep-2002 : Added getSerialIndex() method (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 10-Jan-2003 : Changed base class and method names (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package and implemented + * Serializable (DG); + * 21-Oct-2003 : Added hashCode() method, and new constructor for + * convenience (DG); + * 30-Sep-2004 : Replaced getTime().getTime() with getTimeInMillis() (DG); + * 04-Nov-2004 : Reverted change of 30-Sep-2004, because it won't work for + * JDK 1.3 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 05-Oct-2006 : Updated API docs (DG); + * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); + * 11-Dec-2006 : Fix for previous() - bug 1611872 (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); + * 02-Mar-2009 : Added new constructor that specifies Locale (DG); + * 05-Jul-2012 : Replaced getTime().getTime() with getTimeInMillis() (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; +import org.jfree.chart.util.ParamChecks; + +/** + * Represents a minute. This class is immutable, which is a requirement for + * all {@link RegularTimePeriod} subclasses. + */ +public class Minute extends RegularTimePeriod implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 2144572840034842871L; + + /** Useful constant for the first minute in a day. */ + public static final int FIRST_MINUTE_IN_HOUR = 0; + + /** Useful constant for the last minute in a day. */ + public static final int LAST_MINUTE_IN_HOUR = 59; + + /** The day. */ + private Day day; + + /** The hour in which the minute falls. */ + private byte hour; + + /** The minute. */ + private byte minute; + + /** The first millisecond. */ + private long firstMillisecond; + + /** The last millisecond. */ + private long lastMillisecond; + + /** + * Constructs a new Minute, based on the system date/time. + */ + public Minute() { + this(new Date()); + } + + /** + * Constructs a new Minute. + * + * @param minute the minute (0 to 59). + * @param hour the hour (null not permitted). + */ + public Minute(int minute, Hour hour) { + ParamChecks.nullNotPermitted(hour, "hour"); + this.minute = (byte) minute; + this.hour = (byte) hour.getHour(); + this.day = hour.getDay(); + peg(Calendar.getInstance()); + } + + /** + * Constructs a new instance, based on the supplied date/time and + * the default time zone. + * + * @param time the time (null not permitted). + * + * @see #Minute(Date, TimeZone) + */ + public Minute(Date time) { + // defer argument checking + this(time, TimeZone.getDefault(), Locale.getDefault()); + } + + /** + * Constructs a new Minute, based on the supplied date/time and timezone. + * + * @param time the time (null not permitted). + * @param zone the time zone (null not permitted). + * + * @deprecated As of 1.0.13, use the constructor that specifies the locale + * also. + */ + public Minute(Date time, TimeZone zone) { + this(time, zone, Locale.getDefault()); + } + + /** + * Constructs a new Minute, based on the supplied date/time and timezone. + * + * @param time the time (null not permitted). + * @param zone the time zone (null not permitted). + * @param locale the locale (null not permitted). + * + * @since 1.0.13 + */ + public Minute(Date time, TimeZone zone, Locale locale) { + ParamChecks.nullNotPermitted(time, "time"); + ParamChecks.nullNotPermitted(zone, "zone"); + ParamChecks.nullNotPermitted(locale, "locale"); + Calendar calendar = Calendar.getInstance(zone, locale); + calendar.setTime(time); + int min = calendar.get(Calendar.MINUTE); + this.minute = (byte) min; + this.hour = (byte) calendar.get(Calendar.HOUR_OF_DAY); + this.day = new Day(time, zone, locale); + peg(calendar); + } + + /** + * Creates a new minute. + * + * @param minute the minute (0-59). + * @param hour the hour (0-23). + * @param day the day (1-31). + * @param month the month (1-12). + * @param year the year (1900-9999). + */ + public Minute(int minute, int hour, int day, int month, int year) { + this(minute, new Hour(hour, new Day(day, month, year))); + } + + /** + * Returns the day. + * + * @return The day. + * + * @since 1.0.3 + */ + public Day getDay() { + return this.day; + } + + /** + * Returns the hour. + * + * @return The hour (never null). + */ + public Hour getHour() { + return new Hour(this.hour, this.day); + } + + /** + * Returns the hour. + * + * @return The hour. + * + * @since 1.0.3 + */ + public int getHourValue() { + return this.hour; + } + + /** + * Returns the minute. + * + * @return The minute. + */ + public int getMinute() { + return this.minute; + } + + /** + * Returns the first millisecond of the minute. This will be determined + * relative to the time zone specified in the constructor, or in the + * calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The first millisecond of the minute. + * + * @see #getLastMillisecond() + */ + @Override + public long getFirstMillisecond() { + return this.firstMillisecond; + } + + /** + * Returns the last millisecond of the minute. This will be + * determined relative to the time zone specified in the constructor, or + * in the calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The last millisecond of the minute. + * + * @see #getFirstMillisecond() + */ + @Override + public long getLastMillisecond() { + return this.lastMillisecond; + } + + /** + * Recalculates the start date/time and end date/time for this time period + * relative to the supplied calendar (which incorporates a time zone). + * + * @param calendar the calendar (null not permitted). + * + * @since 1.0.3 + */ + @Override + public void peg(Calendar calendar) { + this.firstMillisecond = getFirstMillisecond(calendar); + this.lastMillisecond = getLastMillisecond(calendar); + } + + /** + * Returns the minute preceding this one. + * + * @return The minute preceding this one. + */ + @Override + public RegularTimePeriod previous() { + Minute result; + if (this.minute != FIRST_MINUTE_IN_HOUR) { + result = new Minute(this.minute - 1, getHour()); + } + else { + Hour h = (Hour) getHour().previous(); + if (h != null) { + result = new Minute(LAST_MINUTE_IN_HOUR, h); + } + else { + result = null; + } + } + return result; + } + + /** + * Returns the minute following this one. + * + * @return The minute following this one. + */ + @Override + public RegularTimePeriod next() { + Minute result; + if (this.minute != LAST_MINUTE_IN_HOUR) { + result = new Minute(this.minute + 1, getHour()); + } + else { // we are at the last minute in the hour... + Hour nextHour = (Hour) getHour().next(); + if (nextHour != null) { + result = new Minute(FIRST_MINUTE_IN_HOUR, nextHour); + } + else { + result = null; + } + } + return result; + } + + /** + * Returns a serial index number for the minute. + * + * @return The serial index number. + */ + @Override + public long getSerialIndex() { + long hourIndex = this.day.getSerialIndex() * 24L + this.hour; + return hourIndex * 60L + this.minute; + } + + /** + * Returns the first millisecond of the minute. + * + * @param calendar the calendar which defines the timezone + * (null not permitted). + * + * @return The first millisecond. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getFirstMillisecond(Calendar calendar) { + int year = this.day.getYear(); + int month = this.day.getMonth() - 1; + int d = this.day.getDayOfMonth(); + + calendar.clear(); + calendar.set(year, month, d, this.hour, this.minute, 0); + calendar.set(Calendar.MILLISECOND, 0); + + return calendar.getTimeInMillis(); + } + + /** + * Returns the last millisecond of the minute. + * + * @param calendar the calendar / timezone (null not + * permitted). + * + * @return The last millisecond. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getLastMillisecond(Calendar calendar) { + int year = this.day.getYear(); + int month = this.day.getMonth() - 1; + int d = this.day.getDayOfMonth(); + + calendar.clear(); + calendar.set(year, month, d, this.hour, this.minute, 59); + calendar.set(Calendar.MILLISECOND, 999); + + return calendar.getTimeInMillis(); + } + + /** + * Tests the equality of this object against an arbitrary Object. + *

+ * This method will return true ONLY if the object is a Minute object + * representing the same minute as this instance. + * + * @param obj the object to compare (null permitted). + * + * @return true if the minute and hour value of this and the + * object are the same. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Minute)) { + return false; + } + Minute that = (Minute) obj; + if (this.minute != that.minute) { + return false; + } + if (this.hour != that.hour) { + return false; + } + return true; + } + + /** + * Returns a hash code for this object instance. The approach described + * by Joshua Bloch in "Effective Java" has been used here: + *

+ * http://developer.java.sun.com/developer/Books/effectivejava + * /Chapter3.pdf + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 17; + result = 37 * result + this.minute; + result = 37 * result + this.hour; + result = 37 * result + this.day.hashCode(); + return result; + } + + /** + * Returns an integer indicating the order of this Minute object relative + * to the specified object: + * + * negative == before, zero == same, positive == after. + * + * @param o1 object to compare. + * + * @return negative == before, zero == same, positive == after. + */ + @Override + public int compareTo(Object o1) { + int result; + + // CASE 1 : Comparing to another Minute object + // ------------------------------------------- + if (o1 instanceof Minute) { + Minute m = (Minute) o1; + result = getHour().compareTo(m.getHour()); + if (result == 0) { + result = this.minute - m.getMinute(); + } + } + + // CASE 2 : Comparing to another TimePeriod object + // ----------------------------------------------- + else if (o1 instanceof RegularTimePeriod) { + // more difficult case - evaluate later... + result = 0; + } + + // CASE 3 : Comparing to a non-TimePeriod object + // --------------------------------------------- + else { + // consider time periods to be ordered after general objects + result = 1; + } + + return result; + } + + /** + * Creates a Minute instance by parsing a string. The string is assumed to + * be in the format "YYYY-MM-DD HH:MM", perhaps with leading or trailing + * whitespace. + * + * @param s the minute string to parse. + * + * @return null, if the string is not parseable, the minute + * otherwise. + */ + public static Minute parseMinute(String s) { + Minute result = null; + s = s.trim(); + + String daystr = s.substring(0, Math.min(10, s.length())); + Day day = Day.parseDay(daystr); + if (day != null) { + String hmstr = s.substring( + Math.min(daystr.length() + 1, s.length()), s.length() + ); + hmstr = hmstr.trim(); + + String hourstr = hmstr.substring(0, Math.min(2, hmstr.length())); + int hour = Integer.parseInt(hourstr); + + if ((hour >= 0) && (hour <= 23)) { + String minstr = hmstr.substring( + Math.min(hourstr.length() + 1, hmstr.length()), + hmstr.length() + ); + int minute = Integer.parseInt(minstr); + if ((minute >= 0) && (minute <= 59)) { + result = new Minute(minute, new Hour(hour, day)); + } + } + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Month.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Month.java new file mode 100755 index 0000000..db46cfe --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Month.java @@ -0,0 +1,556 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------- + * Month.java + * ---------- + * (C) Copyright 2001-2012, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Chris Boek; + * + * Changes + * ------- + * 11-Oct-2001 : Version 1 (DG); + * 14-Nov-2001 : Added method to get year as primitive (DG); + * Override for toString() method (DG); + * 18-Dec-2001 : Changed order of parameters in constructor (DG); + * 19-Dec-2001 : Added a new constructor as suggested by Paul English (DG); + * 29-Jan-2002 : Worked on the parseMonth() method (DG); + * 14-Feb-2002 : Fixed bugs in the Month constructors (DG); + * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to + * evaluate with reference to a particular time zone (DG); + * 19-Mar-2002 : Changed API for TimePeriod classes (DG); + * 10-Sep-2002 : Added getSerialIndex() method (DG); + * 04-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 10-Jan-2003 : Changed base class and method names (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package, and implemented + * Serializable (DG); + * 21-Oct-2003 : Added hashCode() method (DG); + * 01-Nov-2005 : Fixed bug 1345383 (argument check in constructor) (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 05-Oct-2006 : Updated API docs (DG); + * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); + * 04-Apr-2007 : Fixed bug in Month(Date, TimeZone) constructor (CB); + * 01-Sep-2008 : Added clarification for previous() and next() methods (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE, and updated parsing to handle + * extended range in Year (DG); + * 25-Nov-2008 : Added new constructor with Locale (DG); + * 04-Feb-2009 : Fix for new constructor with Locale - bug 2564636 (DG); + * 05-Jul-2012 : Removed JDK 1.3.1 supporting code (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +import org.jfree.date.MonthConstants; +import org.jfree.date.SerialDate; + +/** + * Represents a single month. This class is immutable, which is a requirement + * for all {@link RegularTimePeriod} subclasses. + */ +public class Month extends RegularTimePeriod implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -5090216912548722570L; + + /** The month (1-12). */ + private int month; + + /** The year in which the month falls. */ + private int year; + + /** The first millisecond. */ + private long firstMillisecond; + + /** The last millisecond. */ + private long lastMillisecond; + + /** + * Constructs a new Month, based on the current system time. + */ + public Month() { + this(new Date()); + } + + /** + * Constructs a new month instance. + * + * @param month the month (in the range 1 to 12). + * @param year the year. + */ + public Month(int month, int year) { + if ((month < 1) || (month > 12)) { + throw new IllegalArgumentException("Month outside valid range."); + } + this.month = month; + this.year = year; + peg(Calendar.getInstance()); + } + + /** + * Constructs a new month instance. + * + * @param month the month (in the range 1 to 12). + * @param year the year. + */ + public Month(int month, Year year) { + if ((month < 1) || (month > 12)) { + throw new IllegalArgumentException("Month outside valid range."); + } + this.month = month; + this.year = year.getYear(); + peg(Calendar.getInstance()); + } + + /** + * Constructs a new Month instance, based on a date/time and + * the default time zone. + * + * @param time the date/time (null not permitted). + * + * @see #Month(Date, TimeZone) + */ + public Month(Date time) { + this(time, TimeZone.getDefault()); + } + + /** + * Constructs a new Month instance, based on a date/time and + * a time zone. The first and last millisecond values are initially + * pegged to the given time zone also. + * + * @param time the date/time. + * @param zone the time zone (null not permitted). + * + * @deprecated Since 1.0.12, use {@link #Month(Date, TimeZone, Locale)} + * instead. + */ + public Month(Date time, TimeZone zone) { + this(time, zone, Locale.getDefault()); + } + + /** + * Creates a new Month instance, based on the specified time, + * zone and locale. + * + * @param time the current time. + * @param zone the time zone. + * @param locale the locale. + * + * @since 1.0.12 + */ + public Month(Date time, TimeZone zone, Locale locale) { + Calendar calendar = Calendar.getInstance(zone, locale); + calendar.setTime(time); + this.month = calendar.get(Calendar.MONTH) + 1; + this.year = calendar.get(Calendar.YEAR); + peg(calendar); + } + + /** + * Returns the year in which the month falls. + * + * @return The year in which the month falls (as a Year object). + */ + public Year getYear() { + return new Year(this.year); + } + + /** + * Returns the year in which the month falls. + * + * @return The year in which the month falls (as an int). + */ + public int getYearValue() { + return this.year; + } + + /** + * Returns the month. Note that 1=JAN, 2=FEB, ... + * + * @return The month. + */ + public int getMonth() { + return this.month; + } + + /** + * Returns the first millisecond of the month. This will be determined + * relative to the time zone specified in the constructor, or in the + * calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The first millisecond of the month. + * + * @see #getLastMillisecond() + */ + @Override + public long getFirstMillisecond() { + return this.firstMillisecond; + } + + /** + * Returns the last millisecond of the month. This will be + * determined relative to the time zone specified in the constructor, or + * in the calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The last millisecond of the month. + * + * @see #getFirstMillisecond() + */ + @Override + public long getLastMillisecond() { + return this.lastMillisecond; + } + + /** + * Recalculates the start date/time and end date/time for this time period + * relative to the supplied calendar (which incorporates a time zone). + * + * @param calendar the calendar (null not permitted). + * + * @since 1.0.3 + */ + @Override + public void peg(Calendar calendar) { + this.firstMillisecond = getFirstMillisecond(calendar); + this.lastMillisecond = getLastMillisecond(calendar); + } + + /** + * Returns the month preceding this one. Note that the returned + * {@link Month} is "pegged" using the default time-zone, irrespective of + * the time-zone used to peg of the current month (which is not recorded + * anywhere). See the {@link #peg(Calendar)} method. + * + * @return The month preceding this one. + */ + @Override + public RegularTimePeriod previous() { + Month result; + if (this.month != MonthConstants.JANUARY) { + result = new Month(this.month - 1, this.year); + } + else { + if (this.year > 1900) { + result = new Month(MonthConstants.DECEMBER, this.year - 1); + } + else { + result = null; + } + } + return result; + } + + /** + * Returns the month following this one. Note that the returned + * {@link Month} is "pegged" using the default time-zone, irrespective of + * the time-zone used to peg of the current month (which is not recorded + * anywhere). See the {@link #peg(Calendar)} method. + * + * @return The month following this one. + */ + @Override + public RegularTimePeriod next() { + Month result; + if (this.month != MonthConstants.DECEMBER) { + result = new Month(this.month + 1, this.year); + } + else { + if (this.year < 9999) { + result = new Month(MonthConstants.JANUARY, this.year + 1); + } + else { + result = null; + } + } + return result; + } + + /** + * Returns a serial index number for the month. + * + * @return The serial index number. + */ + @Override + public long getSerialIndex() { + return this.year * 12L + this.month; + } + + /** + * Returns a string representing the month (e.g. "January 2002"). + *

+ * To do: look at internationalisation. + * + * @return A string representing the month. + */ + @Override + public String toString() { + return SerialDate.monthCodeToString(this.month) + " " + this.year; + } + + /** + * Tests the equality of this Month object to an arbitrary object. + * Returns true if the target is a Month instance representing the same + * month as this object. In all other cases, returns false. + * + * @param obj the object (null permitted). + * + * @return true if month and year of this and object are the + * same. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Month)) { + return false; + } + Month that = (Month) obj; + if (this.month != that.month) { + return false; + } + if (this.year != that.year) { + return false; + } + return true; + } + + /** + * Returns a hash code for this object instance. The approach described by + * Joshua Bloch in "Effective Java" has been used here: + *

+ * http://developer.java.sun.com/developer/Books/effectivejava + * /Chapter3.pdf + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 17; + result = 37 * result + this.month; + result = 37 * result + this.year; + return result; + } + + /** + * Returns an integer indicating the order of this Month object relative to + * the specified + * object: negative == before, zero == same, positive == after. + * + * @param o1 the object to compare. + * + * @return negative == before, zero == same, positive == after. + */ + @Override + public int compareTo(Object o1) { + + int result; + + // CASE 1 : Comparing to another Month object + // -------------------------------------------- + if (o1 instanceof Month) { + Month m = (Month) o1; + result = this.year - m.getYearValue(); + if (result == 0) { + result = this.month - m.getMonth(); + } + } + + // CASE 2 : Comparing to another TimePeriod object + // ----------------------------------------------- + else if (o1 instanceof RegularTimePeriod) { + // more difficult case - evaluate later... + result = 0; + } + + // CASE 3 : Comparing to a non-TimePeriod object + // --------------------------------------------- + else { + // consider time periods to be ordered after general objects + result = 1; + } + + return result; + + } + + /** + * Returns the first millisecond of the month, evaluated using the supplied + * calendar (which determines the time zone). + * + * @param calendar the calendar (null not permitted). + * + * @return The first millisecond of the month. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getFirstMillisecond(Calendar calendar) { + calendar.set(this.year, this.month - 1, 1, 0, 0, 0); + calendar.set(Calendar.MILLISECOND, 0); + return calendar.getTimeInMillis(); + } + + /** + * Returns the last millisecond of the month, evaluated using the supplied + * calendar (which determines the time zone). + * + * @param calendar the calendar (null not permitted). + * + * @return The last millisecond of the month. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getLastMillisecond(Calendar calendar) { + int eom = SerialDate.lastDayOfMonth(this.month, this.year); + calendar.set(this.year, this.month - 1, eom, 23, 59, 59); + calendar.set(Calendar.MILLISECOND, 999); + return calendar.getTimeInMillis(); + } + + /** + * Parses the string argument as a month. This method is required to + * accept the format "YYYY-MM". It will also accept "MM-YYYY". Anything + * else, at the moment, is a bonus. + * + * @param s the string to parse (null permitted). + * + * @return null if the string is not parseable, the month + * otherwise. + */ + public static Month parseMonth(String s) { + Month result = null; + if (s == null) { + return result; + } + // trim whitespace from either end of the string + s = s.trim(); + int i = Month.findSeparator(s); + String s1, s2; + boolean yearIsFirst; + // if there is no separator, we assume the first four characters + // are YYYY + if (i == -1) { + yearIsFirst = true; + s1 = s.substring(0, 5); + s2 = s.substring(5); + } + else { + s1 = s.substring(0, i).trim(); + s2 = s.substring(i + 1, s.length()).trim(); + // now it is trickier to determine if the month or year is first + Year y1 = Month.evaluateAsYear(s1); + if (y1 == null) { + yearIsFirst = false; + } + else { + Year y2 = Month.evaluateAsYear(s2); + if (y2 == null) { + yearIsFirst = true; + } + else { + yearIsFirst = (s1.length() > s2.length()); + } + } + } + Year year; + int month; + if (yearIsFirst) { + year = Month.evaluateAsYear(s1); + month = SerialDate.stringToMonthCode(s2); + } + else { + year = Month.evaluateAsYear(s2); + month = SerialDate.stringToMonthCode(s1); + } + if (month == -1) { + throw new TimePeriodFormatException("Can't evaluate the month."); + } + if (year == null) { + throw new TimePeriodFormatException("Can't evaluate the year."); + } + result = new Month(month, year); + return result; + } + + /** + * Finds the first occurrence of '-', or if that character is not found, + * the first occurrence of ',', or the first occurrence of ' ' or '.' + * + * @param s the string to parse. + * + * @return The position of the separator character, or -1 if + * none of the characters were found. + */ + private static int findSeparator(String s) { + int result = s.indexOf('-'); + if (result == -1) { + result = s.indexOf(','); + } + if (result == -1) { + result = s.indexOf(' '); + } + if (result == -1) { + result = s.indexOf('.'); + } + return result; + } + + /** + * Creates a year from a string, or returns null (format + * exceptions suppressed). + * + * @param s the string to parse. + * + * @return null if the string is not parseable, the year + * otherwise. + */ + private static Year evaluateAsYear(String s) { + Year result = null; + try { + result = Year.parseYear(s); + } + catch (TimePeriodFormatException e) { + // suppress + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/MovingAverage.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/MovingAverage.java new file mode 100755 index 0000000..30cab87 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/MovingAverage.java @@ -0,0 +1,348 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * MovingAverage.java + * ------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Benoit Xhenseval; + * + * Changes + * ------- + * 28-Jan-2003 : Version 1 (DG); + * 10-Mar-2003 : Added createPointMovingAverage() method contributed by Benoit + * Xhenseval (DG); + * 01-Aug-2003 : Added new method for TimeSeriesCollection, and fixed bug in + * XYDataset method (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * 09-Jun-2009 : Tidied up some calls to TimeSeries (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.time; + +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; + +/** + * A utility class for calculating moving averages of time series data. + */ +public class MovingAverage { + + /** + * Creates a new {@link TimeSeriesCollection} containing a moving average + * series for each series in the source collection. + * + * @param source the source collection. + * @param suffix the suffix added to each source series name to create the + * corresponding moving average series name. + * @param periodCount the number of periods in the moving average + * calculation. + * @param skip the number of initial periods to skip. + * + * @return A collection of moving average time series. + */ + public static TimeSeriesCollection createMovingAverage( + TimeSeriesCollection source, String suffix, int periodCount, + int skip) { + + ParamChecks.nullNotPermitted(source, "source"); + if (periodCount < 1) { + throw new IllegalArgumentException("periodCount must be greater " + + "than or equal to 1."); + } + + TimeSeriesCollection result = new TimeSeriesCollection(); + for (int i = 0; i < source.getSeriesCount(); i++) { + TimeSeries sourceSeries = source.getSeries(i); + TimeSeries maSeries = createMovingAverage(sourceSeries, + sourceSeries.getKey() + suffix, periodCount, skip); + result.addSeries(maSeries); + } + return result; + + } + + /** + * Creates a new {@link TimeSeries} containing moving average values for + * the given series. If the series is empty (contains zero items), the + * result is an empty series. + * + * @param source the source series. + * @param name the name of the new series. + * @param periodCount the number of periods used in the average + * calculation. + * @param skip the number of initial periods to skip. + * + * @return The moving average series. + */ + public static TimeSeries createMovingAverage(TimeSeries source, + String name, int periodCount, int skip) { + + ParamChecks.nullNotPermitted(source, "source"); + if (periodCount < 1) { + throw new IllegalArgumentException("periodCount must be greater " + + "than or equal to 1."); + } + + TimeSeries result = new TimeSeries(name); + + if (source.getItemCount() > 0) { + + // if the initial averaging period is to be excluded, then + // calculate the index of the + // first data item to have an average calculated... + long firstSerial = source.getTimePeriod(0).getSerialIndex() + skip; + + for (int i = source.getItemCount() - 1; i >= 0; i--) { + + // get the current data item... + RegularTimePeriod period = source.getTimePeriod(i); + long serial = period.getSerialIndex(); + + if (serial >= firstSerial) { + // work out the average for the earlier values... + int n = 0; + double sum = 0.0; + long serialLimit = period.getSerialIndex() - periodCount; + int offset = 0; + boolean finished = false; + + while ((offset < periodCount) && (!finished)) { + if ((i - offset) >= 0) { + TimeSeriesDataItem item = source.getRawDataItem( + i - offset); + RegularTimePeriod p = item.getPeriod(); + Number v = item.getValue(); + long currentIndex = p.getSerialIndex(); + if (currentIndex > serialLimit) { + if (v != null) { + sum = sum + v.doubleValue(); + n = n + 1; + } + } + else { + finished = true; + } + } + offset = offset + 1; + } + if (n > 0) { + result.add(period, sum / n); + } + else { + result.add(period, null); + } + } + + } + } + + return result; + + } + + /** + * Creates a new {@link TimeSeries} containing moving average values for + * the given series, calculated by number of points (irrespective of the + * 'age' of those points). If the series is empty (contains zero items), + * the result is an empty series. + *

+ * Developed by Benoit Xhenseval (www.ObjectLab.co.uk). + * + * @param source the source series. + * @param name the name of the new series. + * @param pointCount the number of POINTS used in the average calculation + * (not periods!) + * + * @return The moving average series. + */ + public static TimeSeries createPointMovingAverage(TimeSeries source, + String name, int pointCount) { + + ParamChecks.nullNotPermitted(source, "source"); + if (pointCount < 2) { + throw new IllegalArgumentException("periodCount must be greater " + + "than or equal to 2."); + } + + TimeSeries result = new TimeSeries(name); + double rollingSumForPeriod = 0.0; + for (int i = 0; i < source.getItemCount(); i++) { + // get the current data item... + TimeSeriesDataItem current = source.getRawDataItem(i); + RegularTimePeriod period = current.getPeriod(); + // FIXME: what if value is null on next line? + rollingSumForPeriod += current.getValue().doubleValue(); + + if (i > pointCount - 1) { + // remove the point i-periodCount out of the rolling sum. + TimeSeriesDataItem startOfMovingAvg = source.getRawDataItem( + i - pointCount); + rollingSumForPeriod -= startOfMovingAvg.getValue() + .doubleValue(); + result.add(period, rollingSumForPeriod / pointCount); + } + else if (i == pointCount - 1) { + result.add(period, rollingSumForPeriod / pointCount); + } + } + return result; + } + + /** + * Creates a new {@link XYDataset} containing the moving averages of each + * series in the source dataset. + * + * @param source the source dataset. + * @param suffix the string to append to source series names to create + * target series names. + * @param period the averaging period. + * @param skip the length of the initial skip period. + * + * @return The dataset. + */ + public static XYDataset createMovingAverage(XYDataset source, String suffix, + long period, long skip) { + + return createMovingAverage(source, suffix, (double) period, + (double) skip); + + } + + + /** + * Creates a new {@link XYDataset} containing the moving averages of each + * series in the source dataset. + * + * @param source the source dataset. + * @param suffix the string to append to source series names to create + * target series names. + * @param period the averaging period. + * @param skip the length of the initial skip period. + * + * @return The dataset. + */ + public static XYDataset createMovingAverage(XYDataset source, + String suffix, double period, double skip) { + + ParamChecks.nullNotPermitted(source, "source"); + XYSeriesCollection result = new XYSeriesCollection(); + for (int i = 0; i < source.getSeriesCount(); i++) { + XYSeries s = createMovingAverage(source, i, source.getSeriesKey(i) + + suffix, period, skip); + result.addSeries(s); + } + return result; + } + + /** + * Creates a new {@link XYSeries} containing the moving averages of one + * series in the source dataset. + * + * @param source the source dataset. + * @param series the series index (zero based). + * @param name the name for the new series. + * @param period the averaging period. + * @param skip the length of the initial skip period. + * + * @return The dataset. + */ + public static XYSeries createMovingAverage(XYDataset source, + int series, String name, double period, double skip) { + + ParamChecks.nullNotPermitted(source, "source"); + if (period < Double.MIN_VALUE) { + throw new IllegalArgumentException("period must be positive."); + } + if (skip < 0.0) { + throw new IllegalArgumentException("skip must be >= 0.0."); + } + + XYSeries result = new XYSeries(name); + + if (source.getItemCount(series) > 0) { + + // if the initial averaging period is to be excluded, then + // calculate the lowest x-value to have an average calculated... + double first = source.getXValue(series, 0) + skip; + + for (int i = source.getItemCount(series) - 1; i >= 0; i--) { + + // get the current data item... + double x = source.getXValue(series, i); + + if (x >= first) { + // work out the average for the earlier values... + int n = 0; + double sum = 0.0; + double limit = x - period; + int offset = 0; + boolean finished = false; + + while (!finished) { + if ((i - offset) >= 0) { + double xx = source.getXValue(series, i - offset); + Number yy = source.getY(series, i - offset); + if (xx > limit) { + if (yy != null) { + sum = sum + yy.doubleValue(); + n = n + 1; + } + } + else { + finished = true; + } + } + else { + finished = true; + } + offset = offset + 1; + } + if (n > 0) { + result.add(x, sum / n); + } + else { + result.add(x, null); + } + } + + } + } + + return result; + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Quarter.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Quarter.java new file mode 100755 index 0000000..aa94c4b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Quarter.java @@ -0,0 +1,499 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------ + * Quarter.java + * ------------ + * (C) Copyright 2001-2012, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-Oct-2001 : Version 1 (DG); + * 18-Dec-2001 : Changed order of parameters in constructor (DG); + * 19-Dec-2001 : Added a new constructor as suggested by Paul English (DG); + * 29-Jan-2002 : Added a new method parseQuarter(String) (DG); + * 14-Feb-2002 : Fixed bug in Quarter(Date) constructor (DG); + * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to + * evaluate with reference to a particular time zone (DG); + * 19-Mar-2002 : Changed API for TimePeriod classes (DG); + * 24-Jun-2002 : Removed main method (just test code) (DG); + * 10-Sep-2002 : Added getSerialIndex() method (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 10-Jan-2003 : Changed base class and method names (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package, and implemented + * Serializable (DG); + * 21-Oct-2003 : Added hashCode() method (DG); + * 10-Dec-2005 : Fixed argument checking bug (1377239) in constructor (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 05-Oct-2006 : Updated API docs (DG); + * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); + * 25-Nov-2008 : Added new constructor with Locale (DG); + * 05-Jul-2012 : REmoved JDK 1.3.1 supporting code (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +import org.jfree.date.MonthConstants; +import org.jfree.date.SerialDate; + +/** + * Defines a quarter (in a given year). The range supported is Q1 1900 to + * Q4 9999. This class is immutable, which is a requirement for all + * {@link RegularTimePeriod} subclasses. + */ +public class Quarter extends RegularTimePeriod implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 3810061714380888671L; + + /** Constant for quarter 1. */ + public static final int FIRST_QUARTER = 1; + + /** Constant for quarter 4. */ + public static final int LAST_QUARTER = 4; + + /** The first month in each quarter. */ + public static final int[] FIRST_MONTH_IN_QUARTER = { + 0, MonthConstants.JANUARY, MonthConstants.APRIL, MonthConstants.JULY, + MonthConstants.OCTOBER + }; + + /** The last month in each quarter. */ + public static final int[] LAST_MONTH_IN_QUARTER = { + 0, MonthConstants.MARCH, MonthConstants.JUNE, MonthConstants.SEPTEMBER, + MonthConstants.DECEMBER + }; + + /** The year in which the quarter falls. */ + private short year; + + /** The quarter (1-4). */ + private byte quarter; + + /** The first millisecond. */ + private long firstMillisecond; + + /** The last millisecond. */ + private long lastMillisecond; + + /** + * Constructs a new Quarter, based on the current system date/time. + */ + public Quarter() { + this(new Date()); + } + + /** + * Constructs a new quarter. + * + * @param year the year (1900 to 9999). + * @param quarter the quarter (1 to 4). + */ + public Quarter(int quarter, int year) { + if ((quarter < FIRST_QUARTER) || (quarter > LAST_QUARTER)) { + throw new IllegalArgumentException("Quarter outside valid range."); + } + this.year = (short) year; + this.quarter = (byte) quarter; + peg(Calendar.getInstance()); + } + + /** + * Constructs a new quarter. + * + * @param quarter the quarter (1 to 4). + * @param year the year (1900 to 9999). + */ + public Quarter(int quarter, Year year) { + if ((quarter < FIRST_QUARTER) || (quarter > LAST_QUARTER)) { + throw new IllegalArgumentException("Quarter outside valid range."); + } + this.year = (short) year.getYear(); + this.quarter = (byte) quarter; + peg(Calendar.getInstance()); + } + + /** + * Constructs a new instance, based on a date/time and the default time + * zone. + * + * @param time the date/time (null not permitted). + * + * @see #Quarter(Date, TimeZone) + */ + public Quarter(Date time) { + this(time, TimeZone.getDefault()); + } + + /** + * Constructs a Quarter, based on a date/time and time zone. + * + * @param time the date/time. + * @param zone the zone (null not permitted). + * + * @deprecated Since 1.0.12, use {@link #Quarter(Date, TimeZone, Locale)} + * instead. + */ + public Quarter(Date time, TimeZone zone) { + this(time, zone, Locale.getDefault()); + } + + /** + * Creates a new Quarter instance, using the specified + * zone and locale. + * + * @param time the current time. + * @param zone the time zone. + * @param locale the locale. + * + * @since 1.0.12 + */ + public Quarter(Date time, TimeZone zone, Locale locale) { + Calendar calendar = Calendar.getInstance(zone, locale); + calendar.setTime(time); + int month = calendar.get(Calendar.MONTH) + 1; + this.quarter = (byte) SerialDate.monthCodeToQuarter(month); + this.year = (short) calendar.get(Calendar.YEAR); + peg(calendar); + } + + /** + * Returns the quarter. + * + * @return The quarter. + */ + public int getQuarter() { + return this.quarter; + } + + /** + * Returns the year. + * + * @return The year. + */ + public Year getYear() { + return new Year(this.year); + } + + /** + * Returns the year. + * + * @return The year. + * + * @since 1.0.3 + */ + public int getYearValue() { + return this.year; + } + + /** + * Returns the first millisecond of the quarter. This will be determined + * relative to the time zone specified in the constructor, or in the + * calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The first millisecond of the quarter. + * + * @see #getLastMillisecond() + */ + @Override + public long getFirstMillisecond() { + return this.firstMillisecond; + } + + /** + * Returns the last millisecond of the quarter. This will be + * determined relative to the time zone specified in the constructor, or + * in the calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The last millisecond of the quarter. + * + * @see #getFirstMillisecond() + */ + @Override + public long getLastMillisecond() { + return this.lastMillisecond; + } + + /** + * Recalculates the start date/time and end date/time for this time period + * relative to the supplied calendar (which incorporates a time zone). + * + * @param calendar the calendar (null not permitted). + * + * @since 1.0.3 + */ + @Override + public void peg(Calendar calendar) { + this.firstMillisecond = getFirstMillisecond(calendar); + this.lastMillisecond = getLastMillisecond(calendar); + } + + /** + * Returns the quarter preceding this one. + * + * @return The quarter preceding this one (or null if this is + * Q1 1900). + */ + @Override + public RegularTimePeriod previous() { + Quarter result; + if (this.quarter > FIRST_QUARTER) { + result = new Quarter(this.quarter - 1, this.year); + } + else { + if (this.year > 1900) { + result = new Quarter(LAST_QUARTER, this.year - 1); + } + else { + result = null; + } + } + return result; + } + + /** + * Returns the quarter following this one. + * + * @return The quarter following this one (or null if this is Q4 9999). + */ + @Override + public RegularTimePeriod next() { + Quarter result; + if (this.quarter < LAST_QUARTER) { + result = new Quarter(this.quarter + 1, this.year); + } + else { + if (this.year < 9999) { + result = new Quarter(FIRST_QUARTER, this.year + 1); + } + else { + result = null; + } + } + return result; + } + + /** + * Returns a serial index number for the quarter. + * + * @return The serial index number. + */ + @Override + public long getSerialIndex() { + return this.year * 4L + this.quarter; + } + + /** + * Tests the equality of this Quarter object to an arbitrary object. + * Returns true if the target is a Quarter instance + * representing the same quarter as this object. In all other cases, + * returns false. + * + * @param obj the object (null permitted). + * + * @return true if quarter and year of this and the object are + * the same. + */ + @Override + public boolean equals(Object obj) { + + if (obj != null) { + if (obj instanceof Quarter) { + Quarter target = (Quarter) obj; + return (this.quarter == target.getQuarter() + && (this.year == target.getYearValue())); + } + else { + return false; + } + } + else { + return false; + } + + } + + /** + * Returns a hash code for this object instance. The approach described by + * Joshua Bloch in "Effective Java" has been used here: + *

+ * http://developer.java.sun.com/developer/Books/effectivejava + * /Chapter3.pdf + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 17; + result = 37 * result + this.quarter; + result = 37 * result + this.year; + return result; + } + + /** + * Returns an integer indicating the order of this Quarter object relative + * to the specified object: + * + * negative == before, zero == same, positive == after. + * + * @param o1 the object to compare + * + * @return negative == before, zero == same, positive == after. + */ + @Override + public int compareTo(Object o1) { + + int result; + + // CASE 1 : Comparing to another Quarter object + // -------------------------------------------- + if (o1 instanceof Quarter) { + Quarter q = (Quarter) o1; + result = this.year - q.getYearValue(); + if (result == 0) { + result = this.quarter - q.getQuarter(); + } + } + + // CASE 2 : Comparing to another TimePeriod object + // ----------------------------------------------- + else if (o1 instanceof RegularTimePeriod) { + // more difficult case - evaluate later... + result = 0; + } + + // CASE 3 : Comparing to a non-TimePeriod object + // --------------------------------------------- + else { + // consider time periods to be ordered after general objects + result = 1; + } + + return result; + + } + + /** + * Returns a string representing the quarter (e.g. "Q1/2002"). + * + * @return A string representing the quarter. + */ + @Override + public String toString() { + return "Q" + this.quarter + "/" + this.year; + } + + /** + * Returns the first millisecond in the Quarter, evaluated using the + * supplied calendar (which determines the time zone). + * + * @param calendar the calendar (null not permitted). + * + * @return The first millisecond in the Quarter. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getFirstMillisecond(Calendar calendar) { + int month = Quarter.FIRST_MONTH_IN_QUARTER[this.quarter]; + calendar.set(this.year, month - 1, 1, 0, 0, 0); + calendar.set(Calendar.MILLISECOND, 0); + return calendar.getTimeInMillis(); + } + + /** + * Returns the last millisecond of the Quarter, evaluated using the + * supplied calendar (which determines the time zone). + * + * @param calendar the calendar (null not permitted). + * + * @return The last millisecond of the Quarter. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getLastMillisecond(Calendar calendar) { + int month = Quarter.LAST_MONTH_IN_QUARTER[this.quarter]; + int eom = SerialDate.lastDayOfMonth(month, this.year); + calendar.set(this.year, month - 1, eom, 23, 59, 59); + calendar.set(Calendar.MILLISECOND, 999); + return calendar.getTimeInMillis(); + } + + /** + * Parses the string argument as a quarter. + *

+ * This method should accept the following formats: "YYYY-QN" and "QN-YYYY", + * where the "-" can be a space, a forward-slash (/), comma or a dash (-). + * @param s A string representing the quarter. + * + * @return The quarter. + */ + public static Quarter parseQuarter(String s) { + + // find the Q and the integer following it (remove both from the + // string)... + int i = s.indexOf("Q"); + if (i == -1) { + throw new TimePeriodFormatException("Missing Q."); + } + + if (i == s.length() - 1) { + throw new TimePeriodFormatException("Q found at end of string."); + } + + String qstr = s.substring(i + 1, i + 2); + int quarter = Integer.parseInt(qstr); + String remaining = s.substring(0, i) + s.substring(i + 2, s.length()); + + // replace any / , or - with a space + remaining = remaining.replace('/', ' '); + remaining = remaining.replace(',', ' '); + remaining = remaining.replace('-', ' '); + + // parse the string... + Year year = Year.parseYear(remaining.trim()); + Quarter result = new Quarter(quarter, year); + return result; + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/RegularTimePeriod.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/RegularTimePeriod.java new file mode 100755 index 0000000..1eb5ce4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/RegularTimePeriod.java @@ -0,0 +1,354 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * RegularTimePeriod.java + * ---------------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-Oct-2001 : Version 1 (DG); + * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to + * evaluate with reference to a particular time zone (DG); + * 29-May-2002 : Implemented MonthConstants interface, so that these constants + * are conveniently available (DG); + * 10-Sep-2002 : Added getSerialIndex() method (DG); + * 10-Jan-2003 : Renamed TimePeriod --> RegularTimePeriod (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package (DG); + * 29-Apr-2004 : Changed getMiddleMillisecond() methods to fix bug 943985 (DG); + * 25-Nov-2004 : Added utility methods (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 06-Oct-2006 : Deprecated the WORKING_CALENDAR field and several methods, + * added new peg() method (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); + * + */ + +package org.jfree.data.time; + +import java.lang.reflect.Constructor; +import java.util.Calendar; +import java.util.Date; +import java.util.TimeZone; + +import org.jfree.date.MonthConstants; + +/** + * An abstract class representing a unit of time. Convenient methods are + * provided for calculating the next and previous time periods. Conversion + * methods are defined that return the first and last milliseconds of the time + * period. The results from these methods are timezone dependent. + *

+ * This class is immutable, and all subclasses should be immutable also. + */ +public abstract class RegularTimePeriod implements TimePeriod, Comparable, + MonthConstants { + + /** + * Creates a time period that includes the specified millisecond, assuming + * the given time zone. + * + * @param c the time period class. + * @param millisecond the time. + * @param zone the time zone. + * + * @return The time period. + */ + public static RegularTimePeriod createInstance(Class c, Date millisecond, + TimeZone zone) { + RegularTimePeriod result = null; + try { + Constructor constructor = c.getDeclaredConstructor( + new Class[] {Date.class, TimeZone.class}); + result = (RegularTimePeriod) constructor.newInstance( + new Object[] {millisecond, zone}); + } + catch (Exception e) { + // do nothing, so null is returned + } + return result; + } + + /** + * Returns a subclass of {@link RegularTimePeriod} that is smaller than + * the specified class. + * + * @param c a subclass of {@link RegularTimePeriod}. + * + * @return A class. + */ + public static Class downsize(Class c) { + if (c.equals(Year.class)) { + return Quarter.class; + } + else if (c.equals(Quarter.class)) { + return Month.class; + } + else if (c.equals(Month.class)) { + return Day.class; + } + else if (c.equals(Day.class)) { + return Hour.class; + } + else if (c.equals(Hour.class)) { + return Minute.class; + } + else if (c.equals(Minute.class)) { + return Second.class; + } + else if (c.equals(Second.class)) { + return Millisecond.class; + } + else { + return Millisecond.class; + } + } + + /** + * Returns the time period preceding this one, or null if some + * lower limit has been reached. + * + * @return The previous time period (possibly null). + */ + public abstract RegularTimePeriod previous(); + + /** + * Returns the time period following this one, or null if some + * limit has been reached. + * + * @return The next time period (possibly null). + */ + public abstract RegularTimePeriod next(); + + /** + * Returns a serial index number for the time unit. + * + * @return The serial index number. + */ + public abstract long getSerialIndex(); + + ////////////////////////////////////////////////////////////////////////// + + /** + * The default time zone. + * + * @deprecated As of 1.0.11, we discourage the use of this field - use + * {@link TimeZone#getDefault()} instead. + */ + public static final TimeZone DEFAULT_TIME_ZONE = TimeZone.getDefault(); + + /** + * A working calendar (recycle to avoid unnecessary object creation). + * + * @deprecated This was a bad idea, don't use it! + */ + public static final Calendar WORKING_CALENDAR = Calendar.getInstance( + DEFAULT_TIME_ZONE); + + /** + * Recalculates the start date/time and end date/time for this time period + * relative to the supplied calendar (which incorporates a time zone). + * + * @param calendar the calendar (null not permitted). + * + * @since 1.0.3 + */ + public abstract void peg(Calendar calendar); + + /** + * Returns the date/time that marks the start of the time period. This + * method returns a new Date instance every time it is called. + * + * @return The start date/time. + * + * @see #getFirstMillisecond() + */ + @Override + public Date getStart() { + return new Date(getFirstMillisecond()); + } + + /** + * Returns the date/time that marks the end of the time period. This + * method returns a new Date instance every time it is called. + * + * @return The end date/time. + * + * @see #getLastMillisecond() + */ + @Override + public Date getEnd() { + return new Date(getLastMillisecond()); + } + + /** + * Returns the first millisecond of the time period. This will be + * determined relative to the time zone specified in the constructor, or + * in the calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The first millisecond of the time period. + * + * @see #getLastMillisecond() + */ + public abstract long getFirstMillisecond(); + + /** + * Returns the first millisecond of the time period, evaluated within a + * specific time zone. + * + * @param zone the time zone (null not permitted). + * + * @return The first millisecond of the time period. + * + * @deprecated As of 1.0.3, you should avoid using this method (it creates + * a new Calendar instance every time it is called). You are advised + * to call {@link #getFirstMillisecond(Calendar)} instead. + * + * @see #getLastMillisecond(TimeZone) + */ + public long getFirstMillisecond(TimeZone zone) { + Calendar calendar = Calendar.getInstance(zone); + return getFirstMillisecond(calendar); + } + + /** + * Returns the first millisecond of the time period, evaluated using the + * supplied calendar (which incorporates a timezone). + * + * @param calendar the calendar (null not permitted). + * + * @return The first millisecond of the time period. + * + * @throws NullPointerException if calendar,/code> is + * null. + * + * @see #getLastMillisecond(Calendar) + */ + public abstract long getFirstMillisecond(Calendar calendar); + + /** + * Returns the last millisecond of the time period. This will be + * determined relative to the time zone specified in the constructor, or + * in the calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The last millisecond of the time period. + * + * @see #getFirstMillisecond() + */ + public abstract long getLastMillisecond(); + + /** + * Returns the last millisecond of the time period, evaluated within a + * specific time zone. + * + * @param zone the time zone (null not permitted). + * + * @return The last millisecond of the time period. + * + * @deprecated As of 1.0.3, you should avoid using this method (it creates + * a new Calendar instance every time it is called). You are advised + * to call {@link #getLastMillisecond(Calendar)} instead. + * + * @see #getFirstMillisecond(TimeZone) + */ + public long getLastMillisecond(TimeZone zone) { + Calendar calendar = Calendar.getInstance(zone); + return getLastMillisecond(calendar); + } + + /** + * Returns the last millisecond of the time period, evaluated using the + * supplied calendar (which incorporates a timezone). + * + * @param calendar the calendar (null not permitted). + * + * @return The last millisecond of the time period. + * + * @see #getFirstMillisecond(Calendar) + */ + public abstract long getLastMillisecond(Calendar calendar); + + /** + * Returns the millisecond closest to the middle of the time period. + * + * @return The middle millisecond. + */ + public long getMiddleMillisecond() { + long m1 = getFirstMillisecond(); + long m2 = getLastMillisecond(); + return m1 + (m2 - m1) / 2; + } + + /** + * Returns the millisecond closest to the middle of the time period, + * evaluated within a specific time zone. + * + * @param zone the time zone (null not permitted). + * + * @return The middle millisecond. + * + * @deprecated As of 1.0.3, you should avoid using this method (it creates + * a new Calendar instance every time it is called). You are advised + * to call {@link #getMiddleMillisecond(Calendar)} instead. + */ + public long getMiddleMillisecond(TimeZone zone) { + Calendar calendar = Calendar.getInstance(zone); + long m1 = getFirstMillisecond(calendar); + long m2 = getLastMillisecond(calendar); + return m1 + (m2 - m1) / 2; + } + + /** + * Returns the millisecond closest to the middle of the time period, + * evaluated using the supplied calendar (which incorporates a timezone). + * + * @param calendar the calendar. + * + * @return The middle millisecond. + */ + public long getMiddleMillisecond(Calendar calendar) { + long m1 = getFirstMillisecond(calendar); + long m2 = getLastMillisecond(calendar); + return m1 + (m2 - m1) / 2; + } + + /** + * Returns a string representation of the time period. + * + * @return The string. + */ + @Override + public String toString() { + return String.valueOf(getStart()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Second.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Second.java new file mode 100755 index 0000000..fa5d27e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Second.java @@ -0,0 +1,475 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------- + * Second.java + * ----------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-Oct-2001 : Version 1 (DG); + * 18-Dec-2001 : Changed order of parameters in constructor (DG); + * 19-Dec-2001 : Added a new constructor as suggested by Paul English (DG); + * 14-Feb-2002 : Fixed bug in Second(Date) constructor, and changed start of + * range to zero from one (DG); + * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to + * evaluate with reference to a particular time zone (DG); + * 13-Mar-2002 : Added parseSecond() method (DG); + * 10-Sep-2002 : Added getSerialIndex() method (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 10-Jan-2003 : Changed base class and method names (DG); + * 05-Mar-2003 : Fixed bug in getLastMillisecond() picked up in JUnit + * tests (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package and implemented + * Serializable (DG); + * 21-Oct-2003 : Added hashCode() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 05-Oct-2006 : Updated API docs (DG); + * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); + * 02-Mar-2009 : Added new constructor with Locale (DG); + * 05-Jul-2012 : Replaced getTime().getTime() with getTimeInMillis() (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; +import org.jfree.chart.util.ParamChecks; + +/** + * Represents a second in a particular day. This class is immutable, which is + * a requirement for all {@link RegularTimePeriod} subclasses. + */ +public class Second extends RegularTimePeriod implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -6536564190712383466L; + + /** Useful constant for the first second in a minute. */ + public static final int FIRST_SECOND_IN_MINUTE = 0; + + /** Useful constant for the last second in a minute. */ + public static final int LAST_SECOND_IN_MINUTE = 59; + + /** The day. */ + private Day day; + + /** The hour of the day. */ + private byte hour; + + /** The minute. */ + private byte minute; + + /** The second. */ + private byte second; + + /** + * The first millisecond. We don't store the last millisecond, because it + * is always firstMillisecond + 999L. + */ + private long firstMillisecond; + + /** + * Constructs a new Second, based on the system date/time. + */ + public Second() { + this(new Date()); + } + + /** + * Constructs a new Second. + * + * @param second the second (0 to 24*60*60-1). + * @param minute the minute (null not permitted). + */ + public Second(int second, Minute minute) { + ParamChecks.nullNotPermitted(minute, "minute"); + this.day = minute.getDay(); + this.hour = (byte) minute.getHourValue(); + this.minute = (byte) minute.getMinute(); + this.second = (byte) second; + peg(Calendar.getInstance()); + } + + /** + * Creates a new second. + * + * @param second the second (0-59). + * @param minute the minute (0-59). + * @param hour the hour (0-23). + * @param day the day (1-31). + * @param month the month (1-12). + * @param year the year (1900-9999). + */ + public Second(int second, int minute, int hour, + int day, int month, int year) { + this(second, new Minute(minute, hour, day, month, year)); + } + + /** + * Constructs a new instance from the specified date/time and the default + * time zone.. + * + * @param time the time (null not permitted). + * + * @see #Second(Date, TimeZone) + */ + public Second(Date time) { + this(time, TimeZone.getDefault(), Locale.getDefault()); + } + + /** + * Creates a new second based on the supplied time and time zone. + * + * @param time the instant in time. + * @param zone the time zone. + * + * @deprecated As of 1.0.13, use the constructor that specifies the locale + * also. + */ + public Second(Date time, TimeZone zone) { + this(time, zone, Locale.getDefault()); + } + + /** + * Creates a new second based on the supplied time and time zone. + * + * @param time the time (null not permitted). + * @param zone the time zone (null not permitted). + * @param locale the locale (null not permitted). + * + * @since 1.0.13 + */ + public Second(Date time, TimeZone zone, Locale locale) { + Calendar calendar = Calendar.getInstance(zone, locale); + calendar.setTime(time); + this.second = (byte) calendar.get(Calendar.SECOND); + this.minute = (byte) calendar.get(Calendar.MINUTE); + this.hour = (byte) calendar.get(Calendar.HOUR_OF_DAY); + this.day = new Day(time, zone, locale); + peg(calendar); + } + + /** + * Returns the second within the minute. + * + * @return The second (0 - 59). + */ + public int getSecond() { + return this.second; + } + + /** + * Returns the minute. + * + * @return The minute (never null). + */ + public Minute getMinute() { + return new Minute(this.minute, new Hour(this.hour, this.day)); + } + + /** + * Returns the first millisecond of the second. This will be determined + * relative to the time zone specified in the constructor, or in the + * calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The first millisecond of the second. + * + * @see #getLastMillisecond() + */ + @Override + public long getFirstMillisecond() { + return this.firstMillisecond; + } + + /** + * Returns the last millisecond of the second. This will be + * determined relative to the time zone specified in the constructor, or + * in the calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The last millisecond of the second. + * + * @see #getFirstMillisecond() + */ + @Override + public long getLastMillisecond() { + return this.firstMillisecond + 999L; + } + + /** + * Recalculates the start date/time and end date/time for this time period + * relative to the supplied calendar (which incorporates a time zone). + * + * @param calendar the calendar (null not permitted). + * + * @since 1.0.3 + */ + @Override + public void peg(Calendar calendar) { + this.firstMillisecond = getFirstMillisecond(calendar); + } + + /** + * Returns the second preceding this one. + * + * @return The second preceding this one. + */ + @Override + public RegularTimePeriod previous() { + Second result = null; + if (this.second != FIRST_SECOND_IN_MINUTE) { + result = new Second(this.second - 1, getMinute()); + } + else { + Minute previous = (Minute) getMinute().previous(); + if (previous != null) { + result = new Second(LAST_SECOND_IN_MINUTE, previous); + } + } + return result; + } + + /** + * Returns the second following this one. + * + * @return The second following this one. + */ + @Override + public RegularTimePeriod next() { + Second result = null; + if (this.second != LAST_SECOND_IN_MINUTE) { + result = new Second(this.second + 1, getMinute()); + } + else { + Minute next = (Minute) getMinute().next(); + if (next != null) { + result = new Second(FIRST_SECOND_IN_MINUTE, next); + } + } + return result; + } + + /** + * Returns a serial index number for the minute. + * + * @return The serial index number. + */ + @Override + public long getSerialIndex() { + long hourIndex = this.day.getSerialIndex() * 24L + this.hour; + long minuteIndex = hourIndex * 60L + this.minute; + return minuteIndex * 60L + this.second; + } + + /** + * Returns the first millisecond of the minute. + * + * @param calendar the calendar/timezone (null not permitted). + * + * @return The first millisecond. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getFirstMillisecond(Calendar calendar) { + int year = this.day.getYear(); + int month = this.day.getMonth() - 1; + int d = this.day.getDayOfMonth(); + calendar.clear(); + calendar.set(year, month, d, this.hour, this.minute, this.second); + calendar.set(Calendar.MILLISECOND, 0); + return calendar.getTimeInMillis(); + } + + /** + * Returns the last millisecond of the second. + * + * @param calendar the calendar/timezone (null not permitted). + * + * @return The last millisecond. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getLastMillisecond(Calendar calendar) { + return getFirstMillisecond(calendar) + 999L; + } + + /** + * Tests the equality of this object against an arbitrary Object. + *

+ * This method will return true ONLY if the object is a Second object + * representing the same second as this instance. + * + * @param obj the object to compare (null permitted). + * + * @return true if second and minute of this and the object + * are the same. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Second)) { + return false; + } + Second that = (Second) obj; + if (this.second != that.second) { + return false; + } + if (this.minute != that.minute) { + return false; + } + if (this.hour != that.hour) { + return false; + } + if (!this.day.equals(that.day)) { + return false; + } + return true; + } + + /** + * Returns a hash code for this object instance. The approach described by + * Joshua Bloch in "Effective Java" has been used here: + *

+ * http://developer.java.sun.com/developer/Books/effectivejava + * /Chapter3.pdf + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 17; + result = 37 * result + this.second; + result = 37 * result + this.minute; + result = 37 * result + this.hour; + result = 37 * result + this.day.hashCode(); + return result; + } + + /** + * Returns an integer indicating the order of this Second object relative + * to the specified + * object: negative == before, zero == same, positive == after. + * + * @param o1 the object to compare. + * + * @return negative == before, zero == same, positive == after. + */ + @Override + public int compareTo(Object o1) { + int result; + + // CASE 1 : Comparing to another Second object + // ------------------------------------------- + if (o1 instanceof Second) { + Second s = (Second) o1; + if (this.firstMillisecond < s.firstMillisecond) { + return -1; + } + else if (this.firstMillisecond > s.firstMillisecond) { + return 1; + } + else { + return 0; + } + } + + // CASE 2 : Comparing to another TimePeriod object + // ----------------------------------------------- + else if (o1 instanceof RegularTimePeriod) { + // more difficult case - evaluate later... + result = 0; + } + + // CASE 3 : Comparing to a non-TimePeriod object + // --------------------------------------------- + else { + // consider time periods to be ordered after general objects + result = 1; + } + + return result; + } + + /** + * Creates a new instance by parsing a string. The string is assumed to + * be in the format "YYYY-MM-DD HH:MM:SS", perhaps with leading or trailing + * whitespace. + * + * @param s the string to parse. + * + * @return The second, or null if the string is not parseable. + */ + public static Second parseSecond(String s) { + Second result = null; + s = s.trim(); + String daystr = s.substring(0, Math.min(10, s.length())); + Day day = Day.parseDay(daystr); + if (day != null) { + String hmsstr = s.substring(Math.min(daystr.length() + 1, + s.length()), s.length()); + hmsstr = hmsstr.trim(); + + int l = hmsstr.length(); + String hourstr = hmsstr.substring(0, Math.min(2, l)); + String minstr = hmsstr.substring(Math.min(3, l), Math.min(5, l)); + String secstr = hmsstr.substring(Math.min(6, l), Math.min(8, l)); + int hour = Integer.parseInt(hourstr); + + if ((hour >= 0) && (hour <= 23)) { + + int minute = Integer.parseInt(minstr); + if ((minute >= 0) && (minute <= 59)) { + + Minute m = new Minute(minute, new Hour(hour, day)); + int second = Integer.parseInt(secstr); + if ((second >= 0) && (second <= 59)) { + result = new Second(second, m); + } + } + } + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/SimpleTimePeriod.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/SimpleTimePeriod.java new file mode 100755 index 0000000..27aa056 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/SimpleTimePeriod.java @@ -0,0 +1,227 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * SimpleTimePeriod.java + * --------------------- + * (C) Copyright 2002-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 07-Oct-2002 : Added Javadocs (DG); + * 10-Jan-2003 : Renamed TimeAllocation --> SimpleTimePeriod (DG); + * 13-Mar-2003 : Added equals() method, and Serializable interface (DG); + * 21-Oct-2003 : Added hashCode() method (DG); + * 27-Jan-2005 : Implemented Comparable, to enable this class to be used + * in the TimeTableXYDataset class (DG); + * 02-Jun-2008 : Fixed problem with fields being mutable (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.util.Date; + +/** + * An arbitrary period of time, measured to millisecond precision using + * java.util.Date. + *

+ * This class is intentionally immutable (that is, once constructed, you cannot + * alter the start and end attributes). + */ +public class SimpleTimePeriod implements TimePeriod, Comparable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 8684672361131829554L; + + /** The start date/time. */ + private long start; + + /** The end date/time. */ + private long end; + + /** + * Creates a new time allocation. + * + * @param start the start date/time in milliseconds. + * @param end the end date/time in milliseconds. + */ + public SimpleTimePeriod(long start, long end) { + if (start > end) { + throw new IllegalArgumentException("Requires start <= end."); + } + this.start = start; + this.end = end; + } + + /** + * Creates a new time allocation. + * + * @param start the start date/time (null not permitted). + * @param end the end date/time (null not permitted). + */ + public SimpleTimePeriod(Date start, Date end) { + this(start.getTime(), end.getTime()); + } + + /** + * Returns the start date/time. + * + * @return The start date/time (never null). + */ + @Override + public Date getStart() { + return new Date(this.start); + } + + /** + * Returns the start date/time in milliseconds. + * + * @return The start. + * + * @since 1.0.10. + */ + public long getStartMillis() { + return this.start; + } + + /** + * Returns the end date/time. + * + * @return The end date/time (never null). + */ + @Override + public Date getEnd() { + return new Date(this.end); + } + + /** + * Returns the end date/time in milliseconds. + * + * @return The end. + * + * @since 1.0.10. + */ + public long getEndMillis() { + return this.end; + } + + /** + * Tests this time period instance for equality with an arbitrary object. + * The object is considered equal if it is an instance of {@link TimePeriod} + * and it has the same start and end dates. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TimePeriod)) { + return false; + } + TimePeriod that = (TimePeriod) obj; + if (!this.getStart().equals(that.getStart())) { + return false; + } + if (!this.getEnd().equals(that.getEnd())) { + return false; + } + return true; + } + + /** + * Returns an integer that indicates the relative ordering of two + * time periods. + * + * @param obj the object (null not permitted). + * + * @return An integer. + * + * @throws ClassCastException if obj is not an instance of + * {@link TimePeriod}. + */ + @Override + public int compareTo(Object obj) { + TimePeriod that = (TimePeriod) obj; + long t0 = getStart().getTime(); + long t1 = getEnd().getTime(); + long m0 = t0 + (t1 - t0) / 2L; + long t2 = that.getStart().getTime(); + long t3 = that.getEnd().getTime(); + long m1 = t2 + (t3 - t2) / 2L; + if (m0 < m1) { + return -1; + } + else if (m0 > m1) { + return 1; + } + else { + if (t0 < t2) { + return -1; + } + else if (t0 > t2) { + return 1; + } + else { + if (t1 < t3) { + return -1; + } + else if (t1 > t3) { + return 1; + } + else { + return 0; + } + } + } + } + + /** + * Returns a hash code for this object instance. The approach described by + * Joshua Bloch in "Effective Java" has been used here - see: + *

+ * http://developer.java.sun.com/ + * developer/Books/effectivejava/Chapter3.pdf + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 17; + result = 37 * result + (int) this.start; + result = 37 * result + (int) this.end; + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriod.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriod.java new file mode 100755 index 0000000..237ad32 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriod.java @@ -0,0 +1,69 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * TimePeriod.java + * --------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-Jan-2003 : Version 1 (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package (DG); + * 27-Jan-2005 : Implemented Comparable (DG); + * + */ + +package org.jfree.data.time; + +import java.util.Date; + +/** + * A period of time measured to millisecond precision using two instances of + * java.util.Date. + */ +public interface TimePeriod extends Comparable { + + /** + * Returns the start date/time. This will always be on or before the + * end date. + * + * @return The start date/time (never null). + */ + public Date getStart(); + + /** + * Returns the end date/time. This will always be on or after the + * start date. + * + * @return The end date/time (never null). + */ + public Date getEnd(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodAnchor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodAnchor.java new file mode 100755 index 0000000..7bb54d1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodAnchor.java @@ -0,0 +1,146 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * TimePeriodAnchor.java + * --------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 30-Jul-2003 : Version 1 (DG); + * 01-Mar-2004 : Added readResolve() method (DG); + * + */ + +package org.jfree.data.time; + +import java.io.ObjectStreamException; +import java.io.Serializable; + +/** + * Used to indicate one of three positions in a time period: + * START, MIDDLE and END. + */ +public final class TimePeriodAnchor implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 2011955697457548862L; + + /** Start of period. */ + public static final TimePeriodAnchor START + = new TimePeriodAnchor("TimePeriodAnchor.START"); + + /** Middle of period. */ + public static final TimePeriodAnchor MIDDLE + = new TimePeriodAnchor("TimePeriodAnchor.MIDDLE"); + + /** End of period. */ + public static final TimePeriodAnchor END + = new TimePeriodAnchor("TimePeriodAnchor.END"); + + /** The name. */ + private String name; + + /** + * Private constructor. + * + * @param name the name. + */ + private TimePeriodAnchor(String name) { + this.name = name; + } + + /** + * Returns a string representing the object. + * + * @return The string. + */ + @Override + public String toString() { + return this.name; + } + + /** + * Returns true if this object is equal to the specified + * object, and false otherwise. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + + if (this == obj) { + return true; + } + if (!(obj instanceof TimePeriodAnchor)) { + return false; + } + + TimePeriodAnchor position = (TimePeriodAnchor) obj; + if (!this.name.equals(position.name)) { + return false; + } + + return true; + } + + /** + * Returns a hash code value for the object. + * + * @return The hashcode + */ + @Override + public int hashCode() { + return this.name.hashCode(); + } + + /** + * 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(TimePeriodAnchor.START)) { + return TimePeriodAnchor.START; + } + else if (this.equals(TimePeriodAnchor.MIDDLE)) { + return TimePeriodAnchor.MIDDLE; + } + else if (this.equals(TimePeriodAnchor.END)) { + return TimePeriodAnchor.END; + } + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodFormatException.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodFormatException.java new file mode 100755 index 0000000..fbca78a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodFormatException.java @@ -0,0 +1,58 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * TimePeriodFormatException.java + * ------------------------------ + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 07-Dec-2001 : Version 1 (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package (DG); + */ + +package org.jfree.data.time; + +/** + * An exception that indicates an invalid format in a string representing a + * time period. + */ +public class TimePeriodFormatException extends IllegalArgumentException { + + /** + * Creates a new exception. + * + * @param message a message describing the exception. + */ + public TimePeriodFormatException(String message) { + super(message); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodValue.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodValue.java new file mode 100755 index 0000000..994448e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodValue.java @@ -0,0 +1,196 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * TimePeriodValue.java + * -------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Apr-2003 : Version 1 (DG); + * 03-Oct-2006 : Added null argument check to constructor (DG); + * 07-Apr-2008 : Added a toString() override for debugging (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +/** + * Represents a time period and an associated value. + */ +public class TimePeriodValue implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 3390443360845711275L; + + /** The time period. */ + private TimePeriod period; + + /** The value associated with the time period. */ + private Number value; + + /** + * Constructs a new data item. + * + * @param period the time period (null not permitted). + * @param value the value associated with the time period. + * + * @throws IllegalArgumentException if period is + * null. + */ + public TimePeriodValue(TimePeriod period, Number value) { + ParamChecks.nullNotPermitted(period, "period"); + this.period = period; + this.value = value; + } + + /** + * Constructs a new data item. + * + * @param period the time period (null not permitted). + * @param value the value associated with the time period. + * + * @throws IllegalArgumentException if period is + * null. + */ + public TimePeriodValue(TimePeriod period, double value) { + this(period, new Double(value)); + } + + /** + * Returns the time period. + * + * @return The time period (never null). + */ + public TimePeriod getPeriod() { + return this.period; + } + + /** + * Returns the value. + * + * @return The value (possibly null). + * + * @see #setValue(Number) + */ + public Number getValue() { + return this.value; + } + + /** + * Sets the value for this data item. + * + * @param value the new value (null permitted). + * + * @see #getValue() + */ + public void setValue(Number value) { + this.value = value; + } + + /** + * Tests this object for equality with the target object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof TimePeriodValue)) { + return false; + } + + TimePeriodValue timePeriodValue = (TimePeriodValue) obj; + + if (this.period != null ? !this.period.equals(timePeriodValue.period) + : timePeriodValue.period != null) { + return false; + } + if (this.value != null ? !this.value.equals(timePeriodValue.value) + : timePeriodValue.value != null) { + return false; + } + + return true; + } + + /** + * Returns a hash code value for the object. + * + * @return The hashcode + */ + @Override + public int hashCode() { + int result; + result = (this.period != null ? this.period.hashCode() : 0); + result = 29 * result + (this.value != null ? this.value.hashCode() : 0); + return result; + } + + /** + * Clones the object. + *

+ * Note: no need to clone the period or value since they are immutable + * classes. + * + * @return A clone. + */ + @Override + public Object clone() { + Object clone = null; + try { + clone = super.clone(); + } + catch (CloneNotSupportedException e) { // won't get here... + throw new RuntimeException(e); + } + return clone; + } + + /** + * Returns a string representing this instance, primarily for use in + * debugging. + * + * @return A string. + */ + @Override + public String toString() { + return "TimePeriodValue[" + getPeriod() + "," + getValue() + "]"; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodValues.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodValues.java new file mode 100755 index 0000000..ff34b75 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodValues.java @@ -0,0 +1,574 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * TimePeriodValues.java + * --------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Apr-2003 : Version 1 (DG); + * 30-Jul-2003 : Added clone and equals methods while testing (DG); + * 11-Mar-2005 : Fixed bug in bounds recalculation - see bug report + * 1161329 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 03-Oct-2006 : Fixed NullPointerException in equals(), fire change event in + * add() method, updated API docs (DG); + * 07-Apr-2008 : Fixed bug with maxMiddleIndex in updateBounds() (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.general.Series; +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.data.general.SeriesException; +import org.jfree.util.ObjectUtilities; + +/** + * A structure containing zero, one or many {@link TimePeriodValue} instances. + * The time periods can overlap, and are maintained in the order that they are + * added to the collection. + *

+ * This is similar to the {@link TimeSeries} class, except that the time + * periods can have irregular lengths. + */ +public class TimePeriodValues extends Series implements Serializable { + + /** For serialization. */ + static final long serialVersionUID = -2210593619794989709L; + + /** Default value for the domain description. */ + protected static final String DEFAULT_DOMAIN_DESCRIPTION = "Time"; + + /** Default value for the range description. */ + protected static final String DEFAULT_RANGE_DESCRIPTION = "Value"; + + /** A description of the domain. */ + private String domain; + + /** A description of the range. */ + private String range; + + /** The list of data pairs in the series. */ + private List data; + + /** Index of the time period with the minimum start milliseconds. */ + private int minStartIndex = -1; + + /** Index of the time period with the maximum start milliseconds. */ + private int maxStartIndex = -1; + + /** Index of the time period with the minimum middle milliseconds. */ + private int minMiddleIndex = -1; + + /** Index of the time period with the maximum middle milliseconds. */ + private int maxMiddleIndex = -1; + + /** Index of the time period with the minimum end milliseconds. */ + private int minEndIndex = -1; + + /** Index of the time period with the maximum end milliseconds. */ + private int maxEndIndex = -1; + + /** + * Creates a new (empty) collection of time period values. + * + * @param name the name of the series (null not permitted). + */ + public TimePeriodValues(String name) { + this(name, DEFAULT_DOMAIN_DESCRIPTION, DEFAULT_RANGE_DESCRIPTION); + } + + /** + * Creates a new time series that contains no data. + *

+ * Descriptions can be specified for the domain and range. One situation + * where this is helpful is when generating a chart for the time series - + * axis labels can be taken from the domain and range description. + * + * @param name the name of the series (null not permitted). + * @param domain the domain description. + * @param range the range description. + */ + public TimePeriodValues(String name, String domain, String range) { + super(name); + this.domain = domain; + this.range = range; + this.data = new ArrayList(); + } + + /** + * Returns the domain description. + * + * @return The domain description (possibly null). + * + * @see #getRangeDescription() + * @see #setDomainDescription(String) + */ + public String getDomainDescription() { + return this.domain; + } + + /** + * Sets the domain description and fires a property change event (with the + * property name Domain if the description changes). + * + * @param description the new description (null permitted). + * + * @see #getDomainDescription() + */ + public void setDomainDescription(String description) { + String old = this.domain; + this.domain = description; + firePropertyChange("Domain", old, description); + } + + /** + * Returns the range description. + * + * @return The range description (possibly null). + * + * @see #getDomainDescription() + * @see #setRangeDescription(String) + */ + public String getRangeDescription() { + return this.range; + } + + /** + * Sets the range description and fires a property change event with the + * name Range. + * + * @param description the new description (null permitted). + * + * @see #getRangeDescription() + */ + public void setRangeDescription(String description) { + String old = this.range; + this.range = description; + firePropertyChange("Range", old, description); + } + + /** + * Returns the number of items in the series. + * + * @return The item count. + */ + @Override + public int getItemCount() { + return this.data.size(); + } + + /** + * Returns one data item for the series. + * + * @param index the item index (in the range 0 to + * getItemCount() - 1). + * + * @return One data item for the series. + */ + public TimePeriodValue getDataItem(int index) { + return (TimePeriodValue) this.data.get(index); + } + + /** + * Returns the time period at the specified index. + * + * @param index the item index (in the range 0 to + * getItemCount() - 1). + * + * @return The time period at the specified index. + * + * @see #getDataItem(int) + */ + public TimePeriod getTimePeriod(int index) { + return getDataItem(index).getPeriod(); + } + + /** + * Returns the value at the specified index. + * + * @param index the item index (in the range 0 to + * getItemCount() - 1). + * + * @return The value at the specified index (possibly null). + * + * @see #getDataItem(int) + */ + public Number getValue(int index) { + return getDataItem(index).getValue(); + } + + /** + * Adds a data item to the series and sends a {@link SeriesChangeEvent} to + * all registered listeners. + * + * @param item the item (null not permitted). + */ + public void add(TimePeriodValue item) { + ParamChecks.nullNotPermitted(item, "item"); + this.data.add(item); + updateBounds(item.getPeriod(), this.data.size() - 1); + fireSeriesChanged(); + } + + /** + * Update the index values for the maximum and minimum bounds. + * + * @param period the time period. + * @param index the index of the time period. + */ + private void updateBounds(TimePeriod period, int index) { + + long start = period.getStart().getTime(); + long end = period.getEnd().getTime(); + long middle = start + ((end - start) / 2); + + if (this.minStartIndex >= 0) { + long minStart = getDataItem(this.minStartIndex).getPeriod() + .getStart().getTime(); + if (start < minStart) { + this.minStartIndex = index; + } + } + else { + this.minStartIndex = index; + } + + if (this.maxStartIndex >= 0) { + long maxStart = getDataItem(this.maxStartIndex).getPeriod() + .getStart().getTime(); + if (start > maxStart) { + this.maxStartIndex = index; + } + } + else { + this.maxStartIndex = index; + } + + if (this.minMiddleIndex >= 0) { + long s = getDataItem(this.minMiddleIndex).getPeriod().getStart() + .getTime(); + long e = getDataItem(this.minMiddleIndex).getPeriod().getEnd() + .getTime(); + long minMiddle = s + (e - s) / 2; + if (middle < minMiddle) { + this.minMiddleIndex = index; + } + } + else { + this.minMiddleIndex = index; + } + + if (this.maxMiddleIndex >= 0) { + long s = getDataItem(this.maxMiddleIndex).getPeriod().getStart() + .getTime(); + long e = getDataItem(this.maxMiddleIndex).getPeriod().getEnd() + .getTime(); + long maxMiddle = s + (e - s) / 2; + if (middle > maxMiddle) { + this.maxMiddleIndex = index; + } + } + else { + this.maxMiddleIndex = index; + } + + if (this.minEndIndex >= 0) { + long minEnd = getDataItem(this.minEndIndex).getPeriod().getEnd() + .getTime(); + if (end < minEnd) { + this.minEndIndex = index; + } + } + else { + this.minEndIndex = index; + } + + if (this.maxEndIndex >= 0) { + long maxEnd = getDataItem(this.maxEndIndex).getPeriod().getEnd() + .getTime(); + if (end > maxEnd) { + this.maxEndIndex = index; + } + } + else { + this.maxEndIndex = index; + } + + } + + /** + * Recalculates the bounds for the collection of items. + */ + private void recalculateBounds() { + this.minStartIndex = -1; + this.minMiddleIndex = -1; + this.minEndIndex = -1; + this.maxStartIndex = -1; + this.maxMiddleIndex = -1; + this.maxEndIndex = -1; + for (int i = 0; i < this.data.size(); i++) { + TimePeriodValue tpv = (TimePeriodValue) this.data.get(i); + updateBounds(tpv.getPeriod(), i); + } + } + + /** + * Adds a new data item to the series and sends a {@link SeriesChangeEvent} + * to all registered listeners. + * + * @param period the time period (null not permitted). + * @param value the value. + * + * @see #add(TimePeriod, Number) + */ + public void add(TimePeriod period, double value) { + TimePeriodValue item = new TimePeriodValue(period, value); + add(item); + } + + /** + * Adds a new data item to the series and sends a {@link SeriesChangeEvent} + * to all registered listeners. + * + * @param period the time period (null not permitted). + * @param value the value (null permitted). + */ + public void add(TimePeriod period, Number value) { + TimePeriodValue item = new TimePeriodValue(period, value); + add(item); + } + + /** + * Updates (changes) the value of a data item and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param index the index of the data item to update. + * @param value the new value (null not permitted). + */ + public void update(int index, Number value) { + TimePeriodValue item = getDataItem(index); + item.setValue(value); + fireSeriesChanged(); + } + + /** + * Deletes data from start until end index (end inclusive) and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param start the index of the first period to delete. + * @param end the index of the last period to delete. + */ + public void delete(int start, int end) { + for (int i = 0; i <= (end - start); i++) { + this.data.remove(start); + } + recalculateBounds(); + fireSeriesChanged(); + } + + /** + * Tests the series for equality with another object. + * + * @param obj the object (null permitted). + * + * @return true or false. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TimePeriodValues)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + TimePeriodValues that = (TimePeriodValues) obj; + if (!ObjectUtilities.equal(this.getDomainDescription(), + that.getDomainDescription())) { + return false; + } + if (!ObjectUtilities.equal(this.getRangeDescription(), + that.getRangeDescription())) { + return false; + } + int count = getItemCount(); + if (count != that.getItemCount()) { + return false; + } + for (int i = 0; i < count; i++) { + if (!getDataItem(i).equals(that.getDataItem(i))) { + return false; + } + } + return true; + } + + /** + * Returns a hash code value for the object. + * + * @return The hashcode + */ + @Override + public int hashCode() { + int result; + result = (this.domain != null ? this.domain.hashCode() : 0); + result = 29 * result + (this.range != null ? this.range.hashCode() : 0); + result = 29 * result + this.data.hashCode(); + result = 29 * result + this.minStartIndex; + result = 29 * result + this.maxStartIndex; + result = 29 * result + this.minMiddleIndex; + result = 29 * result + this.maxMiddleIndex; + result = 29 * result + this.minEndIndex; + result = 29 * result + this.maxEndIndex; + return result; + } + + /** + * Returns a clone of the collection. + *

+ * Notes: + *

    + *
  • no need to clone the domain and range descriptions, since String + * object is immutable;
  • + *
  • we pass over to the more general method createCopy(start, end). + *
  • + *
+ * + * @return A clone of the time series. + * + * @throws CloneNotSupportedException if there is a cloning problem. + */ + @Override + public Object clone() throws CloneNotSupportedException { + Object clone = createCopy(0, getItemCount() - 1); + return clone; + } + + /** + * Creates a new instance by copying a subset of the data in this + * collection. + * + * @param start the index of the first item to copy. + * @param end the index of the last item to copy. + * + * @return A copy of a subset of the items. + * + * @throws CloneNotSupportedException if there is a cloning problem. + */ + public TimePeriodValues createCopy(int start, int end) + throws CloneNotSupportedException { + + TimePeriodValues copy = (TimePeriodValues) super.clone(); + + copy.data = new ArrayList(); + if (this.data.size() > 0) { + for (int index = start; index <= end; index++) { + TimePeriodValue item = (TimePeriodValue) this.data.get(index); + TimePeriodValue clone = (TimePeriodValue) item.clone(); + try { + copy.add(clone); + } + catch (SeriesException e) { + System.err.println("Failed to add cloned item."); + } + } + } + return copy; + + } + + /** + * Returns the index of the time period with the minimum start milliseconds. + * + * @return The index. + */ + public int getMinStartIndex() { + return this.minStartIndex; + } + + /** + * Returns the index of the time period with the maximum start milliseconds. + * + * @return The index. + */ + public int getMaxStartIndex() { + return this.maxStartIndex; + } + + /** + * Returns the index of the time period with the minimum middle + * milliseconds. + * + * @return The index. + */ + public int getMinMiddleIndex() { + return this.minMiddleIndex; + } + + /** + * Returns the index of the time period with the maximum middle + * milliseconds. + * + * @return The index. + */ + public int getMaxMiddleIndex() { + return this.maxMiddleIndex; + } + + /** + * Returns the index of the time period with the minimum end milliseconds. + * + * @return The index. + */ + public int getMinEndIndex() { + return this.minEndIndex; + } + + /** + * Returns the index of the time period with the maximum end milliseconds. + * + * @return The index. + */ + public int getMaxEndIndex() { + return this.maxEndIndex; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodValuesCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodValuesCollection.java new file mode 100755 index 0000000..153aab1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimePeriodValuesCollection.java @@ -0,0 +1,494 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * TimePeriodValuesCollection.java + * ------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Apr-2003 : Version 1 (DG); + * 05-May-2004 : Now extends AbstractIntervalXYDataset (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 06-Oct-2004 : Updated for changes in DomainInfo interface (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 03-Oct-2006 : Deprecated get/setDomainIsPointsInTime() (DG); + * 11-Jun-2007 : Fixed bug in getDomainBounds() method, and changed default + * value for domainIsPointsInTime to false (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.util.Iterator; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.DomainInfo; +import org.jfree.data.Range; +import org.jfree.data.xy.AbstractIntervalXYDataset; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.util.ObjectUtilities; + +/** + * A collection of {@link TimePeriodValues} objects. + *

+ * This class implements the {@link org.jfree.data.xy.XYDataset} interface, as + * well as the extended {@link IntervalXYDataset} interface. This makes it a + * convenient dataset for use with the {@link org.jfree.chart.plot.XYPlot} + * class. + */ +public class TimePeriodValuesCollection extends AbstractIntervalXYDataset + implements IntervalXYDataset, DomainInfo, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -3077934065236454199L; + + /** Storage for the time series. */ + private List data; + + /** + * The position within a time period to return as the x-value (START, + * MIDDLE or END). + */ + private TimePeriodAnchor xPosition; + + /** + * A flag that indicates that the domain is 'points in time'. If this + * flag is true, only the x-value is used to determine the range of values + * in the domain, the start and end x-values are ignored. + */ + private boolean domainIsPointsInTime; + + /** + * Constructs an empty dataset. + */ + public TimePeriodValuesCollection() { + this((TimePeriodValues) null); + } + + /** + * Constructs a dataset containing a single series. Additional series can + * be added. + * + * @param series the series (null ignored). + */ + public TimePeriodValuesCollection(TimePeriodValues series) { + this.data = new java.util.ArrayList(); + this.xPosition = TimePeriodAnchor.MIDDLE; + this.domainIsPointsInTime = false; + if (series != null) { + this.data.add(series); + series.addChangeListener(this); + } + } + + /** + * Returns the position of the X value within each time period. + * + * @return The position (never null). + * + * @see #setXPosition(TimePeriodAnchor) + */ + public TimePeriodAnchor getXPosition() { + return this.xPosition; + } + + /** + * Sets the position of the x axis within each time period. + * + * @param position the position (null not permitted). + * + * @see #getXPosition() + */ + public void setXPosition(TimePeriodAnchor position) { + ParamChecks.nullNotPermitted(position, "position"); + this.xPosition = position; + } + + /** + * Returns the number of series in the collection. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.data.size(); + } + + /** + * Returns a series. + * + * @param series the index of the series (zero-based). + * + * @return The series. + */ + public TimePeriodValues getSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Index 'series' out of range."); + } + return (TimePeriodValues) this.data.get(series); + } + + /** + * Returns the key for a series. + * + * @param series the index of the series (zero-based). + * + * @return The key for a series. + */ + @Override + public Comparable getSeriesKey(int series) { + // defer argument checking + return getSeries(series).getKey(); + } + + /** + * Adds a series to the collection. A + * {@link org.jfree.data.general.DatasetChangeEvent} is sent to all + * registered listeners. + * + * @param series the time series. + */ + public void addSeries(TimePeriodValues series) { + ParamChecks.nullNotPermitted(series, "series"); + this.data.add(series); + series.addChangeListener(this); + fireDatasetChanged(); + } + + /** + * Removes the specified series from the collection. + * + * @param series the series to remove (null not permitted). + */ + public void removeSeries(TimePeriodValues series) { + ParamChecks.nullNotPermitted(series, "series"); + this.data.remove(series); + series.removeChangeListener(this); + fireDatasetChanged(); + + } + + /** + * Removes a series from the collection. + * + * @param index the series index (zero-based). + */ + public void removeSeries(int index) { + TimePeriodValues series = getSeries(index); + if (series != null) { + removeSeries(series); + } + } + + /** + * Returns the number of items in the specified series. + *

+ * This method is provided for convenience. + * + * @param series the index of the series of interest (zero-based). + * + * @return The number of items in the specified series. + */ + @Override + public int getItemCount(int series) { + return getSeries(series).getItemCount(); + } + + /** + * Returns the x-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The x-value for the specified series and item. + */ + @Override + public Number getX(int series, int item) { + TimePeriodValues ts = (TimePeriodValues) this.data.get(series); + TimePeriodValue dp = ts.getDataItem(item); + TimePeriod period = dp.getPeriod(); + return new Long(getX(period)); + } + + /** + * Returns the x-value for a time period. + * + * @param period the time period. + * + * @return The x-value. + */ + private long getX(TimePeriod period) { + + if (this.xPosition == TimePeriodAnchor.START) { + return period.getStart().getTime(); + } + else if (this.xPosition == TimePeriodAnchor.MIDDLE) { + return period.getStart().getTime() + / 2 + period.getEnd().getTime() / 2; + } + else if (this.xPosition == TimePeriodAnchor.END) { + return period.getEnd().getTime(); + } + else { + throw new IllegalStateException("TimePeriodAnchor unknown."); + } + + } + + /** + * Returns the starting X value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The starting X value for the specified series and item. + */ + @Override + public Number getStartX(int series, int item) { + TimePeriodValues ts = (TimePeriodValues) this.data.get(series); + TimePeriodValue dp = ts.getDataItem(item); + return new Long(dp.getPeriod().getStart().getTime()); + } + + /** + * Returns the ending X value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The ending X value for the specified series and item. + */ + @Override + public Number getEndX(int series, int item) { + TimePeriodValues ts = (TimePeriodValues) this.data.get(series); + TimePeriodValue dp = ts.getDataItem(item); + return new Long(dp.getPeriod().getEnd().getTime()); + } + + /** + * Returns the y-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The y-value for the specified series and item. + */ + @Override + public Number getY(int series, int item) { + TimePeriodValues ts = (TimePeriodValues) this.data.get(series); + TimePeriodValue dp = ts.getDataItem(item); + return dp.getValue(); + } + + /** + * Returns the starting Y value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The starting Y value for the specified series and item. + */ + @Override + public Number getStartY(int series, int item) { + return getY(series, item); + } + + /** + * Returns the ending Y value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The ending Y value for the specified series and item. + */ + @Override + public Number getEndY(int series, int item) { + return getY(series, item); + } + + /** + * Returns the minimum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The minimum value. + */ + @Override + public double getDomainLowerBound(boolean includeInterval) { + double result = Double.NaN; + Range r = getDomainBounds(includeInterval); + if (r != null) { + result = r.getLowerBound(); + } + return result; + } + + /** + * Returns the maximum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The maximum value. + */ + @Override + public double getDomainUpperBound(boolean includeInterval) { + double result = Double.NaN; + Range r = getDomainBounds(includeInterval); + if (r != null) { + result = r.getUpperBound(); + } + return result; + } + + /** + * Returns the range of the values in this dataset's domain. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The range. + */ + @Override + public Range getDomainBounds(boolean includeInterval) { + boolean interval = includeInterval || this.domainIsPointsInTime; + Range result = null; + Range temp = null; + Iterator iterator = this.data.iterator(); + while (iterator.hasNext()) { + TimePeriodValues series = (TimePeriodValues) iterator.next(); + int count = series.getItemCount(); + if (count > 0) { + TimePeriod start = series.getTimePeriod( + series.getMinStartIndex()); + TimePeriod end = series.getTimePeriod(series.getMaxEndIndex()); + if (!interval) { + if (this.xPosition == TimePeriodAnchor.START) { + TimePeriod maxStart = series.getTimePeriod( + series.getMaxStartIndex()); + temp = new Range(start.getStart().getTime(), + maxStart.getStart().getTime()); + } + else if (this.xPosition == TimePeriodAnchor.MIDDLE) { + TimePeriod minMiddle = series.getTimePeriod( + series.getMinMiddleIndex()); + long s1 = minMiddle.getStart().getTime(); + long e1 = minMiddle.getEnd().getTime(); + TimePeriod maxMiddle = series.getTimePeriod( + series.getMaxMiddleIndex()); + long s2 = maxMiddle.getStart().getTime(); + long e2 = maxMiddle.getEnd().getTime(); + temp = new Range(s1 + (e1 - s1) / 2, + s2 + (e2 - s2) / 2); + } + else if (this.xPosition == TimePeriodAnchor.END) { + TimePeriod minEnd = series.getTimePeriod( + series.getMinEndIndex()); + temp = new Range(minEnd.getEnd().getTime(), + end.getEnd().getTime()); + } + } + else { + temp = new Range(start.getStart().getTime(), + end.getEnd().getTime()); + } + result = Range.combine(result, temp); + } + } + return result; + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TimePeriodValuesCollection)) { + return false; + } + TimePeriodValuesCollection that = (TimePeriodValuesCollection) obj; + if (this.domainIsPointsInTime != that.domainIsPointsInTime) { + return false; + } + if (this.xPosition != that.xPosition) { + return false; + } + if (!ObjectUtilities.equal(this.data, that.data)) { + return false; + } + return true; + } + + // --- DEPRECATED METHODS ------------------------------------------------- + + /** + * Returns a flag that controls whether the domain is treated as 'points + * in time'. This flag is used when determining the max and min values for + * the domain. If true, then only the x-values are considered for the max + * and min values. If false, then the start and end x-values will also be + * taken into consideration + * + * @return The flag. + * + * @deprecated This flag is no longer used by JFreeChart (as of version + * 1.0.3). + */ + public boolean getDomainIsPointsInTime() { + return this.domainIsPointsInTime; + } + + /** + * Sets a flag that controls whether the domain is treated as 'points in + * time', or time periods. + * + * @param flag the new value of the flag. + * + * @deprecated This flag is no longer used by JFreeChart (as of version + * 1.0.3). + */ + public void setDomainIsPointsInTime(boolean flag) { + this.domainIsPointsInTime = flag; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeSeries.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeSeries.java new file mode 100755 index 0000000..fccc67a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeSeries.java @@ -0,0 +1,1342 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * TimeSeries.java + * --------------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Bryan Scott; + * Nick Guenther; + * + * Changes + * ------- + * 11-Oct-2001 : Version 1 (DG); + * 14-Nov-2001 : Added listener mechanism (DG); + * 15-Nov-2001 : Updated argument checking and exceptions in add() method (DG); + * 29-Nov-2001 : Added properties to describe the domain and range (DG); + * 07-Dec-2001 : Renamed TimeSeries --> BasicTimeSeries (DG); + * 01-Mar-2002 : Updated import statements (DG); + * 28-Mar-2002 : Added a method add(TimePeriod, double) (DG); + * 27-Aug-2002 : Changed return type of delete method to void (DG); + * 04-Oct-2002 : Added itemCount and historyCount attributes, fixed errors + * reported by Checkstyle (DG); + * 29-Oct-2002 : Added series change notification to addOrUpdate() method (DG); + * 28-Jan-2003 : Changed name back to TimeSeries (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package and implemented + * Serializable (DG); + * 01-May-2003 : Updated equals() method (see bug report 727575) (DG); + * 14-Aug-2003 : Added ageHistoryCountItems method (copied existing code for + * contents) made a method and added to addOrUpdate. Made a + * public method to enable ageing against a specified time + * (eg now) as opposed to lastest time in series (BS); + * 15-Oct-2003 : Added fix for setItemCount method - see bug report 804425. + * Modified exception message in add() method to be more + * informative (DG); + * 13-Apr-2004 : Added clear() method (DG); + * 21-May-2004 : Added an extra addOrUpdate() method (DG); + * 15-Jun-2004 : Fixed NullPointerException in equals() method (DG); + * 29-Nov-2004 : Fixed bug 1075255 (DG); + * 17-Nov-2005 : Renamed historyCount --> maximumItemAge (DG); + * 28-Nov-2005 : Changed maximumItemAge from int to long (DG); + * 01-Dec-2005 : New add methods accept notify flag (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 24-May-2006 : Improved error handling in createCopy() methods (DG); + * 01-Sep-2006 : Fixed bugs in removeAgedItems() methods - see bug report + * 1550045 (DG); + * 22-Mar-2007 : Simplified getDataItem(RegularTimePeriod) - see patch 1685500 + * by Nick Guenther (DG); + * 31-Oct-2007 : Implemented faster hashCode() (DG); + * 21-Nov-2007 : Fixed clone() method (bug 1832432) (DG); + * 10-Jan-2008 : Fixed createCopy(RegularTimePeriod, RegularTimePeriod) (bug + * 1864222) (DG); + * 13-Jan-2009 : Fixed constructors so that timePeriodClass doesn't need to + * be specified in advance (DG); + * 26-May-2009 : Added cache for minY and maxY values (DG); + * 09-Jun-2009 : Ensure that TimeSeriesDataItem objects used in underlying + * storage are cloned to keep series isolated from external + * changes (DG); + * 10-Jun-2009 : Added addOrUpdate(TimeSeriesDataItem) method (DG); + * 31-Aug-2009 : Clear minY and maxY cache values in createCopy (DG); + * 03-Dec-2011 : Fixed bug 3446965 which affects the y-range calculation for + * the series (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.TimeZone; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.general.Series; +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.data.general.SeriesException; +import org.jfree.util.ObjectUtilities; + +/** + * Represents a sequence of zero or more data items in the form (period, value) + * where 'period' is some instance of a subclass of {@link RegularTimePeriod}. + * The time series will ensure that (a) all data items have the same type of + * period (for example, {@link Day}) and (b) that each period appears at + * most one time in the series. + */ +public class TimeSeries extends Series implements Cloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -5032960206869675528L; + + /** Default value for the domain description. */ + protected static final String DEFAULT_DOMAIN_DESCRIPTION = "Time"; + + /** Default value for the range description. */ + protected static final String DEFAULT_RANGE_DESCRIPTION = "Value"; + + /** A description of the domain. */ + private String domain; + + /** A description of the range. */ + private String range; + + /** The type of period for the data. */ + protected Class timePeriodClass; + + /** The list of data items in the series. */ + protected List data; + + /** The maximum number of items for the series. */ + private int maximumItemCount; + + /** + * The maximum age of items for the series, specified as a number of + * time periods. + */ + private long maximumItemAge; + + /** + * The minimum y-value in the series. + * + * @since 1.0.14 + */ + private double minY; + + /** + * The maximum y-value in the series. + * + * @since 1.0.14 + */ + private double maxY; + + /** + * Creates a new (empty) time series. By default, a daily time series is + * created. Use one of the other constructors if you require a different + * time period. + * + * @param name the series name (null not permitted). + */ + public TimeSeries(Comparable name) { + this(name, DEFAULT_DOMAIN_DESCRIPTION, DEFAULT_RANGE_DESCRIPTION); + } + + /** + * Creates a new time series that contains no data. + *

+ * Descriptions can be specified for the domain and range. One situation + * where this is helpful is when generating a chart for the time series - + * axis labels can be taken from the domain and range description. + * + * @param name the name of the series (null not permitted). + * @param domain the domain description (null permitted). + * @param range the range description (null permitted). + * + * @since 1.0.13 + */ + public TimeSeries(Comparable name, String domain, String range) { + super(name); + this.domain = domain; + this.range = range; + this.timePeriodClass = null; + this.data = new java.util.ArrayList(); + this.maximumItemCount = Integer.MAX_VALUE; + this.maximumItemAge = Long.MAX_VALUE; + this.minY = Double.NaN; + this.maxY = Double.NaN; + } + + /** + * Returns the domain description. + * + * @return The domain description (possibly null). + * + * @see #setDomainDescription(String) + */ + public String getDomainDescription() { + return this.domain; + } + + /** + * Sets the domain description and sends a PropertyChangeEvent + * (with the property name Domain) to all registered + * property change listeners. + * + * @param description the description (null permitted). + * + * @see #getDomainDescription() + */ + public void setDomainDescription(String description) { + String old = this.domain; + this.domain = description; + firePropertyChange("Domain", old, description); + } + + /** + * Returns the range description. + * + * @return The range description (possibly null). + * + * @see #setRangeDescription(String) + */ + public String getRangeDescription() { + return this.range; + } + + /** + * Sets the range description and sends a PropertyChangeEvent + * (with the property name Range) to all registered listeners. + * + * @param description the description (null permitted). + * + * @see #getRangeDescription() + */ + public void setRangeDescription(String description) { + String old = this.range; + this.range = description; + firePropertyChange("Range", old, description); + } + + /** + * Returns the number of items in the series. + * + * @return The item count. + */ + @Override + public int getItemCount() { + return this.data.size(); + } + + /** + * Returns the list of data items for the series (the list contains + * {@link TimeSeriesDataItem} objects and is unmodifiable). + * + * @return The list of data items. + */ + public List getItems() { + // FIXME: perhaps we should clone the data list + return Collections.unmodifiableList(this.data); + } + + /** + * Returns the maximum number of items that will be retained in the series. + * The default value is Integer.MAX_VALUE. + * + * @return The maximum item count. + * + * @see #setMaximumItemCount(int) + */ + public int getMaximumItemCount() { + return this.maximumItemCount; + } + + /** + * Sets the maximum number of items that will be retained in the series. + * If you add a new item to the series such that the number of items will + * exceed the maximum item count, then the FIRST element in the series is + * automatically removed, ensuring that the maximum item count is not + * exceeded. + * + * @param maximum the maximum (requires >= 0). + * + * @see #getMaximumItemCount() + */ + public void setMaximumItemCount(int maximum) { + if (maximum < 0) { + throw new IllegalArgumentException("Negative 'maximum' argument."); + } + this.maximumItemCount = maximum; + int count = this.data.size(); + if (count > maximum) { + delete(0, count - maximum - 1); + } + } + + /** + * Returns the maximum item age (in time periods) for the series. + * + * @return The maximum item age. + * + * @see #setMaximumItemAge(long) + */ + public long getMaximumItemAge() { + return this.maximumItemAge; + } + + /** + * Sets the number of time units in the 'history' for the series. This + * provides one mechanism for automatically dropping old data from the + * time series. For example, if a series contains daily data, you might set + * the history count to 30. Then, when you add a new data item, all data + * items more than 30 days older than the latest value are automatically + * dropped from the series. + * + * @param periods the number of time periods. + * + * @see #getMaximumItemAge() + */ + public void setMaximumItemAge(long periods) { + if (periods < 0) { + throw new IllegalArgumentException("Negative 'periods' argument."); + } + this.maximumItemAge = periods; + removeAgedItems(true); // remove old items and notify if necessary + } + + /** + * Returns the smallest y-value in the series, ignoring any null and + * Double.NaN values. This method returns Double.NaN if there is no + * smallest y-value (for example, when the series is empty). + * + * @return The smallest y-value. + * + * @see #getMaxY() + * + * @since 1.0.14 + */ + public double getMinY() { + return this.minY; + } + + /** + * Returns the largest y-value in the series, ignoring any Double.NaN + * values. This method returns Double.NaN if there is no largest y-value + * (for example, when the series is empty). + * + * @return The largest y-value. + * + * @see #getMinY() + * + * @since 1.0.14 + */ + public double getMaxY() { + return this.maxY; + } + + /** + * Returns the time period class for this series. + *

+ * Only one time period class can be used within a single series (enforced). + * If you add a data item with a {@link Year} for the time period, then all + * subsequent data items must also have a {@link Year} for the time period. + * + * @return The time period class (may be null but only for + * an empty series). + */ + public Class getTimePeriodClass() { + return this.timePeriodClass; + } + + /** + * Returns a data item from the dataset. Note that the returned object + * is a clone of the item in the series, so modifying it will have no + * effect on the data series. + * + * @param index the item index. + * + * @return The data item. + */ + public TimeSeriesDataItem getDataItem(int index) { + TimeSeriesDataItem item = (TimeSeriesDataItem) this.data.get(index); + return (TimeSeriesDataItem) item.clone(); + } + + /** + * Returns the data item for a specific period. Note that the returned + * object is a clone of the item in the series, so modifying it will have + * no effect on the data series. + * + * @param period the period of interest (null not allowed). + * + * @return The data item matching the specified period (or + * null if there is no match). + * + * @see #getDataItem(int) + */ + public TimeSeriesDataItem getDataItem(RegularTimePeriod period) { + int index = getIndex(period); + if (index >= 0) { + return getDataItem(index); + } + return null; + } + + /** + * Returns a data item for the series. This method returns the object + * that is used for the underlying storage - you should not modify the + * contents of the returned value unless you know what you are doing. + * + * @param index the item index (zero-based). + * + * @return The data item. + * + * @see #getDataItem(int) + * + * @since 1.0.14 + */ + TimeSeriesDataItem getRawDataItem(int index) { + return (TimeSeriesDataItem) this.data.get(index); + } + + /** + * Returns a data item for the series. This method returns the object + * that is used for the underlying storage - you should not modify the + * contents of the returned value unless you know what you are doing. + * + * @param period the item index (zero-based). + * + * @return The data item. + * + * @see #getDataItem(RegularTimePeriod) + * + * @since 1.0.14 + */ + TimeSeriesDataItem getRawDataItem(RegularTimePeriod period) { + int index = getIndex(period); + if (index >= 0) { + return (TimeSeriesDataItem) this.data.get(index); + } + return null; + } + + /** + * Returns the time period at the specified index. + * + * @param index the index of the data item. + * + * @return The time period. + */ + public RegularTimePeriod getTimePeriod(int index) { + return getRawDataItem(index).getPeriod(); + } + + /** + * Returns a time period that would be the next in sequence on the end of + * the time series. + * + * @return The next time period. + */ + public RegularTimePeriod getNextTimePeriod() { + RegularTimePeriod last = getTimePeriod(getItemCount() - 1); + return last.next(); + } + + /** + * Returns a collection of all the time periods in the time series. + * + * @return A collection of all the time periods. + */ + public Collection getTimePeriods() { + Collection result = new java.util.ArrayList(); + for (int i = 0; i < getItemCount(); i++) { + result.add(getTimePeriod(i)); + } + return result; + } + + /** + * Returns a collection of time periods in the specified series, but not in + * this series, and therefore unique to the specified series. + * + * @param series the series to check against this one. + * + * @return The unique time periods. + */ + public Collection getTimePeriodsUniqueToOtherSeries(TimeSeries series) { + Collection result = new java.util.ArrayList(); + for (int i = 0; i < series.getItemCount(); i++) { + RegularTimePeriod period = series.getTimePeriod(i); + int index = getIndex(period); + if (index < 0) { + result.add(period); + } + } + return result; + } + + /** + * Returns the index for the item (if any) that corresponds to a time + * period. + * + * @param period the time period (null not permitted). + * + * @return The index. + */ + public int getIndex(RegularTimePeriod period) { + ParamChecks.nullNotPermitted(period, "period"); + TimeSeriesDataItem dummy = new TimeSeriesDataItem( + period, Integer.MIN_VALUE); + return Collections.binarySearch(this.data, dummy); + } + + /** + * Returns the value at the specified index. + * + * @param index index of a value. + * + * @return The value (possibly null). + */ + public Number getValue(int index) { + return getRawDataItem(index).getValue(); + } + + /** + * Returns the value for a time period. If there is no data item with the + * specified period, this method will return null. + * + * @param period time period (null not permitted). + * + * @return The value (possibly null). + */ + public Number getValue(RegularTimePeriod period) { + int index = getIndex(period); + if (index >= 0) { + return getValue(index); + } + return null; + } + + /** + * Adds a data item to the series and sends a {@link SeriesChangeEvent} to + * all registered listeners. + * + * @param item the (timeperiod, value) pair (null not + * permitted). + */ + public void add(TimeSeriesDataItem item) { + add(item, true); + } + + /** + * Adds a data item to the series and sends a {@link SeriesChangeEvent} to + * all registered listeners. + * + * @param item the (timeperiod, value) pair (null not + * permitted). + * @param notify notify listeners? + */ + public void add(TimeSeriesDataItem item, boolean notify) { + ParamChecks.nullNotPermitted(item, "item"); + item = (TimeSeriesDataItem) item.clone(); + Class c = item.getPeriod().getClass(); + if (this.timePeriodClass == null) { + this.timePeriodClass = c; + } + else if (!this.timePeriodClass.equals(c)) { + StringBuilder b = new StringBuilder(); + b.append("You are trying to add data where the time period class "); + b.append("is "); + b.append(item.getPeriod().getClass().getName()); + b.append(", but the TimeSeries is expecting an instance of "); + b.append(this.timePeriodClass.getName()); + b.append("."); + throw new SeriesException(b.toString()); + } + + // make the change (if it's not a duplicate time period)... + boolean added = false; + int count = getItemCount(); + if (count == 0) { + this.data.add(item); + added = true; + } + else { + RegularTimePeriod last = getTimePeriod(getItemCount() - 1); + if (item.getPeriod().compareTo(last) > 0) { + this.data.add(item); + added = true; + } + else { + int index = Collections.binarySearch(this.data, item); + if (index < 0) { + this.data.add(-index - 1, item); + added = true; + } + else { + StringBuilder b = new StringBuilder(); + b.append("You are attempting to add an observation for "); + b.append("the time period "); + b.append(item.getPeriod().toString()); + b.append(" but the series already contains an observation"); + b.append(" for that time period. Duplicates are not "); + b.append("permitted. Try using the addOrUpdate() method."); + throw new SeriesException(b.toString()); + } + } + } + if (added) { + updateBoundsForAddedItem(item); + // check if this addition will exceed the maximum item count... + if (getItemCount() > this.maximumItemCount) { + TimeSeriesDataItem d = (TimeSeriesDataItem) this.data.remove(0); + updateBoundsForRemovedItem(d); + } + + removeAgedItems(false); // remove old items if necessary, but + // don't notify anyone, because that + // happens next anyway... + if (notify) { + fireSeriesChanged(); + } + } + + } + + /** + * Adds a new data item to the series and sends a {@link SeriesChangeEvent} + * to all registered listeners. + * + * @param period the time period (null not permitted). + * @param value the value. + */ + public void add(RegularTimePeriod period, double value) { + // defer argument checking... + add(period, value, true); + } + + /** + * Adds a new data item to the series and sends a {@link SeriesChangeEvent} + * to all registered listeners. + * + * @param period the time period (null not permitted). + * @param value the value. + * @param notify notify listeners? + */ + public void add(RegularTimePeriod period, double value, boolean notify) { + // defer argument checking... + TimeSeriesDataItem item = new TimeSeriesDataItem(period, value); + add(item, notify); + } + + /** + * Adds a new data item to the series and sends + * a {@link org.jfree.data.general.SeriesChangeEvent} to all registered + * listeners. + * + * @param period the time period (null not permitted). + * @param value the value (null permitted). + */ + public void add(RegularTimePeriod period, Number value) { + // defer argument checking... + add(period, value, true); + } + + /** + * Adds a new data item to the series and sends a {@link SeriesChangeEvent} + * to all registered listeners. + * + * @param period the time period (null not permitted). + * @param value the value (null permitted). + * @param notify notify listeners? + */ + public void add(RegularTimePeriod period, Number value, boolean notify) { + // defer argument checking... + TimeSeriesDataItem item = new TimeSeriesDataItem(period, value); + add(item, notify); + } + + /** + * Updates (changes) the value for a time period. Throws a + * {@link SeriesException} if the period does not exist. + * + * @param period the period (null not permitted). + * @param value the value. + * + * @since 1.0.14 + */ + public void update(RegularTimePeriod period, double value) { + update(period, new Double(value)); + } + + /** + * Updates (changes) the value for a time period. Throws a + * {@link SeriesException} if the period does not exist. + * + * @param period the period (null not permitted). + * @param value the value (null permitted). + */ + public void update(RegularTimePeriod period, Number value) { + TimeSeriesDataItem temp = new TimeSeriesDataItem(period, value); + int index = Collections.binarySearch(this.data, temp); + if (index < 0) { + throw new SeriesException("There is no existing value for the " + + "specified 'period'."); + } + update(index, value); + } + + /** + * Updates (changes) the value of a data item. + * + * @param index the index of the data item. + * @param value the new value (null permitted). + */ + public void update(int index, Number value) { + TimeSeriesDataItem item = (TimeSeriesDataItem) this.data.get(index); + boolean iterate = false; + Number oldYN = item.getValue(); + if (oldYN != null) { + double oldY = oldYN.doubleValue(); + if (!Double.isNaN(oldY)) { + iterate = oldY <= this.minY || oldY >= this.maxY; + } + } + item.setValue(value); + if (iterate) { + findBoundsByIteration(); + } + else if (value != null) { + double yy = value.doubleValue(); + this.minY = minIgnoreNaN(this.minY, yy); + this.maxY = maxIgnoreNaN(this.maxY, yy); + } + fireSeriesChanged(); + } + + /** + * Adds or updates data from one series to another. Returns another series + * containing the values that were overwritten. + * + * @param series the series to merge with this. + * + * @return A series containing the values that were overwritten. + */ + public TimeSeries addAndOrUpdate(TimeSeries series) { + TimeSeries overwritten = new TimeSeries("Overwritten values from: " + + getKey()); + for (int i = 0; i < series.getItemCount(); i++) { + TimeSeriesDataItem item = series.getRawDataItem(i); + TimeSeriesDataItem oldItem = addOrUpdate(item.getPeriod(), + item.getValue()); + if (oldItem != null) { + overwritten.add(oldItem); + } + } + return overwritten; + } + + /** + * Adds or updates an item in the times series and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param period the time period to add/update (null not + * permitted). + * @param value the new value. + * + * @return A copy of the overwritten data item, or null if no + * item was overwritten. + */ + public TimeSeriesDataItem addOrUpdate(RegularTimePeriod period, + double value) { + return addOrUpdate(period, new Double(value)); + } + + /** + * Adds or updates an item in the times series and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param period the time period to add/update (null not + * permitted). + * @param value the new value (null permitted). + * + * @return A copy of the overwritten data item, or null if no + * item was overwritten. + */ + public TimeSeriesDataItem addOrUpdate(RegularTimePeriod period, + Number value) { + return addOrUpdate(new TimeSeriesDataItem(period, value)); + } + + /** + * Adds or updates an item in the times series and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param item the data item (null not permitted). + * + * @return A copy of the overwritten data item, or null if no + * item was overwritten. + * + * @since 1.0.14 + */ + public TimeSeriesDataItem addOrUpdate(TimeSeriesDataItem item) { + + ParamChecks.nullNotPermitted(item, "item"); + Class periodClass = item.getPeriod().getClass(); + if (this.timePeriodClass == null) { + this.timePeriodClass = periodClass; + } + else if (!this.timePeriodClass.equals(periodClass)) { + String msg = "You are trying to add data where the time " + + "period class is " + periodClass.getName() + + ", but the TimeSeries is expecting an instance of " + + this.timePeriodClass.getName() + "."; + throw new SeriesException(msg); + } + TimeSeriesDataItem overwritten = null; + int index = Collections.binarySearch(this.data, item); + if (index >= 0) { + TimeSeriesDataItem existing + = (TimeSeriesDataItem) this.data.get(index); + overwritten = (TimeSeriesDataItem) existing.clone(); + // figure out if we need to iterate through all the y-values + // to find the revised minY / maxY + boolean iterate = false; + Number oldYN = existing.getValue(); + double oldY = oldYN != null ? oldYN.doubleValue() : Double.NaN; + if (!Double.isNaN(oldY)) { + iterate = oldY <= this.minY || oldY >= this.maxY; + } + existing.setValue(item.getValue()); + if (iterate) { + findBoundsByIteration(); + } + else if (item.getValue() != null) { + double yy = item.getValue().doubleValue(); + this.minY = minIgnoreNaN(this.minY, yy); + this.maxY = maxIgnoreNaN(this.maxY, yy); + } + } + else { + item = (TimeSeriesDataItem) item.clone(); + this.data.add(-index - 1, item); + updateBoundsForAddedItem(item); + + // check if this addition will exceed the maximum item count... + if (getItemCount() > this.maximumItemCount) { + TimeSeriesDataItem d = (TimeSeriesDataItem) this.data.remove(0); + updateBoundsForRemovedItem(d); + } + } + removeAgedItems(false); // remove old items if necessary, but + // don't notify anyone, because that + // happens next anyway... + fireSeriesChanged(); + return overwritten; + + } + + /** + * Age items in the series. Ensure that the timespan from the youngest to + * the oldest record in the series does not exceed maximumItemAge time + * periods. Oldest items will be removed if required. + * + * @param notify controls whether or not a {@link SeriesChangeEvent} is + * sent to registered listeners IF any items are removed. + */ + public void removeAgedItems(boolean notify) { + // check if there are any values earlier than specified by the history + // count... + if (getItemCount() > 1) { + long latest = getTimePeriod(getItemCount() - 1).getSerialIndex(); + boolean removed = false; + while ((latest - getTimePeriod(0).getSerialIndex()) + > this.maximumItemAge) { + this.data.remove(0); + removed = true; + } + if (removed) { + findBoundsByIteration(); + if (notify) { + fireSeriesChanged(); + } + } + } + } + + /** + * Age items in the series. Ensure that the timespan from the supplied + * time to the oldest record in the series does not exceed history count. + * oldest items will be removed if required. + * + * @param latest the time to be compared against when aging data + * (specified in milliseconds). + * @param notify controls whether or not a {@link SeriesChangeEvent} is + * sent to registered listeners IF any items are removed. + */ + public void removeAgedItems(long latest, boolean notify) { + if (this.data.isEmpty()) { + return; // nothing to do + } + // find the serial index of the period specified by 'latest' + long index = Long.MAX_VALUE; + try { + Method m = RegularTimePeriod.class.getDeclaredMethod( + "createInstance", new Class[] {Class.class, Date.class, + TimeZone.class}); + RegularTimePeriod newest = (RegularTimePeriod) m.invoke( + this.timePeriodClass, new Object[] {this.timePeriodClass, + new Date(latest), TimeZone.getDefault()}); + index = newest.getSerialIndex(); + } + catch (NoSuchMethodException e) { + e.printStackTrace(); + } + catch (IllegalAccessException e) { + e.printStackTrace(); + } + catch (InvocationTargetException e) { + e.printStackTrace(); + } + + // check if there are any values earlier than specified by the history + // count... + boolean removed = false; + while (getItemCount() > 0 && (index + - getTimePeriod(0).getSerialIndex()) > this.maximumItemAge) { + this.data.remove(0); + removed = true; + } + if (removed) { + findBoundsByIteration(); + if (notify) { + fireSeriesChanged(); + } + } + } + + /** + * Removes all data items from the series and sends a + * {@link SeriesChangeEvent} to all registered listeners. + */ + public void clear() { + if (this.data.size() > 0) { + this.data.clear(); + this.timePeriodClass = null; + this.minY = Double.NaN; + this.maxY = Double.NaN; + fireSeriesChanged(); + } + } + + /** + * Deletes the data item for the given time period and sends a + * {@link SeriesChangeEvent} to all registered listeners. If there is no + * item with the specified time period, this method does nothing. + * + * @param period the period of the item to delete (null not + * permitted). + */ + public void delete(RegularTimePeriod period) { + int index = getIndex(period); + if (index >= 0) { + TimeSeriesDataItem item = (TimeSeriesDataItem) this.data.remove( + index); + updateBoundsForRemovedItem(item); + if (this.data.isEmpty()) { + this.timePeriodClass = null; + } + fireSeriesChanged(); + } + } + + /** + * Deletes data from start until end index (end inclusive). + * + * @param start the index of the first period to delete. + * @param end the index of the last period to delete. + */ + public void delete(int start, int end) { + delete(start, end, true); + } + + /** + * Deletes data from start until end index (end inclusive). + * + * @param start the index of the first period to delete. + * @param end the index of the last period to delete. + * @param notify notify listeners? + * + * @since 1.0.14 + */ + public void delete(int start, int end, boolean notify) { + if (end < start) { + throw new IllegalArgumentException("Requires start <= end."); + } + for (int i = 0; i <= (end - start); i++) { + this.data.remove(start); + } + findBoundsByIteration(); + if (this.data.isEmpty()) { + this.timePeriodClass = null; + } + if (notify) { + fireSeriesChanged(); + } + } + + /** + * Returns a clone of the time series. + *

+ * Notes: + *

    + *
  • no need to clone the domain and range descriptions, since String + * object is immutable;
  • + *
  • we pass over to the more general method clone(start, end).
  • + *
+ * + * @return A clone of the time series. + * + * @throws CloneNotSupportedException not thrown by this class, but + * subclasses may differ. + */ + @Override + public Object clone() throws CloneNotSupportedException { + TimeSeries clone = (TimeSeries) super.clone(); + clone.data = (List) ObjectUtilities.deepClone(this.data); + return clone; + } + + /** + * Creates a new timeseries by copying a subset of the data in this time + * series. + * + * @param start the index of the first time period to copy. + * @param end the index of the last time period to copy. + * + * @return A series containing a copy of this times series from start until + * end. + * + * @throws CloneNotSupportedException if there is a cloning problem. + */ + public TimeSeries createCopy(int start, int end) + throws CloneNotSupportedException { + if (start < 0) { + throw new IllegalArgumentException("Requires start >= 0."); + } + if (end < start) { + throw new IllegalArgumentException("Requires start <= end."); + } + TimeSeries copy = (TimeSeries) super.clone(); + copy.minY = Double.NaN; + copy.maxY = Double.NaN; + copy.data = new java.util.ArrayList(); + if (this.data.size() > 0) { + for (int index = start; index <= end; index++) { + TimeSeriesDataItem item + = (TimeSeriesDataItem) this.data.get(index); + TimeSeriesDataItem clone = (TimeSeriesDataItem) item.clone(); + try { + copy.add(clone); + } + catch (SeriesException e) { + e.printStackTrace(); + } + } + } + return copy; + } + + /** + * Creates a new timeseries by copying a subset of the data in this time + * series. + * + * @param start the first time period to copy (null not + * permitted). + * @param end the last time period to copy (null not + * permitted). + * + * @return A time series containing a copy of this time series from start + * until end. + * + * @throws CloneNotSupportedException if there is a cloning problem. + */ + public TimeSeries createCopy(RegularTimePeriod start, RegularTimePeriod end) + throws CloneNotSupportedException { + + ParamChecks.nullNotPermitted(start, "start"); + ParamChecks.nullNotPermitted(end, "end"); + if (start.compareTo(end) > 0) { + throw new IllegalArgumentException( + "Requires start on or before end."); + } + boolean emptyRange = false; + int startIndex = getIndex(start); + if (startIndex < 0) { + startIndex = -(startIndex + 1); + if (startIndex == this.data.size()) { + emptyRange = true; // start is after last data item + } + } + int endIndex = getIndex(end); + if (endIndex < 0) { // end period is not in original series + endIndex = -(endIndex + 1); // this is first item AFTER end period + endIndex = endIndex - 1; // so this is last item BEFORE end + } + if ((endIndex < 0) || (endIndex < startIndex)) { + emptyRange = true; + } + if (emptyRange) { + TimeSeries copy = (TimeSeries) super.clone(); + copy.data = new java.util.ArrayList(); + return copy; + } + return createCopy(startIndex, endIndex); + } + + /** + * Tests the series for equality with an arbitrary object. + * + * @param obj the object to test against (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TimeSeries)) { + return false; + } + TimeSeries that = (TimeSeries) obj; + if (!ObjectUtilities.equal(getDomainDescription(), + that.getDomainDescription())) { + return false; + } + if (!ObjectUtilities.equal(getRangeDescription(), + that.getRangeDescription())) { + return false; + } + if (!ObjectUtilities.equal(this.timePeriodClass, + that.timePeriodClass)) { + return false; + } + if (getMaximumItemAge() != that.getMaximumItemAge()) { + return false; + } + if (getMaximumItemCount() != that.getMaximumItemCount()) { + return false; + } + int count = getItemCount(); + if (count != that.getItemCount()) { + return false; + } + if (!ObjectUtilities.equal(this.data, that.data)) { + return false; + } + return super.equals(obj); + } + + /** + * Returns a hash code value for the object. + * + * @return The hashcode + */ + @Override + public int hashCode() { + int result = super.hashCode(); + result = 29 * result + (this.domain != null ? this.domain.hashCode() + : 0); + result = 29 * result + (this.range != null ? this.range.hashCode() : 0); + result = 29 * result + (this.timePeriodClass != null + ? this.timePeriodClass.hashCode() : 0); + // it is too slow to look at every data item, so let's just look at + // the first, middle and last items... + int count = getItemCount(); + if (count > 0) { + TimeSeriesDataItem item = getRawDataItem(0); + result = 29 * result + item.hashCode(); + } + if (count > 1) { + TimeSeriesDataItem item = getRawDataItem(count - 1); + result = 29 * result + item.hashCode(); + } + if (count > 2) { + TimeSeriesDataItem item = getRawDataItem(count / 2); + result = 29 * result + item.hashCode(); + } + result = 29 * result + this.maximumItemCount; + result = 29 * result + (int) this.maximumItemAge; + return result; + } + + /** + * Updates the cached values for the minimum and maximum data values. + * + * @param item the item added (null not permitted). + * + * @since 1.0.14 + */ + private void updateBoundsForAddedItem(TimeSeriesDataItem item) { + Number yN = item.getValue(); + if (item.getValue() != null) { + double y = yN.doubleValue(); + this.minY = minIgnoreNaN(this.minY, y); + this.maxY = maxIgnoreNaN(this.maxY, y); + } + } + + /** + * Updates the cached values for the minimum and maximum data values on + * the basis that the specified item has just been removed. + * + * @param item the item added (null not permitted). + * + * @since 1.0.14 + */ + private void updateBoundsForRemovedItem(TimeSeriesDataItem item) { + Number yN = item.getValue(); + if (yN != null) { + double y = yN.doubleValue(); + if (!Double.isNaN(y)) { + if (y <= this.minY || y >= this.maxY) { + findBoundsByIteration(); + } + } + } + } + + /** + * Finds the bounds of the x and y values for the series, by iterating + * through all the data items. + * + * @since 1.0.14 + */ + private void findBoundsByIteration() { + this.minY = Double.NaN; + this.maxY = Double.NaN; + Iterator iterator = this.data.iterator(); + while (iterator.hasNext()) { + TimeSeriesDataItem item = (TimeSeriesDataItem) iterator.next(); + updateBoundsForAddedItem(item); + } + } + + /** + * A function to find the minimum of two values, but ignoring any + * Double.NaN values. + * + * @param a the first value. + * @param b the second value. + * + * @return The minimum of the two values. + */ + private double minIgnoreNaN(double a, double b) { + if (Double.isNaN(a)) { + return b; + } + if (Double.isNaN(b)) { + return a; + } + return Math.min(a, b); + } + + /** + * A function to find the maximum of two values, but ignoring any + * Double.NaN values. + * + * @param a the first value. + * @param b the second value. + * + * @return The maximum of the two values. + */ + private double maxIgnoreNaN(double a, double b) { + if (Double.isNaN(a)) { + return b; + } + if (Double.isNaN(b)) { + return a; + } + else { + return Math.max(a, b); + } + } + + + /** + * Creates a new (empty) time series with the specified name and class + * of {@link RegularTimePeriod}. + * + * @param name the series name (null not permitted). + * @param timePeriodClass the type of time period (null not + * permitted). + * + * @deprecated As of 1.0.13, it is not necessary to specify the + * timePeriodClass as this will be inferred when the + * first data item is added to the dataset. + */ + public TimeSeries(Comparable name, Class timePeriodClass) { + this(name, DEFAULT_DOMAIN_DESCRIPTION, DEFAULT_RANGE_DESCRIPTION, + timePeriodClass); + } + + /** + * Creates a new time series that contains no data. + *

+ * Descriptions can be specified for the domain and range. One situation + * where this is helpful is when generating a chart for the time series - + * axis labels can be taken from the domain and range description. + * + * @param name the name of the series (null not permitted). + * @param domain the domain description (null permitted). + * @param range the range description (null permitted). + * @param timePeriodClass the type of time period (null not + * permitted). + * + * @deprecated As of 1.0.13, it is not necessary to specify the + * timePeriodClass as this will be inferred when the + * first data item is added to the dataset. + */ + public TimeSeries(Comparable name, String domain, String range, + Class timePeriodClass) { + super(name); + this.domain = domain; + this.range = range; + this.timePeriodClass = timePeriodClass; + this.data = new java.util.ArrayList(); + this.maximumItemCount = Integer.MAX_VALUE; + this.maximumItemAge = Long.MAX_VALUE; + this.minY = Double.NaN; + this.maxY = Double.NaN; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeSeriesCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeSeriesCollection.java new file mode 100755 index 0000000..c67fd5a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeSeriesCollection.java @@ -0,0 +1,838 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * TimeSeriesCollection.java + * ------------------------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-Oct-2001 : Version 1 (DG); + * 18-Oct-2001 : Added implementation of IntervalXYDataSource so that bar plots + * (using numerical axes) can be plotted from time series + * data (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * 15-Nov-2001 : Added getSeries() method. Changed name from TimeSeriesDataset + * to TimeSeriesCollection (DG); + * 07-Dec-2001 : TimeSeries --> BasicTimeSeries (DG); + * 01-Mar-2002 : Added a time zone offset attribute, to enable fast calculation + * of the time period start and end values (DG); + * 29-Mar-2002 : The collection now registers itself with all the time series + * objects as a SeriesChangeListener. Removed redundant + * calculateZoneOffset method (DG); + * 06-Jun-2002 : Added a setting to control whether the x-value supplied in the + * getXValue() method comes from the START, MIDDLE, or END of the + * time period. This is a workaround for JFreeChart, where the + * current date axis always labels the start of a time + * period (DG); + * 24-Jun-2002 : Removed unnecessary import (DG); + * 24-Aug-2002 : Implemented DomainInfo interface, and added the + * DomainIsPointsInTime flag (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 16-Oct-2002 : Added remove methods (DG); + * 10-Jan-2003 : Changed method names in RegularTimePeriod class (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package and implemented + * Serializable (DG); + * 04-Sep-2003 : Added getSeries(String) method (DG); + * 15-Sep-2003 : Added a removeAllSeries() method to match + * XYSeriesCollection (DG); + * 05-May-2004 : Now extends AbstractIntervalXYDataset (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 06-Oct-2004 : Updated for changed in DomainInfo interface (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * 28-Mar-2005 : Fixed bug in getSeries(int) method (1170825) (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 13-Dec-2005 : Deprecated the 'domainIsPointsInTime' flag as it is + * redundant. Fixes bug 1243050 (DG); + * 04-May-2007 : Override getDomainOrder() to indicate that items are sorted + * by x-value (ascending) (DG); + * 08-May-2007 : Added indexOf(TimeSeries) method (DG); + * 18-Jan-2008 : Changed getSeries(String) to getSeries(Comparable) (DG); + * 19-May-2009 : Implemented XYDomainInfo (DG); + * 26-May-2009 : Implemented XYRangeInfo (DG); + * 09-Jun-2009 : Apply some short-cuts to series value lookups (DG); + * 26-Jun-2009 : Fixed clone() (DG); + * 08-Jan-2012 : Fixed getRangeBounds() method (bug 3445507) (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.time; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyVetoException; +import java.beans.VetoableChangeListener; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import java.util.TimeZone; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.DomainInfo; +import org.jfree.data.DomainOrder; +import org.jfree.data.Range; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.Series; +import org.jfree.data.xy.AbstractIntervalXYDataset; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYDomainInfo; +import org.jfree.data.xy.XYRangeInfo; +import org.jfree.util.ObjectUtilities; + +/** + * A collection of time series objects. This class implements the + * {@link XYDataset} interface, as well as the extended + * {@link IntervalXYDataset} interface. This makes it a convenient dataset for + * use with the {@link org.jfree.chart.plot.XYPlot} class. + */ +public class TimeSeriesCollection extends AbstractIntervalXYDataset + implements XYDataset, IntervalXYDataset, DomainInfo, XYDomainInfo, + XYRangeInfo, VetoableChangeListener, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 834149929022371137L; + + /** Storage for the time series. */ + private List data; + + /** A working calendar (to recycle) */ + private Calendar workingCalendar; + + /** + * The point within each time period that is used for the X value when this + * collection is used as an {@link org.jfree.data.xy.XYDataset}. This can + * be the start, middle or end of the time period. + */ + private TimePeriodAnchor xPosition; + + /** + * A flag that indicates that the domain is 'points in time'. If this + * flag is true, only the x-value is used to determine the range of values + * in the domain, the start and end x-values are ignored. + * + * @deprecated No longer used (as of 1.0.1). + */ + private boolean domainIsPointsInTime; + + /** + * Constructs an empty dataset, tied to the default timezone. + */ + public TimeSeriesCollection() { + this(null, TimeZone.getDefault()); + } + + /** + * Constructs an empty dataset, tied to a specific timezone. + * + * @param zone the timezone (null permitted, will use + * TimeZone.getDefault() in that case). + */ + public TimeSeriesCollection(TimeZone zone) { + // FIXME: need a locale as well as a timezone + this(null, zone); + } + + /** + * Constructs a dataset containing a single series (more can be added), + * tied to the default timezone. + * + * @param series the series (null permitted). + */ + public TimeSeriesCollection(TimeSeries series) { + this(series, TimeZone.getDefault()); + } + + /** + * Constructs a dataset containing a single series (more can be added), + * tied to a specific timezone. + * + * @param series a series to add to the collection (null + * permitted). + * @param zone the timezone (null permitted, will use + * TimeZone.getDefault() in that case). + */ + public TimeSeriesCollection(TimeSeries series, TimeZone zone) { + // FIXME: need a locale as well as a timezone + if (zone == null) { + zone = TimeZone.getDefault(); + } + this.workingCalendar = Calendar.getInstance(zone); + this.data = new ArrayList(); + if (series != null) { + this.data.add(series); + series.addChangeListener(this); + } + this.xPosition = TimePeriodAnchor.START; + this.domainIsPointsInTime = true; + + } + + /** + * Returns a flag that controls whether the domain is treated as 'points in + * time'. This flag is used when determining the max and min values for + * the domain. If true, then only the x-values are considered + * for the max and min values. If false, then the start and + * end x-values will also be taken into consideration. + * + * @return The flag. + * + * @deprecated This flag is no longer used (as of 1.0.1). + */ + public boolean getDomainIsPointsInTime() { + return this.domainIsPointsInTime; + } + + /** + * Sets a flag that controls whether the domain is treated as 'points in + * time', or time periods. + * + * @param flag the flag. + * + * @deprecated This flag is no longer used, as of 1.0.1. The + * includeInterval flag in methods such as + * {@link #getDomainBounds(boolean)} makes this unnecessary. + */ + public void setDomainIsPointsInTime(boolean flag) { + this.domainIsPointsInTime = flag; + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Returns the order of the domain values in this dataset. + * + * @return {@link DomainOrder#ASCENDING} + */ + @Override + public DomainOrder getDomainOrder() { + return DomainOrder.ASCENDING; + } + + /** + * Returns the position within each time period that is used for the X + * value when the collection is used as an + * {@link org.jfree.data.xy.XYDataset}. + * + * @return The anchor position (never null). + */ + public TimePeriodAnchor getXPosition() { + return this.xPosition; + } + + /** + * Sets the position within each time period that is used for the X values + * when the collection is used as an {@link XYDataset}, then sends a + * {@link DatasetChangeEvent} is sent to all registered listeners. + * + * @param anchor the anchor position (null not permitted). + */ + public void setXPosition(TimePeriodAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.xPosition = anchor; + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Returns a list of all the series in the collection. + * + * @return The list (which is unmodifiable). + */ + public List getSeries() { + return Collections.unmodifiableList(this.data); + } + + /** + * Returns the number of series in the collection. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.data.size(); + } + + /** + * Returns the index of the specified series, or -1 if that series is not + * present in the dataset. + * + * @param series the series (null not permitted). + * + * @return The series index. + * + * @since 1.0.6 + */ + public int indexOf(TimeSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + return this.data.indexOf(series); + } + + /** + * Returns a series. + * + * @param series the index of the series (zero-based). + * + * @return The series. + */ + public TimeSeries getSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException( + "The 'series' argument is out of bounds (" + series + ")."); + } + return (TimeSeries) this.data.get(series); + } + + /** + * Returns the series with the specified key, or null if + * there is no such series. + * + * @param key the series key (null permitted). + * + * @return The series with the given key. + */ + public TimeSeries getSeries(Comparable key) { + TimeSeries result = null; + Iterator iterator = this.data.iterator(); + while (iterator.hasNext()) { + TimeSeries series = (TimeSeries) iterator.next(); + Comparable k = series.getKey(); + if (k != null && k.equals(key)) { + result = series; + } + } + return result; + } + + /** + * Returns the key for a series. + * + * @param series the index of the series (zero-based). + * + * @return The key for a series. + */ + @Override + public Comparable getSeriesKey(int series) { + // check arguments...delegated + // fetch the series name... + return getSeries(series).getKey(); + } + + /** + * Returns the index of the series with the specified key, or -1 if no + * series has that key. + * + * @param key the key (null not permitted). + * + * @return The index. + * + * @since 1.0.17 + */ + public int getSeriesIndex(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + int seriesCount = getSeriesCount(); + for (int i = 0; i < seriesCount; i++) { + TimeSeries series = (TimeSeries) this.data.get(i); + if (key.equals(series.getKey())) { + return i; + } + } + return -1; + } + + /** + * Adds a series to the collection and sends a {@link DatasetChangeEvent} to + * all registered listeners. + * + * @param series the series (null not permitted). + */ + public void addSeries(TimeSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + this.data.add(series); + series.addChangeListener(this); + series.addVetoableChangeListener(this); + fireDatasetChanged(); + } + + /** + * Removes the specified series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param series the series (null not permitted). + */ + public void removeSeries(TimeSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + this.data.remove(series); + series.removeChangeListener(this); + series.removeVetoableChangeListener(this); + fireDatasetChanged(); + } + + /** + * Removes a series from the collection. + * + * @param index the series index (zero-based). + */ + public void removeSeries(int index) { + TimeSeries series = getSeries(index); + if (series != null) { + removeSeries(series); + } + } + + /** + * Removes all the series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + */ + public void removeAllSeries() { + + // deregister the collection as a change listener to each series in the + // collection + for (int i = 0; i < this.data.size(); i++) { + TimeSeries series = (TimeSeries) this.data.get(i); + series.removeChangeListener(this); + series.removeVetoableChangeListener(this); + } + + // remove all the series from the collection and notify listeners. + this.data.clear(); + fireDatasetChanged(); + + } + + /** + * Returns the number of items in the specified series. This method is + * provided for convenience. + * + * @param series the series index (zero-based). + * + * @return The item count. + */ + @Override + public int getItemCount(int series) { + return getSeries(series).getItemCount(); + } + + /** + * Returns the x-value (as a double primitive) for an item within a series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The x-value. + */ + @Override + public double getXValue(int series, int item) { + TimeSeries s = (TimeSeries) this.data.get(series); + RegularTimePeriod period = s.getTimePeriod(item); + return getX(period); + } + + /** + * Returns the x-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value. + */ + @Override + public Number getX(int series, int item) { + TimeSeries ts = (TimeSeries) this.data.get(series); + RegularTimePeriod period = ts.getTimePeriod(item); + return new Long(getX(period)); + } + + /** + * Returns the x-value for a time period. + * + * @param period the time period (null not permitted). + * + * @return The x-value. + */ + protected synchronized long getX(RegularTimePeriod period) { + long result = 0L; + if (this.xPosition == TimePeriodAnchor.START) { + result = period.getFirstMillisecond(this.workingCalendar); + } + else if (this.xPosition == TimePeriodAnchor.MIDDLE) { + result = period.getMiddleMillisecond(this.workingCalendar); + } + else if (this.xPosition == TimePeriodAnchor.END) { + result = period.getLastMillisecond(this.workingCalendar); + } + return result; + } + + /** + * Returns the starting X value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value. + */ + @Override + public synchronized Number getStartX(int series, int item) { + TimeSeries ts = (TimeSeries) this.data.get(series); + return new Long(ts.getTimePeriod(item).getFirstMillisecond( + this.workingCalendar)); + } + + /** + * Returns the ending X value for the specified series and item. + * + * @param series The series (zero-based index). + * @param item The item (zero-based index). + * + * @return The value. + */ + @Override + public synchronized Number getEndX(int series, int item) { + TimeSeries ts = (TimeSeries) this.data.get(series); + return new Long(ts.getTimePeriod(item).getLastMillisecond( + this.workingCalendar)); + } + + /** + * Returns the y-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value (possibly null). + */ + @Override + public Number getY(int series, int item) { + TimeSeries ts = (TimeSeries) this.data.get(series); + return ts.getValue(item); + } + + /** + * Returns the starting Y value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value (possibly null). + */ + @Override + public Number getStartY(int series, int item) { + return getY(series, item); + } + + /** + * Returns the ending Y value for the specified series and item. + * + * @param series te series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value (possibly null). + */ + @Override + public Number getEndY(int series, int item) { + return getY(series, item); + } + + + /** + * Returns the indices of the two data items surrounding a particular + * millisecond value. + * + * @param series the series index. + * @param milliseconds the time. + * + * @return An array containing the (two) indices of the items surrounding + * the time. + */ + public int[] getSurroundingItems(int series, long milliseconds) { + int[] result = new int[] {-1, -1}; + TimeSeries timeSeries = getSeries(series); + for (int i = 0; i < timeSeries.getItemCount(); i++) { + Number x = getX(series, i); + long m = x.longValue(); + if (m <= milliseconds) { + result[0] = i; + } + if (m >= milliseconds) { + result[1] = i; + break; + } + } + return result; + } + + /** + * Returns the minimum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The minimum value. + */ + @Override + public double getDomainLowerBound(boolean includeInterval) { + double result = Double.NaN; + Range r = getDomainBounds(includeInterval); + if (r != null) { + result = r.getLowerBound(); + } + return result; + } + + /** + * Returns the maximum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The maximum value. + */ + @Override + public double getDomainUpperBound(boolean includeInterval) { + double result = Double.NaN; + Range r = getDomainBounds(includeInterval); + if (r != null) { + result = r.getUpperBound(); + } + return result; + } + + /** + * Returns the range of the values in this dataset's domain. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The range. + */ + @Override + public Range getDomainBounds(boolean includeInterval) { + Range result = null; + Iterator iterator = this.data.iterator(); + while (iterator.hasNext()) { + TimeSeries series = (TimeSeries) iterator.next(); + int count = series.getItemCount(); + if (count > 0) { + RegularTimePeriod start = series.getTimePeriod(0); + RegularTimePeriod end = series.getTimePeriod(count - 1); + Range temp; + if (!includeInterval) { + temp = new Range(getX(start), getX(end)); + } + else { + temp = new Range( + start.getFirstMillisecond(this.workingCalendar), + end.getLastMillisecond(this.workingCalendar)); + } + result = Range.combine(result, temp); + } + } + return result; + } + + /** + * Returns the bounds of the domain values for the specified series. + * + * @param visibleSeriesKeys a list of keys for the visible series. + * @param includeInterval include the x-interval? + * + * @return A range. + * + * @since 1.0.13 + */ + @Override + public Range getDomainBounds(List visibleSeriesKeys, + boolean includeInterval) { + Range result = null; + Iterator iterator = visibleSeriesKeys.iterator(); + while (iterator.hasNext()) { + Comparable seriesKey = (Comparable) iterator.next(); + TimeSeries series = getSeries(seriesKey); + int count = series.getItemCount(); + if (count > 0) { + RegularTimePeriod start = series.getTimePeriod(0); + RegularTimePeriod end = series.getTimePeriod(count - 1); + Range temp; + if (!includeInterval) { + temp = new Range(getX(start), getX(end)); + } + else { + temp = new Range( + start.getFirstMillisecond(this.workingCalendar), + end.getLastMillisecond(this.workingCalendar)); + } + result = Range.combine(result, temp); + } + } + return result; + } + + /** + * Returns the bounds for the y-values in the dataset. + * + * @param includeInterval ignored for this dataset. + * + * @return The range of value in the dataset (possibly null). + * + * @since 1.0.15 + */ + public Range getRangeBounds(boolean includeInterval) { + Range result = null; + Iterator iterator = this.data.iterator(); + while (iterator.hasNext()) { + TimeSeries series = (TimeSeries) iterator.next(); + Range r = new Range(series.getMinY(), series.getMaxY()); + result = Range.combineIgnoringNaN(result, r); + } + return result; + } + + /** + * Returns the bounds for the y-values in the dataset. + * + * @param visibleSeriesKeys the visible series keys. + * @param xRange the x-range (null not permitted). + * @param includeInterval ignored. + * + * @return The bounds. + * + * @since 1.0.14 + */ + @Override + public Range getRangeBounds(List visibleSeriesKeys, Range xRange, + boolean includeInterval) { + Range result = null; + Iterator iterator = visibleSeriesKeys.iterator(); + while (iterator.hasNext()) { + Comparable seriesKey = (Comparable) iterator.next(); + TimeSeries series = getSeries(seriesKey); + Range r = new Range(series.getMinY(), series.getMaxY()); + // FIXME: Here we are ignoring the xRange + result = Range.combineIgnoringNaN(result, r); + } + return result; + } + + /** + * Receives notification that the key for one of the series in the + * collection has changed, and vetos it if the key is already present in + * the collection. + * + * @param e the event. + * + * @since 1.0.17 + */ + @Override + public void vetoableChange(PropertyChangeEvent e) + throws PropertyVetoException { + // if it is not the series name, then we have no interest + if (!"Key".equals(e.getPropertyName())) { + return; + } + + // to be defensive, let's check that the source series does in fact + // belong to this collection + Series s = (Series) e.getSource(); + if (getSeriesIndex(s.getKey()) == -1) { + throw new IllegalStateException("Receiving events from a series " + + "that does not belong to this collection."); + } + // check if the new series name already exists for another series + Comparable key = (Comparable) e.getNewValue(); + if (getSeriesIndex(key) >= 0) { + throw new PropertyVetoException("Duplicate key2", e); + } + } + + /** + * Tests this time series collection for equality with another object. + * + * @param obj the other object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TimeSeriesCollection)) { + return false; + } + TimeSeriesCollection that = (TimeSeriesCollection) obj; + if (this.xPosition != that.xPosition) { + return false; + } + if (this.domainIsPointsInTime != that.domainIsPointsInTime) { + return false; + } + if (!ObjectUtilities.equal(this.data, that.data)) { + return false; + } + return true; + } + + /** + * Returns a hash code value for the object. + * + * @return The hashcode + */ + @Override + public int hashCode() { + int result; + result = this.data.hashCode(); + result = 29 * result + (this.workingCalendar != null + ? this.workingCalendar.hashCode() : 0); + result = 29 * result + (this.xPosition != null + ? this.xPosition.hashCode() : 0); + result = 29 * result + (this.domainIsPointsInTime ? 1 : 0); + return result; + } + + /** + * Returns a clone of this time series collection. + * + * @return A clone. + * + * @throws java.lang.CloneNotSupportedException + */ + @Override + public Object clone() throws CloneNotSupportedException { + TimeSeriesCollection clone = (TimeSeriesCollection) super.clone(); + clone.data = (List) ObjectUtilities.deepClone(this.data); + clone.workingCalendar = (Calendar) this.workingCalendar.clone(); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeSeriesDataItem.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeSeriesDataItem.java new file mode 100755 index 0000000..2581d54 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeSeriesDataItem.java @@ -0,0 +1,236 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * TimeSeriesDataItem.java + * ----------------------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-Oct-2001 : Version 1 (DG); + * 15-Nov-2001 : Updated Javadoc comments (DG); + * 29-Nov-2001 : Added cloning (DG); + * 24-Jun-2002 : Removed unnecessary import (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 13-Mar-2003 : Renamed TimeSeriesDataPair --> TimeSeriesDataItem, moved to + * com.jrefinery.data.time package, implemented Serializable (DG) + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 09-Jun-2009 : Tidied up equals() (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; +import org.jfree.util.ObjectUtilities; + +/** + * Represents one data item in a time series. + *

+ * The time period can be any of the following: + *

    + *
  • {@link Year}
  • + *
  • {@link Quarter}
  • + *
  • {@link Month}
  • + *
  • {@link Week}
  • + *
  • {@link Day}
  • + *
  • {@link Hour}
  • + *
  • {@link Minute}
  • + *
  • {@link Second}
  • + *
  • {@link Millisecond}
  • + *
  • {@link FixedMillisecond}
  • + *
+ * + * The time period is an immutable property of the data item. Data items will + * often be sorted within a list, and allowing the time period to be changed + * could destroy the sort order. + *

+ * Implements the Comparable interface so that standard Java + * sorting can be used to keep the data items in order. + * + */ +public class TimeSeriesDataItem implements Cloneable, Comparable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -2235346966016401302L; + + /** The time period. */ + private RegularTimePeriod period; + + /** The value associated with the time period. */ + private Number value; + + /** + * Constructs a new data item that associates a value with a time period. + * + * @param period the time period (null not permitted). + * @param value the value (null permitted). + */ + public TimeSeriesDataItem(RegularTimePeriod period, Number value) { + ParamChecks.nullNotPermitted(period, "period"); + this.period = period; + this.value = value; + } + + /** + * Constructs a new data item that associates a value with a time period. + * + * @param period the time period (null not permitted). + * @param value the value associated with the time period. + */ + public TimeSeriesDataItem(RegularTimePeriod period, double value) { + this(period, new Double(value)); + } + + /** + * Returns the time period. + * + * @return The time period (never null). + */ + public RegularTimePeriod getPeriod() { + return this.period; + } + + /** + * Returns the value. + * + * @return The value (null possible). + * + * @see #setValue(java.lang.Number) + */ + public Number getValue() { + return this.value; + } + + /** + * Sets the value for this data item. + * + * @param value the value (null permitted). + * + * @see #getValue() + */ + public void setValue(Number value) { + this.value = value; + } + + /** + * Tests this object for equality with an arbitrary object. + * + * @param obj the other object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof TimeSeriesDataItem)) { + return false; + } + TimeSeriesDataItem that = (TimeSeriesDataItem) obj; + if (!ObjectUtilities.equal(this.period, that.period)) { + return false; + } + if (!ObjectUtilities.equal(this.value, that.value)) { + return false; + } + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result; + result = (this.period != null ? this.period.hashCode() : 0); + result = 29 * result + (this.value != null ? this.value.hashCode() : 0); + return result; + } + + /** + * Returns an integer indicating the order of this data pair object + * relative to another object. + *

+ * For the order we consider only the timing: + * negative == before, zero == same, positive == after. + * + * @param o1 The object being compared to. + * + * @return An integer indicating the order of the data item object + * relative to another object. + */ + @Override + public int compareTo(Object o1) { + + int result; + + // CASE 1 : Comparing to another TimeSeriesDataItem object + // ------------------------------------------------------- + if (o1 instanceof TimeSeriesDataItem) { + TimeSeriesDataItem datapair = (TimeSeriesDataItem) o1; + result = getPeriod().compareTo(datapair.getPeriod()); + } + + // CASE 2 : Comparing to a general object + // --------------------------------------------- + else { + // consider time periods to be ordered after general objects + result = 1; + } + + return result; + + } + + /** + * Clones the data item. Note: there is no need to clone the period or + * value since they are immutable classes. + * + * @return A clone of the data item. + */ + @Override + public Object clone() { + Object clone = null; + try { + clone = super.clone(); + } + catch (CloneNotSupportedException e) { // won't get here... + e.printStackTrace(); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeSeriesTableModel.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeSeriesTableModel.java new file mode 100755 index 0000000..83a1c1c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeSeriesTableModel.java @@ -0,0 +1,274 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * TimeSeriesTableModel.java + * ------------------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 14-Nov-2001 : Version 1 (DG); + * 05-Apr-2002 : Removed redundant first column (DG); + * 24-Jun-2002 : Removed unnecessary local variable (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * + */ + +package org.jfree.data.time; + +import javax.swing.table.AbstractTableModel; + +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.data.general.SeriesChangeListener; + +/** + * Wrapper around a time series to convert it to a table model for use in + * a JTable. + */ +public class TimeSeriesTableModel extends AbstractTableModel + implements SeriesChangeListener { + + /** The series. */ + private TimeSeries series; + + /** A flag that controls whether the series is editable. */ + private boolean editable; + + /** The new time period. */ + private RegularTimePeriod newTimePeriod; + + /** The new value. */ + private Number newValue; + + /** + * Default constructor. + */ + public TimeSeriesTableModel() { + this(new TimeSeries("Untitled")); + } + + /** + * Constructs a table model for a time series. + * + * @param series the time series. + */ + public TimeSeriesTableModel(TimeSeries series) { + this(series, false); + } + + /** + * Creates a table model based on a time series. + * + * @param series the time series. + * @param editable if true, the table is editable. + */ + public TimeSeriesTableModel(TimeSeries series, boolean editable) { + this.series = series; + this.series.addChangeListener(this); + this.editable = editable; + } + + /** + * Returns the number of columns in the table model. For this particular + * model, the column count is fixed at 2. + * + * @return The column count. + */ + @Override + public int getColumnCount() { + return 2; + } + + /** + * Returns the column class in the table model. + * + * @param column The column index. + * + * @return The column class in the table model. + */ + @Override + public Class getColumnClass(int column) { + if (column == 0) { + return String.class; + } + else { + if (column == 1) { + return Double.class; + } + else { + return null; + } + } + } + + /** + * Returns the name of a column + * + * @param column the column index. + * + * @return The name of a column. + */ + @Override + public String getColumnName(int column) { + + if (column == 0) { + return "Period:"; + } + else { + if (column == 1) { + return "Value:"; + } + else { + return null; + } + } + + } + + /** + * Returns the number of rows in the table model. + * + * @return The row count. + */ + @Override + public int getRowCount() { + return this.series.getItemCount(); + } + + /** + * Returns the data value for a cell in the table model. + * + * @param row the row number. + * @param column the column number. + * + * @return The data value for a cell in the table model. + */ + @Override + public Object getValueAt(int row, int column) { + + if (row < this.series.getItemCount()) { + if (column == 0) { + return this.series.getTimePeriod(row); + } + else { + if (column == 1) { + return this.series.getValue(row); + } + else { + return null; + } + } + } + else { + if (column == 0) { + return this.newTimePeriod; + } + else { + if (column == 1) { + return this.newValue; + } + else { + return null; + } + } + } + + } + + /** + * Returns a flag indicating whether or not the specified cell is editable. + * + * @param row the row number. + * @param column the column number. + * + * @return true if the specified cell is editable. + */ + @Override + public boolean isCellEditable(int row, int column) { + if (this.editable) { + if ((column == 0) || (column == 1)) { + return true; + } + else { + return false; + } + } + else { + return false; + } + } + + /** + * Updates the time series. + * + * @param value the new value. + * @param row the row. + * @param column the column. + */ + @Override + public void setValueAt(Object value, int row, int column) { + + if (row < this.series.getItemCount()) { + + // update the time series appropriately + if (column == 1) { + try { + Double v = Double.valueOf(value.toString()); + this.series.update(row, v); + + } + catch (NumberFormatException nfe) { + System.err.println("Number format exception"); + } + } + } + else { + if (column == 0) { + // this.series.getClass().valueOf(value.toString()); + this.newTimePeriod = null; + } + else if (column == 1) { + this.newValue = Double.valueOf(value.toString()); + } + } + } + + /** + * Receives notification that the time series has been changed. Responds + * by firing a table data change event. + * + * @param event the event. + */ + @Override + public void seriesChanged(SeriesChangeEvent event) { + fireTableDataChanged(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeTableXYDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeTableXYDataset.java new file mode 100755 index 0000000..9ef7277 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/TimeTableXYDataset.java @@ -0,0 +1,613 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * TimeTableXYDataset.java + * ----------------------- + * (C) Copyright 2004-2013, by Andreas Schroeder and Contributors. + * + * Original Author: Andreas Schroeder; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Rob Eden; + * + * Changes + * ------- + * 01-Apr-2004 : Version 1 (AS); + * 05-May-2004 : Now implements AbstractIntervalXYDataset (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 15-Sep-2004 : Added getXPosition(), setXPosition(), equals() and + * clone() (DG); + * 17-Nov-2004 : Updated methods for changes in DomainInfo interface (DG); + * 25-Nov-2004 : Added getTimePeriod(int) method (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * 27-Jan-2005 : Modified to use TimePeriod rather than RegularTimePeriod (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 25-Jul-2007 : Added clear() method by Rob Eden, see patch 1752205 (DG); + * 04-Jun-2008 : Updated Javadocs (DG); + * 26-May-2009 : Peg to time zone if RegularTimePeriod is used (DG); + * 02-Nov-2009 : Changed String to Comparable in add methods (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.time; + +import java.util.Calendar; +import java.util.List; +import java.util.Locale; +import java.util.TimeZone; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.DefaultKeyedValues2D; +import org.jfree.data.DomainInfo; +import org.jfree.data.Range; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.xy.AbstractIntervalXYDataset; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.TableXYDataset; +import org.jfree.util.PublicCloneable; + +/** + * A dataset for regular time periods that implements the + * {@link TableXYDataset} interface. Note that the {@link TableXYDataset} + * interface requires all series to share the same set of x-values. When + * adding a new item (x, y) to one series, all other series + * automatically get a new item (x, null) unless a non-null item + * has already been specified. + * + * @see org.jfree.data.xy.TableXYDataset + */ +public class TimeTableXYDataset extends AbstractIntervalXYDataset + implements Cloneable, PublicCloneable, IntervalXYDataset, DomainInfo, + TableXYDataset { + + /** + * The data structure to store the values. Each column represents + * a series (elsewhere in JFreeChart rows are typically used for series, + * but it doesn't matter that much since this data structure is private + * and symmetrical anyway), each row contains values for the same + * {@link RegularTimePeriod} (the rows are sorted into ascending order). + */ + private DefaultKeyedValues2D values; + + /** + * A flag that indicates that the domain is 'points in time'. If this flag + * is true, only the x-value (and not the x-interval) is used to determine + * the range of values in the domain. + */ + private boolean domainIsPointsInTime; + + /** + * The point within each time period that is used for the X value when this + * collection is used as an {@link org.jfree.data.xy.XYDataset}. This can + * be the start, middle or end of the time period. + */ + private TimePeriodAnchor xPosition; + + /** A working calendar (to recycle) */ + private Calendar workingCalendar; + + /** + * Creates a new dataset. + */ + public TimeTableXYDataset() { + // defer argument checking + this(TimeZone.getDefault(), Locale.getDefault()); + } + + /** + * Creates a new dataset with the given time zone. + * + * @param zone the time zone to use (null not permitted). + */ + public TimeTableXYDataset(TimeZone zone) { + // defer argument checking + this(zone, Locale.getDefault()); + } + + /** + * Creates a new dataset with the given time zone and locale. + * + * @param zone the time zone to use (null not permitted). + * @param locale the locale to use (null not permitted). + */ + public TimeTableXYDataset(TimeZone zone, Locale locale) { + ParamChecks.nullNotPermitted(zone, "zone"); + ParamChecks.nullNotPermitted(locale, "locale"); + this.values = new DefaultKeyedValues2D(true); + this.workingCalendar = Calendar.getInstance(zone, locale); + this.xPosition = TimePeriodAnchor.START; + } + + /** + * Returns a flag that controls whether the domain is treated as 'points in + * time'. + *

+ * This flag is used when determining the max and min values for the domain. + * If true, then only the x-values are considered for the max and min + * values. If false, then the start and end x-values will also be taken + * into consideration. + * + * @return The flag. + * + * @see #setDomainIsPointsInTime(boolean) + */ + public boolean getDomainIsPointsInTime() { + return this.domainIsPointsInTime; + } + + /** + * Sets a flag that controls whether the domain is treated as 'points in + * time', or time periods. A {@link DatasetChangeEvent} is sent to all + * registered listeners. + * + * @param flag the new value of the flag. + * + * @see #getDomainIsPointsInTime() + */ + public void setDomainIsPointsInTime(boolean flag) { + this.domainIsPointsInTime = flag; + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Returns the position within each time period that is used for the X + * value. + * + * @return The anchor position (never null). + * + * @see #setXPosition(TimePeriodAnchor) + */ + public TimePeriodAnchor getXPosition() { + return this.xPosition; + } + + /** + * Sets the position within each time period that is used for the X values, + * then sends a {@link DatasetChangeEvent} to all registered listeners. + * + * @param anchor the anchor position (null not permitted). + * + * @see #getXPosition() + */ + public void setXPosition(TimePeriodAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.xPosition = anchor; + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Adds a new data item to the dataset and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param period the time period. + * @param y the value for this period. + * @param seriesName the name of the series to add the value. + * + * @see #remove(TimePeriod, Comparable) + */ + public void add(TimePeriod period, double y, Comparable seriesName) { + add(period, new Double(y), seriesName, true); + } + + /** + * Adds a new data item to the dataset and, if requested, sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param period the time period (null not permitted). + * @param y the value for this period (null permitted). + * @param seriesName the name of the series to add the value + * (null not permitted). + * @param notify whether dataset listener are notified or not. + * + * @see #remove(TimePeriod, Comparable, boolean) + */ + public void add(TimePeriod period, Number y, Comparable seriesName, + boolean notify) { + // here's a quirk - the API has been defined in terms of a plain + // TimePeriod, which cannot make use of the timezone and locale + // specified in the constructor...so we only do the time zone + // pegging if the period is an instanceof RegularTimePeriod + if (period instanceof RegularTimePeriod) { + RegularTimePeriod p = (RegularTimePeriod) period; + p.peg(this.workingCalendar); + } + this.values.addValue(y, period, seriesName); + if (notify) { + fireDatasetChanged(); + } + } + + /** + * Removes an existing data item from the dataset. + * + * @param period the (existing!) time period of the value to remove + * (null not permitted). + * @param seriesName the (existing!) series name to remove the value + * (null not permitted). + * + * @see #add(TimePeriod, double, Comparable) + */ + public void remove(TimePeriod period, Comparable seriesName) { + remove(period, seriesName, true); + } + + /** + * Removes an existing data item from the dataset and, if requested, + * sends a {@link DatasetChangeEvent} to all registered listeners. + * + * @param period the (existing!) time period of the value to remove + * (null not permitted). + * @param seriesName the (existing!) series name to remove the value + * (null not permitted). + * @param notify whether dataset listener are notified or not. + * + * @see #add(TimePeriod, double, Comparable) + */ + public void remove(TimePeriod period, Comparable seriesName, + boolean notify) { + this.values.removeValue(period, seriesName); + if (notify) { + fireDatasetChanged(); + } + } + + /** + * Removes all data items from the dataset and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @since 1.0.7 + */ + public void clear() { + if (this.values.getRowCount() > 0) { + this.values.clear(); + fireDatasetChanged(); + } + } + + /** + * Returns the time period for the specified item. Bear in mind that all + * series share the same set of time periods. + * + * @param item the item index (0 <= i <= {@link #getItemCount()}). + * + * @return The time period. + */ + public TimePeriod getTimePeriod(int item) { + return (TimePeriod) this.values.getRowKey(item); + } + + /** + * Returns the number of items in ALL series. + * + * @return The item count. + */ + @Override + public int getItemCount() { + return this.values.getRowCount(); + } + + /** + * Returns the number of items in a series. This is the same value + * that is returned by {@link #getItemCount()} since all series + * share the same x-values (time periods). + * + * @param series the series (zero-based index, ignored). + * + * @return The number of items within the series. + */ + @Override + public int getItemCount(int series) { + return getItemCount(); + } + + /** + * Returns the number of series in the dataset. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.values.getColumnCount(); + } + + /** + * Returns the key for a series. + * + * @param series the series (zero-based index). + * + * @return The key for the series. + */ + @Override + public Comparable getSeriesKey(int series) { + return this.values.getColumnKey(series); + } + + /** + * Returns the x-value for an item within a series. The x-values may or + * may not be returned in ascending order, that is up to the class + * implementing the interface. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The x-value. + */ + @Override + public Number getX(int series, int item) { + return new Double(getXValue(series, item)); + } + + /** + * Returns the x-value (as a double primitive) for an item within a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getXValue(int series, int item) { + TimePeriod period = (TimePeriod) this.values.getRowKey(item); + return getXValue(period); + } + + /** + * Returns the starting X value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item within a series (zero-based index). + * + * @return The starting X value for the specified series and item. + * + * @see #getStartXValue(int, int) + */ + @Override + public Number getStartX(int series, int item) { + return new Double(getStartXValue(series, item)); + } + + /** + * Returns the start x-value (as a double primitive) for an item within + * a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getStartXValue(int series, int item) { + TimePeriod period = (TimePeriod) this.values.getRowKey(item); + return period.getStart().getTime(); + } + + /** + * Returns the ending X value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item within a series (zero-based index). + * + * @return The ending X value for the specified series and item. + * + * @see #getEndXValue(int, int) + */ + @Override + public Number getEndX(int series, int item) { + return new Double(getEndXValue(series, item)); + } + + /** + * Returns the end x-value (as a double primitive) for an item within + * a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getEndXValue(int series, int item) { + TimePeriod period = (TimePeriod) this.values.getRowKey(item); + return period.getEnd().getTime(); + } + + /** + * Returns the y-value for an item within a series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The y-value (possibly null). + */ + @Override + public Number getY(int series, int item) { + return this.values.getValue(item, series); + } + + /** + * Returns the starting Y value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item within a series (zero-based index). + * + * @return The starting Y value for the specified series and item. + */ + @Override + public Number getStartY(int series, int item) { + return getY(series, item); + } + + /** + * Returns the ending Y value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item within a series (zero-based index). + * + * @return The ending Y value for the specified series and item. + */ + @Override + public Number getEndY(int series, int item) { + return getY(series, item); + } + + /** + * Returns the x-value for a time period. + * + * @param period the time period. + * + * @return The x-value. + */ + private long getXValue(TimePeriod period) { + long result = 0L; + if (this.xPosition == TimePeriodAnchor.START) { + result = period.getStart().getTime(); + } + else if (this.xPosition == TimePeriodAnchor.MIDDLE) { + long t0 = period.getStart().getTime(); + long t1 = period.getEnd().getTime(); + result = t0 + (t1 - t0) / 2L; + } + else if (this.xPosition == TimePeriodAnchor.END) { + result = period.getEnd().getTime(); + } + return result; + } + + /** + * Returns the minimum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The minimum value. + */ + @Override + public double getDomainLowerBound(boolean includeInterval) { + double result = Double.NaN; + Range r = getDomainBounds(includeInterval); + if (r != null) { + result = r.getLowerBound(); + } + return result; + } + + /** + * Returns the maximum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The maximum value. + */ + @Override + public double getDomainUpperBound(boolean includeInterval) { + double result = Double.NaN; + Range r = getDomainBounds(includeInterval); + if (r != null) { + result = r.getUpperBound(); + } + return result; + } + + /** + * Returns the range of the values in this dataset's domain. + * + * @param includeInterval a flag that controls whether or not the + * x-intervals are taken into account. + * + * @return The range. + */ + @Override + public Range getDomainBounds(boolean includeInterval) { + List keys = this.values.getRowKeys(); + if (keys.isEmpty()) { + return null; + } + + TimePeriod first = (TimePeriod) keys.get(0); + TimePeriod last = (TimePeriod) keys.get(keys.size() - 1); + + if (!includeInterval || this.domainIsPointsInTime) { + return new Range(getXValue(first), getXValue(last)); + } + else { + return new Range(first.getStart().getTime(), + last.getEnd().getTime()); + } + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TimeTableXYDataset)) { + return false; + } + TimeTableXYDataset that = (TimeTableXYDataset) obj; + if (this.domainIsPointsInTime != that.domainIsPointsInTime) { + return false; + } + if (this.xPosition != that.xPosition) { + return false; + } + if (!this.workingCalendar.getTimeZone().equals( + that.workingCalendar.getTimeZone()) + ) { + return false; + } + if (!this.values.equals(that.values)) { + return false; + } + return true; + } + + /** + * Returns a clone of this dataset. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the dataset cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + TimeTableXYDataset clone = (TimeTableXYDataset) super.clone(); + clone.values = (DefaultKeyedValues2D) this.values.clone(); + clone.workingCalendar = (Calendar) this.workingCalendar.clone(); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Week.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Week.java new file mode 100755 index 0000000..71c1cb5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Week.java @@ -0,0 +1,659 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------- + * Week.java + * --------- + * (C) Copyright 2001-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Aimin Han; + * + * Changes + * ------- + * 11-Oct-2001 : Version 1 (DG); + * 18-Dec-2001 : Changed order of parameters in constructor (DG); + * 19-Dec-2001 : Added a new constructor as suggested by Paul English (DG); + * 29-Jan-2002 : Worked on the parseWeek() method (DG); + * 13-Feb-2002 : Fixed bug in Week(Date) constructor (DG); + * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to + * evaluate with reference to a particular time zone (DG); + * 05-Apr-2002 : Reinstated this class to the JCommon library (DG); + * 24-Jun-2002 : Removed unnecessary main method (DG); + * 10-Sep-2002 : Added getSerialIndex() method (DG); + * 06-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 18-Oct-2002 : Changed to observe 52 or 53 weeks per year, consistent with + * GregorianCalendar. Thanks to Aimin Han for the code (DG); + * 02-Jan-2003 : Removed debug code (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package, and implemented + * Serializable (DG); + * 21-Oct-2003 : Added hashCode() method (DG); + * 24-May-2004 : Modified getFirstMillisecond() and getLastMillisecond() to + * take account of firstDayOfWeek setting in Java's Calendar + * class (DG); + * 30-Sep-2004 : Replaced getTime().getTime() with getTimeInMillis() (DG); + * 04-Nov-2004 : Reverted change of 30-Sep-2004, because it won't work for + * JDK 1.3 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 06-Mar-2006 : Fix for bug 1448828, incorrect calculation of week and year + * for the first few days of some years (DG); + * 05-Oct-2006 : Updated API docs (DG); + * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); + * 09-Jan-2007 : Fixed bug in next() (DG); + * 28-Aug-2007 : Added new constructor to avoid problem in creating new + * instances (DG); + * 19-Dec-2007 : Fixed bug in deprecated constructor (DG); + * 16-Sep-2008 : Deprecated DEFAULT_TIME_ZONE (DG); + * 05-Jul-2012 : Replaced getTime().getTime() with getTimeInMillis() (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; +import org.jfree.chart.util.ParamChecks; + +/** + * A calendar week. All years are considered to have 53 weeks, numbered from 1 + * to 53, although in many cases the 53rd week is empty. Most of the time, the + * 1st week of the year *begins* in the previous calendar year, but it always + * finishes in the current year (this behaviour matches the workings of the + * GregorianCalendar class). + *

+ * This class is immutable, which is a requirement for all + * {@link RegularTimePeriod} subclasses. + */ +public class Week extends RegularTimePeriod implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 1856387786939865061L; + + /** Constant for the first week in the year. */ + public static final int FIRST_WEEK_IN_YEAR = 1; + + /** Constant for the last week in the year. */ + public static final int LAST_WEEK_IN_YEAR = 53; + + /** The year in which the week falls. */ + private short year; + + /** The week (1-53). */ + private byte week; + + /** The first millisecond. */ + private long firstMillisecond; + + /** The last millisecond. */ + private long lastMillisecond; + + /** + * Creates a new time period for the week in which the current system + * date/time falls. + */ + public Week() { + this(new Date()); + } + + /** + * Creates a time period representing the week in the specified year. + * + * @param week the week (1 to 53). + * @param year the year (1900 to 9999). + */ + public Week(int week, int year) { + if ((week < FIRST_WEEK_IN_YEAR) && (week > LAST_WEEK_IN_YEAR)) { + throw new IllegalArgumentException( + "The 'week' argument must be in the range 1 - 53."); + } + this.week = (byte) week; + this.year = (short) year; + peg(Calendar.getInstance()); + } + + /** + * Creates a time period representing the week in the specified year. + * + * @param week the week (1 to 53). + * @param year the year (1900 to 9999). + */ + public Week(int week, Year year) { + if ((week < FIRST_WEEK_IN_YEAR) && (week > LAST_WEEK_IN_YEAR)) { + throw new IllegalArgumentException( + "The 'week' argument must be in the range 1 - 53."); + } + this.week = (byte) week; + this.year = (short) year.getYear(); + peg(Calendar.getInstance()); + } + + /** + * Creates a time period for the week in which the specified date/time + * falls, using the default time zone and locale (the locale can affect the + * day-of-the-week that marks the beginning of the week, as well as the + * minimal number of days in the first week of the year). + * + * @param time the time (null not permitted). + * + * @see #Week(Date, TimeZone, Locale) + */ + public Week(Date time) { + // defer argument checking... + this(time, TimeZone.getDefault(), Locale.getDefault()); + } + + /** + * Creates a time period for the week in which the specified date/time + * falls, calculated relative to the specified time zone. + * + * @param time the date/time (null not permitted). + * @param zone the time zone (null not permitted). + * + * @deprecated As of 1.0.7, use {@link #Week(Date, TimeZone, Locale)}. + */ + public Week(Date time, TimeZone zone) { + // defer argument checking... + this(time, zone, Locale.getDefault()); + } + + /** + * Creates a time period for the week in which the specified date/time + * falls, calculated relative to the specified time zone. + * + * @param time the date/time (null not permitted). + * @param zone the time zone (null not permitted). + * @param locale the locale (null not permitted). + * + * @since 1.0.7 + */ + public Week(Date time, TimeZone zone, Locale locale) { + ParamChecks.nullNotPermitted(time, "time"); + ParamChecks.nullNotPermitted(zone, "zone"); + ParamChecks.nullNotPermitted(locale, "locale"); + Calendar calendar = Calendar.getInstance(zone, locale); + calendar.setTime(time); + + // sometimes the last few days of the year are considered to fall in + // the *first* week of the following year. Refer to the Javadocs for + // GregorianCalendar. + int tempWeek = calendar.get(Calendar.WEEK_OF_YEAR); + if (tempWeek == 1 + && calendar.get(Calendar.MONTH) == Calendar.DECEMBER) { + this.week = 1; + this.year = (short) (calendar.get(Calendar.YEAR) + 1); + } + else { + this.week = (byte) Math.min(tempWeek, LAST_WEEK_IN_YEAR); + int yyyy = calendar.get(Calendar.YEAR); + // alternatively, sometimes the first few days of the year are + // considered to fall in the *last* week of the previous year... + if (calendar.get(Calendar.MONTH) == Calendar.JANUARY + && this.week >= 52) { + yyyy--; + } + this.year = (short) yyyy; + } + peg(calendar); + } + + /** + * Returns the year in which the week falls. + * + * @return The year (never null). + */ + public Year getYear() { + return new Year(this.year); + } + + /** + * Returns the year in which the week falls, as an integer value. + * + * @return The year. + */ + public int getYearValue() { + return this.year; + } + + /** + * Returns the week. + * + * @return The week. + */ + public int getWeek() { + return this.week; + } + + /** + * Returns the first millisecond of the week. This will be determined + * relative to the time zone specified in the constructor, or in the + * calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The first millisecond of the week. + * + * @see #getLastMillisecond() + */ + @Override + public long getFirstMillisecond() { + return this.firstMillisecond; + } + + /** + * Returns the last millisecond of the week. This will be + * determined relative to the time zone specified in the constructor, or + * in the calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The last millisecond of the week. + * + * @see #getFirstMillisecond() + */ + @Override + public long getLastMillisecond() { + return this.lastMillisecond; + } + + /** + * Recalculates the start date/time and end date/time for this time period + * relative to the supplied calendar (which incorporates a time zone). + * + * @param calendar the calendar (null not permitted). + * + * @since 1.0.3 + */ + @Override + public void peg(Calendar calendar) { + this.firstMillisecond = getFirstMillisecond(calendar); + this.lastMillisecond = getLastMillisecond(calendar); + } + + /** + * Returns the week preceding this one. This method will return + * null for some lower limit on the range of weeks (currently + * week 1, 1900). For week 1 of any year, the previous week is always week + * 53, but week 53 may not contain any days (you should check for this). + * + * @return The preceding week (possibly null). + */ + @Override + public RegularTimePeriod previous() { + + Week result; + if (this.week != FIRST_WEEK_IN_YEAR) { + result = new Week(this.week - 1, this.year); + } + else { + // we need to work out if the previous year has 52 or 53 weeks... + if (this.year > 1900) { + int yy = this.year - 1; + Calendar prevYearCalendar = Calendar.getInstance(); + prevYearCalendar.set(yy, Calendar.DECEMBER, 31); + result = new Week(prevYearCalendar.getActualMaximum( + Calendar.WEEK_OF_YEAR), yy); + } + else { + result = null; + } + } + return result; + + } + + /** + * Returns the week following this one. This method will return + * null for some upper limit on the range of weeks (currently + * week 53, 9999). For week 52 of any year, the following week is always + * week 53, but week 53 may not contain any days (you should check for + * this). + * + * @return The following week (possibly null). + */ + @Override + public RegularTimePeriod next() { + + Week result; + if (this.week < 52) { + result = new Week(this.week + 1, this.year); + } + else { + Calendar calendar = Calendar.getInstance(); + calendar.set(this.year, Calendar.DECEMBER, 31); + int actualMaxWeek + = calendar.getActualMaximum(Calendar.WEEK_OF_YEAR); + if (this.week < actualMaxWeek) { + result = new Week(this.week + 1, this.year); + } + else { + if (this.year < 9999) { + result = new Week(FIRST_WEEK_IN_YEAR, this.year + 1); + } + else { + result = null; + } + } + } + return result; + + } + + /** + * Returns a serial index number for the week. + * + * @return The serial index number. + */ + @Override + public long getSerialIndex() { + return this.year * 53L + this.week; + } + + /** + * Returns the first millisecond of the week, evaluated using the supplied + * calendar (which determines the time zone). + * + * @param calendar the calendar (null not permitted). + * + * @return The first millisecond of the week. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getFirstMillisecond(Calendar calendar) { + Calendar c = (Calendar) calendar.clone(); + c.clear(); + c.set(Calendar.YEAR, this.year); + c.set(Calendar.WEEK_OF_YEAR, this.week); + c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); + c.set(Calendar.HOUR, 0); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + c.set(Calendar.MILLISECOND, 0); + return c.getTimeInMillis(); + } + + /** + * Returns the last millisecond of the week, evaluated using the supplied + * calendar (which determines the time zone). + * + * @param calendar the calendar (null not permitted). + * + * @return The last millisecond of the week. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getLastMillisecond(Calendar calendar) { + Calendar c = (Calendar) calendar.clone(); + c.clear(); + c.set(Calendar.YEAR, this.year); + c.set(Calendar.WEEK_OF_YEAR, this.week + 1); + c.set(Calendar.DAY_OF_WEEK, c.getFirstDayOfWeek()); + c.set(Calendar.HOUR, 0); + c.set(Calendar.MINUTE, 0); + c.set(Calendar.SECOND, 0); + c.set(Calendar.MILLISECOND, 0); + return c.getTimeInMillis() - 1; + } + + /** + * Returns a string representing the week (e.g. "Week 9, 2002"). + * + * TODO: look at internationalisation. + * + * @return A string representing the week. + */ + @Override + public String toString() { + return "Week " + this.week + ", " + this.year; + } + + /** + * Tests the equality of this Week object to an arbitrary object. Returns + * true if the target is a Week instance representing the same week as this + * object. In all other cases, returns false. + * + * @param obj the object (null permitted). + * + * @return true if week and year of this and object are the + * same. + */ + @Override + public boolean equals(Object obj) { + + if (obj == this) { + return true; + } + if (!(obj instanceof Week)) { + return false; + } + Week that = (Week) obj; + if (this.week != that.week) { + return false; + } + if (this.year != that.year) { + return false; + } + return true; + + } + + /** + * Returns a hash code for this object instance. The approach described by + * Joshua Bloch in "Effective Java" has been used here: + *

+ * http://developer.java.sun.com/developer/Books/effectivejava + * /Chapter3.pdf + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 17; + result = 37 * result + this.week; + result = 37 * result + this.year; + return result; + } + + /** + * Returns an integer indicating the order of this Week object relative to + * the specified object: + * + * negative == before, zero == same, positive == after. + * + * @param o1 the object to compare. + * + * @return negative == before, zero == same, positive == after. + */ + @Override + public int compareTo(Object o1) { + + int result; + + // CASE 1 : Comparing to another Week object + // -------------------------------------------- + if (o1 instanceof Week) { + Week w = (Week) o1; + result = this.year - w.getYear().getYear(); + if (result == 0) { + result = this.week - w.getWeek(); + } + } + + // CASE 2 : Comparing to another TimePeriod object + // ----------------------------------------------- + else if (o1 instanceof RegularTimePeriod) { + // more difficult case - evaluate later... + result = 0; + } + + // CASE 3 : Comparing to a non-TimePeriod object + // --------------------------------------------- + else { + // consider time periods to be ordered after general objects + result = 1; + } + + return result; + + } + + /** + * Parses the string argument as a week. + *

+ * This method is required to accept the format "YYYY-Wnn". It will also + * accept "Wnn-YYYY". Anything else, at the moment, is a bonus. + * + * @param s string to parse. + * + * @return null if the string is not parseable, the week + * otherwise. + */ + public static Week parseWeek(String s) { + + Week result = null; + if (s != null) { + + // trim whitespace from either end of the string + s = s.trim(); + + int i = Week.findSeparator(s); + if (i != -1) { + String s1 = s.substring(0, i).trim(); + String s2 = s.substring(i + 1, s.length()).trim(); + + Year y = Week.evaluateAsYear(s1); + int w; + if (y != null) { + w = Week.stringToWeek(s2); + if (w == -1) { + throw new TimePeriodFormatException( + "Can't evaluate the week."); + } + result = new Week(w, y); + } + else { + y = Week.evaluateAsYear(s2); + if (y != null) { + w = Week.stringToWeek(s1); + if (w == -1) { + throw new TimePeriodFormatException( + "Can't evaluate the week."); + } + result = new Week(w, y); + } + else { + throw new TimePeriodFormatException( + "Can't evaluate the year."); + } + } + + } + else { + throw new TimePeriodFormatException( + "Could not find separator."); + } + + } + return result; + + } + + /** + * Finds the first occurrence of ' ', '-', ',' or '.' + * + * @param s the string to parse. + * + * @return -1 if none of the characters was found, the + * index of the first occurrence otherwise. + */ + private static int findSeparator(String s) { + + int result = s.indexOf('-'); + if (result == -1) { + result = s.indexOf(','); + } + if (result == -1) { + result = s.indexOf(' '); + } + if (result == -1) { + result = s.indexOf('.'); + } + return result; + } + + /** + * Creates a year from a string, or returns null (format exceptions + * suppressed). + * + * @param s string to parse. + * + * @return null if the string is not parseable, the year + * otherwise. + */ + private static Year evaluateAsYear(String s) { + + Year result = null; + try { + result = Year.parseYear(s); + } + catch (TimePeriodFormatException e) { + // suppress + } + return result; + + } + + /** + * Converts a string to a week. + * + * @param s the string to parse. + * @return -1 if the string does not contain a week number, + * the number of the week otherwise. + */ + private static int stringToWeek(String s) { + + int result = -1; + s = s.replace('W', ' '); + s = s.trim(); + try { + result = Integer.parseInt(s); + if ((result < 1) || (result > LAST_WEEK_IN_YEAR)) { + result = -1; + } + } + catch (NumberFormatException e) { + // suppress + } + return result; + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Year.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Year.java new file mode 100755 index 0000000..e18576b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/Year.java @@ -0,0 +1,419 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------- + * Year.java + * --------- + * (C) Copyright 2001-2012, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-Oct-2001 : Version 1 (DG); + * 14-Nov-2001 : Override for toString() method (DG); + * 19-Dec-2001 : Added a new constructor as suggested by Paul English (DG); + * 29-Jan-2002 : Worked on parseYear() method (DG); + * 14-Feb-2002 : Fixed bug in Year(Date) constructor (DG); + * 26-Feb-2002 : Changed getStart(), getMiddle() and getEnd() methods to + * evaluate with reference to a particular time zone (DG); + * 19-Mar-2002 : Changed API for TimePeriod classes (DG); + * 10-Sep-2002 : Added getSerialIndex() method (DG); + * 04-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 10-Jan-2003 : Changed base class and method names (DG); + * 05-Mar-2003 : Fixed bug in getFirstMillisecond() picked up in JUnit + * tests (DG); + * 13-Mar-2003 : Moved to com.jrefinery.data.time package, and implemented + * Serializable (DG); + * 21-Oct-2003 : Added hashCode() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 05-Oct-2006 : Updated API docs (DG); + * 06-Oct-2006 : Refactored to cache first and last millisecond values (DG); + * 16-Sep-2008 : Extended range of valid years, and deprecated + * DEFAULT_TIME_ZONE (DG); + * 25-Nov-2008 : Added new constructor with Locale (DG); + * 05-Jul-2012 : Removed JRE 1.3.1 code (DG); + * + */ + +package org.jfree.data.time; + +import java.io.Serializable; +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +/** + * Represents a year in the range -9999 to 9999. This class is immutable, + * which is a requirement for all {@link RegularTimePeriod} subclasses. + */ +public class Year extends RegularTimePeriod implements Serializable { + + /** + * The minimum year value. + * + * @since 1.0.11 + */ + public static final int MINIMUM_YEAR = -9999; + + /** + * The maximum year value. + * + * @since 1.0.11 + */ + public static final int MAXIMUM_YEAR = 9999; + + /** For serialization. */ + private static final long serialVersionUID = -7659990929736074836L; + + /** The year. */ + private short year; + + /** The first millisecond. */ + private long firstMillisecond; + + /** The last millisecond. */ + private long lastMillisecond; + + /** + * Creates a new Year, based on the current system date/time. + */ + public Year() { + this(new Date()); + } + + /** + * Creates a time period representing a single year. + * + * @param year the year. + */ + public Year(int year) { + if ((year < Year.MINIMUM_YEAR) || (year > Year.MAXIMUM_YEAR)) { + throw new IllegalArgumentException( + "Year constructor: year (" + year + ") outside valid range."); + } + this.year = (short) year; + peg(Calendar.getInstance()); + } + + /** + * Creates a new Year, based on a particular instant in time, + * using the default time zone. + * + * @param time the time (null not permitted). + * + * @see #Year(Date, TimeZone) + */ + public Year(Date time) { + this(time, TimeZone.getDefault()); + } + + /** + * Constructs a year, based on a particular instant in time and a time zone. + * + * @param time the time (null not permitted). + * @param zone the time zone. + * + * @deprecated Since 1.0.12, use {@link #Year(Date, TimeZone, Locale)} + * instead. + */ + public Year(Date time, TimeZone zone) { + this(time, zone, Locale.getDefault()); + } + + /** + * Creates a new Year instance, for the specified time zone + * and locale. + * + * @param time the current time (null not permitted). + * @param zone the time zone. + * @param locale the locale. + * + * @since 1.0.12 + */ + public Year(Date time, TimeZone zone, Locale locale) { + Calendar calendar = Calendar.getInstance(zone, locale); + calendar.setTime(time); + this.year = (short) calendar.get(Calendar.YEAR); + peg(calendar); + } + + /** + * Returns the year. + * + * @return The year. + */ + public int getYear() { + return this.year; + } + + /** + * Returns the first millisecond of the year. This will be determined + * relative to the time zone specified in the constructor, or in the + * calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The first millisecond of the year. + * + * @see #getLastMillisecond() + */ + @Override + public long getFirstMillisecond() { + return this.firstMillisecond; + } + + /** + * Returns the last millisecond of the year. This will be + * determined relative to the time zone specified in the constructor, or + * in the calendar instance passed in the most recent call to the + * {@link #peg(Calendar)} method. + * + * @return The last millisecond of the year. + * + * @see #getFirstMillisecond() + */ + @Override + public long getLastMillisecond() { + return this.lastMillisecond; + } + + /** + * Recalculates the start date/time and end date/time for this time period + * relative to the supplied calendar (which incorporates a time zone). + * + * @param calendar the calendar (null not permitted). + * + * @since 1.0.3 + */ + @Override + public void peg(Calendar calendar) { + this.firstMillisecond = getFirstMillisecond(calendar); + this.lastMillisecond = getLastMillisecond(calendar); + } + + /** + * Returns the year preceding this one. + * + * @return The year preceding this one (or null if the + * current year is -9999). + */ + @Override + public RegularTimePeriod previous() { + if (this.year > Year.MINIMUM_YEAR) { + return new Year(this.year - 1); + } + else { + return null; + } + } + + /** + * Returns the year following this one. + * + * @return The year following this one (or null if the current + * year is 9999). + */ + @Override + public RegularTimePeriod next() { + if (this.year < Year.MAXIMUM_YEAR) { + return new Year(this.year + 1); + } + else { + return null; + } + } + + /** + * Returns a serial index number for the year. + *

+ * The implementation simply returns the year number (e.g. 2002). + * + * @return The serial index number. + */ + @Override + public long getSerialIndex() { + return this.year; + } + + /** + * Returns the first millisecond of the year, evaluated using the supplied + * calendar (which determines the time zone). + * + * @param calendar the calendar (null not permitted). + * + * @return The first millisecond of the year. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getFirstMillisecond(Calendar calendar) { + calendar.set(this.year, Calendar.JANUARY, 1, 0, 0, 0); + calendar.set(Calendar.MILLISECOND, 0); + return calendar.getTimeInMillis(); + } + + /** + * Returns the last millisecond of the year, evaluated using the supplied + * calendar (which determines the time zone). + * + * @param calendar the calendar (null not permitted). + * + * @return The last millisecond of the year. + * + * @throws NullPointerException if calendar is + * null. + */ + @Override + public long getLastMillisecond(Calendar calendar) { + calendar.set(this.year, Calendar.DECEMBER, 31, 23, 59, 59); + calendar.set(Calendar.MILLISECOND, 999); + return calendar.getTimeInMillis(); + } + + /** + * Tests the equality of this Year object to an arbitrary + * object. Returns true if the target is a Year + * instance representing the same year as this object. In all other cases, + * returns false. + * + * @param obj the object (null permitted). + * + * @return true if the year of this and the object are the + * same. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Year)) { + return false; + } + Year that = (Year) obj; + return (this.year == that.year); + } + + /** + * Returns a hash code for this object instance. The approach described by + * Joshua Bloch in "Effective Java" has been used here: + *

+ * http://developer.java.sun.com/developer/Books/effectivejava + * /Chapter3.pdf + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 17; + int c = this.year; + result = 37 * result + c; + return result; + } + + /** + * Returns an integer indicating the order of this Year object + * relative to the specified object: + * + * negative == before, zero == same, positive == after. + * + * @param o1 the object to compare. + * + * @return negative == before, zero == same, positive == after. + */ + @Override + public int compareTo(Object o1) { + + int result; + + // CASE 1 : Comparing to another Year object + // ----------------------------------------- + if (o1 instanceof Year) { + Year y = (Year) o1; + result = this.year - y.getYear(); + } + + // CASE 2 : Comparing to another TimePeriod object + // ----------------------------------------------- + else if (o1 instanceof RegularTimePeriod) { + // more difficult case - evaluate later... + result = 0; + } + + // CASE 3 : Comparing to a non-TimePeriod object + // --------------------------------------------- + else { + // consider time periods to be ordered after general objects + result = 1; + } + + return result; + + } + + /** + * Returns a string representing the year.. + * + * @return A string representing the year. + */ + @Override + public String toString() { + return Integer.toString(this.year); + } + + /** + * Parses the string argument as a year. + *

+ * The string format is YYYY. + * + * @param s a string representing the year. + * + * @return null if the string is not parseable, the year + * otherwise. + */ + public static Year parseYear(String s) { + + // parse the string... + int y; + try { + y = Integer.parseInt(s.trim()); + } + catch (NumberFormatException e) { + throw new TimePeriodFormatException("Cannot parse string."); + } + + // create the year... + try { + return new Year(y); + } + catch (IllegalArgumentException e) { + throw new TimePeriodFormatException("Year outside valid range."); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/OHLC.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/OHLC.java new file mode 100755 index 0000000..c26e725 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/OHLC.java @@ -0,0 +1,164 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------- + * OHLC.java + * --------- + * (C) Copyright 2006, 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Dec-2006 : Version 1 (DG); + * 23-May-2009 : Implemented hashCode() (DG); + * + */ + +package org.jfree.data.time.ohlc; + +import java.io.Serializable; +import org.jfree.chart.HashUtilities; + +/** + * A data record containing open-high-low-close data (immutable). This class + * is used internally by the {@link OHLCItem} class. + * + * @since 1.0.4 + */ +public class OHLC implements Serializable { + + /** The open value. */ + private double open; + + /** The close value. */ + private double close; + + /** The high value. */ + private double high; + + /** The low value. */ + private double low; + + /** + * Creates a new instance of OHLC. + * + * @param open the open value. + * @param close the close value. + * @param high the high value. + * @param low the low value. + */ + public OHLC(double open, double high, double low, double close) { + this.open = open; + this.close = close; + this.high = high; + this.low = low; + } + + /** + * Returns the open value. + * + * @return The open value. + */ + public double getOpen() { + return this.open; + } + + /** + * Returns the close value. + * + * @return The close value. + */ + public double getClose() { + return this.close; + } + + /** + * Returns the high value. + * + * @return The high value. + */ + public double getHigh() { + return this.high; + } + + /** + * Returns the low value. + * + * @return The low value. + */ + public double getLow() { + return this.low; + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OHLC)) { + return false; + } + OHLC that = (OHLC) obj; + if (this.open != that.open) { + return false; + } + if (this.close != that.close) { + return false; + } + if (this.high != that.high) { + return false; + } + if (this.low != that.low) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 193; + result = HashUtilities.hashCode(result, this.open); + result = HashUtilities.hashCode(result, this.high); + result = HashUtilities.hashCode(result, this.low); + result = HashUtilities.hashCode(result, this.close); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/OHLCItem.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/OHLCItem.java new file mode 100755 index 0000000..7006e29 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/OHLCItem.java @@ -0,0 +1,146 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * OHLCItem.java + * ------------- + * (C) Copyright 2006, 2007, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Dec-2006 : Version 1 (DG); + * + */ + +package org.jfree.data.time.ohlc; + +import org.jfree.data.ComparableObjectItem; +import org.jfree.data.time.RegularTimePeriod; + +/** + * An item representing data in the form (time-period, open, high, low, + * close). + * + * @since 1.0.4 + */ +public class OHLCItem extends ComparableObjectItem { + + /** + * Creates a new instance of OHLCItem. + * + * @param period the time period. + * @param open the open-value. + * @param high the high-value. + * @param low the low-value. + * @param close the close-value. + */ + public OHLCItem(RegularTimePeriod period, double open, double high, + double low, double close) { + super(period, new OHLC(open, high, low, close)); + } + + /** + * Returns the period. + * + * @return The period (never null). + */ + public RegularTimePeriod getPeriod() { + return (RegularTimePeriod) getComparable(); + } + + /** + * Returns the y-value. + * + * @return The y-value. + */ + public double getYValue() { + return getCloseValue(); + } + + /** + * Returns the open value. + * + * @return The open value. + */ + public double getOpenValue() { + OHLC ohlc = (OHLC) getObject(); + if (ohlc != null) { + return ohlc.getOpen(); + } + else { + return Double.NaN; + } + } + + /** + * Returns the high value. + * + * @return The high value. + */ + public double getHighValue() { + OHLC ohlc = (OHLC) getObject(); + if (ohlc != null) { + return ohlc.getHigh(); + } + else { + return Double.NaN; + } + } + + /** + * Returns the low value. + * + * @return The low value. + */ + public double getLowValue() { + OHLC ohlc = (OHLC) getObject(); + if (ohlc != null) { + return ohlc.getLow(); + } + else { + return Double.NaN; + } + } + + /** + * Returns the close value. + * + * @return The close value. + */ + public double getCloseValue() { + OHLC ohlc = (OHLC) getObject(); + if (ohlc != null) { + return ohlc.getClose(); + } + else { + return Double.NaN; + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/OHLCSeries.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/OHLCSeries.java new file mode 100755 index 0000000..6e8b0b9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/OHLCSeries.java @@ -0,0 +1,141 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * OHLCSeries.java + * --------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Dec-2006 : Version 1 (DG); + * 17-Jun-2009 : Added remove(int) method (DG); + * 21-Nov-2013 : Added add(OHLCItem) method - feature request #385 (DG); + * + */ + +package org.jfree.data.time.ohlc; + +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.ComparableObjectItem; +import org.jfree.data.ComparableObjectSeries; +import org.jfree.data.time.RegularTimePeriod; + +/** + * A list of ({@link RegularTimePeriod}, open, high, low, close) data items. + * + * @since 1.0.4 + * + * @see OHLCSeriesCollection + */ +public class OHLCSeries extends ComparableObjectSeries { + + /** + * Creates a new empty series. By default, items added to the series will + * be sorted into ascending order by period, and duplicate periods will + * not be allowed. + * + * @param key the series key (null not permitted). + */ + public OHLCSeries(Comparable key) { + super(key, true, false); + } + + /** + * Returns the time period for the specified item. + * + * @param index the item index. + * + * @return The time period. + */ + public RegularTimePeriod getPeriod(int index) { + OHLCItem item = (OHLCItem) getDataItem(index); + return item.getPeriod(); + } + + /** + * Returns the data item at the specified index. + * + * @param index the item index. + * + * @return The data item. + */ + @Override + public ComparableObjectItem getDataItem(int index) { + return super.getDataItem(index); + } + + /** + * Adds a data item to the series. + * + * @param period the period. + * @param open the open-value. + * @param high the high-value. + * @param low the low-value. + * @param close the close-value. + */ + public void add(RegularTimePeriod period, double open, double high, + double low, double close) { + if (getItemCount() > 0) { + OHLCItem item0 = (OHLCItem) this.getDataItem(0); + if (!period.getClass().equals(item0.getPeriod().getClass())) { + throw new IllegalArgumentException( + "Can't mix RegularTimePeriod class types."); + } + } + super.add(new OHLCItem(period, open, high, low, close), true); + } + + /** + * Adds a data item to the series. The values from the item passed to + * this method will be copied into a new object. + * + * @param item the item (null not permitted). + * + * @since 1.0.17 + */ + public void add(OHLCItem item) { + ParamChecks.nullNotPermitted(item, "item"); + add(item.getPeriod(), item.getOpenValue(), item.getHighValue(), + item.getLowValue(), item.getCloseValue()); + } + + /** + * Removes the item with the specified index. + * + * @param index the item index. + * + * @since 1.0.14 + */ + @Override + public ComparableObjectItem remove(int index) { + return super.remove(index); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/OHLCSeriesCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/OHLCSeriesCollection.java new file mode 100755 index 0000000..57e214b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/OHLCSeriesCollection.java @@ -0,0 +1,500 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * OHLCSeriesCollection.java + * ------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Dec-2006 : Version 1 (DG); + * 10-Jul-2008 : Added accessor methods for xPosition attribute (DG); + * 23-May-2009 : Added hashCode() implementation (DG); + * 26-Jun-2009 : Added removeSeries() methods (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.time.ohlc; + +import java.io.Serializable; +import java.util.List; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.time.RegularTimePeriod; +import org.jfree.data.time.TimePeriodAnchor; +import org.jfree.data.xy.AbstractXYDataset; +import org.jfree.data.xy.OHLCDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.util.ObjectUtilities; + +/** + * A collection of {@link OHLCSeries} objects. + * + * @since 1.0.4 + * + * @see OHLCSeries + */ +public class OHLCSeriesCollection extends AbstractXYDataset + implements OHLCDataset, Serializable { + + /** Storage for the data series. */ + private List data; + + private TimePeriodAnchor xPosition = TimePeriodAnchor.MIDDLE; + + /** + * Creates a new instance of OHLCSeriesCollection. + */ + public OHLCSeriesCollection() { + this.data = new java.util.ArrayList(); + } + + /** + * Returns the position within each time period that is used for the X + * value when the collection is used as an {@link XYDataset}. + * + * @return The anchor position (never null). + * + * @since 1.0.11 + */ + public TimePeriodAnchor getXPosition() { + return this.xPosition; + } + + /** + * Sets the position within each time period that is used for the X values + * when the collection is used as an {@link XYDataset}, then sends a + * {@link DatasetChangeEvent} is sent to all registered listeners. + * + * @param anchor the anchor position (null not permitted). + * + * @since 1.0.11 + */ + public void setXPosition(TimePeriodAnchor anchor) { + ParamChecks.nullNotPermitted(anchor, "anchor"); + this.xPosition = anchor; + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Adds a series to the collection and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param series the series (null not permitted). + */ + public void addSeries(OHLCSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + this.data.add(series); + series.addChangeListener(this); + fireDatasetChanged(); + } + + /** + * Returns the number of series in the collection. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.data.size(); + } + + /** + * Returns a series from the collection. + * + * @param series the series index (zero-based). + * + * @return The series. + * + * @throws IllegalArgumentException if series is not in the + * range 0 to getSeriesCount() - 1. + */ + public OHLCSeries getSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + return (OHLCSeries) this.data.get(series); + } + + /** + * Returns the key for a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The key for a series. + * + * @throws IllegalArgumentException if series is not in the + * specified range. + */ + @Override + public Comparable getSeriesKey(int series) { + // defer argument checking + return getSeries(series).getKey(); + } + + /** + * Returns the number of items in the specified series. + * + * @param series the series (zero-based index). + * + * @return The item count. + * + * @throws IllegalArgumentException if series is not in the + * range 0 to getSeriesCount() - 1. + */ + @Override + public int getItemCount(int series) { + // defer argument checking + return getSeries(series).getItemCount(); + } + + /** + * Returns the x-value for a time period. + * + * @param period the time period (null not permitted). + * + * @return The x-value. + */ + protected synchronized long getX(RegularTimePeriod period) { + long result = 0L; + if (this.xPosition == TimePeriodAnchor.START) { + result = period.getFirstMillisecond(); + } + else if (this.xPosition == TimePeriodAnchor.MIDDLE) { + result = period.getMiddleMillisecond(); + } + else if (this.xPosition == TimePeriodAnchor.END) { + result = period.getLastMillisecond(); + } + return result; + } + + /** + * Returns the x-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value. + */ + @Override + public double getXValue(int series, int item) { + OHLCSeries s = (OHLCSeries) this.data.get(series); + OHLCItem di = (OHLCItem) s.getDataItem(item); + RegularTimePeriod period = di.getPeriod(); + return getX(period); + } + + /** + * Returns the x-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value. + */ + @Override + public Number getX(int series, int item) { + return new Double(getXValue(series, item)); + } + + /** + * Returns the y-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The y-value. + */ + @Override + public Number getY(int series, int item) { + OHLCSeries s = (OHLCSeries) this.data.get(series); + OHLCItem di = (OHLCItem) s.getDataItem(item); + return new Double(di.getYValue()); + } + + /** + * Returns the open-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The open-value. + */ + @Override + public double getOpenValue(int series, int item) { + OHLCSeries s = (OHLCSeries) this.data.get(series); + OHLCItem di = (OHLCItem) s.getDataItem(item); + return di.getOpenValue(); + } + + /** + * Returns the open-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The open-value. + */ + @Override + public Number getOpen(int series, int item) { + return new Double(getOpenValue(series, item)); + } + + /** + * Returns the close-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The close-value. + */ + @Override + public double getCloseValue(int series, int item) { + OHLCSeries s = (OHLCSeries) this.data.get(series); + OHLCItem di = (OHLCItem) s.getDataItem(item); + return di.getCloseValue(); + } + + /** + * Returns the close-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The close-value. + */ + @Override + public Number getClose(int series, int item) { + return new Double(getCloseValue(series, item)); + } + + /** + * Returns the high-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The high-value. + */ + @Override + public double getHighValue(int series, int item) { + OHLCSeries s = (OHLCSeries) this.data.get(series); + OHLCItem di = (OHLCItem) s.getDataItem(item); + return di.getHighValue(); + } + + /** + * Returns the high-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The high-value. + */ + @Override + public Number getHigh(int series, int item) { + return new Double(getHighValue(series, item)); + } + + /** + * Returns the low-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The low-value. + */ + @Override + public double getLowValue(int series, int item) { + OHLCSeries s = (OHLCSeries) this.data.get(series); + OHLCItem di = (OHLCItem) s.getDataItem(item); + return di.getLowValue(); + } + + /** + * Returns the low-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The low-value. + */ + @Override + public Number getLow(int series, int item) { + return new Double(getLowValue(series, item)); + } + + /** + * Returns null always, because this dataset doesn't record + * any volume data. + * + * @param series the series index (ignored). + * @param item the item index (ignored). + * + * @return null. + */ + @Override + public Number getVolume(int series, int item) { + return null; + } + + /** + * Returns Double.NaN always, because this dataset doesn't + * record any volume data. + * + * @param series the series index (ignored). + * @param item the item index (ignored). + * + * @return Double.NaN. + */ + @Override + public double getVolumeValue(int series, int item) { + return Double.NaN; + } + + /** + * Removes the series with the specified index and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param index the series index. + * + * @since 1.0.14 + */ + public void removeSeries(int index) { + OHLCSeries series = getSeries(index); + if (series != null) { + removeSeries(series); + } + } + + /** + * Removes the specified series from the dataset and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param series the series (null not permitted). + * + * @return true if the series was removed, and + * false otherwise. + * + * @since 1.0.14 + */ + public boolean removeSeries(OHLCSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + boolean removed = this.data.remove(series); + if (removed) { + series.removeChangeListener(this); + fireDatasetChanged(); + } + return removed; + } + + /** + * Removes all the series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @since 1.0.14 + */ + public void removeAllSeries() { + + if (this.data.isEmpty()) { + return; // nothing to do + } + + // deregister the collection as a change listener to each series in the + // collection + for (int i = 0; i < this.data.size(); i++) { + OHLCSeries series = (OHLCSeries) this.data.get(i); + series.removeChangeListener(this); + } + + // remove all the series from the collection and notify listeners. + this.data.clear(); + fireDatasetChanged(); + + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OHLCSeriesCollection)) { + return false; + } + OHLCSeriesCollection that = (OHLCSeriesCollection) obj; + if (!this.xPosition.equals(that.xPosition)) { + return false; + } + return ObjectUtilities.equal(this.data, that.data); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 137; + result = HashUtilities.hashCode(result, this.xPosition); + for (int i = 0; i < this.data.size(); i++) { + result = HashUtilities.hashCode(result, this.data.get(i)); + } + return result; + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem. + */ + @Override + public Object clone() throws CloneNotSupportedException { + OHLCSeriesCollection clone + = (OHLCSeriesCollection) super.clone(); + clone.data = (List) ObjectUtilities.deepClone(this.data); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/package.html new file mode 100755 index 0000000..98b7109 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/ohlc/package.html @@ -0,0 +1,6 @@ + + + +Classes for representing financial data in open-high-low-close form. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/package.html new file mode 100755 index 0000000..a33e3da --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/time/package.html @@ -0,0 +1,6 @@ + + + +Interfaces and classes for time-related data. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/CategoryDatasetHandler.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/CategoryDatasetHandler.java new file mode 100755 index 0000000..b5aa697 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/CategoryDatasetHandler.java @@ -0,0 +1,139 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * CategoryDatasetHandler.java + * --------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Jan-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.xml; + +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.DefaultCategoryDataset; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * A SAX handler for reading a {@link CategoryDataset} from an XML file. + */ +public class CategoryDatasetHandler extends RootHandler implements DatasetTags { + + /** The dataset under construction. */ + private DefaultCategoryDataset dataset; + + /** + * Creates a new handler. + */ + public CategoryDatasetHandler() { + this.dataset = null; + } + + /** + * Returns the dataset. + * + * @return The dataset. + */ + public CategoryDataset getDataset() { + return this.dataset; + } + + /** + * Adds an item to the dataset. + * + * @param rowKey the row key. + * @param columnKey the column key. + * @param value the value. + */ + public void addItem(Comparable rowKey, Comparable columnKey, Number value) { + this.dataset.addValue(value, rowKey, columnKey); + } + + /** + * The start of an element. + * + * @param namespaceURI the namespace. + * @param localName the element name. + * @param qName the element name. + * @param atts the element attributes. + * + * @throws SAXException for errors. + */ + @Override + public void startElement(String namespaceURI, + String localName, + String qName, + Attributes atts) throws SAXException { + + DefaultHandler current = getCurrentHandler(); + if (current != this) { + current.startElement(namespaceURI, localName, qName, atts); + } + else if (qName.equals(CATEGORYDATASET_TAG)) { + this.dataset = new DefaultCategoryDataset(); + } + else if (qName.equals(SERIES_TAG)) { + CategorySeriesHandler subhandler = new CategorySeriesHandler(this); + getSubHandlers().push(subhandler); + subhandler.startElement(namespaceURI, localName, qName, atts); + } + else { + throw new SAXException("Element not recognised: " + qName); + } + + } + + /** + * The end of an element. + * + * @param namespaceURI the namespace. + * @param localName the element name. + * @param qName the element name. + * + * @throws SAXException for errors. + */ + @Override + public void endElement(String namespaceURI, + String localName, + String qName) throws SAXException { + + DefaultHandler current = getCurrentHandler(); + if (current != this) { + current.endElement(namespaceURI, localName, qName); + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/CategorySeriesHandler.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/CategorySeriesHandler.java new file mode 100755 index 0000000..f73b919 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/CategorySeriesHandler.java @@ -0,0 +1,155 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * CategorySeriesHandler.java + * -------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Jan-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.xml; + +import java.util.Iterator; + +import org.jfree.data.DefaultKeyedValues; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * A handler for reading a series for a category dataset. + */ +public class CategorySeriesHandler extends DefaultHandler + implements DatasetTags { + + /** The root handler. */ + private RootHandler root; + + /** The series key. */ + private Comparable seriesKey; + + /** The values. */ + private DefaultKeyedValues values; + + /** + * Creates a new item handler. + * + * @param root the root handler. + */ + public CategorySeriesHandler(RootHandler root) { + this.root = root; + this.values = new DefaultKeyedValues(); + } + + /** + * Sets the series key. + * + * @param key the key. + */ + public void setSeriesKey(Comparable key) { + this.seriesKey = key; + } + + /** + * Adds an item to the temporary storage for the series. + * + * @param key the key. + * @param value the value. + */ + public void addItem(Comparable key, final Number value) { + this.values.addValue(key, value); + } + + /** + * The start of an element. + * + * @param namespaceURI the namespace. + * @param localName the element name. + * @param qName the element name. + * @param atts the attributes. + * + * @throws SAXException for errors. + */ + @Override + public void startElement(String namespaceURI, + String localName, + String qName, + Attributes atts) throws SAXException { + + if (qName.equals(SERIES_TAG)) { + setSeriesKey(atts.getValue("name")); + ItemHandler subhandler = new ItemHandler(this.root, this); + this.root.pushSubHandler(subhandler); + } + else if (qName.equals(ITEM_TAG)) { + ItemHandler subhandler = new ItemHandler(this.root, this); + this.root.pushSubHandler(subhandler); + subhandler.startElement(namespaceURI, localName, qName, atts); + } + + else { + throw new SAXException( + "Expecting or tag...found " + qName + ); + } + } + + /** + * The end of an element. + * + * @param namespaceURI the namespace. + * @param localName the element name. + * @param qName the element name. + */ + @Override + public void endElement(String namespaceURI, + String localName, + String qName) { + + if (this.root instanceof CategoryDatasetHandler) { + CategoryDatasetHandler handler = (CategoryDatasetHandler) this.root; + + Iterator iterator = this.values.getKeys().iterator(); + while (iterator.hasNext()) { + Comparable key = (Comparable) iterator.next(); + Number value = this.values.getValue(key); + handler.addItem(this.seriesKey, key, value); + } + + this.root.popSubHandler(); + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/DatasetReader.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/DatasetReader.java new file mode 100755 index 0000000..ee29ed3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/DatasetReader.java @@ -0,0 +1,152 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * DatasetReader.java + * ------------------ + * (C) Copyright 2002-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Nov-2002 : Version 1 (DG); + * + */ + +package org.jfree.data.xml; + +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; + +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.PieDataset; +import org.xml.sax.SAXException; + +/** + * A utility class for reading datasets from XML. + */ +public class DatasetReader { + + /** + * Reads a {@link PieDataset} from an XML file. + * + * @param file the file. + * + * @return A dataset. + * + * @throws IOException if there is a problem reading the file. + */ + public static PieDataset readPieDatasetFromXML(File file) + throws IOException { + InputStream in = new FileInputStream(file); + return readPieDatasetFromXML(in); + } + + /** + * Reads a {@link PieDataset} from a stream. + * + * @param in the input stream. + * + * @return A dataset. + * + * @throws IOException if there is an I/O error. + */ + public static PieDataset readPieDatasetFromXML(InputStream in) + throws IOException { + + PieDataset result = null; + SAXParserFactory factory = SAXParserFactory.newInstance(); + try { + SAXParser parser = factory.newSAXParser(); + PieDatasetHandler handler = new PieDatasetHandler(); + parser.parse(in, handler); + result = handler.getDataset(); + } + catch (SAXException e) { + System.out.println(e.getMessage()); + } + catch (ParserConfigurationException e2) { + System.out.println(e2.getMessage()); + } + return result; + + } + + /** + * Reads a {@link CategoryDataset} from a file. + * + * @param file the file. + * + * @return A dataset. + * + * @throws IOException if there is a problem reading the file. + */ + public static CategoryDataset readCategoryDatasetFromXML(File file) + throws IOException { + InputStream in = new FileInputStream(file); + return readCategoryDatasetFromXML(in); + } + + /** + * Reads a {@link CategoryDataset} from a stream. + * + * @param in the stream. + * + * @return A dataset. + * + * @throws IOException if there is a problem reading the file. + */ + public static CategoryDataset readCategoryDatasetFromXML(InputStream in) + throws IOException { + + CategoryDataset result = null; + + SAXParserFactory factory = SAXParserFactory.newInstance(); + try { + SAXParser parser = factory.newSAXParser(); + CategoryDatasetHandler handler = new CategoryDatasetHandler(); + parser.parse(in, handler); + result = handler.getDataset(); + } + catch (SAXException e) { + System.out.println(e.getMessage()); + } + catch (ParserConfigurationException e2) { + System.out.println(e2.getMessage()); + } + return result; + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/DatasetTags.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/DatasetTags.java new file mode 100755 index 0000000..0522e0d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/DatasetTags.java @@ -0,0 +1,66 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * DatasetTags.java + * ---------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Jan-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.xml; + +/** + * Constants for the tags that identify the elements in the XML files. + */ +public interface DatasetTags { + + /** The 'PieDataset' element name. */ + public static final String PIEDATASET_TAG = "PieDataset"; + + /** The 'CategoryDataset' element name. */ + public static final String CATEGORYDATASET_TAG = "CategoryDataset"; + + /** The 'Series' element name. */ + public static final String SERIES_TAG = "Series"; + + /** The 'Item' element name. */ + public static final String ITEM_TAG = "Item"; + + /** The 'Key' element name. */ + public static final String KEY_TAG = "Key"; + + /** The 'Value' element name. */ + public static final String VALUE_TAG = "Value"; + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/ItemHandler.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/ItemHandler.java new file mode 100755 index 0000000..6af4849 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/ItemHandler.java @@ -0,0 +1,170 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * ItemHandler.java + * ---------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Jan-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.xml; + +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * A handler for reading key-value items. + */ +public class ItemHandler extends DefaultHandler implements DatasetTags { + + /** The root handler. */ + private RootHandler root; + + /** The parent handler (can be the same as root, but not always). */ + private DefaultHandler parent; + + /** The key. */ + private Comparable key; + + /** The value. */ + private Number value; + + /** + * Creates a new item handler. + * + * @param root the root handler. + * @param parent the parent handler. + */ + public ItemHandler(RootHandler root, DefaultHandler parent) { + this.root = root; + this.parent = parent; + this.key = null; + this.value = null; + } + + /** + * Returns the key that has been read by the handler, or null. + * + * @return The key. + */ + public Comparable getKey() { + return this.key; + } + + /** + * Sets the key. + * + * @param key the key. + */ + public void setKey(Comparable key) { + this.key = key; + } + + /** + * Returns the key that has been read by the handler, or null. + * + * @return The value. + */ + public Number getValue() { + return this.value; + } + + /** + * Sets the value. + * + * @param value the value. + */ + public void setValue(Number value) { + this.value = value; + } + + /** + * The start of an element. + * + * @param namespaceURI the namespace. + * @param localName the element name. + * @param qName the element name. + * @param atts the attributes. + * + * @throws SAXException for errors. + */ + @Override + public void startElement(String namespaceURI, + String localName, + String qName, + Attributes atts) throws SAXException { + + if (qName.equals(ITEM_TAG)) { + KeyHandler subhandler = new KeyHandler(this.root, this); + this.root.pushSubHandler(subhandler); + } + else if (qName.equals(VALUE_TAG)) { + ValueHandler subhandler = new ValueHandler(this.root, this); + this.root.pushSubHandler(subhandler); + } + else { + throw new SAXException( + "Expected or ...found " + qName + ); + } + + } + + /** + * The end of an element. + * + * @param namespaceURI the namespace. + * @param localName the element name. + * @param qName the element name. + */ + @Override + public void endElement(String namespaceURI, + String localName, + String qName) { + + if (this.parent instanceof PieDatasetHandler) { + PieDatasetHandler handler = (PieDatasetHandler) this.parent; + handler.addItem(this.key, this.value); + this.root.popSubHandler(); + } + else if (this.parent instanceof CategorySeriesHandler) { + CategorySeriesHandler handler = (CategorySeriesHandler) this.parent; + handler.addItem(this.key, this.value); + this.root.popSubHandler(); + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/KeyHandler.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/KeyHandler.java new file mode 100755 index 0000000..562234c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/KeyHandler.java @@ -0,0 +1,159 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * KeyHandler.java + * --------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Jan-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.xml; + +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * A SAX handler for reading a key. + */ +public class KeyHandler extends DefaultHandler implements DatasetTags { + + /** The root handler. */ + private RootHandler rootHandler; + + /** The item handler. */ + private ItemHandler itemHandler; + + /** Storage for the current CDATA */ + private StringBuffer currentText; + + /** The key. */ + //private Comparable key; + + /** + * Creates a new handler. + * + * @param rootHandler the root handler. + * @param itemHandler the item handler. + */ + public KeyHandler(RootHandler rootHandler, ItemHandler itemHandler) { + this.rootHandler = rootHandler; + this.itemHandler = itemHandler; + this.currentText = new StringBuffer(); + //this.key = null; + } + + /** + * The start of an element. + * + * @param namespaceURI the namespace. + * @param localName the element name. + * @param qName the element name. + * @param atts the attributes. + * + * @throws SAXException for errors. + */ + @Override + public void startElement(String namespaceURI, + String localName, + String qName, + Attributes atts) throws SAXException { + + if (qName.equals(KEY_TAG)) { + clearCurrentText(); + } + else { + throw new SAXException("Expecting but found " + qName); + } + + } + + /** + * The end of an element. + * + * @param namespaceURI the namespace. + * @param localName the element name. + * @param qName the element name. + * + * @throws SAXException for errors. + */ + @Override + public void endElement(String namespaceURI, + String localName, + String qName) throws SAXException { + + if (qName.equals(KEY_TAG)) { + this.itemHandler.setKey(getCurrentText()); + this.rootHandler.popSubHandler(); + this.rootHandler.pushSubHandler( + new ValueHandler(this.rootHandler, this.itemHandler) + ); + } + else { + throw new SAXException("Expecting but found " + qName); + } + + } + + /** + * Receives some (or all) of the text in the current element. + * + * @param ch character buffer. + * @param start the start index. + * @param length the length of the valid character data. + */ + @Override + public void characters(char[] ch, int start, int length) { + if (this.currentText != null) { + this.currentText.append(String.copyValueOf(ch, start, length)); + } + } + + /** + * Returns the current text of the textbuffer. + * + * @return The current text. + */ + protected String getCurrentText() { + return this.currentText.toString(); + } + + /** + * Removes all text from the textbuffer at the end of a CDATA section. + */ + protected void clearCurrentText() { + this.currentText.delete(0, this.currentText.length()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/PieDatasetHandler.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/PieDatasetHandler.java new file mode 100755 index 0000000..de9d029 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/PieDatasetHandler.java @@ -0,0 +1,135 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * PieDatasetHandler.java + * ---------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Jan-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.xml; + +import org.jfree.data.general.DefaultPieDataset; +import org.jfree.data.general.PieDataset; +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * A SAX handler for reading a {@link PieDataset} from an XML file. + */ +public class PieDatasetHandler extends RootHandler implements DatasetTags { + + /** The pie dataset under construction. */ + private DefaultPieDataset dataset; + + /** + * Default constructor. + */ + public PieDatasetHandler() { + this.dataset = null; + } + + /** + * Returns the dataset. + * + * @return The dataset. + */ + public PieDataset getDataset() { + return this.dataset; + } + + /** + * Adds an item to the dataset under construction. + * + * @param key the key. + * @param value the value. + */ + public void addItem(Comparable key, Number value) { + this.dataset.setValue(key, value); + } + + /** + * Starts an element. + * + * @param namespaceURI the namespace. + * @param localName the element name. + * @param qName the element name. + * @param atts the element attributes. + * + * @throws SAXException for errors. + */ + @Override + public void startElement(String namespaceURI, + String localName, + String qName, + Attributes atts) throws SAXException { + + DefaultHandler current = getCurrentHandler(); + if (current != this) { + current.startElement(namespaceURI, localName, qName, atts); + } + else if (qName.equals(PIEDATASET_TAG)) { + this.dataset = new DefaultPieDataset(); + } + else if (qName.equals(ITEM_TAG)) { + ItemHandler subhandler = new ItemHandler(this, this); + getSubHandlers().push(subhandler); + subhandler.startElement(namespaceURI, localName, qName, atts); + } + + } + + /** + * The end of an element. + * + * @param namespaceURI the namespace. + * @param localName the element name. + * @param qName the element name. + * + * @throws SAXException for errors. + */ + @Override + public void endElement(String namespaceURI, + String localName, + String qName) throws SAXException { + + DefaultHandler current = getCurrentHandler(); + if (current != this) { + current.endElement(namespaceURI, localName, qName); + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/RootHandler.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/RootHandler.java new file mode 100755 index 0000000..f2fae93 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/RootHandler.java @@ -0,0 +1,126 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * RootHandler.java + * ---------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Jan-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.xml; + +import java.util.Stack; + +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * A SAX handler that delegates work to sub-handlers. + */ +public class RootHandler extends DefaultHandler implements DatasetTags { + + /** The sub-handlers. */ + private Stack subHandlers; + + /** + * Creates a new handler. + */ + public RootHandler() { + this.subHandlers = new Stack(); + } + + /** + * Returns the stack of sub handlers. + * + * @return The sub-handler stack. + */ + public Stack getSubHandlers() { + return this.subHandlers; + } + + /** + * Receives some (or all) of the text in the current element. + * + * @param ch character buffer. + * @param start the start index. + * @param length the length of the valid character data. + * + * @throws SAXException for errors. + */ + @Override + public void characters(char[] ch, int start, int length) + throws SAXException { + DefaultHandler handler = getCurrentHandler(); + if (handler != this) { + handler.characters(ch, start, length); + } + } + + /** + * Returns the handler at the top of the stack. + * + * @return The handler. + */ + public DefaultHandler getCurrentHandler() { + DefaultHandler result = this; + if (this.subHandlers != null) { + if (this.subHandlers.size() > 0) { + Object top = this.subHandlers.peek(); + if (top != null) { + result = (DefaultHandler) top; + } + } + } + return result; + } + + /** + * Pushes a sub-handler onto the stack. + * + * @param subhandler the sub-handler. + */ + public void pushSubHandler(DefaultHandler subhandler) { + this.subHandlers.push(subhandler); + } + + /** + * Pops a sub-handler from the stack. + * + * @return The sub-handler. + */ + public DefaultHandler popSubHandler() { + return (DefaultHandler) this.subHandlers.pop(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/ValueHandler.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/ValueHandler.java new file mode 100755 index 0000000..7e63c1a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/ValueHandler.java @@ -0,0 +1,164 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * ValueHandler.java + * ----------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Luke Quinane; + * + * Changes + * ------- + * 23-Jan-2003 : Version 1 (DG); + * 25-Nov-2003 : Patch to handle 'NaN' values (DG); + * + */ + +package org.jfree.data.xml; + +import org.xml.sax.Attributes; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +/** + * A handler for reading a 'Value' element. + */ +public class ValueHandler extends DefaultHandler implements DatasetTags { + + /** The root handler. */ + private RootHandler rootHandler; + + /** The item handler. */ + private ItemHandler itemHandler; + + /** Storage for the current CDATA */ + private StringBuffer currentText; + + /** + * Creates a new value handler. + * + * @param rootHandler the root handler. + * @param itemHandler the item handler. + */ + public ValueHandler(RootHandler rootHandler, ItemHandler itemHandler) { + this.rootHandler = rootHandler; + this.itemHandler = itemHandler; + this.currentText = new StringBuffer(); + } + + /** + * The start of an element. + * + * @param namespaceURI the namespace. + * @param localName the element name. + * @param qName the element name. + * @param atts the attributes. + * + * @throws SAXException for errors. + */ + @Override + public void startElement(String namespaceURI, + String localName, + String qName, + Attributes atts) throws SAXException { + + if (qName.equals(VALUE_TAG)) { + // no attributes to read + clearCurrentText(); + } + else { + throw new SAXException("Expecting but found " + qName); + } + + } + + /** + * The end of an element. + * + * @param namespaceURI the namespace. + * @param localName the element name. + * @param qName the element name. + * + * @throws SAXException for errors. + */ + @Override + public void endElement(String namespaceURI, + String localName, + String qName) throws SAXException { + + if (qName.equals(VALUE_TAG)) { + Number value; + try { + value = Double.valueOf(this.currentText.toString()); + if (((Double) value).isNaN()) { + value = null; + } + } + catch (NumberFormatException e1) { + value = null; + } + this.itemHandler.setValue(value); + this.rootHandler.popSubHandler(); + } + else { + throw new SAXException("Expecting but found " + qName); + } + + } + + /** + * Receives some (or all) of the text in the current element. + * + * @param ch character buffer. + * @param start the start index. + * @param length the length of the valid character data. + */ + @Override + public void characters(char[] ch, int start, int length) { + if (this.currentText != null) { + this.currentText.append(String.copyValueOf(ch, start, length)); + } + } + + /** + * Returns the current text of the textbuffer. + * + * @return The current text. + */ + protected String getCurrentText() { + return this.currentText.toString(); + } + + /** + * Removes all text from the textbuffer at the end of a CDATA section. + */ + protected void clearCurrentText() { + this.currentText.delete(0, this.currentText.length()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/package.html new file mode 100755 index 0000000..c6c4614 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xml/package.html @@ -0,0 +1,6 @@ + + + +Support for reading datasets from XML files. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/AbstractIntervalXYDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/AbstractIntervalXYDataset.java new file mode 100755 index 0000000..b6b70fd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/AbstractIntervalXYDataset.java @@ -0,0 +1,130 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * AbstractIntervalXYDataset.java + * ------------------------------ + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited). + * Contributor(s): -; + * + * Changes + * ------- + * 05-May-2004 : Version 1 (DG); + * 15-Jul-2004 : Switched getStartX() and getStartXValue() methods and + * others (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); + * + */ + +package org.jfree.data.xy; + + +/** + * An base class that you can use to create new implementations of the + * {@link IntervalXYDataset} interface. + */ +public abstract class AbstractIntervalXYDataset extends AbstractXYDataset + implements IntervalXYDataset { + + /** + * Returns the start x-value (as a double primitive) for an item within a + * series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getStartXValue(int series, int item) { + double result = Double.NaN; + Number x = getStartX(series, item); + if (x != null) { + result = x.doubleValue(); + } + return result; + } + + /** + * Returns the end x-value (as a double primitive) for an item within a + * series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getEndXValue(int series, int item) { + double result = Double.NaN; + Number x = getEndX(series, item); + if (x != null) { + result = x.doubleValue(); + } + return result; + } + + /** + * Returns the start y-value (as a double primitive) for an item within a + * series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getStartYValue(int series, int item) { + double result = Double.NaN; + Number y = getStartY(series, item); + if (y != null) { + result = y.doubleValue(); + } + return result; + } + + /** + * Returns the end y-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value. + */ + @Override + public double getEndYValue(int series, int item) { + double result = Double.NaN; + Number y = getEndY(series, item); + if (y != null) { + result = y.doubleValue(); + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/AbstractXYDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/AbstractXYDataset.java new file mode 100755 index 0000000..d78de18 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/AbstractXYDataset.java @@ -0,0 +1,102 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * AbstractXYDataset.java + * ---------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited). + * Contributor(s): -; + * + * Changes + * ------- + * 05-May-2004 : Version 1 (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); + * + */ + +package org.jfree.data.xy; + +import org.jfree.data.DomainOrder; +import org.jfree.data.general.AbstractSeriesDataset; + +/** + * An base class that you can use to create new implementations of the + * {@link XYDataset} interface. + */ +public abstract class AbstractXYDataset extends AbstractSeriesDataset + implements XYDataset { + + /** + * Returns the order of the domain (X) values. + * + * @return The domain order. + */ + @Override + public DomainOrder getDomainOrder() { + return DomainOrder.NONE; + } + + /** + * Returns the x-value (as a double primitive) for an item within a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getXValue(int series, int item) { + double result = Double.NaN; + Number x = getX(series, item); + if (x != null) { + result = x.doubleValue(); + } + return result; + } + + /** + * Returns the y-value (as a double primitive) for an item within a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getYValue(int series, int item) { + double result = Double.NaN; + Number y = getY(series, item); + if (y != null) { + result = y.doubleValue(); + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/AbstractXYZDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/AbstractXYZDataset.java new file mode 100755 index 0000000..f2b351c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/AbstractXYZDataset.java @@ -0,0 +1,69 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * AbstractXYZDataset.java + * ----------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited). + * Contributor(s): -; + * + * Changes + * ------- + * 05-May-2004 : Version 1 (DG); + * 15-Jul-2004 : Switched getZ() and getZValue() (DG); + * + */ + +package org.jfree.data.xy; + +/** + * An base class that you can use to create new implementations of the + * {@link XYZDataset} interface. + */ +public abstract class AbstractXYZDataset extends AbstractXYDataset + implements XYZDataset { + + /** + * Returns the z-value (as a double primitive) for an item within a series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The z-value. + */ + @Override + public double getZValue(int series, int item) { + double result = Double.NaN; + Number z = getZ(series, item); + if (z != null) { + result = z.doubleValue(); + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/CategoryTableXYDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/CategoryTableXYDataset.java new file mode 100755 index 0000000..c037167 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/CategoryTableXYDataset.java @@ -0,0 +1,429 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * CategoryTableXYDataset.java + * --------------------------- + * (C) Copyright 2004-2011, by Andreas Schroeder and Contributors. + * + * Original Author: Andreas Schroeder; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 31-Mar-2004 : Version 1 (AS); + * 05-May-2004 : Now extends AbstractIntervalXYDataset (DG); + * 15-Jul-2004 : Switched interval access method names (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); + * 17-Nov-2004 : Updates required by changes to DomainInfo interface (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); + * 05-Oct-2005 : Made the interval delegate a dataset change listener (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 22-Apr-2008 : Implemented PublicCloneable, and fixed clone() method (DG); + * 18-Oct-2011 : Fixed bug 3190615 - added clear() method (DG); + * + */ + +package org.jfree.data.xy; + +import org.jfree.data.DefaultKeyedValues2D; +import org.jfree.data.DomainInfo; +import org.jfree.data.Range; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.util.PublicCloneable; + +/** + * An implementation variant of the {@link TableXYDataset} where every series + * shares the same x-values (required for generating stacked area charts). + * This implementation uses a {@link DefaultKeyedValues2D} Object as backend + * implementation and is hence more "category oriented" than the {@link + * DefaultTableXYDataset} implementation. + *

+ * This implementation provides no means to remove data items yet. + * This is due to the lack of such facility in the DefaultKeyedValues2D class. + *

+ * This class also implements the {@link IntervalXYDataset} interface, but this + * implementation is provisional. + */ +public class CategoryTableXYDataset extends AbstractIntervalXYDataset + implements TableXYDataset, IntervalXYDataset, DomainInfo, + PublicCloneable { + + /** + * The backing data structure. + */ + private DefaultKeyedValues2D values; + + /** A delegate for controlling the interval width. */ + private IntervalXYDelegate intervalDelegate; + + /** + * Creates a new empty CategoryTableXYDataset. + */ + public CategoryTableXYDataset() { + this.values = new DefaultKeyedValues2D(true); + this.intervalDelegate = new IntervalXYDelegate(this); + addChangeListener(this.intervalDelegate); + } + + /** + * Adds a data item to this dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param x the x value. + * @param y the y value. + * @param seriesName the name of the series to add the data item. + */ + public void add(double x, double y, String seriesName) { + add(new Double(x), new Double(y), seriesName, true); + } + + /** + * Adds a data item to this dataset and, if requested, sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param x the x value. + * @param y the y value. + * @param seriesName the name of the series to add the data item. + * @param notify notify listeners? + */ + public void add(Number x, Number y, String seriesName, boolean notify) { + this.values.addValue(y, (Comparable) x, seriesName); + if (notify) { + fireDatasetChanged(); + } + } + + /** + * Removes a value from the dataset. + * + * @param x the x-value. + * @param seriesName the series name. + */ + public void remove(double x, String seriesName) { + remove(new Double(x), seriesName, true); + } + + /** + * Removes an item from the dataset. + * + * @param x the x-value. + * @param seriesName the series name. + * @param notify notify listeners? + */ + public void remove(Number x, String seriesName, boolean notify) { + this.values.removeValue((Comparable) x, seriesName); + if (notify) { + fireDatasetChanged(); + } + } + + /** + * Clears all data from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @since 1.0.14 + */ + public void clear() { + this.values.clear(); + fireDatasetChanged(); + } + + /** + * Returns the number of series in the collection. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.values.getColumnCount(); + } + + /** + * Returns the key for a series. + * + * @param series the series index (zero-based). + * + * @return The key for a series. + */ + @Override + public Comparable getSeriesKey(int series) { + return this.values.getColumnKey(series); + } + + /** + * Returns the number of x values in the dataset. + * + * @return The item count. + */ + @Override + public int getItemCount() { + return this.values.getRowCount(); + } + + /** + * Returns the number of items in the specified series. + * Returns the same as {@link CategoryTableXYDataset#getItemCount()}. + * + * @param series the series index (zero-based). + * + * @return The item count. + */ + @Override + public int getItemCount(int series) { + return getItemCount(); // all series have the same number of items in + // this dataset + } + + /** + * Returns the x-value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public Number getX(int series, int item) { + return (Number) this.values.getRowKey(item); + } + + /** + * Returns the starting X value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The starting X value. + */ + @Override + public Number getStartX(int series, int item) { + return this.intervalDelegate.getStartX(series, item); + } + + /** + * Returns the ending X value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The ending X value. + */ + @Override + public Number getEndX(int series, int item) { + return this.intervalDelegate.getEndX(series, item); + } + + /** + * Returns the y-value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The y value (possibly null). + */ + @Override + public Number getY(int series, int item) { + return this.values.getValue(item, series); + } + + /** + * Returns the starting Y value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The starting Y value. + */ + @Override + public Number getStartY(int series, int item) { + return getY(series, item); + } + + /** + * Returns the ending Y value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The ending Y value. + */ + @Override + public Number getEndY(int series, int item) { + return getY(series, item); + } + + /** + * Returns the minimum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The minimum value. + */ + @Override + public double getDomainLowerBound(boolean includeInterval) { + return this.intervalDelegate.getDomainLowerBound(includeInterval); + } + + /** + * Returns the maximum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The maximum value. + */ + @Override + public double getDomainUpperBound(boolean includeInterval) { + return this.intervalDelegate.getDomainUpperBound(includeInterval); + } + + /** + * Returns the range of the values in this dataset's domain. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The range. + */ + @Override + public Range getDomainBounds(boolean includeInterval) { + if (includeInterval) { + return this.intervalDelegate.getDomainBounds(includeInterval); + } + else { + return DatasetUtilities.iterateDomainBounds(this, includeInterval); + } + } + + /** + * Returns the interval position factor. + * + * @return The interval position factor. + */ + public double getIntervalPositionFactor() { + return this.intervalDelegate.getIntervalPositionFactor(); + } + + /** + * Sets the interval position factor. Must be between 0.0 and 1.0 inclusive. + * If the factor is 0.5, the gap is in the middle of the x values. If it + * is lesser than 0.5, the gap is farther to the left and if greater than + * 0.5 it gets farther to the right. + * + * @param d the new interval position factor. + */ + public void setIntervalPositionFactor(double d) { + this.intervalDelegate.setIntervalPositionFactor(d); + fireDatasetChanged(); + } + + /** + * Returns the full interval width. + * + * @return The interval width to use. + */ + public double getIntervalWidth() { + return this.intervalDelegate.getIntervalWidth(); + } + + /** + * Sets the interval width to a fixed value, and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param d the new interval width (must be > 0). + */ + public void setIntervalWidth(double d) { + this.intervalDelegate.setFixedIntervalWidth(d); + fireDatasetChanged(); + } + + /** + * Returns whether the interval width is automatically calculated or not. + * + * @return whether the width is automatically calculated or not. + */ + public boolean isAutoWidth() { + return this.intervalDelegate.isAutoWidth(); + } + + /** + * Sets the flag that indicates whether the interval width is automatically + * calculated or not. + * + * @param b the flag. + */ + public void setAutoWidth(boolean b) { + this.intervalDelegate.setAutoWidth(b); + fireDatasetChanged(); + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (!(obj instanceof CategoryTableXYDataset)) { + return false; + } + CategoryTableXYDataset that = (CategoryTableXYDataset) obj; + if (!this.intervalDelegate.equals(that.intervalDelegate)) { + return false; + } + if (!this.values.equals(that.values)) { + return false; + } + return true; + } + + /** + * Returns an independent copy of this dataset. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is some reason that cloning + * cannot be performed. + */ + @Override + public Object clone() throws CloneNotSupportedException { + CategoryTableXYDataset clone = (CategoryTableXYDataset) super.clone(); + clone.values = (DefaultKeyedValues2D) this.values.clone(); + clone.intervalDelegate = new IntervalXYDelegate(clone); + // need to configure the intervalDelegate to match the original + clone.intervalDelegate.setFixedIntervalWidth(getIntervalWidth()); + clone.intervalDelegate.setAutoWidth(isAutoWidth()); + clone.intervalDelegate.setIntervalPositionFactor( + getIntervalPositionFactor()); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultHighLowDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultHighLowDataset.java new file mode 100755 index 0000000..3da5b2d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultHighLowDataset.java @@ -0,0 +1,444 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * DefaultHighLowDataset.java + * -------------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Mar-2002 : Version 1 (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 06-May-2004 : Now extends AbstractXYDataset and added new methods from + * HighLowDataset (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 28-Nov-2006 : Added equals() method override (DG); + * 22-Apr-2008 : Implemented PublicCloneable (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.xy; + +import java.util.Arrays; +import java.util.Date; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.util.PublicCloneable; + +/** + * A simple implementation of the {@link OHLCDataset} interface. See also + * the {@link DefaultOHLCDataset} class, which provides another implementation + * that is very similar. + */ +public class DefaultHighLowDataset extends AbstractXYDataset + implements OHLCDataset, PublicCloneable { + + /** The series key. */ + private Comparable seriesKey; + + /** Storage for the dates. */ + private Date[] date; + + /** Storage for the high values. */ + private Number[] high; + + /** Storage for the low values. */ + private Number[] low; + + /** Storage for the open values. */ + private Number[] open; + + /** Storage for the close values. */ + private Number[] close; + + /** Storage for the volume values. */ + private Number[] volume; + + /** + * Constructs a new high/low/open/close dataset. + *

+ * The current implementation allows only one series in the dataset. + * This may be extended in a future version. + * + * @param seriesKey the key for the series (null not + * permitted). + * @param date the dates (null not permitted). + * @param high the high values (null not permitted). + * @param low the low values (null not permitted). + * @param open the open values (null not permitted). + * @param close the close values (null not permitted). + * @param volume the volume values (null not permitted). + */ + public DefaultHighLowDataset(Comparable seriesKey, Date[] date, + double[] high, double[] low, double[] open, double[] close, + double[] volume) { + + ParamChecks.nullNotPermitted(seriesKey, "seriesKey"); + ParamChecks.nullNotPermitted(date, "date"); + this.seriesKey = seriesKey; + this.date = date; + this.high = createNumberArray(high); + this.low = createNumberArray(low); + this.open = createNumberArray(open); + this.close = createNumberArray(close); + this.volume = createNumberArray(volume); + + } + + /** + * Returns the key for the series stored in this dataset. + * + * @param series the index of the series (ignored, this dataset supports + * only one series and this method always returns the key for series 0). + * + * @return The series key (never null). + */ + @Override + public Comparable getSeriesKey(int series) { + return this.seriesKey; + } + + /** + * Returns the x-value for one item in a series. The value returned is a + * Long instance generated from the underlying + * Date object. To avoid generating a new object instance, + * you might prefer to call {@link #getXValue(int, int)}. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The x-value. + * + * @see #getXValue(int, int) + * @see #getXDate(int, int) + */ + @Override + public Number getX(int series, int item) { + return new Long(this.date[item].getTime()); + } + + /** + * Returns the x-value for one item in a series, as a Date. + *

+ * This method is provided for convenience only. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The x-value as a Date. + * + * @see #getX(int, int) + */ + public Date getXDate(int series, int item) { + return this.date[item]; + } + + /** + * Returns the y-value for one item in a series. + *

+ * This method (from the {@link XYDataset} interface) is mapped to the + * {@link #getCloseValue(int, int)} method. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The y-value. + * + * @see #getYValue(int, int) + */ + @Override + public Number getY(int series, int item) { + return getClose(series, item); + } + + /** + * Returns the high-value for one item in a series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The high-value. + * + * @see #getHighValue(int, int) + */ + @Override + public Number getHigh(int series, int item) { + return this.high[item]; + } + + /** + * Returns the high-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The high-value. + * + * @see #getHigh(int, int) + */ + @Override + public double getHighValue(int series, int item) { + double result = Double.NaN; + Number h = getHigh(series, item); + if (h != null) { + result = h.doubleValue(); + } + return result; + } + + /** + * Returns the low-value for one item in a series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The low-value. + * + * @see #getLowValue(int, int) + */ + @Override + public Number getLow(int series, int item) { + return this.low[item]; + } + + /** + * Returns the low-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The low-value. + * + * @see #getLow(int, int) + */ + @Override + public double getLowValue(int series, int item) { + double result = Double.NaN; + Number l = getLow(series, item); + if (l != null) { + result = l.doubleValue(); + } + return result; + } + + /** + * Returns the open-value for one item in a series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The open-value. + * + * @see #getOpenValue(int, int) + */ + @Override + public Number getOpen(int series, int item) { + return this.open[item]; + } + + /** + * Returns the open-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The open-value. + * + * @see #getOpen(int, int) + */ + @Override + public double getOpenValue(int series, int item) { + double result = Double.NaN; + Number open = getOpen(series, item); + if (open != null) { + result = open.doubleValue(); + } + return result; + } + + /** + * Returns the close-value for one item in a series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The close-value. + * + * @see #getCloseValue(int, int) + */ + @Override + public Number getClose(int series, int item) { + return this.close[item]; + } + + /** + * Returns the close-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The close-value. + * + * @see #getClose(int, int) + */ + @Override + public double getCloseValue(int series, int item) { + double result = Double.NaN; + Number c = getClose(series, item); + if (c != null) { + result = c.doubleValue(); + } + return result; + } + + /** + * Returns the volume-value for one item in a series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The volume-value. + * + * @see #getVolumeValue(int, int) + */ + @Override + public Number getVolume(int series, int item) { + return this.volume[item]; + } + + /** + * Returns the volume-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The volume-value. + * + * @see #getVolume(int, int) + */ + @Override + public double getVolumeValue(int series, int item) { + double result = Double.NaN; + Number v = getVolume(series, item); + if (v != null) { + result = v.doubleValue(); + } + return result; + } + + /** + * Returns the number of series in the dataset. + *

+ * This implementation only allows one series. + * + * @return The number of series. + */ + @Override + public int getSeriesCount() { + return 1; + } + + /** + * Returns the number of items in the specified series. + * + * @param series the index (zero-based) of the series. + * + * @return The number of items in the specified series. + */ + @Override + public int getItemCount(int series) { + return this.date.length; + } + + /** + * Tests this dataset for equality with an arbitrary instance. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DefaultHighLowDataset)) { + return false; + } + DefaultHighLowDataset that = (DefaultHighLowDataset) obj; + if (!this.seriesKey.equals(that.seriesKey)) { + return false; + } + if (!Arrays.equals(this.date, that.date)) { + return false; + } + if (!Arrays.equals(this.open, that.open)) { + return false; + } + if (!Arrays.equals(this.high, that.high)) { + return false; + } + if (!Arrays.equals(this.low, that.low)) { + return false; + } + if (!Arrays.equals(this.close, that.close)) { + return false; + } + if (!Arrays.equals(this.volume, that.volume)) { + return false; + } + return true; + } + + /** + * Constructs an array of Number objects from an array of doubles. + * + * @param data the double values to convert (null not + * permitted). + * + * @return The data as an array of Number objects. + */ + public static Number[] createNumberArray(double[] data) { + Number[] result = new Number[data.length]; + for (int i = 0; i < data.length; i++) { + result[i] = new Double(data[i]); + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultIntervalXYDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultIntervalXYDataset.java new file mode 100755 index 0000000..f4a3be9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultIntervalXYDataset.java @@ -0,0 +1,569 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * DefaultIntervalXYDataset.java + * ----------------------------- + * (C) Copyright 2006-2009, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Oct-2006 : Version 1 (DG); + * 02-Nov-2006 : Fixed a problem with adding a new series with the same key + * as an existing series (see bug 1589392) (DG); + * 28-Nov-2006 : New override for clone() (DG); + * 22-Apr-2008 : Implemented PublicCloneable (DG); + * 10-Aug-2009 : Fixed typo in Javadocs - see bug 2830419 (DG); + * + */ + +package org.jfree.data.xy; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.util.PublicCloneable; + +/** + * A dataset that defines a range (interval) for both the x-values and the + * y-values. This implementation uses six arrays to store the x, start-x, + * end-x, y, start-y and end-y values. + *

+ * An alternative implementation of the {@link IntervalXYDataset} interface + * is provided by the {@link XYIntervalSeriesCollection} class. + * + * @since 1.0.3 + */ +public class DefaultIntervalXYDataset extends AbstractIntervalXYDataset + implements PublicCloneable { + + /** + * Storage for the series keys. This list must be kept in sync with the + * seriesList. + */ + private List seriesKeys; + + /** + * Storage for the series in the dataset. We use a list because the + * order of the series is significant. This list must be kept in sync + * with the seriesKeys list. + */ + private List seriesList; + + /** + * Creates a new DefaultIntervalXYDataset instance, initially + * containing no data. + */ + public DefaultIntervalXYDataset() { + this.seriesKeys = new java.util.ArrayList(); + this.seriesList = new java.util.ArrayList(); + } + + /** + * Returns the number of series in the dataset. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.seriesList.size(); + } + + /** + * Returns the key for a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The key for the series. + * + * @throws IllegalArgumentException if series is not in the + * specified range. + */ + @Override + public Comparable getSeriesKey(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + return (Comparable) this.seriesKeys.get(series); + } + + /** + * Returns the number of items in the specified series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The item count. + * + * @throws IllegalArgumentException if series is not in the + * specified range. + */ + @Override + public int getItemCount(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + double[][] seriesArray = (double[][]) this.seriesList.get(series); + return seriesArray[0].length; + } + + /** + * Returns the x-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The x-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getX(int, int) + */ + @Override + public double getXValue(int series, int item) { + double[][] seriesData = (double[][]) this.seriesList.get(series); + return seriesData[0][item]; + } + + /** + * Returns the y-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The y-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getY(int, int) + */ + @Override + public double getYValue(int series, int item) { + double[][] seriesData = (double[][]) this.seriesList.get(series); + return seriesData[3][item]; + } + + /** + * Returns the starting x-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The starting x-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getStartX(int, int) + */ + @Override + public double getStartXValue(int series, int item) { + double[][] seriesData = (double[][]) this.seriesList.get(series); + return seriesData[1][item]; + } + + /** + * Returns the ending x-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The ending x-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getEndX(int, int) + */ + @Override + public double getEndXValue(int series, int item) { + double[][] seriesData = (double[][]) this.seriesList.get(series); + return seriesData[2][item]; + } + + /** + * Returns the starting y-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The starting y-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getStartY(int, int) + */ + @Override + public double getStartYValue(int series, int item) { + double[][] seriesData = (double[][]) this.seriesList.get(series); + return seriesData[4][item]; + } + + /** + * Returns the ending y-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The ending y-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getEndY(int, int) + */ + @Override + public double getEndYValue(int series, int item) { + double[][] seriesData = (double[][]) this.seriesList.get(series); + return seriesData[5][item]; + } + + /** + * Returns the ending x-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The ending x-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getEndXValue(int, int) + */ + @Override + public Number getEndX(int series, int item) { + return new Double(getEndXValue(series, item)); + } + + /** + * Returns the ending y-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The ending y-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getEndYValue(int, int) + */ + @Override + public Number getEndY(int series, int item) { + return new Double(getEndYValue(series, item)); + } + + /** + * Returns the starting x-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The starting x-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getStartXValue(int, int) + */ + @Override + public Number getStartX(int series, int item) { + return new Double(getStartXValue(series, item)); + } + + /** + * Returns the starting y-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The starting y-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getStartYValue(int, int) + */ + @Override + public Number getStartY(int series, int item) { + return new Double(getStartYValue(series, item)); + } + + /** + * Returns the x-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The x-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getXValue(int, int) + */ + @Override + public Number getX(int series, int item) { + return new Double(getXValue(series, item)); + } + + /** + * Returns the y-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The y-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getYValue(int, int) + */ + @Override + public Number getY(int series, int item) { + return new Double(getYValue(series, item)); + } + + /** + * Adds a series or if a series with the same key already exists replaces + * the data for that series, then sends a {@link DatasetChangeEvent} to + * all registered listeners. + * + * @param seriesKey the series key (null not permitted). + * @param data the data (must be an array with length 6, containing six + * arrays of equal length, the first three containing the x-values + * (x, xLow and xHigh) and the last three containing the y-values + * (y, yLow and yHigh)). + */ + public void addSeries(Comparable seriesKey, double[][] data) { + if (seriesKey == null) { + throw new IllegalArgumentException( + "The 'seriesKey' cannot be null."); + } + if (data == null) { + throw new IllegalArgumentException("The 'data' is null."); + } + if (data.length != 6) { + throw new IllegalArgumentException( + "The 'data' array must have length == 6."); + } + int length = data[0].length; + if (length != data[1].length || length != data[2].length + || length != data[3].length || length != data[4].length + || length != data[5].length) { + throw new IllegalArgumentException( + "The 'data' array must contain six arrays with equal length."); + } + int seriesIndex = indexOf(seriesKey); + if (seriesIndex == -1) { // add a new series + this.seriesKeys.add(seriesKey); + this.seriesList.add(data); + } + else { // replace an existing series + this.seriesList.remove(seriesIndex); + this.seriesList.add(seriesIndex, data); + } + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Tests this DefaultIntervalXYDataset instance for equality + * with an arbitrary object. This method returns true if and + * only if: + *

    + *
  • obj is not null;
  • + *
  • obj is an instance of + * DefaultIntervalXYDataset;
  • + *
  • both datasets have the same number of series, each containing + * exactly the same values.
  • + *
+ * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DefaultIntervalXYDataset)) { + return false; + } + DefaultIntervalXYDataset that = (DefaultIntervalXYDataset) obj; + if (!this.seriesKeys.equals(that.seriesKeys)) { + return false; + } + for (int i = 0; i < this.seriesList.size(); i++) { + double[][] d1 = (double[][]) this.seriesList.get(i); + double[][] d2 = (double[][]) that.seriesList.get(i); + double[] d1x = d1[0]; + double[] d2x = d2[0]; + if (!Arrays.equals(d1x, d2x)) { + return false; + } + double[] d1xs = d1[1]; + double[] d2xs = d2[1]; + if (!Arrays.equals(d1xs, d2xs)) { + return false; + } + double[] d1xe = d1[2]; + double[] d2xe = d2[2]; + if (!Arrays.equals(d1xe, d2xe)) { + return false; + } + double[] d1y = d1[3]; + double[] d2y = d2[3]; + if (!Arrays.equals(d1y, d2y)) { + return false; + } + double[] d1ys = d1[4]; + double[] d2ys = d2[4]; + if (!Arrays.equals(d1ys, d2ys)) { + return false; + } + double[] d1ye = d1[5]; + double[] d2ye = d2[5]; + if (!Arrays.equals(d1ye, d2ye)) { + return false; + } + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result; + result = this.seriesKeys.hashCode(); + result = 29 * result + this.seriesList.hashCode(); + return result; + } + + /** + * Returns a clone of this dataset. + * + * @return A clone. + * + * @throws CloneNotSupportedException if the dataset contains a series with + * a key that cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultIntervalXYDataset clone + = (DefaultIntervalXYDataset) super.clone(); + clone.seriesKeys = new java.util.ArrayList(this.seriesKeys); + clone.seriesList = new ArrayList(this.seriesList.size()); + for (int i = 0; i < this.seriesList.size(); i++) { + double[][] data = (double[][]) this.seriesList.get(i); + double[] x = data[0]; + double[] xStart = data[1]; + double[] xEnd = data[2]; + double[] y = data[3]; + double[] yStart = data[4]; + double[] yEnd = data[5]; + double[] xx = new double[x.length]; + double[] xxStart = new double[xStart.length]; + double[] xxEnd = new double[xEnd.length]; + double[] yy = new double[y.length]; + double[] yyStart = new double[yStart.length]; + double[] yyEnd = new double[yEnd.length]; + System.arraycopy(x, 0, xx, 0, x.length); + System.arraycopy(xStart, 0, xxStart, 0, xStart.length); + System.arraycopy(xEnd, 0, xxEnd, 0, xEnd.length); + System.arraycopy(y, 0, yy, 0, y.length); + System.arraycopy(yStart, 0, yyStart, 0, yStart.length); + System.arraycopy(yEnd, 0, yyEnd, 0, yEnd.length); + clone.seriesList.add(i, new double[][] {xx, xxStart, xxEnd, yy, + yyStart, yyEnd}); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultOHLCDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultOHLCDataset.java new file mode 100755 index 0000000..3edaee2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultOHLCDataset.java @@ -0,0 +1,356 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * DefaultOHLCDataset.java + * ----------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Dec-2003 : Version 1 (DG); + * 05-May-2004 : Now extends AbstractXYDataset (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 29-Apr-2005 : Added equals() method (DG); + * 22-Apr-2008 : Implemented PublicCloneable, and fixed cloning bug (DG); + * + */ + +package org.jfree.data.xy; + +import java.util.Arrays; +import java.util.Date; + +import org.jfree.util.PublicCloneable; + +/** + * A simple implementation of the {@link OHLCDataset} interface. This + * implementation supports only one series. + */ +public class DefaultOHLCDataset extends AbstractXYDataset + implements OHLCDataset, PublicCloneable { + + /** The series key. */ + private Comparable key; + + /** Storage for the data items. */ + private OHLCDataItem[] data; + + /** + * Creates a new dataset. + * + * @param key the series key. + * @param data the data items. + */ + public DefaultOHLCDataset(Comparable key, OHLCDataItem[] data) { + this.key = key; + this.data = data; + } + + /** + * Returns the series key. + * + * @param series the series index (ignored). + * + * @return The series key. + */ + @Override + public Comparable getSeriesKey(int series) { + return this.key; + } + + /** + * Returns the x-value for a data item. + * + * @param series the series index (ignored). + * @param item the item index (zero-based). + * + * @return The x-value. + */ + @Override + public Number getX(int series, int item) { + return new Long(this.data[item].getDate().getTime()); + } + + /** + * Returns the x-value for a data item as a date. + * + * @param series the series index (ignored). + * @param item the item index (zero-based). + * + * @return The x-value as a date. + */ + public Date getXDate(int series, int item) { + return this.data[item].getDate(); + } + + /** + * Returns the y-value. + * + * @param series the series index (ignored). + * @param item the item index (zero-based). + * + * @return The y value. + */ + @Override + public Number getY(int series, int item) { + return getClose(series, item); + } + + /** + * Returns the high value. + * + * @param series the series index (ignored). + * @param item the item index (zero-based). + * + * @return The high value. + */ + @Override + public Number getHigh(int series, int item) { + return this.data[item].getHigh(); + } + + /** + * Returns the high-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The high-value. + */ + @Override + public double getHighValue(int series, int item) { + double result = Double.NaN; + Number high = getHigh(series, item); + if (high != null) { + result = high.doubleValue(); + } + return result; + } + + /** + * Returns the low value. + * + * @param series the series index (ignored). + * @param item the item index (zero-based). + * + * @return The low value. + */ + @Override + public Number getLow(int series, int item) { + return this.data[item].getLow(); + } + + /** + * Returns the low-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The low-value. + */ + @Override + public double getLowValue(int series, int item) { + double result = Double.NaN; + Number low = getLow(series, item); + if (low != null) { + result = low.doubleValue(); + } + return result; + } + + /** + * Returns the open value. + * + * @param series the series index (ignored). + * @param item the item index (zero-based). + * + * @return The open value. + */ + @Override + public Number getOpen(int series, int item) { + return this.data[item].getOpen(); + } + + /** + * Returns the open-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The open-value. + */ + @Override + public double getOpenValue(int series, int item) { + double result = Double.NaN; + Number open = getOpen(series, item); + if (open != null) { + result = open.doubleValue(); + } + return result; + } + + /** + * Returns the close value. + * + * @param series the series index (ignored). + * @param item the item index (zero-based). + * + * @return The close value. + */ + @Override + public Number getClose(int series, int item) { + return this.data[item].getClose(); + } + + /** + * Returns the close-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The close-value. + */ + @Override + public double getCloseValue(int series, int item) { + double result = Double.NaN; + Number close = getClose(series, item); + if (close != null) { + result = close.doubleValue(); + } + return result; + } + + /** + * Returns the trading volume. + * + * @param series the series index (ignored). + * @param item the item index (zero-based). + * + * @return The trading volume. + */ + @Override + public Number getVolume(int series, int item) { + return this.data[item].getVolume(); + } + + /** + * Returns the volume-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The volume-value. + */ + @Override + public double getVolumeValue(int series, int item) { + double result = Double.NaN; + Number volume = getVolume(series, item); + if (volume != null) { + result = volume.doubleValue(); + } + return result; + } + + /** + * Returns the series count. + * + * @return 1. + */ + @Override + public int getSeriesCount() { + return 1; + } + + /** + * Returns the item count for the specified series. + * + * @param series the series index (ignored). + * + * @return The item count. + */ + @Override + public int getItemCount(int series) { + return this.data.length; + } + + /** + * Sorts the data into ascending order by date. + */ + public void sortDataByDate() { + Arrays.sort(this.data); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof DefaultOHLCDataset)) { + return false; + } + DefaultOHLCDataset that = (DefaultOHLCDataset) obj; + if (!this.key.equals(that.key)) { + return false; + } + if (!Arrays.equals(this.data, that.data)) { + return false; + } + return true; + } + + /** + * Returns an independent copy of this dataset. + * + * @return A clone. + * + * @throws CloneNotSupportedException + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultOHLCDataset clone = (DefaultOHLCDataset) super.clone(); + clone.data = new OHLCDataItem[this.data.length]; + System.arraycopy(this.data, 0, clone.data, 0, this.data.length); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultTableXYDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultTableXYDataset.java new file mode 100755 index 0000000..c29fe77 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultTableXYDataset.java @@ -0,0 +1,666 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * DefaultTableXYDataset.java + * -------------------------- + * (C) Copyright 2003-2013, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): Jody Brownell; + * David Gilbert (for Object Refinery Limited); + * Andreas Schroeder; + * + * Changes: + * -------- + * 27-Jul-2003 : XYDataset that forces each series to have a value for every + * X-point which is essential for stacked XY area charts (RA); + * 18-Aug-2003 : Fixed event notification when removing and updating + * series (RA); + * 22-Sep-2003 : Functionality moved from TableXYDataset to + * DefaultTableXYDataset (RA); + * 23-Dec-2003 : Added patch for large datasets, submitted by Jody + * Brownell (DG); + * 16-Feb-2004 : Added pruning methods (DG); + * 31-Mar-2004 : Provisional implementation of IntervalXYDataset (AS); + * 01-Apr-2004 : Sound implementation of IntervalXYDataset (AS); + * 05-May-2004 : Now extends AbstractIntervalXYDataset (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for the 1.0.0 + * release (DG); + * 05-Oct-2005 : Made the interval delegate a dataset listener (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 22-Apr-2008 : Implemented PublicCloneable (DG); + * 10-Jun-2009 : Simplified getX() and getY() (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.xy; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.DomainInfo; +import org.jfree.data.Range; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * An {@link XYDataset} where every series shares the same x-values (required + * for generating stacked area charts). + */ +public class DefaultTableXYDataset extends AbstractIntervalXYDataset + implements TableXYDataset, IntervalXYDataset, DomainInfo, + PublicCloneable { + + /** + * Storage for the data - this list will contain zero, one or many + * XYSeries objects. + */ + private List data = null; + + /** Storage for the x values. */ + private HashSet xPoints = null; + + /** A flag that controls whether or not events are propogated. */ + private boolean propagateEvents = true; + + /** A flag that controls auto pruning. */ + private boolean autoPrune = false; + + /** The delegate used to control the interval width. */ + private IntervalXYDelegate intervalDelegate; + + /** + * Creates a new empty dataset. + */ + public DefaultTableXYDataset() { + this(false); + } + + /** + * Creates a new empty dataset. + * + * @param autoPrune a flag that controls whether or not x-values are + * removed whenever the corresponding y-values are all + * null. + */ + public DefaultTableXYDataset(boolean autoPrune) { + this.autoPrune = autoPrune; + this.data = new ArrayList(); + this.xPoints = new HashSet(); + this.intervalDelegate = new IntervalXYDelegate(this, false); + addChangeListener(this.intervalDelegate); + } + + /** + * Returns the flag that controls whether or not x-values are removed from + * the dataset when the corresponding y-values are all null. + * + * @return A boolean. + */ + public boolean isAutoPrune() { + return this.autoPrune; + } + + /** + * Adds a series to the collection and sends a {@link DatasetChangeEvent} + * to all registered listeners. The series should be configured to NOT + * allow duplicate x-values. + * + * @param series the series (null not permitted). + */ + public void addSeries(XYSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + if (series.getAllowDuplicateXValues()) { + throw new IllegalArgumentException( + "Cannot accept XYSeries that allow duplicate values. " + + "Use XYSeries(seriesName, , false) constructor." + ); + } + updateXPoints(series); + this.data.add(series); + series.addChangeListener(this); + fireDatasetChanged(); + } + + /** + * Adds any unique x-values from 'series' to the dataset, and also adds any + * x-values that are in the dataset but not in 'series' to the series. + * + * @param series the series (null not permitted). + */ + private void updateXPoints(XYSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + HashSet seriesXPoints = new HashSet(); + boolean savedState = this.propagateEvents; + this.propagateEvents = false; + for (int itemNo = 0; itemNo < series.getItemCount(); itemNo++) { + Number xValue = series.getX(itemNo); + seriesXPoints.add(xValue); + if (!this.xPoints.contains(xValue)) { + this.xPoints.add(xValue); + int seriesCount = this.data.size(); + for (int seriesNo = 0; seriesNo < seriesCount; seriesNo++) { + XYSeries dataSeries = (XYSeries) this.data.get(seriesNo); + if (!dataSeries.equals(series)) { + dataSeries.add(xValue, null); + } + } + } + } + Iterator iterator = this.xPoints.iterator(); + while (iterator.hasNext()) { + Number xPoint = (Number) iterator.next(); + if (!seriesXPoints.contains(xPoint)) { + series.add(xPoint, null); + } + } + this.propagateEvents = savedState; + } + + /** + * Updates the x-values for all the series in the dataset. + */ + public void updateXPoints() { + this.propagateEvents = false; + for (int s = 0; s < this.data.size(); s++) { + updateXPoints((XYSeries) this.data.get(s)); + } + if (this.autoPrune) { + prune(); + } + this.propagateEvents = true; + } + + /** + * Returns the number of series in the collection. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.data.size(); + } + + /** + * Returns the number of x values in the dataset. + * + * @return The number of x values in the dataset. + */ + @Override + public int getItemCount() { + if (this.xPoints == null) { + return 0; + } + else { + return this.xPoints.size(); + } + } + + /** + * Returns a series. + * + * @param series the series (zero-based index). + * + * @return The series (never null). + */ + public XYSeries getSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Index outside valid range."); + } + return (XYSeries) this.data.get(series); + } + + /** + * Returns the key for a series. + * + * @param series the series (zero-based index). + * + * @return The key for a series. + */ + @Override + public Comparable getSeriesKey(int series) { + // check arguments...delegated + return getSeries(series).getKey(); + } + + /** + * Returns the number of items in the specified series. + * + * @param series the series (zero-based index). + * + * @return The number of items in the specified series. + */ + @Override + public int getItemCount(int series) { + // check arguments...delegated + return getSeries(series).getItemCount(); + } + + /** + * Returns the x-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The x-value for the specified series and item. + */ + @Override + public Number getX(int series, int item) { + XYSeries s = (XYSeries) this.data.get(series); + return s.getX(item); + + } + + /** + * Returns the starting X value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The starting X value. + */ + @Override + public Number getStartX(int series, int item) { + return this.intervalDelegate.getStartX(series, item); + } + + /** + * Returns the ending X value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The ending X value. + */ + @Override + public Number getEndX(int series, int item) { + return this.intervalDelegate.getEndX(series, item); + } + + /** + * Returns the y-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param index the index of the item of interest (zero-based). + * + * @return The y-value for the specified series and item (possibly + * null). + */ + @Override + public Number getY(int series, int index) { + XYSeries s = (XYSeries) this.data.get(series); + return s.getY(index); + } + + /** + * Returns the starting Y value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The starting Y value. + */ + @Override + public Number getStartY(int series, int item) { + return getY(series, item); + } + + /** + * Returns the ending Y value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The ending Y value. + */ + @Override + public Number getEndY(int series, int item) { + return getY(series, item); + } + + /** + * Removes all the series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + */ + public void removeAllSeries() { + + // Unregister the collection as a change listener to each series in + // the collection. + for (int i = 0; i < this.data.size(); i++) { + XYSeries series = (XYSeries) this.data.get(i); + series.removeChangeListener(this); + } + + // Remove all the series from the collection and notify listeners. + this.data.clear(); + this.xPoints.clear(); + fireDatasetChanged(); + } + + /** + * Removes a series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param series the series (null not permitted). + */ + public void removeSeries(XYSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + if (this.data.contains(series)) { + series.removeChangeListener(this); + this.data.remove(series); + if (this.data.isEmpty()) { + this.xPoints.clear(); + } + fireDatasetChanged(); + } + } + + /** + * Removes a series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param series the series (zero based index). + */ + public void removeSeries(int series) { + + // check arguments... + if ((series < 0) || (series > getSeriesCount())) { + throw new IllegalArgumentException("Index outside valid range."); + } + + // fetch the series, remove the change listener, then remove the series. + XYSeries s = (XYSeries) this.data.get(series); + s.removeChangeListener(this); + this.data.remove(series); + if (this.data.isEmpty()) { + this.xPoints.clear(); + } + else if (this.autoPrune) { + prune(); + } + fireDatasetChanged(); + + } + + /** + * Removes the items from all series for a given x value. + * + * @param x the x-value. + */ + public void removeAllValuesForX(Number x) { + ParamChecks.nullNotPermitted(x, "x"); + boolean savedState = this.propagateEvents; + this.propagateEvents = false; + for (int s = 0; s < this.data.size(); s++) { + XYSeries series = (XYSeries) this.data.get(s); + series.remove(x); + } + this.propagateEvents = savedState; + this.xPoints.remove(x); + fireDatasetChanged(); + } + + /** + * Returns true if all the y-values for the specified x-value + * are null and false otherwise. + * + * @param x the x-value. + * + * @return A boolean. + */ + protected boolean canPrune(Number x) { + for (int s = 0; s < this.data.size(); s++) { + XYSeries series = (XYSeries) this.data.get(s); + if (series.getY(series.indexOf(x)) != null) { + return false; + } + } + return true; + } + + /** + * Removes all x-values for which all the y-values are null. + */ + public void prune() { + HashSet hs = (HashSet) this.xPoints.clone(); + Iterator iterator = hs.iterator(); + while (iterator.hasNext()) { + Number x = (Number) iterator.next(); + if (canPrune(x)) { + removeAllValuesForX(x); + } + } + } + + /** + * This method receives notification when a series belonging to the dataset + * changes. It responds by updating the x-points for the entire dataset + * and sending a {@link DatasetChangeEvent} to all registered listeners. + * + * @param event information about the change. + */ + @Override + public void seriesChanged(SeriesChangeEvent event) { + if (this.propagateEvents) { + updateXPoints(); + fireDatasetChanged(); + } + } + + /** + * Tests this collection for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DefaultTableXYDataset)) { + return false; + } + DefaultTableXYDataset that = (DefaultTableXYDataset) obj; + if (this.autoPrune != that.autoPrune) { + return false; + } + if (this.propagateEvents != that.propagateEvents) { + return false; + } + if (!this.intervalDelegate.equals(that.intervalDelegate)) { + return false; + } + if (!ObjectUtilities.equal(this.data, that.data)) { + return false; + } + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result; + result = (this.data != null ? this.data.hashCode() : 0); + result = 29 * result + + (this.xPoints != null ? this.xPoints.hashCode() : 0); + result = 29 * result + (this.propagateEvents ? 1 : 0); + result = 29 * result + (this.autoPrune ? 1 : 0); + return result; + } + + /** + * Returns an independent copy of this dataset. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is some reason that cloning + * cannot be performed. + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultTableXYDataset clone = (DefaultTableXYDataset) super.clone(); + int seriesCount = this.data.size(); + clone.data = new java.util.ArrayList(seriesCount); + for (int i = 0; i < seriesCount; i++) { + XYSeries series = (XYSeries) this.data.get(i); + clone.data.add(series.clone()); + } + + clone.intervalDelegate = new IntervalXYDelegate(clone); + // need to configure the intervalDelegate to match the original + clone.intervalDelegate.setFixedIntervalWidth(getIntervalWidth()); + clone.intervalDelegate.setAutoWidth(isAutoWidth()); + clone.intervalDelegate.setIntervalPositionFactor( + getIntervalPositionFactor()); + clone.updateXPoints(); + return clone; + } + + /** + * Returns the minimum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The minimum value. + */ + @Override + public double getDomainLowerBound(boolean includeInterval) { + return this.intervalDelegate.getDomainLowerBound(includeInterval); + } + + /** + * Returns the maximum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The maximum value. + */ + @Override + public double getDomainUpperBound(boolean includeInterval) { + return this.intervalDelegate.getDomainUpperBound(includeInterval); + } + + /** + * Returns the range of the values in this dataset's domain. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The range. + */ + @Override + public Range getDomainBounds(boolean includeInterval) { + if (includeInterval) { + return this.intervalDelegate.getDomainBounds(includeInterval); + } + else { + return DatasetUtilities.iterateDomainBounds(this, includeInterval); + } + } + + /** + * Returns the interval position factor. + * + * @return The interval position factor. + */ + public double getIntervalPositionFactor() { + return this.intervalDelegate.getIntervalPositionFactor(); + } + + /** + * Sets the interval position factor. Must be between 0.0 and 1.0 inclusive. + * If the factor is 0.5, the gap is in the middle of the x values. If it + * is lesser than 0.5, the gap is farther to the left and if greater than + * 0.5 it gets farther to the right. + * + * @param d the new interval position factor. + */ + public void setIntervalPositionFactor(double d) { + this.intervalDelegate.setIntervalPositionFactor(d); + fireDatasetChanged(); + } + + /** + * returns the full interval width. + * + * @return The interval width to use. + */ + public double getIntervalWidth() { + return this.intervalDelegate.getIntervalWidth(); + } + + /** + * Sets the interval width to a fixed value, and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param d the new interval width (must be > 0). + */ + public void setIntervalWidth(double d) { + this.intervalDelegate.setFixedIntervalWidth(d); + fireDatasetChanged(); + } + + /** + * Returns whether the interval width is automatically calculated or not. + * + * @return A flag that determines whether or not the interval width is + * automatically calculated. + */ + public boolean isAutoWidth() { + return this.intervalDelegate.isAutoWidth(); + } + + /** + * Sets the flag that indicates whether the interval width is automatically + * calculated or not. + * + * @param b a boolean. + */ + public void setAutoWidth(boolean b) { + this.intervalDelegate.setAutoWidth(b); + fireDatasetChanged(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultWindDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultWindDataset.java new file mode 100755 index 0000000..f7e931f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultWindDataset.java @@ -0,0 +1,440 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * DefaultWindDataset.java + * ----------------------- + * (C) Copyright 2001-2013, by Achilleus Mantzios and Contributors. + * + * Original Author: Achilleus Mantzios; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 06-Feb-2002 : Version 1, based on code contributed by Achilleus + * Mantzios (DG); + * 05-May-2004 : Now extends AbstractXYDataset (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 22-Apr-2008 : Implemented PublicCloneable (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; +import java.util.Arrays; +import java.util.Collections; +import java.util.Date; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.util.PublicCloneable; + +/** + * A default implementation of the {@link WindDataset} interface. + */ +public class DefaultWindDataset extends AbstractXYDataset + implements WindDataset, PublicCloneable { + + /** The keys for the series. */ + private List seriesKeys; + + /** Storage for the series data. */ + private List allSeriesData; + + /** + * Constructs a new, empty, dataset. Since there are currently no methods + * to add data to an existing dataset, you should probably use a different + * constructor. + */ + public DefaultWindDataset() { + this.seriesKeys = new java.util.ArrayList(); + this.allSeriesData = new java.util.ArrayList(); + } + + /** + * Constructs a dataset based on the specified data array. + * + * @param data the data (null not permitted). + * + * @throws NullPointerException if data is null. + */ + public DefaultWindDataset(Object[][][] data) { + this(seriesNameListFromDataArray(data), data); + } + + /** + * Constructs a dataset based on the specified data array. + * + * @param seriesNames the names of the series (null not + * permitted). + * @param data the wind data. + * + * @throws NullPointerException if seriesNames is + * null. + */ + public DefaultWindDataset(String[] seriesNames, Object[][][] data) { + this(Arrays.asList(seriesNames), data); + } + + /** + * Constructs a dataset based on the specified data array. The array + * can contain multiple series, each series can contain multiple items, + * and each item is as follows: + *
    + *
  • data[series][item][0] - the date (either a + * Date or a Number that is the milliseconds + * since 1-Jan-1970);
  • + *
  • data[series][item][1] - the wind direction (1 - 12, + * like the numbers on a clock face);
  • + *
  • data[series][item][2] - the wind force (1 - 12 on the + * Beaufort scale)
  • + *
+ * + * @param seriesKeys the names of the series (null not + * permitted). + * @param data the wind dataset (null not permitted). + * + * @throws IllegalArgumentException if seriesKeys is + * null. + * @throws IllegalArgumentException if the number of series keys does not + * match the number of series in the array. + * @throws NullPointerException if data is null. + */ + public DefaultWindDataset(List seriesKeys, Object[][][] data) { + ParamChecks.nullNotPermitted(seriesKeys, "seriesKeys"); + if (seriesKeys.size() != data.length) { + throw new IllegalArgumentException("The number of series keys does " + + "not match the number of series in the data array."); + } + this.seriesKeys = seriesKeys; + int seriesCount = data.length; + this.allSeriesData = new java.util.ArrayList(seriesCount); + + for (int seriesIndex = 0; seriesIndex < seriesCount; seriesIndex++) { + List oneSeriesData = new java.util.ArrayList(); + int maxItemCount = data[seriesIndex].length; + for (int itemIndex = 0; itemIndex < maxItemCount; itemIndex++) { + Object xObject = data[seriesIndex][itemIndex][0]; + if (xObject != null) { + Number xNumber; + if (xObject instanceof Number) { + xNumber = (Number) xObject; + } + else { + if (xObject instanceof Date) { + Date xDate = (Date) xObject; + xNumber = new Long(xDate.getTime()); + } + else { + xNumber = new Integer(0); + } + } + Number windDir = (Number) data[seriesIndex][itemIndex][1]; + Number windForce = (Number) data[seriesIndex][itemIndex][2]; + oneSeriesData.add(new WindDataItem(xNumber, windDir, + windForce)); + } + } + Collections.sort(oneSeriesData); + this.allSeriesData.add(seriesIndex, oneSeriesData); + } + + } + + /** + * Returns the number of series in the dataset. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.allSeriesData.size(); + } + + /** + * Returns the number of items in a series. + * + * @param series the series (zero-based index). + * + * @return The item count. + */ + @Override + public int getItemCount(int series) { + if (series < 0 || series >= getSeriesCount()) { + throw new IllegalArgumentException("Invalid series index: " + + series); + } + List oneSeriesData = (List) this.allSeriesData.get(series); + return oneSeriesData.size(); + } + + /** + * Returns the key for a series. + * + * @param series the series (zero-based index). + * + * @return The series key. + */ + @Override + public Comparable getSeriesKey(int series) { + if (series < 0 || series >= getSeriesCount()) { + throw new IllegalArgumentException("Invalid series index: " + + series); + } + return (Comparable) this.seriesKeys.get(series); + } + + /** + * Returns the x-value for one item within a series. This should represent + * a point in time, encoded as milliseconds in the same way as + * java.util.Date. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The x-value for the item within the series. + */ + @Override + public Number getX(int series, int item) { + List oneSeriesData = (List) this.allSeriesData.get(series); + WindDataItem windItem = (WindDataItem) oneSeriesData.get(item); + return windItem.getX(); + } + + /** + * Returns the y-value for one item within a series. This maps to the + * {@link #getWindForce(int, int)} method and is implemented because + * WindDataset is an extension of {@link XYDataset}. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The y-value for the item within the series. + */ + @Override + public Number getY(int series, int item) { + return getWindForce(series, item); + } + + /** + * Returns the wind direction for one item within a series. This is a + * number between 0 and 12, like the numbers on an upside-down clock face. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The wind direction for the item within the series. + */ + @Override + public Number getWindDirection(int series, int item) { + List oneSeriesData = (List) this.allSeriesData.get(series); + WindDataItem windItem = (WindDataItem) oneSeriesData.get(item); + return windItem.getWindDirection(); + } + + /** + * Returns the wind force for one item within a series. This is a number + * between 0 and 12, as defined by the Beaufort scale. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The wind force for the item within the series. + */ + @Override + public Number getWindForce(int series, int item) { + List oneSeriesData = (List) this.allSeriesData.get(series); + WindDataItem windItem = (WindDataItem) oneSeriesData.get(item); + return windItem.getWindForce(); + } + + /** + * Utility method for automatically generating series names. + * + * @param data the wind data (null not permitted). + * + * @return An array of Series N with N = { 1 .. data.length }. + * + * @throws NullPointerException if data is null. + */ + public static List seriesNameListFromDataArray(Object[][] data) { + int seriesCount = data.length; + List seriesNameList = new java.util.ArrayList(seriesCount); + for (int i = 0; i < seriesCount; i++) { + seriesNameList.add("Series " + (i + 1)); + } + return seriesNameList; + } + + /** + * Checks this WindDataset for equality with an arbitrary + * object. This method returns true if and only if: + *
    + *
  • obj is not null;
  • + *
  • obj is an instance of + * DefaultWindDataset;
  • + *
  • both datasets have the same number of series containing identical + * values.
  • + *
      + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (!(obj instanceof DefaultWindDataset)) { + return false; + } + DefaultWindDataset that = (DefaultWindDataset) obj; + if (!this.seriesKeys.equals(that.seriesKeys)) { + return false; + } + if (!this.allSeriesData.equals(that.allSeriesData)) { + return false; + } + return true; + } + +} + +/** + * A wind data item. + */ +class WindDataItem implements Comparable, Serializable { + + /** The x-value. */ + private Number x; + + /** The wind direction. */ + private Number windDir; + + /** The wind force. */ + private Number windForce; + + /** + * Creates a new wind data item. + * + * @param x the x-value. + * @param windDir the direction. + * @param windForce the force. + */ + public WindDataItem(Number x, Number windDir, Number windForce) { + this.x = x; + this.windDir = windDir; + this.windForce = windForce; + } + + /** + * Returns the x-value. + * + * @return The x-value. + */ + public Number getX() { + return this.x; + } + + /** + * Returns the wind direction. + * + * @return The wind direction. + */ + public Number getWindDirection() { + return this.windDir; + } + + /** + * Returns the wind force. + * + * @return The wind force. + */ + public Number getWindForce() { + return this.windForce; + } + + /** + * Compares this item to another object. + * + * @param object the other object. + * + * @return An int that indicates the relative comparison. + */ + @Override + public int compareTo(Object object) { + if (object instanceof WindDataItem) { + WindDataItem item = (WindDataItem) object; + if (this.x.doubleValue() > item.x.doubleValue()) { + return 1; + } + else if (this.x.equals(item.x)) { + return 0; + } + else { + return -1; + } + } + else { + throw new ClassCastException("WindDataItem.compareTo(error)"); + } + } + + /** + * Tests this WindDataItem for equality with an arbitrary + * object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (this == obj) { + return false; + } + if (!(obj instanceof WindDataItem)) { + return false; + } + WindDataItem that = (WindDataItem) obj; + if (!this.x.equals(that.x)) { + return false; + } + if (!this.windDir.equals(that.windDir)) { + return false; + } + if (!this.windForce.equals(that.windForce)) { + return false; + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultXYDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultXYDataset.java new file mode 100755 index 0000000..6f17ec2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultXYDataset.java @@ -0,0 +1,387 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * DefaultXYDataset.java + * --------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 06-Jul-2006 : Version 1 (DG); + * 02-Nov-2006 : Fixed a problem with adding a new series with the same key + * as an existing series (see bug 1589392) (DG); + * 25-Jan-2007 : Implemented PublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.jfree.data.DomainOrder; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.util.PublicCloneable; + +/** + * A default implementation of the {@link XYDataset} interface that stores + * data values in arrays of double primitives. + * + * @since 1.0.2 + */ +public class DefaultXYDataset extends AbstractXYDataset + implements XYDataset, PublicCloneable { + + /** + * Storage for the series keys. This list must be kept in sync with the + * seriesList. + */ + private List seriesKeys; + + /** + * Storage for the series in the dataset. We use a list because the + * order of the series is significant. This list must be kept in sync + * with the seriesKeys list. + */ + private List seriesList; + + /** + * Creates a new DefaultXYDataset instance, initially + * containing no data. + */ + public DefaultXYDataset() { + this.seriesKeys = new java.util.ArrayList(); + this.seriesList = new java.util.ArrayList(); + } + + /** + * Returns the number of series in the dataset. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.seriesList.size(); + } + + /** + * Returns the key for a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The key for the series. + * + * @throws IllegalArgumentException if series is not in the + * specified range. + */ + @Override + public Comparable getSeriesKey(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + return (Comparable) this.seriesKeys.get(series); + } + + /** + * Returns the index of the series with the specified key, or -1 if there + * is no such series in the dataset. + * + * @param seriesKey the series key (null permitted). + * + * @return The index, or -1. + */ + @Override + public int indexOf(Comparable seriesKey) { + return this.seriesKeys.indexOf(seriesKey); + } + + /** + * Returns the order of the domain (x-) values in the dataset. In this + * implementation, we cannot guarantee that the x-values are ordered, so + * this method returns DomainOrder.NONE. + * + * @return DomainOrder.NONE. + */ + @Override + public DomainOrder getDomainOrder() { + return DomainOrder.NONE; + } + + /** + * Returns the number of items in the specified series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The item count. + * + * @throws IllegalArgumentException if series is not in the + * specified range. + */ + @Override + public int getItemCount(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + double[][] seriesArray = (double[][]) this.seriesList.get(series); + return seriesArray[0].length; + } + + /** + * Returns the x-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The x-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getX(int, int) + */ + @Override + public double getXValue(int series, int item) { + double[][] seriesData = (double[][]) this.seriesList.get(series); + return seriesData[0][item]; + } + + /** + * Returns the x-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The x-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getXValue(int, int) + */ + @Override + public Number getX(int series, int item) { + return new Double(getXValue(series, item)); + } + + /** + * Returns the y-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The y-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getY(int, int) + */ + @Override + public double getYValue(int series, int item) { + double[][] seriesData = (double[][]) this.seriesList.get(series); + return seriesData[1][item]; + } + + /** + * Returns the y-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The y-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getX(int, int) + */ + @Override + public Number getY(int series, int item) { + return new Double(getYValue(series, item)); + } + + /** + * Adds a series or if a series with the same key already exists replaces + * the data for that series, then sends a {@link DatasetChangeEvent} to + * all registered listeners. + * + * @param seriesKey the series key (null not permitted). + * @param data the data (must be an array with length 2, containing two + * arrays of equal length, the first containing the x-values and the + * second containing the y-values). + */ + public void addSeries(Comparable seriesKey, double[][] data) { + if (seriesKey == null) { + throw new IllegalArgumentException( + "The 'seriesKey' cannot be null."); + } + if (data == null) { + throw new IllegalArgumentException("The 'data' is null."); + } + if (data.length != 2) { + throw new IllegalArgumentException( + "The 'data' array must have length == 2."); + } + if (data[0].length != data[1].length) { + throw new IllegalArgumentException( + "The 'data' array must contain two arrays with equal length."); + } + int seriesIndex = indexOf(seriesKey); + if (seriesIndex == -1) { // add a new series + this.seriesKeys.add(seriesKey); + this.seriesList.add(data); + } + else { // replace an existing series + this.seriesList.remove(seriesIndex); + this.seriesList.add(seriesIndex, data); + } + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Removes a series from the dataset, then sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param seriesKey the series key (null not permitted). + * + */ + public void removeSeries(Comparable seriesKey) { + int seriesIndex = indexOf(seriesKey); + if (seriesIndex >= 0) { + this.seriesKeys.remove(seriesIndex); + this.seriesList.remove(seriesIndex); + notifyListeners(new DatasetChangeEvent(this, this)); + } + } + + /** + * Tests this DefaultXYDataset instance for equality with an + * arbitrary object. This method returns true if and only if: + *
        + *
      • obj is not null;
      • + *
      • obj is an instance of + * DefaultXYDataset;
      • + *
      • both datasets have the same number of series, each containing + * exactly the same values.
      • + *
      + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DefaultXYDataset)) { + return false; + } + DefaultXYDataset that = (DefaultXYDataset) obj; + if (!this.seriesKeys.equals(that.seriesKeys)) { + return false; + } + for (int i = 0; i < this.seriesList.size(); i++) { + double[][] d1 = (double[][]) this.seriesList.get(i); + double[][] d2 = (double[][]) that.seriesList.get(i); + double[] d1x = d1[0]; + double[] d2x = d2[0]; + if (!Arrays.equals(d1x, d2x)) { + return false; + } + double[] d1y = d1[1]; + double[] d2y = d2[1]; + if (!Arrays.equals(d1y, d2y)) { + return false; + } + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result; + result = this.seriesKeys.hashCode(); + result = 29 * result + this.seriesList.hashCode(); + return result; + } + + /** + * Creates an independent copy of this dataset. + * + * @return The cloned dataset. + * + * @throws CloneNotSupportedException if there is a problem cloning the + * dataset (for instance, if a non-cloneable object is used for a + * series key). + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultXYDataset clone = (DefaultXYDataset) super.clone(); + clone.seriesKeys = new java.util.ArrayList(this.seriesKeys); + clone.seriesList = new ArrayList(this.seriesList.size()); + for (int i = 0; i < this.seriesList.size(); i++) { + double[][] data = (double[][]) this.seriesList.get(i); + double[] x = data[0]; + double[] y = data[1]; + double[] xx = new double[x.length]; + double[] yy = new double[y.length]; + System.arraycopy(x, 0, xx, 0, x.length); + System.arraycopy(y, 0, yy, 0, y.length); + clone.seriesList.add(i, new double[][] {xx, yy}); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultXYZDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultXYZDataset.java new file mode 100755 index 0000000..06b18f9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/DefaultXYZDataset.java @@ -0,0 +1,443 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * DefaultXYZDataset.java + * ---------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 12-Jul-2006 : Version 1 (DG); + * 06-Oct-2006 : Fixed API doc warnings (DG); + * 02-Nov-2006 : Fixed a problem with adding a new series with the same key + * as an existing series (see bug 1589392) (DG); + * 22-Apr-2008 : Implemented PublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.jfree.data.DomainOrder; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.util.PublicCloneable; + +/** + * A default implementation of the {@link XYZDataset} interface that stores + * data values in arrays of double primitives. + * + * @since 1.0.2 + */ +public class DefaultXYZDataset extends AbstractXYZDataset + implements XYZDataset, PublicCloneable { + + /** + * Storage for the series keys. This list must be kept in sync with the + * seriesList. + */ + private List seriesKeys; + + /** + * Storage for the series in the dataset. We use a list because the + * order of the series is significant. This list must be kept in sync + * with the seriesKeys list. + */ + private List seriesList; + + /** + * Creates a new DefaultXYZDataset instance, initially + * containing no data. + */ + public DefaultXYZDataset() { + this.seriesKeys = new java.util.ArrayList(); + this.seriesList = new java.util.ArrayList(); + } + + /** + * Returns the number of series in the dataset. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.seriesList.size(); + } + + /** + * Returns the key for a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The key for the series. + * + * @throws IllegalArgumentException if series is not in the + * specified range. + */ + @Override + public Comparable getSeriesKey(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + return (Comparable) this.seriesKeys.get(series); + } + + /** + * Returns the index of the series with the specified key, or -1 if there + * is no such series in the dataset. + * + * @param seriesKey the series key (null permitted). + * + * @return The index, or -1. + */ + @Override + public int indexOf(Comparable seriesKey) { + return this.seriesKeys.indexOf(seriesKey); + } + + /** + * Returns the order of the domain (x-) values in the dataset. In this + * implementation, we cannot guarantee that the x-values are ordered, so + * this method returns DomainOrder.NONE. + * + * @return DomainOrder.NONE. + */ + @Override + public DomainOrder getDomainOrder() { + return DomainOrder.NONE; + } + + /** + * Returns the number of items in the specified series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The item count. + * + * @throws IllegalArgumentException if series is not in the + * specified range. + */ + @Override + public int getItemCount(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + double[][] seriesArray = (double[][]) this.seriesList.get(series); + return seriesArray[0].length; + } + + /** + * Returns the x-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The x-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getX(int, int) + */ + @Override + public double getXValue(int series, int item) { + double[][] seriesData = (double[][]) this.seriesList.get(series); + return seriesData[0][item]; + } + + /** + * Returns the x-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The x-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getXValue(int, int) + */ + @Override + public Number getX(int series, int item) { + return new Double(getXValue(series, item)); + } + + /** + * Returns the y-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The y-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getY(int, int) + */ + @Override + public double getYValue(int series, int item) { + double[][] seriesData = (double[][]) this.seriesList.get(series); + return seriesData[1][item]; + } + + /** + * Returns the y-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The y-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getX(int, int) + */ + @Override + public Number getY(int series, int item) { + return new Double(getYValue(series, item)); + } + + /** + * Returns the z-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The z-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getZ(int, int) + */ + @Override + public double getZValue(int series, int item) { + double[][] seriesData = (double[][]) this.seriesList.get(series); + return seriesData[2][item]; + } + + /** + * Returns the z-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The z-value. + * + * @throws ArrayIndexOutOfBoundsException if series is not + * within the specified range. + * @throws ArrayIndexOutOfBoundsException if item is not + * within the specified range. + * + * @see #getZ(int, int) + */ + @Override + public Number getZ(int series, int item) { + return new Double(getZValue(series, item)); + } + + /** + * Adds a series or if a series with the same key already exists replaces + * the data for that series, then sends a {@link DatasetChangeEvent} to + * all registered listeners. + * + * @param seriesKey the series key (null not permitted). + * @param data the data (must be an array with length 3, containing three + * arrays of equal length, the first containing the x-values, the + * second containing the y-values and the third containing the + * z-values). + */ + public void addSeries(Comparable seriesKey, double[][] data) { + if (seriesKey == null) { + throw new IllegalArgumentException( + "The 'seriesKey' cannot be null."); + } + if (data == null) { + throw new IllegalArgumentException("The 'data' is null."); + } + if (data.length != 3) { + throw new IllegalArgumentException( + "The 'data' array must have length == 3."); + } + if (data[0].length != data[1].length + || data[0].length != data[2].length) { + throw new IllegalArgumentException("The 'data' array must contain " + + "three arrays all having the same length."); + } + int seriesIndex = indexOf(seriesKey); + if (seriesIndex == -1) { // add a new series + this.seriesKeys.add(seriesKey); + this.seriesList.add(data); + } + else { // replace an existing series + this.seriesList.remove(seriesIndex); + this.seriesList.add(seriesIndex, data); + } + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Removes a series from the dataset, then sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param seriesKey the series key (null not permitted). + * + */ + public void removeSeries(Comparable seriesKey) { + int seriesIndex = indexOf(seriesKey); + if (seriesIndex >= 0) { + this.seriesKeys.remove(seriesIndex); + this.seriesList.remove(seriesIndex); + notifyListeners(new DatasetChangeEvent(this, this)); + } + } + + /** + * Tests this DefaultXYDataset instance for equality with an + * arbitrary object. This method returns true if and only if: + *
        + *
      • obj is not null;
      • + *
      • obj is an instance of + * DefaultXYDataset;
      • + *
      • both datasets have the same number of series, each containing + * exactly the same values.
      • + *
      + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof DefaultXYZDataset)) { + return false; + } + DefaultXYZDataset that = (DefaultXYZDataset) obj; + if (!this.seriesKeys.equals(that.seriesKeys)) { + return false; + } + for (int i = 0; i < this.seriesList.size(); i++) { + double[][] d1 = (double[][]) this.seriesList.get(i); + double[][] d2 = (double[][]) that.seriesList.get(i); + double[] d1x = d1[0]; + double[] d2x = d2[0]; + if (!Arrays.equals(d1x, d2x)) { + return false; + } + double[] d1y = d1[1]; + double[] d2y = d2[1]; + if (!Arrays.equals(d1y, d2y)) { + return false; + } + double[] d1z = d1[2]; + double[] d2z = d2[2]; + if (!Arrays.equals(d1z, d2z)) { + return false; + } + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result; + result = this.seriesKeys.hashCode(); + result = 29 * result + this.seriesList.hashCode(); + return result; + } + + /** + * Creates an independent copy of this dataset. + * + * @return The cloned dataset. + * + * @throws CloneNotSupportedException if there is a problem cloning the + * dataset (for instance, if a non-cloneable object is used for a + * series key). + */ + @Override + public Object clone() throws CloneNotSupportedException { + DefaultXYZDataset clone = (DefaultXYZDataset) super.clone(); + clone.seriesKeys = new java.util.ArrayList(this.seriesKeys); + clone.seriesList = new ArrayList(this.seriesList.size()); + for (int i = 0; i < this.seriesList.size(); i++) { + double[][] data = (double[][]) this.seriesList.get(i); + double[] x = data[0]; + double[] y = data[1]; + double[] z = data[2]; + double[] xx = new double[x.length]; + double[] yy = new double[y.length]; + double[] zz = new double[z.length]; + System.arraycopy(x, 0, xx, 0, x.length); + System.arraycopy(y, 0, yy, 0, y.length); + System.arraycopy(z, 0, zz, 0, z.length); + clone.seriesList.add(i, new double[][] {xx, yy, zz}); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/IntervalXYDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/IntervalXYDataset.java new file mode 100755 index 0000000..2d91bef --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/IntervalXYDataset.java @@ -0,0 +1,155 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * IntervalXYDataset.java + * ---------------------- + * (C) Copyright 2001-2009, by Object Refinery Limited and Contributors. + * + * Original Author: Mark Watson (www.markwatson.com); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 18-Oct-2001 : Version 1, thanks to Mark Watson (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc (DG); + * 06-May-2004 : Added methods that return double primitives (DG); + * 15-Sep-2009 : Added clarifications to API docs (DG); + * + */ + +package org.jfree.data.xy; + +/** + * An extension of the {@link XYDataset} interface that allows an x-interval + * and a y-interval to be defined. Note that the x and y values defined + * by the parent interface are NOT required to fall within these intervals. + * This interface is used to support (among other things) bar plots against + * numerical axes. + */ +public interface IntervalXYDataset extends XYDataset { + + /** + * Returns the lower bound of the x-interval for the specified series and + * item. If this lower bound is specified, it should be less than or + * equal to the upper bound of the interval (if one is specified). + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The lower bound of the x-interval (null permitted). + */ + public Number getStartX(int series, int item); + + /** + * Returns the lower bound of the x-interval (as a double primitive) for + * the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The lower bound of the x-interval. + * + * @see #getStartX(int, int) + */ + public double getStartXValue(int series, int item); + + /** + * Returns the upper bound of the x-interval for the specified series and + * item. If this upper bound is specified, it should be greater than or + * equal to the lower bound of the interval (if one is specified). + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The upper bound of the x-interval (null permitted). + */ + public Number getEndX(int series, int item); + + /** + * Returns the upper bound of the x-interval (as a double primitive) for + * the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The upper bound of the x-interval. + * + * @see #getEndX(int, int) + */ + public double getEndXValue(int series, int item); + + /** + * Returns the lower bound of the y-interval for the specified series and + * item. If this lower bound is specified, it should be less than or + * equal to the upper bound of the interval (if one is specified). + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The lower bound of the y-interval (null permitted). + */ + public Number getStartY(int series, int item); + + /** + * Returns the lower bound of the y-interval (as a double primitive) for + * the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The lower bound of the y-interval. + * + * @see #getStartY(int, int) + */ + public double getStartYValue(int series, int item); + + /** + * Returns the upper bound of the y-interval for the specified series and + * item. If this upper bound is specified, it should be greater than or + * equal to the lower bound of the interval (if one is specified). + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The upper bound of the y-interval (null permitted). + */ + public Number getEndY(int series, int item); + + /** + * Returns the upper bound of the y-interval (as a double primitive) for + * the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The upper bound of the y-interval. + * + * @see #getEndY(int, int) + */ + public double getEndYValue(int series, int item); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/IntervalXYDelegate.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/IntervalXYDelegate.java new file mode 100755 index 0000000..e71a584 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/IntervalXYDelegate.java @@ -0,0 +1,488 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * IntervalXYDelegate.java + * ----------------------- + * (C) Copyright 2004-2013, by Andreas Schroeder and Contributors. + * + * Original Author: Andreas Schroeder; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 31-Mar-2004 : Version 1 (AS); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); + * 04-Nov-2004 : Added argument check for setIntervalWidth() method (DG); + * 17-Nov-2004 : New methods to reflect changes in DomainInfo (DG); + * 11-Jan-2005 : Removed deprecated methods in preparation for the 1.0.0 + * release (DG); + * 21-Feb-2005 : Made public and added equals() method (DG); + * 06-Oct-2005 : Implemented DatasetChangeListener to recalculate + * autoIntervalWidth (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 06-Mar-2009 : Implemented hashCode() (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.DomainInfo; +import org.jfree.data.Range; +import org.jfree.data.RangeInfo; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetChangeListener; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A delegate that handles the specification or automatic calculation of the + * interval surrounding the x-values in a dataset. This is used to extend + * a regular {@link XYDataset} to support the {@link IntervalXYDataset} + * interface. + *

      + * The decorator pattern was not used because of the several possibly + * implemented interfaces of the decorated instance (e.g. + * {@link TableXYDataset}, {@link RangeInfo}, {@link DomainInfo} etc.). + *

      + * The width can be set manually or calculated automatically. The switch + * autoWidth allows to determine which behavior is used. The auto width + * calculation tries to find the smallest gap between two x-values in the + * dataset. If there is only one item in the series, the auto width + * calculation fails and falls back on the manually set interval width (which + * is itself defaulted to 1.0). + */ +public class IntervalXYDelegate implements DatasetChangeListener, + DomainInfo, Serializable, Cloneable, PublicCloneable { + + /** For serialization. */ + private static final long serialVersionUID = -685166711639592857L; + + /** + * The dataset to enhance. + */ + private XYDataset dataset; + + /** + * A flag to indicate whether the width should be calculated automatically. + */ + private boolean autoWidth; + + /** + * A value between 0.0 and 1.0 that indicates the position of the x-value + * within the interval. + */ + private double intervalPositionFactor; + + /** + * The fixed interval width (defaults to 1.0). + */ + private double fixedIntervalWidth; + + /** + * The automatically calculated interval width. + */ + private double autoIntervalWidth; + + /** + * Creates a new delegate that. + * + * @param dataset the underlying dataset (null not permitted). + */ + public IntervalXYDelegate(XYDataset dataset) { + this(dataset, true); + } + + /** + * Creates a new delegate for the specified dataset. + * + * @param dataset the underlying dataset (null not permitted). + * @param autoWidth a flag that controls whether the interval width is + * calculated automatically. + */ + public IntervalXYDelegate(XYDataset dataset, boolean autoWidth) { + ParamChecks.nullNotPermitted(dataset, "dataset"); + this.dataset = dataset; + this.autoWidth = autoWidth; + this.intervalPositionFactor = 0.5; + this.autoIntervalWidth = Double.POSITIVE_INFINITY; + this.fixedIntervalWidth = 1.0; + } + + /** + * Returns true if the interval width is automatically + * calculated, and false otherwise. + * + * @return A boolean. + */ + public boolean isAutoWidth() { + return this.autoWidth; + } + + /** + * Sets the flag that indicates whether the interval width is automatically + * calculated. If the flag is set to true, the interval is + * recalculated. + *

      + * Note: recalculating the interval amounts to changing the data values + * represented by the dataset. The calling dataset must fire an + * appropriate {@link DatasetChangeEvent}. + * + * @param b a boolean. + */ + public void setAutoWidth(boolean b) { + this.autoWidth = b; + if (b) { + this.autoIntervalWidth = recalculateInterval(); + } + } + + /** + * Returns the interval position factor. + * + * @return The interval position factor. + */ + public double getIntervalPositionFactor() { + return this.intervalPositionFactor; + } + + /** + * Sets the interval position factor. This controls how the interval is + * aligned to the x-value. For a value of 0.5, the interval is aligned + * with the x-value in the center. For a value of 0.0, the interval is + * aligned with the x-value at the lower end of the interval, and for a + * value of 1.0, the interval is aligned with the x-value at the upper + * end of the interval. + *

      + * Note that changing the interval position factor amounts to changing the + * data values represented by the dataset. Therefore, the dataset that is + * using this delegate is responsible for generating the + * appropriate {@link DatasetChangeEvent}. + * + * @param d the new interval position factor (in the range + * 0.0 to 1.0 inclusive). + */ + public void setIntervalPositionFactor(double d) { + if (d < 0.0 || 1.0 < d) { + throw new IllegalArgumentException( + "Argument 'd' outside valid range."); + } + this.intervalPositionFactor = d; + } + + /** + * Returns the fixed interval width. + * + * @return The fixed interval width. + */ + public double getFixedIntervalWidth() { + return this.fixedIntervalWidth; + } + + /** + * Sets the fixed interval width and, as a side effect, sets the + * autoWidth flag to false. + *

      + * Note that changing the interval width amounts to changing the data + * values represented by the dataset. Therefore, the dataset + * that is using this delegate is responsible for generating the + * appropriate {@link DatasetChangeEvent}. + * + * @param w the width (negative values not permitted). + */ + public void setFixedIntervalWidth(double w) { + if (w < 0.0) { + throw new IllegalArgumentException("Negative 'w' argument."); + } + this.fixedIntervalWidth = w; + this.autoWidth = false; + } + + /** + * Returns the interval width. This method will return either the + * auto calculated interval width or the manually specified interval + * width, depending on the {@link #isAutoWidth()} result. + * + * @return The interval width to use. + */ + public double getIntervalWidth() { + if (isAutoWidth() && !Double.isInfinite(this.autoIntervalWidth)) { + // everything is fine: autoWidth is on, and an autoIntervalWidth + // was set. + return this.autoIntervalWidth; + } + else { + // either autoWidth is off or autoIntervalWidth was not set. + return this.fixedIntervalWidth; + } + } + + /** + * Returns the start value of the x-interval for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The start value of the x-interval (possibly null). + * + * @see #getStartXValue(int, int) + */ + public Number getStartX(int series, int item) { + Number startX = null; + Number x = this.dataset.getX(series, item); + if (x != null) { + startX = new Double(x.doubleValue() + - (getIntervalPositionFactor() * getIntervalWidth())); + } + return startX; + } + + /** + * Returns the start value of the x-interval for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The start value of the x-interval. + * + * @see #getStartX(int, int) + */ + public double getStartXValue(int series, int item) { + return this.dataset.getXValue(series, item) + - getIntervalPositionFactor() * getIntervalWidth(); + } + + /** + * Returns the end value of the x-interval for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The end value of the x-interval (possibly null). + * + * @see #getEndXValue(int, int) + */ + public Number getEndX(int series, int item) { + Number endX = null; + Number x = this.dataset.getX(series, item); + if (x != null) { + endX = new Double(x.doubleValue() + + ((1.0 - getIntervalPositionFactor()) * getIntervalWidth())); + } + return endX; + } + + /** + * Returns the end value of the x-interval for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The end value of the x-interval. + * + * @see #getEndX(int, int) + */ + public double getEndXValue(int series, int item) { + return this.dataset.getXValue(series, item) + + (1.0 - getIntervalPositionFactor()) * getIntervalWidth(); + } + + /** + * Returns the minimum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The minimum value. + */ + @Override + public double getDomainLowerBound(boolean includeInterval) { + double result = Double.NaN; + Range r = getDomainBounds(includeInterval); + if (r != null) { + result = r.getLowerBound(); + } + return result; + } + + /** + * Returns the maximum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The maximum value. + */ + @Override + public double getDomainUpperBound(boolean includeInterval) { + double result = Double.NaN; + Range r = getDomainBounds(includeInterval); + if (r != null) { + result = r.getUpperBound(); + } + return result; + } + + /** + * Returns the range of the values in the dataset's domain, including + * or excluding the interval around each x-value as specified. + * + * @param includeInterval a flag that determines whether or not the + * x-interval should be taken into account. + * + * @return The range. + */ + @Override + public Range getDomainBounds(boolean includeInterval) { + // first get the range without the interval, then expand it for the + // interval width + Range range = DatasetUtilities.findDomainBounds(this.dataset, false); + if (includeInterval && range != null) { + double lowerAdj = getIntervalWidth() * getIntervalPositionFactor(); + double upperAdj = getIntervalWidth() - lowerAdj; + range = new Range(range.getLowerBound() - lowerAdj, + range.getUpperBound() + upperAdj); + } + return range; + } + + /** + * Handles events from the dataset by recalculating the interval if + * necessary. + * + * @param e the event. + */ + @Override + public void datasetChanged(DatasetChangeEvent e) { + // TODO: by coding the event with some information about what changed + // in the dataset, we could make the recalculation of the interval + // more efficient in some cases (for instance, if the change is + // just an update to a y-value, then the x-interval doesn't need + // updating)... + if (this.autoWidth) { + this.autoIntervalWidth = recalculateInterval(); + } + } + + /** + * Recalculate the minimum width "from scratch". + * + * @return The minimum width. + */ + private double recalculateInterval() { + double result = Double.POSITIVE_INFINITY; + int seriesCount = this.dataset.getSeriesCount(); + for (int series = 0; series < seriesCount; series++) { + result = Math.min(result, calculateIntervalForSeries(series)); + } + return result; + } + + /** + * Calculates the interval width for a given series. + * + * @param series the series index. + * + * @return The interval width. + */ + private double calculateIntervalForSeries(int series) { + double result = Double.POSITIVE_INFINITY; + int itemCount = this.dataset.getItemCount(series); + if (itemCount > 1) { + double prev = this.dataset.getXValue(series, 0); + for (int item = 1; item < itemCount; item++) { + double x = this.dataset.getXValue(series, item); + result = Math.min(result, x - prev); + prev = x; + } + } + return result; + } + + /** + * Tests the delegate for equality with an arbitrary object. The + * equality test considers two delegates to be equal if they would + * calculate the same intervals for any given dataset (for this reason, the + * dataset itself is NOT included in the equality test, because it is just + * a reference back to the current 'owner' of the delegate). + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof IntervalXYDelegate)) { + return false; + } + IntervalXYDelegate that = (IntervalXYDelegate) obj; + if (this.autoWidth != that.autoWidth) { + return false; + } + if (this.intervalPositionFactor != that.intervalPositionFactor) { + return false; + } + if (this.fixedIntervalWidth != that.fixedIntervalWidth) { + return false; + } + return true; + } + + /** + * @return A clone of this delegate. + * + * @throws CloneNotSupportedException if the object cannot be cloned. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int hash = 5; + hash = HashUtilities.hashCode(hash, this.autoWidth); + hash = HashUtilities.hashCode(hash, this.intervalPositionFactor); + hash = HashUtilities.hashCode(hash, this.fixedIntervalWidth); + return hash; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/IntervalXYZDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/IntervalXYZDataset.java new file mode 100755 index 0000000..2a21774 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/IntervalXYZDataset.java @@ -0,0 +1,109 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * IntervalXYZDataset.java + * ----------------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 31-Oct-2001 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +/** + * An extension of the {@link XYZDataset} interface that allows a range of data + * to be defined for any of the X values, the Y values, and the Z values. + */ +public interface IntervalXYZDataset extends XYZDataset { + + /** + * Returns the starting X value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item within a series (zero-based index). + * + * @return The starting X value for the specified series and item. + */ + public Number getStartXValue(int series, int item); + + /** + * Returns the ending X value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item within a series (zero-based index). + * + * @return The ending X value for the specified series and item. + */ + public Number getEndXValue(int series, int item); + + /** + * Returns the starting Y value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item within a series (zero-based index). + * + * @return The starting Y value for the specified series and item. + */ + public Number getStartYValue(int series, int item); + + /** + * Returns the ending Y value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item within a series (zero-based index). + * + * @return The ending Y value for the specified series and item. + */ + public Number getEndYValue(int series, int item); + + /** + * Returns the starting Z value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item within a series (zero-based index). + * + * @return The starting Z value for the specified series and item. + */ + public Number getStartZValue(int series, int item); + + /** + * Returns the ending Z value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item within a series (zero-based index). + * + * @return The ending Z value for the specified series and item. + */ + public Number getEndZValue(int series, int item); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/MatrixSeries.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/MatrixSeries.java new file mode 100755 index 0000000..b1e6c99 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/MatrixSeries.java @@ -0,0 +1,239 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * MatrixSeries.java + * ----------------- + * (C) Copyright 2003-2008, by Barak Naveh and Contributors. + * + * Original Author: Barak Naveh; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Zhitao Wang; + * + * Changes + * ------- + * 10-Jul-2003 : Version 1 contributed by Barak Naveh (DG); + * 10-Feb-2004 : Fixed Checkstyle complaints (DG); + * 21-May-2004 : Fixed bug 940188 - problem in getItemColumn() and + * getItemRow() (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 27-Nov-2006 : Fixed bug in equals() method (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; + +import org.jfree.data.general.Series; + +/** + * Represents a dense matrix M[i,j] where each Mij item of the matrix has a + * value (default is 0). + */ +public class MatrixSeries extends Series implements Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7934188527308315704L; + + /** Series matrix values */ + protected double[][] data; + + /** + * Constructs a new matrix series. + *

      + * By default, all matrix items are initialzed to 0. + *

      + * + * @param name series name (null not permitted). + * @param rows the number of rows. + * @param columns the number of columns. + */ + public MatrixSeries(String name, int rows, int columns) { + super(name); + this.data = new double[rows][columns]; + zeroAll(); + } + + /** + * Returns the number of columns in this matrix series. + * + * @return The number of columns in this matrix series. + */ + public int getColumnsCount() { + return this.data[0].length; + } + + + /** + * Return the matrix item at the specified index. Note that this method + * creates a new Double instance every time it is called. + * + * @param itemIndex item index. + * + * @return The matrix item at the specified index. + * + * @see #get(int, int) + */ + public Number getItem(int itemIndex) { + int i = getItemRow(itemIndex); + int j = getItemColumn(itemIndex); + + Number n = new Double(get(i, j)); + + return n; + } + + + /** + * Returns the column of the specified item. + * + * @param itemIndex the index of the item. + * + * @return The column of the specified item. + */ + public int getItemColumn(int itemIndex) { + //assert itemIndex >= 0 && itemIndex < getItemCount(); + return itemIndex % getColumnsCount(); + } + + + /** + * Returns the number of items in the series. + * + * @return The item count. + */ + @Override + public int getItemCount() { + return getRowCount() * getColumnsCount(); + } + + + /** + * Returns the row of the specified item. + * + * @param itemIndex the index of the item. + * + * @return The row of the specified item. + */ + public int getItemRow(int itemIndex) { + //assert itemIndex >= 0 && itemIndex < getItemCount(); + return itemIndex / getColumnsCount(); + } + + + /** + * Returns the number of rows in this matrix series. + * + * @return The number of rows in this matrix series. + */ + public int getRowCount() { + return this.data.length; + } + + + /** + * Returns the value of the specified item in this matrix series. + * + * @param i the row of the item. + * @param j the column of the item. + * + * @return The value of the specified item in this matrix series. + * + * @see #getItem(int) + * @see #update(int, int, double) + */ + public double get(int i, int j) { + return this.data[i][j]; + } + + + /** + * Updates the value of the specified item in this matrix series. + * + * @param i the row of the item. + * @param j the column of the item. + * @param mij the new value for the item. + * + * @see #get(int, int) + */ + public void update(int i, int j, double mij) { + this.data[i][j] = mij; + fireSeriesChanged(); + } + + + /** + * Sets all matrix values to zero and sends a + * {@link org.jfree.data.general.SeriesChangeEvent} to all registered + * listeners. + */ + public void zeroAll() { + int rows = getRowCount(); + int columns = getColumnsCount(); + + for (int row = 0; row < rows; row++) { + for (int column = 0; column < columns; column++) { + this.data[row][column] = 0.0; + } + } + fireSeriesChanged(); + } + + /** + * Tests this object instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof MatrixSeries)) { + return false; + } + MatrixSeries that = (MatrixSeries) obj; + if (!(getRowCount() == that.getRowCount())) { + return false; + } + if (!(getColumnsCount() == that.getColumnsCount())) { + return false; + } + for (int r = 0; r < getRowCount(); r++) { + for (int c = 0; c < getColumnsCount(); c++) { + if (get(r, c) != that.get(r, c)) { + return false; + } + } + } + return super.equals(obj); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/MatrixSeriesCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/MatrixSeriesCollection.java new file mode 100755 index 0000000..12a09f1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/MatrixSeriesCollection.java @@ -0,0 +1,335 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * MatrixSeriesCollection.java + * --------------------------- + * (C) Copyright 2003-2013, by Barak Naveh and Contributors. + * + * Original Author: Barak Naveh; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 10-Jul-2003 : Version 1 contributed by Barak Naveh (DG); + * 05-May-2004 : Now extends AbstractXYZDataset (DG); + * 15-Jul-2004 : Switched getZ() and getZValue() methods (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 27-Nov-2006 : Added clone() override (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 22-Apr-2008 : Implemented PublicCloneable (DG); + */ + +package org.jfree.data.xy; + +import java.io.Serializable; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * Represents a collection of {@link MatrixSeries} that can be used as a + * dataset. + * + * @see org.jfree.data.xy.MatrixSeries + */ +public class MatrixSeriesCollection extends AbstractXYZDataset + implements XYZDataset, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -3197705779242543945L; + + /** The series that are included in the collection. */ + private List seriesList; + + /** + * Constructs an empty dataset. + */ + public MatrixSeriesCollection() { + this(null); + } + + + /** + * Constructs a dataset and populates it with a single matrix series. + * + * @param series the time series. + */ + public MatrixSeriesCollection(MatrixSeries series) { + this.seriesList = new java.util.ArrayList(); + + if (series != null) { + this.seriesList.add(series); + series.addChangeListener(this); + } + } + + /** + * Returns the number of items in the specified series. + * + * @param seriesIndex zero-based series index. + * + * @return The number of items in the specified series. + */ + @Override + public int getItemCount(int seriesIndex) { + return getSeries(seriesIndex).getItemCount(); + } + + + /** + * Returns the series having the specified index. + * + * @param seriesIndex zero-based series index. + * + * @return The series. + * + * @throws IllegalArgumentException + */ + public MatrixSeries getSeries(int seriesIndex) { + if ((seriesIndex < 0) || (seriesIndex > getSeriesCount())) { + throw new IllegalArgumentException("Index outside valid range."); + } + MatrixSeries series = (MatrixSeries) this.seriesList.get(seriesIndex); + return series; + } + + + /** + * Returns the number of series in the collection. + * + * @return The number of series in the collection. + */ + @Override + public int getSeriesCount() { + return this.seriesList.size(); + } + + + /** + * Returns the key for a series. + * + * @param seriesIndex zero-based series index. + * + * @return The key for a series. + */ + @Override + public Comparable getSeriesKey(int seriesIndex) { + return getSeries(seriesIndex).getKey(); + } + + + /** + * Returns the j index value of the specified Mij matrix item in the + * specified matrix series. + * + * @param seriesIndex zero-based series index. + * @param itemIndex zero-based item index. + * + * @return The j index value for the specified matrix item. + * + * @see org.jfree.data.xy.XYDataset#getXValue(int, int) + */ + @Override + public Number getX(int seriesIndex, int itemIndex) { + MatrixSeries series = (MatrixSeries) this.seriesList.get(seriesIndex); + int x = series.getItemColumn(itemIndex); + + return new Integer(x); // I know it's bad to create object. better idea? + } + + + /** + * Returns the i index value of the specified Mij matrix item in the + * specified matrix series. + * + * @param seriesIndex zero-based series index. + * @param itemIndex zero-based item index. + * + * @return The i index value for the specified matrix item. + * + * @see org.jfree.data.xy.XYDataset#getYValue(int, int) + */ + @Override + public Number getY(int seriesIndex, int itemIndex) { + MatrixSeries series = (MatrixSeries) this.seriesList.get(seriesIndex); + int y = series.getItemRow(itemIndex); + + return new Integer(y); // I know it's bad to create object. better idea? + } + + + /** + * Returns the Mij item value of the specified Mij matrix item in the + * specified matrix series. + * + * @param seriesIndex the series (zero-based index). + * @param itemIndex zero-based item index. + * + * @return The Mij item value for the specified matrix item. + * + * @see org.jfree.data.xy.XYZDataset#getZValue(int, int) + */ + @Override + public Number getZ(int seriesIndex, int itemIndex) { + MatrixSeries series = (MatrixSeries) this.seriesList.get(seriesIndex); + Number z = series.getItem(itemIndex); + return z; + } + + + /** + * Adds a series to the collection. + *

      + * Notifies all registered listeners that the dataset has changed. + *

      + * + * @param series the series (null not permitted). + */ + public void addSeries(MatrixSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + // FIXME: Check that there isn't already a series with the same key + + // add the series... + this.seriesList.add(series); + series.addChangeListener(this); + fireDatasetChanged(); + } + + + /** + * Tests this collection for equality with an arbitrary object. + * + * @param obj the object. + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + + if (obj == this) { + return true; + } + + if (obj instanceof MatrixSeriesCollection) { + MatrixSeriesCollection c = (MatrixSeriesCollection) obj; + + return ObjectUtilities.equal(this.seriesList, c.seriesList); + } + + return false; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return (this.seriesList != null ? this.seriesList.hashCode() : 0); + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem. + */ + @Override + public Object clone() throws CloneNotSupportedException { + MatrixSeriesCollection clone = (MatrixSeriesCollection) super.clone(); + clone.seriesList = (List) ObjectUtilities.deepClone(this.seriesList); + return clone; + } + + /** + * Removes all the series from the collection. + *

      + * Notifies all registered listeners that the dataset has changed. + *

      + */ + public void removeAllSeries() { + // Unregister the collection as a change listener to each series in + // the collection. + for (int i = 0; i < this.seriesList.size(); i++) { + MatrixSeries series = (MatrixSeries) this.seriesList.get(i); + series.removeChangeListener(this); + } + + // Remove all the series from the collection and notify listeners. + this.seriesList.clear(); + fireDatasetChanged(); + } + + + /** + * Removes a series from the collection. + *

      + * Notifies all registered listeners that the dataset has changed. + *

      + * + * @param series the series (null). + */ + public void removeSeries(MatrixSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + if (this.seriesList.contains(series)) { + series.removeChangeListener(this); + this.seriesList.remove(series); + fireDatasetChanged(); + } + } + + + /** + * Removes a series from the collection. + *

      + * Notifies all registered listeners that the dataset has changed. + * + * @param seriesIndex the series (zero based index). + * + * @throws IllegalArgumentException + */ + public void removeSeries(int seriesIndex) { + // check arguments... + if ((seriesIndex < 0) || (seriesIndex > getSeriesCount())) { + throw new IllegalArgumentException("Index outside valid range."); + } + + // fetch the series, remove the change listener, then remove the series. + MatrixSeries series = (MatrixSeries) this.seriesList.get(seriesIndex); + series.removeChangeListener(this); + this.seriesList.remove(seriesIndex); + fireDatasetChanged(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/NormalizedMatrixSeries.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/NormalizedMatrixSeries.java new file mode 100755 index 0000000..c21d51f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/NormalizedMatrixSeries.java @@ -0,0 +1,153 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * NormalizedMatrixSeries.java + * --------------------------- + * (C) Copyright 2003-2008, by Barak Naveh and Contributors. + * + * Original Author: Barak Naveh; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 10-Jul-2003 : Version 1 contributed by Barak Naveh (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.xy; + +/** + * Represents a dense normalized matrix M[i,j] where each Mij item of the + * matrix has a value (default is 0). When a matrix item is observed using + * getItem method, it is normalized, that is, divided by the + * total sum of all items. It can be also be scaled by setting a scale factor. + */ +public class NormalizedMatrixSeries extends MatrixSeries { + + /** The default scale factor. */ + public static final double DEFAULT_SCALE_FACTOR = 1.0; + + /** + * A factor that multiplies each item in this series when observed using + * getItem method. + */ + private double m_scaleFactor = DEFAULT_SCALE_FACTOR; + + /** The sum of all items in this matrix */ + private double m_totalSum; + + /** + * Constructor for NormalizedMatrixSeries. + * + * @param name the series name. + * @param rows the number of rows. + * @param columns the number of columns. + */ + public NormalizedMatrixSeries(String name, int rows, int columns) { + super(name, rows, columns); + + /* + * we assum super is always initialized to all-zero matrix, so the + * total sum should be 0 upon initialization. However, we set it to + * Double.MIN_VALUE to get the same effect and yet avoid division by 0 + * upon initialization. + */ + this.m_totalSum = Double.MIN_VALUE; + } + + /** + * Returns an item. + * + * @param itemIndex the index. + * + * @return The value. + * + * @see org.jfree.data.xy.MatrixSeries#getItem(int) + */ + @Override + public Number getItem(int itemIndex) { + int i = getItemRow(itemIndex); + int j = getItemColumn(itemIndex); + + double mij = get(i, j) * this.m_scaleFactor; + Number n = new Double(mij / this.m_totalSum); + + return n; + } + + /** + * Sets the factor that multiplies each item in this series when observed + * using getItem mehtod. + * + * @param factor new factor to set. + * + * @see #DEFAULT_SCALE_FACTOR + */ + public void setScaleFactor(double factor) { + this.m_scaleFactor = factor; + // FIXME: this should generate a series change event + } + + + /** + * Returns the factor that multiplies each item in this series when + * observed using getItem mehtod. + * + * @return The factor + */ + public double getScaleFactor() { + return this.m_scaleFactor; + } + + + /** + * Updates the value of the specified item in this matrix series. + * + * @param i the row of the item. + * @param j the column of the item. + * @param mij the new value for the item. + * + * @see #get(int, int) + */ + @Override + public void update(int i, int j, double mij) { + this.m_totalSum -= get(i, j); + this.m_totalSum += mij; + + super.update(i, j, mij); + } + + /** + * @see org.jfree.data.xy.MatrixSeries#zeroAll() + */ + @Override + public void zeroAll() { + this.m_totalSum = 0; + super.zeroAll(); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/OHLCDataItem.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/OHLCDataItem.java new file mode 100755 index 0000000..bc1b3f7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/OHLCDataItem.java @@ -0,0 +1,208 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * OHLCDataItem.java + * ----------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Dec-2003 : Version 1 (DG); + * 29-Apr-2005 : Added equals() method (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; +import java.util.Date; +import org.jfree.chart.util.ParamChecks; + +/** + * Represents a single (open-high-low-close) data item in + * an {@link DefaultOHLCDataset}. This data item is commonly used + * to summarise the trading activity of a financial commodity for + * a fixed period (most often one day). + */ +public class OHLCDataItem implements Comparable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 7753817154401169901L; + + /** The date. */ + private Date date; + + /** The open value. */ + private Number open; + + /** The high value. */ + private Number high; + + /** The low value. */ + private Number low; + + /** The close value. */ + private Number close; + + /** The trading volume (number of shares, contracts or whatever). */ + private Number volume; + + /** + * Creates a new item. + * + * @param date the date (null not permitted). + * @param open the open value. + * @param high the high value. + * @param low the low value. + * @param close the close value. + * @param volume the volume. + */ + public OHLCDataItem(Date date, double open, double high, double low, + double close, double volume) { + ParamChecks.nullNotPermitted(date, "date"); + this.date = date; + this.open = new Double(open); + this.high = new Double(high); + this.low = new Double(low); + this.close = new Double(close); + this.volume = new Double(volume); + } + + /** + * Returns the date that the data item relates to. + * + * @return The date (never null). + */ + public Date getDate() { + return this.date; + } + + /** + * Returns the open value. + * + * @return The open value (never null). + */ + public Number getOpen() { + return this.open; + } + + /** + * Returns the high value. + * + * @return The high value (never null). + */ + public Number getHigh() { + return this.high; + } + + /** + * Returns the low value. + * + * @return The low value (never null). + */ + public Number getLow() { + return this.low; + } + + /** + * Returns the close value. + * + * @return The close value (never null). + */ + public Number getClose() { + return this.close; + } + + /** + * Returns the volume. + * + * @return The volume (never null). + */ + public Number getVolume() { + return this.volume; + } + + /** + * Checks this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof OHLCDataItem)) { + return false; + } + OHLCDataItem that = (OHLCDataItem) obj; + if (!this.date.equals(that.date)) { + return false; + } + if (!this.high.equals(that.high)) { + return false; + } + if (!this.low.equals(that.low)) { + return false; + } + if (!this.open.equals(that.open)) { + return false; + } + if (!this.close.equals(that.close)) { + return false; + } + return true; + } + + /** + * Compares this object with the specified object for order. Returns a + * negative integer, zero, or a positive integer as this object is less + * than, equal to, or greater than the specified object. + * + * @param object the object to compare to. + * + * @return A negative integer, zero, or a positive integer as this object + * is less than, equal to, or greater than the specified object. + */ + @Override + public int compareTo(Object object) { + if (object instanceof OHLCDataItem) { + OHLCDataItem item = (OHLCDataItem) object; + return this.date.compareTo(item.date); + } + else { + throw new ClassCastException("OHLCDataItem.compareTo()."); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/OHLCDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/OHLCDataset.java new file mode 100755 index 0000000..c759432 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/OHLCDataset.java @@ -0,0 +1,162 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * OHLCDataset.java + * ---------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Sylvain Vieujot; + * + * Changes (from 18-Sep-2001) + * -------------------------- + * 18-Sep-2001 : Updated header info (DG); + * 16-Oct-2001 : Moved to package com.jrefinery.data.* (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * 05-Feb-2002 : Added getVolumeValue() method, as requested by Sylvain + * Vieujot (DG); + * 05-May-2004 : Added methods that return double primitives (DG); + * 26-Jul-2004 : Switched names of methods that return Number vs + * primitives (DG); + * 06-Sep-2004 : Renamed HighLowDataset --> OHLCDataset (DG); + * + */ + +package org.jfree.data.xy; + +/** + * An interface that defines data in the form of (x, high, low, open, close) + * tuples. + */ +public interface OHLCDataset extends XYDataset { + + /** + * Returns the high-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value. + */ + public Number getHigh(int series, int item); + + /** + * Returns the high-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The high-value. + */ + public double getHighValue(int series, int item); + + /** + * Returns the low-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value. + */ + public Number getLow(int series, int item); + + /** + * Returns the low-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The low-value. + */ + public double getLowValue(int series, int item); + + /** + * Returns the open-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value. + */ + public Number getOpen(int series, int item); + + /** + * Returns the open-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The open-value. + */ + public double getOpenValue(int series, int item); + + /** + * Returns the y-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value. + */ + public Number getClose(int series, int item); + + /** + * Returns the close-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The close-value. + */ + public double getCloseValue(int series, int item); + + /** + * Returns the volume for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value. + */ + public Number getVolume(int series, int item); + + /** + * Returns the volume-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The volume-value. + */ + public double getVolumeValue(int series, int item); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/TableXYDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/TableXYDataset.java new file mode 100755 index 0000000..b9878ec --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/TableXYDataset.java @@ -0,0 +1,62 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * TableXYDataset.java + * ------------------- + * (C) Copyright 2000-2008, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 22-Sep-2003 : Changed to be an interface. Previous functionality moved to + * DefaultTableXYDataset; + * 16-Feb-2004 : Updated Javadocs (DG); + * + */ + +package org.jfree.data.xy; + + +/** + * A dataset containing one or more data series containing (x, y) data items, + * where all series in the dataset share the same set of x-values. This is a + * restricted form of the {@link XYDataset} interface (which allows independent + * x-values between series). This is used primarily by the + * {@link org.jfree.chart.renderer.xy.StackedXYAreaRenderer}. + */ +public interface TableXYDataset extends XYDataset { + + /** + * Returns the number of items every series. + * + * @return The item count. + */ + public int getItemCount(); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/Vector.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/Vector.java new file mode 100755 index 0000000..d575042 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/Vector.java @@ -0,0 +1,148 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------- + * Vector.java + * ----------- + * (C) Copyright 2007, 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jan-2007 : Version 1 (DG); + * 24-May-2007 : Added getLength() and getAngle() methods, thanks to + * matinh (DG); + * 25-May-2007 : Moved from experimental to the main source tree (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; + +/** + * A vector. + * + * @since 1.0.6 + */ +public class Vector implements Serializable { + + /** The vector x. */ + private double x; + + /** The vector y. */ + private double y; + + /** + * Creates a new instance of Vector. + * + * @param x the x-component. + * @param y the y-component. + */ + public Vector(double x, double y) { + this.x = x; + this.y = y; + } + + /** + * Returns the x-value. + * + * @return The x-value. + */ + public double getX() { + return this.x; + } + + /** + * Returns the y-value. + * + * @return The y-value. + */ + public double getY() { + return this.y; + } + + /** + * Returns the length of the vector. + * + * @return The vector length. + */ + public double getLength() { + return Math.sqrt((this.x * this.x) + (this.y * this.y)); + } + + /** + * Returns the angle of the vector. + * + * @return The angle of the vector. + */ + public double getAngle() { + return Math.atan2(this.y, this.x); + } + + /** + * Tests this vector for equality with an arbitrary object. + * + * @param obj the object (null not permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof Vector)) { + return false; + } + Vector that = (Vector) obj; + if (this.x != that.x) { + return false; + } + if (this.y != that.y) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 193; + 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)); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/VectorDataItem.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/VectorDataItem.java new file mode 100755 index 0000000..b8ce8a5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/VectorDataItem.java @@ -0,0 +1,127 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * VectorDataItem.java + * ------------------- + * (C) Copyright 2007-2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jan-2007 : Version 1 (DG); + * 24-May-2007 : Added getVector(), renamed getDeltaX() --> getVectorX(), + * and likewise for getDeltaY() (DG); + * 25-May-2007 : Moved from experimental to the main source tree (DG); + * + */ + +package org.jfree.data.xy; + +import org.jfree.data.ComparableObjectItem; + +/** + * A data item representing data in the form (x, y, deltaX, deltaY), intended + * for use by the {@link VectorSeries} class. + * + * @since 1.0.6 + */ +public class VectorDataItem extends ComparableObjectItem { + + /** + * Creates a new instance of VectorDataItem. + * + * @param x the x-value. + * @param y the y-value. + * @param deltaX the vector x. + * @param deltaY the vector y. + */ + public VectorDataItem(double x, double y, double deltaX, double deltaY) { + super(new XYCoordinate(x, y), new Vector(deltaX, deltaY)); + } + + /** + * Returns the x-value. + * + * @return The x-value (never null). + */ + public double getXValue() { + XYCoordinate xy = (XYCoordinate) getComparable(); + return xy.getX(); + } + + /** + * Returns the y-value. + * + * @return The y-value. + */ + public double getYValue() { + XYCoordinate xy = (XYCoordinate) getComparable(); + return xy.getY(); + } + + /** + * Returns the vector. + * + * @return The vector (possibly null). + */ + public Vector getVector() { + return (Vector) getObject(); + } + + /** + * Returns the x-component for the vector. + * + * @return The x-component. + */ + public double getVectorX() { + Vector vi = (Vector) getObject(); + if (vi != null) { + return vi.getX(); + } + else { + return Double.NaN; + } + } + + /** + * Returns the y-component for the vector. + * + * @return The y-component. + */ + public double getVectorY() { + Vector vi = (Vector) getObject(); + if (vi != null) { + return vi.getY(); + } + else { + return Double.NaN; + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/VectorSeries.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/VectorSeries.java new file mode 100755 index 0000000..2b5b17a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/VectorSeries.java @@ -0,0 +1,173 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * VectorSeries.java + * ----------------- + * (C) Copyright 2007, 2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jan-2007 : Version 1 (DG); + * 24-May-2007 : Renamed getDeltaXValue() --> getVectorXValue(), and likewise + * for getDeltaYValue() (DG); + * 25-May-2007 : Added remove(int) and clear() methods, and moved from the + * experimental to the main source tree (DG); + * 27-Nov-2007 : Removed redundant clear() method (DG); + * + */ + +package org.jfree.data.xy; + +import org.jfree.data.ComparableObjectItem; +import org.jfree.data.ComparableObjectSeries; +import org.jfree.data.general.SeriesChangeEvent; + +/** + * A list of (x,y, deltaX, deltaY) data items. + * + * @since 1.0.6 + * + * @see VectorSeriesCollection + */ +public class VectorSeries extends ComparableObjectSeries { + + /** + * Creates a new empty series. + * + * @param key the series key (null not permitted). + */ + public VectorSeries(Comparable key) { + this(key, false, true); + } + + /** + * Constructs a new series that contains no data. You can specify + * whether or not duplicate x-values are allowed for the series. + * + * @param key the series key (null not permitted). + * @param autoSort a flag that controls whether or not the items in the + * series are sorted. + * @param allowDuplicateXValues a flag that controls whether duplicate + * x-values are allowed. + */ + public VectorSeries(Comparable key, boolean autoSort, + boolean allowDuplicateXValues) { + super(key, autoSort, allowDuplicateXValues); + } + + /** + * Adds a data item to the series. + * + * @param x the x-value. + * @param y the y-value. + * @param deltaX the vector x. + * @param deltaY the vector y. + */ + public void add(double x, double y, double deltaX, double deltaY) { + super.add(new VectorDataItem(x, y, deltaX, deltaY), true); + } + + /** + * Removes the item at the specified index and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param index the index. + * + * @return The item removed. + */ + @Override + public ComparableObjectItem remove(int index) { + VectorDataItem result = (VectorDataItem) this.data.remove(index); + fireSeriesChanged(); + return result; + } + + /** + * Returns the x-value for the specified item. + * + * @param index the item index. + * + * @return The x-value. + */ + public double getXValue(int index) { + VectorDataItem item = (VectorDataItem) this.getDataItem(index); + return item.getXValue(); + } + + /** + * Returns the y-value for the specified item. + * + * @param index the item index. + * + * @return The y-value. + */ + public double getYValue(int index) { + VectorDataItem item = (VectorDataItem) getDataItem(index); + return item.getYValue(); + } + + /** + * Returns the x-component of the vector for an item in the series. + * + * @param index the item index. + * + * @return The x-component of the vector. + */ + public double getVectorXValue(int index) { + VectorDataItem item = (VectorDataItem) getDataItem(index); + return item.getVectorX(); + } + + /** + * Returns the y-component of the vector for an item in the series. + * + * @param index the item index. + * + * @return The y-component of the vector. + */ + public double getVectorYValue(int index) { + VectorDataItem item = (VectorDataItem) getDataItem(index); + return item.getVectorY(); + } + + /** + * Returns the data item at the specified index. + * + * @param index the item index. + * + * @return The data item. + */ + @Override + public ComparableObjectItem getDataItem(int index) { + // overridden to make public + return super.getDataItem(index); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/VectorSeriesCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/VectorSeriesCollection.java new file mode 100755 index 0000000..ee8534d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/VectorSeriesCollection.java @@ -0,0 +1,337 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * VectorSeriesCollection.java + * --------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jan-2007 : Version 1 (DG); + * 24-May-2007 : Added indexOf(), removeSeries() and removeAllSeries() + * methods (DG); + * 25-May-2007 : Moved from experimental to the main source tree (DG); + * 22-Apr-2008 : Implemented PublicCloneable (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A collection of {@link VectorSeries} objects. + * + * @since 1.0.6 + */ +public class VectorSeriesCollection extends AbstractXYDataset + implements VectorXYDataset, PublicCloneable, Serializable { + + /** Storage for the data series. */ + private List data; + + /** + * Creates a new instance of VectorSeriesCollection. + */ + public VectorSeriesCollection() { + this.data = new java.util.ArrayList(); + } + + /** + * Adds a series to the collection and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param series the series (null not permitted). + */ + public void addSeries(VectorSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + this.data.add(series); + series.addChangeListener(this); + fireDatasetChanged(); + } + + /** + * Removes the specified series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param series the series (null not permitted). + * + * @return A boolean indicating whether the series has actually been + * removed. + */ + public boolean removeSeries(VectorSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + boolean removed = this.data.remove(series); + if (removed) { + series.removeChangeListener(this); + fireDatasetChanged(); + } + return removed; + } + + /** + * Removes all the series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + */ + public void removeAllSeries() { + + // deregister the collection as a change listener to each series in the + // collection + for (int i = 0; i < this.data.size(); i++) { + VectorSeries series = (VectorSeries) this.data.get(i); + series.removeChangeListener(this); + } + + // remove all the series from the collection and notify listeners. + this.data.clear(); + fireDatasetChanged(); + + } + + /** + * Returns the number of series in the collection. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.data.size(); + } + + /** + * Returns a series from the collection. + * + * @param series the series index (zero-based). + * + * @return The series. + * + * @throws IllegalArgumentException if series is not in the + * range 0 to getSeriesCount() - 1. + */ + public VectorSeries getSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + return (VectorSeries) this.data.get(series); + } + + /** + * Returns the key for a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The key for a series. + * + * @throws IllegalArgumentException if series is not in the + * specified range. + */ + @Override + public Comparable getSeriesKey(int series) { + // defer argument checking + return getSeries(series).getKey(); + } + + /** + * Returns the index of the specified series, or -1 if that series is not + * present in the dataset. + * + * @param series the series (null not permitted). + * + * @return The series index. + */ + public int indexOf(VectorSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + return this.data.indexOf(series); + } + + /** + * Returns the number of items in the specified series. + * + * @param series the series (zero-based index). + * + * @return The item count. + * + * @throws IllegalArgumentException if series is not in the + * range 0 to getSeriesCount() - 1. + */ + @Override + public int getItemCount(int series) { + // defer argument checking + return getSeries(series).getItemCount(); + } + + /** + * Returns the x-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value. + */ + @Override + public double getXValue(int series, int item) { + VectorSeries s = (VectorSeries) this.data.get(series); + VectorDataItem di = (VectorDataItem) s.getDataItem(item); + return di.getXValue(); + } + + /** + * Returns the x-value for an item within a series. Note that this method + * creates a new {@link Double} instance every time it is called---use + * {@link #getXValue(int, int)} instead, if possible. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value. + */ + @Override + public Number getX(int series, int item) { + return new Double(getXValue(series, item)); + } + + /** + * Returns the y-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The y-value. + */ + @Override + public double getYValue(int series, int item) { + VectorSeries s = (VectorSeries) this.data.get(series); + VectorDataItem di = (VectorDataItem) s.getDataItem(item); + return di.getYValue(); + } + + /** + * Returns the y-value for an item within a series. Note that this method + * creates a new {@link Double} instance every time it is called---use + * {@link #getYValue(int, int)} instead, if possible. + * + * @param series the series index. + * @param item the item index. + * + * @return The y-value. + */ + @Override + public Number getY(int series, int item) { + return new Double(getYValue(series, item)); + } + + /** + * Returns the vector for an item in a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The vector (possibly null). + */ + @Override + public Vector getVector(int series, int item) { + VectorSeries s = (VectorSeries) this.data.get(series); + VectorDataItem di = (VectorDataItem) s.getDataItem(item); + return di.getVector(); + } + + /** + * Returns the x-component of the vector for an item in a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-component of the vector. + */ + @Override + public double getVectorXValue(int series, int item) { + VectorSeries s = (VectorSeries) this.data.get(series); + VectorDataItem di = (VectorDataItem) s.getDataItem(item); + return di.getVectorX(); + } + + /** + * Returns the y-component of the vector for an item in a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The y-component of the vector. + */ + @Override + public double getVectorYValue(int series, int item) { + VectorSeries s = (VectorSeries) this.data.get(series); + VectorDataItem di = (VectorDataItem) s.getDataItem(item); + return di.getVectorY(); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof VectorSeriesCollection)) { + return false; + } + VectorSeriesCollection that = (VectorSeriesCollection) obj; + return ObjectUtilities.equal(this.data, that.data); + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem. + */ + @Override + public Object clone() throws CloneNotSupportedException { + VectorSeriesCollection clone + = (VectorSeriesCollection) super.clone(); + clone.data = (List) ObjectUtilities.deepClone(this.data); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/VectorXYDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/VectorXYDataset.java new file mode 100755 index 0000000..86ad62d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/VectorXYDataset.java @@ -0,0 +1,89 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * VectorXYDataset.java + * -------------------- + * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jan-2007 : Version 1 (DG); + * 24-May-2007 : Renamed getDeltaXValue() as getVectorXValue(), and likewise + * for getDeltaYValue(), and replaced getDeltaX()/getDeltaY() + * with getVector() (DG); + * 25-May-2007 : Moved from experimental to the main source tree (DG); + * + */ + +package org.jfree.data.xy; + +/** + * An extension of the {@link XYDataset} interface that allows a vector to be + * defined at a specific (x, y) location. + * + * @since 1.0.6 + */ +public interface VectorXYDataset extends XYDataset { + + /** + * Returns the x-component of the vector for an item in a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-component of the vector. + */ + public double getVectorXValue(int series, int item); + + /** + * Returns the y-component of the vector for an item in a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The y-component of the vector. + */ + public double getVectorYValue(int series, int item); + + /** + * Returns the vector for an item in a series. Depending on the particular + * dataset implementation, this may involve creating a new {@link Vector} + * instance --- if you are just interested in the x and y components, + * use the {@link #getVectorXValue(int, int)} and + * {@link #getVectorYValue(int, int)} methods instead. + * + * @param series the series index. + * @param item the item index. + * + * @return The vector (possibly null). + */ + public Vector getVector(int series, int item); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/WindDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/WindDataset.java new file mode 100755 index 0000000..cd48de0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/WindDataset.java @@ -0,0 +1,77 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * WindDataset.java + * ---------------- + * (C) Copyright 2001-2008, by Achilleus Mantzios and Contributors. + * + * Original Author: Achilleus Mantzios; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 06-Feb-2002 : Version 1, based on code contributed by Achilleus + * Mantzios (DG); + * + */ + +package org.jfree.data.xy; + +/** + * Interface for a dataset that supplies wind intensity and direction values + * observed at various points in time. + */ +public interface WindDataset extends XYDataset { + + /** + * Returns the wind direction (should be in the range 0 to 12, + * corresponding to the positions on an upside-down clock face). + * + * @param series the series (in the range 0 to + * getSeriesCount() - 1). + * @param item the item (in the range 0 to + * getItemCount(series) - 1). + * + * @return The wind direction. + */ + public Number getWindDirection(int series, int item); + + /** + * Returns the wind force on the Beaufort scale (0 to 12). See: + *

      + * http://en.wikipedia.org/wiki/Beaufort_scale + * + * @param series the series (in the range 0 to + * getSeriesCount() - 1). + * @param item the item (in the range 0 to + * getItemCount(series) - 1). + * + * @return The wind force. + */ + public Number getWindForce(int series, int item); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XIntervalDataItem.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XIntervalDataItem.java new file mode 100755 index 0000000..7367009 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XIntervalDataItem.java @@ -0,0 +1,118 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * XIntervalDataItem.java + * ---------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import org.jfree.data.ComparableObjectItem; + +/** + * An item representing data in the form (x, x-low, x-high, y). + * + * @since 1.0.3 + */ +public class XIntervalDataItem extends ComparableObjectItem { + + /** + * Creates a new instance of XIntervalDataItem. + * + * @param x the x-value. + * @param xLow the lower bound of the x-interval. + * @param xHigh the upper bound of the x-interval. + * @param y the y-value. + */ + public XIntervalDataItem(double x, double xLow, double xHigh, double y) { + super(new Double(x), new YWithXInterval(y, xLow, xHigh)); + } + + /** + * Returns the x-value. + * + * @return The x-value (never null). + */ + public Number getX() { + return (Number) getComparable(); + } + + /** + * Returns the y-value. + * + * @return The y-value. + */ + public double getYValue() { + YWithXInterval interval = (YWithXInterval) getObject(); + if (interval != null) { + return interval.getY(); + } + else { + return Double.NaN; + } + } + + /** + * Returns the lower bound of the x-interval. + * + * @return The lower bound of the x-interval. + */ + public double getXLowValue() { + YWithXInterval interval = (YWithXInterval) getObject(); + if (interval != null) { + return interval.getXLow(); + } + else { + return Double.NaN; + } + } + + /** + * Returns the upper bound of the x-interval. + * + * @return The upper bound of the x-interval. + */ + public double getXHighValue() { + YWithXInterval interval = (YWithXInterval) getObject(); + if (interval != null) { + return interval.getXHigh(); + } + else { + return Double.NaN; + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XIntervalSeries.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XIntervalSeries.java new file mode 100755 index 0000000..f62448f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XIntervalSeries.java @@ -0,0 +1,158 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * XIntervalSeries.java + * -------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * 11-Apr-2008 : Added getXLowValue() and getXHighValue() methods (DG); + * + */ + +package org.jfree.data.xy; + +import org.jfree.data.ComparableObjectItem; +import org.jfree.data.ComparableObjectSeries; + +/** + * A list of (x, x-low, x-high, y) data items. + * + * @since 1.0.3 + * + * @see XIntervalSeriesCollection + */ +public class XIntervalSeries extends ComparableObjectSeries { + + /** + * Creates a new empty series. By default, items added to the series will + * be sorted into ascending order by x-value, and duplicate x-values will + * be allowed (these defaults can be modified with another constructor. + * + * @param key the series key (null not permitted). + */ + public XIntervalSeries(Comparable key) { + this(key, true, true); + } + + /** + * Constructs a new xy-series that contains no data. You can specify + * whether or not duplicate x-values are allowed for the series. + * + * @param key the series key (null not permitted). + * @param autoSort a flag that controls whether or not the items in the + * series are sorted. + * @param allowDuplicateXValues a flag that controls whether duplicate + * x-values are allowed. + */ + public XIntervalSeries(Comparable key, boolean autoSort, + boolean allowDuplicateXValues) { + super(key, autoSort, allowDuplicateXValues); + } + + /** + * Adds a data item to the series. + * + * @param x the x-value. + * @param y the y-value. + * @param xLow the lower bound of the y-interval. + * @param xHigh the upper bound of the y-interval. + */ + public void add(double x, double xLow, double xHigh, double y) { + super.add(new XIntervalDataItem(x, xLow, xHigh, y), true); + } + + /** + * Returns the x-value for the specified item. + * + * @param index the item index. + * + * @return The x-value (never null). + */ + public Number getX(int index) { + XIntervalDataItem item = (XIntervalDataItem) getDataItem(index); + return item.getX(); + } + + /** + * Returns the lower bound of the x-interval for the specified item. + * + * @param index the item index. + * + * @return The lower bound of the x-interval. + * + * @since 1.0.10 + */ + public double getXLowValue(int index) { + XIntervalDataItem item = (XIntervalDataItem) getDataItem(index); + return item.getXLowValue(); + } + + /** + * Returns the upper bound of the x-interval for the specified item. + * + * @param index the item index. + * + * @return The upper bound of the x-interval. + * + * @since 1.0.10 + */ + public double getXHighValue(int index) { + XIntervalDataItem item = (XIntervalDataItem) getDataItem(index); + return item.getXHighValue(); + } + + /** + * Returns the y-value for the specified item. + * + * @param index the item index. + * + * @return The y-value. + */ + public double getYValue(int index) { + XIntervalDataItem item = (XIntervalDataItem) getDataItem(index); + return item.getYValue(); + } + + /** + * Returns the data item at the specified index. + * + * @param index the item index. + * + * @return The data item. + */ + @Override + public ComparableObjectItem getDataItem(int index) { + return super.getDataItem(index); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XIntervalSeriesCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XIntervalSeriesCollection.java new file mode 100755 index 0000000..c6db6cd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XIntervalSeriesCollection.java @@ -0,0 +1,367 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * XIntervalSeriesCollection.java + * ------------------------------ + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * 27-Nov-2006 : Added clone() override (DG); + * 18-Jan-2008 : Added removeSeries() and removeAllSeries() methods (DG); + * 22-Apr-2008 : Implemented PublicCloneable (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A collection of {@link XIntervalSeries} objects. + * + * @since 1.0.3 + * + * @see XIntervalSeries + */ +public class XIntervalSeriesCollection extends AbstractIntervalXYDataset + implements IntervalXYDataset, PublicCloneable, Serializable { + + /** Storage for the data series. */ + private List data; + + /** + * Creates a new instance of XIntervalSeriesCollection. + */ + public XIntervalSeriesCollection() { + this.data = new java.util.ArrayList(); + } + + /** + * Adds a series to the collection and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param series the series (null not permitted). + */ + public void addSeries(XIntervalSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + this.data.add(series); + series.addChangeListener(this); + fireDatasetChanged(); + } + + /** + * Returns the number of series in the collection. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.data.size(); + } + + /** + * Returns a series from the collection. + * + * @param series the series index (zero-based). + * + * @return The series. + * + * @throws IllegalArgumentException if series is not in the + * range 0 to getSeriesCount() - 1. + */ + public XIntervalSeries getSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + return (XIntervalSeries) this.data.get(series); + } + + /** + * Returns the key for a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The key for a series. + * + * @throws IllegalArgumentException if series is not in the + * specified range. + */ + @Override + public Comparable getSeriesKey(int series) { + // defer argument checking + return getSeries(series).getKey(); + } + + /** + * Returns the number of items in the specified series. + * + * @param series the series (zero-based index). + * + * @return The item count. + * + * @throws IllegalArgumentException if series is not in the + * range 0 to getSeriesCount() - 1. + */ + @Override + public int getItemCount(int series) { + // defer argument checking + return getSeries(series).getItemCount(); + } + + /** + * Returns the x-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value. + */ + @Override + public Number getX(int series, int item) { + XIntervalSeries s = (XIntervalSeries) this.data.get(series); + XIntervalDataItem di = (XIntervalDataItem) s.getDataItem(item); + return di.getX(); + } + + /** + * Returns the start x-value (as a double primitive) for an item within a + * series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getStartXValue(int series, int item) { + XIntervalSeries s = (XIntervalSeries) this.data.get(series); + return s.getXLowValue(item); + } + + /** + * Returns the end x-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value. + */ + @Override + public double getEndXValue(int series, int item) { + XIntervalSeries s = (XIntervalSeries) this.data.get(series); + return s.getXHighValue(item); + } + + /** + * Returns the y-value (as a double primitive) for an item within a + * series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getYValue(int series, int item) { + XIntervalSeries s = (XIntervalSeries) this.data.get(series); + return s.getYValue(item); + } + + /** + * Returns the y-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The y-value. + */ + @Override + public Number getY(int series, int item) { + XIntervalSeries s = (XIntervalSeries) this.data.get(series); + XIntervalDataItem di = (XIntervalDataItem) s.getDataItem(item); + return new Double(di.getYValue()); + } + + /** + * Returns the start x-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value. + */ + @Override + public Number getStartX(int series, int item) { + XIntervalSeries s = (XIntervalSeries) this.data.get(series); + XIntervalDataItem di = (XIntervalDataItem) s.getDataItem(item); + return new Double(di.getXLowValue()); + } + + /** + * Returns the end x-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value. + */ + @Override + public Number getEndX(int series, int item) { + XIntervalSeries s = (XIntervalSeries) this.data.get(series); + XIntervalDataItem di = (XIntervalDataItem) s.getDataItem(item); + return new Double(di.getXHighValue()); + } + + /** + * Returns the start y-value for an item within a series. This method + * maps directly to {@link #getY(int, int)}. + * + * @param series the series index. + * @param item the item index. + * + * @return The start y-value. + */ + @Override + public Number getStartY(int series, int item) { + return getY(series, item); + } + + /** + * Returns the end y-value for an item within a series. This method + * maps directly to {@link #getY(int, int)}. + * + * @param series the series index. + * @param item the item index. + * + * @return The end y-value. + */ + @Override + public Number getEndY(int series, int item) { + return getY(series, item); + } + + /** + * Removes a series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * + * @since 1.0.10 + */ + public void removeSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds."); + } + XIntervalSeries ts = (XIntervalSeries) this.data.get(series); + ts.removeChangeListener(this); + this.data.remove(series); + fireDatasetChanged(); + } + + /** + * Removes a series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param series the series (null not permitted). + * + * @since 1.0.10 + */ + public void removeSeries(XIntervalSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + if (this.data.contains(series)) { + series.removeChangeListener(this); + this.data.remove(series); + fireDatasetChanged(); + } + } + + /** + * Removes all the series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @since 1.0.10 + */ + public void removeAllSeries() { + // Unregister the collection as a change listener to each series in + // the collection. + for (int i = 0; i < this.data.size(); i++) { + XIntervalSeries series = (XIntervalSeries) this.data.get(i); + series.removeChangeListener(this); + } + this.data.clear(); + fireDatasetChanged(); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XIntervalSeriesCollection)) { + return false; + } + XIntervalSeriesCollection that = (XIntervalSeriesCollection) obj; + return ObjectUtilities.equal(this.data, that.data); + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem. + */ + @Override + public Object clone() throws CloneNotSupportedException { + XIntervalSeriesCollection clone + = (XIntervalSeriesCollection) super.clone(); + clone.data = (List) ObjectUtilities.deepClone(this.data); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYBarDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYBarDataset.java new file mode 100755 index 0000000..03b1ef1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYBarDataset.java @@ -0,0 +1,399 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * XYBarDataset.java + * ----------------- + * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 02-Mar-2004 : Version 1 (DG); + * 05-May-2004 : Now extends AbstractIntervalXYDataset (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 25-Jan-2007 : Added some accessor methods, plus new equals() and clone() + * overrides (DG); + * 30-Jan-2007 : Added method overrides to prevent unnecessary object + * creation (DG); + * 22-Apr-2008 : Implemented PublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetChangeListener; +import org.jfree.util.PublicCloneable; + +/** + * A dataset wrapper class that converts a standard {@link XYDataset} into an + * {@link IntervalXYDataset} suitable for use in creating XY bar charts. + */ +public class XYBarDataset extends AbstractIntervalXYDataset + implements IntervalXYDataset, DatasetChangeListener, PublicCloneable { + + /** The underlying dataset. */ + private XYDataset underlying; + + /** The bar width. */ + private double barWidth; + + /** + * Creates a new dataset. + * + * @param underlying the underlying dataset (null not + * permitted). + * @param barWidth the width of the bars. + */ + public XYBarDataset(XYDataset underlying, double barWidth) { + this.underlying = underlying; + this.underlying.addChangeListener(this); + this.barWidth = barWidth; + } + + /** + * Returns the underlying dataset that was specified via the constructor. + * + * @return The underlying dataset (never null). + * + * @since 1.0.4 + */ + public XYDataset getUnderlyingDataset() { + return this.underlying; + } + + /** + * Returns the bar width. + * + * @return The bar width. + * + * @see #setBarWidth(double) + * @since 1.0.4 + */ + public double getBarWidth() { + return this.barWidth; + } + + /** + * Sets the bar width and sends a {@link DatasetChangeEvent} to all + * registered listeners. + * + * @param barWidth the bar width. + * + * @see #getBarWidth() + * @since 1.0.4 + */ + public void setBarWidth(double barWidth) { + this.barWidth = barWidth; + notifyListeners(new DatasetChangeEvent(this, this)); + } + + /** + * Returns the number of series in the dataset. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.underlying.getSeriesCount(); + } + + /** + * Returns the key for a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The series key. + */ + @Override + public Comparable getSeriesKey(int series) { + return this.underlying.getSeriesKey(series); + } + + /** + * Returns the number of items in a series. + * + * @param series the series index (zero-based). + * + * @return The item count. + */ + @Override + public int getItemCount(int series) { + return this.underlying.getItemCount(series); + } + + /** + * Returns the x-value for an item within a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The x-value. + * + * @see #getXValue(int, int) + */ + @Override + public Number getX(int series, int item) { + return this.underlying.getX(series, item); + } + + /** + * Returns the x-value (as a double primitive) for an item within a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + * + * @see #getX(int, int) + */ + @Override + public double getXValue(int series, int item) { + return this.underlying.getXValue(series, item); + } + + /** + * Returns the y-value for an item within a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The y-value (possibly null). + * + * @see #getYValue(int, int) + */ + @Override + public Number getY(int series, int item) { + return this.underlying.getY(series, item); + } + + /** + * Returns the y-value (as a double primitive) for an item within a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + * + * @see #getY(int, int) + */ + @Override + public double getYValue(int series, int item) { + return this.underlying.getYValue(series, item); + } + + /** + * Returns the starting X value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public Number getStartX(int series, int item) { + Number result = null; + Number xnum = this.underlying.getX(series, item); + if (xnum != null) { + result = new Double(xnum.doubleValue() - this.barWidth / 2.0); + } + return result; + } + + /** + * Returns the starting x-value (as a double primitive) for an item within + * a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + * + * @see #getXValue(int, int) + */ + @Override + public double getStartXValue(int series, int item) { + return getXValue(series, item) - this.barWidth / 2.0; + } + + /** + * Returns the ending X value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public Number getEndX(int series, int item) { + Number result = null; + Number xnum = this.underlying.getX(series, item); + if (xnum != null) { + result = new Double(xnum.doubleValue() + this.barWidth / 2.0); + } + return result; + } + + /** + * Returns the ending x-value (as a double primitive) for an item within + * a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + * + * @see #getXValue(int, int) + */ + @Override + public double getEndXValue(int series, int item) { + return getXValue(series, item) + this.barWidth / 2.0; + } + + /** + * Returns the starting Y value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public Number getStartY(int series, int item) { + return this.underlying.getY(series, item); + } + + /** + * Returns the starting y-value (as a double primitive) for an item within + * a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + * + * @see #getYValue(int, int) + */ + @Override + public double getStartYValue(int series, int item) { + return getYValue(series, item); + } + + /** + * Returns the ending Y value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public Number getEndY(int series, int item) { + return this.underlying.getY(series, item); + } + + /** + * Returns the ending y-value (as a double primitive) for an item within + * a series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + * + * @see #getYValue(int, int) + */ + @Override + public double getEndYValue(int series, int item) { + return getYValue(series, item); + } + + /** + * Receives notification of an dataset change event. + * + * @param event information about the event. + */ + @Override + public void datasetChanged(DatasetChangeEvent event) { + notifyListeners(event); + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYBarDataset)) { + return false; + } + XYBarDataset that = (XYBarDataset) obj; + if (!this.underlying.equals(that.underlying)) { + return false; + } + if (this.barWidth != that.barWidth) { + return false; + } + return true; + } + + /** + * Returns an independent copy of the dataset. Note that: + *

        + *
      • the underlying dataset is only cloned if it implements the + * {@link PublicCloneable} interface;
      • + *
      • the listeners registered with this dataset are not carried over to + * the cloned dataset.
      • + *
      + * + * @return An independent copy of the dataset. + * + * @throws CloneNotSupportedException if the dataset cannot be cloned for + * any reason. + */ + @Override + public Object clone() throws CloneNotSupportedException { + XYBarDataset clone = (XYBarDataset) super.clone(); + if (this.underlying instanceof PublicCloneable) { + PublicCloneable pc = (PublicCloneable) this.underlying; + clone.underlying = (XYDataset) pc.clone(); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYCoordinate.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYCoordinate.java new file mode 100755 index 0000000..c13808e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYCoordinate.java @@ -0,0 +1,176 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * XYCoordinate.java + * ----------------- + * (C) Copyright 2007, 2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jan-2007 : Version 1 (DG); + * 25-May-2007 : Moved from experimental to the main source tree (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; + +/** + * Represents an (x, y) coordinate. + * + * @since 1.0.6 + */ +public class XYCoordinate implements Comparable, Serializable { + + /** The x-coordinate. */ + private double x; + + /** The y-coordinate. */ + private double y; + + /** + * Creates a new coordinate for the point (0.0, 0.0). + */ + public XYCoordinate() { + this(0.0, 0.0); + } + + /** + * Creates a new coordinate for the point (x, y). + * + * @param x the x-coordinate. + * @param y the y-coordinate. + */ + public XYCoordinate(double x, double y) { + this.x = x; + this.y = y; + } + + /** + * Returns the x-coordinate. + * + * @return The x-coordinate. + */ + public double getX() { + return this.x; + } + + /** + * Returns the y-coordinate. + * + * @return The y-coordinate. + */ + public double getY() { + return this.y; + } + + /** + * Tests this coordinate for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYCoordinate)) { + return false; + } + XYCoordinate that = (XYCoordinate) obj; + if (this.x != that.x) { + return false; + } + if (this.y != that.y) { + return false; + } + return true; + } + + /** + * Returns a hash code for this instance. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = 193; + 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)); + return result; + } + + /** + * Returns a string representation of this instance, primarily for + * debugging purposes. + * + * @return A string. + */ + @Override + public String toString() { + return "(" + this.x + ", " + this.y + ")"; + } + + /** + * Compares this instance against an arbitrary object. + * + * @param obj the object (null not permitted). + * + * @return An integer indicating the relative order of the items. + */ + @Override + public int compareTo(Object obj) { + if (!(obj instanceof XYCoordinate)) { + throw new IllegalArgumentException("Incomparable object."); + } + XYCoordinate that = (XYCoordinate) obj; + if (this.x > that.x) { + return 1; + } + else if (this.x < that.x) { + return -1; + } + else { + if (this.y > that.y) { + return 1; + } + else if (this.y < that.y) { + return -1; + } + } + return 0; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYDataItem.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYDataItem.java new file mode 100755 index 0000000..6ce579d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYDataItem.java @@ -0,0 +1,277 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * XYDataItem.java + * --------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Aug-2003 : Renamed XYDataPair --> XYDataItem (DG); + * 03-Feb-2004 : Fixed bug in equals() method (DG); + * 21-Feb-2005 : Added setY(double) method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 30-Nov-2007 : Implemented getXValue() and getYValue(), plus toString() for + * debugging use (DG); + * 10-Jun-2009 : Reimplemented cloning (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.util.ObjectUtilities; + +/** + * Represents one (x, y) data item for an {@link XYSeries}. Note that + * subclasses are REQUIRED to support cloning. + */ +public class XYDataItem implements Cloneable, Comparable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = 2751513470325494890L; + + /** The x-value (null not permitted). */ + private Number x; + + /** The y-value. */ + private Number y; + + /** + * Constructs a new data item. + * + * @param x the x-value (null NOT permitted). + * @param y the y-value (null permitted). + */ + public XYDataItem(Number x, Number y) { + ParamChecks.nullNotPermitted(x, "x"); + this.x = x; + this.y = y; + } + + /** + * Constructs a new data item. + * + * @param x the x-value. + * @param y the y-value. + */ + public XYDataItem(double x, double y) { + this(new Double(x), new Double(y)); + } + + /** + * Returns the x-value. + * + * @return The x-value (never null). + */ + public Number getX() { + return this.x; + } + + /** + * Returns the x-value as a double primitive. + * + * @return The x-value. + * + * @see #getX() + * @see #getYValue() + * + * @since 1.0.9 + */ + public double getXValue() { + // this.x is not allowed to be null... + return this.x.doubleValue(); + } + + /** + * Returns the y-value. + * + * @return The y-value (possibly null). + */ + public Number getY() { + return this.y; + } + + /** + * Returns the y-value as a double primitive. + * + * @return The y-value. + * + * @see #getY() + * @see #getXValue() + * + * @since 1.0.9 + */ + public double getYValue() { + double result = Double.NaN; + if (this.y != null) { + result = this.y.doubleValue(); + } + return result; + } + + /** + * Sets the y-value for this data item. Note that there is no + * corresponding method to change the x-value. + * + * @param y the new y-value. + */ + public void setY(double y) { + setY(new Double(y)); + } + + /** + * Sets the y-value for this data item. Note that there is no + * corresponding method to change the x-value. + * + * @param y the new y-value (null permitted). + */ + public void setY(Number y) { + this.y = y; + } + + /** + * Returns an integer indicating the order of this object relative to + * another object. + *

      + * For the order we consider only the x-value: + * negative == "less-than", zero == "equal", positive == "greater-than". + * + * @param o1 the object being compared to. + * + * @return An integer indicating the order of this data pair object + * relative to another object. + */ + @Override + public int compareTo(Object o1) { + + int result; + + // CASE 1 : Comparing to another TimeSeriesDataPair object + // ------------------------------------------------------- + if (o1 instanceof XYDataItem) { + XYDataItem dataItem = (XYDataItem) o1; + double compare = this.x.doubleValue() + - dataItem.getX().doubleValue(); + if (compare > 0.0) { + result = 1; + } + else { + if (compare < 0.0) { + result = -1; + } + else { + result = 0; + } + } + } + + // CASE 2 : Comparing to a general object + // --------------------------------------------- + else { + // consider time periods to be ordered after general objects + result = 1; + } + + return result; + + } + + /** + * Returns a clone of this object. + * + * @return A clone. + */ + @Override + public Object clone() { + Object clone = null; + try { + clone = super.clone(); + } + catch (CloneNotSupportedException e) { // won't get here... + e.printStackTrace(); + } + return clone; + } + + /** + * Tests if this object is equal to another. + * + * @param obj the object to test against for equality (null + * permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYDataItem)) { + return false; + } + XYDataItem that = (XYDataItem) obj; + if (!this.x.equals(that.x)) { + return false; + } + if (!ObjectUtilities.equal(this.y, that.y)) { + return false; + } + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result; + result = this.x.hashCode(); + result = 29 * result + (this.y != null ? this.y.hashCode() : 0); + return result; + } + + /** + * Returns a string representing this instance, primarily for debugging + * use. + * + * @return A string. + */ + @Override + public String toString() { + return "[" + getXValue() + ", " + getYValue() + "]"; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYDataset.java new file mode 100755 index 0000000..74cc354 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYDataset.java @@ -0,0 +1,129 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * XYDataset.java + * -------------- + * (C) Copyright 2000-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes (from 18-Sep-2001) + * -------------------------- + * 18-Sep-2001 : Added standard header and fixed DOS encoding problem (DG); + * 15-Oct-2001 : Moved to a new package (com.jrefinery.data.*) (DG); + * 22-Oct-2001 : Renamed DataSource.java --> Dataset.java etc. (DG); + * 17-Nov-2001 : Now extends SeriesDataset (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 29-Jul-2004 : Added getDomainOrder() method (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); + * + */ + +package org.jfree.data.xy; + +import org.jfree.data.DomainOrder; +import org.jfree.data.general.SeriesDataset; + +/** + * An interface through which data in the form of (x, y) items can be accessed. + */ +public interface XYDataset extends SeriesDataset { + + /** + * Returns the order of the domain (or X) values returned by the dataset. + * + * @return The order (never null). + */ + public DomainOrder getDomainOrder(); + + /** + * Returns the number of items in a series. + *

      + * It is recommended that classes that implement this method should throw + * an IllegalArgumentException if the series + * argument is outside the specified range. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The item count. + */ + public int getItemCount(int series); + + /** + * Returns the x-value for an item within a series. The x-values may or + * may not be returned in ascending order, that is up to the class + * implementing the interface. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The x-value (never null). + */ + public Number getX(int series, int item); + + /** + * Returns the x-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The x-value. + */ + public double getXValue(int series, int item); + + /** + * Returns the y-value for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The y-value (possibly null). + */ + public Number getY(int series, int item); + + /** + * Returns the y-value (as a double primitive) for an item within a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * @param item the item index (in the range 0 to + * getItemCount(series)). + * + * @return The y-value. + */ + public double getYValue(int series, int item); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYDatasetTableModel.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYDatasetTableModel.java new file mode 100755 index 0000000..4c96b94 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYDatasetTableModel.java @@ -0,0 +1,258 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * XYDatasetTableModel.java + * ------------------------ + * (C)opyright 2003-2008, by Bryan Scott and Contributors. + * + * Original Author: Bryan Scott ; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 01-Jul-2003 : Version 1 contributed by Bryan Scott (DG); + * 27-Apr-2005 : Change XYDataset --> TableXYDataset because the table model + * assumes all series share the same x-values, and this is not + * enforced by XYDataset. Also fixed bug 1191046, a problem + * in the getValueAt() method (DG); + * + */ + +package org.jfree.data.xy; + +import javax.swing.table.AbstractTableModel; +import javax.swing.table.TableModel; + +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetChangeListener; + +/** + * A READ-ONLY wrapper around a {@link TableXYDataset} to convert it to a + * table model for use in a JTable. The first column of the table shows the + * x-values, the remaining columns show the y-values for each series (series 0 + * appears in column 1, series 1 appears in column 2, etc). + *

      + * TO DO: + *

        + *
      • implement proper naming for x axis (getColumnName)
      • + *
      • implement setValueAt to remove READ-ONLY constraint (not sure how)
      • + *
      + */ +public class XYDatasetTableModel extends AbstractTableModel + implements TableModel, DatasetChangeListener { + + /** The dataset. */ + TableXYDataset model = null; + + /** + * Default constructor. + */ + public XYDatasetTableModel() { + super(); + } + + /** + * Creates a new table model based on the specified dataset. + * + * @param dataset the dataset. + */ + public XYDatasetTableModel(TableXYDataset dataset) { + this(); + this.model = dataset; + this.model.addChangeListener(this); + } + + /** + * Sets the model (dataset). + * + * @param dataset the dataset. + */ + public void setModel(TableXYDataset dataset) { + this.model = dataset; + this.model.addChangeListener(this); + fireTableDataChanged(); + } + + /** + * Returns the number of rows. + * + * @return The row count. + */ + @Override + public int getRowCount() { + if (this.model == null) { + return 0; + } + return this.model.getItemCount(); + } + + /** + * Gets the number of columns in the model. + * + * @return The number of columns in the model. + */ + @Override + public int getColumnCount() { + if (this.model == null) { + return 0; + } + return this.model.getSeriesCount() + 1; + } + + /** + * Returns the column name. + * + * @param column the column index. + * + * @return The column name. + */ + @Override + public String getColumnName(int column) { + if (this.model == null) { + return super.getColumnName(column); + } + if (column < 1) { + return "X Value"; + } + else { + return this.model.getSeriesKey(column - 1).toString(); + } + } + + /** + * Returns a value of the specified cell. + * Column 0 is the X axis, Columns 1 and over are the Y axis + * + * @param row the row number. + * @param column the column number. + * + * @return The value of the specified cell. + */ + @Override + public Object getValueAt(int row, int column) { + if (this.model == null) { + return null; + } + if (column < 1) { + return this.model.getX(0, row); + } + else { + return this.model.getY(column - 1, row); + } + } + + /** + * Receives notification that the underlying dataset has changed. + * + * @param event the event + * + * @see DatasetChangeListener + */ + @Override + public void datasetChanged(DatasetChangeEvent event) { + fireTableDataChanged(); + } + + /** + * Returns a flag indicating whether or not the specified cell is editable. + * + * @param row the row number. + * @param column the column number. + * + * @return true if the specified cell is editable. + */ + @Override + public boolean isCellEditable(int row, int column) { + return false; + } + + /** + * Updates the {@link XYDataset} if allowed. + * + * @param value the new value. + * @param row the row. + * @param column the column. + */ + @Override + public void setValueAt(Object value, int row, int column) { + if (isCellEditable(row, column)) { + // XYDataset only provides methods for reading a dataset... + } + } + +// /** +// * Run a demonstration of the table model interface. +// * +// * @param args ignored. +// * +// * @throws Exception when an error occurs. +// */ +// public static void main(String args[]) throws Exception { +// JFrame frame = new JFrame(); +// JPanel panel = new JPanel(); +// panel.setLayout(new BorderLayout()); +// +// XYSeries s1 = new XYSeries("Series 1", true, false); +// for (int i = 0; i < 10; i++) { +// s1.add(i, Math.random()); +// } +// XYSeries s2 = new XYSeries("Series 2", true, false); +// for (int i = 0; i < 15; i++) { +// s2.add(i, Math.random()); +// } +// DefaultTableXYDataset dataset = new DefaultTableXYDataset(); +// dataset.addSeries(s1); +// dataset.addSeries(s2); +// XYDatasetTableModel tablemodel = new XYDatasetTableModel(); +// +// tablemodel.setModel(dataset); +// +// JTable dataTable = new JTable(tablemodel); +// JScrollPane scroll = new JScrollPane(dataTable); +// scroll.setPreferredSize(new Dimension(600, 150)); +// +// JFreeChart chart = ChartFactory.createXYLineChart( +// "XY Series Demo", +// "X", "Y", dataset, PlotOrientation.VERTICAL, +// true, +// true, +// false +// ); +// +// ChartPanel chartPanel = new ChartPanel(chart); +// +// panel.add(chartPanel, BorderLayout.CENTER); +// panel.add(scroll, BorderLayout.SOUTH); +// +// frame.setContentPane(panel); +// frame.setSize(600, 500); +// frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); +// frame.show(); +// RefineryUtilities.centerFrameOnScreen(frame); +// } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYDomainInfo.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYDomainInfo.java new file mode 100755 index 0000000..ef28c98 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYDomainInfo.java @@ -0,0 +1,67 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * XYDomainInfo.java + * ----------------- + * (C) Copyright 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Mar-2009 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import java.util.List; +import org.jfree.data.Range; + +/** + * An interface that can (optionally) be implemented by a dataset to assist in + * determining the minimum and maximum x-values in the dataset. + * + * @since 1.0.13 + */ +public interface XYDomainInfo { + + /** + * Returns the range of the values in this dataset's domain. + * + * @param visibleSeriesKeys the keys of the visible series. + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The range (or null if the dataset contains no + * values). + */ + public Range getDomainBounds(List visibleSeriesKeys, + boolean includeInterval); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYInterval.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYInterval.java new file mode 100755 index 0000000..e0a8d8d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYInterval.java @@ -0,0 +1,165 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * XYInterval.java + * --------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; + +/** + * An xy-interval. This class is used internally by the + * {@link XYIntervalDataItem} class. + * + * @since 1.0.3 + */ +public class XYInterval implements Serializable { + + /** The lower bound of the x-interval. */ + private double xLow; + + /** The upper bound of the y-interval. */ + private double xHigh; + + /** The y-value. */ + private double y; + + /** The lower bound of the y-interval. */ + private double yLow; + + /** The upper bound of the y-interval. */ + private double yHigh; + + /** + * Creates a new instance of XYInterval. + * + * @param xLow the lower bound of the x-interval. + * @param xHigh the upper bound of the y-interval. + * @param y the y-value. + * @param yLow the lower bound of the y-interval. + * @param yHigh the upper bound of the y-interval. + */ + public XYInterval(double xLow, double xHigh, double y, double yLow, + double yHigh) { + this.xLow = xLow; + this.xHigh = xHigh; + this.y = y; + this.yLow = yLow; + this.yHigh = yHigh; + } + + /** + * Returns the lower bound of the x-interval. + * + * @return The lower bound of the x-interval. + */ + public double getXLow() { + return this.xLow; + } + + /** + * Returns the upper bound of the x-interval. + * + * @return The upper bound of the x-interval. + */ + public double getXHigh() { + return this.xHigh; + } + + /** + * Returns the y-value. + * + * @return The y-value. + */ + public double getY() { + return this.y; + } + + /** + * Returns the lower bound of the y-interval. + * + * @return The lower bound of the y-interval. + */ + public double getYLow() { + return this.yLow; + } + + /** + * Returns the upper bound of the y-interval. + * + * @return The upper bound of the y-interval. + */ + public double getYHigh() { + return this.yHigh; + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYInterval)) { + return false; + } + XYInterval that = (XYInterval) obj; + if (this.xLow != that.xLow) { + return false; + } + if (this.xHigh != that.xHigh) { + return false; + } + if (this.y != that.y) { + return false; + } + if (this.yLow != that.yLow) { + return false; + } + if (this.yHigh != that.yHigh) { + return false; + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYIntervalDataItem.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYIntervalDataItem.java new file mode 100755 index 0000000..0a77abe --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYIntervalDataItem.java @@ -0,0 +1,151 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * XYIntervalDataItem.java + * ----------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import org.jfree.data.ComparableObjectItem; + +/** + * An item representing data in the form (x, x-low, x-high, y, y-low, y-high). + * + * @since 1.0.3 + */ +public class XYIntervalDataItem extends ComparableObjectItem { + + /** + * Creates a new instance of XYIntervalItem. + * + * @param x the x-value. + * @param xLow the lower bound of the x-interval. + * @param xHigh the upper bound of the x-interval. + * @param y the y-value. + * @param yLow the lower bound of the y-interval. + * @param yHigh the upper bound of the y-interval. + */ + public XYIntervalDataItem(double x, double xLow, double xHigh, double y, + double yLow, double yHigh) { + super(new Double(x), new XYInterval(xLow, xHigh, y, yLow, yHigh)); + } + + /** + * Returns the x-value. + * + * @return The x-value (never null). + */ + public Double getX() { + return (Double) getComparable(); + } + + /** + * Returns the y-value. + * + * @return The y-value. + */ + public double getYValue() { + XYInterval interval = (XYInterval) getObject(); + if (interval != null) { + return interval.getY(); + } + else { + return Double.NaN; + } + } + + /** + * Returns the lower bound of the x-interval. + * + * @return The lower bound of the x-interval. + */ + public double getXLowValue() { + XYInterval interval = (XYInterval) getObject(); + if (interval != null) { + return interval.getXLow(); + } + else { + return Double.NaN; + } + } + + /** + * Returns the upper bound of the x-interval. + * + * @return The upper bound of the x-interval. + */ + public double getXHighValue() { + XYInterval interval = (XYInterval) getObject(); + if (interval != null) { + return interval.getXHigh(); + } + else { + return Double.NaN; + } + } + + /** + * Returns the lower bound of the y-interval. + * + * @return The lower bound of the y-interval. + */ + public double getYLowValue() { + XYInterval interval = (XYInterval) getObject(); + if (interval != null) { + return interval.getYLow(); + } + else { + return Double.NaN; + } + } + + /** + * Returns the upper bound of the y-interval. + * + * @return The upper bound of the y-interval. + */ + public double getYHighValue() { + XYInterval interval = (XYInterval) getObject(); + if (interval != null) { + return interval.getYHigh(); + } + else { + return Double.NaN; + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYIntervalSeries.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYIntervalSeries.java new file mode 100755 index 0000000..f59395e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYIntervalSeries.java @@ -0,0 +1,193 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * XYIntervalSeries.java + * --------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * 13-Feb-2007 : Added several new accessor methods (DG); + * + */ + +package org.jfree.data.xy; + +import org.jfree.data.ComparableObjectItem; +import org.jfree.data.ComparableObjectSeries; + +/** + * A list of (x, x-low, x-high, y, y-low, y-high) data items. + * + * @since 1.0.3 + * + * @see XYIntervalSeriesCollection + */ +public class XYIntervalSeries extends ComparableObjectSeries { + + /** + * Creates a new empty series. By default, items added to the series will + * be sorted into ascending order by x-value, and duplicate x-values will + * be allowed (these defaults can be modified with another constructor). + * + * @param key the series key (null not permitted). + */ + public XYIntervalSeries(Comparable key) { + this(key, true, true); + } + + /** + * Constructs a new xy-series that contains no data. You can specify + * whether or not duplicate x-values are allowed for the series. + * + * @param key the series key (null not permitted). + * @param autoSort a flag that controls whether or not the items in the + * series are sorted. + * @param allowDuplicateXValues a flag that controls whether duplicate + * x-values are allowed. + */ + public XYIntervalSeries(Comparable key, boolean autoSort, + boolean allowDuplicateXValues) { + super(key, autoSort, allowDuplicateXValues); + } + + /** + * Adds a data item to the series. + * + * @param x the x-value. + * @param xLow the lower bound of the x-interval. + * @param xHigh the upper bound of the x-interval. + * @param y the y-value. + * @param yLow the lower bound of the y-interval. + * @param yHigh the upper bound of the y-interval. + */ + public void add(double x, double xLow, double xHigh, double y, double yLow, + double yHigh) { + super.add(new XYIntervalDataItem(x, xLow, xHigh, y, yLow, yHigh), true); + } + + /** + * Returns the x-value for the specified item. + * + * @param index the item index. + * + * @return The x-value (never null). + */ + public Number getX(int index) { + XYIntervalDataItem item = (XYIntervalDataItem) getDataItem(index); + return item.getX(); + } + + /** + * Returns the lower bound of the x-interval for the specified item in the + * series. + * + * @param index the item index. + * + * @return The lower bound of the x-interval. + * + * @since 1.0.5 + */ + public double getXLowValue(int index) { + XYIntervalDataItem item = (XYIntervalDataItem) getDataItem(index); + return item.getXLowValue(); + } + + /** + * Returns the upper bound of the x-interval for the specified item in the + * series. + * + * @param index the item index. + * + * @return The upper bound of the x-interval. + * + * @since 1.0.5 + */ + public double getXHighValue(int index) { + XYIntervalDataItem item = (XYIntervalDataItem) getDataItem(index); + return item.getXHighValue(); + } + + /** + * Returns the y-value for the specified item. + * + * @param index the item index. + * + * @return The y-value. + */ + public double getYValue(int index) { + XYIntervalDataItem item = (XYIntervalDataItem) getDataItem(index); + return item.getYValue(); + } + + /** + * Returns the lower bound of the Y-interval for the specified item in the + * series. + * + * @param index the item index. + * + * @return The lower bound of the Y-interval. + * + * @since 1.0.5 + */ + public double getYLowValue(int index) { + XYIntervalDataItem item = (XYIntervalDataItem) getDataItem(index); + return item.getYLowValue(); + } + + /** + * Returns the upper bound of the y-interval for the specified item in the + * series. + * + * @param index the item index. + * + * @return The upper bound of the y-interval. + * + * @since 1.0.5 + */ + public double getYHighValue(int index) { + XYIntervalDataItem item = (XYIntervalDataItem) getDataItem(index); + return item.getYHighValue(); + } + + /** + * Returns the data item at the specified index. + * + * @param index the item index. + * + * @return The data item. + */ + @Override + public ComparableObjectItem getDataItem(int index) { + return super.getDataItem(index); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYIntervalSeriesCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYIntervalSeriesCollection.java new file mode 100755 index 0000000..3d99911 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYIntervalSeriesCollection.java @@ -0,0 +1,396 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * XYIntervalSeriesCollection.java + * ------------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * 13-Feb-2007 : Provided a number of method overrides that enhance + * performance, and added a proper clone() + * implementation (DG); + * 18-Jan-2008 : Added removeSeries() and removeAllSeries() methods (DG); + * 22-Apr-2008 : Implemented PublicCloneable (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A collection of {@link XYIntervalSeries} objects. + * + * @since 1.0.3 + * + * @see XYIntervalSeries + */ +public class XYIntervalSeriesCollection extends AbstractIntervalXYDataset + implements IntervalXYDataset, PublicCloneable, Serializable { + + /** Storage for the data series. */ + private List data; + + /** + * Creates a new instance of XIntervalSeriesCollection. + */ + public XYIntervalSeriesCollection() { + this.data = new java.util.ArrayList(); + } + + /** + * Adds a series to the collection and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param series the series (null not permitted). + */ + public void addSeries(XYIntervalSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + this.data.add(series); + series.addChangeListener(this); + fireDatasetChanged(); + } + + /** + * Returns the number of series in the collection. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.data.size(); + } + + /** + * Returns a series from the collection. + * + * @param series the series index (zero-based). + * + * @return The series. + * + * @throws IllegalArgumentException if series is not in the + * range 0 to getSeriesCount() - 1. + */ + public XYIntervalSeries getSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + return (XYIntervalSeries) this.data.get(series); + } + + /** + * Returns the key for a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The key for a series. + * + * @throws IllegalArgumentException if series is not in the + * specified range. + */ + @Override + public Comparable getSeriesKey(int series) { + // defer argument checking + return getSeries(series).getKey(); + } + + /** + * Returns the number of items in the specified series. + * + * @param series the series (zero-based index). + * + * @return The item count. + * + * @throws IllegalArgumentException if series is not in the + * range 0 to getSeriesCount() - 1. + */ + @Override + public int getItemCount(int series) { + // defer argument checking + return getSeries(series).getItemCount(); + } + + /** + * Returns the x-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value. + */ + @Override + public Number getX(int series, int item) { + XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); + return s.getX(item); + } + + /** + * Returns the start x-value (as a double primitive) for an item within a + * series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getStartXValue(int series, int item) { + XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); + return s.getXLowValue(item); + } + + /** + * Returns the end x-value (as a double primitive) for an item within a + * series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getEndXValue(int series, int item) { + XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); + return s.getXHighValue(item); + } + + /** + * Returns the y-value (as a double primitive) for an item within a + * series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getYValue(int series, int item) { + XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); + return s.getYValue(item); + } + + /** + * Returns the start y-value (as a double primitive) for an item within a + * series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getStartYValue(int series, int item) { + XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); + return s.getYLowValue(item); + } + + /** + * Returns the end y-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value. + */ + @Override + public double getEndYValue(int series, int item) { + XYIntervalSeries s = (XYIntervalSeries) this.data.get(series); + return s.getYHighValue(item); + } + + /** + * Returns the y-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The y-value. + */ + @Override + public Number getY(int series, int item) { + return new Double(getYValue(series, item)); + } + + /** + * Returns the start x-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value. + */ + @Override + public Number getStartX(int series, int item) { + return new Double(getStartXValue(series, item)); + } + + /** + * Returns the end x-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value. + */ + @Override + public Number getEndX(int series, int item) { + return new Double(getEndXValue(series, item)); + } + + /** + * Returns the start y-value for an item within a series. This method + * maps directly to {@link #getY(int, int)}. + * + * @param series the series index. + * @param item the item index. + * + * @return The start y-value. + */ + @Override + public Number getStartY(int series, int item) { + return new Double(getStartYValue(series, item)); + } + + /** + * Returns the end y-value for an item within a series. This method + * maps directly to {@link #getY(int, int)}. + * + * @param series the series index. + * @param item the item index. + * + * @return The end y-value. + */ + @Override + public Number getEndY(int series, int item) { + return new Double(getEndYValue(series, item)); + } + + /** + * Removes a series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * + * @since 1.0.10 + */ + public void removeSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds."); + } + XYIntervalSeries ts = (XYIntervalSeries) this.data.get(series); + ts.removeChangeListener(this); + this.data.remove(series); + fireDatasetChanged(); + } + + /** + * Removes a series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param series the series (null not permitted). + * + * @since 1.0.10 + */ + public void removeSeries(XYIntervalSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + if (this.data.contains(series)) { + series.removeChangeListener(this); + this.data.remove(series); + fireDatasetChanged(); + } + } + + /** + * Removes all the series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @since 1.0.10 + */ + public void removeAllSeries() { + // Unregister the collection as a change listener to each series in + // the collection. + for (int i = 0; i < this.data.size(); i++) { + XYIntervalSeries series = (XYIntervalSeries) this.data.get(i); + series.removeChangeListener(this); + } + this.data.clear(); + fireDatasetChanged(); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYIntervalSeriesCollection)) { + return false; + } + XYIntervalSeriesCollection that = (XYIntervalSeriesCollection) obj; + return ObjectUtilities.equal(this.data, that.data); + } + + /** + * Returns a clone of this dataset. + * + * @return A clone of this dataset. + * + * @throws CloneNotSupportedException if there is a problem cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + XYIntervalSeriesCollection clone + = (XYIntervalSeriesCollection) super.clone(); + int seriesCount = getSeriesCount(); + clone.data = new java.util.ArrayList(seriesCount); + for (int i = 0; i < this.data.size(); i++) { + clone.data.set(i, getSeries(i).clone()); + } + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYRangeInfo.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYRangeInfo.java new file mode 100755 index 0000000..cc0c135 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYRangeInfo.java @@ -0,0 +1,68 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * XYRangeInfo.java + * ---------------- + * (C) Copyright 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Mar-2009 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import java.util.List; +import org.jfree.data.Range; + +/** + * An interface that can (optionally) be implemented by a dataset to assist in + * determining the minimum and maximum y-values. + * + * @since 1.0.13 + */ +public interface XYRangeInfo { + + /** + * Returns the range of the values in this dataset's range. + * + * @param visibleSeriesKeys the keys of the visible series. + * @param xRange the x-range (null not permitted). + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The range (or null if the dataset contains no + * values). + */ + public Range getRangeBounds(List visibleSeriesKeys, Range xRange, + boolean includeInterval); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYSeries.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYSeries.java new file mode 100755 index 0000000..a33b894 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYSeries.java @@ -0,0 +1,1012 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * XYSeries.java + * ------------- + * (C) Copyright 2001-2013, Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Aaron Metzger; + * Jonathan Gabbai; + * Richard Atkinson; + * Michel Santos; + * Ted Schwartz (fix for bug 1955483); + * + * Changes + * ------- + * 15-Nov-2001 : Version 1 (DG); + * 03-Apr-2002 : Added an add(double, double) method (DG); + * 29-Apr-2002 : Added a clear() method (ARM); + * 06-Jun-2002 : Updated Javadoc comments (DG); + * 29-Aug-2002 : Modified to give user control over whether or not duplicate + * x-values are allowed (DG); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 11-Nov-2002 : Added maximum item count, code contributed by Jonathan + * Gabbai (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 04-Aug-2003 : Added getItems() method (DG); + * 15-Aug-2003 : Changed 'data' from private to protected, added new add() + * methods with a 'notify' argument (DG); + * 22-Sep-2003 : Added getAllowDuplicateXValues() method (RA); + * 29-Jan-2004 : Added autoSort attribute, based on a contribution by + * Michel Santos - see patch 886740 (DG); + * 03-Feb-2004 : Added indexOf() method (DG); + * 16-Feb-2004 : Added remove() method (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); + * 21-Feb-2005 : Added update(Number, Number) and addOrUpdate(Number, Number) + * methods (DG); + * 03-May-2005 : Added a new constructor, fixed the setMaximumItemCount() + * method to remove items (and notify listeners) if necessary, + * fixed the add() and addOrUpdate() methods to handle unsorted + * series (DG); + * ------------- JFreeChart 1.0.x --------------------------------------------- + * 11-Jan-2005 : Renamed update(int, Number) --> updateByIndex() (DG); + * 15-Jan-2007 : Added toArray() method (DG); + * 31-Oct-2007 : Implemented faster hashCode() (DG); + * 22-Nov-2007 : Reimplemented clone() (DG); + * 01-May-2008 : Fixed bug 1955483 in addOrUpdate() method, thanks to + * Ted Schwartz (DG); + * 24-Nov-2008 : Further fix for 1955483 (DG); + * 06-Mar-2009 : Added minX, maxX, minY and maxY fields (DG); + * 10-Jun-2009 : Make clones to isolate XYDataItem instances used + * for data storage (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.general.Series; +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.data.general.SeriesException; +import org.jfree.util.ObjectUtilities; + +/** + * Represents a sequence of zero or more data items in the form (x, y). By + * default, items in the series will be sorted into ascending order by x-value, + * and duplicate x-values are permitted. Both the sorting and duplicate + * defaults can be changed in the constructor. Y-values can be + * null to represent missing values. + */ +public class XYSeries extends Series implements Cloneable, Serializable { + + /** For serialization. */ + static final long serialVersionUID = -5908509288197150436L; + + // In version 0.9.12, in response to several developer requests, I changed + // the 'data' attribute from 'private' to 'protected', so that others can + // make subclasses that work directly with the underlying data structure. + + /** Storage for the data items in the series. */ + protected List data; + + /** The maximum number of items for the series. */ + private int maximumItemCount = Integer.MAX_VALUE; + + /** + * A flag that controls whether the items are automatically sorted + * (by x-value ascending). + */ + private boolean autoSort; + + /** A flag that controls whether or not duplicate x-values are allowed. */ + private boolean allowDuplicateXValues; + + /** The lowest x-value in the series, excluding Double.NaN values. */ + private double minX; + + /** The highest x-value in the series, excluding Double.NaN values. */ + private double maxX; + + /** The lowest y-value in the series, excluding Double.NaN values. */ + private double minY; + + /** The highest y-value in the series, excluding Double.NaN values. */ + private double maxY; + + /** + * Creates a new empty series. By default, items added to the series will + * be sorted into ascending order by x-value, and duplicate x-values will + * be allowed (these defaults can be modified with another constructor). + * + * @param key the series key (null not permitted). + */ + public XYSeries(Comparable key) { + this(key, true, true); + } + + /** + * Constructs a new empty series, with the auto-sort flag set as requested, + * and duplicate values allowed. + * + * @param key the series key (null not permitted). + * @param autoSort a flag that controls whether or not the items in the + * series are sorted. + */ + public XYSeries(Comparable key, boolean autoSort) { + this(key, autoSort, true); + } + + /** + * Constructs a new xy-series that contains no data. You can specify + * whether or not duplicate x-values are allowed for the series. + * + * @param key the series key (null not permitted). + * @param autoSort a flag that controls whether or not the items in the + * series are sorted. + * @param allowDuplicateXValues a flag that controls whether duplicate + * x-values are allowed. + */ + public XYSeries(Comparable key, boolean autoSort, + boolean allowDuplicateXValues) { + super(key); + this.data = new java.util.ArrayList(); + this.autoSort = autoSort; + this.allowDuplicateXValues = allowDuplicateXValues; + this.minX = Double.NaN; + this.maxX = Double.NaN; + this.minY = Double.NaN; + this.maxY = Double.NaN; + } + + /** + * Returns the smallest x-value in the series, ignoring any Double.NaN + * values. This method returns Double.NaN if there is no smallest x-value + * (for example, when the series is empty). + * + * @return The smallest x-value. + * + * @see #getMaxX() + * + * @since 1.0.13 + */ + public double getMinX() { + return this.minX; + } + + /** + * Returns the largest x-value in the series, ignoring any Double.NaN + * values. This method returns Double.NaN if there is no largest x-value + * (for example, when the series is empty). + * + * @return The largest x-value. + * + * @see #getMinX() + * + * @since 1.0.13 + */ + public double getMaxX() { + return this.maxX; + } + + /** + * Returns the smallest y-value in the series, ignoring any null and + * Double.NaN values. This method returns Double.NaN if there is no + * smallest y-value (for example, when the series is empty). + * + * @return The smallest y-value. + * + * @see #getMaxY() + * + * @since 1.0.13 + */ + public double getMinY() { + return this.minY; + } + + /** + * Returns the largest y-value in the series, ignoring any Double.NaN + * values. This method returns Double.NaN if there is no largest y-value + * (for example, when the series is empty). + * + * @return The largest y-value. + * + * @see #getMinY() + * + * @since 1.0.13 + */ + public double getMaxY() { + return this.maxY; + } + + /** + * Updates the cached values for the minimum and maximum data values. + * + * @param item the item added (null not permitted). + * + * @since 1.0.13 + */ + private void updateBoundsForAddedItem(XYDataItem item) { + double x = item.getXValue(); + this.minX = minIgnoreNaN(this.minX, x); + this.maxX = maxIgnoreNaN(this.maxX, x); + if (item.getY() != null) { + double y = item.getYValue(); + this.minY = minIgnoreNaN(this.minY, y); + this.maxY = maxIgnoreNaN(this.maxY, y); + } + } + + /** + * Updates the cached values for the minimum and maximum data values on + * the basis that the specified item has just been removed. + * + * @param item the item added (null not permitted). + * + * @since 1.0.13 + */ + private void updateBoundsForRemovedItem(XYDataItem item) { + boolean itemContributesToXBounds = false; + boolean itemContributesToYBounds = false; + double x = item.getXValue(); + if (!Double.isNaN(x)) { + if (x <= this.minX || x >= this.maxX) { + itemContributesToXBounds = true; + } + } + if (item.getY() != null) { + double y = item.getYValue(); + if (!Double.isNaN(y)) { + if (y <= this.minY || y >= this.maxY) { + itemContributesToYBounds = true; + } + } + } + if (itemContributesToYBounds) { + findBoundsByIteration(); + } + else if (itemContributesToXBounds) { + if (getAutoSort()) { + this.minX = getX(0).doubleValue(); + this.maxX = getX(getItemCount() - 1).doubleValue(); + } + else { + findBoundsByIteration(); + } + } + } + + /** + * Finds the bounds of the x and y values for the series, by iterating + * through all the data items. + * + * @since 1.0.13 + */ + private void findBoundsByIteration() { + this.minX = Double.NaN; + this.maxX = Double.NaN; + this.minY = Double.NaN; + this.maxY = Double.NaN; + Iterator iterator = this.data.iterator(); + while (iterator.hasNext()) { + XYDataItem item = (XYDataItem) iterator.next(); + updateBoundsForAddedItem(item); + } + } + + /** + * Returns the flag that controls whether the items in the series are + * automatically sorted. There is no setter for this flag, it must be + * defined in the series constructor. + * + * @return A boolean. + */ + public boolean getAutoSort() { + return this.autoSort; + } + + /** + * Returns a flag that controls whether duplicate x-values are allowed. + * This flag can only be set in the constructor. + * + * @return A boolean. + */ + public boolean getAllowDuplicateXValues() { + return this.allowDuplicateXValues; + } + + /** + * Returns the number of items in the series. + * + * @return The item count. + * + * @see #getItems() + */ + @Override + public int getItemCount() { + return this.data.size(); + } + + /** + * Returns the list of data items for the series (the list contains + * {@link XYDataItem} objects and is unmodifiable). + * + * @return The list of data items. + */ + public List getItems() { + return Collections.unmodifiableList(this.data); + } + + /** + * Returns the maximum number of items that will be retained in the series. + * The default value is Integer.MAX_VALUE. + * + * @return The maximum item count. + * + * @see #setMaximumItemCount(int) + */ + public int getMaximumItemCount() { + return this.maximumItemCount; + } + + /** + * Sets the maximum number of items that will be retained in the series. + * If you add a new item to the series such that the number of items will + * exceed the maximum item count, then the first element in the series is + * automatically removed, ensuring that the maximum item count is not + * exceeded. + *

      + * Typically this value is set before the series is populated with data, + * but if it is applied later, it may cause some items to be removed from + * the series (in which case a {@link SeriesChangeEvent} will be sent to + * all registered listeners). + * + * @param maximum the maximum number of items for the series. + */ + public void setMaximumItemCount(int maximum) { + this.maximumItemCount = maximum; + int remove = this.data.size() - maximum; + if (remove > 0) { + this.data.subList(0, remove).clear(); + findBoundsByIteration(); + fireSeriesChanged(); + } + } + + /** + * Adds a data item to the series and sends a {@link SeriesChangeEvent} to + * all registered listeners. + * + * @param item the (x, y) item (null not permitted). + */ + public void add(XYDataItem item) { + // argument checking delegated... + add(item, true); + } + + /** + * Adds a data item to the series and sends a {@link SeriesChangeEvent} to + * all registered listeners. + * + * @param x the x value. + * @param y the y value. + */ + public void add(double x, double y) { + add(new Double(x), new Double(y), true); + } + + /** + * Adds a data item to the series and, if requested, sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param x the x value. + * @param y the y value. + * @param notify a flag that controls whether or not a + * {@link SeriesChangeEvent} is sent to all registered + * listeners. + */ + public void add(double x, double y, boolean notify) { + add(new Double(x), new Double(y), notify); + } + + /** + * Adds a data item to the series and sends a {@link SeriesChangeEvent} to + * all registered listeners. The unusual pairing of parameter types is to + * make it easier to add null y-values. + * + * @param x the x value. + * @param y the y value (null permitted). + */ + public void add(double x, Number y) { + add(new Double(x), y); + } + + /** + * Adds a data item to the series and, if requested, sends a + * {@link SeriesChangeEvent} to all registered listeners. The unusual + * pairing of parameter types is to make it easier to add null y-values. + * + * @param x the x value. + * @param y the y value (null permitted). + * @param notify a flag that controls whether or not a + * {@link SeriesChangeEvent} is sent to all registered + * listeners. + */ + public void add(double x, Number y, boolean notify) { + add(new Double(x), y, notify); + } + + /** + * Adds a new data item to the series (in the correct position if the + * autoSort flag is set for the series) and sends a + * {@link SeriesChangeEvent} to all registered listeners. + *

      + * Throws an exception if the x-value is a duplicate AND the + * allowDuplicateXValues flag is false. + * + * @param x the x-value (null not permitted). + * @param y the y-value (null permitted). + * + * @throws SeriesException if the x-value is a duplicate and the + * allowDuplicateXValues flag is not set for this series. + */ + public void add(Number x, Number y) { + // argument checking delegated... + add(x, y, true); + } + + /** + * Adds new data to the series and, if requested, sends a + * {@link SeriesChangeEvent} to all registered listeners. + *

      + * Throws an exception if the x-value is a duplicate AND the + * allowDuplicateXValues flag is false. + * + * @param x the x-value (null not permitted). + * @param y the y-value (null permitted). + * @param notify a flag the controls whether or not a + * {@link SeriesChangeEvent} is sent to all registered + * listeners. + */ + public void add(Number x, Number y, boolean notify) { + // delegate argument checking to XYDataItem... + XYDataItem item = new XYDataItem(x, y); + add(item, notify); + } + + /** + * Adds a data item to the series and, if requested, sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param item the (x, y) item (null not permitted). + * @param notify a flag that controls whether or not a + * {@link SeriesChangeEvent} is sent to all registered + * listeners. + */ + public void add(XYDataItem item, boolean notify) { + ParamChecks.nullNotPermitted(item, "item"); + item = (XYDataItem) item.clone(); + if (this.autoSort) { + int index = Collections.binarySearch(this.data, item); + if (index < 0) { + this.data.add(-index - 1, item); + } + else { + if (this.allowDuplicateXValues) { + // need to make sure we are adding *after* any duplicates + int size = this.data.size(); + while (index < size && item.compareTo( + this.data.get(index)) == 0) { + index++; + } + if (index < this.data.size()) { + this.data.add(index, item); + } + else { + this.data.add(item); + } + } + else { + throw new SeriesException("X-value already exists."); + } + } + } + else { + if (!this.allowDuplicateXValues) { + // can't allow duplicate values, so we need to check whether + // there is an item with the given x-value already + int index = indexOf(item.getX()); + if (index >= 0) { + throw new SeriesException("X-value already exists."); + } + } + this.data.add(item); + } + updateBoundsForAddedItem(item); + if (getItemCount() > this.maximumItemCount) { + XYDataItem removed = (XYDataItem) this.data.remove(0); + updateBoundsForRemovedItem(removed); + } + if (notify) { + fireSeriesChanged(); + } + } + + /** + * Deletes a range of items from the series and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param start the start index (zero-based). + * @param end the end index (zero-based). + */ + public void delete(int start, int end) { + this.data.subList(start, end + 1).clear(); + findBoundsByIteration(); + fireSeriesChanged(); + } + + /** + * Removes the item at the specified index and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param index the index. + * + * @return The item removed. + */ + public XYDataItem remove(int index) { + XYDataItem removed = (XYDataItem) this.data.remove(index); + updateBoundsForRemovedItem(removed); + fireSeriesChanged(); + return removed; + } + + /** + * Removes an item with the specified x-value and sends a + * {@link SeriesChangeEvent} to all registered listeners. Note that when + * a series permits multiple items with the same x-value, this method + * could remove any one of the items with that x-value. + * + * @param x the x-value. + + * @return The item removed. + */ + public XYDataItem remove(Number x) { + return remove(indexOf(x)); + } + + /** + * Removes all data items from the series and sends a + * {@link SeriesChangeEvent} to all registered listeners. + */ + public void clear() { + if (this.data.size() > 0) { + this.data.clear(); + this.minX = Double.NaN; + this.maxX = Double.NaN; + this.minY = Double.NaN; + this.maxY = Double.NaN; + fireSeriesChanged(); + } + } + + /** + * Return the data item with the specified index. + * + * @param index the index. + * + * @return The data item with the specified index. + */ + public XYDataItem getDataItem(int index) { + XYDataItem item = (XYDataItem) this.data.get(index); + return (XYDataItem) item.clone(); + } + + /** + * Return the data item with the specified index. + * + * @param index the index. + * + * @return The data item with the specified index. + * + * @since 1.0.14 + */ + XYDataItem getRawDataItem(int index) { + return (XYDataItem) this.data.get(index); + } + + /** + * Returns the x-value at the specified index. + * + * @param index the index (zero-based). + * + * @return The x-value (never null). + */ + public Number getX(int index) { + return getRawDataItem(index).getX(); + } + + /** + * Returns the y-value at the specified index. + * + * @param index the index (zero-based). + * + * @return The y-value (possibly null). + */ + public Number getY(int index) { + return getRawDataItem(index).getY(); + } + + /** + * Updates the value of an item in the series and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param index the item (zero based index). + * @param y the new value (null permitted). + * + * @deprecated Renamed {@link #updateByIndex(int, Number)} to avoid + * confusion with the {@link #update(Number, Number)} method. + */ + public void update(int index, Number y) { + XYDataItem item = getRawDataItem(index); + + // figure out if we need to iterate through all the y-values + boolean iterate = false; + double oldY = item.getYValue(); + if (!Double.isNaN(oldY)) { + iterate = oldY <= this.minY || oldY >= this.maxY; + } + item.setY(y); + + if (iterate) { + findBoundsByIteration(); + } + else if (y != null) { + double yy = y.doubleValue(); + this.minY = minIgnoreNaN(this.minY, yy); + this.maxY = maxIgnoreNaN(this.maxY, yy); + } + fireSeriesChanged(); + } + + /** + * A function to find the minimum of two values, but ignoring any + * Double.NaN values. + * + * @param a the first value. + * @param b the second value. + * + * @return The minimum of the two values. + */ + private double minIgnoreNaN(double a, double b) { + if (Double.isNaN(a)) { + return b; + } + if (Double.isNaN(b)) { + return a; + } + return Math.min(a, b); + } + + /** + * A function to find the maximum of two values, but ignoring any + * Double.NaN values. + * + * @param a the first value. + * @param b the second value. + * + * @return The maximum of the two values. + */ + private double maxIgnoreNaN(double a, double b) { + if (Double.isNaN(a)) { + return b; + } + if (Double.isNaN(b)) { + return a; + } + return Math.max(a, b); + } + + /** + * Updates the value of an item in the series and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param index the item (zero based index). + * @param y the new value (null permitted). + * + * @since 1.0.1 + */ + public void updateByIndex(int index, Number y) { + update(index, y); + } + + /** + * Updates an item in the series. + * + * @param x the x-value (null not permitted). + * @param y the y-value (null permitted). + * + * @throws SeriesException if there is no existing item with the specified + * x-value. + */ + public void update(Number x, Number y) { + int index = indexOf(x); + if (index < 0) { + throw new SeriesException("No observation for x = " + x); + } + updateByIndex(index, y); + } + + /** + * Adds or updates an item in the series and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param x the x-value. + * @param y the y-value. + * + * @return The item that was overwritten, if any. + * + * @since 1.0.10 + */ + public XYDataItem addOrUpdate(double x, double y) { + return addOrUpdate(new Double(x), new Double(y)); + } + + /** + * Adds or updates an item in the series and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param x the x-value (null not permitted). + * @param y the y-value (null permitted). + * + * @return A copy of the overwritten data item, or null if no + * item was overwritten. + */ + public XYDataItem addOrUpdate(Number x, Number y) { + // defer argument checking + return addOrUpdate(new XYDataItem(x, y)); + } + + /** + * Adds or updates an item in the series and sends a + * {@link SeriesChangeEvent} to all registered listeners. + * + * @param item the data item (null not permitted). + * + * @return A copy of the overwritten data item, or null if no + * item was overwritten. + * + * @since 1.0.14 + */ + public XYDataItem addOrUpdate(XYDataItem item) { + ParamChecks.nullNotPermitted(item, "item"); + if (this.allowDuplicateXValues) { + add(item); + return null; + } + + // if we get to here, we know that duplicate X values are not permitted + XYDataItem overwritten = null; + int index = indexOf(item.getX()); + if (index >= 0) { + XYDataItem existing = (XYDataItem) this.data.get(index); + overwritten = (XYDataItem) existing.clone(); + // figure out if we need to iterate through all the y-values + boolean iterate = false; + double oldY = existing.getYValue(); + if (!Double.isNaN(oldY)) { + iterate = oldY <= this.minY || oldY >= this.maxY; + } + existing.setY(item.getY()); + + if (iterate) { + findBoundsByIteration(); + } + else if (item.getY() != null) { + double yy = item.getY().doubleValue(); + this.minY = minIgnoreNaN(this.minY, yy); + this.maxY = maxIgnoreNaN(this.maxY, yy); + } + } + else { + // if the series is sorted, the negative index is a result from + // Collections.binarySearch() and tells us where to insert the + // new item...otherwise it will be just -1 and we should just + // append the value to the list... + item = (XYDataItem) item.clone(); + if (this.autoSort) { + this.data.add(-index - 1, item); + } + else { + this.data.add(item); + } + updateBoundsForAddedItem(item); + + // check if this addition will exceed the maximum item count... + if (getItemCount() > this.maximumItemCount) { + XYDataItem removed = (XYDataItem) this.data.remove(0); + updateBoundsForRemovedItem(removed); + } + } + fireSeriesChanged(); + return overwritten; + } + + /** + * Returns the index of the item with the specified x-value, or a negative + * index if the series does not contain an item with that x-value. Be + * aware that for an unsorted series, the index is found by iterating + * through all items in the series. + * + * @param x the x-value (null not permitted). + * + * @return The index. + */ + public int indexOf(Number x) { + if (this.autoSort) { + return Collections.binarySearch(this.data, new XYDataItem(x, null)); + } + else { + for (int i = 0; i < this.data.size(); i++) { + XYDataItem item = (XYDataItem) this.data.get(i); + if (item.getX().equals(x)) { + return i; + } + } + return -1; + } + } + + /** + * Returns a new array containing the x and y values from this series. + * + * @return A new array containing the x and y values from this series. + * + * @since 1.0.4 + */ + public double[][] toArray() { + int itemCount = getItemCount(); + double[][] result = new double[2][itemCount]; + for (int i = 0; i < itemCount; i++) { + result[0][i] = this.getX(i).doubleValue(); + Number y = getY(i); + if (y != null) { + result[1][i] = y.doubleValue(); + } + else { + result[1][i] = Double.NaN; + } + } + return result; + } + + /** + * Returns a clone of the series. + * + * @return A clone of the series. + * + * @throws CloneNotSupportedException if there is a cloning problem. + */ + @Override + public Object clone() throws CloneNotSupportedException { + XYSeries clone = (XYSeries) super.clone(); + clone.data = (List) ObjectUtilities.deepClone(this.data); + return clone; + } + + /** + * Creates a new series by copying a subset of the data in this time series. + * + * @param start the index of the first item to copy. + * @param end the index of the last item to copy. + * + * @return A series containing a copy of this series from start until end. + * + * @throws CloneNotSupportedException if there is a cloning problem. + */ + public XYSeries createCopy(int start, int end) + throws CloneNotSupportedException { + + XYSeries copy = (XYSeries) super.clone(); + copy.data = new java.util.ArrayList(); + if (this.data.size() > 0) { + for (int index = start; index <= end; index++) { + XYDataItem item = (XYDataItem) this.data.get(index); + XYDataItem clone = (XYDataItem) item.clone(); + try { + copy.add(clone); + } + catch (SeriesException e) { + System.err.println("Unable to add cloned data item."); + } + } + } + return copy; + + } + + /** + * Tests this series for equality with an arbitrary object. + * + * @param obj the object to test against for equality + * (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYSeries)) { + return false; + } + if (!super.equals(obj)) { + return false; + } + XYSeries that = (XYSeries) obj; + if (this.maximumItemCount != that.maximumItemCount) { + return false; + } + if (this.autoSort != that.autoSort) { + return false; + } + if (this.allowDuplicateXValues != that.allowDuplicateXValues) { + return false; + } + if (!ObjectUtilities.equal(this.data, that.data)) { + return false; + } + return true; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int result = super.hashCode(); + // it is too slow to look at every data item, so let's just look at + // the first, middle and last items... + int count = getItemCount(); + if (count > 0) { + XYDataItem item = getRawDataItem(0); + result = 29 * result + item.hashCode(); + } + if (count > 1) { + XYDataItem item = getRawDataItem(count - 1); + result = 29 * result + item.hashCode(); + } + if (count > 2) { + XYDataItem item = getRawDataItem(count / 2); + result = 29 * result + item.hashCode(); + } + result = 29 * result + this.maximumItemCount; + result = 29 * result + (this.autoSort ? 1 : 0); + result = 29 * result + (this.allowDuplicateXValues ? 1 : 0); + return result; + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYSeriesCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYSeriesCollection.java new file mode 100755 index 0000000..27cbddd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYSeriesCollection.java @@ -0,0 +1,760 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * XYSeriesCollection.java + * ----------------------- + * (C) Copyright 2001-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Aaron Metzger; + * + * Changes + * ------- + * 15-Nov-2001 : Version 1 (DG); + * 03-Apr-2002 : Added change listener code (DG); + * 29-Apr-2002 : Added removeSeries, removeAllSeries methods (ARM); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 26-Mar-2003 : Implemented Serializable (DG); + * 04-Aug-2003 : Added getSeries() method (DG); + * 31-Mar-2004 : Modified to use an XYIntervalDelegate. + * 05-May-2004 : Now extends AbstractIntervalXYDataset (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); + * 17-Nov-2004 : Updated for changes to DomainInfo interface (DG); + * 11-Jan-2005 : Removed deprecated code in preparation for 1.0.0 release (DG); + * 28-Mar-2005 : Fixed bug in getSeries(int) method (1170825) (DG); + * 05-Oct-2005 : Made the interval delegate a dataset listener (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 27-Nov-2006 : Added clone() override (DG); + * 08-May-2007 : Added indexOf(XYSeries) method (DG); + * 03-Dec-2007 : Added getSeries(Comparable) method (DG); + * 22-Apr-2008 : Implemented PublicCloneable (DG); + * 27-Feb-2009 : Overridden getDomainOrder() to detect when all series are + * sorted in ascending order (DG); + * 06-Mar-2009 : Implemented RangeInfo (DG); + * 06-Mar-2009 : Fixed equals() implementation (DG); + * 10-Jun-2009 : Simplified code in getX() and getY() methods (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * 21-Nov-2013 : Fixed bug where removeSeries(int) was not deregistering + * vetoable listener (DG); + * + */ + +package org.jfree.data.xy; + +import java.beans.PropertyChangeEvent; +import java.beans.PropertyVetoException; +import java.beans.VetoableChangeListener; +import java.io.Serializable; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import org.jfree.chart.HashUtilities; +import org.jfree.chart.util.ParamChecks; +import org.jfree.data.DomainInfo; +import org.jfree.data.DomainOrder; +import org.jfree.data.Range; +import org.jfree.data.RangeInfo; +import org.jfree.data.UnknownKeyException; +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.Series; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * Represents a collection of {@link XYSeries} objects that can be used as a + * dataset. + */ +public class XYSeriesCollection extends AbstractIntervalXYDataset + implements IntervalXYDataset, DomainInfo, RangeInfo, + VetoableChangeListener, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -7590013825931496766L; + + /** The series that are included in the collection. */ + private List data; + + /** The interval delegate (used to calculate the start and end x-values). */ + private IntervalXYDelegate intervalDelegate; + + /** + * Constructs an empty dataset. + */ + public XYSeriesCollection() { + this(null); + } + + /** + * Constructs a dataset and populates it with a single series. + * + * @param series the series (null ignored). + */ + public XYSeriesCollection(XYSeries series) { + this.data = new java.util.ArrayList(); + this.intervalDelegate = new IntervalXYDelegate(this, false); + addChangeListener(this.intervalDelegate); + if (series != null) { + this.data.add(series); + series.addChangeListener(this); + series.addVetoableChangeListener(this); + } + } + + /** + * Returns the order of the domain (X) values, if this is known. + * + * @return The domain order. + */ + @Override + public DomainOrder getDomainOrder() { + int seriesCount = getSeriesCount(); + for (int i = 0; i < seriesCount; i++) { + XYSeries s = getSeries(i); + if (!s.getAutoSort()) { + return DomainOrder.NONE; // we can't be sure of the order + } + } + return DomainOrder.ASCENDING; + } + + /** + * Adds a series to the collection and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param series the series (null not permitted). + * + * @throws IllegalArgumentException if the key for the series is null or + * not unique within the dataset. + */ + public void addSeries(XYSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + if (getSeriesIndex(series.getKey()) >= 0) { + throw new IllegalArgumentException( + "This dataset already contains a series with the key " + + series.getKey()); + } + this.data.add(series); + series.addChangeListener(this); + series.addVetoableChangeListener(this); + fireDatasetChanged(); + } + + /** + * Removes a series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + */ + public void removeSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds."); + } + XYSeries s = (XYSeries) this.data.get(series); + if (s != null) { + removeSeries(s); + } + } + + /** + * Removes a series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param series the series (null not permitted). + */ + public void removeSeries(XYSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + if (this.data.contains(series)) { + series.removeChangeListener(this); + series.removeVetoableChangeListener(this); + this.data.remove(series); + fireDatasetChanged(); + } + } + + /** + * Removes all the series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + */ + public void removeAllSeries() { + // Unregister the collection as a change listener to each series in + // the collection. + for (int i = 0; i < this.data.size(); i++) { + XYSeries series = (XYSeries) this.data.get(i); + series.removeChangeListener(this); + series.removeVetoableChangeListener(this); + } + + // Remove all the series from the collection and notify listeners. + this.data.clear(); + fireDatasetChanged(); + } + + /** + * Returns the number of series in the collection. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.data.size(); + } + + /** + * Returns a list of all the series in the collection. + * + * @return The list (which is unmodifiable). + */ + public List getSeries() { + return Collections.unmodifiableList(this.data); + } + + /** + * Returns the index of the specified series, or -1 if that series is not + * present in the dataset. + * + * @param series the series (null not permitted). + * + * @return The series index. + * + * @since 1.0.6 + */ + public int indexOf(XYSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + return this.data.indexOf(series); + } + + /** + * Returns a series from the collection. + * + * @param series the series index (zero-based). + * + * @return The series. + * + * @throws IllegalArgumentException if series is not in the + * range 0 to getSeriesCount() - 1. + */ + public XYSeries getSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + return (XYSeries) this.data.get(series); + } + + /** + * Returns a series from the collection. + * + * @param key the key (null not permitted). + * + * @return The series with the specified key. + * + * @throws UnknownKeyException if key is not found in the + * collection. + * + * @since 1.0.9 + */ + public XYSeries getSeries(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + Iterator iterator = this.data.iterator(); + while (iterator.hasNext()) { + XYSeries series = (XYSeries) iterator.next(); + if (key.equals(series.getKey())) { + return series; + } + } + throw new UnknownKeyException("Key not found: " + key); + } + + /** + * Returns the key for a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The key for a series. + * + * @throws IllegalArgumentException if series is not in the + * specified range. + */ + @Override + public Comparable getSeriesKey(int series) { + // defer argument checking + return getSeries(series).getKey(); + } + + /** + * Returns the index of the series with the specified key, or -1 if no + * series has that key. + * + * @param key the key (null not permitted). + * + * @return The index. + * + * @since 1.0.14 + */ + public int getSeriesIndex(Comparable key) { + ParamChecks.nullNotPermitted(key, "key"); + int seriesCount = getSeriesCount(); + for (int i = 0; i < seriesCount; i++) { + XYSeries series = (XYSeries) this.data.get(i); + if (key.equals(series.getKey())) { + return i; + } + } + return -1; + } + + /** + * Returns the number of items in the specified series. + * + * @param series the series (zero-based index). + * + * @return The item count. + * + * @throws IllegalArgumentException if series is not in the + * range 0 to getSeriesCount() - 1. + */ + @Override + public int getItemCount(int series) { + // defer argument checking + return getSeries(series).getItemCount(); + } + + /** + * Returns the x-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value. + */ + @Override + public Number getX(int series, int item) { + XYSeries s = (XYSeries) this.data.get(series); + return s.getX(item); + } + + /** + * Returns the starting X value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The starting X value. + */ + @Override + public Number getStartX(int series, int item) { + return this.intervalDelegate.getStartX(series, item); + } + + /** + * Returns the ending X value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The ending X value. + */ + @Override + public Number getEndX(int series, int item) { + return this.intervalDelegate.getEndX(series, item); + } + + /** + * Returns the y-value for the specified series and item. + * + * @param series the series (zero-based index). + * @param index the index of the item of interest (zero-based). + * + * @return The value (possibly null). + */ + @Override + public Number getY(int series, int index) { + XYSeries s = (XYSeries) this.data.get(series); + return s.getY(index); + } + + /** + * Returns the starting Y value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The starting Y value. + */ + @Override + public Number getStartY(int series, int item) { + return getY(series, item); + } + + /** + * Returns the ending Y value for the specified series and item. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The ending Y value. + */ + @Override + public Number getEndY(int series, int item) { + return getY(series, item); + } + + /** + * Tests this collection for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof XYSeriesCollection)) { + return false; + } + XYSeriesCollection that = (XYSeriesCollection) obj; + if (!this.intervalDelegate.equals(that.intervalDelegate)) { + return false; + } + return ObjectUtilities.equal(this.data, that.data); + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem. + */ + @Override + public Object clone() throws CloneNotSupportedException { + XYSeriesCollection clone = (XYSeriesCollection) super.clone(); + clone.data = (List) ObjectUtilities.deepClone(this.data); + clone.intervalDelegate + = (IntervalXYDelegate) this.intervalDelegate.clone(); + return clone; + } + + /** + * Returns a hash code. + * + * @return A hash code. + */ + @Override + public int hashCode() { + int hash = 5; + hash = HashUtilities.hashCode(hash, this.intervalDelegate); + hash = HashUtilities.hashCode(hash, this.data); + return hash; + } + + /** + * Returns the minimum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The minimum value. + */ + @Override + public double getDomainLowerBound(boolean includeInterval) { + if (includeInterval) { + return this.intervalDelegate.getDomainLowerBound(includeInterval); + } + double result = Double.NaN; + int seriesCount = getSeriesCount(); + for (int s = 0; s < seriesCount; s++) { + XYSeries series = getSeries(s); + double lowX = series.getMinX(); + if (Double.isNaN(result)) { + result = lowX; + } + else { + if (!Double.isNaN(lowX)) { + result = Math.min(result, lowX); + } + } + } + return result; + } + + /** + * Returns the maximum x-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The maximum value. + */ + @Override + public double getDomainUpperBound(boolean includeInterval) { + if (includeInterval) { + return this.intervalDelegate.getDomainUpperBound(includeInterval); + } + else { + double result = Double.NaN; + int seriesCount = getSeriesCount(); + for (int s = 0; s < seriesCount; s++) { + XYSeries series = getSeries(s); + double hiX = series.getMaxX(); + if (Double.isNaN(result)) { + result = hiX; + } + else { + if (!Double.isNaN(hiX)) { + result = Math.max(result, hiX); + } + } + } + return result; + } + } + + /** + * Returns the range of the values in this dataset's domain. + * + * @param includeInterval a flag that determines whether or not the + * x-interval is taken into account. + * + * @return The range (or null if the dataset contains no + * values). + */ + @Override + public Range getDomainBounds(boolean includeInterval) { + if (includeInterval) { + return this.intervalDelegate.getDomainBounds(includeInterval); + } + else { + double lower = Double.POSITIVE_INFINITY; + double upper = Double.NEGATIVE_INFINITY; + int seriesCount = getSeriesCount(); + for (int s = 0; s < seriesCount; s++) { + XYSeries series = getSeries(s); + double minX = series.getMinX(); + if (!Double.isNaN(minX)) { + lower = Math.min(lower, minX); + } + double maxX = series.getMaxX(); + if (!Double.isNaN(maxX)) { + upper = Math.max(upper, maxX); + } + } + if (lower > upper) { + return null; + } + else { + return new Range(lower, upper); + } + } + } + + /** + * Returns the interval width. This is used to calculate the start and end + * x-values, if/when the dataset is used as an {@link IntervalXYDataset}. + * + * @return The interval width. + */ + public double getIntervalWidth() { + return this.intervalDelegate.getIntervalWidth(); + } + + /** + * Sets the interval width and sends a {@link DatasetChangeEvent} to all + * registered listeners. + * + * @param width the width (negative values not permitted). + */ + public void setIntervalWidth(double width) { + if (width < 0.0) { + throw new IllegalArgumentException("Negative 'width' argument."); + } + this.intervalDelegate.setFixedIntervalWidth(width); + fireDatasetChanged(); + } + + /** + * Returns the interval position factor. + * + * @return The interval position factor. + */ + public double getIntervalPositionFactor() { + return this.intervalDelegate.getIntervalPositionFactor(); + } + + /** + * Sets the interval position factor. This controls where the x-value is in + * relation to the interval surrounding the x-value (0.0 means the x-value + * will be positioned at the start, 0.5 in the middle, and 1.0 at the end). + * + * @param factor the factor. + */ + public void setIntervalPositionFactor(double factor) { + this.intervalDelegate.setIntervalPositionFactor(factor); + fireDatasetChanged(); + } + + /** + * Returns whether the interval width is automatically calculated or not. + * + * @return Whether the width is automatically calculated or not. + */ + public boolean isAutoWidth() { + return this.intervalDelegate.isAutoWidth(); + } + + /** + * Sets the flag that indicates whether the interval width is automatically + * calculated or not. + * + * @param b a boolean. + */ + public void setAutoWidth(boolean b) { + this.intervalDelegate.setAutoWidth(b); + fireDatasetChanged(); + } + + /** + * Returns the range of the values in this dataset's range. + * + * @param includeInterval ignored. + * + * @return The range (or null if the dataset contains no + * values). + */ + @Override + public Range getRangeBounds(boolean includeInterval) { + double lower = Double.POSITIVE_INFINITY; + double upper = Double.NEGATIVE_INFINITY; + int seriesCount = getSeriesCount(); + for (int s = 0; s < seriesCount; s++) { + XYSeries series = getSeries(s); + double minY = series.getMinY(); + if (!Double.isNaN(minY)) { + lower = Math.min(lower, minY); + } + double maxY = series.getMaxY(); + if (!Double.isNaN(maxY)) { + upper = Math.max(upper, maxY); + } + } + if (lower > upper) { + return null; + } + else { + return new Range(lower, upper); + } + } + + /** + * Returns the minimum y-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The minimum value. + */ + @Override + public double getRangeLowerBound(boolean includeInterval) { + double result = Double.NaN; + int seriesCount = getSeriesCount(); + for (int s = 0; s < seriesCount; s++) { + XYSeries series = getSeries(s); + double lowY = series.getMinY(); + if (Double.isNaN(result)) { + result = lowY; + } + else { + if (!Double.isNaN(lowY)) { + result = Math.min(result, lowY); + } + } + } + return result; + } + + /** + * Returns the maximum y-value in the dataset. + * + * @param includeInterval a flag that determines whether or not the + * y-interval is taken into account. + * + * @return The maximum value. + */ + @Override + public double getRangeUpperBound(boolean includeInterval) { + double result = Double.NaN; + int seriesCount = getSeriesCount(); + for (int s = 0; s < seriesCount; s++) { + XYSeries series = getSeries(s); + double hiY = series.getMaxY(); + if (Double.isNaN(result)) { + result = hiY; + } + else { + if (!Double.isNaN(hiY)) { + result = Math.max(result, hiY); + } + } + } + return result; + } + + /** + * Receives notification that the key for one of the series in the + * collection has changed, and vetos it if the key is already present in + * the collection. + * + * @param e the event. + * + * @since 1.0.14 + */ + @Override + public void vetoableChange(PropertyChangeEvent e) + throws PropertyVetoException { + // if it is not the series name, then we have no interest + if (!"Key".equals(e.getPropertyName())) { + return; + } + + // to be defensive, let's check that the source series does in fact + // belong to this collection + Series s = (Series) e.getSource(); + if (getSeriesIndex(s.getKey()) == -1) { + throw new IllegalStateException("Receiving events from a series " + + "that does not belong to this collection."); + } + // check if the new series name already exists for another series + Comparable key = (Comparable) e.getNewValue(); + if (getSeriesIndex(key) >= 0) { + throw new PropertyVetoException("Duplicate key2", e); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYZDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYZDataset.java new file mode 100755 index 0000000..599e3df --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XYZDataset.java @@ -0,0 +1,72 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * XYZDataset.java + * --------------- + * (C) Copyright 2001-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 31-Oct-2001 : Initial version (DG); + * 05-May-2004 : Added getZ() method; + * 15-Jul-2004 : Switched getZ() and getZValue() methods (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); + * + */ + +package org.jfree.data.xy; + +/** + * The interface through which JFreeChart obtains data in the form of (x, y, z) + * items - used for XY and XYZ plots. + */ +public interface XYZDataset extends XYDataset { + + /** + * Returns the z-value for the specified series and item. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The z-value (possibly null). + */ + public Number getZ(int series, int item); + + /** + * Returns the z-value (as a double primitive) for an item within a series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The z-value. + */ + public double getZValue(int series, int item); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XisSymbolic.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XisSymbolic.java new file mode 100755 index 0000000..d1c8cba --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/XisSymbolic.java @@ -0,0 +1,79 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * XisSymbolic.java + * ---------------- + * (C) Copyright 2006-2008, by Anthony Boulestreau and Contributors. + * + * Original Author: Anthony Boulestreau; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 29-Mar-2002 : First version (AB); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.xy; + +/** + * Represent a data set where X is a symbolic values. Each symbolic value is + * linked with an Integer. + */ +public interface XisSymbolic { + + /** + * Returns the list of symbolic values. + * + * @return An array of symbolic values. + */ + public String[] getXSymbolicValues(); + + /** + * Returns the symbolic value of the data set specified by + * series and item parameters. + * + * @param series value of the serie. + * @param item value of the item. + * + * @return The symbolic value. + */ + public String getXSymbolicValue(int series, int item); + + /** + * Returns the symbolic value linked with the specified + * Integer. + * + * @param val value of the integer linked with the symbolic value. + * + * @return The symbolic value. + */ + public String getXSymbolicValue(Integer val); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YInterval.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YInterval.java new file mode 100755 index 0000000..af9e3c0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YInterval.java @@ -0,0 +1,130 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * YInterval.java + * -------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; + +/** + * A y-interval. This class is used internally by the + * {@link YIntervalDataItem} class. + * + * @since 1.0.3 + */ +public class YInterval implements Serializable { + + /** The y-value. */ + private double y; + + /** The lower bound of the y-interval. */ + private double yLow; + + /** The upper bound of the y-interval. */ + private double yHigh; + + /** + * Creates a new instance of YInterval. + * + * @param y the y-value. + * @param yLow the lower bound of the y-interval. + * @param yHigh the upper bound of the y-interval. + */ + public YInterval(double y, double yLow, double yHigh) { + this.y = y; + this.yLow = yLow; + this.yHigh = yHigh; + } + + /** + * Returns the y-value. + * + * @return The y-value. + */ + public double getY() { + return this.y; + } + + /** + * Returns the lower bound of the y-interval. + * + * @return The lower bound of the y-interval. + */ + public double getYLow() { + return this.yLow; + } + + /** + * Returns the upper bound of the y-interval. + * + * @return The upper bound of the y-interval. + */ + public double getYHigh() { + return this.yHigh; + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof YInterval)) { + return false; + } + YInterval that = (YInterval) obj; + if (this.y != that.y) { + return false; + } + if (this.yLow != that.yLow) { + return false; + } + if (this.yHigh != that.yHigh) { + return false; + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YIntervalDataItem.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YIntervalDataItem.java new file mode 100755 index 0000000..60abc5a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YIntervalDataItem.java @@ -0,0 +1,118 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * YIntervalDataItem.java + * ---------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import org.jfree.data.ComparableObjectItem; + +/** + * An item representing data in the form (x, y, y-low, y-high). + * + * @since 1.0.3 + */ +public class YIntervalDataItem extends ComparableObjectItem { + + /** + * Creates a new instance of YIntervalItem. + * + * @param x the x-value. + * @param y the y-value. + * @param yLow the lower bound of the y-interval. + * @param yHigh the upper bound of the y-interval. + */ + public YIntervalDataItem(double x, double y, double yLow, double yHigh) { + super(new Double(x), new YInterval(y, yLow, yHigh)); + } + + /** + * Returns the x-value. + * + * @return The x-value (never null). + */ + public Double getX() { + return (Double) getComparable(); + } + + /** + * Returns the y-value. + * + * @return The y-value. + */ + public double getYValue() { + YInterval interval = (YInterval) getObject(); + if (interval != null) { + return interval.getY(); + } + else { + return Double.NaN; + } + } + + /** + * Returns the lower bound of the y-interval. + * + * @return The lower bound of the y-interval. + */ + public double getYLowValue() { + YInterval interval = (YInterval) getObject(); + if (interval != null) { + return interval.getYLow(); + } + else { + return Double.NaN; + } + } + + /** + * Returns the upper bound of the y-interval. + * + * @return The upper bound of the y-interval. + */ + public double getYHighValue() { + YInterval interval = (YInterval) getObject(); + if (interval != null) { + return interval.getYHigh(); + } + else { + return Double.NaN; + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YIntervalSeries.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YIntervalSeries.java new file mode 100755 index 0000000..ff0831d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YIntervalSeries.java @@ -0,0 +1,160 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * YIntervalSeries.java + * -------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * 20-Feb-2007 : Added getYHighValue() and getYLowValue() methods (DG); + * + */ + +package org.jfree.data.xy; + +import org.jfree.data.ComparableObjectItem; +import org.jfree.data.ComparableObjectSeries; + +/** + * A list of (x, y, y-low, y-high) data items. + * + * @since 1.0.3 + * + * @see YIntervalSeriesCollection + */ +public class YIntervalSeries extends ComparableObjectSeries { + + /** + * Creates a new empty series. By default, items added to the series will + * be sorted into ascending order by x-value, and duplicate x-values will + * be allowed (these defaults can be modified with another constructor. + * + * @param key the series key (null not permitted). + */ + public YIntervalSeries(Comparable key) { + this(key, true, true); + } + + /** + * Constructs a new xy-series that contains no data. You can specify + * whether or not duplicate x-values are allowed for the series. + * + * @param key the series key (null not permitted). + * @param autoSort a flag that controls whether or not the items in the + * series are sorted. + * @param allowDuplicateXValues a flag that controls whether duplicate + * x-values are allowed. + */ + public YIntervalSeries(Comparable key, boolean autoSort, + boolean allowDuplicateXValues) { + super(key, autoSort, allowDuplicateXValues); + } + + /** + * Adds a data item to the series. + * + * @param x the x-value. + * @param y the y-value. + * @param yLow the lower bound of the y-interval. + * @param yHigh the upper bound of the y-interval. + */ + public void add(double x, double y, double yLow, double yHigh) { + super.add(new YIntervalDataItem(x, y, yLow, yHigh), true); + } + + /** + * Returns the x-value for the specified item. + * + * @param index the item index. + * + * @return The x-value (never null). + */ + public Number getX(int index) { + YIntervalDataItem item = (YIntervalDataItem) getDataItem(index); + return item.getX(); + } + + /** + * Returns the y-value for the specified item. + * + * @param index the item index. + * + * @return The y-value. + */ + public double getYValue(int index) { + YIntervalDataItem item = (YIntervalDataItem) getDataItem(index); + return item.getYValue(); + } + + /** + * Returns the lower bound of the Y-interval for the specified item in the + * series. + * + * @param index the item index. + * + * @return The lower bound of the Y-interval. + * + * @since 1.0.5 + */ + public double getYLowValue(int index) { + YIntervalDataItem item = (YIntervalDataItem) getDataItem(index); + return item.getYLowValue(); + } + + /** + * Returns the upper bound of the y-interval for the specified item in the + * series. + * + * @param index the item index. + * + * @return The upper bound of the y-interval. + * + * @since 1.0.5 + */ + public double getYHighValue(int index) { + YIntervalDataItem item = (YIntervalDataItem) getDataItem(index); + return item.getYHighValue(); + } + + /** + * Returns the data item at the specified index. + * + * @param index the item index. + * + * @return The data item. + */ + @Override + public ComparableObjectItem getDataItem(int index) { + return super.getDataItem(index); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YIntervalSeriesCollection.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YIntervalSeriesCollection.java new file mode 100755 index 0000000..1387e98 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YIntervalSeriesCollection.java @@ -0,0 +1,365 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * YIntervalSeriesCollection.java + * ------------------------------ + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * 27-Nov-2006 : Added clone() override (DG); + * 20-Feb-2007 : Added getYValue(), getStartYValue() and getEndYValue() + * methods (DG); + * 18-Jan-2008 : Added removeSeries() and removeAllSeries() methods (DG); + * 22-Apr-2008 : Implemented PublicCloneable (DG); + * 02-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; +import java.util.List; +import org.jfree.chart.util.ParamChecks; + +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.util.ObjectUtilities; +import org.jfree.util.PublicCloneable; + +/** + * A collection of {@link YIntervalSeries} objects. + * + * @since 1.0.3 + * + * @see YIntervalSeries + */ +public class YIntervalSeriesCollection extends AbstractIntervalXYDataset + implements IntervalXYDataset, PublicCloneable, Serializable { + + /** Storage for the data series. */ + private List data; + + /** + * Creates a new instance of YIntervalSeriesCollection. + */ + public YIntervalSeriesCollection() { + this.data = new java.util.ArrayList(); + } + + /** + * Adds a series to the collection and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param series the series (null not permitted). + */ + public void addSeries(YIntervalSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + this.data.add(series); + series.addChangeListener(this); + fireDatasetChanged(); + } + + /** + * Returns the number of series in the collection. + * + * @return The series count. + */ + @Override + public int getSeriesCount() { + return this.data.size(); + } + + /** + * Returns a series from the collection. + * + * @param series the series index (zero-based). + * + * @return The series. + * + * @throws IllegalArgumentException if series is not in the + * range 0 to getSeriesCount() - 1. + */ + public YIntervalSeries getSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + return (YIntervalSeries) this.data.get(series); + } + + /** + * Returns the key for a series. + * + * @param series the series index (in the range 0 to + * getSeriesCount() - 1). + * + * @return The key for a series. + * + * @throws IllegalArgumentException if series is not in the + * specified range. + */ + @Override + public Comparable getSeriesKey(int series) { + // defer argument checking + return getSeries(series).getKey(); + } + + /** + * Returns the number of items in the specified series. + * + * @param series the series (zero-based index). + * + * @return The item count. + * + * @throws IllegalArgumentException if series is not in the + * range 0 to getSeriesCount() - 1. + */ + @Override + public int getItemCount(int series) { + // defer argument checking + return getSeries(series).getItemCount(); + } + + /** + * Returns the x-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value. + */ + @Override + public Number getX(int series, int item) { + YIntervalSeries s = (YIntervalSeries) this.data.get(series); + return s.getX(item); + } + + /** + * Returns the y-value (as a double primitive) for an item within a + * series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getYValue(int series, int item) { + YIntervalSeries s = (YIntervalSeries) this.data.get(series); + return s.getYValue(item); + } + + /** + * Returns the start y-value (as a double primitive) for an item within a + * series. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The value. + */ + @Override + public double getStartYValue(int series, int item) { + YIntervalSeries s = (YIntervalSeries) this.data.get(series); + return s.getYLowValue(item); + } + + /** + * Returns the end y-value (as a double primitive) for an item within a + * series. + * + * @param series the series (zero-based index). + * @param item the item (zero-based index). + * + * @return The value. + */ + @Override + public double getEndYValue(int series, int item) { + YIntervalSeries s = (YIntervalSeries) this.data.get(series); + return s.getYHighValue(item); + } + + /** + * Returns the y-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The y-value. + */ + @Override + public Number getY(int series, int item) { + YIntervalSeries s = (YIntervalSeries) this.data.get(series); + return new Double(s.getYValue(item)); + } + + /** + * Returns the start x-value for an item within a series. This method + * maps directly to {@link #getX(int, int)}. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value. + */ + @Override + public Number getStartX(int series, int item) { + return getX(series, item); + } + + /** + * Returns the end x-value for an item within a series. This method + * maps directly to {@link #getX(int, int)}. + * + * @param series the series index. + * @param item the item index. + * + * @return The x-value. + */ + @Override + public Number getEndX(int series, int item) { + return getX(series, item); + } + + /** + * Returns the start y-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The start y-value. + */ + @Override + public Number getStartY(int series, int item) { + YIntervalSeries s = (YIntervalSeries) this.data.get(series); + return new Double(s.getYLowValue(item)); + } + + /** + * Returns the end y-value for an item within a series. + * + * @param series the series index. + * @param item the item index. + * + * @return The end y-value. + */ + @Override + public Number getEndY(int series, int item) { + YIntervalSeries s = (YIntervalSeries) this.data.get(series); + return new Double(s.getYHighValue(item)); + } + + /** + * Removes a series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param series the series index (zero-based). + * + * @since 1.0.10 + */ + public void removeSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds."); + } + YIntervalSeries ts = (YIntervalSeries) this.data.get(series); + ts.removeChangeListener(this); + this.data.remove(series); + fireDatasetChanged(); + } + + /** + * Removes a series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param series the series (null not permitted). + * + * @since 1.0.10 + */ + public void removeSeries(YIntervalSeries series) { + ParamChecks.nullNotPermitted(series, "series"); + if (this.data.contains(series)) { + series.removeChangeListener(this); + this.data.remove(series); + fireDatasetChanged(); + } + } + + /** + * Removes all the series from the collection and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @since 1.0.10 + */ + public void removeAllSeries() { + // Unregister the collection as a change listener to each series in + // the collection. + for (int i = 0; i < this.data.size(); i++) { + YIntervalSeries series = (YIntervalSeries) this.data.get(i); + series.removeChangeListener(this); + } + this.data.clear(); + fireDatasetChanged(); + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof YIntervalSeriesCollection)) { + return false; + } + YIntervalSeriesCollection that = (YIntervalSeriesCollection) obj; + return ObjectUtilities.equal(this.data, that.data); + } + + /** + * Returns a clone of this instance. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem. + */ + @Override + public Object clone() throws CloneNotSupportedException { + YIntervalSeriesCollection clone + = (YIntervalSeriesCollection) super.clone(); + clone.data = (List) ObjectUtilities.deepClone(this.data); + return clone; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YWithXInterval.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YWithXInterval.java new file mode 100755 index 0000000..11991bb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YWithXInterval.java @@ -0,0 +1,134 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * YWithXInterval.java + * ------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import java.io.Serializable; + +/** + * A y-value plus the bounds for the related x-interval. This curious + * combination exists as an implementation detail, to fit into the structure + * of the ComparableObjectSeries class. It would have been possible to + * simply reuse the {@link YInterval} class by assuming that the y-interval + * in fact represents the x-interval, however I decided it was better to + * duplicate some code in order to document the real intent. + * + * @since 1.0.3 + */ +public class YWithXInterval implements Serializable { + + /** The y-value. */ + private double y; + + /** The lower bound of the x-interval. */ + private double xLow; + + /** The upper bound of the x-interval. */ + private double xHigh; + + /** + * Creates a new instance of YWithXInterval. + * + * @param y the y-value. + * @param xLow the lower bound of the x-interval. + * @param xHigh the upper bound of the x-interval. + */ + public YWithXInterval(double y, double xLow, double xHigh) { + this.y = y; + this.xLow = xLow; + this.xHigh = xHigh; + } + + /** + * Returns the y-value. + * + * @return The y-value. + */ + public double getY() { + return this.y; + } + + /** + * Returns the lower bound of the x-interval. + * + * @return The lower bound of the x-interval. + */ + public double getXLow() { + return this.xLow; + } + + /** + * Returns the upper bound of the x-interval. + * + * @return The upper bound of the x-interval. + */ + public double getXHigh() { + return this.xHigh; + } + + /** + * Tests this instance for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof YWithXInterval)) { + return false; + } + YWithXInterval that = (YWithXInterval) obj; + if (this.y != that.y) { + return false; + } + if (this.xLow != that.xLow) { + return false; + } + if (this.xHigh != that.xHigh) { + return false; + } + return true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YisSymbolic.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YisSymbolic.java new file mode 100755 index 0000000..62a0cd8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/YisSymbolic.java @@ -0,0 +1,80 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * YisSymbolic.java + * ---------------- + * (C) Copyright 2006-2008, by Anthony Boulestreau and Contributors. + * + * Original Author: Anthony Boulestreau; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes (from 21-Aug-2001) + * -------------------------- + * 29-Mar-2002 : First version (AB); + * 07-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 18-Aug-2004 : Moved from org.jfree.data --> org.jfree.data.xy (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.data.xy; + +/** + * Represent a data set where Y is a symbolic values. Each symbolic value is + * linked with an Integer. + */ +public interface YisSymbolic { + + /** + * Returns the list of symbolic values. + * + * @return The symbolic values. + */ + public String[] getYSymbolicValues(); + + /** + * Returns the symbolic value of the data set specified by + * series and item parameters. + * + * @param series the series index (zero-based). + * @param item the item index (zero-based). + * + * @return The symbolic value. + */ + public String getYSymbolicValue(int series, int item); + + /** + * Returns the symbolic value linked with the specified + * Integer. + * + * @param val value of the integer linked with the symbolic value. + * + * @return The symbolic value. + */ + public String getYSymbolicValue(Integer val); + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/package.html new file mode 100755 index 0000000..dd4431a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/org/jfree/data/xy/package.html @@ -0,0 +1,6 @@ + + + +A package containing the {@link org.jfree.data.xy.XYDataset} interface and related classes. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/source/overview.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/overview.html new file mode 100755 index 0000000..f13f5d9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/source/overview.html @@ -0,0 +1,12 @@ + + + +JFreeChart is a free chart library for Java that can generate a +wide variety of charts for use in applications, applets and servlets. +

      +Please visit + http://www.jfree.org/jfreechart/index.html + +for the latest information about JFreeChart. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/README b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/README new file mode 100755 index 0000000..20a8f72 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/README @@ -0,0 +1,48 @@ +EXPERIMENTAL SWT CODE FOR JFREECHART +------------------------------------ + +07 November 2006 + +SWT is the Java Standard Widget Toolkit [1], an open source (released under the +Eclipse Public License) and portable library to create user interfaces. The +SWT interfaces will use native widget on any operating system it supports. + +This code provide support for using the JFreeChart library directly into +SWT Composites. Note that there is the alternative to use the SWT_AWT class +but it will run only with SUN JRE and Java 1.5 (and it is not native, so +potentially much slower). + +To compile this code, you will need to link it against the swt.jar of the +target os. Indeed while the API is totally cross platform, the implementation +is platform dependent since it calls on native widget if available (much +faster) and only rely on a Java implementation if it is not. An ant script: +build-swt.xml is provided to help you build the code. This file contains two +compile targets to build the following jar: + + * swtgraphics2d.jar - The generic classes not JFreeChart specific. + * jfreechart-1.0.x-swt.jar - The specific JFreeChart SWT classes. + +To get a successful build id pretty straightforward, download the SWT library +from eclipse.org [1]. Unpack the archive in the JFreeChart tree as libswt. +If you need to build for multiple OS, put all the SWT in there. For instance +(with SWT version 3.2): + +libswt + | + `--swt-linux-gtk-x86 + | | + | `--swt.jar + | `--libswt-gtk-3232.so + | `-- etc... + `--swt-win32-win32-x86 + | + `--swt.jar + `--swt-win32-3232.dll + +Then you need to edit the build-swt.xml script and change line 14 to what is +needed. Of course all of the paths are relative. You can change it to whatever +you like provided the path in the xml file is correct. Then just run: + +ant -buildfile build-swt.xml + +[1] http://www.eclipse.org/swt/ diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/ChartComposite.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/ChartComposite.java new file mode 100755 index 0000000..227da65 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/ChartComposite.java @@ -0,0 +1,1910 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * ChartComposite.java + * ------------------- + * (C) Copyright 2006-2012, by Henry Proudhon and Contributors. + * + * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * Cedric Chabanois (cchabanois AT no-log.org); + * Christoph Beck; + * Sebastiao Correia (patch 3463807); + * Jonas Rüttimann (bug fix 2963199); + * Bernard Sarter; + * + * Changes + * ------- + * 19-Jun-2006 : New class (HP); + * 06-Nov-2006 : Added accessor methods for zoomInFactor and zoomOutFactor (DG); + * 28-Nov-2006 : Added support for trace lines (HP); + * 30-Nov-2006 : Improved zoom box handling (HP); + * 06-Dec-2006 : Added (simplified) tool tip support (HP); + * 11-Dec-2006 : Fixed popup menu location by fgiust, bug 1612770 (HP); + * 31-Jan-2007 : Fixed some issues with the trace lines, fixed cross hair not + * being drawn, added getter and setter methods for the trace + * lines (HP); + * 07-Apr-2007 : Changed this.redraw() into canvas.redraw() to fix redraw + * problems (HP); + * 19-May-2007 : Small fix in paintControl to check for null charts, bug + * 1719260 (HP); + * 19-May-2007 : Corrected bug with scaling when the drawing region is larger + * than maximum draw width/height (HP); + * 23-May-2007 : Added some dispose call to free SWT resources, patch sent by + * Cédric Chabanois (CC); + * 06-Jun-2007 : Fixed minor issues with tooltips. bug reported and fix + * proposed by Christoph Beck, bug 1726404 (HP); + * 22-Oct-2007 : Added addChartMouseListener and removeChartMouseListener + * methods as suggested by Christoph Beck, bug 1742002 (HP); + * 22-Oct-2007 : Fixed bug in zooming with multiple plots (HP); + * 22-Oct-2007 : Check for null zoom point when restoring auto range and domain + * bounds (HP); + * 22-Oct-2007 : Pass mouse moved events to listening ChartMouseListeners (HP); + * 22-Oct-2007 : Refactored class, now implements PaintListener, MouseListener, + * MouseMoveListener. Made the chart field be private again and + * added new method addSWTListener to allow custom behavior. + * 14-Nov-2007 : Create canvas with SWT.DOUBLE_BUFFER, added + * getChartRenderingInfo(), is/setDomainZoomable() and + * is/setRangeZoomable() as per feature request (DG); + * 11-Jul-2008 : Bug 1994355 fix (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * 08-Jan-2012 : Dispose popup-menu (patch 3463807 by Sebastiao Correia) (DG) + * 05-Jul-2012 : Fix SWT print (bug 2963199 by Jonas Rüttimann); + * 26-Jul-2013 : Fix memory leak (patch in forum from Bernard Sarter) (DG); + * + */ + +package org.jfree.experimental.chart.swt; + +import java.awt.Graphics; +import java.awt.Point; +import java.awt.RenderingHints; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.print.PageFormat; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.io.File; +import java.io.IOException; +import java.util.EventListener; +import java.util.ResourceBundle; + +import javax.swing.event.EventListenerList; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ControlListener; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.HelpListener; +import org.eclipse.swt.events.KeyListener; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.MouseListener; +import org.eclipse.swt.events.MouseMoveListener; +import org.eclipse.swt.events.MouseTrackListener; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.events.TraverseListener; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; +import org.jfree.chart.ChartMouseEvent; +import org.jfree.chart.ChartMouseListener; +import org.jfree.chart.ChartRenderingInfo; +import org.jfree.chart.ChartUtilities; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.entity.ChartEntity; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.event.ChartProgressEvent; +import org.jfree.chart.event.ChartProgressListener; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.PlotRenderingInfo; +import org.jfree.chart.plot.ValueAxisPlot; +import org.jfree.chart.plot.Zoomable; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.experimental.chart.swt.editor.SWTChartEditor; +import org.jfree.experimental.swt.SWTGraphics2D; +import org.jfree.experimental.swt.SWTUtils; + +/** + * A SWT GUI composite for displaying a {@link JFreeChart} object. + *

      + * The composite listens to the chart to receive notification of changes to any + * component of the chart. The chart is redrawn automatically whenever this + * notification is received. + */ +public class ChartComposite extends Composite implements ChartChangeListener, + ChartProgressListener, PaintListener, SelectionListener, + MouseListener, MouseMoveListener, Printable { + + /** Default setting for buffer usage. */ + public static final boolean DEFAULT_BUFFER_USED = false; + + /** The default panel width. */ + public static final int DEFAULT_WIDTH = 680; + + /** The default panel height. */ + public static final int DEFAULT_HEIGHT = 420; + + /** The default limit below which chart scaling kicks in. */ + public static final int DEFAULT_MINIMUM_DRAW_WIDTH = 300; + + /** The default limit below which chart scaling kicks in. */ + public static final int DEFAULT_MINIMUM_DRAW_HEIGHT = 200; + + /** The default limit below which chart scaling kicks in. */ + public static final int DEFAULT_MAXIMUM_DRAW_WIDTH = 800; + + /** The default limit below which chart scaling kicks in. */ + public static final int DEFAULT_MAXIMUM_DRAW_HEIGHT = 600; + + /** The minimum size required to perform a zoom on a rectangle */ + public static final int DEFAULT_ZOOM_TRIGGER_DISTANCE = 10; + + /** Properties action command. */ + public static final String PROPERTIES_COMMAND = "PROPERTIES"; + + /** Save action command. */ + public static final String SAVE_COMMAND = "SAVE"; + + /** Print action command. */ + public static final String PRINT_COMMAND = "PRINT"; + + /** Zoom in (both axes) action command. */ + public static final String ZOOM_IN_BOTH_COMMAND = "ZOOM_IN_BOTH"; + + /** Zoom in (domain axis only) action command. */ + public static final String ZOOM_IN_DOMAIN_COMMAND = "ZOOM_IN_DOMAIN"; + + /** Zoom in (range axis only) action command. */ + public static final String ZOOM_IN_RANGE_COMMAND = "ZOOM_IN_RANGE"; + + /** Zoom out (both axes) action command. */ + public static final String ZOOM_OUT_BOTH_COMMAND = "ZOOM_OUT_BOTH"; + + /** Zoom out (domain axis only) action command. */ + public static final String ZOOM_OUT_DOMAIN_COMMAND = "ZOOM_DOMAIN_BOTH"; + + /** Zoom out (range axis only) action command. */ + public static final String ZOOM_OUT_RANGE_COMMAND = "ZOOM_RANGE_BOTH"; + + /** Zoom reset (both axes) action command. */ + public static final String ZOOM_RESET_BOTH_COMMAND = "ZOOM_RESET_BOTH"; + + /** Zoom reset (domain axis only) action command. */ + public static final String ZOOM_RESET_DOMAIN_COMMAND = "ZOOM_RESET_DOMAIN"; + + /** Zoom reset (range axis only) action command. */ + public static final String ZOOM_RESET_RANGE_COMMAND = "ZOOM_RESET_RANGE"; + + /** The chart that is displayed in the panel. */ + private JFreeChart chart; + + /** The canvas to display the chart. */ + private Canvas canvas; + + /** Storage for registered (chart) mouse listeners. */ + private EventListenerList chartMouseListeners; + + /** A flag that controls whether or not the off-screen buffer is used. */ + private boolean useBuffer; + + /** A flag that indicates that the buffer should be refreshed. */ + private boolean refreshBuffer; + + /** A flag that indicates that the tooltips should be displayed. */ + private boolean displayToolTips; + + /** A buffer for the rendered chart. */ + private org.eclipse.swt.graphics.Image chartBuffer; + + /** The height of the chart buffer. */ + private int chartBufferHeight; + + /** The width of the chart buffer. */ + private int chartBufferWidth; + + /** + * The minimum width for drawing a chart (uses scaling for smaller widths). + */ + private int minimumDrawWidth; + + /** + * The minimum height for drawing a chart (uses scaling for smaller + * heights). + */ + private int minimumDrawHeight; + + /** + * The maximum width for drawing a chart (uses scaling for bigger + * widths). + */ + private int maximumDrawWidth; + + /** + * The maximum height for drawing a chart (uses scaling for bigger + * heights). + */ + private int maximumDrawHeight; + + /** The popup menu for the frame. */ + private Menu popup; + + /** The drawing info collected the last time the chart was drawn. */ + private ChartRenderingInfo info; + + /** The chart anchor point. */ + private Point2D anchor; + + /** The scale factor used to draw the chart. */ + private double scaleX; + + /** The scale factor used to draw the chart. */ + private double scaleY; + + /** The plot orientation. */ + private PlotOrientation orientation = PlotOrientation.VERTICAL; + + /** A flag that controls whether or not domain zooming is enabled. */ + private boolean domainZoomable = false; + + /** A flag that controls whether or not range zooming is enabled. */ + private boolean rangeZoomable = false; + + /** + * The zoom rectangle starting point (selected by the user with a mouse + * click). This is a point on the screen, not the chart (which may have + * been scaled up or down to fit the panel). + */ + private org.eclipse.swt.graphics.Point zoomPoint = null; + + /** The zoom rectangle (selected by the user with the mouse). */ + private transient Rectangle zoomRectangle = null; + + /** Controls if the zoom rectangle is drawn as an outline or filled. */ + //TODO private boolean fillZoomRectangle = true; + + /** The minimum distance required to drag the mouse to trigger a zoom. */ + private int zoomTriggerDistance; + + /** A flag that controls whether or not horizontal tracing is enabled. */ + private boolean horizontalAxisTrace = false; + + /** A flag that controls whether or not vertical tracing is enabled. */ + private boolean verticalAxisTrace = false; + + /** A vertical trace line. */ + private transient int verticalTraceLineX; + + /** A horizontal trace line. */ + private transient int horizontalTraceLineY; + + /** Menu item for zooming in on a chart (both axes). */ + private MenuItem zoomInBothMenuItem; + + /** Menu item for zooming in on a chart (domain axis). */ + private MenuItem zoomInDomainMenuItem; + + /** Menu item for zooming in on a chart (range axis). */ + private MenuItem zoomInRangeMenuItem; + + /** Menu item for zooming out on a chart. */ + private MenuItem zoomOutBothMenuItem; + + /** Menu item for zooming out on a chart (domain axis). */ + private MenuItem zoomOutDomainMenuItem; + + /** Menu item for zooming out on a chart (range axis). */ + private MenuItem zoomOutRangeMenuItem; + + /** Menu item for resetting the zoom (both axes). */ + private MenuItem zoomResetBothMenuItem; + + /** Menu item for resetting the zoom (domain axis only). */ + private MenuItem zoomResetDomainMenuItem; + + /** Menu item for resetting the zoom (range axis only). */ + private MenuItem zoomResetRangeMenuItem; + + /** A flag that controls whether or not file extensions are enforced. */ + private boolean enforceFileExtensions; + + /** The factor used to zoom in on an axis range. */ + private double zoomInFactor = 0.5; + + /** The factor used to zoom out on an axis range. */ + private double zoomOutFactor = 2.0; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.LocalizationBundle"); + + /** + * Create a new chart composite with a default FillLayout. + * This way, when drawn, the chart will fill all the space. + * @param comp The parent. + * @param style The style of the composite. + */ + public ChartComposite(Composite comp, int style) { + this(comp, + style, + null, + DEFAULT_WIDTH, + DEFAULT_HEIGHT, + DEFAULT_MINIMUM_DRAW_WIDTH, + DEFAULT_MINIMUM_DRAW_HEIGHT, + DEFAULT_MAXIMUM_DRAW_WIDTH, + DEFAULT_MAXIMUM_DRAW_HEIGHT, + DEFAULT_BUFFER_USED, + true, // properties + true, // save + true, // print + true, // zoom + true // tooltips + ); + } + + /** + * Constructs a panel that displays the specified chart. + * + * @param comp The parent. + * @param style The style of the composite. + * @param chart the chart. + */ + public ChartComposite(Composite comp, int style, JFreeChart chart) { + this(comp, + style, + chart, + DEFAULT_WIDTH, + DEFAULT_HEIGHT, + DEFAULT_MINIMUM_DRAW_WIDTH, + DEFAULT_MINIMUM_DRAW_HEIGHT, + DEFAULT_MAXIMUM_DRAW_WIDTH, + DEFAULT_MAXIMUM_DRAW_HEIGHT, + DEFAULT_BUFFER_USED, + true, // properties + true, // save + true, // print + true, // zoom + true // tooltips + ); + } + + /** + * Constructs a panel containing a chart. + * + * @param comp The parent. + * @param style The style of the composite. + * @param chart the chart. + * @param useBuffer a flag controlling whether or not an off-screen buffer + * is used. + */ + public ChartComposite(Composite comp, int style, JFreeChart chart, + boolean useBuffer) { + + this(comp, style, chart, + DEFAULT_WIDTH, + DEFAULT_HEIGHT, + DEFAULT_MINIMUM_DRAW_WIDTH, + DEFAULT_MINIMUM_DRAW_HEIGHT, + DEFAULT_MAXIMUM_DRAW_WIDTH, + DEFAULT_MAXIMUM_DRAW_HEIGHT, + useBuffer, + true, // properties + true, // save + true, // print + true, // zoom + true // tooltips + ); + } + + /** + * Constructs a JFreeChart panel. + * + * @param comp The parent. + * @param style The style of the composite. + * @param chart the chart. + * @param properties a flag indicating whether or not the chart property + * editor should be available via the popup menu. + * @param save a flag indicating whether or not save options should be + * available via the popup menu. + * @param print a flag indicating whether or not the print option + * should be available via the popup menu. + * @param zoom a flag indicating whether or not zoom options should + * be added to the popup menu. + * @param tooltips a flag indicating whether or not tooltips should be + * enabled for the chart. + */ + public ChartComposite( + Composite comp, + int style, + JFreeChart chart, + boolean properties, + boolean save, + boolean print, + boolean zoom, + boolean tooltips) { + this( + comp, + style, + chart, + DEFAULT_WIDTH, + DEFAULT_HEIGHT, + DEFAULT_MINIMUM_DRAW_WIDTH, + DEFAULT_MINIMUM_DRAW_HEIGHT, + DEFAULT_MAXIMUM_DRAW_WIDTH, + DEFAULT_MAXIMUM_DRAW_HEIGHT, + DEFAULT_BUFFER_USED, + properties, + save, + print, + zoom, + tooltips + ); + } + + /** + * Constructs a JFreeChart panel. + * + * @param comp The parent. + * @param style The style of the composite. + * @param jfreechart the chart. + * @param width the preferred width of the panel. + * @param height the preferred height of the panel. + * @param minimumDrawW the minimum drawing width. + * @param minimumDrawH the minimum drawing height. + * @param maximumDrawW the maximum drawing width. + * @param maximumDrawH the maximum drawing height. + * @param usingBuffer a flag that indicates whether to use the off-screen + * buffer to improve performance (at the expense of + * memory). + * @param properties a flag indicating whether or not the chart property + * editor should be available via the popup menu. + * @param save a flag indicating whether or not save options should be + * available via the popup menu. + * @param print a flag indicating whether or not the print option + * should be available via the popup menu. + * @param zoom a flag indicating whether or not zoom options should be + * added to the popup menu. + * @param tooltips a flag indicating whether or not tooltips should be + * enabled for the chart. + */ + public ChartComposite(Composite comp, + int style, + JFreeChart jfreechart, + int width, + int height, + int minimumDrawW, + int minimumDrawH, + int maximumDrawW, + int maximumDrawH, + boolean usingBuffer, + boolean properties, + boolean save, + boolean print, + boolean zoom, + boolean tooltips) { + super(comp, style); + setChart(jfreechart); + this.chartMouseListeners = new EventListenerList(); + setLayout(new FillLayout()); + this.info = new ChartRenderingInfo(); + this.useBuffer = usingBuffer; + this.refreshBuffer = false; + this.minimumDrawWidth = minimumDrawW; + this.minimumDrawHeight = minimumDrawH; + this.maximumDrawWidth = maximumDrawW; + this.maximumDrawHeight = maximumDrawH; + this.zoomTriggerDistance = DEFAULT_ZOOM_TRIGGER_DISTANCE; + setDisplayToolTips(tooltips); + // create the canvas and add the required listeners + this.canvas = new Canvas(this, SWT.DOUBLE_BUFFERED | SWT.NO_BACKGROUND); + this.canvas.addPaintListener(this); + this.canvas.addMouseListener(this); + this.canvas.addMouseMoveListener(this); + this.canvas.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + org.eclipse.swt.graphics.Image img; + img = (org.eclipse.swt.graphics.Image) canvas.getData("double-buffer-image"); + if (img != null) { + img.dispose(); + } + } + }); + + // set up popup menu... + this.popup = null; + if (properties || save || print || zoom) + this.popup = createPopupMenu(properties, save, print, zoom); + + this.enforceFileExtensions = true; + } + + /** + * Returns the X scale factor for the chart. This will be 1.0 if no + * scaling has been used. + * + * @return The scale factor. + */ + public double getScaleX() { + return this.scaleX; + } + + /** + * Returns the Y scale factory for the chart. This will be 1.0 if no + * scaling has been used. + * + * @return The scale factor. + */ + public double getScaleY() { + return this.scaleY; + } + + /** + * Returns the anchor point. + * + * @return The anchor point (possibly null). + */ + public Point2D getAnchor() { + return this.anchor; + } + + /** + * Sets the anchor point. This method is provided for the use of + * subclasses, not end users. + * + * @param anchor the anchor point (null permitted). + */ + protected void setAnchor(Point2D anchor) { + this.anchor = anchor; + } + + /** + * Returns the chart contained in the panel. + * + * @return The chart (possibly null). + */ + public JFreeChart getChart() { + return this.chart; + } + + /** + * Sets the chart that is displayed in the panel. + * + * @param chart the chart (null permitted). + */ + public void setChart(JFreeChart chart) { + // stop listening for changes to the existing chart + if (this.chart != null) { + this.chart.removeChangeListener(this); + this.chart.removeProgressListener(this); + } + + // add the new chart + this.chart = chart; + if (chart != null) { + this.chart.addChangeListener(this); + this.chart.addProgressListener(this); + Plot plot = chart.getPlot(); + this.domainZoomable = false; + this.rangeZoomable = false; + if (plot instanceof Zoomable) { + Zoomable z = (Zoomable) plot; + this.domainZoomable = z.isDomainZoomable(); + this.rangeZoomable = z.isRangeZoomable(); + this.orientation = z.getOrientation(); + } + } + else { + this.domainZoomable = false; + this.rangeZoomable = false; + } + if (this.useBuffer) { + this.refreshBuffer = true; + } + } + + /** + * Returns the chart rendering info from the most recent chart redraw. + * + * @return The chart rendering info (possibly null). + */ + public ChartRenderingInfo getChartRenderingInfo() { + return this.info; + } + + /** + * Returns the flag that determines whether or not zooming is enabled for + * the domain axis. + * + * @return A boolean. + */ + public boolean isDomainZoomable() { + return this.domainZoomable; + } + + /** + * Sets the flag that controls whether or not zooming is enable for the + * domain axis. A check is made to ensure that the current plot supports + * zooming for the domain values. + * + * @param flag true enables zooming if possible. + */ + public void setDomainZoomable(boolean flag) { + if (flag) { + Plot plot = this.chart.getPlot(); + if (plot instanceof Zoomable) { + Zoomable z = (Zoomable) plot; + this.domainZoomable = flag && (z.isDomainZoomable()); + } + } + else { + this.domainZoomable = false; + } + } + + /** + * Returns the flag that determines whether or not zooming is enabled for + * the range axis. + * + * @return A boolean. + */ + public boolean isRangeZoomable() { + return this.rangeZoomable; + } + + /** + * A flag that controls mouse-based zooming on the vertical axis. + * + * @param flag true enables zooming. + */ + public void setRangeZoomable(boolean flag) { + if (flag) { + Plot plot = this.chart.getPlot(); + if (plot instanceof Zoomable) { + Zoomable z = (Zoomable) plot; + this.rangeZoomable = flag && (z.isRangeZoomable()); + } + } + else { + this.rangeZoomable = false; + } + } + + /** + * Returns the zoom in factor. + * + * @return The zoom in factor. + * + * @see #setZoomInFactor(double) + */ + public double getZoomInFactor() { + return this.zoomInFactor; + } + + /** + * Sets the zoom in factor. + * + * @param factor the factor. + * + * @see #getZoomInFactor() + */ + public void setZoomInFactor(double factor) { + this.zoomInFactor = factor; + } + + /** + * Returns the zoom out factor. + * + * @return The zoom out factor. + * + * @see #setZoomOutFactor(double) + */ + public double getZoomOutFactor() { + return this.zoomOutFactor; + } + + /** + * Sets the zoom out factor. + * + * @param factor the factor. + * + * @see #getZoomOutFactor() + */ + public void setZoomOutFactor(double factor) { + this.zoomOutFactor = factor; + } + + /** + * Displays a dialog that allows the user to edit the properties for the + * current chart. + */ + private void attemptEditChartProperties() { + SWTChartEditor editor = new SWTChartEditor(this.canvas.getDisplay(), + this.chart); + //ChartEditorManager.getChartEditor(canvas.getDisplay(), this.chart); + editor.open(); + } + + /** + * Returns true if file extensions should be enforced, and + * false otherwise. + * + * @return The flag. + */ + public boolean isEnforceFileExtensions() { + return this.enforceFileExtensions; + } + + /** + * Sets a flag that controls whether or not file extensions are enforced. + * + * @param enforce the new flag value. + */ + public void setEnforceFileExtensions(boolean enforce) { + this.enforceFileExtensions = enforce; + } + + /** + * Opens a file chooser and gives the user an opportunity to save the chart + * in PNG format. + * + * @throws IOException if there is an I/O error. + */ + public void doSaveAs() throws IOException { + FileDialog fileDialog = new FileDialog(this.canvas.getShell(), + SWT.SAVE); + String[] extensions = {"*.png"}; + fileDialog.setFilterExtensions(extensions); + String filename = fileDialog.open(); + if (filename != null) { + if (isEnforceFileExtensions()) { + if (!filename.endsWith(".png")) { + filename = filename + ".png"; + } + } + //TODO replace getSize by getBounds ? + ChartUtilities.saveChartAsPNG(new File(filename), this.chart, + this.canvas.getSize().x, this.canvas.getSize().y); + } + } + + /** + * Returns a point based on (x, y) but constrained to be within the bounds + * of the given rectangle. This method could be moved to JCommon. + * + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param area the rectangle (null not permitted). + * + * @return A point within the rectangle. + */ + private org.eclipse.swt.graphics.Point getPointInRectangle(int x, int y, + Rectangle area) { + x = Math.max(area.x, Math.min(x, area.x + area.width)); + y = Math.max(area.y, Math.min(y, area.y + area.height)); + return new org.eclipse.swt.graphics.Point(x, y); + } + + /** + * Zooms in on an anchor point (specified in screen coordinate space). + * + * @param x the x value (in screen coordinates). + * @param y the y value (in screen coordinates). + */ + public void zoomInBoth(double x, double y) { + zoomInDomain(x, y); + zoomInRange(x, y); + } + + /** + * Decreases the length of the domain axis, centered about the given + * coordinate on the screen. The length of the domain axis is reduced + * by the value of {@link #getZoomInFactor()}. + * + * @param x the x coordinate (in screen coordinates). + * @param y the y-coordinate (in screen coordinates). + */ + public void zoomInDomain(double x, double y) { + Plot p = this.chart.getPlot(); + if (p instanceof Zoomable) + { + Zoomable plot = (Zoomable) p; + plot.zoomDomainAxes(this.zoomInFactor, this.info.getPlotInfo(), + translateScreenToJava2D(new Point((int) x, (int) y))); + } + } + + /** + * Decreases the length of the range axis, centered about the given + * coordinate on the screen. The length of the range axis is reduced by + * the value of {@link #getZoomInFactor()}. + * + * @param x the x-coordinate (in screen coordinates). + * @param y the y coordinate (in screen coordinates). + */ + public void zoomInRange(double x, double y) { + Plot p = this.chart.getPlot(); + if (p instanceof Zoomable) { + Zoomable z = (Zoomable) p; + z.zoomRangeAxes(this.zoomInFactor, this.info.getPlotInfo(), + translateScreenToJava2D(new Point((int) x, (int) y))); + } + } + + /** + * Zooms out on an anchor point (specified in screen coordinate space). + * + * @param x the x value (in screen coordinates). + * @param y the y value (in screen coordinates). + */ + public void zoomOutBoth(double x, double y) { + zoomOutDomain(x, y); + zoomOutRange(x, y); + } + + /** + * Increases the length of the domain axis, centered about the given + * coordinate on the screen. The length of the domain axis is increased + * by the value of {@link #getZoomOutFactor()}. + * + * @param x the x coordinate (in screen coordinates). + * @param y the y-coordinate (in screen coordinates). + */ + public void zoomOutDomain(double x, double y) { + Plot p = this.chart.getPlot(); + if (p instanceof Zoomable) { + Zoomable z = (Zoomable) p; + z.zoomDomainAxes(this.zoomOutFactor, this.info.getPlotInfo(), + translateScreenToJava2D(new Point((int) x, (int) y))); + } + } + + /** + * Increases the length the range axis, centered about the given + * coordinate on the screen. The length of the range axis is increased + * by the value of {@link #getZoomOutFactor()}. + * + * @param x the x coordinate (in screen coordinates). + * @param y the y-coordinate (in screen coordinates). + */ + public void zoomOutRange(double x, double y) { + Plot p = this.chart.getPlot(); + if (p instanceof Zoomable) { + Zoomable z = (Zoomable) p; + z.zoomRangeAxes(this.zoomOutFactor, this.info.getPlotInfo(), + translateScreenToJava2D(new Point((int) x, (int) y))); + } + } + + /** + * Zooms in on a selected region. + * + * @param selection the selected region. + */ + public void zoom(Rectangle selection) { + + // get the origin of the zoom selection in the Java2D space used for + // drawing the chart (that is, before any scaling to fit the panel) + Point2D selectOrigin = translateScreenToJava2D( + new Point(selection.x, selection.y)); + PlotRenderingInfo plotInfo = this.info.getPlotInfo(); + Rectangle scaledDataArea = getScreenDataArea( + (selection.x + selection.width / 2), + (selection.y + selection.height / 2)); + if ((selection.height > 0) && (selection.width > 0)) { + + double hLower = (selection.x - scaledDataArea.x) + / (double) scaledDataArea.width; + double hUpper = (selection.x + selection.width - scaledDataArea.x) + / (double) scaledDataArea.width; + double vLower = (scaledDataArea.y + scaledDataArea.height + - selection.y - selection.height) + / (double) scaledDataArea.height; + double vUpper = (scaledDataArea.y + scaledDataArea.height + - selection.y) / (double) scaledDataArea.height; + Plot p = this.chart.getPlot(); + if (p instanceof Zoomable) { + Zoomable z = (Zoomable) p; + if (z.getOrientation() == PlotOrientation.HORIZONTAL) { + z.zoomDomainAxes(vLower, vUpper, plotInfo, selectOrigin); + z.zoomRangeAxes(hLower, hUpper, plotInfo, selectOrigin); + } + else { + z.zoomDomainAxes(hLower, hUpper, plotInfo, selectOrigin); + z.zoomRangeAxes(vLower, vUpper, plotInfo, selectOrigin); + } + } + + } + + } + + /** + * Receives notification of changes to the chart, and redraws the chart. + * + * @param event details of the chart change event. + */ + public void chartChanged(ChartChangeEvent event) { + this.refreshBuffer = true; + Plot plot = this.chart.getPlot(); + if (plot instanceof Zoomable) { + Zoomable z = (Zoomable) plot; + this.orientation = z.getOrientation(); + } + this.canvas.redraw(); + } + + /** + * Forces a redraw of the canvas by invoking a new PaintEvent. + */ + public void forceRedraw() { + Event ev = new Event(); + ev.gc = new GC(this.canvas); + ev.x = 0; + ev.y = 0; + ev.width = this.canvas.getBounds().width; + ev.height = this.canvas.getBounds().height; + ev.count = 0; + this.canvas.notifyListeners(SWT.Paint, ev); + ev.gc.dispose(); + } + + /** + * Adds a listener to the list of objects listening for chart mouse events. + * + * @param listener the listener (null not permitted). + */ + public void addChartMouseListener(ChartMouseListener listener) { + this.chartMouseListeners.add(ChartMouseListener.class, listener); + } + + /** + * Removes a listener from the list of objects listening for chart mouse + * events. + * + * @param listener the listener. + */ + public void removeChartMouseListener(ChartMouseListener listener) { + this.chartMouseListeners.remove(ChartMouseListener.class, listener); + } + + /** + * Receives notification of a chart progress event. + * + * @param event the event. + */ + public void chartProgress(ChartProgressEvent event) { + // does nothing - override if necessary + } + + /** + * Restores the auto-range calculation on both axes. + */ + public void restoreAutoBounds() { + restoreAutoDomainBounds(); + restoreAutoRangeBounds(); + } + + /** + * Restores the auto-range calculation on the domain axis. + */ + public void restoreAutoDomainBounds() { + Plot p = this.chart.getPlot(); + if (p instanceof Zoomable) { + Zoomable z = (Zoomable) p; + // we need to guard against this.zoomPoint being null + org.eclipse.swt.graphics.Point zp = + (this.zoomPoint != null ? this.zoomPoint + : new org.eclipse.swt.graphics.Point(0, 0)); + z.zoomDomainAxes(0.0, this.info.getPlotInfo(), + SWTUtils.toAwtPoint(zp)); + } + } + + /** + * Restores the auto-range calculation on the range axis. + */ + public void restoreAutoRangeBounds() { + Plot p = this.chart.getPlot(); + if (p instanceof ValueAxisPlot) { + Zoomable z = (Zoomable) p; + // we need to guard against this.zoomPoint being null + org.eclipse.swt.graphics.Point zp = + (this.zoomPoint != null ? this.zoomPoint + : new org.eclipse.swt.graphics.Point(0, 0)); + z.zoomRangeAxes(0.0, this.info.getPlotInfo(), + SWTUtils.toAwtPoint(zp)); + } + } + + /** + * Applies any scaling that is in effect for the chart drawing to the + * given rectangle. + * + * @param rect the rectangle. + * + * @return A new scaled rectangle. + */ + public Rectangle scale(Rectangle2D rect) { + Rectangle insets = this.getClientArea(); + int x = (int) Math.round(rect.getX() * getScaleX()) + insets.x; + int y = (int) Math.round(rect.getY() * this.getScaleY()) + insets.y; + int w = (int) Math.round(rect.getWidth() * this.getScaleX()); + int h = (int) Math.round(rect.getHeight() * this.getScaleY()); + return new Rectangle(x, y, w, h); + } + + /** + * Returns the data area for the chart (the area inside the axes) with the + * current scaling applied (that is, the area as it appears on screen). + * + * @return The scaled data area. + */ + public Rectangle getScreenDataArea() { + Rectangle2D dataArea = this.info.getPlotInfo().getDataArea(); + Rectangle clientArea = this.getClientArea(); + int x = (int) (dataArea.getX() * this.scaleX + clientArea.x); + int y = (int) (dataArea.getY() * this.scaleY + clientArea.y); + int w = (int) (dataArea.getWidth() * this.scaleX); + int h = (int) (dataArea.getHeight() * this.scaleY); + return new Rectangle(x, y, w, h); + } + + /** + * Returns the data area (the area inside the axes) for the plot or subplot, + * with the current scaling applied. + * + * @param x the x-coordinate (for subplot selection). + * @param y the y-coordinate (for subplot selection). + * + * @return The scaled data area. + */ + public Rectangle getScreenDataArea(int x, int y) { + PlotRenderingInfo plotInfo = this.info.getPlotInfo(); + Rectangle result; + if (plotInfo.getSubplotCount() == 0) + result = getScreenDataArea(); + else { + // get the origin of the zoom selection in the Java2D space used for + // drawing the chart (that is, before any scaling to fit the panel) + Point2D selectOrigin = translateScreenToJava2D(new Point(x, y)); + int subplotIndex = plotInfo.getSubplotIndex(selectOrigin); + if (subplotIndex == -1) { + return null; + } + result = scale(plotInfo.getSubplotInfo(subplotIndex).getDataArea()); + } + return result; + } + + /** + * Translates a Java2D point on the chart to a screen location. + * + * @param java2DPoint the Java2D point. + * + * @return The screen location. + */ + public Point translateJava2DToScreen(Point2D java2DPoint) { + Rectangle insets = this.getClientArea(); + int x = (int) (java2DPoint.getX() * this.scaleX + insets.x); + int y = (int) (java2DPoint.getY() * this.scaleY + insets.y); + return new Point(x, y); + } + + /** + * Translates a screen location to a Java SWT point. + * + * @param screenPoint the screen location. + * + * @return The Java2D coordinates. + */ + public Point translateScreenToJavaSWT(Point screenPoint) { + Rectangle insets = this.getClientArea(); + int x = (int) ((screenPoint.x - insets.x) / this.scaleX); + int y = (int) ((screenPoint.y - insets.y) / this.scaleY); + return new Point(x, y); + } + + /** + * Translates a screen location to a Java2D point. + * + * @param screenPoint the screen location. + * + * @return The Java2D coordinates. + */ + public Point2D translateScreenToJava2D(Point screenPoint) { + Rectangle insets = this.getClientArea(); + int x = (int) ((screenPoint.x - insets.x) / this.scaleX); + int y = (int) ((screenPoint.y - insets.y) / this.scaleY); + return new Point2D.Double(x, y); + } + + /** + * Returns the flag that controls whether or not a horizontal axis trace + * line is drawn over the plot area at the current mouse location. + * + * @return A boolean. + */ + public boolean getHorizontalAxisTrace() { + return this.horizontalAxisTrace; + } + + /** + * A flag that controls trace lines on the horizontal axis. + * + * @param flag true enables trace lines for the mouse + * pointer on the horizontal axis. + */ + public void setHorizontalAxisTrace(boolean flag) { + this.horizontalAxisTrace = flag; + } + + /** + * Returns the flag that controls whether or not a vertical axis trace + * line is drawn over the plot area at the current mouse location. + * + * @return A boolean. + */ + public boolean getVerticalAxisTrace() { + return this.verticalAxisTrace; + } + + /** + * A flag that controls trace lines on the vertical axis. + * + * @param flag true enables trace lines for the mouse + * pointer on the vertical axis. + */ + public void setVerticalAxisTrace(boolean flag) { + this.verticalAxisTrace = flag; + } + + /** + * @param displayToolTips the displayToolTips to set + */ + public void setDisplayToolTips(boolean displayToolTips) { + this.displayToolTips = displayToolTips; + } + + /** + * Returns a string for the tooltip. + * + * @param e the mouse event. + * + * @return A tool tip or null if no tooltip is available. + */ + public String getToolTipText(org.eclipse.swt.events.MouseEvent e) { + String result = null; + if (this.info != null) { + EntityCollection entities = this.info.getEntityCollection(); + if (entities != null) { + Rectangle insets = getClientArea(); + ChartEntity entity = entities.getEntity( + (int) ((e.x - insets.x) / this.scaleX), + (int) ((e.y - insets.y) / this.scaleY)); + if (entity != null) { + result = entity.getToolTipText(); + } + } + } + return result; + + } + + /** + * The idea is to modify the zooming options depending on the type of chart + * being displayed by the panel. + * + * @param x horizontal position of the popup. + * @param y vertical position of the popup. + */ + protected void displayPopupMenu(int x, int y) { + if (this.popup != null) { + // go through each zoom menu item and decide whether or not to + // enable it... + Plot plot = this.chart.getPlot(); + boolean isDomainZoomable = false; + boolean isRangeZoomable = false; + if (plot instanceof Zoomable) { + Zoomable z = (Zoomable) plot; + isDomainZoomable = z.isDomainZoomable(); + isRangeZoomable = z.isRangeZoomable(); + } + if (this.zoomInDomainMenuItem != null) { + this.zoomInDomainMenuItem.setEnabled(isDomainZoomable); + } + if (this.zoomOutDomainMenuItem != null) { + this.zoomOutDomainMenuItem.setEnabled(isDomainZoomable); + } + if (this.zoomResetDomainMenuItem != null) { + this.zoomResetDomainMenuItem.setEnabled(isDomainZoomable); + } + + if (this.zoomInRangeMenuItem != null) { + this.zoomInRangeMenuItem.setEnabled(isRangeZoomable); + } + if (this.zoomOutRangeMenuItem != null) { + this.zoomOutRangeMenuItem.setEnabled(isRangeZoomable); + } + + if (this.zoomResetRangeMenuItem != null) { + this.zoomResetRangeMenuItem.setEnabled(isRangeZoomable); + } + + if (this.zoomInBothMenuItem != null) { + this.zoomInBothMenuItem.setEnabled(isDomainZoomable + & isRangeZoomable); + } + if (this.zoomOutBothMenuItem != null) { + this.zoomOutBothMenuItem.setEnabled(isDomainZoomable + & isRangeZoomable); + } + if (this.zoomResetBothMenuItem != null) { + this.zoomResetBothMenuItem.setEnabled(isDomainZoomable + & isRangeZoomable); + } + + this.popup.setLocation(x, y); + this.popup.setVisible(true); + } + + } + + /** + * Creates a print job for the chart. + */ + public void createChartPrintJob() { + new ChartPrintJob("PlotPrint").print(this); + } + + /** + * Creates a popup menu for the canvas. + * + * @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 Menu createPopupMenu(boolean properties, boolean save, + boolean print, boolean zoom) { + + Menu result = new Menu(this); + boolean separator = false; + + if (properties) { + MenuItem propertiesItem = new MenuItem(result, SWT.PUSH); + propertiesItem.setText(localizationResources.getString( + "Properties...")); + propertiesItem.setData(PROPERTIES_COMMAND); + propertiesItem.addSelectionListener(this); + separator = true; + } + if (save) { + if (separator) { + new MenuItem(result, SWT.SEPARATOR); + separator = false; + } + MenuItem saveItem = new MenuItem(result, SWT.NONE); + saveItem.setText(localizationResources.getString("Save_as...")); + saveItem.setData(SAVE_COMMAND); + saveItem.addSelectionListener(this); + separator = true; + } + if (print) { + if (separator) { + new MenuItem(result, SWT.SEPARATOR); + separator = false; + } + MenuItem printItem = new MenuItem(result, SWT.NONE); + printItem.setText(localizationResources.getString("Print...")); + printItem.setData(PRINT_COMMAND); + printItem.addSelectionListener(this); + separator = true; + } + if (zoom) { + if (separator) { + new MenuItem(result, SWT.SEPARATOR); + separator = false; + } + + Menu zoomInMenu = new Menu(result); + MenuItem zoomInMenuItem = new MenuItem(result, SWT.CASCADE); + zoomInMenuItem.setText(localizationResources.getString("Zoom_In")); + zoomInMenuItem.setMenu(zoomInMenu); + + this.zoomInBothMenuItem = new MenuItem(zoomInMenu, SWT.PUSH); + this.zoomInBothMenuItem.setText(localizationResources.getString( + "All_Axes")); + this.zoomInBothMenuItem.setData(ZOOM_IN_BOTH_COMMAND); + this.zoomInBothMenuItem.addSelectionListener(this); + + new MenuItem(zoomInMenu, SWT.SEPARATOR); + + this.zoomInDomainMenuItem = new MenuItem(zoomInMenu, SWT.PUSH); + this.zoomInDomainMenuItem.setText(localizationResources.getString( + "Domain_Axis")); + this.zoomInDomainMenuItem.setData(ZOOM_IN_DOMAIN_COMMAND); + this.zoomInDomainMenuItem.addSelectionListener(this); + + this.zoomInRangeMenuItem = new MenuItem(zoomInMenu, SWT.PUSH); + this.zoomInRangeMenuItem.setText(localizationResources.getString( + "Range_Axis")); + this.zoomInRangeMenuItem.setData(ZOOM_IN_RANGE_COMMAND); + this.zoomInRangeMenuItem.addSelectionListener(this); + + Menu zoomOutMenu = new Menu(result); + MenuItem zoomOutMenuItem = new MenuItem(result, SWT.CASCADE); + zoomOutMenuItem.setText(localizationResources.getString( + "Zoom_Out")); + zoomOutMenuItem.setMenu(zoomOutMenu); + + this.zoomOutBothMenuItem = new MenuItem(zoomOutMenu, SWT.PUSH); + this.zoomOutBothMenuItem.setText(localizationResources.getString( + "All_Axes")); + this.zoomOutBothMenuItem.setData(ZOOM_OUT_BOTH_COMMAND); + this.zoomOutBothMenuItem.addSelectionListener(this); + + new MenuItem(zoomOutMenu, SWT.SEPARATOR); + + this.zoomOutDomainMenuItem = new MenuItem(zoomOutMenu, SWT.PUSH); + this.zoomOutDomainMenuItem.setText(localizationResources.getString( + "Domain_Axis")); + this.zoomOutDomainMenuItem.setData(ZOOM_OUT_DOMAIN_COMMAND); + this.zoomOutDomainMenuItem.addSelectionListener(this); + + this.zoomOutRangeMenuItem = new MenuItem(zoomOutMenu, SWT.PUSH); + this.zoomOutRangeMenuItem.setText( + localizationResources.getString("Range_Axis")); + this.zoomOutRangeMenuItem.setData(ZOOM_OUT_RANGE_COMMAND); + this.zoomOutRangeMenuItem.addSelectionListener(this); + + Menu autoRangeMenu = new Menu(result); + MenuItem autoRangeMenuItem = new MenuItem(result, SWT.CASCADE); + autoRangeMenuItem.setText(localizationResources.getString( + "Auto_Range")); + autoRangeMenuItem.setMenu(autoRangeMenu); + + this.zoomResetBothMenuItem = new MenuItem(autoRangeMenu, SWT.PUSH); + this.zoomResetBothMenuItem.setText(localizationResources.getString( + "All_Axes")); + this.zoomResetBothMenuItem.setData(ZOOM_RESET_BOTH_COMMAND); + this.zoomResetBothMenuItem.addSelectionListener(this); + + new MenuItem(autoRangeMenu, SWT.SEPARATOR); + + this.zoomResetDomainMenuItem = new MenuItem(autoRangeMenu, + SWT.PUSH); + this.zoomResetDomainMenuItem.setText( + localizationResources.getString("Domain_Axis")); + this.zoomResetDomainMenuItem.setData(ZOOM_RESET_DOMAIN_COMMAND); + this.zoomResetDomainMenuItem.addSelectionListener(this); + + this.zoomResetRangeMenuItem = new MenuItem(autoRangeMenu, SWT.PUSH); + this.zoomResetRangeMenuItem.setText( + localizationResources.getString("Range_Axis")); + this.zoomResetRangeMenuItem.setData(ZOOM_RESET_RANGE_COMMAND); + this.zoomResetRangeMenuItem.addSelectionListener(this); + } + + return result; + } + + /** + * Handles action events generated by the popup menu. + * + * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected( + * org.eclipse.swt.events.SelectionEvent) + */ + public void widgetDefaultSelected(SelectionEvent e) { + widgetSelected(e); + } + + /** + * Handles action events generated by the popup menu. + * + * @see org.eclipse.swt.events.SelectionListener#widgetSelected( + * org.eclipse.swt.events.SelectionEvent) + */ + public void widgetSelected(SelectionEvent e) { + String command = (String) ((MenuItem) e.getSource()).getData(); + if (command.equals(PROPERTIES_COMMAND)) { + attemptEditChartProperties(); + } + else if (command.equals(SAVE_COMMAND)) { + try { + doSaveAs(); + } + catch (IOException ex) { + ex.printStackTrace(); + } + } + else if (command.equals(PRINT_COMMAND)) { + createChartPrintJob(); + } + /* in the next zoomPoint.x and y replace by e.x and y for now. + * this helps to handle the mouse events and besides, + * those values are unused AFAIK. */ + else if (command.equals(ZOOM_IN_BOTH_COMMAND)) { + zoomInBoth(e.x, e.y); + } + else if (command.equals(ZOOM_IN_DOMAIN_COMMAND)) { + zoomInDomain(e.x, e.y); + } + else if (command.equals(ZOOM_IN_RANGE_COMMAND)) { + zoomInRange(e.x, e.y); + } + else if (command.equals(ZOOM_OUT_BOTH_COMMAND)) { + zoomOutBoth(e.x, e.y); + } + else if (command.equals(ZOOM_OUT_DOMAIN_COMMAND)) { + zoomOutDomain(e.x, e.y); + } + else if (command.equals(ZOOM_OUT_RANGE_COMMAND)) { + zoomOutRange(e.x, e.y); + } + else if (command.equals(ZOOM_RESET_BOTH_COMMAND)) { + restoreAutoBounds(); + } + else if (command.equals(ZOOM_RESET_DOMAIN_COMMAND)) { + restoreAutoDomainBounds(); + } + else if (command.equals(ZOOM_RESET_RANGE_COMMAND)) { + restoreAutoRangeBounds(); + } + this.forceRedraw(); + } + + /** + * Not implemented. + * + * @param graphics the graphics. + * @param pageFormat the page format. + * @param pageIndex the page index. + * + * @return ?. + * + * @throws PrinterException if there is a problem. + */ + public int print(Graphics graphics, PageFormat pageFormat, int pageIndex) + throws PrinterException { + if (pageIndex != 0) { + return NO_SUCH_PAGE; + } + /* + CairoImage image = new CairoImage( + this.getBounds().width, this.getBounds().height); + Graphics2D g2 = image.createGraphics2D(); + double x = pageFormat.getImageableX(); + double y = pageFormat.getImageableY(); + double w = pageFormat.getImageableWidth(); + double h = pageFormat.getImageableHeight(); + this.chart.draw( + g2, new Rectangle2D.Double(x, y, w, h), this.anchor, null + ); + */ + return PAGE_EXISTS; + } + + /** + * Hook an SWT listener on the canvas where the chart is drawn. + * The purpose of this method is to allow some degree of customization. + * + * @param listener The SWT listener to attach to the canvas. + */ + public void addSWTListener(EventListener listener) { + if (listener instanceof ControlListener) { + this.canvas.addControlListener((ControlListener) listener); + } + else if (listener instanceof DisposeListener) { + this.canvas.addDisposeListener((DisposeListener) listener); +// } +// else if (listener instanceof DragDetectListener) { +// this.canvas.addDragDetectListener((DragDetectListener) listener); + } + else if (listener instanceof FocusListener) { + this.canvas.addFocusListener((FocusListener) listener); + } + else if (listener instanceof HelpListener) { + this.canvas.addHelpListener((HelpListener) listener); + } + else if (listener instanceof KeyListener) { + this.canvas.addKeyListener((KeyListener) listener); +// } +// else if (listener instanceof MenuDetectListener) { +// this.canvas.addMenuDetectListener((MenuDetectListener) listener); + } + else if (listener instanceof MouseListener) { + this.canvas.addMouseListener((MouseListener) listener); + } + else if (listener instanceof MouseMoveListener) { + this.canvas.addMouseMoveListener((MouseMoveListener) listener); + } + else if (listener instanceof MouseTrackListener) { + this.canvas.addMouseTrackListener((MouseTrackListener) listener); +// } else if (listener instanceof MouseWheelListener) { +// this.canvas.addMouseWheelListener((MouseWheelListener) listener); + } + else if (listener instanceof PaintListener) { + this.canvas.addPaintListener((PaintListener) listener); + } + else if (listener instanceof TraverseListener) { + this.canvas.addTraverseListener((TraverseListener) listener); + } + } + + /** + * Does nothing - override if necessary. + * + * @param event the mouse event. + */ + public void mouseDoubleClick(MouseEvent event) { + // do nothing, override if necessary + } + + /** + * Handles a mouse down event. + * + * @param event the event. + */ + public void mouseDown(MouseEvent event) { + + Rectangle scaledDataArea = getScreenDataArea(event.x, event.y); + if (scaledDataArea == null) return; + this.zoomPoint = getPointInRectangle(event.x, event.y, scaledDataArea); + int x = (int) ((event.x - getClientArea().x) / this.scaleX); + int y = (int) ((event.y - getClientArea().y) / this.scaleY); + + this.anchor = new Point2D.Double(x, y); + this.chart.setNotify(true); // force a redraw + this.canvas.redraw(); + + // new entity code + ChartEntity entity = null; + if (this.info != null) { + EntityCollection entities = this.info.getEntityCollection(); + if (entities != null) { + entity = entities.getEntity(x, y); + } + } + + Object[] listeners = this.chartMouseListeners.getListeners( + ChartMouseListener.class); + if (listeners.length == 0) { + return; + } + + // pass mouse down event if some ChartMouseListener are listening + java.awt.event.MouseEvent mouseEvent = SWTUtils.toAwtMouseEvent(event); + ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), + mouseEvent, entity); + for (int i = listeners.length - 1; i >= 0; i -= 1) { + ((ChartMouseListener) listeners[i]).chartMouseClicked(chartEvent); + } + } + + /** + * Handles a mouse up event. + * + * @param event the event. + */ + public void mouseUp(MouseEvent event) { + + boolean hZoom, vZoom; + if (this.zoomRectangle == null) { + Rectangle screenDataArea = getScreenDataArea(event.x, event.y); + if (screenDataArea != null) { + this.zoomPoint = getPointInRectangle(event.x, event.y, + screenDataArea); + } + if (this.popup != null && event.button == 3) { + org.eclipse.swt.graphics.Point pt = this.canvas.toDisplay( + event.x, event.y); + displayPopupMenu(pt.x, pt.y); + } + } + else { + hZoom = false; + vZoom = false; + if (this.orientation == PlotOrientation.HORIZONTAL) { + hZoom = this.rangeZoomable; + vZoom = this.domainZoomable; + } + else { + hZoom = this.domainZoomable; + vZoom = this.rangeZoomable; + } + boolean zoomTrigger1 = hZoom && Math.abs(this.zoomRectangle.width) + >= this.zoomTriggerDistance; + boolean zoomTrigger2 = vZoom + && Math.abs(this.zoomRectangle.height) + >= this.zoomTriggerDistance; + if (zoomTrigger1 || zoomTrigger2) { + // if the box has been drawn backwards, restore the auto bounds + if ((hZoom && (this.zoomRectangle.x + this.zoomRectangle.width + < this.zoomPoint.x)) || (vZoom && (this.zoomRectangle.y + + this.zoomRectangle.height < this.zoomPoint.y))) + restoreAutoBounds(); + else { + zoom(this.zoomRectangle); + } + this.canvas.redraw(); + } + } + this.zoomPoint = null; + this.zoomRectangle = null; + } + + /** + * Handles a mouse move event. + * + * @param event the mouse event. + */ + public void mouseMove(MouseEvent event) { + + // handle axis trace + if (this.horizontalAxisTrace || this.verticalAxisTrace) { + this.horizontalTraceLineY = event.y; + this.verticalTraceLineX = event.x; + this.canvas.redraw(); + } + + // handle tool tips in a simple way + if (this.displayToolTips) { + String s = getToolTipText(event); + if (s == null && this.canvas.getToolTipText() != null + || s != null && !s.equals(this.canvas.getToolTipText())) + this.canvas.setToolTipText(s); + } + + // handle zoom box + boolean hZoom, vZoom; + if (this.zoomPoint != null) { + Rectangle scaledDataArea = getScreenDataArea(this.zoomPoint.x, + this.zoomPoint.y); + org.eclipse.swt.graphics.Point movingPoint + = getPointInRectangle(event.x, event.y, scaledDataArea); + if (this.orientation == PlotOrientation.HORIZONTAL) { + hZoom = this.rangeZoomable; + vZoom = this.domainZoomable; + } + else { + hZoom = this.domainZoomable; + vZoom = this.rangeZoomable; + } + if (hZoom && vZoom) { + // selected rectangle shouldn't extend outside the data area... + this.zoomRectangle = new Rectangle(this.zoomPoint.x, + this.zoomPoint.y, movingPoint.x - this.zoomPoint.x, + movingPoint.y - this.zoomPoint.y); + } + else if (hZoom) { + this.zoomRectangle = new Rectangle(this.zoomPoint.x, + scaledDataArea.y, movingPoint.x - this.zoomPoint.x, + scaledDataArea.height); + } + else if (vZoom) { + int ymax = Math.max(movingPoint.y, scaledDataArea.y); + this.zoomRectangle = new Rectangle( + scaledDataArea.x, this.zoomPoint.y, + scaledDataArea.width, ymax - this.zoomPoint.y); + } + this.canvas.redraw(); + } + + // new entity code + ChartEntity entity = null; + int x = (int) ((event.x - getClientArea().x) / this.scaleX); + int y = (int) ((event.y - getClientArea().y) / this.scaleY); + + if (this.info != null) { + EntityCollection entities = this.info.getEntityCollection(); + if (entities != null) { + entity = entities.getEntity(x, y); + } + } + + Object[] listeners = this.chartMouseListeners.getListeners( + ChartMouseListener.class); + if (listeners.length == 0) { + return; + } + + // pass mouse move event if some ChartMouseListener are listening + java.awt.event.MouseEvent mouseEvent = SWTUtils.toAwtMouseEvent(event); + ChartMouseEvent chartEvent = new ChartMouseEvent(getChart(), + mouseEvent, entity); + for (int i = listeners.length - 1; i >= 0; i -= 1) { + ((ChartMouseListener) listeners[i]).chartMouseMoved(chartEvent); + } + } + + /** + * Paints the control. + * + * @param e the paint event. + */ + public void paintControl(PaintEvent e) { + // first determine the size of the chart rendering area... + // TODO workout insets for SWT + Rectangle available = getBounds(); + // skip if chart is null + if (this.chart == null) { + this.canvas.drawBackground(e.gc, available.x, available.y, + available.width, available.height); + return; + } + SWTGraphics2D sg2 = new SWTGraphics2D(e.gc); + + // work out if scaling is required... + boolean scale = false; + int drawWidth = available.width; + int drawHeight = available.height; + if (drawWidth == 0.0 || drawHeight == 0.0) return; + this.scaleX = 1.0; + this.scaleY = 1.0; + if (drawWidth < this.minimumDrawWidth) { + this.scaleX = (double) drawWidth / this.minimumDrawWidth; + drawWidth = this.minimumDrawWidth; + scale = true; + } + else if (drawWidth > this.maximumDrawWidth) { + this.scaleX = (double) drawWidth / this.maximumDrawWidth; + drawWidth = this.maximumDrawWidth; + scale = true; + } + if (drawHeight < this.minimumDrawHeight) { + this.scaleY = (double) drawHeight / this.minimumDrawHeight; + drawHeight = this.minimumDrawHeight; + scale = true; + } + else if (drawHeight > this.maximumDrawHeight) { + this.scaleY = (double) drawHeight / this.maximumDrawHeight; + drawHeight = this.maximumDrawHeight; + scale = true; + } + // are we using the chart buffer? + if (this.useBuffer) { + //SwtGraphics2D sg2 = new SwtGraphics2D(e.gc); + this.chartBuffer = (org.eclipse.swt.graphics.Image) + this.canvas.getData("double-buffer-image"); + // do we need to fill the buffer? + if (this.chartBuffer == null + || this.chartBufferWidth != available.width + || this.chartBufferHeight != available.height) { + this.chartBufferWidth = available.width; + this.chartBufferHeight = available.height; + if (this.chartBuffer != null) { + this.chartBuffer.dispose(); + } + this.chartBuffer = new org.eclipse.swt.graphics.Image( + getDisplay(), this.chartBufferWidth, + this.chartBufferHeight); + this.refreshBuffer = true; + } + + // do we need to redraw the buffer? + if (this.refreshBuffer) { + // Performs the actual drawing here ... + GC gci = new GC(this.chartBuffer); + // anti-aliasing + if (this.chart.getAntiAlias()) { + gci.setAntialias(SWT.ON); + } + if (this.chart.getTextAntiAlias() + == RenderingHints.KEY_TEXT_ANTIALIASING) { + gci.setTextAntialias(SWT.ON); + } + SWTGraphics2D sg2d = new SWTGraphics2D(gci); + if (scale) { + sg2d.scale(this.scaleX, this.scaleY); + this.chart.draw(sg2d, new Rectangle2D.Double(0, 0, + drawWidth, drawHeight), getAnchor(), this.info); + } + else { + this.chart.draw(sg2d, new Rectangle2D.Double(0, 0, + drawWidth, drawHeight), getAnchor(), this.info); + } + this.canvas.setData("double-buffer-image", this.chartBuffer); + sg2d.dispose(); + gci.dispose(); + this.refreshBuffer = false; + } + + // zap the buffer onto the canvas... + sg2.drawImage(this.chartBuffer, 0, 0); + } + // or redrawing the chart every time... + else { + if (this.chart.getAntiAlias()) { + e.gc.setAntialias(SWT.ON); + } + if (this.chart.getTextAntiAlias() + == RenderingHints.KEY_TEXT_ANTIALIASING) { + e.gc.setTextAntialias(SWT.ON); + } + this.chart.draw(sg2, new Rectangle2D.Double(0, 0, + getBounds().width, getBounds().height), getAnchor(), + this.info); + } + Rectangle area = getScreenDataArea(); + // TODO see if we need to apply some line color and style to the + // axis traces + if (this.horizontalAxisTrace && area.x < this.verticalTraceLineX + && area.x + area.width > this.verticalTraceLineX) { + e.gc.drawLine(this.verticalTraceLineX, area.y, + this.verticalTraceLineX, area.y + area.height); + } + if (this.verticalAxisTrace && area.y < this.horizontalTraceLineY + && area.y + area.height > this.horizontalTraceLineY) { + e.gc.drawLine(area.x, this.horizontalTraceLineY, + area.x + area.width, this.horizontalTraceLineY); + } + this.verticalTraceLineX = 0; + this.horizontalTraceLineY = 0; + if (this.zoomRectangle != null) { + e.gc.drawRectangle(this.zoomRectangle); + } + sg2.dispose(); + } + + /** + * Disposes the control. + */ + public void dispose() { + // de-register the composite as a listener for the chart. + if (this.chart != null) { + this.chart.removeChangeListener(this); + this.chart.removeProgressListener(this); + } + + if (this.chartBuffer != null) { + this.chartBuffer.dispose(); + } + + if (this.popup != null) { + this.popup.dispose(); + } + super.dispose(); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/ChartPrintJob.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/ChartPrintJob.java new file mode 100755 index 0000000..6e37742 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/ChartPrintJob.java @@ -0,0 +1,178 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * ChartPrintJob.java + * ------------------ + * (C) Copyright 2012, by Jonas Rüttimann. + * + * Original Author: Jonas Rüttimann; + * Contributor(s): - + * + * Changes + * ------- + * 05-Jul-2012 : Version 1, from bug 2963199 (JR); + * + */ + +package org.jfree.experimental.chart.swt; + +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.printing.PrintDialog; +import org.eclipse.swt.printing.Printer; +import org.eclipse.swt.printing.PrinterData; +import org.eclipse.swt.widgets.Composite; + +/** + * Printer job for SWT. + */ +public class ChartPrintJob { + + /** + * Border on the paper not to print on (in inches) + */ + private static final double BORDER = 0.8; + + private String jobName; + + /** + * Creates a new job. + * + * @param jobName this will be the name of the print job or the default + * name of the file (if printed to a file). + */ + public ChartPrintJob(String jobName) { + this.jobName = jobName; + } + + /** + * Prints the specified element. + * + * @param elementToPrint the {@link Composite} to be printed. + */ + public void print(Composite elementToPrint) { + PrintDialog dialog = new PrintDialog(elementToPrint.getShell()); + PrinterData printerData = dialog.open(); + if (printerData == null) { + return; // Anwender hat abgebrochen. + } + startPrintJob(elementToPrint, printerData); + } + + protected void startPrintJob(Composite elementToPrint, + PrinterData printerData) { + Printer printer = new Printer(printerData); + try { + printer.startJob(jobName); + + GC gc = new GC(printer); + try { + Rectangle printArea = getPrintableArea(printer, BORDER); + printer.startPage(); + printComposite(elementToPrint, gc, printArea); + printer.endPage(); + } finally { + gc.dispose(); + } + printer.endJob(); + + } finally { + printer.dispose(); + } + } + + /** + * @param printer + * @param safetyBorder + * @return the rectangle in pixels to print on (and which is also supported + * by the printer hardware) + */ + private Rectangle getPrintableArea(Printer printer, double safetyBorder) { + int safetyBorderWidth = (int) (safetyBorder * printer.getDPI().x); + int safetyBorderHeight = (int) (safetyBorder * printer.getDPI().y); + + Rectangle trim = printer.computeTrim(0, 0, 0, 0); + int trimLeft = -trim.x; + int trimTop = -trim.y; + int trimRight = trim.x + trim.width; + int trimBottom = trim.y + trim.height; + + int marginLeft = Math.max(trimLeft, safetyBorderWidth); + int marginRight = Math.max(trimRight, safetyBorderWidth); + int marginTop = Math.max(trimTop, safetyBorderHeight); + int marginBottom = Math.max(trimBottom, safetyBorderHeight); + + int availWidth = printer.getClientArea().width - marginLeft + - marginRight; + int availHeight = printer.getClientArea().height - marginTop + - marginBottom; + return new Rectangle(marginLeft, marginTop, availWidth, availHeight); + } + + private void printComposite(Composite elementToPrint, GC gc, + Rectangle printArea) { + Image image = new Image(elementToPrint.getDisplay(), + elementToPrint.getSize().x, elementToPrint.getSize().y); + try { + GC imageGC = new GC(image); + try { + elementToPrint.print(imageGC); + Point fittedSize = calcFittedSize(printArea, + elementToPrint.getSize()); + gc.drawImage(image, 0, 0, elementToPrint.getSize().x, + elementToPrint.getSize().y, printArea.x, printArea.y, + fittedSize.x, fittedSize.y); + + } finally { + imageGC.dispose(); + } + } finally { + image.dispose(); + } + } + + /** + * The object to print should be scaled up or down to fit horizontally and + * vertically the available space. + * + * @param printArea + * @param originalSize + * + * @return the fitted size of the object to print + */ + Point calcFittedSize(Rectangle printArea, Point originalSize) { + double scaleFactor = Math.min( + (double) printArea.height / originalSize.y, + (double) printArea.width / originalSize.x); + int trgHeight = (int) Math.ceil(originalSize.y * scaleFactor); + int trgWidth = (int) Math.ceil(originalSize.x * scaleFactor); + return new Point(trgWidth, trgHeight); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/demo/SWTBarChartDemo1.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/demo/SWTBarChartDemo1.java new file mode 100755 index 0000000..fa8e299 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/demo/SWTBarChartDemo1.java @@ -0,0 +1,181 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * SWTBarChartDemo1.java + * --------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Henry Proudhon (henry.proudhon AT ensmp.fr). + * + * Changes + * ------- + * 23-Aug-2006 : New class (DG); + * + */ + +package org.jfree.experimental.chart.swt.demo; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.CategoryLabelPositions; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.renderer.category.BarRenderer; +import org.jfree.chart.renderer.category.StandardBarPainter; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.experimental.chart.swt.ChartComposite; + +/** + * An SWT demo. + */ +public class SWTBarChartDemo1 { + + /** + * Returns a sample dataset. + * + * @return The dataset. + */ + private static CategoryDataset createDataset() { + + // row keys... + String series1 = "First"; + String series2 = "Second"; + String series3 = "Third"; + + // column keys... + String category1 = "Category 1"; + String category2 = "Category 2"; + String category3 = "Category 3"; + String category4 = "Category 4"; + String category5 = "Category 5"; + + // create the dataset... + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + + dataset.addValue(1.0, series1, category1); + dataset.addValue(4.0, series1, category2); + dataset.addValue(3.0, series1, category3); + dataset.addValue(5.0, series1, category4); + dataset.addValue(5.0, series1, category5); + + dataset.addValue(5.0, series2, category1); + dataset.addValue(7.0, series2, category2); + dataset.addValue(6.0, series2, category3); + dataset.addValue(8.0, series2, category4); + dataset.addValue(4.0, series2, category5); + + dataset.addValue(4.0, series3, category1); + dataset.addValue(3.0, series3, category2); + dataset.addValue(2.0, series3, category3); + dataset.addValue(3.0, series3, category4); + dataset.addValue(6.0, series3, category5); + + return dataset; + + } + + /** + * Creates a sample chart. + * + * @param dataset the dataset. + * + * @return The chart. + */ + private static JFreeChart createChart(CategoryDataset dataset) { + + // create the chart... + JFreeChart chart = ChartFactory.createBarChart( + "SWTBarChartDemo1", // chart title + "Category", // domain axis label + "Value", // range axis label + dataset, // data + PlotOrientation.VERTICAL, // orientation + true, // include legend + true, // tooltips? + false // URLs? + ); + + // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... + + // get a reference to the plot for further customisation... + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + + // set the range axis to display integers only... + NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + + // disable bar outlines... + BarRenderer renderer = (BarRenderer) plot.getRenderer(); + renderer.setDrawBarOutline(false); + + // the SWTGraphics2D class doesn't handle GradientPaint well, so + // replace the gradient painter from the default theme with a + // standard painter... + renderer.setBarPainter(new StandardBarPainter()); + + CategoryAxis domainAxis = plot.getDomainAxis(); + domainAxis.setCategoryLabelPositions( + CategoryLabelPositions.createUpRotationLabelPositions( + Math.PI / 6.0)); + // OPTIONAL CUSTOMISATION COMPLETED. + + return chart; + + } + + /** + * Starting point for the demonstration application. + * + * @param args ignored. + */ + public static void main(String[] args) { + JFreeChart chart = createChart(createDataset()); + Display display = new Display(); + Shell shell = new Shell(display); + shell.setSize(600, 300); + shell.setLayout(new FillLayout()); + shell.setText("Test for jfreechart running with SWT"); + ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, + true); + frame.pack(); + shell.open(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/demo/SWTMultipleAxisDemo1.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/demo/SWTMultipleAxisDemo1.java new file mode 100755 index 0000000..828baff --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/demo/SWTMultipleAxisDemo1.java @@ -0,0 +1,221 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * SWTMultipleAxisDemo1.java + * ------------------------- + * (C) Copyright 2006-2009, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Henry Proudhon; + * + * Changes + * ------- + * 23-Aug-2006 : New class (HP); + * + */ + +package org.jfree.experimental.chart.swt.demo; + +import java.awt.Color; + +import javax.swing.JPanel; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartPanel; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.AxisLocation; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.StandardXYItemRenderer; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.chart.title.TextTitle; +import org.jfree.data.time.Minute; +import org.jfree.data.time.RegularTimePeriod; +import org.jfree.data.time.TimeSeries; +import org.jfree.data.time.TimeSeriesCollection; +import org.jfree.data.xy.XYDataset; +import org.jfree.experimental.chart.swt.ChartComposite; +import org.jfree.ui.RectangleInsets; + +/** + * This demo shows a time series chart that has multiple range axes. + */ +public class SWTMultipleAxisDemo1 +{ + /** + * Creates the demo chart. + * + * @return The chart. + */ + private static JFreeChart createChart() { + + XYDataset dataset1 = createDataset("Series 1", 100.0, new Minute(), + 200); + + JFreeChart chart = ChartFactory.createTimeSeriesChart( + "Multiple Axis Demo 3", + "Time of Day", + "Primary Range Axis", + dataset1, + true, + true, + false + ); + + chart.setBackgroundPaint(Color.white); + chart.setBorderVisible(true); + chart.setBorderPaint(Color.BLACK); + TextTitle subtitle = new TextTitle("Four datasets and four range axes."); + chart.addSubtitle(subtitle); + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setOrientation(PlotOrientation.VERTICAL); + plot.setBackgroundPaint(Color.lightGray); + plot.setDomainGridlinePaint(Color.white); + plot.setRangeGridlinePaint(Color.white); + + plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); + XYItemRenderer renderer = plot.getRenderer(); + renderer.setSeriesPaint(0, Color.black); + + // AXIS 2 + NumberAxis axis2 = new NumberAxis("Range Axis 2"); + axis2.setAutoRangeIncludesZero(false); + axis2.setLabelPaint(Color.red); + axis2.setTickLabelPaint(Color.red); + plot.setRangeAxis(1, axis2); + plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); + + XYDataset dataset2 = createDataset("Series 2", 1000.0, new Minute(), + 170); + plot.setDataset(1, dataset2); + plot.mapDatasetToRangeAxis(1, 1); + XYItemRenderer renderer2 = new StandardXYItemRenderer(); + renderer2.setSeriesPaint(0, Color.red); + plot.setRenderer(1, renderer2); + + // AXIS 3 + NumberAxis axis3 = new NumberAxis("Range Axis 3"); + axis3.setLabelPaint(Color.blue); + axis3.setTickLabelPaint(Color.blue); + //axis3.setPositiveArrowVisible(true); + plot.setRangeAxis(2, axis3); + + XYDataset dataset3 = createDataset("Series 3", 10000.0, new Minute(), + 170); + plot.setDataset(2, dataset3); + plot.mapDatasetToRangeAxis(2, 2); + XYItemRenderer renderer3 = new StandardXYItemRenderer(); + renderer3.setSeriesPaint(0, Color.blue); + plot.setRenderer(2, renderer3); + + // AXIS 4 + NumberAxis axis4 = new NumberAxis("Range Axis 4"); + axis4.setLabelPaint(Color.green); + axis4.setTickLabelPaint(Color.green); + plot.setRangeAxis(3, axis4); + + XYDataset dataset4 = createDataset("Series 4", 25.0, new Minute(), 200); + plot.setDataset(3, dataset4); + plot.mapDatasetToRangeAxis(3, 3); + + XYItemRenderer renderer4 = new StandardXYItemRenderer(); + renderer4.setSeriesPaint(0, Color.green); + plot.setRenderer(3, renderer4); + + return chart; + } + + /** + * Creates a sample dataset. + * + * @param name the dataset name. + * @param base the starting value. + * @param start the starting period. + * @param count the number of values to generate. + * + * @return The dataset. + */ + private static XYDataset createDataset(String name, double base, + RegularTimePeriod start, int count) { + + TimeSeries series = new TimeSeries(name); + RegularTimePeriod period = start; + double value = base; + for (int i = 0; i < count; i++) { + series.add(period, value); + period = period.next(); + value = value * (1 + (Math.random() - 0.495) / 10.0); + } + + TimeSeriesCollection dataset = new TimeSeriesCollection(); + dataset.addSeries(series); + + return dataset; + + } + + /** + * 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) + { + final JFreeChart chart = createChart(); + final Display display = new Display(); + Shell shell = new Shell(display); + shell.setSize(600, 300); + shell.setLayout(new FillLayout()); + shell.setText("Test for jfreechart running with SWT"); + ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true); + frame.setDisplayToolTips(false); + frame.setHorizontalAxisTrace(true); + frame.setVerticalAxisTrace(true); + shell.open(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/demo/SWTPieChartDemo1.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/demo/SWTPieChartDemo1.java new file mode 100755 index 0000000..3081193 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/demo/SWTPieChartDemo1.java @@ -0,0 +1,128 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * SWTPieChartDemo1.java + * --------------------- + * (C) Copyright 2006, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): + * + * Changes + * ------- + * 23-Aug-2006 : New class (DG); + * + */ + +package org.jfree.experimental.chart.swt.demo; + +import java.awt.Font; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.plot.PiePlot; +import org.jfree.data.general.DefaultPieDataset; +import org.jfree.data.general.PieDataset; +import org.jfree.experimental.chart.swt.ChartComposite; + +/** + * This demo shows a time series chart that has multiple range axes. + */ +public class SWTPieChartDemo1 { + + /** + * Creates a sample dataset. + * + * @return A sample dataset. + */ + private static PieDataset createDataset() { + DefaultPieDataset dataset = new DefaultPieDataset(); + dataset.setValue("One", new Double(43.2)); + dataset.setValue("Two", new Double(10.0)); + dataset.setValue("Three", new Double(27.5)); + dataset.setValue("Four", new Double(17.5)); + dataset.setValue("Five", new Double(11.0)); + dataset.setValue("Six", new Double(19.4)); + return dataset; + } + + /** + * Creates a chart. + * + * @param dataset the dataset. + * + * @return A chart. + */ + private static JFreeChart createChart(PieDataset dataset) { + + JFreeChart chart = ChartFactory.createPieChart( + "Pie Chart Demo 1", // chart title + dataset, // data + true, // include legend + true, + false + ); + + PiePlot plot = (PiePlot) chart.getPlot(); + plot.setSectionOutlinesVisible(false); + plot.setLabelFont(new Font("SansSerif", Font.PLAIN, 12)); + plot.setNoDataMessage("No data available"); + plot.setCircular(false); + plot.setLabelGap(0.02); + return chart; + + } + + /** + * Starting point for the demonstration application. + * + * @param args ignored. + */ + public static void main(String[] args) + { + JFreeChart chart = createChart(createDataset()); + Display display = new Display(); + Shell shell = new Shell(display); + shell.setSize(600, 400); + shell.setLayout(new FillLayout()); + shell.setText("Test for jfreechart running with SWT"); + final ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true); + //frame.setDisplayToolTips(false); + frame.pack(); + shell.open(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/demo/SWTTimeSeriesDemo.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/demo/SWTTimeSeriesDemo.java new file mode 100755 index 0000000..a6b662c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/demo/SWTTimeSeriesDemo.java @@ -0,0 +1,190 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * SWTTimeSeriesDemo.java + * --------------------- + * (C) Copyright 2006-2009, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Henry Proudhon (henry.proudhon AT ensmp.fr); + * + * Changes + * ------- + * 30-Jan-2007 : New class derived from TimeSeriesDemo.java (HP); + * + */ +package org.jfree.experimental.chart.swt.demo; + +import java.awt.Color; +import java.text.SimpleDateFormat; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.DateAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; +import org.jfree.data.time.Month; +import org.jfree.data.time.TimeSeries; +import org.jfree.data.time.TimeSeriesCollection; +import org.jfree.data.xy.XYDataset; +import org.jfree.experimental.chart.swt.ChartComposite; +import org.jfree.ui.RectangleInsets; + +/** + * An example of a time series chart. For the most part, default settings are + * used, except that the renderer is modified to show filled shapes (as well as + * lines) at each data point. + */ +public class SWTTimeSeriesDemo +{ + + /** + * Creates a chart. + * + * @param dataset a dataset. + * + * @return A chart. + */ + private static JFreeChart createChart(XYDataset dataset) { + + JFreeChart chart = ChartFactory.createTimeSeriesChart( + "Legal & General Unit Trust Prices", // title + "Date", // x-axis label + "Price Per Unit", // y-axis label + dataset, // data + true, // create legend? + true, // generate tooltips? + false // generate URLs? + ); + + chart.setBackgroundPaint(Color.white); + + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setBackgroundPaint(Color.lightGray); + plot.setDomainGridlinePaint(Color.white); + plot.setRangeGridlinePaint(Color.white); + plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); + plot.setDomainCrosshairVisible(true); + plot.setRangeCrosshairVisible(true); + + XYItemRenderer r = plot.getRenderer(); + if (r instanceof XYLineAndShapeRenderer) { + XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; + renderer.setBaseShapesVisible(true); + renderer.setBaseShapesFilled(true); + } + + DateAxis axis = (DateAxis) plot.getDomainAxis(); + axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); + + return chart; + + } + + /** + * Creates a dataset, consisting of two series of monthly data. + * + * @return The dataset. + */ + private static XYDataset createDataset() { + + TimeSeries s1 = new TimeSeries("L&G European Index Trust"); + s1.add(new Month(2, 2001), 181.8); + s1.add(new Month(3, 2001), 167.3); + s1.add(new Month(4, 2001), 153.8); + s1.add(new Month(5, 2001), 167.6); + s1.add(new Month(6, 2001), 158.8); + s1.add(new Month(7, 2001), 148.3); + s1.add(new Month(8, 2001), 153.9); + s1.add(new Month(9, 2001), 142.7); + s1.add(new Month(10, 2001), 123.2); + s1.add(new Month(11, 2001), 131.8); + s1.add(new Month(12, 2001), 139.6); + s1.add(new Month(1, 2002), 142.9); + s1.add(new Month(2, 2002), 138.7); + s1.add(new Month(3, 2002), 137.3); + s1.add(new Month(4, 2002), 143.9); + s1.add(new Month(5, 2002), 139.8); + s1.add(new Month(6, 2002), 137.0); + s1.add(new Month(7, 2002), 132.8); + + TimeSeries s2 = new TimeSeries("L&G UK Index Trust"); + s2.add(new Month(2, 2001), 129.6); + s2.add(new Month(3, 2001), 123.2); + s2.add(new Month(4, 2001), 117.2); + s2.add(new Month(5, 2001), 124.1); + s2.add(new Month(6, 2001), 122.6); + s2.add(new Month(7, 2001), 119.2); + s2.add(new Month(8, 2001), 116.5); + s2.add(new Month(9, 2001), 112.7); + s2.add(new Month(10, 2001), 101.5); + s2.add(new Month(11, 2001), 106.1); + s2.add(new Month(12, 2001), 110.3); + s2.add(new Month(1, 2002), 111.7); + s2.add(new Month(2, 2002), 111.0); + s2.add(new Month(3, 2002), 109.6); + s2.add(new Month(4, 2002), 113.2); + s2.add(new Month(5, 2002), 111.6); + s2.add(new Month(6, 2002), 108.8); + s2.add(new Month(7, 2002), 101.6); + + TimeSeriesCollection dataset = new TimeSeriesCollection(); + dataset.addSeries(s1); + dataset.addSeries(s2); + + return dataset; + } + + /** + * Starting point for the demonstration application. + * + * @param args ignored. + */ + public static void main(String[] args) { + final JFreeChart chart = createChart(createDataset()); + final Display display = new Display(); + Shell shell = new Shell(display); + shell.setSize(600, 300); + shell.setLayout(new FillLayout()); + shell.setText("Time series demo for jfreechart running with SWT"); + ChartComposite frame = new ChartComposite(shell, SWT.NONE, chart, true); + frame.setDisplayToolTips(true); + frame.setHorizontalAxisTrace(false); + frame.setVerticalAxisTrace(false); + shell.open(); + while (!shell.isDisposed()) { + if (!display.readAndDispatch()) + display.sleep(); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTAxisEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTAxisEditor.java new file mode 100755 index 0000000..d873f6d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTAxisEditor.java @@ -0,0 +1,382 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * SWTAxisEditor.java + * ------------------ + * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. + * + * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 01-Aug-2006 : New class (HP); + * 07-Feb-2007 : Fixed bug 1647749, handle null axis labels (DG); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * + */ + +package org.jfree.experimental.chart.swt.editor; + +import java.awt.Paint; +import java.util.ResourceBundle; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.ColorDialog; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.FontDialog; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; +import org.eclipse.swt.widgets.Text; +import org.jfree.chart.axis.Axis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.experimental.swt.SWTPaintCanvas; +import org.jfree.experimental.swt.SWTUtils; + +/** + * An editor for axis properties. + */ +class SWTAxisEditor extends Composite { + + /** The axis label. */ + private Text label; + + /** The font used to draw the axis labels. */ + private FontData labelFont; + + /** The paint (color) used to draw the axis labels. */ + private Color labelPaintColor; + + /** The font used to draw the axis tick labels. */ + private FontData tickLabelFont; + + /** The paint (color) used to draw the axis tick labels. */ + private Color tickLabelPaintColor; + + /** A field showing a description of the label font. */ + private Text labelFontField; + + /** + * A field containing a description of the font + * for displaying tick labels on the axis. + */ + private Text tickLabelFontField; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.editor.LocalizationBundle"); + + /** Font object used to handle a change of font. */ + private Font font; + + /** A flag that indicates whether or not the tick labels are visible. */ + private Button showTickLabelsCheckBox; + + /** A flag that indicates whether or not the tick marks are visible. */ + private Button showTickMarksCheckBox; + + /** A tabbed pane for... */ + private TabFolder otherTabs; + + /** + * Standard constructor: builds a composite for displaying/editing + * the properties of the specified axis. + * + * @param parent The parent composite. + * @param style The SWT style of the SwtAxisEditor. + * @param axis the axis whose properties are to be displayed/edited + * in the composite. + */ + public SWTAxisEditor(Composite parent, int style, Axis axis) { + super(parent, style); + this.labelFont = SWTUtils.toSwtFontData(getDisplay(), + axis.getLabelFont(), true); + this.labelPaintColor = SWTUtils.toSwtColor(getDisplay(), + axis.getLabelPaint()); + this.tickLabelFont = SWTUtils.toSwtFontData(getDisplay(), + axis.getTickLabelFont(), true); + this.tickLabelPaintColor = SWTUtils.toSwtColor(getDisplay(), + axis.getTickLabelPaint()); + + FillLayout layout = new FillLayout(SWT.VERTICAL); + layout.marginHeight = layout.marginWidth = 4; + setLayout(layout); + Group general = new Group(this, SWT.NONE); + general.setLayout(new GridLayout(3, false)); + general.setText(localizationResources.getString("General")); + // row 1 + new Label(general, SWT.NONE).setText(localizationResources.getString( + "Label")); + this.label = new Text(general, SWT.BORDER); + if (axis.getLabel() != null) { + this.label.setText(axis.getLabel()); + } + this.label.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, + false)); + new Label(general, SWT.NONE).setText(""); //empty cell + // row 2 + new Label(general, SWT.NONE).setText(localizationResources.getString( + "Font")); + this.labelFontField = new Text(general, SWT.BORDER); + this.labelFontField.setText(this.labelFont.toString()); + this.labelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, + true, false)); + Button selectFontButton = new Button(general, SWT.PUSH); + selectFontButton.setText(localizationResources.getString("Select...")); + selectFontButton.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + // Create the color-change dialog + FontDialog dlg = new FontDialog(getShell()); + dlg.setText(localizationResources.getString( + "Font_Selection")); + dlg.setFontList(new FontData[] { + SWTAxisEditor.this.labelFont }); + if (dlg.open() != null) { + // Dispose of any fonts we have created + if (SWTAxisEditor.this.font != null) { + SWTAxisEditor.this.font.dispose(); + } + // Create the new font and set it into the title + // label + SWTAxisEditor.this.font = new Font( + getShell().getDisplay(), dlg.getFontList()); + //label.setFont(font); + SWTAxisEditor.this.labelFontField.setText( + SWTAxisEditor.this.font.getFontData()[0] + .toString()); + SWTAxisEditor.this.labelFont + = SWTAxisEditor.this.font.getFontData()[0]; + } + } + } + ); + // row 3 + new Label(general, SWT.NONE).setText(localizationResources.getString( + "Paint")); + // Use a colored text field to show the color + final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general, + SWT.NONE, this.labelPaintColor); + GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true, + false); + canvasGridData.heightHint = 20; + colorCanvas.setLayoutData(canvasGridData); + Button selectColorButton = new Button(general, SWT.PUSH); + selectColorButton.setText(localizationResources.getString("Select...")); + selectColorButton.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + // Create the color-change dialog + ColorDialog dlg = new ColorDialog(getShell()); + dlg.setText(localizationResources.getString( + "Title_Color")); + dlg.setRGB(SWTAxisEditor.this.labelPaintColor.getRGB()); + RGB rgb = dlg.open(); + if (rgb != null) { + // create the new color and set it to the + // SwtPaintCanvas + SWTAxisEditor.this.labelPaintColor = new Color( + getDisplay(), rgb); + colorCanvas.setColor( + SWTAxisEditor.this.labelPaintColor); + } + } + } + ); + Group other = new Group(this, SWT.NONE); + FillLayout tabLayout = new FillLayout(); + tabLayout.marginHeight = tabLayout.marginWidth = 4; + other.setLayout(tabLayout); + other.setText(localizationResources.getString("Other")); + + this.otherTabs = new TabFolder(other, SWT.NONE); + TabItem item1 = new TabItem(this.otherTabs, SWT.NONE); + item1.setText(" " + localizationResources.getString("Ticks") + " "); + Composite ticks = new Composite(this.otherTabs, SWT.NONE); + ticks.setLayout(new GridLayout(3, false)); + this.showTickLabelsCheckBox = new Button(ticks, SWT.CHECK); + this.showTickLabelsCheckBox.setText(localizationResources.getString( + "Show_tick_labels")); + this.showTickLabelsCheckBox.setSelection(axis.isTickLabelsVisible()); + this.showTickLabelsCheckBox.setLayoutData(new GridData(SWT.FILL, + SWT.CENTER, true, false, 3, 1)); + new Label(ticks, SWT.NONE).setText(localizationResources.getString( + "Tick_label_font")); + this.tickLabelFontField = new Text(ticks, SWT.BORDER); + this.tickLabelFontField.setText(this.tickLabelFont.toString()); + //tickLabelFontField.setFont(SwtUtils.toSwtFontData(getDisplay(), + // axis.getTickLabelFont())); + this.tickLabelFontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, + true, false)); + Button selectTickLabelFontButton = new Button(ticks, SWT.PUSH); + selectTickLabelFontButton.setText(localizationResources.getString( + "Select...")); + selectTickLabelFontButton.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + // Create the font-change dialog + FontDialog dlg = new FontDialog(getShell()); + dlg.setText(localizationResources.getString( + "Font_Selection")); + dlg.setFontList(new FontData[] { + SWTAxisEditor.this.tickLabelFont}); + if (dlg.open() != null) { + // Dispose of any fonts we have created + if (SWTAxisEditor.this.font != null) { + SWTAxisEditor.this.font.dispose(); + } + // Create the new font and set it into the title + // label + SWTAxisEditor.this.font = new Font( + getShell().getDisplay(), dlg.getFontList()); + //tickLabelFontField.setFont(font); + SWTAxisEditor.this.tickLabelFontField.setText( + SWTAxisEditor.this.font.getFontData()[0] + .toString()); + SWTAxisEditor.this.tickLabelFont + = SWTAxisEditor.this.font.getFontData()[0]; + } + } + } + ); + this.showTickMarksCheckBox = new Button(ticks, SWT.CHECK); + this.showTickMarksCheckBox.setText(localizationResources.getString( + "Show_tick_marks")); + this.showTickMarksCheckBox.setSelection(axis.isTickMarksVisible()); + this.showTickMarksCheckBox.setLayoutData(new GridData(SWT.FILL, + SWT.CENTER, true, false, 3, 1)); + item1.setControl(ticks); + } + + /** + * A static method that returns a panel that is appropriate + * for the axis type. + * + * @param parent the parent. + * @param style the style. + * @param axis the axis whose properties are to be displayed/edited + * in the composite. + * @return A composite or nullnull. + */ + public static SWTAxisEditor getInstance(Composite parent, int style, + Axis axis) { + + if (axis != null) { + // return the appropriate axis editor + if (axis instanceof NumberAxis) + return new SWTNumberAxisEditor(parent, style, + (NumberAxis) axis); + else return new SWTAxisEditor(parent, style, axis); + } + else return null; + } + + /** + * Returns a reference to the tabbed composite. + * + * @return A reference to the tabbed composite. + */ + public TabFolder getOtherTabs() { + return this.otherTabs; + } + + /** + * Returns the current axis label. + * + * @return The current axis label. + */ + public String getLabel() { + return this.label.getText(); + } + + /** + * Returns the current label font. + * + * @return The current label font. + */ + public java.awt.Font getLabelFont() { + return SWTUtils.toAwtFont(getDisplay(), this.labelFont, true); + } + + /** + * Returns the current label paint. + * + * @return The current label paint. + */ + public Paint getTickLabelPaint() { + return SWTUtils.toAwtColor(this.tickLabelPaintColor); + } + + /** + * Returns the current label font. + * + * @return The current label font. + */ + public java.awt.Font getTickLabelFont() { + return SWTUtils.toAwtFont(getDisplay(), this.tickLabelFont, true); + } + + /** + * Returns the current label paint. + * + * @return The current label paint. + */ + public Paint getLabelPaint() { + return SWTUtils.toAwtColor(this.labelPaintColor); + } + + /** + * Sets the properties of the specified axis to match + * the properties defined on this panel. + * + * @param axis the axis. + */ + public void setAxisProperties(Axis axis) { + axis.setLabel(getLabel()); + axis.setLabelFont(getLabelFont()); + axis.setLabelPaint(getLabelPaint()); + axis.setTickMarksVisible(this.showTickMarksCheckBox.getSelection()); + axis.setTickLabelsVisible(this.showTickLabelsCheckBox.getSelection()); + axis.setTickLabelFont(getTickLabelFont()); + axis.setTickLabelPaint(getTickLabelPaint()); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTChartEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTChartEditor.java new file mode 100755 index 0000000..5a5dce4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTChartEditor.java @@ -0,0 +1,173 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * SWTChartEditor.java + * ------------------- + * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. + * + * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 01-Aug-2006 : New class (HP); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * + */ + +package org.jfree.experimental.chart.swt.editor; + +import java.util.ResourceBundle; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.editor.ChartEditor; +import org.jfree.chart.util.ResourceBundleWrapper; + +/** + * An editor for chart properties. + */ +public class SWTChartEditor implements ChartEditor { + + /** The shell */ + private Shell shell; + + /** The chart which the properties have to be edited */ + private JFreeChart chart; + + /** A composite for displaying/editing the properties of the title. */ + private SWTTitleEditor titleEditor; + + /** A composite for displaying/editing the properties of the plot. */ + private SWTPlotEditor plotEditor; + + /** A composite for displaying/editing the other properties of the chart. */ + private SWTOtherEditor otherEditor; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.editor.LocalizationBundle"); + + /** + * Creates a new editor. + * + * @param display the display. + * @param chart2edit the chart to edit. + */ + public SWTChartEditor(Display display, JFreeChart chart2edit) { + this.shell = new Shell(display, SWT.DIALOG_TRIM); + this.shell.setSize(400, 500); + this.chart = chart2edit; + this.shell.setText(ResourceBundleWrapper.getBundle( + "org.jfree.chart.LocalizationBundle").getString( + "Chart_Properties")); + GridLayout layout = new GridLayout(2, true); + layout.marginLeft = layout.marginTop = layout.marginRight + = layout.marginBottom = 5; + this.shell.setLayout(layout); + Composite main = new Composite(this.shell, SWT.NONE); + main.setLayout(new FillLayout()); + main.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1)); + + TabFolder tab = new TabFolder(main, SWT.BORDER); + // build first tab + TabItem item1 = new TabItem(tab, SWT.NONE); + item1.setText(" " + localizationResources.getString("Title") + " "); + this.titleEditor = new SWTTitleEditor(tab, SWT.NONE, + this.chart.getTitle()); + item1.setControl(this.titleEditor); + // build second tab + TabItem item2 = new TabItem(tab, SWT.NONE); + item2.setText(" " + localizationResources.getString("Plot") + " "); + this.plotEditor = new SWTPlotEditor(tab, SWT.NONE, + this.chart.getPlot()); + item2.setControl(this.plotEditor); + // build the third tab + TabItem item3 = new TabItem(tab, SWT.NONE); + item3.setText(" " + localizationResources.getString("Other") + " "); + this.otherEditor = new SWTOtherEditor(tab, SWT.NONE, this.chart); + item3.setControl(this.otherEditor); + + // ok and cancel buttons + Button ok = new Button(this.shell, SWT.PUSH | SWT.OK); + ok.setText(" Ok "); + ok.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); + ok.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + updateChart(SWTChartEditor.this.chart); + SWTChartEditor.this.shell.dispose(); + } + }); + Button cancel = new Button(this.shell, SWT.PUSH); + cancel.setText(" Cancel "); + cancel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false)); + cancel.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + SWTChartEditor.this.shell.dispose(); + } + }); + } + + /** + * Opens the editor. + */ + public void open() { + this.shell.open(); + this.shell.layout(); + while (!this.shell.isDisposed()) { + if (!this.shell.getDisplay().readAndDispatch()) { + this.shell.getDisplay().sleep(); + } + } + } + + /** + * Updates the chart properties. + * + * @param chart the chart. + */ + public void updateChart(JFreeChart chart) + { + this.titleEditor.setTitleProperties(chart); + this.plotEditor.updatePlotProperties(chart.getPlot()); + this.otherEditor.updateChartProperties(chart); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTNumberAxisEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTNumberAxisEditor.java new file mode 100755 index 0000000..d3d66aa --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTNumberAxisEditor.java @@ -0,0 +1,245 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * SWTNumberAxisEditor.java + * ------------------------ + * (C) Copyright 2006, 2007, by Henry Proudhon and Contributors. + * + * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 01-Aug-2006 : New class (HP); + * + */ + +package org.jfree.experimental.chart.swt.editor; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.FocusEvent; +import org.eclipse.swt.events.FocusListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.TabItem; +import org.eclipse.swt.widgets.Text; +import org.jfree.chart.axis.Axis; +import org.jfree.chart.axis.NumberAxis; + +/** + * An editor for {@link NumberAxis} properties. + */ +class SWTNumberAxisEditor extends SWTAxisEditor implements FocusListener { + + /** A flag that indicates whether or not the axis range is determined + * automatically. + */ + private boolean autoRange; + + /** The lowest value in the axis range. */ + private double minimumValue; + + /** The highest value in the axis range. */ + private double maximumValue; + + /** A checkbox that indicates whether or not the axis range is determined + * automatically. + */ + private Button autoRangeCheckBox; + + /** A text field for entering the minimum value in the axis range. */ + private Text minimumRangeValue; + + /** A text field for entering the maximum value in the axis range. */ + private Text maximumRangeValue; + + /** + * Creates a new editor. + * + * @param parent the parent. + * @param style the style. + * @param axis the axis. + */ + public SWTNumberAxisEditor(Composite parent, int style, NumberAxis axis) { + super(parent, style, axis); + this.autoRange = axis.isAutoRange(); + this.minimumValue = axis.getLowerBound(); + this.maximumValue = axis.getUpperBound(); + + TabItem item2 = new TabItem(getOtherTabs(), SWT.NONE); + item2.setText(" " + localizationResources.getString("Range") + " "); + Composite range = new Composite(getOtherTabs(), SWT.NONE); + range.setLayout(new GridLayout(2, true)); + item2.setControl(range); + + this.autoRangeCheckBox = new Button(range, SWT.CHECK); + this.autoRangeCheckBox.setText(localizationResources.getString( + "Auto-adjust_range")); + this.autoRangeCheckBox.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, + true, false, 2, 1)); + this.autoRangeCheckBox.setSelection(this.autoRange); + this.autoRangeCheckBox.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + toggleAutoRange(); + } + }); + new Label(range, SWT.NONE).setText(localizationResources.getString( + "Minimum_range_value")); + this.minimumRangeValue = new Text(range, SWT.BORDER); + this.minimumRangeValue.setText(String.valueOf(this.minimumValue)); + this.minimumRangeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, + true, false)); + this.minimumRangeValue.setEnabled(!this.autoRange); + //this.minimumRangeValue.addModifyListener(this); + //this.minimumRangeValue.addVerifyListener(this); + this.minimumRangeValue.addFocusListener(this); + new Label(range, SWT.NONE).setText(localizationResources.getString( + "Maximum_range_value")); + this.maximumRangeValue = new Text(range, SWT.BORDER); + this.maximumRangeValue.setText(String.valueOf(this.maximumValue)); + this.maximumRangeValue.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, + true, false)); + this.maximumRangeValue.setEnabled(!this.autoRange); + //this.maximumRangeValue.addModifyListener(this); + //this.maximumRangeValue.addVerifyListener(this); + this.maximumRangeValue.addFocusListener(this); + } + + /** + * Toggle the auto range setting. + */ + public void toggleAutoRange() { + this.autoRange = this.autoRangeCheckBox.getSelection(); + if (this.autoRange) { + this.minimumRangeValue.setText(Double.toString(this.minimumValue)); + this.minimumRangeValue.setEnabled(false); + this.maximumRangeValue.setText(Double.toString(this.maximumValue)); + this.maximumRangeValue.setEnabled(false); + } + else { + this.minimumRangeValue.setEnabled(true); + this.maximumRangeValue.setEnabled(true); + } + } + + /** + * Revalidate the range minimum: + * it should be less than the current maximum. + * + * @param candidate the minimum value + * + * @return A boolean. + */ + public boolean validateMinimum(String candidate) + { + boolean valid = true; + try { + if (Double.parseDouble(candidate) >= this.maximumValue) { + valid = false; + } + } + catch (NumberFormatException e) { + valid = false; + } + return valid; + } + + /** + * Revalidate the range maximum: + * it should be greater than the current minimum + * + * @param candidate the maximum value + * + * @return A boolean. + */ + public boolean validateMaximum(String candidate) + { + boolean valid = true; + try { + if (Double.parseDouble(candidate) <= this.minimumValue) { + valid = false; + } + } + catch (NumberFormatException e) { + valid = false; + } + return valid; + } + + /* (non-Javadoc) + * @see org.eclipse.swt.events.FocusListener#focusGained( + * org.eclipse.swt.events.FocusEvent) + */ + public void focusGained(FocusEvent e) { + // don't need to do anything + } + + /* (non-Javadoc) + * @see org.eclipse.swt.events.FocusListener#focusLost( + * org.eclipse.swt.events.FocusEvent) + */ + public void focusLost(FocusEvent e) { + if (e.getSource() == this.minimumRangeValue) { + // verify min value + if (!validateMinimum(this.minimumRangeValue.getText())) + this.minimumRangeValue.setText(String.valueOf( + this.minimumValue)); + else + this.minimumValue = Double.parseDouble( + this.minimumRangeValue.getText()); + } + else if (e.getSource() == this.maximumRangeValue) { + // verify max value + if (!validateMaximum(this.maximumRangeValue.getText())) + this.maximumRangeValue.setText(String.valueOf( + this.maximumValue)); + else + this.maximumValue = Double.parseDouble( + this.maximumRangeValue.getText()); + } + } + + /** + * Sets the properties of the specified axis to match + * the properties defined on this panel. + * + * @param axis the axis. + */ + public void setAxisProperties(Axis axis) { + super.setAxisProperties(axis); + NumberAxis numberAxis = (NumberAxis) axis; + numberAxis.setAutoRange(this.autoRange); + if (!this.autoRange) { + numberAxis.setRange(this.minimumValue, this.maximumValue); + } + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTOtherEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTOtherEditor.java new file mode 100755 index 0000000..862c20f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTOtherEditor.java @@ -0,0 +1,148 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * SWTOtherEditor.java + * ------------------- + * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. + * + * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 01-Aug-2006 : New class (HP); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * + */ + +package org.jfree.experimental.chart.swt.editor; + +import java.util.ResourceBundle; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.ColorDialog; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.experimental.swt.SWTPaintCanvas; +import org.jfree.experimental.swt.SWTUtils; + +/** + * An editor for miscellaneous chart properties. + */ +class SWTOtherEditor extends Composite { + + /** A checkbox indicating whether or not + * the chart is drawn with anti-aliasing. */ + private Button antialias; + + /** The chart background color. */ + private SWTPaintCanvas backgroundPaintCanvas; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.editor.LocalizationBundle"); + + /** + * Creates a new instance. + * + * @param parent the parent. + * @param style the style. + * @param chart the chart. + */ + public SWTOtherEditor(Composite parent, int style, JFreeChart chart) { + super(parent, style); + FillLayout layout = new FillLayout(); + layout.marginHeight = layout.marginWidth = 4; + setLayout(layout); + + Group general = new Group(this, SWT.NONE); + general.setLayout(new GridLayout(3, false)); + general.setText(localizationResources.getString("General")); + + // row 1: antialiasing + this.antialias = new Button(general, SWT.CHECK); + this.antialias.setText(localizationResources.getString( + "Draw_anti-aliased")); + this.antialias.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, + false, 3, 1)); + this.antialias.setSelection(chart.getAntiAlias()); + + //row 2: background paint for the chart + new Label(general, SWT.NONE).setText(localizationResources.getString( + "Background_paint")); + this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, + SWTUtils.toSwtColor(getDisplay(), chart.getBackgroundPaint())); + GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + bgGridData.heightHint = 20; + this.backgroundPaintCanvas.setLayoutData(bgGridData); + Button selectBgPaint = new Button(general, SWT.PUSH); + selectBgPaint.setText(localizationResources.getString("Select...")); + selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, + false)); + selectBgPaint.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + ColorDialog dlg = new ColorDialog(getShell()); + dlg.setText(localizationResources.getString( + "Background_paint")); + dlg.setRGB(SWTOtherEditor.this.backgroundPaintCanvas + .getColor().getRGB()); + RGB rgb = dlg.open(); + if (rgb != null) { + SWTOtherEditor.this.backgroundPaintCanvas.setColor( + new Color(getDisplay(), rgb)); + } + } + } + ); + } + + /** + * Updates the chart. + * + * @param chart the chart. + */ + public void updateChartProperties(JFreeChart chart) { + chart.setAntiAlias(this.antialias.getSelection()); + chart.setBackgroundPaint(SWTUtils.toAwtColor( + this.backgroundPaintCanvas.getColor())); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTPlotAppearanceEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTPlotAppearanceEditor.java new file mode 100755 index 0000000..cb7e413 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTPlotAppearanceEditor.java @@ -0,0 +1,277 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * SWTPlotAppearanceEditor.java + * ---------------------------- + * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. + * + * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 01-Aug-2006 : New class (HP); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * + */ + +package org.jfree.experimental.chart.swt.editor; + +import java.awt.BasicStroke; +import java.awt.Stroke; +import java.util.ResourceBundle; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.ColorDialog; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Spinner; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.experimental.swt.SWTPaintCanvas; +import org.jfree.experimental.swt.SWTUtils; + +/** + * An editor for plot properties. + */ +class SWTPlotAppearanceEditor extends Composite { + + private Spinner selectStroke; + + /** The stroke (pen) used to draw the outline of the plot. */ + private SWTStrokeCanvas strokeCanvas; + + /** The paint (color) used to fill the background of the plot. */ + private SWTPaintCanvas backgroundPaintCanvas; + + /** The paint (color) used to draw the outline of the plot. */ + private SWTPaintCanvas outlinePaintCanvas; + + /** The orientation for the plot. */ + private PlotOrientation plotOrientation; + + private Combo orientation; + + /** Orientation constants. */ + private final static String[] orientationNames = {"Vertical", "Horizontal"}; + private final static int ORIENTATION_VERTICAL = 0; + private final static int ORIENTATION_HORIZONTAL = 1; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.editor.LocalizationBundle"); + + SWTPlotAppearanceEditor(Composite parent, int style, Plot plot) { + super(parent, style); + FillLayout layout = new FillLayout(); + layout.marginHeight = layout.marginWidth = 4; + setLayout(layout); + + Group general = new Group(this, SWT.NONE); + GridLayout groupLayout = new GridLayout(3, false); + groupLayout.marginHeight = groupLayout.marginWidth = 4; + general.setLayout(groupLayout); + general.setText(localizationResources.getString("General")); + + // row 1: stroke + new Label(general, SWT.NONE).setText(localizationResources.getString( + "Outline_stroke")); + this.strokeCanvas = new SWTStrokeCanvas(general, SWT.NONE); + this.strokeCanvas.setStroke(plot.getOutlineStroke()); + GridData strokeGridData = new GridData(SWT.FILL, SWT.CENTER, true, + false); + strokeGridData.heightHint = 20; + this.strokeCanvas.setLayoutData(strokeGridData); + this.selectStroke = new Spinner(general, SWT.BORDER); + this.selectStroke.setMinimum(1); + this.selectStroke.setMaximum(3); + this.selectStroke.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, + false, false)); + this.selectStroke.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + int w = SWTPlotAppearanceEditor.this.selectStroke + .getSelection(); + if (w > 0) { + SWTPlotAppearanceEditor.this.strokeCanvas.setStroke( + new BasicStroke(w)); + SWTPlotAppearanceEditor.this.strokeCanvas.redraw(); + } + } + } + ); + // row 2: outline color + new Label(general, SWT.NONE).setText(localizationResources.getString( + "Outline_Paint")); + this.outlinePaintCanvas = new SWTPaintCanvas(general, SWT.NONE, + SWTUtils.toSwtColor(getDisplay(), plot.getOutlinePaint())); + GridData outlineGridData = new GridData(SWT.FILL, SWT.CENTER, true, + false); + outlineGridData.heightHint = 20; + this.outlinePaintCanvas.setLayoutData(outlineGridData); + Button selectOutlineColor = new Button(general, SWT.PUSH); + selectOutlineColor.setText(localizationResources.getString( + "Select...")); + selectOutlineColor.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, + false, false)); + selectOutlineColor.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + ColorDialog dlg = new ColorDialog(getShell()); + dlg.setText(localizationResources.getString( + "Outline_Paint")); + dlg.setRGB(SWTPlotAppearanceEditor.this + .outlinePaintCanvas.getColor().getRGB()); + RGB rgb = dlg.open(); + if (rgb != null) { + SWTPlotAppearanceEditor.this.outlinePaintCanvas + .setColor(new Color(getDisplay(), rgb)); + } + } + } + ); + // row 3: background paint + new Label(general, SWT.NONE).setText(localizationResources.getString( + "Background_paint")); + this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, + SWTUtils.toSwtColor(getDisplay(), plot.getBackgroundPaint())); + GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); + bgGridData.heightHint = 20; + this.backgroundPaintCanvas.setLayoutData(bgGridData); + Button selectBgPaint = new Button(general, SWT.PUSH); + selectBgPaint.setText(localizationResources.getString("Select...")); + selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, + false)); + selectBgPaint.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + ColorDialog dlg = new ColorDialog(getShell()); + dlg.setText(localizationResources.getString( + "Background_paint")); + dlg.setRGB(SWTPlotAppearanceEditor.this + .backgroundPaintCanvas.getColor().getRGB()); + RGB rgb = dlg.open(); + if (rgb != null) { + SWTPlotAppearanceEditor.this.backgroundPaintCanvas + .setColor(new Color(getDisplay(), rgb)); + } + } + } + ); + // row 4: orientation + if (plot instanceof CategoryPlot) { + this.plotOrientation = ((CategoryPlot) plot).getOrientation(); + } + else if (plot instanceof XYPlot) { + this.plotOrientation = ((XYPlot) plot).getOrientation(); + } + if (this.plotOrientation != null) { + boolean isVertical + = this.plotOrientation.equals(PlotOrientation.VERTICAL); + int index = isVertical ? ORIENTATION_VERTICAL + : ORIENTATION_HORIZONTAL; + new Label(general, SWT.NONE).setText( + localizationResources.getString("Orientation")); + this.orientation = new Combo(general, SWT.DROP_DOWN); + this.orientation.setItems(orientationNames); + this.orientation.select(index); + this.orientation.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, + true, false, 2, 1)); + this.orientation.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + switch (SWTPlotAppearanceEditor.this.orientation + .getSelectionIndex()) { + case ORIENTATION_VERTICAL: + SWTPlotAppearanceEditor.this.plotOrientation + = PlotOrientation.VERTICAL; + break; + case ORIENTATION_HORIZONTAL: + SWTPlotAppearanceEditor.this.plotOrientation + = PlotOrientation.HORIZONTAL; + break; + default: + SWTPlotAppearanceEditor.this.plotOrientation + = PlotOrientation.VERTICAL; + } + } + } + ); + } + } + + /** + * Returns the plot orientation. + * + * @return The plot orientation. + */ + public PlotOrientation getPlotOrientation() { + return this.plotOrientation; + } + + /** + * Returns the background paint. + * + * @return The background paint. + */ + public Color getBackGroundPaint() { + return this.backgroundPaintCanvas.getColor(); + } + + /** + * Returns the outline paint. + * + * @return The outline paint. + */ + public Color getOutlinePaint() { + return this.outlinePaintCanvas.getColor(); + } + + /** + * Returns the stroke. + * + * @return The stroke. + */ + public Stroke getStroke() { + return this.strokeCanvas.getStroke(); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTPlotEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTPlotEditor.java new file mode 100755 index 0000000..f820d3a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTPlotEditor.java @@ -0,0 +1,219 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * SWTPlotEditor.java + * ------------------ + * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. + * + * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 01-Aug-2006 : New class (HP); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * + */ + +package org.jfree.experimental.chart.swt.editor; + +import java.awt.Stroke; +import java.util.ResourceBundle; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.TabFolder; +import org.eclipse.swt.widgets.TabItem; +import org.jfree.chart.axis.Axis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.Plot; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.experimental.swt.SWTUtils; + +/** + * An editor for plot properties. + */ +class SWTPlotEditor extends Composite { + + /** + * A panel used to display/edit the properties of the domain axis (if any). + */ + private SWTAxisEditor domainAxisPropertyPanel; + + /** + * A panel used to display/edit the properties of the range axis (if any). + */ + private SWTAxisEditor rangeAxisPropertyPanel; + + private SWTPlotAppearanceEditor plotAppearance; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.editor.LocalizationBundle"); + + /** + * Creates a new editor for the specified plot. + * + * @param parent the parent. + * @param style the style. + * @param plot the plot. + */ + public SWTPlotEditor(Composite parent, int style, Plot plot) { + super(parent, style); + FillLayout layout = new FillLayout(); + layout.marginHeight = layout.marginWidth = 4; + setLayout(layout); + + Group plotType = new Group(this, SWT.NONE); + FillLayout plotTypeLayout = new FillLayout(); + plotTypeLayout.marginHeight = plotTypeLayout.marginWidth = 4; + plotType.setLayout(plotTypeLayout); + plotType.setText(plot.getPlotType() + localizationResources.getString( + ":")); + + TabFolder tabs = new TabFolder(plotType, SWT.NONE); + + //deal with domain axis + TabItem item1 = new TabItem(tabs, SWT.NONE); + item1.setText(localizationResources.getString("Domain_Axis")); + Axis domainAxis = null; + if (plot instanceof CategoryPlot) { + domainAxis = ((CategoryPlot) plot).getDomainAxis(); + } + else if (plot instanceof XYPlot) { + domainAxis = ((XYPlot) plot).getDomainAxis(); + } + this.domainAxisPropertyPanel = SWTAxisEditor.getInstance(tabs, + SWT.NONE, domainAxis); + item1.setControl(this.domainAxisPropertyPanel); + + //deal with range axis + TabItem item2 = new TabItem(tabs, SWT.NONE); + item2.setText(localizationResources.getString("Range_Axis")); + Axis rangeAxis = null; + if (plot instanceof CategoryPlot) { + rangeAxis = ((CategoryPlot) plot).getRangeAxis(); + } + else if (plot instanceof XYPlot) { + rangeAxis = ((XYPlot) plot).getRangeAxis(); + } + this.rangeAxisPropertyPanel = SWTAxisEditor.getInstance(tabs, SWT.NONE, + rangeAxis); + item2.setControl(this.rangeAxisPropertyPanel); + + //deal with plot appearance + TabItem item3 = new TabItem(tabs, SWT.NONE); + item3.setText(localizationResources.getString("Appearance")); + this.plotAppearance = new SWTPlotAppearanceEditor(tabs, SWT.NONE, plot); + item3.setControl(this.plotAppearance); + } + + /** + * Returns the current outline stroke. + * + * @return The current outline stroke. + */ + public Color getBackgroundPaint() { + return this.plotAppearance.getBackGroundPaint(); + } + + /** + * Returns the current outline stroke. + * + * @return The current outline stroke. + */ + public Color getOutlinePaint() { + return this.plotAppearance.getOutlinePaint(); + } + + /** + * Returns the current outline stroke. + * + * @return The current outline stroke. + */ + public Stroke getOutlineStroke() { + return this.plotAppearance.getStroke(); + } + + + /** + * Updates the plot properties to match the properties + * defined on the panel. + * + * @param plot The plot. + */ + public void updatePlotProperties(Plot plot) { + // set the plot properties... + plot.setBackgroundPaint(SWTUtils.toAwtColor(getBackgroundPaint())); + plot.setOutlinePaint(SWTUtils.toAwtColor(getOutlinePaint())); + plot.setOutlineStroke(getOutlineStroke()); + + // set the axis properties + if (this.domainAxisPropertyPanel != null) { + Axis domainAxis = null; + if (plot instanceof CategoryPlot) { + CategoryPlot p = (CategoryPlot) plot; + domainAxis = p.getDomainAxis(); + } + else if (plot instanceof XYPlot) { + XYPlot p = (XYPlot) plot; + domainAxis = p.getDomainAxis(); + } + if (domainAxis != null) + this.domainAxisPropertyPanel.setAxisProperties(domainAxis); + } + if (this.rangeAxisPropertyPanel != null) { + Axis rangeAxis = null; + if (plot instanceof CategoryPlot) { + CategoryPlot p = (CategoryPlot) plot; + rangeAxis = p.getRangeAxis(); + } + else if (plot instanceof XYPlot) { + XYPlot p = (XYPlot) plot; + rangeAxis = p.getRangeAxis(); + } + if (rangeAxis != null) + this.rangeAxisPropertyPanel.setAxisProperties(rangeAxis); + } + if (this.plotAppearance.getPlotOrientation() != null) { + if (plot instanceof CategoryPlot) { + CategoryPlot p = (CategoryPlot) plot; + p.setOrientation(this.plotAppearance.getPlotOrientation()); + } + else if (plot instanceof XYPlot) { + XYPlot p = (XYPlot) plot; + p.setOrientation(this.plotAppearance.getPlotOrientation()); + } + } + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTStrokeCanvas.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTStrokeCanvas.java new file mode 100755 index 0000000..9d7779a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTStrokeCanvas.java @@ -0,0 +1,124 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * SWTStrokeCanvas.java + * -------------------- + * (C) Copyright 2006, by Henry Proudhon and Contributors. + * + * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 01-Aug-2006 : New class (HP); + * + */ + +package org.jfree.experimental.chart.swt.editor; + +import java.awt.BasicStroke; +import java.awt.Stroke; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.graphics.Transform; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; + +/** + * A control for displaying a Stroke sample. + */ +class SWTStrokeCanvas extends Canvas { + + /** + * Creates a new instance. + * + * @param parent the parent. + * @param style the style. + * @param image the image. + */ + public SWTStrokeCanvas(Composite parent, int style, Image image) { + this(parent, style); + } + + /** + * Creates a new instance. + * + * @param parent the parent. + * @param style the style. + */ + public SWTStrokeCanvas(Composite parent, int style) { + super(parent, style); + addPaintListener(new PaintListener() { + public void paintControl(PaintEvent e) { + BasicStroke stroke = (BasicStroke) getStroke(); + if (stroke != null) { + int x, y; + Rectangle rect = getClientArea(); + x = (rect.width - 100) / 2; + y = (rect.height - 16) / 2; + Transform swtTransform = new Transform(e.gc.getDevice()); + e.gc.getTransform(swtTransform); + swtTransform.translate(x, y); + e.gc.setTransform(swtTransform); + swtTransform.dispose(); + e.gc.setBackground(getDisplay().getSystemColor( + SWT.COLOR_BLACK)); + e.gc.setLineWidth((int) stroke.getLineWidth()); + e.gc.drawLine(10, 8, 90, 8); + } + } + }); + } + + /** + * Sets the stroke. + * + * @param stroke the stroke. + */ + public void setStroke(Stroke stroke) { + if (stroke instanceof BasicStroke) { + setData(stroke); + } + else { + throw new RuntimeException( + "Can only handle 'Basic Stroke' at present."); + } + } + + /** + * Returns the stroke. + * + * @return The stroke. + */ + public BasicStroke getStroke() { + return (BasicStroke) this.getData(); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTTitleEditor.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTTitleEditor.java new file mode 100755 index 0000000..7cbdcdd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/chart/swt/editor/SWTTitleEditor.java @@ -0,0 +1,281 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * SWTTitleEditor.java + * ------------------- + * (C) Copyright 2006-2008, by Henry Proudhon and Contributors. + * + * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 01-Aug-2006 : New class (HP); + * 18-Dec-2008 : Use ResourceBundleWrapper - see patch 1607918 by + * Jess Thrysoee (DG); + * + */ + +package org.jfree.experimental.chart.swt.editor; + +import java.util.ResourceBundle; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.layout.FillLayout; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.ColorDialog; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.FontDialog; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.title.TextTitle; +import org.jfree.chart.title.Title; +import org.jfree.chart.util.ResourceBundleWrapper; +import org.jfree.experimental.swt.SWTPaintCanvas; +import org.jfree.experimental.swt.SWTUtils; + +/** + * An editor for chart title properties. + */ +class SWTTitleEditor extends Composite { + + /** Whether or not to display the title on the chart. */ + private boolean showTitle; + + /** The checkbox to indicate whether or not to display the title. */ + private Button showTitleCheckBox; + + /** A field for displaying/editing the title text. */ + private Text titleField; + + /** The font used to draw the title. */ + private FontData titleFont; + + /** A field for displaying a description of the title font. */ + private Text fontField; + + /** The button to use to select a new title font. */ + private Button selectFontButton; + + /** The paint (color) used to draw the title. */ + private Color titleColor; + + /** The button to use to select a new paint (color) to draw the title. */ + private Button selectColorButton; + + /** The resourceBundle for the localization. */ + protected static ResourceBundle localizationResources + = ResourceBundleWrapper.getBundle( + "org.jfree.chart.editor.LocalizationBundle"); + + /** Font object used to handle a change of font. */ + private Font font; + + /** + * Standard constructor: builds a panel for displaying/editing the + * properties of the specified title. + * + * @param parent the parent. + * @param style the style. + * @param title the title, which should be changed. + * + */ + SWTTitleEditor(Composite parent, int style, Title title) { + super(parent, style); + FillLayout layout = new FillLayout(); + layout.marginHeight = layout.marginWidth = 4; + setLayout(layout); + + TextTitle t = (title != null ? (TextTitle) title + : new TextTitle(localizationResources.getString("Title"))); + this.showTitle = (title != null); + this.titleFont = SWTUtils.toSwtFontData(getDisplay(), t.getFont(), + true); + this.titleColor = SWTUtils.toSwtColor(getDisplay(), t.getPaint()); + + Group general = new Group(this, SWT.NONE); + general.setLayout(new GridLayout(3, false)); + general.setText(localizationResources.getString("General")); + // row 1 + Label label = new Label(general, SWT.NONE); + label.setText(localizationResources.getString("Show_Title")); + GridData gridData = new GridData(); + gridData.horizontalSpan = 2; + label.setLayoutData(gridData); + this.showTitleCheckBox = new Button(general, SWT.CHECK); + this.showTitleCheckBox.setSelection(this.showTitle); + this.showTitleCheckBox.setLayoutData(new GridData(SWT.CENTER, + SWT.CENTER, false, false)); + this.showTitleCheckBox.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + SWTTitleEditor.this.showTitle = SWTTitleEditor.this + .showTitleCheckBox.getSelection(); + } + }); + // row 2 + new Label(general, SWT.NONE).setText(localizationResources.getString( + "Text")); + this.titleField = new Text(general, SWT.BORDER); + this.titleField.setText(t.getText()); + this.titleField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, + false)); + new Label(general, SWT.NONE).setText(""); + // row 3 + new Label(general, SWT.NONE).setText(localizationResources.getString( + "Font")); + this.fontField = new Text(general, SWT.BORDER); + this.fontField.setText(this.titleFont.toString()); + this.fontField.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, + false)); + this.selectFontButton = new Button(general, SWT.PUSH); + this.selectFontButton.setText(localizationResources.getString( + "Select...")); + this.selectFontButton.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + // Create the font-change dialog + FontDialog dlg = new FontDialog(getShell()); + dlg.setText(localizationResources.getString( + "Font_Selection")); + dlg.setFontList(new FontData[] { + SWTTitleEditor.this.titleFont }); + if (dlg.open() != null) { + // Dispose of any fonts we have created + if (SWTTitleEditor.this.font != null) { + SWTTitleEditor.this.font.dispose(); + } + // Create the new font and set it into the title + // label + SWTTitleEditor.this.font = new Font( + getShell().getDisplay(), dlg.getFontList()); + //titleField.setFont(font); + SWTTitleEditor.this.fontField.setText( + SWTTitleEditor.this.font.getFontData()[0] + .toString()); + SWTTitleEditor.this.titleFont + = SWTTitleEditor.this.font.getFontData()[0]; + } + } + } + ); + // row 4 + new Label(general, SWT.NONE).setText(localizationResources.getString( + "Color")); + // Use a SwtPaintCanvas to show the color, note that we must set the + // heightHint. + final SWTPaintCanvas colorCanvas = new SWTPaintCanvas(general, + SWT.NONE, this.titleColor); + GridData canvasGridData = new GridData(SWT.FILL, SWT.CENTER, true, + false); + canvasGridData.heightHint = 20; + colorCanvas.setLayoutData(canvasGridData); + this.selectColorButton = new Button(general, SWT.PUSH); + this.selectColorButton.setText(localizationResources.getString( + "Select...")); + this.selectColorButton.addSelectionListener( + new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + // Create the color-change dialog + ColorDialog dlg = new ColorDialog(getShell()); + dlg.setText(localizationResources.getString( + "Title_Color")); + dlg.setRGB(SWTTitleEditor.this.titleColor.getRGB()); + RGB rgb = dlg.open(); + if (rgb != null) { + // create the new color and set it to the + // SwtPaintCanvas + SWTTitleEditor.this.titleColor = new Color( + getDisplay(), rgb); + colorCanvas.setColor( + SWTTitleEditor.this.titleColor); + } + } + } + ); + } + + /** + * Returns the title text entered in the panel. + * + * @return The title text entered in the panel. + */ + public String getTitleText() { + return this.titleField.getText(); + } + + /** + * Returns the font selected in the panel. + * + * @return The font selected in the panel. + */ + public FontData getTitleFont() { + return this.titleFont; + } + + /** + * Returns the font selected in the panel. + * + * @return The font selected in the panel. + */ + public Color getTitleColor() { + return this.titleColor; + } + + /** + * Sets the properties of the specified title to match the properties + * defined on this panel. + * + * @param chart the chart whose title is to be modified. + */ + public void setTitleProperties(JFreeChart chart) { + if (this.showTitle) { + TextTitle title = chart.getTitle(); + if (title == null) { + title = new TextTitle(); + chart.setTitle(title); + } + title.setText(getTitleText()); + title.setFont(SWTUtils.toAwtFont(getDisplay(), getTitleFont(), + true)); + title.setPaint(SWTUtils.toAwtColor(getTitleColor())); + } + else { + chart.setTitle((TextTitle) null); + } + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/swt/SWTGraphics2D.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/swt/SWTGraphics2D.java new file mode 100755 index 0000000..2f20b56 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/swt/SWTGraphics2D.java @@ -0,0 +1,1512 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * SWTGraphics2D.java + * ------------------ + * (C) Copyright 2006-2013, by Henry Proudhon and Contributors. + * + * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); + * Contributor(s): Cedric Chabanois (cchabanois AT no-log.org); + * David Gilbert (for Object Refinery Limited); + * Ronnie Duan (see bug report 2583891); + * Kevin Xu (parts of patch 3506228); + * + * Changes + * ------- + * 14-Jun-2006 : New class (HP); + * 29-Jan-2007 : Fixed the fillRect method (HP); + * 31-Jan-2007 : Moved the dummy JPanel to SWTUtils.java, + * implemented the drawLine method (HP); + * 07-Apr-2007 : Dispose some of the swt ressources, + * thanks to silent for pointing this out (HP); + * 23-May-2007 : Removed resource leaks by adding a resource pool (CC); + * 15-Jun-2007 : Fixed compile error for JDK 1.4 (DG); + * 22-Oct-2007 : Implemented clipping (HP); + * 22-Oct-2007 : Implemented some AlphaComposite support (HP); + * 23-Oct-2007 : Added mechanism for storing RenderingHints (which are + * still ignored at this point) (DG); + * 23-Oct-2007 : Implemented drawPolygon(), drawPolyline(), drawOval(), + * fillOval(), drawArc() and fillArc() (DG); + * 27-Nov-2007 : Implemented a couple of drawImage() methods (DG); + * 18-Nov-2008 : Check for GradientPaint in setPaint() method (DG); + * 27-Feb-2009 : Implemented fillPolygon() - see bug 2583891 (DG); + * 04-Jul-2012 : Fixed get/setStroke() - see bug 3514487 (DG); + * 18-Sep-2012 : Fixed missing text - see bug 3482106 and patch 3506228 (DG); + * 03-Jul-2013 : Use ParamChecks (DG); + * + */ + +package org.jfree.experimental.swt; + +import java.awt.AlphaComposite; +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Composite; +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.GradientPaint; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GraphicsConfiguration; +import java.awt.Image; +import java.awt.Paint; +import java.awt.Rectangle; +import java.awt.RenderingHints; +import java.awt.RenderingHints.Key; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; +import java.awt.geom.AffineTransform; +import java.awt.geom.Area; +import java.awt.geom.PathIterator; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.awt.image.BufferedImageOp; +import java.awt.image.ImageObserver; +import java.awt.image.RenderedImage; +import java.awt.image.renderable.RenderableImage; +import java.text.AttributedCharacterIterator; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.Path; +import org.eclipse.swt.graphics.Resource; +import org.eclipse.swt.graphics.Transform; +import org.jfree.chart.util.ParamChecks; + +/** + * This is a class utility to draw Graphics2D stuff on a swt composite. + * It is presently developed to use JFreeChart with the Standard + * Widget Toolkit but may be of a wider use later. + */ +public class SWTGraphics2D extends Graphics2D { + + /** The swt graphic composite */ + private GC gc; + + /** + * The rendering hints. For now, these are not used, but at least the + * basic mechanism is present. + */ + private RenderingHints hints; + + /** A reference to the compositing rule to apply. This is necessary + * due to the poor compositing interface of the SWT toolkit. */ + private java.awt.Composite composite; + + /** A HashMap to store the Swt color resources. */ + private Map colorsPool = new HashMap(); + + /** A HashMap to store the Swt font resources. */ + private Map fontsPool = new HashMap(); + + /** A HashMap to store the Swt transform resources. */ + private Map transformsPool = new HashMap(); + + /** A List to store the Swt resources. */ + private List resourcePool = new ArrayList(); + + /** + * Creates a new instance. + * + * @param gc the graphics context. + */ + public SWTGraphics2D(GC gc) { + super(); + this.gc = gc; + this.hints = new RenderingHints(null); + this.composite = AlphaComposite.getInstance(AlphaComposite.SRC, 1.0f); + setStroke(new BasicStroke()); + } + + /** + * Not implemented yet - see {@link Graphics#create()}. + * + * @return null. + */ + public Graphics create() { + // TODO Auto-generated method stub + return null; + } + + /** + * Not implemented yet - see {@link Graphics2D#getDeviceConfiguration()}. + * + * @return null. + */ + public GraphicsConfiguration getDeviceConfiguration() { + // TODO Auto-generated method stub + return null; + } + + /** + * Returns the current value for the specified hint key, or + * null if no value is set. + * + * @param hintKey the hint key (null permitted). + * + * @return The hint value, or null. + * + * @see #setRenderingHint(RenderingHints.Key, Object) + */ + public Object getRenderingHint(Key hintKey) { + return this.hints.get(hintKey); + } + + /** + * Sets the value for a rendering hint. For now, this graphics context + * ignores all hints. + * + * @param hintKey the key (null not permitted). + * @param hintValue the value (must be compatible with the specified key). + * + * @throws IllegalArgumentException if hintValue is not + * compatible with the hintKey. + * + * @see #getRenderingHint(RenderingHints.Key) + */ + public void setRenderingHint(Key hintKey, Object hintValue) { + this.hints.put(hintKey, hintValue); + } + + /** + * Returns a copy of the hints collection for this graphics context. + * + * @return A copy of the hints collection. + */ + public RenderingHints getRenderingHints() { + return (RenderingHints) this.hints.clone(); + } + + /** + * Adds the hints in the specified map to the graphics context, replacing + * any existing hints. For now, this graphics context ignores all hints. + * + * @param hints the hints (null not permitted). + * + * @see #setRenderingHints(Map) + */ + public void addRenderingHints(Map hints) { + this.hints.putAll(hints); + } + + /** + * Replaces the existing hints with those contained in the specified + * map. Note that, for now, this graphics context ignores all hints. + * + * @param hints the hints (null not permitted). + * + * @see #addRenderingHints(Map) + */ + public void setRenderingHints(Map hints) { + if (hints == null) { + throw new NullPointerException("Null 'hints' argument."); + } + this.hints = new RenderingHints(hints); + } + + /** + * Returns the current paint for this graphics context. + * + * @return The current paint. + * + * @see #setPaint(Paint) + */ + public Paint getPaint() { + // TODO: it might be a good idea to keep a reference to the color + // specified in setPaint() or setColor(), rather than creating a + // new object every time getPaint() is called. + return SWTUtils.toAwtColor(this.gc.getForeground()); + } + + /** + * Sets the paint for this graphics context. For now, this graphics + * context only supports instances of {@link Color} or + * {@link GradientPaint} (in the latter case there is no real gradient + * support, the paint used is the Color returned by + * getColor1()). + * + * @param paint the paint (null permitted, ignored). + * + * @see #getPaint() + * @see #setColor(Color) + */ + public void setPaint(Paint paint) { + if (paint == null) { + return; // to be consistent with other Graphics2D implementations + } + if (paint instanceof Color) { + setColor((Color) paint); + } + else if (paint instanceof GradientPaint) { + GradientPaint gp = (GradientPaint) paint; + setColor(gp.getColor1()); + } + else { + throw new RuntimeException("Can only handle 'Color' at present."); + } + } + + /** + * Returns the current color for this graphics context. + * + * @return The current color. + * + * @see #setColor(Color) + */ + public Color getColor() { + // TODO: it might be a good idea to keep a reference to the color + // specified in setPaint() or setColor(), rather than creating a + // new object every time getPaint() is called. + return SWTUtils.toAwtColor(this.gc.getForeground()); + } + + /** + * Sets the current color for this graphics context. + * + * @param color the color (null permitted but ignored). + * + * @see #getColor() + */ + public void setColor(Color color) { + if (color == null) { + return; + } + org.eclipse.swt.graphics.Color swtColor = getSwtColorFromPool(color); + this.gc.setForeground(swtColor); + // handle transparency and compositing. + if (this.composite instanceof AlphaComposite) { + AlphaComposite acomp = (AlphaComposite) this.composite; + switch (acomp.getRule()) { + case AlphaComposite.SRC_OVER: + this.gc.setAlpha((int) (color.getAlpha() * acomp.getAlpha())); + break; + default: + this.gc.setAlpha(color.getAlpha()); + break; + } + } + } + + private Color backgroundColor; + + /** + * Sets the background colour. + * + * @param color the colour. + */ + public void setBackground(Color color) { + // since this is only used by clearRect(), we don't update the GC yet + this.backgroundColor = color; + } + + /** + * Returns the background colour. + * + * @return The background colour (possibly null).. + */ + public Color getBackground() { + return this.backgroundColor; + } + + /** + * Not implemented - see {@link Graphics#setPaintMode()}. + */ + public void setPaintMode() { + // TODO Auto-generated method stub + } + + /** + * Not implemented - see {@link Graphics#setXORMode(Color)}. + * + * @param color the colour. + */ + public void setXORMode(Color color) { + // TODO Auto-generated method stub + } + + /** + * Returns the current composite. + * + * @return The current composite. + * + * @see #setComposite(Composite) + */ + public Composite getComposite() { + return this.composite; + } + + /** + * Sets the current composite. This implementation currently supports + * only the {@link AlphaComposite} class. + * + * @param comp the composite (null not permitted). + */ + public void setComposite(Composite comp) { + if (comp == null) { + throw new IllegalArgumentException("Null 'comp' argument."); + } + this.composite = comp; + if (comp instanceof AlphaComposite) { + AlphaComposite acomp = (AlphaComposite) comp; + int alpha = (int) (acomp.getAlpha() * 0xFF); + this.gc.setAlpha(alpha); + } + } + + /** + * Returns the current stroke for this graphics context. + * + * @return The current stroke. + * + * @see #setStroke(Stroke) + */ + public Stroke getStroke() { + return new BasicStroke(this.gc.getLineWidth(), + toAwtLineCap(this.gc.getLineCap()), + toAwtLineJoin(this.gc.getLineJoin())); + } + + /** + * Sets the stroke for this graphics context. For now, this implementation + * only recognises the {@link BasicStroke} class. + * + * @param stroke the stroke (null not permitted). + * + * @see #getStroke() + */ + public void setStroke(Stroke stroke) { + if (stroke == null) { + throw new IllegalArgumentException("Null 'stroke' argument."); + } + if (stroke instanceof BasicStroke) { + BasicStroke bs = (BasicStroke) stroke; + this.gc.setLineWidth((int) bs.getLineWidth()); + this.gc.setLineJoin(toSwtLineJoin(bs.getLineJoin())); + this.gc.setLineCap(toSwtLineCap(bs.getEndCap())); + + // set the line style to solid by default + this.gc.setLineStyle(SWT.LINE_SOLID); + + // apply dash style if any + float[] dashes = bs.getDashArray(); + if (dashes != null) { + int[] swtDashes = new int[dashes.length]; + for (int i = 0; i < swtDashes.length; i++) { + swtDashes[i] = (int) dashes[i]; + } + this.gc.setLineDash(swtDashes); + } + } + else { + throw new RuntimeException( + "Can only handle 'Basic Stroke' at present."); + } + } + + /** + * Applies the specified clip. + * + * @param s the shape for the clip. + */ + public void clip(Shape s) { + Path path = toSwtPath(s); + this.gc.setClipping(path); + path.dispose(); + } + + /** + * Returns the clip bounds. + * + * @return The clip bounds. + */ + public Rectangle getClipBounds() { + org.eclipse.swt.graphics.Rectangle clip = this.gc.getClipping(); + return new Rectangle(clip.x, clip.y, clip.width, clip.height); + } + + /** + * Sets the clipping to the intersection of the current clip region and + * the specified rectangle. + * + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param width the width. + * @param height the height. + */ + public void clipRect(int x, int y, int width, int height) { + org.eclipse.swt.graphics.Rectangle clip = this.gc.getClipping(); + org.eclipse.swt.graphics.Rectangle r + = new org.eclipse.swt.graphics.Rectangle(x, y, width, height); + clip.intersect(r); + this.gc.setClipping(clip); + } + + /** + * Returns the current clip. + * + * @return The current clip. + */ + public Shape getClip() { + return SWTUtils.toAwtRectangle(this.gc.getClipping()); + } + + /** + * Sets the clip region. + * + * @param clip the clip. + */ + public void setClip(Shape clip) { + if (clip == null) { + return; + } + Path clipPath = toSwtPath(clip); + this.gc.setClipping(clipPath); + clipPath.dispose(); + } + + /** + * Sets the clip region to the specified rectangle. + * + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param width the width. + * @param height the height. + */ + public void setClip(int x, int y, int width, int height) { + this.gc.setClipping(x, y, width, height); + } + + /** + * Returns the current transform. + * + * @return The current transform. + */ + public AffineTransform getTransform() { + Transform swtTransform = new Transform(this.gc.getDevice()); + this.gc.getTransform(swtTransform); + AffineTransform awtTransform = toAwtTransform(swtTransform); + swtTransform.dispose(); + return awtTransform; + } + + /** + * Sets the current transform. + * + * @param t the transform. + */ + public void setTransform(AffineTransform t) { + Transform transform = getSwtTransformFromPool(t); + this.gc.setTransform(transform); + } + + /** + * Concatenates the specified transform to the existing transform. + * + * @param t the transform. + */ + public void transform(AffineTransform t) { + Transform swtTransform = new Transform(this.gc.getDevice()); + this.gc.getTransform(swtTransform); + swtTransform.multiply(getSwtTransformFromPool(t)); + this.gc.setTransform(swtTransform); + swtTransform.dispose(); + } + + /** + * Applies a translation. + * + * @param x the translation along the x-axis. + * @param y the translation along the y-axis. + */ + public void translate(int x, int y) { + Transform swtTransform = new Transform(this.gc.getDevice()); + this.gc.getTransform(swtTransform); + swtTransform.translate(x, y); + this.gc.setTransform(swtTransform); + swtTransform.dispose(); + } + + /** + * Applies a translation. + * + * @param tx the translation along the x-axis. + * @param ty the translation along the y-axis. + */ + public void translate(double tx, double ty) { + translate((int) tx, (int) ty); + } + + /** + * Applies a rotation transform. + * + * @param theta the angle of rotation. + */ + public void rotate(double theta) { + AffineTransform t = getTransform(); + t.rotate(theta); + setTransform(t); + } + + /** + * Not implemented - see {@link Graphics2D#rotate(double, double, double)}. + * + * @see java.awt.Graphics2D#rotate(double, double, double) + */ + public void rotate(double theta, double x, double y) { + translate(x, y); + rotate(theta); + translate(-x, -y); + } + + /** + * Applies a scale transform. + * + * @param scaleX the scale factor along the x-axis. + * @param scaleY the scale factor along the y-axis. + */ + public void scale(double scaleX, double scaleY) { + Transform swtTransform = new Transform(this.gc.getDevice()); + this.gc.getTransform(swtTransform); + swtTransform.scale((float) scaleX, (float) scaleY); + this.gc.setTransform(swtTransform); + swtTransform.dispose(); + } + + /** + * Applies a shear transform. + * + * @param shearX the x-factor. + * @param shearY the y-factor. + */ + public void shear(double shearX, double shearY) { + transform(AffineTransform.getShearInstance(shearX, shearY)); + } + + /** + * Draws the outline of the specified shape using the current stroke and + * paint settings. + * + * @param shape the shape (null not permitted). + * + * @see #getPaint() + * @see #getStroke() + * @see #fill(Shape) + */ + public void draw(Shape shape) { + Path path = toSwtPath(shape); + this.gc.drawPath(path); + path.dispose(); + } + + /** + * Draws a line from (x1, y1) to (x2, y2) using the current stroke + * and paint settings. + * + * @param x1 the x-coordinate for the starting point. + * @param y1 the y-coordinate for the starting point. + * @param x2 the x-coordinate for the ending point. + * @param y2 the y-coordinate for the ending point. + * + * @see #draw(Shape) + */ + public void drawLine(int x1, int y1, int x2, int y2) { + this.gc.drawLine(x1, y1, x2, y2); + } + + /** + * Draws the outline of the polygon specified by the given points, using + * the current paint and stroke settings. + * + * @param xPoints the x-coordinates. + * @param yPoints the y-coordinates. + * @param npoints the number of points in the polygon. + * + * @see #draw(Shape) + */ + public void drawPolygon(int [] xPoints, int [] yPoints, int npoints) { + drawPolyline(xPoints, yPoints, npoints); + if (npoints > 1) { + this.gc.drawLine(xPoints[npoints - 1], yPoints[npoints - 1], + xPoints[0], yPoints[0]); + } + } + + /** + * Draws a sequence of connected lines specified by the given points, using + * the current paint and stroke settings. + * + * @param xPoints the x-coordinates. + * @param yPoints the y-coordinates. + * @param npoints the number of points in the polygon. + * + * @see #draw(Shape) + */ + public void drawPolyline(int [] xPoints, int [] yPoints, int npoints) { + if (npoints > 1) { + int x0 = xPoints[0]; + int y0 = yPoints[0]; + int x1 = 0, y1 = 0; + for (int i = 1; i < npoints; i++) { + x1 = xPoints[i]; + y1 = yPoints[i]; + this.gc.drawLine(x0, y0, x1, y1); + x0 = x1; + y0 = y1; + } + } + } + + /** + * Draws an oval that fits within the specified rectangular region. + * + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param width the frame width. + * @param height the frame height. + * + * @see #fillOval(int, int, int, int) + * @see #draw(Shape) + */ + public void drawOval(int x, int y, int width, int height) { + this.gc.drawOval(x, y, width - 1, height - 1); + } + + /** + * Draws an arc that is part of an ellipse that fits within the specified + * framing rectangle. + * + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param width the frame width. + * @param height the frame height. + * @param arcStart the arc starting point, in degrees. + * @param arcAngle the extent of the arc. + * + * @see #fillArc(int, int, int, int, int, int) + */ + public void drawArc(int x, int y, int width, int height, int arcStart, + int arcAngle) { + this.gc.drawArc(x, y, width - 1, height - 1, arcStart, arcAngle); + } + + /** + * Draws a rectangle with rounded corners that fits within the specified + * framing rectangle. + * + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param width the frame width. + * @param height the frame height. + * @param arcWidth the width of the arc defining the roundedness of the + * rectangle's corners. + * @param arcHeight the height of the arc defining the roundedness of the + * rectangle's corners. + * + * @see #fillRoundRect(int, int, int, int, int, int) + */ + public void drawRoundRect(int x, int y, int width, int height, + int arcWidth, int arcHeight) { + this.gc.drawRoundRectangle(x, y, width - 1, height - 1, arcWidth, + arcHeight); + } + + /** + * Fills the specified shape using the current paint. + * + * @param shape the shape (null not permitted). + * + * @see #getPaint() + * @see #draw(Shape) + */ + public void fill(Shape shape) { + Path path = toSwtPath(shape); + // Note that for consistency with the AWT implementation, it is + // necessary to switch temporarily the foreground and background + // colours + switchColors(); + this.gc.fillPath(path); + switchColors(); + path.dispose(); + } + + /** + * Fill a rectangle area on the swt graphic composite. + * The fillRectangle method of the GC + * class uses the background color so we must switch colors. + * @see java.awt.Graphics#fillRect(int, int, int, int) + */ + public void fillRect(int x, int y, int width, int height) { + this.switchColors(); + this.gc.fillRectangle(x, y, width, height); + this.switchColors(); + } + + /** + * Fills the specified rectangle with the current background colour. + * + * @param x the x-coordinate for the rectangle. + * @param y the y-coordinate for the rectangle. + * @param width the width. + * @param height the height. + * + * @see #fillRect(int, int, int, int) + */ + public void clearRect(int x, int y, int width, int height) { + Color bgcolor = getBackground(); + if (bgcolor == null) { + return; // we can't do anything + } + Paint saved = getPaint(); + setPaint(bgcolor); + fillRect(x, y, width, height); + setPaint(saved); + } + + /** + * Fills the specified polygon. + * + * @param xPoints the x-coordinates. + * @param yPoints the y-coordinates. + * @param npoints the number of points. + */ + public void fillPolygon(int[] xPoints, int[] yPoints, int npoints) { + int[] pointArray = new int[npoints * 2]; + for (int i = 0; i < npoints; i++) { + pointArray[2 * i] = xPoints[i]; + pointArray[2 * i + 1] = yPoints[i]; + } + switchColors(); + this.gc.fillPolygon(pointArray); + switchColors(); + } + + /** + * Draws a rectangle with rounded corners that fits within the specified + * framing rectangle. + * + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param width the frame width. + * @param height the frame height. + * @param arcWidth the width of the arc defining the roundedness of the + * rectangle's corners. + * @param arcHeight the height of the arc defining the roundedness of the + * rectangle's corners. + * + * @see #drawRoundRect(int, int, int, int, int, int) + */ + public void fillRoundRect(int x, int y, int width, int height, + int arcWidth, int arcHeight) { + switchColors(); + this.gc.fillRoundRectangle(x, y, width - 1, height - 1, arcWidth, + arcHeight); + switchColors(); + } + + /** + * Fills an oval that fits within the specified rectangular region. + * + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param width the frame width. + * @param height the frame height. + * + * @see #drawOval(int, int, int, int) + * @see #fill(Shape) + */ + public void fillOval(int x, int y, int width, int height) { + switchColors(); + this.gc.fillOval(x, y, width - 1, height - 1); + switchColors(); + } + + /** + * Fills an arc that is part of an ellipse that fits within the specified + * framing rectangle. + * + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param width the frame width. + * @param height the frame height. + * @param arcStart the arc starting point, in degrees. + * @param arcAngle the extent of the arc. + * + * @see #drawArc(int, int, int, int, int, int) + */ + public void fillArc(int x, int y, int width, int height, int arcStart, + int arcAngle) { + switchColors(); + this.gc.fillArc(x, y, width - 1, height - 1, arcStart, arcAngle); + switchColors(); + } + + /** + * Returns the font in form of an awt font created + * with the parameters of the font of the swt graphic + * composite. + * @see java.awt.Graphics#getFont() + */ + public Font getFont() { + // retrieve the swt font description in an os indept way + FontData[] fontData = this.gc.getFont().getFontData(); + // create a new awt font with the appropiate data + return SWTUtils.toAwtFont(this.gc.getDevice(), fontData[0], true); + } + + /** + * Set the font swt graphic composite from the specified + * awt font. Be careful that the newly created swt font + * must be disposed separately. + * @see java.awt.Graphics#setFont(java.awt.Font) + */ + public void setFont(Font font) { + org.eclipse.swt.graphics.Font swtFont = getSwtFontFromPool(font); + this.gc.setFont(swtFont); + } + + /** + * Returns the font metrics. + * + * @param font the font. + * + * @return The font metrics. + */ + public FontMetrics getFontMetrics(Font font) { + return SWTUtils.DUMMY_PANEL.getFontMetrics(font); + } + + /** + * Returns the font render context. + * + * @return The font render context. + */ + public FontRenderContext getFontRenderContext() { + FontRenderContext fontRenderContext = new FontRenderContext( + new AffineTransform(), true, true); + return fontRenderContext; + } + + /** + * Draws the specified glyph vector at the location (x, y). + * + * @param g the glyph vector (null not permitted). + * @param x the x-coordinate. + * @param y the y-coordinate. + */ + public void drawGlyphVector(GlyphVector g, float x, float y) { + fill(g.getOutline(x, y)); + } + + /** + * Draws a string on the receiver. note that + * to be consistent with the awt method, + * the y has to be modified with the ascent of the font. + * + * @see java.awt.Graphics#drawString(java.lang.String, int, int) + */ + public void drawString(String text, int x, int y) { + drawString(text, (float) x, (float) y); + } + + /** + * Draws a string at the specified position. + * + * @param text the string. + * @param x the x-coordinate. + * @param y the y-coordinate. + */ + public void drawString(String text, float x, float y) { + if (text == null) { + throw new NullPointerException("Null 'text' argument."); + } + float fm = this.gc.getFontMetrics().getAscent(); + this.gc.drawString(text, (int) x, (int) (y - fm), true); + } + + /** + * Draws a string at the specified position. + * + * @param iterator the string. + * @param x the x-coordinate. + * @param y the y-coordinate. + */ + public void drawString(AttributedCharacterIterator iterator, int x, int y) { + // for now we simply want to extract the chars from the iterator + // and call an unstyled text renderer + StringBuffer sb = new StringBuffer(); + int numChars = iterator.getEndIndex() - iterator.getBeginIndex(); + char c = iterator.first(); + for (int i = 0; i < numChars; i++) { + sb.append(c); + c = iterator.next(); + } + drawString(new String(sb),x,y); + } + + /** + * Draws a string at the specified position. + * + * @param iterator the string. + * @param x the x-coordinate. + * @param y the y-coordinate. + */ + public void drawString(AttributedCharacterIterator iterator, float x, + float y) { + drawString(iterator, (int) x, (int) y); + } + + /** + * Returns true if the rectangle (in device space) intersects + * with the shape (the interior, if onStroke is false, + * otherwise the stroked outline of the shape). + * + * @param rect a rectangle (in device space). + * @param s the shape. + * @param onStroke test the stroked outline only? + * + * @return A boolean. + */ + @Override + public boolean hit(Rectangle rect, Shape s, boolean onStroke) { + AffineTransform transform = getTransform(); + Shape ts; + if (onStroke) { + Stroke stroke = getStroke(); + ts = transform.createTransformedShape(stroke.createStrokedShape(s)); + } else { + ts = transform.createTransformedShape(s); + } + if (!rect.getBounds2D().intersects(ts.getBounds2D())) { + return false; + } + Area a1 = new Area(rect); + Area a2 = new Area(ts); + a1.intersect(a2); + return !a1.isEmpty(); + } + + /** + * Not implemented - see {@link Graphics#copyArea(int, int, int, int, int, + * int)}. + */ + public void copyArea(int x, int y, int width, int height, int dx, int dy) { + // TODO Auto-generated method stub + } + + /** + * Not implemented - see {@link Graphics2D#drawImage(Image, + * AffineTransform, ImageObserver)}. + * + * @param image the image. + * @param xform the transform. + * @param obs an image observer. + * + * @return A boolean. + */ + public boolean drawImage(Image image, AffineTransform xform, + ImageObserver obs) { + // TODO Auto-generated method stub + return false; + } + + /** + * Draws an image. + * + * @param image the image. + * @param op the image operation. + * @param x the x-coordinate. + * @param y the y-coordinate. + */ + public void drawImage(BufferedImage image, BufferedImageOp op, int x, + int y) { + org.eclipse.swt.graphics.Image im = new org.eclipse.swt.graphics.Image( + this.gc.getDevice(), SWTUtils.convertToSWT(image)); + this.gc.drawImage(im, x, y); + im.dispose(); + } + + /** + * Draws an SWT image with the top left corner of the image aligned to the + * point (x, y). + * + * @param image the image. + * @param x the x-coordinate. + * @param y the y-coordinate. + */ + public void drawImage(org.eclipse.swt.graphics.Image image, int x, int y) { + this.gc.drawImage(image, x, y); + } + + /** + * Not implemented - see {@link Graphics2D#drawRenderedImage(RenderedImage, + * AffineTransform)}. + * + * @param image the image. + * @param xform the transform. + */ + public void drawRenderedImage(RenderedImage image, AffineTransform xform) { + // TODO Auto-generated method stub + } + + /** + * Not implemented - see {@link Graphics2D#drawRenderableImage( + * RenderableImage, AffineTransform)}. + * + * @param image the image. + * @param xform the transform. + */ + public void drawRenderableImage(RenderableImage image, + AffineTransform xform) { + // TODO Auto-generated method stub + + } + + /** + * Draws an image with the top left corner aligned to the point (x, y). + * + * @param image the image. + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param observer ignored here. + * + * @return true if the image has been drawn. + */ + public boolean drawImage(Image image, int x, int y, + ImageObserver observer) { + ImageData data = SWTUtils.convertAWTImageToSWT(image); + if (data == null) { + return false; + } + org.eclipse.swt.graphics.Image im = new org.eclipse.swt.graphics.Image( + this.gc.getDevice(), data); + this.gc.drawImage(im, x, y); + im.dispose(); + return true; + } + + /** + * Draws an image with the top left corner aligned to the point (x, y), + * and scaled to the specified width and height. + * + * @param image the image. + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param width the width for the rendered image. + * @param height the height for the rendered image. + * @param observer ignored here. + * + * @return true if the image has been drawn. + */ + public boolean drawImage(Image image, int x, int y, int width, int height, + ImageObserver observer) { + ImageData data = SWTUtils.convertAWTImageToSWT(image); + if (data == null) { + return false; + } + org.eclipse.swt.graphics.Image im = new org.eclipse.swt.graphics.Image( + this.gc.getDevice(), data); + org.eclipse.swt.graphics.Rectangle bounds = im.getBounds(); + this.gc.drawImage(im, 0, 0, bounds.width, bounds.height, x, y, width, + height); + im.dispose(); + return true; + } + + /** + * Draws an image. + * + * @param image (null not permitted). + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param bgcolor the background color. + * @param observer an image observer. + * + * @return A boolean. + */ + public boolean drawImage(Image image, int x, int y, Color bgcolor, + ImageObserver observer) { + ParamChecks.nullNotPermitted(image, "image"); + int w = image.getWidth(null); + int h = image.getHeight(null); + if (w == -1 || h == -1) { + return false; + } + Paint savedPaint = getPaint(); + fill(new Rectangle2D.Double(x, y, w, h)); + setPaint(savedPaint); + return drawImage(image, x, y, observer); + } + + /** + * Draws an image. + * + * @param image the image (null not permitted). + * @param x the x-coordinate. + * @param y the y-coordinate. + * @param width the width. + * @param height the height. + * @param bgcolor the background colour. + * @param observer an image observer. + * + * @return A boolean. + */ + public boolean drawImage(Image image, int x, int y, int width, int height, + Color bgcolor, ImageObserver observer) { + ParamChecks.nullNotPermitted(image, "image"); + int w = image.getWidth(null); + int h = image.getHeight(null); + if (w == -1 || h == -1) { + return false; + } + Paint savedPaint = getPaint(); + fill(new Rectangle2D.Double(x, y, w, h)); + setPaint(savedPaint); + return drawImage(image, x, y, width, height, observer); + } + + /** + * Not implemented - see {@link Graphics#drawImage(Image, int, int, int, + * int, int, int, int, int, ImageObserver)}. + * + * @param image the image. + * @param dx1 + * @param dy1 + * @param dx2 + * @param dy2 + * @param sx1 + * @param sy1 + * @param sx2 + * @param sy2 + * @param observer + */ + public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, + int sx1, int sy1, int sx2, int sy2, ImageObserver observer) { + // TODO Auto-generated method stub + return false; + } + + /** + * Not implemented - see {@link Graphics#drawImage(Image, int, int, int, + * int, int, int, int, int, Color, ImageObserver)}. + * + * @param image the image. + * @param dx1 + * @param dy1 + * @param dx2 + * @param dy2 + * @param sx1 + * @param sy1 + * @param sx2 + * @param sy2 + * @param bgcolor + * @param observer + */ + public boolean drawImage(Image image, int dx1, int dy1, int dx2, int dy2, + int sx1, int sy1, int sx2, int sy2, Color bgcolor, + ImageObserver observer) { + // TODO Auto-generated method stub + return false; + } + + /** + * Releases resources held by this instance (but note that the caller + * must dispose of the 'GC' passed to the constructor). + * + * @see java.awt.Graphics#dispose() + */ + public void dispose() { + // we dispose resources we own but user must dispose gc + disposeResourcePool(); + } + + /** + * Add given swt resource to the resource pool. All resources added + * to the resource pool will be disposed when {@link #dispose()} is called. + * + * @param resource the resource to add to the pool. + * @return the swt Resource just added. + */ + private Resource addToResourcePool(Resource resource) { + this.resourcePool.add(resource); + return resource; + } + + /** + * Dispose the resource pool. + */ + private void disposeResourcePool() { + for (Iterator it = this.resourcePool.iterator(); it.hasNext();) { + Resource resource = (Resource) it.next(); + resource.dispose(); + } + this.fontsPool.clear(); + this.colorsPool.clear(); + this.transformsPool.clear(); + this.resourcePool.clear(); + } + + /** + * Internal method to convert a AWT font object into + * a SWT font resource. If a corresponding SWT font + * instance is already in the pool, it will be used + * instead of creating a new one. This is used in + * {@link #setFont()} for instance. + * + * @param font The AWT font to convert. + * @return The SWT font instance. + */ + private org.eclipse.swt.graphics.Font getSwtFontFromPool(Font font) { + org.eclipse.swt.graphics.Font swtFont = (org.eclipse.swt.graphics.Font) + this.fontsPool.get(font); + if (swtFont == null) { + swtFont = new org.eclipse.swt.graphics.Font(this.gc.getDevice(), + SWTUtils.toSwtFontData(this.gc.getDevice(), font, true)); + addToResourcePool(swtFont); + this.fontsPool.put(font, swtFont); + } + return swtFont; + } + + /** + * Internal method to convert a AWT color object into + * a SWT color resource. If a corresponding SWT color + * instance is already in the pool, it will be used + * instead of creating a new one. This is used in + * {@link #setColor()} for instance. + * + * @param awtColor The AWT color to convert. + * @return A SWT color instance. + */ + private org.eclipse.swt.graphics.Color getSwtColorFromPool(Color awtColor) { + org.eclipse.swt.graphics.Color swtColor = + (org.eclipse.swt.graphics.Color) + // we can't use the following valueOf() method, because it + // won't compile with JDK1.4 + // this.colorsPool.get(Integer.valueOf(awtColor.getRGB())); + this.colorsPool.get(new Integer(awtColor.getRGB())); + if (swtColor == null) { + swtColor = SWTUtils.toSwtColor(this.gc.getDevice(), awtColor); + addToResourcePool(swtColor); + // see comment above + //this.colorsPool.put(Integer.valueOf(awtColor.getRGB()), swtColor); + this.colorsPool.put(new Integer(awtColor.getRGB()), swtColor); + } + return swtColor; + } + + /** + * Internal method to convert a AWT transform object into + * a SWT transform resource. If a corresponding SWT transform + * instance is already in the pool, it will be used + * instead of creating a new one. This is used in + * {@link #setTransform()} for instance. + * + * @param awtTransform The AWT transform to convert. + * @return A SWT transform instance. + */ + private Transform getSwtTransformFromPool(AffineTransform awtTransform) { + Transform t = (Transform) this.transformsPool.get(awtTransform); + if (t == null) { + t = new Transform(this.gc.getDevice()); + double[] matrix = new double[6]; + awtTransform.getMatrix(matrix); + t.setElements((float) matrix[0], (float) matrix[1], + (float) matrix[2], (float) matrix[3], + (float) matrix[4], (float) matrix[5]); + addToResourcePool(t); + this.transformsPool.put(awtTransform, t); + } + return t; + } + + /** + * Perform a switch between foreground and background + * color of gc. This is needed for consistency with + * the awt behaviour, and is required notably for the + * filling methods. + */ + private void switchColors() { + org.eclipse.swt.graphics.Color bg = this.gc.getBackground(); + org.eclipse.swt.graphics.Color fg = this.gc.getForeground(); + this.gc.setBackground(fg); + this.gc.setForeground(bg); + } + + /** + * Converts an AWT Shape into a SWT Path. + * + * @param shape the shape (null not permitted). + * + * @return The path. + */ + private Path toSwtPath(Shape shape) { + int type; + float[] coords = new float[6]; + Path path = new Path(this.gc.getDevice()); + PathIterator pit = shape.getPathIterator(null); + while (!pit.isDone()) { + type = pit.currentSegment(coords); + switch (type) { + case (PathIterator.SEG_MOVETO): + path.moveTo(coords[0], coords[1]); + break; + case (PathIterator.SEG_LINETO): + path.lineTo(coords[0], coords[1]); + break; + case (PathIterator.SEG_QUADTO): + path.quadTo(coords[0], coords[1], coords[2], coords[3]); + break; + case (PathIterator.SEG_CUBICTO): + path.cubicTo(coords[0], coords[1], coords[2], + coords[3], coords[4], coords[5]); + break; + case (PathIterator.SEG_CLOSE): + path.close(); + break; + default: + break; + } + pit.next(); + } + return path; + } + + /** + * Converts an SWT transform into the equivalent AWT transform. + * + * @param swtTransform the SWT transform. + * + * @return The AWT transform. + */ + private AffineTransform toAwtTransform(Transform swtTransform) { + float[] elements = new float[6]; + swtTransform.getElements(elements); + AffineTransform awtTransform = new AffineTransform(elements); + return awtTransform; + } + + /** + * Returns the AWT line cap corresponding to the specified SWT line cap. + * + * @param swtLineCap the SWT line cap. + * + * @return The AWT line cap. + */ + private int toAwtLineCap(int swtLineCap) { + if (swtLineCap == SWT.CAP_FLAT) { + return BasicStroke.CAP_BUTT; + } + else if (swtLineCap == SWT.CAP_ROUND) { + return BasicStroke.CAP_ROUND; + } + else if (swtLineCap == SWT.CAP_SQUARE) { + return BasicStroke.CAP_SQUARE; + } + else { + throw new IllegalArgumentException("SWT LineCap " + swtLineCap + + " not recognised"); + } + } + + /** + * Returns the AWT line join corresponding to the specified SWT line join. + * + * @param swtLineJoin the SWT line join. + * + * @return The AWT line join. + */ + private int toAwtLineJoin(int swtLineJoin) { + if (swtLineJoin == SWT.JOIN_BEVEL) { + return BasicStroke.JOIN_BEVEL; + } + else if (swtLineJoin == SWT.JOIN_MITER) { + return BasicStroke.JOIN_MITER; + } + else if (swtLineJoin == SWT.JOIN_ROUND) { + return BasicStroke.JOIN_ROUND; + } + else { + throw new IllegalArgumentException("SWT LineJoin " + swtLineJoin + + " not recognised"); + } + } + + /** + * Returns the SWT line cap corresponding to the specified AWT line cap. + * + * @param awtLineCap the AWT line cap. + * + * @return The SWT line cap. + */ + private int toSwtLineCap(int awtLineCap) { + if (awtLineCap == BasicStroke.CAP_BUTT) { + return SWT.CAP_FLAT; + } + else if (awtLineCap == BasicStroke.CAP_ROUND) { + return SWT.CAP_ROUND; + } + else if (awtLineCap == BasicStroke.CAP_SQUARE) { + return SWT.CAP_SQUARE; + } + else { + throw new IllegalArgumentException("AWT LineCap " + awtLineCap + + " not recognised"); + } + } + + /** + * Returns the SWT line join corresponding to the specified AWT line join. + * + * @param awtLineJoin the AWT line join. + * + * @return The SWT line join. + */ + private int toSwtLineJoin(int awtLineJoin) { + if (awtLineJoin == BasicStroke.JOIN_BEVEL) { + return SWT.JOIN_BEVEL; + } + else if (awtLineJoin == BasicStroke.JOIN_MITER) { + return SWT.JOIN_MITER; + } + else if (awtLineJoin == BasicStroke.JOIN_ROUND) { + return SWT.JOIN_ROUND; + } + else { + throw new IllegalArgumentException("AWT LineJoin " + awtLineJoin + + " not recognised"); + } + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/swt/SWTPaintCanvas.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/swt/SWTPaintCanvas.java new file mode 100755 index 0000000..b8873fe --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/swt/SWTPaintCanvas.java @@ -0,0 +1,135 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * SwtPaintCanvas.java + * ------------------- + * (C) Copyright 2000-2007, by Object Refinery Limited. + * + * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 04-Aug-2006 : New class (HP); + * 25-Oct-2007 : Fixed Eclipse warnings (DG); + * + */ + +package org.jfree.experimental.swt; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; + +/** + * A paint canvas. + */ +public class SWTPaintCanvas extends Canvas { + private Color myColor; + + /** + * Creates a new instance. + * + * @param parent the parent. + * @param style the style. + * @param color the color. + */ + public SWTPaintCanvas(Composite parent, int style, Color color) { + this(parent, style); + setColor(color); + } + + /** + * Creates a new instance. + * + * @param parent the parent. + * @param style the style. + */ + public SWTPaintCanvas(Composite parent, int style) { + super(parent, style); + addPaintListener(new PaintListener() { + public void paintControl(PaintEvent e) { + e.gc.setForeground(e.gc.getDevice().getSystemColor( + SWT.COLOR_BLACK)); + e.gc.setBackground(SWTPaintCanvas.this.myColor); + e.gc.fillRectangle(getClientArea()); + e.gc.drawRectangle(getClientArea().x, getClientArea().y, + getClientArea().width - 1, getClientArea().height - 1); + } + }); + } + + /** + * Sets the color. + * + * @param color the color. + */ + public void setColor(Color color) { + if (this.myColor != null) { + this.myColor.dispose(); + } + //this.myColor = new Color(getDisplay(), color.getRGB()); + this.myColor = color; + } + + /** + * Returns the color. + * + * @return The color. + */ + public Color getColor() { + return this.myColor; + } + + /** + * Overridden to do nothing. + * + * @param c the color. + */ + public void setBackground(Color c) { + return; + } + + /** + * Overridden to do nothing. + * + * @param c the color. + */ + public void setForeground(Color c) { + return; + } + + /** + * Frees resources. + */ + public void dispose() { + this.myColor.dispose(); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/swt/SWTUtils.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/swt/SWTUtils.java new file mode 100755 index 0000000..b7229bd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/swt/org/jfree/experimental/swt/SWTUtils.java @@ -0,0 +1,461 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * SWTUtils.java + * ------------- + * (C) Copyright 2006-2013, by Henry Proudhon and Contributors. + * + * Original Author: Henry Proudhon (henry.proudhon AT ensmp.fr); + * Contributor(s): Rainer Blessing; + * David Gilbert (david.gilbert@object-refinery.com); + * Christoph Beck. + * + * Changes + * ------- + * 01-Aug-2006 : New class (HP); + * 16-Jan-2007 : Use FontData.getHeight() instead of direct field access (RB); + * 31-Jan-2007 : Moved the dummy JPanel from SWTGraphics2D.java, + * added a new convert method for mouse events (HP); + * 12-Jul-2007 : Improved the mouse event conversion with buttons + * and modifiers handling, patch sent by Christoph Beck (HP); + * 27-Aug-2007 : Modified toAwtMouseEvent signature (HP); + * 27-Nov-2007 : Moved convertToSWT() method from SWTGraphics2D and added + * convertAWTImageToSWT() (DG); + * 01-Jul-2008 : Simplify AWT/SWT font style conversions (HP); + * 03-Jul-2012 : Use ParamChecks (DG); + * + */ + +package org.jfree.experimental.swt; + +import java.awt.Graphics; +import java.awt.Image; +import java.awt.event.InputEvent; +import java.awt.event.MouseEvent; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.awt.image.DirectColorModel; +import java.awt.image.IndexColorModel; +import java.awt.image.WritableRaster; + +import javax.swing.JPanel; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Device; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.FontData; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.PaletteData; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.graphics.Rectangle; +import org.jfree.chart.util.ParamChecks; + +/** + * Utility class gathering some useful and general method. + * Mainly convert forth and back graphical stuff between + * awt and swt. + */ +public class SWTUtils { + + private final static String Az = "ABCpqr"; + + /** A dummy JPanel used to provide font metrics. */ + protected static final JPanel DUMMY_PANEL = new JPanel(); + + /** + * Create a FontData object which encapsulate + * the essential data to create a swt font. The data is taken + * from the provided awt Font. + *

      Generally speaking, given a font size, the returned swt font + * will display differently on the screen than the awt one. + * Because the SWT toolkit use native graphical resources whenever + * it is possible, this fact is platform dependent. To address + * this issue, it is possible to enforce the method to return + * a font with the same size (or at least as close as possible) + * as the awt one. + *

      When the object is no more used, the user must explicitly + * call the dispose method on the returned font to free the + * operating system resources (the garbage collector won't do it). + * + * @param device The swt device to draw on (display or gc device). + * @param font The awt font from which to get the data. + * @param ensureSameSize A boolean used to enforce the same size + * (in pixels) between the awt font and the newly created swt font. + * @return a FontData object. + */ + public static FontData toSwtFontData(Device device, java.awt.Font font, + boolean ensureSameSize) { + FontData fontData = new FontData(); + fontData.setName(font.getFamily()); + // SWT and AWT share the same style constants. + fontData.setStyle(font.getStyle()); + // convert the font size (in pt for awt) to height in pixels for swt + int height = (int) Math.round(font.getSize() * 72.0 + / device.getDPI().y); + fontData.setHeight(height); + // hack to ensure the newly created swt fonts will be rendered with the + // same height as the awt one + if (ensureSameSize) { + GC tmpGC = new GC(device); + Font tmpFont = new Font(device, fontData); + tmpGC.setFont(tmpFont); + if (tmpGC.textExtent(Az).x + > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) { + while (tmpGC.textExtent(Az).x + > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) { + tmpFont.dispose(); + height--; + fontData.setHeight(height); + tmpFont = new Font(device, fontData); + tmpGC.setFont(tmpFont); + } + } + else if (tmpGC.textExtent(Az).x + < DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) { + while (tmpGC.textExtent(Az).x + < DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) { + tmpFont.dispose(); + height++; + fontData.setHeight(height); + tmpFont = new Font(device, fontData); + tmpGC.setFont(tmpFont); + } + } + tmpFont.dispose(); + tmpGC.dispose(); + } + return fontData; + } + + /** + * Create an awt font by converting as much information + * as possible from the provided swt FontData. + *

      Generally speaking, given a font size, an swt font will + * display differently on the screen than the corresponding awt + * one. Because the SWT toolkit use native graphical ressources whenever + * it is possible, this fact is platform dependent. To address + * this issue, it is possible to enforce the method to return + * an awt font with the same height as the swt one. + * + * @param device The swt device being drawn on (display or gc device). + * @param fontData The swt font to convert. + * @param ensureSameSize A boolean used to enforce the same size + * (in pixels) between the swt font and the newly created awt font. + * @return An awt font converted from the provided swt font. + */ + public static java.awt.Font toAwtFont(Device device, FontData fontData, + boolean ensureSameSize) { + int height = (int) Math.round(fontData.getHeight() * device.getDPI().y + / 72.0); + // hack to ensure the newly created awt fonts will be rendered with the + // same height as the swt one + if (ensureSameSize) { + GC tmpGC = new GC(device); + Font tmpFont = new Font(device, fontData); + tmpGC.setFont(tmpFont); + JPanel DUMMY_PANEL = new JPanel(); + java.awt.Font tmpAwtFont = new java.awt.Font(fontData.getName(), + fontData.getStyle(), height); + if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) + > tmpGC.textExtent(Az).x) { + while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) + > tmpGC.textExtent(Az).x) { + height--; + tmpAwtFont = new java.awt.Font(fontData.getName(), + fontData.getStyle(), height); + } + } + else if (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) + < tmpGC.textExtent(Az).x) { + while (DUMMY_PANEL.getFontMetrics(tmpAwtFont).stringWidth(Az) + < tmpGC.textExtent(Az).x) { + height++; + tmpAwtFont = new java.awt.Font(fontData.getName(), + fontData.getStyle(), height); + } + } + tmpFont.dispose(); + tmpGC.dispose(); + } + return new java.awt.Font(fontData.getName(), fontData.getStyle(), + height); + } + + /** + * Create an awt font by converting as much information + * as possible from the provided swt Font. + * + * @param device The swt device to draw on (display or gc device). + * @param font The swt font to convert. + * @return An awt font converted from the provided swt font. + */ + public static java.awt.Font toAwtFont(Device device, Font font) { + FontData fontData = font.getFontData()[0]; + return toAwtFont(device, fontData, true); + } + + /** + * Creates an awt color instance to match the rgb values + * of the specified swt color. + * + * @param color The swt color to match. + * @return an awt color abject. + */ + public static java.awt.Color toAwtColor(Color color) { + return new java.awt.Color(color.getRed(), color.getGreen(), + color.getBlue()); + } + + /** + * Creates a swt color instance to match the rgb values + * of the specified awt paint. For now, this method test + * if the paint is a color and then return the adequate + * swt color. Otherwise plain black is assumed. + * + * @param device The swt device to draw on (display or gc device). + * @param paint The awt color to match. + * @return a swt color object. + */ + public static Color toSwtColor(Device device, java.awt.Paint paint) { + java.awt.Color color; + if (paint instanceof java.awt.Color) { + color = (java.awt.Color) paint; + } + else { + try { + throw new Exception("only color is supported at present... " + + "setting paint to uniform black color"); + } + catch (Exception e) { + e.printStackTrace(); + color = new java.awt.Color(0, 0, 0); + } + } + return new org.eclipse.swt.graphics.Color(device, + color.getRed(), color.getGreen(), color.getBlue()); + } + + /** + * Creates a swt color instance to match the rgb values + * of the specified awt color. alpha channel is not supported. + * Note that the dispose method will need to be called on the + * returned object. + * + * @param device The swt device to draw on (display or gc device). + * @param color The awt color to match. + * @return a swt color object. + */ + public static Color toSwtColor(Device device, java.awt.Color color) { + return new org.eclipse.swt.graphics.Color(device, + color.getRed(), color.getGreen(), color.getBlue()); + } + + /** + * Transform an awt Rectangle2d instance into a swt one. + * The coordinates are rounded to integer for the swt object. + * @param rect2d The awt rectangle to map. + * @return an swt Rectangle object. + */ + public static Rectangle toSwtRectangle(Rectangle2D rect2d) { + return new Rectangle( + (int) Math.round(rect2d.getMinX()), + (int) Math.round(rect2d.getMinY()), + (int) Math.round(rect2d.getWidth()), + (int) Math.round(rect2d.getHeight())); + } + + /** + * Transform a swt Rectangle instance into an awt one. + * @param rect the swt Rectangle + * @return a Rectangle2D.Double instance with + * the eappropriate location and size. + */ + public static Rectangle2D toAwtRectangle(Rectangle rect) { + Rectangle2D rect2d = new Rectangle2D.Double(); + rect2d.setRect(rect.x, rect.y, rect.width, rect.height); + return rect2d; + } + + /** + * Returns an AWT point with the same coordinates as the specified + * SWT point. + * + * @param p the SWT point (null not permitted). + * + * @return An AWT point with the same coordinates as p. + * + * @see #toSwtPoint(java.awt.Point) + */ + public static Point2D toAwtPoint(Point p) { + return new java.awt.Point(p.x, p.y); + } + + /** + * Returns an SWT point with the same coordinates as the specified + * AWT point. + * + * @param p the AWT point (null not permitted). + * + * @return An SWT point with the same coordinates as p. + * + * @see #toAwtPoint(Point) + */ + public static Point toSwtPoint(java.awt.Point p) { + return new Point(p.x, p.y); + } + + /** + * Returns an SWT point with the same coordinates as the specified AWT + * point (rounded to integer values). + * + * @param p the AWT point (null not permitted). + * + * @return An SWT point with the same coordinates as p. + * + * @see #toAwtPoint(Point) + */ + public static Point toSwtPoint(java.awt.geom.Point2D p) { + return new Point((int) Math.round(p.getX()), + (int) Math.round(p.getY())); + } + + /** + * Creates an AWT MouseEvent from a swt event. + * This method helps passing SWT mouse event to awt components. + * @param event The swt event. + * @return A AWT mouse event based on the given SWT event. + */ + public static MouseEvent toAwtMouseEvent(org.eclipse.swt.events.MouseEvent event) { + int button = MouseEvent.NOBUTTON; + switch (event.button) { + case 1: button = MouseEvent.BUTTON1; break; + case 2: button = MouseEvent.BUTTON2; break; + case 3: button = MouseEvent.BUTTON3; break; + } + int modifiers = 0; + if ((event.stateMask & SWT.CTRL) != 0) { + modifiers |= InputEvent.CTRL_DOWN_MASK; + } + if ((event.stateMask & SWT.SHIFT) != 0) { + modifiers |= InputEvent.SHIFT_DOWN_MASK; + } + if ((event.stateMask & SWT.ALT) != 0) { + modifiers |= InputEvent.ALT_DOWN_MASK; + } + MouseEvent awtMouseEvent = new MouseEvent(DUMMY_PANEL, event.hashCode(), + event.time, modifiers, event.x, event.y, 1, false, button); + return awtMouseEvent; + } + + /** + * Converts an AWT image to SWT. + * + * @param image the image (null not permitted). + * + * @return Image data. + */ + public static ImageData convertAWTImageToSWT(Image image) { + ParamChecks.nullNotPermitted(image, "image"); + int w = image.getWidth(null); + int h = image.getHeight(null); + if (w == -1 || h == -1) { + return null; + } + BufferedImage bi = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); + Graphics g = bi.getGraphics(); + g.drawImage(image, 0, 0, null); + g.dispose(); + return convertToSWT(bi); + } + + /** + * Converts a buffered image to SWT ImageData. + * + * @param bufferedImage the buffered image (null not + * permitted). + * + * @return The image data. + */ + public static ImageData convertToSWT(BufferedImage bufferedImage) { + if (bufferedImage.getColorModel() instanceof DirectColorModel) { + DirectColorModel colorModel + = (DirectColorModel) bufferedImage.getColorModel(); + PaletteData palette = new PaletteData(colorModel.getRedMask(), + colorModel.getGreenMask(), colorModel.getBlueMask()); + ImageData data = new ImageData(bufferedImage.getWidth(), + bufferedImage.getHeight(), colorModel.getPixelSize(), + palette); + WritableRaster raster = bufferedImage.getRaster(); + int[] pixelArray = new int[3]; + for (int y = 0; y < data.height; y++) { + for (int x = 0; x < data.width; x++) { + raster.getPixel(x, y, pixelArray); + int pixel = palette.getPixel(new RGB(pixelArray[0], + pixelArray[1], pixelArray[2])); + data.setPixel(x, y, pixel); + } + } + return data; + } + else if (bufferedImage.getColorModel() instanceof IndexColorModel) { + IndexColorModel colorModel = (IndexColorModel) + bufferedImage.getColorModel(); + int size = colorModel.getMapSize(); + byte[] reds = new byte[size]; + byte[] greens = new byte[size]; + byte[] blues = new byte[size]; + colorModel.getReds(reds); + colorModel.getGreens(greens); + colorModel.getBlues(blues); + RGB[] rgbs = new RGB[size]; + for (int i = 0; i < rgbs.length; i++) { + rgbs[i] = new RGB(reds[i] & 0xFF, greens[i] & 0xFF, + blues[i] & 0xFF); + } + PaletteData palette = new PaletteData(rgbs); + ImageData data = new ImageData(bufferedImage.getWidth(), + bufferedImage.getHeight(), colorModel.getPixelSize(), + palette); + data.transparentPixel = colorModel.getTransparentPixel(); + WritableRaster raster = bufferedImage.getRaster(); + int[] pixelArray = new int[1]; + for (int y = 0; y < data.height; y++) { + for (int x = 0; x < data.width; x++) { + raster.getPixel(x, y, pixelArray); + data.setPixel(x, y, pixelArray[0]); + } + } + return data; + } + return null; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/AreaChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/AreaChartTest.java new file mode 100755 index 0000000..28e4a80 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/AreaChartTest.java @@ -0,0 +1,196 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * AreaChartTest.java + * ------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 12-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.fail; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.CategoryToolTipGenerator; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.urls.CategoryURLGenerator; +import org.jfree.chart.urls.StandardCategoryURLGenerator; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetUtilities; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests for an area chart. + */ +public class AreaChartTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createAreaChart(); + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryToolTipGenerator tt + = new StandardCategoryToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertSame(tt2, tt); + } + + /** + * Check that setting a URL generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesURLGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryURLGenerator url1 + = new StandardCategoryURLGenerator(); + renderer.setSeriesItemURLGenerator(0, url1); + CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); + assertSame(url2, url1); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("There should be no exception."); + } + } + + /** + * Replaces the chart's dataset and then checks that the new dataset is OK. + */ + @Test + public void testReplaceDataset() { + Number[][] data = new Integer[][] + {{new Integer(-30), new Integer(-20)}, + {new Integer(-10), new Integer(10)}, + {new Integer(20), new Integer(30)}}; + + CategoryDataset newData = DatasetUtilities.createCategoryDataset( + "S", "C", data); + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + plot.setDataset(newData); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around -30: " + + range.getLowerBound(), range.getLowerBound() <= -30); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Create an area chart with sample data in the range -3 to +3. + * + * @return The chart. + */ + private static JFreeChart createAreaChart() { + Number[][] data = new Integer[][] + {{new Integer(-3), new Integer(-2)}, + {new Integer(-1), new Integer(1)}, + {new Integer(2), new Integer(3)}}; + CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", + "C", data); + return ChartFactory.createAreaChart("Area Chart", "Domain", "Range", + dataset, PlotOrientation.HORIZONTAL, true, true, true); + + } + + /** + * A chart change listener. + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/BarChart3DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/BarChart3DTest.java new file mode 100755 index 0000000..ac02e36 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/BarChart3DTest.java @@ -0,0 +1,204 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * BarChart3DTest.java + * ------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 11-Jun-2002 : Version 1 (DG); + * 25-Jun-2002 : Removed redundant code (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 14-Jul-2003 : Renamed BarChart3DTests.java (DG); + * + */ + +package org.jfree.chart; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.CategoryToolTipGenerator; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.urls.CategoryURLGenerator; +import org.jfree.chart.urls.StandardCategoryURLGenerator; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetUtilities; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests for a 3D bar chart. + */ +public class BarChart3DTest { + + /** The chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createBarChart3D(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("There should be no exception."); + } + } + + /** + * Replaces the dataset and checks that the data range is as expected. + */ + @Test + public void testReplaceDataset() { + + // create a dataset... + Number[][] data = new Integer[][] + {{new Integer(-30), new Integer(-20)}, + {new Integer(-10), new Integer(10)}, + {new Integer(20), new Integer(30)}}; + + CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", + "C", data); + + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + plot.setDataset(newData); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around -30: " + + range.getLowerBound(), range.getLowerBound() <= -30); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryToolTipGenerator tt + = new StandardCategoryToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertSame(tt2, tt); + } + + /** + * Check that setting a URL generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesURLGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryURLGenerator url1 + = new StandardCategoryURLGenerator(); + renderer.setSeriesItemURLGenerator(0, url1); + CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); + assertSame(url2, url1); + } + + /** + * Create a bar chart with sample data in the range -3 to +3. + * + * @return The chart. + */ + private static JFreeChart createBarChart3D() { + Number[][] data = new Integer[][] + {{new Integer(-3), new Integer(-2)}, + {new Integer(-1), new Integer(1)}, + {new Integer(2), new Integer(3)}}; + + CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", + "C", data); + return ChartFactory.createBarChart3D("Bar Chart 3D", "Domain", "Range", + dataset, PlotOrientation.HORIZONTAL, true, true, true); + + } + + /** + * A chart change listener. + * + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/BarChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/BarChartTest.java new file mode 100755 index 0000000..b15e625 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/BarChartTest.java @@ -0,0 +1,214 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * BarChartTest.java + * ----------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 11-Jun-2002 : Version 1 (DG); + * 25-Jun-2002 : Removed redundant code (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 14-Jul-2003 : Renamed BarChartTests.java (DG); + * + */ + +package org.jfree.chart; + +import static org.junit.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.CategoryToolTipGenerator; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.urls.CategoryURLGenerator; +import org.jfree.chart.urls.StandardCategoryURLGenerator; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetUtilities; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests for a bar chart. + */ +public class BarChartTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createBarChart(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("There should be no exception."); + } + } + + /** + * Replaces the chart's dataset and then checks that the new dataset is OK. + */ + @Test + public void testReplaceDataset() { + + // create a dataset... + Number[][] data = new Integer[][] + {{new Integer(-30), new Integer(-20)}, + {new Integer(-10), new Integer(10)}, + {new Integer(20), new Integer(30)}}; + + CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", + "C", data); + + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + plot.setDataset(newData); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around -30: " + + range.getLowerBound(), range.getLowerBound() <= -30); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryToolTipGenerator tt + = new StandardCategoryToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertTrue(tt2 == tt); + } + + /** + * Check that setting a URL generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesURLGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryURLGenerator url1 + = new StandardCategoryURLGenerator(); + renderer.setSeriesItemURLGenerator(0, url1); + CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); + assertTrue(url2 == url1); + } + + /** + * Create a bar chart with sample data in the range -3 to +3. + * + * @return The chart. + */ + private static JFreeChart createBarChart() { + + // create a dataset... + Number[][] data = new Integer[][] + {{new Integer(-3), new Integer(-2)}, + {new Integer(-1), new Integer(1)}, + {new Integer(2), new Integer(3)}}; + + CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", + "C", data); + + // create the chart... + return ChartFactory.createBarChart( + "Bar Chart", + "Domain", "Range", + dataset, + PlotOrientation.HORIZONTAL, + true, // include legend + true, + true + ); + + } + + /** + * A chart change listener. + * + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag = false; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/ChartPanelTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/ChartPanelTest.java new file mode 100755 index 0000000..cc90f91 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/ChartPanelTest.java @@ -0,0 +1,346 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * ChartPanelTest.java + * ------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Jul-2004 : Version 1 (DG); + * 12-Jan-2009 : Added test2502355() (DG); + * 08-Jun-2009 : Added testSetMouseWheelEnabled() (DG); + */ + +package org.jfree.chart; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import java.awt.geom.Rectangle2D; +import java.util.EventListener; +import java.util.List; + +import javax.swing.event.CaretListener; + +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.xy.DefaultXYDataset; +import org.junit.Test; + +/** + * Tests for the {@link ChartPanel} class. + */ +public class ChartPanelTest implements ChartChangeListener, ChartMouseListener { + + private List chartChangeEvents = new java.util.ArrayList(); + + /** + * Receives a chart change event and stores it in a list for later + * inspection. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.chartChangeEvents.add(event); + } + + /** + * Test that the constructor will accept a null chart. + */ + @Test + public void testConstructor1() { + ChartPanel panel = new ChartPanel(null); + assertEquals(null, panel.getChart()); + } + + /** + * Test that it is possible to set the panel's chart to null. + */ + @Test + public void testSetChart() { + JFreeChart chart = new JFreeChart(new XYPlot()); + ChartPanel panel = new ChartPanel(chart); + panel.setChart(null); + assertEquals(null, panel.getChart()); + } + + /** + * Check the behaviour of the getListeners() method. + */ + @Test + public void testGetListeners() { + ChartPanel p = new ChartPanel(null); + p.addChartMouseListener(this); + EventListener[] listeners = p.getListeners(ChartMouseListener.class); + assertEquals(1, listeners.length); + assertEquals(this, listeners[0]); + // try a listener type that isn't registered + listeners = p.getListeners(CaretListener.class); + assertEquals(0, listeners.length); + p.removeChartMouseListener(this); + listeners = p.getListeners(ChartMouseListener.class); + assertEquals(0, listeners.length); + + // try a null argument + boolean pass = false; + try { + listeners = p.getListeners((Class) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + + // try a class that isn't a listener + pass = false; + try { + listeners = p.getListeners(Integer.class); + } + catch (ClassCastException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Ignores a mouse click event. + * + * @param event the event. + */ + @Override + public void chartMouseClicked(ChartMouseEvent event) { + // ignore + } + + /** + * Ignores a mouse move event. + * + * @param event the event. + */ + @Override + public void chartMouseMoved(ChartMouseEvent event) { + // ignore + } + + /** + * Checks that a call to the zoom() method generates just one + * ChartChangeEvent. + */ + @Test + public void test2502355_zoom() { + DefaultXYDataset dataset = new DefaultXYDataset(); + JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", + "Y", dataset, PlotOrientation.VERTICAL, false, false, false); + ChartPanel panel = new ChartPanel(chart); + chart.addChangeListener(this); + this.chartChangeEvents.clear(); + panel.zoom(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertEquals(1, this.chartChangeEvents.size()); + } + + /** + * Checks that a call to the zoomInBoth() method generates just one + * ChartChangeEvent. + */ + @Test + public void test2502355_zoomInBoth() { + DefaultXYDataset dataset = new DefaultXYDataset(); + JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", + "Y", dataset, PlotOrientation.VERTICAL, false, false, false); + ChartPanel panel = new ChartPanel(chart); + chart.addChangeListener(this); + this.chartChangeEvents.clear(); + panel.zoomInBoth(1.0, 2.0); + assertEquals(1, this.chartChangeEvents.size()); + } + + /** + * Checks that a call to the zoomOutBoth() method generates just one + * ChartChangeEvent. + */ + @Test + public void test2502355_zoomOutBoth() { + DefaultXYDataset dataset = new DefaultXYDataset(); + JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", + "Y", dataset, PlotOrientation.VERTICAL, false, false, false); + ChartPanel panel = new ChartPanel(chart); + chart.addChangeListener(this); + this.chartChangeEvents.clear(); + panel.zoomOutBoth(1.0, 2.0); + assertEquals(1, this.chartChangeEvents.size()); + } + + /** + * Checks that a call to the restoreAutoBounds() method generates just one + * ChartChangeEvent. + */ + @Test + public void test2502355_restoreAutoBounds() { + DefaultXYDataset dataset = new DefaultXYDataset(); + JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", + "Y", dataset, PlotOrientation.VERTICAL, false, false, false); + ChartPanel panel = new ChartPanel(chart); + chart.addChangeListener(this); + this.chartChangeEvents.clear(); + panel.restoreAutoBounds(); + assertEquals(1, this.chartChangeEvents.size()); + } + + /** + * Checks that a call to the zoomInDomain() method, for a plot with more + * than one domain axis, generates just one ChartChangeEvent. + */ + @Test + public void test2502355_zoomInDomain() { + DefaultXYDataset dataset = new DefaultXYDataset(); + JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", + "Y", dataset, PlotOrientation.VERTICAL, false, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setDomainAxis(1, new NumberAxis("X2")); + ChartPanel panel = new ChartPanel(chart); + chart.addChangeListener(this); + this.chartChangeEvents.clear(); + panel.zoomInDomain(1.0, 2.0); + assertEquals(1, this.chartChangeEvents.size()); + } + + /** + * Checks that a call to the zoomInRange() method, for a plot with more + * than one range axis, generates just one ChartChangeEvent. + */ + @Test + public void test2502355_zoomInRange() { + DefaultXYDataset dataset = new DefaultXYDataset(); + JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", + "Y", dataset, PlotOrientation.VERTICAL, false, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setRangeAxis(1, new NumberAxis("X2")); + ChartPanel panel = new ChartPanel(chart); + chart.addChangeListener(this); + this.chartChangeEvents.clear(); + panel.zoomInRange(1.0, 2.0); + assertEquals(1, this.chartChangeEvents.size()); + } + + /** + * Checks that a call to the zoomOutDomain() method, for a plot with more + * than one domain axis, generates just one ChartChangeEvent. + */ + @Test + public void test2502355_zoomOutDomain() { + DefaultXYDataset dataset = new DefaultXYDataset(); + JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", + "Y", dataset, PlotOrientation.VERTICAL, false, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setDomainAxis(1, new NumberAxis("X2")); + ChartPanel panel = new ChartPanel(chart); + chart.addChangeListener(this); + this.chartChangeEvents.clear(); + panel.zoomOutDomain(1.0, 2.0); + assertEquals(1, this.chartChangeEvents.size()); + } + + /** + * Checks that a call to the zoomOutRange() method, for a plot with more + * than one range axis, generates just one ChartChangeEvent. + */ + @Test + public void test2502355_zoomOutRange() { + DefaultXYDataset dataset = new DefaultXYDataset(); + JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", + "Y", dataset, PlotOrientation.VERTICAL, false, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setRangeAxis(1, new NumberAxis("X2")); + ChartPanel panel = new ChartPanel(chart); + chart.addChangeListener(this); + this.chartChangeEvents.clear(); + panel.zoomOutRange(1.0, 2.0); + assertEquals(1, this.chartChangeEvents.size()); + } + + /** + * Checks that a call to the restoreAutoDomainBounds() method, for a plot + * with more than one range axis, generates just one ChartChangeEvent. + */ + @Test + public void test2502355_restoreAutoDomainBounds() { + DefaultXYDataset dataset = new DefaultXYDataset(); + JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", + "Y", dataset, PlotOrientation.VERTICAL, false, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setDomainAxis(1, new NumberAxis("X2")); + ChartPanel panel = new ChartPanel(chart); + chart.addChangeListener(this); + this.chartChangeEvents.clear(); + panel.restoreAutoDomainBounds(); + assertEquals(1, this.chartChangeEvents.size()); + } + + /** + * Checks that a call to the restoreAutoRangeBounds() method, for a plot + * with more than one range axis, generates just one ChartChangeEvent. + */ + @Test + public void test2502355_restoreAutoRangeBounds() { + DefaultXYDataset dataset = new DefaultXYDataset(); + JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", + "Y", dataset, PlotOrientation.VERTICAL, false, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setRangeAxis(1, new NumberAxis("X2")); + ChartPanel panel = new ChartPanel(chart); + chart.addChangeListener(this); + this.chartChangeEvents.clear(); + panel.restoreAutoRangeBounds(); + assertEquals(1, this.chartChangeEvents.size()); + } + + /** + * In version 1.0.13 there is a bug where enabling the mouse wheel handler + * twice would in fact disable it. + */ + @Test + public void testSetMouseWheelEnabled() { + DefaultXYDataset dataset = new DefaultXYDataset(); + JFreeChart chart = ChartFactory.createXYLineChart("TestChart", "X", + "Y", dataset, PlotOrientation.VERTICAL, false, false, false); + ChartPanel panel = new ChartPanel(chart); + panel.setMouseWheelEnabled(true); + assertTrue(panel.isMouseWheelEnabled()); + panel.setMouseWheelEnabled(true); + assertTrue(panel.isMouseWheelEnabled()); + panel.setMouseWheelEnabled(false); + assertFalse(panel.isMouseWheelEnabled()); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/ChartRenderingInfoTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/ChartRenderingInfoTest.java new file mode 100755 index 0000000..9380ee5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/ChartRenderingInfoTest.java @@ -0,0 +1,139 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * ChartRenderingInfoTest.java + * --------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Mar-2004 : Version 1 (DG); + * 30-Nov-2005 : Updated for removed field in ChartRenderingInfo (DG); + * + */ + +package org.jfree.chart; + +import java.awt.Rectangle; +import java.awt.geom.Rectangle2D; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; + +import org.jfree.chart.entity.ChartEntity; +import org.jfree.chart.entity.StandardEntityCollection; +import org.junit.Test; + +/** + * Tests for the {@link ChartRenderingInfo} class. + */ +public class ChartRenderingInfoTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + ChartRenderingInfo i1 = new ChartRenderingInfo(); + ChartRenderingInfo i2 = new ChartRenderingInfo(); + assertEquals(i1, i2); + + i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertFalse(i1.equals(i2)); + i2.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertEquals(i1, i2); + + i1.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4)); + assertFalse(i1.equals(i2)); + i2.getPlotInfo().setDataArea(new Rectangle(1, 2, 3, 4)); + assertEquals(i1, i2); + + StandardEntityCollection e1 = new StandardEntityCollection(); + e1.add(new ChartEntity(new Rectangle(1, 2, 3, 4))); + i1.setEntityCollection(e1); + assertFalse(i1.equals(i2)); + StandardEntityCollection e2 = new StandardEntityCollection(); + e2.add(new ChartEntity(new Rectangle(1, 2, 3, 4))); + i2.setEntityCollection(e2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ChartRenderingInfo i1 = new ChartRenderingInfo(); + ChartRenderingInfo i2 = (ChartRenderingInfo) i1.clone(); + + assertNotSame(i1, i2); + assertSame(i1.getClass(), i2.getClass()); + assertEquals(i1, i2); + + // check independence + i1.getChartArea().setRect(4.0, 3.0, 2.0, 1.0); + assertFalse(i1.equals(i2)); + i2.getChartArea().setRect(4.0, 3.0, 2.0, 1.0); + assertEquals(i1, i2); + + i1.getEntityCollection().add(new ChartEntity(new Rectangle(1, 2, 2, + 1))); + assertFalse(i1.equals(i2)); + i2.getEntityCollection().add(new ChartEntity(new Rectangle(1, 2, 2, + 1))); + assertEquals(i1, i2); + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ChartRenderingInfo i1 = new ChartRenderingInfo(); + i1.setChartArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + ChartRenderingInfo i2 = (ChartRenderingInfo) TestUtilities.serialised(i1); + assertEquals(i1, i2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization2() { + ChartRenderingInfo i1 = new ChartRenderingInfo(); + i1.getPlotInfo().setDataArea(new Rectangle2D.Double(1.0, 2.0, 3.0, + 4.0)); + ChartRenderingInfo i2 = (ChartRenderingInfo) TestUtilities.serialised(i1); + assertEquals(i1, i2); + assertEquals(i2, i2.getPlotInfo().getOwner()); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/GanttChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/GanttChartTest.java new file mode 100755 index 0000000..7464322 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/GanttChartTest.java @@ -0,0 +1,302 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * GanttChartTest.java + * ------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 12-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.Calendar; +import java.util.Date; + +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.CategoryToolTipGenerator; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.urls.CategoryURLGenerator; +import org.jfree.chart.urls.StandardCategoryURLGenerator; +import org.jfree.data.category.IntervalCategoryDataset; +import org.jfree.data.gantt.Task; +import org.jfree.data.gantt.TaskSeries; +import org.jfree.data.gantt.TaskSeriesCollection; +import org.jfree.data.time.SimpleTimePeriod; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; + +/** + * Some tests for a Gantt chart. + */ +public class GanttChartTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createGanttChart(); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("There should be no exception."); + } + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo2() { + JFreeChart chart = createGanttChart(); + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + plot.setDataset(createDataset()); + /* BufferedImage img =*/ chart.createBufferedImage(300, 200, null); + //FIXME we should really assert a value + } + + /** + * Replaces the chart's dataset and then checks that the new dataset is OK. + */ + @Test + public void testReplaceDataset() { + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + plot.setDataset(null); + assertEquals(true, l.flag); + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryToolTipGenerator tt + = new StandardCategoryToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertSame(tt2, tt); + } + + /** + * Check that setting a URL generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesURLGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryURLGenerator url1 + = new StandardCategoryURLGenerator(); + renderer.setSeriesItemURLGenerator(0, url1); + CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); + assertSame(url2, url1); + } + + /** + * Create a Gantt chart. + * + * @return The chart. + */ + private static JFreeChart createGanttChart() { + + return ChartFactory.createGanttChart( + "Gantt Chart", + "Domain", "Range", + null, + true, // include legend + true, + true + ); + } + + /** + * Creates a sample dataset for a Gantt chart. + * + * @return The dataset. + */ + public static IntervalCategoryDataset createDataset() { + + TaskSeries s1 = new TaskSeries("Scheduled"); + s1.add(new Task("Write Proposal", + new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), + date(5, Calendar.APRIL, 2001)))); + s1.add(new Task("Obtain Approval", + new SimpleTimePeriod(date(9, Calendar.APRIL, 2001), + date(9, Calendar.APRIL, 2001)))); + s1.add(new Task("Requirements Analysis", + new SimpleTimePeriod(date(10, Calendar.APRIL, 2001), + date(5, Calendar.MAY, 2001)))); + s1.add(new Task("Design Phase", + new SimpleTimePeriod(date(6, Calendar.MAY, 2001), + date(30, Calendar.MAY, 2001)))); + s1.add(new Task("Design Signoff", + new SimpleTimePeriod(date(2, Calendar.JUNE, 2001), + date(2, Calendar.JUNE, 2001)))); + s1.add(new Task("Alpha Implementation", + new SimpleTimePeriod(date(3, Calendar.JUNE, 2001), + date(31, Calendar.JULY, 2001)))); + s1.add(new Task("Design Review", + new SimpleTimePeriod(date(1, Calendar.AUGUST, 2001), + date(8, Calendar.AUGUST, 2001)))); + s1.add(new Task("Revised Design Signoff", + new SimpleTimePeriod(date(10, Calendar.AUGUST, 2001), + date(10, Calendar.AUGUST, 2001)))); + s1.add(new Task("Beta Implementation", + new SimpleTimePeriod(date(12, Calendar.AUGUST, 2001), + date(12, Calendar.SEPTEMBER, 2001)))); + s1.add(new Task("Testing", + new SimpleTimePeriod(date(13, Calendar.SEPTEMBER, 2001), + date(31, Calendar.OCTOBER, 2001)))); + s1.add(new Task("Final Implementation", + new SimpleTimePeriod(date(1, Calendar.NOVEMBER, 2001), + date(15, Calendar.NOVEMBER, 2001)))); + s1.add(new Task("Signoff", + new SimpleTimePeriod(date(28, Calendar.NOVEMBER, 2001), + date(30, Calendar.NOVEMBER, 2001)))); + + TaskSeries s2 = new TaskSeries("Actual"); + s2.add(new Task("Write Proposal", + new SimpleTimePeriod(date(1, Calendar.APRIL, 2001), + date(5, Calendar.APRIL, 2001)))); + s2.add(new Task("Obtain Approval", + new SimpleTimePeriod(date(9, Calendar.APRIL, 2001), + date(9, Calendar.APRIL, 2001)))); + s2.add(new Task("Requirements Analysis", + new SimpleTimePeriod(date(10, Calendar.APRIL, 2001), + date(15, Calendar.MAY, 2001)))); + s2.add(new Task("Design Phase", + new SimpleTimePeriod(date(15, Calendar.MAY, 2001), + date(17, Calendar.JUNE, 2001)))); + s2.add(new Task("Design Signoff", + new SimpleTimePeriod(date(30, Calendar.JUNE, 2001), + date(30, Calendar.JUNE, 2001)))); + s2.add(new Task("Alpha Implementation", + new SimpleTimePeriod(date(1, Calendar.JULY, 2001), + date(12, Calendar.SEPTEMBER, 2001)))); + s2.add(new Task("Design Review", + new SimpleTimePeriod(date(12, Calendar.SEPTEMBER, 2001), + date(22, Calendar.SEPTEMBER, 2001)))); + s2.add(new Task("Revised Design Signoff", + new SimpleTimePeriod(date(25, Calendar.SEPTEMBER, 2001), + date(27, Calendar.SEPTEMBER, 2001)))); + s2.add(new Task("Beta Implementation", + new SimpleTimePeriod(date(27, Calendar.SEPTEMBER, 2001), + date(30, Calendar.OCTOBER, 2001)))); + s2.add(new Task("Testing", + new SimpleTimePeriod(date(31, Calendar.OCTOBER, 2001), + date(17, Calendar.NOVEMBER, 2001)))); + s2.add(new Task("Final Implementation", + new SimpleTimePeriod(date(18, Calendar.NOVEMBER, 2001), + date(5, Calendar.DECEMBER, 2001)))); + s2.add(new Task("Signoff", + new SimpleTimePeriod(date(10, Calendar.DECEMBER, 2001), + date(11, Calendar.DECEMBER, 2001)))); + + TaskSeriesCollection collection = new TaskSeriesCollection(); + collection.add(s1); + collection.add(s2); + + return collection; + } + + /** + * Utility method for creating Date objects. + * + * @param day the date. + * @param month the month. + * @param year the year. + * + * @return a date. + */ + private static Date date(int day, int month, int year) { + + Calendar calendar = Calendar.getInstance(); + calendar.set(year, month, day); + Date result = calendar.getTime(); + return result; + + } /** + * A chart change listener. + * + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/HashUtilitiesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/HashUtilitiesTest.java new file mode 100755 index 0000000..20c8bc9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/HashUtilitiesTest.java @@ -0,0 +1,68 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * HashUtilitiesTest.java + * ---------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 06-Mar-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +/** + * Tests for the {@link HashUtilities} class. + */ +public class HashUtilitiesTest { + + /** + * Some sanity checks for the hashCodeForDoubleArray() method. + */ + @Test + public void testHashCodeForDoubleArray() { + double[] a1 = new double[] {1.0}; + double[] a2 = new double[] {1.0}; + int h1 = HashUtilities.hashCodeForDoubleArray(a1); + int h2 = HashUtilities.hashCodeForDoubleArray(a2); + assertEquals(h1, h2); + + double[] a3 = new double[] {0.5, 1.0}; + int h3 = HashUtilities.hashCodeForDoubleArray(a3); + assertFalse(h1 == h3); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/JFreeChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/JFreeChartTest.java new file mode 100755 index 0000000..15fb42c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/JFreeChartTest.java @@ -0,0 +1,485 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * JFreeChartTest.java + * ------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 11-Jun-2002 : Version 1 (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 23-Sep-2003 : Removed null title test, since TM has added code to ensure + * null titles cannot be created (DG); + * 24-Nov-2005 : Removed OldLegend (DG); + * 16-May-2007 : Added some new tests (DG); + * + */ + +package org.jfree.chart; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.RenderingHints; +import java.util.List; + +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.plot.PiePlot; +import org.jfree.chart.plot.RingPlot; +import org.jfree.chart.title.LegendTitle; +import org.jfree.chart.title.TextTitle; +import org.jfree.chart.title.Title; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.data.general.DefaultPieDataset; +import org.jfree.data.time.Day; +import org.jfree.data.time.RegularTimePeriod; +import org.jfree.data.time.TimeSeries; +import org.jfree.data.time.TimeSeriesCollection; +import org.jfree.ui.Align; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.RectangleInsets; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.fail; + +/** + * Tests for the {@link JFreeChart} class. + */ +public class JFreeChartTest implements ChartChangeListener { + + /** A pie chart. */ + private JFreeChart pieChart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + DefaultPieDataset data = new DefaultPieDataset(); + data.setValue("Java", new Double(43.2)); + data.setValue("Visual Basic", new Double(0.0)); + data.setValue("C/C++", new Double(17.5)); + this.pieChart = ChartFactory.createPieChart("Pie Chart", data); + } + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + JFreeChart chart1 = new JFreeChart("Title", + new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true); + JFreeChart chart2 = new JFreeChart("Title", + new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true); + assertEquals(chart1, chart2); + assertEquals(chart2, chart1); + + // renderingHints + chart1.setRenderingHints(new RenderingHints( + RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON)); + assertFalse(chart1.equals(chart2)); + chart2.setRenderingHints(new RenderingHints( + RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON)); + assertEquals(chart1, chart2); + + // borderVisible + chart1.setBorderVisible(true); + assertFalse(chart1.equals(chart2)); + chart2.setBorderVisible(true); + assertEquals(chart1, chart2); + + // borderStroke + BasicStroke s = new BasicStroke(2.0f); + chart1.setBorderStroke(s); + assertFalse(chart1.equals(chart2)); + chart2.setBorderStroke(s); + assertEquals(chart1, chart2); + + // borderPaint + chart1.setBorderPaint(Color.red); + assertFalse(chart1.equals(chart2)); + chart2.setBorderPaint(Color.red); + assertEquals(chart1, chart2); + + // padding + chart1.setPadding(new RectangleInsets(1, 2, 3, 4)); + assertFalse(chart1.equals(chart2)); + chart2.setPadding(new RectangleInsets(1, 2, 3, 4)); + assertEquals(chart1, chart2); + + // title + chart1.setTitle("XYZ"); + assertFalse(chart1.equals(chart2)); + chart2.setTitle("XYZ"); + assertEquals(chart1, chart2); + + // subtitles + chart1.addSubtitle(new TextTitle("Subtitle")); + assertFalse(chart1.equals(chart2)); + chart2.addSubtitle(new TextTitle("Subtitle")); + assertEquals(chart1, chart2); + + // plot + chart1 = new JFreeChart("Title", + new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false); + chart2 = new JFreeChart("Title", + new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false); + assertFalse(chart1.equals(chart2)); + chart2 = new JFreeChart("Title", + new Font("SansSerif", Font.PLAIN, 12), new RingPlot(), false); + assertEquals(chart1, chart2); + + // backgroundPaint + chart1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertFalse(chart1.equals(chart2)); + chart2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertEquals(chart1, chart2); + + // backgroundImage + chart1.setBackgroundImage(JFreeChart.INFO.getLogo()); + assertFalse(chart1.equals(chart2)); + chart2.setBackgroundImage(JFreeChart.INFO.getLogo()); + assertEquals(chart1, chart2); + + // backgroundImageAlignment + chart1.setBackgroundImageAlignment(Align.BOTTOM_LEFT); + assertFalse(chart1.equals(chart2)); + chart2.setBackgroundImageAlignment(Align.BOTTOM_LEFT); + assertEquals(chart1, chart2); + + // backgroundImageAlpha + chart1.setBackgroundImageAlpha(0.1f); + assertFalse(chart1.equals(chart2)); + chart2.setBackgroundImageAlpha(0.1f); + assertEquals(chart1, chart2); + } + + /** + * A test to make sure that the legend is being picked up in the + * equals() testing. + */ + @Test + public void testEquals2() { + JFreeChart chart1 = new JFreeChart("Title", + new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), true); + JFreeChart chart2 = new JFreeChart("Title", + new Font("SansSerif", Font.PLAIN, 12), new PiePlot(), false); + assertFalse(chart1.equals(chart2)); + assertFalse(chart2.equals(chart1)); + } + + /** + * Checks the subtitle count - should be 1 (the legend). + */ + @Test + public void testSubtitleCount() { + int count = this.pieChart.getSubtitleCount(); + assertEquals(1, count); + } + + /** + * Some checks for the getSubtitle() method. + */ + @Test + public void testGetSubtitle() { + DefaultPieDataset dataset = new DefaultPieDataset(); + JFreeChart chart = ChartFactory.createPieChart("title", dataset); + Title t = chart.getSubtitle(0); + assertTrue(t instanceof LegendTitle); + + try { + chart.getSubtitle(-1); + fail("Should have thrown an IllegalArgumentException on negative number"); + } + catch (IllegalArgumentException e) { + assertEquals("Index out of range.", e.getMessage()); + } + + try { + chart.getSubtitle(1); + fail("Should have thrown an IllegalArgumentException on excesive number"); + } + catch (IllegalArgumentException e) { + assertEquals("Index out of range.", e.getMessage()); + } + + try { + chart.getSubtitle(2); + fail("Should have thrown an IllegalArgumentException on number being out of range"); + } + catch (IllegalArgumentException e) { + assertEquals("Index out of range.", e.getMessage()); + } + + } + + /** + * Serialize a pie chart, restore it, and check for equality. + */ + @Test + public void testSerialization1() { + DefaultPieDataset data = new DefaultPieDataset(); + data.setValue("Type 1", 54.5); + data.setValue("Type 2", 23.9); + data.setValue("Type 3", 45.8); + + JFreeChart c1 = ChartFactory.createPieChart("Test", data); + JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1); + assertEquals(c1, c2); + LegendTitle lt2 = c2.getLegend(); + assertSame(lt2.getSources()[0], c2.getPlot()); + } + + /** + * Serialize a 3D pie chart, restore it, and check for equality. + */ + @Test + public void testSerialization2() { + DefaultPieDataset data = new DefaultPieDataset(); + data.setValue("Type 1", 54.5); + data.setValue("Type 2", 23.9); + data.setValue("Type 3", 45.8); + JFreeChart c1 = ChartFactory.createPieChart3D("Test", data); + JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + + /** + * Serialize a bar chart, restore it, and check for equality. + */ + @Test + public void testSerialization3() { + + // row keys... + String series1 = "First"; + String series2 = "Second"; + String series3 = "Third"; + + // column keys... + String category1 = "Category 1"; + String category2 = "Category 2"; + String category3 = "Category 3"; + String category4 = "Category 4"; + String category5 = "Category 5"; + String category6 = "Category 6"; + String category7 = "Category 7"; + String category8 = "Category 8"; + + // create the dataset... + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + + dataset.addValue(1.0, series1, category1); + dataset.addValue(4.0, series1, category2); + dataset.addValue(3.0, series1, category3); + dataset.addValue(5.0, series1, category4); + dataset.addValue(5.0, series1, category5); + dataset.addValue(7.0, series1, category6); + dataset.addValue(7.0, series1, category7); + dataset.addValue(8.0, series1, category8); + + dataset.addValue(5.0, series2, category1); + dataset.addValue(7.0, series2, category2); + dataset.addValue(6.0, series2, category3); + dataset.addValue(8.0, series2, category4); + dataset.addValue(4.0, series2, category5); + dataset.addValue(4.0, series2, category6); + dataset.addValue(2.0, series2, category7); + dataset.addValue(1.0, series2, category8); + + dataset.addValue(4.0, series3, category1); + dataset.addValue(3.0, series3, category2); + dataset.addValue(2.0, series3, category3); + dataset.addValue(3.0, series3, category4); + dataset.addValue(6.0, series3, category5); + dataset.addValue(3.0, series3, category6); + dataset.addValue(4.0, series3, category7); + dataset.addValue(3.0, series3, category8); + + // create the chart... + JFreeChart c1 = ChartFactory.createBarChart("Vertical Bar Chart", + "Category", "Value", dataset); + JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + + /** + * Serialize a time seroes chart, restore it, and check for equality. + */ + @Test + public void testSerialization4() { + + RegularTimePeriod t = new Day(); + TimeSeries series = new TimeSeries("Series 1"); + series.add(t, 36.4); + t = t.next(); + series.add(t, 63.5); + TimeSeriesCollection dataset = new TimeSeriesCollection(); + dataset.addSeries(series); + + JFreeChart c1 = ChartFactory.createTimeSeriesChart("Test", "Date", + "Value", dataset); + JFreeChart c2 = (JFreeChart) TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + + /** + * Some checks for the addSubtitle() methods. + */ + @Test + public void testAddSubtitle() { + DefaultPieDataset dataset = new DefaultPieDataset(); + JFreeChart chart = ChartFactory.createPieChart("title", dataset); + + TextTitle t0 = new TextTitle("T0"); + chart.addSubtitle(0, t0); + assertEquals(t0, chart.getSubtitle(0)); + + TextTitle t1 = new TextTitle("T1"); + chart.addSubtitle(t1); + assertEquals(t1, chart.getSubtitle(2)); // subtitle 1 is the legend + + try { + chart.addSubtitle(null); + fail("Should have thrown an IllegalArgumentException on index out of range"); + } + catch (IllegalArgumentException e) { + assertEquals("Null 'subtitle' argument.", e.getMessage()); + } + + try { + chart.addSubtitle(-1, t0); + fail("Should have thrown an IllegalArgumentException on index out of range"); + } + catch (IllegalArgumentException e) { + assertEquals("The 'index' argument is out of range.", e.getMessage()); + } + + try { + chart.addSubtitle(4, t0); + fail("Should have thrown an IllegalArgumentException on index out of range"); + } + catch (IllegalArgumentException e) { + assertEquals("The 'index' argument is out of range.", e.getMessage()); + } + + } + + /** + * Some checks for the getSubtitles() method. + */ + @Test + public void testGetSubtitles() { + DefaultPieDataset dataset = new DefaultPieDataset(); + JFreeChart chart = ChartFactory.createPieChart("title", dataset); + List subtitles = chart.getSubtitles(); + + assertEquals(1, chart.getSubtitleCount()); + + // adding something to the returned list should NOT change the chart + subtitles.add(new TextTitle("T")); + assertEquals(1, chart.getSubtitleCount()); + } + + /** + * Some checks for the default legend firing change events. + */ + @Test + public void testLegendEvents() { + DefaultPieDataset dataset = new DefaultPieDataset(); + JFreeChart chart = ChartFactory.createPieChart("title", dataset); + chart.addChangeListener(this); + this.lastChartChangeEvent = null; + LegendTitle legend = chart.getLegend(); + legend.setPosition(RectangleEdge.TOP); + assertNotNull(this.lastChartChangeEvent); + } + + /** + * Some checks for title changes and event notification. + */ + @Test + public void testTitleChangeEvent() { + DefaultPieDataset dataset = new DefaultPieDataset(); + JFreeChart chart = ChartFactory.createPieChart("title", dataset); + chart.addChangeListener(this); + this.lastChartChangeEvent = null; + TextTitle t = chart.getTitle(); + t.setFont(new Font("Dialog", Font.BOLD, 9)); + assertNotNull(this.lastChartChangeEvent); + this.lastChartChangeEvent = null; + + // now create a new title and replace the existing title, several + // things should happen: + // (1) Adding the new title should trigger an immediate + // ChartChangeEvent; + // (2) Modifying the new title should trigger a ChartChangeEvent; + // (3) Modifying the old title should NOT trigger a ChartChangeEvent + TextTitle t2 = new TextTitle("T2"); + chart.setTitle(t2); + assertNotNull(this.lastChartChangeEvent); + this.lastChartChangeEvent = null; + + t2.setFont(new Font("Dialog", Font.BOLD, 9)); + assertNotNull(this.lastChartChangeEvent); + this.lastChartChangeEvent = null; + + t.setFont(new Font("Dialog", Font.BOLD, 9)); + assertNull(this.lastChartChangeEvent); + this.lastChartChangeEvent = null; + } + + /** The last ChartChangeEvent received. */ + private ChartChangeEvent lastChartChangeEvent; + + /** + * Records the last chart change event. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.lastChartChangeEvent = event; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/LegendItemCollectionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/LegendItemCollectionTest.java new file mode 100755 index 0000000..59272eb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/LegendItemCollectionTest.java @@ -0,0 +1,121 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2012, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * LegendItemCollectionTest.java + * ----------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Apr-2005 : Version 1 (DG); + * 23-Apr-2008 : Extended testCloning() (DG); + * + */ + +package org.jfree.chart; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertNotSame; + +/** + * Tests for the {@link LegendItemCollection} class. + */ +public class LegendItemCollectionTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + LegendItemCollection c1 = new LegendItemCollection(); + LegendItemCollection c2 = new LegendItemCollection(); + assertEquals(c1, c2); + assertEquals(c2, c1); + + LegendItem item1 = new LegendItem("Label", "Description", + "ToolTip", "URL", true, + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, + true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), + new BasicStroke(2.1f), Color.green); + LegendItem item2 = new LegendItem("Label", "Description", + "ToolTip", "URL", true, + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), + true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + c1.add(item1); + assertFalse(c1.equals(c2)); + c2.add(item2); + assertEquals(c1, c2); + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + LegendItemCollection c1 = new LegendItemCollection(); + c1.add(new LegendItem("Item", "Description", "ToolTip", "URL", + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.red)); + LegendItemCollection c2 = (LegendItemCollection) TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + LegendItemCollection c1 = new LegendItemCollection(); + LegendItem item1 = new LegendItem("Item 1"); + c1.add(item1); + LegendItemCollection c2 = (LegendItemCollection) c1.clone(); + + assertNotSame(c1, c2); + assertSame(c1.getClass(), c2.getClass()); + assertEquals(c1, c2); + + Rectangle2D item1Shape = (Rectangle2D) item1.getShape(); + item1Shape.setRect(1.0, 2.0, 3.0, 4.0); + assertFalse(c1.equals(c2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/LegendItemTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/LegendItemTest.java new file mode 100755 index 0000000..a82aca6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/LegendItemTest.java @@ -0,0 +1,359 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * LegendItemTest.java + * ------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Jun-2004 : Version 1 (DG); + * 10-Dec-2005 : Addded new test to cover bug report 1374328 (DG); + * 13-Dec-2006 : Extended testEquals() for new fillPaintTransformer + * attribute (DG); + * 23-Apr-2008 : Implemented Cloneable (DG); + * 17-Jun-2008 : Included new fields in existing tests (DG); + * + */ + +package org.jfree.chart; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.font.TextAttribute; +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; +import java.text.AttributedString; + +import org.jfree.ui.GradientPaintTransformType; +import org.jfree.ui.StandardGradientPaintTransformer; + +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertNotSame; + + +/** + * Tests for the {@link LegendItem} class. + */ +public class LegendItemTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + LegendItem item1 = new LegendItem("Label", "Description", + "ToolTip", "URL", true, + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, + true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), + new BasicStroke(2.1f), Color.green); + LegendItem item2 = new LegendItem("Label", "Description", + "ToolTip", "URL", true, + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), + true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertEquals(item1, item2); + assertEquals(item2, item1); + + item1 = new LegendItem("Label2", "Description", "ToolTip", "URL", + true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, + Color.red, true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertFalse(item1.equals(item2)); + item2 = new LegendItem("Label2", "Description", "ToolTip", "URL", + true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), + true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertEquals(item1, item2); + + item1 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), + true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertFalse(item1.equals(item2)); + item2 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), + true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertEquals(item1, item2); + + item1 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", false, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), + true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertFalse(item1.equals(item2)); + item2 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", false, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), + true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertEquals(item1, item2); + + item1 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertFalse(item1.equals(item2)); + item2 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + true, Color.red, true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertEquals(item1, item2); + + item1 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + false, Color.red, true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertFalse(item1.equals(item2)); + item2 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + false, Color.red, true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertEquals(item1, item2); + + item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", + false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, + Color.black, true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertFalse(item1.equals(item2)); + item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", + false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, + Color.black, true, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertEquals(item1, item2); + + item1 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + false, Color.black, false, Color.blue, new BasicStroke(1.2f), + true, new Line2D.Double(1.0, 2.0, 3.0, 4.0), + new BasicStroke(2.1f), Color.green); + assertFalse(item1.equals(item2)); + item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", + false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, + Color.black, false, Color.blue, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertEquals(item1, item2); + + item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", + false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, + Color.black, false, Color.yellow, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertFalse(item1.equals(item2)); + item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", + false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, + Color.black, false, Color.yellow, new BasicStroke(1.2f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertEquals(item1, item2); + + item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", + false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, + Color.black, false, Color.yellow, new BasicStroke(2.1f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertFalse(item1.equals(item2)); + item2 = new LegendItem("Label2", "Description2", "ToolTip", "URL", + false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, + Color.black, false, Color.yellow, new BasicStroke(2.1f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(2.1f), + Color.green); + assertEquals(item1, item2); + + item1 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + false, Color.black, false, Color.yellow, new BasicStroke(2.1f), + false, new Line2D.Double(1.0, 2.0, 3.0, 4.0), + new BasicStroke(2.1f), Color.green); + assertFalse(item1.equals(item2)); + item2 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + false, Color.black, false, Color.yellow, new BasicStroke(2.1f), + false, new Line2D.Double(1.0, 2.0, 3.0, 4.0), + new BasicStroke(2.1f), Color.green); + assertEquals(item1, item2); + + item1 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + false, Color.black, false, Color.yellow, new BasicStroke(2.1f), + false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), + new BasicStroke(2.1f), Color.green); + assertFalse(item1.equals(item2)); + item2 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + false, Color.black, false, Color.yellow, new BasicStroke(2.1f), + false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), + new BasicStroke(2.1f), Color.green); + assertEquals(item1, item2); + + item1 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + false, Color.black, false, Color.yellow, new BasicStroke(2.1f), + false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), + new BasicStroke(3.3f), Color.green); + assertFalse(item1.equals(item2)); + item2 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + false, Color.black, false, Color.yellow, new BasicStroke(2.1f), + false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), + new BasicStroke(3.3f), Color.green); + assertEquals(item1, item2); + + item1 = new LegendItem("Label2", "Description2", "ToolTip", "URL", + false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), false, + Color.black, false, Color.yellow, new BasicStroke(2.1f), false, + new Line2D.Double(4.0, 3.0, 2.0, 1.0), new BasicStroke(3.3f), + Color.white + ); + assertFalse(item1.equals(item2)); + item2 = new LegendItem("Label2", "Description2", "ToolTip", + "URL", false, new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + false, Color.black, false, Color.yellow, new BasicStroke(2.1f), + false, new Line2D.Double(4.0, 3.0, 2.0, 1.0), + new BasicStroke(3.3f), + Color.white); + assertEquals(item1, item2); + + // fillPaintTransformer + item1.setFillPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_VERTICAL)); + assertFalse(item1.equals(item2)); + item2.setFillPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_VERTICAL)); + assertEquals(item1, item2); + + // labelFont + item1.setLabelFont(new Font("Dialog", Font.PLAIN, 13)); + assertFalse(item1.equals(item2)); + item2.setLabelFont(new Font("Dialog", Font.PLAIN, 13)); + assertEquals(item1, item2); + + // labelPaint + item1.setLabelPaint(Color.red); + assertFalse(item1.equals(item2)); + item2.setLabelPaint(Color.red); + assertEquals(item1, item2); + + // fillPaint + item1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, + 4.0f, Color.blue)); + assertFalse(item1.equals(item2)); + item2.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, + 4.0f, Color.blue)); + assertEquals(item1, item2); + + // outlinePaint + item1.setOutlinePaint(new GradientPaint(1.1f, 2.2f, Color.green, 3.3f, + 4.4f, Color.blue)); + assertFalse(item1.equals(item2)); + item2.setOutlinePaint(new GradientPaint(1.1f, 2.2f, Color.green, 3.3f, + 4.4f, Color.blue)); + assertEquals(item1, item2); + + // linePaint + item1.setLinePaint(new GradientPaint(0.1f, 0.2f, Color.green, 0.3f, + 0.4f, Color.blue)); + assertFalse(item1.equals(item2)); + item2.setLinePaint(new GradientPaint(0.1f, 0.2f, Color.green, 0.3f, + 0.4f, Color.blue)); + assertEquals(item1, item2); + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + LegendItem item1 = new LegendItem("Item", "Description", + "ToolTip", "URL", + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), new GradientPaint( + 5.0f, 6.0f, Color.blue, 7.0f, 8.0f, Color.gray)); + item1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.yellow)); + item1.setOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.green, 2.0f, + 1.0f, Color.red)); + item1.setLinePaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, + 4.0f, Color.red)); + LegendItem item2; + item2 = (LegendItem) TestUtilities.serialised(item1); + assertEquals(item1, item2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization2() { + AttributedString as = new AttributedString("Test String"); + as.addAttribute(TextAttribute.FONT, new Font("Dialog", Font.PLAIN, 12)); + LegendItem item1 = new LegendItem(as, "Description", "ToolTip", "URL", + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), Color.red); + LegendItem item2 = (LegendItem) TestUtilities.serialised(item1); + assertEquals(item1, item2); + } + + /** + * Basic checks for cloning. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + LegendItem item1 = new LegendItem("Item"); + LegendItem item2 = (LegendItem) item1.clone(); + + assertNotSame(item1, item2); + assertSame(item1.getClass(), item2.getClass()); + assertEquals(item1, item2); + + // the clone references the same dataset as the original + assertSame(item1.getDataset(), item2.getDataset()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/LineChart3DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/LineChart3DTest.java new file mode 100755 index 0000000..baeb171 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/LineChart3DTest.java @@ -0,0 +1,195 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * LineChart3DTest.java + * -------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 12-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.CategoryToolTipGenerator; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.urls.CategoryURLGenerator; +import org.jfree.chart.urls.StandardCategoryURLGenerator; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetUtilities; +import org.junit.Before; +import org.junit.Test; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +/** + * Some tests for a line chart with a 3D effect. + */ +public class LineChart3DTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createLineChart3D(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + //FIXME we should really assert a value here + } + + /** + * Replaces the chart's dataset and then checks that the new dataset is OK. + */ + @Test + public void testReplaceDataset() { + + // create a dataset... + Number[][] data = new Integer[][] + {{new Integer(-30), new Integer(-20)}, + {new Integer(-10), new Integer(10)}, + {new Integer(20), new Integer(30)}}; + + CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", + "C", data); + + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + plot.setDataset(newData); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around -30: " + + range.getLowerBound(), range.getLowerBound() <= -30); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryToolTipGenerator tt + = new StandardCategoryToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertSame(tt2, tt); + } + + /** + * Check that setting a URL generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesURLGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryURLGenerator url1 + = new StandardCategoryURLGenerator(); + renderer.setSeriesItemURLGenerator(0, url1); + CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); + assertSame(url2, url1); + } + + /** + * Create a line chart with sample data in the range -3 to +3. + * + * @return The chart. + */ + private static JFreeChart createLineChart3D() { + Number[][] data = new Integer[][] + {{new Integer(-3), new Integer(-2)}, + {new Integer(-1), new Integer(1)}, + {new Integer(2), new Integer(3)}}; + + CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", + "C", data); + return ChartFactory.createLineChart3D("Line Chart", "Domain", "Range", + dataset); + } + + /** + * A chart change listener. + * + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/LineChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/LineChartTest.java new file mode 100755 index 0000000..886b0a3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/LineChartTest.java @@ -0,0 +1,197 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * LineChartTest.java + * ------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 12-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.CategoryToolTipGenerator; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.urls.CategoryURLGenerator; +import org.jfree.chart.urls.StandardCategoryURLGenerator; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetUtilities; +import org.junit.Before; +import org.junit.Test; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + +/** + * Some tests for a line chart. + */ +public class LineChartTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createLineChart(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + //FIXME we should really assert a value here + } + + /** + * Replaces the chart's dataset and then checks that the new dataset is OK. + */ + @Test + public void testReplaceDataset() { + + // create a dataset... + Number[][] data = new Integer[][] + {{new Integer(-30), new Integer(-20)}, + {new Integer(-10), new Integer(10)}, + {new Integer(20), new Integer(30)}}; + + CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", + "C", data); + + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + plot.setDataset(newData); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around -30: " + + range.getLowerBound(), range.getLowerBound() <= -30); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryToolTipGenerator tt + = new StandardCategoryToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertSame(tt2, tt); + } + + /** + * Check that setting a URL generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesURLGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryURLGenerator url1 + = new StandardCategoryURLGenerator(); + renderer.setSeriesItemURLGenerator(0, url1); + CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); + assertSame(url2, url1); + } + + /** + * Create a line chart with sample data in the range -3 to +3. + * + * @return The chart. + */ + private static JFreeChart createLineChart() { + + Number[][] data = new Integer[][] + {{new Integer(-3), new Integer(-2)}, + {new Integer(-1), new Integer(1)}, + {new Integer(2), new Integer(3)}}; + + CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", + "C", data); + + return ChartFactory.createLineChart("Line Chart", "Domain", "Range", + dataset); + + } + + /** + * A chart change listener. + * + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/MeterChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/MeterChartTest.java new file mode 100755 index 0000000..d2effdb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/MeterChartTest.java @@ -0,0 +1,75 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * MeterChartTest.java + * ------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 29-Mar-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.plot.MeterInterval; +import org.jfree.chart.plot.MeterPlot; +import org.jfree.data.Range; +import org.jfree.data.general.DefaultValueDataset; +import org.junit.Test; + +/** + * Miscellaneous checks for meter charts. + */ +public class MeterChartTest { + + /** + * Draws the chart with a single range. At one point, this caused a null + * pointer exception (fixed now). + */ + @Test + public void testDrawWithNullInfo() { + MeterPlot plot = new MeterPlot(new DefaultValueDataset(60.0)); + plot.addInterval(new MeterInterval("Normal", new Range(0.0, 80.0))); + JFreeChart chart = new JFreeChart(plot); + BufferedImage image = new BufferedImage(200, 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); + g2.dispose(); + //FIXME we should really assert a value here + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/PaintMapTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/PaintMapTest.java new file mode 100755 index 0000000..740a4fe --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/PaintMapTest.java @@ -0,0 +1,183 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * PaintMapTest.java + * ----------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 27-Sep-2006 : Version 1 (DG); + * 17-Jan-2007 : Added testKeysOfDifferentClasses() (DG); + * + */ + +package org.jfree.chart; + +import org.junit.Test; + +import java.awt.Color; +import java.awt.GradientPaint; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +/** + * Some tests for the {@link PaintMap} class. + */ +public class PaintMapTest { + + /** + * Some checks for the getPaint() method. + */ + @Test + public void testGetPaint() { + PaintMap m1 = new PaintMap(); + assertEquals(null, m1.getPaint("A")); + m1.put("A", Color.red); + assertEquals(Color.red, m1.getPaint("A")); + m1.put("A", null); + assertEquals(null, m1.getPaint("A")); + + // a null key should throw an IllegalArgumentException + try { + m1.getPaint(null); + fail("IllegalArgumentException should have been thrown on passing null value"); + } + catch (IllegalArgumentException e) { + assertEquals("Null 'key' argument.", e.getMessage()); + } + } + + /** + * Some checks for the put() method. + */ + @Test + public void testPut() { + PaintMap m1 = new PaintMap(); + m1.put("A", Color.red); + assertEquals(Color.red, m1.getPaint("A")); + + // a null key should throw an IllegalArgumentException + + try { + m1.put(null, Color.blue); + fail("IllegalArgumentException should have been thrown on null key"); + } + catch (IllegalArgumentException e) { + assertEquals("Null 'key' argument.", e.getMessage()); + } + } + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + PaintMap m1 = new PaintMap(); + PaintMap m2 = new PaintMap(); + assertEquals(m1, m1); + assertEquals(m1, m2); + assertFalse(m1.equals(null)); + assertFalse(m1.equals("ABC")); + + m1.put("K1", Color.red); + assertFalse(m1.equals(m2)); + m2.put("K1", Color.red); + assertEquals(m1, m2); + + m1.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, + Color.yellow)); + assertFalse(m1.equals(m2)); + m2.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, + Color.yellow)); + assertEquals(m1, m2); + + m1.put("K2", null); + assertFalse(m1.equals(m2)); + m2.put("K2", null); + assertEquals(m1, m2); + } + + /** + * Some checks for cloning. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + PaintMap m1 = new PaintMap(); + PaintMap m2 = (PaintMap) m1.clone(); + assertEquals(m1, m2); + + m1.put("K1", Color.red); + m1.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, + Color.yellow)); + m2 = (PaintMap) m1.clone(); + assertEquals(m1, m2); + } + + /** + * A check for serialization. + */ + @Test + public void testSerialization1() { + PaintMap m1 = new PaintMap(); + PaintMap m2 = (PaintMap) TestUtilities.serialised(m1); + assertEquals(m1, m2); + } + + /** + * A check for serialization. + */ + @Test + public void testSerialization2() { + PaintMap m1 = new PaintMap(); + m1.put("K1", Color.red); + m1.put("K2", new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, 4.0f, + Color.yellow)); + PaintMap m2 = (PaintMap) TestUtilities.serialised(m1); + assertEquals(m1, m2); + } + + /** + * This test covers a bug reported in the forum: + * + * http://www.jfree.org/phpBB2/viewtopic.php?t=19980 + */ + @Test + public void testKeysOfDifferentClasses() { + PaintMap m = new PaintMap(); + m.put("ABC", Color.red); + m.put(new Integer(99), Color.blue); + assertEquals(Color.blue, m.getPaint(new Integer(99))); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/PieChart3DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/PieChart3DTest.java new file mode 100755 index 0000000..52f7e7f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/PieChart3DTest.java @@ -0,0 +1,142 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * PieChart3DTest.java + * ------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 21-May-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.plot.PiePlot; +import org.jfree.data.general.DefaultPieDataset; +import org.jfree.data.general.PieDataset; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertEquals; +/** + * Tests for a pie chart with a 3D effect. + */ +public class PieChart3DTest { + + /** A chart. */ + private JFreeChart pieChart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + // create a dataset... + DefaultPieDataset dataset = new DefaultPieDataset(); + dataset.setValue("Java", new Double(43.2)); + dataset.setValue("Visual Basic", new Double(0.0)); + dataset.setValue("C/C++", new Double(17.5)); + this.pieChart = createPieChart3D(dataset); + } + + /** + * Using a regular pie chart, we replace the dataset with null. Expect to + * receive notification of a chart change event, and (of course) the + * dataset should be null. + */ + @Test + public void testReplaceDatasetOnPieChart() { + LocalListener l = new LocalListener(); + this.pieChart.addChangeListener(l); + PiePlot plot = (PiePlot) this.pieChart.getPlot(); + plot.setDataset(null); + assertEquals(true, l.flag); + assertNull(plot.getDataset()); + } + + /** + * Tests that no exceptions are thrown when there is a null + * value in the dataset. + */ + @Test + public void testNullValueInDataset() { + DefaultPieDataset dataset = new DefaultPieDataset(); + dataset.setValue("Section 1", 10.0); + dataset.setValue("Section 2", 11.0); + dataset.setValue("Section 3", null); + JFreeChart chart = createPieChart3D(dataset); + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); + g2.dispose(); + //FIXME we should really assert a value here + } + + /** + * Creates a pie chart. + * + * @param dataset the dataset. + * + * @return The pie chart. + */ + private static JFreeChart createPieChart3D(PieDataset dataset) { + return ChartFactory.createPieChart3D("Pie Chart", dataset); + } + + /** + * A chart change listener. + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/PieChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/PieChartTest.java new file mode 100755 index 0000000..738c33b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/PieChartTest.java @@ -0,0 +1,120 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * PieChartTest.java + * ----------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 11-Jun-2002 : Version 1 (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * + */ + +package org.jfree.chart; + +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.plot.PiePlot; +import org.jfree.data.general.DefaultPieDataset; +import org.junit.Before; +import org.junit.Test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +/** + * Tests for a pie chart. + * + */ +public class PieChartTest { + + /** A chart. */ + private JFreeChart pieChart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.pieChart = createPieChart(); + } + + /** + * Using a regular pie chart, we replace the dataset with null. Expect to + * receive notification of a chart change event, and (of course) the + * dataset should be null. + */ + @Test + public void testReplaceDatasetOnPieChart() { + LocalListener l = new LocalListener(); + this.pieChart.addChangeListener(l); + PiePlot plot = (PiePlot) this.pieChart.getPlot(); + plot.setDataset(null); + assertEquals(true, l.flag); + assertNull(plot.getDataset()); + } + + /** + * Creates a pie chart. + * + * @return The pie chart. + */ + private static JFreeChart createPieChart() { + DefaultPieDataset data = new DefaultPieDataset(); + data.setValue("Java", new Double(43.2)); + data.setValue("Visual Basic", new Double(0.0)); + data.setValue("C/C++", new Double(17.5)); + return ChartFactory.createPieChart("Pie Chart", data); + } + + /** + * A chart change listener. + * + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/ScatterPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/ScatterPlotTest.java new file mode 100755 index 0000000..ce54524 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/ScatterPlotTest.java @@ -0,0 +1,178 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * ScatterPlotTest.java + * -------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 11-Jun-2002 : Version 1 (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * + */ + +package org.jfree.chart; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.StandardXYToolTipGenerator; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.data.Range; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests for a scatter plot. + */ +public class ScatterPlotTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createChart(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("No exception should be thrown."); + } + } + + /** + * Replaces the dataset and checks that it has changed as expected. + */ + @Test + public void testReplaceDataset() { + + // create a dataset... + XYSeries series1 = new XYSeries("Series 1"); + series1.add(10.0, 10.0); + series1.add(20.0, 20.0); + series1.add(30.0, 30.0); + XYDataset dataset = new XYSeriesCollection(series1); + + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + XYPlot plot = (XYPlot) this.chart.getPlot(); + plot.setDataset(dataset); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around 10: " + + range.getLowerBound(), range.getLowerBound() <= 10); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + XYPlot plot = (XYPlot) this.chart.getPlot(); + XYItemRenderer renderer = plot.getRenderer(); + StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertTrue(tt2 == tt); + } + + /** + * Create a horizontal bar chart with sample data in the range -3 to +3. + * + * @return The chart. + */ + private static JFreeChart createChart() { + XYSeries series1 = new XYSeries("Series 1"); + series1.add(1.0, 1.0); + series1.add(2.0, 2.0); + series1.add(3.0, 3.0); + XYDataset dataset = new XYSeriesCollection(series1); + return ChartFactory.createScatterPlot("Scatter Plot", "Domain", + "Range", dataset); + } + + /** + * A chart change listener. + * + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag = false; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StackedAreaChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StackedAreaChartTest.java new file mode 100755 index 0000000..fc4d023 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StackedAreaChartTest.java @@ -0,0 +1,204 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * StackedAreaChartTest.java + * ------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 12-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.CategoryToolTipGenerator; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.urls.CategoryURLGenerator; +import org.jfree.chart.urls.StandardCategoryURLGenerator; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetUtilities; +import org.junit.Before; +import org.junit.Test; + +/** + * Some tests for a stacked area chart. + */ +public class StackedAreaChartTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createChart(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("There should be no exception."); + } + } + + /** + * Replaces the dataset and checks that it has changed as expected. + */ + @Test + public void testReplaceDataset() { + Number[][] data = new Integer[][] + {{new Integer(-30), new Integer(-20)}, + {new Integer(-10), new Integer(10)}, + {new Integer(20), new Integer(30)}}; + + CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", + "C", data); + + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + plot.setDataset(newData); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around -30: " + + range.getLowerBound(), range.getLowerBound() <= -30); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryToolTipGenerator tt + = new StandardCategoryToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertTrue(tt2 == tt); + } + + /** + * Check that setting a URL generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesURLGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryURLGenerator url1 + = new StandardCategoryURLGenerator(); + renderer.setSeriesItemURLGenerator(0, url1); + CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); + assertTrue(url2 == url1); + } + + /** + * Create a stacked bar chart with sample data in the range -3 to +3. + * + * @return The chart. + */ + private static JFreeChart createChart() { + Number[][] data = new Integer[][] + {{new Integer(-3), new Integer(-2)}, + {new Integer(-1), new Integer(1)}, + {new Integer(2), new Integer(3)}}; + + CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", + "C", data); + return ChartFactory.createStackedAreaChart( + "Stacked Area Chart", // chart title + "Domain", "Range", + dataset, // data + PlotOrientation.HORIZONTAL, + true, // include legend + true, + true + ); + + } + + /** + * A chart change listener. + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag = false; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StackedBarChart3DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StackedBarChart3DTest.java new file mode 100755 index 0000000..6883363 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StackedBarChart3DTest.java @@ -0,0 +1,207 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * StackedBarChart3DTest.java + * -------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 12-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.CategoryToolTipGenerator; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.urls.CategoryURLGenerator; +import org.jfree.chart.urls.StandardCategoryURLGenerator; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetUtilities; +import org.junit.Before; +import org.junit.Test; + +/** + * Some tests for a stacked bar chart with 3D effect. + */ +public class StackedBarChart3DTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createChart(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("There should be no exception."); + } + } + + /** + * Replaces the dataset and checks that it has changed as expected. + */ + @Test + public void testReplaceDataset() { + + // create a dataset... + Number[][] data = new Integer[][] + {{new Integer(-30), new Integer(-20)}, + {new Integer(-10), new Integer(10)}, + {new Integer(20), new Integer(30)}}; + + CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", + "C", data); + + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + plot.setDataset(newData); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around -30: " + + range.getLowerBound(), range.getLowerBound() <= -30); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryToolTipGenerator tt + = new StandardCategoryToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertTrue(tt2 == tt); + } + + /** + * Check that setting a URL generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesURLGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryURLGenerator url1 + = new StandardCategoryURLGenerator(); + renderer.setSeriesItemURLGenerator(0, url1); + CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); + assertTrue(url2 == url1); + } + + /** + * Create a stacked bar chart with sample data in the range -3 to +3. + * + * @return The chart. + */ + private static JFreeChart createChart() { + + Number[][] data = new Integer[][] + {{new Integer(-3), new Integer(-2)}, + {new Integer(-1), new Integer(1)}, + {new Integer(2), new Integer(3)}}; + + CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", + "C", data); + return ChartFactory.createStackedBarChart3D( + "Stacked Bar Chart 3D", // chart title + "Domain", "Range", + dataset, // data + PlotOrientation.HORIZONTAL, + true, // include legend + true, + true + ); + + } + + /** + * A chart change listener. + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag = false; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StackedBarChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StackedBarChartTest.java new file mode 100755 index 0000000..7696c02 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StackedBarChartTest.java @@ -0,0 +1,210 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * StackedBarChartTest.java + * ------------------------ + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 11-Jun-2002 : Version 1 (DG); + * 25-Jun-2002 : Removed unnecessary import (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 29-Jan-2004 : Renamed StackedHorizontalBarChartTests + * --> StackedBarChartTests (DG); + * + */ + +package org.jfree.chart; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.CategoryToolTipGenerator; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.urls.CategoryURLGenerator; +import org.jfree.chart.urls.StandardCategoryURLGenerator; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetUtilities; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests for a stacked bar chart. + */ +public class StackedBarChartTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createChart(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("There should be no exception."); + } + } + + /** + * Replaces the dataset and checks that it has changed as expected. + */ + @Test + public void testReplaceDataset() { + + // create a dataset... + Number[][] data = new Integer[][] + {{new Integer(-30), new Integer(-20)}, + {new Integer(-10), new Integer(10)}, + {new Integer(20), new Integer(30)}}; + + CategoryDataset newData = DatasetUtilities.createCategoryDataset("S", + "C", data); + + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + plot.setDataset(newData); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around -30: " + + range.getLowerBound(), range.getLowerBound() <= -30); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryToolTipGenerator tt + = new StandardCategoryToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertTrue(tt2 == tt); + } + + /** + * Check that setting a URL generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesURLGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryURLGenerator url1 + = new StandardCategoryURLGenerator(); + renderer.setSeriesItemURLGenerator(0, url1); + CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); + assertTrue(url2 == url1); + } + + /** + * Create a stacked bar chart with sample data in the range -3 to +3. + * + * @return The chart. + */ + private static JFreeChart createChart() { + Number[][] data = new Integer[][] + {{new Integer(-3), new Integer(-2)}, + {new Integer(-1), new Integer(1)}, + {new Integer(2), new Integer(3)}}; + + CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", + "C", data); + return ChartFactory.createStackedBarChart( + "Stacked Bar Chart", // chart title + "Domain", "Range", + dataset, // data + PlotOrientation.HORIZONTAL, + true, // include legend + true, + true + ); + + } + + /** + * A chart change listener. + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag = false; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StandardChartThemeTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StandardChartThemeTest.java new file mode 100755 index 0000000..a272138 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StandardChartThemeTest.java @@ -0,0 +1,284 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * StandardChartThemeTest.java + * --------------------------- + * (C) Copyright 2008-2013, 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 static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.plot.DefaultDrawingSupplier; +import org.jfree.chart.plot.PieLabelLinkStyle; +import org.jfree.chart.renderer.category.StandardBarPainter; +import org.jfree.chart.renderer.xy.StandardXYBarPainter; +import org.jfree.ui.RectangleInsets; +import org.junit.Test; + +/** + * Tests for the {@link StandardChartTheme} class. + */ +public class StandardChartThemeTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + StandardChartTheme t1 = new StandardChartTheme("Name"); + StandardChartTheme t2 = new StandardChartTheme("Name"); + assertTrue(t1.equals(t2)); + + // name + t1 = new StandardChartTheme("t1"); + assertFalse(t1.equals(t2)); + t2 = new StandardChartTheme("t1"); + assertTrue(t1.equals(t2)); + + //extraLargeFont + t1.setExtraLargeFont(new Font("Dialog", Font.PLAIN, 21)); + assertFalse(t1.equals(t2)); + t2.setExtraLargeFont(new Font("Dialog", Font.PLAIN, 21)); + assertTrue(t1.equals(t2)); + + //largeFont + t1.setLargeFont(new Font("Dialog", Font.PLAIN, 19)); + assertFalse(t1.equals(t2)); + t2.setLargeFont(new Font("Dialog", Font.PLAIN, 19)); + assertTrue(t1.equals(t2)); + + //regularFont; + t1.setRegularFont(new Font("Dialog", Font.PLAIN, 17)); + assertFalse(t1.equals(t2)); + t2.setRegularFont(new Font("Dialog", Font.PLAIN, 17)); + assertTrue(t1.equals(t2)); + + //titlePaint; + t1.setTitlePaint(new GradientPaint(0f, 1f, Color.red, 2f, 3f, Color.blue)); + assertFalse(t1.equals(t2)); + t2.setTitlePaint(new GradientPaint(0f, 1f, Color.red, 2f, 3f, Color.blue)); + assertTrue(t1.equals(t2)); + + //subtitlePaint; + t1.setSubtitlePaint(new GradientPaint(1f, 2f, Color.red, 3f, 4f, Color.blue)); + assertFalse(t1.equals(t2)); + t2.setSubtitlePaint(new GradientPaint(1f, 2f, Color.red, 3f, 4f, Color.blue)); + assertTrue(t1.equals(t2)); + + //chartBackgroundPaint; + t1.setChartBackgroundPaint(new GradientPaint(2f, 3f, Color.blue, 4f, 5f, Color.red)); + assertFalse(t1.equals(t2)); + t2.setChartBackgroundPaint(new GradientPaint(2f, 3f, Color.blue, 4f, 5f, Color.red)); + assertTrue(t1.equals(t2)); + + //legendBackgroundPaint; + t1.setLegendBackgroundPaint(new GradientPaint(3f, 4f, Color.gray, 1f, 2f, Color.red)); + assertFalse(t1.equals(t2)); + t2.setLegendBackgroundPaint(new GradientPaint(3f, 4f, Color.gray, 1f, 2f, Color.red)); + assertTrue(t1.equals(t2)); + + //legendItemPaint; + t1.setLegendItemPaint(new GradientPaint(9f, 8f, Color.red, 7f, 6f, Color.blue)); + assertFalse(t1.equals(t2)); + t2.setLegendItemPaint(new GradientPaint(9f, 8f, Color.red, 7f, 6f, Color.blue)); + assertTrue(t1.equals(t2)); + + //drawingSupplier; + t1.setDrawingSupplier(new DefaultDrawingSupplier( + new Paint[] {Color.red}, + new Paint[] {Color.blue}, + new Stroke[] {new BasicStroke(1.0f)}, + new Stroke[] {new BasicStroke(1.0f)}, + new Shape[] {new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)})); + assertFalse(t1.equals(t2)); + t2.setDrawingSupplier(new DefaultDrawingSupplier( + new Paint[] {Color.red}, + new Paint[] {Color.blue}, + new Stroke[] {new BasicStroke(1.0f)}, + new Stroke[] {new BasicStroke(1.0f)}, + new Shape[] {new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)})); + assertTrue(t1.equals(t2)); + + //plotBackgroundPaint; + t1.setPlotBackgroundPaint(new GradientPaint(4f, 3f, Color.red, 6f, 7f, Color.blue)); + assertFalse(t1.equals(t2)); + t2.setPlotBackgroundPaint(new GradientPaint(4f, 3f, Color.red, 6f, 7f, Color.blue)); + assertTrue(t1.equals(t2)); + + //plotOutlinePaint; + t1.setPlotOutlinePaint(new GradientPaint(5f, 2f, Color.blue, 6f, 7f, Color.red)); + assertFalse(t1.equals(t2)); + t2.setPlotOutlinePaint(new GradientPaint(5f, 2f, Color.blue, 6f, 7f, Color.red)); + assertTrue(t1.equals(t2)); + + //labelLinkStyle; + t1.setLabelLinkStyle(PieLabelLinkStyle.STANDARD); + assertFalse(t1.equals(t2)); + t2.setLabelLinkStyle(PieLabelLinkStyle.STANDARD); + assertTrue(t1.equals(t2)); + + //labelLinkPaint; + t1.setLabelLinkPaint(new GradientPaint(4f, 3f, Color.red, 2f, 9f, Color.blue)); + assertFalse(t1.equals(t2)); + t2.setLabelLinkPaint(new GradientPaint(4f, 3f, Color.red, 2f, 9f, Color.blue)); + assertTrue(t1.equals(t2)); + + //domainGridlinePaint; + t1.setDomainGridlinePaint(Color.blue); + assertFalse(t1.equals(t2)); + t2.setDomainGridlinePaint(Color.blue); + assertTrue(t1.equals(t2)); + + //rangeGridlinePaint; + t1.setRangeGridlinePaint(Color.red); + assertFalse(t1.equals(t2)); + t2.setRangeGridlinePaint(Color.red); + assertTrue(t1.equals(t2)); + + //axisOffset; + t1.setAxisOffset(new RectangleInsets(1, 2, 3, 4)); + assertFalse(t1.equals(t2)); + t2.setAxisOffset(new RectangleInsets(1, 2, 3, 4)); + assertTrue(t1.equals(t2)); + + //axisLabelPaint; + t1.setAxisLabelPaint(new GradientPaint(8f, 4f, Color.gray, 2f, 9f, Color.blue)); + assertFalse(t1.equals(t2)); + t2.setAxisLabelPaint(new GradientPaint(8f, 4f, Color.gray, 2f, 9f, Color.blue)); + assertTrue(t1.equals(t2)); + + //tickLabelPaint; + t1.setTickLabelPaint(new GradientPaint(3f, 4f, Color.red, 5f, 6f, Color.yellow)); + assertFalse(t1.equals(t2)); + t2.setTickLabelPaint(new GradientPaint(3f, 4f, Color.red, 5f, 6f, Color.yellow)); + assertTrue(t1.equals(t2)); + + //itemLabelPaint; + t1.setItemLabelPaint(new GradientPaint(2f, 5f, Color.gray, 1f, 2f, Color.blue)); + assertFalse(t1.equals(t2)); + t2.setItemLabelPaint(new GradientPaint(2f, 5f, Color.gray, 1f, 2f, Color.blue)); + assertTrue(t1.equals(t2)); + + //shadowVisible; + t1.setShadowVisible(!t1.isShadowVisible()); + assertFalse(t1.equals(t2)); + t2.setShadowVisible(t1.isShadowVisible()); + assertTrue(t1.equals(t2)); + + //shadowPaint; + t1.setShadowPaint(new GradientPaint(7f, 1f, Color.blue, 4f, 6f, Color.red)); + assertFalse(t1.equals(t2)); + t2.setShadowPaint(new GradientPaint(7f, 1f, Color.blue, 4f, 6f, Color.red)); + assertTrue(t1.equals(t2)); + + //barPainter; + t1.setBarPainter(new StandardBarPainter()); + assertFalse(t1.equals(t2)); + t2.setBarPainter(new StandardBarPainter()); + assertTrue(t1.equals(t2)); + + //xyBarPainter; + t1.setXYBarPainter(new StandardXYBarPainter()); + assertFalse(t1.equals(t2)); + t2.setXYBarPainter(new StandardXYBarPainter()); + assertTrue(t1.equals(t2)); + + //thermometerPaint; + t1.setThermometerPaint(new GradientPaint(9f, 7f, Color.red, 5f, 1f, Color.blue)); + assertFalse(t1.equals(t2)); + t2.setThermometerPaint(new GradientPaint(9f, 7f, Color.red, 5f, 1f, Color.blue)); + assertTrue(t1.equals(t2)); + + //wallPaint; + t1.setWallPaint(new GradientPaint(4f, 5f, Color.red, 1f, 0f, Color.gray)); + assertFalse(t1.equals(t2)); + t2.setWallPaint(new GradientPaint(4f, 5f, Color.red, 1f, 0f, Color.gray)); + assertTrue(t1.equals(t2)); + + //errorIndicatorPaint; + t1.setErrorIndicatorPaint(new GradientPaint(0f, 1f, Color.white, 2f, 3f, Color.blue)); + assertFalse(t1.equals(t2)); + t2.setErrorIndicatorPaint(new GradientPaint(0f, 1f, Color.white, 2f, 3f, Color.blue)); + assertTrue(t1.equals(t2)); + + //gridBandPaint + t1.setGridBandPaint(new GradientPaint(1f, 2f, Color.white, 4f, 8f, Color.red)); + assertFalse(t1.equals(t2)); + t2.setGridBandPaint(new GradientPaint(1f, 2f, Color.white, 4f, 8f, Color.red)); + assertTrue(t1.equals(t2)); + + //gridBandAlternatePaint + t1.setGridBandAlternatePaint(new GradientPaint(1f, 4f, Color.green, 1f, 2f, Color.red)); + assertFalse(t1.equals(t2)); + t2.setGridBandAlternatePaint(new GradientPaint(1f, 4f, Color.green, 1f, 2f, Color.red)); + assertTrue(t1.equals(t2)); + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardChartTheme t1 = new StandardChartTheme("Name"); + StandardChartTheme t2 = (StandardChartTheme) TestUtilities.serialised(t1); + assertTrue(t1.equals(t2)); + } + + /** + * Basic checks for cloning. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StandardChartTheme t1 = new StandardChartTheme("Name"); + StandardChartTheme t2 = (StandardChartTheme) t1.clone(); + assertTrue(t1 != t2); + assertTrue(t1.getClass() == t2.getClass()); + assertTrue(t1.equals(t2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StrokeMapTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StrokeMapTest.java new file mode 100755 index 0000000..201db74 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/StrokeMapTest.java @@ -0,0 +1,164 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * StrokeMapTest.java + * ------------------ + * (C) Copyright 2006-2013, 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 static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.BasicStroke; +import org.junit.Test; + +/** + * Some tests for the {@link StrokeMap} class. + */ +public class StrokeMapTest { + + /** + * Some checks for the getStroke() method. + */ + @Test + public void testGetStroke() { + StrokeMap m1 = new StrokeMap(); + assertEquals(null, m1.getStroke("A")); + m1.put("A", new BasicStroke(1.1f)); + assertEquals(new BasicStroke(1.1f), m1.getStroke("A")); + m1.put("A", null); + assertEquals(null, m1.getStroke("A")); + + // a null key should throw an IllegalArgumentException + boolean pass = false; + try { + m1.getStroke(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the put() method. + */ + @Test + public void testPut() { + StrokeMap m1 = new StrokeMap(); + m1.put("A", new BasicStroke(1.1f)); + assertEquals(new BasicStroke(1.1f), m1.getStroke("A")); + + // a null key should throw an IllegalArgumentException + boolean pass = false; + try { + m1.put(null, new BasicStroke(1.1f)); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + StrokeMap m1 = new StrokeMap(); + StrokeMap m2 = new StrokeMap(); + assertTrue(m1.equals(m1)); + assertTrue(m1.equals(m2)); + assertFalse(m1.equals(null)); + assertFalse(m1.equals("ABC")); + + m1.put("K1", new BasicStroke(1.1f)); + assertFalse(m1.equals(m2)); + m2.put("K1", new BasicStroke(1.1f)); + assertTrue(m1.equals(m2)); + + m1.put("K2", new BasicStroke(2.2f)); + assertFalse(m1.equals(m2)); + m2.put("K2", new BasicStroke(2.2f)); + assertTrue(m1.equals(m2)); + + m1.put("K2", null); + assertFalse(m1.equals(m2)); + m2.put("K2", null); + assertTrue(m1.equals(m2)); + } + + /** + * Some checks for cloning. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StrokeMap m1 = new StrokeMap(); + StrokeMap m2 = (StrokeMap) m1.clone(); + assertTrue(m1.equals(m2)); + + m1.put("K1", new BasicStroke(1.1f)); + m1.put("K2", new BasicStroke(2.2f)); + m2 = (StrokeMap) m1.clone(); + assertTrue(m1.equals(m2)); + } + + /** + * A check for serialization. + */ + @Test + public void testSerialization1() { + StrokeMap m1 = new StrokeMap(); + StrokeMap m2 = (StrokeMap) TestUtilities.serialised(m1); + assertEquals(m1, m2); + } + + /** + * A check for serialization. + */ + @Test + public void testSerialization2() { + StrokeMap m1 = new StrokeMap(); + m1.put("K1", new BasicStroke(1.1f)); + m1.put("K2", new BasicStroke(2.2f)); + StrokeMap m2 = (StrokeMap) TestUtilities.serialised(m1); + assertEquals(m1, m2); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/TestUtilities.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/TestUtilities.java new file mode 100755 index 0000000..5a75b21 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/TestUtilities.java @@ -0,0 +1,98 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * TestUtilities.java + * ------------------ + * (C) Copyright 2007-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 08-Jun-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.ObjectInput; +import java.io.ObjectInputStream; +import java.io.ObjectOutput; +import java.io.ObjectOutputStream; +import java.util.Collection; +import java.util.Iterator; + +/** + * Some utility methods for use by the testing code. + */ +public class TestUtilities { + + /** + * Returns true if the collections contains any object that + * is an instance of the specified class, and false otherwise. + * + * @param collection the collection. + * @param c the class. + * + * @return A boolean. + */ + public static boolean containsInstanceOf(Collection collection, Class c) { + Iterator iterator = collection.iterator(); + while (iterator.hasNext()) { + Object obj = iterator.next(); + if (obj != null && obj.getClass().equals(c)) { + return true; + } + } + return false; + } + + public static Object serialised(Object original) { + Object result = null; + ByteArrayOutputStream buffer = new ByteArrayOutputStream(); + ObjectOutput out; + try { + out = new ObjectOutputStream(buffer); + out.writeObject(original); + out.close(); + ObjectInput in = new ObjectInputStream( + new ByteArrayInputStream(buffer.toByteArray())); + result = in.readObject(); + in.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } catch (ClassNotFoundException e) { + throw new RuntimeException(e); + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/TimeSeriesChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/TimeSeriesChartTest.java new file mode 100755 index 0000000..d6727b2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/TimeSeriesChartTest.java @@ -0,0 +1,185 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * TimeSeriesChartTest.java + * ------------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 12-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.StandardXYToolTipGenerator; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.data.Range; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.junit.Before; +import org.junit.Test; + +/** + * Some tests for a time series chart. + */ +public class TimeSeriesChartTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createChart(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("No exception should be triggered."); + } + } + + /** + * Replaces the dataset and checks that it has changed as expected. + */ + @Test + public void testReplaceDataset() { + + // create a dataset... + XYSeries series1 = new XYSeries("Series 1"); + series1.add(10.0, 10.0); + series1.add(20.0, 20.0); + series1.add(30.0, 30.0); + XYDataset dataset = new XYSeriesCollection(series1); + + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + XYPlot plot = (XYPlot) this.chart.getPlot(); + plot.setDataset(dataset); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around 10: " + + range.getLowerBound(), range.getLowerBound() <= 10); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + XYPlot plot = (XYPlot) this.chart.getPlot(); + XYItemRenderer renderer = plot.getRenderer(); + StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertTrue(tt2 == tt); + } + + /** + * Create a horizontal bar chart with sample data in the range -3 to +3. + * + * @return The chart. + */ + private static JFreeChart createChart() { + XYSeries series1 = new XYSeries("Series 1"); + series1.add(1.0, 1.0); + series1.add(2.0, 2.0); + series1.add(3.0, 3.0); + XYDataset dataset = new XYSeriesCollection(series1); + return ChartFactory.createTimeSeriesChart( + "XY Line Chart", // chart title + "Domain", + "Range", + dataset, // data + true, // include legend + true, // tooltips + true // urls + ); + + } + + /** + * A chart change listener. + * + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag = false; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/WaterfallChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/WaterfallChartTest.java new file mode 100755 index 0000000..9140d0a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/WaterfallChartTest.java @@ -0,0 +1,152 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * WaterfallChartTest.java + * ----------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 12-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.labels.CategoryToolTipGenerator; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.urls.CategoryURLGenerator; +import org.jfree.chart.urls.StandardCategoryURLGenerator; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.general.DatasetUtilities; +import org.junit.Before; +import org.junit.Test; + +/** + * Some tests for a waterfall chart. + */ +public class WaterfallChartTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createWaterfallChart(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("There should be no exception."); + } + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryToolTipGenerator tt + = new StandardCategoryToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + CategoryToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertTrue(tt2 == tt); + } + + /** + * Check that setting a URL generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesURLGenerator() { + CategoryPlot plot = (CategoryPlot) this.chart.getPlot(); + CategoryItemRenderer renderer = plot.getRenderer(); + StandardCategoryURLGenerator url1 + = new StandardCategoryURLGenerator(); + renderer.setSeriesItemURLGenerator(0, url1); + CategoryURLGenerator url2 = renderer.getItemURLGenerator(0, 0); + assertTrue(url2 == url1); + } + + /** + * Create a bar chart with sample data in the range -3 to +3. + * + * @return The chart. + */ + private static JFreeChart createWaterfallChart() { + Number[][] data = new Integer[][] + {{new Integer(-3), new Integer(-2)}, + {new Integer(-1), new Integer(1)}, + {new Integer(2), new Integer(3)}}; + + CategoryDataset dataset = DatasetUtilities.createCategoryDataset("S", + "C", data); + return ChartFactory.createWaterfallChart( + "Waterfall Chart", + "Domain", "Range", + dataset, + PlotOrientation.HORIZONTAL, + true, // include legend + true, + true + ); + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYAreaChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYAreaChartTest.java new file mode 100755 index 0000000..947dfea --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYAreaChartTest.java @@ -0,0 +1,177 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * XYAreaChartTest.java + * -------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 12-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.StandardXYToolTipGenerator; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.data.Range; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.junit.Before; +import org.junit.Test; + +/** + * Some tests for an XY area chart. + */ +public class XYAreaChartTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createChart(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("No exception should be triggered."); + } + } + + /** + * Replaces the dataset and checks that it has changed as expected. + */ + @Test + public void testReplaceDataset() { + + // create a dataset... + XYSeries series1 = new XYSeries("Series 1"); + series1.add(10.0, 10.0); + series1.add(20.0, 20.0); + series1.add(30.0, 30.0); + XYDataset dataset = new XYSeriesCollection(series1); + + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + XYPlot plot = (XYPlot) this.chart.getPlot(); + plot.setDataset(dataset); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around 10: " + + range.getLowerBound(), range.getLowerBound() <= 10); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + XYPlot plot = (XYPlot) this.chart.getPlot(); + XYItemRenderer renderer = plot.getRenderer(); + StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertTrue(tt2 == tt); + } + + /** + * Create a chart for testing. + * + * @return The chart. + */ + private static JFreeChart createChart() { + XYSeries series1 = new XYSeries("Series 1"); + series1.add(1.0, 1.0); + series1.add(2.0, 2.0); + series1.add(3.0, 3.0); + XYDataset dataset = new XYSeriesCollection(series1); + return ChartFactory.createXYAreaChart("Area Chart", "Domain", + "Range", dataset); + } + + /** + * A chart change listener. + * + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag = false; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYBarChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYBarChartTest.java new file mode 100755 index 0000000..c616468 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYBarChartTest.java @@ -0,0 +1,182 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * XYBarChartTest.java + * ------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 12-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.StandardXYToolTipGenerator; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.data.Range; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.XYBarDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.junit.Before; +import org.junit.Test; + +/** + * Some tests for an XY bar chart. + */ +public class XYBarChartTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createChart(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("No exception should be triggered."); + } + } + + /** + * Replaces the dataset and checks that it has changed as expected. + */ + @Test + public void testReplaceDataset() { + + // create a dataset... + XYSeries series1 = new XYSeries("Series 1"); + series1.add(10.0, 10.0); + series1.add(20.0, 20.0); + series1.add(30.0, 30.0); + XYDataset dataset = new XYSeriesCollection(series1); + + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + + XYPlot plot = (XYPlot) this.chart.getPlot(); + plot.setDataset(dataset); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around 10: " + + range.getLowerBound(), range.getLowerBound() <= 10); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + XYPlot plot = (XYPlot) this.chart.getPlot(); + XYItemRenderer renderer = plot.getRenderer(); + StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertTrue(tt2 == tt); + } + + /** + * Create a horizontal bar chart with sample data in the range -3 to +3. + * + * @return The chart. + */ + private static JFreeChart createChart() { + XYSeries series1 = new XYSeries("Series 1"); + series1.add(1.0, 1.0); + series1.add(2.0, 2.0); + series1.add(3.0, 3.0); + IntervalXYDataset dataset = new XYBarDataset(new XYSeriesCollection( + series1), 1.0); + return ChartFactory.createXYBarChart("XY Bar Chart", "Domain", false, + "Range", dataset); + + } + + /** + * A chart change listener. + * + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag = false; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYLineChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYLineChartTest.java new file mode 100755 index 0000000..92a040a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYLineChartTest.java @@ -0,0 +1,178 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * XYLineChartTest.java + * -------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 12-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.StandardXYToolTipGenerator; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.data.Range; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.junit.Before; +import org.junit.Test; + +/** + * Some tests for an XY line chart. + */ +public class XYLineChartTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createChart(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("No exception should be triggered."); + } + } + + /** + * Replaces the dataset and checks that it has changed as expected. + */ + @Test + public void testReplaceDataset() { + + // create a dataset... + XYSeries series1 = new XYSeries("Series 1"); + series1.add(10.0, 10.0); + series1.add(20.0, 20.0); + series1.add(30.0, 30.0); + XYDataset dataset = new XYSeriesCollection(series1); + + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + XYPlot plot = (XYPlot) this.chart.getPlot(); + plot.setDataset(dataset); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around 10: " + + range.getLowerBound(), range.getLowerBound() <= 10); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + XYPlot plot = (XYPlot) this.chart.getPlot(); + XYItemRenderer renderer = plot.getRenderer(); + StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertTrue(tt2 == tt); + } + + /** + * Create a horizontal bar chart with sample data in the range -3 to +3. + * + * @return The chart. + */ + private static JFreeChart createChart() { + XYSeries series1 = new XYSeries("Series 1"); + series1.add(1.0, 1.0); + series1.add(2.0, 2.0); + series1.add(3.0, 3.0); + XYDataset dataset = new XYSeriesCollection(series1); + return ChartFactory.createXYLineChart("XY Line Chart", "Domain", + "Range", dataset); + } + + /** + * A chart change listener. + * + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag = false; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYStepAreaChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYStepAreaChartTest.java new file mode 100755 index 0000000..10461ef --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYStepAreaChartTest.java @@ -0,0 +1,177 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * XYStepAreaChartTest.java + * ------------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 12-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertEquals; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.StandardXYToolTipGenerator; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.data.Range; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.junit.Before; +import org.junit.Test; + +/** + * Some tests for an XY step area chart. + */ +public class XYStepAreaChartTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createChart(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("No exception should be triggered."); + } + } + + /** + * Replaces the dataset and checks that it has changed as expected. + */ + @Test + public void testReplaceDataset() { + + // create a dataset... + XYSeries series1 = new XYSeries("Series 1"); + series1.add(10.0, 10.0); + series1.add(20.0, 20.0); + series1.add(30.0, 30.0); + XYDataset dataset = new XYSeriesCollection(series1); + + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + XYPlot plot = (XYPlot) this.chart.getPlot(); + plot.setDataset(dataset); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around 10: " + + range.getLowerBound(), range.getLowerBound() <= 10); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + XYPlot plot = (XYPlot) this.chart.getPlot(); + XYItemRenderer renderer = plot.getRenderer(); + StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertTrue(tt2 == tt); + } + + /** + * Create an area chart. + * + * @return The chart. + */ + private static JFreeChart createChart() { + XYSeries series1 = new XYSeries("Series 1"); + series1.add(1.0, 1.0); + series1.add(2.0, 2.0); + series1.add(3.0, 3.0); + XYDataset dataset = new XYSeriesCollection(series1); + return ChartFactory.createXYStepAreaChart("Step Chart", "Domain", + "Range", dataset); + } + + /** + * A chart change listener. + * + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag = false; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYStepChartTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYStepChartTest.java new file mode 100755 index 0000000..22e33c5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/XYStepChartTest.java @@ -0,0 +1,191 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * XYStepChartTest.java + * -------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 12-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.StandardXYToolTipGenerator; +import org.jfree.chart.labels.XYToolTipGenerator; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.data.Range; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.junit.Before; +import org.junit.Test; + +/** + * Some tests for an XY step plot. + */ +public class XYStepChartTest { + + /** A chart. */ + private JFreeChart chart; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.chart = createChart(); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown (a problem that was occurring at one point). + */ + @Test + public void testDrawWithNullInfo() { + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + null); + g2.dispose(); + } + catch (Exception e) { + fail("No exception should be triggered."); + } + } + + /** + * Replaces the dataset and checks that it has changed as expected. + */ + @Test + public void testReplaceDataset() { + + // create a dataset... + XYSeries series1 = new XYSeries("Series 1"); + series1.add(10.0, 10.0); + series1.add(20.0, 20.0); + series1.add(30.0, 30.0); + XYDataset dataset = new XYSeriesCollection(series1); + + LocalListener l = new LocalListener(); + this.chart.addChangeListener(l); + XYPlot plot = (XYPlot) this.chart.getPlot(); + plot.setDataset(dataset); + assertEquals(true, l.flag); + ValueAxis axis = plot.getRangeAxis(); + Range range = axis.getRange(); + assertTrue("Expecting the lower bound of the range to be around 10: " + + range.getLowerBound(), range.getLowerBound() <= 10); + assertTrue("Expecting the upper bound of the range to be around 30: " + + range.getUpperBound(), range.getUpperBound() >= 30); + + } + + /** + * Check that setting a tool tip generator for a series does override the + * default generator. + */ + @Test + public void testSetSeriesToolTipGenerator() { + XYPlot plot = (XYPlot) this.chart.getPlot(); + XYItemRenderer renderer = plot.getRenderer(); + StandardXYToolTipGenerator tt = new StandardXYToolTipGenerator(); + renderer.setSeriesToolTipGenerator(0, tt); + XYToolTipGenerator tt2 = renderer.getToolTipGenerator(0, 0); + assertTrue(tt2 == tt); + } + + /** + * Create a horizontal bar chart with sample data in the range -3 to +3. + * + * @return The chart. + */ + private static JFreeChart createChart() { + + // create a dataset... + XYSeries series1 = new XYSeries("Series 1"); + series1.add(1.0, 1.0); + series1.add(2.0, 2.0); + series1.add(3.0, 3.0); + XYDataset dataset = new XYSeriesCollection(series1); + + // create the chart... + return ChartFactory.createXYStepChart( + "Step Chart", // chart title + "Domain", + "Range", + dataset, // data + PlotOrientation.VERTICAL, + true, // include legend + true, // tooltips + true // urls + ); + + } + + /** + * A chart change listener. + * + */ + static class LocalListener implements ChartChangeListener { + + /** A flag. */ + private boolean flag = false; + + /** + * Event handler. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.flag = true; + } + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/CategoryLineAnnotationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/CategoryLineAnnotationTest.java new file mode 100755 index 0000000..2d28c72 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/CategoryLineAnnotationTest.java @@ -0,0 +1,162 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * CategoryLineAnnotationTest.java + * ------------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Jul-2005 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.annotations; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.BasicStroke; +import java.awt.Color; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link CategoryLineAnnotation} class. + */ +public class CategoryLineAnnotationTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + BasicStroke s1 = new BasicStroke(1.0f); + BasicStroke s2 = new BasicStroke(2.0f); + CategoryLineAnnotation a1 = new CategoryLineAnnotation("Category 1", + 1.0, "Category 2", 2.0, Color.red, s1); + CategoryLineAnnotation a2 = new CategoryLineAnnotation("Category 1", + 1.0, "Category 2", 2.0, Color.red, s1); + assertTrue(a1.equals(a2)); + assertTrue(a2.equals(a1)); + + // category 1 + a1.setCategory1("Category A"); + assertFalse(a1.equals(a2)); + a2.setCategory1("Category A"); + assertTrue(a1.equals(a2)); + + // value 1 + a1.setValue1(0.15); + assertFalse(a1.equals(a2)); + a2.setValue1(0.15); + assertTrue(a1.equals(a2)); + + // category 2 + a1.setCategory2("Category B"); + assertFalse(a1.equals(a2)); + a2.setCategory2("Category B"); + assertTrue(a1.equals(a2)); + + // value 2 + a1.setValue2(0.25); + assertFalse(a1.equals(a2)); + a2.setValue2(0.25); + assertTrue(a1.equals(a2)); + + // paint + a1.setPaint(Color.yellow); + assertFalse(a1.equals(a2)); + a2.setPaint(Color.yellow); + assertTrue(a1.equals(a2)); + + // stroke + a1.setStroke(s2); + assertFalse(a1.equals(a2)); + a2.setStroke(s2); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + CategoryLineAnnotation a1 = new CategoryLineAnnotation("Category 1", + 1.0, "Category 2", 2.0, Color.red, new BasicStroke(1.0f)); + CategoryLineAnnotation a2 = new CategoryLineAnnotation("Category 1", + 1.0, "Category 2", 2.0, Color.red, new BasicStroke(1.0f)); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CategoryLineAnnotation a1 = new CategoryLineAnnotation("Category 1", + 1.0, "Category 2", 2.0, Color.red, new BasicStroke(1.0f)); + CategoryLineAnnotation a2 = (CategoryLineAnnotation) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Checks that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + CategoryLineAnnotation a1 = new CategoryLineAnnotation( + "Category 1", 1.0, "Category 2", 2.0, Color.red, + new BasicStroke(1.0f)); + assertTrue(a1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CategoryLineAnnotation a1 = new CategoryLineAnnotation("Category 1", + 1.0, "Category 2", 2.0, Color.red, new BasicStroke(1.0f)); + CategoryLineAnnotation a2 = (CategoryLineAnnotation) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/CategoryPointerAnnotationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/CategoryPointerAnnotationTest.java new file mode 100755 index 0000000..e7a88db --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/CategoryPointerAnnotationTest.java @@ -0,0 +1,188 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------- + * CategoryPointerAnnotationTest.java + * ---------------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 02-Oct-2006 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.annotations; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Stroke; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link CategoryPointerAnnotation} class. + */ +public class CategoryPointerAnnotationTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", + "Key 1", 20.0, Math.PI); + CategoryPointerAnnotation a2 = new CategoryPointerAnnotation("Label", + "Key 1", 20.0, Math.PI); + assertTrue(a1.equals(a2)); + + a1 = new CategoryPointerAnnotation("Label2", "Key 1", 20.0, Math.PI); + assertFalse(a1.equals(a2)); + a2 = new CategoryPointerAnnotation("Label2", "Key 1", 20.0, Math.PI); + assertTrue(a1.equals(a2)); + + a1.setCategory("Key 2"); + assertFalse(a1.equals(a2)); + a2.setCategory("Key 2"); + assertTrue(a1.equals(a2)); + + a1.setValue(22.0); + assertFalse(a1.equals(a2)); + a2.setValue(22.0); + assertTrue(a1.equals(a2)); + + //private double angle; + a1.setAngle(Math.PI / 4.0); + assertFalse(a1.equals(a2)); + a2.setAngle(Math.PI / 4.0); + assertTrue(a1.equals(a2)); + + //private double tipRadius; + a1.setTipRadius(20.0); + assertFalse(a1.equals(a2)); + a2.setTipRadius(20.0); + assertTrue(a1.equals(a2)); + + //private double baseRadius; + a1.setBaseRadius(5.0); + assertFalse(a1.equals(a2)); + a2.setBaseRadius(5.0); + assertTrue(a1.equals(a2)); + + //private double arrowLength; + a1.setArrowLength(33.0); + assertFalse(a1.equals(a2)); + a2.setArrowLength(33.0); + assertTrue(a1.equals(a2)); + + //private double arrowWidth; + a1.setArrowWidth(9.0); + assertFalse(a1.equals(a2)); + a2.setArrowWidth(9.0); + assertTrue(a1.equals(a2)); + + //private Stroke arrowStroke; + Stroke stroke = new BasicStroke(1.5f); + a1.setArrowStroke(stroke); + assertFalse(a1.equals(a2)); + a2.setArrowStroke(stroke); + assertTrue(a1.equals(a2)); + + //private Paint arrowPaint; + a1.setArrowPaint(Color.blue); + assertFalse(a1.equals(a2)); + a2.setArrowPaint(Color.blue); + assertTrue(a1.equals(a2)); + + //private double labelOffset; + a1.setLabelOffset(10.0); + assertFalse(a1.equals(a2)); + a2.setLabelOffset(10.0); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", + "A", 20.0, Math.PI); + CategoryPointerAnnotation a2 = new CategoryPointerAnnotation("Label", + "A", 20.0, Math.PI); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", + "A", 20.0, Math.PI); + CategoryPointerAnnotation a2 = (CategoryPointerAnnotation) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Checks that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", + "A", 20.0, Math.PI); + assertTrue(a1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CategoryPointerAnnotation a1 = new CategoryPointerAnnotation("Label", + "A", 20.0, Math.PI); + CategoryPointerAnnotation a2 = (CategoryPointerAnnotation) + TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/CategoryTextAnnotationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/CategoryTextAnnotationTest.java new file mode 100755 index 0000000..2cf4787 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/CategoryTextAnnotationTest.java @@ -0,0 +1,139 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * CategoryTextAnnotationTest.java + * ------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Aug-2003 : Version 1 (DG); + * 07-Jan-2005 : Added hashCode() test (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.annotations; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.axis.CategoryAnchor; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link CategoryTextAnnotation} class. + */ +public class CategoryTextAnnotationTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + CategoryTextAnnotation a1 = new CategoryTextAnnotation("Test", + "Category", 1.0); + CategoryTextAnnotation a2 = new CategoryTextAnnotation("Test", + "Category", 1.0); + assertTrue(a1.equals(a2)); + + // category + a1.setCategory("Category 2"); + assertFalse(a1.equals(a2)); + a2.setCategory("Category 2"); + assertTrue(a1.equals(a2)); + + // categoryAnchor + a1.setCategoryAnchor(CategoryAnchor.START); + assertFalse(a1.equals(a2)); + a2.setCategoryAnchor(CategoryAnchor.START); + assertTrue(a1.equals(a2)); + + // value + a1.setValue(0.15); + assertFalse(a1.equals(a2)); + a2.setValue(0.15); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + CategoryTextAnnotation a1 = new CategoryTextAnnotation("Test", + "Category", 1.0); + CategoryTextAnnotation a2 = new CategoryTextAnnotation("Test", + "Category", 1.0); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CategoryTextAnnotation a1 = new CategoryTextAnnotation( + "Test", "Category", 1.0); + CategoryTextAnnotation a2 = (CategoryTextAnnotation) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Checks that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + CategoryTextAnnotation a1 = new CategoryTextAnnotation( + "Test", "Category", 1.0); + assertTrue(a1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CategoryTextAnnotation a1 = new CategoryTextAnnotation("Test", + "Category", 1.0); + CategoryTextAnnotation a2 = (CategoryTextAnnotation) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/TextAnnotationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/TextAnnotationTest.java new file mode 100755 index 0000000..fe1f69b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/TextAnnotationTest.java @@ -0,0 +1,188 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * TextAnnotationTest.java + * ----------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Martin Hoeller; + * + * Changes + * ------- + * 19-Aug-2003 : Version 1 (DG); + * 07-Jan-2005 : Added testHashCode() method (DG); + * 28-Oct-2011 : Added testSetRotationAnchor() method for bug #3428870 (MH); + * 01-Jul-2013 : Added testChangeEvents() (DG); + * + */ + +package org.jfree.chart.annotations; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNotNull; + +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; + +import org.jfree.chart.event.AnnotationChangeEvent; +import org.jfree.chart.event.AnnotationChangeListener; +import org.jfree.ui.TextAnchor; +import org.junit.Test; + +/** + * Tests for the {@link TextAnnotation} class. + */ +public class TextAnnotationTest implements AnnotationChangeListener { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + TextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); + TextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); + assertTrue(a1.equals(a2)); + + // text + a1.setText("Text"); + assertFalse(a1.equals(a2)); + a2.setText("Text"); + assertTrue(a1.equals(a2)); + + // font + a1.setFont(new Font("Serif", Font.BOLD, 18)); + assertFalse(a1.equals(a2)); + a2.setFont(new Font("Serif", Font.BOLD, 18)); + assertTrue(a1.equals(a2)); + + // paint + a1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.pink)); + assertFalse(a1.equals(a2)); + a2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.pink)); + assertTrue(a1.equals(a2)); + + // textAnchor + a1.setTextAnchor(TextAnchor.BOTTOM_LEFT); + assertFalse(a1.equals(a2)); + a2.setTextAnchor(TextAnchor.BOTTOM_LEFT); + assertTrue(a1.equals(a2)); + + // rotationAnchor + a1.setRotationAnchor(TextAnchor.BOTTOM_LEFT); + assertFalse(a1.equals(a2)); + a2.setRotationAnchor(TextAnchor.BOTTOM_LEFT); + assertTrue(a1.equals(a2)); + + // rotationAngle + a1.setRotationAngle(Math.PI); + assertFalse(a1.equals(a2)); + a2.setRotationAngle(Math.PI); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + TextAnnotation a1 = new CategoryTextAnnotation("Test", "Category", 1.0); + TextAnnotation a2 = new CategoryTextAnnotation("Test", "Category", 1.0); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Test null-argument (Bug #3428870). + */ + @Test + public void testSetRotationAnchor() { + TextAnnotation a = new CategoryTextAnnotation("Test", "Category", 1.0); + try { + a.setRotationAnchor(null); + fail("Should have thrown Exception."); + } catch (IllegalArgumentException e) { + // ok, exception is expected + } + } + + /** + * Some tests to ensure that change events are generated as expected. + */ + @Test + public void testChangeEvents() { + TextAnnotation a = new CategoryTextAnnotation("Test", "A", 1.0); + a.addChangeListener(this); + this.lastEvent = null; + a.setText("B"); + assertNotNull(this.lastEvent); + this.lastEvent = null; + a.setText("B"); + assertNotNull(this.lastEvent); + + this.lastEvent = null; + a.setFont(new Font("SansSerif", Font.PLAIN, 12)); + assertNotNull(this.lastEvent); + + this.lastEvent = null; + a.setPaint(Color.BLUE); + assertNotNull(this.lastEvent); + + this.lastEvent = null; + a.setTextAnchor(TextAnchor.CENTER_LEFT); + assertNotNull(this.lastEvent); + + this.lastEvent = null; + a.setRotationAnchor(TextAnchor.CENTER_LEFT); + assertNotNull(this.lastEvent); + + this.lastEvent = null; + a.setRotationAngle(123.4); + assertNotNull(this.lastEvent); + } + + private AnnotationChangeEvent lastEvent; + + /** + * Receives notification of a change to an annotation. + * + * @param event the event. + */ + @Override + public void annotationChanged(AnnotationChangeEvent event) { + this.lastEvent = event; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYBoxAnnotationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYBoxAnnotationTest.java new file mode 100755 index 0000000..74f00f3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYBoxAnnotationTest.java @@ -0,0 +1,203 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * XYBoxAnnotationTest.java + * ------------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Jan-2005 : Version 1 (DG); + * 26-Feb-2008 : Added testDrawWithNullInfo() method (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.annotations; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; +import org.jfree.data.xy.DefaultTableXYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Some tests for the {@link XYBoxAnnotation} class. + */ +public class XYBoxAnnotationTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, + new BasicStroke(1.2f), Color.red, Color.blue); + XYBoxAnnotation a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, + new BasicStroke(1.2f), Color.red, Color.blue); + assertTrue(a1.equals(a2)); + assertTrue(a2.equals(a1)); + + // x0 + a1 = new XYBoxAnnotation(2.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), + Color.red, Color.blue); + assertFalse(a1.equals(a2)); + a2 = new XYBoxAnnotation(2.0, 2.0, 3.0, 4.0, new BasicStroke(1.2f), + Color.red, Color.blue); + assertTrue(a1.equals(a2)); + + // stroke + a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), + Color.red, Color.blue); + assertFalse(a1.equals(a2)); + a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), + Color.red, Color.blue); + assertTrue(a1.equals(a2)); + + GradientPaint gp1a = new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red); + GradientPaint gp1b = new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red); + GradientPaint gp2a = new GradientPaint(5.0f, 6.0f, Color.pink, + 7.0f, 8.0f, Color.white); + GradientPaint gp2b = new GradientPaint(5.0f, 6.0f, Color.pink, + 7.0f, 8.0f, Color.white); + + // outlinePaint + a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), + gp1a, Color.blue); + assertFalse(a1.equals(a2)); + a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), + gp1b, Color.blue); + assertTrue(a1.equals(a2)); + + // fillPaint + a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), + gp1a, gp2a); + assertFalse(a1.equals(a2)); + a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, new BasicStroke(2.3f), + gp1b, gp2b); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + public void testHashCode() { + XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, + new BasicStroke(1.2f), Color.red, Color.blue); + XYBoxAnnotation a2 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, + new BasicStroke(1.2f), Color.red, Color.blue); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + public void testCloning() throws CloneNotSupportedException { + XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, + new BasicStroke(1.2f), Color.red, Color.blue); + XYBoxAnnotation a2 = (XYBoxAnnotation) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Checks that this class implements PublicCloneable. + */ + public void testPublicCloneable() { + XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, + new BasicStroke(1.2f), Color.red, Color.blue); + assertTrue(a1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + public void testSerialization() { + XYBoxAnnotation a1 = new XYBoxAnnotation(1.0, 2.0, 3.0, 4.0, + new BasicStroke(1.2f), Color.red, Color.blue); + XYBoxAnnotation a2 = (XYBoxAnnotation) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown. + */ + public void testDrawWithNullInfo() { + try { + DefaultTableXYDataset dataset = new DefaultTableXYDataset(); + + XYSeries s1 = new XYSeries("Series 1", true, false); + s1.add(5.0, 5.0); + s1.add(10.0, 15.5); + s1.add(15.0, 9.5); + s1.add(20.0, 7.5); + dataset.addSeries(s1); + + XYSeries s2 = new XYSeries("Series 2", true, false); + s2.add(5.0, 5.0); + s2.add(10.0, 15.5); + s2.add(15.0, 9.5); + s2.add(20.0, 3.5); + dataset.addSeries(s2); + XYPlot plot = new XYPlot(dataset, + new NumberAxis("X"), new NumberAxis("Y"), + new XYLineAndShapeRenderer()); + plot.addAnnotation(new XYBoxAnnotation(10.0, 12.0, 3.0, 4.0, + new BasicStroke(1.2f), Color.red, Color.blue)); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be triggered."); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYDrawableAnnotationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYDrawableAnnotationTest.java new file mode 100755 index 0000000..4eba12f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYDrawableAnnotationTest.java @@ -0,0 +1,204 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * XYDrawableAnnotationTest.java + * ----------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Aug-2003 : Version 1 (DG); + * 01-Oct-2004 : Fixed bugs in tests (DG); + * 07-Jan-2005 : Added hashCode() test (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.annotations; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.io.Serializable; + +import org.jfree.chart.TestUtilities; + +import org.jfree.ui.Drawable; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYDrawableAnnotation} class. + */ +public class XYDrawableAnnotationTest { + + static class TestDrawable implements Drawable, Cloneable, Serializable { + /** + * Default constructor. + */ + public TestDrawable() { + } + /** + * Draws something. + * @param g2 the graphics device. + * @param area the area in which to draw. + */ + @Override + public void draw(Graphics2D g2, Rectangle2D area) { + // do nothing + } + /** + * Tests this object for equality with an arbitrary object. + * @param obj the object to test against (null permitted). + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TestDrawable)) { + return false; + } + return true; + } + /** + * Returns a clone. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning. + */ + @Override + public Object clone() throws CloneNotSupportedException { + return super.clone(); + } + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, + 200.0, new TestDrawable()); + XYDrawableAnnotation a2 = new XYDrawableAnnotation(10.0, 20.0, 100.0, + 200.0, new TestDrawable()); + assertTrue(a1.equals(a2)); + + a1 = new XYDrawableAnnotation(11.0, 20.0, 100.0, 200.0, + new TestDrawable()); + assertFalse(a1.equals(a2)); + a2 = new XYDrawableAnnotation(11.0, 20.0, 100.0, 200.0, + new TestDrawable()); + assertTrue(a1.equals(a2)); + + a1 = new XYDrawableAnnotation(11.0, 22.0, 100.0, 200.0, + new TestDrawable()); + assertFalse(a1.equals(a2)); + a2 = new XYDrawableAnnotation(11.0, 22.0, 100.0, 200.0, + new TestDrawable()); + assertTrue(a1.equals(a2)); + + a1 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 200.0, + new TestDrawable()); + assertFalse(a1.equals(a2)); + a2 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 200.0, + new TestDrawable()); + assertTrue(a1.equals(a2)); + + a1 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 202.0, + new TestDrawable()); + assertFalse(a1.equals(a2)); + a2 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 202.0, + new TestDrawable()); + assertTrue(a1.equals(a2)); + + a1 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 202.0, 2.0, + new TestDrawable()); + assertFalse(a1.equals(a2)); + a2 = new XYDrawableAnnotation(11.0, 22.0, 101.0, 202.0, 2.0, + new TestDrawable()); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, + 200.0, new TestDrawable()); + XYDrawableAnnotation a2 = new XYDrawableAnnotation(10.0, 20.0, 100.0, + 200.0, new TestDrawable()); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, + 200.0, new TestDrawable()); + XYDrawableAnnotation a2 = (XYDrawableAnnotation) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Checks that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, + 200.0, new TestDrawable()); + assertTrue(a1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYDrawableAnnotation a1 = new XYDrawableAnnotation(10.0, 20.0, 100.0, + 200.0, new TestDrawable()); + XYDrawableAnnotation a2 = (XYDrawableAnnotation) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYImageAnnotationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYImageAnnotationTest.java new file mode 100755 index 0000000..474bd36 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYImageAnnotationTest.java @@ -0,0 +1,140 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * XYImageAnnotationTest.java + * -------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 17-May-2004 : Version 1 (DG); + * 01-Dec-2006 : Updated testEquals() for new field (DG); + * 09-Jan-2007 : Comment out failing test (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.annotations; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.Image; + +import org.jfree.chart.JFreeChart; +import org.jfree.ui.RectangleAnchor; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYImageAnnotation} class. + */ +public class XYImageAnnotationTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + Image image = JFreeChart.INFO.getLogo(); + XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, image); + XYImageAnnotation a2 = new XYImageAnnotation(10.0, 20.0, image); + assertTrue(a1.equals(a2)); + + a1 = new XYImageAnnotation(10.0, 20.0, image, RectangleAnchor.LEFT); + assertFalse(a1.equals(a2)); + a2 = new XYImageAnnotation(10.0, 20.0, image, RectangleAnchor.LEFT); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + Image image = JFreeChart.INFO.getLogo(); + XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, image); + XYImageAnnotation a2 = new XYImageAnnotation(10.0, 20.0, image); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, + JFreeChart.INFO.getLogo()); + XYImageAnnotation a2 = (XYImageAnnotation) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Checks that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, + JFreeChart.INFO.getLogo()); + assertTrue(a1 instanceof PublicCloneable); + } + +// FIXME: Make this test pass +// /** +// * Serialize an instance, restore it, and check for equality. +// */ +// public void testSerialization() { +// XYImageAnnotation a1 = new XYImageAnnotation(10.0, 20.0, +// JFreeChart.INFO.getLogo()); +// XYImageAnnotation a2 = null; +// try { +// ByteArrayOutputStream buffer = new ByteArrayOutputStream(); +// ObjectOutput out = new ObjectOutputStream(buffer); +// out.writeObject(a1); +// out.close(); +// +// ObjectInput in = new ObjectInputStream(new ByteArrayInputStream( +// buffer.toByteArray())); +// a2 = (XYImageAnnotation) in.readObject(); +// in.close(); +// } +// catch (Exception e) { +// e.printStackTrace(); +// } +// assertEquals(a1, a2); +// } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYLineAnnotationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYLineAnnotationTest.java new file mode 100755 index 0000000..88169fe --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYLineAnnotationTest.java @@ -0,0 +1,166 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * XYLineAnnotationTest.java + * ------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Aug-2003 : Version 1 (DG); + * 07-Jan-2005 : Added hashCode() test (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.annotations; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Stroke; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYLineAnnotation} class. + */ +public class XYLineAnnotationTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + Stroke stroke = new BasicStroke(2.0f); + XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, + stroke, Color.blue); + XYLineAnnotation a2 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, + stroke, Color.blue); + assertTrue(a1.equals(a2)); + assertTrue(a2.equals(a1)); + + a1 = new XYLineAnnotation(11.0, 20.0, 100.0, 200.0, stroke, Color.blue); + assertFalse(a1.equals(a2)); + a2 = new XYLineAnnotation(11.0, 20.0, 100.0, 200.0, stroke, Color.blue); + assertTrue(a1.equals(a2)); + + a1 = new XYLineAnnotation(11.0, 21.0, 100.0, 200.0, stroke, Color.blue); + assertFalse(a1.equals(a2)); + a2 = new XYLineAnnotation(11.0, 21.0, 100.0, 200.0, stroke, Color.blue); + assertTrue(a1.equals(a2)); + + a1 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke, Color.blue); + assertFalse(a1.equals(a2)); + a2 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke, Color.blue); + assertTrue(a1.equals(a2)); + + a1 = new XYLineAnnotation(11.0, 21.0, 101.0, 201.0, stroke, Color.blue); + assertFalse(a1.equals(a2)); + a2 = new XYLineAnnotation(11.0, 21.0, 101.0, 201.0, stroke, Color.blue); + assertTrue(a1.equals(a2)); + + Stroke stroke2 = new BasicStroke(0.99f); + a1 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke2, Color.blue); + assertFalse(a1.equals(a2)); + a2 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke2, Color.blue); + assertTrue(a1.equals(a2)); + + GradientPaint g1 = new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.white); + GradientPaint g2 = new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.white); + a1 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke2, g1); + assertFalse(a1.equals(a2)); + a2 = new XYLineAnnotation(11.0, 21.0, 101.0, 200.0, stroke2, g2); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + Stroke stroke = new BasicStroke(2.0f); + XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, + stroke, Color.blue); + XYLineAnnotation a2 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, + stroke, Color.blue); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + Stroke stroke = new BasicStroke(2.0f); + XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, + stroke, Color.blue); + XYLineAnnotation a2 = (XYLineAnnotation) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Checks that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + Stroke stroke = new BasicStroke(2.0f); + XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, + stroke, Color.blue); + assertTrue(a1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Stroke stroke = new BasicStroke(2.0f); + XYLineAnnotation a1 = new XYLineAnnotation(10.0, 20.0, 100.0, 200.0, + stroke, Color.blue); + XYLineAnnotation a2 = (XYLineAnnotation) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYPointerAnnotationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYPointerAnnotationTest.java new file mode 100755 index 0000000..86f4ba6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYPointerAnnotationTest.java @@ -0,0 +1,190 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * XYPointerAnnotationTest.java + * ---------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Aug-2003 : Version 1 (DG); + * 13-Oct-2003 : Expanded test for equals() method (DG); + * 07-Jan-2005 : Added hashCode() test (DG); + * 20-Feb-2006 : Added 'x' and 'y' checks to testEquals() (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.annotations; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Stroke; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYPointerAnnotation} class. + */ +public class XYPointerAnnotationTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, + Math.PI); + XYPointerAnnotation a2 = new XYPointerAnnotation("Label", 10.0, 20.0, + Math.PI); + assertTrue(a1.equals(a2)); + + a1 = new XYPointerAnnotation("Label2", 10.0, 20.0, Math.PI); + assertFalse(a1.equals(a2)); + a2 = new XYPointerAnnotation("Label2", 10.0, 20.0, Math.PI); + assertTrue(a1.equals(a2)); + + a1.setX(11.0); + assertFalse(a1.equals(a2)); + a2.setX(11.0); + assertTrue(a1.equals(a2)); + + a1.setY(22.0); + assertFalse(a1.equals(a2)); + a2.setY(22.0); + assertTrue(a1.equals(a2)); + + //private double angle; + a1.setAngle(Math.PI / 4.0); + assertFalse(a1.equals(a2)); + a2.setAngle(Math.PI / 4.0); + assertTrue(a1.equals(a2)); + + //private double tipRadius; + a1.setTipRadius(20.0); + assertFalse(a1.equals(a2)); + a2.setTipRadius(20.0); + assertTrue(a1.equals(a2)); + + //private double baseRadius; + a1.setBaseRadius(5.0); + assertFalse(a1.equals(a2)); + a2.setBaseRadius(5.0); + assertTrue(a1.equals(a2)); + + //private double arrowLength; + a1.setArrowLength(33.0); + assertFalse(a1.equals(a2)); + a2.setArrowLength(33.0); + assertTrue(a1.equals(a2)); + + //private double arrowWidth; + a1.setArrowWidth(9.0); + assertFalse(a1.equals(a2)); + a2.setArrowWidth(9.0); + assertTrue(a1.equals(a2)); + + //private Stroke arrowStroke; + Stroke stroke = new BasicStroke(1.5f); + a1.setArrowStroke(stroke); + assertFalse(a1.equals(a2)); + a2.setArrowStroke(stroke); + assertTrue(a1.equals(a2)); + + //private Paint arrowPaint; + a1.setArrowPaint(Color.blue); + assertFalse(a1.equals(a2)); + a2.setArrowPaint(Color.blue); + assertTrue(a1.equals(a2)); + + //private double labelOffset; + a1.setLabelOffset(10.0); + assertFalse(a1.equals(a2)); + a2.setLabelOffset(10.0); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, + Math.PI); + XYPointerAnnotation a2 = new XYPointerAnnotation("Label", 10.0, 20.0, + Math.PI); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, + Math.PI); + XYPointerAnnotation a2 = a2 = (XYPointerAnnotation) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Checks that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, + Math.PI); + assertTrue(a1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYPointerAnnotation a1 = new XYPointerAnnotation("Label", 10.0, 20.0, + Math.PI); + XYPointerAnnotation a2 = (XYPointerAnnotation) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYPolygonAnnotationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYPolygonAnnotationTest.java new file mode 100755 index 0000000..b3049b4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYPolygonAnnotationTest.java @@ -0,0 +1,167 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * XYPolygonAnnotationTest.java + * ---------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-Jul-2006 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.annotations; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Stroke; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYPolygonAnnotation} class. + */ +public class XYPolygonAnnotationTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + Stroke stroke1 = new BasicStroke(2.0f); + Stroke stroke2 = new BasicStroke(2.5f); + XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, + 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.red, Color.blue); + XYPolygonAnnotation a2 = new XYPolygonAnnotation(new double[] {1.0, + 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.red, Color.blue); + assertTrue(a1.equals(a2)); + assertTrue(a2.equals(a1)); + + a1 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, + 6.0}, stroke1, Color.red, Color.blue); + assertFalse(a1.equals(a2)); + a2 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, + 6.0}, stroke1, Color.red, Color.blue); + assertTrue(a1.equals(a2)); + + a1 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, + 6.0}, stroke2, Color.red, Color.blue); + assertFalse(a1.equals(a2)); + a2 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, + 6.0}, stroke2, Color.red, Color.blue); + assertTrue(a1.equals(a2)); + + GradientPaint gp1 = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, + 4.0f, Color.white); + GradientPaint gp2 = new GradientPaint(1.0f, 2.0f, Color.yellow, 3.0f, + 4.0f, Color.white); + a1 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, + 6.0}, stroke2, gp1, Color.blue); + assertFalse(a1.equals(a2)); + a2 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, + 6.0}, stroke2, gp2, Color.blue); + assertTrue(a1.equals(a2)); + + GradientPaint gp3 = new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, + 4.0f, Color.white); + GradientPaint gp4 = new GradientPaint(1.0f, 2.0f, Color.green, 3.0f, + 4.0f, Color.white); + a1 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, + 6.0}, stroke2, gp1, gp3); + assertFalse(a1.equals(a2)); + a2 = new XYPolygonAnnotation(new double[] {99.0, 2.0, 3.0, 4.0, 5.0, + 6.0}, stroke2, gp2, gp4); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + Stroke stroke = new BasicStroke(2.0f); + XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, + 2.0, 3.0, 4.0, 5.0, 6.0}, stroke, Color.red, Color.blue); + XYPolygonAnnotation a2 = new XYPolygonAnnotation(new double[] {1.0, + 2.0, 3.0, 4.0, 5.0, 6.0}, stroke, Color.red, Color.blue); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + Stroke stroke1 = new BasicStroke(2.0f); + XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, + 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.red, Color.blue); + XYPolygonAnnotation a2 = (XYPolygonAnnotation) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Checks that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + Stroke stroke1 = new BasicStroke(2.0f); + XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, + 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.red, Color.blue); + assertTrue(a1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Stroke stroke1 = new BasicStroke(2.0f); + XYPolygonAnnotation a1 = new XYPolygonAnnotation(new double[] {1.0, + 2.0, 3.0, 4.0, 5.0, 6.0}, stroke1, Color.red, Color.blue); + XYPolygonAnnotation a2 = (XYPolygonAnnotation) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYShapeAnnotationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYShapeAnnotationTest.java new file mode 100755 index 0000000..12e6279 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYShapeAnnotationTest.java @@ -0,0 +1,183 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * XYShapeAnnotationTest.java + * -------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Sep-2004 : Version 1 (DG); + * 07-Jan-2005 : Added hashCode() test (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.annotations; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Some tests for the {@link XYShapeAnnotation} class. + */ +public class XYShapeAnnotationTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + XYShapeAnnotation a1 = new XYShapeAnnotation( + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), + new BasicStroke(1.2f), Color.red, Color.blue); + XYShapeAnnotation a2 = new XYShapeAnnotation( + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), + new BasicStroke(1.2f), Color.red, Color.blue); + assertTrue(a1.equals(a2)); + assertTrue(a2.equals(a1)); + + // shape + a1 = new XYShapeAnnotation( + new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + new BasicStroke(1.2f), Color.red, Color.blue); + assertFalse(a1.equals(a2)); + a2 = new XYShapeAnnotation( + new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + new BasicStroke(1.2f), Color.red, Color.blue); + assertTrue(a1.equals(a2)); + + // stroke + a1 = new XYShapeAnnotation( + new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + new BasicStroke(2.3f), Color.red, Color.blue); + assertFalse(a1.equals(a2)); + a2 = new XYShapeAnnotation( + new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + new BasicStroke(2.3f), Color.red, Color.blue); + assertTrue(a1.equals(a2)); + + GradientPaint gp1a = new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red); + GradientPaint gp1b = new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red); + GradientPaint gp2a = new GradientPaint(5.0f, 6.0f, Color.pink, + 7.0f, 8.0f, Color.white); + GradientPaint gp2b = new GradientPaint(5.0f, 6.0f, Color.pink, + 7.0f, 8.0f, Color.white); + + // outlinePaint + a1 = new XYShapeAnnotation( + new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + new BasicStroke(2.3f), gp1a, Color.blue); + assertFalse(a1.equals(a2)); + a2 = new XYShapeAnnotation( + new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + new BasicStroke(2.3f), gp1b, Color.blue); + assertTrue(a1.equals(a2)); + + // fillPaint + a1 = new XYShapeAnnotation( + new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + new BasicStroke(2.3f), gp1a, gp2a); + assertFalse(a1.equals(a2)); + a2 = new XYShapeAnnotation( + new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0), + new BasicStroke(2.3f), gp1b, gp2b); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + XYShapeAnnotation a1 = new XYShapeAnnotation( + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), + new BasicStroke(1.2f), Color.red, Color.blue); + XYShapeAnnotation a2 = new XYShapeAnnotation( + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), + new BasicStroke(1.2f), Color.red, Color.blue); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYShapeAnnotation a1 = new XYShapeAnnotation( + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), + new BasicStroke(1.2f), Color.red, Color.blue); + XYShapeAnnotation a2 = (XYShapeAnnotation) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Checks that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + XYShapeAnnotation a1 = new XYShapeAnnotation( + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), + new BasicStroke(1.2f), Color.red, Color.blue); + assertTrue(a1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYShapeAnnotation a1 = new XYShapeAnnotation( + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), + new BasicStroke(1.2f), Color.red, Color.blue); + XYShapeAnnotation a2 = (XYShapeAnnotation) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYTextAnnotationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYTextAnnotationTest.java new file mode 100755 index 0000000..1275f3d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYTextAnnotationTest.java @@ -0,0 +1,196 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * XYTextAnnotationTest.java + * ------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Aug-2003 : Version 1 (DG); + * 07-Jan-2005 : Added hashCode() test (DG); + * 26-Jan-2006 : Extended equals() test (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * 12-Feb-2009 : Updated testEquals() (DG); + * + */ + +package org.jfree.chart.annotations; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.ui.TextAnchor; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYTextAnnotation} class. + */ +public class XYTextAnnotationTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); + XYTextAnnotation a2 = new XYTextAnnotation("Text", 10.0, 20.0); + assertTrue(a1.equals(a2)); + + // text + a1 = new XYTextAnnotation("ABC", 10.0, 20.0); + assertFalse(a1.equals(a2)); + a2 = new XYTextAnnotation("ABC", 10.0, 20.0); + assertTrue(a1.equals(a2)); + + // x + a1 = new XYTextAnnotation("ABC", 11.0, 20.0); + assertFalse(a1.equals(a2)); + a2 = new XYTextAnnotation("ABC", 11.0, 20.0); + assertTrue(a1.equals(a2)); + + // y + a1 = new XYTextAnnotation("ABC", 11.0, 22.0); + assertFalse(a1.equals(a2)); + a2 = new XYTextAnnotation("ABC", 11.0, 22.0); + assertTrue(a1.equals(a2)); + + // font + a1.setFont(new Font("Serif", Font.PLAIN, 23)); + assertFalse(a1.equals(a2)); + a2.setFont(new Font("Serif", Font.PLAIN, 23)); + assertTrue(a1.equals(a2)); + + // paint + GradientPaint gp1 = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.yellow); + GradientPaint gp2 = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.yellow); + a1.setPaint(gp1); + assertFalse(a1.equals(a2)); + a2.setPaint(gp2); + assertTrue(a1.equals(a2)); + + // rotation anchor + a1.setRotationAnchor(TextAnchor.BASELINE_RIGHT); + assertFalse(a1.equals(a2)); + a2.setRotationAnchor(TextAnchor.BASELINE_RIGHT); + assertTrue(a1.equals(a2)); + + // rotation angle + a1.setRotationAngle(12.3); + assertFalse(a1.equals(a2)); + a2.setRotationAngle(12.3); + assertTrue(a1.equals(a2)); + + // text anchor + a1.setTextAnchor(TextAnchor.BASELINE_RIGHT); + assertFalse(a1.equals(a2)); + a2.setTextAnchor(TextAnchor.BASELINE_RIGHT); + assertTrue(a1.equals(a2)); + + a1.setBackgroundPaint(gp1); + assertFalse(a1.equals(a2)); + a2.setBackgroundPaint(gp1); + assertTrue(a1.equals(a2)); + + a1.setOutlinePaint(gp1); + assertFalse(a1.equals(a2)); + a2.setOutlinePaint(gp1); + assertTrue(a1.equals(a2)); + + a1.setOutlineStroke(new BasicStroke(1.2f)); + assertFalse(a1.equals(a2)); + a2.setOutlineStroke(new BasicStroke(1.2f)); + assertTrue(a1.equals(a2)); + + a1.setOutlineVisible(!a1.isOutlineVisible()); + assertFalse(a1.equals(a2)); + a2.setOutlineVisible(a1.isOutlineVisible()); + assertTrue(a1.equals(a2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); + XYTextAnnotation a2 = new XYTextAnnotation("Text", 10.0, 20.0); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); + XYTextAnnotation a2 = (XYTextAnnotation) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Checks that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); + assertTrue(a1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYTextAnnotation a1 = new XYTextAnnotation("Text", 10.0, 20.0); + a1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue)); + XYTextAnnotation a2 = (XYTextAnnotation) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYTitleAnnotationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYTitleAnnotationTest.java new file mode 100755 index 0000000..c7939cc --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/XYTitleAnnotationTest.java @@ -0,0 +1,165 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * XYTitleAnnotationTest.java + * -------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Apr-2007 : Version 1 (DG); + * 26-Feb-2008 : Added testDrawWithNullInfo() (DG); + * + */ + +package org.jfree.chart.annotations; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; +import org.jfree.chart.title.TextTitle; +import org.jfree.data.xy.DefaultTableXYDataset; +import org.jfree.data.xy.XYSeries; +import org.junit.Test; + +/** + * Tests for the {@link XYTitleAnnotation} class. + */ +public class XYTitleAnnotationTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + TextTitle t = new TextTitle("Title"); + XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); + XYTitleAnnotation a2 = new XYTitleAnnotation(1.0, 2.0, t); + assertTrue(a1.equals(a2)); + + a1 = new XYTitleAnnotation(1.1, 2.0, t); + assertFalse(a1.equals(a2)); + a2 = new XYTitleAnnotation(1.1, 2.0, t); + assertTrue(a1.equals(a2)); + + a1 = new XYTitleAnnotation(1.1, 2.2, t); + assertFalse(a1.equals(a2)); + a2 = new XYTitleAnnotation(1.1, 2.2, t); + assertTrue(a1.equals(a2)); + + TextTitle t2 = new TextTitle("Title 2"); + a1 = new XYTitleAnnotation(1.1, 2.2, t2); + assertFalse(a1.equals(a2)); + a2 = new XYTitleAnnotation(1.1, 2.2, t2); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + TextTitle t = new TextTitle("Title"); + XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); + XYTitleAnnotation a2 = new XYTitleAnnotation(1.0, 2.0, t); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + TextTitle t = new TextTitle("Title"); + XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); + XYTitleAnnotation a2 = (XYTitleAnnotation) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TextTitle t = new TextTitle("Title"); + XYTitleAnnotation a1 = new XYTitleAnnotation(1.0, 2.0, t); + XYTitleAnnotation a2 = (XYTitleAnnotation) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown. + */ + @Test + public void testDrawWithNullInfo() { + try { + DefaultTableXYDataset dataset = new DefaultTableXYDataset(); + + XYSeries s1 = new XYSeries("Series 1", true, false); + s1.add(5.0, 5.0); + s1.add(10.0, 15.5); + s1.add(15.0, 9.5); + s1.add(20.0, 7.5); + dataset.addSeries(s1); + + XYSeries s2 = new XYSeries("Series 2", true, false); + s2.add(5.0, 5.0); + s2.add(10.0, 15.5); + s2.add(15.0, 9.5); + s2.add(20.0, 3.5); + dataset.addSeries(s2); + XYPlot plot = new XYPlot(dataset, + new NumberAxis("X"), new NumberAxis("Y"), + new XYLineAndShapeRenderer()); + plot.addAnnotation(new XYTitleAnnotation(5.0, 6.0, + new TextTitle("Hello World!"))); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("There should be no exception."); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/package.html new file mode 100755 index 0000000..fa8b880 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/annotations/package.html @@ -0,0 +1,6 @@ + + + +Tests for the classes in the org.jfree.chart.annotations package. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/AxisLocationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/AxisLocationTest.java new file mode 100755 index 0000000..5c1bf90 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/AxisLocationTest.java @@ -0,0 +1,92 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * AxisLocationTest.java + * --------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-Jul-2003 : Version 1 (DG); + * 07-Jan-2005 : Added hashCode() test (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link AxisLocation} class. + */ +public class AxisLocationTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + assertEquals(AxisLocation.TOP_OR_RIGHT, AxisLocation.TOP_OR_RIGHT); + assertEquals(AxisLocation.BOTTOM_OR_RIGHT, + AxisLocation.BOTTOM_OR_RIGHT); + assertEquals(AxisLocation.TOP_OR_LEFT, AxisLocation.TOP_OR_LEFT); + assertEquals(AxisLocation.BOTTOM_OR_LEFT, AxisLocation.BOTTOM_OR_LEFT); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + AxisLocation a1 = AxisLocation.TOP_OR_RIGHT; + AxisLocation a2 = AxisLocation.TOP_OR_RIGHT; + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + AxisLocation location1 = AxisLocation.BOTTOM_OR_RIGHT; + AxisLocation location2 = (AxisLocation) TestUtilities.serialised(location1); + assertEquals(location1, location2); + boolean same = location1 == location2; + assertEquals(true, same); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/AxisSpaceTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/AxisSpaceTest.java new file mode 100755 index 0000000..475de85 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/AxisSpaceTest.java @@ -0,0 +1,110 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * AxisSpaceTest.java + * ------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 14-Aug-2003 : Version 1 (DG); + * 07-Jan-2005 : Added hashCode test (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import org.junit.Test; + +/** + * Tests for the {@link AxisSpace} class. + */ +public class AxisSpaceTest { + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + AxisSpace a1 = new AxisSpace(); + AxisSpace a2 = new AxisSpace(); + assertEquals(a1, a2); + + a1.setTop(1.11); + assertFalse(a1.equals(a2)); + a2.setTop(1.11); + assertTrue(a1.equals(a2)); + + a1.setBottom(2.22); + assertFalse(a1.equals(a2)); + a2.setBottom(2.22); + assertTrue(a1.equals(a2)); + + a1.setLeft(3.33); + assertFalse(a1.equals(a2)); + a2.setLeft(3.33); + assertTrue(a1.equals(a2)); + + a1.setRight(4.44); + assertFalse(a1.equals(a2)); + a2.setRight(4.44); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + AxisSpace s1 = new AxisSpace(); + AxisSpace s2 = new AxisSpace(); + assertTrue(s1.equals(s2)); + int h1 = s1.hashCode(); + int h2 = s2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + AxisSpace s1 = new AxisSpace(); + AxisSpace s2 = (AxisSpace) s1.clone(); + assertTrue(s1 != s2); + assertTrue(s1.getClass() == s2.getClass()); + assertTrue(s1.equals(s2)); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/AxisTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/AxisTest.java new file mode 100755 index 0000000..7b22aae --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/AxisTest.java @@ -0,0 +1,279 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * AxisTest.java + * ------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Aug-2003 : Version 1 (DG); + * 06-Jan-2004 : Added tests for axis line attributes (DG); + * 07-Jan-2005 : Added hashCode() test (DG); + * 25-Sep-2008 : Extended equals() to cover new fields (DG); + * 05-Aug-2013 : Extended equals for new fields (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.assertSame; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.font.TextAttribute; +import java.text.AttributedString; +import org.jfree.chart.TestUtilities; +import org.jfree.ui.RectangleInsets; + +import org.junit.Test; + +/** + * Tests for the {@link Axis} class. + */ +public class AxisTest { + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CategoryAxis a1 = new CategoryAxis("Test"); + a1.setAxisLinePaint(Color.red); + CategoryAxis a2 = (CategoryAxis) a1.clone(); + assertNotSame(a1, a2); + assertSame(a1.getClass(), a2.getClass()); + assertEquals(a1, a2); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + Axis a1 = new CategoryAxis("Test"); + Axis a2 = new CategoryAxis("Test"); + assertEquals(a1, a2); + + // visible flag... + a1.setVisible(false); + assertNotEquals(a1, a2); + a2.setVisible(false); + assertEquals(a1, a2); + + // label... + a1.setLabel("New Label"); + assertNotEquals(a1, a2); + a2.setLabel("New Label"); + assertEquals(a1, a2); + + // label font... + a1.setLabelFont(new Font("Dialog", Font.PLAIN, 8)); + assertNotEquals(a1, a2); + a2.setLabelFont(new Font("Dialog", Font.PLAIN, 8)); + assertEquals(a1, a2); + + // label paint... + a1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.black)); + assertNotEquals(a1, a2); + a2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.black)); + assertEquals(a1, a2); + + // attributed label... + a1.setAttributedLabel(new AttributedString("Hello World!")); + assertNotEquals(a1, a2); + a2.setAttributedLabel(new AttributedString("Hello World!")); + assertEquals(a1, a2); + + AttributedString l1 = a1.getAttributedLabel(); + l1.addAttribute(TextAttribute.SUPERSCRIPT, + TextAttribute.SUPERSCRIPT_SUB, 1, 2); + a1.setAttributedLabel(l1); + assertNotEquals(a1, a2); + AttributedString l2 = a2.getAttributedLabel(); + l2.addAttribute(TextAttribute.SUPERSCRIPT, + TextAttribute.SUPERSCRIPT_SUB, 1, 2); + a2.setAttributedLabel(l2); + assertEquals(a1, a2); + + // label insets... + a1.setLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); + assertNotEquals(a1, a2); + a2.setLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); + assertEquals(a1, a2); + + // label angle... + a1.setLabelAngle(1.23); + assertNotEquals(a1, a2); + a2.setLabelAngle(1.23); + assertEquals(a1, a2); + + // label location... + a1.setLabelLocation(AxisLabelLocation.HIGH_END); + assertNotEquals(a1, a2); + a2.setLabelLocation(AxisLabelLocation.HIGH_END); + assertEquals(a1, a2); + + // axis line visible... + a1.setAxisLineVisible(false); + assertNotEquals(a1, a2); + a2.setAxisLineVisible(false); + assertEquals(a1, a2); + + // axis line stroke... + BasicStroke s = new BasicStroke(1.1f); + a1.setAxisLineStroke(s); + assertNotEquals(a1, a2); + a2.setAxisLineStroke(s); + assertEquals(a1, a2); + + // axis line paint... + a1.setAxisLinePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.black)); + assertNotEquals(a1, a2); + a2.setAxisLinePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.black)); + assertEquals(a1, a2); + + // tick labels visible flag... + a1.setTickLabelsVisible(false); + assertNotEquals(a1, a2); + a2.setTickLabelsVisible(false); + assertEquals(a1, a2); + + // tick label font... + a1.setTickLabelFont(new Font("Dialog", Font.PLAIN, 12)); + assertNotEquals(a1, a2); + a2.setTickLabelFont(new Font("Dialog", Font.PLAIN, 12)); + assertEquals(a1, a2); + + // tick label paint... + a1.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.black)); + assertNotEquals(a1, a2); + a2.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.black)); + assertEquals(a1, a2); + + // tick label insets... + a1.setTickLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); + assertNotEquals(a1, a2); + a2.setTickLabelInsets(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); + assertEquals(a1, a2); + + // tick marks visible flag... + a1.setTickMarksVisible(false); + assertNotEquals(a1, a2); + a2.setTickMarksVisible(false); + assertEquals(a1, a2); + + // tick mark inside length... + a1.setTickMarkInsideLength(1.23f); + assertNotEquals(a1, a2); + a2.setTickMarkInsideLength(1.23f); + assertEquals(a1, a2); + + // tick mark outside length... + a1.setTickMarkOutsideLength(1.23f); + assertNotEquals(a1, a2); + a2.setTickMarkOutsideLength(1.23f); + assertEquals(a1, a2); + + // tick mark stroke... + a1.setTickMarkStroke(new BasicStroke(2.0f)); + assertNotEquals(a1, a2); + a2.setTickMarkStroke(new BasicStroke(2.0f)); + assertEquals(a1, a2); + + // tick mark paint... + a1.setTickMarkPaint(new GradientPaint(1.0f, 2.0f, Color.cyan, + 3.0f, 4.0f, Color.black)); + assertNotEquals(a1, a2); + a2.setTickMarkPaint(new GradientPaint(1.0f, 2.0f, Color.cyan, + 3.0f, 4.0f, Color.black)); + assertEquals(a1, a2); + + // fixed dimension... + a1.setFixedDimension(3.21f); + assertNotEquals(a1, a2); + a2.setFixedDimension(3.21f); + assertEquals(a1, a2); + + a1.setMinorTickMarksVisible(true); + assertNotEquals(a1, a2); + a2.setMinorTickMarksVisible(true); + assertEquals(a1, a2); + + a1.setMinorTickMarkInsideLength(1.23f); + assertNotEquals(a1, a2); + a2.setMinorTickMarkInsideLength(1.23f); + assertEquals(a1, a2); + + a1.setMinorTickMarkOutsideLength(3.21f); + assertNotEquals(a1, a2); + a2.setMinorTickMarkOutsideLength(3.21f); + assertEquals(a1, a2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + Axis a1 = new CategoryAxis("Test"); + Axis a2 = new CategoryAxis("Test"); + assertEquals(a1, a2); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Checks that serialization works, particularly with the attributed label. + */ + @Test + public void testSerialization() { + Axis a1 = new CategoryAxis("Test"); + AttributedString label = new AttributedString("Axis Label"); + label.addAttribute(TextAttribute.SUPERSCRIPT, + TextAttribute.SUPERSCRIPT_SUB, 1, 4); + a1.setAttributedLabel(label); + Axis a2 = (Axis) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryAnchorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryAnchorTest.java new file mode 100755 index 0000000..a73472e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryAnchorTest.java @@ -0,0 +1,92 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * CategoryAnchorTest.java + * ----------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-May-2004 : Version 1 (DG); + * 07-Jan-2005 : Added hashCode() test (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link CategoryAnchor} class. + */ +public class CategoryAnchorTest { + + /** + * Check that the equals() method distinguishes known instances. + */ + @Test + public void testEquals() { + assertEquals(CategoryAnchor.START, CategoryAnchor.START); + assertEquals(CategoryAnchor.MIDDLE, CategoryAnchor.MIDDLE); + assertEquals(CategoryAnchor.END, CategoryAnchor.END); + assertFalse(CategoryAnchor.START.equals(CategoryAnchor.END)); + assertFalse(CategoryAnchor.MIDDLE.equals(CategoryAnchor.END)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + CategoryAnchor a1 = CategoryAnchor.START; + CategoryAnchor a2 = CategoryAnchor.START; + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CategoryAnchor a1 = CategoryAnchor.MIDDLE; + CategoryAnchor a2 = (CategoryAnchor) TestUtilities.serialised(a1); + assertEquals(a1, a2); + assertTrue(a1 == a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryAxis3DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryAxis3DTest.java new file mode 100755 index 0000000..deb47d9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryAxis3DTest.java @@ -0,0 +1,76 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * CategoryAxis3DTest.java + * ----------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Mar-2003 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link CategoryAxis3D} class. + */ +public class CategoryAxis3DTest { + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CategoryAxis3D a1 = new CategoryAxis3D("Test"); + CategoryAxis3D a2 = (CategoryAxis3D) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CategoryAxis3D a1 = new CategoryAxis3D("Test Axis"); + CategoryAxis3D a2 = (CategoryAxis3D) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryAxisTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryAxisTest.java new file mode 100755 index 0000000..e049488 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryAxisTest.java @@ -0,0 +1,211 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * CategoryAxisTest.java + * --------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Mar-2003 : Version 1 (DG); + * 13-Aug-2003 : Added clone() test (DG); + * 07-Jan-2005 : Added hashCode() test (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link CategoryAxis} class. + */ +public class CategoryAxisTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + CategoryAxis a1 = new CategoryAxis("Test"); + CategoryAxis a2 = new CategoryAxis("Test"); + assertTrue(a1.equals(a2)); + + // lowerMargin + a1.setLowerMargin(0.15); + assertFalse(a1.equals(a2)); + a2.setLowerMargin(0.15); + assertTrue(a1.equals(a2)); + + // upperMargin + a1.setUpperMargin(0.15); + assertFalse(a1.equals(a2)); + a2.setUpperMargin(0.15); + assertTrue(a1.equals(a2)); + + // categoryMargin + a1.setCategoryMargin(0.15); + assertFalse(a1.equals(a2)); + a2.setCategoryMargin(0.15); + assertTrue(a1.equals(a2)); + + // maxCategoryLabelWidthRatio + a1.setMaximumCategoryLabelWidthRatio(0.98f); + assertFalse(a1.equals(a2)); + a2.setMaximumCategoryLabelWidthRatio(0.98f); + assertTrue(a1.equals(a2)); + + // categoryLabelPositionOffset + a1.setCategoryLabelPositionOffset(11); + assertFalse(a1.equals(a2)); + a2.setCategoryLabelPositionOffset(11); + assertTrue(a1.equals(a2)); + + // categoryLabelPositions + a1.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); + assertFalse(a1.equals(a2)); + a2.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); + assertTrue(a1.equals(a2)); + + // categoryLabelToolTips + a1.addCategoryLabelToolTip("Test", "Check"); + assertFalse(a1.equals(a2)); + a2.addCategoryLabelToolTip("Test", "Check"); + assertTrue(a1.equals(a2)); + + // categoryLabelURLs + a1.addCategoryLabelURL("Test", "http://www.jfree.org/"); + assertFalse(a1.equals(a2)); + a2.addCategoryLabelURL("Test", "http://www.jfree.org/"); + assertTrue(a1.equals(a2)); + + // tickLabelFont + a1.setTickLabelFont("C1", new Font("Dialog", Font.PLAIN, 21)); + assertFalse(a1.equals(a2)); + a2.setTickLabelFont("C1", new Font("Dialog", Font.PLAIN, 21)); + assertTrue(a1.equals(a2)); + + // tickLabelPaint + a1.setTickLabelPaint("C1", Color.red); + assertFalse(a1.equals(a2)); + a2.setTickLabelPaint("C1", Color.red); + assertTrue(a1.equals(a2)); + + // tickLabelPaint2 + a1.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertFalse(a1.equals(a2)); + a2.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertTrue(a1.equals(a2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + CategoryAxis a1 = new CategoryAxis("Test"); + CategoryAxis a2 = new CategoryAxis("Test"); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CategoryAxis a1 = new CategoryAxis("Test"); + CategoryAxis a2 = (CategoryAxis) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Confirm that cloning works. This test customises the font and paint + * per category label. + */ + @Test + public void testCloning2() throws CloneNotSupportedException { + CategoryAxis a1 = new CategoryAxis("Test"); + a1.setTickLabelFont("C1", new Font("Dialog", Font.PLAIN, 15)); + a1.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.white)); + CategoryAxis a2 = (CategoryAxis) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + + // check that changing a tick label font in a1 doesn't change a2 + a1.setTickLabelFont("C1", null); + assertFalse(a1.equals(a2)); + a2.setTickLabelFont("C1", null); + assertTrue(a1.equals(a2)); + + // check that changing a tick label paint in a1 doesn't change a2 + a1.setTickLabelPaint("C1", Color.yellow); + assertFalse(a1.equals(a2)); + a2.setTickLabelPaint("C1", Color.yellow); + assertTrue(a1.equals(a2)); + + // check that changing a category label tooltip in a1 doesn't change a2 + a1.addCategoryLabelToolTip("C1", "XYZ"); + assertFalse(a1.equals(a2)); + a2.addCategoryLabelToolTip("C1", "XYZ"); + assertTrue(a1.equals(a2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CategoryAxis a1 = new CategoryAxis("Test Axis"); + a1.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.white)); + CategoryAxis a2 = (CategoryAxis) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryLabelPositionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryLabelPositionTest.java new file mode 100755 index 0000000..69d04f2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryLabelPositionTest.java @@ -0,0 +1,154 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * CategoryLabelPositionTest.java + * ------------------------------ + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 17-Feb-2004 : Version 1 (DG); + * 07-Jan-2005 : Improved testEquals() code and added hashCode() test (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; + +import org.jfree.text.TextBlockAnchor; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.TextAnchor; +import org.junit.Test; + +/** + * Tests for the {@link CategoryLabelPosition} class. + */ +public class CategoryLabelPositionTest { + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + CategoryLabelPosition p1 = new CategoryLabelPosition( + RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT, + TextAnchor.BASELINE_LEFT, Math.PI / 4.0, + CategoryLabelWidthType.RANGE, 0.44f); + CategoryLabelPosition p2 = new CategoryLabelPosition( + RectangleAnchor.BOTTOM_LEFT, TextBlockAnchor.CENTER_RIGHT, + TextAnchor.BASELINE_LEFT, Math.PI / 4.0, + CategoryLabelWidthType.RANGE, 0.44f); + assertTrue(p1.equals(p2)); + assertTrue(p2.equals(p1)); + + p1 = new CategoryLabelPosition(RectangleAnchor.TOP, + TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT, + Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); + assertFalse(p1.equals(p2)); + p2 = new CategoryLabelPosition(RectangleAnchor.TOP, + TextBlockAnchor.CENTER_RIGHT, TextAnchor.BASELINE_LEFT, + Math.PI / 4.0, CategoryLabelWidthType.RANGE, 0.44f); + assertTrue(p1.equals(p2)); + + p1 = new CategoryLabelPosition(RectangleAnchor.TOP, + TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0, + CategoryLabelWidthType.RANGE, 0.44f); + assertFalse(p1.equals(p2)); + p2 = new CategoryLabelPosition(RectangleAnchor.TOP, + TextBlockAnchor.CENTER, TextAnchor.BASELINE_LEFT, Math.PI / 4.0, + CategoryLabelWidthType.RANGE, 0.44f); + assertTrue(p1.equals(p2)); + + p1 = new CategoryLabelPosition(RectangleAnchor.TOP, + TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0, + CategoryLabelWidthType.RANGE, 0.44f); + assertFalse(p1.equals(p2)); + p2 = new CategoryLabelPosition(RectangleAnchor.TOP, + TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 4.0, + CategoryLabelWidthType.RANGE, 0.44f); + assertTrue(p1.equals(p2)); + + p1 = new CategoryLabelPosition(RectangleAnchor.TOP, + TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, + CategoryLabelWidthType.RANGE, 0.44f); + assertFalse(p1.equals(p2)); + p2 = new CategoryLabelPosition(RectangleAnchor.TOP, + TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, + CategoryLabelWidthType.RANGE, 0.44f); + assertTrue(p1.equals(p2)); + + p1 = new CategoryLabelPosition(RectangleAnchor.TOP, + TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, + CategoryLabelWidthType.CATEGORY, 0.44f); + assertFalse(p1.equals(p2)); + p2 = new CategoryLabelPosition(RectangleAnchor.TOP, + TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, + CategoryLabelWidthType.CATEGORY, 0.44f); + assertTrue(p1.equals(p2)); + + p1 = new CategoryLabelPosition(RectangleAnchor.TOP, + TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, + CategoryLabelWidthType.CATEGORY, 0.55f); + assertFalse(p1.equals(p2)); + p2 = new CategoryLabelPosition(RectangleAnchor.TOP, + TextBlockAnchor.CENTER, TextAnchor.CENTER, Math.PI / 6.0, + CategoryLabelWidthType.CATEGORY, 0.55f); + assertTrue(p1.equals(p2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + CategoryLabelPosition a1 = new CategoryLabelPosition(); + CategoryLabelPosition a2 = new CategoryLabelPosition(); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CategoryLabelPosition p1 = new CategoryLabelPosition(); + CategoryLabelPosition p2 = (CategoryLabelPosition) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryLabelPositionsTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryLabelPositionsTest.java new file mode 100755 index 0000000..b0d6d59 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryLabelPositionsTest.java @@ -0,0 +1,181 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * CategoryLabelPositionsTest.java + * ------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 17-Feb-2004 : Version 1 (DG); + * 07-Jan-2005 : Added test for hashCode() (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.text.TextBlockAnchor; +import org.jfree.ui.RectangleAnchor; +import org.junit.Test; + +/** + * Tests for the {@link CategoryLabelPositions} class. + */ +public class CategoryLabelPositionsTest { + + private static final RectangleAnchor RA_TOP = RectangleAnchor.TOP; + private static final RectangleAnchor RA_BOTTOM = RectangleAnchor.BOTTOM; + + /** + * Check that the equals method distinguishes all fields. + */ + @Test + public void testEquals() { + CategoryLabelPositions p1 = new CategoryLabelPositions( + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); + CategoryLabelPositions p2 = new CategoryLabelPositions( + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); + assertEquals(p1, p2); + + p1 = new CategoryLabelPositions( + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); + assertTrue(!p1.equals(p2)); + p2 = new CategoryLabelPositions( + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); + assertTrue(p1.equals(p2)); + + p1 = new CategoryLabelPositions( + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_BOTTOM, TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); + assertTrue(!p1.equals(p2)); + p2 = new CategoryLabelPositions( + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); + assertTrue(p1.equals(p2)); + + p1 = new CategoryLabelPositions( + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); + assertTrue(!p1.equals(p2)); + p2 = new CategoryLabelPositions( + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); + assertTrue(p1.equals(p2)); + + p1 = new CategoryLabelPositions( + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER)); + assertTrue(!p1.equals(p2)); + p2 = new CategoryLabelPositions( + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER), + new CategoryLabelPosition(RA_BOTTOM, + TextBlockAnchor.TOP_CENTER)); + assertTrue(p1.equals(p2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + CategoryLabelPositions p1 = new CategoryLabelPositions( + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); + CategoryLabelPositions p2 = new CategoryLabelPositions( + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER), + new CategoryLabelPosition(RA_TOP, TextBlockAnchor.CENTER)); + assertTrue(p1.equals(p2)); + int h1 = p1.hashCode(); + int h2 = p2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CategoryLabelPositions p1 = CategoryLabelPositions.STANDARD; + CategoryLabelPositions p2 = (CategoryLabelPositions) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryLabelWidthTypeTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryLabelWidthTypeTest.java new file mode 100755 index 0000000..bc401d0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryLabelWidthTypeTest.java @@ -0,0 +1,89 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * CategoryLabelWidthTypeTest.java + * ------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-May-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link CategoryLabelWidthType} class. + */ +public class CategoryLabelWidthTypeTest { + + /** + * Confirm that the equals() method distinguishes the known values. + */ + @Test + public void testEquals() { + assertEquals(CategoryLabelWidthType.CATEGORY, + CategoryLabelWidthType.CATEGORY); + assertEquals(CategoryLabelWidthType.RANGE, + CategoryLabelWidthType.RANGE); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + CategoryLabelWidthType a1 = CategoryLabelWidthType.CATEGORY; + CategoryLabelWidthType a2 = CategoryLabelWidthType.CATEGORY; + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CategoryLabelWidthType w1 = CategoryLabelWidthType.RANGE; + CategoryLabelWidthType w2 = (CategoryLabelWidthType) TestUtilities.serialised(w1); + assertEquals(w1, w2); + assertTrue(w1 == w2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryTickTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryTickTest.java new file mode 100755 index 0000000..495966a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CategoryTickTest.java @@ -0,0 +1,152 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * CategoryTickTest.java + * --------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-May-2004 : Version 1 (DG); + * 07-Jan-2005 : Added test for hashCode() (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.text.TextBlock; +import org.jfree.text.TextBlockAnchor; +import org.jfree.text.TextLine; +import org.jfree.ui.TextAnchor; +import org.junit.Test; + +/** + * Tests for the {@link CategoryTick} class. + */ +public class CategoryTickTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + Comparable c1 = "C1"; + Comparable c2 = "C2"; + TextBlock tb1 = new TextBlock(); + tb1.addLine(new TextLine("Block 1")); + TextBlock tb2 = new TextBlock(); + tb1.addLine(new TextLine("Block 2")); + TextBlockAnchor tba1 = TextBlockAnchor.CENTER; + TextBlockAnchor tba2 = TextBlockAnchor.BOTTOM_CENTER; + TextAnchor ta1 = TextAnchor.CENTER; + TextAnchor ta2 = TextAnchor.BASELINE_LEFT; + + CategoryTick t1 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f); + CategoryTick t2 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f); + assertTrue(t1.equals(t2)); + + t1 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f); + assertFalse(t1.equals(t2)); + t2 = new CategoryTick(c2, tb1, tba1, ta1, 1.0f); + assertTrue(t1.equals(t2)); + + t1 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f); + assertFalse(t1.equals(t2)); + t2 = new CategoryTick(c2, tb2, tba1, ta1, 1.0f); + assertTrue(t1.equals(t2)); + + t1 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f); + assertFalse(t1.equals(t2)); + t2 = new CategoryTick(c2, tb2, tba2, ta1, 1.0f); + assertTrue(t1.equals(t2)); + + t1 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f); + assertFalse(t1.equals(t2)); + t2 = new CategoryTick(c2, tb2, tba2, ta2, 1.0f); + assertTrue(t1.equals(t2)); + + t1 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f); + assertFalse(t1.equals(t2)); + t2 = new CategoryTick(c2, tb2, tba2, ta2, 2.0f); + assertTrue(t1.equals(t2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + Comparable c1 = "C1"; + TextBlock tb1 = new TextBlock(); + tb1.addLine(new TextLine("Block 1")); + tb1.addLine(new TextLine("Block 2")); + TextBlockAnchor tba1 = TextBlockAnchor.CENTER; + TextAnchor ta1 = TextAnchor.CENTER; + + CategoryTick t1 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f); + CategoryTick t2 = new CategoryTick(c1, tb1, tba1, ta1, 1.0f); + assertTrue(t1.equals(t2)); + int h1 = t1.hashCode(); + int h2 = t2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CategoryTick t1 = new CategoryTick("C1", new TextBlock(), + TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f); + CategoryTick t2 = (CategoryTick) t1.clone(); + assertTrue(t1 != t2); + assertTrue(t1.getClass() == t2.getClass()); + assertTrue(t1.equals(t2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CategoryTick t1 = new CategoryTick("C1", new TextBlock(), + TextBlockAnchor.CENTER, TextAnchor.CENTER, 1.5f); + CategoryTick t2 = (CategoryTick) TestUtilities.serialised(t1); + assertEquals(t1, t2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/ColorBarTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/ColorBarTest.java new file mode 100755 index 0000000..2bbeec3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/ColorBarTest.java @@ -0,0 +1,112 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * ColorBarTest.java + * ----------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Mar-2003 : Version 1 (DG); + * 07-Jan-2005 : Added test for hashCode() method (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.plot.GreyPalette; +import org.junit.Test; + +/** + * Tests for the ColorBar class. + */ +public class ColorBarTest { + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + ColorBar c1 = new ColorBar("Test"); + ColorBar c2 = new ColorBar("Test"); + assertEquals(c1, c2); + + c1.setAxis(new NumberAxis("Axis 1")); + assertTrue(!c1.equals(c2)); + c2.setAxis(new NumberAxis("Axis 1")); + assertTrue(c1.equals(c2)); + + c1.setColorPalette(new GreyPalette()); + assertTrue(!c1.equals(c2)); + c2.setColorPalette(new GreyPalette()); + assertTrue(c1.equals(c2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + ColorBar c1 = new ColorBar("Test"); + ColorBar c2 = new ColorBar("Test"); + assertTrue(c1.equals(c2)); + int h1 = c1.hashCode(); + int h2 = c2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ColorBar c1 = new ColorBar("Test"); + ColorBar c2 = (ColorBar) c1.clone(); + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ColorBar a1 = new ColorBar("Test Axis"); + ColorBar a2 = (ColorBar) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CyclicNumberAxisTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CyclicNumberAxisTest.java new file mode 100755 index 0000000..8464062 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/CyclicNumberAxisTest.java @@ -0,0 +1,150 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * CyclicAxisTest.java + * ------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: Nicolas Brodu + * Contributor(s): -; + * + * Changes + * ------- + * 19-Nov-2003 : First version (NB); + * 05-Oct-2004 : Removed extension of NumberAxisTests (DG); + * 07-Jan-2004 : Added test for hashCode() (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Stroke; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link CyclicNumberAxis} class. + */ +public class CyclicNumberAxisTest { + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CyclicNumberAxis a1 = new CyclicNumberAxis(10, 0, "Test"); + CyclicNumberAxis a2 = (CyclicNumberAxis) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + CyclicNumberAxis a1 = new CyclicNumberAxis(10, 0, "Test"); + CyclicNumberAxis a2 = new CyclicNumberAxis(10, 0, "Test"); + assertTrue(a1.equals(a2)); + + // period + a1.setPeriod(5); + assertFalse(a1.equals(a2)); + a2.setPeriod(5); + assertTrue(a1.equals(a2)); + + // offset + a1.setOffset(2.0); + assertFalse(a1.equals(a2)); + a2.setOffset(2.0); + assertTrue(a1.equals(a2)); + + // advance line Paint + a1.setAdvanceLinePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.black)); + assertFalse(a1.equals(a2)); + a2.setAdvanceLinePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.black)); + assertTrue(a1.equals(a2)); + + // advance line Stroke + Stroke stroke = new BasicStroke(0.2f); + a1.setAdvanceLineStroke(stroke); + assertFalse(a1.equals(a2)); + a2.setAdvanceLineStroke(stroke); + assertTrue(a1.equals(a2)); + + // advance line Visible + a1.setAdvanceLineVisible(!a1.isAdvanceLineVisible()); + assertFalse(a1.equals(a2)); + a2.setAdvanceLineVisible(a1.isAdvanceLineVisible()); + assertTrue(a1.equals(a2)); + + // cycle bound mapping + a1.setBoundMappedToLastCycle(!a1.isBoundMappedToLastCycle()); + assertFalse(a1.equals(a2)); + a2.setBoundMappedToLastCycle(a1.isBoundMappedToLastCycle()); + assertTrue(a1.equals(a2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + CyclicNumberAxis a1 = new CyclicNumberAxis(10, 0, "Test"); + CyclicNumberAxis a2 = new CyclicNumberAxis(10, 0, "Test"); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CyclicNumberAxis a1 = new CyclicNumberAxis(10, 0, "Test Axis"); + CyclicNumberAxis a2 = (CyclicNumberAxis) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/DateAxisTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/DateAxisTest.java new file mode 100755 index 0000000..38f5df5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/DateAxisTest.java @@ -0,0 +1,1192 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * DateAxisTest.java + * ----------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Apr-2003 : Version 1 (DG); + * 07-Jan-2005 : Added test for hashCode() method (DG); + * 25-Sep-2005 : New tests for bug 1564977 (DG); + * 19-Apr-2007 : Added further checks for setMinimumDate() and + * setMaximumDate() (DG); + * 03-May-2007 : Replaced the tests for the previousStandardDate() method with + * new tests that check that the previousStandardDate and the + * next standard date do in fact span the reference date (DG); + * 25-Nov-2008 : Added testBug2201869 (DG); + * 08-Feb-2012 : Added testBug3484403 (MH); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.text.SimpleDateFormat; +import java.util.Arrays; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.List; +import java.util.Locale; +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.time.DateRange; +import org.jfree.data.time.Day; +import org.jfree.data.time.Hour; +import org.jfree.data.time.Millisecond; +import org.jfree.data.time.Month; +import org.jfree.data.time.Second; +import org.jfree.data.time.Year; +import org.jfree.ui.RectangleEdge; +import org.junit.Test; + +/** + * Tests for the {@link DateAxis} class. + */ +public class DateAxisTest { + + static class MyDateAxis extends DateAxis { + + /** + * Creates a new instance. + * + * @param label the label. + */ + public MyDateAxis(String label) { + super(label); + } + + @Override + public Date previousStandardDate(Date d, DateTickUnit unit) { + return super.previousStandardDate(d, unit); + } + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + DateAxis a1 = new DateAxis("Test"); + DateAxis a2 = new DateAxis("Test"); + assertTrue(a1.equals(a2)); + assertFalse(a1.equals(null)); + assertFalse(a1.equals("Some non-DateAxis object")); + + // tickUnit + a1.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7)); + assertFalse(a1.equals(a2)); + a2.setTickUnit(new DateTickUnit(DateTickUnit.DAY, 7)); + assertTrue(a1.equals(a2)); + + // dateFormatOverride + a1.setDateFormatOverride(new SimpleDateFormat("yyyy")); + assertFalse(a1.equals(a2)); + a2.setDateFormatOverride(new SimpleDateFormat("yyyy")); + assertTrue(a1.equals(a2)); + + // tickMarkPosition + a1.setTickMarkPosition(DateTickMarkPosition.END); + assertFalse(a1.equals(a2)); + a2.setTickMarkPosition(DateTickMarkPosition.END); + assertTrue(a1.equals(a2)); + + // timeline + a1.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline()); + assertFalse(a1.equals(a2)); + a2.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline()); + assertTrue(a1.equals(a2)); + + } + + /** + * A test for bug report 1472942. The DateFormat.equals() method is not + * checking the range attribute. + */ + @Test + public void test1472942() { + DateAxis a1 = new DateAxis("Test"); + DateAxis a2 = new DateAxis("Test"); + assertTrue(a1.equals(a2)); + + // range + a1.setRange(new Date(1L), new Date(2L)); + assertFalse(a1.equals(a2)); + a2.setRange(new Date(1L), new Date(2L)); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + DateAxis a1 = new DateAxis("Test"); + DateAxis a2 = new DateAxis("Test"); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DateAxis a1 = new DateAxis("Test"); + DateAxis a2 = (DateAxis) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Test that the setRange() method works. + */ + @Test + public void testSetRange() { + + DateAxis axis = new DateAxis("Test Axis"); + Calendar calendar = Calendar.getInstance(); + calendar.set(1999, Calendar.JANUARY, 3); + Date d1 = calendar.getTime(); + calendar.set(1999, Calendar.JANUARY, 31); + Date d2 = calendar.getTime(); + axis.setRange(d1, d2); + + DateRange range = (DateRange) axis.getRange(); + assertEquals(d1, range.getLowerDate()); + assertEquals(d2, range.getUpperDate()); + + } + + /** + * Test that the setMaximumDate() method works. + */ + @Test + public void testSetMaximumDate() { + DateAxis axis = new DateAxis("Test Axis"); + Date date = new Date(); + axis.setMaximumDate(date); + assertEquals(date, axis.getMaximumDate()); + + // check that setting the max date to something on or before the + // current min date works... + Date d1 = new Date(); + Date d2 = new Date(d1.getTime() + 1); + Date d0 = new Date(d1.getTime() - 1); + axis.setMaximumDate(d2); + axis.setMinimumDate(d1); + axis.setMaximumDate(d1); + assertEquals(d0, axis.getMinimumDate()); + } + + /** + * Test that the setMinimumDate() method works. + */ + @Test + public void testSetMinimumDate() { + DateAxis axis = new DateAxis("Test Axis"); + Date d1 = new Date(); + Date d2 = new Date(d1.getTime() + 1); + axis.setMaximumDate(d2); + axis.setMinimumDate(d1); + assertEquals(d1, axis.getMinimumDate()); + + // check that setting the min date to something on or after the + // current min date works... + Date d3 = new Date(d2.getTime() + 1); + axis.setMinimumDate(d2); + assertEquals(d3, axis.getMaximumDate()); + } + + /** + * Tests two doubles for 'near enough' equality. + * + * @param d1 number 1. + * @param d2 number 2. + * @param tolerance maximum tolerance. + * + * @return A boolean. + */ + private boolean same(double d1, double d2, double tolerance) { + return (Math.abs(d1 - d2) < tolerance); + } + + /** + * Test the translation of Java2D values to data values. + */ + @Test + public void testJava2DToValue() { + DateAxis axis = new DateAxis(); + axis.setRange(50.0, 100.0); + Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0); + double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); + assertTrue(same(y1, 95.8333333, 1.0)); + double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); + assertTrue(same(y2, 95.8333333, 1.0)); + double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); + assertTrue(same(x1, 58.125, 1.0)); + double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); + assertTrue(same(x2, 58.125, 1.0)); + axis.setInverted(true); + double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); + assertTrue(same(y3, 54.1666667, 1.0)); + double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); + assertTrue(same(y4, 54.1666667, 1.0)); + double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); + assertTrue(same(x3, 91.875, 1.0)); + double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); + assertTrue(same(x4, 91.875, 1.0)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DateAxis a1 = new DateAxis("Test Axis"); + DateAxis a2 = (DateAxis) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + + /** + * A basic check for the testPreviousStandardDate() method when the + * tick unit is 1 year. + */ + @Test + public void testPreviousStandardDateYearA() { + MyDateAxis axis = new MyDateAxis("Year"); + Year y2006 = new Year(2006); + Year y2007 = new Year(2007); + + // five dates to check... + Date d0 = new Date(y2006.getFirstMillisecond()); + Date d1 = new Date(y2006.getFirstMillisecond() + 500L); + Date d2 = new Date(y2006.getMiddleMillisecond()); + Date d3 = new Date(y2006.getMiddleMillisecond() + 500L); + Date d4 = new Date(y2006.getLastMillisecond()); + + Date end = new Date(y2007.getLastMillisecond()); + + DateTickUnit unit = new DateTickUnit(DateTickUnit.YEAR, 1); + axis.setTickUnit(unit); + + // START: check d0 and d1 + axis.setTickMarkPosition(DateTickMarkPosition.START); + + axis.setRange(d0, end); + Date psd = axis.previousStandardDate(d0, unit); + Date nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + // MIDDLE: check d1, d2 and d3 + axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + axis.setRange(d2, end); + psd = axis.previousStandardDate(d2, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d2.getTime()); + assertTrue(nsd.getTime() >= d2.getTime()); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + // END: check d3 and d4 + axis.setTickMarkPosition(DateTickMarkPosition.END); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + axis.setRange(d4, end); + psd = axis.previousStandardDate(d4, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d4.getTime()); + assertTrue(nsd.getTime() >= d4.getTime()); + } + + /** + * A basic check for the testPreviousStandardDate() method when the + * tick unit is 10 years (just for the sake of having a multiple). + */ + @Test + public void testPreviousStandardDateYearB() { + MyDateAxis axis = new MyDateAxis("Year"); + Year y2006 = new Year(2006); + Year y2007 = new Year(2007); + + // five dates to check... + Date d0 = new Date(y2006.getFirstMillisecond()); + Date d1 = new Date(y2006.getFirstMillisecond() + 500L); + Date d2 = new Date(y2006.getMiddleMillisecond()); + Date d3 = new Date(y2006.getMiddleMillisecond() + 500L); + Date d4 = new Date(y2006.getLastMillisecond()); + + Date end = new Date(y2007.getLastMillisecond()); + + DateTickUnit unit = new DateTickUnit(DateTickUnit.YEAR, 10); + axis.setTickUnit(unit); + + // START: check d0 and d1 + axis.setTickMarkPosition(DateTickMarkPosition.START); + + axis.setRange(d0, end); + Date psd = axis.previousStandardDate(d0, unit); + Date nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + // MIDDLE: check d1, d2 and d3 + axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + axis.setRange(d2, end); + psd = axis.previousStandardDate(d2, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d2.getTime()); + assertTrue(nsd.getTime() >= d2.getTime()); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + // END: check d3 and d4 + axis.setTickMarkPosition(DateTickMarkPosition.END); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + axis.setRange(d4, end); + psd = axis.previousStandardDate(d4, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d4.getTime()); + assertTrue(nsd.getTime() >= d4.getTime()); + } + + /** + * A basic check for the testPreviousStandardDate() method when the + * tick unit is 1 month. + */ + @Test + public void testPreviousStandardDateMonthA() { + MyDateAxis axis = new MyDateAxis("Month"); + Month nov2006 = new Month(11, 2006); + Month dec2006 = new Month(12, 2006); + + // five dates to check... + Date d0 = new Date(nov2006.getFirstMillisecond()); + Date d1 = new Date(nov2006.getFirstMillisecond() + 500L); + Date d2 = new Date(nov2006.getMiddleMillisecond()); + Date d3 = new Date(nov2006.getMiddleMillisecond() + 500L); + Date d4 = new Date(nov2006.getLastMillisecond()); + + Date end = new Date(dec2006.getLastMillisecond()); + + DateTickUnit unit = new DateTickUnit(DateTickUnit.MONTH, 1); + axis.setTickUnit(unit); + + // START: check d0 and d1 + axis.setTickMarkPosition(DateTickMarkPosition.START); + + axis.setRange(d0, end); + Date psd = axis.previousStandardDate(d0, unit); + Date nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + // MIDDLE: check d1, d2 and d3 + axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + axis.setRange(d2, end); + psd = axis.previousStandardDate(d2, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d2.getTime()); + assertTrue(nsd.getTime() >= d2.getTime()); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + // END: check d3 and d4 + axis.setTickMarkPosition(DateTickMarkPosition.END); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + axis.setRange(d4, end); + psd = axis.previousStandardDate(d4, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d4.getTime()); + assertTrue(nsd.getTime() >= d4.getTime()); + } + + /** + * A basic check for the testPreviousStandardDate() method when the + * tick unit is 3 months (just for the sake of having a multiple). + */ + @Test + public void testPreviousStandardDateMonthB() { + MyDateAxis axis = new MyDateAxis("Month"); + Month nov2006 = new Month(11, 2006); + Month dec2006 = new Month(12, 2006); + + // five dates to check... + Date d0 = new Date(nov2006.getFirstMillisecond()); + Date d1 = new Date(nov2006.getFirstMillisecond() + 500L); + Date d2 = new Date(nov2006.getMiddleMillisecond()); + Date d3 = new Date(nov2006.getMiddleMillisecond() + 500L); + Date d4 = new Date(nov2006.getLastMillisecond()); + + Date end = new Date(dec2006.getLastMillisecond()); + + DateTickUnit unit = new DateTickUnit(DateTickUnit.MONTH, 3); + axis.setTickUnit(unit); + + // START: check d0 and d1 + axis.setTickMarkPosition(DateTickMarkPosition.START); + + axis.setRange(d0, end); + Date psd = axis.previousStandardDate(d0, unit); + Date nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + // MIDDLE: check d1, d2 and d3 + axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + axis.setRange(d2, end); + psd = axis.previousStandardDate(d2, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d2.getTime()); + assertTrue(nsd.getTime() >= d2.getTime()); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + // END: check d3 and d4 + axis.setTickMarkPosition(DateTickMarkPosition.END); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + axis.setRange(d4, end); + psd = axis.previousStandardDate(d4, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d4.getTime()); + assertTrue(nsd.getTime() >= d4.getTime()); + } + + /** + * A basic check for the testPreviousStandardDate() method when the + * tick unit is 1 day. + */ + @Test + public void testPreviousStandardDateDayA() { + MyDateAxis axis = new MyDateAxis("Day"); + Day apr12007 = new Day(1, 4, 2007); + Day apr22007 = new Day(2, 4, 2007); + + // five dates to check... + Date d0 = new Date(apr12007.getFirstMillisecond()); + Date d1 = new Date(apr12007.getFirstMillisecond() + 500L); + Date d2 = new Date(apr12007.getMiddleMillisecond()); + Date d3 = new Date(apr12007.getMiddleMillisecond() + 500L); + Date d4 = new Date(apr12007.getLastMillisecond()); + + Date end = new Date(apr22007.getLastMillisecond()); + + DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 1); + axis.setTickUnit(unit); + + // START: check d0 and d1 + axis.setTickMarkPosition(DateTickMarkPosition.START); + + axis.setRange(d0, end); + Date psd = axis.previousStandardDate(d0, unit); + Date nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + // MIDDLE: check d1, d2 and d3 + axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + axis.setRange(d2, end); + psd = axis.previousStandardDate(d2, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d2.getTime()); + assertTrue(nsd.getTime() >= d2.getTime()); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + // END: check d3 and d4 + axis.setTickMarkPosition(DateTickMarkPosition.END); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + axis.setRange(d4, end); + psd = axis.previousStandardDate(d4, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d4.getTime()); + assertTrue(nsd.getTime() >= d4.getTime()); + } + + /** + * A basic check for the testPreviousStandardDate() method when the + * tick unit is 7 days (just for the sake of having a multiple). + */ + @Test + public void testPreviousStandardDateDayB() { + MyDateAxis axis = new MyDateAxis("Day"); + Day apr12007 = new Day(1, 4, 2007); + Day apr22007 = new Day(2, 4, 2007); + + // five dates to check... + Date d0 = new Date(apr12007.getFirstMillisecond()); + Date d1 = new Date(apr12007.getFirstMillisecond() + 500L); + Date d2 = new Date(apr12007.getMiddleMillisecond()); + Date d3 = new Date(apr12007.getMiddleMillisecond() + 500L); + Date d4 = new Date(apr12007.getLastMillisecond()); + + Date end = new Date(apr22007.getLastMillisecond()); + + DateTickUnit unit = new DateTickUnit(DateTickUnit.DAY, 7); + axis.setTickUnit(unit); + + // START: check d0 and d1 + axis.setTickMarkPosition(DateTickMarkPosition.START); + + axis.setRange(d0, end); + Date psd = axis.previousStandardDate(d0, unit); + Date nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + // MIDDLE: check d1, d2 and d3 + axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + axis.setRange(d2, end); + psd = axis.previousStandardDate(d2, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d2.getTime()); + assertTrue(nsd.getTime() >= d2.getTime()); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + // END: check d3 and d4 + axis.setTickMarkPosition(DateTickMarkPosition.END); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + axis.setRange(d4, end); + psd = axis.previousStandardDate(d4, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d4.getTime()); + assertTrue(nsd.getTime() >= d4.getTime()); + } + + /** + * A basic check for the testPreviousStandardDate() method when the + * tick unit is 1 hour. + */ + @Test + public void testPreviousStandardDateHourA() { + MyDateAxis axis = new MyDateAxis("Hour"); + Hour h0 = new Hour(12, 1, 4, 2007); + Hour h1 = new Hour(13, 1, 4, 2007); + + // five dates to check... + Date d0 = new Date(h0.getFirstMillisecond()); + Date d1 = new Date(h0.getFirstMillisecond() + 500L); + Date d2 = new Date(h0.getMiddleMillisecond()); + Date d3 = new Date(h0.getMiddleMillisecond() + 500L); + Date d4 = new Date(h0.getLastMillisecond()); + + Date end = new Date(h1.getLastMillisecond()); + + DateTickUnit unit = new DateTickUnit(DateTickUnit.HOUR, 1); + axis.setTickUnit(unit); + + // START: check d0 and d1 + axis.setTickMarkPosition(DateTickMarkPosition.START); + + axis.setRange(d0, end); + Date psd = axis.previousStandardDate(d0, unit); + Date nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + // MIDDLE: check d1, d2 and d3 + axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + axis.setRange(d2, end); + psd = axis.previousStandardDate(d2, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d2.getTime()); + assertTrue(nsd.getTime() >= d2.getTime()); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + // END: check d3 and d4 + axis.setTickMarkPosition(DateTickMarkPosition.END); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + axis.setRange(d4, end); + psd = axis.previousStandardDate(d4, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d4.getTime()); + assertTrue(nsd.getTime() >= d4.getTime()); + } + + /** + * A basic check for the testPreviousStandardDate() method when the + * tick unit is 6 hours (just for the sake of having a multiple). + */ + @Test + public void testPreviousStandardDateHourB() { + MyDateAxis axis = new MyDateAxis("Hour"); + Hour h0 = new Hour(12, 1, 4, 2007); + Hour h1 = new Hour(13, 1, 4, 2007); + + // five dates to check... + Date d0 = new Date(h0.getFirstMillisecond()); + Date d1 = new Date(h0.getFirstMillisecond() + 500L); + Date d2 = new Date(h0.getMiddleMillisecond()); + Date d3 = new Date(h0.getMiddleMillisecond() + 500L); + Date d4 = new Date(h0.getLastMillisecond()); + + Date end = new Date(h1.getLastMillisecond()); + + DateTickUnit unit = new DateTickUnit(DateTickUnit.HOUR, 6); + axis.setTickUnit(unit); + + // START: check d0 and d1 + axis.setTickMarkPosition(DateTickMarkPosition.START); + + axis.setRange(d0, end); + Date psd = axis.previousStandardDate(d0, unit); + Date nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + // MIDDLE: check d1, d2 and d3 + axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + axis.setRange(d2, end); + psd = axis.previousStandardDate(d2, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d2.getTime()); + assertTrue(nsd.getTime() >= d2.getTime()); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + // END: check d3 and d4 + axis.setTickMarkPosition(DateTickMarkPosition.END); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + axis.setRange(d4, end); + psd = axis.previousStandardDate(d4, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d4.getTime()); + assertTrue(nsd.getTime() >= d4.getTime()); + } + + /** + * A basic check for the testPreviousStandardDate() method when the + * tick unit is 1 second. + */ + @Test + public void testPreviousStandardDateSecondA() { + MyDateAxis axis = new MyDateAxis("Second"); + Second s0 = new Second(58, 31, 12, 1, 4, 2007); + Second s1 = new Second(59, 31, 12, 1, 4, 2007); + + // five dates to check... + Date d0 = new Date(s0.getFirstMillisecond()); + Date d1 = new Date(s0.getFirstMillisecond() + 50L); + Date d2 = new Date(s0.getMiddleMillisecond()); + Date d3 = new Date(s0.getMiddleMillisecond() + 50L); + Date d4 = new Date(s0.getLastMillisecond()); + + Date end = new Date(s1.getLastMillisecond()); + + DateTickUnit unit = new DateTickUnit(DateTickUnit.SECOND, 1); + axis.setTickUnit(unit); + + // START: check d0 and d1 + axis.setTickMarkPosition(DateTickMarkPosition.START); + + axis.setRange(d0, end); + Date psd = axis.previousStandardDate(d0, unit); + Date nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + // MIDDLE: check d1, d2 and d3 + axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + axis.setRange(d2, end); + psd = axis.previousStandardDate(d2, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d2.getTime()); + assertTrue(nsd.getTime() >= d2.getTime()); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + // END: check d3 and d4 + axis.setTickMarkPosition(DateTickMarkPosition.END); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + axis.setRange(d4, end); + psd = axis.previousStandardDate(d4, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d4.getTime()); + assertTrue(nsd.getTime() >= d4.getTime()); + } + + /** + * A basic check for the testPreviousStandardDate() method when the + * tick unit is 5 seconds (just for the sake of having a multiple). + */ + @Test + public void testPreviousStandardDateSecondB() { + MyDateAxis axis = new MyDateAxis("Second"); + Second s0 = new Second(58, 31, 12, 1, 4, 2007); + Second s1 = new Second(59, 31, 12, 1, 4, 2007); + + // five dates to check... + Date d0 = new Date(s0.getFirstMillisecond()); + Date d1 = new Date(s0.getFirstMillisecond() + 50L); + Date d2 = new Date(s0.getMiddleMillisecond()); + Date d3 = new Date(s0.getMiddleMillisecond() + 50L); + Date d4 = new Date(s0.getLastMillisecond()); + + Date end = new Date(s1.getLastMillisecond()); + + DateTickUnit unit = new DateTickUnit(DateTickUnit.SECOND, 5); + axis.setTickUnit(unit); + + // START: check d0 and d1 + axis.setTickMarkPosition(DateTickMarkPosition.START); + + axis.setRange(d0, end); + Date psd = axis.previousStandardDate(d0, unit); + Date nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + // MIDDLE: check d1, d2 and d3 + axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); + + axis.setRange(d1, end); + psd = axis.previousStandardDate(d1, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d1.getTime()); + assertTrue(nsd.getTime() >= d1.getTime()); + + axis.setRange(d2, end); + psd = axis.previousStandardDate(d2, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d2.getTime()); + assertTrue(nsd.getTime() >= d2.getTime()); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + // END: check d3 and d4 + axis.setTickMarkPosition(DateTickMarkPosition.END); + + axis.setRange(d3, end); + psd = axis.previousStandardDate(d3, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d3.getTime()); + assertTrue(nsd.getTime() >= d3.getTime()); + + axis.setRange(d4, end); + psd = axis.previousStandardDate(d4, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d4.getTime()); + assertTrue(nsd.getTime() >= d4.getTime()); + } + + /** + * A basic check for the testPreviousStandardDate() method when the + * tick unit is 1 millisecond. + */ + @Test + public void testPreviousStandardDateMillisecondA() { + MyDateAxis axis = new MyDateAxis("Millisecond"); + Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); + Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); + + Date d0 = new Date(m0.getFirstMillisecond()); + Date end = new Date(m1.getLastMillisecond()); + + DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 1); + axis.setTickUnit(unit); + + // START: check d0 + axis.setTickMarkPosition(DateTickMarkPosition.START); + + axis.setRange(d0, end); + Date psd = axis.previousStandardDate(d0, unit); + Date nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + + // MIDDLE: check d0 + axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); + + axis.setRange(d0, end); + psd = axis.previousStandardDate(d0, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + + // END: check d0 + axis.setTickMarkPosition(DateTickMarkPosition.END); + + axis.setRange(d0, end); + psd = axis.previousStandardDate(d0, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + } + + /** + * A basic check for the testPreviousStandardDate() method when the + * tick unit is 10 milliseconds (just for the sake of having a multiple). + */ + @Test + public void testPreviousStandardDateMillisecondB() { + MyDateAxis axis = new MyDateAxis("Millisecond"); + Millisecond m0 = new Millisecond(458, 58, 31, 12, 1, 4, 2007); + Millisecond m1 = new Millisecond(459, 58, 31, 12, 1, 4, 2007); + + Date d0 = new Date(m0.getFirstMillisecond()); + Date end = new Date(m1.getLastMillisecond()); + + DateTickUnit unit = new DateTickUnit(DateTickUnit.MILLISECOND, 10); + axis.setTickUnit(unit); + + // START: check d0 + axis.setTickMarkPosition(DateTickMarkPosition.START); + + axis.setRange(d0, end); + Date psd = axis.previousStandardDate(d0, unit); + Date nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + + // MIDDLE: check d0 + axis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); + + axis.setRange(d0, end); + psd = axis.previousStandardDate(d0, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + + // END: check d0 + axis.setTickMarkPosition(DateTickMarkPosition.END); + + axis.setRange(d0, end); + psd = axis.previousStandardDate(d0, unit); + nsd = unit.addToDate(psd); + assertTrue(psd.getTime() < d0.getTime()); + assertTrue(nsd.getTime() >= d0.getTime()); + } + + /** + * A test to reproduce bug 2201869. + */ + @Test + public void testBug2201869() { + TimeZone tz = TimeZone.getTimeZone("GMT"); + GregorianCalendar c = new GregorianCalendar(tz, Locale.UK); + DateAxis axis = new DateAxis("Date", tz, Locale.UK); + SimpleDateFormat sdf = new SimpleDateFormat("d-MMM-yyyy", Locale.UK); + sdf.setCalendar(c); + axis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1, sdf)); + Day d1 = new Day(1, 3, 2008); + d1.peg(c); + Day d2 = new Day(30, 6, 2008); + d2.peg(c); + axis.setRange(d1.getStart(), d2.getEnd()); + BufferedImage image = new BufferedImage(200, 100, + BufferedImage.TYPE_INT_ARGB); + Graphics2D g2 = image.createGraphics(); + Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, 200, 100); + axis.setTickMarkPosition(DateTickMarkPosition.END); + List ticks = axis.refreshTicks(g2, new AxisState(), area, + RectangleEdge.BOTTOM); + assertEquals(3, ticks.size()); + DateTick t1 = (DateTick) ticks.get(0); + assertEquals("31-Mar-2008", t1.getText()); + DateTick t2 = (DateTick) ticks.get(1); + assertEquals("30-Apr-2008", t2.getText()); + DateTick t3 = (DateTick) ticks.get(2); + assertEquals("31-May-2008", t3.getText()); + + // now repeat for a vertical axis + ticks = axis.refreshTicks(g2, new AxisState(), area, + RectangleEdge.LEFT); + assertEquals(3, ticks.size()); + t1 = (DateTick) ticks.get(0); + assertEquals("31-Mar-2008", t1.getText()); + t2 = (DateTick) ticks.get(1); + assertEquals("30-Apr-2008", t2.getText()); + t3 = (DateTick) ticks.get(2); + assertEquals("31-May-2008", t3.getText()); + } + + @Test + public void testBug3484403() { + + final long[] dates = + { 1304892000000L, 1304632800000L, 1304546400000L, 1304460000000L, + 1304373600000L, 1304287200000L, 1320015600000L, 1309384800000L, + 1319752800000L, 1319666400000L, 1319580000000L, 1319493600000L }; + Arrays.sort(dates); + + DateAxis axis = new DateAxis("Date"); + // set start and end date + Date start = new Date(dates[0]); + Date end = new Date(dates[dates.length-1]); + axis.setMinimumDate(start); + axis.setMaximumDate(end); + + SegmentedTimeline timeline = + SegmentedTimeline.newMondayThroughFridayTimeline(); + timeline.setStartTime(start.getTime()); + axis.setTimeline(timeline); + + BufferedImage image = new BufferedImage(200, 100, + BufferedImage.TYPE_INT_ARGB); + Graphics2D g2 = image.createGraphics(); + Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, 500, 200); + + // if the bug is still present, this leads to an endless loop + axis.refreshTicks(g2, new AxisState(), area, RectangleEdge.BOTTOM); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/DateTickMarkPositionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/DateTickMarkPositionTest.java new file mode 100755 index 0000000..465d73d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/DateTickMarkPositionTest.java @@ -0,0 +1,94 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * DateTickMarkPositionTest.java + * ----------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-May-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link DateTickMarkPosition} class. + */ +public class DateTickMarkPositionTest { + + /** + * Test equals() method. + */ + @Test + public void testEquals() { + assertEquals(DateTickMarkPosition.START, DateTickMarkPosition.START); + assertEquals(DateTickMarkPosition.MIDDLE, DateTickMarkPosition.MIDDLE); + assertEquals(DateTickMarkPosition.END, DateTickMarkPosition.END); + assertFalse(DateTickMarkPosition.START.equals(null)); + assertFalse(DateTickMarkPosition.START.equals( + DateTickMarkPosition.END)); + assertFalse(DateTickMarkPosition.MIDDLE.equals( + DateTickMarkPosition.END)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + DateTickMarkPosition a1 = DateTickMarkPosition.END; + DateTickMarkPosition a2 = DateTickMarkPosition.END; + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DateTickMarkPosition p1 = DateTickMarkPosition.MIDDLE; + DateTickMarkPosition p2 = (DateTickMarkPosition) TestUtilities.serialised(p1); + assertEquals(p1, p2); + assertTrue(p1 == p2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/DateTickTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/DateTickTest.java new file mode 100755 index 0000000..8e192ef --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/DateTickTest.java @@ -0,0 +1,148 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * DateTickTest.java + * ----------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-May-2004 : Version 1 (DG); + * 25-Sep-2008 : Extended testEquals() to cover new fields (DG); + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.Date; + +import org.jfree.chart.TestUtilities; + +import org.jfree.ui.TextAnchor; +import org.junit.Test; + +/** + * Tests for the {@link DateTick} class. + */ +public class DateTickTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + Date d1 = new Date(0L); + Date d2 = new Date(1L); + String l1 = "Label 1"; + String l2 = "Label 2"; + TextAnchor ta1 = TextAnchor.CENTER; + TextAnchor ta2 = TextAnchor.BASELINE_LEFT; + + DateTick t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0); + DateTick t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0); + assertTrue(t1.equals(t2)); + + t1 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0); + assertFalse(t1.equals(t2)); + t2 = new DateTick(d2, l1, ta1, ta1, Math.PI / 2.0); + assertTrue(t1.equals(t2)); + + t1 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0); + assertFalse(t1.equals(t2)); + t2 = new DateTick(d1, l2, ta1, ta1, Math.PI / 2.0); + assertTrue(t1.equals(t2)); + + t1 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0); + assertFalse(t1.equals(t2)); + t2 = new DateTick(d1, l1, ta2, ta1, Math.PI / 2.0); + assertTrue(t1.equals(t2)); + + t1 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0); + assertFalse(t1.equals(t2)); + t2 = new DateTick(d1, l1, ta1, ta2, Math.PI / 2.0); + assertTrue(t1.equals(t2)); + + t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0); + assertFalse(t1.equals(t2)); + t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 3.0); + assertTrue(t1.equals(t2)); + + t1 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI); + t2 = new DateTick(TickType.MAJOR, d1, l1, ta1, ta1, Math.PI); + assertFalse(t1.equals(t2)); + t2 = new DateTick(TickType.MINOR, d1, l1, ta1, ta1, Math.PI); + assertTrue(t1.equals(t2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + Date d1 = new Date(0L); + String l1 = "Label 1"; + TextAnchor ta1 = TextAnchor.CENTER; + + DateTick t1 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0); + DateTick t2 = new DateTick(d1, l1, ta1, ta1, Math.PI / 2.0); + assertTrue(t1.equals(t2)); + int h1 = t1.hashCode(); + int h2 = t2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DateTick t1 = new DateTick(new Date(0L), "Label", TextAnchor.CENTER, + TextAnchor.CENTER, 10.0); + DateTick t2 = (DateTick) t1.clone(); + assertTrue(t1 != t2); + assertTrue(t1.getClass() == t2.getClass()); + assertTrue(t1.equals(t2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DateTick t1 = new DateTick(new Date(0L), "Label", TextAnchor.CENTER, + TextAnchor.CENTER, 10.0); + DateTick t2 = (DateTick) TestUtilities.serialised(t1); + assertEquals(t1, t2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/DateTickUnitTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/DateTickUnitTest.java new file mode 100755 index 0000000..981731c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/DateTickUnitTest.java @@ -0,0 +1,88 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * DateTickUnitTest.java + * --------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Mar-2003 : Version 1 (DG); + * 07-Jan-2005 : Added test for hashCode() (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link DateTickUnit} class. + */ +public class DateTickUnitTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DateTickUnit t1 = new DateTickUnit(DateTickUnit.DAY, 1); + DateTickUnit t2 = new DateTickUnit(DateTickUnit.DAY, 1); + assertTrue(t1.equals(t2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + DateTickUnit t1 = new DateTickUnit(DateTickUnit.DAY, 1); + DateTickUnit t2 = new DateTickUnit(DateTickUnit.DAY, 1); + assertTrue(t1.equals(t2)); + int h1 = t1.hashCode(); + int h2 = t2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DateTickUnit a1 = new DateTickUnit(DateTickUnit.DAY, 7); + DateTickUnit a2 = (DateTickUnit) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/ExtendedCategoryAxisTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/ExtendedCategoryAxisTest.java new file mode 100755 index 0000000..cac27ba --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/ExtendedCategoryAxisTest.java @@ -0,0 +1,164 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * ExtendedCategoryAxisTest.java + * ----------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Mar-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link ExtendedCategoryAxis} class. + */ +public class ExtendedCategoryAxisTest { + + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); + ExtendedCategoryAxis a2 = new ExtendedCategoryAxis("Test"); + assertTrue(a1.equals(a2)); + + a1.addSubLabel("C1", "C1-sublabel"); + assertFalse(a1.equals(a2)); + a2.addSubLabel("C1", "C1-sublabel"); + assertTrue(a1.equals(a2)); + + a1.setSubLabelFont(new Font("Dialog", Font.BOLD, 8)); + assertFalse(a1.equals(a2)); + a2.setSubLabelFont(new Font("Dialog", Font.BOLD, 8)); + assertTrue(a1.equals(a2)); + + a1.setSubLabelPaint(Color.red); + assertFalse(a1.equals(a2)); + a2.setSubLabelPaint(Color.red); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); + ExtendedCategoryAxis a2 = new ExtendedCategoryAxis("Test"); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); + ExtendedCategoryAxis a2 = (ExtendedCategoryAxis) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + + // check independence + a1.addSubLabel("C1", "ABC"); + assertFalse(a1.equals(a2)); + a2.addSubLabel("C1", "ABC"); + assertTrue(a1.equals(a2)); + } + + /** + * Confirm that cloning works. This test customises the font and paint + * per category label. + */ + @Test + public void testCloning2() throws CloneNotSupportedException { + ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); + a1.setTickLabelFont("C1", new Font("Dialog", Font.PLAIN, 15)); + a1.setTickLabelPaint("C1", new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.white)); + ExtendedCategoryAxis a2 = (ExtendedCategoryAxis) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + + // check that changing a tick label font in a1 doesn't change a2 + a1.setTickLabelFont("C1", null); + assertFalse(a1.equals(a2)); + a2.setTickLabelFont("C1", null); + assertTrue(a1.equals(a2)); + + // check that changing a tick label paint in a1 doesn't change a2 + a1.setTickLabelPaint("C1", Color.yellow); + assertFalse(a1.equals(a2)); + a2.setTickLabelPaint("C1", Color.yellow); + assertTrue(a1.equals(a2)); + + // check that changing a category label tooltip in a1 doesn't change a2 + a1.addCategoryLabelToolTip("C1", "XYZ"); + assertFalse(a1.equals(a2)); + a2.addCategoryLabelToolTip("C1", "XYZ"); + assertTrue(a1.equals(a2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ExtendedCategoryAxis a1 = new ExtendedCategoryAxis("Test"); + a1.setSubLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.blue)); + ExtendedCategoryAxis a2 = (ExtendedCategoryAxis) + TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/LogAxisTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/LogAxisTest.java new file mode 100755 index 0000000..01750d2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/LogAxisTest.java @@ -0,0 +1,282 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * LogAxisTest.java + * ---------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-Jul-2007 : Version 1 (DG); + * 08-Apr-2008 : Fixed incorrect testEquals() method (DG); + * 28-Oct-2011 : Cdded test for endless loop, # 3429707 (MH); + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.ui.RectangleEdge; +import org.junit.Test; + +/** + * Tests for the {@link LogAxis} class. + */ +public class LogAxisTest { + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + LogAxis a1 = new LogAxis("Test"); + LogAxis a2 = (LogAxis) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + LogAxis a1 = new LogAxis("Test"); + LogAxis a2 = new LogAxis("Test"); + assertTrue(a1.equals(a2)); + + a1.setBase(2.0); + assertFalse(a1.equals(a2)); + a2.setBase(2.0); + assertTrue(a1.equals(a2)); + + a1.setSmallestValue(0.1); + assertFalse(a1.equals(a2)); + a2.setSmallestValue(0.1); + assertTrue(a1.equals(a2)); + + a1.setMinorTickCount(8); + assertFalse(a1.equals(a2)); + a2.setMinorTickCount(8); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + LogAxis a1 = new LogAxis("Test"); + LogAxis a2 = new LogAxis("Test"); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + private static final double EPSILON = 0.0000001; + + /** + * Test the translation of Java2D values to data values. + */ + @Test + public void testTranslateJava2DToValue() { + LogAxis axis = new LogAxis(); + axis.setRange(50.0, 100.0); + Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0); + double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); + assertEquals(94.3874312681693, y1, EPSILON); + double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); + assertEquals(94.3874312681693, y2, EPSILON); + double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); + assertEquals(55.961246381405, x1, EPSILON); + double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); + assertEquals(55.961246381405, x2, EPSILON); + axis.setInverted(true); + double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); + assertEquals(52.9731547179647, y3, EPSILON); + double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); + assertEquals(52.9731547179647, y4, EPSILON); + double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); + assertEquals(89.3475453695651, x3, EPSILON); + double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); + assertEquals(89.3475453695651, x4, EPSILON); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + LogAxis a1 = new LogAxis("Test Axis"); + LogAxis a2 = (LogAxis) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + + /** + * A simple test for the auto-range calculation looking at a + * LogAxis used as the range axis for a CategoryPlot. + */ + @Test + public void testAutoRange1() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.setValue(100.0, "Row 1", "Column 1"); + dataset.setValue(200.0, "Row 1", "Column 2"); + JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", + "Value", dataset); + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + LogAxis axis = new LogAxis("Log(Y)"); + plot.setRangeAxis(axis); + assertEquals(0.0, axis.getLowerBound(), EPSILON); + assertEquals(2.6066426411261268E7, axis.getUpperBound(), EPSILON); + } + + /** + * A simple test for the auto-range calculation looking at a + * NumberAxis used as the range axis for a CategoryPlot. In this + * case, the original dataset is replaced with a new dataset. + */ + @Test + public void testAutoRange3() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.setValue(100.0, "Row 1", "Column 1"); + dataset.setValue(200.0, "Row 1", "Column 2"); + JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", + "Value", dataset, PlotOrientation.VERTICAL, false, false, + false); + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + LogAxis axis = new LogAxis("Log(Y)"); + plot.setRangeAxis(axis); + assertEquals(96.59363289248458, axis.getLowerBound(), EPSILON); + assertEquals(207.0529847682752, axis.getUpperBound(), EPSILON); + + // now replacing the dataset should update the axis range... + DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); + dataset2.setValue(900.0, "Row 1", "Column 1"); + dataset2.setValue(1000.0, "Row 1", "Column 2"); + plot.setDataset(dataset2); + assertEquals(895.2712433374774, axis.getLowerBound(), EPSILON); + assertEquals(1005.2819262292991, axis.getUpperBound(), EPSILON); + } + + /** + * Checks that the auto-range for the domain axis on an XYPlot is + * working as expected. + */ + @Test + public void testXYAutoRange1() { + XYSeries series = new XYSeries("Series 1"); + series.add(1.0, 1.0); + series.add(2.0, 2.0); + series.add(3.0, 3.0); + XYSeriesCollection dataset = new XYSeriesCollection(); + dataset.addSeries(series); + JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", + dataset); + XYPlot plot = (XYPlot) chart.getPlot(); + LogAxis axis = new LogAxis("Log(Y)"); + plot.setRangeAxis(axis); + assertEquals(0.9465508226401592, axis.getLowerBound(), EPSILON); + assertEquals(3.1694019256486126, axis.getUpperBound(), EPSILON); + } + + /** + * Checks that the auto-range for the range axis on an XYPlot is + * working as expected. + */ + @Test + public void testXYAutoRange2() { + XYSeries series = new XYSeries("Series 1"); + series.add(1.0, 1.0); + series.add(2.0, 2.0); + series.add(3.0, 3.0); + XYSeriesCollection dataset = new XYSeriesCollection(); + dataset.addSeries(series); + JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", + dataset); + XYPlot plot = (XYPlot) chart.getPlot(); + LogAxis axis = new LogAxis("Log(Y)"); + plot.setRangeAxis(axis); + assertEquals(0.9465508226401592, axis.getLowerBound(), EPSILON); + assertEquals(3.1694019256486126, axis.getUpperBound(), EPSILON); + } + + /** + * Some checks for the setLowerBound() method. + */ + @Test + public void testSetLowerBound() { + LogAxis axis = new LogAxis("X"); + axis.setRange(0.0, 10.0); + axis.setLowerBound(5.0); + assertEquals(5.0, axis.getLowerBound(), EPSILON); + axis.setLowerBound(10.0); + assertEquals(10.0, axis.getLowerBound(), EPSILON); + assertEquals(11.0, axis.getUpperBound(), EPSILON); + } + + /** + * Checks the default value for the tickMarksVisible flag. + */ + @Test + public void testTickMarksVisibleDefault() { + LogAxis axis = new LogAxis("Log Axis"); + assertTrue(axis.isTickMarksVisible()); + } + + /** + * Checks that a TickUnit with a size of 0 doesn't crash. + */ + @Test + public void testrefreshTicksWithZeroTickUnit() { + LogAxis axis = new LogAxis(); + AxisState state = new AxisState(); + BufferedImage image = new BufferedImage(200, 100, + BufferedImage.TYPE_INT_ARGB); + Graphics2D g2 = image.createGraphics(); + Rectangle2D area = new Rectangle2D.Double(0.0, 0.0, 200, 100); + axis.refreshTicks(g2, state, area, RectangleEdge.TOP); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/LogarithmicAxisTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/LogarithmicAxisTest.java new file mode 100755 index 0000000..aaf40d0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/LogarithmicAxisTest.java @@ -0,0 +1,251 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * LogarithmicAxisTest.java + * ------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Mar-2003 : Version 1 (DG); + * 02-Mar-2007 : Added tests from bug report 880597 (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; + +import org.jfree.ui.RectangleEdge; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests for the {@link LogarithmicAxis} class. + */ +public class LogarithmicAxisTest { + + static class MyLogarithmicAxis extends LogarithmicAxis { + + /** + * Creates a new instance. + * + * @param label the label. + */ + public MyLogarithmicAxis(String label) { + super(label); + } + + /* (non-Javadoc) + * @see org.jfree.chart.axis.LogarithmicAxis#switchedLog10(double) + */ + @Override + protected double switchedLog10(double val) { + return super.switchedLog10(val); + } + + } + + /** Tolerance for floating point comparisons */ + public static double EPSILON = 0.000001; + + MyLogarithmicAxis axis = null; + + /** + * Sets up a new axis. + * + * @throws Exception + */ + @Before + public void setUp() throws Exception { + this.axis = new MyLogarithmicAxis("Value (log)"); + this.axis.setAllowNegativesFlag(false); + this.axis.setLog10TickLabelsFlag(false); + this.axis.setLowerMargin(0.0); + this.axis.setUpperMargin(0.0); + + this.axis.setLowerBound(0.2); + this.axis.setUpperBound(100.0); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + LogarithmicAxis a1 = new LogarithmicAxis("Test Axis"); + LogarithmicAxis a2 = (LogarithmicAxis) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + + /** + * Test if adjustedLog10 and adjustedPow10 are inverses of each other + */ + @Test + public void testAdjustedLog10() { + checkLogPowRoundTrip(20); + checkLogPowRoundTrip(10); + checkLogPowRoundTrip(5); + checkLogPowRoundTrip(2); + checkLogPowRoundTrip(1); + checkLogPowRoundTrip(0.5); + checkLogPowRoundTrip(0.2); + checkLogPowRoundTrip(0.0001); + } + + private void checkLogPowRoundTrip(double value) { + assertEquals("log(pow(x)) = x", value, this.axis.adjustedLog10( + this.axis.adjustedPow10(value)), EPSILON); + assertEquals("pow(log(x)) = x", value, this.axis.adjustedPow10( + this.axis.adjustedLog10(value)), EPSILON); + } + + /** + * Test if switchedLog10 and switchedPow10 are inverses of each other + */ + @Test + public void testSwitchedLog10() { + assertFalse("Axis should not allow negative values", + this.axis.getAllowNegativesFlag()); + + assertEquals(Math.log(0.5) / LogarithmicAxis.LOG10_VALUE, + this.axis.switchedLog10(0.5), EPSILON); + checkSwitchedLogPowRoundTrip(20); + checkSwitchedLogPowRoundTrip(10); + checkSwitchedLogPowRoundTrip(5); + checkSwitchedLogPowRoundTrip(2); + checkSwitchedLogPowRoundTrip(1); + checkSwitchedLogPowRoundTrip(0.5); + checkSwitchedLogPowRoundTrip(0.2); + checkSwitchedLogPowRoundTrip(0.0001); + } + + private void checkSwitchedLogPowRoundTrip(double value) { + assertEquals("log(pow(x)) = x", value, this.axis.switchedLog10( + this.axis.switchedPow10(value)), EPSILON); + assertEquals("pow(log(x)) = x", value, this.axis.switchedPow10( + this.axis.switchedLog10(value)), EPSILON); + } + + /** + * Test of java2DToValue method. + */ + @Test + public void testJava2DToValue() { + Rectangle2D plotArea = new Rectangle2D.Double(22, 33, 500, 500); + RectangleEdge edge = RectangleEdge.BOTTOM; + + // set axis bounds to be both greater than 1 + this.axis.setRange(10, 20); + checkPointsToValue(edge, plotArea); + + // check for bounds interval that includes 1 + this.axis.setRange(0.5, 10); + checkPointsToValue(edge, plotArea); + + // check for bounds interval that includes 1 + this.axis.setRange(0.2, 20); + checkPointsToValue(edge, plotArea); + + // check for both bounds smaller than 1 + this.axis.setRange(0.2, 0.7); + checkPointsToValue(edge, plotArea); + } + + /** + * Test of valueToJava2D method. + */ + @Test + public void testValueToJava2D() { + Rectangle2D plotArea = new Rectangle2D.Double(22, 33, 500, 500); + RectangleEdge edge = RectangleEdge.BOTTOM; + + // set axis bounds to be both greater than 1 + this.axis.setRange(10, 20); + checkPointsToJava2D(edge, plotArea); + + // check for bounds interval that includes 1 + this.axis.setRange(0.5, 10); + checkPointsToJava2D(edge, plotArea); + + // check for bounds interval that includes 1 + this.axis.setRange(0.2, 20); + checkPointsToJava2D(edge, plotArea); + + // check for both bounds smaller than 1 + this.axis.setRange(0.2, 0.7); + checkPointsToJava2D(edge, plotArea); + } + + private void checkPointsToJava2D(RectangleEdge edge, + Rectangle2D plotArea) { + assertEquals("Left most point on the axis should be beginning of " + + "range.", plotArea.getX(), this.axis.valueToJava2D( + this.axis.getLowerBound(), plotArea, edge), EPSILON); + assertEquals("Right most point on the axis should be end of range.", + plotArea.getX() + plotArea.getWidth(), + this.axis.valueToJava2D(this.axis.getUpperBound(), + plotArea, edge), EPSILON); + assertEquals("Center point on the axis should geometric mean of the bounds.", + plotArea.getX() + (plotArea.getWidth() / 2), + this.axis.valueToJava2D(Math.sqrt(this.axis.getLowerBound() + * this.axis.getUpperBound()), plotArea, edge), EPSILON); + } + + /** + * Check the translation java2D to value for left, right, and center point. + * + * @param edge the edge. + * @param plotArea the plot area. + */ + private void checkPointsToValue(RectangleEdge edge, Rectangle2D plotArea) { + assertEquals("Right most point on the axis should be end of range.", + this.axis.getUpperBound(), this.axis.java2DToValue( + plotArea.getX() + plotArea.getWidth(), plotArea, edge), + EPSILON); + + assertEquals("Left most point on the axis should be beginning of " + + "range.", this.axis.getLowerBound(), + this.axis.java2DToValue(plotArea.getX(), plotArea, edge), + EPSILON); + + assertEquals("Center point on the axis should geometric mean of the " + + "bounds.", Math.sqrt(this.axis.getUpperBound() + * this.axis.getLowerBound()), this.axis.java2DToValue( + plotArea.getX() + (plotArea.getWidth() / 2), plotArea, edge), + EPSILON); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/MarkerAxisBandTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/MarkerAxisBandTest.java new file mode 100755 index 0000000..4584592 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/MarkerAxisBandTest.java @@ -0,0 +1,121 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * MarkerAxisBandTest.java + * ----------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Mar-2003 : Version 1 (DG); + * 07-Jan-2005 : Added tests for equals() and hashCode() (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Font; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link MarkerAxisBand} class. + */ +public class MarkerAxisBandTest { + + /** + * Test that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + Font font1 = new Font("SansSerif", Font.PLAIN, 12); + Font font2 = new Font("SansSerif", Font.PLAIN, 14); + + MarkerAxisBand a1 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, font1); + MarkerAxisBand a2 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, font1); + assertEquals(a1, a2); + + a1 = new MarkerAxisBand(null, 2.0, 1.0, 1.0, 1.0, font1); + assertFalse(a1.equals(a2)); + a2 = new MarkerAxisBand(null, 2.0, 1.0, 1.0, 1.0, font1); + assertTrue(a1.equals(a2)); + + a1 = new MarkerAxisBand(null, 2.0, 3.0, 1.0, 1.0, font1); + assertFalse(a1.equals(a2)); + a2 = new MarkerAxisBand(null, 2.0, 3.0, 1.0, 1.0, font1); + assertTrue(a1.equals(a2)); + + a1 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 1.0, font1); + assertFalse(a1.equals(a2)); + a2 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 1.0, font1); + assertTrue(a1.equals(a2)); + + a1 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 5.0, font1); + assertFalse(a1.equals(a2)); + a2 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 5.0, font1); + assertTrue(a1.equals(a2)); + + a1 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 5.0, font2); + assertFalse(a1.equals(a2)); + a2 = new MarkerAxisBand(null, 2.0, 3.0, 4.0, 5.0, font2); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + Font font1 = new Font("SansSerif", Font.PLAIN, 12); + + MarkerAxisBand a1 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, font1); + MarkerAxisBand a2 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, font1); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + MarkerAxisBand a1 = new MarkerAxisBand(null, 1.0, 1.0, 1.0, 1.0, null); + MarkerAxisBand a2 = (MarkerAxisBand) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/ModuloAxisTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/ModuloAxisTest.java new file mode 100755 index 0000000..b3f7ece --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/ModuloAxisTest.java @@ -0,0 +1,107 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * ModuloAxisTest.java + * ------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Nov-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.junit.Test; + +/** + * Tests for the {@link ModuloAxis} class. + */ +public class ModuloAxisTest { + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ModuloAxis a1 = new ModuloAxis("Test", new Range(0.0, 1.0)); + ModuloAxis a2 = (ModuloAxis) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + ModuloAxis a1 = new ModuloAxis("Test", new Range(0.0, 1.0)); + ModuloAxis a2 = new ModuloAxis("Test", new Range(0.0, 1.0)); + assertTrue(a1.equals(a2)); + + a1.setDisplayRange(0.1, 1.1); + assertFalse(a1.equals(a2)); + a2.setDisplayRange(0.1, 1.1); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + ModuloAxis a1 = new ModuloAxis("Test", new Range(0.0, 1.0)); + ModuloAxis a2 = new ModuloAxis("Test", new Range(0.0, 1.0)); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ModuloAxis a1 = new ModuloAxis("Test", new Range(0.0, 1.0)); + ModuloAxis a2 = (ModuloAxis) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/MonthDateFormatTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/MonthDateFormatTest.java new file mode 100755 index 0000000..29de863 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/MonthDateFormatTest.java @@ -0,0 +1,152 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * MonthDateFormatTest.java + * ------------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-May-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.SimpleDateFormat; +import java.util.Locale; +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Some tests for the {@link MonthDateFormat} class. + */ +public class MonthDateFormatTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + MonthDateFormat mf1 = new MonthDateFormat(); + MonthDateFormat mf2 = new MonthDateFormat(); + assertTrue(mf1.equals(mf2)); + assertTrue(mf2.equals(mf1)); + + boolean[] showYear1 = new boolean [12]; + showYear1[0] = true; + boolean[] showYear2 = new boolean [12]; + showYear1[1] = true; + + // time zone + mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.US, 1, + showYear1, new SimpleDateFormat("yy")); + assertFalse(mf1.equals(mf2)); + mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.US, 1, + showYear1, new SimpleDateFormat("yy")); + assertTrue(mf1.equals(mf2)); + + // locale + mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 1, + showYear1, new SimpleDateFormat("yy")); + assertFalse(mf1.equals(mf2)); + mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 1, + showYear1, new SimpleDateFormat("yy")); + assertTrue(mf1.equals(mf2)); + + // chars + mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, + showYear1, new SimpleDateFormat("yy")); + assertFalse(mf1.equals(mf2)); + mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, + showYear1, new SimpleDateFormat("yy")); + assertTrue(mf1.equals(mf2)); + + // showYear[] + mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, + showYear2, new SimpleDateFormat("yy")); + assertFalse(mf1.equals(mf2)); + mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, + showYear2, new SimpleDateFormat("yy")); + assertTrue(mf1.equals(mf2)); + + // yearFormatter + mf1 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, + showYear2, new SimpleDateFormat("yyyy")); + assertFalse(mf1.equals(mf2)); + mf2 = new MonthDateFormat(TimeZone.getTimeZone("PST"), Locale.FRANCE, 2, + showYear2, new SimpleDateFormat("yyyy")); + assertTrue(mf1.equals(mf2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + MonthDateFormat mf1 = new MonthDateFormat(); + MonthDateFormat mf2 = new MonthDateFormat(); + assertTrue(mf1.equals(mf2)); + int h1 = mf1.hashCode(); + int h2 = mf2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() { + MonthDateFormat mf1 = new MonthDateFormat(); + MonthDateFormat mf2 = null; + mf2 = (MonthDateFormat) mf1.clone(); + assertTrue(mf1 != mf2); + assertTrue(mf1.getClass() == mf2.getClass()); + assertTrue(mf1.equals(mf2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + MonthDateFormat mf1 = new MonthDateFormat(); + MonthDateFormat mf2 = (MonthDateFormat) TestUtilities.serialised(mf1); + assertTrue(mf1.equals(mf2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/NumberAxis3DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/NumberAxis3DTest.java new file mode 100755 index 0000000..d7b7871 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/NumberAxis3DTest.java @@ -0,0 +1,63 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * NumberAxis3DTest.java + * --------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Mar-2003 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link NumberAxis3D} class. + */ +public class NumberAxis3DTest { + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + NumberAxis3D a1 = new NumberAxis3D("Test Axis"); + NumberAxis3D a2 = (NumberAxis3D) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/NumberAxisTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/NumberAxisTest.java new file mode 100755 index 0000000..f52870c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/NumberAxisTest.java @@ -0,0 +1,400 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * NumberAxisTest.java + * ------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Mar-2003 : Version 1 (DG); + * 14-Aug-2003 : Added tests for equals() method (DG); + * 05-Oct-2004 : Added tests to pick up a bug in the auto-range calculation for + * a domain axis on an XYPlot using an XYSeriesCollection (DG); + * 07-Jan-2005 : Added test for hashCode() (DG); + * 11-Jan-2006 : Fixed testAutoRange2() and testAutoRange3() following changes + * to BarRenderer (DG); + * 20-Feb-2006 : Added rangeType field to equals() test (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.geom.Rectangle2D; +import java.text.DecimalFormat; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.renderer.category.BarRenderer; +import org.jfree.data.RangeType; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.ui.RectangleEdge; +import org.junit.Test; + +/** + * Tests for the {@link NumberAxis} class. + */ +public class NumberAxisTest { + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + NumberAxis a1 = new NumberAxis("Test"); + NumberAxis a2 = (NumberAxis) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + NumberAxis a1 = new NumberAxis("Test"); + NumberAxis a2 = new NumberAxis("Test"); + assertTrue(a1.equals(a2)); + + //private boolean autoRangeIncludesZero; + a1.setAutoRangeIncludesZero(false); + assertFalse(a1.equals(a2)); + a2.setAutoRangeIncludesZero(false); + assertTrue(a1.equals(a2)); + + //private boolean autoRangeStickyZero; + a1.setAutoRangeStickyZero(false); + assertFalse(a1.equals(a2)); + a2.setAutoRangeStickyZero(false); + assertTrue(a1.equals(a2)); + + //private NumberTickUnit tickUnit; + a1.setTickUnit(new NumberTickUnit(25.0)); + assertFalse(a1.equals(a2)); + a2.setTickUnit(new NumberTickUnit(25.0)); + assertTrue(a1.equals(a2)); + + //private NumberFormat numberFormatOverride; + a1.setNumberFormatOverride(new DecimalFormat("0.00")); + assertFalse(a1.equals(a2)); + a2.setNumberFormatOverride(new DecimalFormat("0.00")); + assertTrue(a1.equals(a2)); + + a1.setRangeType(RangeType.POSITIVE); + assertFalse(a1.equals(a2)); + a2.setRangeType(RangeType.POSITIVE); + assertTrue(a1.equals(a2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + NumberAxis a1 = new NumberAxis("Test"); + NumberAxis a2 = new NumberAxis("Test"); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + private static final double EPSILON = 0.0000001; + + /** + * Test the translation of Java2D values to data values. + */ + @Test + public void testTranslateJava2DToValue() { + NumberAxis axis = new NumberAxis(); + axis.setRange(50.0, 100.0); + Rectangle2D dataArea = new Rectangle2D.Double(10.0, 50.0, 400.0, 300.0); + double y1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); + assertEquals(y1, 95.8333333, EPSILON); + double y2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); + assertEquals(y2, 95.8333333, EPSILON); + double x1 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); + assertEquals(x1, 58.125, EPSILON); + double x2 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); + assertEquals(x2, 58.125, EPSILON); + axis.setInverted(true); + double y3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.LEFT); + assertEquals(y3, 54.1666667, EPSILON); + double y4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.RIGHT); + assertEquals(y4, 54.1666667, EPSILON); + double x3 = axis.java2DToValue(75.0, dataArea, RectangleEdge.TOP); + assertEquals(x3, 91.875, EPSILON); + double x4 = axis.java2DToValue(75.0, dataArea, RectangleEdge.BOTTOM); + assertEquals(x4, 91.875, EPSILON); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + NumberAxis a1 = new NumberAxis("Test Axis"); + NumberAxis a2 = (NumberAxis) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + + /** + * A simple test for the auto-range calculation looking at a + * NumberAxis used as the range axis for a CategoryPlot. + */ + @Test + public void testAutoRange1() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.setValue(100.0, "Row 1", "Column 1"); + dataset.setValue(200.0, "Row 1", "Column 2"); + JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", + "Value", dataset); + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + NumberAxis axis = (NumberAxis) plot.getRangeAxis(); + assertEquals(axis.getLowerBound(), 0.0, EPSILON); + assertEquals(axis.getUpperBound(), 210.0, EPSILON); + } + + /** + * A simple test for the auto-range calculation looking at a + * NumberAxis used as the range axis for a CategoryPlot. In this + * case, the 'autoRangeIncludesZero' flag is set to false. + */ + @Test + public void testAutoRange2() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.setValue(100.0, "Row 1", "Column 1"); + dataset.setValue(200.0, "Row 1", "Column 2"); + JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", + "Value", dataset, PlotOrientation.VERTICAL, false, false, + false); + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + NumberAxis axis = (NumberAxis) plot.getRangeAxis(); + axis.setAutoRangeIncludesZero(false); + assertEquals(axis.getLowerBound(), 95.0, EPSILON); + assertEquals(axis.getUpperBound(), 205.0, EPSILON); + } + + /** + * A simple test for the auto-range calculation looking at a + * NumberAxis used as the range axis for a CategoryPlot. In this + * case, the 'autoRangeIncludesZero' flag is set to false AND the + * original dataset is replaced with a new dataset. + */ + @Test + public void testAutoRange3() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.setValue(100.0, "Row 1", "Column 1"); + dataset.setValue(200.0, "Row 1", "Column 2"); + JFreeChart chart = ChartFactory.createLineChart("Test", "Categories", + "Value", dataset, PlotOrientation.VERTICAL, false, false, + false); + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + NumberAxis axis = (NumberAxis) plot.getRangeAxis(); + axis.setAutoRangeIncludesZero(false); + assertEquals(axis.getLowerBound(), 95.0, EPSILON); + assertEquals(axis.getUpperBound(), 205.0, EPSILON); + + // now replacing the dataset should update the axis range... + DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); + dataset2.setValue(900.0, "Row 1", "Column 1"); + dataset2.setValue(1000.0, "Row 1", "Column 2"); + plot.setDataset(dataset2); + assertEquals(axis.getLowerBound(), 895.0, EPSILON); + assertEquals(axis.getUpperBound(), 1005.0, EPSILON); + } + + /** + * A check for the interaction between the 'autoRangeIncludesZero' flag + * and the base setting in the BarRenderer. + */ + @Test + public void testAutoRange4() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.setValue(100.0, "Row 1", "Column 1"); + dataset.setValue(200.0, "Row 1", "Column 2"); + JFreeChart chart = ChartFactory.createBarChart("Test", "Categories", + "Value", dataset, PlotOrientation.VERTICAL, false, false, + false); + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + NumberAxis axis = (NumberAxis) plot.getRangeAxis(); + axis.setAutoRangeIncludesZero(false); + BarRenderer br = (BarRenderer) plot.getRenderer(); + br.setIncludeBaseInRange(false); + assertEquals(95.0, axis.getLowerBound(), EPSILON); + assertEquals(205.0, axis.getUpperBound(), EPSILON); + + br.setIncludeBaseInRange(true); + assertEquals(0.0, axis.getLowerBound(), EPSILON); + assertEquals(210.0, axis.getUpperBound(), EPSILON); + + axis.setAutoRangeIncludesZero(true); + assertEquals(0.0, axis.getLowerBound(), EPSILON); + assertEquals(210.0, axis.getUpperBound(), EPSILON); + + br.setIncludeBaseInRange(true); + assertEquals(0.0, axis.getLowerBound(), EPSILON); + assertEquals(210.0, axis.getUpperBound(), EPSILON); + + // now replacing the dataset should update the axis range... + DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); + dataset2.setValue(900.0, "Row 1", "Column 1"); + dataset2.setValue(1000.0, "Row 1", "Column 2"); + plot.setDataset(dataset2); + assertEquals(0.0, axis.getLowerBound(), EPSILON); + assertEquals(1050.0, axis.getUpperBound(), EPSILON); + + br.setIncludeBaseInRange(false); + assertEquals(0.0, axis.getLowerBound(), EPSILON); + assertEquals(1050.0, axis.getUpperBound(), EPSILON); + + axis.setAutoRangeIncludesZero(false); + assertEquals(895.0, axis.getLowerBound(), EPSILON); + assertEquals(1005.0, axis.getUpperBound(), EPSILON); + } + + /** + * Checks that the auto-range for the domain axis on an XYPlot is + * working as expected. + */ + @Test + public void testXYAutoRange1() { + XYSeries series = new XYSeries("Series 1"); + series.add(1.0, 1.0); + series.add(2.0, 2.0); + series.add(3.0, 3.0); + XYSeriesCollection dataset = new XYSeriesCollection(); + dataset.addSeries(series); + JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", + dataset); + XYPlot plot = (XYPlot) chart.getPlot(); + NumberAxis axis = (NumberAxis) plot.getDomainAxis(); + axis.setAutoRangeIncludesZero(false); + assertEquals(0.9, axis.getLowerBound(), EPSILON); + assertEquals(3.1, axis.getUpperBound(), EPSILON); + } + + /** + * Checks that the auto-range for the range axis on an XYPlot is + * working as expected. + */ + @Test + public void testXYAutoRange2() { + XYSeries series = new XYSeries("Series 1"); + series.add(1.0, 1.0); + series.add(2.0, 2.0); + series.add(3.0, 3.0); + XYSeriesCollection dataset = new XYSeriesCollection(); + dataset.addSeries(series); + JFreeChart chart = ChartFactory.createScatterPlot("Test", "X", "Y", + dataset); + XYPlot plot = (XYPlot) chart.getPlot(); + NumberAxis axis = (NumberAxis) plot.getRangeAxis(); + axis.setAutoRangeIncludesZero(false); + assertEquals(0.9, axis.getLowerBound(), EPSILON); + assertEquals(3.1, axis.getUpperBound(), EPSILON); + } + +// /** +// * Some checks for the setRangeType() method. +// */ +// public void testSetRangeType() { +// +// NumberAxis axis = new NumberAxis("X"); +// axis.setRangeType(RangeType.POSITIVE); +// assertEquals(RangeType.POSITIVE, axis.getRangeType()); +// +// // test a change to RangeType.POSITIVE +// axis.setRangeType(RangeType.FULL); +// axis.setRange(-5.0, 5.0); +// axis.setRangeType(RangeType.POSITIVE); +// assertEquals(new Range(0.0, 5.0), axis.getRange()); +// +// axis.setRangeType(RangeType.FULL); +// axis.setRange(-10.0, -5.0); +// axis.setRangeType(RangeType.POSITIVE); +// assertEquals(new Range(0.0, axis.getAutoRangeMinimumSize()), +// axis.getRange()); +// +// // test a change to RangeType.NEGATIVE +// axis.setRangeType(RangeType.FULL); +// axis.setRange(-5.0, 5.0); +// axis.setRangeType(RangeType.NEGATIVE); +// assertEquals(new Range(-5.0, 0.0), axis.getRange()); +// +// axis.setRangeType(RangeType.FULL); +// axis.setRange(5.0, 10.0); +// axis.setRangeType(RangeType.NEGATIVE); +// assertEquals(new Range(-axis.getAutoRangeMinimumSize(), 0.0), +// axis.getRange()); +// +// // try null +// boolean pass = false; +// try { +// axis.setRangeType(null); +// } +// catch (IllegalArgumentException e) { +// pass = true; +// } +// assertTrue(pass); +// } + + /** + * Some checks for the setLowerBound() method. + */ + @Test + public void testSetLowerBound() { + NumberAxis axis = new NumberAxis("X"); + axis.setRange(0.0, 10.0); + axis.setLowerBound(5.0); + assertEquals(5.0, axis.getLowerBound(), EPSILON); + axis.setLowerBound(10.0); + assertEquals(10.0, axis.getLowerBound(), EPSILON); + assertEquals(11.0, axis.getUpperBound(), EPSILON); + + //axis.setRangeType(RangeType.POSITIVE); + //axis.setLowerBound(-5.0); + //assertEquals(0.0, axis.getLowerBound(), EPSILON); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/NumberTickUnitTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/NumberTickUnitTest.java new file mode 100755 index 0000000..8ce9ebb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/NumberTickUnitTest.java @@ -0,0 +1,110 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * NumberTickUnitTest.java + * ----------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 5-Jul-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.DecimalFormat; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Some tests for the {@link NumberTickUnit} class. + */ +public class NumberTickUnitTest { + + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); + NumberTickUnit t2 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); + assertTrue(t1.equals(t2)); + assertTrue(t2.equals(t1)); + + t1 = new NumberTickUnit(3.21, new DecimalFormat("0.00")); + assertFalse(t1.equals(t2)); + t2 = new NumberTickUnit(3.21, new DecimalFormat("0.00")); + assertTrue(t1.equals(t2)); + + t1 = new NumberTickUnit(3.21, new DecimalFormat("0.000")); + assertFalse(t1.equals(t2)); + t2 = new NumberTickUnit(3.21, new DecimalFormat("0.000")); + assertTrue(t1.equals(t2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); + NumberTickUnit t2 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); + int h1 = t1.hashCode(); + int h2 = t2.hashCode(); + assertEquals(h1, h2); + } + + /** + * This is an immutable class so it doesn't need to be cloneable. + */ + @Test + public void testCloning() { + NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); + assertFalse(t1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + NumberTickUnit t1 = new NumberTickUnit(1.23, new DecimalFormat("0.00")); + NumberTickUnit t2 = (NumberTickUnit) TestUtilities.serialised(t1); + assertEquals(t1, t2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/PeriodAxisLabelInfoTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/PeriodAxisLabelInfoTest.java new file mode 100755 index 0000000..568bed0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/PeriodAxisLabelInfoTest.java @@ -0,0 +1,199 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * PeriodAxisLabelInfoTest.java + * ---------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-Jun-2003 : Version 1 (DG); + * 07-Jan-2005 : Added test for hashCode() (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.Paint; +import java.awt.Stroke; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.time.Day; +import org.jfree.data.time.Month; +import org.jfree.data.time.Year; +import org.jfree.ui.RectangleInsets; +import org.junit.Test; + +/** + * Tests for the {@link PeriodAxisLabelInfo} class. + */ +public class PeriodAxisLabelInfoTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class, + new SimpleDateFormat("d")); + PeriodAxisLabelInfo info2 = new PeriodAxisLabelInfo(Day.class, + new SimpleDateFormat("d")); + assertTrue(info1.equals(info2)); + assertTrue(info2.equals(info1)); + + Class c1 = Day.class; + Class c2 = Month.class; + DateFormat df1 = new SimpleDateFormat("d"); + DateFormat df2 = new SimpleDateFormat("MMM"); + RectangleInsets sp1 = new RectangleInsets(1, 1, 1, 1); + RectangleInsets sp2 = new RectangleInsets(2, 2, 2, 2); + Font lf1 = new Font("SansSerif", Font.PLAIN, 10); + Font lf2 = new Font("SansSerif", Font.BOLD, 9); + Paint lp1 = Color.black; + Paint lp2 = Color.blue; + boolean b1 = true; + boolean b2 = false; + Stroke s1 = new BasicStroke(0.5f); + Stroke s2 = new BasicStroke(0.25f); + Paint dp1 = Color.red; + Paint dp2 = Color.green; + + info1 = new PeriodAxisLabelInfo(c2, df1, sp1, lf1, lp1, b1, s1, dp1); + info2 = new PeriodAxisLabelInfo(c1, df1, sp1, lf1, lp1, b1, s1, dp1); + assertFalse(info1.equals(info2)); + info2 = new PeriodAxisLabelInfo(c2, df1, sp1, lf1, lp1, b1, s1, dp1); + assertTrue(info1.equals(info2)); + + info1 = new PeriodAxisLabelInfo(c2, df2, sp1, lf1, lp1, b1, s1, dp1); + assertFalse(info1.equals(info2)); + info2 = new PeriodAxisLabelInfo(c2, df2, sp1, lf1, lp1, b1, s1, dp1); + assertTrue(info1.equals(info2)); + + info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf1, lp1, b1, s1, dp1); + assertFalse(info1.equals(info2)); + info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf1, lp1, b1, s1, dp1); + assertTrue(info1.equals(info2)); + + info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp1, b1, s1, dp1); + assertFalse(info1.equals(info2)); + info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp1, b1, s1, dp1); + assertTrue(info1.equals(info2)); + + info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b1, s1, dp1); + assertFalse(info1.equals(info2)); + info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b1, s1, dp1); + assertTrue(info1.equals(info2)); + + info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s1, dp1); + assertFalse(info1.equals(info2)); + info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s1, dp1); + assertTrue(info1.equals(info2)); + + info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp1); + assertFalse(info1.equals(info2)); + info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp1); + assertTrue(info1.equals(info2)); + + info1 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp2); + assertFalse(info1.equals(info2)); + info2 = new PeriodAxisLabelInfo(c2, df2, sp2, lf2, lp2, b2, s2, dp2); + assertTrue(info1.equals(info2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class, + new SimpleDateFormat("d")); + PeriodAxisLabelInfo info2 = new PeriodAxisLabelInfo(Day.class, + new SimpleDateFormat("d")); + assertTrue(info1.equals(info2)); + int h1 = info1.hashCode(); + int h2 = info2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class, + new SimpleDateFormat("d")); + PeriodAxisLabelInfo info2 = (PeriodAxisLabelInfo) info1.clone(); + assertTrue(info1 != info2); + assertTrue(info1.getClass() == info2.getClass()); + assertTrue(info1.equals(info2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PeriodAxisLabelInfo info1 = new PeriodAxisLabelInfo(Day.class, + new SimpleDateFormat("d")); + PeriodAxisLabelInfo info2 = (PeriodAxisLabelInfo) TestUtilities.serialised(info1); + assertEquals(info1, info2); + } + + /** + * A test for the createInstance() method. + */ + @Test + public void testCreateInstance() { + TimeZone zone = TimeZone.getTimeZone("GMT"); + PeriodAxisLabelInfo info = new PeriodAxisLabelInfo(Day.class, + new SimpleDateFormat("d")); + Day d = (Day) info.createInstance(new Date(0L), zone, Locale.UK); + assertEquals(new Day(1, 1, 1970), d); + + info = new PeriodAxisLabelInfo(Year.class, new SimpleDateFormat("YYYY")); + Year y = (Year) info.createInstance(new Date(0L), zone, Locale.UK); + assertEquals(new Year(1970), y); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/PeriodAxisTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/PeriodAxisTest.java new file mode 100755 index 0000000..35d4b7f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/PeriodAxisTest.java @@ -0,0 +1,299 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * PeriodAxisTest.java + * ------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-Jun-2003 : Version 1 (DG); + * 07-Jan-2005 : Added test for hashCode() method (DG); + * 08-Apr-2008 : Added test1932146() (DG); + * 16-Jan-2009 : Added test2490803() (DG); + * 02-Mar-2009 : Added testEqualsWithLocale (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Stroke; +import java.text.SimpleDateFormat; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.SimpleTimeZone; +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.event.AxisChangeEvent; +import org.jfree.chart.event.AxisChangeListener; +import org.jfree.data.Range; +import org.jfree.data.time.DateRange; +import org.jfree.data.time.Day; +import org.jfree.data.time.Minute; +import org.jfree.data.time.Month; +import org.jfree.data.time.Quarter; +import org.jfree.data.time.Second; +import org.jfree.data.time.Year; +import org.junit.Test; + +/** + * Tests for the {@link PeriodAxis} class. + */ +public class PeriodAxisTest implements AxisChangeListener { + + /** The last event received. */ + private AxisChangeEvent lastEvent; + + /** + * Receives and records an {@link AxisChangeEvent}. + * + * @param event the event. + */ + @Override + public void axisChanged(AxisChangeEvent event) { + this.lastEvent = event; + } + + /** + * Confirm that the equals() method can distinguish all the required fields. + */ + @Test + public void testEquals() { + PeriodAxis a1 = new PeriodAxis("Test"); + PeriodAxis a2 = new PeriodAxis("Test"); + assertTrue(a1.equals(a2)); + assertTrue(a2.equals(a1)); + + a1.setFirst(new Year(2000)); + assertFalse(a1.equals(a2)); + a2.setFirst(new Year(2000)); + assertTrue(a1.equals(a2)); + + a1.setLast(new Year(2004)); + assertFalse(a1.equals(a2)); + a2.setLast(new Year(2004)); + assertTrue(a1.equals(a2)); + + a1.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); + assertFalse(a1.equals(a2)); + a2.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); + assertTrue(a1.equals(a2)); + + a1.setAutoRangeTimePeriodClass(Quarter.class); + assertFalse(a1.equals(a2)); + a2.setAutoRangeTimePeriodClass(Quarter.class); + assertTrue(a1.equals(a2)); + + PeriodAxisLabelInfo info[] = new PeriodAxisLabelInfo[1]; + info[0] = new PeriodAxisLabelInfo(Month.class, + new SimpleDateFormat("MMM")); + + a1.setLabelInfo(info); + assertFalse(a1.equals(a2)); + a2.setLabelInfo(info); + assertTrue(a1.equals(a2)); + + a1.setMajorTickTimePeriodClass(Minute.class); + assertFalse(a1.equals(a2)); + a2.setMajorTickTimePeriodClass(Minute.class); + assertTrue(a1.equals(a2)); + + a1.setMinorTickMarksVisible(!a1.isMinorTickMarksVisible()); + assertFalse(a1.equals(a2)); + a2.setMinorTickMarksVisible(a1.isMinorTickMarksVisible()); + assertTrue(a1.equals(a2)); + + a1.setMinorTickTimePeriodClass(Minute.class); + assertFalse(a1.equals(a2)); + a2.setMinorTickTimePeriodClass(Minute.class); + assertTrue(a1.equals(a2)); + + Stroke s = new BasicStroke(1.23f); + a1.setMinorTickMarkStroke(s); + assertFalse(a1.equals(a2)); + a2.setMinorTickMarkStroke(s); + assertTrue(a1.equals(a2)); + + a1.setMinorTickMarkPaint(Color.blue); + assertFalse(a1.equals(a2)); + a2.setMinorTickMarkPaint(Color.blue); + assertTrue(a1.equals(a2)); + } + + /** + * Confirm that the equals() method can distinguish the locale field (which + * is new in version 1.0.13). + */ + @Test + public void testEqualsWithLocale() { + PeriodAxis a1 = new PeriodAxis("Test", new Year(2000), new Year(2009), + TimeZone.getDefault(), Locale.JAPAN); + PeriodAxis a2 = new PeriodAxis("Test", new Year(2000), new Year(2009), + TimeZone.getDefault(), Locale.JAPAN); + assertTrue(a1.equals(a2)); + assertTrue(a2.equals(a1)); + + a1 = new PeriodAxis("Test", new Year(2000), new Year(2009), + TimeZone.getDefault(), Locale.UK); + assertFalse(a1.equals(a2)); + a2 = new PeriodAxis("Test", new Year(2000), new Year(2009), + TimeZone.getDefault(), Locale.UK); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + PeriodAxis a1 = new PeriodAxis("Test"); + PeriodAxis a2 = new PeriodAxis("Test"); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + PeriodAxis a1 = new PeriodAxis("Test"); + PeriodAxis a2 = (PeriodAxis) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + + // some checks that the clone is independent of the original + a1.setLabel("New Label"); + assertFalse(a1.equals(a2)); + a2.setLabel("New Label"); + assertTrue(a1.equals(a2)); + + a1.setFirst(new Year(1920)); + assertFalse(a1.equals(a2)); + a2.setFirst(new Year(1920)); + assertTrue(a1.equals(a2)); + + a1.setLast(new Year(2020)); + assertFalse(a1.equals(a2)); + a2.setLast(new Year(2020)); + assertTrue(a1.equals(a2)); + + PeriodAxisLabelInfo[] info = new PeriodAxisLabelInfo[2]; + info[0] = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); + info[1] = new PeriodAxisLabelInfo(Year.class, + new SimpleDateFormat("yyyy")); + a1.setLabelInfo(info); + assertFalse(a1.equals(a2)); + a2.setLabelInfo(info); + assertTrue(a1.equals(a2)); + + a1.setAutoRangeTimePeriodClass(Second.class); + assertFalse(a1.equals(a2)); + a2.setAutoRangeTimePeriodClass(Second.class); + assertTrue(a1.equals(a2)); + + a1.setTimeZone(new SimpleTimeZone(123, "Bogus")); + assertFalse(a1.equals(a2)); + a2.setTimeZone(new SimpleTimeZone(123, "Bogus")); + assertTrue(a1.equals(a2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PeriodAxis a1 = new PeriodAxis("Test Axis"); + PeriodAxis a2 = (PeriodAxis) TestUtilities.serialised(a1); + boolean b = a1.equals(a2); + assertTrue(b); + } + + /** + * A test for bug 1932146. + */ + @Test + public void test1932146() { + PeriodAxis axis = new PeriodAxis("TestAxis"); + axis.addChangeListener(this); + this.lastEvent = null; + axis.setRange(new DateRange(0L, 1000L)); + assertTrue(this.lastEvent != null); + } + + private static final double EPSILON = 0.0000000001; + + /** + * A test for the setRange() method (because the axis shows whole time + * periods, the range set for the axis will most likely be wider than the + * one specified). + */ + @Test + public void test2490803() { + Locale savedLocale = Locale.getDefault(); + TimeZone savedTimeZone = TimeZone.getDefault(); + try { + Locale.setDefault(Locale.FRANCE); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/Paris")); + GregorianCalendar c0 = new GregorianCalendar(); + c0.clear(); + /* c0.set(2009, Calendar.JANUARY, 16, 12, 34, 56); + System.out.println(c0.getTime().getTime()); + c0.clear(); + c0.set(2009, Calendar.JANUARY, 17, 12, 34, 56); + System.out.println(c0.getTime().getTime()); */ + PeriodAxis axis = new PeriodAxis("TestAxis"); + axis.setRange(new Range(1232105696000L, 1232192096000L), false, + false); + Range r = axis.getRange(); + Day d0 = new Day(16, 1, 2009); + Day d1 = new Day(17, 1, 2009); + assertEquals(d0.getFirstMillisecond(), r.getLowerBound(), EPSILON); + assertEquals(d1.getLastMillisecond() + 1.0, r.getUpperBound(), + EPSILON); + } + finally { + TimeZone.setDefault(savedTimeZone); + Locale.setDefault(savedLocale); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/QuarterDateFormatTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/QuarterDateFormatTest.java new file mode 100755 index 0000000..896967b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/QuarterDateFormatTest.java @@ -0,0 +1,132 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * QuarterDateFormatTest.java + * -------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-May-2005 : Version 1 (DG); + * 08-Jun-2007 : Added check for new field in testEquals() (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link QuarterDateFormat} class. + */ +public class QuarterDateFormatTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + QuarterDateFormat qf1 = new QuarterDateFormat(TimeZone.getTimeZone( + "GMT"), new String[] {"1", "2", "3", "4"}); + QuarterDateFormat qf2 = new QuarterDateFormat(TimeZone.getTimeZone( + "GMT"), new String[] {"1", "2", "3", "4"}); + assertTrue(qf1.equals(qf2)); + assertTrue(qf2.equals(qf1)); + + qf1 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), + new String[] {"1", "2", "3", "4"}); + assertFalse(qf1.equals(qf2)); + qf2 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), + new String[] {"1", "2", "3", "4"}); + assertTrue(qf1.equals(qf2)); + + qf1 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), + new String[] {"A", "2", "3", "4"}); + assertFalse(qf1.equals(qf2)); + qf2 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), + new String[] {"A", "2", "3", "4"}); + assertTrue(qf1.equals(qf2)); + + qf1 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), + new String[] {"A", "2", "3", "4"}, true); + assertFalse(qf1.equals(qf2)); + qf2 = new QuarterDateFormat(TimeZone.getTimeZone("PST"), + new String[] {"A", "2", "3", "4"}, true); + assertTrue(qf1.equals(qf2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + QuarterDateFormat qf1 = new QuarterDateFormat(TimeZone.getTimeZone( + "GMT"), new String[] {"1", "2", "3", "4"}); + QuarterDateFormat qf2 = new QuarterDateFormat(TimeZone.getTimeZone( + "GMT"), new String[] {"1", "2", "3", "4"}); + assertTrue(qf1.equals(qf2)); + int h1 = qf1.hashCode(); + int h2 = qf2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() { + QuarterDateFormat qf1 = new QuarterDateFormat(TimeZone.getTimeZone( + "GMT"), new String[] {"1", "2", "3", "4"}); + QuarterDateFormat qf2 = null; + qf2 = (QuarterDateFormat) qf1.clone(); + assertTrue(qf1 != qf2); + assertTrue(qf1.getClass() == qf2.getClass()); + assertTrue(qf1.equals(qf2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + QuarterDateFormat qf1 = new QuarterDateFormat(TimeZone.getTimeZone( + "GMT"), new String[] {"1", "2", "3", "4"}); + QuarterDateFormat qf2 = (QuarterDateFormat) TestUtilities.serialised(qf1); + assertEquals(qf1, qf2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/SegmentedTimelineAdditionalTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/SegmentedTimelineAdditionalTest.java new file mode 100755 index 0000000..8fb73c5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/SegmentedTimelineAdditionalTest.java @@ -0,0 +1,445 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * SegmentedTimelineTest2.java + * --------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 02-Aug-2004 : Added standard header (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertTrue; + +import java.util.Calendar; +import java.util.Date; +import java.util.Locale; +import java.util.TimeZone; +import org.junit.Test; + +/** + * Some tests for the {@link SegmentedTimeline} class. + */ +public class SegmentedTimelineAdditionalTest { + + /** + * Constructor + */ + public SegmentedTimelineAdditionalTest() { + super(); + } + + /** + * Test 1 checks 9am Friday 26 March 2004 converts to a timeline value and + * back again correctly. This is prior to Daylight Saving. + */ + @Test + public void test1() { + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Locale savedLocale = Locale.getDefault(); + Locale.setDefault(Locale.UK); + Calendar cal = Calendar.getInstance(Locale.UK); + cal.set(Calendar.YEAR, 2004); + cal.set(Calendar.MONTH, Calendar.MARCH); + cal.set(Calendar.DAY_OF_MONTH, 26); + cal.set(Calendar.HOUR_OF_DAY, 9); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + Date date = cal.getTime(); + + SegmentedTimeline timeline = getTimeline(); + long value = timeline.toTimelineValue(date); + long ms = timeline.toMillisecond(value); + Calendar cal2 = Calendar.getInstance(Locale.UK); + cal2.setTime(new Date(ms)); + Date reverted = cal2.getTime(); + assertTrue("test1", value == (900000 * 34) + && date.getTime() == reverted.getTime()); + TimeZone.setDefault(savedZone); + Locale.setDefault(savedLocale); + } + + /** + * Test 2 checks 9.15am Friday 26 March 2004 converts to a timeline value + * and back again correctly. This is prior to Daylight Saving. + */ + @Test + public void test2() { + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Calendar cal = Calendar.getInstance(Locale.UK); + cal.set(Calendar.YEAR, 2004); + cal.set(Calendar.MONTH, Calendar.MARCH); + cal.set(Calendar.DAY_OF_MONTH, 26); + cal.set(Calendar.HOUR_OF_DAY, 9); + cal.set(Calendar.MINUTE, 15); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + Date date = cal.getTime(); + + SegmentedTimeline timeline = getTimeline(); + + long value = timeline.toTimelineValue(date); + long ms = timeline.toMillisecond(value); + Calendar cal2 = Calendar.getInstance(Locale.UK); + cal2.setTime(new Date(ms)); + Date reverted = cal2.getTime(); + assertTrue("test2", value == (900000 * 34 + 900000) + && date.getTime() == reverted.getTime()); + TimeZone.setDefault(savedZone); + } + + /** + * Test 3 checks 9.30am Friday 26 March 2004 converts to a timeline value + * and back again correctly. This is prior to Daylight Saving. + */ + @Test + public void test3() { + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Calendar cal = Calendar.getInstance(Locale.UK); + cal.set(Calendar.YEAR, 2004); + cal.set(Calendar.MONTH, Calendar.MARCH); + cal.set(Calendar.DAY_OF_MONTH, 26); + cal.set(Calendar.HOUR_OF_DAY, 9); + cal.set(Calendar.MINUTE, 30); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + Date date = cal.getTime(); + SegmentedTimeline timeline = getTimeline(); + + long value = timeline.toTimelineValue(date); + long ms = timeline.toMillisecond(value); + + Calendar cal2 = Calendar.getInstance(Locale.UK); + cal2.setTime(new Date(ms)); + Date reverted = cal2.getTime(); + assertTrue("test3", value == (900000 * 34 + 900000 * 2) + && date.getTime() == reverted.getTime()); + TimeZone.setDefault(savedZone); + } + + /** + * Test 4 checks 9.30am Friday 26 March 2004 (+ 1 millisecond) converts to + * a timeline value and back again correctly. This is prior to Daylight + * Saving. + */ + @Test + public void test4() { + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Calendar cal = Calendar.getInstance(Locale.UK); + cal.set(Calendar.YEAR, 2004); + cal.set(Calendar.MONTH, Calendar.MARCH); + cal.set(Calendar.DAY_OF_MONTH, 26); + cal.set(Calendar.HOUR_OF_DAY, 9); + cal.set(Calendar.MINUTE, 30); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 1); + Date date = cal.getTime(); + SegmentedTimeline timeline = getTimeline(); + + long value = timeline.toTimelineValue(date); + long ms = timeline.toMillisecond(value); + Calendar cal2 = Calendar.getInstance(Locale.UK); + cal2.setTime(new Date(ms)); + Date reverted = cal2.getTime(); + assertTrue("test4", value == (900000 * 34 + 900000 * 2 + 1) + && date.getTime() == reverted.getTime()); + TimeZone.setDefault(savedZone); + } + + /** + * Test 5 checks 5.30pm Thursday 25 March 2004 converts to a timeline + * value and back again correctly. As it is in the excluded segment, we + * expect it to map to 9am, Friday 26 March 2004. This is prior to + * Daylight Saving. + */ + @Test + public void test5() { + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Calendar cal = Calendar.getInstance(Locale.UK); + cal.set(Calendar.YEAR, 2004); + cal.set(Calendar.MONTH, Calendar.MARCH); + cal.set(Calendar.DAY_OF_MONTH, 25); + cal.set(Calendar.HOUR_OF_DAY, 17); + cal.set(Calendar.MINUTE, 30); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + Date date = cal.getTime(); + SegmentedTimeline timeline = getTimeline(); + + long value = timeline.toTimelineValue(date); + long ms = timeline.toMillisecond(value); + Calendar cal2 = Calendar.getInstance(Locale.UK); + cal2.setTime(new Date(ms)); + Date reverted = cal2.getTime(); + Calendar expectedReverted = Calendar.getInstance(Locale.UK); + expectedReverted.set(Calendar.YEAR, 2004); + expectedReverted.set(Calendar.MONTH, Calendar.MARCH); + expectedReverted.set(Calendar.DAY_OF_MONTH, 26); + expectedReverted.set(Calendar.HOUR_OF_DAY, 9); + expectedReverted.set(Calendar.MINUTE, 0); + expectedReverted.set(Calendar.SECOND, 0); + expectedReverted.set(Calendar.MILLISECOND, 0); + + assertTrue("test5", value == (900000 * 34) + && expectedReverted.getTime().getTime() == reverted.getTime()); + TimeZone.setDefault(savedZone); + } + + /** + * Test 6 checks that 9am on Sunday 28 March 2004 converts to the timeline + * value and back again correctly. Note that Saturday and Sunday are + * excluded from the timeline, so we expect the value to map to 9am on + * Monday 29 March 2004. This is during daylight saving. + */ + @Test + public void test6() { + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Calendar cal = Calendar.getInstance(Locale.UK); + cal.set(Calendar.YEAR, 2004); + cal.set(Calendar.MONTH, Calendar.MARCH); + cal.set(Calendar.DAY_OF_MONTH, 28); + cal.set(Calendar.HOUR_OF_DAY, 9); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + Date date = cal.getTime(); + SegmentedTimeline timeline = getTimeline(); + + long value = timeline.toTimelineValue(date); + long ms = timeline.toMillisecond(value); + Calendar cal2 = Calendar.getInstance(Locale.UK); + cal2.setTime(new Date(ms)); + Date reverted = cal2.getTime(); + + Calendar expectedReverted = Calendar.getInstance(Locale.UK); + expectedReverted.set(Calendar.YEAR, 2004); + expectedReverted.set(Calendar.MONTH, Calendar.MARCH); + expectedReverted.set(Calendar.DAY_OF_MONTH, 29); + expectedReverted.set(Calendar.HOUR_OF_DAY, 9); + expectedReverted.set(Calendar.MINUTE, 0); + expectedReverted.set(Calendar.SECOND, 0); + expectedReverted.set(Calendar.MILLISECOND, 0); + + assertTrue("test6", value == (900000 * 34 * 2) + && expectedReverted.getTime().getTime() == reverted.getTime()); + TimeZone.setDefault(savedZone); + } + + /** + * Test 7 checks 9am Monday 29 March 2004 converts to a timeline value and + * back again correctly. This is during Daylight Saving. + */ + @Test + public void test7() { + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Calendar cal = Calendar.getInstance(Locale.UK); + cal.set(Calendar.YEAR, 2004); + cal.set(Calendar.MONTH, Calendar.MARCH); + cal.set(Calendar.DAY_OF_MONTH, 29); + cal.set(Calendar.HOUR_OF_DAY, 9); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + Date date = cal.getTime(); + + SegmentedTimeline timeline = getTimeline(); + long value = timeline.toTimelineValue(date); + long ms = timeline.toMillisecond(value); + + Calendar cal2 = Calendar.getInstance(Locale.UK); + cal2.setTime(new Date(ms)); + Date reverted = cal2.getTime(); + + Calendar expectedReverted = Calendar.getInstance(); + expectedReverted.set(Calendar.YEAR, 2004); + expectedReverted.set(Calendar.MONTH, Calendar.MARCH); + expectedReverted.set(Calendar.DAY_OF_MONTH, 29); + expectedReverted.set(Calendar.HOUR_OF_DAY, 9); + expectedReverted.set(Calendar.MINUTE, 0); + expectedReverted.set(Calendar.SECOND, 0); + expectedReverted.set(Calendar.MILLISECOND, 0); + + assertTrue("test7", value == (900000 * 34 * 2) + && expectedReverted.getTime().getTime() == reverted.getTime()); + TimeZone.setDefault(savedZone); + } + + /** + * Test 8. + */ + @Test + public void test8() { + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Calendar cal = Calendar.getInstance(Locale.UK); + cal.set(Calendar.YEAR, 2004); + cal.set(Calendar.MONTH, Calendar.MARCH); + cal.set(Calendar.DAY_OF_MONTH, 29); + cal.set(Calendar.HOUR_OF_DAY, 10); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + Date date = cal.getTime(); + + SegmentedTimeline timeline = getTimeline(); + + // Add exception in included segments + cal.set(Calendar.YEAR, 2004); + cal.set(Calendar.MONTH, Calendar.MARCH); + cal.set(Calendar.DAY_OF_MONTH, 29); + cal.set(Calendar.HOUR_OF_DAY, 9); + cal.set(Calendar.MINUTE, 15); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + timeline.addException(cal.getTime()); + + long value = timeline.toTimelineValue(date); + long ms = timeline.toMillisecond(value); + + Calendar cal2 = Calendar.getInstance(Locale.UK); + cal2.setTime(new Date(ms)); + Date reverted = cal2.getTime(); + + Calendar expectedReverted = Calendar.getInstance(); + expectedReverted.set(Calendar.YEAR, 2004); + expectedReverted.set(Calendar.MONTH, Calendar.MARCH); + expectedReverted.set(Calendar.DAY_OF_MONTH, 29); + expectedReverted.set(Calendar.HOUR_OF_DAY, 10); + expectedReverted.set(Calendar.MINUTE, 0); + expectedReverted.set(Calendar.SECOND, 0); + expectedReverted.set(Calendar.MILLISECOND, 0); + + assertTrue("test8", value == (900000 * 34 * 2 + 900000 * (4 - 1)) + && expectedReverted.getTime().getTime() == reverted.getTime()); + TimeZone.setDefault(savedZone); + } + + /** + * Creates a timeline from 9am on Thursday 25 March 2004 to 5pm on + * Tuesday 30 March 2004, for the UK locale. + * + * @return A timeline. + */ + private SegmentedTimeline getTimeline() { + Calendar cal = Calendar.getInstance(Locale.UK); + cal.set(Calendar.YEAR, 2004); + cal.set(Calendar.MONTH, Calendar.MARCH); + cal.set(Calendar.DAY_OF_MONTH, 25); + cal.set(Calendar.HOUR_OF_DAY, 9); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + Date from = cal.getTime(); + + cal = Calendar.getInstance(Locale.UK); + cal.set(Calendar.YEAR, 2004); + cal.set(Calendar.MONTH, Calendar.MARCH); + cal.set(Calendar.DAY_OF_MONTH, 30); + cal.set(Calendar.HOUR_OF_DAY, 17); + cal.set(Calendar.MINUTE, 30); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + Date to = cal.getTime(); + + return getTimeline(from, to); + } + + /** + * Returns a segmented timeline for 15 minute segments, Monday to Friday + * only, between 9am and 5pm. The UK locale is used. + * + * @param start the start date. + * @param end the end date. + * + * @return The timeline. + */ + private SegmentedTimeline getTimeline(Date start, Date end) { + + Calendar cal = Calendar.getInstance(Locale.UK); + cal.set(Calendar.YEAR, 1970); + cal.set(Calendar.MONTH, Calendar.JANUARY); + cal.set(Calendar.DAY_OF_MONTH, 1); + cal.set(Calendar.HOUR_OF_DAY, 9); + cal.set(Calendar.MINUTE, 0); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + Date open = cal.getTime(); + + cal = Calendar.getInstance(Locale.UK); + cal.set(Calendar.YEAR, 1970); + cal.set(Calendar.MONTH, Calendar.JANUARY); + cal.set(Calendar.DAY_OF_MONTH, 1); + cal.set(Calendar.HOUR_OF_DAY, 17); + cal.set(Calendar.MINUTE, 30); + cal.set(Calendar.SECOND, 0); + cal.set(Calendar.MILLISECOND, 0); + Date close = cal.getTime(); + + SegmentedTimeline result = null; + // Create a segmented time line (segment size : 15 minutes) + long quarterHourCount = (close.getTime() - open.getTime()) + / SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE; + long totalQuarterHourCount = SegmentedTimeline.DAY_SEGMENT_SIZE + / SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE; + result = new SegmentedTimeline( + SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE, + (int) quarterHourCount, + (int) (totalQuarterHourCount - quarterHourCount) + ); + result.setAdjustForDaylightSaving(true); + // Set start time + result.setStartTime(start.getTime()); + // Saturday and Sundays are non business hours + result.setBaseTimeline( + SegmentedTimeline.newMondayThroughFridayTimeline() + ); + /* PUT exclusions in test */ + if (start != null && end != null) { + result.addBaseTimelineExclusions(start.getTime(), end.getTime()); + } + + return result; + } + + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/SegmentedTimelineTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/SegmentedTimelineTest.java new file mode 100755 index 0000000..42bd568 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/SegmentedTimelineTest.java @@ -0,0 +1,1107 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * SegmentedTimelineTest.java + * --------------------------- + * (C) Copyright 2003-2013, by Bill Kelemen and Contributors. + * + * Original Author: Bill Kelemen; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 24-May-2003 : Version 1 (BK); + * 07-Jan-2005 : Added test for hashCode() method (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.Format; +import java.text.NumberFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Calendar; +import java.util.GregorianCalendar; +import java.util.Iterator; + +import org.jfree.chart.TestUtilities; +import org.junit.Before; +import org.junit.Ignore; +import org.junit.Test; + +/** + * JUnit Tests for the {@link SegmentedTimeline} class. + */ +public class SegmentedTimelineTest { + + /** These constants control test cycles in the validateXXXX methods. */ + private static final int TEST_CYCLE_START = 0; + + /** These constants control test cycles in the validateXXXX methods. */ + private static final int TEST_CYCLE_END = 1000; + + /** These constants control test cycles in the validateXXXX methods. */ + private static final int TEST_CYCLE_INC = 55; + + /** Number of ms in five years */ + private static final long FIVE_YEARS = 5 * 365 + * SegmentedTimeline.DAY_SEGMENT_SIZE; + + /** Number format object for ms tests. */ + private static final NumberFormat NUMBER_FORMAT + = NumberFormat.getNumberInstance(); + + /** Date format object for Monday through Friday tests. */ + private static final SimpleDateFormat DATE_FORMAT; + + /** Date format object 9:00 AM to 4:00 PM tests. */ + private static final SimpleDateFormat DATE_TIME_FORMAT; + + /** Some ms exceptions for ms testing. */ + private static final String[] MS_EXCEPTIONS = {"0", "2", "4", "10", "15", + "16", "17", "18", "19", "20", "21", "22", "23", "24", "47", "58", + "100", "101"}; + + /** Some ms4 exceptions for ms testing. */ + private static final String[] MS2_BASE_TIMELINE_EXCEPTIONS = {"0", "8", + "16", "24", "32", "40", "48", "56", "64", "72", "80", "88", "96", + "104", "112", "120", "128", "136"}; + + /** US non-trading dates in 2000 through 2002 to test exceptions. */ + private static final String[] US_HOLIDAYS = {"2000-01-17", "2000-02-21", + "2000-04-21", "2000-05-29", "2000-07-04", "2000-09-04", "2000-11-23", + "2000-12-25", "2001-01-01", "2001-01-15", "2001-02-19", "2001-04-13", + "2001-05-28", "2001-07-04", "2001-09-03", "2001-09-11", "2001-09-12", + "2001-09-13", "2001-09-14", "2001-11-22", "2001-12-25", "2002-01-01", + "2002-01-21", "2002-02-18", "2002-03-29", "2002-05-27", "2002-07-04", + "2002-09-02", "2002-11-28", "2002-12-25"}; + + /** Some test exceptions for the fifteen min timeline. */ + private static final String[] FIFTEEN_MIN_EXCEPTIONS = { + "2000-01-10 09:00:00", "2000-01-10 09:15:00", "2000-01-10 09:30:00", + "2000-01-10 09:45:00", "2000-01-10 10:00:00", "2000-01-10 10:15:00", + "2000-02-15 09:00:00", "2000-02-15 09:15:00", "2000-02-15 09:30:00", + "2000-02-15 09:45:00", "2000-02-15 10:00:00", "2000-02-15 10:15:00", + "2000-02-16 11:00:00", "2000-02-16 11:15:00", "2000-02-16 11:30:00", + "2000-02-16 11:45:00", "2000-02-16 12:00:00", "2000-02-16 12:15:00", + "2000-02-16 12:30:00", "2000-02-16 12:45:00", "2000-02-16 01:00:00", + "2000-02-16 01:15:00", "2000-02-16 01:30:00", "2000-02-16 01:45:00", + "2000-05-17 11:45:00", "2000-05-17 12:00:00", "2000-05-17 12:15:00", + "2000-05-17 12:30:00", "2000-05-17 12:45:00", "2000-05-17 01:00:00", + "2000-05-17 01:15:00", "2000-05-17 01:30:00", "2000-05-17 01:45:00", + "2000-05-17 02:00:00", "2000-05-17 02:15:00", "2000-05-17 02:30:00", + "2000-05-17 02:45:00", "2000-05-17 03:00:00", "2000-05-17 03:15:00", + "2000-05-17 03:30:00", "2000-05-17 03:45:00", "2000-05-17 04:00:00"}; + + /** Our 1-ms test timeline using 5 included and 2 excluded segments. */ + private SegmentedTimeline msTimeline; + + /** + * Our 1-ms test timeline (with baseTimeline) using 2 included and 2 + * excluded segments. + */ + private SegmentedTimeline ms2Timeline; + + /** + * Our 4-ms test base timeline for ms2Timeline using 1 included and 1 + * excluded segments + */ + private SegmentedTimeline ms2BaseTimeline; + + /** Our test Monday through Friday test timeline. */ + private SegmentedTimeline mondayFridayTimeline; + + /** Our 9:00 AM to 4:00 PM fifteen minute timeline. */ + private SegmentedTimeline fifteenMinTimeline; + + /** ms from 1970-01-01 to first monday after 2001-01-01. */ + private Calendar monday; + + /** ms from 1970-01-01 to 9 am first monday after 2001-01-01. */ + private Calendar monday9am; + + /** Static initialization block. */ + static { + DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd"); + DATE_FORMAT.setTimeZone(SegmentedTimeline.NO_DST_TIME_ZONE); + + DATE_TIME_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + DATE_TIME_FORMAT.setTimeZone(SegmentedTimeline.NO_DST_TIME_ZONE); + } + + /** + * Sets up the fixture, for example, open a network connection. + * This method is called before a test is executed. + * + * @throws Exception if there is a problem. + */ + @Before + public void setUp() throws Exception { + // setup our test timelines + // + // Legend for comments below: + // = Segments included in the final timeline + // EE = Excluded segments via timeline rules + // xx = Exception segments inherited from base timeline exclusions + + // 1-ms test timeline using 5 included and 2 excluded segments. + // + // timeline start time = 0 + // | + // v + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 .. + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+.. + // | | | | | |EE|EE| | | | | |EE|EE| | | | | | |EE|EE| <-- msTimeline + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+.. + // \_________ ________/ \_/ + // \/ | + // segment group segment size = 1 ms + // + this.msTimeline = new SegmentedTimeline(1, 5, 2); + this.msTimeline.setStartTime(0); + + // 4-ms test base timeline for ms2Timeline using 1 included and 1 + // excluded segments + // + // timeline start time = 0 + // | + // v + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+... + // | | | | |EE|EE|EE|EE| | | | |EE|EE|EE|EE| | | | | <-- ms2BaseTimeline + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+... + // \__________ _________/ \____ _____/ + // \/ \/ + // segment group segment size = 4 ms + // + this.ms2BaseTimeline = new SegmentedTimeline(4, 1, 1); + this.ms2BaseTimeline.setStartTime(0); + + // 1-ms test timeline (with a baseTimeline) using 2 included and 2 + // excluded segments centered inside each base segment + // + // The ms2Timeline without a base would look like this: + // + // timeline start time = 1 + // | + // v + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+... + // |EE| | |EE|EE| | |EE|EE| | |EE|EE| | |EE|EE| | |EE| <-- ms2Timeline + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+... + // \____ _____/ \_/ + // \/ | + // segment group segment size = 1 ms + // + // With the base timeline some originally included segments are now + // removed (see "xx" below): + // + // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ... + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+... + // |EE| | |EE|EE|xx|xx|EE|EE| | |EE|EE|xx|xx|EE|EE| | |EE| <-- ms2Timeline + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+... + // | | | | |EE|EE|EE|EE| | | | |EE|EE|EE|EE| | | | | <-- ms2BaseTimeline + // +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+... + // + this.ms2Timeline = new SegmentedTimeline(1, 2, 2); + this.ms2Timeline.setStartTime(1); + this.ms2Timeline.setBaseTimeline(this.ms2BaseTimeline); + + // test monday though friday timeline + this.mondayFridayTimeline + = SegmentedTimeline.newMondayThroughFridayTimeline(); + + // test 9am-4pm Monday through Friday timeline + this.fifteenMinTimeline + = SegmentedTimeline.newFifteenMinuteTimeline(); + + // find first Monday after 2001-01-01 + Calendar cal = new GregorianCalendar( + SegmentedTimeline.NO_DST_TIME_ZONE); + cal.set(2001, 0, 1, 0, 0, 0); + cal.set(Calendar.MILLISECOND, 0); + while (cal.get(Calendar.DAY_OF_WEEK) != Calendar.MONDAY) { + cal.add(Calendar.DATE, 1); + } + this.monday = (Calendar) cal.clone(); + + // calculate 9am on the first Monday after 2001-01-01 + cal.add(Calendar.HOUR, 9); + this.monday9am = (Calendar) cal.clone(); + } + + ////////////////////////////////////////////////////////////////////////// + // test construction process + ////////////////////////////////////////////////////////////////////////// + + /** + * Tests that the new method that created the msTimeline segmented + * timeline did so correctly. + */ + @Test + public void testMsSegmentedTimeline() { + // verify attributes set during object construction + assertEquals(1, this.msTimeline.getSegmentSize()); + assertEquals(0, this.msTimeline.getStartTime()); + assertEquals(5, this.msTimeline.getSegmentsIncluded()); + assertEquals(2, this.msTimeline.getSegmentsExcluded()); + } + + /** + * Tests that the new method that created the ms2Timeline segmented + * timeline did so correctly. + */ + @Test + public void testMs2SegmentedTimeline() { + // verify attributes set during object construction + assertEquals(1, this.ms2Timeline.getSegmentSize()); + assertEquals(1, this.ms2Timeline.getStartTime()); + assertEquals(2, this.ms2Timeline.getSegmentsIncluded()); + assertEquals(2, this.ms2Timeline.getSegmentsExcluded()); + assertEquals(this.ms2BaseTimeline, this.ms2Timeline.getBaseTimeline()); + } + + /** + * Tests that the factory method that creates Monday through Friday + * segmented timeline does so correctly. + */ + @Test + public void testMondayThroughFridaySegmentedTimeline() { + // verify attributes set during object construction + assertEquals(SegmentedTimeline.DAY_SEGMENT_SIZE, + this.mondayFridayTimeline.getSegmentSize()); + assertEquals(SegmentedTimeline.FIRST_MONDAY_AFTER_1900, + this.mondayFridayTimeline.getStartTime()); + assertEquals(5, this.mondayFridayTimeline.getSegmentsIncluded()); + assertEquals(2, this.mondayFridayTimeline.getSegmentsExcluded()); + } + + /** + * Tests that the factory method that creates a 15-min 9:00 AM 4:00 PM + * segmented axis does so correctly. + */ + @Test + public void testFifteenMinSegmentedTimeline() { + assertEquals(SegmentedTimeline.FIFTEEN_MINUTE_SEGMENT_SIZE, + this.fifteenMinTimeline.getSegmentSize()); + assertEquals(SegmentedTimeline.FIRST_MONDAY_AFTER_1900 + 36 + * this.fifteenMinTimeline.getSegmentSize(), + this.fifteenMinTimeline.getStartTime()); + assertEquals(28, this.fifteenMinTimeline.getSegmentsIncluded()); + assertEquals(68, this.fifteenMinTimeline.getSegmentsExcluded()); + } + + ////////////////////////////////////////////////////////////////////////// + // test one-segment and adjacent segments + ////////////////////////////////////////////////////////////////////////// + + /** + * Tests one segment of the ms timeline. Internal indices + * inside one segment as well as adjacent segments are verified. + */ + @Test + public void testMsSegment() { + verifyOneSegment(this.msTimeline); + } + + /** + * Tests one segment of the ms timeline. Internal indices + * inside one segment as well as adjacent segments are verified. + */ + @Test + public void testMs2Segment() { + verifyOneSegment(this.ms2Timeline); + } + + /** + * Tests one segment of the Monday through Friday timeline. Internal indices + * inside one segment as well as adjacent segments are verified. + */ + @Test + public void testMondayThroughFridaySegment() { + verifyOneSegment(this.mondayFridayTimeline); + } + + /** + * Tests one segment of the Fifteen timeline. Internal indices + * inside one segment as well as adjacent segments are verified. + */ + @Test + public void testFifteenMinSegment() { + verifyOneSegment(this.fifteenMinTimeline); + } + + /** + * Tests one segment of the Monday through Friday timeline. Internal indices + * inside one segment as well as adjacent segments are verified. + * @param timeline the timeline to use for verifications. + */ + public void verifyOneSegment(SegmentedTimeline timeline) { + + for (long testCycle = TEST_CYCLE_START; testCycle < TEST_CYCLE_END; + testCycle += TEST_CYCLE_INC) { + + // get two consecutive segments for various tests + SegmentedTimeline.Segment segment1 = timeline.getSegment( + this.monday.getTime().getTime() + testCycle); + SegmentedTimeline.Segment segment2 = timeline.getSegment( + segment1.getSegmentEnd() + 1); + + // verify segments are consecutive and correct + assertEquals(segment1.getSegmentNumber() + 1, + segment2.getSegmentNumber()); + assertEquals(segment1.getSegmentEnd() + 1, + segment2.getSegmentStart()); + assertEquals(segment1.getSegmentStart() + + timeline.getSegmentSize() - 1, segment1.getSegmentEnd()); + assertEquals(segment1.getSegmentStart() + timeline.getSegmentSize(), + segment2.getSegmentStart()); + assertEquals(segment1.getSegmentEnd() + timeline.getSegmentSize(), + segment2.getSegmentEnd()); + + // verify various indices inside a segment are the same segment + long delta; + if (timeline.getSegmentSize() > 1000000) { + delta = timeline.getSegmentSize() / 10000; + } + else if (timeline.getSegmentSize() > 100000) { + delta = timeline.getSegmentSize() / 1000; + } + else if (timeline.getSegmentSize() > 10000) { + delta = timeline.getSegmentSize() / 100; + } + else if (timeline.getSegmentSize() > 1000) { + delta = timeline.getSegmentSize() / 10; + } + else if (timeline.getSegmentSize() > 100) { + delta = timeline.getSegmentSize() / 5; + } + else { + delta = 1; + } + + long start = segment1.getSegmentStart() + delta; + long end = segment1.getSegmentStart() + + timeline.getSegmentSize() - 1; + SegmentedTimeline.Segment lastSeg = timeline.getSegment( + segment1.getSegmentStart()); + SegmentedTimeline.Segment seg; + for (long i = start; i < end; i += delta) { + seg = timeline.getSegment(i); + assertEquals(lastSeg.getSegmentNumber(), + seg.getSegmentNumber()); + assertEquals(lastSeg.getSegmentStart(), seg.getSegmentStart()); + assertEquals(lastSeg.getSegmentEnd(), seg.getSegmentEnd()); + assertTrue(lastSeg.getMillisecond() < seg.getMillisecond()); + lastSeg = seg; + } + + // try next segment + seg = timeline.getSegment(end + 1); + assertEquals(segment2.getSegmentNumber(), seg.getSegmentNumber()); + assertEquals(segment2.getSegmentStart(), seg.getSegmentStart()); + assertEquals(segment2.getSegmentEnd(), seg.getSegmentEnd()); + } + } + + ////////////////////////////////////////////////////////////////////////// + // test inc methods + ////////////////////////////////////////////////////////////////////////// + + /** + * Tests the inc methods on the msTimeline. + */ + @Test + public void testMsInc() { + verifyInc(this.msTimeline); + } + + /** + * Tests the inc methods on the msTimeline. + */ + @Test + public void testMs2Inc() { + verifyInc(this.ms2Timeline); + } + + /** + * Tests the inc methods on the Monday through Friday timeline. + */ + @Test + public void testMondayThroughFridayInc() { + verifyInc(this.mondayFridayTimeline); + } + + /** + * Tests the inc methods on the Fifteen minute timeline. + */ + @Test + public void testFifteenMinInc() { + verifyInc(this.fifteenMinTimeline); + } + + /** + * Tests the inc methods. + * @param timeline the timeline to use for verifications. + */ + public void verifyInc(SegmentedTimeline timeline) { + for (long testCycle = TEST_CYCLE_START; testCycle < TEST_CYCLE_END; + testCycle += TEST_CYCLE_INC) { + + long m = timeline.getSegmentSize(); + SegmentedTimeline.Segment segment = timeline.getSegment(testCycle); + SegmentedTimeline.Segment seg1 = segment.copy(); + for (int i = 0; i < 1000; i++) { + + // test inc() method + SegmentedTimeline.Segment seg2 = seg1.copy(); + seg2.inc(); + + if ((seg1.getSegmentEnd() + 1) != seg2.getSegmentStart()) { + // logically consecutive segments non-physically consecutive + // (with non-contained time in between) + assertTrue(!timeline.containsDomainRange( + seg1.getSegmentEnd() + 1, + seg2.getSegmentStart() - 1)); + assertEquals(0, (seg2.getSegmentStart() + - seg1.getSegmentStart()) % m); + assertEquals(0, (seg2.getSegmentEnd() + - seg1.getSegmentEnd()) % m); + assertEquals(0, (seg2.getMillisecond() + - seg1.getMillisecond()) % m); + } + else { + // physically consecutive + assertEquals(seg1.getSegmentStart() + m, + seg2.getSegmentStart()); + assertEquals(seg1.getSegmentEnd() + m, + seg2.getSegmentEnd()); + assertEquals(seg1.getMillisecond() + m, + seg2.getMillisecond()); + } + + // test inc(n) method + SegmentedTimeline.Segment seg3 = seg1.copy(); + SegmentedTimeline.Segment seg4 = seg1.copy(); + + for (int j = 0; j < i; j++) { + seg3.inc(); + } + seg4.inc(i); + + assertEquals(seg3.getSegmentStart(), seg4.getSegmentStart()); + assertEquals(seg3.getSegmentEnd(), seg4.getSegmentEnd()); + assertEquals(seg3.getMillisecond(), seg4.getMillisecond()); + + // go to another segment to continue test + seg1.inc(); + } + } + } + + ////////////////////////////////////////////////////////////////////////// + // main include and excluded segments + ////////////////////////////////////////////////////////////////////////// + + /** + * Tests that the msTimeline's included and excluded + * segments are being calculated correctly. + */ + @Test + public void testMsIncludedAndExcludedSegments() { + verifyIncludedAndExcludedSegments(this.msTimeline, 0); + } + + /** + * Tests that the ms2Timeline's included and excluded + * segments are being calculated correctly. + */ + @Test + public void testMs2IncludedAndExcludedSegments() { + verifyIncludedAndExcludedSegments(this.ms2Timeline, 1); + } + + /** + * Tests that the Monday through Friday timeline's included and excluded + * segments are being calculated correctly. The test is performed starting + * on the first monday after 1/1/2000 and for five years. + */ + @Test + public void testMondayThroughFridayIncludedAndExcludedSegments() { + verifyIncludedAndExcludedSegments(this.mondayFridayTimeline, + this.monday.getTime().getTime()); + } + + /** + * Tests that the Fifteen-Min timeline's included and excluded + * segments are being calculated correctly. The test is performed starting + * on the first monday after 1/1/2000 and for five years. + */ + @Test + public void testFifteenMinIncludedAndExcludedSegments() { + verifyIncludedAndExcludedSegments(this.fifteenMinTimeline, + this.monday9am.getTime().getTime()); + } + + /** + * Tests that a timeline's included and excluded segments are being + * calculated correctly. + * + * @param timeline the timeline to verify + * @param n the first segment number to start verifying + */ + public void verifyIncludedAndExcludedSegments(SegmentedTimeline timeline, + long n) { + // clear any exceptions in this timeline + timeline.setExceptionSegments(new java.util.ArrayList()); + + // test some included and excluded segments + SegmentedTimeline.Segment segment = timeline.getSegment(n); + for (int i = 0; i < 1000; i++) { + int d = (i % timeline.getGroupSegmentCount()); + if (d < timeline.getSegmentsIncluded()) { + // should be an included segment + assertTrue(segment.inIncludeSegments()); + assertTrue(!segment.inExcludeSegments()); + assertTrue(!segment.inExceptionSegments()); + } + else { + // should be an excluded segment + assertTrue(!segment.inIncludeSegments()); + assertTrue(segment.inExcludeSegments()); + assertTrue(!segment.inExceptionSegments()); + } + segment.inc(); + } + } + + ////////////////////////////////////////////////////////////////////////// + // test exception segments + ////////////////////////////////////////////////////////////////////////// + + /** + * Tests methods related to exceptions methods in the msTimeline. + * + * @throws ParseException if there is a parsing error. + */ + @Test + public void testMsExceptionSegments() throws ParseException { + verifyExceptionSegments(this.msTimeline, MS_EXCEPTIONS, NUMBER_FORMAT); + } + + /** + * Tests methods related to exceptions methods in the ms2BaseTimeline. + * + * @throws ParseException if there is a parsing error. + */ + @Test + public void testMs2BaseTimelineExceptionSegments() throws ParseException { + verifyExceptionSegments(this.ms2BaseTimeline, + MS2_BASE_TIMELINE_EXCEPTIONS, NUMBER_FORMAT); + } + + /** + * Tests methods related to exceptions methods in the mondayFridayTimeline. + * + * @throws ParseException if there is a parsing error. + */ + @Test + public void testMondayThoughFridayExceptionSegments() + throws ParseException { + verifyExceptionSegments(this.mondayFridayTimeline, + US_HOLIDAYS, DATE_FORMAT); + } + + /** + * Tests methods related to exceptions methods in the fifteenMinTimeline. + * + * @throws ParseException if there is a parsing error. + */ + @Test + public void testFifteenMinExceptionSegments() throws ParseException { + verifyExceptionSegments(this.fifteenMinTimeline, + FIFTEEN_MIN_EXCEPTIONS, DATE_TIME_FORMAT); + } + + /** + * Tests methods related to adding exceptions. + * + * @param timeline the timeline to verify + * @param exceptionString array of Strings that represent the exceptions + * @param fmt Format object that can parse the exceptionString strings + * + * @throws ParseException if there is a parsing error. + */ + public void verifyExceptionSegments(SegmentedTimeline timeline, + String[] exceptionString, + Format fmt) + throws ParseException { + + // fill in the exceptions + long[] exception = verifyFillInExceptions(timeline, exceptionString, + fmt); + + int m = exception.length; + + // verify list of exceptions + assertEquals(exception.length, timeline.getExceptionSegments().size()); + SegmentedTimeline.Segment lastSegment = timeline.getSegment( + exception[m - 1]); + for (int i = 0; i < m; i++) { + SegmentedTimeline.Segment segment = timeline.getSegment( + exception[i]); + assertTrue(segment.inExceptionSegments()); + // include current exception and last one + assertEquals(m - i, timeline.getExceptionSegmentCount( + segment.getSegmentStart(), lastSegment.getSegmentEnd())); + // exclude current exception and last one + assertEquals(Math.max(0, m - i - 2), + timeline.getExceptionSegmentCount(exception[i] + 1, + exception[m - 1] - 1)); + } + + } + + ////////////////////////////////////////////////////////////////////////// + // test timeline translations + ////////////////////////////////////////////////////////////////////////// + + /** + * Tests translations for 1-ms timeline + * + * @throws ParseException if there is a parsing error. + */ + @Test + public void testMsTranslations() throws ParseException { + verifyFillInExceptions(this.msTimeline, MS_EXCEPTIONS, NUMBER_FORMAT); + verifyTranslations(this.msTimeline, 0); + } + + /** + * Tests translations for the base timeline used for the ms2Timeline + * + * @throws ParseException if there is a parsing error. + */ + @Test + public void testMs2BaseTimelineTranslations() throws ParseException { + verifyFillInExceptions(this.ms2BaseTimeline, + MS2_BASE_TIMELINE_EXCEPTIONS, NUMBER_FORMAT); + verifyTranslations(this.ms2BaseTimeline, 0); + } + + /** + * Tests translations for the Monday through Friday timeline + * + * @throws ParseException if there is a parsing error. + */ + @Test + public void testMs2Translations() throws ParseException { + fillInBaseTimelineExceptions(this.ms2Timeline, + MS2_BASE_TIMELINE_EXCEPTIONS, NUMBER_FORMAT); + fillInBaseTimelineExclusionsAsExceptions(this.ms2Timeline, 0, 5000); + verifyTranslations(this.ms2Timeline, 1); + } + + /** + * Tests translations for the Monday through Friday timeline + * + * @throws ParseException if there is a parsing error. + */ + @Ignore + public void testMondayThroughFridayTranslations() throws ParseException { + verifyFillInExceptions(this.mondayFridayTimeline, US_HOLIDAYS, + DATE_FORMAT); + verifyTranslations(this.mondayFridayTimeline, + this.monday.getTime().getTime()); + } + + /** + * Tests translations for the Fifteen Min timeline + * + * @throws ParseException if there is a parsing error. + */ + @Test + public void testFifteenMinTranslations() throws ParseException { + verifyFillInExceptions(this.fifteenMinTimeline, + FIFTEEN_MIN_EXCEPTIONS, DATE_TIME_FORMAT); + fillInBaseTimelineExceptions(this.fifteenMinTimeline, + US_HOLIDAYS, DATE_FORMAT); + fillInBaseTimelineExclusionsAsExceptions(this.fifteenMinTimeline, + this.monday9am.getTime().getTime(), + this.monday9am.getTime().getTime() + FIVE_YEARS); + verifyTranslations(this.fifteenMinTimeline, + this.monday9am.getTime().getTime()); + } + + /** + * Tests translations between timelines. + * + * @param timeline the timeline to use for verifications. + * @param startTest ??. + */ + public void verifyTranslations(SegmentedTimeline timeline, long startTest) { + for (long testCycle = TEST_CYCLE_START; testCycle < TEST_CYCLE_END; + testCycle += TEST_CYCLE_INC) { + + long millisecond = startTest + testCycle + * timeline.getSegmentSize(); + SegmentedTimeline.Segment segment = timeline.getSegment( + millisecond); + + for (int i = 0; i < 1000; i++) { + long translatedValue = timeline.toTimelineValue( + segment.getMillisecond()); + long newValue = timeline.toMillisecond(translatedValue); + + if (segment.inExcludeSegments() + || segment.inExceptionSegments()) { + // the reverse transformed value will be in the start of the + // next non-excluded and non-exception segment + SegmentedTimeline.Segment tempSegment = segment.copy(); + tempSegment.moveIndexToStart(); + do { + tempSegment.inc(); + } + while (!tempSegment.inIncludeSegments()); + assertEquals(tempSegment.getMillisecond(), newValue); + } + + else { + assertEquals(segment.getMillisecond(), newValue); + } + segment.inc(); + } + } + } + + ////////////////////////////////////////////////////////////////////////// + // test serialization + ////////////////////////////////////////////////////////////////////////// + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + verifySerialization(this.msTimeline); + verifySerialization(this.ms2Timeline); + verifySerialization(this.ms2BaseTimeline); + verifySerialization(SegmentedTimeline.newMondayThroughFridayTimeline()); + verifySerialization(SegmentedTimeline.newFifteenMinuteTimeline()); + } + + /** + * Tests serialization of an instance. + * @param a1 The timeline to verify the serialization + */ + private void verifySerialization(SegmentedTimeline a1) { + SegmentedTimeline a2 = (SegmentedTimeline) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + + /** + * Adds an array of exceptions to the timeline. The timeline exception list + * is first cleared. + * @param timeline The timeline where the exceptions will be stored + * @param exceptionString The exceptions to load + * @param fmt The date formatter to use to parse each exceptions[i] value + * @throws ParseException If there is any exception parsing each + * exceptions[i] value. + * @return An array of Dates[] containing each exception date. + */ + private long[] verifyFillInExceptions(SegmentedTimeline timeline, + String[] exceptionString, + Format fmt) throws ParseException { + // make sure there are no exceptions + timeline.setExceptionSegments(new java.util.ArrayList()); + assertEquals(0, timeline.getExceptionSegments().size()); + + // add our exceptions and store locally in ArrayList of Longs + ArrayList exceptionList = new ArrayList(); + for (int i = 0; i < exceptionString.length; i++) { + long e; + if (fmt instanceof NumberFormat) { + e = ((NumberFormat) fmt).parse(exceptionString[i]).longValue(); + } + else { + e = timeline.getTime(((SimpleDateFormat) fmt) + .parse(exceptionString[i])); + } + // only add an exception if it is currently an included segment + SegmentedTimeline.Segment segment = timeline.getSegment(e); + if (segment.inIncludeSegments()) { + timeline.addException(e); + exceptionList.add(new Long(e)); + assertEquals(exceptionList.size(), + timeline.getExceptionSegments().size()); + assertTrue(segment.inExceptionSegments()); + } + } + + // make array of exceptions + long[] exception = new long[exceptionList.size()]; + int i = 0; + for (Iterator iter = exceptionList.iterator(); iter.hasNext();) { + Long l = (Long) iter.next(); + exception[i++] = l.longValue(); + } + + return (exception); + + } + + /** + * Adds an array of exceptions relative to the base timeline. + * + * @param timeline The timeline where the exceptions will be stored + * @param exceptionString The exceptions to load + * @param fmt The date formatter to use to parse each exceptions[i] value + * @throws ParseException If there is any exception parsing each + * exceptions[i] value. + */ + private void fillInBaseTimelineExceptions(SegmentedTimeline timeline, + String[] exceptionString, + Format fmt) throws ParseException { + SegmentedTimeline baseTimeline = timeline.getBaseTimeline(); + for (int i = 0; i < exceptionString.length; i++) { + long e; + if (fmt instanceof NumberFormat) { + e = ((NumberFormat) fmt).parse(exceptionString[i]).longValue(); + } + else { + e = timeline.getTime(((SimpleDateFormat) fmt) + .parse(exceptionString[i])); + } + timeline.addBaseTimelineException(e); + + // verify all timeline segments included in the + // baseTimeline.segment are now exceptions + SegmentedTimeline.Segment segment1 = baseTimeline.getSegment(e); + for (SegmentedTimeline.Segment segment2 + = timeline.getSegment(segment1.getSegmentStart()); + segment2.getSegmentStart() <= segment1.getSegmentEnd(); + segment2.inc()) { + if (!segment2.inExcludeSegments()) { + assertTrue(segment2.inExceptionSegments()); + } + } + + } + } + + /** + * Adds new exceptions to a timeline. The exceptions are the excluded + * segments from its base timeline. + * + * @param timeline the timeline. + * @param from the start. + * @param to the end. + */ + private void fillInBaseTimelineExclusionsAsExceptions( + SegmentedTimeline timeline, long from, long to) { + + // add the base timeline exclusions as timeline's esceptions + timeline.addBaseTimelineExclusions(from, to); + + // validate base timeline exclusions added as timeline's esceptions + for (SegmentedTimeline.Segment segment1 = timeline.getBaseTimeline() + .getSegment(from); + segment1.getSegmentStart() <= to; + segment1.inc()) { + + if (segment1.inExcludeSegments()) { + + // verify all timeline segments included in the + // baseTimeline.segment are now exceptions + for (SegmentedTimeline.Segment segment2 = timeline.getSegment( + segment1.getSegmentStart()); + segment2.getSegmentStart() <= segment1.getSegmentEnd(); + segment2.inc()) { + if (!segment2.inExcludeSegments()) { + assertTrue(segment2.inExceptionSegments()); + } + } + } + } + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + SegmentedTimeline l1 = new SegmentedTimeline(1000, 5, 2); + SegmentedTimeline l2 = (SegmentedTimeline) l1.clone(); + assertTrue(l1 != l2); + assertTrue(l1.getClass() == l2.getClass()); + assertTrue(l1.equals(l2)); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + SegmentedTimeline l1 = new SegmentedTimeline(1000, 5, 2); + SegmentedTimeline l2 = new SegmentedTimeline(1000, 5, 2); + assertTrue(l1.equals(l2)); + + l1 = new SegmentedTimeline(1000, 5, 2); + l2 = new SegmentedTimeline(1001, 5, 2); + assertFalse(l1.equals(l2)); + + l1 = new SegmentedTimeline(1000, 5, 2); + l2 = new SegmentedTimeline(1000, 4, 2); + assertFalse(l1.equals(l2)); + + l1 = new SegmentedTimeline(1000, 5, 2); + l2 = new SegmentedTimeline(1000, 5, 1); + assertFalse(l1.equals(l2)); + + l1 = new SegmentedTimeline(1000, 5, 2); + l2 = new SegmentedTimeline(1000, 5, 2); + + // start time... + l1.setStartTime(1234L); + assertFalse(l1.equals(l2)); + l2.setStartTime(1234L); + assertTrue(l1.equals(l2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + SegmentedTimeline l1 = new SegmentedTimeline(1000, 5, 2); + SegmentedTimeline l2 = new SegmentedTimeline(1000, 5, 2); + assertTrue(l1.equals(l2)); + int h1 = l1.hashCode(); + int h2 = l2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization2() { + SegmentedTimeline l1 = new SegmentedTimeline(1000, 5, 2); + SegmentedTimeline l2 = (SegmentedTimeline) TestUtilities.serialised(l1); + assertEquals(l1, l2); + } + + ////////////////////////////////////////////////////////////////////////// + // utility methods + ////////////////////////////////////////////////////////////////////////// + + /** + * Tests a basic segmented timeline. + */ + @Test + public void testBasicSegmentedTimeline() { + SegmentedTimeline stl = new SegmentedTimeline(10, 2, 3); + stl.setStartTime(946684800000L); // 1-Jan-2000 + assertFalse(stl.containsDomainValue(946684799999L)); + assertTrue(stl.containsDomainValue(946684800000L)); + assertTrue(stl.containsDomainValue(946684800019L)); + assertFalse(stl.containsDomainValue(946684800020L)); + assertFalse(stl.containsDomainValue(946684800049L)); + assertTrue(stl.containsDomainValue(946684800050L)); + assertTrue(stl.containsDomainValue(946684800069L)); + assertFalse(stl.containsDomainValue(946684800070L)); + assertFalse(stl.containsDomainValue(946684800099L)); + assertTrue(stl.containsDomainValue(946684800100L)); + + assertEquals(0, stl.toTimelineValue(946684800000L)); + assertEquals(19, stl.toTimelineValue(946684800019L)); + assertEquals(20, stl.toTimelineValue(946684800020L)); + assertEquals(20, stl.toTimelineValue(946684800049L)); + assertEquals(20, stl.toTimelineValue(946684800050L)); + assertEquals(39, stl.toTimelineValue(946684800069L)); + assertEquals(40, stl.toTimelineValue(946684800070L)); + assertEquals(40, stl.toTimelineValue(946684800099L)); + assertEquals(40, stl.toTimelineValue(946684800100L)); + + assertEquals(946684800000L, stl.toMillisecond(0)); + assertEquals(946684800019L, stl.toMillisecond(19)); + assertEquals(946684800050L, stl.toMillisecond(20)); + assertEquals(946684800069L, stl.toMillisecond(39)); + assertEquals(946684800100L, stl.toMillisecond(40)); + + } + + /** + * Tests a basic time line with one exception. + */ + @Test + public void testSegmentedTimelineWithException1() { + SegmentedTimeline stl = new SegmentedTimeline(10, 2, 3); + stl.setStartTime(946684800000L); // 1-Jan-2000 + stl.addException(946684800050L); + assertFalse(stl.containsDomainValue(946684799999L)); + assertTrue(stl.containsDomainValue(946684800000L)); + assertTrue(stl.containsDomainValue(946684800019L)); + assertFalse(stl.containsDomainValue(946684800020L)); + assertFalse(stl.containsDomainValue(946684800049L)); + assertFalse(stl.containsDomainValue(946684800050L)); + assertFalse(stl.containsDomainValue(946684800059L)); + assertTrue(stl.containsDomainValue(946684800060L)); + assertTrue(stl.containsDomainValue(946684800069L)); + assertFalse(stl.containsDomainValue(946684800070L)); + assertFalse(stl.containsDomainValue(946684800099L)); + assertTrue(stl.containsDomainValue(946684800100L)); + + //long v = stl.toTimelineValue(946684800020L); + assertEquals(0, stl.toTimelineValue(946684800000L)); + assertEquals(19, stl.toTimelineValue(946684800019L)); + assertEquals(20, stl.toTimelineValue(946684800020L)); + assertEquals(20, stl.toTimelineValue(946684800049L)); + assertEquals(20, stl.toTimelineValue(946684800050L)); + assertEquals(29, stl.toTimelineValue(946684800069L)); + assertEquals(30, stl.toTimelineValue(946684800070L)); + assertEquals(30, stl.toTimelineValue(946684800099L)); + assertEquals(30, stl.toTimelineValue(946684800100L)); + + assertEquals(946684800000L, stl.toMillisecond(0)); + assertEquals(946684800019L, stl.toMillisecond(19)); + assertEquals(946684800060L, stl.toMillisecond(20)); + assertEquals(946684800069L, stl.toMillisecond(29)); + assertEquals(946684800100L, stl.toMillisecond(30)); + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/StandardTickUnitSourceTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/StandardTickUnitSourceTest.java new file mode 100755 index 0000000..1458d40 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/StandardTickUnitSourceTest.java @@ -0,0 +1,74 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * StandardTickUnitSourceTest.java + * ------------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Oct-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link StandardTickUnitSource} class. + */ +public class StandardTickUnitSourceTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + StandardTickUnitSource t1 = new StandardTickUnitSource(); + StandardTickUnitSource t2 = new StandardTickUnitSource(); + assertTrue(t1.equals(t2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardTickUnitSource t1 = new StandardTickUnitSource(); + StandardTickUnitSource t2 = (StandardTickUnitSource) TestUtilities.serialised(t1); + assertEquals(t1, t2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/SubCategoryAxisTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/SubCategoryAxisTest.java new file mode 100755 index 0000000..94647e2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/SubCategoryAxisTest.java @@ -0,0 +1,156 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * SubCategoryAxisTest.java + * ------------------------ + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 12-May-2004 : Version 1 (DG); + * 07-Jan-2005 : Added test for hashCode() (DG); + * 13-Nov-2008 : Added test2275695() (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.junit.Test; + +/** + * Tests for the {@link SubCategoryAxis} class. + */ +public class SubCategoryAxisTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + SubCategoryAxis a1 = new SubCategoryAxis("Test"); + SubCategoryAxis a2 = new SubCategoryAxis("Test"); + assertTrue(a1.equals(a2)); + assertTrue(a2.equals(a1)); + + // subcategories + a1.addSubCategory("Sub 1"); + assertFalse(a1.equals(a2)); + a2.addSubCategory("Sub 1"); + assertTrue(a1.equals(a2)); + + // subLabelFont + a1.setSubLabelFont(new Font("Serif", Font.BOLD, 15)); + assertFalse(a1.equals(a2)); + a2.setSubLabelFont(new Font("Serif", Font.BOLD, 15)); + assertTrue(a1.equals(a2)); + + // subLabelPaint + a1.setSubLabelPaint(Color.red); + assertFalse(a1.equals(a2)); + a2.setSubLabelPaint(Color.red); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + SubCategoryAxis a1 = new SubCategoryAxis("Test"); + SubCategoryAxis a2 = new SubCategoryAxis("Test"); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + SubCategoryAxis a1 = new SubCategoryAxis("Test"); + a1.addSubCategory("SubCategoryA"); + SubCategoryAxis a2 = (SubCategoryAxis) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + SubCategoryAxis a1 = new SubCategoryAxis("Test Axis"); + a1.addSubCategory("SubCategoryA"); + SubCategoryAxis a2 = (SubCategoryAxis) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + + /** + * A check for the NullPointerException in bug 2275695. + */ + @Test + public void test2275695() { + JFreeChart chart = ChartFactory.createStackedBarChart("Test", + "Category", "Value", null, PlotOrientation.VERTICAL, + true, false, false); + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + plot.setDomainAxis(new SubCategoryAxis("SubCategoryAxis")); + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); + g2.dispose(); + } + catch (Exception e) { + fail("There should be no exception."); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/SymbolAxisTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/SymbolAxisTest.java new file mode 100755 index 0000000..c9c007f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/SymbolAxisTest.java @@ -0,0 +1,117 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * SymbolicAxisTest.java + * --------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Mar-2003 : Version 1 (DG); + * 25-Jul-2007 : Added new field in testEquals() (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import java.awt.Color; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link SymbolAxis} class. + */ +public class SymbolAxisTest { + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + String[] tickLabels = new String[] {"One", "Two", "Three"}; + SymbolAxis a1 = new SymbolAxis("Test Axis", tickLabels); + SymbolAxis a2 = (SymbolAxis) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + SymbolAxis a1 = new SymbolAxis("Axis", new String[] {"A", "B"}); + SymbolAxis a2 = (SymbolAxis) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + SymbolAxis a1 = new SymbolAxis("Axis", new String[] {"A", "B"}); + SymbolAxis a2 = new SymbolAxis("Axis", new String[] {"A", "B"}); + assertTrue(a1.equals(a2)); + assertTrue(a2.equals(a1)); + + a1 = new SymbolAxis("Axis 2", new String[] {"A", "B"}); + assertFalse(a1.equals(a2)); + a2 = new SymbolAxis("Axis 2", new String[] {"A", "B"}); + assertTrue(a1.equals(a2)); + + a1 = new SymbolAxis("Axis 2", new String[] {"C", "B"}); + assertFalse(a1.equals(a2)); + a2 = new SymbolAxis("Axis 2", new String[] {"C", "B"}); + assertTrue(a1.equals(a2)); + + a1.setGridBandsVisible(false); + assertFalse(a1.equals(a2)); + a2.setGridBandsVisible(false); + assertTrue(a1.equals(a2)); + + a1.setGridBandPaint(Color.black); + assertFalse(a1.equals(a2)); + a2.setGridBandPaint(Color.black); + assertTrue(a1.equals(a2)); + + a1.setGridBandAlternatePaint(Color.red); + assertFalse(a1.equals(a2)); + a2.setGridBandAlternatePaint(Color.red); + assertTrue(a1.equals(a2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/TickUnitsTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/TickUnitsTest.java new file mode 100755 index 0000000..ff62e0b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/TickUnitsTest.java @@ -0,0 +1,87 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * TickUnitsTest.java + * ------------------ + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 02-Aug-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link TickUnits} class. + */ +public class TickUnitsTest { + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TickUnits t1 = (TickUnits) NumberAxis.createIntegerTickUnits(); + TickUnits t2 = (TickUnits) TestUtilities.serialised(t1); + assertEquals(t1, t2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + TickUnits t1 = (TickUnits) NumberAxis.createIntegerTickUnits(); + TickUnits t2 = (TickUnits) t1.clone(); + assertTrue(t1 != t2); + assertTrue(t1.getClass() == t2.getClass()); + assertTrue(t1.equals(t2)); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + TickUnits t1 = (TickUnits) NumberAxis.createIntegerTickUnits(); + TickUnits t2 = (TickUnits) NumberAxis.createIntegerTickUnits(); + assertTrue(t1.equals(t2)); + assertTrue(t2.equals(t1)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/ValueAxisTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/ValueAxisTest.java new file mode 100755 index 0000000..716c4e9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/ValueAxisTest.java @@ -0,0 +1,256 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * ValueAxisTest.java + * ------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Aug-2003 : Version 1 (DG); + * 22-Mar-2007 : Extended testEquals() for new field (DG); + * 04-Sep-2012 : Added test3555275() (DG); + * + */ + +package org.jfree.chart.axis; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Graphics2D; +import java.awt.Stroke; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartRenderingInfo; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.Range; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.ui.RectangleInsets; +import org.junit.Test; + +/** + * Tests for the {@link ValueAxis} class. + */ +public class ValueAxisTest { + + private static final double EPSILON = 0.000000001; + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ValueAxis a1 = new NumberAxis("Test"); + ValueAxis a2 = (NumberAxis) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + NumberAxis a1 = new NumberAxis("Test"); + NumberAxis a2 = new NumberAxis("Test"); + assertTrue(a1.equals(a2)); + + // axis line visible flag... + a1.setAxisLineVisible(false); + assertFalse(a1.equals(a2)); + a2.setAxisLineVisible(false); + assertTrue(a1.equals(a2)); + + // positiveArrowVisible; + a1.setPositiveArrowVisible(true); + assertFalse(a1.equals(a2)); + a2.setPositiveArrowVisible(true); + assertTrue(a1.equals(a2)); + + // negativeArrowVisible; + a1.setNegativeArrowVisible(true); + assertFalse(a1.equals(a2)); + a2.setNegativeArrowVisible(true); + assertTrue(a1.equals(a2)); + + //private Shape upArrow; + + //private Shape downArrow; + + //private Shape leftArrow; + + //private Shape rightArrow; + + // axisLinePaint + a1.setAxisLinePaint(Color.blue); + assertFalse(a1.equals(a2)); + a2.setAxisLinePaint(Color.blue); + assertTrue(a1.equals(a2)); + + // axisLineStroke + Stroke stroke = new BasicStroke(2.0f); + a1.setAxisLineStroke(stroke); + assertFalse(a1.equals(a2)); + a2.setAxisLineStroke(stroke); + assertTrue(a1.equals(a2)); + + // inverted + a1.setInverted(true); + assertFalse(a1.equals(a2)); + a2.setInverted(true); + assertTrue(a1.equals(a2)); + + // range + a1.setRange(new Range(50.0, 75.0)); + assertFalse(a1.equals(a2)); + a2.setRange(new Range(50.0, 75.0)); + assertTrue(a1.equals(a2)); + + // autoRange + a1.setAutoRange(true); + assertFalse(a1.equals(a2)); + a2.setAutoRange(true); + assertTrue(a1.equals(a2)); + + // autoRangeMinimumSize + a1.setAutoRangeMinimumSize(3.33); + assertFalse(a1.equals(a2)); + a2.setAutoRangeMinimumSize(3.33); + assertTrue(a1.equals(a2)); + + a1.setDefaultAutoRange(new Range(1.2, 3.4)); + assertFalse(a1.equals(a2)); + a2.setDefaultAutoRange(new Range(1.2, 3.4)); + assertTrue(a1.equals(a2)); + + // upperMargin + a1.setUpperMargin(0.09); + assertFalse(a1.equals(a2)); + a2.setUpperMargin(0.09); + assertTrue(a1.equals(a2)); + + // lowerMargin + a1.setLowerMargin(0.09); + assertFalse(a1.equals(a2)); + a2.setLowerMargin(0.09); + assertTrue(a1.equals(a2)); + + //private double fixedAutoRange; + a1.setFixedAutoRange(50.0); + assertFalse(a1.equals(a2)); + a2.setFixedAutoRange(50.0); + assertTrue(a1.equals(a2)); + + //private boolean autoTickUnitSelection; + a1.setAutoTickUnitSelection(false); + assertFalse(a1.equals(a2)); + a2.setAutoTickUnitSelection(false); + assertTrue(a1.equals(a2)); + + //private TickUnits standardTickUnits; + a1.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + assertFalse(a1.equals(a2)); + a2.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + assertTrue(a1.equals(a2)); + + // verticalTickLabels + a1.setVerticalTickLabels(true); + assertFalse(a1.equals(a2)); + a2.setVerticalTickLabels(true); + assertTrue(a1.equals(a2)); + + + //private int autoTickIndex; + //protected double reservedForTickLabels; + //protected double reservedForAxisLabel; + + } + + /** + * Tests the the lower and upper margin settings produce the expected + * results. + */ + @Test + public void testAxisMargins() { + XYSeries series = new XYSeries("S1"); + series.add(100.0, 1.1); + series.add(200.0, 2.2); + XYSeriesCollection dataset = new XYSeriesCollection(series); + dataset.setIntervalWidth(0.0); + JFreeChart chart = ChartFactory.createScatterPlot("Title", "X", "Y", + dataset); + ValueAxis domainAxis = ((XYPlot) chart.getPlot()).getDomainAxis(); + Range r = domainAxis.getRange(); + assertEquals(110.0, r.getLength(), EPSILON); + domainAxis.setLowerMargin(0.10); + domainAxis.setUpperMargin(0.10); + r = domainAxis.getRange(); + assertEquals(120.0, r.getLength(), EPSILON); + } + + /** + * A test for bug 3555275 (where the fixed axis space is calculated + * incorrectly). + */ + @Test + public void test3555275() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y", + dataset, PlotOrientation.VERTICAL, true, false, false); + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + plot.setInsets(RectangleInsets.ZERO_INSETS); + plot.setAxisOffset(RectangleInsets.ZERO_INSETS); + ValueAxis yAxis = plot.getRangeAxis(); + yAxis.setFixedDimension(100.0); + BufferedImage image = new BufferedImage(500, 300, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + ChartRenderingInfo info = new ChartRenderingInfo(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 500, 300), info); + g2.dispose(); + Rectangle2D rect = info.getPlotInfo().getDataArea(); + double x = rect.getMinX(); + assertEquals(100.0, x, 1.0); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/package.html new file mode 100755 index 0000000..d2acd01 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/axis/package.html @@ -0,0 +1,6 @@ + + + +Tests for the axis classes and interfaces. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/AbstractBlockTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/AbstractBlockTest.java new file mode 100755 index 0000000..f437269 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/AbstractBlockTest.java @@ -0,0 +1,153 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * AbstractBlockTest.java + * ---------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Mar-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.Color; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; + +import org.jfree.ui.RectangleInsets; +import org.junit.Test; + +/** + * Tests for the {@link AbstractBlock} class. + */ +public class AbstractBlockTest{ + + /** + * Confirm that the equals() method can distinguish all the required fields. + */ + @Test + public void testEquals() { + EmptyBlock b1 = new EmptyBlock(1.0, 2.0); + EmptyBlock b2 = new EmptyBlock(1.0, 2.0); + assertTrue(b1.equals(b2)); + assertTrue(b2.equals(b2)); + + b1.setID("Test"); + assertFalse(b1.equals(b2)); + b2.setID("Test"); + assertTrue(b1.equals(b2)); + + b1.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); + assertFalse(b1.equals(b2)); + b2.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); + assertTrue(b1.equals(b2)); + + b1.setFrame(new BlockBorder(Color.red)); + assertFalse(b1.equals(b2)); + b2.setFrame(new BlockBorder(Color.red)); + assertTrue(b1.equals(b2)); + + b1.setPadding(new RectangleInsets(2.0, 4.0, 6.0, 8.0)); + assertFalse(b1.equals(b2)); + b2.setPadding(new RectangleInsets(2.0, 4.0, 6.0, 8.0)); + assertTrue(b1.equals(b2)); + + b1.setWidth(1.23); + assertFalse(b1.equals(b2)); + b2.setWidth(1.23); + assertTrue(b1.equals(b2)); + + b1.setHeight(4.56); + assertFalse(b1.equals(b2)); + b2.setHeight(4.56); + assertTrue(b1.equals(b2)); + + b1.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertFalse(b1.equals(b2)); + b2.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertTrue(b1.equals(b2)); + + b1 = new EmptyBlock(1.1, 2.0); + assertFalse(b1.equals(b2)); + b2 = new EmptyBlock(1.1, 2.0); + assertTrue(b1.equals(b2)); + + b1 = new EmptyBlock(1.1, 2.2); + assertFalse(b1.equals(b2)); + b2 = new EmptyBlock(1.1, 2.2); + assertTrue(b1.equals(b2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() { + EmptyBlock b1 = new EmptyBlock(1.0, 2.0); + Rectangle2D bounds1 = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); + b1.setBounds(bounds1); + EmptyBlock b2 = null; + + try { + b2 = (EmptyBlock) b1.clone(); + } + catch (CloneNotSupportedException e) { + fail(e.toString()); + } + assertTrue(b1 != b2); + assertTrue(b1.getClass() == b2.getClass()); + assertTrue(b1.equals(b2)); + + bounds1.setFrame(2.0, 4.0, 6.0, 8.0); + assertFalse(b1.equals(b2)); + b2.setBounds(new Rectangle2D.Double(2.0, 4.0, 6.0, 8.0)); + assertTrue(b1.equals(b2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + EmptyBlock b1 = new EmptyBlock(1.0, 2.0); + EmptyBlock b2 = (EmptyBlock) TestUtilities.serialised(b1); + assertEquals(b1, b2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/BlockBorderTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/BlockBorderTest.java new file mode 100755 index 0000000..dd85a16 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/BlockBorderTest.java @@ -0,0 +1,112 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * BlockBorderTest.java + * -------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Feb-2005 : Version 1 (DG); + * 23-Feb-2005 : Extended equals() test (DG); + * + */ + +package org.jfree.chart.block; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.ui.RectangleInsets; +import org.jfree.util.UnitType; +import org.junit.Test; + +/** + * Tests for the {@link BlockBorder} class. + */ +public class BlockBorderTest { + + /** + * Confirm that the equals() method can distinguish all the required fields. + */ + @Test + public void testEquals() { + BlockBorder b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, + 4.0), Color.red); + BlockBorder b2 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, + 4.0), Color.red); + assertTrue(b1.equals(b2)); + assertTrue(b2.equals(b2)); + + // insets + b1 = new BlockBorder(new RectangleInsets(UnitType.RELATIVE, 1.0, 2.0, + 3.0, 4.0), Color.red); + assertFalse(b1.equals(b2)); + b2 = new BlockBorder(new RectangleInsets(UnitType.RELATIVE, 1.0, 2.0, + 3.0, 4.0), Color.red); + assertTrue(b1.equals(b2)); + + // paint + b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), + Color.blue); + assertFalse(b1.equals(b2)); + b2 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, 4.0), + Color.blue); + assertTrue(b1.equals(b2)); + } + + /** + * Immutable - cloning not necessary. + */ + @Test + public void testCloning() { + BlockBorder b1 = new BlockBorder(); + assertFalse(b1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + BlockBorder b1 = new BlockBorder(new RectangleInsets(1.0, 2.0, 3.0, + 4.0), new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.yellow)); + BlockBorder b2 = (BlockBorder) TestUtilities.serialised(b1); + assertEquals(b1, b2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/BlockContainerTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/BlockContainerTest.java new file mode 100755 index 0000000..e13d13c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/BlockContainerTest.java @@ -0,0 +1,100 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * BlockContainerTest.java + * ----------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Feb-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link BlockContainer} class. + */ +public class BlockContainerTest { + + /** + * Confirm that the equals() method can distinguish all the required fields. + */ + @Test + public void testEquals() { + BlockContainer c1 = new BlockContainer(new FlowArrangement()); + BlockContainer c2 = new BlockContainer(new FlowArrangement()); + assertTrue(c1.equals(c2)); + assertTrue(c2.equals(c2)); + + c1.setArrangement(new ColumnArrangement()); + assertFalse(c1.equals(c2)); + c2.setArrangement(new ColumnArrangement()); + assertTrue(c1.equals(c2)); + + c1.add(new EmptyBlock(1.2, 3.4)); + assertFalse(c1.equals(c2)); + c2.add(new EmptyBlock(1.2, 3.4)); + assertTrue(c1.equals(c2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + BlockContainer c1 = new BlockContainer(new FlowArrangement()); + c1.add(new EmptyBlock(1.2, 3.4)); + BlockContainer c2 = (BlockContainer) c1.clone(); + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + BlockContainer c1 = new BlockContainer(); + c1.add(new EmptyBlock(1.2, 3.4)); + BlockContainer c2 = (BlockContainer) TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/BorderArrangementTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/BorderArrangementTest.java new file mode 100755 index 0000000..a634632 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/BorderArrangementTest.java @@ -0,0 +1,808 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * BorderArrangementTest.java + * -------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Oct-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.Size2D; +import org.junit.Test; + +/** + * Tests for the {@link BorderArrangement} class. + */ +public class BorderArrangementTest { + + private static final double EPSILON = 0.0000000001; + + /** + * Confirm that the equals() method can distinguish all the required fields. + */ + @Test + public void testEquals() { + BorderArrangement b1 = new BorderArrangement(); + BorderArrangement b2 = new BorderArrangement(); + assertTrue(b1.equals(b2)); + assertTrue(b2.equals(b1)); + + b1.add(new EmptyBlock(99.0, 99.0), null); + assertFalse(b1.equals(b2)); + b2.add(new EmptyBlock(99.0, 99.0), null); + assertTrue(b1.equals(b2)); + + b1.add(new EmptyBlock(1.0, 1.0), RectangleEdge.LEFT); + assertFalse(b1.equals(b2)); + b2.add(new EmptyBlock(1.0, 1.0), RectangleEdge.LEFT); + assertTrue(b1.equals(b2)); + + b1.add(new EmptyBlock(2.0, 2.0), RectangleEdge.RIGHT); + assertFalse(b1.equals(b2)); + b2.add(new EmptyBlock(2.0, 2.0), RectangleEdge.RIGHT); + assertTrue(b1.equals(b2)); + + b1.add(new EmptyBlock(3.0, 3.0), RectangleEdge.TOP); + assertFalse(b1.equals(b2)); + b2.add(new EmptyBlock(3.0, 3.0), RectangleEdge.TOP); + assertTrue(b1.equals(b2)); + + b1.add(new EmptyBlock(4.0, 4.0), RectangleEdge.BOTTOM); + assertFalse(b1.equals(b2)); + b2.add(new EmptyBlock(4.0, 4.0), RectangleEdge.BOTTOM); + assertTrue(b1.equals(b2)); + } + + /** + * Immutable - cloning is not necessary. + */ + @Test + public void testCloning() { + BorderArrangement b1 = new BorderArrangement(); + assertFalse(b1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + BorderArrangement b1 = new BorderArrangement(); + BorderArrangement b2 = (BorderArrangement) TestUtilities.serialised(b1); + assertEquals(b1, b2); + } + + /** + * Run some checks on sizing. + */ + @Test + public void testSizing() { + BlockContainer container = new BlockContainer(new BorderArrangement()); + BufferedImage image = new BufferedImage(200, 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + + // TBLRC + // 00000 - no items + Size2D size = container.arrange(g2); + assertEquals(0.0, size.width, EPSILON); + assertEquals(0.0, size.height, EPSILON); + + // TBLRC + // 00001 - center item only + container.add(new EmptyBlock(123.4, 567.8)); + size = container.arrange(g2); + assertEquals(123.4, size.width, EPSILON); + assertEquals(567.8, size.height, EPSILON); + + // TBLRC + // 00010 - right item only + container.clear(); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); + size = container.arrange(g2); + assertEquals(12.3, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // TBLRC + // 00011 - right and center items + container.clear(); + container.add(new EmptyBlock(10.0, 20.0)); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); + size = container.arrange(g2); + assertEquals(22.3, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // try case where right item is shorter than center item + container.clear(); + Block rb = new EmptyBlock(12.3, 15.6); + container.add(new EmptyBlock(10.0, 20.0)); + container.add(rb, RectangleEdge.RIGHT); + size = container.arrange(g2); + assertEquals(22.3, size.width, EPSILON); + assertEquals(20.0, size.height, EPSILON); + assertEquals(20.0, rb.getBounds().getHeight(), EPSILON); + + // TBLRC + // 00100 - left item only + container.clear(); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); + size = container.arrange(g2); + assertEquals(12.3, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // TBLRC + // 00101 - left and center items + container.clear(); + container.add(new EmptyBlock(10.0, 20.0)); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); + size = container.arrange(g2); + assertEquals(22.3, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // try case where left item is shorter than center item + container.clear(); + Block lb = new EmptyBlock(12.3, 15.6); + container.add(new EmptyBlock(10.0, 20.0)); + container.add(lb, RectangleEdge.LEFT); + size = container.arrange(g2); + assertEquals(22.3, size.width, EPSILON); + assertEquals(20.0, size.height, EPSILON); + assertEquals(20.0, lb.getBounds().getHeight(), EPSILON); + + // TBLRC + // 00110 - left and right items + container.clear(); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); + size = container.arrange(g2); + assertEquals(22.3, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // TBLRC + // 00111 - left, right and center items + container.clear(); + container.add(new EmptyBlock(10.0, 20.0)); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); + container.add(new EmptyBlock(5.4, 3.2), RectangleEdge.RIGHT); + size = container.arrange(g2); + assertEquals(27.7, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // TBLRC + // 01000 - bottom item only + container.clear(); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2); + assertEquals(12.3, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // TBLRC + // 01001 - bottom and center only + container.clear(); + container.add(new EmptyBlock(10.0, 20.0)); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2); + assertEquals(12.3, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 01010 - bottom and right only + container.clear(); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2); + assertEquals(12.3, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 01011 - bottom, right and center + container.clear(); + container.add(new EmptyBlock(21.0, 12.3)); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2); + assertEquals(31.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 01100 + container.clear(); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2); + assertEquals(12.3, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 01101 - bottom, left and center + container.clear(); + container.add(new EmptyBlock(21.0, 12.3)); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2); + assertEquals(31.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 01110 - bottom. left and right + container.clear(); + container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2); + assertEquals(31.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 01111 + container.clear(); + container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); + container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(9.0, 10.0)); + size = container.arrange(g2); + assertEquals(21.0, size.width, EPSILON); + assertEquals(14.0, size.height, EPSILON); + + // TBLRC + // 10000 - top item only + container.clear(); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); + size = container.arrange(g2); + assertEquals(12.3, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // TBLRC + // 10001 - top and center only + container.clear(); + container.add(new EmptyBlock(10.0, 20.0)); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); + size = container.arrange(g2); + assertEquals(12.3, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 10010 - right and top only + container.clear(); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); + size = container.arrange(g2); + assertEquals(12.3, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 10011 - top, right and center + container.clear(); + container.add(new EmptyBlock(21.0, 12.3)); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); + size = container.arrange(g2); + assertEquals(33.3, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 10100 - top and left only + container.clear(); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); + size = container.arrange(g2); + assertEquals(12.3, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 10101 - top, left and center + container.clear(); + container.add(new EmptyBlock(21.0, 12.3)); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); + size = container.arrange(g2); + assertEquals(33.3, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 10110 - top, left and right + container.clear(); + container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); + size = container.arrange(g2); + assertEquals(33.3, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 10111 + container.clear(); + container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); + container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(9.0, 10.0)); + size = container.arrange(g2); + assertEquals(21.0, size.width, EPSILON); + assertEquals(12.0, size.height, EPSILON); + + // TBLRC + // 11000 - top and bottom only + container.clear(); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2); + assertEquals(12.3, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 11001 + container.clear(); + container.add(new EmptyBlock(21.0, 12.3)); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2); + assertEquals(21.0, size.width, EPSILON); + assertEquals(77.9, size.height, EPSILON); + + // TBLRC + // 11010 - top, bottom and right + container.clear(); + container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2); + assertEquals(21.0, size.width, EPSILON); + assertEquals(77.9, size.height, EPSILON); + + // TBLRC + // 11011 + container.clear(); + container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); + container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); + container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(9.0, 10.0)); + size = container.arrange(g2); + assertEquals(16.0, size.width, EPSILON); + assertEquals(16.0, size.height, EPSILON); + + // TBLRC + // 11100 + container.clear(); + container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.LEFT); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2); + assertEquals(21.0, size.width, EPSILON); + assertEquals(77.9, size.height, EPSILON); + + // TBLRC + // 11101 + container.clear(); + container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); + container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); + container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(9.0, 10.0)); + size = container.arrange(g2); + assertEquals(14.0, size.width, EPSILON); + assertEquals(16.0, size.height, EPSILON); + + // TBLRC + // 11110 + container.clear(); + container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); + container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); + container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); + size = container.arrange(g2); + assertEquals(12.0, size.width, EPSILON); + assertEquals(14.0, size.height, EPSILON); + + // TBLRC + // 11111 - all + container.clear(); + container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); + container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); + container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(9.0, 10.0)); + size = container.arrange(g2); + assertEquals(21.0, size.width, EPSILON); + assertEquals(16.0, size.height, EPSILON); + + } + + /** + * Run some checks on sizing when there is a fixed width constraint. + */ + public void testSizingWithWidthConstraint() { + RectangleConstraint constraint = new RectangleConstraint( + 10.0, new Range(10.0, 10.0), LengthConstraintType.FIXED, + 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE); + + BlockContainer container = new BlockContainer(new BorderArrangement()); + BufferedImage image = new BufferedImage(200, 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + + // TBLRC + // 00001 - center item only + container.add(new EmptyBlock(5.0, 6.0)); + Size2D size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(6.0, size.height, EPSILON); + + container.clear(); + container.add(new EmptyBlock(15.0, 16.0)); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(16.0, size.height, EPSILON); + + // TBLRC + // 00010 - right item only + container.clear(); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // TBLRC + // 00011 - right and center items + container.clear(); + container.add(new EmptyBlock(7.0, 20.0)); + container.add(new EmptyBlock(8.0, 45.6), RectangleEdge.RIGHT); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // TBLRC + // 00100 - left item only + container.clear(); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // TBLRC + // 00101 - left and center items + container.clear(); + container.add(new EmptyBlock(10.0, 20.0)); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // TBLRC + // 00110 - left and right items + container.clear(); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // TBLRC + // 00111 - left, right and center items + container.clear(); + container.add(new EmptyBlock(10.0, 20.0)); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); + container.add(new EmptyBlock(5.4, 3.2), RectangleEdge.RIGHT); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // TBLRC + // 01000 - bottom item only + container.clear(); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // TBLRC + // 01001 - bottom and center only + container.clear(); + container.add(new EmptyBlock(10.0, 20.0)); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 01010 - bottom and right only + container.clear(); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 01011 - bottom, right and center + container.clear(); + container.add(new EmptyBlock(21.0, 12.3)); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 01100 + container.clear(); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 01101 - bottom, left and center + container.clear(); + container.add(new EmptyBlock(21.0, 12.3)); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 01110 - bottom. left and right + container.clear(); + container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 01111 + container.clear(); + container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); + container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(9.0, 10.0)); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(14.0, size.height, EPSILON); + + // TBLRC + // 10000 - top item only + container.clear(); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(45.6, size.height, EPSILON); + + // TBLRC + // 10001 - top and center only + container.clear(); + container.add(new EmptyBlock(10.0, 20.0)); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 10010 - right and top only + container.clear(); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 10011 - top, right and center + container.clear(); + container.add(new EmptyBlock(21.0, 12.3)); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.RIGHT); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 10100 - top and left only + container.clear(); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.TOP); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 10101 - top, left and center + container.clear(); + container.add(new EmptyBlock(21.0, 12.3)); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 10110 - top, left and right + container.clear(); + container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.LEFT); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 10111 + container.clear(); + container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); + container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(9.0, 10.0)); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(12.0, size.height, EPSILON); + + // TBLRC + // 11000 - top and bottom only + container.clear(); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(65.6, size.height, EPSILON); + + // TBLRC + // 11001 + container.clear(); + container.add(new EmptyBlock(21.0, 12.3)); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(77.9, size.height, EPSILON); + + // TBLRC + // 11010 - top, bottom and right + container.clear(); + container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.RIGHT); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(77.9, size.height, EPSILON); + + // TBLRC + // 11011 + container.clear(); + container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); + container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); + container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(9.0, 10.0)); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(16.0, size.height, EPSILON); + + // TBLRC + // 11100 + container.clear(); + container.add(new EmptyBlock(21.0, 12.3), RectangleEdge.LEFT); + container.add(new EmptyBlock(10.0, 20.0), RectangleEdge.TOP); + container.add(new EmptyBlock(12.3, 45.6), RectangleEdge.BOTTOM); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(77.9, size.height, EPSILON); + + // TBLRC + // 11101 + container.clear(); + container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); + container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); + container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(9.0, 10.0)); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(16.0, size.height, EPSILON); + + // TBLRC + // 11110 + container.clear(); + container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); + container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); + container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(14.0, size.height, EPSILON); + + // TBLRC + // 11111 - all + container.clear(); + container.add(new EmptyBlock(1.0, 2.0), RectangleEdge.TOP); + container.add(new EmptyBlock(3.0, 4.0), RectangleEdge.BOTTOM); + container.add(new EmptyBlock(5.0, 6.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(7.0, 8.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(9.0, 10.0)); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(16.0, size.height, EPSILON); + + // TBLRC + // 00000 - no items + container.clear(); + size = container.arrange(g2, constraint); + assertEquals(10.0, size.width, EPSILON); + assertEquals(0.0, size.height, EPSILON); + + } + + /** + * This test is for a particular bug that arose just prior to the release + * of JFreeChart 1.0.10. A BorderArrangement with LEFT, CENTRE and RIGHT + * blocks that is too wide, by default, for the available space, wasn't + * shrinking the centre block as expected. + */ + @Test + public void testBugX() { + RectangleConstraint constraint = new RectangleConstraint( + new Range(0.0, 200.0), new Range(0.0, 100.0)); + BlockContainer container = new BlockContainer(new BorderArrangement()); + BufferedImage image = new BufferedImage(200, 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + + container.add(new EmptyBlock(10.0, 6.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(20.0, 6.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(30.0, 6.0)); + Size2D size = container.arrange(g2, constraint); + assertEquals(60.0, size.width, EPSILON); + assertEquals(6.0, size.height, EPSILON); + + container.clear(); + container.add(new EmptyBlock(10.0, 6.0), RectangleEdge.LEFT); + container.add(new EmptyBlock(20.0, 6.0), RectangleEdge.RIGHT); + container.add(new EmptyBlock(300.0, 6.0)); + size = container.arrange(g2, constraint); + assertEquals(200.0, size.width, EPSILON); + assertEquals(6.0, size.height, EPSILON); + } +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/ColorBlockTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/ColorBlockTest.java new file mode 100755 index 0000000..cb50d95 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/ColorBlockTest.java @@ -0,0 +1,127 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * ColorBlockTest.java + * ------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Mar-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link ColorBlock} class. + */ +public class ColorBlockTest { + + /** + * Confirm that the equals() method can distinguish all the required fields. + */ + @Test + public void testEquals() { + ColorBlock b1 = new ColorBlock(Color.red, 1.0, 2.0); + ColorBlock b2 = new ColorBlock(Color.red, 1.0, 2.0); + assertTrue(b1.equals(b2)); + assertTrue(b2.equals(b2)); + + b1 = new ColorBlock(Color.blue, 1.0, 2.0); + assertFalse(b1.equals(b2)); + b2 = new ColorBlock(Color.blue, 1.0, 2.0); + assertTrue(b1.equals(b2)); + + b1 = new ColorBlock(Color.blue, 1.1, 2.0); + assertFalse(b1.equals(b2)); + b2 = new ColorBlock(Color.blue, 1.1, 2.0); + assertTrue(b1.equals(b2)); + + b1 = new ColorBlock(Color.blue, 1.1, 2.2); + assertFalse(b1.equals(b2)); + b2 = new ColorBlock(Color.blue, 1.1, 2.2); + assertTrue(b1.equals(b2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() { + GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue); + Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0); + ColorBlock b1 = new ColorBlock(gp, 1.0, 2.0); + b1.setBounds(bounds1); + ColorBlock b2 = null; + + try { + b2 = (ColorBlock) b1.clone(); + } + catch (CloneNotSupportedException e) { + fail(e.toString()); + } + assertTrue(b1 != b2); + assertTrue(b1.getClass() == b2.getClass()); + assertTrue(b1.equals(b2)); + + // check independence + bounds1.setRect(1.0, 2.0, 3.0, 4.0); + assertFalse(b1.equals(b2)); + b2.setBounds(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertTrue(b1.equals(b2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue); + ColorBlock b1 = new ColorBlock(gp, 1.0, 2.0); + ColorBlock b2 = (ColorBlock) TestUtilities.serialised(b1); + assertEquals(b1, b2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/ColumnArrangementTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/ColumnArrangementTest.java new file mode 100755 index 0000000..4335fe0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/ColumnArrangementTest.java @@ -0,0 +1,119 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * ColumnArrangementTest.java + * -------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Feb-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.ui.HorizontalAlignment; +import org.jfree.ui.VerticalAlignment; +import org.junit.Test; + +/** + * Tests for the {@link ColumnArrangement} class. + */ +public class ColumnArrangementTest { + + /** + * Confirm that the equals() method can distinguish all the required fields. + */ + @Test + public void testEquals() { + ColumnArrangement c1 = new ColumnArrangement(HorizontalAlignment.LEFT, + VerticalAlignment.TOP, 1.0, 2.0); + ColumnArrangement c2 = new ColumnArrangement(HorizontalAlignment.LEFT, + VerticalAlignment.TOP, 1.0, 2.0); + assertTrue(c1.equals(c2)); + assertTrue(c2.equals(c1)); + + c1 = new ColumnArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.TOP, 1.0, 2.0); + assertFalse(c1.equals(c2)); + c2 = new ColumnArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.TOP, 1.0, 2.0); + assertTrue(c1.equals(c2)); + + c1 = new ColumnArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.BOTTOM, 1.0, 2.0); + assertFalse(c1.equals(c2)); + c2 = new ColumnArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.BOTTOM, 1.0, 2.0); + assertTrue(c1.equals(c2)); + + c1 = new ColumnArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.BOTTOM, 1.1, 2.0); + assertFalse(c1.equals(c2)); + c2 = new ColumnArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.BOTTOM, 1.1, 2.0); + assertTrue(c1.equals(c2)); + + c1 = new ColumnArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.BOTTOM, 1.1, 2.2); + assertFalse(c1.equals(c2)); + c2 = new ColumnArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.BOTTOM, 1.1, 2.2); + assertTrue(c1.equals(c2)); + } + + /** + * Immutable - cloning is not necessary. + */ + @Test + public void testCloning() { + FlowArrangement f1 = new FlowArrangement(); + assertFalse(f1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + FlowArrangement f1 = new FlowArrangement(HorizontalAlignment.LEFT, + VerticalAlignment.TOP, 1.0, 2.0); + FlowArrangement f2 = (FlowArrangement) TestUtilities.serialised(f1); + assertEquals(f1, f2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/EmptyBlockTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/EmptyBlockTest.java new file mode 100755 index 0000000..2d9227b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/EmptyBlockTest.java @@ -0,0 +1,106 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * EmptyBlockTest.java + * ------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Feb-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link EmptyBlock} class. + */ +public class EmptyBlockTest { + + /** + * Confirm that the equals() method can distinguish all the required fields. + */ + @Test + public void testEquals() { + EmptyBlock b1 = new EmptyBlock(1.0, 2.0); + EmptyBlock b2 = new EmptyBlock(1.0, 2.0); + assertTrue(b1.equals(b2)); + assertTrue(b2.equals(b2)); + + b1 = new EmptyBlock(1.1, 2.0); + assertFalse(b1.equals(b2)); + b2 = new EmptyBlock(1.1, 2.0); + assertTrue(b1.equals(b2)); + + b1 = new EmptyBlock(1.1, 2.2); + assertFalse(b1.equals(b2)); + b2 = new EmptyBlock(1.1, 2.2); + assertTrue(b1.equals(b2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() { + EmptyBlock b1 = new EmptyBlock(1.0, 2.0); + EmptyBlock b2 = null; + + try { + b2 = (EmptyBlock) b1.clone(); + } + catch (CloneNotSupportedException e) { + fail(e.toString()); + } + assertTrue(b1 != b2); + assertTrue(b1.getClass() == b2.getClass()); + assertTrue(b1.equals(b2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + EmptyBlock b1 = new EmptyBlock(1.0, 2.0); + EmptyBlock b2 = (EmptyBlock) TestUtilities.serialised(b1); + assertEquals(b1, b2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/FlowArrangementTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/FlowArrangementTest.java new file mode 100755 index 0000000..1ccd813 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/FlowArrangementTest.java @@ -0,0 +1,120 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * FlowArrangementTest.java + * ------------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Feb-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.ui.HorizontalAlignment; +import org.jfree.ui.VerticalAlignment; +import org.junit.Test; + +/** + * Tests for the {@link FlowArrangement} class. + */ +public class FlowArrangementTest { + + /** + * Confirm that the equals() method can distinguish all the required fields. + */ + @Test + public void testEquals() { + FlowArrangement f1 = new FlowArrangement(HorizontalAlignment.LEFT, + VerticalAlignment.TOP, 1.0, 2.0); + FlowArrangement f2 = new FlowArrangement(HorizontalAlignment.LEFT, + VerticalAlignment.TOP, 1.0, 2.0); + assertTrue(f1.equals(f2)); + assertTrue(f2.equals(f1)); + + f1 = new FlowArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.TOP, 1.0, 2.0); + assertFalse(f1.equals(f2)); + f2 = new FlowArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.TOP, 1.0, 2.0); + assertTrue(f1.equals(f2)); + + f1 = new FlowArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.BOTTOM, 1.0, 2.0); + assertFalse(f1.equals(f2)); + f2 = new FlowArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.BOTTOM, 1.0, 2.0); + assertTrue(f1.equals(f2)); + + f1 = new FlowArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.BOTTOM, 1.1, 2.0); + assertFalse(f1.equals(f2)); + f2 = new FlowArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.BOTTOM, 1.1, 2.0); + assertTrue(f1.equals(f2)); + + f1 = new FlowArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.BOTTOM, 1.1, 2.2); + assertFalse(f1.equals(f2)); + f2 = new FlowArrangement(HorizontalAlignment.RIGHT, + VerticalAlignment.BOTTOM, 1.1, 2.2); + assertTrue(f1.equals(f2)); + + } + + /** + * Immutable - cloning is not necessary. + */ + @Test + public void testCloning() { + FlowArrangement f1 = new FlowArrangement(); + assertFalse(f1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + FlowArrangement f1 = new FlowArrangement(HorizontalAlignment.LEFT, + VerticalAlignment.TOP, 1.0, 2.0); + FlowArrangement f2 = (FlowArrangement) TestUtilities.serialised(f1); + assertEquals(f1, f2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/GridArrangementTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/GridArrangementTest.java new file mode 100755 index 0000000..da2372d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/GridArrangementTest.java @@ -0,0 +1,304 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * GridArrangementTest.java + * ------------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Mar-2005 : Version 1 (DG); + * 03-Dec-2008 : Added more tests (DG); + * + */ + +package org.jfree.chart.block; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.ui.Size2D; +import org.junit.Test; + +/** + * Tests for the {@link GridArrangement} class. + */ +public class GridArrangementTest { + + /** + * Confirm that the equals() method can distinguish all the required fields. + */ + @Test + public void testEquals() { + GridArrangement f1 = new GridArrangement(11, 22); + GridArrangement f2 = new GridArrangement(11, 22); + assertTrue(f1.equals(f2)); + assertTrue(f2.equals(f1)); + + f1 = new GridArrangement(33, 22); + assertFalse(f1.equals(f2)); + f2 = new GridArrangement(33, 22); + assertTrue(f1.equals(f2)); + + f1 = new GridArrangement(33, 44); + assertFalse(f1.equals(f2)); + f2 = new GridArrangement(33, 44); + assertTrue(f1.equals(f2)); + } + + /** + * Immutable - cloning is not necessary. + */ + @Test + public void testCloning() { + GridArrangement f1 = new GridArrangement(1, 2); + assertFalse(f1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + GridArrangement f1 = new GridArrangement(33, 44); + GridArrangement f2 = (GridArrangement) TestUtilities.serialised(f1); + assertEquals(f1, f2); + } + + private static final double EPSILON = 0.000000001; + + /** + * Test arrangement with no constraints. + */ + @Test + public void testNN() { + BlockContainer c = createTestContainer1(); + Size2D s = c.arrange(null, RectangleConstraint.NONE); + assertEquals(90.0, s.width, EPSILON); + assertEquals(33.0, s.height, EPSILON); + } + + /** + * Test arrangement with a fixed width and no height constraint. + */ + @Test + public void testFN() { + BlockContainer c = createTestContainer1(); + RectangleConstraint constraint = new RectangleConstraint(100.0, null, + LengthConstraintType.FIXED, 0.0, null, + LengthConstraintType.NONE); + Size2D s = c.arrange(null, constraint); + assertEquals(100.0, s.width, EPSILON); + assertEquals(33.0, s.height, EPSILON); + } + + /** + * Test arrangement with a fixed height and no width constraint. + */ + @Test + public void testNF() { + BlockContainer c = createTestContainer1(); + RectangleConstraint constraint = RectangleConstraint.NONE.toFixedHeight( + 100.0); + Size2D s = c.arrange(null, constraint); + assertEquals(90.0, s.width, EPSILON); + assertEquals(100.0, s.height, EPSILON); + } + + /** + * Test arrangement with a range for the width and a fixed height. + */ + @Test + public void testRF() { + BlockContainer c = createTestContainer1(); + RectangleConstraint constraint = new RectangleConstraint(new Range(40.0, + 60.0), 100.0); + Size2D s = c.arrange(null, constraint); + assertEquals(60.0, s.width, EPSILON); + assertEquals(100.0, s.height, EPSILON); + } + + /** + * Test arrangement with a range for the width and height. + */ + @Test + public void testRR() { + BlockContainer c = createTestContainer1(); + RectangleConstraint constraint = new RectangleConstraint(new Range(40.0, + 60.0), new Range(50.0, 70.0)); + Size2D s = c.arrange(null, constraint); + assertEquals(60.0, s.width, EPSILON); + assertEquals(50.0, s.height, EPSILON); + } + + /** + * Test arrangement with a range for the width and no height constraint. + */ + @Test + public void testRN() { + BlockContainer c = createTestContainer1(); + RectangleConstraint constraint = RectangleConstraint.NONE.toRangeWidth( + new Range(40.0, 60.0)); + Size2D s = c.arrange(null, constraint); + assertEquals(60.0, s.width, EPSILON); + assertEquals(33.0, s.height, EPSILON); + } + + /** + * Test arrangement with a range for the height and no width constraint. + */ + @Test + public void testNR() { + BlockContainer c = createTestContainer1(); + RectangleConstraint constraint = RectangleConstraint.NONE.toRangeHeight( + new Range(40.0, 60.0)); + Size2D s = c.arrange(null, constraint); + assertEquals(90.0, s.width, EPSILON); + assertEquals(40.0, s.height, EPSILON); + } + + private BlockContainer createTestContainer1() { + Block b1 = new EmptyBlock(10, 11); + Block b2 = new EmptyBlock(20, 22); + Block b3 = new EmptyBlock(30, 33); + BlockContainer result = new BlockContainer(new GridArrangement(1, 3)); + result.add(b1); + result.add(b2); + result.add(b3); + return result; + } + + /** + * The arrangement should be able to handle null blocks in the layout. + */ + @Test + public void testNullBlock_FF() { + BlockContainer c = new BlockContainer(new GridArrangement(1, 1)); + c.add(null); + Size2D s = c.arrange(null, new RectangleConstraint(20, 10)); + assertEquals(20.0, s.getWidth(), EPSILON); + assertEquals(10.0, s.getHeight(), EPSILON); + } + + /** + * The arrangement should be able to handle null blocks in the layout. + */ + @Test + public void testNullBlock_FN() { + BlockContainer c = new BlockContainer(new GridArrangement(1, 1)); + c.add(null); + Size2D s = c.arrange(null, RectangleConstraint.NONE.toFixedWidth(10)); + assertEquals(10.0, s.getWidth(), EPSILON); + assertEquals(0.0, s.getHeight(), EPSILON); + } + + /** + * The arrangement should be able to handle null blocks in the layout. + */ + @Test + public void testNullBlock_FR() { + BlockContainer c = new BlockContainer(new GridArrangement(1, 1)); + c.add(null); + Size2D s = c.arrange(null, new RectangleConstraint(30.0, new Range(5.0, + 10.0))); + assertEquals(30.0, s.getWidth(), EPSILON); + assertEquals(5.0, s.getHeight(), EPSILON); + } + + /** + * The arrangement should be able to handle null blocks in the layout. + */ + @Test + public void testNullBlock_NN() { + BlockContainer c = new BlockContainer(new GridArrangement(1, 1)); + c.add(null); + Size2D s = c.arrange(null, RectangleConstraint.NONE); + assertEquals(0.0, s.getWidth(), EPSILON); + assertEquals(0.0, s.getHeight(), EPSILON); + } + + /** + * The arrangement should be able to handle less blocks than grid spaces. + */ + @Test + public void testGridNotFull_FF() { + Block b1 = new EmptyBlock(5, 5); + BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); + c.add(b1); + Size2D s = c.arrange(null, new RectangleConstraint(200, 100)); + assertEquals(200.0, s.getWidth(), EPSILON); + assertEquals(100.0, s.getHeight(), EPSILON); + } + + /** + * The arrangement should be able to handle less blocks than grid spaces. + */ + @Test + public void testGridNotFull_FN() { + Block b1 = new EmptyBlock(5, 5); + BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); + c.add(b1); + Size2D s = c.arrange(null, RectangleConstraint.NONE.toFixedWidth(30.0)); + assertEquals(30.0, s.getWidth(), EPSILON); + assertEquals(10.0, s.getHeight(), EPSILON); + } + + /** + * The arrangement should be able to handle less blocks than grid spaces. + */ + @Test + public void testGridNotFull_FR() { + Block b1 = new EmptyBlock(5, 5); + BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); + c.add(b1); + Size2D s = c.arrange(null, new RectangleConstraint(30.0, new Range(5.0, + 10.0))); + assertEquals(30.0, s.getWidth(), EPSILON); + assertEquals(10.0, s.getHeight(), EPSILON); + } + + /** + * The arrangement should be able to handle less blocks than grid spaces. + */ + @Test + public void testGridNotFull_NN() { + Block b1 = new EmptyBlock(5, 5); + BlockContainer c = new BlockContainer(new GridArrangement(2, 3)); + c.add(b1); + Size2D s = c.arrange(null, RectangleConstraint.NONE); + assertEquals(15.0, s.getWidth(), EPSILON); + assertEquals(10.0, s.getHeight(), EPSILON); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/LabelBlockTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/LabelBlockTest.java new file mode 100755 index 0000000..875e74b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/LabelBlockTest.java @@ -0,0 +1,144 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * LabelBlockTest.java + * ------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 01-Sep-2005 : Version 1 (DG); + * 16-Mar-2007 : Check GradientPaint in testSerialization() (DG); + * 10-Feb-2009 : Added new fields to testEquals() (DG); + * + */ + +package org.jfree.chart.block; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.text.TextBlockAnchor; +import org.jfree.ui.RectangleAnchor; +import org.junit.Test; + +/** + * Some tests for the {@link LabelBlock} class. + */ +public class LabelBlockTest { + + /** + * Confirm that the equals() method can distinguish all the required fields. + */ + @Test + public void testEquals() { + LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", + Font.PLAIN, 12), Color.red); + LabelBlock b2 = new LabelBlock("ABC", new Font("Dialog", + Font.PLAIN, 12), Color.red); + assertTrue(b1.equals(b2)); + assertTrue(b2.equals(b2)); + + b1 = new LabelBlock("XYZ", new Font("Dialog", Font.PLAIN, 12), + Color.red); + assertFalse(b1.equals(b2)); + b2 = new LabelBlock("XYZ", new Font("Dialog", Font.PLAIN, 12), + Color.red); + assertTrue(b1.equals(b2)); + + b1 = new LabelBlock("XYZ", new Font("Dialog", Font.BOLD, 12), + Color.red); + assertFalse(b1.equals(b2)); + b2 = new LabelBlock("XYZ", new Font("Dialog", Font.BOLD, 12), + Color.red); + assertTrue(b1.equals(b2)); + + b1 = new LabelBlock("XYZ", new Font("Dialog", Font.BOLD, 12), + Color.blue); + assertFalse(b1.equals(b2)); + b2 = new LabelBlock("XYZ", new Font("Dialog", Font.BOLD, 12), + Color.blue); + assertTrue(b1.equals(b2)); + + b1.setToolTipText("Tooltip"); + assertFalse(b1.equals(b2)); + b2.setToolTipText("Tooltip"); + assertTrue(b1.equals(b2)); + + b1.setURLText("URL"); + assertFalse(b1.equals(b2)); + b2.setURLText("URL"); + assertTrue(b1.equals(b2)); + + b1.setContentAlignmentPoint(TextBlockAnchor.CENTER_RIGHT); + assertFalse(b1.equals(b2)); + b2.setContentAlignmentPoint(TextBlockAnchor.CENTER_RIGHT); + assertTrue(b1.equals(b2)); + + b1.setTextAnchor(RectangleAnchor.BOTTOM_RIGHT); + assertFalse(b1.equals(b2)); + b2.setTextAnchor(RectangleAnchor.BOTTOM_RIGHT); + assertTrue(b1.equals(b2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", + Font.PLAIN, 12), Color.red); + LabelBlock b2 = (LabelBlock) b1.clone(); + assertTrue(b1 != b2); + assertTrue(b1.getClass() == b2.getClass()); + assertTrue(b1.equals(b2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue); + LabelBlock b1 = new LabelBlock("ABC", new Font("Dialog", + Font.PLAIN, 12), gp); + LabelBlock b2 = (LabelBlock) TestUtilities.serialised(b1); + assertEquals(b1, b2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/LineBorderTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/LineBorderTest.java new file mode 100755 index 0000000..76d3b0d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/LineBorderTest.java @@ -0,0 +1,117 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * LineBorderTest.java + * ------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Mar-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.ui.RectangleInsets; +import org.junit.Test; + +/** + * Tests for the {@link LineBorder} class. + */ +public class LineBorderTest { + + /** + * Confirm that the equals() method can distinguish all the required fields. + */ + @Test + public void testEquals() { + LineBorder b1 = new LineBorder(Color.red, new BasicStroke(1.0f), + new RectangleInsets(1.0, 1.0, 1.0, 1.0)); + LineBorder b2 = new LineBorder(Color.red, new BasicStroke(1.0f), + new RectangleInsets(1.0, 1.0, 1.0, 1.0)); + assertTrue(b1.equals(b2)); + assertTrue(b2.equals(b2)); + + b1 = new LineBorder(Color.blue, new BasicStroke(1.0f), + new RectangleInsets(1.0, 1.0, 1.0, 1.0)); + assertFalse(b1.equals(b2)); + b2 = new LineBorder(Color.blue, new BasicStroke(1.0f), + new RectangleInsets(1.0, 1.0, 1.0, 1.0)); + assertTrue(b1.equals(b2)); + + b1 = new LineBorder(Color.blue, new BasicStroke(1.1f), + new RectangleInsets(1.0, 1.0, 1.0, 1.0)); + assertFalse(b1.equals(b2)); + b2 = new LineBorder(Color.blue, new BasicStroke(1.1f), + new RectangleInsets(1.0, 1.0, 1.0, 1.0)); + assertTrue(b1.equals(b2)); + + b1 = new LineBorder(Color.blue, new BasicStroke(1.1f), + new RectangleInsets(1.0, 2.0, 3.0, 4.0)); + assertFalse(b1.equals(b2)); + b2 = new LineBorder(Color.blue, new BasicStroke(1.1f), + new RectangleInsets(1.0, 2.0, 3.0, 4.0)); + assertTrue(b1.equals(b2)); + + } + + /** + * Immutable - cloning not necessary. + */ + @Test + public void testCloning() { + LineBorder b1 = new LineBorder(); + assertFalse(b1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + LineBorder b1 = new LineBorder(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow), new BasicStroke(1.0f), + new RectangleInsets(1.0, 1.0, 1.0, 1.0)); + LineBorder b2 = (LineBorder) TestUtilities.serialised(b1); + assertEquals(b1, b2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/RectangleConstraintTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/RectangleConstraintTest.java new file mode 100755 index 0000000..000c537 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/block/RectangleConstraintTest.java @@ -0,0 +1,138 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * RectangleConstraintTest.java + * ---------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Oct-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.block; + +import static org.junit.Assert.assertEquals; + +import org.jfree.data.Range; +import org.jfree.ui.Size2D; +import org.junit.Test; + +/** + * Tests for the {@link RectangleConstraint} class. + */ +public class RectangleConstraintTest { + + private static final double EPSILON = 0.0000000001; + + /** + * Run some checks on the constrained size calculation. + */ + @Test + public void testCalculateConstrainedSize() { + Size2D s; + + // NONE / NONE + RectangleConstraint c1 = RectangleConstraint.NONE; + s = c1.calculateConstrainedSize(new Size2D(1.2, 3.4)); + assertEquals(s.width, 1.2, EPSILON); + assertEquals(s.height, 3.4, EPSILON); + + // NONE / RANGE + RectangleConstraint c2 = new RectangleConstraint( + 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE, + 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE + ); + s = c2.calculateConstrainedSize(new Size2D(1.2, 3.4)); + assertEquals(s.width, 1.2, EPSILON); + assertEquals(s.height, 3.0, EPSILON); + + // NONE / FIXED + RectangleConstraint c3 = new RectangleConstraint( + 0.0, null, LengthConstraintType.NONE, + 9.9, null, LengthConstraintType.FIXED + ); + s = c3.calculateConstrainedSize(new Size2D(1.2, 3.4)); + assertEquals(s.width, 1.2, EPSILON); + assertEquals(s.height, 9.9, EPSILON); + + // RANGE / NONE + RectangleConstraint c4 = new RectangleConstraint( + 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE, + 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE + ); + s = c4.calculateConstrainedSize(new Size2D(1.2, 3.4)); + assertEquals(s.width, 2.0, EPSILON); + assertEquals(s.height, 3.4, EPSILON); + + // RANGE / RANGE + RectangleConstraint c5 = new RectangleConstraint( + 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE, + 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE + ); + s = c5.calculateConstrainedSize(new Size2D(1.2, 3.4)); + assertEquals(s.width, 2.0, EPSILON); + assertEquals(s.height, 3.0, EPSILON); + + // RANGE / FIXED + RectangleConstraint c6 = new RectangleConstraint( + 0.0, null, LengthConstraintType.NONE, + 9.9, null, LengthConstraintType.FIXED + ); + s = c6.calculateConstrainedSize(new Size2D(1.2, 3.4)); + assertEquals(s.width, 1.2, EPSILON); + assertEquals(s.height, 9.9, EPSILON); + + // FIXED / NONE + RectangleConstraint c7 = RectangleConstraint.NONE; + s = c7.calculateConstrainedSize(new Size2D(1.2, 3.4)); + assertEquals(s.width, 1.2, EPSILON); + assertEquals(s.height, 3.4, EPSILON); + + // FIXED / RANGE + RectangleConstraint c8 = new RectangleConstraint( + 0.0, new Range(0.0, 0.0), LengthConstraintType.NONE, + 0.0, new Range(2.0, 3.0), LengthConstraintType.RANGE + ); + s = c8.calculateConstrainedSize(new Size2D(1.2, 3.4)); + assertEquals(s.width, 1.2, EPSILON); + assertEquals(s.height, 3.0, EPSILON); + + // FIXED / FIXED + RectangleConstraint c9 = new RectangleConstraint( + 0.0, null, LengthConstraintType.NONE, + 9.9, null, LengthConstraintType.FIXED + ); + s = c9.calculateConstrainedSize(new Size2D(1.2, 3.4)); + assertEquals(s.width, 1.2, EPSILON); + assertEquals(s.height, 9.9, EPSILON); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/CategoryItemEntityTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/CategoryItemEntityTest.java new file mode 100755 index 0000000..89fbb0f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/CategoryItemEntityTest.java @@ -0,0 +1,141 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * CategoryItemEntityTest.java + * --------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-May-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.entity; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.category.DefaultCategoryDataset; +import org.junit.Test; + +/** + * Tests for the {@link CategoryItemEntity} class. + */ +public class CategoryItemEntityTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(1.0, "R1", "C1"); + d.addValue(2.0, "R1", "C2"); + d.addValue(3.0, "R2", "C1"); + d.addValue(4.0, "R2", "C2"); + CategoryItemEntity e1 = new CategoryItemEntity(new Rectangle2D.Double( + 1.0, 2.0, 3.0, 4.0), "ToolTip", "URL", d, 1, "C2", 1); + CategoryItemEntity e2 = new CategoryItemEntity(new Rectangle2D.Double( + 1.0, 2.0, 3.0, 4.0), "ToolTip", "URL", d, 1, "C2", 1); + assertTrue(e1.equals(e2)); + + e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertFalse(e1.equals(e2)); + e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertTrue(e1.equals(e2)); + + e1.setToolTipText("New ToolTip"); + assertFalse(e1.equals(e2)); + e2.setToolTipText("New ToolTip"); + assertTrue(e1.equals(e2)); + + e1.setURLText("New URL"); + assertFalse(e1.equals(e2)); + e2.setURLText("New URL"); + assertTrue(e1.equals(e2)); + + e1.setCategory("C1"); + assertFalse(e1.equals(e2)); + e2.setCategory("C1"); + assertTrue(e1.equals(e2)); + + e1.setCategoryIndex(0); + assertFalse(e1.equals(e2)); + e2.setCategoryIndex(0); + assertTrue(e1.equals(e2)); + + e1.setSeries(0); + assertFalse(e1.equals(e2)); + e2.setSeries(0); + assertTrue(e1.equals(e2)); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(1.0, "R1", "C1"); + d.addValue(2.0, "R1", "C2"); + d.addValue(3.0, "R2", "C1"); + d.addValue(4.0, "R2", "C2"); + CategoryItemEntity e1 = new CategoryItemEntity(new Rectangle2D.Double( + 1.0, 2.0, 3.0, 4.0), "ToolTip", "URL", d, 1, "C2", 1); + CategoryItemEntity e2 = (CategoryItemEntity) e1.clone(); + assertTrue(e1 != e2); + assertTrue(e1.getClass() == e2.getClass()); + assertTrue(e1.equals(e2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(1.0, "R1", "C1"); + d.addValue(2.0, "R1", "C2"); + d.addValue(3.0, "R2", "C1"); + d.addValue(4.0, "R2", "C2"); + CategoryItemEntity e1 = new CategoryItemEntity(new Rectangle2D.Double( + 1.0, 2.0, 3.0, 4.0), "ToolTip", "URL", d, 1, "C2", 1); + CategoryItemEntity e2 = (CategoryItemEntity) TestUtilities.serialised(e1); + assertEquals(e1, e2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/CategoryLabelEntityTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/CategoryLabelEntityTest.java new file mode 100755 index 0000000..6053dab --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/CategoryLabelEntityTest.java @@ -0,0 +1,115 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * CategoryLabelEntityTest.java + * ---------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 17-Nov-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.entity; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link CategoryLabelEntity} class. + */ +public class CategoryLabelEntityTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + CategoryLabelEntity e1 = new CategoryLabelEntity("A", + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); + CategoryLabelEntity e2 = new CategoryLabelEntity("A", + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); + assertTrue(e1.equals(e2)); + + e1 = new CategoryLabelEntity("B", new Rectangle2D.Double(1.0, 2.0, + 3.0, 4.0), "ToolTip", "URL"); + assertFalse(e1.equals(e2)); + e2 = new CategoryLabelEntity("B", new Rectangle2D.Double(1.0, 2.0, + 3.0, 4.0), "ToolTip", "URL"); + assertTrue(e1.equals(e2)); + + e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertFalse(e1.equals(e2)); + e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertTrue(e1.equals(e2)); + + e1.setToolTipText("New ToolTip"); + assertFalse(e1.equals(e2)); + e2.setToolTipText("New ToolTip"); + assertTrue(e1.equals(e2)); + + e1.setURLText("New URL"); + assertFalse(e1.equals(e2)); + e2.setURLText("New URL"); + assertTrue(e1.equals(e2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CategoryLabelEntity e1 = new CategoryLabelEntity("A", + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); + CategoryLabelEntity e2 = (CategoryLabelEntity) e1.clone(); + assertTrue(e1 != e2); + assertTrue(e1.getClass() == e2.getClass()); + assertTrue(e1.equals(e2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CategoryLabelEntity e1 = new CategoryLabelEntity("A", + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL"); + CategoryLabelEntity e2 = (CategoryLabelEntity) TestUtilities.serialised(e1); + assertEquals(e1, e2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/ContourEntityTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/ContourEntityTest.java new file mode 100755 index 0000000..2ac48e2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/ContourEntityTest.java @@ -0,0 +1,115 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * ContourEntityTest.java + * ---------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-May-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.entity; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the ContourEntity class. + */ +public class ContourEntityTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + ContourEntity e1 = new ContourEntity( + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL" + ); + ContourEntity e2 = new ContourEntity( + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), "ToolTip", "URL" + ); + assertTrue(e1.equals(e2)); + + e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertFalse(e1.equals(e2)); + e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertTrue(e1.equals(e2)); + + e1.setToolTipText("New ToolTip"); + assertFalse(e1.equals(e2)); + e2.setToolTipText("New ToolTip"); + assertTrue(e1.equals(e2)); + + e1.setURLText("New URL"); + assertFalse(e1.equals(e2)); + e2.setURLText("New URL"); + assertTrue(e1.equals(e2)); + + e1.setIndex(99); + assertFalse(e1.equals(e2)); + e2.setIndex(99); + assertTrue(e1.equals(e2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ContourEntity e1 = new ContourEntity(new Rectangle2D.Double(1.0, 2.0, + 3.0, 4.0), "ToolTip", "URL"); + ContourEntity e2 = (ContourEntity) e1.clone(); + assertTrue(e1 != e2); + assertTrue(e1.getClass() == e2.getClass()); + assertTrue(e1.equals(e2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ContourEntity e1 = new ContourEntity(new Rectangle2D.Double(1.0, 2.0, + 3.0, 4.0), "ToolTip", "URL"); + ContourEntity e2 = (ContourEntity) TestUtilities.serialised(e1); + assertEquals(e1, e2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/LegendItemEntityTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/LegendItemEntityTest.java new file mode 100755 index 0000000..9c63e96 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/LegendItemEntityTest.java @@ -0,0 +1,127 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * LegendItemEntityTest.java + * ------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-May-2004 : Version 1 (DG); + * 18-May-2007 : Added checks for new fields (DG); + * + */ + +package org.jfree.chart.entity; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.category.DefaultCategoryDataset; +import org.junit.Test; + +/** + * Tests for the {@link LegendItemEntity} class. + */ +public class LegendItemEntityTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + LegendItemEntity e1 = new LegendItemEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0)); + LegendItemEntity e2 = new LegendItemEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0)); + assertTrue(e1.equals(e2)); + + e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertFalse(e1.equals(e2)); + e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertTrue(e1.equals(e2)); + + e1.setToolTipText("New ToolTip"); + assertFalse(e1.equals(e2)); + e2.setToolTipText("New ToolTip"); + assertTrue(e1.equals(e2)); + + e1.setURLText("New URL"); + assertFalse(e1.equals(e2)); + e2.setURLText("New URL"); + assertTrue(e1.equals(e2)); + + e1.setDataset(new DefaultCategoryDataset()); + assertFalse(e1.equals(e2)); + e2.setDataset(new DefaultCategoryDataset()); + assertTrue(e1.equals(e2)); + + e1.setSeriesKey("A"); + assertFalse(e1.equals(e2)); + e2.setSeriesKey("A"); + assertTrue(e1.equals(e2)); + + e1.setSeriesIndex(7); + assertFalse(e1.equals(e2)); + e2.setSeriesIndex(7); + assertTrue(e1.equals(e2)); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + LegendItemEntity e1 = new LegendItemEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0)); + LegendItemEntity e2 = (LegendItemEntity) e1.clone(); + assertTrue(e1 != e2); + assertTrue(e1.getClass() == e2.getClass()); + assertTrue(e1.equals(e2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + LegendItemEntity e1 = new LegendItemEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0)); + LegendItemEntity e2 = (LegendItemEntity) TestUtilities.serialised(e1); + assertEquals(e1, e2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/PieSectionEntityTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/PieSectionEntityTest.java new file mode 100755 index 0000000..b581f65 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/PieSectionEntityTest.java @@ -0,0 +1,134 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * PieSectionEntityTest.java + * ------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-May-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.entity; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.DefaultPieDataset; +import org.junit.Test; + +/** + * Tests for the {@link PieSectionEntity} class. + */ +public class PieSectionEntityTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double( + 1.0, 2.0, 3.0, 4.0), new DefaultPieDataset(), 1, 2, "Key", + "ToolTip", "URL"); + PieSectionEntity e2 = new PieSectionEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0), new DefaultPieDataset(), 1, 2, "Key", + "ToolTip", "URL"); + assertTrue(e1.equals(e2)); + + e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertFalse(e1.equals(e2)); + e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertTrue(e1.equals(e2)); + + e1.setToolTipText("New ToolTip"); + assertFalse(e1.equals(e2)); + e2.setToolTipText("New ToolTip"); + assertTrue(e1.equals(e2)); + + e1.setURLText("New URL"); + assertFalse(e1.equals(e2)); + e2.setURLText("New URL"); + assertTrue(e1.equals(e2)); + + e1.setDataset(null); + assertFalse(e1.equals(e2)); + e2.setDataset(null); + assertTrue(e1.equals(e2)); + + e1.setPieIndex(99); + assertFalse(e1.equals(e2)); + e2.setPieIndex(99); + assertTrue(e1.equals(e2)); + + e1.setSectionIndex(66); + assertFalse(e1.equals(e2)); + e2.setSectionIndex(66); + assertTrue(e1.equals(e2)); + + e1.setSectionKey("ABC"); + assertFalse(e1.equals(e2)); + e2.setSectionKey("ABC"); + assertTrue(e1.equals(e2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0), new DefaultPieDataset(), 1, 2, "Key", + "ToolTip", "URL"); + PieSectionEntity e2 = (PieSectionEntity) e1.clone(); + assertTrue(e1 != e2); + assertTrue(e1.getClass() == e2.getClass()); + assertTrue(e1.equals(e2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0), new DefaultPieDataset(), 1, 2, "Key", + "ToolTip", "URL"); + PieSectionEntity e2 = (PieSectionEntity) TestUtilities.serialised(e1); + assertEquals(e1, e2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/StandardEntityCollectionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/StandardEntityCollectionTest.java new file mode 100755 index 0000000..edab641 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/StandardEntityCollectionTest.java @@ -0,0 +1,117 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * StandardEntityCollectionTest.java + * --------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-May-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.entity; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.DefaultPieDataset; +import org.junit.Test; + +/** + * Tests for the {@link StandardEntityCollection} class. + */ +public class StandardEntityCollectionTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + StandardEntityCollection c1 = new StandardEntityCollection(); + StandardEntityCollection c2 = new StandardEntityCollection(); + assertTrue(c1.equals(c2)); + + PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", + "ToolTip", "URL"); + c1.add(e1); + assertFalse(c1.equals(c2)); + PieSectionEntity e2 = new PieSectionEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", + "ToolTip", "URL"); + c2.add(e2); + assertTrue(c1.equals(c2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", + "ToolTip", "URL"); + StandardEntityCollection c1 = new StandardEntityCollection(); + c1.add(e1); + StandardEntityCollection c2 = (StandardEntityCollection) c1.clone(); + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + + // check independence + c1.clear(); + assertFalse(c1.equals(c2)); + c2.clear(); + assertTrue(c1.equals(c2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PieSectionEntity e1 = new PieSectionEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0), new DefaultPieDataset(), 0, 1, "Key", + "ToolTip", "URL"); + StandardEntityCollection c1 = new StandardEntityCollection(); + c1.add(e1); + StandardEntityCollection c2 = (StandardEntityCollection) + TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/TickLabelEntityTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/TickLabelEntityTest.java new file mode 100755 index 0000000..db15c0b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/TickLabelEntityTest.java @@ -0,0 +1,108 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * TickLabelEntityTest.java + * ------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-May-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.entity; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link TickLabelEntity} class. + */ +public class TickLabelEntityTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + TickLabelEntity e1 = new TickLabelEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0), "ToolTip", "URL"); + TickLabelEntity e2 = new TickLabelEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0), "ToolTip", "URL"); + assertTrue(e1.equals(e2)); + + e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertFalse(e1.equals(e2)); + e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertTrue(e1.equals(e2)); + + e1.setToolTipText("New ToolTip"); + assertFalse(e1.equals(e2)); + e2.setToolTipText("New ToolTip"); + assertTrue(e1.equals(e2)); + + e1.setURLText("New URL"); + assertFalse(e1.equals(e2)); + e2.setURLText("New URL"); + assertTrue(e1.equals(e2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + TickLabelEntity e1 = new TickLabelEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0), "ToolTip", "URL"); + TickLabelEntity e2 = (TickLabelEntity) e1.clone(); + assertTrue(e1 != e2); + assertTrue(e1.getClass() == e2.getClass()); + assertTrue(e1.equals(e2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TickLabelEntity e1 = new TickLabelEntity(new Rectangle2D.Double(1.0, + 2.0, 3.0, 4.0), "ToolTip", "URL"); + TickLabelEntity e2 = (TickLabelEntity) TestUtilities.serialised(e1); + assertEquals(e1, e2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/XYItemEntityTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/XYItemEntityTest.java new file mode 100755 index 0000000..52b0e0b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/entity/XYItemEntityTest.java @@ -0,0 +1,121 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * XYItemEntityTest.java + * --------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-May-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.entity; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.time.TimeSeriesCollection; +import org.junit.Test; + +/** + * Tests for the {@link XYItemEntity} class. + */ +public class XYItemEntityTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XYItemEntity e1 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, + 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"); + XYItemEntity e2 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, + 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"); + assertTrue(e1.equals(e2)); + + e1.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertFalse(e1.equals(e2)); + e2.setArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertTrue(e1.equals(e2)); + + e1.setToolTipText("New ToolTip"); + assertFalse(e1.equals(e2)); + e2.setToolTipText("New ToolTip"); + assertTrue(e1.equals(e2)); + + e1.setURLText("New URL"); + assertFalse(e1.equals(e2)); + e2.setURLText("New URL"); + assertTrue(e1.equals(e2)); + + e1.setSeriesIndex(88); + assertFalse(e1.equals(e2)); + e2.setSeriesIndex(88); + assertTrue(e1.equals(e2)); + + e1.setItem(88); + assertFalse(e1.equals(e2)); + e2.setItem(88); + assertTrue(e1.equals(e2)); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYItemEntity e1 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, + 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"); + XYItemEntity e2 = (XYItemEntity) e1.clone(); + assertTrue(e1 != e2); + assertTrue(e1.getClass() == e2.getClass()); + assertTrue(e1.equals(e2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYItemEntity e1 = new XYItemEntity(new Rectangle2D.Double(1.0, 2.0, + 3.0, 4.0), new TimeSeriesCollection(), 1, 9, "ToolTip", "URL"); + XYItemEntity e2 = (XYItemEntity) TestUtilities.serialised(e1); + assertEquals(e1, e2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGeneratorTest.java new file mode 100755 index 0000000..2630061 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/DynamicDriveToolTipTagFragmentGeneratorTest.java @@ -0,0 +1,66 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------------------ + * DynamicDriveToolTipTagFragmentGeneratorTest.java + * ------------------------------------------------ + * (C) Copyright 2009-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2009 : Version 1 (DG); + * + */ + +package org.jfree.chart.imagemap; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +/** + * Tests for the {@link DynamicDriveToolTipTagFragmentGenerator} class. + */ +public class DynamicDriveToolTipTagFragmentGeneratorTest { + + /** + * Some checks for the generateURLFragment() method. + */ + @Test + public void testGenerateURLFragment() { + OverLIBToolTipTagFragmentGenerator g + = new OverLIBToolTipTagFragmentGenerator(); + assertEquals(" onMouseOver=\"return overlib('abc');\"" + + " onMouseOut=\"return nd();\"", + g.generateToolTipFragment("abc")); + assertEquals(" onMouseOver=\"return overlib(" + + "'It\\'s \\\"A\\\", 100.0');\" onMouseOut=\"return nd();\"", + g.generateToolTipFragment("It\'s \"A\", 100.0")); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/ImageMapUtilitiesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/ImageMapUtilitiesTest.java new file mode 100755 index 0000000..d8f67c0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/ImageMapUtilitiesTest.java @@ -0,0 +1,79 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * ImageMapUtilitiesTest.java + * -------------------------- + * (C) Copyright 2009-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2009 : Version 1 (DG); + * + */ + +package org.jfree.chart.imagemap; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +/** + * Tests for the {@link ImageMapUtilities} class. + */ +public class ImageMapUtilitiesTest { + + /** + * Some checks for the htmlEscape() method. + */ + @Test + public void testHTMLEscape() { + assertEquals("", ImageMapUtilities.htmlEscape("")); + assertEquals("abc", ImageMapUtilities.htmlEscape("abc")); + assertEquals("&", ImageMapUtilities.htmlEscape("&")); + assertEquals(""", ImageMapUtilities.htmlEscape("\"")); + assertEquals("<", ImageMapUtilities.htmlEscape("<")); + assertEquals(">", ImageMapUtilities.htmlEscape(">")); + assertEquals("'", ImageMapUtilities.htmlEscape("\'")); + assertEquals("\abc", ImageMapUtilities.htmlEscape("\\abc")); + assertEquals("abc\n", ImageMapUtilities.htmlEscape("abc\n")); + } + + /** + * Some checks for the javascriptEscape() method. + */ + @Test + public void testJavascriptEscape() { + assertEquals("", ImageMapUtilities.javascriptEscape("")); + assertEquals("abc", ImageMapUtilities.javascriptEscape("abc")); + assertEquals("\\\'", ImageMapUtilities.javascriptEscape("\'")); + assertEquals("\\\"", ImageMapUtilities.javascriptEscape("\"")); + assertEquals("\\\\", ImageMapUtilities.javascriptEscape("\\")); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/OverLIBToolTipTagFragmentGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/OverLIBToolTipTagFragmentGeneratorTest.java new file mode 100755 index 0000000..60584ba --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/OverLIBToolTipTagFragmentGeneratorTest.java @@ -0,0 +1,66 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------------- + * OverLIBToolTipTagFragmentGeneratorTest.java + * ------------------------------------------- + * (C) Copyright 2009-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2009 : Version 1 (DG); + * + */ + +package org.jfree.chart.imagemap; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +/** + * Tests for the {@link OverLIBToolTipTagFragmentGenerator} class. + */ +public class OverLIBToolTipTagFragmentGeneratorTest { + + /** + * Some checks for the generateURLFragment() method. + */ + @Test + public void testGenerateURLFragment() { + OverLIBToolTipTagFragmentGenerator g + = new OverLIBToolTipTagFragmentGenerator(); + assertEquals(" onMouseOver=\"return overlib('abc');\"" + + " onMouseOut=\"return nd();\"", + g.generateToolTipFragment("abc")); + assertEquals(" onMouseOver=\"return overlib(" + + "'It\\'s \\\"A\\\", 100.0');\" onMouseOut=\"return nd();\"", + g.generateToolTipFragment("It\'s \"A\", 100.0")); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/StandardToolTipTagFragmentGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/StandardToolTipTagFragmentGeneratorTest.java new file mode 100755 index 0000000..85f8da2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/StandardToolTipTagFragmentGeneratorTest.java @@ -0,0 +1,64 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------------------- + * StandardToolTipTagFragmentGeneratorTest.java + * -------------------------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Dec-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.imagemap; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +/** + * Tests for the {@link StandardToolTipTagFragmentGenerator} class. + */ +public class StandardToolTipTagFragmentGeneratorTest { + + /** + * Some checks for the generateURLFragment() method. + */ + @Test + public void testGenerateURLFragment() { + StandardToolTipTagFragmentGenerator g + = new StandardToolTipTagFragmentGenerator(); + assertEquals(" title=\"abc\" alt=\"\"", + g.generateToolTipFragment("abc")); + assertEquals(" title=\"Series "A", 100.0\" alt=\"\"", + g.generateToolTipFragment("Series \"A\", 100.0")); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/StandardURLTagFragmentGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/StandardURLTagFragmentGeneratorTest.java new file mode 100755 index 0000000..6a37417 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/imagemap/StandardURLTagFragmentGeneratorTest.java @@ -0,0 +1,65 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------------- + * StandardURLTagFragmentGeneratorTest.java + * ---------------------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Dec-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.imagemap; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +/** + * Tests for the {@link StandardURLTagFragmentGenerator} class. + */ +public class StandardURLTagFragmentGeneratorTest { + + /** + * Some checks for the generateURLFragment() method. + */ + @Test + public void testGenerateURLFragment() { + StandardURLTagFragmentGenerator g + = new StandardURLTagFragmentGenerator(); + assertEquals(" href=\"abc\"", g.generateURLFragment("abc")); + assertEquals(" href=\"images/abc.png\"", + g.generateURLFragment("images/abc.png")); + assertEquals(" href=\"http://www.jfree.org/images/abc.png\"", + g.generateURLFragment("http://www.jfree.org/images/abc.png")); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/BoxAndWhiskerToolTipGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/BoxAndWhiskerToolTipGeneratorTest.java new file mode 100755 index 0000000..b17e6ab --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/BoxAndWhiskerToolTipGeneratorTest.java @@ -0,0 +1,133 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------------- + * BoxAndWhiskerToolTipGeneratorTest.java + * -------------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 02-Jun-2004 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.DecimalFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link BoxAndWhiskerToolTipGenerator} class. + */ +public class BoxAndWhiskerToolTipGeneratorTest { + + /** + * A series of tests for the equals() method. + */ + @Test + public void testEquals() { + + // standard test + BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); + BoxAndWhiskerToolTipGenerator g2 = new BoxAndWhiskerToolTipGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + // tooltip format + g1 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}", + new DecimalFormat("0.0")); + g2 = new BoxAndWhiskerToolTipGenerator("{1} {2}", + new DecimalFormat("0.0")); + assertFalse(g1.equals(g2)); + g2 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}", + new DecimalFormat("0.0")); + assertTrue(g1.equals(g2)); + + // Y format + g1 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}", + new DecimalFormat("0.0")); + g2 = new BoxAndWhiskerToolTipGenerator("{0} --> {1} {2}", + new DecimalFormat("0.00")); + assertFalse(g1.equals(g2)); + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); + BoxAndWhiskerToolTipGenerator g2 = new BoxAndWhiskerToolTipGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); + BoxAndWhiskerToolTipGenerator g2 = (BoxAndWhiskerToolTipGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + BoxAndWhiskerToolTipGenerator g1 = new BoxAndWhiskerToolTipGenerator(); + BoxAndWhiskerToolTipGenerator g2 = (BoxAndWhiskerToolTipGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/BoxAndWhiskerXYToolTipGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/BoxAndWhiskerXYToolTipGeneratorTest.java new file mode 100755 index 0000000..cea1228 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/BoxAndWhiskerXYToolTipGeneratorTest.java @@ -0,0 +1,156 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------------- + * BoxAndWhiskerXYToolTipGeneratorTest.java + * ---------------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Aug-2003 : Version 1 (DG); + * 27-Feb-2004 : Renamed BoxAndWhiskerItemLabelGenerator + * --> XYBoxAndWhiskerItemLabelGenerator (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link BoxAndWhiskerXYToolTipGenerator} class. + */ +public class BoxAndWhiskerXYToolTipGeneratorTest { + + /** + * A series of tests for the equals() method. + */ + @Test + public void testEquals() { + + // standard test + BoxAndWhiskerXYToolTipGenerator g1 + = new BoxAndWhiskerXYToolTipGenerator(); + BoxAndWhiskerXYToolTipGenerator g2 + = new BoxAndWhiskerXYToolTipGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + // tooltip format + g1 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", + new SimpleDateFormat("yyyy"), new DecimalFormat("0.0")); + g2 = new BoxAndWhiskerXYToolTipGenerator("{1} {2}", + new SimpleDateFormat("yyyy"), new DecimalFormat("0.0")); + assertFalse(g1.equals(g2)); + g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", + new SimpleDateFormat("yyyy"), new DecimalFormat("0.0")); + assertTrue(g1.equals(g2)); + + // date format + g1 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", + new SimpleDateFormat("yyyy"), new DecimalFormat("0.0")); + g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", + new SimpleDateFormat("MMM-yyyy"), new DecimalFormat("0.0")); + assertFalse(g1.equals(g2)); + g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", + new SimpleDateFormat("yyyy"), new DecimalFormat("0.0")); + assertTrue(g1.equals(g2)); + + // Y format + g1 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", + new SimpleDateFormat("yyyy"), new DecimalFormat("0.0")); + g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", + new SimpleDateFormat("yyyy"), new DecimalFormat("0.00")); + assertFalse(g1.equals(g2)); + g2 = new BoxAndWhiskerXYToolTipGenerator("{0} --> {1} {2}", + new SimpleDateFormat("yyyy"), new DecimalFormat("0.0")); + assertTrue(g1.equals(g2)); + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + BoxAndWhiskerXYToolTipGenerator g1 + = new BoxAndWhiskerXYToolTipGenerator(); + BoxAndWhiskerXYToolTipGenerator g2 + = new BoxAndWhiskerXYToolTipGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + BoxAndWhiskerXYToolTipGenerator g1 + = new BoxAndWhiskerXYToolTipGenerator(); + BoxAndWhiskerXYToolTipGenerator g2 = (BoxAndWhiskerXYToolTipGenerator) + g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + BoxAndWhiskerXYToolTipGenerator g1 + = new BoxAndWhiskerXYToolTipGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + BoxAndWhiskerXYToolTipGenerator g1 + = new BoxAndWhiskerXYToolTipGenerator(); + BoxAndWhiskerXYToolTipGenerator g2 = (BoxAndWhiskerXYToolTipGenerator) TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/BubbleXYItemLabelGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/BubbleXYItemLabelGeneratorTest.java new file mode 100755 index 0000000..da3d6f1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/BubbleXYItemLabelGeneratorTest.java @@ -0,0 +1,198 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------- + * BubbleXYItemLabelGeneratorTest.java + * ----------------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Jan-2006 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link BubbleXYItemLabelGenerator} class. + */ +public class BubbleXYItemLabelGeneratorTest { + + /** + * A series of tests for the equals() method. + */ + @Test + public void testEquals() { + + // some setup... + String f1 = "{1}"; + String f2 = "{2}"; + NumberFormat xnf1 = new DecimalFormat("0.00"); + NumberFormat xnf2 = new DecimalFormat("0.000"); + NumberFormat ynf1 = new DecimalFormat("0.00"); + NumberFormat ynf2 = new DecimalFormat("0.000"); + NumberFormat znf1 = new DecimalFormat("0.00"); + NumberFormat znf2 = new DecimalFormat("0.000"); + + BubbleXYItemLabelGenerator g1 = null; + BubbleXYItemLabelGenerator g2 = null; + + g1 = new BubbleXYItemLabelGenerator(f1, xnf1, ynf1, znf1); + g2 = new BubbleXYItemLabelGenerator(f1, xnf1, ynf1, znf1); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new BubbleXYItemLabelGenerator(f2, xnf1, ynf1, znf1); + assertFalse(g1.equals(g2)); + g2 = new BubbleXYItemLabelGenerator(f2, xnf1, ynf1, znf1); + assertTrue(g1.equals(g2)); + + g1 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf1, znf1); + assertFalse(g1.equals(g2)); + g2 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf1, znf1); + assertTrue(g1.equals(g2)); + + g1 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf2, znf1); + assertFalse(g1.equals(g2)); + g2 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf2, znf1); + assertTrue(g1.equals(g2)); + + g1 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf2, znf2); + assertFalse(g1.equals(g2)); + g2 = new BubbleXYItemLabelGenerator(f2, xnf2, ynf2, znf2); + assertTrue(g1.equals(g2)); + + DateFormat xdf1 = new SimpleDateFormat("d-MMM"); + DateFormat xdf2 = new SimpleDateFormat("d-MMM-yyyy"); + DateFormat ydf1 = new SimpleDateFormat("d-MMM"); + DateFormat ydf2 = new SimpleDateFormat("d-MMM-yyyy"); + DateFormat zdf1 = new SimpleDateFormat("d-MMM"); + DateFormat zdf2 = new SimpleDateFormat("d-MMM-yyyy"); + + g1 = new BubbleXYItemLabelGenerator(f1, xdf1, ydf1, zdf1); + g2 = new BubbleXYItemLabelGenerator(f1, xdf1, ydf1, zdf1); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf1, zdf1); + assertFalse(g1.equals(g2)); + g2 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf1, zdf1); + assertTrue(g1.equals(g2)); + + g1 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf2, zdf1); + assertFalse(g1.equals(g2)); + g2 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf2, zdf1); + assertTrue(g1.equals(g2)); + + g1 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf2, zdf2); + assertFalse(g1.equals(g2)); + g2 = new BubbleXYItemLabelGenerator(f1, xdf2, ydf2, zdf2); + assertTrue(g1.equals(g2)); + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + BubbleXYItemLabelGenerator g1 + = new BubbleXYItemLabelGenerator(); + BubbleXYItemLabelGenerator g2 + = new BubbleXYItemLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + BubbleXYItemLabelGenerator g1 = new BubbleXYItemLabelGenerator(); + BubbleXYItemLabelGenerator g2 = (BubbleXYItemLabelGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + BubbleXYItemLabelGenerator g1 = new BubbleXYItemLabelGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + BubbleXYItemLabelGenerator g1 = new BubbleXYItemLabelGenerator(); + BubbleXYItemLabelGenerator g2 = (BubbleXYItemLabelGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + + /** + * Some checks for the testGenerateLabel() method. + */ + @Test + public void testGenerateLabel() { + // check handling when the dataset is a regular XYDataset, not an + // XYZDataset... + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 2.0); + s1.add(2.2, 3.3); + XYSeriesCollection dataset = new XYSeriesCollection(s1); + BubbleXYItemLabelGenerator g = new BubbleXYItemLabelGenerator(); + assertEquals("{3}", g.generateLabel(dataset, 0, 0)); + assertEquals("{3}", g.generateLabel(dataset, 0, 1)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/CustomXYItemLabelGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/CustomXYItemLabelGeneratorTest.java new file mode 100755 index 0000000..f5f0ec8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/CustomXYItemLabelGeneratorTest.java @@ -0,0 +1,104 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------- + * CustomXYItemLabelGeneratorTest.java + * ----------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Mar-2003 : Version 1 (DG); + * 13-Aug-2003 : Added cloning tests (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.List; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link CustomXYToolTipGenerator} class. + */ +public class CustomXYItemLabelGeneratorTest { + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CustomXYToolTipGenerator g1 = new CustomXYToolTipGenerator(); + CustomXYToolTipGenerator g2 = (CustomXYToolTipGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + CustomXYToolTipGenerator g1 = new CustomXYToolTipGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + List t1 = new java.util.ArrayList(); + t1.add("Tooltip A1"); + t1.add("Tooltip A2"); + t1.add("Tooltip A3"); + + List t2 = new java.util.ArrayList(); + t2.add("Tooltip B1"); + t2.add("Tooltip B2"); + t2.add("Tooltip B3"); + + CustomXYToolTipGenerator g1 = new CustomXYToolTipGenerator(); + g1.addToolTipSeries(t1); + g1.addToolTipSeries(t2); + CustomXYToolTipGenerator g2 = (CustomXYToolTipGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/HighLowItemLabelGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/HighLowItemLabelGeneratorTest.java new file mode 100755 index 0000000..6e7486f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/HighLowItemLabelGeneratorTest.java @@ -0,0 +1,130 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------- + * HighLowItemLabelGeneratorTest.java + * ---------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Mar-2003 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link HighLowItemLabelGenerator} class. + */ +public class HighLowItemLabelGeneratorTest { + + /** + * Tests that the equals method can distinguish all fields. + */ + @Test + public void testEquals() { + HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator(); + HighLowItemLabelGenerator g2 = new HighLowItemLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new HighLowItemLabelGenerator(new SimpleDateFormat("d-MMM-yyyy"), + NumberFormat.getInstance()); + assertFalse(g1.equals(g2)); + g2 = new HighLowItemLabelGenerator(new SimpleDateFormat("d-MMM-yyyy"), + NumberFormat.getInstance()); + assertTrue(g1.equals(g2)); + + g1 = new HighLowItemLabelGenerator(new SimpleDateFormat("d-MMM-yyyy"), + new DecimalFormat("0.000")); + assertFalse(g1.equals(g2)); + g2 = new HighLowItemLabelGenerator(new SimpleDateFormat("d-MMM-yyyy"), + new DecimalFormat("0.000")); + assertTrue(g1.equals(g2)); + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator(); + HighLowItemLabelGenerator g2 = new HighLowItemLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator(); + HighLowItemLabelGenerator g2 = (HighLowItemLabelGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + HighLowItemLabelGenerator g1 = new HighLowItemLabelGenerator(); + HighLowItemLabelGenerator g2 = (HighLowItemLabelGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/IntervalCategoryItemLabelGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/IntervalCategoryItemLabelGeneratorTest.java new file mode 100755 index 0000000..ae41df9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/IntervalCategoryItemLabelGeneratorTest.java @@ -0,0 +1,139 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------------- + * IntervalCategoryItemLabelGeneratorTest.java + * ------------------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Mar-2003 : Version 1 (DG); + * 13-Aug-2003 : Added cloning tests, and renamed class (DG); + * 23-Apr-2008 : Added testPublicCloneble() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link IntervalCategoryItemLabelGenerator} class. + */ +public class IntervalCategoryItemLabelGeneratorTest { + + /** + * Tests the equals() method. + */ + @Test + public void testEquals() { + IntervalCategoryItemLabelGenerator g1 + = new IntervalCategoryItemLabelGenerator(); + IntervalCategoryItemLabelGenerator g2 + = new IntervalCategoryItemLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}", + new DecimalFormat("0.000")); + assertFalse(g1.equals(g2)); + g2 = new IntervalCategoryItemLabelGenerator("{3} - {4}", + new DecimalFormat("0.000")); + assertTrue(g1.equals(g2)); + + g1 = new IntervalCategoryItemLabelGenerator("{3} - {4}", + new SimpleDateFormat("d-MMM")); + assertFalse(g1.equals(g2)); + g2 = new IntervalCategoryItemLabelGenerator("{3} - {4}", + new SimpleDateFormat("d-MMM")); + assertTrue(g1.equals(g2)); + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + IntervalCategoryItemLabelGenerator g1 + = new IntervalCategoryItemLabelGenerator(); + IntervalCategoryItemLabelGenerator g2 + = new IntervalCategoryItemLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + IntervalCategoryItemLabelGenerator g1 + = new IntervalCategoryItemLabelGenerator(); + IntervalCategoryItemLabelGenerator g2 + = (IntervalCategoryItemLabelGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + IntervalCategoryItemLabelGenerator g1 + = new IntervalCategoryItemLabelGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + IntervalCategoryItemLabelGenerator g1 + = new IntervalCategoryItemLabelGenerator("{3} - {4}", + DateFormat.getInstance()); + IntervalCategoryItemLabelGenerator g2 = (IntervalCategoryItemLabelGenerator) TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/IntervalCategoryToolTipGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/IntervalCategoryToolTipGeneratorTest.java new file mode 100755 index 0000000..c1e037d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/IntervalCategoryToolTipGeneratorTest.java @@ -0,0 +1,154 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------------- + * IntervalCategoryToolTipGeneratorTest.java + * ----------------------------------------- + * (C) Copyright 2008, 2013 by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 07-Oct-2008 : Version 1, based on + * IntervalCategoryItemLabelGeneratorTests (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link IntervalCategoryToolTipGenerator} class. + */ +public class IntervalCategoryToolTipGeneratorTest { + + /** + * Tests the equals() method. + */ + @Test + public void testEquals() { + IntervalCategoryToolTipGenerator g1 + = new IntervalCategoryToolTipGenerator(); + IntervalCategoryToolTipGenerator g2 + = new IntervalCategoryToolTipGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new IntervalCategoryToolTipGenerator("{3} - {4}", + new DecimalFormat("0.000")); + assertFalse(g1.equals(g2)); + g2 = new IntervalCategoryToolTipGenerator("{3} - {4}", + new DecimalFormat("0.000")); + assertTrue(g1.equals(g2)); + + g1 = new IntervalCategoryToolTipGenerator("{3} - {4}", + new SimpleDateFormat("d-MMM")); + assertFalse(g1.equals(g2)); + g2 = new IntervalCategoryToolTipGenerator("{3} - {4}", + new SimpleDateFormat("d-MMM")); + assertTrue(g1.equals(g2)); + } + + /** + * Check that the subclass is not equal to an instance of the superclass. + */ + @Test + public void testEquals2() { + IntervalCategoryToolTipGenerator g1 + = new IntervalCategoryToolTipGenerator(); + StandardCategoryToolTipGenerator g2 + = new StandardCategoryToolTipGenerator( + IntervalCategoryToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT_STRING, + NumberFormat.getInstance()); + assertFalse(g1.equals(g2)); + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + IntervalCategoryToolTipGenerator g1 + = new IntervalCategoryToolTipGenerator(); + IntervalCategoryToolTipGenerator g2 + = new IntervalCategoryToolTipGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + IntervalCategoryToolTipGenerator g1 + = new IntervalCategoryToolTipGenerator(); + IntervalCategoryToolTipGenerator g2 + = (IntervalCategoryToolTipGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + IntervalCategoryToolTipGenerator g1 + = new IntervalCategoryToolTipGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + IntervalCategoryToolTipGenerator g1 + = new IntervalCategoryToolTipGenerator("{3} - {4}", + DateFormat.getInstance()); + IntervalCategoryToolTipGenerator g2 = (IntervalCategoryToolTipGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/ItemLabelAnchorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/ItemLabelAnchorTest.java new file mode 100755 index 0000000..8fabc6a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/ItemLabelAnchorTest.java @@ -0,0 +1,73 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * ItemLabelAnchorTest.java + * ------------------------ + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Feb-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link ItemLabelAnchor} class. + */ +public class ItemLabelAnchorTest { + + /** + * Test the equals() method. + */ + @Test + public void testEquals() { + assertTrue(ItemLabelAnchor.INSIDE1.equals(ItemLabelAnchor.INSIDE1)); + assertFalse(ItemLabelAnchor.INSIDE1.equals(ItemLabelAnchor.INSIDE2)); + } + + /** + * Serialize an instance, restore it, and check for identity. + */ + @Test + public void testSerialization() { + ItemLabelAnchor a1 = ItemLabelAnchor.INSIDE1; + ItemLabelAnchor a2 = (ItemLabelAnchor) TestUtilities.serialised(a1); + assertTrue(a1 == a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/ItemLabelPositionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/ItemLabelPositionTest.java new file mode 100755 index 0000000..2055ba3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/ItemLabelPositionTest.java @@ -0,0 +1,74 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * ItemLabelPositionTest.java + * -------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Oct-2003 : Version 1 (DG); + * 19-Feb-2004 : Moved to org.jfree.chart.labels.junit (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link ItemLabelPosition} class. + */ +public class ItemLabelPositionTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + ItemLabelPosition p1 = new ItemLabelPosition(); + ItemLabelPosition p2 = new ItemLabelPosition(); + assertEquals(p1, p2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ItemLabelPosition p1 = new ItemLabelPosition(); + ItemLabelPosition p2 = (ItemLabelPosition) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/MultipleXYSeriesLabelGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/MultipleXYSeriesLabelGeneratorTest.java new file mode 100755 index 0000000..3b4d8bc --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/MultipleXYSeriesLabelGeneratorTest.java @@ -0,0 +1,139 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------------- + * MultipleXYSeriesLabelGeneratorTest.java + * --------------------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Jan-2007 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link MultipleXYSeriesLabelGenerator} class. + */ +public class MultipleXYSeriesLabelGeneratorTest { + + /** + * A series of tests for the equals() method. + */ + @Test + public void testEquals() { + MultipleXYSeriesLabelGenerator g1 + = new MultipleXYSeriesLabelGenerator(); + MultipleXYSeriesLabelGenerator g2 + = new MultipleXYSeriesLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new MultipleXYSeriesLabelGenerator("Series {0}"); + assertFalse(g1.equals(g2)); + g2 = new MultipleXYSeriesLabelGenerator("Series {0}"); + assertTrue(g1.equals(g2)); + + g1.addSeriesLabel(1, "Additional 1"); + assertFalse(g1.equals(g2)); + g2.addSeriesLabel(1, "Additional 1"); + assertTrue(g1.equals(g2)); + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + MultipleXYSeriesLabelGenerator g1 + = new MultipleXYSeriesLabelGenerator(); + MultipleXYSeriesLabelGenerator g2 + = new MultipleXYSeriesLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + MultipleXYSeriesLabelGenerator g1 + = new MultipleXYSeriesLabelGenerator(); + MultipleXYSeriesLabelGenerator g2 = (MultipleXYSeriesLabelGenerator) + g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + + // check independence + g1.addSeriesLabel(3, "Add3"); + assertFalse(g1.equals(g2)); + g2.addSeriesLabel(3, "Add3"); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + MultipleXYSeriesLabelGenerator g1 + = new MultipleXYSeriesLabelGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + MultipleXYSeriesLabelGenerator g1 + = new MultipleXYSeriesLabelGenerator(); + g1.addSeriesLabel(0, "Add0"); + g1.addSeriesLabel(0, "Add0b"); + g1.addSeriesLabel(1, "Add1"); + MultipleXYSeriesLabelGenerator g2 = (MultipleXYSeriesLabelGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardCategoryItemLabelGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardCategoryItemLabelGeneratorTest.java new file mode 100755 index 0000000..e4d0408 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardCategoryItemLabelGeneratorTest.java @@ -0,0 +1,186 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------------- + * StandardCategoryItemLabelGeneratorTest.java + * ------------------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Mar-2003 : Version 1 (DG); + * 13-Aug-2003 : Added cloning tests (DG); + * 11-May-2004 : Renamed class (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StandardCategoryItemLabelGenerator} class. + */ +public class StandardCategoryItemLabelGeneratorTest { + + /** + * Some checks for the generalLabel() method. + */ + @Test + public void testGenerateLabel() { + StandardCategoryItemLabelGenerator g + = new StandardCategoryItemLabelGenerator("{2}", + new DecimalFormat("0.000")); + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(1.0, "R0", "C0"); + dataset.addValue(2.0, "R0", "C1"); + dataset.addValue(3.0, "R1", "C0"); + dataset.addValue(null, "R1", "C1"); + String s = g.generateLabel(dataset, 0, 0); + assertTrue(s.startsWith("1")); + assertTrue(s.endsWith("000")); + + // try a null value + s = g.generateLabel(dataset, 1, 1); + assertEquals("-", s); + } + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + StandardCategoryItemLabelGenerator g1 + = new StandardCategoryItemLabelGenerator(); + StandardCategoryItemLabelGenerator g2 + = new StandardCategoryItemLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new StandardCategoryItemLabelGenerator("{0}", + new DecimalFormat("0.000")); + assertFalse(g1.equals(g2)); + g2 = new StandardCategoryItemLabelGenerator("{0}", + new DecimalFormat("0.000")); + assertTrue(g1.equals(g2)); + + g1 = new StandardCategoryItemLabelGenerator("{1}", + new DecimalFormat("0.000")); + assertFalse(g1.equals(g2)); + g2 = new StandardCategoryItemLabelGenerator("{1}", + new DecimalFormat("0.000")); + assertTrue(g1.equals(g2)); + + g1 = new StandardCategoryItemLabelGenerator("{2}", + new SimpleDateFormat("d-MMM")); + assertFalse(g1.equals(g2)); + g2 = new StandardCategoryItemLabelGenerator("{2}", + new SimpleDateFormat("d-MMM")); + assertTrue(g1.equals(g2)); + + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + StandardCategoryItemLabelGenerator g1 + = new StandardCategoryItemLabelGenerator(); + StandardCategoryItemLabelGenerator g2 + = new StandardCategoryItemLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StandardCategoryItemLabelGenerator g1 + = new StandardCategoryItemLabelGenerator(); + StandardCategoryItemLabelGenerator g2 + = (StandardCategoryItemLabelGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + StandardCategoryItemLabelGenerator g1 + = new StandardCategoryItemLabelGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardCategoryItemLabelGenerator g1 + = new StandardCategoryItemLabelGenerator("{2}", + DateFormat.getInstance()); + StandardCategoryItemLabelGenerator g2 = (StandardCategoryItemLabelGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + + /** + * A test for bug 1481087. + */ + @Test + public void testEquals1481087() { + StandardCategoryItemLabelGenerator g1 + = new StandardCategoryItemLabelGenerator("{0}", + new DecimalFormat("0.00")); + StandardCategoryToolTipGenerator g2 + = new StandardCategoryToolTipGenerator("{0}", + new DecimalFormat("0.00")); + assertFalse(g1.equals(g2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardCategorySeriesLabelGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardCategorySeriesLabelGeneratorTest.java new file mode 100755 index 0000000..51b8bb3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardCategorySeriesLabelGeneratorTest.java @@ -0,0 +1,142 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------------------- + * StandardCategorySeriesLabelGeneratorTest.java + * --------------------------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-May-2006 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StandardCategorySeriesLabelGenerator} class. + */ +public class StandardCategorySeriesLabelGeneratorTest { + + /** + * Some checks for the generalLabel() method. + */ + @Test + public void testGenerateLabel() { + StandardCategorySeriesLabelGenerator g + = new StandardCategorySeriesLabelGenerator("{0}"); + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(1.0, "R0", "C0"); + dataset.addValue(2.0, "R0", "C1"); + dataset.addValue(3.0, "R1", "C0"); + dataset.addValue(null, "R1", "C1"); + String s = g.generateLabel(dataset, 0); + assertEquals("R0", s); + } + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + StandardCategorySeriesLabelGenerator g1 + = new StandardCategorySeriesLabelGenerator(); + StandardCategorySeriesLabelGenerator g2 + = new StandardCategorySeriesLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new StandardCategorySeriesLabelGenerator("{1}"); + assertFalse(g1.equals(g2)); + g2 = new StandardCategorySeriesLabelGenerator("{1}"); + assertTrue(g1.equals(g2)); + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + StandardCategorySeriesLabelGenerator g1 + = new StandardCategorySeriesLabelGenerator(); + StandardCategorySeriesLabelGenerator g2 + = new StandardCategorySeriesLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StandardCategorySeriesLabelGenerator g1 + = new StandardCategorySeriesLabelGenerator("{1}"); + StandardCategorySeriesLabelGenerator g2 + = (StandardCategorySeriesLabelGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + StandardCategorySeriesLabelGenerator g1 + = new StandardCategorySeriesLabelGenerator("{1}"); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardCategorySeriesLabelGenerator g1 + = new StandardCategorySeriesLabelGenerator("{2}"); + StandardCategorySeriesLabelGenerator g2 = (StandardCategorySeriesLabelGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardCategoryToolTipGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardCategoryToolTipGeneratorTest.java new file mode 100755 index 0000000..e7d223d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardCategoryToolTipGeneratorTest.java @@ -0,0 +1,164 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------------- + * StandardCategoryToolTipGeneratorTest.java + * ----------------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-May-2004 : Version 1 (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 03-May-2006 : Added testEquals1481087() (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StandardCategoryToolTipGenerator} class. + */ +public class StandardCategoryToolTipGeneratorTest { + + /** + * Tests the equals() method. + */ + @Test + public void testEquals() { + + StandardCategoryToolTipGenerator g1 + = new StandardCategoryToolTipGenerator(); + StandardCategoryToolTipGenerator g2 + = new StandardCategoryToolTipGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new StandardCategoryToolTipGenerator("{0}", + new DecimalFormat("0.000")); + assertFalse(g1.equals(g2)); + g2 = new StandardCategoryToolTipGenerator("{0}", + new DecimalFormat("0.000")); + assertTrue(g1.equals(g2)); + + g1 = new StandardCategoryToolTipGenerator("{1}", + new DecimalFormat("0.000")); + assertFalse(g1.equals(g2)); + g2 = new StandardCategoryToolTipGenerator("{1}", + new DecimalFormat("0.000")); + assertTrue(g1.equals(g2)); + + g1 = new StandardCategoryToolTipGenerator("{2}", + new SimpleDateFormat("d-MMM")); + assertFalse(g1.equals(g2)); + g2 = new StandardCategoryToolTipGenerator("{2}", + new SimpleDateFormat("d-MMM")); + assertTrue(g1.equals(g2)); + + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + StandardCategoryToolTipGenerator g1 + = new StandardCategoryToolTipGenerator(); + StandardCategoryToolTipGenerator g2 + = new StandardCategoryToolTipGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StandardCategoryToolTipGenerator g1 + = new StandardCategoryToolTipGenerator(); + StandardCategoryToolTipGenerator g2 + = (StandardCategoryToolTipGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + StandardCategoryToolTipGenerator g1 + = new StandardCategoryToolTipGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardCategoryToolTipGenerator g1 + = new StandardCategoryToolTipGenerator("{2}", + DateFormat.getInstance()); + StandardCategoryToolTipGenerator g2 = (StandardCategoryToolTipGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + + /** + * A test for bug 1481087. + */ + @Test + public void testEquals1481087() { + StandardCategoryToolTipGenerator g1 + = new StandardCategoryToolTipGenerator("{0}", + new DecimalFormat("0.00")); + StandardCategoryItemLabelGenerator g2 + = new StandardCategoryItemLabelGenerator("{0}", + new DecimalFormat("0.00")); + assertFalse(g1.equals(g2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardContourToolTipGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardContourToolTipGeneratorTest.java new file mode 100755 index 0000000..f6e8fff --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardContourToolTipGeneratorTest.java @@ -0,0 +1,65 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------------- + * StandardContourToolTipGeneratorTest.java + * ---------------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Mar-2003 : Version 1 (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the StandardContourToolTipGenerator class. + */ +public class StandardContourToolTipGeneratorTest { + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardContourToolTipGenerator g1 + = new StandardContourToolTipGenerator(); + StandardContourToolTipGenerator g2 = (StandardContourToolTipGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardPieSectionLabelGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardPieSectionLabelGeneratorTest.java new file mode 100755 index 0000000..c40a5d1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardPieSectionLabelGeneratorTest.java @@ -0,0 +1,165 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------------- + * StandardPieSectionLabelGeneratorTest.java + * ----------------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Mar-2003 : Version 1 (DG); + * 13-Aug-2003 : Added clone tests (DG); + * 04-Mar-2004 : Added test for equals() method (DG); + * 23-Nov-2006 : Extended equals() test (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.AttributedString; +import java.text.DecimalFormat; +import java.text.NumberFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StandardPieSectionLabelGenerator} class. + */ +public class StandardPieSectionLabelGeneratorTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + StandardPieSectionLabelGenerator g1 + = new StandardPieSectionLabelGenerator(); + StandardPieSectionLabelGenerator g2 + = new StandardPieSectionLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new StandardPieSectionLabelGenerator("{0}", + new DecimalFormat("#,##0.00"), + NumberFormat.getPercentInstance()); + assertFalse(g1.equals(g2)); + g2 = new StandardPieSectionLabelGenerator("{0}", + new DecimalFormat("#,##0.00"), + NumberFormat.getPercentInstance()); + assertTrue(g1.equals(g2)); + + g1 = new StandardPieSectionLabelGenerator("{0} {1}", + new DecimalFormat("#,##0.00"), + NumberFormat.getPercentInstance()); + assertFalse(g1.equals(g2)); + g2 = new StandardPieSectionLabelGenerator("{0} {1}", + new DecimalFormat("#,##0.00"), + NumberFormat.getPercentInstance()); + assertTrue(g1.equals(g2)); + + g1 = new StandardPieSectionLabelGenerator("{0} {1}", + new DecimalFormat("#,##0"), NumberFormat.getPercentInstance()); + assertFalse(g1.equals(g2)); + g2 = new StandardPieSectionLabelGenerator("{0} {1}", + new DecimalFormat("#,##0"), NumberFormat.getPercentInstance()); + assertTrue(g1.equals(g2)); + + g1 = new StandardPieSectionLabelGenerator("{0} {1}", + new DecimalFormat("#,##0"), new DecimalFormat("0.000%")); + assertFalse(g1.equals(g2)); + g2 = new StandardPieSectionLabelGenerator("{0} {1}", + new DecimalFormat("#,##0"), new DecimalFormat("0.000%")); + assertTrue(g1.equals(g2)); + + AttributedString as = new AttributedString("XYZ"); + g1.setAttributedLabel(0, as); + assertFalse(g1.equals(g2)); + g2.setAttributedLabel(0, as); + assertTrue(g1.equals(g2)); + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + StandardPieSectionLabelGenerator g1 + = new StandardPieSectionLabelGenerator(); + StandardPieSectionLabelGenerator g2 + = new StandardPieSectionLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StandardPieSectionLabelGenerator g1 + = new StandardPieSectionLabelGenerator(); + StandardPieSectionLabelGenerator g2 + = (StandardPieSectionLabelGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + StandardPieSectionLabelGenerator g1 + = new StandardPieSectionLabelGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardPieSectionLabelGenerator g1 + = new StandardPieSectionLabelGenerator(); + StandardPieSectionLabelGenerator g2 = (StandardPieSectionLabelGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardPieToolTipGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardPieToolTipGeneratorTest.java new file mode 100755 index 0000000..21c3796 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardPieToolTipGeneratorTest.java @@ -0,0 +1,158 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------ + * StandardPieToolTipGeneratorTest.java + * ------------------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Mar-2003 : Version 1 (DG); + * 13-Aug-2003 : Added clone tests (DG); + * 04-Mar-2004 : Added test for equals() method (DG); + * ------------- JFREECHART 1.0.x --------------------------------------------- + * 03-May-2006 : Extended test for clone() method (DG); + * 03-May-2006 : Renamed StandardPieItemLabelGeneratorTests + * --> StandardPieToolTipGeneratorTests (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.DecimalFormat; +import java.text.NumberFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StandardPieToolTipGenerator} class. + */ +public class StandardPieToolTipGeneratorTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator(); + StandardPieToolTipGenerator g2 = new StandardPieToolTipGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new StandardPieToolTipGenerator("{0}", + new DecimalFormat("#,##0.00"), + NumberFormat.getPercentInstance()); + assertFalse(g1.equals(g2)); + g2 = new StandardPieToolTipGenerator("{0}", + new DecimalFormat("#,##0.00"), + NumberFormat.getPercentInstance()); + assertTrue(g1.equals(g2)); + + g1 = new StandardPieToolTipGenerator("{0} {1}", + new DecimalFormat("#,##0.00"), + NumberFormat.getPercentInstance()); + assertFalse(g1.equals(g2)); + g2 = new StandardPieToolTipGenerator("{0} {1}", + new DecimalFormat("#,##0.00"), + NumberFormat.getPercentInstance()); + assertTrue(g1.equals(g2)); + + g1 = new StandardPieToolTipGenerator("{0} {1}", + new DecimalFormat("#,##0"), NumberFormat.getPercentInstance()); + assertFalse(g1.equals(g2)); + g2 = new StandardPieToolTipGenerator("{0} {1}", + new DecimalFormat("#,##0"), NumberFormat.getPercentInstance()); + assertTrue(g1.equals(g2)); + + g1 = new StandardPieToolTipGenerator("{0} {1}", + new DecimalFormat("#,##0"), new DecimalFormat("0.000%")); + assertFalse(g1.equals(g2)); + g2 = new StandardPieToolTipGenerator("{0} {1}", + new DecimalFormat("#,##0"), new DecimalFormat("0.000%")); + assertTrue(g1.equals(g2)); + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + StandardPieToolTipGenerator g1 + = new StandardPieToolTipGenerator(); + StandardPieToolTipGenerator g2 + = new StandardPieToolTipGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Some checks for cloning. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator(); + StandardPieToolTipGenerator g2 = (StandardPieToolTipGenerator) + g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + assertTrue(g1.getNumberFormat() != g2.getNumberFormat()); + assertTrue(g1.getPercentFormat() != g2.getPercentFormat()); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardPieToolTipGenerator g1 = new StandardPieToolTipGenerator(); + StandardPieToolTipGenerator g2 = (StandardPieToolTipGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardXYItemLabelGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardXYItemLabelGeneratorTest.java new file mode 100755 index 0000000..1fba752 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardXYItemLabelGeneratorTest.java @@ -0,0 +1,202 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------- + * StandardXYItemLabelGeneratorTest.java + * ------------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Mar-2003 : Version 1 (DG); + * 26-Feb-2004 : Updates for new code (DG); + * 20-Jan-2006 : Renamed StandardXYItemLabelGeneratorTests.java (DG); + * 25-Jan-2007 : Added independence checks to testCloning() (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StandardXYItemLabelGenerator} class. + */ +public class StandardXYItemLabelGeneratorTest { + + /** + * A series of tests for the equals() method. + */ + @Test + public void testEquals() { + + // some setup... + String f1 = "{1}"; + String f2 = "{2}"; + NumberFormat xnf1 = new DecimalFormat("0.00"); + NumberFormat xnf2 = new DecimalFormat("0.000"); + NumberFormat ynf1 = new DecimalFormat("0.00"); + NumberFormat ynf2 = new DecimalFormat("0.000"); + + StandardXYItemLabelGenerator g1 = null; + StandardXYItemLabelGenerator g2 = null; + + g1 = new StandardXYItemLabelGenerator(f1, xnf1, ynf1); + g2 = new StandardXYItemLabelGenerator(f1, xnf1, ynf1); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new StandardXYItemLabelGenerator(f2, xnf1, ynf1); + assertFalse(g1.equals(g2)); + g2 = new StandardXYItemLabelGenerator(f2, xnf1, ynf1); + assertTrue(g1.equals(g2)); + + g1 = new StandardXYItemLabelGenerator(f2, xnf2, ynf1); + assertFalse(g1.equals(g2)); + g2 = new StandardXYItemLabelGenerator(f2, xnf2, ynf1); + assertTrue(g1.equals(g2)); + + g1 = new StandardXYItemLabelGenerator(f2, xnf2, ynf2); + assertFalse(g1.equals(g2)); + g2 = new StandardXYItemLabelGenerator(f2, xnf2, ynf2); + assertTrue(g1.equals(g2)); + + DateFormat xdf1 = new SimpleDateFormat("d-MMM"); + DateFormat xdf2 = new SimpleDateFormat("d-MMM-yyyy"); + DateFormat ydf1 = new SimpleDateFormat("d-MMM"); + DateFormat ydf2 = new SimpleDateFormat("d-MMM-yyyy"); + + g1 = new StandardXYItemLabelGenerator(f1, xdf1, ydf1); + g2 = new StandardXYItemLabelGenerator(f1, xdf1, ydf1); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new StandardXYItemLabelGenerator(f1, xdf2, ydf1); + assertFalse(g1.equals(g2)); + g2 = new StandardXYItemLabelGenerator(f1, xdf2, ydf1); + assertTrue(g1.equals(g2)); + + g1 = new StandardXYItemLabelGenerator(f1, xdf2, ydf2); + assertFalse(g1.equals(g2)); + g2 = new StandardXYItemLabelGenerator(f1, xdf2, ydf2); + assertTrue(g1.equals(g2)); + + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + StandardXYItemLabelGenerator g1 + = new StandardXYItemLabelGenerator(); + StandardXYItemLabelGenerator g2 + = new StandardXYItemLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StandardXYItemLabelGenerator g1 = new StandardXYItemLabelGenerator(); + StandardXYItemLabelGenerator g2 = (StandardXYItemLabelGenerator) + g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + + // check independence + g1.getXFormat().setMinimumIntegerDigits(2); + assertFalse(g1.equals(g2)); + g2.getXFormat().setMinimumIntegerDigits(2); + assertTrue(g1.equals(g2)); + + g1.getYFormat().setMinimumIntegerDigits(2); + assertFalse(g1.equals(g2)); + g2.getYFormat().setMinimumIntegerDigits(2); + assertTrue(g1.equals(g2)); + + // another test... + g1 = new StandardXYItemLabelGenerator("{0} {1} {2}", + DateFormat.getInstance(), DateFormat.getInstance()); + g2 = (StandardXYItemLabelGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + + // check independence + g1.getXDateFormat().setNumberFormat(new DecimalFormat("0.000")); + assertFalse(g1.equals(g2)); + g2.getXDateFormat().setNumberFormat(new DecimalFormat("0.000")); + assertTrue(g1.equals(g2)); + + g1.getYDateFormat().setNumberFormat(new DecimalFormat("0.000")); + assertFalse(g1.equals(g2)); + g2.getYDateFormat().setNumberFormat(new DecimalFormat("0.000")); + assertTrue(g1.equals(g2)); + + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + StandardXYItemLabelGenerator g1 = new StandardXYItemLabelGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardXYItemLabelGenerator g1 = new StandardXYItemLabelGenerator(); + StandardXYItemLabelGenerator g2 = (StandardXYItemLabelGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardXYSeriesLabelGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardXYSeriesLabelGeneratorTest.java new file mode 100755 index 0000000..16f35e7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardXYSeriesLabelGeneratorTest.java @@ -0,0 +1,140 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------------- + * StandardXYSeriesLabelGeneratorTest.java + * --------------------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 24-Nov-2006 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG) + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StandardXYSeriesLabelGenerator} class. + */ +public class StandardXYSeriesLabelGeneratorTest { + + /** + * Some checks for the generalLabel() method. + */ + @Test + public void testGenerateLabel() { + StandardXYSeriesLabelGenerator g + = new StandardXYSeriesLabelGenerator("Series {0}"); + XYSeriesCollection dataset = new XYSeriesCollection(); + dataset.addSeries(new XYSeries("1")); + dataset.addSeries(new XYSeries("2")); + assertEquals("Series 1", g.generateLabel(dataset, 0)); + assertEquals("Series 2", g.generateLabel(dataset, 1)); + } + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + StandardXYSeriesLabelGenerator g1 + = new StandardXYSeriesLabelGenerator("Series {0}"); + StandardXYSeriesLabelGenerator g2 + = new StandardXYSeriesLabelGenerator("Series {0}"); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new StandardXYSeriesLabelGenerator("{1}"); + assertFalse(g1.equals(g2)); + g2 = new StandardXYSeriesLabelGenerator("{1}"); + assertTrue(g1.equals(g2)); + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + StandardXYSeriesLabelGenerator g1 + = new StandardXYSeriesLabelGenerator(); + StandardXYSeriesLabelGenerator g2 + = new StandardXYSeriesLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StandardXYSeriesLabelGenerator g1 + = new StandardXYSeriesLabelGenerator("Series {0}"); + StandardXYSeriesLabelGenerator g2 = (StandardXYSeriesLabelGenerator) + g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + StandardXYSeriesLabelGenerator g1 + = new StandardXYSeriesLabelGenerator("Series {0}"); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardXYSeriesLabelGenerator g1 + = new StandardXYSeriesLabelGenerator("Series {0}"); + StandardXYSeriesLabelGenerator g2 = (StandardXYSeriesLabelGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardXYToolTipGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardXYToolTipGeneratorTest.java new file mode 100755 index 0000000..052dd08 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardXYToolTipGeneratorTest.java @@ -0,0 +1,167 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------- + * StandardXYToolTipGeneratorTest.java + * ----------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-May-2004 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StandardXYToolTipGenerator} class. + */ +public class StandardXYToolTipGeneratorTest { + + /** + * Tests the equals() method. + */ + @Test + public void testEquals() { + + // some setup... + String f1 = "{1}"; + String f2 = "{2}"; + NumberFormat xnf1 = new DecimalFormat("0.00"); + NumberFormat xnf2 = new DecimalFormat("0.000"); + NumberFormat ynf1 = new DecimalFormat("0.00"); + NumberFormat ynf2 = new DecimalFormat("0.000"); + + StandardXYToolTipGenerator g1 = null; + StandardXYToolTipGenerator g2 = null; + + g1 = new StandardXYToolTipGenerator(f1, xnf1, ynf1); + g2 = new StandardXYToolTipGenerator(f1, xnf1, ynf1); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new StandardXYToolTipGenerator(f2, xnf1, ynf1); + assertFalse(g1.equals(g2)); + g2 = new StandardXYToolTipGenerator(f2, xnf1, ynf1); + assertTrue(g1.equals(g2)); + + g1 = new StandardXYToolTipGenerator(f2, xnf2, ynf1); + assertFalse(g1.equals(g2)); + g2 = new StandardXYToolTipGenerator(f2, xnf2, ynf1); + assertTrue(g1.equals(g2)); + + g1 = new StandardXYToolTipGenerator(f2, xnf2, ynf2); + assertFalse(g1.equals(g2)); + g2 = new StandardXYToolTipGenerator(f2, xnf2, ynf2); + assertTrue(g1.equals(g2)); + + DateFormat xdf1 = new SimpleDateFormat("d-MMM"); + DateFormat xdf2 = new SimpleDateFormat("d-MMM-yyyy"); + DateFormat ydf1 = new SimpleDateFormat("d-MMM"); + DateFormat ydf2 = new SimpleDateFormat("d-MMM-yyyy"); + + g1 = new StandardXYToolTipGenerator(f1, xdf1, ydf1); + g2 = new StandardXYToolTipGenerator(f1, xdf1, ydf1); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new StandardXYToolTipGenerator(f1, xdf2, ydf1); + assertFalse(g1.equals(g2)); + g2 = new StandardXYToolTipGenerator(f1, xdf2, ydf1); + assertTrue(g1.equals(g2)); + + g1 = new StandardXYToolTipGenerator(f1, xdf2, ydf2); + assertFalse(g1.equals(g2)); + g2 = new StandardXYToolTipGenerator(f1, xdf2, ydf2); + assertTrue(g1.equals(g2)); + + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + StandardXYToolTipGenerator g1 + = new StandardXYToolTipGenerator(); + StandardXYToolTipGenerator g2 + = new StandardXYToolTipGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StandardXYToolTipGenerator g1 = new StandardXYToolTipGenerator(); + StandardXYToolTipGenerator g2 = (StandardXYToolTipGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + StandardXYToolTipGenerator g1 = new StandardXYToolTipGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardXYToolTipGenerator g1 = new StandardXYToolTipGenerator(); + StandardXYToolTipGenerator g2 = (StandardXYToolTipGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardXYZToolTipGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardXYZToolTipGeneratorTest.java new file mode 100755 index 0000000..a5707d0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/StandardXYZToolTipGeneratorTest.java @@ -0,0 +1,187 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------ + * StandardXYZToolTipGeneratorTest.java + * ------------------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Mar-2003 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.DateFormat; +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StandardXYZToolTipGenerator} class. + */ +public class StandardXYZToolTipGeneratorTest { + + /** + * Tests that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + + // some setup... + String f1 = "{1}"; + String f2 = "{2}"; + NumberFormat xnf1 = new DecimalFormat("0.00"); + NumberFormat xnf2 = new DecimalFormat("0.000"); + NumberFormat ynf1 = new DecimalFormat("0.00"); + NumberFormat ynf2 = new DecimalFormat("0.000"); + NumberFormat znf1 = new DecimalFormat("0.00"); + NumberFormat znf2 = new DecimalFormat("0.000"); + + DateFormat xdf1 = new SimpleDateFormat("d-MMM"); + DateFormat xdf2 = new SimpleDateFormat("d-MMM-yyyy"); + DateFormat ydf1 = new SimpleDateFormat("d-MMM"); + DateFormat ydf2 = new SimpleDateFormat("d-MMM-yyyy"); + DateFormat zdf1 = new SimpleDateFormat("d-MMM"); + DateFormat zdf2 = new SimpleDateFormat("d-MMM-yyyy"); + + StandardXYZToolTipGenerator g1 = null; + StandardXYZToolTipGenerator g2 = null; + + g1 = new StandardXYZToolTipGenerator(f1, xnf1, ynf1, znf1); + g2 = new StandardXYZToolTipGenerator(f1, xnf1, ynf1, znf1); + assertTrue(g1.equals(g2)); + + // format string... + g1 = new StandardXYZToolTipGenerator(f2, xnf1, ynf1, znf1); + assertFalse(g1.equals(g2)); + g2 = new StandardXYZToolTipGenerator(f2, xnf1, ynf1, znf1); + assertTrue(g1.equals(g2)); + + // x number format + g1 = new StandardXYZToolTipGenerator(f2, xnf2, ynf1, znf1); + assertFalse(g1.equals(g2)); + g2 = new StandardXYZToolTipGenerator(f2, xnf2, ynf1, znf1); + assertTrue(g1.equals(g2)); + + // y number format + g1 = new StandardXYZToolTipGenerator(f2, xnf2, ynf2, znf1); + assertFalse(g1.equals(g2)); + g2 = new StandardXYZToolTipGenerator(f2, xnf2, ynf2, znf1); + assertTrue(g1.equals(g2)); + + // z number format + g1 = new StandardXYZToolTipGenerator(f2, xnf2, ynf2, znf2); + assertFalse(g1.equals(g2)); + g2 = new StandardXYZToolTipGenerator(f2, xnf2, ynf2, znf2); + assertTrue(g1.equals(g2)); + + g1 = new StandardXYZToolTipGenerator(f2, xdf1, ydf1, zdf1); + g2 = new StandardXYZToolTipGenerator(f2, xdf1, ydf1, zdf1); + assertTrue(g1.equals(g2)); + + // x date format + g1 = new StandardXYZToolTipGenerator(f2, xdf2, ydf1, zdf1); + assertFalse(g1.equals(g2)); + g2 = new StandardXYZToolTipGenerator(f2, xdf2, ydf1, zdf1); + assertTrue(g1.equals(g2)); + + // y date format + g1 = new StandardXYZToolTipGenerator(f2, xdf2, ydf2, zdf1); + assertFalse(g1.equals(g2)); + g2 = new StandardXYZToolTipGenerator(f2, xdf2, ydf2, zdf1); + assertTrue(g1.equals(g2)); + + // z date format + g1 = new StandardXYZToolTipGenerator(f2, xdf2, ydf2, zdf2); + assertFalse(g1.equals(g2)); + g2 = new StandardXYZToolTipGenerator(f2, xdf2, ydf2, zdf2); + assertTrue(g1.equals(g2)); + + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + StandardXYZToolTipGenerator g1 + = new StandardXYZToolTipGenerator(); + StandardXYZToolTipGenerator g2 + = new StandardXYZToolTipGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StandardXYZToolTipGenerator g1 = new StandardXYZToolTipGenerator(); + StandardXYZToolTipGenerator g2 = (StandardXYZToolTipGenerator) + g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + StandardXYZToolTipGenerator g1 = new StandardXYZToolTipGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardXYZToolTipGenerator g1 = new StandardXYZToolTipGenerator(); + StandardXYZToolTipGenerator g2 = (StandardXYZToolTipGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/SymbolicXYItemLabelGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/SymbolicXYItemLabelGeneratorTest.java new file mode 100755 index 0000000..67dffe5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/SymbolicXYItemLabelGeneratorTest.java @@ -0,0 +1,114 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------- + * SymbolicXYItemLabelGeneratorTest.java + * ------------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Aug-2003 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.labels; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link SymbolicXYItemLabelGenerator} class. + */ +public class SymbolicXYItemLabelGeneratorTest { + + /** + * Tests the equals method. + */ + @Test + public void testEquals() { + SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator(); + SymbolicXYItemLabelGenerator g2 = new SymbolicXYItemLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + SymbolicXYItemLabelGenerator g1 + = new SymbolicXYItemLabelGenerator(); + SymbolicXYItemLabelGenerator g2 + = new SymbolicXYItemLabelGenerator(); + assertTrue(g1.equals(g2)); + assertTrue(g1.hashCode() == g2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator(); + SymbolicXYItemLabelGenerator g2 = (SymbolicXYItemLabelGenerator) + g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + SymbolicXYItemLabelGenerator g1 = new SymbolicXYItemLabelGenerator(); + SymbolicXYItemLabelGenerator g2 = (SymbolicXYItemLabelGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/package.html new file mode 100755 index 0000000..08924b5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/labels/package.html @@ -0,0 +1,6 @@ + + + +JUnit tests. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/ArrowNeedleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/ArrowNeedleTest.java new file mode 100755 index 0000000..1c7a39d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/ArrowNeedleTest.java @@ -0,0 +1,92 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * ArrowNeedleTest.java + * -------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Jun-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.needle; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link ArrowNeedle} class. + */ +public class ArrowNeedleTest { + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + ArrowNeedle n1 = new ArrowNeedle(false); + ArrowNeedle n2 = new ArrowNeedle(false); + assertTrue(n1.equals(n2)); + assertTrue(n2.equals(n1)); + + n1 = new ArrowNeedle(true); + assertFalse(n1.equals(n2)); + n2 = new ArrowNeedle(true); + assertTrue(n1.equals(n2)); + } + + /** + * Check that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ArrowNeedle n1 = new ArrowNeedle(false); + ArrowNeedle n2 = (ArrowNeedle) n1.clone(); + assertTrue(n1 != n2); + assertTrue(n1.getClass() == n2.getClass()); + assertTrue(n1.equals(n2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ArrowNeedle n1 = new ArrowNeedle(false); + ArrowNeedle n2 = (ArrowNeedle) TestUtilities.serialised(n1); + assertTrue(n1.equals(n2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/LineNeedleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/LineNeedleTest.java new file mode 100755 index 0000000..802d846 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/LineNeedleTest.java @@ -0,0 +1,86 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * LineNeedleTest.java + * ------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Jun-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.needle; + +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link LineNeedle} class. + */ +public class LineNeedleTest { + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + LineNeedle n1 = new LineNeedle(); + LineNeedle n2 = new LineNeedle(); + assertTrue(n1.equals(n2)); + assertTrue(n2.equals(n1)); + } + + /** + * Check that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + LineNeedle n1 = new LineNeedle(); + LineNeedle n2 = (LineNeedle) n1.clone(); + assertTrue(n1 != n2); + assertTrue(n1.getClass() == n2.getClass()); + assertTrue(n1.equals(n2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + LineNeedle n1 = new LineNeedle(); + LineNeedle n2 = (LineNeedle) TestUtilities.serialised(n1); + assertTrue(n1.equals(n2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/LongNeedleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/LongNeedleTest.java new file mode 100755 index 0000000..8249813 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/LongNeedleTest.java @@ -0,0 +1,86 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * LongNeedleTest.java + * ------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Jun-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.needle; + +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link LongNeedle} class. + */ +public class LongNeedleTest { + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + LongNeedle n1 = new LongNeedle(); + LongNeedle n2 = new LongNeedle(); + assertTrue(n1.equals(n2)); + assertTrue(n2.equals(n1)); + } + + /** + * Check that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + LongNeedle n1 = new LongNeedle(); + LongNeedle n2 = (LongNeedle) n1.clone(); + assertTrue(n1 != n2); + assertTrue(n1.getClass() == n2.getClass()); + assertTrue(n1.equals(n2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + LongNeedle n1 = new LongNeedle(); + LongNeedle n2 = (LongNeedle) TestUtilities.serialised(n1); + assertTrue(n1.equals(n2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/MeterNeedleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/MeterNeedleTest.java new file mode 100755 index 0000000..13bb826 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/MeterNeedleTest.java @@ -0,0 +1,104 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * MeterNeedleTest.java + * -------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Jun-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.needle; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Stroke; +import org.junit.Test; + + +/** + * Tests for the {@link MeterNeedle} class. + */ +public class MeterNeedleTest { + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + MeterNeedle n1 = new LineNeedle(); + MeterNeedle n2 = new LineNeedle(); + assertTrue(n1.equals(n2)); + + n1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); + assertFalse(n1.equals(n2)); + n2.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.blue)); + assertTrue(n1.equals(n2)); + + n1.setOutlinePaint(new GradientPaint(5.0f, 6.0f, Color.red, 7.0f, 8.0f, Color.blue)); + assertFalse(n1.equals(n2)); + n2.setOutlinePaint(new GradientPaint(5.0f, 6.0f, Color.red, 7.0f, 8.0f, Color.blue)); + assertTrue(n1.equals(n2)); + + n1.setHighlightPaint(new GradientPaint(9.0f, 0.0f, Color.red, 1.0f, 2.0f, Color.blue)); + assertFalse(n1.equals(n2)); + n2.setHighlightPaint(new GradientPaint(9.0f, 0.0f, Color.red, 1.0f, 2.0f, Color.blue)); + assertTrue(n1.equals(n2)); + + Stroke s = new BasicStroke(1.23f); + n1.setOutlineStroke(s); + assertFalse(n1.equals(n2)); + n2.setOutlineStroke(s); + assertTrue(n1.equals(n2)); + + n1.setRotateX(1.23); + assertFalse(n1.equals(n2)); + n2.setRotateX(1.23); + assertTrue(n1.equals(n2)); + + n1.setRotateY(4.56); + assertFalse(n1.equals(n2)); + n2.setRotateY(4.56); + assertTrue(n1.equals(n2)); + + n1.setSize(11); + assertFalse(n1.equals(n2)); + n2.setSize(11); + assertTrue(n1.equals(n2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/MiddlePinNeedleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/MiddlePinNeedleTest.java new file mode 100755 index 0000000..6ebf802 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/MiddlePinNeedleTest.java @@ -0,0 +1,86 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * MiddlePinNeedleTest.java + * ------------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Jun-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.needle; + +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link MiddlePinNeedle} class. + */ +public class MiddlePinNeedleTest { + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + MiddlePinNeedle n1 = new MiddlePinNeedle(); + MiddlePinNeedle n2 = new MiddlePinNeedle(); + assertTrue(n1.equals(n2)); + assertTrue(n2.equals(n1)); + } + + /** + * Check that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + MiddlePinNeedle n1 = new MiddlePinNeedle(); + MiddlePinNeedle n2 = (MiddlePinNeedle) n1.clone(); + assertTrue(n1 != n2); + assertTrue(n1.getClass() == n2.getClass()); + assertTrue(n1.equals(n2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + MiddlePinNeedle n1 = new MiddlePinNeedle(); + MiddlePinNeedle n2 = (MiddlePinNeedle) TestUtilities.serialised(n1); + assertTrue(n1.equals(n2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/PinNeedleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/PinNeedleTest.java new file mode 100755 index 0000000..5681c62 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/PinNeedleTest.java @@ -0,0 +1,86 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * PinNeedleTest.java + * ------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Jun-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.needle; + +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link PinNeedle} class. + */ +public class PinNeedleTest { + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + PinNeedle n1 = new PinNeedle(); + PinNeedle n2 = new PinNeedle(); + assertTrue(n1.equals(n2)); + assertTrue(n2.equals(n1)); + } + + /** + * Check that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + PinNeedle n1 = new PinNeedle(); + PinNeedle n2 = (PinNeedle) n1.clone(); + assertTrue(n1 != n2); + assertTrue(n1.getClass() == n2.getClass()); + assertTrue(n1.equals(n2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PinNeedle n1 = new PinNeedle(); + PinNeedle n2 = (PinNeedle) TestUtilities.serialised(n1); + assertTrue(n1.equals(n2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/PlumNeedleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/PlumNeedleTest.java new file mode 100755 index 0000000..72b59f6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/PlumNeedleTest.java @@ -0,0 +1,86 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * PlumNeedleTest.java + * ------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Jun-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.needle; + +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link PlumNeedle} class. + */ +public class PlumNeedleTest { + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + PlumNeedle n1 = new PlumNeedle(); + PlumNeedle n2 = new PlumNeedle(); + assertTrue(n1.equals(n2)); + assertTrue(n2.equals(n1)); + } + + /** + * Check that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + PlumNeedle n1 = new PlumNeedle(); + PlumNeedle n2 = (PlumNeedle) n1.clone(); + assertTrue(n1 != n2); + assertTrue(n1.getClass() == n2.getClass()); + assertTrue(n1.equals(n2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PlumNeedle n1 = new PlumNeedle(); + PlumNeedle n2 = (PlumNeedle) TestUtilities.serialised(n1); + assertTrue(n1.equals(n2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/PointerNeedleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/PointerNeedleTest.java new file mode 100755 index 0000000..7f28a84 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/PointerNeedleTest.java @@ -0,0 +1,86 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * PointerNeedleTest.java + * ---------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Jun-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.needle; + +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link PointerNeedle} class. + */ +public class PointerNeedleTest { + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + PointerNeedle n1 = new PointerNeedle(); + PointerNeedle n2 = new PointerNeedle(); + assertTrue(n1.equals(n2)); + assertTrue(n2.equals(n1)); + } + + /** + * Check that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + PointerNeedle n1 = new PointerNeedle(); + PointerNeedle n2 = (PointerNeedle) n1.clone(); + assertTrue(n1 != n2); + assertTrue(n1.getClass() == n2.getClass()); + assertTrue(n1.equals(n2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PointerNeedle n1 = new PointerNeedle(); + PointerNeedle n2 = (PointerNeedle) TestUtilities.serialised(n1); + assertTrue(n1.equals(n2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/ShipNeedleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/ShipNeedleTest.java new file mode 100755 index 0000000..a4b8710 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/ShipNeedleTest.java @@ -0,0 +1,86 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * ShipNeedleTest.java + * ------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Jun-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.needle; + +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link ShipNeedle} class. + */ +public class ShipNeedleTest { + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + ShipNeedle n1 = new ShipNeedle(); + ShipNeedle n2 = new ShipNeedle(); + assertTrue(n1.equals(n2)); + assertTrue(n2.equals(n1)); + } + + /** + * Check that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ShipNeedle n1 = new ShipNeedle(); + ShipNeedle n2 = (ShipNeedle) n1.clone(); + assertTrue(n1 != n2); + assertTrue(n1.getClass() == n2.getClass()); + assertTrue(n1.equals(n2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ShipNeedle n1 = new ShipNeedle(); + ShipNeedle n2 = (ShipNeedle) TestUtilities.serialised(n1); + assertTrue(n1.equals(n2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/WindNeedleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/WindNeedleTest.java new file mode 100755 index 0000000..e431eed --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/needle/WindNeedleTest.java @@ -0,0 +1,86 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * WindNeedleTest.java + * ------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Jun-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.needle; + +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link WindNeedle} class. + */ +public class WindNeedleTest { + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + WindNeedle n1 = new WindNeedle(); + WindNeedle n2 = new WindNeedle(); + assertTrue(n1.equals(n2)); + assertTrue(n2.equals(n1)); + } + + /** + * Check that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + WindNeedle n1 = new WindNeedle(); + WindNeedle n2 = (WindNeedle) n1.clone(); + assertTrue(n1 != n2); + assertTrue(n1.getClass() == n2.getClass()); + assertTrue(n1.equals(n2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + WindNeedle n1 = new WindNeedle(); + WindNeedle n2 = (WindNeedle) TestUtilities.serialised(n1); + assertTrue(n1.equals(n2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/package.html new file mode 100755 index 0000000..1f7cafb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/package.html @@ -0,0 +1,6 @@ + + + +Test cases for the JFreeChart class library, based on the JUnit framework. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/panel/CrosshairOverlayTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/panel/CrosshairOverlayTest.java new file mode 100755 index 0000000..e4c3cec --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/panel/CrosshairOverlayTest.java @@ -0,0 +1,103 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * CrosshairOverlayTest.java + * ------------------------- + * (C) Copyright 2009-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-Apr-2009 : Version 1 (DG); + * + */ + +package org.jfree.chart.panel; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.plot.Crosshair; +import org.junit.Test; + +/** + * Tests for the {@link CrosshairOverlay} class. + */ +public class CrosshairOverlayTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + CrosshairOverlay o1 = new CrosshairOverlay(); + CrosshairOverlay o2 = new CrosshairOverlay(); + assertEquals(o1, o2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CrosshairOverlay o1 = new CrosshairOverlay(); + o1.addDomainCrosshair(new Crosshair(99.9)); + o1.addRangeCrosshair(new Crosshair(1.23, new GradientPaint(1.0f, 2.0f, + Color.red, 3.0f, 4.0f, Color.blue), new BasicStroke(1.1f))); + CrosshairOverlay o2 = (CrosshairOverlay) TestUtilities.serialised(o1); + assertEquals(o1, o2); + } + + /** + * Basic checks for cloning. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CrosshairOverlay o1 = new CrosshairOverlay(); + o1.addDomainCrosshair(new Crosshair(99.9)); + o1.addRangeCrosshair(new Crosshair(1.23, new GradientPaint(1.0f, 2.0f, + Color.red, 3.0f, 4.0f, Color.blue), new BasicStroke(1.1f))); + CrosshairOverlay o2 = (CrosshairOverlay) o1.clone(); + assertTrue(o1 != o2); + assertTrue(o1.getClass() == o2.getClass()); + assertTrue(o1.equals(o2)); + + o1.addDomainCrosshair(new Crosshair(3.21)); + o1.addRangeCrosshair(new Crosshair(4.32)); + assertFalse(o1.equals(o2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CategoryMarkerTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CategoryMarkerTest.java new file mode 100755 index 0000000..a1e42b8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CategoryMarkerTest.java @@ -0,0 +1,201 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * CategoryMarkerTest.java + * ----------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Mar-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.event.MarkerChangeEvent; +import org.jfree.chart.event.MarkerChangeListener; +import org.junit.Test; + +/** + * Some tests for the {@link CategoryMarker} class. + */ +public class CategoryMarkerTest implements MarkerChangeListener { + + MarkerChangeEvent lastEvent; + + /** + * Records the last event. + * + * @param event the last event. + */ + @Override + public void markerChanged(MarkerChangeEvent event) { + this.lastEvent = event; + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + CategoryMarker m1 = new CategoryMarker("A"); + CategoryMarker m2 = new CategoryMarker("A"); + assertTrue(m1.equals(m2)); + assertTrue(m2.equals(m1)); + + //key + m1 = new CategoryMarker("B"); + assertFalse(m1.equals(m2)); + m2 = new CategoryMarker("B"); + assertTrue(m1.equals(m2)); + + //paint + m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f)); + assertFalse(m1.equals(m2)); + m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.yellow), new BasicStroke(1.1f)); + assertTrue(m1.equals(m2)); + + //stroke + m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f)); + assertFalse(m1.equals(m2)); + m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f)); + assertTrue(m1.equals(m2)); + + //outlinePaint + m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.red, + new BasicStroke(1.0f), 1.0f); + assertFalse(m1.equals(m2)); + m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.red, + new BasicStroke(1.0f), 1.0f); + assertTrue(m1.equals(m2)); + + //outlineStroke + m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.red, + new BasicStroke(3.3f), 1.0f); + assertFalse(m1.equals(m2)); + m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.red, + new BasicStroke(3.3f), 1.0f); + assertTrue(m1.equals(m2)); + + //alpha + m1 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.red, + new BasicStroke(1.0f), 0.5f); + assertFalse(m1.equals(m2)); + m2 = new CategoryMarker("A", new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.yellow), new BasicStroke(2.2f), Color.red, + new BasicStroke(1.0f), 0.5f); + assertTrue(m1.equals(m2)); + + } + + /** + * Check cloning. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CategoryMarker m1 = new CategoryMarker("A", new GradientPaint(1.0f, + 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), + new BasicStroke(1.1f)); + CategoryMarker m2 = (CategoryMarker) m1.clone(); + assertTrue(m1 != m2); + assertTrue(m1.getClass() == m2.getClass()); + assertTrue(m1.equals(m2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CategoryMarker m1 = new CategoryMarker("A", new GradientPaint(1.0f, + 2.0f, Color.white, 3.0f, 4.0f, Color.yellow), + new BasicStroke(1.1f)); + CategoryMarker m2 = (CategoryMarker) TestUtilities.serialised(m1); + assertEquals(m1, m2); + } + + /** + * Some checks for the getKey() and setKey() methods. + */ + @Test + public void testGetSetKey() { + CategoryMarker m = new CategoryMarker("X"); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals("X", m.getKey()); + m.setKey("Y"); + assertEquals("Y", m.getKey()); + assertEquals(m, this.lastEvent.getMarker()); + + // check null argument... + try { + m.setKey(null); + fail("Expected an IllegalArgumentException for null."); + } + catch (IllegalArgumentException e) { + assertTrue(true); + } + } + + /** + * Some checks for the getDrawAsLine() and setDrawAsLine() methods. + */ + @Test + public void testGetSetDrawAsLine() { + CategoryMarker m = new CategoryMarker("X"); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(false, m.getDrawAsLine()); + m.setDrawAsLine(true); + assertEquals(true, m.getDrawAsLine()); + assertEquals(m, this.lastEvent.getMarker()); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CategoryPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CategoryPlotTest.java new file mode 100755 index 0000000..1668112 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CategoryPlotTest.java @@ -0,0 +1,992 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * CategoryPlotTest.java + * --------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Mar-2003 : Version 1 (DG); + * 15-Sep-2003 : Added a unit test to reproduce a bug in serialization (now + * fixed) (DG); + * 05-Feb-2007 : Added testAddDomainMarker() and testAddRangeMarker() (DG); + * 07-Feb-2007 : Added test1654215() (DG); + * 07-Apr-2008 : Added testRemoveDomainMarker() and + * testRemoveRangeMarker() (DG); + * 23-Apr-2008 : Extended testEquals() and testCloning(), and added + * testCloning2() and testCloning3() (DG); + * 26-Jun-2008 : Updated testEquals() (DG); + * 21-Jan-2009 : Updated testEquals() for new fields (DG); + * 10-Jul-2009 : Updated testEquals() for new field (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Stroke; +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.Arrays; +import java.util.List; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.annotations.CategoryLineAnnotation; +import org.jfree.chart.annotations.CategoryTextAnnotation; +import org.jfree.chart.axis.AxisLocation; +import org.jfree.chart.axis.AxisSpace; +import org.jfree.chart.axis.CategoryAnchor; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.event.MarkerChangeListener; +import org.jfree.chart.renderer.category.AreaRenderer; +import org.jfree.chart.renderer.category.BarRenderer; +import org.jfree.chart.renderer.category.CategoryItemRenderer; +import org.jfree.chart.renderer.category.DefaultCategoryItemRenderer; +import org.jfree.chart.renderer.category.LineAndShapeRenderer; +import org.jfree.chart.util.DefaultShadowGenerator; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.ui.Layer; +import org.jfree.ui.RectangleInsets; +import org.jfree.util.SortOrder; +import org.junit.Test; + +/** + * Tests for the {@link CategoryPlot} class. + */ +public class CategoryPlotTest { + + /** + * Some checks for the constructor. + */ + @Test + public void testConstructor() { + CategoryPlot plot = new CategoryPlot(); + assertEquals(RectangleInsets.ZERO_INSETS, plot.getAxisOffset()); + } + + /** + * A test for a bug reported in the forum. + */ + @Test + public void testAxisRange() { + DefaultCategoryDataset datasetA = new DefaultCategoryDataset(); + DefaultCategoryDataset datasetB = new DefaultCategoryDataset(); + datasetB.addValue(50.0, "R1", "C1"); + datasetB.addValue(80.0, "R1", "C1"); + CategoryPlot plot = new CategoryPlot(datasetA, new CategoryAxis(null), + new NumberAxis(null), new LineAndShapeRenderer()); + plot.setDataset(1, datasetB); + plot.setRenderer(1, new LineAndShapeRenderer()); + Range r = plot.getRangeAxis().getRange(); + assertEquals(84.0, r.getUpperBound(), 0.00001); + } + + /** + * Test that the equals() method differentiates all the required fields. + */ + @Test + public void testEquals() { + + CategoryPlot plot1 = new CategoryPlot(); + CategoryPlot plot2 = new CategoryPlot(); + assertTrue(plot1.equals(plot2)); + assertTrue(plot2.equals(plot1)); + + // orientation... + plot1.setOrientation(PlotOrientation.HORIZONTAL); + assertFalse(plot1.equals(plot2)); + plot2.setOrientation(PlotOrientation.HORIZONTAL); + assertTrue(plot1.equals(plot2)); + + // axisOffset... + plot1.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05)); + assertFalse(plot1.equals(plot2)); + plot2.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05)); + assertTrue(plot1.equals(plot2)); + + // domainAxis - no longer a separate field but test anyway... + plot1.setDomainAxis(new CategoryAxis("Category Axis")); + assertFalse(plot1.equals(plot2)); + plot2.setDomainAxis(new CategoryAxis("Category Axis")); + assertTrue(plot1.equals(plot2)); + + // domainAxes... + plot1.setDomainAxis(11, new CategoryAxis("Secondary Axis")); + assertFalse(plot1.equals(plot2)); + plot2.setDomainAxis(11, new CategoryAxis("Secondary Axis")); + assertTrue(plot1.equals(plot2)); + + // domainAxisLocation - no longer a separate field but test anyway... + plot1.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); + assertFalse(plot1.equals(plot2)); + plot2.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); + assertTrue(plot1.equals(plot2)); + + // domainAxisLocations... + plot1.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT); + assertFalse(plot1.equals(plot2)); + plot2.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT); + assertTrue(plot1.equals(plot2)); + + // draw shared domain axis... + plot1.setDrawSharedDomainAxis(!plot1.getDrawSharedDomainAxis()); + assertFalse(plot1.equals(plot2)); + plot2.setDrawSharedDomainAxis(!plot2.getDrawSharedDomainAxis()); + assertTrue(plot1.equals(plot2)); + + // rangeAxis - no longer a separate field but test anyway... + plot1.setRangeAxis(new NumberAxis("Range Axis")); + assertFalse(plot1.equals(plot2)); + plot2.setRangeAxis(new NumberAxis("Range Axis")); + assertTrue(plot1.equals(plot2)); + + // rangeAxes... + plot1.setRangeAxis(11, new NumberAxis("Secondary Range Axis")); + assertFalse(plot1.equals(plot2)); + plot2.setRangeAxis(11, new NumberAxis("Secondary Range Axis")); + assertTrue(plot1.equals(plot2)); + + // rangeAxisLocation - no longer a separate field but test anyway... + plot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT); + assertFalse(plot1.equals(plot2)); + plot2.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT); + assertTrue(plot1.equals(plot2)); + + // rangeAxisLocations... + plot1.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT); + assertFalse(plot1.equals(plot2)); + plot2.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT); + assertTrue(plot1.equals(plot2)); + + // datasetToDomainAxisMap... + plot1.mapDatasetToDomainAxis(11, 11); + assertFalse(plot1.equals(plot2)); + plot2.mapDatasetToDomainAxis(11, 11); + assertTrue(plot1.equals(plot2)); + + // datasetToRangeAxisMap... + plot1.mapDatasetToRangeAxis(11, 11); + assertFalse(plot1.equals(plot2)); + plot2.mapDatasetToRangeAxis(11, 11); + assertTrue(plot1.equals(plot2)); + + // renderer - no longer a separate field but test anyway... + plot1.setRenderer(new AreaRenderer()); + assertFalse(plot1.equals(plot2)); + plot2.setRenderer(new AreaRenderer()); + assertTrue(plot1.equals(plot2)); + + // renderers... + plot1.setRenderer(11, new AreaRenderer()); + assertFalse(plot1.equals(plot2)); + plot2.setRenderer(11, new AreaRenderer()); + assertTrue(plot1.equals(plot2)); + + // rendering order... + plot1.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); + assertFalse(plot1.equals(plot2)); + plot2.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); + assertTrue(plot1.equals(plot2)); + + // columnRenderingOrder... + plot1.setColumnRenderingOrder(SortOrder.DESCENDING); + assertFalse(plot1.equals(plot2)); + plot2.setColumnRenderingOrder(SortOrder.DESCENDING); + assertTrue(plot1.equals(plot2)); + + // rowRenderingOrder... + plot1.setRowRenderingOrder(SortOrder.DESCENDING); + assertFalse(plot1.equals(plot2)); + plot2.setRowRenderingOrder(SortOrder.DESCENDING); + assertTrue(plot1.equals(plot2)); + + // domainGridlinesVisible + plot1.setDomainGridlinesVisible(true); + assertFalse(plot1.equals(plot2)); + plot2.setDomainGridlinesVisible(true); + assertTrue(plot1.equals(plot2)); + + // domainGridlinePosition + plot1.setDomainGridlinePosition(CategoryAnchor.END); + assertFalse(plot1.equals(plot2)); + plot2.setDomainGridlinePosition(CategoryAnchor.END); + assertTrue(plot1.equals(plot2)); + + // domainGridlineStroke + Stroke stroke = new BasicStroke(2.0f); + plot1.setDomainGridlineStroke(stroke); + assertFalse(plot1.equals(plot2)); + plot2.setDomainGridlineStroke(stroke); + assertTrue(plot1.equals(plot2)); + + // domainGridlinePaint + plot1.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.yellow)); + assertFalse(plot1.equals(plot2)); + plot2.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.yellow)); + assertTrue(plot1.equals(plot2)); + + // rangeGridlinesVisible + plot1.setRangeGridlinesVisible(false); + assertFalse(plot1.equals(plot2)); + plot2.setRangeGridlinesVisible(false); + assertTrue(plot1.equals(plot2)); + + // rangeGridlineStroke + plot1.setRangeGridlineStroke(stroke); + assertFalse(plot1.equals(plot2)); + plot2.setRangeGridlineStroke(stroke); + assertTrue(plot1.equals(plot2)); + + // rangeGridlinePaint + plot1.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, + 3.0f, 4.0f, Color.yellow)); + assertFalse(plot1.equals(plot2)); + plot2.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, + 3.0f, 4.0f, Color.yellow)); + assertTrue(plot1.equals(plot2)); + + // anchorValue + plot1.setAnchorValue(100.0); + assertFalse(plot1.equals(plot2)); + plot2.setAnchorValue(100.0); + assertTrue(plot1.equals(plot2)); + + // rangeCrosshairVisible + plot1.setRangeCrosshairVisible(true); + assertFalse(plot1.equals(plot2)); + plot2.setRangeCrosshairVisible(true); + assertTrue(plot1.equals(plot2)); + + // rangeCrosshairValue + plot1.setRangeCrosshairValue(100.0); + assertFalse(plot1.equals(plot2)); + plot2.setRangeCrosshairValue(100.0); + assertTrue(plot1.equals(plot2)); + + // rangeCrosshairStroke + plot1.setRangeCrosshairStroke(stroke); + assertFalse(plot1.equals(plot2)); + plot2.setRangeCrosshairStroke(stroke); + assertTrue(plot1.equals(plot2)); + + // rangeCrosshairPaint + plot1.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.yellow)); + assertFalse(plot1.equals(plot2)); + plot2.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.yellow)); + assertTrue(plot1.equals(plot2)); + + // rangeCrosshairLockedOnData + plot1.setRangeCrosshairLockedOnData(false); + assertFalse(plot1.equals(plot2)); + plot2.setRangeCrosshairLockedOnData(false); + assertTrue(plot1.equals(plot2)); + + // foreground domain markers + plot1.addDomainMarker(new CategoryMarker("C1"), Layer.FOREGROUND); + assertFalse(plot1.equals(plot2)); + plot2.addDomainMarker(new CategoryMarker("C1"), Layer.FOREGROUND); + assertTrue(plot1.equals(plot2)); + + // background domain markers + plot1.addDomainMarker(new CategoryMarker("C2"), Layer.BACKGROUND); + assertFalse(plot1.equals(plot2)); + plot2.addDomainMarker(new CategoryMarker("C2"), Layer.BACKGROUND); + assertTrue(plot1.equals(plot2)); + + // range markers - no longer separate fields but test anyway... + plot1.addRangeMarker(new ValueMarker(4.0), Layer.FOREGROUND); + assertFalse(plot1.equals(plot2)); + plot2.addRangeMarker(new ValueMarker(4.0), Layer.FOREGROUND); + assertTrue(plot1.equals(plot2)); + + plot1.addRangeMarker(new ValueMarker(5.0), Layer.BACKGROUND); + assertFalse(plot1.equals(plot2)); + plot2.addRangeMarker(new ValueMarker(5.0), Layer.BACKGROUND); + assertTrue(plot1.equals(plot2)); + + // foreground range markers... + plot1.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND); + assertFalse(plot1.equals(plot2)); + plot2.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND); + assertTrue(plot1.equals(plot2)); + + // background range markers... + plot1.addRangeMarker(1, new ValueMarker(5.0), Layer.BACKGROUND); + assertFalse(plot1.equals(plot2)); + plot2.addRangeMarker(1, new ValueMarker(5.0), Layer.BACKGROUND); + assertTrue(plot1.equals(plot2)); + + // annotations + plot1.addAnnotation(new CategoryTextAnnotation("Text", "Category", + 43.0)); + assertFalse(plot1.equals(plot2)); + plot2.addAnnotation(new CategoryTextAnnotation("Text", "Category", + 43.0)); + assertTrue(plot1.equals(plot2)); + + // weight + plot1.setWeight(3); + assertFalse(plot1.equals(plot2)); + plot2.setWeight(3); + assertTrue(plot1.equals(plot2)); + + // fixed domain axis space... + plot1.setFixedDomainAxisSpace(new AxisSpace()); + assertFalse(plot1.equals(plot2)); + plot2.setFixedDomainAxisSpace(new AxisSpace()); + assertTrue(plot1.equals(plot2)); + + // fixed range axis space... + plot1.setFixedRangeAxisSpace(new AxisSpace()); + assertFalse(plot1.equals(plot2)); + plot2.setFixedRangeAxisSpace(new AxisSpace()); + assertTrue(plot1.equals(plot2)); + + // fixed legend items + plot1.setFixedLegendItems(new LegendItemCollection()); + assertFalse(plot1.equals(plot2)); + plot2.setFixedLegendItems(new LegendItemCollection()); + assertTrue(plot1.equals(plot2)); + + // crosshairDatasetIndex + plot1.setCrosshairDatasetIndex(99); + assertFalse(plot1.equals(plot2)); + plot2.setCrosshairDatasetIndex(99); + assertTrue(plot1.equals(plot2)); + + // domainCrosshairColumnKey + plot1.setDomainCrosshairColumnKey("A"); + assertFalse(plot1.equals(plot2)); + plot2.setDomainCrosshairColumnKey("A"); + assertTrue(plot1.equals(plot2)); + + // domainCrosshairRowKey + plot1.setDomainCrosshairRowKey("B"); + assertFalse(plot1.equals(plot2)); + plot2.setDomainCrosshairRowKey("B"); + assertTrue(plot1.equals(plot2)); + + // domainCrosshairVisible + plot1.setDomainCrosshairVisible(true); + assertFalse(plot1.equals(plot2)); + plot2.setDomainCrosshairVisible(true); + assertTrue(plot1.equals(plot2)); + + // domainCrosshairPaint + plot1.setDomainCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertFalse(plot1.equals(plot2)); + plot2.setDomainCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertTrue(plot1.equals(plot2)); + + // domainCrosshairStroke + plot1.setDomainCrosshairStroke(new BasicStroke(1.23f)); + assertFalse(plot1.equals(plot2)); + plot2.setDomainCrosshairStroke(new BasicStroke(1.23f)); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeMinorGridlinesVisible(true); + assertFalse(plot1.equals(plot2)); + plot2.setRangeMinorGridlinesVisible(true); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeMinorGridlinePaint(new GradientPaint(1.0f, 2.0f, + Color.red, 3.0f, 4.0f, Color.blue)); + assertFalse(plot1.equals(plot2)); + plot2.setRangeMinorGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeMinorGridlineStroke(new BasicStroke(1.23f)); + assertFalse(plot1.equals(plot2)); + plot2.setRangeMinorGridlineStroke(new BasicStroke(1.23f)); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeZeroBaselineVisible(!plot1.isRangeZeroBaselineVisible()); + assertFalse(plot1.equals(plot2)); + plot2.setRangeZeroBaselineVisible(!plot2.isRangeZeroBaselineVisible()); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, + Color.red, 3.0f, 4.0f, Color.blue)); + assertFalse(plot1.equals(plot2)); + plot2.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeZeroBaselineStroke(new BasicStroke(1.23f)); + assertFalse(plot1.equals(plot2)); + plot2.setRangeZeroBaselineStroke(new BasicStroke(1.23f)); + assertTrue(plot1.equals(plot2)); + + // shadowGenerator + plot1.setShadowGenerator(new DefaultShadowGenerator(5, Color.gray, + 0.6f, 4, -Math.PI / 4)); + assertFalse(plot1.equals(plot2)); + plot2.setShadowGenerator(new DefaultShadowGenerator(5, Color.gray, + 0.6f, 4, -Math.PI / 4)); + assertTrue(plot1.equals(plot2)); + + plot1.setShadowGenerator(null); + assertFalse(plot1.equals(plot2)); + plot2.setShadowGenerator(null); + assertTrue(plot1.equals(plot2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() { + CategoryPlot p1 = new CategoryPlot(); + p1.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.yellow)); + p1.setRangeMinorGridlinePaint(new GradientPaint(2.0f, 3.0f, Color.white, + 4.0f, 5.0f, Color.red)); + p1.setRangeZeroBaselinePaint(new GradientPaint(3.0f, 4.0f, Color.red, + 5.0f, 6.0f, Color.white)); + CategoryPlot p2 = null; + try { + p2 = (CategoryPlot) p1.clone(); + } + catch (CloneNotSupportedException e) { + fail("Cloning failed."); + return; + } + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // check independence + p1.addAnnotation(new CategoryLineAnnotation("C1", 1.0, "C2", 2.0, + Color.red, new BasicStroke(1.0f))); + assertFalse(p1.equals(p2)); + p2.addAnnotation(new CategoryLineAnnotation("C1", 1.0, "C2", 2.0, + Color.red, new BasicStroke(1.0f))); + assertTrue(p1.equals(p2)); + + p1.addDomainMarker(new CategoryMarker("C1"), Layer.FOREGROUND); + assertFalse(p1.equals(p2)); + p2.addDomainMarker(new CategoryMarker("C1"), Layer.FOREGROUND); + assertTrue(p1.equals(p2)); + + p1.addDomainMarker(new CategoryMarker("C2"), Layer.BACKGROUND); + assertFalse(p1.equals(p2)); + p2.addDomainMarker(new CategoryMarker("C2"), Layer.BACKGROUND); + assertTrue(p1.equals(p2)); + + p1.addRangeMarker(new ValueMarker(1.0), Layer.FOREGROUND); + assertFalse(p1.equals(p2)); + p2.addRangeMarker(new ValueMarker(1.0), Layer.FOREGROUND); + assertTrue(p1.equals(p2)); + + p1.addRangeMarker(new ValueMarker(2.0), Layer.BACKGROUND); + assertFalse(p1.equals(p2)); + p2.addRangeMarker(new ValueMarker(2.0), Layer.BACKGROUND); + assertTrue(p1.equals(p2)); + } + + /** + * Some more cloning checks. + */ + @Test + public void testCloning2() { + AxisSpace da1 = new AxisSpace(); + AxisSpace ra1 = new AxisSpace(); + CategoryPlot p1 = new CategoryPlot(); + p1.setFixedDomainAxisSpace(da1); + p1.setFixedRangeAxisSpace(ra1); + CategoryPlot p2 = null; + try { + p2 = (CategoryPlot) p1.clone(); + } + catch (CloneNotSupportedException e) { + fail("Cloning failed."); + return; + } + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + da1.setBottom(99.0); + assertFalse(p1.equals(p2)); + p2.getFixedDomainAxisSpace().setBottom(99.0); + assertTrue(p1.equals(p2)); + + ra1.setBottom(11.0); + assertFalse(p1.equals(p2)); + p2.getFixedRangeAxisSpace().setBottom(11.0); + assertTrue(p1.equals(p2)); + } + + /** + * Some more cloning checks. + */ + @Test + public void testCloning3() { + LegendItemCollection c1 = new LegendItemCollection(); + CategoryPlot p1 = new CategoryPlot(); + p1.setFixedLegendItems(c1); + CategoryPlot p2 = null; + try { + p2 = (CategoryPlot) p1.clone(); + } + catch (CloneNotSupportedException e) { + fail("Cloning failed."); + return; + } + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + c1.add(new LegendItem("X", "XX", "tt", "url", true, + new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, Color.red, + true, Color.yellow, new BasicStroke(1.0f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.0f), + Color.green)); + assertFalse(p1.equals(p2)); + p2.getFixedLegendItems().add(new LegendItem("X", "XX", "tt", "url", + true, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0), true, + Color.red, true, Color.yellow, new BasicStroke(1.0f), true, + new Line2D.Double(1.0, 2.0, 3.0, 4.0), new BasicStroke(1.0f), + Color.green)); + assertTrue(p1.equals(p2)); + } + + /** + * Renderers that belong to the plot are being cloned but they are + * retaining a reference to the original plot. + */ + @Test + public void testBug2817504() { + CategoryPlot p1 = new CategoryPlot(); + LineAndShapeRenderer r1 = new LineAndShapeRenderer(); + p1.setRenderer(r1); + CategoryPlot p2 = null; + try { + p2 = (CategoryPlot) p1.clone(); + } + catch (CloneNotSupportedException e) { + fail("Cloning failed."); + return; + } + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // check for independence + LineAndShapeRenderer r2 = (LineAndShapeRenderer) p2.getRenderer(); + assertTrue(r2.getPlot() == p2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + CategoryAxis domainAxis = new CategoryAxis("Domain"); + NumberAxis rangeAxis = new NumberAxis("Range"); + BarRenderer renderer = new BarRenderer(); + CategoryPlot p1 = new CategoryPlot(dataset, domainAxis, rangeAxis, + renderer); + p1.setOrientation(PlotOrientation.HORIZONTAL); + CategoryPlot p2 = (CategoryPlot) TestUtilities.serialised(p1); + assertTrue(p1.equals(p2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization2() { + DefaultCategoryDataset data = new DefaultCategoryDataset(); + CategoryAxis domainAxis = new CategoryAxis("Domain"); + NumberAxis rangeAxis = new NumberAxis("Range"); + BarRenderer renderer = new BarRenderer(); + CategoryPlot p1 = new CategoryPlot(data, domainAxis, rangeAxis, + renderer); + p1.setOrientation(PlotOrientation.VERTICAL); + CategoryPlot p2 = (CategoryPlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization3() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + JFreeChart chart = ChartFactory.createBarChart( + "Test Chart", "Category Axis", "Value Axis", dataset, + PlotOrientation.VERTICAL, true, true, false); + JFreeChart chart2 = (JFreeChart) TestUtilities.serialised(chart); + + // now check that the chart is usable... + try { + chart2.createBufferedImage(300, 200); + } + catch (Exception e) { + fail("No exception should be thrown."); + } + } + + /** + * This test ensures that a plot with markers is serialized correctly. + */ + @Test + public void testSerialization4() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + JFreeChart chart = ChartFactory.createBarChart( + "Test Chart", "Category Axis", "Value Axis", + dataset, PlotOrientation.VERTICAL, true, true, false); + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + plot.addRangeMarker(new ValueMarker(1.1), Layer.FOREGROUND); + plot.addRangeMarker(new IntervalMarker(2.2, 3.3), Layer.BACKGROUND); + JFreeChart chart2 = (JFreeChart) TestUtilities.serialised(chart); + assertEquals(chart, chart2); + + // now check that the chart is usable... + try { + chart2.createBufferedImage(300, 200); + } + catch (Exception e) { + fail("No exception should be thrown."); + } + } + + /** + * Tests a bug where the plot is no longer registered as a listener + * with the dataset(s) and axes after deserialization. See patch 1209475 + * at SourceForge. + */ + @Test + public void testSerialization5() { + DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); + CategoryAxis domainAxis1 = new CategoryAxis("Domain 1"); + NumberAxis rangeAxis1 = new NumberAxis("Range 1"); + BarRenderer renderer1 = new BarRenderer(); + CategoryPlot p1 = new CategoryPlot(dataset1, domainAxis1, rangeAxis1, + renderer1); + CategoryAxis domainAxis2 = new CategoryAxis("Domain 2"); + NumberAxis rangeAxis2 = new NumberAxis("Range 2"); + BarRenderer renderer2 = new BarRenderer(); + DefaultCategoryDataset dataset2 = new DefaultCategoryDataset(); + p1.setDataset(1, dataset2); + p1.setDomainAxis(1, domainAxis2); + p1.setRangeAxis(1, rangeAxis2); + p1.setRenderer(1, renderer2); + CategoryPlot p2 = (CategoryPlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + + // now check that all datasets, renderers and axes are being listened + // too... + CategoryAxis domainAxisA = p2.getDomainAxis(0); + NumberAxis rangeAxisA = (NumberAxis) p2.getRangeAxis(0); + DefaultCategoryDataset datasetA + = (DefaultCategoryDataset) p2.getDataset(0); + BarRenderer rendererA = (BarRenderer) p2.getRenderer(0); + CategoryAxis domainAxisB = p2.getDomainAxis(1); + NumberAxis rangeAxisB = (NumberAxis) p2.getRangeAxis(1); + DefaultCategoryDataset datasetB + = (DefaultCategoryDataset) p2.getDataset(1); + BarRenderer rendererB = (BarRenderer) p2.getRenderer(1); + assertTrue(datasetA.hasListener(p2)); + assertTrue(domainAxisA.hasListener(p2)); + assertTrue(rangeAxisA.hasListener(p2)); + assertTrue(rendererA.hasListener(p2)); + assertTrue(datasetB.hasListener(p2)); + assertTrue(domainAxisB.hasListener(p2)); + assertTrue(rangeAxisB.hasListener(p2)); + assertTrue(rendererB.hasListener(p2)); + } + + /** + * A test for a bug where setting the renderer doesn't register the plot + * as a RendererChangeListener. + */ + @Test + public void testSetRenderer() { + CategoryPlot plot = new CategoryPlot(); + CategoryItemRenderer renderer = new LineAndShapeRenderer(); + plot.setRenderer(renderer); + // now make a change to the renderer and see if it triggers a plot + // change event... + MyPlotChangeListener listener = new MyPlotChangeListener(); + plot.addChangeListener(listener); + renderer.setSeriesPaint(0, Color.black); + assertTrue(listener.getEvent() != null); + } + + /** + * A test for bug report 1169972. + */ + @Test + public void test1169972() { + CategoryPlot plot = new CategoryPlot(null, null, null, null); + plot.setDomainAxis(new CategoryAxis("C")); + plot.setRangeAxis(new NumberAxis("Y")); + plot.setRenderer(new BarRenderer()); + plot.setDataset(new DefaultCategoryDataset()); + assertTrue(true); // we didn't get an exception so all is good + } + + /** + * Some tests for the addDomainMarker() method(s). + */ + @Test + public void testAddDomainMarker() { + CategoryPlot plot = new CategoryPlot(); + CategoryMarker m = new CategoryMarker("C1"); + plot.addDomainMarker(m); + List listeners = Arrays.asList(m.getListeners( + MarkerChangeListener.class)); + assertTrue(listeners.contains(plot)); + plot.clearDomainMarkers(); + listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class)); + assertFalse(listeners.contains(plot)); + } + + /** + * Some tests for the addRangeMarker() method(s). + */ + @Test + public void testAddRangeMarker() { + CategoryPlot plot = new CategoryPlot(); + Marker m = new ValueMarker(1.0); + plot.addRangeMarker(m); + List listeners = Arrays.asList(m.getListeners( + MarkerChangeListener.class)); + assertTrue(listeners.contains(plot)); + plot.clearRangeMarkers(); + listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class)); + assertFalse(listeners.contains(plot)); + } + + /** + * A test for bug 1654215 (where a renderer is added to the plot without + * a corresponding dataset and it throws an exception at drawing time). + */ + @Test + public void test1654215() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + JFreeChart chart = ChartFactory.createLineChart("Title", "X", "Y", + dataset, PlotOrientation.VERTICAL, true, false, false); + CategoryPlot plot = (CategoryPlot) chart.getPlot(); + plot.setRenderer(1, new LineAndShapeRenderer()); + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); + g2.dispose(); + } + catch (Exception e) { + fail("No exception should be thrown."); + } + } + + /** + * Some checks for the getDomainAxisIndex() method. + */ + @Test + public void testGetDomainAxisIndex() { + CategoryAxis domainAxis1 = new CategoryAxis("X1"); + CategoryAxis domainAxis2 = new CategoryAxis("X2"); + NumberAxis rangeAxis1 = new NumberAxis("Y1"); + CategoryPlot plot = new CategoryPlot(null, domainAxis1, rangeAxis1, + null); + assertEquals(0, plot.getDomainAxisIndex(domainAxis1)); + assertEquals(-1, plot.getDomainAxisIndex(domainAxis2)); + plot.setDomainAxis(1, domainAxis2); + assertEquals(1, plot.getDomainAxisIndex(domainAxis2)); + assertEquals(-1, plot.getDomainAxisIndex(new CategoryAxis("X2"))); + boolean pass = false; + try { + plot.getDomainAxisIndex(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getRangeAxisIndex() method. + */ + @Test + public void testGetRangeAxisIndex() { + CategoryAxis domainAxis1 = new CategoryAxis("X1"); + NumberAxis rangeAxis1 = new NumberAxis("Y1"); + NumberAxis rangeAxis2 = new NumberAxis("Y2"); + CategoryPlot plot = new CategoryPlot(null, domainAxis1, rangeAxis1, + null); + assertEquals(0, plot.getRangeAxisIndex(rangeAxis1)); + assertEquals(-1, plot.getRangeAxisIndex(rangeAxis2)); + plot.setRangeAxis(1, rangeAxis2); + assertEquals(1, plot.getRangeAxisIndex(rangeAxis2)); + assertEquals(-1, plot.getRangeAxisIndex(new NumberAxis("Y2"))); + boolean pass = false; + try { + plot.getRangeAxisIndex(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Check that removing a marker that isn't assigned to the plot returns + * false. + */ + @Test + public void testRemoveDomainMarker() { + CategoryPlot plot = new CategoryPlot(); + assertFalse(plot.removeDomainMarker(new CategoryMarker("Category 1"))); + } + + /** + * Check that removing a marker that isn't assigned to the plot returns + * false. + */ + @Test + public void testRemoveRangeMarker() { + CategoryPlot plot = new CategoryPlot(); + assertFalse(plot.removeRangeMarker(new ValueMarker(0.5))); + } + + /** + * Some tests for the getDomainAxisForDataset() method. + */ + @Test + public void testGetDomainAxisForDataset() { + CategoryDataset dataset = new DefaultCategoryDataset(); + CategoryAxis xAxis = new CategoryAxis("X"); + NumberAxis yAxis = new NumberAxis("Y"); + CategoryItemRenderer renderer = new BarRenderer(); + CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); + assertEquals(xAxis, plot.getDomainAxisForDataset(0)); + + // should get IllegalArgumentException for negative index + boolean pass = false; + try { + plot.getDomainAxisForDataset(-1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + // if multiple axes are mapped, the first in the list should be + // returned... + CategoryAxis xAxis2 = new CategoryAxis("X2"); + plot.setDomainAxis(1, xAxis2); + assertEquals(xAxis, plot.getDomainAxisForDataset(0)); + + plot.mapDatasetToDomainAxis(0, 1); + assertEquals(xAxis2, plot.getDomainAxisForDataset(0)); + + List axisIndices = Arrays.asList(new Integer[] {new Integer(0), + new Integer(1)}); + plot.mapDatasetToDomainAxes(0, axisIndices); + assertEquals(xAxis, plot.getDomainAxisForDataset(0)); + + axisIndices = Arrays.asList(new Integer[] {new Integer(1), + new Integer(2)}); + plot.mapDatasetToDomainAxes(0, axisIndices); + assertEquals(xAxis2, plot.getDomainAxisForDataset(0)); + } + + /** + * Some tests for the getRangeAxisForDataset() method. + */ + @Test + public void testGetRangeAxisForDataset() { + CategoryDataset dataset = new DefaultCategoryDataset(); + CategoryAxis xAxis = new CategoryAxis("X"); + NumberAxis yAxis = new NumberAxis("Y"); + CategoryItemRenderer renderer = new DefaultCategoryItemRenderer(); + CategoryPlot plot = new CategoryPlot(dataset, xAxis, yAxis, renderer); + assertEquals(yAxis, plot.getRangeAxisForDataset(0)); + + // should get IllegalArgumentException for negative index + boolean pass = false; + try { + plot.getRangeAxisForDataset(-1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + // if multiple axes are mapped, the first in the list should be + // returned... + NumberAxis yAxis2 = new NumberAxis("Y2"); + plot.setRangeAxis(1, yAxis2); + assertEquals(yAxis, plot.getRangeAxisForDataset(0)); + + plot.mapDatasetToRangeAxis(0, 1); + assertEquals(yAxis2, plot.getRangeAxisForDataset(0)); + + List axisIndices = Arrays.asList(new Integer[] {new Integer(0), + new Integer(1)}); + plot.mapDatasetToRangeAxes(0, axisIndices); + assertEquals(yAxis, plot.getRangeAxisForDataset(0)); + + axisIndices = Arrays.asList(new Integer[] {new Integer(1), + new Integer(2)}); + plot.mapDatasetToRangeAxes(0, axisIndices); + assertEquals(yAxis2, plot.getRangeAxisForDataset(0)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/ColorPaletteTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/ColorPaletteTest.java new file mode 100755 index 0000000..fae4b6c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/ColorPaletteTest.java @@ -0,0 +1,74 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * ColorPaletteTest.java + * --------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 14-Aug-2003 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertTrue; +import org.junit.Test; + + +/** + * Tests for the ColorPalette class. + */ +public class ColorPaletteTest { + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ColorPalette p1 = new GreyPalette(); + ColorPalette p2 = (ColorPalette) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + ColorPalette p1 = new GreyPalette(); + ColorPalette p2 = new GreyPalette(); + assertTrue(p1.equals(p2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CombinedDomainCategoryPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CombinedDomainCategoryPlotTest.java new file mode 100755 index 0000000..6b8ad6d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CombinedDomainCategoryPlotTest.java @@ -0,0 +1,287 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------- + * CombinedDomainCategoryPlotTest.java + * ----------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Aug-2003 : Version 1 (DG); + * 03-Jan-2008 : Added testNotification() (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.List; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +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.junit.Test; + +/** + * Tests for the {@link CombinedDomainCategoryPlot} class. + */ +public class CombinedDomainCategoryPlotTest implements ChartChangeListener { + + /** A list of the events received. */ + private List events = new java.util.ArrayList(); + + /** + * Receives a chart change event. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.events.add(event); + } + + /** + * This is a test to replicate the bug report 987080. + */ + @Test + public void testRemoveSubplot() { + CombinedDomainCategoryPlot plot = new CombinedDomainCategoryPlot(); + CategoryPlot plot1 = new CategoryPlot(); + CategoryPlot plot2 = new CategoryPlot(); + plot.add(plot1); + plot.add(plot2); + // remove plot2, but plot1 is removed instead + plot.remove(plot2); + List plots = plot.getSubplots(); + assertTrue(plots.get(0) == plot1); + assertEquals(1, plots.size()); + } + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + CombinedDomainCategoryPlot plot1 = createPlot(); + CombinedDomainCategoryPlot plot2 = createPlot(); + assertTrue(plot1.equals(plot2)); + } + + /** + * Some checks for cloning. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CombinedDomainCategoryPlot plot1 = createPlot(); + CombinedDomainCategoryPlot plot2 = (CombinedDomainCategoryPlot) + plot1.clone(); + assertTrue(plot1 != plot2); + assertTrue(plot1.getClass() == plot2.getClass()); + assertTrue(plot1.equals(plot2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CombinedDomainCategoryPlot plot1 = createPlot(); + CombinedDomainCategoryPlot plot2 = (CombinedDomainCategoryPlot) + TestUtilities.serialised(plot1); + assertEquals(plot1, plot2); + } + + /** + * Check that only one chart change event is generated by a change to a + * subplot. + */ + @Test + public void testNotification() { + CombinedDomainCategoryPlot plot = createPlot(); + JFreeChart chart = new JFreeChart(plot); + chart.addChangeListener(this); + CategoryPlot subplot1 = (CategoryPlot) plot.getSubplots().get(0); + NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); + yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); + assertEquals(1, this.events.size()); + + // a redraw should NOT trigger another change event + BufferedImage image = new BufferedImage(200, 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.events.clear(); + chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); + assertTrue(this.events.isEmpty()); + } + + /** + * Creates a dataset. + * + * @return A dataset. + */ + public CategoryDataset createDataset1() { + + DefaultCategoryDataset result = new DefaultCategoryDataset(); + + // row keys... + String series1 = "First"; + String series2 = "Second"; + + // column keys... + 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 CategoryDataset createDataset2() { + + DefaultCategoryDataset result = new DefaultCategoryDataset(); + + // row keys... + String series1 = "Third"; + String series2 = "Fourth"; + + // column keys... + 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 sample plot. + * + * @return A sample plot. + */ + private CombinedDomainCategoryPlot createPlot() { + + 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"); + CombinedDomainCategoryPlot plot + = new CombinedDomainCategoryPlot(domainAxis); + plot.add(subplot1, 2); + plot.add(subplot2, 1); + return plot; + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CombinedDomainXYPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CombinedDomainXYPlotTest.java new file mode 100755 index 0000000..931d8d2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CombinedDomainXYPlotTest.java @@ -0,0 +1,282 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * CombinedDomainXYPlotTest.java + * ----------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Aug-2003 : Version 1 (DG); + * 03-Jan-2008 : Added testNotification() (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.List; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.annotations.XYTextAnnotation; +import org.jfree.chart.axis.AxisLocation; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.renderer.xy.StandardXYItemRenderer; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.junit.Test; + +/** + * Tests for the {@link CombinedDomainXYPlot} class. + */ +public class CombinedDomainXYPlotTest implements ChartChangeListener { + + /** A list of the events received. */ + private List events = new java.util.ArrayList(); + + /** + * Receives a chart change event. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.events.add(event); + } + + /** + * Confirm that the constructor will accept a null axis. + */ + @Test + public void testConstructor1() { + CombinedDomainXYPlot plot = new CombinedDomainXYPlot(null); + assertEquals(null, plot.getDomainAxis()); + } + + /** + * This is a test to replicate the bug report 987080. + */ + @Test + public void testRemoveSubplot() { + CombinedDomainXYPlot plot = new CombinedDomainXYPlot(); + XYPlot plot1 = new XYPlot(); + XYPlot plot2 = new XYPlot(); + plot.add(plot1); + plot.add(plot2); + // remove plot2, but plot1 is removed instead + plot.remove(plot2); + List plots = plot.getSubplots(); + assertTrue(plots.get(0) == plot1); + } + + /** + * Tests the equals() method. + */ + @Test + public void testEquals() { + CombinedDomainXYPlot plot1 = createPlot(); + CombinedDomainXYPlot plot2 = createPlot(); + assertTrue(plot1.equals(plot2)); + assertTrue(plot2.equals(plot1)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CombinedDomainXYPlot plot1 = createPlot(); + CombinedDomainXYPlot plot2 = (CombinedDomainXYPlot) plot1.clone(); + assertTrue(plot1 != plot2); + assertTrue(plot1.getClass() == plot2.getClass()); + assertTrue(plot1.equals(plot2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CombinedDomainXYPlot plot1 = createPlot(); + CombinedDomainXYPlot plot2 = (CombinedDomainXYPlot) + TestUtilities.serialised(plot1); + assertEquals(plot1, plot2); + } + + /** + * Check that only one chart change event is generated by a change to a + * subplot. + */ + @Test + public void testNotification() { + CombinedDomainXYPlot plot = createPlot(); + JFreeChart chart = new JFreeChart(plot); + chart.addChangeListener(this); + XYPlot subplot1 = (XYPlot) plot.getSubplots().get(0); + NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); + yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); + assertEquals(1, this.events.size()); + + // a redraw should NOT trigger another change event + BufferedImage image = new BufferedImage(200, 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.events.clear(); + chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); + assertTrue(this.events.isEmpty()); + } + + /** + * Creates a sample dataset. + * + * @return Series 1. + */ + private XYDataset createDataset1() { + + // create dataset 1... + XYSeries series1 = new XYSeries("Series 1"); + series1.add(10.0, 12353.3); + series1.add(20.0, 13734.4); + series1.add(30.0, 14525.3); + series1.add(40.0, 13984.3); + series1.add(50.0, 12999.4); + series1.add(60.0, 14274.3); + series1.add(70.0, 15943.5); + series1.add(80.0, 14845.3); + series1.add(90.0, 14645.4); + series1.add(100.0, 16234.6); + series1.add(110.0, 17232.3); + series1.add(120.0, 14232.2); + series1.add(130.0, 13102.2); + series1.add(140.0, 14230.2); + series1.add(150.0, 11235.2); + + XYSeries series2 = new XYSeries("Series 2"); + series2.add(10.0, 15000.3); + series2.add(20.0, 11000.4); + series2.add(30.0, 17000.3); + series2.add(40.0, 15000.3); + series2.add(50.0, 14000.4); + series2.add(60.0, 12000.3); + series2.add(70.0, 11000.5); + series2.add(80.0, 12000.3); + series2.add(90.0, 13000.4); + series2.add(100.0, 12000.6); + series2.add(110.0, 13000.3); + series2.add(120.0, 17000.2); + series2.add(130.0, 18000.2); + series2.add(140.0, 16000.2); + series2.add(150.0, 17000.2); + + XYSeriesCollection collection = new XYSeriesCollection(); + collection.addSeries(series1); + collection.addSeries(series2); + return collection; + + } + + /** + * Creates a sample dataset. + * + * @return Series 2. + */ + private XYDataset createDataset2() { + + XYSeries series2 = new XYSeries("Series 3"); + + series2.add(10.0, 16853.2); + series2.add(20.0, 19642.3); + series2.add(30.0, 18253.5); + series2.add(40.0, 15352.3); + series2.add(50.0, 13532.0); + series2.add(100.0, 12635.3); + series2.add(110.0, 13998.2); + series2.add(120.0, 11943.2); + series2.add(130.0, 16943.9); + series2.add(140.0, 17843.2); + series2.add(150.0, 16495.3); + series2.add(160.0, 17943.6); + series2.add(170.0, 18500.7); + series2.add(180.0, 19595.9); + + return new XYSeriesCollection(series2); + + } + + /** + * Creates a sample plot. + * + * @return A sample plot. + */ + private CombinedDomainXYPlot createPlot() { + // create subplot 1... + XYDataset data1 = createDataset1(); + XYItemRenderer renderer1 = new StandardXYItemRenderer(); + NumberAxis rangeAxis1 = new NumberAxis("Range 1"); + XYPlot subplot1 = new XYPlot(data1, null, rangeAxis1, renderer1); + subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); + + XYTextAnnotation annotation = new XYTextAnnotation("Hello!", 50.0, + 10000.0); + annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); + annotation.setRotationAngle(Math.PI / 4.0); + subplot1.addAnnotation(annotation); + + // create subplot 2... + XYDataset data2 = createDataset2(); + XYItemRenderer renderer2 = new StandardXYItemRenderer(); + NumberAxis rangeAxis2 = new NumberAxis("Range 2"); + rangeAxis2.setAutoRangeIncludesZero(false); + XYPlot subplot2 = new XYPlot(data2, null, rangeAxis2, renderer2); + subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); + + // parent plot... + CombinedDomainXYPlot plot = new CombinedDomainXYPlot( + new NumberAxis("Domain")); + plot.setGap(10.0); + + // add the subplots... + plot.add(subplot1, 1); + plot.add(subplot2, 1); + plot.setOrientation(PlotOrientation.VERTICAL); + return plot; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CombinedRangeCategoryPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CombinedRangeCategoryPlotTest.java new file mode 100755 index 0000000..cf39416 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CombinedRangeCategoryPlotTest.java @@ -0,0 +1,279 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------- + * CombinedRangeCategoryPlotTest.java + * ----------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Aug-2003 : Version 1 (DG); + * 03-Jan-2008 : Added testNotification() (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.List; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +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.junit.Test; + +/** + * Tests for the {@link CombinedRangeCategoryPlot} class. + */ +public class CombinedRangeCategoryPlotTest implements ChartChangeListener { + + /** A list of the events received. */ + private List events = new java.util.ArrayList(); + + /** + * Receives a chart change event. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.events.add(event); + } + + /** + * Test the equals() method. + */ + @Test + public void testEquals() { + CombinedRangeCategoryPlot plot1 = createPlot(); + CombinedRangeCategoryPlot plot2 = createPlot(); + assertTrue(plot1.equals(plot2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CombinedRangeCategoryPlot plot1 = createPlot(); + CombinedRangeCategoryPlot plot2 = (CombinedRangeCategoryPlot) + plot1.clone(); + assertTrue(plot1 != plot2); + assertTrue(plot1.getClass() == plot2.getClass()); + assertTrue(plot1.equals(plot2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CombinedRangeCategoryPlot plot1 = createPlot(); + CombinedRangeCategoryPlot plot2 = (CombinedRangeCategoryPlot) + TestUtilities.serialised(plot1); + assertEquals(plot1, plot2); + } + + /** + * This is a test to replicate the bug report 1121172. + */ + @Test + public void testRemoveSubplot() { + CombinedRangeCategoryPlot plot = new CombinedRangeCategoryPlot(); + CategoryPlot plot1 = new CategoryPlot(); + CategoryPlot plot2 = new CategoryPlot(); + CategoryPlot plot3 = new CategoryPlot(); + plot.add(plot1); + plot.add(plot2); + plot.add(plot3); + plot.remove(plot2); + List plots = plot.getSubplots(); + assertEquals(2, plots.size()); + } + + /** + * Check that only one chart change event is generated by a change to a + * subplot. + */ + @Test + public void testNotification() { + CombinedRangeCategoryPlot plot = createPlot(); + JFreeChart chart = new JFreeChart(plot); + chart.addChangeListener(this); + CategoryPlot subplot1 = (CategoryPlot) plot.getSubplots().get(0); + NumberAxis yAxis = (NumberAxis) subplot1.getRangeAxis(); + yAxis.setAutoRangeIncludesZero(!yAxis.getAutoRangeIncludesZero()); + assertEquals(1, this.events.size()); + + // a redraw should NOT trigger another change event + BufferedImage image = new BufferedImage(200, 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.events.clear(); + chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); + assertTrue(this.events.isEmpty()); + } + + /** + * Creates a dataset. + * + * @return A dataset. + */ + public CategoryDataset createDataset1() { + + DefaultCategoryDataset result = new DefaultCategoryDataset(); + + // row keys... + String series1 = "First"; + String series2 = "Second"; + + // column keys... + 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 CategoryDataset createDataset2() { + + DefaultCategoryDataset result = new DefaultCategoryDataset(); + + // row keys... + String series1 = "Third"; + String series2 = "Fourth"; + + // column keys... + 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 sample plot. + * + * @return A plot. + */ + private CombinedRangeCategoryPlot createPlot() { + CategoryDataset dataset1 = createDataset1(); + CategoryAxis catAxis1 = new CategoryAxis("Category"); + LineAndShapeRenderer renderer1 = new LineAndShapeRenderer(); + renderer1.setBaseToolTipGenerator( + new StandardCategoryToolTipGenerator()); + CategoryPlot subplot1 = new CategoryPlot(dataset1, catAxis1, null, + renderer1); + subplot1.setDomainGridlinesVisible(true); + + CategoryDataset dataset2 = createDataset2(); + CategoryAxis catAxis2 = new CategoryAxis("Category"); + BarRenderer renderer2 = new BarRenderer(); + renderer2.setBaseToolTipGenerator( + new StandardCategoryToolTipGenerator()); + CategoryPlot subplot2 = new CategoryPlot(dataset2, catAxis2, null, + renderer2); + subplot2.setDomainGridlinesVisible(true); + + NumberAxis rangeAxis = new NumberAxis("Value"); + CombinedRangeCategoryPlot plot = new CombinedRangeCategoryPlot( + rangeAxis); + plot.add(subplot1, 2); + plot.add(subplot2, 1); + return plot; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CombinedRangeXYPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CombinedRangeXYPlotTest.java new file mode 100755 index 0000000..de7f1e3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CombinedRangeXYPlotTest.java @@ -0,0 +1,274 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * CombinedRangeXYPlotTest.java + * ---------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Aug-2003 : Version 1 (DG); + * 03-Jan-2008 : Added testNotification (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.awt.Font; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.List; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.annotations.XYTextAnnotation; +import org.jfree.chart.axis.AxisLocation; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.event.ChartChangeEvent; +import org.jfree.chart.event.ChartChangeListener; +import org.jfree.chart.renderer.xy.StandardXYItemRenderer; +import org.jfree.chart.renderer.xy.XYItemRenderer; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.junit.Test; + +/** + * Tests for the {@link CombinedRangeXYPlot} class. + */ +public class CombinedRangeXYPlotTest implements ChartChangeListener { + + /** A list of the events received. */ + private List events = new java.util.ArrayList(); + + /** + * Receives a chart change event. + * + * @param event the event. + */ + @Override + public void chartChanged(ChartChangeEvent event) { + this.events.add(event); + } + + /** + * Test the equals method. + */ + @Test + public void testEquals() { + CombinedRangeXYPlot plot1 = createPlot(); + CombinedRangeXYPlot plot2 = createPlot(); + assertTrue(plot1.equals(plot2)); + assertTrue(plot2.equals(plot1)); + } + + /** + * This is a test to replicate the bug report 987080. + */ + @Test + public void testRemoveSubplot() { + CombinedRangeXYPlot plot = new CombinedRangeXYPlot(); + XYPlot plot1 = new XYPlot(); + XYPlot plot2 = new XYPlot(); + plot.add(plot1); + plot.add(plot2); + // remove plot2, but plot1 is removed instead + plot.remove(plot2); + List plots = plot.getSubplots(); + assertTrue(plots.get(0) == plot1); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CombinedRangeXYPlot plot1 = createPlot(); + CombinedRangeXYPlot plot2 = (CombinedRangeXYPlot) plot1.clone(); + assertTrue(plot1 != plot2); + assertTrue(plot1.getClass() == plot2.getClass()); + assertTrue(plot1.equals(plot2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CombinedRangeXYPlot plot1 = createPlot(); + CombinedRangeXYPlot plot2 = (CombinedRangeXYPlot) + TestUtilities.serialised(plot1); + assertEquals(plot1, plot2); + } + + /** + * Check that only one chart change event is generated by a change to a + * subplot. + */ + @Test + public void testNotification() { + CombinedRangeXYPlot plot = createPlot(); + JFreeChart chart = new JFreeChart(plot); + chart.addChangeListener(this); + XYPlot subplot1 = (XYPlot) plot.getSubplots().get(0); + NumberAxis xAxis = (NumberAxis) subplot1.getDomainAxis(); + xAxis.setAutoRangeIncludesZero(!xAxis.getAutoRangeIncludesZero()); + assertEquals(1, this.events.size()); + + // a redraw should NOT trigger another change event + BufferedImage image = new BufferedImage(200, 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + this.events.clear(); + chart.draw(g2, new Rectangle2D.Double(0.0, 0.0, 200.0, 100.0)); + assertTrue(this.events.isEmpty()); + } + + /** + * Creates a sample dataset. + * + * @return Series 1. + */ + private XYDataset createDataset1() { + + XYSeries series1 = new XYSeries("Series 1"); + series1.add(10.0, 12353.3); + series1.add(20.0, 13734.4); + series1.add(30.0, 14525.3); + series1.add(40.0, 13984.3); + series1.add(50.0, 12999.4); + series1.add(60.0, 14274.3); + series1.add(70.0, 15943.5); + series1.add(80.0, 14845.3); + series1.add(90.0, 14645.4); + series1.add(100.0, 16234.6); + series1.add(110.0, 17232.3); + series1.add(120.0, 14232.2); + series1.add(130.0, 13102.2); + series1.add(140.0, 14230.2); + series1.add(150.0, 11235.2); + + XYSeries series2 = new XYSeries("Series 2"); + series2.add(10.0, 15000.3); + series2.add(20.0, 11000.4); + series2.add(30.0, 17000.3); + series2.add(40.0, 15000.3); + series2.add(50.0, 14000.4); + series2.add(60.0, 12000.3); + series2.add(70.0, 11000.5); + series2.add(80.0, 12000.3); + series2.add(90.0, 13000.4); + series2.add(100.0, 12000.6); + series2.add(110.0, 13000.3); + series2.add(120.0, 17000.2); + series2.add(130.0, 18000.2); + series2.add(140.0, 16000.2); + series2.add(150.0, 17000.2); + + XYSeriesCollection collection = new XYSeriesCollection(); + collection.addSeries(series1); + collection.addSeries(series2); + return collection; + + } + + /** + * Creates a sample dataset. + * + * @return Series 2. + */ + private XYDataset createDataset2() { + + // create dataset 2... + XYSeries series2 = new XYSeries("Series 3"); + + series2.add(10.0, 16853.2); + series2.add(20.0, 19642.3); + series2.add(30.0, 18253.5); + series2.add(40.0, 15352.3); + series2.add(50.0, 13532.0); + series2.add(100.0, 12635.3); + series2.add(110.0, 13998.2); + series2.add(120.0, 11943.2); + series2.add(130.0, 16943.9); + series2.add(140.0, 17843.2); + series2.add(150.0, 16495.3); + series2.add(160.0, 17943.6); + series2.add(170.0, 18500.7); + series2.add(180.0, 19595.9); + + return new XYSeriesCollection(series2); + + } + + /** + * Creates a sample plot. + * + * @return A sample plot. + */ + private CombinedRangeXYPlot createPlot() { + // create subplot 1... + XYDataset data1 = createDataset1(); + XYItemRenderer renderer1 = new StandardXYItemRenderer(); + NumberAxis xAxis1 = new NumberAxis("X1"); + XYPlot subplot1 = new XYPlot(data1, xAxis1, null, renderer1); + subplot1.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); + + XYTextAnnotation annotation + = new XYTextAnnotation("Hello!", 50.0, 10000.0); + annotation.setFont(new Font("SansSerif", Font.PLAIN, 9)); + annotation.setRotationAngle(Math.PI / 4.0); + subplot1.addAnnotation(annotation); + + // create subplot 2... + XYDataset data2 = createDataset2(); + XYItemRenderer renderer2 = new StandardXYItemRenderer(); + NumberAxis xAxis2 = new NumberAxis("X2"); + xAxis2.setAutoRangeIncludesZero(false); + XYPlot subplot2 = new XYPlot(data2, xAxis2, null, renderer2); + subplot2.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); + + // parent plot... + CombinedRangeXYPlot plot = new CombinedRangeXYPlot(new NumberAxis( + "Range")); + plot.setGap(10.0); + + // add the subplots... + plot.add(subplot1, 1); + plot.add(subplot2, 1); + plot.setOrientation(PlotOrientation.VERTICAL); + return plot; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CompassPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CompassPlotTest.java new file mode 100755 index 0000000..b93591b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CompassPlotTest.java @@ -0,0 +1,142 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * CompassPlotTest.java + * -------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Mar-2003 : Version 1 (DG); + * 20-Mar-2007 : Extended serialization tests (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.DefaultValueDataset; +import org.junit.Test; + +/** + * Tests for the {@link CompassPlot} class. + */ +public class CompassPlotTest { + + /** + * Test the equals() method. + */ + @Test + public void testEquals() { + CompassPlot plot1 = new CompassPlot(); + CompassPlot plot2 = new CompassPlot(); + assertTrue(plot1.equals(plot2)); + + // labelType... + plot1.setLabelType(CompassPlot.VALUE_LABELS); + assertFalse(plot1.equals(plot2)); + plot2.setLabelType(CompassPlot.VALUE_LABELS); + assertTrue(plot1.equals(plot2)); + + // labelFont + plot1.setLabelFont(new Font("Serif", Font.PLAIN, 10)); + assertFalse(plot1.equals(plot2)); + plot2.setLabelFont(new Font("Serif", Font.PLAIN, 10)); + assertTrue(plot1.equals(plot2)); + + // drawBorder + plot1.setDrawBorder(true); + assertFalse(plot1.equals(plot2)); + plot2.setDrawBorder(true); + assertTrue(plot1.equals(plot2)); + + // rosePaint + plot1.setRosePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.yellow)); + assertFalse(plot1.equals(plot2)); + plot2.setRosePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.yellow)); + assertTrue(plot1.equals(plot2)); + + // roseCenterPaint + plot1.setRoseCenterPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertFalse(plot1.equals(plot2)); + plot2.setRoseCenterPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertTrue(plot1.equals(plot2)); + + // roseHighlightPaint + plot1.setRoseHighlightPaint(new GradientPaint(1.0f, 2.0f, Color.green, + 3.0f, 4.0f, Color.yellow)); + assertFalse(plot1.equals(plot2)); + plot2.setRoseHighlightPaint(new GradientPaint(1.0f, 2.0f, Color.green, + 3.0f, 4.0f, Color.yellow)); + assertTrue(plot1.equals(plot2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CompassPlot p1 = new CompassPlot(null); + p1.setRosePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue)); + p1.setRoseCenterPaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, + 1.0f, Color.green)); + p1.setRoseHighlightPaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, + 1.0f, Color.green)); + CompassPlot p2 = (CompassPlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CompassPlot p1 = new CompassPlot(new DefaultValueDataset(15.0)); + CompassPlot p2 = (CompassPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/ContourPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/ContourPlotTest.java new file mode 100755 index 0000000..24ac4b9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/ContourPlotTest.java @@ -0,0 +1,63 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * ContourPlotTest.java + * -------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Mar-2003 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the ContourPlot class. + */ +public class ContourPlotTest { + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ContourPlot p1 = new ContourPlot(null, null, null, null); + ContourPlot p2 = (ContourPlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CrosshairTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CrosshairTest.java new file mode 100755 index 0000000..6cafbbd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/CrosshairTest.java @@ -0,0 +1,198 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * CrosshairTest.java + * ------------------ + * (C) Copyright 2009-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 09-Apr-2009 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; + +import java.awt.Font; +import java.awt.GradientPaint; +import java.text.NumberFormat; +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.labels.StandardCrosshairLabelGenerator; +import org.jfree.ui.RectangleAnchor; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link Crosshair} class. + */ +public class CrosshairTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + Crosshair c1 = new Crosshair(1.0, Color.blue, new BasicStroke(1.0f)); + Crosshair c2 = new Crosshair(1.0, Color.blue, new BasicStroke(1.0f)); + assertTrue(c1.equals(c1)); + assertTrue(c2.equals(c1)); + + c1.setVisible(false); + assertFalse(c1.equals(c2)); + c2.setVisible(false); + assertTrue(c1.equals(c2)); + + c1.setValue(2.0); + assertFalse(c1.equals(c2)); + c2.setValue(2.0); + assertTrue(c1.equals(c2)); + + c1.setPaint(Color.red); + assertFalse(c1.equals(c2)); + c2.setPaint(Color.red); + assertTrue(c1.equals(c2)); + + c1.setStroke(new BasicStroke(1.1f)); + assertFalse(c1.equals(c2)); + c2.setStroke(new BasicStroke(1.1f)); + assertTrue(c1.equals(c2)); + + c1.setLabelVisible(true); + assertFalse(c1.equals(c2)); + c2.setLabelVisible(true); + assertTrue(c1.equals(c2)); + + c1.setLabelAnchor(RectangleAnchor.TOP_LEFT); + assertFalse(c1.equals(c2)); + c2.setLabelAnchor(RectangleAnchor.TOP_LEFT); + assertTrue(c1.equals(c2)); + + c1.setLabelGenerator(new StandardCrosshairLabelGenerator("Value = {0}", + NumberFormat.getNumberInstance())); + assertFalse(c1.equals(c2)); + c2.setLabelGenerator(new StandardCrosshairLabelGenerator("Value = {0}", + NumberFormat.getNumberInstance())); + assertTrue(c1.equals(c2)); + + c1.setLabelXOffset(11); + assertFalse(c1.equals(c2)); + c2.setLabelXOffset(11); + assertTrue(c1.equals(c2)); + + c1.setLabelYOffset(22); + assertFalse(c1.equals(c2)); + c2.setLabelYOffset(22); + assertTrue(c1.equals(c2)); + + c1.setLabelFont(new Font("Dialog", Font.PLAIN, 8)); + assertFalse(c1.equals(c2)); + c2.setLabelFont(new Font("Dialog", Font.PLAIN, 8)); + assertTrue(c1.equals(c2)); + + c1.setLabelPaint(Color.red); + assertFalse(c1.equals(c2)); + c2.setLabelPaint(Color.red); + assertTrue(c1.equals(c2)); + + c1.setLabelBackgroundPaint(Color.yellow); + assertFalse(c1.equals(c2)); + c2.setLabelBackgroundPaint(Color.yellow); + assertTrue(c1.equals(c2)); + + c1.setLabelOutlineVisible(false); + assertFalse(c1.equals(c2)); + c2.setLabelOutlineVisible(false); + assertTrue(c1.equals(c2)); + + c1.setLabelOutlineStroke(new BasicStroke(2.0f)); + assertFalse(c1.equals(c2)); + c2.setLabelOutlineStroke(new BasicStroke(2.0f)); + assertTrue(c1.equals(c2)); + + c1.setLabelOutlinePaint(Color.darkGray); + assertFalse(c1.equals(c2)); + c2.setLabelOutlinePaint(Color.darkGray); + assertTrue(c1.equals(c2)); + + } + + /** + * Simple check that hashCode is implemented. + */ + @Test + public void testHashCode() { + Crosshair c1 = new Crosshair(1.0); + Crosshair c2 = new Crosshair(1.0); + assertTrue(c1.equals(c2)); + assertTrue(c1.hashCode() == c2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + Crosshair c1 = new Crosshair(1.0, new GradientPaint(1.0f, 2.0f, + Color.red, 3.0f, 4.0f, Color.BLUE), new BasicStroke(1.0f)); + Crosshair c2 = (Crosshair) c1.clone(); + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + } + + /** + * Check to ensure that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + Crosshair c1 = new Crosshair(1.0); + assertTrue(c1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Crosshair c1 = new Crosshair(1.0, new GradientPaint(1.0f, 2.0f, + Color.red, 3.0f, 4.0f, Color.BLUE), new BasicStroke(1.0f)); + Crosshair c2 = (Crosshair) TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/DefaultDrawingSupplierTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/DefaultDrawingSupplierTest.java new file mode 100755 index 0000000..8749fc2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/DefaultDrawingSupplierTest.java @@ -0,0 +1,192 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * DefaultDrawingSupplierTest.java + * ------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Paint; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link DefaultDrawingSupplier} class. + */ +public class DefaultDrawingSupplierTest { + + /** + * Check that the equals() method can distinguish all required fields. + */ + @Test + public void testEquals() { + DefaultDrawingSupplier r1 = new DefaultDrawingSupplier(); + DefaultDrawingSupplier r2 = new DefaultDrawingSupplier(); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + // set up some objects... + Paint[] ps1A = new Paint[] {Color.red, Color.blue}; + Paint[] ps2A = new Paint[] {Color.green, Color.yellow, Color.white}; + Paint[] ops1A = new Paint[] {Color.lightGray, Color.blue}; + Paint[] ops2A = new Paint[] {Color.black, Color.yellow, Color.cyan}; + Stroke[] ss1A = new Stroke[] {new BasicStroke(1.1f)}; + Stroke[] ss2A + = new Stroke[] {new BasicStroke(2.2f), new BasicStroke(3.3f)}; + Stroke[] oss1A = new Stroke[] {new BasicStroke(4.4f)}; + Stroke[] oss2A + = new Stroke[] {new BasicStroke(5.5f), new BasicStroke(6.6f)}; + Shape[] shapes1A = new Shape[] { + new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0) + }; + Shape[] shapes2A = new Shape[] { + new Rectangle2D.Double(2.0, 2.0, 2.0, 2.0), + new Rectangle2D.Double(2.0, 2.0, 2.0, 2.0) + }; + Paint[] ps1B = new Paint[] {Color.red, Color.blue}; + Paint[] ps2B = new Paint[] {Color.green, Color.yellow, Color.white}; + Paint[] ops1B = new Paint[] {Color.lightGray, Color.blue}; + Paint[] ops2B = new Paint[] {Color.black, Color.yellow, Color.cyan}; + Stroke[] ss1B = new Stroke[] {new BasicStroke(1.1f)}; + Stroke[] ss2B + = new Stroke[] {new BasicStroke(2.2f), new BasicStroke(3.3f)}; + Stroke[] oss1B = new Stroke[] {new BasicStroke(4.4f)}; + Stroke[] oss2B + = new Stroke[] {new BasicStroke(5.5f), new BasicStroke(6.6f)}; + Shape[] shapes1B = new Shape[] { + new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0) + }; + Shape[] shapes2B = new Shape[] { + new Rectangle2D.Double(2.0, 2.0, 2.0, 2.0), + new Rectangle2D.Double(2.0, 2.0, 2.0, 2.0) + }; + + r1 = new DefaultDrawingSupplier(ps1A, ops1A, ss1A, oss1A, shapes1A); + r2 = new DefaultDrawingSupplier(ps1B, ops1B, ss1B, oss1B, shapes1B); + assertTrue(r1.equals(r2)); + + // paint sequence + r1 = new DefaultDrawingSupplier(ps2A, ops1A, ss1A, oss1A, shapes1A); + assertFalse(r1.equals(r2)); + r2 = new DefaultDrawingSupplier(ps2B, ops1B, ss1B, oss1B, shapes1B); + assertTrue(r1.equals(r2)); + // outline paint sequence + r1 = new DefaultDrawingSupplier(ps2A, ops2A, ss1A, oss1A, shapes1A); + assertFalse(r1.equals(r2)); + r2 = new DefaultDrawingSupplier(ps2B, ops2B, ss1B, oss1B, shapes1B); + assertTrue(r1.equals(r2)); + // stroke sequence + r1 = new DefaultDrawingSupplier(ps2A, ops2A, ss2A, oss1A, shapes1A); + assertFalse(r1.equals(r2)); + r2 = new DefaultDrawingSupplier(ps2B, ops2B, ss2B, oss1B, shapes1B); + assertTrue(r1.equals(r2)); + // outline stroke sequence + r1 = new DefaultDrawingSupplier(ps2A, ops2A, ss2A, oss2A, shapes1A); + assertFalse(r1.equals(r2)); + r2 = new DefaultDrawingSupplier(ps2B, ops2B, ss2B, oss2B, shapes1B); + assertTrue(r1.equals(r2)); + // shape sequence + r1 = new DefaultDrawingSupplier(ps2A, ops2A, ss2A, oss2A, shapes2A); + assertFalse(r1.equals(r2)); + r2 = new DefaultDrawingSupplier(ps2B, ops2B, ss2B, oss2B, shapes2B); + assertTrue(r1.equals(r2)); + + // paint index + r1.getNextPaint(); + assertFalse(r1.equals(r2)); + r2.getNextPaint(); + assertTrue(r1.equals(r2)); + + // outline paint index + r1.getNextOutlinePaint(); + assertFalse(r1.equals(r2)); + r2.getNextOutlinePaint(); + assertTrue(r1.equals(r2)); + + // stroke index + r1.getNextStroke(); + assertFalse(r1.equals(r2)); + r2.getNextStroke(); + assertTrue(r1.equals(r2)); + + // outline stroke index + r1.getNextOutlineStroke(); + assertFalse(r1.equals(r2)); + r2.getNextOutlineStroke(); + assertTrue(r1.equals(r2)); + + // shape index + r1.getNextShape(); + assertFalse(r1.equals(r2)); + r2.getNextShape(); + assertTrue(r1.equals(r2)); + } + + /** + * Some basic checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultDrawingSupplier r1 = new DefaultDrawingSupplier(); + DefaultDrawingSupplier r2 = (DefaultDrawingSupplier) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultDrawingSupplier r1 = new DefaultDrawingSupplier(); + DefaultDrawingSupplier r2 = (DefaultDrawingSupplier) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/FastScatterPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/FastScatterPlotTest.java new file mode 100755 index 0000000..1527800 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/FastScatterPlotTest.java @@ -0,0 +1,237 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * FastScatterPlotTest.java + * ------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Mar-2003 : Version 1 (DG); + * 29-Jan-2009 : Updated testEquals() (DG); + * 26-Mar-2009 : Updated testEquals() for new panning fields (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Stroke; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.ValueAxis; +import org.junit.Test; + +/** + * Tests for the {@link FastScatterPlot} class. + */ +public class FastScatterPlotTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + + FastScatterPlot plot1 = new FastScatterPlot(); + FastScatterPlot plot2 = new FastScatterPlot(); + assertTrue(plot1.equals(plot2)); + assertTrue(plot2.equals(plot1)); + + plot1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertFalse(plot1.equals(plot2)); + plot2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertTrue(plot1.equals(plot2)); + + plot1.setDomainGridlinesVisible(false); + assertFalse(plot1.equals(plot2)); + plot2.setDomainGridlinesVisible(false); + assertTrue(plot1.equals(plot2)); + + plot1.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.yellow)); + assertFalse(plot1.equals(plot2)); + plot2.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.yellow)); + assertTrue(plot1.equals(plot2)); + + Stroke s = new BasicStroke(1.5f); + plot1.setDomainGridlineStroke(s); + assertFalse(plot1.equals(plot2)); + plot2.setDomainGridlineStroke(s); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeGridlinesVisible(false); + assertFalse(plot1.equals(plot2)); + plot2.setRangeGridlinesVisible(false); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, + 3.0f, 4.0f, Color.yellow)); + assertFalse(plot1.equals(plot2)); + plot2.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, + 3.0f, 4.0f, Color.yellow)); + assertTrue(plot1.equals(plot2)); + + Stroke s2 = new BasicStroke(1.5f); + plot1.setRangeGridlineStroke(s2); + assertFalse(plot1.equals(plot2)); + plot2.setRangeGridlineStroke(s2); + assertTrue(plot1.equals(plot2)); + + plot1.setDomainPannable(true); + assertFalse(plot1.equals(plot2)); + plot2.setDomainPannable(true); + assertTrue(plot1.equals(plot2)); + + plot1.setRangePannable(true); + assertFalse(plot1.equals(plot2)); + plot2.setRangePannable(true); + assertTrue(plot1.equals(plot2)); + + } + + /** + * Some tests for the data array equality in the equals() method. + */ + @Test + public void testEquals2() { + FastScatterPlot plot1 = new FastScatterPlot(); + FastScatterPlot plot2 = new FastScatterPlot(); + assertTrue(plot1.equals(plot2)); + assertTrue(plot2.equals(plot1)); + + float[][] a = new float[2][]; + float[][] b = new float[2][]; + plot1.setData(a); + assertFalse(plot1.equals(plot2)); + plot2.setData(b); + assertTrue(plot1.equals(plot2)); + + a[0] = new float[6]; + assertFalse(plot1.equals(plot2)); + b[0] = new float[6]; + assertTrue(plot1.equals(plot2)); + + a[0][0] = 1.0f; + assertFalse(plot1.equals(plot2)); + b[0][0] = 1.0f; + assertTrue(plot1.equals(plot2)); + + a[0][1] = Float.NaN; + assertFalse(plot1.equals(plot2)); + b[0][1] = Float.NaN; + assertTrue(plot1.equals(plot2)); + + a[0][2] = Float.POSITIVE_INFINITY; + assertFalse(plot1.equals(plot2)); + b[0][2] = Float.POSITIVE_INFINITY; + assertTrue(plot1.equals(plot2)); + + a[0][3] = Float.NEGATIVE_INFINITY; + assertFalse(plot1.equals(plot2)); + b[0][3] = Float.NEGATIVE_INFINITY; + assertTrue(plot1.equals(plot2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + FastScatterPlot p1 = new FastScatterPlot(); + FastScatterPlot p2 = (FastScatterPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + float[][] data = createData(); + ValueAxis domainAxis = new NumberAxis("X"); + ValueAxis rangeAxis = new NumberAxis("Y"); + FastScatterPlot p1 = new FastScatterPlot(data, domainAxis, rangeAxis); + FastScatterPlot p2 = (FastScatterPlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown. + */ + @Test + public void testDrawWithNullInfo() { + try { + float[][] data = createData(); + + ValueAxis domainAxis = new NumberAxis("X"); + ValueAxis rangeAxis = new NumberAxis("Y"); + FastScatterPlot plot = new FastScatterPlot(data, domainAxis, + rangeAxis); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * Populates the data array with random values. + * + * @return Random data. + */ + private float[][] createData() { + float[][] result = new float[2][1000]; + for (int i = 0; i < result[0].length; i++) { + float x = (float) i + 100; + result[0][i] = x; + result[1][i] = 100 + (float) Math.random() * 1000; + } + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/IntervalMarkerTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/IntervalMarkerTest.java new file mode 100755 index 0000000..5ce75f4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/IntervalMarkerTest.java @@ -0,0 +1,155 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * IntervalMarkerTest.java + * ----------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 14-Jun-2004 : Version 1 (DG); + * 05-Sep-2006 : Added checks for MarkerChangeEvents (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.event.MarkerChangeEvent; +import org.jfree.chart.event.MarkerChangeListener; +import org.jfree.ui.GradientPaintTransformType; +import org.jfree.ui.GradientPaintTransformer; +import org.jfree.ui.StandardGradientPaintTransformer; +import org.junit.Test; + +/** + * Tests for the {@link IntervalMarker} class. + */ +public class IntervalMarkerTest implements MarkerChangeListener { + + MarkerChangeEvent lastEvent; + + /** + * Records the last event. + * + * @param event the last event. + */ + @Override + public void markerChanged(MarkerChangeEvent event) { + this.lastEvent = event; + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + IntervalMarker m1 = new IntervalMarker(45.0, 50.0); + IntervalMarker m2 = new IntervalMarker(45.0, 50.0); + assertTrue(m1.equals(m2)); + assertTrue(m2.equals(m1)); + + m1 = new IntervalMarker(44.0, 50.0); + assertFalse(m1.equals(m2)); + m2 = new IntervalMarker(44.0, 50.0); + assertTrue(m1.equals(m2)); + + m1 = new IntervalMarker(44.0, 55.0); + assertFalse(m1.equals(m2)); + m2 = new IntervalMarker(44.0, 55.0); + assertTrue(m1.equals(m2)); + + GradientPaintTransformer t = new StandardGradientPaintTransformer( + GradientPaintTransformType.HORIZONTAL); + m1.setGradientPaintTransformer(t); + assertFalse(m1.equals(m2)); + m2.setGradientPaintTransformer(t); + assertTrue(m1.equals(m2)); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + IntervalMarker m1 = new IntervalMarker(45.0, 50.0); + IntervalMarker m2 = (IntervalMarker) m1.clone(); + assertTrue(m1 != m2); + assertTrue(m1.getClass() == m2.getClass()); + assertTrue(m1.equals(m2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + IntervalMarker m1 = new IntervalMarker(45.0, 50.0); + IntervalMarker m2 = (IntervalMarker) TestUtilities.serialised(m1); + assertEquals(m1, m2); + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the getStartValue() and setStartValue() methods. + */ + @Test + public void testGetSetStartValue() { + IntervalMarker m = new IntervalMarker(1.0, 2.0); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(1.0, m.getStartValue(), EPSILON); + m.setStartValue(0.5); + assertEquals(0.5, m.getStartValue(), EPSILON); + assertEquals(m, this.lastEvent.getMarker()); + } + + /** + * Some checks for the getEndValue() and setEndValue() methods. + */ + @Test + public void testGetSetEndValue() { + IntervalMarker m = new IntervalMarker(1.0, 2.0); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(2.0, m.getEndValue(), EPSILON); + m.setEndValue(0.5); + assertEquals(0.5, m.getEndValue(), EPSILON); + assertEquals(m, this.lastEvent.getMarker()); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MarkerTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MarkerTest.java new file mode 100755 index 0000000..087a69b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MarkerTest.java @@ -0,0 +1,407 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * MarkerTest.java + * --------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Sep-2006 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.util.Arrays; +import java.util.EventListener; + +import org.jfree.chart.event.MarkerChangeEvent; +import org.jfree.chart.event.MarkerChangeListener; +import org.jfree.ui.LengthAdjustmentType; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.TextAnchor; +import org.junit.Test; + +/** + * Tests for the {@link Marker} class. + */ +public class MarkerTest implements MarkerChangeListener { + + MarkerChangeEvent lastEvent; + + /** + * Some checks for the getPaint() and setPaint() methods. + */ + @Test + public void testGetSetPaint() { + // we use ValueMarker for the tests, because we need a concrete + // subclass... + ValueMarker m = new ValueMarker(1.1); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(Color.gray, m.getPaint()); + m.setPaint(Color.blue); + assertEquals(Color.blue, m.getPaint()); + assertEquals(m, this.lastEvent.getMarker()); + + // check null argument... + try { + m.setPaint(null); + fail("Expected an IllegalArgumentException for null."); + } + catch (IllegalArgumentException e) { + assertTrue(true); + } + } + + /** + * Some checks for the getStroke() and setStroke() methods. + */ + @Test + public void testGetSetStroke() { + // we use ValueMarker for the tests, because we need a concrete + // subclass... + ValueMarker m = new ValueMarker(1.1); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(new BasicStroke(0.5f), m.getStroke()); + m.setStroke(new BasicStroke(1.1f)); + assertEquals(new BasicStroke(1.1f), m.getStroke()); + assertEquals(m, this.lastEvent.getMarker()); + + // check null argument... + try { + m.setStroke(null); + fail("Expected an IllegalArgumentException for null."); + } + catch (IllegalArgumentException e) { + assertTrue(true); + } + } + + /** + * Some checks for the getOutlinePaint() and setOutlinePaint() methods. + */ + @Test + public void testGetSetOutlinePaint() { + // we use ValueMarker for the tests, because we need a concrete + // subclass... + ValueMarker m = new ValueMarker(1.1); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(Color.gray, m.getOutlinePaint()); + m.setOutlinePaint(Color.yellow); + assertEquals(Color.yellow, m.getOutlinePaint()); + assertEquals(m, this.lastEvent.getMarker()); + + // check null argument... + m.setOutlinePaint(null); + assertEquals(null, m.getOutlinePaint()); + } + + /** + * Some checks for the getOutlineStroke() and setOutlineStroke() methods. + */ + @Test + public void testGetSetOutlineStroke() { + // we use ValueMarker for the tests, because we need a concrete + // subclass... + ValueMarker m = new ValueMarker(1.1); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(new BasicStroke(0.5f), m.getOutlineStroke()); + m.setOutlineStroke(new BasicStroke(1.1f)); + assertEquals(new BasicStroke(1.1f), m.getOutlineStroke()); + assertEquals(m, this.lastEvent.getMarker()); + + // check null argument... + m.setOutlineStroke(null); + assertEquals(null, m.getOutlineStroke()); + } + + private static final float EPSILON = 0.000000001f; + + /** + * Some checks for the getAlpha() and setAlpha() methods. + */ + @Test + public void testGetSetAlpha() { + // we use ValueMarker for the tests, because we need a concrete + // subclass... + ValueMarker m = new ValueMarker(1.1); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(0.8f, m.getAlpha(), EPSILON); + m.setAlpha(0.5f); + assertEquals(0.5f, m.getAlpha(), EPSILON); + assertEquals(m, this.lastEvent.getMarker()); + } + + /** + * Some checks for the getLabel() and setLabel() methods. + */ + @Test + public void testGetSetLabel() { + // we use ValueMarker for the tests, because we need a concrete + // subclass... + ValueMarker m = new ValueMarker(1.1); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(null, m.getLabel()); + m.setLabel("XYZ"); + assertEquals("XYZ", m.getLabel()); + assertEquals(m, this.lastEvent.getMarker()); + + // check null argument... + m.setLabel(null); + assertEquals(null, m.getLabel()); + } + + /** + * Some checks for the getLabelFont() and setLabelFont() methods. + */ + @Test + public void testGetSetLabelFont() { + // we use ValueMarker for the tests, because we need a concrete + // subclass... + ValueMarker m = new ValueMarker(1.1); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(new Font("SansSerif", Font.PLAIN, 9), m.getLabelFont()); + m.setLabelFont(new Font("SansSerif", Font.BOLD, 10)); + assertEquals(new Font("SansSerif", Font.BOLD, 10), m.getLabelFont()); + assertEquals(m, this.lastEvent.getMarker()); + + // check null argument... + try { + m.setLabelFont(null); + fail("Expected an IllegalArgumentException for null."); + } + catch (IllegalArgumentException e) { + assertTrue(true); + } + } + + /** + * Some checks for the getLabelPaint() and setLabelPaint() methods. + */ + @Test + public void testGetSetLabelPaint() { + // we use ValueMarker for the tests, because we need a concrete + // subclass... + ValueMarker m = new ValueMarker(1.1); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(Color.black, m.getLabelPaint()); + m.setLabelPaint(Color.red); + assertEquals(Color.red, m.getLabelPaint()); + assertEquals(m, this.lastEvent.getMarker()); + + // check null argument... + try { + m.setLabelPaint(null); + fail("Expected an IllegalArgumentException for null."); + } + catch (IllegalArgumentException e) { + assertTrue(true); + } + } + + /** + * Some checks for the getLabelAnchor() and setLabelAnchor() methods. + */ + @Test + public void testGetSetLabelAnchor() { + // we use ValueMarker for the tests, because we need a concrete + // subclass... + ValueMarker m = new ValueMarker(1.1); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(RectangleAnchor.TOP_LEFT, m.getLabelAnchor()); + m.setLabelAnchor(RectangleAnchor.TOP); + assertEquals(RectangleAnchor.TOP, m.getLabelAnchor()); + assertEquals(m, this.lastEvent.getMarker()); + + // check null argument... + try { + m.setLabelAnchor(null); + fail("Expected an IllegalArgumentException for null."); + } + catch (IllegalArgumentException e) { + assertTrue(true); + } + } + + /** + * Some checks for the getLabelOffset() and setLabelOffset() methods. + */ + @Test + public void testGetSetLabelOffset() { + // we use ValueMarker for the tests, because we need a concrete + // subclass... + ValueMarker m = new ValueMarker(1.1); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(new RectangleInsets(3, 3, 3, 3), m.getLabelOffset()); + m.setLabelOffset(new RectangleInsets(1, 2, 3, 4)); + assertEquals(new RectangleInsets(1, 2, 3, 4), m.getLabelOffset()); + assertEquals(m, this.lastEvent.getMarker()); + + // check null argument... + try { + m.setLabelOffset(null); + fail("Expected an IllegalArgumentException for null."); + } + catch (IllegalArgumentException e) { + assertTrue(true); + } + } + + /** + * Some checks for the getLabelOffsetType() and setLabelOffsetType() + * methods. + */ + @Test + public void testGetSetLabelOffsetType() { + // we use ValueMarker for the tests, because we need a concrete + // subclass... + ValueMarker m = new ValueMarker(1.1); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(LengthAdjustmentType.CONTRACT, m.getLabelOffsetType()); + m.setLabelOffsetType(LengthAdjustmentType.EXPAND); + assertEquals(LengthAdjustmentType.EXPAND, m.getLabelOffsetType()); + assertEquals(m, this.lastEvent.getMarker()); + + // check null argument... + try { + m.setLabelOffsetType(null); + fail("Expected an IllegalArgumentException for null."); + } + catch (IllegalArgumentException e) { + assertTrue(true); + } + } + + /** + * Some checks for the getLabelTextAnchor() and setLabelTextAnchor() + * methods. + */ + @Test + public void testGetSetLabelTextAnchor() { + // we use ValueMarker for the tests, because we need a concrete + // subclass... + ValueMarker m = new ValueMarker(1.1); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(TextAnchor.CENTER, m.getLabelTextAnchor()); + m.setLabelTextAnchor(TextAnchor.BASELINE_LEFT); + assertEquals(TextAnchor.BASELINE_LEFT, m.getLabelTextAnchor()); + assertEquals(m, this.lastEvent.getMarker()); + + // check null argument... + try { + m.setLabelTextAnchor(null); + fail("Expected an IllegalArgumentException for null."); + } + catch (IllegalArgumentException e) { + assertTrue(true); + } + } + + /** + * Checks that a CategoryPlot deregisters listeners when clearing markers. + */ + @Test + public void testListenersWithCategoryPlot() { + CategoryPlot plot = new CategoryPlot(); + CategoryMarker marker1 = new CategoryMarker("X"); + ValueMarker marker2 = new ValueMarker(1.0); + plot.addDomainMarker(marker1); + plot.addRangeMarker(marker2); + EventListener[] listeners1 = marker1.getListeners( + MarkerChangeListener.class); + assertTrue(Arrays.asList(listeners1).contains(plot)); + EventListener[] listeners2 = marker1.getListeners( + MarkerChangeListener.class); + assertTrue(Arrays.asList(listeners2).contains(plot)); + plot.clearDomainMarkers(); + plot.clearRangeMarkers(); + listeners1 = marker1.getListeners(MarkerChangeListener.class); + assertFalse(Arrays.asList(listeners1).contains(plot)); + listeners2 = marker1.getListeners(MarkerChangeListener.class); + assertFalse(Arrays.asList(listeners2).contains(plot)); + } + + /** + * Checks that an XYPlot deregisters listeners when clearing markers. + */ + @Test + public void testListenersWithXYPlot() { + XYPlot plot = new XYPlot(); + ValueMarker marker1 = new ValueMarker(1.0); + ValueMarker marker2 = new ValueMarker(2.0); + plot.addDomainMarker(marker1); + plot.addRangeMarker(marker2); + EventListener[] listeners1 = marker1.getListeners( + MarkerChangeListener.class); + assertTrue(Arrays.asList(listeners1).contains(plot)); + EventListener[] listeners2 = marker1.getListeners( + MarkerChangeListener.class); + assertTrue(Arrays.asList(listeners2).contains(plot)); + plot.clearDomainMarkers(); + plot.clearRangeMarkers(); + listeners1 = marker1.getListeners(MarkerChangeListener.class); + assertFalse(Arrays.asList(listeners1).contains(plot)); + listeners2 = marker1.getListeners(MarkerChangeListener.class); + assertFalse(Arrays.asList(listeners2).contains(plot)); + } + + /** + * Records the last event. + * + * @param event the event. + */ + @Override + public void markerChanged(MarkerChangeEvent event) { + this.lastEvent = event; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MeterIntervalTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MeterIntervalTest.java new file mode 100755 index 0000000..008d8e0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MeterIntervalTest.java @@ -0,0 +1,109 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * MeterIntervalTest.java + * ---------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Mar-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.junit.Test; + +/** + * Tests for the {@link MeterInterval} class. + */ +public class MeterIntervalTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + MeterInterval m1 = new MeterInterval( + "Label 1", new Range(1.2, 3.4), Color.red, new BasicStroke(1.0f), + Color.blue + ); + MeterInterval m2 = new MeterInterval( + "Label 1", new Range(1.2, 3.4), Color.red, new BasicStroke(1.0f), + Color.blue + ); + assertTrue(m1.equals(m2)); + assertTrue(m2.equals(m1)); + + m1 = new MeterInterval( + "Label 2", new Range(1.2, 3.4), Color.red, new BasicStroke(1.0f), + Color.blue + ); + assertFalse(m1.equals(m2)); + m2 = new MeterInterval( + "Label 2", new Range(1.2, 3.4), Color.red, new BasicStroke(1.0f), + Color.blue + ); + assertTrue(m1.equals(m2)); + + } + + /** + * This class is immutable so cloning isn't required. + */ + @Test + public void testCloning() { + MeterInterval m1 = new MeterInterval("X", new Range(1.0, 2.0)); + assertFalse(m1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + MeterInterval m1 = new MeterInterval("X", new Range(1.0, 2.0)); + MeterInterval m2 = (MeterInterval) TestUtilities.serialised(m1); + assertEquals(m1, m2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MeterPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MeterPlotTest.java new file mode 100755 index 0000000..6e36db7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MeterPlotTest.java @@ -0,0 +1,255 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * MeterPlotTest.java + * ------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Mar-2003 : Version 1 (DG); + * 12-May-2004 : Updated testEquals() (DG); + * 29-Nov-2007 : Updated testEquals() and testSerialization1() for + * dialOutlinePaint (DG) + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; +import java.text.DecimalFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.data.general.DefaultValueDataset; +import org.junit.Test; + +/** + * Tests for the {@link MeterPlot} class. + */ +public class MeterPlotTest { + + /** + * Test the equals method to ensure that it can distinguish the required + * fields. Note that the dataset is NOT considered in the equals test. + */ + @Test + public void testEquals() { + MeterPlot plot1 = new MeterPlot(); + MeterPlot plot2 = new MeterPlot(); + assertTrue(plot1.equals(plot2)); + + // units + plot1.setUnits("mph"); + assertFalse(plot1.equals(plot2)); + plot2.setUnits("mph"); + assertTrue(plot1.equals(plot2)); + + // range + plot1.setRange(new Range(50.0, 70.0)); + assertFalse(plot1.equals(plot2)); + plot2.setRange(new Range(50.0, 70.0)); + assertTrue(plot1.equals(plot2)); + + // interval + plot1.addInterval(new MeterInterval("Normal", new Range(55.0, 60.0))); + assertFalse(plot1.equals(plot2)); + plot2.addInterval(new MeterInterval("Normal", new Range(55.0, 60.0))); + assertTrue(plot1.equals(plot2)); + + // dial outline paint + plot1.setDialOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertFalse(plot1.equals(plot2)); + plot2.setDialOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertTrue(plot1.equals(plot2)); + + // dial shape + plot1.setDialShape(DialShape.CHORD); + assertFalse(plot1.equals(plot2)); + plot2.setDialShape(DialShape.CHORD); + assertTrue(plot1.equals(plot2)); + + // dial background paint + plot1.setDialBackgroundPaint(new GradientPaint(9.0f, 8.0f, Color.red, + 7.0f, 6.0f, Color.blue)); + assertFalse(plot1.equals(plot2)); + plot2.setDialBackgroundPaint(new GradientPaint(9.0f, 8.0f, Color.red, + 7.0f, 6.0f, Color.blue)); + assertTrue(plot1.equals(plot2)); + + // dial outline paint + plot1.setDialOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, + 3.0f, 4.0f, Color.red)); + assertFalse(plot1.equals(plot2)); + plot2.setDialOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, + 3.0f, 4.0f, Color.red)); + assertTrue(plot1.equals(plot2)); + + // needle paint + plot1.setNeedlePaint(new GradientPaint(9.0f, 8.0f, Color.red, + 7.0f, 6.0f, Color.blue)); + assertFalse(plot1.equals(plot2)); + plot2.setNeedlePaint(new GradientPaint(9.0f, 8.0f, Color.red, + 7.0f, 6.0f, Color.blue)); + assertTrue(plot1.equals(plot2)); + + // value font + plot1.setValueFont(new Font("Serif", Font.PLAIN, 6)); + assertFalse(plot1.equals(plot2)); + plot2.setValueFont(new Font("Serif", Font.PLAIN, 6)); + assertTrue(plot1.equals(plot2)); + + // value paint + plot1.setValuePaint(new GradientPaint(1.0f, 2.0f, Color.black, + 3.0f, 4.0f, Color.white)); + assertFalse(plot1.equals(plot2)); + plot2.setValuePaint(new GradientPaint(1.0f, 2.0f, Color.black, + 3.0f, 4.0f, Color.white)); + assertTrue(plot1.equals(plot2)); + + // tick labels visible + plot1.setTickLabelsVisible(false); + assertFalse(plot1.equals(plot2)); + plot2.setTickLabelsVisible(false); + assertTrue(plot1.equals(plot2)); + + // tick label font + plot1.setTickLabelFont(new Font("Serif", Font.PLAIN, 6)); + assertFalse(plot1.equals(plot2)); + plot2.setTickLabelFont(new Font("Serif", Font.PLAIN, 6)); + assertTrue(plot1.equals(plot2)); + + // tick label paint + plot1.setTickLabelPaint(Color.red); + assertFalse(plot1.equals(plot2)); + plot2.setTickLabelPaint(Color.red); + assertTrue(plot1.equals(plot2)); + + // tick label format + plot1.setTickLabelFormat(new DecimalFormat("0")); + assertFalse(plot1.equals(plot2)); + plot2.setTickLabelFormat(new DecimalFormat("0")); + assertTrue(plot1.equals(plot2)); + + // tick paint + plot1.setTickPaint(Color.green); + assertFalse(plot1.equals(plot2)); + plot2.setTickPaint(Color.green); + assertTrue(plot1.equals(plot2)); + + // tick size + plot1.setTickSize(1.23); + assertFalse(plot1.equals(plot2)); + plot2.setTickSize(1.23); + assertTrue(plot1.equals(plot2)); + + // draw border + plot1.setDrawBorder(!plot1.getDrawBorder()); + assertFalse(plot1.equals(plot2)); + plot2.setDrawBorder(plot1.getDrawBorder()); + assertTrue(plot1.equals(plot2)); + + // meter angle + plot1.setMeterAngle(22); + assertFalse(plot1.equals(plot2)); + plot2.setMeterAngle(22); + assertTrue(plot1.equals(plot2)); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + MeterPlot p1 = new MeterPlot(); + MeterPlot p2 = (MeterPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // the clone and the original share a reference to the SAME dataset + assertTrue(p1.getDataset() == p2.getDataset()); + + // try a few checks to ensure that the clone is independent of the + // original + p1.getTickLabelFormat().setMinimumIntegerDigits(99); + assertFalse(p1.equals(p2)); + p2.getTickLabelFormat().setMinimumIntegerDigits(99); + assertTrue(p1.equals(p2)); + + p1.addInterval(new MeterInterval("Test", new Range(1.234, 5.678))); + assertFalse(p1.equals(p2)); + p2.addInterval(new MeterInterval("Test", new Range(1.234, 5.678))); + assertTrue(p1.equals(p2)); + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization1() { + MeterPlot p1 = new MeterPlot(null); + p1.setDialBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + p1.setDialOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.red, + 2.0f, 1.0f, Color.blue)); + p1.setNeedlePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + p1.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + p1.setTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + MeterPlot p2 = (MeterPlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization2() { + MeterPlot p1 = new MeterPlot(new DefaultValueDataset(1.23)); + MeterPlot p2 = (MeterPlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MultiplePiePlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MultiplePiePlotTest.java new file mode 100755 index 0000000..67bf47f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MultiplePiePlotTest.java @@ -0,0 +1,206 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * MultiplePiePlotTest.java + * ------------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Jun-2005 : Version 1 (DG); + * 06-Apr-2006 : Added tests for new fields (DG); + * 18-Apr-2008 : Added testConstructor() (DG); + * 30-Dec-2008 : Updated for new legendItemShape field (DG); + * 01-Jun-2009 : Added test for getLegendItems() bug, series key is not + * set (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; + +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.event.PlotChangeListener; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.TableOrder; +import org.junit.Test; + +/** + * Some tests for the {@link MultiplePiePlot} class. + */ +public class MultiplePiePlotTest implements PlotChangeListener { + + /** The last event received. */ + PlotChangeEvent lastEvent; + + /** + * Receives a plot change event and records it. Some tests will use this + * to check that events have been generated (or not) when required. + * + * @param event the event. + */ + @Override + public void plotChanged(PlotChangeEvent event) { + this.lastEvent = event; + } + + /** + * Some checks for the constructors. + */ + @Test + public void testConstructor() { + MultiplePiePlot plot = new MultiplePiePlot(); + assertNull(plot.getDataset()); + + // the following checks that the plot registers itself as a listener + // with the dataset passed to the constructor - see patch 1943021 + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + plot = new MultiplePiePlot(dataset); + assertTrue(dataset.hasListener(plot)); + } + + /** + * Check that the equals() method distinguishes the required fields. + */ + @Test + public void testEquals() { + MultiplePiePlot p1 = new MultiplePiePlot(); + MultiplePiePlot p2 = new MultiplePiePlot(); + assertTrue(p1.equals(p2)); + assertTrue(p2.equals(p1)); + + p1.setDataExtractOrder(TableOrder.BY_ROW); + assertFalse(p1.equals(p2)); + p2.setDataExtractOrder(TableOrder.BY_ROW); + assertTrue(p1.equals(p2)); + + p1.setLimit(1.23); + assertFalse(p1.equals(p2)); + p2.setLimit(1.23); + assertTrue(p1.equals(p2)); + + p1.setAggregatedItemsKey("Aggregated Items"); + assertFalse(p1.equals(p2)); + p2.setAggregatedItemsKey("Aggregated Items"); + assertTrue(p1.equals(p2)); + + p1.setAggregatedItemsPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertFalse(p1.equals(p2)); + p2.setAggregatedItemsPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertTrue(p1.equals(p2)); + + p1.setPieChart(ChartFactory.createPieChart("Title", null, true, true, + true)); + assertFalse(p1.equals(p2)); + p2.setPieChart(ChartFactory.createPieChart("Title", null, true, true, + true)); + assertTrue(p1.equals(p2)); + + p1.setLegendItemShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertFalse(p1.equals(p2)); + p2.setLegendItemShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertTrue(p1.equals(p2)); + } + + /** + * Some basic checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + MultiplePiePlot p1 = new MultiplePiePlot(); + Rectangle2D rect = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); + p1.setLegendItemShape(rect); + MultiplePiePlot p2 = (MultiplePiePlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // check independence + rect.setRect(2.0, 3.0, 4.0, 5.0); + assertFalse(p1.equals(p2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + MultiplePiePlot p1 = new MultiplePiePlot(null); + p1.setAggregatedItemsPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.red)); + MultiplePiePlot p2 = (MultiplePiePlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + + /** + * Fetches the legend items and checks the values. + */ + @Test + public void testGetLegendItems() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(35.0, "S1", "C1"); + dataset.addValue(45.0, "S1", "C2"); + dataset.addValue(55.0, "S2", "C1"); + dataset.addValue(15.0, "S2", "C2"); + MultiplePiePlot plot = new MultiplePiePlot(dataset); + JFreeChart chart = new JFreeChart(plot); + LegendItemCollection legendItems = plot.getLegendItems(); + assertEquals(2, legendItems.getItemCount()); + LegendItem item1 = legendItems.get(0); + assertEquals("S1", item1.getLabel()); + assertEquals("S1", item1.getSeriesKey()); + assertEquals(0, item1.getSeriesIndex()); + assertEquals(dataset, item1.getDataset()); + assertEquals(0, item1.getDatasetIndex()); + + LegendItem item2 = legendItems.get(1); + assertEquals("S2", item2.getLabel()); + assertEquals("S2", item2.getSeriesKey()); + assertEquals(1, item2.getSeriesIndex()); + assertEquals(dataset, item2.getDataset()); + assertEquals(0, item2.getDatasetIndex()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MyPlotChangeListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MyPlotChangeListener.java new file mode 100755 index 0000000..634915e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/MyPlotChangeListener.java @@ -0,0 +1,88 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * MyPlotChangeListener.java + * ------------------------- + * (C) Copyright 2005-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Mar-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.event.PlotChangeListener; + +/** + * A utility class for testing plot events. + */ +public class MyPlotChangeListener implements PlotChangeListener { + + private PlotChangeEvent event; + + /** + * Creates a new instance. + */ + public MyPlotChangeListener() { + this.event = null; + } + + /** + * Returns the last event received by the listener. + * + * @return The event. + */ + public PlotChangeEvent getEvent() { + return this.event; + } + + /** + * Sets the event for the listener. + * + * @param e the event. + */ + public void setEvent(PlotChangeEvent e) { + this.event = e; + } + + /** + * Receives notification of a plot change event. + * + * @param e the event. + */ + @Override + public void plotChanged(PlotChangeEvent e) { + this.event = e; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PieLabelRecordTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PieLabelRecordTest.java new file mode 100755 index 0000000..f7ea409 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PieLabelRecordTest.java @@ -0,0 +1,126 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * PieLabelRecordTest.java + * ----------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Nov-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.text.TextBox; +import org.junit.Test; + +/** + * Some tests for the {@link PieLabelRecord} class. + */ +public class PieLabelRecordTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + PieLabelRecord p1 = new PieLabelRecord("A", 1.0, 2.0, new TextBox("B"), + 3.0, 4.0, 5.0); + PieLabelRecord p2 = new PieLabelRecord("A", 1.0, 2.0, new TextBox("B"), + 3.0, 4.0, 5.0); + assertTrue(p1.equals(p2)); + assertTrue(p2.equals(p1)); + + p1 = new PieLabelRecord("B", 1.0, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); + assertFalse(p1.equals(p2)); + p2 = new PieLabelRecord("B", 1.0, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); + assertTrue(p1.equals(p2)); + + p1 = new PieLabelRecord("B", 1.1, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); + assertFalse(p1.equals(p2)); + p2 = new PieLabelRecord("B", 1.1, 2.0, new TextBox("B"), 3.0, 4.0, 5.0); + assertTrue(p1.equals(p2)); + + p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("B"), 3.0, 4.0, 5.0); + assertFalse(p1.equals(p2)); + p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("B"), 3.0, 4.0, 5.0); + assertTrue(p1.equals(p2)); + + p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.0, 4.0, 5.0); + assertFalse(p1.equals(p2)); + p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.0, 4.0, 5.0); + assertTrue(p1.equals(p2)); + + p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.0, 5.0); + assertFalse(p1.equals(p2)); + p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.0, 5.0); + assertTrue(p1.equals(p2)); + + p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.4, 5.0); + assertFalse(p1.equals(p2)); + p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.4, 5.0); + assertTrue(p1.equals(p2)); + + p1 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.4, 5.5); + assertFalse(p1.equals(p2)); + p2 = new PieLabelRecord("B", 1.1, 2.2, new TextBox("C"), 3.3, 4.4, 5.5); + assertTrue(p1.equals(p2)); + + } + + /** + * Confirm that cloning is not implemented. + */ + @Test + public void testCloning() { + PieLabelRecord p1 = new PieLabelRecord("A", 1.0, 2.0, new TextBox("B"), + 3.0, 4.0, 5.0); + assertFalse(p1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PieLabelRecord p1 = new PieLabelRecord("A", 1.0, 2.0, new TextBox("B"), + 3.0, 4.0, 5.0); + PieLabelRecord p2 = (PieLabelRecord) TestUtilities.serialised(p1); + boolean b = p1.equals(p2); + assertTrue(b); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PiePlot3DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PiePlot3DTest.java new file mode 100755 index 0000000..7843619 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PiePlot3DTest.java @@ -0,0 +1,117 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * Pie3DPlotTest.java + * ------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Mar-2003 : Version 1 (DG); + * 22-Mar-2007 : Added testEquals() (DG); + * 05-Oct-2007 : Modified testEquals() for new field (DG); + * 19-Mar-2008 : Added test for null dataset (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link PiePlot3D} class. + */ +public class PiePlot3DTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + PiePlot3D p1 = new PiePlot3D(); + PiePlot3D p2 = new PiePlot3D(); + assertTrue(p1.equals(p2)); + assertTrue(p2.equals(p1)); + + p1.setDepthFactor(1.23); + assertFalse(p1.equals(p2)); + p2.setDepthFactor(1.23); + assertTrue(p1.equals(p2)); + + p1.setDarkerSides(true); + assertFalse(p1.equals(p2)); + p2.setDarkerSides(true); + assertTrue(p1.equals(p2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PiePlot3D p1 = new PiePlot3D(null); + PiePlot3D p2 = (PiePlot3D) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + + /** + * Draws a pie chart where the label generator returns null. + */ + @Test + public void testDrawWithNullDataset() { + JFreeChart chart = ChartFactory.createPieChart3D("Test", null, true, + false, false); + boolean success = false; + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); + g2.dispose(); + success = true; + } + catch (Exception e) { + success = false; + } + assertTrue(success); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PiePlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PiePlotTest.java new file mode 100755 index 0000000..e488054 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PiePlotTest.java @@ -0,0 +1,637 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * PiePlotTest.java + * ---------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Mar-2003 : Version 1 (DG); + * 10-May-2005 : Strengthened equals() test (DG); + * 27-Sep-2006 : Added tests for the getBaseSectionPaint() method (DG); + * 23-Nov-2006 : Additional equals() and clone() tests (DG); + * 17-Apr-2007 : Added check for label generator that returns a null label (DG); + * 31-Mar-2008 : Updated testEquals() (DG); + * 10-Jul-2009 : Updated testEquals() (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.Stroke; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.text.AttributedString; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.labels.PieSectionLabelGenerator; +import org.jfree.chart.labels.StandardPieSectionLabelGenerator; +import org.jfree.chart.labels.StandardPieToolTipGenerator; +import org.jfree.chart.urls.CustomPieURLGenerator; +import org.jfree.chart.urls.StandardPieURLGenerator; +import org.jfree.chart.util.DefaultShadowGenerator; +import org.jfree.data.general.DefaultPieDataset; +import org.jfree.data.general.PieDataset; +import org.jfree.util.Rotation; +import org.junit.Test; + +/** + * Some tests for the {@link PiePlot} class. + */ +public class PiePlotTest { + + /** + * Test the equals() method. + */ + @Test + public void testEquals() { + + PiePlot plot1 = new PiePlot(); + PiePlot plot2 = new PiePlot(); + assertTrue(plot1.equals(plot2)); + assertTrue(plot2.equals(plot1)); + + // pieIndex... + plot1.setPieIndex(99); + assertFalse(plot1.equals(plot2)); + plot2.setPieIndex(99); + assertTrue(plot1.equals(plot2)); + + // interiorGap... + plot1.setInteriorGap(0.15); + assertFalse(plot1.equals(plot2)); + plot2.setInteriorGap(0.15); + assertTrue(plot1.equals(plot2)); + + // circular + plot1.setCircular(!plot1.isCircular()); + assertFalse(plot1.equals(plot2)); + plot2.setCircular(false); + assertTrue(plot1.equals(plot2)); + + // startAngle + plot1.setStartAngle(Math.PI); + assertFalse(plot1.equals(plot2)); + plot2.setStartAngle(Math.PI); + assertTrue(plot1.equals(plot2)); + + // direction + plot1.setDirection(Rotation.ANTICLOCKWISE); + assertFalse(plot1.equals(plot2)); + plot2.setDirection(Rotation.ANTICLOCKWISE); + assertTrue(plot1.equals(plot2)); + + // ignoreZeroValues + plot1.setIgnoreZeroValues(true); + plot2.setIgnoreZeroValues(false); + assertFalse(plot1.equals(plot2)); + plot2.setIgnoreZeroValues(true); + assertTrue(plot1.equals(plot2)); + + // ignoreNullValues + plot1.setIgnoreNullValues(true); + plot2.setIgnoreNullValues(false); + assertFalse(plot1.equals(plot2)); + plot2.setIgnoreNullValues(true); + assertTrue(plot1.equals(plot2)); + + // sectionPaint + plot1.setSectionPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.white)); + assertFalse(plot1.equals(plot2)); + plot2.setSectionPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.white)); + assertTrue(plot1.equals(plot2)); + + // sectionPaintMap + plot1.setSectionPaint("A", new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.white)); + assertFalse(plot1.equals(plot2)); + plot2.setSectionPaint("A", new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.white)); + assertTrue(plot1.equals(plot2)); + + // baseSectionPaint + plot1.setBaseSectionPaint(new GradientPaint(1.0f, 2.0f, Color.black, + 3.0f, 4.0f, Color.white)); + assertFalse(plot1.equals(plot2)); + plot2.setBaseSectionPaint(new GradientPaint(1.0f, 2.0f, Color.black, + 3.0f, 4.0f, Color.white)); + assertTrue(plot1.equals(plot2)); + + // sectionOutlinesVisible + plot1.setSectionOutlinesVisible(false); + assertFalse(plot1.equals(plot2)); + plot2.setSectionOutlinesVisible(false); + assertTrue(plot1.equals(plot2)); + + // sectionOutlinePaint + plot1.setSectionOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.cyan, + 3.0f, 4.0f, Color.white)); + assertFalse(plot1.equals(plot2)); + plot2.setSectionOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.cyan, + 3.0f, 4.0f, Color.white)); + assertTrue(plot1.equals(plot2)); + + // sectionOutlinePaintList + plot1.setSectionOutlinePaint("A", new GradientPaint(1.0f, 2.0f, + Color.green, 3.0f, 4.0f, Color.white)); + assertFalse(plot1.equals(plot2)); + plot2.setSectionOutlinePaint("A", new GradientPaint(1.0f, 2.0f, + Color.green, 3.0f, 4.0f, Color.white)); + assertTrue(plot1.equals(plot2)); + + // baseSectionOutlinePaint + plot1.setBaseSectionOutlinePaint(new GradientPaint(1.0f, 2.0f, + Color.gray, 3.0f, 4.0f, Color.white)); + assertFalse(plot1.equals(plot2)); + plot2.setBaseSectionOutlinePaint(new GradientPaint(1.0f, 2.0f, + Color.gray, 3.0f, 4.0f, Color.white)); + assertTrue(plot1.equals(plot2)); + + // sectionOutlineStroke + plot1.setSectionOutlineStroke(new BasicStroke(1.0f)); + assertFalse(plot1.equals(plot2)); + plot2.setSectionOutlineStroke(new BasicStroke(1.0f)); + assertTrue(plot1.equals(plot2)); + + // sectionOutlineStrokeList + plot1.setSectionOutlineStroke("A", new BasicStroke(1.0f)); + assertFalse(plot1.equals(plot2)); + plot2.setSectionOutlineStroke("A", new BasicStroke(1.0f)); + assertTrue(plot1.equals(plot2)); + + // baseSectionOutlineStroke + plot1.setBaseSectionOutlineStroke(new BasicStroke(1.0f)); + assertFalse(plot1.equals(plot2)); + plot2.setBaseSectionOutlineStroke(new BasicStroke(1.0f)); + assertTrue(plot1.equals(plot2)); + + // shadowPaint + plot1.setShadowPaint(new GradientPaint(1.0f, 2.0f, Color.orange, + 3.0f, 4.0f, Color.white)); + assertFalse(plot1.equals(plot2)); + plot2.setShadowPaint(new GradientPaint(1.0f, 2.0f, Color.orange, + 3.0f, 4.0f, Color.white)); + assertTrue(plot1.equals(plot2)); + + // shadowXOffset + plot1.setShadowXOffset(4.4); + assertFalse(plot1.equals(plot2)); + plot2.setShadowXOffset(4.4); + assertTrue(plot1.equals(plot2)); + + // shadowYOffset + plot1.setShadowYOffset(4.4); + assertFalse(plot1.equals(plot2)); + plot2.setShadowYOffset(4.4); + assertTrue(plot1.equals(plot2)); + + // labelFont + plot1.setLabelFont(new Font("Serif", Font.PLAIN, 18)); + assertFalse(plot1.equals(plot2)); + plot2.setLabelFont(new Font("Serif", Font.PLAIN, 18)); + assertTrue(plot1.equals(plot2)); + + // labelPaint + plot1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.darkGray, + 3.0f, 4.0f, Color.white)); + assertFalse(plot1.equals(plot2)); + plot2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.darkGray, + 3.0f, 4.0f, Color.white)); + assertTrue(plot1.equals(plot2)); + + // labelBackgroundPaint + plot1.setLabelBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.white)); + assertFalse(plot1.equals(plot2)); + plot2.setLabelBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.white)); + assertTrue(plot1.equals(plot2)); + + // labelOutlinePaint + plot1.setLabelOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.white)); + assertFalse(plot1.equals(plot2)); + plot2.setLabelOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.white)); + assertTrue(plot1.equals(plot2)); + + // labelOutlineStroke + Stroke s = new BasicStroke(1.1f); + plot1.setLabelOutlineStroke(s); + assertFalse(plot1.equals(plot2)); + plot2.setLabelOutlineStroke(s); + assertTrue(plot1.equals(plot2)); + + // labelShadowPaint + plot1.setLabelShadowPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.white)); + assertFalse(plot1.equals(plot2)); + plot2.setLabelShadowPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.white)); + assertTrue(plot1.equals(plot2)); + + // explodePercentages + plot1.setExplodePercent("A", 0.33); + assertFalse(plot1.equals(plot2)); + plot2.setExplodePercent("A", 0.33); + assertTrue(plot1.equals(plot2)); + + // labelGenerator + plot1.setLabelGenerator(new StandardPieSectionLabelGenerator( + "{2}{1}{0}")); + assertFalse(plot1.equals(plot2)); + plot2.setLabelGenerator(new StandardPieSectionLabelGenerator( + "{2}{1}{0}")); + assertTrue(plot1.equals(plot2)); + + // labelFont + Font f = new Font("SansSerif", Font.PLAIN, 20); + plot1.setLabelFont(f); + assertFalse(plot1.equals(plot2)); + plot2.setLabelFont(f); + assertTrue(plot1.equals(plot2)); + + // labelPaint + plot1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.magenta, + 3.0f, 4.0f, Color.white)); + assertFalse(plot1.equals(plot2)); + plot2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.magenta, + 3.0f, 4.0f, Color.white)); + assertTrue(plot1.equals(plot2)); + + // maximumLabelWidth + plot1.setMaximumLabelWidth(0.33); + assertFalse(plot1.equals(plot2)); + plot2.setMaximumLabelWidth(0.33); + assertTrue(plot1.equals(plot2)); + + // labelGap + plot1.setLabelGap(0.11); + assertFalse(plot1.equals(plot2)); + plot2.setLabelGap(0.11); + assertTrue(plot1.equals(plot2)); + + // links visible + plot1.setLabelLinksVisible(false); + assertFalse(plot1.equals(plot2)); + plot2.setLabelLinksVisible(false); + assertTrue(plot1.equals(plot2)); + + plot1.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE); + assertFalse(plot1.equals(plot2)); + plot2.setLabelLinkStyle(PieLabelLinkStyle.QUAD_CURVE); + assertTrue(plot1.equals(plot2)); + + // linkMargin + plot1.setLabelLinkMargin(0.11); + assertFalse(plot1.equals(plot2)); + plot2.setLabelLinkMargin(0.11); + assertTrue(plot1.equals(plot2)); + + // labelLinkPaint + plot1.setLabelLinkPaint(new GradientPaint(1.0f, 2.0f, Color.magenta, + 3.0f, 4.0f, Color.white)); + assertFalse(plot1.equals(plot2)); + plot2.setLabelLinkPaint(new GradientPaint(1.0f, 2.0f, Color.magenta, + 3.0f, 4.0f, Color.white)); + assertTrue(plot1.equals(plot2)); + + // labelLinkStroke + plot1.setLabelLinkStroke(new BasicStroke(1.0f)); + assertFalse(plot1.equals(plot2)); + plot2.setLabelLinkStroke(new BasicStroke(1.0f)); + assertTrue(plot1.equals(plot2)); + + // toolTipGenerator + plot1.setToolTipGenerator( + new StandardPieToolTipGenerator("{2}{1}{0}") + ); + assertFalse(plot1.equals(plot2)); + plot2.setToolTipGenerator( + new StandardPieToolTipGenerator("{2}{1}{0}") + ); + assertTrue(plot1.equals(plot2)); + + // urlGenerator + plot1.setURLGenerator(new StandardPieURLGenerator("xx")); + assertFalse(plot1.equals(plot2)); + plot2.setURLGenerator(new StandardPieURLGenerator("xx")); + assertTrue(plot1.equals(plot2)); + + // minimumArcAngleToDraw + plot1.setMinimumArcAngleToDraw(1.0); + assertFalse(plot1.equals(plot2)); + plot2.setMinimumArcAngleToDraw(1.0); + assertTrue(plot1.equals(plot2)); + + // legendItemShape + plot1.setLegendItemShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertFalse(plot1.equals(plot2)); + plot2.setLegendItemShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertTrue(plot1.equals(plot2)); + + // legendLabelGenerator + plot1.setLegendLabelGenerator(new StandardPieSectionLabelGenerator( + "{0} --> {1}")); + assertFalse(plot1.equals(plot2)); + plot2.setLegendLabelGenerator(new StandardPieSectionLabelGenerator( + "{0} --> {1}")); + assertTrue(plot1.equals(plot2)); + + // legendLabelToolTipGenerator + plot1.setLegendLabelToolTipGenerator( + new StandardPieSectionLabelGenerator("{0} is {1}")); + assertFalse(plot1.equals(plot2)); + plot2.setLegendLabelToolTipGenerator( + new StandardPieSectionLabelGenerator("{0} is {1}")); + assertTrue(plot1.equals(plot2)); + + // legendLabelURLGenerator + plot1.setLegendLabelURLGenerator(new StandardPieURLGenerator( + "index.html")); + assertFalse(plot1.equals(plot2)); + plot2.setLegendLabelURLGenerator(new StandardPieURLGenerator( + "index.html")); + assertTrue(plot1.equals(plot2)); + + // autoPopulateSectionPaint + plot1.setAutoPopulateSectionPaint(false); + assertFalse(plot1.equals(plot2)); + plot2.setAutoPopulateSectionPaint(false); + assertTrue(plot1.equals(plot2)); + + // autoPopulateSectionOutlinePaint + plot1.setAutoPopulateSectionOutlinePaint(true); + assertFalse(plot1.equals(plot2)); + plot2.setAutoPopulateSectionOutlinePaint(true); + assertTrue(plot1.equals(plot2)); + + // autoPopulateSectionOutlineStroke + plot1.setAutoPopulateSectionOutlineStroke(true); + assertFalse(plot1.equals(plot2)); + plot2.setAutoPopulateSectionOutlineStroke(true); + assertTrue(plot1.equals(plot2)); + + // shadowGenerator + plot1.setShadowGenerator(new DefaultShadowGenerator(5, Color.gray, + 0.6f, 4, -Math.PI / 4)); + assertFalse(plot1.equals(plot2)); + plot2.setShadowGenerator(new DefaultShadowGenerator(5, Color.gray, + 0.6f, 4, -Math.PI / 4)); + assertTrue(plot1.equals(plot2)); + + plot1.setShadowGenerator(null); + assertFalse(plot1.equals(plot2)); + plot2.setShadowGenerator(null); + assertTrue(plot1.equals(plot2)); + } + + /** + * Some basic checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + PiePlot p1 = new PiePlot(); + PiePlot p2 = (PiePlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + } + + /** + * Check cloning of the urlGenerator field. + */ + @Test + public void testCloning_URLGenerator() throws CloneNotSupportedException { + CustomPieURLGenerator generator = new CustomPieURLGenerator(); + PiePlot p1 = new PiePlot(); + p1.setURLGenerator(generator); + PiePlot p2 = (PiePlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // check that the URL generator has been cloned + assertTrue(p1.getURLGenerator() != p2.getURLGenerator()); + } + + /** + * Check cloning of the legendItemShape field. + */ + @Test + public void testCloning_LegendItemShape() throws CloneNotSupportedException { + Rectangle shape = new Rectangle(-4, -4, 8, 8); + PiePlot p1 = new PiePlot(); + p1.setLegendItemShape(shape); + PiePlot p2 = (PiePlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // change the shape and make sure it only affects p1 + shape.setRect(1.0, 2.0, 3.0, 4.0); + assertFalse(p1.equals(p2)); + } + + /** + * Check cloning of the legendLabelGenerator field. + */ + @Test + public void testCloning_LegendLabelGenerator() throws CloneNotSupportedException { + StandardPieSectionLabelGenerator generator + = new StandardPieSectionLabelGenerator(); + PiePlot p1 = new PiePlot(); + p1.setLegendLabelGenerator(generator); + PiePlot p2 = (PiePlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // change the generator and make sure it only affects p1 + generator.getNumberFormat().setMinimumFractionDigits(2); + assertFalse(p1.equals(p2)); + } + + /** + * Check cloning of the legendLabelToolTipGenerator field. + */ + @Test + public void testCloning_LegendLabelToolTipGenerator() throws CloneNotSupportedException { + StandardPieSectionLabelGenerator generator + = new StandardPieSectionLabelGenerator(); + PiePlot p1 = new PiePlot(); + p1.setLegendLabelToolTipGenerator(generator); + PiePlot p2 = (PiePlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // change the generator and make sure it only affects p1 + generator.getNumberFormat().setMinimumFractionDigits(2); + assertFalse(p1.equals(p2)); + } + + /** + * Check cloning of the legendLabelURLGenerator field. + */ + @Test + public void testCloning_LegendLabelURLGenerator() throws CloneNotSupportedException { + CustomPieURLGenerator generator = new CustomPieURLGenerator(); + PiePlot p1 = new PiePlot(); + p1.setLegendLabelURLGenerator(generator); + PiePlot p2 = (PiePlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // check that the URL generator has been cloned + assertTrue(p1.getLegendLabelURLGenerator() + != p2.getLegendLabelURLGenerator()); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PiePlot p1 = new PiePlot(null); + PiePlot p2 = (PiePlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + + /** + * Some checks for the getLegendItems() method. + */ + @Test + public void testGetLegendItems() { + DefaultPieDataset dataset = new DefaultPieDataset(); + dataset.setValue("Item 1", 1.0); + dataset.setValue("Item 2", 2.0); + dataset.setValue("Item 3", 0.0); + dataset.setValue("Item 4", null); + + PiePlot plot = new PiePlot(dataset); + plot.setIgnoreNullValues(false); + plot.setIgnoreZeroValues(false); + LegendItemCollection items = plot.getLegendItems(); + assertEquals(4, items.getItemCount()); + + // check that null items are ignored if requested + plot.setIgnoreNullValues(true); + items = plot.getLegendItems(); + assertEquals(3, items.getItemCount()); + + // check that zero items are ignored if requested + plot.setIgnoreZeroValues(true); + items = plot.getLegendItems(); + assertEquals(2, items.getItemCount()); + + // check that negative items are always ignored + dataset.setValue("Item 5", -1.0); + items = plot.getLegendItems(); + assertEquals(2, items.getItemCount()); + } + + /** + * Check that the default base section paint is not null, and that you + * can never set it to null. + */ + @Test + public void testGetBaseSectionPaint() { + PiePlot plot = new PiePlot(); + assertNotNull(plot.getBaseSectionPaint()); + + boolean pass = false; + try { + plot.setBaseSectionPaint(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + static class NullLegendLabelGenerator implements PieSectionLabelGenerator { + @Override + public AttributedString generateAttributedSectionLabel( + PieDataset dataset, Comparable key) { + return null; + } + @Override + public String generateSectionLabel(PieDataset dataset, Comparable key) { + return null; + } + } + + /** + * Draws a pie chart where the label generator returns null. + */ + @Test + public void testDrawWithNullLegendLabels() { + DefaultPieDataset dataset = new DefaultPieDataset(); + dataset.setValue("L1", 12.0); + dataset.setValue("L2", 11.0); + JFreeChart chart = ChartFactory.createPieChart("Test", dataset, true, + false, false); + PiePlot plot = (PiePlot) chart.getPlot(); + plot.setLegendLabelGenerator(new NullLegendLabelGenerator()); + boolean success = false; + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); + g2.dispose(); + success = true; + } + catch (Exception e) { + success = false; + } + assertTrue(success); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PlotOrientationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PlotOrientationTest.java new file mode 100755 index 0000000..024fe13 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PlotOrientationTest.java @@ -0,0 +1,83 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * PlotOrientationTest.java + * ------------------------ + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Apr-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link PlotOrientation} class. + * + */ +public class PlotOrientationTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + assertEquals(PlotOrientation.HORIZONTAL, PlotOrientation.HORIZONTAL); + assertEquals(PlotOrientation.VERTICAL, PlotOrientation.VERTICAL); + assertFalse( + PlotOrientation.HORIZONTAL.equals(PlotOrientation.VERTICAL) + ); + assertFalse( + PlotOrientation.VERTICAL.equals(PlotOrientation.HORIZONTAL) + ); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PlotOrientation orientation1 = PlotOrientation.HORIZONTAL; + PlotOrientation orientation2 = (PlotOrientation) + TestUtilities.serialised(orientation1); + assertEquals(orientation1, orientation2); + boolean same = orientation1 == orientation2; + assertEquals(true, same); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PlotRenderingInfoTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PlotRenderingInfoTest.java new file mode 100755 index 0000000..a39c844 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PlotRenderingInfoTest.java @@ -0,0 +1,124 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * PlotRenderingInfoTest.java + * -------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-May-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Rectangle; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.ChartRenderingInfo; +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link PlotRenderingInfo} class. + */ +public class PlotRenderingInfoTest { + + /** + * Test the equals() method. + */ + @Test + public void testEquals() { + PlotRenderingInfo p1 = new PlotRenderingInfo(new ChartRenderingInfo()); + PlotRenderingInfo p2 = new PlotRenderingInfo(new ChartRenderingInfo()); + assertTrue(p1.equals(p2)); + assertTrue(p2.equals(p1)); + + p1.setPlotArea(new Rectangle(2, 3, 4, 5)); + assertFalse(p1.equals(p2)); + p2.setPlotArea(new Rectangle(2, 3, 4, 5)); + assertTrue(p1.equals(p2)); + + p1.setDataArea(new Rectangle(2, 4, 6, 8)); + assertFalse(p1.equals(p2)); + p2.setDataArea(new Rectangle(2, 4, 6, 8)); + assertTrue(p1.equals(p2)); + + p1.addSubplotInfo(new PlotRenderingInfo(null)); + assertFalse(p1.equals(p2)); + p2.addSubplotInfo(new PlotRenderingInfo(null)); + assertTrue(p1.equals(p2)); + + p1.getSubplotInfo(0).setDataArea(new Rectangle(1, 2, 3, 4)); + assertFalse(p1.equals(p2)); + p2.getSubplotInfo(0).setDataArea(new Rectangle(1, 2, 3, 4)); + assertTrue(p1.equals(p2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + PlotRenderingInfo p1 = new PlotRenderingInfo(new ChartRenderingInfo()); + p1.setPlotArea(new Rectangle2D.Double()); + PlotRenderingInfo p2 = (PlotRenderingInfo) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // check independence + p1.getPlotArea().setRect(1.0, 2.0, 3.0, 4.0); + assertFalse(p1.equals(p2)); + p2.getPlotArea().setRect(1.0, 2.0, 3.0, 4.0); + assertTrue(p1.equals(p2)); + + p1.getDataArea().setRect(4.0, 3.0, 2.0, 1.0); + assertFalse(p1.equals(p2)); + p2.getDataArea().setRect(4.0, 3.0, 2.0, 1.0); + assertTrue(p1.equals(p2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PlotRenderingInfo p1 = new PlotRenderingInfo(new ChartRenderingInfo()); + PlotRenderingInfo p2 = (PlotRenderingInfo) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PlotTest.java new file mode 100755 index 0000000..2a8d926 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PlotTest.java @@ -0,0 +1,178 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * PlotTest.java + * ------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 06-Jun-2005 : Version 1 (DG); + * 30-Jun-2006 : Extended equals() test to cover new field (DG); + * 11-May-2007 : Another new field in testEquals() (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.Paint; +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.Stroke; + +import org.jfree.chart.JFreeChart; +import org.jfree.ui.Align; +import org.jfree.ui.RectangleInsets; +import org.junit.Test; + +/** + * Some tests for the {@link Plot} class. + */ +public class PlotTest { + + /** + * Check that the equals() method can distinguish all fields (note that + * the dataset is NOT considered in the equals() method). + */ + @Test + public void testEquals() { + PiePlot plot1 = new PiePlot(); + PiePlot plot2 = new PiePlot(); + assertTrue(plot1.equals(plot2)); + assertTrue(plot2.equals(plot1)); + + // noDataMessage + plot1.setNoDataMessage("No data XYZ"); + assertFalse(plot1.equals(plot2)); + plot2.setNoDataMessage("No data XYZ"); + assertTrue(plot1.equals(plot2)); + + // noDataMessageFont + plot1.setNoDataMessageFont(new Font("SansSerif", Font.PLAIN, 13)); + assertFalse(plot1.equals(plot2)); + plot2.setNoDataMessageFont(new Font("SansSerif", Font.PLAIN, 13)); + assertTrue(plot1.equals(plot2)); + + // noDataMessagePaint + plot1.setNoDataMessagePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertFalse(plot1.equals(plot2)); + plot2.setNoDataMessagePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertTrue(plot1.equals(plot2)); + + // insets + plot1.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); + assertFalse(plot1.equals(plot2)); + plot2.setInsets(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); + assertTrue(plot1.equals(plot2)); + + // outlineVisible + plot1.setOutlineVisible(false); + assertFalse(plot1.equals(plot2)); + plot2.setOutlineVisible(false); + assertTrue(plot1.equals(plot2)); + + // outlineStroke + BasicStroke s = new BasicStroke(1.23f); + plot1.setOutlineStroke(s); + assertFalse(plot1.equals(plot2)); + plot2.setOutlineStroke(s); + assertTrue(plot1.equals(plot2)); + + // outlinePaint + plot1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.green)); + assertFalse(plot1.equals(plot2)); + plot2.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.green)); + assertTrue(plot1.equals(plot2)); + + // backgroundPaint + plot1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.cyan, + 3.0f, 4.0f, Color.green)); + assertFalse(plot1.equals(plot2)); + plot2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.cyan, + 3.0f, 4.0f, Color.green)); + assertTrue(plot1.equals(plot2)); + + // backgroundImage + plot1.setBackgroundImage(JFreeChart.INFO.getLogo()); + assertFalse(plot1.equals(plot2)); + plot2.setBackgroundImage(JFreeChart.INFO.getLogo()); + assertTrue(plot1.equals(plot2)); + + // backgroundImageAlignment + plot1.setBackgroundImageAlignment(Align.BOTTOM_RIGHT); + assertFalse(plot1.equals(plot2)); + plot2.setBackgroundImageAlignment(Align.BOTTOM_RIGHT); + assertTrue(plot1.equals(plot2)); + + // backgroundImageAlpha + plot1.setBackgroundImageAlpha(0.77f); + assertFalse(plot1.equals(plot2)); + plot2.setBackgroundImageAlpha(0.77f); + assertTrue(plot1.equals(plot2)); + + // foregroundAlpha + plot1.setForegroundAlpha(0.99f); + assertFalse(plot1.equals(plot2)); + plot2.setForegroundAlpha(0.99f); + assertTrue(plot1.equals(plot2)); + + // backgroundAlpha + plot1.setBackgroundAlpha(0.99f); + assertFalse(plot1.equals(plot2)); + plot2.setBackgroundAlpha(0.99f); + assertTrue(plot1.equals(plot2)); + + // drawingSupplier + plot1.setDrawingSupplier(new DefaultDrawingSupplier( + new Paint[] {Color.blue}, new Paint[] {Color.red}, + new Stroke[] {new BasicStroke(1.1f)}, + new Stroke[] {new BasicStroke(9.9f)}, + new Shape[] {new Rectangle(1, 2, 3, 4)})); + assertFalse(plot1.equals(plot2)); + plot2.setDrawingSupplier(new DefaultDrawingSupplier( + new Paint[] {Color.blue}, new Paint[] {Color.red}, + new Stroke[] {new BasicStroke(1.1f)}, + new Stroke[] {new BasicStroke(9.9f)}, + new Shape[] {new Rectangle(1, 2, 3, 4)})); + assertTrue(plot1.equals(plot2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PolarPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PolarPlotTest.java new file mode 100755 index 0000000..6a4f107 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/PolarPlotTest.java @@ -0,0 +1,384 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * PolarPlotTest.java + * ------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Feb-2005 : Version 1 (DG); + * 08-Jun-2005 : Extended testEquals() (DG); + * 07-Feb-2007 : Extended testEquals() and testCloning() (DG); + * 17-Feb-2008 : Tests for new angleTickUnit field (DG); + * 09-Dec-2009 : Added new tests (DG); + * 12-Nov-2011 : Added tests for translateToJava2D (MH); + * 17-Dec-2011 : Updated testEquals() (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.Point; +import java.awt.Stroke; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.LogAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.axis.NumberTickUnit; +import org.jfree.chart.axis.ValueAxis; +import org.jfree.chart.renderer.DefaultPolarItemRenderer; +import org.jfree.data.xy.DefaultXYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.junit.Test; + +/** + * Some tests for the {@link PolarPlot} class. + */ +public class PolarPlotTest { + + /** + * Some checks for the getLegendItems() method. + */ + @Test + public void testGetLegendItems() { + XYSeriesCollection d = new XYSeriesCollection(); + d.addSeries(new XYSeries("A")); + d.addSeries(new XYSeries("B")); + DefaultPolarItemRenderer r = new DefaultPolarItemRenderer(); + PolarPlot plot = new PolarPlot(); + plot.setDataset(d); + plot.setRenderer(r); + LegendItemCollection items = plot.getLegendItems(); + assertEquals(2, items.getItemCount()); + LegendItem item1 = items.get(0); + assertEquals("A", item1.getLabel()); + LegendItem item2 = items.get(1); + assertEquals("B", item2.getLabel()); + } + + /** + * Some checks for the getLegendItems() method with multiple datasets. + */ + @Test + public void testGetLegendItems2() { + XYSeriesCollection d1 = new XYSeriesCollection(); + d1.addSeries(new XYSeries("A")); + d1.addSeries(new XYSeries("B")); + XYSeriesCollection d2 = new XYSeriesCollection(); + d2.addSeries(new XYSeries("C")); + d2.addSeries(new XYSeries("D")); + DefaultPolarItemRenderer r = new DefaultPolarItemRenderer(); + PolarPlot plot = new PolarPlot(); + plot.setDataset(d1); + plot.setDataset(1, d2); + plot.setRenderer(r); + plot.setRenderer(1, new DefaultPolarItemRenderer()); + LegendItemCollection items = plot.getLegendItems(); + assertEquals(4, items.getItemCount()); + LegendItem item1 = items.get(0); + assertEquals("A", item1.getLabel()); + LegendItem item2 = items.get(1); + assertEquals("B", item2.getLabel()); + LegendItem item3 = items.get(2); + assertEquals("C", item3.getLabel()); + LegendItem item4 = items.get(3); + assertEquals("D", item4.getLabel()); + } + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + PolarPlot plot1 = new PolarPlot(); + PolarPlot plot2 = new PolarPlot(); + assertTrue(plot1.equals(plot2)); + assertTrue(plot2.equals(plot1)); + + plot1.setAngleGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertFalse(plot1.equals(plot2)); + plot2.setAngleGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertTrue(plot1.equals(plot2)); + + Stroke s = new BasicStroke(1.23f); + plot1.setAngleGridlineStroke(s); + assertFalse(plot1.equals(plot2)); + plot2.setAngleGridlineStroke(s); + assertTrue(plot1.equals(plot2)); + + plot1.setAngleTickUnit(new NumberTickUnit(11.0)); + assertFalse(plot1.equals(plot2)); + plot2.setAngleTickUnit(new NumberTickUnit(11.0)); + assertTrue(plot1.equals(plot2)); + + plot1.setAngleGridlinesVisible(false); + assertFalse(plot1.equals(plot2)); + plot2.setAngleGridlinesVisible(false); + assertTrue(plot1.equals(plot2)); + + plot1.setAngleLabelFont(new Font("Serif", Font.PLAIN, 9)); + assertFalse(plot1.equals(plot2)); + plot2.setAngleLabelFont(new Font("Serif", Font.PLAIN, 9)); + assertTrue(plot1.equals(plot2)); + + plot1.setAngleLabelPaint(new GradientPaint(9.0f, 8.0f, Color.blue, + 7.0f, 6.0f, Color.red)); + assertFalse(plot1.equals(plot2)); + plot2.setAngleLabelPaint(new GradientPaint(9.0f, 8.0f, Color.blue, + 7.0f, 6.0f, Color.red)); + assertTrue(plot1.equals(plot2)); + + plot1.setAngleLabelsVisible(false); + assertFalse(plot1.equals(plot2)); + plot2.setAngleLabelsVisible(false); + assertTrue(plot1.equals(plot2)); + + plot1.setAxis(new NumberAxis("Test")); + assertFalse(plot1.equals(plot2)); + plot2.setAxis(new NumberAxis("Test")); + assertTrue(plot1.equals(plot2)); + + plot1.setRadiusGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.black)); + assertFalse(plot1.equals(plot2)); + plot2.setRadiusGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.black)); + assertTrue(plot1.equals(plot2)); + + plot1.setRadiusGridlineStroke(s); + assertFalse(plot1.equals(plot2)); + plot2.setRadiusGridlineStroke(s); + assertTrue(plot1.equals(plot2)); + + plot1.setRadiusGridlinesVisible(false); + assertFalse(plot1.equals(plot2)); + plot2.setRadiusGridlinesVisible(false); + assertTrue(plot1.equals(plot2)); + + plot1.setRadiusMinorGridlinesVisible(false); + assertFalse(plot1.equals(plot2)); + plot2.setRadiusMinorGridlinesVisible(false); + assertTrue(plot1.equals(plot2)); + + plot1.addCornerTextItem("XYZ"); + assertFalse(plot1.equals(plot2)); + plot2.addCornerTextItem("XYZ"); + assertTrue(plot1.equals(plot2)); + + plot1.setMargin(6); + assertFalse(plot1.equals(plot2)); + plot2.setMargin(6); + assertTrue(plot1.equals(plot2)); + + LegendItemCollection lic1 = new LegendItemCollection(); + lic1.add(new LegendItem("XYZ", Color.red)); + plot1.setFixedLegendItems(lic1); + assertFalse(plot1.equals(plot2)); + LegendItemCollection lic2 = new LegendItemCollection(); + lic2.add(new LegendItem("XYZ", Color.red)); + plot2.setFixedLegendItems(lic2); + assertTrue(plot1.equals(plot2)); + } + + /** + * Some basic checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + PolarPlot p1 = new PolarPlot(); + PolarPlot p2 = (PolarPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // check independence + p1.addCornerTextItem("XYZ"); + assertFalse(p1.equals(p2)); + p2.addCornerTextItem("XYZ"); + assertTrue(p1.equals(p2)); + + p1 = new PolarPlot(new DefaultXYDataset(), new NumberAxis("A1"), + new DefaultPolarItemRenderer()); + p2 = (PolarPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // check independence + p1.getAxis().setLabel("ABC"); + assertFalse(p1.equals(p2)); + p2.getAxis().setLabel("ABC"); + assertTrue(p1.equals(p2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PolarPlot p1 = new PolarPlot(); + p1.setAngleGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.blue)); + p1.setAngleLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.blue)); + p1.setRadiusGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.blue)); + PolarPlot p2 = (PolarPlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + + @Test + public void testTranslateToJava2D_NumberAxis() { + + Rectangle2D dataArea = new Rectangle2D.Double(0.0, 0.0, 100.0, 100.0); + ValueAxis axis = new NumberAxis(); + axis.setRange(0.0, 20.0); + + PolarPlot plot = new PolarPlot(null, axis, null); + plot.setMargin(0); + plot.setAngleOffset(0.0); + + Point point = plot.translateToJava2D(0.0, 10.0, axis, dataArea ); + assertEquals(75.0, point.getX(), 0.5); + assertEquals(50.0, point.getY(), 0.5); + + point = plot.translateToJava2D(90.0, 5.0, axis, dataArea ); + assertEquals(50.0, point.getX(), 0.5); + assertEquals(62.5, point.getY(), 0.5); + + point = plot.translateToJava2D(45.0, 20.0, axis, dataArea ); + assertEquals(85.0, point.getX(), 0.5); + assertEquals(85.0, point.getY(), 0.5); + + point = plot.translateToJava2D(135.0, 20.0, axis, dataArea ); + assertEquals(15.0, point.getX(), 0.5); + assertEquals(85.0, point.getY(), 0.5); + + point = plot.translateToJava2D(225.0, 15.0, axis, dataArea ); + assertEquals(23.0, point.getX(), 0.5); + assertEquals(23.0, point.getY(), 0.5); + + point = plot.translateToJava2D(315.0, 15.0, axis, dataArea ); + assertEquals(77.0, point.getX(), 0.5); + assertEquals(23.0, point.getY(), 0.5); + + point = plot.translateToJava2D(21.0, 11.5, axis, dataArea ); + assertEquals(77.0, point.getX(), 0.5); + assertEquals(60.0, point.getY(), 0.5); + + point = plot.translateToJava2D(162.0, 7.0, axis, dataArea ); + assertEquals(33.0, point.getX(), 0.5); + assertEquals(55.0, point.getY(), 0.5); + + } + + @Test + public void testTranslateToJava2D_NumberAxisAndMargin() { + + Rectangle2D dataArea = new Rectangle2D.Double(10.0, 10.0, 80.0, 80.0); + ValueAxis axis = new NumberAxis(); + axis.setRange(-2.0, 2.0); + + PolarPlot plot = new PolarPlot(null, axis, null); + plot.setAngleOffset(0.0); + + Point point = plot.translateToJava2D(0.0, 10.0, axis, dataArea ); + assertEquals(110.0, point.getX(), 0.5); + assertEquals(50.0, point.getY(), 0.5); + + point = plot.translateToJava2D(90.0, 5.0, axis, dataArea ); + assertEquals(50.0, point.getX(), 0.5); + assertEquals(85.0, point.getY(), 0.5); + + point = plot.translateToJava2D(45.0, 20.0, axis, dataArea ); + assertEquals(128.0, point.getX(), 0.5); + assertEquals(128.0, point.getY(), 0.5); + + point = plot.translateToJava2D(135.0, 20.0, axis, dataArea ); + assertEquals(-28.0, point.getX(), 0.5); + assertEquals(128.0, point.getY(), 0.5); + + point = plot.translateToJava2D(225.0, 15.0, axis, dataArea ); + assertEquals(-10.0, point.getX(), 0.5); + assertEquals(-10.0, point.getY(), 0.5); + + point = plot.translateToJava2D(315.0, 15.0, axis, dataArea ); + assertEquals(110.0, point.getX(), 0.5); + assertEquals(-10.0, point.getY(), 0.5); + + point = plot.translateToJava2D(21.0, 11.5, axis, dataArea ); + assertEquals(113.0, point.getX(), 0.5); + assertEquals(74.0, point.getY(), 0.5); + + point = plot.translateToJava2D(162.0, 7.0, axis, dataArea ); + assertEquals(7.0, point.getX(), 0.5); + assertEquals(64.0, point.getY(), 0.5); + + } + + @Test + public void testTranslateToJava2D_LogAxis() { + + Rectangle2D dataArea = new Rectangle2D.Double(0.0, 0.0, 100.0, 100.0); + ValueAxis axis = new LogAxis(); + axis.setRange(1.0, 100.0); + + PolarPlot plot = new PolarPlot(null, axis, null); + plot.setMargin(0); + plot.setAngleOffset(0.0); + + Point point = plot.translateToJava2D(0.0, 10.0, axis, dataArea ); + assertEquals(75.0, point.getX(), 0.5); + assertEquals(50.0, point.getY(), 0.5); + + point = plot.translateToJava2D(90.0, 5.0, axis, dataArea ); + assertEquals(50.0, point.getX(), 0.5); + assertEquals(67.5, point.getY(), 0.5); + + point = plot.translateToJava2D(45.0, 20.0, axis, dataArea ); + assertEquals(73.0, point.getX(), 0.5); + assertEquals(73.0, point.getY(), 0.5); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/RingPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/RingPlotTest.java new file mode 100755 index 0000000..7e76a8f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/RingPlotTest.java @@ -0,0 +1,142 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * RingPlotTest.java + * ----------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 09-Nov-2004 : Version 1 (DG); + * 12-Oct-2006 : Updated testEquals() (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Stroke; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link RingPlot} class. + */ +public class RingPlotTest { + + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + + RingPlot plot1 = new RingPlot(null); + RingPlot plot2 = new RingPlot(null); + assertTrue(plot1.equals(plot2)); + assertTrue(plot2.equals(plot1)); + + // separatorsVisible + plot1.setSeparatorsVisible(false); + assertFalse(plot1.equals(plot2)); + plot2.setSeparatorsVisible(false); + assertTrue(plot1.equals(plot2)); + + // separatorStroke + Stroke s = new BasicStroke(1.1f); + plot1.setSeparatorStroke(s); + assertFalse(plot1.equals(plot2)); + plot2.setSeparatorStroke(s); + assertTrue(plot1.equals(plot2)); + + // separatorPaint + plot1.setSeparatorPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 2.0f, 1.0f, Color.blue)); + assertFalse(plot1.equals(plot2)); + plot2.setSeparatorPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 2.0f, 1.0f, Color.blue)); + assertTrue(plot1.equals(plot2)); + + // innerSeparatorExtension + plot1.setInnerSeparatorExtension(0.01); + assertFalse(plot1.equals(plot2)); + plot2.setInnerSeparatorExtension(0.01); + assertTrue(plot1.equals(plot2)); + + // outerSeparatorExtension + plot1.setOuterSeparatorExtension(0.02); + assertFalse(plot1.equals(plot2)); + plot2.setOuterSeparatorExtension(0.02); + assertTrue(plot1.equals(plot2)); + + // sectionDepth + plot1.setSectionDepth(0.12); + assertFalse(plot1.equals(plot2)); + plot2.setSectionDepth(0.12); + assertTrue(plot1.equals(plot2)); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + RingPlot p1 = new RingPlot(null); + GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.red); + p1.setSeparatorPaint(gp); + RingPlot p2 = (RingPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + RingPlot p1 = new RingPlot(null); + GradientPaint gp = new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.red); + p1.setSeparatorPaint(gp); + RingPlot p2 = (RingPlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/SpiderWebPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/SpiderWebPlotTest.java new file mode 100755 index 0000000..26170d3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/SpiderWebPlotTest.java @@ -0,0 +1,360 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * SpiderWebPlotTest.java + * ---------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-Jun-2005 : Version 1 (DG); + * 01-Jun-2006 : Added testDrawWithNullInfo() method (DG); + * 05-Feb-2007 : Added more checks to testCloning (DG); + * 01-Jun-2009 : Added test for getLegendItems() bug, series key is not + * set (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Rectangle; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.text.DecimalFormat; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +import org.jfree.chart.urls.StandardCategoryURLGenerator; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.Rotation; +import org.jfree.util.TableOrder; +import org.junit.Test; + +/** + * Tests for the {@link SpiderWebPlot} class. + */ +public class SpiderWebPlotTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + SpiderWebPlot p1 = new SpiderWebPlot(new DefaultCategoryDataset()); + SpiderWebPlot p2 = new SpiderWebPlot(new DefaultCategoryDataset()); + assertTrue(p1.equals(p2)); + assertTrue(p2.equals(p1)); + + // dataExtractOrder + p1.setDataExtractOrder(TableOrder.BY_COLUMN); + assertFalse(p1.equals(p2)); + p2.setDataExtractOrder(TableOrder.BY_COLUMN); + assertTrue(p1.equals(p2)); + + // headPercent + p1.setHeadPercent(0.321); + assertFalse(p1.equals(p2)); + p2.setHeadPercent(0.321); + assertTrue(p1.equals(p2)); + + // interiorGap + p1.setInteriorGap(0.123); + assertFalse(p1.equals(p2)); + p2.setInteriorGap(0.123); + assertTrue(p1.equals(p2)); + + // startAngle + p1.setStartAngle(0.456); + assertFalse(p1.equals(p2)); + p2.setStartAngle(0.456); + assertTrue(p1.equals(p2)); + + // direction + p1.setDirection(Rotation.ANTICLOCKWISE); + assertFalse(p1.equals(p2)); + p2.setDirection(Rotation.ANTICLOCKWISE); + assertTrue(p1.equals(p2)); + + // maxValue + p1.setMaxValue(123.4); + assertFalse(p1.equals(p2)); + p2.setMaxValue(123.4); + assertTrue(p1.equals(p2)); + + // legendItemShape + p1.setLegendItemShape(new Rectangle(1, 2, 3, 4)); + assertFalse(p1.equals(p2)); + p2.setLegendItemShape(new Rectangle(1, 2, 3, 4)); + assertTrue(p1.equals(p2)); + + // seriesPaint + p1.setSeriesPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.white)); + assertFalse(p1.equals(p2)); + p2.setSeriesPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.white)); + assertTrue(p1.equals(p2)); + + // seriesPaintList + p1.setSeriesPaint(1, new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.white)); + assertFalse(p1.equals(p2)); + p2.setSeriesPaint(1, new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.white)); + assertTrue(p1.equals(p2)); + + // baseSeriesPaint + p1.setBaseSeriesPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.black)); + assertFalse(p1.equals(p2)); + p2.setBaseSeriesPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.black)); + assertTrue(p1.equals(p2)); + + // seriesOutlinePaint + p1.setSeriesOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.black)); + assertFalse(p1.equals(p2)); + p2.setSeriesOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.black)); + assertTrue(p1.equals(p2)); + + // seriesOutlinePaintList + p1.setSeriesOutlinePaint(1, new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.green)); + assertFalse(p1.equals(p2)); + p2.setSeriesOutlinePaint(1, new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.green)); + assertTrue(p1.equals(p2)); + + // baseSeriesOutlinePaint + p1.setBaseSeriesOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.cyan, + 3.0f, 4.0f, Color.green)); + assertFalse(p1.equals(p2)); + p2.setBaseSeriesOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.cyan, + 3.0f, 4.0f, Color.green)); + assertTrue(p1.equals(p2)); + + // seriesOutlineStroke + BasicStroke s = new BasicStroke(1.23f); + p1.setSeriesOutlineStroke(s); + assertFalse(p1.equals(p2)); + p2.setSeriesOutlineStroke(s); + assertTrue(p1.equals(p2)); + + // seriesOutlineStrokeList + p1.setSeriesOutlineStroke(1, s); + assertFalse(p1.equals(p2)); + p2.setSeriesOutlineStroke(1, s); + assertTrue(p1.equals(p2)); + + // baseSeriesOutlineStroke + p1.setBaseSeriesOutlineStroke(s); + assertFalse(p1.equals(p2)); + p2.setBaseSeriesOutlineStroke(s); + assertTrue(p1.equals(p2)); + + // webFilled + p1.setWebFilled(false); + assertFalse(p1.equals(p2)); + p2.setWebFilled(false); + assertTrue(p1.equals(p2)); + + // axisLabelGap + p1.setAxisLabelGap(0.11); + assertFalse(p1.equals(p2)); + p2.setAxisLabelGap(0.11); + assertTrue(p1.equals(p2)); + + // labelFont + p1.setLabelFont(new Font("Serif", Font.PLAIN, 9)); + assertFalse(p1.equals(p2)); + p2.setLabelFont(new Font("Serif", Font.PLAIN, 9)); + assertTrue(p1.equals(p2)); + + // labelPaint + p1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertFalse(p1.equals(p2)); + p2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertTrue(p1.equals(p2)); + + // labelGenerator + p1.setLabelGenerator(new StandardCategoryItemLabelGenerator("XYZ: {0}", + new DecimalFormat("0.000"))); + assertFalse(p1.equals(p2)); + p2.setLabelGenerator(new StandardCategoryItemLabelGenerator("XYZ: {0}", + new DecimalFormat("0.000"))); + assertTrue(p1.equals(p2)); + + // toolTipGenerator + p1.setToolTipGenerator(new StandardCategoryToolTipGenerator()); + assertFalse(p1.equals(p2)); + p2.setToolTipGenerator(new StandardCategoryToolTipGenerator()); + assertTrue(p1.equals(p2)); + + // urlGenerator + p1.setURLGenerator(new StandardCategoryURLGenerator()); + assertFalse(p1.equals(p2)); + p2.setURLGenerator(new StandardCategoryURLGenerator()); + assertTrue(p1.equals(p2)); + + // axisLinePaint + p1.setAxisLinePaint(Color.red); + assertFalse(p1.equals(p2)); + p2.setAxisLinePaint(Color.red); + assertTrue(p1.equals(p2)); + + // axisLineStroke + p1.setAxisLineStroke(new BasicStroke(1.1f)); + assertFalse(p1.equals(p2)); + p2.setAxisLineStroke(new BasicStroke(1.1f)); + assertTrue(p1.equals(p2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + SpiderWebPlot p1 = new SpiderWebPlot(new DefaultCategoryDataset()); + Rectangle2D legendShape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); + p1.setLegendItemShape(legendShape); + SpiderWebPlot p2 = (SpiderWebPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // change the legendItemShape + legendShape.setRect(4.0, 3.0, 2.0, 1.0); + assertFalse(p1.equals(p2)); + p2.setLegendItemShape(legendShape); + assertTrue(p1.equals(p2)); + + // change a series paint + p1.setSeriesPaint(1, Color.black); + assertFalse(p1.equals(p2)); + p2.setSeriesPaint(1, Color.black); + assertTrue(p1.equals(p2)); + + // change a series outline paint + p1.setSeriesOutlinePaint(0, Color.red); + assertFalse(p1.equals(p2)); + p2.setSeriesOutlinePaint(0, Color.red); + assertTrue(p1.equals(p2)); + + // change a series outline stroke + p1.setSeriesOutlineStroke(0, new BasicStroke(1.1f)); + assertFalse(p1.equals(p2)); + p2.setSeriesOutlineStroke(0, new BasicStroke(1.1f)); + assertTrue(p1.equals(p2)); + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + SpiderWebPlot p1 = new SpiderWebPlot(new DefaultCategoryDataset()); + SpiderWebPlot p2 = (SpiderWebPlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + + /** + * Draws the chart with a null info object to make sure that no exceptions + * are thrown. + */ + @Test + public void testDrawWithNullInfo() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(35.0, "S1", "C1"); + dataset.addValue(45.0, "S1", "C2"); + dataset.addValue(55.0, "S1", "C3"); + dataset.addValue(15.0, "S1", "C4"); + dataset.addValue(25.0, "S1", "C5"); + SpiderWebPlot plot = new SpiderWebPlot(dataset); + JFreeChart chart = new JFreeChart(plot); + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); + g2.dispose(); + } + catch (Exception e) { + fail("There should be no exception."); + } + } + + /** + * Fetches the legend items and checks the values. + */ + @Test + public void testGetLegendItems() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(35.0, "S1", "C1"); + dataset.addValue(45.0, "S1", "C2"); + dataset.addValue(55.0, "S2", "C1"); + dataset.addValue(15.0, "S2", "C2"); + SpiderWebPlot plot = new SpiderWebPlot(dataset); + JFreeChart chart = new JFreeChart(plot); + LegendItemCollection legendItems = plot.getLegendItems(); + assertEquals(2, legendItems.getItemCount()); + LegendItem item1 = legendItems.get(0); + assertEquals("S1", item1.getLabel()); + assertEquals("S1", item1.getSeriesKey()); + assertEquals(0, item1.getSeriesIndex()); + assertEquals(dataset, item1.getDataset()); + assertEquals(0, item1.getDatasetIndex()); + + LegendItem item2 = legendItems.get(1); + assertEquals("S2", item2.getLabel()); + assertEquals("S2", item2.getSeriesKey()); + assertEquals(1, item2.getSeriesIndex()); + assertEquals(dataset, item2.getDataset()); + assertEquals(0, item2.getDatasetIndex()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/ThermometerPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/ThermometerPlotTest.java new file mode 100755 index 0000000..0154088 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/ThermometerPlotTest.java @@ -0,0 +1,223 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * ThermometerPlotTest.java + * ------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Mar-2003 : Version 1 (DG); + * 30-Apr-2007 : Added new serialization test (DG); + * 03-May-2007 : Added cloning test (DG); + * 08-Oct-2007 : Updated testEquals() for new fields (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; +import java.text.DecimalFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.ui.RectangleInsets; +import org.junit.Test; + +/** + * Tests for the {@link ThermometerPlot} class. + */ +public class ThermometerPlotTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + ThermometerPlot p1 = new ThermometerPlot(); + ThermometerPlot p2 = new ThermometerPlot(); + assertTrue(p1.equals(p2)); + assertTrue(p2.equals(p1)); + + // padding + p1.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); + assertFalse(p1.equals(p2)); + p2.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); + assertTrue(p2.equals(p1)); + + // thermometerStroke + BasicStroke s = new BasicStroke(1.23f); + p1.setThermometerStroke(s); + assertFalse(p1.equals(p2)); + p2.setThermometerStroke(s); + assertTrue(p2.equals(p1)); + + // thermometerPaint + p1.setThermometerPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertFalse(p1.equals(p2)); + p2.setThermometerPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertTrue(p2.equals(p1)); + + // units + p1.setUnits(ThermometerPlot.UNITS_KELVIN); + assertFalse(p1.equals(p2)); + p2.setUnits(ThermometerPlot.UNITS_KELVIN); + assertTrue(p2.equals(p1)); + + // valueLocation + p1.setValueLocation(ThermometerPlot.LEFT); + assertFalse(p1.equals(p2)); + p2.setValueLocation(ThermometerPlot.LEFT); + assertTrue(p2.equals(p1)); + + // axisLocation + p1.setAxisLocation(ThermometerPlot.RIGHT); + assertFalse(p1.equals(p2)); + p2.setAxisLocation(ThermometerPlot.RIGHT); + assertTrue(p2.equals(p1)); + + // valueFont + p1.setValueFont(new Font("Serif", Font.PLAIN, 9)); + assertFalse(p1.equals(p2)); + p2.setValueFont(new Font("Serif", Font.PLAIN, 9)); + assertTrue(p2.equals(p1)); + + // valuePaint + p1.setValuePaint(new GradientPaint(4.0f, 5.0f, Color.red, + 6.0f, 7.0f, Color.white)); + assertFalse(p1.equals(p2)); + p2.setValuePaint(new GradientPaint(4.0f, 5.0f, Color.red, + 6.0f, 7.0f, Color.white)); + assertTrue(p2.equals(p1)); + + // valueFormat + p1.setValueFormat(new DecimalFormat("0.0000")); + assertFalse(p1.equals(p2)); + p2.setValueFormat(new DecimalFormat("0.0000")); + assertTrue(p2.equals(p1)); + + // mercuryPaint + p1.setMercuryPaint(new GradientPaint(9.0f, 8.0f, Color.red, + 7.0f, 6.0f, Color.blue)); + assertFalse(p1.equals(p2)); + p2.setMercuryPaint(new GradientPaint(9.0f, 8.0f, Color.red, + 7.0f, 6.0f, Color.blue)); + assertTrue(p2.equals(p1)); + + // showValueLines + p1.setShowValueLines(true); + assertFalse(p1.equals(p2)); + p2.setShowValueLines(true); + assertTrue(p2.equals(p1)); + + p1.setSubrange(1, 1.0, 2.0); + assertFalse(p1.equals(p2)); + p2.setSubrange(1, 1.0, 2.0); + assertTrue(p2.equals(p1)); + + p1.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertFalse(p1.equals(p2)); + p2.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertTrue(p2.equals(p1)); + + p1.setBulbRadius(9); + assertFalse(p1.equals(p2)); + p2.setBulbRadius(9); + assertTrue(p2.equals(p1)); + + p1.setColumnRadius(8); + assertFalse(p1.equals(p2)); + p2.setColumnRadius(8); + assertTrue(p2.equals(p1)); + + p1.setGap(7); + assertFalse(p1.equals(p2)); + p2.setGap(7); + assertTrue(p2.equals(p1)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ThermometerPlot p1 = new ThermometerPlot(); + ThermometerPlot p2 = (ThermometerPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ThermometerPlot p1 = new ThermometerPlot(); + ThermometerPlot p2 = (ThermometerPlot) TestUtilities.serialised(p1); + assertTrue(p1.equals(p2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization2() { + ThermometerPlot p1 = new ThermometerPlot(); + p1.setSubrangePaint(1, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.blue)); + ThermometerPlot p2 = (ThermometerPlot) TestUtilities.serialised(p1); + assertTrue(p1.equals(p2)); + } + + /** + * Some checks for the setUnits() method. + */ + @Test + public void testSetUnits() { + ThermometerPlot p1 = new ThermometerPlot(); + assertEquals(ThermometerPlot.UNITS_CELCIUS, p1.getUnits()); + p1.setUnits("FAHRENHEIT"); // this doesn't work + assertEquals(ThermometerPlot.UNITS_CELCIUS, p1.getUnits()); + p1.setUnits("\u00B0F"); // ...but this does! + assertEquals(ThermometerPlot.UNITS_FAHRENHEIT, p1.getUnits()); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/ValueMarkerTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/ValueMarkerTest.java new file mode 100755 index 0000000..fa8cb76 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/ValueMarkerTest.java @@ -0,0 +1,243 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * ValueMarkerTest.java + * -------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Aug-2003 : Version 1 (DG); + * 14-Jun-2004 : Renamed MarkerTests --> ValueMarkerTests (DG); + * 01-Jun-2005 : Strengthened equals() test (DG); + * 05-Sep-2006 : Added checks for MarkerChangeEvent generation (DG); + * 26-Sep-2007 : Added test1802195() method (DG); + * 08-Oct-2007 : Added test1808376() method (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.Stroke; + +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.event.MarkerChangeEvent; +import org.jfree.chart.event.MarkerChangeListener; +import org.jfree.ui.LengthAdjustmentType; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.TextAnchor; +import org.junit.Test; + +/** + * Tests for the {@link ValueMarker} class. + */ +public class ValueMarkerTest implements MarkerChangeListener { + + MarkerChangeEvent lastEvent; + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + Marker m1 = new ValueMarker(45.0); + Marker m2 = new ValueMarker(45.0); + assertTrue(m1.equals(m2)); + assertTrue(m2.equals(m1)); + + m1.setPaint(new GradientPaint(1.0f, 2.0f, Color.green, + 3.0f, 4.0f, Color.red)); + assertFalse(m1.equals(m2)); + m2.setPaint(new GradientPaint(1.0f, 2.0f, Color.green, + 3.0f, 4.0f, Color.red)); + assertTrue(m1.equals(m2)); + + BasicStroke stroke = new BasicStroke(2.2f); + m1.setStroke(stroke); + assertFalse(m1.equals(m2)); + m2.setStroke(stroke); + assertTrue(m1.equals(m2)); + + m1.setOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.yellow, + 2.0f, 1.0f, Color.white)); + assertFalse(m1.equals(m2)); + m2.setOutlinePaint(new GradientPaint(4.0f, 3.0f, Color.yellow, + 2.0f, 1.0f, Color.white)); + assertTrue(m1.equals(m2)); + + m1.setOutlineStroke(stroke); + assertFalse(m1.equals(m2)); + m2.setOutlineStroke(stroke); + assertTrue(m1.equals(m2)); + + m1.setAlpha(0.1f); + assertFalse(m1.equals(m2)); + m2.setAlpha(0.1f); + assertTrue(m1.equals(m2)); + + m1.setLabel("New Label"); + assertFalse(m1.equals(m2)); + m2.setLabel("New Label"); + assertTrue(m1.equals(m2)); + + m1.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); + assertFalse(m1.equals(m2)); + m2.setLabelFont(new Font("SansSerif", Font.PLAIN, 10)); + assertTrue(m1.equals(m2)); + + m1.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.yellow)); + assertFalse(m1.equals(m2)); + m2.setLabelPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.yellow)); + assertTrue(m1.equals(m2)); + + m1.setLabelAnchor(RectangleAnchor.TOP_RIGHT); + assertFalse(m1.equals(m2)); + m2.setLabelAnchor(RectangleAnchor.TOP_RIGHT); + assertTrue(m1.equals(m2)); + + m1.setLabelTextAnchor(TextAnchor.BASELINE_RIGHT); + assertFalse(m1.equals(m2)); + m2.setLabelTextAnchor(TextAnchor.BASELINE_RIGHT); + assertTrue(m1.equals(m2)); + + m1.setLabelOffset(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); + assertFalse(m1.equals(m2)); + m2.setLabelOffset(new RectangleInsets(10.0, 10.0, 10.0, 10.0)); + assertTrue(m1.equals(m2)); + + m1.setLabelOffsetType(LengthAdjustmentType.EXPAND); + assertFalse(m1.equals(m2)); + m2.setLabelOffsetType(LengthAdjustmentType.EXPAND); + assertTrue(m1.equals(m2)); + + m1 = new ValueMarker(12.3); + m2 = new ValueMarker(45.6); + assertFalse(m1.equals(m2)); + m2 = new ValueMarker(12.3); + assertTrue(m1.equals(m2)); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ValueMarker m1 = new ValueMarker(25.0); + ValueMarker m2 = (ValueMarker) m1.clone(); + assertTrue(m1 != m2); + assertTrue(m1.getClass() == m2.getClass()); + assertTrue(m1.equals(m2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ValueMarker m1 = new ValueMarker(25.0); + ValueMarker m2 = (ValueMarker) TestUtilities.serialised(m1); + assertEquals(m1, m2); + } + + private static final double EPSILON = 0.000000001; + + /** + * Some checks for the getValue() and setValue() methods. + */ + @Test + public void testGetSetValue() { + ValueMarker m = new ValueMarker(1.1); + m.addChangeListener(this); + this.lastEvent = null; + assertEquals(1.1, m.getValue(), EPSILON); + m.setValue(33.3); + assertEquals(33.3, m.getValue(), EPSILON); + assertEquals(m, this.lastEvent.getMarker()); + } + + /** + * Records the last event. + * + * @param event the last event. + */ + @Override + public void markerChanged(MarkerChangeEvent event) { + this.lastEvent = event; + } + + /** + * A test for bug 1802195. + */ + @Test + public void test1802195() { + ValueMarker m1 = new ValueMarker(25.0); + ValueMarker m2 = (ValueMarker) TestUtilities.serialised(m1); + assertEquals(m1, m2); + try { + m2.setValue(-10.0); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * A test for bug report 1808376. + */ + @Test + public void test1808376() { + Stroke stroke = new BasicStroke(1.0f); + Stroke outlineStroke = new BasicStroke(2.0f); + ValueMarker m = new ValueMarker(1.0, Color.red, stroke, Color.blue, + outlineStroke, 0.5f); + assertEquals(1.0, m.getValue(), EPSILON); + assertEquals(Color.red, m.getPaint()); + assertEquals(stroke, m.getStroke()); + assertEquals(Color.blue, m.getOutlinePaint()); + assertEquals(outlineStroke, m.getOutlineStroke()); + assertEquals(0.5f, m.getAlpha(), EPSILON); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/XYPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/XYPlotTest.java new file mode 100755 index 0000000..58923c9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/XYPlotTest.java @@ -0,0 +1,1124 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * XYPlotTest.java + * --------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Mar-2003 : Version 1 (DG); + * 22-Mar-2004 : Added new cloning test (DG); + * 05-Oct-2004 : Strengthened test for clone independence (DG); + * 22-Nov-2006 : Added quadrant fields to equals() and clone() tests (DG); + * 09-Jan-2007 : Mark and comment out testGetDatasetCount() (DG); + * 05-Feb-2007 : Added testAddDomainMarker() and testAddRangeMarker() (DG); + * 07-Feb-2007 : Added test1654215() (DG); + * 24-May-2007 : Added testDrawSeriesWithZeroItems() (DG); + * 07-Apr-2008 : Added testRemoveDomainMarker() and + * testRemoveRangeMarker() (DG); + * 10-May-2009 : Extended testEquals(), added testCloning3() (DG); + * 06-Jul-2009 : Added testBug2817504() (DG); + * + */ + +package org.jfree.chart.plot; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.Stroke; +import java.awt.geom.Point2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.Arrays; +import java.util.List; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.annotations.XYTextAnnotation; +import org.jfree.chart.axis.AxisLocation; +import org.jfree.chart.axis.DateAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.event.MarkerChangeListener; +import org.jfree.chart.labels.StandardXYToolTipGenerator; +import org.jfree.chart.renderer.xy.DefaultXYItemRenderer; +import org.jfree.chart.renderer.xy.StandardXYItemRenderer; +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.util.DefaultShadowGenerator; +import org.jfree.data.time.Day; +import org.jfree.data.time.TimeSeries; +import org.jfree.data.time.TimeSeriesCollection; +import org.jfree.data.xy.DefaultXYDataset; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.date.MonthConstants; +import org.jfree.ui.Layer; +import org.jfree.ui.RectangleInsets; +import org.junit.Test; + +/** + * Tests for the {@link XYPlot} class. + */ +public class XYPlotTest { + +// FIXME: the getDatasetCount() method is returning a count of the slots +// available for datasets, rather than the number of datasets actually +// specified...see if there is some way to clean this up. +// /** +// * Added this test in response to a bug report. +// */ +// public void testGetDatasetCount() { +// XYPlot plot = new XYPlot(); +// assertEquals(0, plot.getDatasetCount()); +// } + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + + XYPlot plot1 = new XYPlot(); + XYPlot plot2 = new XYPlot(); + assertTrue(plot1.equals(plot2)); + + // orientation... + plot1.setOrientation(PlotOrientation.HORIZONTAL); + assertFalse(plot1.equals(plot2)); + plot2.setOrientation(PlotOrientation.HORIZONTAL); + assertTrue(plot1.equals(plot2)); + + // axisOffset... + plot1.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05)); + assertFalse(plot1.equals(plot2)); + plot2.setAxisOffset(new RectangleInsets(0.05, 0.05, 0.05, 0.05)); + assertTrue(plot1.equals(plot2)); + + // domainAxis... + plot1.setDomainAxis(new NumberAxis("Domain Axis")); + assertFalse(plot1.equals(plot2)); + plot2.setDomainAxis(new NumberAxis("Domain Axis")); + assertTrue(plot1.equals(plot2)); + + // domainAxisLocation... + plot1.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); + assertFalse(plot1.equals(plot2)); + plot2.setDomainAxisLocation(AxisLocation.TOP_OR_RIGHT); + assertTrue(plot1.equals(plot2)); + + // secondary DomainAxes... + plot1.setDomainAxis(11, new NumberAxis("Secondary Domain Axis")); + assertFalse(plot1.equals(plot2)); + plot2.setDomainAxis(11, new NumberAxis("Secondary Domain Axis")); + assertTrue(plot1.equals(plot2)); + + // secondary DomainAxisLocations... + plot1.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT); + assertFalse(plot1.equals(plot2)); + plot2.setDomainAxisLocation(11, AxisLocation.TOP_OR_RIGHT); + assertTrue(plot1.equals(plot2)); + + // rangeAxis... + plot1.setRangeAxis(new NumberAxis("Range Axis")); + assertFalse(plot1.equals(plot2)); + plot2.setRangeAxis(new NumberAxis("Range Axis")); + assertTrue(plot1.equals(plot2)); + + // rangeAxisLocation... + plot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT); + assertFalse(plot1.equals(plot2)); + plot2.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT); + assertTrue(plot1.equals(plot2)); + + // secondary RangeAxes... + plot1.setRangeAxis(11, new NumberAxis("Secondary Range Axis")); + assertFalse(plot1.equals(plot2)); + plot2.setRangeAxis(11, new NumberAxis("Secondary Range Axis")); + assertTrue(plot1.equals(plot2)); + + // secondary RangeAxisLocations... + plot1.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT); + assertFalse(plot1.equals(plot2)); + plot2.setRangeAxisLocation(11, AxisLocation.TOP_OR_RIGHT); + assertTrue(plot1.equals(plot2)); + + // secondary DatasetDomainAxisMap... + plot1.mapDatasetToDomainAxis(11, 11); + assertFalse(plot1.equals(plot2)); + plot2.mapDatasetToDomainAxis(11, 11); + assertTrue(plot1.equals(plot2)); + + // secondaryDatasetRangeAxisMap... + plot1.mapDatasetToRangeAxis(11, 11); + assertFalse(plot1.equals(plot2)); + plot2.mapDatasetToRangeAxis(11, 11); + assertTrue(plot1.equals(plot2)); + + // renderer + plot1.setRenderer(new DefaultXYItemRenderer()); + assertFalse(plot1.equals(plot2)); + plot2.setRenderer(new DefaultXYItemRenderer()); + assertTrue(plot1.equals(plot2)); + + // secondary renderers + plot1.setRenderer(11, new DefaultXYItemRenderer()); + assertFalse(plot1.equals(plot2)); + plot2.setRenderer(11, new DefaultXYItemRenderer()); + assertTrue(plot1.equals(plot2)); + + // domainGridlinesVisible + plot1.setDomainGridlinesVisible(false); + assertFalse(plot1.equals(plot2)); + plot2.setDomainGridlinesVisible(false); + assertTrue(plot1.equals(plot2)); + + // domainGridlineStroke + Stroke stroke = new BasicStroke(2.0f); + plot1.setDomainGridlineStroke(stroke); + assertFalse(plot1.equals(plot2)); + plot2.setDomainGridlineStroke(stroke); + assertTrue(plot1.equals(plot2)); + + // domainGridlinePaint + plot1.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertFalse(plot1.equals(plot2)); + plot2.setDomainGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertTrue(plot1.equals(plot2)); + + // rangeGridlinesVisible + plot1.setRangeGridlinesVisible(false); + assertFalse(plot1.equals(plot2)); + plot2.setRangeGridlinesVisible(false); + assertTrue(plot1.equals(plot2)); + + // rangeGridlineStroke + plot1.setRangeGridlineStroke(stroke); + assertFalse(plot1.equals(plot2)); + plot2.setRangeGridlineStroke(stroke); + assertTrue(plot1.equals(plot2)); + + // rangeGridlinePaint + plot1.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, + 3.0f, 4.0f, Color.red)); + assertFalse(plot1.equals(plot2)); + plot2.setRangeGridlinePaint(new GradientPaint(1.0f, 2.0f, Color.green, + 3.0f, 4.0f, Color.red)); + assertTrue(plot1.equals(plot2)); + + // rangeZeroBaselineVisible + plot1.setRangeZeroBaselineVisible(true); + assertFalse(plot1.equals(plot2)); + plot2.setRangeZeroBaselineVisible(true); + assertTrue(plot1.equals(plot2)); + + // rangeZeroBaselineStroke + plot1.setRangeZeroBaselineStroke(stroke); + assertFalse(plot1.equals(plot2)); + plot2.setRangeZeroBaselineStroke(stroke); + assertTrue(plot1.equals(plot2)); + + // rangeZeroBaselinePaint + plot1.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.red)); + assertFalse(plot1.equals(plot2)); + plot2.setRangeZeroBaselinePaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.red)); + assertTrue(plot1.equals(plot2)); + + // rangeCrosshairVisible + plot1.setRangeCrosshairVisible(true); + assertFalse(plot1.equals(plot2)); + plot2.setRangeCrosshairVisible(true); + assertTrue(plot1.equals(plot2)); + + // rangeCrosshairValue + plot1.setRangeCrosshairValue(100.0); + assertFalse(plot1.equals(plot2)); + plot2.setRangeCrosshairValue(100.0); + assertTrue(plot1.equals(plot2)); + + // rangeCrosshairStroke + plot1.setRangeCrosshairStroke(stroke); + assertFalse(plot1.equals(plot2)); + plot2.setRangeCrosshairStroke(stroke); + assertTrue(plot1.equals(plot2)); + + // rangeCrosshairPaint + plot1.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.pink, + 3.0f, 4.0f, Color.red)); + assertFalse(plot1.equals(plot2)); + plot2.setRangeCrosshairPaint(new GradientPaint(1.0f, 2.0f, Color.pink, + 3.0f, 4.0f, Color.red)); + assertTrue(plot1.equals(plot2)); + + // rangeCrosshairLockedOnData + plot1.setRangeCrosshairLockedOnData(false); + assertFalse(plot1.equals(plot2)); + plot2.setRangeCrosshairLockedOnData(false); + assertTrue(plot1.equals(plot2)); + + // range markers + plot1.addRangeMarker(new ValueMarker(4.0)); + assertFalse(plot1.equals(plot2)); + plot2.addRangeMarker(new ValueMarker(4.0)); + assertTrue(plot1.equals(plot2)); + + // secondary range markers + plot1.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND); + assertFalse(plot1.equals(plot2)); + plot2.addRangeMarker(1, new ValueMarker(4.0), Layer.FOREGROUND); + assertTrue(plot1.equals(plot2)); + + plot1.addRangeMarker(1, new ValueMarker(99.0), Layer.BACKGROUND); + assertFalse(plot1.equals(plot2)); + plot2.addRangeMarker(1, new ValueMarker(99.0), Layer.BACKGROUND); + assertTrue(plot1.equals(plot2)); + + // fixed legend items + plot1.setFixedLegendItems(new LegendItemCollection()); + assertFalse(plot1.equals(plot2)); + plot2.setFixedLegendItems(new LegendItemCollection()); + assertTrue(plot1.equals(plot2)); + + // weight + plot1.setWeight(3); + assertFalse(plot1.equals(plot2)); + plot2.setWeight(3); + assertTrue(plot1.equals(plot2)); + + // quadrant origin + plot1.setQuadrantOrigin(new Point2D.Double(12.3, 45.6)); + assertFalse(plot1.equals(plot2)); + plot2.setQuadrantOrigin(new Point2D.Double(12.3, 45.6)); + assertTrue(plot1.equals(plot2)); + + // quadrant paint + plot1.setQuadrantPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertFalse(plot1.equals(plot2)); + plot2.setQuadrantPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertTrue(plot1.equals(plot2)); + plot1.setQuadrantPaint(1, new GradientPaint(2.0f, 3.0f, Color.red, + 4.0f, 5.0f, Color.blue)); + assertFalse(plot1.equals(plot2)); + plot2.setQuadrantPaint(1, new GradientPaint(2.0f, 3.0f, Color.red, + 4.0f, 5.0f, Color.blue)); + assertTrue(plot1.equals(plot2)); + plot1.setQuadrantPaint(2, new GradientPaint(3.0f, 4.0f, Color.red, + 5.0f, 6.0f, Color.blue)); + assertFalse(plot1.equals(plot2)); + plot2.setQuadrantPaint(2, new GradientPaint(3.0f, 4.0f, Color.red, + 5.0f, 6.0f, Color.blue)); + assertTrue(plot1.equals(plot2)); + plot1.setQuadrantPaint(3, new GradientPaint(4.0f, 5.0f, Color.red, + 6.0f, 7.0f, Color.blue)); + assertFalse(plot1.equals(plot2)); + plot2.setQuadrantPaint(3, new GradientPaint(4.0f, 5.0f, Color.red, + 6.0f, 7.0f, Color.blue)); + assertTrue(plot1.equals(plot2)); + + plot1.setDomainTickBandPaint(Color.red); + assertFalse(plot1.equals(plot2)); + plot2.setDomainTickBandPaint(Color.red); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeTickBandPaint(Color.blue); + assertFalse(plot1.equals(plot2)); + plot2.setRangeTickBandPaint(Color.blue); + assertTrue(plot1.equals(plot2)); + + plot1.setDomainMinorGridlinesVisible(true); + assertFalse(plot1.equals(plot2)); + plot2.setDomainMinorGridlinesVisible(true); + assertTrue(plot1.equals(plot2)); + + plot1.setDomainMinorGridlinePaint(Color.red); + assertFalse(plot1.equals(plot2)); + plot2.setDomainMinorGridlinePaint(Color.red); + assertTrue(plot1.equals(plot2)); + + plot1.setDomainGridlineStroke(new BasicStroke(1.1f)); + assertFalse(plot1.equals(plot2)); + plot2.setDomainGridlineStroke(new BasicStroke(1.1f)); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeMinorGridlinesVisible(true); + assertFalse(plot1.equals(plot2)); + plot2.setRangeMinorGridlinesVisible(true); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeMinorGridlinePaint(Color.blue); + assertFalse(plot1.equals(plot2)); + plot2.setRangeMinorGridlinePaint(Color.blue); + assertTrue(plot1.equals(plot2)); + + plot1.setRangeMinorGridlineStroke(new BasicStroke(1.23f)); + assertFalse(plot1.equals(plot2)); + plot2.setRangeMinorGridlineStroke(new BasicStroke(1.23f)); + assertTrue(plot1.equals(plot2)); + + List axisIndices = Arrays.asList(new Integer[] {new Integer(0), + new Integer(1)}); + plot1.mapDatasetToDomainAxes(0, axisIndices); + assertFalse(plot1.equals(plot2)); + plot2.mapDatasetToDomainAxes(0, axisIndices); + assertTrue(plot1.equals(plot2)); + + plot1.mapDatasetToRangeAxes(0, axisIndices); + assertFalse(plot1.equals(plot2)); + plot2.mapDatasetToRangeAxes(0, axisIndices); + assertTrue(plot1.equals(plot2)); + + // shadowGenerator + plot1.setShadowGenerator(new DefaultShadowGenerator(5, Color.gray, + 0.6f, 4, -Math.PI / 4)); + assertFalse(plot1.equals(plot2)); + plot2.setShadowGenerator(new DefaultShadowGenerator(5, Color.gray, + 0.6f, 4, -Math.PI / 4)); + assertTrue(plot1.equals(plot2)); + + plot1.setShadowGenerator(null); + assertFalse(plot1.equals(plot2)); + plot2.setShadowGenerator(null); + assertTrue(plot1.equals(plot2)); + + LegendItemCollection lic1 = new LegendItemCollection(); + lic1.add(new LegendItem("XYZ", Color.red)); + plot1.setFixedLegendItems(lic1); + assertFalse(plot1.equals(plot2)); + LegendItemCollection lic2 = new LegendItemCollection(); + lic2.add(new LegendItem("XYZ", Color.red)); + plot2.setFixedLegendItems(lic2); + assertTrue(plot1.equals(plot2)); + } + + /** + * Confirm that basic cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYPlot p1 = new XYPlot(); + XYPlot p2 = (XYPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + } + + /** + * Tests cloning for a more complex plot. + */ + @Test + public void testCloning2() throws CloneNotSupportedException { + XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"), + new NumberAxis("Range Axis"), new StandardXYItemRenderer()); + p1.setRangeAxis(1, new NumberAxis("Range Axis 2")); + List axisIndices = Arrays.asList(new Integer[] {new Integer(0), + new Integer(1)}); + p1.mapDatasetToDomainAxes(0, axisIndices); + p1.mapDatasetToRangeAxes(0, axisIndices); + p1.setRenderer(1, new XYBarRenderer()); + XYPlot p2 = (XYPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + } + + /** + * Tests cloning for a plot where the fixed legend items have been + * specified. + */ + @Test + public void testCloning3() throws CloneNotSupportedException { + XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"), + new NumberAxis("Range Axis"), new StandardXYItemRenderer()); + LegendItemCollection c1 = new LegendItemCollection(); + p1.setFixedLegendItems(c1); + XYPlot p2 = (XYPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // verify independence of fixed legend item collection + c1.add(new LegendItem("X")); + assertFalse(p1.equals(p2)); + } + + /** + * Tests cloning to ensure that the cloned plot is registered as a listener + * on the cloned renderer. + */ + @Test + public void testCloning4() throws CloneNotSupportedException { + XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); + XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"), + new NumberAxis("Range Axis"), r1); + XYPlot p2 = (XYPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // verify that the plot is listening to the cloned renderer + XYLineAndShapeRenderer r2 = (XYLineAndShapeRenderer) p2.getRenderer(); + assertTrue(r2.hasListener(p2)); + } + + /** + * Confirm that cloning captures the quadrantOrigin field. + */ + @Test + public void testCloning_QuadrantOrigin() throws CloneNotSupportedException { + XYPlot p1 = new XYPlot(); + Point2D p = new Point2D.Double(1.2, 3.4); + p1.setQuadrantOrigin(p); + XYPlot p2 = (XYPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + assertTrue(p2.getQuadrantOrigin() != p); + } + + /** + * Confirm that cloning captures the quadrantOrigin field. + */ + @Test + public void testCloning_QuadrantPaint() throws CloneNotSupportedException { + XYPlot p1 = new XYPlot(); + p1.setQuadrantPaint(3, new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + XYPlot p2 = (XYPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // check for independence + p1.setQuadrantPaint(1, Color.red); + assertFalse(p1.equals(p2)); + p2.setQuadrantPaint(1, Color.red); + assertTrue(p1.equals(p2)); + } + + /** + * Renderers that belong to the plot are being cloned but they are + * retaining a reference to the original plot. + */ + @Test + public void testBug2817504() throws CloneNotSupportedException { + XYPlot p1 = new XYPlot(); + XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); + p1.setRenderer(r1); + XYPlot p2 = (XYPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + + // check for independence + XYLineAndShapeRenderer r2 = (XYLineAndShapeRenderer) p2.getRenderer(); + assertTrue(r2.getPlot() == p2); + } + + /** + * Tests the independence of the clones. + */ + @Test + public void testCloneIndependence() throws CloneNotSupportedException { + XYPlot p1 = new XYPlot(null, new NumberAxis("Domain Axis"), + new NumberAxis("Range Axis"), new StandardXYItemRenderer()); + p1.setDomainAxis(1, new NumberAxis("Domain Axis 2")); + p1.setDomainAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); + p1.setRangeAxis(1, new NumberAxis("Range Axis 2")); + p1.setRangeAxisLocation(1, AxisLocation.TOP_OR_RIGHT); + p1.setRenderer(1, new XYBarRenderer()); + XYPlot p2 = (XYPlot) p1.clone(); + assertTrue(p1.equals(p2)); + + p1.getDomainAxis().setLabel("Label"); + assertFalse(p1.equals(p2)); + p2.getDomainAxis().setLabel("Label"); + assertTrue(p1.equals(p2)); + + p1.getDomainAxis(1).setLabel("S1"); + assertFalse(p1.equals(p2)); + p2.getDomainAxis(1).setLabel("S1"); + assertTrue(p1.equals(p2)); + + p1.setDomainAxisLocation(1, AxisLocation.TOP_OR_RIGHT); + assertFalse(p1.equals(p2)); + p2.setDomainAxisLocation(1, AxisLocation.TOP_OR_RIGHT); + assertTrue(p1.equals(p2)); + + p1.mapDatasetToDomainAxis(2, 1); + assertFalse(p1.equals(p2)); + p2.mapDatasetToDomainAxis(2, 1); + assertTrue(p1.equals(p2)); + + p1.getRangeAxis().setLabel("Label"); + assertFalse(p1.equals(p2)); + p2.getRangeAxis().setLabel("Label"); + assertTrue(p1.equals(p2)); + + p1.getRangeAxis(1).setLabel("S1"); + assertFalse(p1.equals(p2)); + p2.getRangeAxis(1).setLabel("S1"); + assertTrue(p1.equals(p2)); + + p1.setRangeAxisLocation(1, AxisLocation.TOP_OR_LEFT); + assertFalse(p1.equals(p2)); + p2.setRangeAxisLocation(1, AxisLocation.TOP_OR_LEFT); + assertTrue(p1.equals(p2)); + + p1.mapDatasetToRangeAxis(2, 1); + assertFalse(p1.equals(p2)); + p2.mapDatasetToRangeAxis(2, 1); + assertTrue(p1.equals(p2)); + + p1.getRenderer().setOutlinePaint(Color.cyan); + assertFalse(p1.equals(p2)); + p2.getRenderer().setOutlinePaint(Color.cyan); + assertTrue(p1.equals(p2)); + + p1.getRenderer(1).setOutlinePaint(Color.red); + assertFalse(p1.equals(p2)); + p2.getRenderer(1).setOutlinePaint(Color.red); + assertTrue(p1.equals(p2)); + + } + + /** + * Setting a null renderer should be allowed, but is generating a null + * pointer exception in 0.9.7. + */ + @Test + public void testSetNullRenderer() { + boolean failed = false; + try { + XYPlot plot = new XYPlot(null, new NumberAxis("X"), + new NumberAxis("Y"), null); + plot.setRenderer(null); + } + catch (Exception e) { + failed = true; + } + assertTrue(!failed); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization1() { + XYDataset data = new XYSeriesCollection(); + NumberAxis domainAxis = new NumberAxis("Domain"); + NumberAxis rangeAxis = new NumberAxis("Range"); + StandardXYItemRenderer renderer = new StandardXYItemRenderer(); + XYPlot p1 = new XYPlot(data, domainAxis, rangeAxis, renderer); + XYPlot p2 = (XYPlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + + /** + * Serialize an instance, restore it, and check for equality. This test + * uses a {@link DateAxis} and a {@link StandardXYToolTipGenerator}. + */ + @Test + public void testSerialization2() { + IntervalXYDataset data1 = createDataset1(); + XYItemRenderer renderer1 = new XYBarRenderer(0.20); + renderer1.setBaseToolTipGenerator( + StandardXYToolTipGenerator.getTimeSeriesInstance()); + XYPlot p1 = new XYPlot(data1, new DateAxis("Date"), null, renderer1); + XYPlot p2 = (XYPlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + + /** + * Problem to reproduce a bug in serialization. The bug (first reported + * against the {@link org.jfree.chart.plot.CategoryPlot} class) is a null + * pointer exception that occurs when drawing a plot after deserialization. + * It is caused by four temporary storage structures (axesAtTop, + * axesAtBottom, axesAtLeft and axesAtRight - all initialized as empty + * lists in the constructor) not being initialized by the readObject() + * method following deserialization. This test has been written to + * reproduce the bug (now fixed). + */ + @Test + public void testSerialization3() { + + XYSeriesCollection dataset = new XYSeriesCollection(); + JFreeChart chart = ChartFactory.createXYLineChart("Test Chart", + "Domain Axis", "Range Axis", dataset); + JFreeChart chart2 = (JFreeChart) TestUtilities.serialised(chart); + assertEquals(chart, chart2); + try { + chart2.createBufferedImage(300, 200); + } + catch (Exception e) { + fail("No exception should be thrown."); + } + } + + /** + * A test to reproduce a bug in serialization: the domain and/or range + * markers for a plot are not being serialized. + */ + @Test + public void testSerialization4() { + + XYSeriesCollection dataset = new XYSeriesCollection(); + JFreeChart chart = ChartFactory.createXYLineChart("Test Chart", + "Domain Axis", "Range Axis", dataset); + XYPlot plot = (XYPlot) chart.getPlot(); + plot.addDomainMarker(new ValueMarker(1.0), Layer.FOREGROUND); + plot.addDomainMarker(new IntervalMarker(2.0, 3.0), Layer.BACKGROUND); + plot.addRangeMarker(new ValueMarker(4.0), Layer.FOREGROUND); + plot.addRangeMarker(new IntervalMarker(5.0, 6.0), Layer.BACKGROUND); + JFreeChart chart2 = (JFreeChart) TestUtilities.serialised(chart); + assertEquals(chart, chart2); + try { + chart2.createBufferedImage(300, 200); + } + catch (Exception e) { + fail("No exception should be thrown."); + } + } + + /** + * Tests a bug where the plot is no longer registered as a listener + * with the dataset(s) and axes after deserialization. See patch 1209475 + * at SourceForge. + */ + @Test + public void testSerialization5() { + XYSeriesCollection dataset1 = new XYSeriesCollection(); + NumberAxis domainAxis1 = new NumberAxis("Domain 1"); + NumberAxis rangeAxis1 = new NumberAxis("Range 1"); + StandardXYItemRenderer renderer1 = new StandardXYItemRenderer(); + XYPlot p1 = new XYPlot(dataset1, domainAxis1, rangeAxis1, renderer1); + NumberAxis domainAxis2 = new NumberAxis("Domain 2"); + NumberAxis rangeAxis2 = new NumberAxis("Range 2"); + StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); + XYSeriesCollection dataset2 = new XYSeriesCollection(); + p1.setDataset(1, dataset2); + p1.setDomainAxis(1, domainAxis2); + p1.setRangeAxis(1, rangeAxis2); + p1.setRenderer(1, renderer2); + XYPlot p2 = (XYPlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + + // now check that all datasets, renderers and axes are being listened + // too... + NumberAxis domainAxisA = (NumberAxis) p2.getDomainAxis(0); + NumberAxis rangeAxisA = (NumberAxis) p2.getRangeAxis(0); + XYSeriesCollection datasetA = (XYSeriesCollection) p2.getDataset(0); + StandardXYItemRenderer rendererA + = (StandardXYItemRenderer) p2.getRenderer(0); + NumberAxis domainAxisB = (NumberAxis) p2.getDomainAxis(1); + NumberAxis rangeAxisB = (NumberAxis) p2.getRangeAxis(1); + XYSeriesCollection datasetB = (XYSeriesCollection) p2.getDataset(1); + StandardXYItemRenderer rendererB + = (StandardXYItemRenderer) p2.getRenderer(1); + assertTrue(datasetA.hasListener(p2)); + assertTrue(domainAxisA.hasListener(p2)); + assertTrue(rangeAxisA.hasListener(p2)); + assertTrue(rendererA.hasListener(p2)); + assertTrue(datasetB.hasListener(p2)); + assertTrue(domainAxisB.hasListener(p2)); + assertTrue(rangeAxisB.hasListener(p2)); + assertTrue(rendererB.hasListener(p2)); + } + + /** + * Some checks for the getRendererForDataset() method. + */ + @Test + public void testGetRendererForDataset() { + XYDataset d0 = new XYSeriesCollection(); + XYDataset d1 = new XYSeriesCollection(); + XYDataset d2 = new XYSeriesCollection(); + XYDataset d3 = new XYSeriesCollection(); // not used by plot + XYItemRenderer r0 = new XYLineAndShapeRenderer(); + XYItemRenderer r2 = new XYLineAndShapeRenderer(); + XYPlot plot = new XYPlot(); + plot.setDataset(0, d0); + plot.setDataset(1, d1); + plot.setDataset(2, d2); + plot.setRenderer(0, r0); + // no renderer 1 + plot.setRenderer(2, r2); + assertEquals(r0, plot.getRendererForDataset(d0)); + assertEquals(r0, plot.getRendererForDataset(d1)); + assertEquals(r2, plot.getRendererForDataset(d2)); + assertEquals(null, plot.getRendererForDataset(d3)); + assertEquals(null, plot.getRendererForDataset(null)); + } + + /** + * Some checks for the getLegendItems() method. + */ + @Test + public void testGetLegendItems() { + // check the case where there is a secondary dataset that doesn't + // have a renderer (i.e. falls back to renderer 0) + XYDataset d0 = createDataset1(); + XYDataset d1 = createDataset2(); + XYItemRenderer r0 = new XYLineAndShapeRenderer(); + XYPlot plot = new XYPlot(); + plot.setDataset(0, d0); + plot.setDataset(1, d1); + plot.setRenderer(0, r0); + LegendItemCollection items = plot.getLegendItems(); + assertEquals(2, items.getItemCount()); + } + + /** + * Creates a sample dataset. + * + * @return Series 1. + */ + private IntervalXYDataset createDataset1() { + + // create dataset 1... + TimeSeries series1 = new TimeSeries("Series 1", Day.class); + series1.add(new Day(1, MonthConstants.MARCH, 2002), 12353.3); + series1.add(new Day(2, MonthConstants.MARCH, 2002), 13734.4); + series1.add(new Day(3, MonthConstants.MARCH, 2002), 14525.3); + series1.add(new Day(4, MonthConstants.MARCH, 2002), 13984.3); + series1.add(new Day(5, MonthConstants.MARCH, 2002), 12999.4); + series1.add(new Day(6, MonthConstants.MARCH, 2002), 14274.3); + series1.add(new Day(7, MonthConstants.MARCH, 2002), 15943.5); + series1.add(new Day(8, MonthConstants.MARCH, 2002), 14845.3); + series1.add(new Day(9, MonthConstants.MARCH, 2002), 14645.4); + series1.add(new Day(10, MonthConstants.MARCH, 2002), 16234.6); + series1.add(new Day(11, MonthConstants.MARCH, 2002), 17232.3); + series1.add(new Day(12, MonthConstants.MARCH, 2002), 14232.2); + series1.add(new Day(13, MonthConstants.MARCH, 2002), 13102.2); + series1.add(new Day(14, MonthConstants.MARCH, 2002), 14230.2); + series1.add(new Day(15, MonthConstants.MARCH, 2002), 11235.2); + + TimeSeriesCollection collection = new TimeSeriesCollection(series1); + return collection; + + } + + /** + * Creates a sample dataset. + * + * @return A sample dataset. + */ + private XYDataset createDataset2() { + // create dataset 1... + XYSeries series = new XYSeries("Series 2"); + XYSeriesCollection collection = new XYSeriesCollection(series); + return collection; + + } + + /** + * A test for a bug where setting the renderer doesn't register the plot + * as a RendererChangeListener. + */ + @Test + public void testSetRenderer() { + XYPlot plot = new XYPlot(); + XYItemRenderer renderer = new XYLineAndShapeRenderer(); + plot.setRenderer(renderer); + // now make a change to the renderer and see if it triggers a plot + // change event... + MyPlotChangeListener listener = new MyPlotChangeListener(); + plot.addChangeListener(listener); + renderer.setSeriesPaint(0, Color.black); + assertTrue(listener.getEvent() != null); + } + + /** + * Some checks for the removeAnnotation() method. + */ + @Test + public void testRemoveAnnotation() { + XYPlot plot = new XYPlot(); + XYTextAnnotation a1 = new XYTextAnnotation("X", 1.0, 2.0); + XYTextAnnotation a2 = new XYTextAnnotation("X", 3.0, 4.0); + XYTextAnnotation a3 = new XYTextAnnotation("X", 1.0, 2.0); + plot.addAnnotation(a1); + plot.addAnnotation(a2); + plot.addAnnotation(a3); + plot.removeAnnotation(a2); + XYTextAnnotation x = (XYTextAnnotation) plot.getAnnotations().get(0); + assertEquals(x, a1); + + // now remove a3, but since a3.equals(a1), this will in fact remove + // a1... + assertTrue(a1.equals(a3)); + plot.removeAnnotation(a3); // actually removes a1 + x = (XYTextAnnotation) plot.getAnnotations().get(0); + assertEquals(x, a3); + } + + /** + * Some tests for the addDomainMarker() method(s). + */ + @Test + public void testAddDomainMarker() { + XYPlot plot = new XYPlot(); + Marker m = new ValueMarker(1.0); + plot.addDomainMarker(m); + List listeners = Arrays.asList(m.getListeners( + MarkerChangeListener.class)); + assertTrue(listeners.contains(plot)); + plot.clearDomainMarkers(); + listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class)); + assertFalse(listeners.contains(plot)); + } + + /** + * Some tests for the addRangeMarker() method(s). + */ + @Test + public void testAddRangeMarker() { + XYPlot plot = new XYPlot(); + Marker m = new ValueMarker(1.0); + plot.addRangeMarker(m); + List listeners = Arrays.asList(m.getListeners( + MarkerChangeListener.class)); + assertTrue(listeners.contains(plot)); + plot.clearRangeMarkers(); + listeners = Arrays.asList(m.getListeners(MarkerChangeListener.class)); + assertFalse(listeners.contains(plot)); + } + + /** + * A test for bug 1654215 (where a renderer is added to the plot without + * a corresponding dataset and it throws an exception at drawing time). + */ + @Test + public void test1654215() { + DefaultXYDataset dataset = new DefaultXYDataset(); + JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", + dataset, PlotOrientation.VERTICAL, true, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setRenderer(1, new XYLineAndShapeRenderer()); + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); + g2.dispose(); + } + catch (Exception e) { + fail("No exception should be thrown."); + } + } + + /** + * A test for drawing range grid lines when there is no primary renderer. + * In 1.0.4, this is throwing a NullPointerException. + */ + @Test + public void testDrawRangeGridlines() { + DefaultXYDataset dataset = new DefaultXYDataset(); + JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", + dataset, PlotOrientation.VERTICAL, true, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setRenderer(null); + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); + g2.dispose(); + } + catch (Exception e) { + fail("No exception should be thrown."); + } + } + + /** + * A test for drawing a plot where a series has zero items. With + * JFreeChart 1.0.5+cvs this was throwing an exception at one point. + */ + @Test + public void testDrawSeriesWithZeroItems() { + DefaultXYDataset dataset = new DefaultXYDataset(); + dataset.addSeries("Series 1", new double[][] {{1.0, 2.0}, {3.0, 4.0}}); + dataset.addSeries("Series 2", new double[][] {{}, {}}); + JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", + dataset, PlotOrientation.VERTICAL, true, false, false); + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); + g2.dispose(); + } + catch (Exception e) { + fail("No exception should be thrown."); + } + } + + /** + * Check that removing a marker that isn't assigned to the plot returns + * false. + */ + @Test + public void testRemoveDomainMarker() { + XYPlot plot = new XYPlot(); + assertFalse(plot.removeDomainMarker(new ValueMarker(0.5))); + } + + /** + * Check that removing a marker that isn't assigned to the plot returns + * false. + */ + @Test + public void testRemoveRangeMarker() { + XYPlot plot = new XYPlot(); + assertFalse(plot.removeRangeMarker(new ValueMarker(0.5))); + } + + /** + * Some tests for the getDomainAxisForDataset() method. + */ + @Test + public void testGetDomainAxisForDataset() { + XYDataset dataset = new XYSeriesCollection(); + NumberAxis xAxis = new NumberAxis("X"); + NumberAxis yAxis = new NumberAxis("Y"); + XYItemRenderer renderer = new DefaultXYItemRenderer(); + XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); + assertEquals(xAxis, plot.getDomainAxisForDataset(0)); + + // should get IllegalArgumentException for negative index + boolean pass = false; + try { + plot.getDomainAxisForDataset(-1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + // should get IllegalArgumentException for index too high + pass = false; + try { + plot.getDomainAxisForDataset(1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + // if multiple axes are mapped, the first in the list should be + // returned... + NumberAxis xAxis2 = new NumberAxis("X2"); + plot.setDomainAxis(1, xAxis2); + assertEquals(xAxis, plot.getDomainAxisForDataset(0)); + + plot.mapDatasetToDomainAxis(0, 1); + assertEquals(xAxis2, plot.getDomainAxisForDataset(0)); + + List axisIndices = Arrays.asList(new Integer[] {new Integer(0), + new Integer(1)}); + plot.mapDatasetToDomainAxes(0, axisIndices); + assertEquals(xAxis, plot.getDomainAxisForDataset(0)); + + axisIndices = Arrays.asList(new Integer[] {new Integer(1), + new Integer(2)}); + plot.mapDatasetToDomainAxes(0, axisIndices); + assertEquals(xAxis2, plot.getDomainAxisForDataset(0)); + } + + /** + * Some tests for the getRangeAxisForDataset() method. + */ + @Test + public void testGetRangeAxisForDataset() { + XYDataset dataset = new XYSeriesCollection(); + NumberAxis xAxis = new NumberAxis("X"); + NumberAxis yAxis = new NumberAxis("Y"); + XYItemRenderer renderer = new DefaultXYItemRenderer(); + XYPlot plot = new XYPlot(dataset, xAxis, yAxis, renderer); + assertEquals(yAxis, plot.getRangeAxisForDataset(0)); + + // should get IllegalArgumentException for negative index + boolean pass = false; + try { + plot.getRangeAxisForDataset(-1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + // should get IllegalArgumentException for index too high + pass = false; + try { + plot.getRangeAxisForDataset(1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + // if multiple axes are mapped, the first in the list should be + // returned... + NumberAxis yAxis2 = new NumberAxis("Y2"); + plot.setRangeAxis(1, yAxis2); + assertEquals(yAxis, plot.getRangeAxisForDataset(0)); + + plot.mapDatasetToRangeAxis(0, 1); + assertEquals(yAxis2, plot.getRangeAxisForDataset(0)); + + List axisIndices = Arrays.asList(new Integer[] {new Integer(0), + new Integer(1)}); + plot.mapDatasetToRangeAxes(0, axisIndices); + assertEquals(yAxis, plot.getRangeAxisForDataset(0)); + + axisIndices = Arrays.asList(new Integer[] {new Integer(1), + new Integer(2)}); + plot.mapDatasetToRangeAxes(0, axisIndices); + assertEquals(yAxis2, plot.getRangeAxisForDataset(0)); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/AbstractDialLayerTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/AbstractDialLayerTest.java new file mode 100755 index 0000000..37ce160 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/AbstractDialLayerTest.java @@ -0,0 +1,107 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * AbstractDialLayerTest.java + * -------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Oct-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link AbstractDialLayer} class. + */ +public class AbstractDialLayerTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DialCap c1 = new DialCap(); + DialCap c2 = new DialCap(); + assertTrue(c1.equals(c2)); + + // visible + c1.setVisible(false); + assertFalse(c1.equals(c2)); + c2.setVisible(false); + assertTrue(c1.equals(c2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + // test a default instance + DialCap c1 = new DialCap(); + DialCap c2 = (DialCap) c1.clone(); + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + + // check that the listener lists are independent + MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); + c1.addChangeListener(l1); + assertTrue(c1.hasListener(l1)); + assertFalse(c2.hasListener(l1)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + // test a default instance + DialCap c1 = new DialCap(); + DialCap c2 = (DialCap) TestUtilities.serialised(c1); + assertEquals(c1, c2); + + // check that the listener lists are independent + MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); + c1.addChangeListener(l1); + assertTrue(c1.hasListener(l1)); + assertFalse(c2.hasListener(l1)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/ArcDialFrameTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/ArcDialFrameTest.java new file mode 100755 index 0000000..fe3efd9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/ArcDialFrameTest.java @@ -0,0 +1,163 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * ArcDialFrameTest.java + * --------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 24-Oct-2007 : Renamed (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link ArcDialFrame} class. + */ +public class ArcDialFrameTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + ArcDialFrame f1 = new ArcDialFrame(); + ArcDialFrame f2 = new ArcDialFrame(); + assertTrue(f1.equals(f2)); + + // background paint + f1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertFalse(f1.equals(f2)); + f2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertTrue(f1.equals(f2)); + + // foreground paint + f1.setForegroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertFalse(f1.equals(f2)); + f2.setForegroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertTrue(f1.equals(f2)); + + // stroke + f1.setStroke(new BasicStroke(1.1f)); + assertFalse(f1.equals(f2)); + f2.setStroke(new BasicStroke(1.1f)); + assertTrue(f1.equals(f2)); + + // inner radius + f1.setInnerRadius(0.11); + assertFalse(f1.equals(f2)); + f2.setInnerRadius(0.11); + assertTrue(f1.equals(f2)); + + // outer radius + f1.setOuterRadius(0.88); + assertFalse(f1.equals(f2)); + f2.setOuterRadius(0.88); + assertTrue(f1.equals(f2)); + + // startAngle + f1.setStartAngle(99); + assertFalse(f1.equals(f2)); + f2.setStartAngle(99); + assertTrue(f1.equals(f2)); + + // extent + f1.setExtent(33); + assertFalse(f1.equals(f2)); + f2.setExtent(33); + assertTrue(f1.equals(f2)); + + // check an inherited attribute + f1.setVisible(false); + assertFalse(f1.equals(f2)); + f2.setVisible(false); + assertTrue(f1.equals(f2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + ArcDialFrame f1 = new ArcDialFrame(); + ArcDialFrame f2 = new ArcDialFrame(); + assertTrue(f1.equals(f2)); + int h1 = f1.hashCode(); + int h2 = f2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ArcDialFrame f1 = new ArcDialFrame(); + ArcDialFrame f2 = (ArcDialFrame) f1.clone(); + assertTrue(f1 != f2); + assertTrue(f1.getClass() == f2.getClass()); + assertTrue(f1.equals(f2)); + + // check that the listener lists are independent + MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); + f1.addChangeListener(l1); + assertTrue(f1.hasListener(l1)); + assertFalse(f2.hasListener(l1)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ArcDialFrame f1 = new ArcDialFrame(); + ArcDialFrame f2 = (ArcDialFrame) TestUtilities.serialised(f1); + assertEquals(f1, f2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialBackgroundTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialBackgroundTest.java new file mode 100755 index 0000000..6ae499b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialBackgroundTest.java @@ -0,0 +1,158 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * DialBackgroundTest.java + * ----------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.ui.GradientPaintTransformType; +import org.jfree.ui.StandardGradientPaintTransformer; +import org.junit.Test; + +/** + * Tests for the {@link DialBackground} class. + */ +public class DialBackgroundTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DialBackground b1 = new DialBackground(); + DialBackground b2 = new DialBackground(); + assertTrue(b1.equals(b2)); + + // paint + b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.yellow)); + assertFalse(b1.equals(b2)); + b2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.yellow)); + assertTrue(b1.equals(b2)); + + // gradient paint transformer + b1.setGradientPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_VERTICAL)); + assertFalse(b1.equals(b2)); + b2.setGradientPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_VERTICAL)); + assertTrue(b1.equals(b2)); + + // check an inherited attribute + b1.setVisible(false); + assertFalse(b1.equals(b2)); + b2.setVisible(false); + assertTrue(b1.equals(b2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + DialBackground b1 = new DialBackground(Color.red); + DialBackground b2 = new DialBackground(Color.red); + assertTrue(b1.equals(b2)); + int h1 = b1.hashCode(); + int h2 = b2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + // test default instance + DialBackground b1 = new DialBackground(); + DialBackground b2 = (DialBackground) b1.clone(); + assertTrue(b1 != b2); + assertTrue(b1.getClass() == b2.getClass()); + assertTrue(b1.equals(b2)); + + // test a customised instance + b1 = new DialBackground(); + b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.green)); + b1.setGradientPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_VERTICAL)); + b2 = (DialBackground) b1.clone(); + assertTrue(b1 != b2); + assertTrue(b1.getClass() == b2.getClass()); + assertTrue(b1.equals(b2)); + + // check that the listener lists are independent + MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); + b1.addChangeListener(l1); + assertTrue(b1.hasListener(l1)); + assertFalse(b2.hasListener(l1)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + // test a default instance + DialBackground b1 = new DialBackground(); + DialBackground b2 = (DialBackground) TestUtilities.serialised(b1); + assertEquals(b1, b2); + + // test a customised instance + b1 = new DialBackground(); + b1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.green)); + b1.setGradientPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_VERTICAL)); + + b2 = (DialBackground) TestUtilities.serialised(b1); + assertEquals(b1, b2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialCapTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialCapTest.java new file mode 100755 index 0000000..16747ed --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialCapTest.java @@ -0,0 +1,172 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * DialCapTest.java + * ---------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + + +/** + * Tests for the {@link DialCap} class. + */ +public class DialCapTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DialCap c1 = new DialCap(); + DialCap c2 = new DialCap(); + assertTrue(c1.equals(c2)); + + // radius + c1.setRadius(0.5); + assertFalse(c1.equals(c2)); + c2.setRadius(0.5); + assertTrue(c1.equals(c2)); + + // fill paint + c1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.green)); + assertFalse(c1.equals(c2)); + c2.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.green)); + + // outline paint + c1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.gray)); + assertFalse(c1.equals(c2)); + c2.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.gray)); + + assertTrue(c1.equals(c2)); + + // outline stroke + c1.setOutlineStroke(new BasicStroke(1.1f)); + assertFalse(c1.equals(c2)); + c2.setOutlineStroke(new BasicStroke(1.1f)); + assertTrue(c1.equals(c2)); + + // check an inherited attribute + c1.setVisible(false); + assertFalse(c1.equals(c2)); + c2.setVisible(false); + assertTrue(c1.equals(c2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + DialCap c1 = new DialCap(); + DialCap c2 = new DialCap(); + assertTrue(c1.equals(c2)); + int h1 = c1.hashCode(); + int h2 = c2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + // test a default instance + DialCap c1 = new DialCap(); + DialCap c2 = (DialCap) c1.clone(); + + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + + // test a customised instance + c1 = new DialCap(); + c1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.green)); + c1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.gray)); + c1.setOutlineStroke(new BasicStroke(2.0f)); + c2 = (DialCap) c1.clone(); + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + + // check that the listener lists are independent + MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); + c1.addChangeListener(l1); + assertTrue(c1.hasListener(l1)); + assertFalse(c2.hasListener(l1)); + } + + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + // test a default instance + DialCap c1 = new DialCap(); + DialCap c2 = (DialCap) TestUtilities.serialised(c1); + assertEquals(c1, c2); + + // test a custom instance + c1 = new DialCap(); + c1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.green)); + c1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.gray)); + c1.setOutlineStroke(new BasicStroke(2.0f)); + + c2 = (DialCap) TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialPlotTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialPlotTest.java new file mode 100755 index 0000000..c6bdf60 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialPlotTest.java @@ -0,0 +1,287 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * DialPlotTest.java + * ----------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; + +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.event.PlotChangeEvent; +import org.jfree.chart.event.PlotChangeListener; +import org.junit.Test; + +/** + * Tests for the {@link DialPlot} class. + */ +public class DialPlotTest implements PlotChangeListener { + + /** The last plot change event received. */ + private PlotChangeEvent lastEvent; + + /** + * Records the last plot change event received. + * + * @param event the event. + */ + @Override + public void plotChanged(PlotChangeEvent event) { + this.lastEvent = event; + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DialPlot p1 = new DialPlot(); + DialPlot p2 = new DialPlot(); + assertTrue(p1.equals(p2)); + + // background + p1.setBackground(new DialBackground(Color.green)); + assertFalse(p1.equals(p2)); + p2.setBackground(new DialBackground(Color.green)); + assertTrue(p1.equals(p2)); + + p1.setBackground(null); + assertFalse(p1.equals(p2)); + p2.setBackground(null); + assertTrue(p1.equals(p2)); + + // dial cap + DialCap cap1 = new DialCap(); + cap1.setFillPaint(Color.red); + p1.setCap(cap1); + assertFalse(p1.equals(p2)); + DialCap cap2 = new DialCap(); + cap2.setFillPaint(Color.red); + p2.setCap(cap2); + assertTrue(p1.equals(p2)); + + p1.setCap(null); + assertFalse(p1.equals(p2)); + p2.setCap(null); + assertTrue(p1.equals(p2)); + + // frame + StandardDialFrame f1 = new StandardDialFrame(); + f1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.white)); + p1.setDialFrame(f1); + assertFalse(p1.equals(p2)); + StandardDialFrame f2 = new StandardDialFrame(); + f2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.white)); + p2.setDialFrame(f2); + assertTrue(p1.equals(p2)); + + // view + p1.setView(0.2, 0.0, 0.8, 1.0); + assertFalse(p1.equals(p2)); + p2.setView(0.2, 0.0, 0.8, 1.0); + assertTrue(p1.equals(p2)); + + // layer + p1.addLayer(new StandardDialScale()); + assertFalse(p1.equals(p2)); + p2.addLayer(new StandardDialScale()); + assertTrue(p1.equals(p2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + DialPlot p1 = new DialPlot(); + DialPlot p2 = new DialPlot(); + assertTrue(p1.equals(p2)); + int h1 = p1.hashCode(); + int h2 = p2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DialPlot p1 = new DialPlot(); + DialPlot p2 = (DialPlot) p1.clone(); + assertTrue(p1 != p2); + assertTrue(p1.getClass() == p2.getClass()); + assertTrue(p1.equals(p2)); + } + + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DialPlot p1 = new DialPlot(); + DialPlot p2 = (DialPlot) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + + /** + * Check the notification event mechanism for the dial background. + */ + @Test + public void testBackgroundListener() { + DialPlot p = new DialPlot(); + DialBackground b1 = new DialBackground(Color.red); + p.setBackground(b1); + p.addChangeListener(this); + this.lastEvent = null; + b1.setPaint(Color.blue); + assertNotNull(this.lastEvent); + + DialBackground b2 = new DialBackground(Color.green); + p.setBackground(b2); + this.lastEvent = null; + b1.setPaint(Color.red); + assertNull(this.lastEvent); + b2.setPaint(Color.red); + assertNotNull(this.lastEvent); + } + + /** + * Check the notification event mechanism for the dial cap. + */ + @Test + public void testCapListener() { + DialPlot p = new DialPlot(); + DialCap c1 = new DialCap(); + p.setCap(c1); + p.addChangeListener(this); + this.lastEvent = null; + c1.setFillPaint(Color.red); + assertNotNull(this.lastEvent); + + DialCap c2 = new DialCap(); + p.setCap(c2); + this.lastEvent = null; + c1.setFillPaint(Color.blue); + assertNull(this.lastEvent); + c2.setFillPaint(Color.green); + assertNotNull(this.lastEvent); + } + + /** + * Check the notification event mechanism for the dial frame. + */ + @Test + public void testFrameListener() { + DialPlot p = new DialPlot(); + ArcDialFrame f1 = new ArcDialFrame(); + p.setDialFrame(f1); + p.addChangeListener(this); + this.lastEvent = null; + f1.setBackgroundPaint(Color.gray); + assertNotNull(this.lastEvent); + + ArcDialFrame f2 = new ArcDialFrame(); + p.setDialFrame(f2); + this.lastEvent = null; + f1.setBackgroundPaint(Color.blue); + assertNull(this.lastEvent); + f2.setBackgroundPaint(Color.green); + assertNotNull(this.lastEvent); + } + + /** + * Check the notification event mechanism for the dial scales. + */ + @Test + public void testScaleListener() { + DialPlot p = new DialPlot(); + StandardDialScale s1 = new StandardDialScale(); + p.addScale(0, s1); + p.addChangeListener(this); + this.lastEvent = null; + s1.setStartAngle(22.0); + assertNotNull(this.lastEvent); + + StandardDialScale s2 = new StandardDialScale(); + p.addScale(0, s2); + this.lastEvent = null; + s1.setStartAngle(33.0); + assertNull(this.lastEvent); + s2.setStartAngle(33.0); + assertNotNull(this.lastEvent); + } + + /** + * Check the notification event mechanism for a layer. + */ + @Test + public void testLayerListener() { + DialPlot p = new DialPlot(); + DialBackground b1 = new DialBackground(Color.red); + p.addLayer(b1); + p.addChangeListener(this); + this.lastEvent = null; + b1.setPaint(Color.blue); + assertNotNull(this.lastEvent); + + DialBackground b2 = new DialBackground(Color.green); + p.addLayer(b2); + this.lastEvent = null; + b1.setPaint(Color.red); + assertNotNull(this.lastEvent); + b2.setPaint(Color.green); + assertNotNull(this.lastEvent); + + p.removeLayer(b2); + this.lastEvent = null; + b2.setPaint(Color.red); + assertNull(this.lastEvent); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialPointerTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialPointerTest.java new file mode 100755 index 0000000..dd69a0c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialPointerTest.java @@ -0,0 +1,173 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * DialPointerTest.java + * -------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Apr-2007 : Version 1 (DG); + * 23-Nov-2007 : Added testEqualsPointer() and testSerialization2() (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link DialPointer} class. + */ +public class DialPointerTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DialPointer i1 = new DialPointer.Pin(1); + DialPointer i2 = new DialPointer.Pin(1); + assertTrue(i1.equals(i2)); + + // dataset index + i1 = new DialPointer.Pin(2); + assertFalse(i1.equals(i2)); + i2 = new DialPointer.Pin(2); + assertTrue(i1.equals(i2)); + + // check an inherited attribute + i1.setVisible(false); + assertFalse(i1.equals(i2)); + i2.setVisible(false); + assertTrue(i1.equals(i2)); + } + + /** + * Check the equals() method for the DialPointer.Pin class. + */ + @Test + public void testEqualsPin() { + DialPointer.Pin p1 = new DialPointer.Pin(); + DialPointer.Pin p2 = new DialPointer.Pin(); + assertEquals(p1, p2); + + p1.setPaint(Color.green); + assertFalse(p1.equals(p2)); + p2.setPaint(Color.green); + assertTrue(p1.equals(p2)); + + BasicStroke s = new BasicStroke(4.4f); + p1.setStroke(s); + assertFalse(p1.equals(p2)); + p2.setStroke(s); + assertTrue(p1.equals(p2)); + } + + /** + * Check the equals() method for the DialPointer.Pointer class. + */ + @Test + public void testEqualsPointer() { + DialPointer.Pointer p1 = new DialPointer.Pointer(); + DialPointer.Pointer p2 = new DialPointer.Pointer(); + assertEquals(p1, p2); + + p1.setFillPaint(Color.green); + assertFalse(p1.equals(p2)); + p2.setFillPaint(Color.green); + assertTrue(p1.equals(p2)); + + p1.setOutlinePaint(Color.green); + assertFalse(p1.equals(p2)); + p2.setOutlinePaint(Color.green); + assertTrue(p1.equals(p2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + DialPointer i1 = new DialPointer.Pin(1); + DialPointer i2 = new DialPointer.Pin(1); + assertTrue(i1.equals(i2)); + int h1 = i1.hashCode(); + int h2 = i2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DialPointer i1 = new DialPointer.Pin(1); + DialPointer i2 = (DialPointer) i1.clone(); + assertTrue(i1 != i2); + assertTrue(i1.getClass() == i2.getClass()); + assertTrue(i1.equals(i2)); + + // check that the listener lists are independent + MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); + i1.addChangeListener(l1); + assertTrue(i1.hasListener(l1)); + assertFalse(i2.hasListener(l1)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + // test a default instance + DialPointer i1 = new DialPointer.Pin(1); + DialPointer i2 = (DialPointer) TestUtilities.serialised(i1); + assertEquals(i1, i2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization2() { + DialPointer i1 = new DialPointer.Pointer(1); + DialPointer i2 = (DialPointer) TestUtilities.serialised(i1); + assertEquals(i1, i2); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialTextAnnotationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialTextAnnotationTest.java new file mode 100755 index 0000000..0f4ef63 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialTextAnnotationTest.java @@ -0,0 +1,158 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * DialTextAnnotationTest.java + * --------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link DialTextAnnotation} class. + */ +public class DialTextAnnotationTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DialTextAnnotation a1 = new DialTextAnnotation("A1"); + DialTextAnnotation a2 = new DialTextAnnotation("A1"); + assertTrue(a1.equals(a2)); + + // angle + a1.setAngle(1.1); + assertFalse(a1.equals(a2)); + a2.setAngle(1.1); + assertTrue(a1.equals(a2)); + + // radius + a1.setRadius(9.9); + assertFalse(a1.equals(a2)); + a2.setRadius(9.9); + assertTrue(a1.equals(a2)); + + // font + Font f = new Font("SansSerif", Font.PLAIN, 14); + a1.setFont(f); + assertFalse(a1.equals(a2)); + a2.setFont(f); + assertTrue(a1.equals(a2)); + + // paint + a1.setPaint(Color.red); + assertFalse(a1.equals(a2)); + a2.setPaint(Color.red); + assertTrue(a1.equals(a2)); + + // label + a1.setLabel("ABC"); + assertFalse(a1.equals(a2)); + a2.setLabel("ABC"); + assertTrue(a1.equals(a2)); + + // check an inherited attribute + a1.setVisible(false); + assertFalse(a1.equals(a2)); + a2.setVisible(false); + assertTrue(a1.equals(a2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + DialTextAnnotation a1 = new DialTextAnnotation("A1"); + DialTextAnnotation a2 = new DialTextAnnotation("A1"); + assertTrue(a1.equals(a2)); + int h1 = a1.hashCode(); + int h2 = a2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + // test a default instance + DialTextAnnotation a1 = new DialTextAnnotation("A1"); + DialTextAnnotation a2 = (DialTextAnnotation) a1.clone(); + assertTrue(a1 != a2); + assertTrue(a1.getClass() == a2.getClass()); + assertTrue(a1.equals(a2)); + + // check that the listener lists are independent + MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); + a1.addChangeListener(l1); + assertTrue(a1.hasListener(l1)); + assertFalse(a2.hasListener(l1)); + } + + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + // test a default instance + DialTextAnnotation a1 = new DialTextAnnotation("A1"); + DialTextAnnotation a2 = (DialTextAnnotation) TestUtilities.serialised(a1); + assertEquals(a1, a2); + + // test a custom instance + a1 = new DialTextAnnotation("A1"); + a1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue)); + + a2 = (DialTextAnnotation) TestUtilities.serialised(a1); + assertEquals(a1, a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialValueIndicatorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialValueIndicatorTest.java new file mode 100755 index 0000000..061b9d0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/DialValueIndicatorTest.java @@ -0,0 +1,209 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * DialValueIndicatorTest.java + * --------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 24-Oct-2007 : Updated for API changes (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.RectangleInsets; +import org.jfree.ui.TextAnchor; +import org.junit.Test; + +/** + * Tests for the {@link DialValueIndicator} class. + */ +public class DialValueIndicatorTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DialValueIndicator i1 = new DialValueIndicator(0); + DialValueIndicator i2 = new DialValueIndicator(0); + assertTrue(i1.equals(i2)); + + // dataset index + i1.setDatasetIndex(99); + assertFalse(i1.equals(i2)); + i2.setDatasetIndex(99); + assertTrue(i1.equals(i2)); + + // angle + i1.setAngle(43); + assertFalse(i1.equals(i2)); + i2.setAngle(43); + assertTrue(i1.equals(i2)); + + // radius + i1.setRadius(0.77); + assertFalse(i1.equals(i2)); + i2.setRadius(0.77); + assertTrue(i1.equals(i2)); + + // frameAnchor + i1.setFrameAnchor(RectangleAnchor.TOP_LEFT); + assertFalse(i1.equals(i2)); + i2.setFrameAnchor(RectangleAnchor.TOP_LEFT); + assertTrue(i1.equals(i2)); + + // templateValue + i1.setTemplateValue(new Double(1.23)); + assertFalse(i1.equals(i2)); + i2.setTemplateValue(new Double(1.23)); + assertTrue(i1.equals(i2)); + + // font + i1.setFont(new Font("Dialog", Font.PLAIN, 7)); + assertFalse(i1.equals(i2)); + i2.setFont(new Font("Dialog", Font.PLAIN, 7)); + assertTrue(i1.equals(i2)); + + // paint + i1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.green)); + assertFalse(i1.equals(i2)); + i2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.green)); + assertTrue(i1.equals(i2)); + + // backgroundPaint + i1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.green)); + assertFalse(i1.equals(i2)); + i2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.green)); + assertTrue(i1.equals(i2)); + + // outlineStroke + i1.setOutlineStroke(new BasicStroke(1.1f)); + assertFalse(i1.equals(i2)); + i2.setOutlineStroke(new BasicStroke(1.1f)); + assertTrue(i1.equals(i2)); + + // outlinePaint + i1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.green)); + assertFalse(i1.equals(i2)); + i2.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.green)); + assertTrue(i1.equals(i2)); + + // insets + i1.setInsets(new RectangleInsets(1, 2, 3, 4)); + assertFalse(i1.equals(i2)); + i2.setInsets(new RectangleInsets(1, 2, 3, 4)); + assertTrue(i1.equals(i2)); + + // valueAnchor + i1.setValueAnchor(RectangleAnchor.BOTTOM_LEFT); + assertFalse(i1.equals(i2)); + i2.setValueAnchor(RectangleAnchor.BOTTOM_LEFT); + assertTrue(i1.equals(i2)); + + // textAnchor + i1.setTextAnchor(TextAnchor.TOP_LEFT); + assertFalse(i1.equals(i2)); + i2.setTextAnchor(TextAnchor.TOP_LEFT); + assertTrue(i1.equals(i2)); + + // check an inherited attribute + i1.setVisible(false); + assertFalse(i1.equals(i2)); + i2.setVisible(false); + assertTrue(i1.equals(i2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + DialValueIndicator i1 = new DialValueIndicator(0); + DialValueIndicator i2 = new DialValueIndicator(0); + assertTrue(i1.equals(i2)); + int h1 = i1.hashCode(); + int h2 = i2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + // test a default instance + DialValueIndicator i1 = new DialValueIndicator(0); + DialValueIndicator i2 = (DialValueIndicator) i1.clone(); + assertTrue(i1 != i2); + assertTrue(i1.getClass() == i2.getClass()); + assertTrue(i1.equals(i2)); + + // check that the listener lists are independent + MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); + i1.addChangeListener(l1); + assertTrue(i1.hasListener(l1)); + assertFalse(i2.hasListener(l1)); + } + + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DialValueIndicator i1 = new DialValueIndicator(0); + DialValueIndicator i2 = (DialValueIndicator) + TestUtilities.serialised(i1); + assertEquals(i1, i2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/MyDialLayerChangeListener.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/MyDialLayerChangeListener.java new file mode 100755 index 0000000..c74f61c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/MyDialLayerChangeListener.java @@ -0,0 +1,63 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * MyDialLayerChangeListener.java + * ------------------------------ + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Oct-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot.dial; + +/** + * A dial layer change listener. + */ +public class MyDialLayerChangeListener implements DialLayerChangeListener { + + /** + * Creates a new instance. + */ + public MyDialLayerChangeListener() { + } + + /** + * Receives a change event. + * + * @param event the event. + */ + @Override + public void dialLayerChanged(DialLayerChangeEvent event) { + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/StandardDialFrameTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/StandardDialFrameTest.java new file mode 100755 index 0000000..6b385f6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/StandardDialFrameTest.java @@ -0,0 +1,145 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * StandardDialFrameTest.java + * -------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 29-Oct-2007 : Renamed StandardDialFrameTests (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link StandardDialFrame} class. + */ +public class StandardDialFrameTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + StandardDialFrame f1 = new StandardDialFrame(); + StandardDialFrame f2 = new StandardDialFrame(); + assertTrue(f1.equals(f2)); + + // radius + f1.setRadius(0.2); + assertFalse(f1.equals(f2)); + f2.setRadius(0.2); + assertTrue(f1.equals(f2)); + + // backgroundPaint + f1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, + 4.0f, Color.yellow)); + assertFalse(f1.equals(f2)); + f2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.white, 3.0f, + 4.0f, Color.yellow)); + assertTrue(f1.equals(f2)); + + // foregroundPaint + f1.setForegroundPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, + 4.0f, Color.green)); + assertFalse(f1.equals(f2)); + f2.setForegroundPaint(new GradientPaint(1.0f, 2.0f, Color.blue, 3.0f, + 4.0f, Color.green)); + assertTrue(f1.equals(f2)); + + // stroke + f1.setStroke(new BasicStroke(2.4f)); + assertFalse(f1.equals(f2)); + f2.setStroke(new BasicStroke(2.4f)); + assertTrue(f1.equals(f2)); + + // check an inherited attribute + f1.setVisible(false); + assertFalse(f1.equals(f2)); + f2.setVisible(false); + assertTrue(f1.equals(f2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + StandardDialFrame f1 = new StandardDialFrame(); + StandardDialFrame f2 = new StandardDialFrame(); + assertTrue(f1.equals(f2)); + int h1 = f1.hashCode(); + int h2 = f2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StandardDialFrame f1 = new StandardDialFrame(); + StandardDialFrame f2 = (StandardDialFrame) f1.clone(); + assertTrue(f1 != f2); + assertTrue(f1.getClass() == f2.getClass()); + assertTrue(f1.equals(f2)); + + // check that the listener lists are independent + MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); + f1.addChangeListener(l1); + assertTrue(f1.hasListener(l1)); + assertFalse(f2.hasListener(l1)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardDialFrame f1 = new StandardDialFrame(); + StandardDialFrame f2 = (StandardDialFrame) TestUtilities.serialised(f1); + assertEquals(f1, f2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/StandardDialRangeTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/StandardDialRangeTest.java new file mode 100755 index 0000000..f4736af --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/StandardDialRangeTest.java @@ -0,0 +1,135 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * SimpleDialRangeTest.java + * ------------------------ + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * + */ + +package org.jfree.chart.plot.dial; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link StandardDialRange} class. + */ +public class StandardDialRangeTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + StandardDialRange r1 = new StandardDialRange(); + StandardDialRange r2 = new StandardDialRange(); + assertTrue(r1.equals(r2)); + + // lowerBound + r1.setLowerBound(1.1); + assertFalse(r1.equals(r2)); + r2.setLowerBound(1.1); + assertTrue(r1.equals(r2)); + + // upperBound + r1.setUpperBound(11.1); + assertFalse(r1.equals(r2)); + r2.setUpperBound(11.1); + assertTrue(r1.equals(r2)); + + // paint + r1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue)); + assertFalse(r1.equals(r2)); + r2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue)); + assertTrue(r1.equals(r2)); + + // check an inherited attribute + r1.setVisible(false); + assertFalse(r1.equals(r2)); + r2.setVisible(false); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + StandardDialRange r1 = new StandardDialRange(); + StandardDialRange r2 = new StandardDialRange(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StandardDialRange r1 = new StandardDialRange(); + StandardDialRange r2 = (StandardDialRange) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // check that the listener lists are independent + MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); + r1.addChangeListener(l1); + assertTrue(r1.hasListener(l1)); + assertFalse(r2.hasListener(l1)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardDialRange r1 = new StandardDialRange(); + StandardDialRange r2 = (StandardDialRange) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/StandardDialScaleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/StandardDialScaleTest.java new file mode 100755 index 0000000..1a1906e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/dial/StandardDialScaleTest.java @@ -0,0 +1,272 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * StandardDialScaleTest.java + * -------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Nov-2006 : Version 1 (DG); + * 24-Oct-2007 : Updated for API changes (DG); + * 08-Jan-2012 : Added tests for valueToAngle() and angleToValue(); + * + */ + +package org.jfree.chart.plot.dial; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link StandardDialScale} class. + */ +public class StandardDialScaleTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + StandardDialScale s1 = new StandardDialScale(); + StandardDialScale s2 = new StandardDialScale(); + assertTrue(s1.equals(s2)); + + // lowerBound + s1 = new StandardDialScale(10.0, 100.0, 0.0, 270.0, 10.0, 4); + assertFalse(s1.equals(s2)); + s2 = new StandardDialScale(10.0, 100.0, 0.0, 270.0, 10.0, 4); + assertTrue(s1.equals(s2)); + + // upperBound + s1 = new StandardDialScale(10.0, 200.0, 0.0, 270.0, 10.0, 4); + assertFalse(s1.equals(s2)); + s2 = new StandardDialScale(10.0, 200.0, 0.0, 270.0, 10.0, 4); + assertTrue(s1.equals(s2)); + + // startAngle + s1 = new StandardDialScale(10.0, 200.0, 20.0, 270.0, 10.0, 4); + assertFalse(s1.equals(s2)); + s2 = new StandardDialScale(10.0, 200.0, 20.0, 270.0, 10.0, 4); + assertTrue(s1.equals(s2)); + + // extent + s1 = new StandardDialScale(10.0, 200.0, 20.0, 99.0, 10.0, 4); + assertFalse(s1.equals(s2)); + s2 = new StandardDialScale(10.0, 200.0, 20.0, 99.0, 10.0, 4); + assertTrue(s1.equals(s2)); + + // tickRadius + s1.setTickRadius(0.99); + assertFalse(s1.equals(s2)); + s2.setTickRadius(0.99); + assertTrue(s1.equals(s2)); + + // majorTickIncrement + s1.setMajorTickIncrement(11.1); + assertFalse(s1.equals(s2)); + s2.setMajorTickIncrement(11.1); + assertTrue(s1.equals(s2)); + + // majorTickLength + s1.setMajorTickLength(0.09); + assertFalse(s1.equals(s2)); + s2.setMajorTickLength(0.09); + assertTrue(s1.equals(s2)); + + // majorTickPaint + s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertFalse(s1.equals(s2)); + s2.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertTrue(s1.equals(s2)); + + // majorTickStroke + s1.setMajorTickStroke(new BasicStroke(1.1f)); + assertFalse(s1.equals(s2)); + s2.setMajorTickStroke(new BasicStroke(1.1f)); + assertTrue(s1.equals(s2)); + + // minorTickCount + s1.setMinorTickCount(7); + assertFalse(s1.equals(s2)); + s2.setMinorTickCount(7); + assertTrue(s1.equals(s2)); + + // minorTickLength + s1.setMinorTickLength(0.09); + assertFalse(s1.equals(s2)); + s2.setMinorTickLength(0.09); + assertTrue(s1.equals(s2)); + + // tickLabelOffset + s1.setTickLabelOffset(0.11); + assertFalse(s1.equals(s2)); + s2.setTickLabelOffset(0.11); + assertTrue(s1.equals(s2)); + + // tickLabelFont + s1.setTickLabelFont(new Font("Dialog", Font.PLAIN, 15)); + assertFalse(s1.equals(s2)); + s2.setTickLabelFont(new Font("Dialog", Font.PLAIN, 15)); + assertTrue(s1.equals(s2)); + + // tickLabelPaint + s1.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.green)); + assertFalse(s1.equals(s2)); + s2.setTickLabelPaint(new GradientPaint(1.0f, 2.0f, Color.white, + 3.0f, 4.0f, Color.green)); + assertTrue(s1.equals(s2)); + + s1.setTickLabelsVisible(false); + assertFalse(s1.equals(s2)); + s2.setTickLabelsVisible(false); + assertTrue(s1.equals(s2)); + + // check an inherited attribute + s1.setVisible(false); + assertFalse(s1.equals(s2)); + s2.setVisible(false); + assertTrue(s1.equals(s2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + StandardDialScale s1 = new StandardDialScale(); + StandardDialScale s2 = new StandardDialScale(); + assertTrue(s1.equals(s2)); + int h1 = s1.hashCode(); + int h2 = s2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + // try a default instance + StandardDialScale s1 = new StandardDialScale(); + StandardDialScale s2 = (StandardDialScale) s1.clone(); + assertTrue(s1 != s2); + assertTrue(s1.getClass() == s2.getClass()); + assertTrue(s1.equals(s2)); + + // try a customised instance + s1 = new StandardDialScale(); + s1.setExtent(123.4); + s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.white)); + s1.setMajorTickStroke(new BasicStroke(2.0f)); + s2 = (StandardDialScale) s1.clone(); + assertTrue(s1 != s2); + assertTrue(s1.getClass() == s2.getClass()); + assertTrue(s1.equals(s2)); + + // check that the listener lists are independent + MyDialLayerChangeListener l1 = new MyDialLayerChangeListener(); + s1.addChangeListener(l1); + assertTrue(s1.hasListener(l1)); + assertFalse(s2.hasListener(l1)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + // try a default instance + StandardDialScale s1 = new StandardDialScale(); + StandardDialScale s2 = (StandardDialScale) TestUtilities.serialised(s1); + assertEquals(s1, s2); + + // try a customised instance + s1 = new StandardDialScale(); + s1.setExtent(123.4); + s1.setMajorTickPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.white)); + s1.setMajorTickStroke(new BasicStroke(2.0f)); + + s2 = (StandardDialScale) TestUtilities.serialised(s1); + assertEquals(s1, s2); + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the valueToAngle() method. + */ + @Test + public void testValueToAngle() { + StandardDialScale s = new StandardDialScale(); + assertEquals(175.0, s.valueToAngle(0.0), EPSILON); + assertEquals(90.0, s.valueToAngle(50.0), EPSILON); + assertEquals(5.0, s.valueToAngle(100.0), EPSILON); + assertEquals(192.0, s.valueToAngle(-10.0), EPSILON); + assertEquals(-12.0, s.valueToAngle(110.0), EPSILON); + + s = new StandardDialScale(0, 20, 180, -180.0, 10, 3); + assertEquals(180.0, s.valueToAngle(0.0), EPSILON); + assertEquals(90.0, s.valueToAngle(10.0), EPSILON); + assertEquals(0.0, s.valueToAngle(20.0), EPSILON); + } + + /** + * Some checks for the angleToValue() method. + */ + @Test + public void testAngleToValue() { + StandardDialScale s = new StandardDialScale(); + assertEquals(0.0, s.angleToValue(175.0), EPSILON); + assertEquals(50.0, s.angleToValue(90.0), EPSILON); + assertEquals(100.0, s.angleToValue(5.0), EPSILON); + assertEquals(-10.0, s.angleToValue(192.0), EPSILON); + assertEquals(110.0, s.angleToValue(-12.0), EPSILON); + + s = new StandardDialScale(0, 20, 180, -180.0, 10, 3); + assertEquals(0.0, s.angleToValue(180.0), EPSILON); + assertEquals(10.0, s.angleToValue(90.0), EPSILON); + assertEquals(20.0, s.angleToValue(0.0), EPSILON); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/package.html new file mode 100755 index 0000000..328b746 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/plot/package.html @@ -0,0 +1,6 @@ + + + +JUnit tests for the plot classes. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/AbstractRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/AbstractRendererTest.java new file mode 100755 index 0000000..2958276 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/AbstractRendererTest.java @@ -0,0 +1,997 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * AbstractRendererTest.java + * ------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Oct-2003 : Version 1 (DG); + * 01-Mar-2004 : Added serialization test (DG); + * 19-Feb-2007 : Added testCloning (DG); + * 28-Feb-2007 : Added checks for cloning (DG); + * 17-Jun-2008 : Added new fields to testEquals() and testCloning() (DG); + * 28-Jan-2009 : Updated testEquals() (DG); + * 28-Apr-2009 : Updated testEquals() (DG); + * + */ + +package org.jfree.chart.renderer; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.Rectangle; +import java.awt.Shape; +import java.awt.Stroke; +import java.awt.geom.Ellipse2D; +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.event.RendererChangeListener; +import org.jfree.chart.labels.ItemLabelAnchor; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.DefaultDrawingSupplier; +import org.jfree.chart.renderer.category.BarRenderer; +import org.jfree.chart.renderer.category.LineAndShapeRenderer; +import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer; +import org.jfree.ui.TextAnchor; +import org.junit.Test; + +/** + * Tests for the {@link AbstractRenderer} class. + */ +public class AbstractRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + // have to use a concrete subclass... + BarRenderer r1 = new BarRenderer(); + BarRenderer r2 = new BarRenderer(); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + // seriesVisible + r1.setSeriesVisible(Boolean.TRUE); + assertFalse(r1.equals(r2)); + r2.setSeriesVisible(Boolean.TRUE); + assertTrue(r1.equals(r2)); + + // seriesVisibleList + r1.setSeriesVisible(2, Boolean.TRUE); + assertFalse(r1.equals(r2)); + r2.setSeriesVisible(2, Boolean.TRUE); + assertTrue(r1.equals(r2)); + + // baseSeriesVisible + r1.setBaseSeriesVisible(false); + assertFalse(r1.equals(r2)); + r2.setBaseSeriesVisible(false); + assertTrue(r1.equals(r2)); + + // seriesVisibleInLegend + r1.setSeriesVisibleInLegend(Boolean.TRUE); + assertFalse(r1.equals(r2)); + r2.setSeriesVisibleInLegend(Boolean.TRUE); + assertTrue(r1.equals(r2)); + + // seriesVisibleInLegendList + r1.setSeriesVisibleInLegend(1, Boolean.TRUE); + assertFalse(r1.equals(r2)); + r2.setSeriesVisibleInLegend(1, Boolean.TRUE); + assertTrue(r1.equals(r2)); + + // baseSeriesVisibleInLegend + r1.setBaseSeriesVisibleInLegend(false); + assertFalse(r1.equals(r2)); + r2.setBaseSeriesVisibleInLegend(false); + assertTrue(r1.equals(r2)); + + // paint + r1.setPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertFalse(r1.equals(r2)); + r2.setPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertTrue(r1.equals(r2)); + + // paintList + r1.setSeriesPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.white)); + assertFalse(r1.equals(r2)); + r2.setSeriesPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.white)); + assertTrue(r1.equals(r2)); + + // basePaint + r1.setBasePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertFalse(r1.equals(r2)); + r2.setBasePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertTrue(r1.equals(r2)); + + // fillPaint + r1.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertFalse(r1.equals(r2)); + r2.setFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertTrue(r1.equals(r2)); + + // fillPaintList + r1.setSeriesFillPaint(0, new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertFalse(r1.equals(r2)); + r2.setSeriesFillPaint(0, new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertTrue(r1.equals(r2)); + + // baseFillPaint + r1.setBaseFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertFalse(r1.equals(r2)); + r2.setBaseFillPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertTrue(r1.equals(r2)); + + // outlinePaint + r1.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertFalse(r1.equals(r2)); + r2.setOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertTrue(r1.equals(r2)); + + // outlinePaintList + r1.setSeriesOutlinePaint(0, new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertFalse(r1.equals(r2)); + r2.setSeriesOutlinePaint(0, new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertTrue(r1.equals(r2)); + + // baseOutlinePaint + r1.setBaseOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertFalse(r1.equals(r2)); + r2.setBaseOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertTrue(r1.equals(r2)); + + // stroke + Stroke s = new BasicStroke(3.21f); + r1.setStroke(s); + assertFalse(r1.equals(r2)); + r2.setStroke(s); + assertTrue(r1.equals(r2)); + + // strokeList + r1.setSeriesStroke(1, s); + assertFalse(r1.equals(r2)); + r2.setSeriesStroke(1, s); + assertTrue(r1.equals(r2)); + + // baseStroke + r1.setBaseStroke(s); + assertFalse(r1.equals(r2)); + r2.setBaseStroke(s); + assertTrue(r1.equals(r2)); + + // outlineStroke + r1.setOutlineStroke(s); + assertFalse(r1.equals(r2)); + r2.setOutlineStroke(s); + assertTrue(r1.equals(r2)); + + // outlineStrokeList + r1.setSeriesOutlineStroke(0, s); + assertFalse(r1.equals(r2)); + r2.setSeriesOutlineStroke(0, s); + assertTrue(r1.equals(r2)); + + // baseOutlineStroke + r1.setBaseOutlineStroke(s); + assertFalse(r1.equals(r2)); + r2.setBaseOutlineStroke(s); + assertTrue(r1.equals(r2)); + + // shape + r1.setShape(new Ellipse2D.Double(1, 2, 3, 4)); + assertFalse(r1.equals(r2)); + r2.setShape(new Ellipse2D.Double(1, 2, 3, 4)); + assertTrue(r1.equals(r2)); + + // shapeList + r1.setSeriesShape(1, new Ellipse2D.Double(1, 2, 3, 4)); + assertFalse(r1.equals(r2)); + r2.setSeriesShape(1, new Ellipse2D.Double(1, 2, 3, 4)); + assertTrue(r1.equals(r2)); + + // baseShape + r1.setBaseShape(new Ellipse2D.Double(1, 2, 3, 4)); + assertFalse(r1.equals(r2)); + r2.setBaseShape(new Ellipse2D.Double(1, 2, 3, 4)); + assertTrue(r1.equals(r2)); + + // itemLabelsVisible + r1.setItemLabelsVisible(true); + assertFalse(r1.equals(r2)); + r2.setItemLabelsVisible(true); + assertTrue(r1.equals(r2)); + + // itemLabelsVisibleList + r1.setSeriesItemLabelsVisible(1, Boolean.TRUE); + assertFalse(r1.equals(r2)); + r2.setSeriesItemLabelsVisible(1, Boolean.TRUE); + assertTrue(r1.equals(r2)); + + // baseItemLabelsVisible + r1.setBaseItemLabelsVisible(true); + assertFalse(r1.equals(r2)); + r2.setBaseItemLabelsVisible(true); + assertTrue(r1.equals(r2)); + + // itemLabelFont + r1.setItemLabelFont(new Font("Serif", Font.PLAIN, 10)); + assertFalse(r1.equals(r2)); + r2.setItemLabelFont(new Font("Serif", Font.PLAIN, 10)); + assertTrue(r1.equals(r2)); + + // itemLabelFontList + r1.setSeriesItemLabelFont(1, new Font("Serif", Font.BOLD, 9)); + assertFalse(r1.equals(r2)); + r2.setSeriesItemLabelFont(1, new Font("Serif", Font.BOLD, 9)); + assertTrue(r1.equals(r2)); + + // baseItemLabelFont + r1.setBaseItemLabelFont(new Font("Serif", Font.PLAIN, 10)); + assertFalse(r1.equals(r2)); + r2.setBaseItemLabelFont(new Font("Serif", Font.PLAIN, 10)); + assertTrue(r1.equals(r2)); + + // itemLabelPaint + r1.setItemLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.gray)); + assertFalse(r1.equals(r2)); + r2.setItemLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.gray)); + assertTrue(r1.equals(r2)); + + // itemLabelPaintList + r1.setSeriesItemLabelPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.gray)); + assertFalse(r1.equals(r2)); + r2.setSeriesItemLabelPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.gray)); + assertTrue(r1.equals(r2)); + + // baseItemLabelPaint + r1.setBaseItemLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.gray)); + assertFalse(r1.equals(r2)); + r2.setBaseItemLabelPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.gray)); + assertTrue(r1.equals(r2)); + + // positiveItemLabelPosition; + r1.setPositiveItemLabelPosition(new ItemLabelPosition()); + assertFalse(r1.equals(r2)); + r2.setPositiveItemLabelPosition(new ItemLabelPosition()); + assertTrue(r1.equals(r2)); + + // positiveItemLabelPositionList; + r1.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition()); + assertFalse(r1.equals(r2)); + r2.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition()); + assertTrue(r1.equals(r2)); + + // basePositiveItemLabelPosition; + r1.setBasePositiveItemLabelPosition(new ItemLabelPosition( + ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); + assertFalse(r1.equals(r2)); + r2.setBasePositiveItemLabelPosition(new ItemLabelPosition( + ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); + assertTrue(r1.equals(r2)); + + // negativeItemLabelPosition; + r1.setNegativeItemLabelPosition(new ItemLabelPosition( + ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); + assertFalse(r1.equals(r2)); + r2.setNegativeItemLabelPosition(new ItemLabelPosition( + ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); + assertTrue(r1.equals(r2)); + + // negativeItemLabelPositionList; + r1.setSeriesNegativeItemLabelPosition(1, new ItemLabelPosition( + ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); + assertFalse(r1.equals(r2)); + r2.setSeriesNegativeItemLabelPosition(1, new ItemLabelPosition( + ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); + assertTrue(r1.equals(r2)); + + // baseNegativeItemLabelPosition; + r1.setBaseNegativeItemLabelPosition(new ItemLabelPosition( + ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); + assertFalse(r1.equals(r2)); + r2.setBaseNegativeItemLabelPosition(new ItemLabelPosition( + ItemLabelAnchor.INSIDE10, TextAnchor.BASELINE_RIGHT)); + assertTrue(r1.equals(r2)); + + // itemLabelAnchorOffset + r1.setItemLabelAnchorOffset(3.0); + assertFalse(r1.equals(r2)); + r2.setItemLabelAnchorOffset(3.0); + assertTrue(r1.equals(r2)); + + // createEntities; + r1.setCreateEntities(Boolean.TRUE); + assertFalse(r1.equals(r2)); + r2.setCreateEntities(Boolean.TRUE); + assertTrue(r1.equals(r2)); + + // createEntitiesList; + r1.setSeriesCreateEntities(0, Boolean.TRUE); + assertFalse(r1.equals(r2)); + r2.setSeriesCreateEntities(0, Boolean.TRUE); + assertTrue(r1.equals(r2)); + + // baseCreateEntities; + r1.setBaseCreateEntities(false); + assertFalse(r1.equals(r2)); + r2.setBaseCreateEntities(false); + assertTrue(r1.equals(r2)); + + // legendShape + r1.setLegendShape(0, new Ellipse2D.Double(1.0, 2.0, 3.0, 4.0)); + assertFalse(r1.equals(r2)); + r2.setLegendShape(0, new Ellipse2D.Double(1.0, 2.0, 3.0, 4.0)); + assertTrue(r1.equals(r2)); + + // baseLegendShape + r1.setBaseLegendShape(new Ellipse2D.Double(5.0, 6.0, 7.0, 8.0)); + assertFalse(r1.equals(r2)); + r2.setBaseLegendShape(new Ellipse2D.Double(5.0, 6.0, 7.0, 8.0)); + assertTrue(r1.equals(r2)); + + // legendTextFont + r1.setLegendTextFont(0, new Font("Dialog", Font.PLAIN, 7)); + assertFalse(r1.equals(r2)); + r2.setLegendTextFont(0, new Font("Dialog", Font.PLAIN, 7)); + assertTrue(r1.equals(r2)); + + // baseLegendTextFont + r1.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 7)); + assertFalse(r1.equals(r2)); + r2.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 7)); + assertTrue(r1.equals(r2)); + + // legendTextPaint + r1.setLegendTextPaint(0, new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertFalse(r1.equals(r2)); + r2.setLegendTextPaint(0, new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertTrue(r1.equals(r2)); + + // baseOutlinePaint + r1.setBaseLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertFalse(r1.equals(r2)); + r2.setBaseLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.blue, + 3.0f, 4.0f, Color.red)); + assertTrue(r1.equals(r2)); + + } + + private static class TestRenderer extends XYLineAndShapeRenderer { + @Override + public void setTreatLegendShapeAsLine(boolean flag) { + super.setTreatLegendShapeAsLine(flag); + } + } + + /** + * Check that the treatLegendShapeAsLine flag is included in the equals() + * comparison. + */ + @Test + public void testEquals2() { + TestRenderer r1 = new TestRenderer(); + TestRenderer r2 = new TestRenderer(); + assertTrue(r1.equals(r2)); + r1.setTreatLegendShapeAsLine(true); + assertFalse(r1.equals(r2)); + r2.setTreatLegendShapeAsLine(true); + assertTrue(r1.equals(r2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + LineAndShapeRenderer r1 = new LineAndShapeRenderer(); + Rectangle2D shape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); + Rectangle2D baseShape = new Rectangle2D.Double(11.0, 12.0, 13.0, 14.0); + r1.setShape(shape); + r1.setBaseShape(baseShape); + r1.setBaseLegendShape(new Rectangle(4, 3, 2, 1)); + r1.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 3)); + r1.setBaseLegendTextPaint(new Color(1, 2, 3)); + + LineAndShapeRenderer r2 = (LineAndShapeRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + r1.setSeriesVisible(0, Boolean.FALSE); + assertFalse(r1.equals(r2)); + r2.setSeriesVisible(0, Boolean.FALSE); + assertTrue(r1.equals(r2)); + + r1.setSeriesVisibleInLegend(0, Boolean.FALSE); + assertFalse(r1.equals(r2)); + r2.setSeriesVisibleInLegend(0, Boolean.FALSE); + assertTrue(r1.equals(r2)); + + r1.setSeriesPaint(0, Color.black); + assertFalse(r1.equals(r2)); + r2.setSeriesPaint(0, Color.black); + assertTrue(r1.equals(r2)); + + r1.setSeriesFillPaint(0, Color.yellow); + assertFalse(r1.equals(r2)); + r2.setSeriesFillPaint(0, Color.yellow); + assertTrue(r1.equals(r2)); + + r1.setSeriesOutlinePaint(0, Color.yellow); + assertFalse(r1.equals(r2)); + r2.setSeriesOutlinePaint(0, Color.yellow); + assertTrue(r1.equals(r2)); + + r1.setSeriesStroke(0, new BasicStroke(2.2f)); + assertFalse(r1.equals(r2)); + r2.setSeriesStroke(0, new BasicStroke(2.2f)); + assertTrue(r1.equals(r2)); + + r1.setSeriesOutlineStroke(0, new BasicStroke(2.2f)); + assertFalse(r1.equals(r2)); + r2.setSeriesOutlineStroke(0, new BasicStroke(2.2f)); + assertTrue(r1.equals(r2)); + + shape.setRect(4.0, 3.0, 2.0, 1.0); + assertFalse(r1.equals(r2)); + r2.setShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertTrue(r1.equals(r2)); + + baseShape.setRect(4.0, 3.0, 2.0, 1.0); + assertFalse(r1.equals(r2)); + r2.setBaseShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertTrue(r1.equals(r2)); + + r1.setSeriesShape(0, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertFalse(r1.equals(r2)); + r2.setSeriesShape(0, new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertTrue(r1.equals(r2)); + + r1.setSeriesItemLabelsVisible(0, Boolean.TRUE); + assertFalse(r1.equals(r2)); + r2.setSeriesItemLabelsVisible(0, Boolean.TRUE); + assertTrue(r1.equals(r2)); + + r1.setSeriesItemLabelPaint(0, Color.red); + assertFalse(r1.equals(r2)); + r2.setSeriesItemLabelPaint(0, Color.red); + assertTrue(r1.equals(r2)); + + r1.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition()); + assertFalse(r1.equals(r2)); + r2.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition()); + assertTrue(r1.equals(r2)); + + r1.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition()); + assertFalse(r1.equals(r2)); + r2.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition()); + assertTrue(r1.equals(r2)); + + r1.setSeriesCreateEntities(0, Boolean.FALSE); + assertFalse(r1.equals(r2)); + r2.setSeriesCreateEntities(0, Boolean.FALSE); + assertTrue(r1.equals(r2)); + + r1.setLegendShape(0, new Rectangle(9, 7, 3, 4)); + assertFalse(r1.equals(r2)); + r2.setLegendShape(0, new Rectangle(9, 7, 3, 4)); + assertTrue(r1.equals(r2)); + + r1.setBaseLegendShape(new Rectangle(3, 4, 1, 5)); + assertFalse(r1.equals(r2)); + r2.setBaseLegendShape(new Rectangle(3, 4, 1, 5)); + assertTrue(r1.equals(r2)); + + r1.setLegendTextFont(1, new Font("Dialog", Font.PLAIN, 33)); + assertFalse(r1.equals(r2)); + r2.setLegendTextFont(1, new Font("Dialog", Font.PLAIN, 33)); + assertTrue(r1.equals(r2)); + + r1.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 11)); + assertFalse(r1.equals(r2)); + r2.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 11)); + assertTrue(r1.equals(r2)); + + r1.setLegendTextPaint(3, Color.red); + assertFalse(r1.equals(r2)); + r2.setLegendTextPaint(3, Color.red); + assertTrue(r1.equals(r2)); + + r1.setBaseLegendTextPaint(Color.green); + assertFalse(r1.equals(r2)); + r2.setBaseLegendTextPaint(Color.green); + assertTrue(r1.equals(r2)); + } + + /** + * A utility class for listening to changes to a renderer. + */ + static class MyRendererChangeListener implements RendererChangeListener { + + /** The last event received. */ + public RendererChangeEvent lastEvent; + + /** + * Creates a new instance. + */ + public MyRendererChangeListener() { + this.lastEvent = null; + } + @Override + public void rendererChanged(RendererChangeEvent event) { + this.lastEvent = event; + } + } + + /** + * A check for cloning. + */ + @Test + public void testCloning2() throws CloneNotSupportedException { + LineAndShapeRenderer r1 = new LineAndShapeRenderer(); + r1.setBasePaint(Color.blue); + r1.setBaseLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + LineAndShapeRenderer r2 = (LineAndShapeRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + MyRendererChangeListener listener = new MyRendererChangeListener(); + r2.addChangeListener(listener); + r2.setBasePaint(Color.red); + assertTrue(listener.lastEvent.getRenderer() == r2); + assertFalse(r1.hasListener(listener)); + } + + /** + * Test that setting the series visibility for ALL series does in fact work. + */ + @Test + public void testSetSeriesVisible() { + BarRenderer r = new BarRenderer(); + r.setSeriesVisible(Boolean.TRUE); + assertTrue(r.getItemVisible(0, 0)); + } + + /** + * Test that setting the paint for ALL series does in fact work. + */ + @Test + public void testSetPaint() { + BarRenderer r = new BarRenderer(); + r.setPaint(Color.orange); + assertEquals(Color.orange, r.getItemPaint(0, 0)); + } + + /** + * Test that setting the outline paint for ALL series does in fact work. + */ + @Test + public void testSetOutlinePaint() { + BarRenderer r = new BarRenderer(); + r.setOutlinePaint(Color.orange); + assertEquals(Color.orange, r.getItemOutlinePaint(0, 0)); + } + + /** + * Test that setting the stroke for ALL series does in fact work. + */ + @Test + public void testSetStroke() { + BarRenderer r = new BarRenderer(); + Stroke s = new BasicStroke(10.0f); + r.setStroke(s); + assertEquals(s, r.getItemStroke(0, 0)); + } + + /** + * Test that setting the outline stroke for ALL series does in fact work. + */ + @Test + public void testSetOutlineStroke() { + BarRenderer r = new BarRenderer(); + Stroke s = new BasicStroke(10.0f); + r.setOutlineStroke(s); + assertEquals(s, r.getItemOutlineStroke(0, 0)); + } + + /** + * Test that setting the shape for ALL series does in fact work. + */ + @Test + public void testSetShape() { + BarRenderer r = new BarRenderer(); + Shape s = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); + r.setShape(s); + assertEquals(s, r.getItemShape(0, 0)); + } + + /** + * Test that setting the item label visibility for ALL series does in fact + * work. + */ + @Test + public void testSetItemLabelsVisible() { + BarRenderer r = new BarRenderer(); + r.setItemLabelsVisible(true); + assertTrue(r.isItemLabelVisible(0, 0)); + } + + /** + * Test that setting the font for ALL series does in fact work (it was + * broken at one point). + */ + @Test + public void testSetItemLabelFont() { + BarRenderer r = new BarRenderer(); + r.setItemLabelFont(new Font("SansSerif", Font.PLAIN, 33)); + assertEquals(new Font("SansSerif", Font.PLAIN, 33), + r.getItemLabelFont(0, 0)); + } + + /** + * Test that setting the paint for ALL series does in fact work (it was + * broken at one point). + */ + @Test + public void testSetItemLabelPaint() { + BarRenderer r = new BarRenderer(); + r.setItemLabelPaint(Color.green); + assertEquals(Color.green, r.getItemLabelPaint(0, 0)); + } + + /** + * Test that setting the positive item label position for ALL series does + * in fact work. + */ + @Test + public void testSetPositiveItemLabelPosition() { + BarRenderer r = new BarRenderer(); + r.setPositiveItemLabelPosition(new ItemLabelPosition( + ItemLabelAnchor.INSIDE1, TextAnchor.BASELINE_LEFT)); + assertEquals(new ItemLabelPosition( + ItemLabelAnchor.INSIDE1, TextAnchor.BASELINE_LEFT), + r.getPositiveItemLabelPosition(0, 0)); + } + + /** + * Test that setting the negative item label position for ALL series does + * in fact work. + */ + @Test + public void testSetNegativeItemLabelPosition() { + BarRenderer r = new BarRenderer(); + r.setNegativeItemLabelPosition(new ItemLabelPosition( + ItemLabelAnchor.INSIDE1, TextAnchor.BASELINE_LEFT)); + assertEquals(new ItemLabelPosition( + ItemLabelAnchor.INSIDE1, TextAnchor.BASELINE_LEFT), + r.getNegativeItemLabelPosition(0, 0)); + } + + /** + * Tests each setter method to ensure that it sends an event notification. + */ + @Test + public void testEventNotification() { + + RendererChangeDetector detector = new RendererChangeDetector(); + BarRenderer r1 = new BarRenderer(); // have to use a subclass of + // AbstractRenderer + r1.addChangeListener(detector); + + // PAINT + detector.setNotified(false); + r1.setPaint(Color.red); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setSeriesPaint(0, Color.red); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setBasePaint(Color.red); + assertTrue(detector.getNotified()); + + // OUTLINE PAINT + detector.setNotified(false); + r1.setOutlinePaint(Color.red); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setSeriesOutlinePaint(0, Color.red); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setBaseOutlinePaint(Color.red); + assertTrue(detector.getNotified()); + + // STROKE + detector.setNotified(false); + r1.setStroke(new BasicStroke(1.0f)); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setSeriesStroke(0, new BasicStroke(1.0f)); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setBaseStroke(new BasicStroke(1.0f)); + assertTrue(detector.getNotified()); + + // OUTLINE STROKE + detector.setNotified(false); + r1.setOutlineStroke(new BasicStroke(1.0f)); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setSeriesOutlineStroke(0, new BasicStroke(1.0f)); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setBaseOutlineStroke(new BasicStroke(1.0f)); + assertTrue(detector.getNotified()); + + // SHAPE + detector.setNotified(false); + r1.setShape(new Rectangle2D.Float()); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setSeriesShape(0, new Rectangle2D.Float()); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setBaseShape(new Rectangle2D.Float()); + assertTrue(detector.getNotified()); + + // ITEM_LABELS_VISIBLE + detector.setNotified(false); + r1.setItemLabelsVisible(Boolean.TRUE); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setSeriesItemLabelsVisible(0, Boolean.TRUE); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setBaseItemLabelsVisible(Boolean.TRUE); + assertTrue(detector.getNotified()); + + // ITEM_LABEL_FONT + detector.setNotified(false); + r1.setItemLabelFont(new Font("Serif", Font.PLAIN, 12)); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setSeriesItemLabelFont(0, new Font("Serif", Font.PLAIN, 12)); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setBaseItemLabelFont(new Font("Serif", Font.PLAIN, 12)); + assertTrue(detector.getNotified()); + + // ITEM_LABEL_PAINT + detector.setNotified(false); + r1.setItemLabelPaint(Color.blue); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setSeriesItemLabelPaint(0, Color.blue); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setBaseItemLabelPaint(Color.blue); + assertTrue(detector.getNotified()); + + // POSITIVE ITEM LABEL POSITION + detector.setNotified(false); + r1.setPositiveItemLabelPosition(new ItemLabelPosition( + ItemLabelAnchor.CENTER, TextAnchor.CENTER)); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition( + ItemLabelAnchor.CENTER, TextAnchor.CENTER)); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setBasePositiveItemLabelPosition(new ItemLabelPosition( + ItemLabelAnchor.CENTER, TextAnchor.CENTER)); + assertTrue(detector.getNotified()); + + // NEGATIVE ITEM LABEL ANCHOR + detector.setNotified(false); + r1.setNegativeItemLabelPosition( + new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER) + ); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setSeriesNegativeItemLabelPosition(0, new ItemLabelPosition( + ItemLabelAnchor.CENTER, TextAnchor.CENTER)); + assertTrue(detector.getNotified()); + + detector.setNotified(false); + r1.setBaseNegativeItemLabelPosition(new ItemLabelPosition( + ItemLabelAnchor.CENTER, TextAnchor.CENTER)); + assertTrue(detector.getNotified()); + + } + + /** + * Serialize an instance, restore it, and check for equality. In addition, + * test for a bug that was reported where the listener list is 'null' after + * deserialization. + */ + @Test + public void testSerialization() { + BarRenderer r1 = new BarRenderer(); + r1.setBaseLegendTextFont(new Font("Dialog", Font.PLAIN, 4)); + r1.setBaseLegendTextPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.green)); + r1.setBaseLegendShape(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); + BarRenderer r2 = (BarRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + try { + r2.notifyListeners(new RendererChangeEvent(r2)); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); // failed + } + } + + /** + * Some checks for the autoPopulate flag default values. + */ + @Test + public void testAutoPopulateFlagDefaults() { + BarRenderer r = new BarRenderer(); + assertEquals(true, r.getAutoPopulateSeriesPaint()); + assertEquals(false, r.getAutoPopulateSeriesFillPaint()); + assertEquals(false, r.getAutoPopulateSeriesOutlinePaint()); + assertEquals(true, r.getAutoPopulateSeriesStroke()); + assertEquals(false, r.getAutoPopulateSeriesOutlineStroke()); + assertEquals(true, r.getAutoPopulateSeriesShape()); + } + + /** + * Some checks for the paint lookup mechanism. + */ + @Test + public void testPaintLookup() { + BarRenderer r = new BarRenderer(); + assertEquals(Color.blue, r.getBasePaint()); + + // first check that autoPopulate==false works as expected + r.setAutoPopulateSeriesPaint(false); + assertEquals(Color.blue, r.lookupSeriesPaint(0)); + assertNull(r.getSeriesPaint(0)); + + // now check autoPopulate==true + r.setAutoPopulateSeriesPaint(true); + /*CategoryPlot plot =*/ new CategoryPlot(null, new CategoryAxis( + "Category"), new NumberAxis("Value"), r); + assertEquals(DefaultDrawingSupplier.DEFAULT_PAINT_SEQUENCE[0], + r.lookupSeriesPaint(0)); + assertNotNull(r.getSeriesPaint(0)); + } + + /** + * Some checks for the fill paint lookup mechanism. + */ + @Test + public void testFillPaintLookup() { + BarRenderer r = new BarRenderer(); + assertEquals(Color.white, r.getBaseFillPaint()); + + // first check that autoPopulate==false works as expected + r.setAutoPopulateSeriesFillPaint(false); + assertEquals(Color.white, r.lookupSeriesFillPaint(0)); + assertNull(r.getSeriesFillPaint(0)); + + // now check autoPopulate==true + r.setAutoPopulateSeriesFillPaint(true); + /*CategoryPlot plot =*/ new CategoryPlot(null, new CategoryAxis( + "Category"), new NumberAxis("Value"), r); + assertEquals(DefaultDrawingSupplier.DEFAULT_FILL_PAINT_SEQUENCE[0], + r.lookupSeriesFillPaint(0)); + assertNotNull(r.getSeriesFillPaint(0)); + } + + /** + * Some checks for the outline paint lookup mechanism. + */ + @Test + public void testOutlinePaintLookup() { + BarRenderer r = new BarRenderer(); + assertEquals(Color.gray, r.getBaseOutlinePaint()); + + // first check that autoPopulate==false works as expected + r.setAutoPopulateSeriesOutlinePaint(false); + assertEquals(Color.gray, r.lookupSeriesOutlinePaint(0)); + assertNull(r.getSeriesOutlinePaint(0)); + + // now check autoPopulate==true + r.setAutoPopulateSeriesOutlinePaint(true); + /*CategoryPlot plot =*/ new CategoryPlot(null, new CategoryAxis( + "Category"), new NumberAxis("Value"), r); + assertEquals(DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE[0], + r.lookupSeriesOutlinePaint(0)); + assertNotNull(r.getSeriesOutlinePaint(0)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/AreaRendererEndTypeTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/AreaRendererEndTypeTest.java new file mode 100755 index 0000000..ef98c08 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/AreaRendererEndTypeTest.java @@ -0,0 +1,77 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * AreaRendererEndTypeTest.java + * ---------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Apr-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.renderer; + +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link AreaRendererEndType} class. + */ +public class AreaRendererEndTypeTest { + + /** + * A test for the equals() method. + */ + @Test + public void testEquals() { + assertEquals(AreaRendererEndType.LEVEL, AreaRendererEndType.LEVEL); + assertEquals(AreaRendererEndType.TAPER, AreaRendererEndType.TAPER); + assertEquals( + AreaRendererEndType.TRUNCATE, AreaRendererEndType.TRUNCATE + ); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + AreaRendererEndType t1 = AreaRendererEndType.TAPER; + AreaRendererEndType t2 = (AreaRendererEndType) TestUtilities.serialised(t1); + assertEquals(t1, t2); + boolean same = t1 == t2; + assertEquals(true, same); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/DefaultPolarItemRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/DefaultPolarItemRendererTest.java new file mode 100755 index 0000000..8323e4a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/DefaultPolarItemRendererTest.java @@ -0,0 +1,114 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * DefaultPolarItemRendererTest.java + * --------------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Aug-2006 : Version 1 (DG); + * 15-Mar-2007 : Added independence check to testCloning() (DG); + * + */ + +package org.jfree.chart.renderer; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link DefaultPolarItemRenderer} class. + */ +public class DefaultPolarItemRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + DefaultPolarItemRenderer r1 = new DefaultPolarItemRenderer(); + DefaultPolarItemRenderer r2 = new DefaultPolarItemRenderer(); + assertEquals(r1, r2); + + r1.setSeriesFilled(1, true); + assertFalse(r1.equals(r2)); + r2.setSeriesFilled(1, true); + assertTrue(r1.equals(r2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + DefaultPolarItemRenderer r1 = new DefaultPolarItemRenderer(); + DefaultPolarItemRenderer r2 = new DefaultPolarItemRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultPolarItemRenderer r1 = new DefaultPolarItemRenderer(); + DefaultPolarItemRenderer r2 = (DefaultPolarItemRenderer) r1.clone(); + + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + r1.setSeriesFilled(1, true); + assertFalse(r1.equals(r2)); + r2.setSeriesFilled(1, true); + assertTrue(r1.equals(r2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultPolarItemRenderer r1 = new DefaultPolarItemRenderer(); + DefaultPolarItemRenderer r2 = (DefaultPolarItemRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/GrayPaintScaleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/GrayPaintScaleTest.java new file mode 100755 index 0000000..a75c7b8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/GrayPaintScaleTest.java @@ -0,0 +1,142 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * GrayPaintScaleTest.java + * ----------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Jul-2006 : Version 1 (DG); + * 26-Sep-2007 : Added testConstructor() and testGetPaint() (DG); + * 29-Jan-2009 : Extended testEquals() for new alpha field (DG); + * + */ + +package org.jfree.chart.renderer; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link GrayPaintScale} class. + */ +public class GrayPaintScaleTest { + + private static final double EPSILON = 0.000000001; + + /** + * Simple check for the default constructor. + */ + @Test + public void testConstructor() { + GrayPaintScale gps = new GrayPaintScale(); + assertEquals(0.0, gps.getLowerBound(), EPSILON); + assertEquals(1.0, gps.getUpperBound(), EPSILON); + assertEquals(255, gps.getAlpha()); + } + + /** + * Some checks for the getPaint() method. + */ + @Test + public void testGetPaint() { + GrayPaintScale gps = new GrayPaintScale(); + Color c = (Color) gps.getPaint(0.0); + assertTrue(c.equals(Color.black)); + c = (Color) gps.getPaint(1.0); + assertTrue(c.equals(Color.white)); + + // check lookup values that are outside the bounds - see bug report + // 1767315 + c = (Color) gps.getPaint(-0.5); + assertTrue(c.equals(Color.black)); + c = (Color) gps.getPaint(1.5); + assertTrue(c.equals(Color.white)); + } + + /** + * A test for the equals() method. + */ + @Test + public void testEquals() { + GrayPaintScale g1 = new GrayPaintScale(); + GrayPaintScale g2 = new GrayPaintScale(); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new GrayPaintScale(0.0, 1.0); + g2 = new GrayPaintScale(0.0, 1.0); + assertTrue(g1.equals(g2)); + g1 = new GrayPaintScale(0.1, 1.0); + assertFalse(g1.equals(g2)); + g2 = new GrayPaintScale(0.1, 1.0); + assertTrue(g1.equals(g2)); + + g1 = new GrayPaintScale(0.1, 0.9); + assertFalse(g1.equals(g2)); + g2 = new GrayPaintScale(0.1, 0.9); + assertTrue(g1.equals(g2)); + + g1 = new GrayPaintScale(0.1, 0.9, 128); + assertFalse(g1.equals(g2)); + g2 = new GrayPaintScale(0.1, 0.9, 128); + assertTrue(g1.equals(g2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + GrayPaintScale g1 = new GrayPaintScale(); + GrayPaintScale g2 = (GrayPaintScale) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + GrayPaintScale g1 = new GrayPaintScale(); + GrayPaintScale g2 = (GrayPaintScale) TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/LookupPaintScaleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/LookupPaintScaleTest.java new file mode 100755 index 0000000..9b5dbd9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/LookupPaintScaleTest.java @@ -0,0 +1,197 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * LookupPaintScaleTest.java + * ------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Jul-2006 : Version 1 (DG); + * 31-Jan-2007 : Additional serialization tests (DG); + * 07-Mar-2007 : Added new tests (DG); + * 09-Mar-2007 : Check independence in testCloning() (DG); + * + */ + +package org.jfree.chart.renderer; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link LookupPaintScale} class. + */ +public class LookupPaintScaleTest { + + /** + * A test for the equals() method. + */ + @Test + public void testEquals() { + LookupPaintScale g1 = new LookupPaintScale(); + LookupPaintScale g2 = new LookupPaintScale(); + assertTrue(g1.equals(g2)); + assertTrue(g2.equals(g1)); + + g1 = new LookupPaintScale(1.0, 2.0, Color.red); + assertFalse(g1.equals(g2)); + g2 = new LookupPaintScale(1.0, 2.0, Color.red); + assertTrue(g1.equals(g2)); + + g1.add(1.5, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue)); + assertFalse(g1.equals(g2)); + g2.add(1.5, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue)); + assertTrue(g1.equals(g2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + LookupPaintScale g1 = new LookupPaintScale(); + LookupPaintScale g2 = (LookupPaintScale) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + + // check independence + g1.add(0.5, Color.red); + assertFalse(g1.equals(g2)); + g2.add(0.5, Color.red); + assertTrue(g1.equals(g2)); + + // try with gradient paint + g1 = new LookupPaintScale(1.0, 2.0, new GradientPaint(1.0f, 2.0f, + Color.red, 3.0f, 4.0f, Color.green)); + g1.add(1.5, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue)); + g2 = (LookupPaintScale) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + LookupPaintScale g1 = new LookupPaintScale(); + LookupPaintScale g2 = (LookupPaintScale) TestUtilities.serialised(g1); + assertEquals(g1, g2); + + g1 = new LookupPaintScale(1.0, 2.0, new GradientPaint(1.0f, 2.0f, + Color.red, 3.0f, 4.0f, Color.yellow)); + g1.add(1.5, new GradientPaint(1.1f, 2.2f, Color.red, 3.3f, 4.4f, + Color.blue)); + g2 = (LookupPaintScale) TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the default constructor. + */ + @Test + public void testConstructor1() { + LookupPaintScale s = new LookupPaintScale(); + assertEquals(0.0, s.getLowerBound(), EPSILON); + assertEquals(1.0, s.getUpperBound(), EPSILON); + } + + /** + * Some checks for the other constructor. + */ + @Test + public void testConstructor2() { + LookupPaintScale s = new LookupPaintScale(1.0, 2.0, Color.red); + assertEquals(1.0, s.getLowerBound(), EPSILON); + assertEquals(2.0, s.getUpperBound(), EPSILON); + assertEquals(Color.red, s.getDefaultPaint()); + } + + /** + * Some general checks for the lookup table. + */ + @Test + public void testGeneral() { + + LookupPaintScale s = new LookupPaintScale(0.0, 100.0, Color.black); + assertEquals(Color.black, s.getPaint(-1.0)); + assertEquals(Color.black, s.getPaint(0.0)); + assertEquals(Color.black, s.getPaint(50.0)); + assertEquals(Color.black, s.getPaint(100.0)); + assertEquals(Color.black, s.getPaint(101.0)); + + s.add(50.0, Color.blue); + assertEquals(Color.black, s.getPaint(-1.0)); + assertEquals(Color.black, s.getPaint(0.0)); + assertEquals(Color.blue, s.getPaint(50.0)); + assertEquals(Color.blue, s.getPaint(100.0)); + assertEquals(Color.black, s.getPaint(101.0)); + + s.add(50.0, Color.red); + assertEquals(Color.black, s.getPaint(-1.0)); + assertEquals(Color.black, s.getPaint(0.0)); + assertEquals(Color.red, s.getPaint(50.0)); + assertEquals(Color.red, s.getPaint(100.0)); + assertEquals(Color.black, s.getPaint(101.0)); + + s.add(25.0, Color.green); + assertEquals(Color.black, s.getPaint(-1.0)); + assertEquals(Color.black, s.getPaint(0.0)); + assertEquals(Color.green, s.getPaint(25.0)); + assertEquals(Color.red, s.getPaint(50.0)); + assertEquals(Color.red, s.getPaint(100.0)); + assertEquals(Color.black, s.getPaint(101.0)); + + s.add(75.0, Color.yellow); + assertEquals(Color.black, s.getPaint(-1.0)); + assertEquals(Color.black, s.getPaint(0.0)); + assertEquals(Color.green, s.getPaint(25.0)); + assertEquals(Color.red, s.getPaint(50.0)); + assertEquals(Color.yellow, s.getPaint(75.0)); + assertEquals(Color.yellow, s.getPaint(100.0)); + assertEquals(Color.black, s.getPaint(101.0)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/OutlierTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/OutlierTest.java new file mode 100755 index 0000000..659ed4e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/OutlierTest.java @@ -0,0 +1,114 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * OutlierTest.java + * ---------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Nov-2007 : Version 1 (DG); + * + */ + +package org.jfree.chart.renderer; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.geom.Point2D; +import java.io.Serializable; +import org.junit.Test; + +/** + * Tests for the {@link Outlier} class. + */ +public class OutlierTest { + + private static final double EPSILON = 0.000000001; + + /** + * Simple check for the default constructor. + */ + @Test + public void testConstructor() { + Outlier out = new Outlier(1.0, 2.0, 3.0); + assertEquals(-2.0, out.getX(), EPSILON); + assertEquals(-1.0, out.getY(), EPSILON); + assertEquals(3.0, out.getRadius(), EPSILON); + } + + /** + * A test for the equals() method. + */ + @Test + public void testEquals() { + Outlier out1 = new Outlier(1.0, 2.0, 3.0); + Outlier out2 = new Outlier(1.0, 2.0, 3.0); + assertTrue(out1.equals(out2)); + assertTrue(out2.equals(out1)); + + out1.setPoint(new Point2D.Double(2.0, 2.0)); + assertFalse(out1.equals(out2)); + out2.setPoint(new Point2D.Double(2.0, 2.0)); + assertTrue(out1.equals(out2)); + + out1.setPoint(new Point2D.Double(2.0, 3.0)); + assertFalse(out1.equals(out2)); + out2.setPoint(new Point2D.Double(2.0, 3.0)); + assertTrue(out1.equals(out2)); + + out1.setRadius(4.0); + assertFalse(out1.equals(out2)); + out2.setRadius(4.0); + assertTrue(out1.equals(out2)); + } + + /** + * Confirm that cloning is not implemented. + */ + @Test + public void testCloning() { + Outlier out1 = new Outlier(1.0, 2.0, 3.0); + assertFalse(out1 instanceof Cloneable); + } + + /** + * Confirm that serialization is not implemented. + */ + @Test + public void testSerialization() { + Outlier out1 = new Outlier(1.0, 2.0, 3.0); + assertFalse(out1 instanceof Serializable); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/RendererChangeDetector.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/RendererChangeDetector.java new file mode 100755 index 0000000..3cdaf67 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/RendererChangeDetector.java @@ -0,0 +1,92 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * RendererChangeDetector.java + * --------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Oct-2003 : Version 1 (DG); + * + */ + +package org.jfree.chart.renderer; + +import org.jfree.chart.event.RendererChangeEvent; +import org.jfree.chart.event.RendererChangeListener; + +/** + * A simple class for detecting whether or not a renderer has generated + * a {@link RendererChangeEvent}. + */ +public class RendererChangeDetector implements RendererChangeListener { + + /** A flag that records whether or not a change event has been received. */ + private boolean notified; + + /** + * Creates a new detector. + */ + public RendererChangeDetector() { + this.notified = false; + } + + /** + * Returns the flag that indicates whether or not a change event has been + * received. + * + * @return The flag. + */ + public boolean getNotified() { + return this.notified; + } + + /** + * Sets the flag that indicates whether or not a change event has been + * received. + * + * @param notified the new value of the flag. + */ + public void setNotified(boolean notified) { + this.notified = notified; + } + + /** + * Receives a {@link RendererChangeEvent} from a renderer. + * + * @param event the event. + */ + @Override + public void rendererChanged(RendererChangeEvent event) { + this.notified = true; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/RendererUtilitiesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/RendererUtilitiesTest.java new file mode 100755 index 0000000..c926110 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/RendererUtilitiesTest.java @@ -0,0 +1,505 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * RendererUtilitiesTest.java + * -------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-Apr-2007 : Version 1 (DG); + * 23-Aug-2012 : Added test3561093() (DG); + * + */ + +package org.jfree.chart.renderer; + +import static org.junit.Assert.assertEquals; + +import org.jfree.data.DomainOrder; +import org.jfree.data.xy.DefaultXYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.junit.Test; + +/** + * Some checks for the {@link RendererUtilities} class. + */ +public class RendererUtilitiesTest { + + /** + * Some checks for the findLiveItemsLowerBound() method when the dataset is + * unordered. + */ + @Test + public void testFindLiveItemsLowerBound_Unordered() { + DefaultXYDataset d = new DefaultXYDataset(); + + // check a series with no items + d.addSeries("S1", new double[][] {{}, {}}); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, + 11.0)); + + // check a series with one item + d.addSeries("S2", new double[][] {{0.0}, {9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, + 1.1)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 2.0, + 3.3)); + + // check a series with two items + d.addSeries("S3", new double[][] {{0.0, 1.0}, {9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.0, + 1.1)); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.0, + 2.2)); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.0, + 3.3)); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.0, + 4.4)); + + // check a series with three items + d.addSeries("S4", new double[][] {{1.0, 2.0, 1.5}, {9.9, 9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, + 1.1)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, + 2.2)); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, + 3.3)); + assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, + 4.4)); + + // check a series with four items + d.addSeries("S5", new double[][] {{1.0, 2.0, 1.5, 1.8}, {9.9, 9.9, + 9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0, + 1.1)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0, + 2.2)); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0, + 3.3)); + assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0, + 4.4)); + assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.0, + 5.5)); + } + + /** + * Some checks for the findLiveItemsLowerBound() method when the dataset is + * ASCENDING. + */ + @Test + public void testFindLiveItemsLowerBound_Ascending() { + DefaultXYDataset d = new DefaultXYDataset() { + @Override + public DomainOrder getDomainOrder() { + // we're doing this for testing only, and make sure that we + // only add data in ascending order by x-value + return DomainOrder.ASCENDING; + } + }; + // check a series with no items + d.addSeries("S1", new double[][] {{}, {}}); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, + 11.1)); + + // check a series with one item + d.addSeries("S2", new double[][] {{1.0}, {9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, + 1.1)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 2.0, + 2.2)); + + // check a series with two items + d.addSeries("S3", new double[][] {{1.0, 2.0}, {9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.0, + 1.1)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.0, + 2.2)); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.0, + 3.3)); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.0, + 4.4)); + + // check a series with three items + d.addSeries("S4", new double[][] {{1.0, 2.0, 3.0}, {9.9, 9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, + 1.1)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, + 2.2)); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, + 3.3)); + assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, + 4.4)); + + // check a series with four items + d.addSeries("S5", new double[][] {{1.0, 2.0, 3.0, 4.0}, {9.9, 9.9, + 9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0, + 1.1)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0, + 2.2)); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0, + 3.3)); + assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0, + 4.4)); + assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.0, + 5.5)); + + // check a series with repeating items + d.addSeries("S5", new double[][] {{1.0, 2.0, 2.0, 2.0, 3.0}, {9.9, 9.9, + 9.9, 9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.0, + 4.0)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.0, + 4.0)); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.0, + 4.0)); + assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.0, + 4.0)); + + } + + /** + * Some checks for the findLiveItemsLowerBound() method when the dataset is + * DESCENDING. + */ + @Test + public void testFindLiveItemsLowerBound_Descending() { + DefaultXYDataset d = new DefaultXYDataset() { + @Override + public DomainOrder getDomainOrder() { + // we're doing this for testing only, and make sure that we + // only add data in descending order by x-value + return DomainOrder.DESCENDING; + } + }; + // check a series with no items + d.addSeries("S1", new double[][] {{}, {}}); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 0, 10.0, + 11.0)); + + // check a series with one item + d.addSeries("S2", new double[][] {{1.0}, {9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 0.0, + 1.0)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 1, 1.1, + 2.0)); + + // check a series with two items + d.addSeries("S3", new double[][] {{2.0, 1.0}, {9.9, 9.9}}); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1, + 0.5)); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 2, 0.1, + 1.0)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 1.1, + 2.0)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 2.2, + 3.0)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 2, 3.3, + 4.0)); + + // check a series with three items + d.addSeries("S4", new double[][] {{3.0, 2.0, 1.0}, {9.9, 9.9, 9.9}}); + assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 3, 0.0, + 1.0)); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 3, 1.0, + 2.0)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 2.0, + 3.0)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 3, 3.0, + 4.0)); + + // check a series with four items + d.addSeries("S5", new double[][] {{4.0, 3.0, 2.0, 1.0}, {9.9, 9.9, + 9.9, 9.9}}); + assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1, + 0.5)); + assertEquals(3, RendererUtilities.findLiveItemsLowerBound(d, 4, 0.1, + 1.0)); + assertEquals(2, RendererUtilities.findLiveItemsLowerBound(d, 4, 1.1, + 2.0)); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 4, 2.2, + 3.0)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 3.3, + 4.0)); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 4, 4.4, + 5.0)); + + // check a series with repeating items + d.addSeries("S6", new double[][] {{3.0, 2.0, 2.0, 2.0, 1.0}, {9.9, 9.9, + 9.9, 9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, + 3.0)); + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, + 2.0)); + assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, + 1.0)); + assertEquals(4, RendererUtilities.findLiveItemsLowerBound(d, 5, 0.0, + 0.5)); + } + + /** + * Some checks for the findLiveItemsUpperBound() method when the dataset is + * unordered. + */ + @Test + public void testFindLiveItemsUpperBound_Unordered() { + DefaultXYDataset d = new DefaultXYDataset(); + + // check a series with no items + d.addSeries("S1", new double[][] {{}, {}}); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, + 11.0)); + + // check a series with one item + d.addSeries("S2", new double[][] {{1.0}, {9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, + 1.1)); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 2.0, + 3.3)); + + // check a series with two items + d.addSeries("S3", new double[][] {{1.0, 2.0}, {9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.0, + 1.1)); + assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.0, + 2.2)); + assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.0, + 3.3)); + assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.0, + 4.4)); + + // check a series with three items + d.addSeries("S4", new double[][] {{1.0, 2.0, 1.5}, {9.9, 9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, + 1.1)); + assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, + 2.2)); + assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, + 3.3)); + assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, + 4.4)); + + // check a series with four items + d.addSeries("S5", new double[][] {{1.0, 2.0, 1.5, 1.8}, {9.9, 9.9, + 9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, + 1.1)); + assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.0, + 2.2)); + assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.0, + 3.3)); + assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.0, + 4.4)); + assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.0, + 5.5)); + } + + /** + * Some checks for the findLiveItemsUpperBound() method when the dataset is + * ASCENDING. + */ + @Test + public void testFindLiveItemsUpperBound_Ascending() { + DefaultXYDataset d = new DefaultXYDataset() { + @Override + public DomainOrder getDomainOrder() { + // we're doing this for testing only, and make sure that we + // only add data in ascending order by x-value + return DomainOrder.ASCENDING; + } + }; + // check a series with no items + d.addSeries("S1", new double[][] {{}, {}}); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, + 11.1)); + + // check a series with one item + d.addSeries("S2", new double[][] {{1.0}, {9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, + 1.1)); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 2.0, + 2.2)); + + // check a series with two items + d.addSeries("S3", new double[][] {{1.0, 2.0}, {9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.0, + 1.0)); + assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.0, + 2.2)); + assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.0, + 3.3)); + assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.0, + 4.4)); + + // check a series with three items + d.addSeries("S4", new double[][] {{1.0, 2.0, 3.0}, {9.9, 9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, + 1.1)); + assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, + 2.2)); + assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, + 3.3)); + assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, + 4.4)); + + // check a series with four items + d.addSeries("S5", new double[][] {{1.0, 2.0, 3.0, 4.0}, {9.9, 9.9, + 9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, + 1.1)); + assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.0, + 2.2)); + assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.0, + 3.3)); + assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.0, + 4.4)); + assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.0, + 5.5)); + + // check a series with repeating items + d.addSeries("S5", new double[][] {{1.0, 2.0, 2.0, 2.0, 3.0}, {9.9, 9.9, + 9.9, 9.9, 9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, + 1.0)); + assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, + 2.0)); + assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, + 3.0)); + assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.0, + 4.0)); + + } + + /** + * Some checks for the findLiveItemsUpperBound() method when the dataset is + * DESCENDING. + */ + @Test + public void testFindLiveItemsUpperBound_Descending() { + DefaultXYDataset d = new DefaultXYDataset() { + @Override + public DomainOrder getDomainOrder() { + // we're doing this for testing only, and make sure that we + // only add data in descending order by x-value + return DomainOrder.DESCENDING; + } + }; + // check a series with no items + d.addSeries("S1", new double[][] {{}, {}}); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 0, 10.0, + 11.0)); + + // check a series with one item + d.addSeries("S2", new double[][] {{1.0}, {9.9}}); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 0.0, + 1.0)); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 1, 1.1, + 2.0)); + + // check a series with two items + d.addSeries("S3", new double[][] {{2.0, 1.0}, {9.9, 9.9}}); + assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.1, + 0.5)); + assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 2, 0.1, + 1.0)); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 1.1, + 2.0)); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 2.2, + 3.0)); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 2, 3.3, + 4.0)); + + // check a series with three items + d.addSeries("S4", new double[][] {{3.0, 2.0, 1.0}, {9.9, 9.9, 9.9}}); + assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 0.0, + 1.0)); + assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 3, 1.0, + 2.0)); + assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 3, 2.0, + 3.0)); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 3, 3.0, + 4.0)); + + // check a series with four items + d.addSeries("S5", new double[][] {{4.0, 3.0, 2.0, 1.0}, {9.9, 9.9, + 9.9, 9.9}}); + assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.1, + 0.5)); + assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 4, 0.1, + 1.0)); + assertEquals(2, RendererUtilities.findLiveItemsUpperBound(d, 4, 1.1, + 2.0)); + assertEquals(1, RendererUtilities.findLiveItemsUpperBound(d, 4, 2.2, + 3.0)); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 3.3, + 4.0)); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 4, 4.4, + 5.0)); + + // check a series with repeating items + d.addSeries("S6", new double[][] {{3.0, 2.0, 2.0, 2.0, 1.0}, {9.9, 9.9, + 9.9, 9.9, 9.9}}); + assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 5, 0.0, + 5.0)); + assertEquals(4, RendererUtilities.findLiveItemsUpperBound(d, 5, 1.0, + 5.0)); + assertEquals(3, RendererUtilities.findLiveItemsUpperBound(d, 5, 2.0, + 5.0)); + assertEquals(0, RendererUtilities.findLiveItemsUpperBound(d, 5, 3.0, + 5.0)); + } + + /** + * Checks the bounds calculation for a series where the x-ordering is not + * known. See bug 3561093. + */ + @Test + public void test3561093() { + XYSeries s = new XYSeries("S1", false); + s.add(0.0, 0.0); + s.add(21.0, 0.0); + s.add(2.0, 0.0); + s.add(23.0, 0.0); + XYSeriesCollection dataset = new XYSeriesCollection(); + dataset.addSeries(s); + + assertEquals(1, RendererUtilities.findLiveItemsLowerBound(dataset, 0, + 10.0, 20.0)); + assertEquals(2, RendererUtilities.findLiveItemsUpperBound(dataset, 0, + 10.0, 20.0)); + + int[] bounds = RendererUtilities.findLiveItems(dataset, 0, 10.0, 20.0); + assertEquals(1, bounds[0]); + assertEquals(2, bounds[1]); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/AbstractCategoryItemRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/AbstractCategoryItemRendererTest.java new file mode 100755 index 0000000..6ff5b26 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/AbstractCategoryItemRendererTest.java @@ -0,0 +1,334 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------- + * AbstractCategoryItemRendererTest.java + * ------------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 12-Feb-2004 : Version 1 (DG); + * 24-Nov-2006 : New cloning tests (DG); + * 07-Dec-2006 : Added testEquals() method (DG); + * 25-Nov-2008 : Added testFindRangeBounds() (DG); + * 09-Feb-2010 : Added test2947660() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; + +import java.text.NumberFormat; + +import org.jfree.chart.LegendItemCollection; +import org.jfree.chart.labels.IntervalCategoryItemLabelGenerator; +import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; +import org.jfree.chart.labels.StandardCategorySeriesLabelGenerator; +import org.jfree.chart.labels.StandardCategoryToolTipGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.urls.StandardCategoryURLGenerator; +import org.jfree.data.Range; +import org.jfree.data.category.DefaultCategoryDataset; +import org.junit.Test; + +/** + * Tests for the {@link AbstractCategoryItemRenderer} class. + */ +public class AbstractCategoryItemRendererTest { + + /** + * Checks that all fields are distinguished. + */ + @Test + public void testEquals() { + BarRenderer r1 = new BarRenderer(); + BarRenderer r2 = new BarRenderer(); + assertEquals(r1, r2); + + // the plot field is NOT tested + + // toolTipGenerator + r1.setToolTipGenerator(new StandardCategoryToolTipGenerator()); + assertFalse(r1.equals(r2)); + r2.setToolTipGenerator(new StandardCategoryToolTipGenerator()); + assertTrue(r1.equals(r2)); + + // toolTipGeneratorList + r1.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); + assertFalse(r1.equals(r2)); + r2.setSeriesToolTipGenerator(1, new StandardCategoryToolTipGenerator()); + assertTrue(r1.equals(r2)); + + // baseToolTipGenerator + r1.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{2}", + NumberFormat.getInstance())); + assertFalse(r1.equals(r2)); + r2.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator("{2}", + NumberFormat.getInstance())); + assertTrue(r1.equals(r2)); + + // itemLabelGenerator + r1.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); + assertFalse(r1.equals(r2)); + r2.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); + assertTrue(r1.equals(r2)); + + // itemLabelGeneratorList + r1.setSeriesItemLabelGenerator(1, + new StandardCategoryItemLabelGenerator()); + assertFalse(r1.equals(r2)); + r2.setSeriesItemLabelGenerator(1, + new StandardCategoryItemLabelGenerator()); + assertTrue(r1.equals(r2)); + + // baseItemLabelGenerator + r1.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( + "{2}", NumberFormat.getInstance())); + assertFalse(r1.equals(r2)); + r2.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator( + "{2}", NumberFormat.getInstance())); + assertTrue(r1.equals(r2)); + + // urlGenerator + r1.setItemURLGenerator(new StandardCategoryURLGenerator()); + assertFalse(r1.equals(r2)); + r2.setItemURLGenerator(new StandardCategoryURLGenerator()); + assertTrue(r1.equals(r2)); + + // urlGeneratorList + r1.setSeriesItemURLGenerator(1, new StandardCategoryURLGenerator()); + assertFalse(r1.equals(r2)); + r2.setSeriesItemURLGenerator(1, new StandardCategoryURLGenerator()); + assertTrue(r1.equals(r2)); + + // baseItemURLGenerator + r1.setBaseItemURLGenerator(new StandardCategoryURLGenerator( + "abc.html")); + assertFalse(r1.equals(r2)); + r2.setBaseItemURLGenerator(new StandardCategoryURLGenerator( + "abc.html")); + assertTrue(r1.equals(r2)); + + // legendItemLabelGenerator + r1.setLegendItemLabelGenerator(new StandardCategorySeriesLabelGenerator( + "XYZ")); + assertFalse(r1.equals(r2)); + r2.setLegendItemLabelGenerator(new StandardCategorySeriesLabelGenerator( + "XYZ")); + assertTrue(r1.equals(r2)); + + // legendItemToolTipGenerator + r1.setLegendItemToolTipGenerator( + new StandardCategorySeriesLabelGenerator("ToolTip")); + assertFalse(r1.equals(r2)); + r2.setLegendItemToolTipGenerator( + new StandardCategorySeriesLabelGenerator("ToolTip")); + assertTrue(r1.equals(r2)); + + // legendItemURLGenerator + r1.setLegendItemURLGenerator( + new StandardCategorySeriesLabelGenerator("URL")); + assertFalse(r1.equals(r2)); + r2.setLegendItemURLGenerator( + new StandardCategorySeriesLabelGenerator("URL")); + assertTrue(r1.equals(r2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning1() throws CloneNotSupportedException { + AbstractCategoryItemRenderer r1 = new BarRenderer(); + r1.setItemLabelGenerator(new StandardCategoryItemLabelGenerator()); + AbstractCategoryItemRenderer r2 = (BarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + r1 = new BarRenderer(); + r1.setSeriesItemLabelGenerator(0, + new StandardCategoryItemLabelGenerator()); + r2 = (BarRenderer) r1.clone(); + + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + r1 = new BarRenderer(); + r1.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); + r2 = (BarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning2() throws CloneNotSupportedException { + BarRenderer r1 = new BarRenderer(); + r1.setBaseItemLabelGenerator(new IntervalCategoryItemLabelGenerator()); + BarRenderer r2 = (BarRenderer) r1.clone(); + + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + r1 = new BarRenderer(); + r1.setSeriesItemLabelGenerator(0, + new IntervalCategoryItemLabelGenerator()); + r2 = (BarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + r1 = new BarRenderer(); + r1.setBaseItemLabelGenerator(new IntervalCategoryItemLabelGenerator()); + r2 = (BarRenderer) r1.clone(); + + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that the legendItemLabelGenerator is cloned. + */ + @Test + public void testCloning_LegendItemLabelGenerator() + throws CloneNotSupportedException { + StandardCategorySeriesLabelGenerator generator + = new StandardCategorySeriesLabelGenerator("Series {0}"); + BarRenderer r1 = new BarRenderer(); + r1.setLegendItemLabelGenerator(generator); + BarRenderer r2 = (BarRenderer) r1.clone(); + + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // check that the generator has been cloned + assertTrue(r1.getLegendItemLabelGenerator() + != r2.getLegendItemLabelGenerator()); + } + + /** + * Check that the legendItemToolTipGenerator is cloned. + */ + @Test + public void testCloning_LegendItemToolTipGenerator() + throws CloneNotSupportedException { + StandardCategorySeriesLabelGenerator generator + = new StandardCategorySeriesLabelGenerator("Series {0}"); + BarRenderer r1 = new BarRenderer(); + r1.setLegendItemToolTipGenerator(generator); + BarRenderer r2 = (BarRenderer) r1.clone(); + + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // check that the generator has been cloned + assertTrue(r1.getLegendItemToolTipGenerator() + != r2.getLegendItemToolTipGenerator()); + } + + /** + * Check that the legendItemURLGenerator is cloned. + */ + @Test + public void testCloning_LegendItemURLGenerator() + throws CloneNotSupportedException { + StandardCategorySeriesLabelGenerator generator + = new StandardCategorySeriesLabelGenerator("Series {0}"); + BarRenderer r1 = new BarRenderer(); + r1.setLegendItemURLGenerator(generator); + BarRenderer r2 = (BarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // check that the generator has been cloned + assertTrue(r1.getLegendItemURLGenerator() + != r2.getLegendItemURLGenerator()); + } + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + AbstractCategoryItemRenderer r = new LineAndShapeRenderer(); + assertNull(r.findRangeBounds(null)); + + // an empty dataset should return a null range + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + assertNull(r.findRangeBounds(dataset)); + + dataset.addValue(1.0, "R1", "C1"); + assertEquals(new Range(1.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(-2.0, "R1", "C2"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(null, "R1", "C3"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + } + + /** + * A test that reproduces the problem reported in bug 2947660. + */ + @Test + public void test2947660() { + AbstractCategoryItemRenderer r = new LineAndShapeRenderer(); + assertNotNull(r.getLegendItems()); + assertEquals(0, r.getLegendItems().getItemCount()); + + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + CategoryPlot plot = new CategoryPlot(); + plot.setDataset(dataset); + plot.setRenderer(r); + assertEquals(0, r.getLegendItems().getItemCount()); + + dataset.addValue(1.0, "S1", "C1"); + LegendItemCollection lic = r.getLegendItems(); + assertEquals(1, lic.getItemCount()); + assertEquals("S1", lic.get(0).getLabel()); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/AreaRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/AreaRendererTest.java new file mode 100755 index 0000000..037b6ac --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/AreaRendererTest.java @@ -0,0 +1,150 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * AreaRendererTest.java + * --------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 22-Oct-2003 : Added hashCode() test (DG); + * 11-Oct-2006 : Strengthened the testEquals() method (DG); + * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.renderer.AreaRendererEndType; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link AreaRenderer} class. + */ +public class AreaRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + AreaRenderer r1 = new AreaRenderer(); + AreaRenderer r2 = new AreaRenderer(); + assertEquals(r1, r2); + + r1.setEndType(AreaRendererEndType.LEVEL); + assertFalse(r1.equals(r2)); + r2.setEndType(AreaRendererEndType.LEVEL); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + AreaRenderer r1 = new AreaRenderer(); + AreaRenderer r2 = new AreaRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + AreaRenderer r1 = new AreaRenderer(); + AreaRenderer r2 = (AreaRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + AreaRenderer r1 = new AreaRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + AreaRenderer r1 = new AreaRenderer(); + AreaRenderer r2 = (AreaRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); + dataset0.addValue(21.0, "R1", "C1"); + dataset0.addValue(22.0, "R2", "C1"); + DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); + dataset1.addValue(23.0, "R3", "C1"); + dataset1.addValue(24.0, "R4", "C1"); + dataset1.addValue(25.0, "R5", "C1"); + AreaRenderer r = new AreaRenderer(); + CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, dataset1); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("R5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/BarRenderer3DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/BarRenderer3DTest.java new file mode 100755 index 0000000..4a4c095 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/BarRenderer3DTest.java @@ -0,0 +1,136 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * BarRenderer3DTest.java + * ---------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 22-Oct-2003 : Added hashCode test (DG); + * 07-Dec-2006 : Improved testEquals() (DG); + * 23-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link BarRenderer3D} class. + */ +public class BarRenderer3DTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + BarRenderer3D r1 = new BarRenderer3D(1.0, 2.0); + BarRenderer3D r2 = new BarRenderer3D(1.0, 2.0); + assertEquals(r1, r2); + + r1 = new BarRenderer3D(1.1, 2.0); + assertFalse(r1.equals(r2)); + r2 = new BarRenderer3D(1.1, 2.0); + assertTrue(r1.equals(r2)); + + r1 = new BarRenderer3D(1.1, 2.2); + assertFalse(r1.equals(r2)); + r2 = new BarRenderer3D(1.1, 2.2); + assertTrue(r1.equals(r2)); + + r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 4.0f, 3.0f, + Color.blue)); + assertFalse(r1.equals(r2)); + r2.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 4.0f, 3.0f, + Color.blue)); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + BarRenderer3D r1 = new BarRenderer3D(); + BarRenderer3D r2 = new BarRenderer3D(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + BarRenderer3D r1 = new BarRenderer3D(); + BarRenderer3D r2 = (BarRenderer3D) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + BarRenderer3D r1 = new BarRenderer3D(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + BarRenderer3D r1 = new BarRenderer3D(); + r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 4.0f, 3.0f, + Color.blue)); + BarRenderer3D r2 = (BarRenderer3D) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/BarRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/BarRendererTest.java new file mode 100755 index 0000000..cecc31f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/BarRendererTest.java @@ -0,0 +1,312 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * BarRendererTest.java + * -------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 19-Aug-2003 : Renamed HorizontalBarRendererTests --> BarRendererTests (DG); + * 22-Oct-2003 : Added hashCode test (DG); + * 18-May-2005 : Added field to equals() test (DG); + * 22-Sep-2005 : Renamed getMaxBarWidth() --> getMaximumBarWidth() (DG); + * 11-May-2007 : Added testGetLegendItem() (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * 25-Nov-2008 : Added testFindRangeBounds (DG); + * 16-May-2009 : Added series visibility check in testFindRangeBounds() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; + +import java.awt.Color; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.labels.ItemLabelAnchor; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.renderer.RendererChangeDetector; +import org.jfree.data.Range; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.ui.GradientPaintTransformType; +import org.jfree.ui.StandardGradientPaintTransformer; +import org.jfree.ui.TextAnchor; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link BarRenderer} class. + */ +public class BarRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + BarRenderer r1 = new BarRenderer(); + BarRenderer r2 = new BarRenderer(); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + // base value + r1.setBase(0.123); + assertFalse(r1.equals(r2)); + r2.setBase(0.123); + assertTrue(r1.equals(r2)); + + // itemMargin + r1.setItemMargin(0.22); + assertFalse(r1.equals(r2)); + r2.setItemMargin(0.22); + assertTrue(r1.equals(r2)); + + // drawBarOutline + r1.setDrawBarOutline(!r1.isDrawBarOutline()); + assertFalse(r1.equals(r2)); + r2.setDrawBarOutline(!r2.isDrawBarOutline()); + assertTrue(r1.equals(r2)); + + // maximumBarWidth + r1.setMaximumBarWidth(0.11); + assertFalse(r1.equals(r2)); + r2.setMaximumBarWidth(0.11); + assertTrue(r1.equals(r2)); + + // minimumBarLength + r1.setMinimumBarLength(0.04); + assertFalse(r1.equals(r2)); + r2.setMinimumBarLength(0.04); + assertTrue(r1.equals(r2)); + + // gradientPaintTransformer + r1.setGradientPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_VERTICAL)); + assertFalse(r1.equals(r2)); + r2.setGradientPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_VERTICAL)); + assertTrue(r1.equals(r2)); + + // positiveItemLabelPositionFallback + r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition( + ItemLabelAnchor.INSIDE1, TextAnchor.CENTER)); + assertFalse(r1.equals(r2)); + r2.setPositiveItemLabelPositionFallback(new ItemLabelPosition( + ItemLabelAnchor.INSIDE1, TextAnchor.CENTER)); + assertTrue(r1.equals(r2)); + + // negativeItemLabelPositionFallback + r1.setNegativeItemLabelPositionFallback(new ItemLabelPosition( + ItemLabelAnchor.INSIDE1, TextAnchor.CENTER)); + assertFalse(r1.equals(r2)); + r2.setNegativeItemLabelPositionFallback(new ItemLabelPosition( + ItemLabelAnchor.INSIDE1, TextAnchor.CENTER)); + assertTrue(r1.equals(r2)); + + // barPainter + r1.setBarPainter(new GradientBarPainter(0.1, 0.2, 0.3)); + assertFalse(r1.equals(r2)); + r2.setBarPainter(new GradientBarPainter(0.1, 0.2, 0.3)); + assertTrue(r1.equals(r2)); + + // shadowsVisible + r1.setShadowVisible(false); + assertFalse(r1.equals(r2)); + r2.setShadowVisible(false); + assertTrue(r1.equals(r2)); + + r1.setShadowPaint(Color.red); + assertFalse(r1.equals(r2)); + r2.setShadowPaint(Color.red); + assertTrue(r1.equals(r2)); + + // shadowXOffset + r1.setShadowXOffset(3.3); + assertFalse(r1.equals(r2)); + r2.setShadowXOffset(3.3); + assertTrue(r1.equals(r2)); + + // shadowYOffset + r1.setShadowYOffset(3.3); + assertFalse(r1.equals(r2)); + r2.setShadowYOffset(3.3); + assertTrue(r1.equals(r2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + BarRenderer r1 = new BarRenderer(); + BarRenderer r2 = new BarRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + BarRenderer r1 = new BarRenderer(); + r1.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); + r1.setBarPainter(new GradientBarPainter(0.11, 0.22, 0.33)); + BarRenderer r2 = (BarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + BarRenderer r1 = new BarRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + BarRenderer r1 = new BarRenderer(); + BarRenderer r2 = (BarRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Tests each setter method to ensure that it sends an event notification. + */ + @Test + public void testEventNotification() { + + RendererChangeDetector detector = new RendererChangeDetector(); + BarRenderer r1 = new BarRenderer(); + r1.addChangeListener(detector); + + detector.setNotified(false); + r1.setBasePaint(Color.red); + assertTrue(detector.getNotified()); + + } + + /** + * Some checks for the getLegendItem() method. + */ + @Test + public void testGetLegendItem() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(21.0, "R1", "C1"); + BarRenderer r = new BarRenderer(); + CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), + new NumberAxis("y"), r); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(0, 0); + assertNotNull(li); + r.setSeriesVisibleInLegend(0, Boolean.FALSE); + li = r.getLegendItem(0, 0); + assertNull(li); + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); + dataset0.addValue(21.0, "R1", "C1"); + dataset0.addValue(22.0, "R2", "C1"); + DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); + dataset1.addValue(23.0, "R3", "C1"); + dataset1.addValue(24.0, "R4", "C1"); + dataset1.addValue(25.0, "R5", "C1"); + BarRenderer r = new BarRenderer(); + CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, dataset1); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("R5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + BarRenderer r = new BarRenderer(); + assertNull(r.findRangeBounds(null)); + + // an empty dataset should return a null range + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + assertNull(r.findRangeBounds(dataset)); + + dataset.addValue(1.0, "R1", "C1"); + assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset)); + r.setIncludeBaseInRange(false); + assertEquals(new Range(1.0, 1.0), r.findRangeBounds(dataset)); + r.setIncludeBaseInRange(true); + + dataset.addValue(-2.0, "R1", "C2"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(null, "R1", "C3"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(-6.0, "R2", "C1"); + assertEquals(new Range(-6.0, 1.0), r.findRangeBounds(dataset)); + + r.setSeriesVisible(1, Boolean.FALSE); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/BoxAndWhiskerRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/BoxAndWhiskerRendererTest.java new file mode 100755 index 0000000..b67dba6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/BoxAndWhiskerRendererTest.java @@ -0,0 +1,557 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * BoxAndWhiskerRendererTest.java + * ------------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Oct-2003 : Version 1 (DG); + * 23-Apr-2004 : Extended testEquals() method (DG); + * 12-Oct-2006 : Added new checks for bug 1572478 (DG); + * 11-May-2007 : Added testGetLegendItem() (DG); + * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); + * 08-Oct-2007 : Added tests for null items in dataset (DG); + * 15-Jan-2008 : Updated testEquals() (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * 21-Jan-2009 : Updated testEquals() for new fields (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; + +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.ArrayList; +import java.util.List; + +import org.jfree.chart.ChartRenderingInfo; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.data.statistics.BoxAndWhiskerItem; +import org.jfree.data.statistics.DefaultBoxAndWhiskerCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link BoxAndWhiskerRenderer} class. + */ +public class BoxAndWhiskerRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer(); + BoxAndWhiskerRenderer r2 = new BoxAndWhiskerRenderer(); + assertEquals(r1, r2); + + r1.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.blue)); + assertFalse(r1.equals(r2)); + r2.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.blue)); + assertEquals(r1, r2); + + r1.setFillBox(!r1.getFillBox()); + assertFalse(r1.equals(r2)); + r2.setFillBox(!r2.getFillBox()); + assertEquals(r1, r2); + + r1.setItemMargin(0.11); + assertFalse(r1.equals(r2)); + r2.setItemMargin(0.11); + assertEquals(r1, r2); + + r1.setMaximumBarWidth(0.99); + assertFalse(r1.equals(r2)); + r2.setMaximumBarWidth(0.99); + assertTrue(r1.equals(r2)); + + r1.setMeanVisible(false); + assertFalse(r1.equals(r2)); + r2.setMeanVisible(false); + assertTrue(r1.equals(r2)); + + r1.setMedianVisible(false); + assertFalse(r1.equals(r2)); + r2.setMedianVisible(false); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer(); + BoxAndWhiskerRenderer r2 = new BoxAndWhiskerRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer(); + BoxAndWhiskerRenderer r2 = (BoxAndWhiskerRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + BoxAndWhiskerRenderer r1 = new BoxAndWhiskerRenderer(); + BoxAndWhiskerRenderer r2 = (BoxAndWhiskerRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (particularly by code in the renderer). + */ + @Test + public void testDrawWithNullInfo() { + try { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset(); + dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), + new Double(0.0), new Double(4.0), new Double(0.5), + new Double(4.5), new Double(-0.5), new Double(5.5), + null), "S1", "C1"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new BoxAndWhiskerRenderer()); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * A check for bug 1572478 (for the vertical orientation). + */ + @Test + public void testBug1572478Vertical() { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset() { + + @Override + public Number getQ1Value(int row, int column) { + return null; + } + + @Override + public Number getQ1Value(Comparable rowKey, Comparable columnKey) { + return null; + } + }; + List values = new ArrayList(); + values.add(new Double(1.0)); + values.add(new Double(10.0)); + values.add(new Double(100.0)); + dataset.add(values, "row", "column"); + CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), + new NumberAxis("y"), new BoxAndWhiskerRenderer()); + JFreeChart chart = new JFreeChart(plot); + boolean success; + + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + new ChartRenderingInfo()); + g2.dispose(); + success = true; + } + catch (Exception e) { + success = false; + } + + assertTrue(success); + + } + + /** + * A check for bug 1572478 (for the horizontal orientation). + */ + @Test + public void testBug1572478Horizontal() { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset() { + + @Override + public Number getQ1Value(int row, int column) { + return null; + } + + @Override + public Number getQ1Value(Comparable rowKey, Comparable columnKey) { + return null; + } + }; + List values = new ArrayList(); + values.add(new Double(1.0)); + values.add(new Double(10.0)); + values.add(new Double(100.0)); + dataset.add(values, "row", "column"); + CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), + new NumberAxis("y"), new BoxAndWhiskerRenderer()); + plot.setOrientation(PlotOrientation.HORIZONTAL); + JFreeChart chart = new JFreeChart(plot); + boolean success; + + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, + new ChartRenderingInfo()); + g2.dispose(); + success = true; + } + catch (Exception e) { + success = false; + } + + assertTrue(success); + + } + + /** + * Some checks for the getLegendItem() method. + */ + @Test + public void testGetLegendItem() { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset(); + List values = new ArrayList(); + values.add(new Double(1.10)); + values.add(new Double(1.45)); + values.add(new Double(1.33)); + values.add(new Double(1.23)); + dataset.add(values, "R1", "C1"); + BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer(); + CategoryPlot plot = new CategoryPlot(dataset, new CategoryAxis("x"), + new NumberAxis("y"), r); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(0, 0); + assertNotNull(li); + r.setSeriesVisibleInLegend(0, Boolean.FALSE); + li = r.getLegendItem(0, 0); + assertNull(li); + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); + dataset0.addValue(21.0, "R1", "C1"); + dataset0.addValue(22.0, "R2", "C1"); + DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); + dataset1.addValue(23.0, "R3", "C1"); + dataset1.addValue(24.0, "R4", "C1"); + dataset1.addValue(25.0, "R5", "C1"); + BoxAndWhiskerRenderer r = new BoxAndWhiskerRenderer(); + CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, dataset1); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("R5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + + /** + * Draws a chart where the dataset contains a null mean value. + */ + @Test + public void testDrawWithNullMean() { + boolean success; + try { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset(); + dataset.add(new BoxAndWhiskerItem(null, new Double(2.0), + new Double(0.0), new Double(4.0), new Double(0.5), + new Double(4.5), new Double(-0.5), new Double(5.5), + null), "S1", "C1"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new BoxAndWhiskerRenderer()); + ChartRenderingInfo info = new ChartRenderingInfo(); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + info); + success = true; + } + catch (Exception e) { + success = false; + } + assertTrue(success); + } + + /** + * Draws a chart where the dataset contains a null median value. + */ + @Test + public void testDrawWithNullMedian() { + boolean success; + try { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset(); + dataset.add(new BoxAndWhiskerItem(new Double(1.0), null, + new Double(0.0), new Double(4.0), new Double(0.5), + new Double(4.5), new Double(-0.5), new Double(5.5), + null), "S1", "C1"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new BoxAndWhiskerRenderer()); + ChartRenderingInfo info = new ChartRenderingInfo(); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + info); + success = true; + } + catch (Exception e) { + success = false; + } + assertTrue(success); + } + + /** + * Draws a chart where the dataset contains a null Q1 value. + */ + @Test + public void testDrawWithNullQ1() { + boolean success; + try { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset(); + dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), + null, new Double(4.0), new Double(0.5), + new Double(4.5), new Double(-0.5), new Double(5.5), + null), "S1", "C1"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new BoxAndWhiskerRenderer()); + ChartRenderingInfo info = new ChartRenderingInfo(); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + info); + success = true; + } + catch (Exception e) { + success = false; + } + assertTrue(success); + } + + /** + * Draws a chart where the dataset contains a null Q3 value. + */ + @Test + public void testDrawWithNullQ3() { + boolean success; + try { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset(); + dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), + new Double(3.0), null, new Double(0.5), + new Double(4.5), new Double(-0.5), new Double(5.5), + null), "S1", "C1"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new BoxAndWhiskerRenderer()); + ChartRenderingInfo info = new ChartRenderingInfo(); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + info); + success = true; + } + catch (Exception e) { + success = false; + } + assertTrue(success); + } + + /** + * Draws a chart where the dataset contains a null min regular value. + */ + @Test + public void testDrawWithNullMinRegular() { + boolean success; + try { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset(); + dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), + new Double(3.0), new Double(4.0), null, + new Double(4.5), new Double(-0.5), new Double(5.5), + null), "S1", "C1"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new BoxAndWhiskerRenderer()); + ChartRenderingInfo info = new ChartRenderingInfo(); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + info); + success = true; + } + catch (Exception e) { + success = false; + } + assertTrue(success); + } + + /** + * Draws a chart where the dataset contains a null max regular value. + */ + @Test + public void testDrawWithNullMaxRegular() { + try { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset(); + dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), + new Double(3.0), new Double(4.0), new Double(0.5), + null, new Double(-0.5), new Double(5.5), + null), "S1", "C1"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new BoxAndWhiskerRenderer()); + ChartRenderingInfo info = new ChartRenderingInfo(); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + info); + } + catch (Exception e) { + fail("No exception should be thrown."); + } + } + + /** + * Draws a chart where the dataset contains a null min outlier value. + */ + @Test + public void testDrawWithNullMinOutlier() { + boolean success; + try { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset(); + dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), + new Double(3.0), new Double(4.0), new Double(0.5), + new Double(4.5), null, new Double(5.5), + null), "S1", "C1"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new BoxAndWhiskerRenderer()); + ChartRenderingInfo info = new ChartRenderingInfo(); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + info); + success = true; + } + catch (Exception e) { + success = false; + } + assertTrue(success); + } + + /** + * Draws a chart where the dataset contains a null max outlier value. + */ + @Test + public void testDrawWithNullMaxOutlier() { + boolean success; + try { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset(); + dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), + new Double(3.0), new Double(4.0), new Double(0.5), + new Double(4.5), new Double(-0.5), null, + new java.util.ArrayList()), "S1", "C1"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new BoxAndWhiskerRenderer()); + ChartRenderingInfo info = new ChartRenderingInfo(); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + info); + success = true; + } + catch (Exception e) { + success = false; + } + assertTrue(success); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/CategoryStepRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/CategoryStepRendererTest.java new file mode 100755 index 0000000..2ee4a60 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/CategoryStepRendererTest.java @@ -0,0 +1,136 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * CategoryStepRendererTest.java + * ----------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Mar-2005 : Version 1 (DG); + * 22-Feb-2007 : Minor updates (DG); + * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); + * 23-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link CategoryStepRenderer} class. + */ +public class CategoryStepRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + CategoryStepRenderer r1 = new CategoryStepRenderer(false); + CategoryStepRenderer r2 = new CategoryStepRenderer(false); + assertEquals(r1, r2); + + r1 = new CategoryStepRenderer(true); + assertFalse(r1.equals(r2)); + r2 = new CategoryStepRenderer(true); + assertTrue(r1.equals(r2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CategoryStepRenderer r1 = new CategoryStepRenderer(false); + CategoryStepRenderer r2 = (CategoryStepRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + CategoryStepRenderer r1 = new CategoryStepRenderer(false); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CategoryStepRenderer r1 = new CategoryStepRenderer(); + CategoryStepRenderer r2 = (CategoryStepRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); + dataset0.addValue(21.0, "R1", "C1"); + dataset0.addValue(22.0, "R2", "C1"); + DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); + dataset1.addValue(23.0, "R3", "C1"); + dataset1.addValue(24.0, "R4", "C1"); + dataset1.addValue(25.0, "R5", "C1"); + CategoryStepRenderer r = new CategoryStepRenderer(); + CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, dataset1); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("R5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/DefaultCategoryItemRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/DefaultCategoryItemRendererTest.java new file mode 100755 index 0000000..f95a7ee --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/DefaultCategoryItemRendererTest.java @@ -0,0 +1,114 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------ + * DefaultCategoryItemRendererTest.java + * ------------------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Apr-2003 : Version 1 (DG); + * 22-Oct-2003 : Added hashCode test (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link DefaultCategoryItemRenderer} class. + */ +public class DefaultCategoryItemRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer(); + DefaultCategoryItemRenderer r2 = new DefaultCategoryItemRenderer(); + assertEquals(r1, r2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer(); + DefaultCategoryItemRenderer r2 = new DefaultCategoryItemRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer(); + DefaultCategoryItemRenderer r2 = (DefaultCategoryItemRenderer) + r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultCategoryItemRenderer r1 = new DefaultCategoryItemRenderer(); + DefaultCategoryItemRenderer r2 = (DefaultCategoryItemRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/GanttRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/GanttRendererTest.java new file mode 100755 index 0000000..9dc1a83 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/GanttRendererTest.java @@ -0,0 +1,140 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * GanttRendererTest.java + * ---------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Oct-2003 : Version 1 (DG); + * 20-Mar-2007 : Extended testEquals() (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link GanttRenderer} class. + */ +public class GanttRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + GanttRenderer r1 = new GanttRenderer(); + GanttRenderer r2 = new GanttRenderer(); + assertEquals(r1, r2); + + r1.setCompletePaint(Color.yellow); + assertFalse(r1.equals(r2)); + r2.setCompletePaint(Color.yellow); + assertTrue(r1.equals(r2)); + + r1.setIncompletePaint(Color.green); + assertFalse(r1.equals(r2)); + r2.setIncompletePaint(Color.green); + assertTrue(r1.equals(r2)); + + r1.setStartPercent(0.11); + assertFalse(r1.equals(r2)); + r2.setStartPercent(0.11); + assertTrue(r1.equals(r2)); + + r1.setEndPercent(0.88); + assertFalse(r1.equals(r2)); + r2.setEndPercent(0.88); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + GanttRenderer r1 = new GanttRenderer(); + GanttRenderer r2 = new GanttRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + GanttRenderer r1 = new GanttRenderer(); + GanttRenderer r2 = (GanttRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + GanttRenderer r1 = new GanttRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + GanttRenderer r1 = new GanttRenderer(); + r1.setCompletePaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.blue)); + r1.setIncompletePaint(new GradientPaint(4.0f, 3.0f, Color.red, 2.0f, + 1.0f, Color.blue)); + GanttRenderer r2 = (GanttRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/GradientBarPainterTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/GradientBarPainterTest.java new file mode 100755 index 0000000..2664fe8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/GradientBarPainterTest.java @@ -0,0 +1,116 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * GradientBarPainterTest.java + * --------------------------- + * (C) Copyright 2008-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Jun-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link GradientBarPainter} class. + */ +public class GradientBarPainterTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + GradientBarPainter p1 = new GradientBarPainter(0.1, 0.2, 0.3); + GradientBarPainter p2 = new GradientBarPainter(0.1, 0.2, 0.3); + assertEquals(p1, p2); + + p1 = new GradientBarPainter(0.11, 0.2, 0.3); + assertFalse(p1.equals(p2)); + p2 = new GradientBarPainter(0.11, 0.2, 0.3); + assertTrue(p1.equals(p2)); + + p1 = new GradientBarPainter(0.11, 0.22, 0.3); + assertFalse(p1.equals(p2)); + p2 = new GradientBarPainter(0.11, 0.22, 0.3); + assertTrue(p1.equals(p2)); + + p1 = new GradientBarPainter(0.11, 0.22, 0.33); + assertFalse(p1.equals(p2)); + p2 = new GradientBarPainter(0.11, 0.22, 0.33); + assertTrue(p1.equals(p2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + GradientBarPainter p1 = new GradientBarPainter(0.1, 0.2, 0.3); + GradientBarPainter p2 = new GradientBarPainter(0.1, 0.2, 0.3); + assertTrue(p1.equals(p2)); + int h1 = p1.hashCode(); + int h2 = p2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning isn't implemented (it isn't required, because + * instances of the class are immutable). + */ + @Test + public void testCloning() { + GradientBarPainter p1 = new GradientBarPainter(0.1, 0.2, 0.3); + assertFalse(p1 instanceof Cloneable); + assertFalse(p1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + GradientBarPainter p1 = new GradientBarPainter(0.1, 0.2, 0.3); + GradientBarPainter p2 = (GradientBarPainter) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/GroupedStackedBarRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/GroupedStackedBarRendererTest.java new file mode 100755 index 0000000..3336a1c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/GroupedStackedBarRendererTest.java @@ -0,0 +1,179 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------- + * GroupedStackedBarRendererTest.java + * ---------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Jul-2004 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.data.KeyToGroupMap; +import org.jfree.data.Range; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link GroupedStackedBarRenderer} class. + */ +public class GroupedStackedBarRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer(); + GroupedStackedBarRenderer r2 = new GroupedStackedBarRenderer(); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + // map + KeyToGroupMap m1 = new KeyToGroupMap("G1"); + m1.mapKeyToGroup("S1", "G2"); + r1.setSeriesToGroupMap(m1); + assertFalse(r1.equals(r2)); + KeyToGroupMap m2 = new KeyToGroupMap("G1"); + m2.mapKeyToGroup("S1", "G2"); + r2.setSeriesToGroupMap(m2); + assertTrue(r1.equals(r2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer(); + GroupedStackedBarRenderer r2 = (GroupedStackedBarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + GroupedStackedBarRenderer r1 = new GroupedStackedBarRenderer(); + GroupedStackedBarRenderer r2 = (GroupedStackedBarRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (particularly by code in the renderer). + */ + @Test + public void testDrawWithNullInfo() { + try { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(1.0, "S1", "C1"); + dataset.addValue(2.0, "S1", "C2"); + dataset.addValue(3.0, "S2", "C1"); + dataset.addValue(4.0, "S2", "C2"); + GroupedStackedBarRenderer renderer + = new GroupedStackedBarRenderer(); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + renderer); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + GroupedStackedBarRenderer r = new GroupedStackedBarRenderer(); + assertNull(r.findRangeBounds(null)); + + // an empty dataset should return a null range + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + assertNull(r.findRangeBounds(dataset)); + + dataset.addValue(1.0, "R1", "C1"); + assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(-2.0, "R1", "C2"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(null, "R1", "C3"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + + KeyToGroupMap m = new KeyToGroupMap("G1"); + m.mapKeyToGroup("R1", "G1"); + m.mapKeyToGroup("R2", "G1"); + m.mapKeyToGroup("R3", "G2"); + r.setSeriesToGroupMap(m); + + dataset.addValue(0.5, "R3", "C1"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(5.0, "R3", "C2"); + assertEquals(new Range(-2.0, 5.0), r.findRangeBounds(dataset)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/IntervalBarRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/IntervalBarRendererTest.java new file mode 100755 index 0000000..0da5f6a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/IntervalBarRendererTest.java @@ -0,0 +1,175 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * IntervalBarRendererTest.java + * ---------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable (DG); + * 16-May-2009 : Added testFindRangeBounds() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.data.Range; +import org.jfree.data.category.DefaultIntervalCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link IntervalBarRenderer} class. + */ +public class IntervalBarRendererTest { + + /** + * Problem that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + IntervalBarRenderer r1 = new IntervalBarRenderer(); + IntervalBarRenderer r2 = new IntervalBarRenderer(); + assertEquals(r1, r2); + + // the renderer should not be equal to a BarRenderer + BarRenderer br = new BarRenderer(); + assertFalse(r1.equals(br)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + IntervalBarRenderer r1 = new IntervalBarRenderer(); + IntervalBarRenderer r2 = new IntervalBarRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + IntervalBarRenderer r1 = new IntervalBarRenderer(); + IntervalBarRenderer r2 = (IntervalBarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + IntervalBarRenderer r1 = new IntervalBarRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + IntervalBarRenderer r1 = new IntervalBarRenderer(); + IntervalBarRenderer r2 = (IntervalBarRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (particularly by code in the renderer). + */ + @Test + public void testDrawWithNullInfo() { + try { + double[][] starts = new double[][] {{0.1, 0.2, 0.3}, + {0.3, 0.4, 0.5}}; + double[][] ends = new double[][] {{0.5, 0.6, 0.7}, {0.7, 0.8, 0.9}}; + DefaultIntervalCategoryDataset dataset + = new DefaultIntervalCategoryDataset(starts, ends); + IntervalBarRenderer renderer = new IntervalBarRenderer(); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + renderer); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + IntervalBarRenderer r = new IntervalBarRenderer(); + assertNull(r.findRangeBounds(null)); + + // an empty dataset should return a null range + DefaultIntervalCategoryDataset dataset + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + assertNull(r.findRangeBounds(dataset)); + + double[][] starts = new double[][] {{0.1, 0.2, 0.3}, {0.3, 0.4, 0.5}}; + double[][] ends = new double[][] {{0.5, 0.6, 0.7}, {0.7, 0.8, 0.9}}; + dataset = new DefaultIntervalCategoryDataset(starts, ends); + assertEquals(new Range(0.0, 0.9), r.findRangeBounds(dataset)); + r.setIncludeBaseInRange(false); + assertEquals(new Range(0.1, 0.9), r.findRangeBounds(dataset)); + r.setIncludeBaseInRange(true); + + r.setSeriesVisible(1, Boolean.FALSE); + assertEquals(new Range(0.0, 0.7), r.findRangeBounds(dataset)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/LayeredBarRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/LayeredBarRendererTest.java new file mode 100755 index 0000000..c3de8e9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/LayeredBarRendererTest.java @@ -0,0 +1,137 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * LayeredBarRendererTest.java + * --------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Oct-2003 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link LayeredBarRenderer} class. + */ +public class LayeredBarRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + LayeredBarRenderer r1 = new LayeredBarRenderer(); + LayeredBarRenderer r2 = new LayeredBarRenderer(); + assertEquals(r1, r2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + LayeredBarRenderer r1 = new LayeredBarRenderer(); + LayeredBarRenderer r2 = new LayeredBarRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + LayeredBarRenderer r1 = new LayeredBarRenderer(); + LayeredBarRenderer r2 = (LayeredBarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + LayeredBarRenderer r1 = new LayeredBarRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + LayeredBarRenderer r1 = new LayeredBarRenderer(); + LayeredBarRenderer r2 = (LayeredBarRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (particularly by code in the renderer). + */ + @Test + public void testDrawWithNullInfo() { + try { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(1.0, "S1", "C1"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new LayeredBarRenderer()); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/LevelRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/LevelRendererTest.java new file mode 100755 index 0000000..78007d6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/LevelRendererTest.java @@ -0,0 +1,203 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * LevelRendererTest.java + * ---------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Mar-2005 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link LevelRenderer} class. + */ +public class LevelRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + LevelRenderer r1 = new LevelRenderer(); + LevelRenderer r2 = new LevelRenderer(); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + r1.setItemMargin(0.123); + assertFalse(r1.equals(r2)); + r2.setItemMargin(0.123); + assertTrue(r1.equals(r2)); + + r1.setMaximumItemWidth(0.234); + assertFalse(r1.equals(r2)); + r2.setMaximumItemWidth(0.234); + assertTrue(r1.equals(r2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + LevelRenderer r1 = new LevelRenderer(); + LevelRenderer r2 = new LevelRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + LevelRenderer r1 = new LevelRenderer(); + r1.setItemMargin(0.123); + r1.setMaximumItemWidth(0.234); + LevelRenderer r2 = (LevelRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + assertTrue(checkIndependence(r1, r2)); + + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + LevelRenderer r1 = new LevelRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Checks that the two renderers are equal but independent of one another. + * + * @param r1 renderer 1. + * @param r2 renderer 2. + * + * @return A boolean. + */ + private boolean checkIndependence(LevelRenderer r1, LevelRenderer r2) { + + // should be equal... + boolean b0 = r1.equals(r2); + + // and independent... + r1.setItemMargin(0.0); + boolean b1 = !r1.equals(r2); + r2.setItemMargin(0.0); + boolean b2 = r1.equals(r2); + + return b0 && b1 && b2; + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + LevelRenderer r1 = new LevelRenderer(); + LevelRenderer r2 = (LevelRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (particularly by code in the renderer). + */ + @Test + public void testDrawWithNullInfo() { + try { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(1.0, "S1", "C1"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new LevelRenderer()); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); + dataset0.addValue(21.0, "R1", "C1"); + dataset0.addValue(22.0, "R2", "C1"); + DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); + dataset1.addValue(23.0, "R3", "C1"); + dataset1.addValue(24.0, "R4", "C1"); + dataset1.addValue(25.0, "R5", "C1"); + LevelRenderer r = new LevelRenderer(); + CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, dataset1); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("R5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/LineAndShapeRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/LineAndShapeRendererTest.java new file mode 100755 index 0000000..8a62f3c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/LineAndShapeRendererTest.java @@ -0,0 +1,348 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * LineAndShapeRendererTest.java + * ----------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Sep-2003 : Version 1 (DG); + * 17-May-2007 : Added check for getLegendItem() method (DG); + * 27-Sep-2007 : Extended equals() test (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * 16-May-2009 : Added testFindRangeBounds() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.data.Range; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link LineAndShapeRenderer} class. + */ +public class LineAndShapeRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + + LineAndShapeRenderer r1 = new LineAndShapeRenderer(); + LineAndShapeRenderer r2 = new LineAndShapeRenderer(); + assertEquals(r1, r2); + + r1.setBaseLinesVisible(!r1.getBaseLinesVisible()); + assertFalse(r1.equals(r2)); + r2.setBaseLinesVisible(r1.getBaseLinesVisible()); + assertTrue(r1.equals(r2)); + + r1.setSeriesLinesVisible(1, true); + assertFalse(r1.equals(r2)); + r2.setSeriesLinesVisible(1, true); + assertTrue(r1.equals(r2)); + + r1.setLinesVisible(false); + assertFalse(r1.equals(r2)); + r2.setLinesVisible(false); + assertTrue(r1.equals(r2)); + + r1.setBaseShapesVisible(!r1.getBaseShapesVisible()); + assertFalse(r1.equals(r2)); + r2.setBaseShapesVisible(r1.getBaseShapesVisible()); + assertTrue(r1.equals(r2)); + + r1.setSeriesShapesVisible(1, true); + assertFalse(r1.equals(r2)); + r2.setSeriesShapesVisible(1, true); + assertTrue(r1.equals(r2)); + + r1.setShapesVisible(false); + assertFalse(r1.equals(r2)); + r2.setShapesVisible(false); + assertTrue(r1.equals(r2)); + + r1.setShapesFilled(false); + assertFalse(r1.equals(r2)); + r2.setShapesFilled(false); + assertTrue(r1.equals(r2)); + + r1.setSeriesShapesFilled(1, true); + assertFalse(r1.equals(r2)); + r2.setSeriesShapesFilled(1, true); + assertTrue(r1.equals(r2)); + + r1.setBaseShapesFilled(false); + assertFalse(r1.equals(r2)); + r2.setBaseShapesFilled(false); + assertTrue(r1.equals(r2)); + + r1.setUseOutlinePaint(true); + assertFalse(r1.equals(r2)); + r2.setUseOutlinePaint(true); + assertTrue(r1.equals(r2)); + + r1.setUseSeriesOffset(true); + assertFalse(r1.equals(r2)); + r2.setUseSeriesOffset(true); + assertTrue(r1.equals(r2)); + + r1.setItemMargin(0.14); + assertFalse(r1.equals(r2)); + r2.setItemMargin(0.14); + assertTrue(r1.equals(r2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + LineAndShapeRenderer r1 = new LineAndShapeRenderer(); + LineAndShapeRenderer r2 = new LineAndShapeRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + LineAndShapeRenderer r1 = new LineAndShapeRenderer(); + LineAndShapeRenderer r2 = (LineAndShapeRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + assertTrue(checkIndependence(r1, r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + LineAndShapeRenderer r1 = new LineAndShapeRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Checks that the two renderers are equal but independent of one another. + * + * @param r1 renderer 1. + * @param r2 renderer 2. + * + * @return A boolean. + */ + private boolean checkIndependence(LineAndShapeRenderer r1, + LineAndShapeRenderer r2) { + + // should be equal... + if (!r1.equals(r2)) { + return false; + } + + // and independent... + r1.setBaseLinesVisible(!r1.getBaseLinesVisible()); + if (r1.equals(r2)) { + return false; + } + r2.setBaseLinesVisible(r1.getBaseLinesVisible()); + if (!r1.equals(r2)) { + return false; + } + + r1.setSeriesLinesVisible(1, true); + if (r1.equals(r2)) { + return false; + } + r2.setSeriesLinesVisible(1, true); + if (!r1.equals(r2)) { + return false; + } + + r1.setLinesVisible(false); + if (r1.equals(r2)) { + return false; + } + r2.setLinesVisible(false); + if (!r1.equals(r2)) { + return false; + } + + r1.setBaseShapesVisible(!r1.getBaseShapesVisible()); + if (r1.equals(r2)) { + return false; + } + r2.setBaseShapesVisible(r1.getBaseShapesVisible()); + if (!r1.equals(r2)) { + return false; + } + + r1.setSeriesShapesVisible(1, true); + if (r1.equals(r2)) { + return false; + } + r2.setSeriesShapesVisible(1, true); + if (!r1.equals(r2)) { + return false; + } + + r1.setShapesVisible(false); + if (r1.equals(r2)) { + return false; + } + r2.setShapesVisible(false); + if (!r1.equals(r2)) { + return false; + } + + boolean flag = true; + Boolean existing = r1.getShapesFilled(); + if (existing != null) { + flag = !existing.booleanValue(); + } + r1.setShapesFilled(flag); + if (r1.equals(r2)) { + return false; + } + r2.setShapesFilled(flag); + if (!r1.equals(r2)) { + return false; + } + + r1.setShapesFilled(false); + r2.setShapesFilled(false); + r1.setSeriesShapesFilled(0, false); + r2.setSeriesShapesFilled(0, true); + if (r1.equals(r2)) { + return false; + } + r2.setSeriesShapesFilled(0, false); + if (!r1.equals(r2)) { + return false; + } + + r1.setBaseShapesFilled(false); + r2.setBaseShapesFilled(true); + if (r1.equals(r2)) { + return false; + } + r2.setBaseShapesFilled(false); + if (!r1.equals(r2)) { + return false; + } + return true; + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + LineAndShapeRenderer r1 = new LineAndShapeRenderer(); + LineAndShapeRenderer r2 = (LineAndShapeRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + DefaultCategoryDataset dataset0 = new DefaultCategoryDataset(); + dataset0.addValue(21.0, "R1", "C1"); + dataset0.addValue(22.0, "R2", "C1"); + DefaultCategoryDataset dataset1 = new DefaultCategoryDataset(); + dataset1.addValue(23.0, "R3", "C1"); + dataset1.addValue(24.0, "R4", "C1"); + dataset1.addValue(25.0, "R5", "C1"); + LineAndShapeRenderer r = new LineAndShapeRenderer(); + CategoryPlot plot = new CategoryPlot(dataset0, new CategoryAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, dataset1); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("R5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + LineAndShapeRenderer r = new LineAndShapeRenderer(); + assertNull(r.findRangeBounds(null)); + + // an empty dataset should return a null range + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + assertNull(r.findRangeBounds(dataset)); + + dataset.addValue(1.0, "R1", "C1"); + assertEquals(new Range(1.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(-2.0, "R1", "C2"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(null, "R1", "C3"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(-6.0, "R2", "C1"); + assertEquals(new Range(-6.0, 1.0), r.findRangeBounds(dataset)); + + r.setSeriesVisible(1, Boolean.FALSE); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/LineRenderer3DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/LineRenderer3DTest.java new file mode 100755 index 0000000..452428c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/LineRenderer3DTest.java @@ -0,0 +1,229 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * LineRenderer3DTest.java + * ----------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 15-Oct-2004 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link LineRenderer3D} class. + */ +public class LineRenderer3DTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + LineRenderer3D r1 = new LineRenderer3D(); + LineRenderer3D r2 = new LineRenderer3D(); + assertEquals(r1, r2); + + r1.setXOffset(99.9); + assertFalse(r1.equals(r2)); + r2.setXOffset(99.9); + assertTrue(r1.equals(r2)); + + r1.setYOffset(111.1); + assertFalse(r1.equals(r2)); + r2.setYOffset(111.1); + assertTrue(r1.equals(r2)); + + r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue)); + assertFalse(r1.equals(r2)); + r2.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue)); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + LineRenderer3D r1 = new LineRenderer3D(); + LineRenderer3D r2 = new LineRenderer3D(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + LineRenderer3D r1 = new LineRenderer3D(); + LineRenderer3D r2 = (LineRenderer3D) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + assertTrue(checkIndependence(r1, r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + LineRenderer3D r1 = new LineRenderer3D(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Checks that the two renderers are equal but independent of one another. + * + * @param r1 renderer 1. + * @param r2 renderer 2. + * + * @return A boolean. + */ + private boolean checkIndependence(LineRenderer3D r1, LineRenderer3D r2) { + + // should be equal... + boolean b0 = r1.equals(r2); + + // and independent... + r1.setBaseLinesVisible(!r1.getBaseLinesVisible()); + if (r1.equals(r2)) { + return false; + } + r2.setBaseLinesVisible(r1.getBaseLinesVisible()); + if (!r1.equals(r2)) { + return false; + } + + r1.setSeriesLinesVisible(1, true); + if (r1.equals(r2)) { + return false; + } + r2.setSeriesLinesVisible(1, true); + if (!r1.equals(r2)) { + return false; + } + + r1.setLinesVisible(false); + if (r1.equals(r2)) { + return false; + } + r2.setLinesVisible(false); + if (!r1.equals(r2)) { + return false; + } + + r1.setBaseShapesVisible(!r1.getBaseShapesVisible()); + if (r1.equals(r2)) { + return false; + } + r2.setBaseShapesVisible(r1.getBaseShapesVisible()); + if (!r1.equals(r2)) { + return false; + } + + r1.setSeriesShapesVisible(1, true); + if (r1.equals(r2)) { + return false; + } + r2.setSeriesShapesVisible(1, true); + if (!r1.equals(r2)) { + return false; + } + + r1.setShapesVisible(false); + if (r1.equals(r2)) { + return false; + } + r2.setShapesVisible(false); + if (!r1.equals(r2)) { + return false; + } + + boolean flag = true; + Boolean existing = r1.getShapesFilled(); + if (existing != null) { + flag = !existing.booleanValue(); + } + r1.setShapesFilled(flag); + boolean b5 = !r1.equals(r2); + r2.setShapesFilled(flag); + boolean b6 = r1.equals(r2); + + r1.setShapesFilled(false); + r2.setShapesFilled(false); + r1.setSeriesShapesFilled(0, false); + r2.setSeriesShapesFilled(0, true); + boolean b7 = !r1.equals(r2); + r2.setSeriesShapesFilled(0, false); + boolean b8 = (r1.equals(r2)); + + r1.setBaseShapesFilled(false); + r2.setBaseShapesFilled(true); + boolean b9 = !r1.equals(r2); + r2.setBaseShapesFilled(false); + boolean b10 = (r1.equals(r2)); + + return b0 && b5 && b6 && b7 && b8 && b9 && b10; + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + LineRenderer3D r1 = new LineRenderer3D(); + LineRenderer3D r2 = (LineRenderer3D) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/MinMaxCategoryRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/MinMaxCategoryRendererTest.java new file mode 100755 index 0000000..8a3a969 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/MinMaxCategoryRendererTest.java @@ -0,0 +1,161 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * MinMaxCategoryRendererTest.java + * ------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Oct-2003 : Version 1 (DG); + * 28-Sep-2007 : Added testEquals() method (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link MinMaxCategoryRenderer} class. + */ +public class MinMaxCategoryRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer(); + MinMaxCategoryRenderer r2 = new MinMaxCategoryRenderer(); + assertEquals(r1, r2); + + r1.setDrawLines(true); + assertFalse(r1.equals(r2)); + r2.setDrawLines(true); + assertTrue(r1.equals(r2)); + + r1.setGroupPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.yellow)); + assertFalse(r1.equals(r2)); + r2.setGroupPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.yellow)); + assertTrue(r1.equals(r2)); + + r1.setGroupStroke(new BasicStroke(1.2f)); + assertFalse(r1.equals(r2)); + r2.setGroupStroke(new BasicStroke(1.2f)); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer(); + MinMaxCategoryRenderer r2 = new MinMaxCategoryRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer(); + MinMaxCategoryRenderer r2 = (MinMaxCategoryRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + MinMaxCategoryRenderer r1 = new MinMaxCategoryRenderer(); + MinMaxCategoryRenderer r2 = (MinMaxCategoryRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (particularly by code in the renderer). + */ + @Test + public void testDrawWithNullInfo() { + try { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(1.0, "S1", "C1"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new MinMaxCategoryRenderer()); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail(); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/ScatterRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/ScatterRendererTest.java new file mode 100755 index 0000000..e83cdc2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/ScatterRendererTest.java @@ -0,0 +1,227 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * ScatterRendererTest.java + * ------------------------ + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Oct-2007 : Version 1 (DG); + * 11-Oct-2007 : Renamed ScatterRenderer (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * 16-May-2009 : Added testFindRangeBounds() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + +import java.util.Arrays; +import java.util.List; +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.data.statistics.DefaultMultiValueCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link ScatterRenderer} class. + */ +public class ScatterRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + + ScatterRenderer r1 = new ScatterRenderer(); + ScatterRenderer r2 = new ScatterRenderer(); + assertEquals(r1, r2); + + r1.setSeriesShapesFilled(1, true); + assertFalse(r1.equals(r2)); + r2.setSeriesShapesFilled(1, true); + assertTrue(r1.equals(r2)); + + r1.setBaseShapesFilled(false); + assertFalse(r1.equals(r2)); + r2.setBaseShapesFilled(false); + assertTrue(r1.equals(r2)); + + r1.setUseFillPaint(true); + assertFalse(r1.equals(r2)); + r2.setUseFillPaint(true); + assertTrue(r1.equals(r2)); + + r1.setDrawOutlines(true); + assertFalse(r1.equals(r2)); + r2.setDrawOutlines(true); + assertTrue(r1.equals(r2)); + + r1.setUseOutlinePaint(true); + assertFalse(r1.equals(r2)); + r2.setUseOutlinePaint(true); + assertTrue(r1.equals(r2)); + + r1.setUseSeriesOffset(false); + assertFalse(r1.equals(r2)); + r2.setUseSeriesOffset(false); + assertTrue(r1.equals(r2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + ScatterRenderer r1 = new ScatterRenderer(); + ScatterRenderer r2 = new ScatterRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ScatterRenderer r1 = new ScatterRenderer(); + ScatterRenderer r2 = (ScatterRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + assertTrue(checkIndependence(r1, r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + ScatterRenderer r1 = new ScatterRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Checks that the two renderers are equal but independent of one another. + * + * @param r1 renderer 1. + * @param r2 renderer 2. + * + * @return A boolean. + */ + private boolean checkIndependence(ScatterRenderer r1, + ScatterRenderer r2) { + + // should be equal... + if (!r1.equals(r2)) { + return false; + } + + // and independent... + r1.setSeriesShapesFilled(1, true); + if (r1.equals(r2)) { + return false; + } + r2.setSeriesShapesFilled(1, true); + if (!r1.equals(r2)) { + return false; + } + + r1.setBaseShapesFilled(false); + r2.setBaseShapesFilled(true); + if (r1.equals(r2)) { + return false; + } + r2.setBaseShapesFilled(false); + if (!r1.equals(r2)) { + return false; + } + return true; + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ScatterRenderer r1 = new ScatterRenderer(); + ScatterRenderer r2 = (ScatterRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + ScatterRenderer r = new ScatterRenderer(); + assertNull(r.findRangeBounds(null)); + + // an empty dataset should return a null range + DefaultMultiValueCategoryDataset dataset + = new DefaultMultiValueCategoryDataset(); + assertNull(r.findRangeBounds(dataset)); + + List values = Arrays.asList(new Double[] {new Double(1.0)}); + dataset.add(values, "R1", "C1"); + assertEquals(new Range(1.0, 1.0), r.findRangeBounds(dataset)); + + values = Arrays.asList(new Double[] {new Double(2.0), new Double(2.2)}); + dataset.add(values, "R1", "C2"); + assertEquals(new Range(1.0, 2.2), r.findRangeBounds(dataset)); + + values = Arrays.asList(new Double[] {new Double(-3.0), + new Double(-3.2)}); + dataset.add(values, "R1", "C3"); + assertEquals(new Range(-3.2, 2.2), r.findRangeBounds(dataset)); + + values = Arrays.asList(new Double[] {new Double(6.0)}); + dataset.add(values, "R2", "C1"); + assertEquals(new Range(-3.2, 6.0), r.findRangeBounds(dataset)); + + r.setSeriesVisible(1, Boolean.FALSE); + assertEquals(new Range(-3.2, 2.2), r.findRangeBounds(dataset)); + } + + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StackedAreaRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StackedAreaRendererTest.java new file mode 100755 index 0000000..0520876 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StackedAreaRendererTest.java @@ -0,0 +1,150 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * StackedAreaRendererTest.java + * ---------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * 04-Feb-2009 : Added testFindRangeBounds (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StackedAreaRenderer} class. + */ +public class StackedAreaRendererTest { + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + StackedAreaRenderer r = new StackedAreaRenderer(); + assertNull(r.findRangeBounds(null)); + + // an empty dataset should return a null range + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + assertNull(r.findRangeBounds(dataset)); + + dataset.addValue(1.0, "R1", "C1"); + assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(-2.0, "R1", "C2"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(null, "R1", "C3"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(2.0, "R2", "C1"); + assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset)); + + dataset.addValue(null, "R2", "C2"); + assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset)); + } + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + StackedAreaRenderer r1 = new StackedAreaRenderer(); + StackedAreaRenderer r2 = new StackedAreaRenderer(); + assertEquals(r1, r2); + + r1.setRenderAsPercentages(true); + assertFalse(r1.equals(r2)); + r2.setRenderAsPercentages(true); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + StackedAreaRenderer r1 = new StackedAreaRenderer(); + StackedAreaRenderer r2 = new StackedAreaRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StackedAreaRenderer r1 = new StackedAreaRenderer(); + StackedAreaRenderer r2 = (StackedAreaRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + StackedAreaRenderer r1 = new StackedAreaRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StackedAreaRenderer r1 = new StackedAreaRenderer(); + StackedAreaRenderer r2 = (StackedAreaRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StackedBarRenderer3DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StackedBarRenderer3DTest.java new file mode 100755 index 0000000..a060629 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StackedBarRenderer3DTest.java @@ -0,0 +1,433 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * StackedBarRenderer3DTest.java + * ----------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 18-Jan-2007 : Added many new tests (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * 03-Feb-2009 : Added testFindRangeBounds() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; + +import java.util.List; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StackedBarRenderer3D} class. + */ +public class StackedBarRenderer3DTest { + + /** + * Provide access to protected method. + */ + static class MyRenderer extends StackedBarRenderer3D { + @Override + public List createStackedValueList(CategoryDataset dataset, + Comparable category, int[] includedRows, double base, + boolean asPercentages) { + return super.createStackedValueList(dataset, category, + includedRows, base, asPercentages); + } + } + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + StackedBarRenderer3D r = new StackedBarRenderer3D(); + assertNull(r.findRangeBounds(null)); + + // an empty dataset should return a null range + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + assertNull(r.findRangeBounds(dataset)); + + dataset.addValue(1.0, "R1", "C1"); + assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(-2.0, "R1", "C2"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(null, "R1", "C3"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(2.0, "R2", "C1"); + assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset)); + + dataset.addValue(null, "R2", "C2"); + assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset)); + } + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + StackedBarRenderer3D r1 = new StackedBarRenderer3D(); + StackedBarRenderer3D r2 = new StackedBarRenderer3D(); + assertEquals(r1, r2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + StackedBarRenderer3D r1 = new StackedBarRenderer3D(); + StackedBarRenderer3D r2 = new StackedBarRenderer3D(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StackedBarRenderer3D r1 = new StackedBarRenderer3D(); + StackedBarRenderer3D r2 = (StackedBarRenderer3D) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + StackedBarRenderer3D r1 = new StackedBarRenderer3D(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StackedBarRenderer3D r1 = new StackedBarRenderer3D(); + StackedBarRenderer3D r2 = (StackedBarRenderer3D) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList1() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(1.0, "s0", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0 }, 0.0, false); + assertEquals(2, l.size()); + assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); + assertEquals(new Double(1.0), ((Object[]) l.get(1))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList2() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(-1.0, "s0", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0 }, 0.0, false); + assertEquals(2, l.size()); + assertEquals(new Double(-1.0), ((Object[]) l.get(0))[1]); + assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList3() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(0.0, "s0", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0 }, 0.0, false); + assertEquals(2, l.size()); + assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); + assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList4() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(null, "s0", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0 }, 0.0, false); + assertEquals(0, l.size()); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList1a() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(1.0, "s0", "c0"); + d.addValue(1.1, "s1", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0, + false); + assertEquals(3, l.size()); + assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); + assertEquals(new Double(1.0), ((Object[]) l.get(1))[1]); + assertEquals(new Double(2.1), ((Object[]) l.get(2))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList1b() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(1.0, "s0", "c0"); + d.addValue(-1.1, "s1", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0, + false); + assertEquals(3, l.size()); + assertEquals(new Double(-1.1), ((Object[]) l.get(0))[1]); + assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); + assertEquals(new Double(1.0), ((Object[]) l.get(2))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList1c() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(1.0, "s0", "c0"); + d.addValue(0.0, "s1", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0, + false); + assertEquals(3, l.size()); + assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); + assertEquals(new Double(1.0), ((Object[]) l.get(1))[1]); + assertEquals(new Double(1.0), ((Object[]) l.get(2))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList1d() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(1.0, "s0", "c0"); + d.addValue(null, "s1", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0, + false); + assertEquals(2, l.size()); + assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); + assertEquals(new Double(1.0), ((Object[]) l.get(1))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList2a() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(-1.0, "s0", "c0"); + d.addValue(1.1, "s1", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0, + false); + assertEquals(3, l.size()); + assertEquals(new Double(-1.0), ((Object[]) l.get(0))[1]); + assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); + assertEquals(new Double(1.1), ((Object[]) l.get(2))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList2b() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(-1.0, "s0", "c0"); + d.addValue(-1.1, "s1", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0, + false); + assertEquals(3, l.size()); + assertEquals(new Double(-2.1), ((Object[]) l.get(0))[1]); + assertEquals(new Double(-1.0), ((Object[]) l.get(1))[1]); + assertEquals(new Double(0.0), ((Object[]) l.get(2))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList2c() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(-1.0, "s0", "c0"); + d.addValue(0.0, "s1", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0, + false); + assertEquals(3, l.size()); + assertEquals(new Double(-1.0), ((Object[]) l.get(0))[1]); + assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); + assertEquals(new Double(0.0), ((Object[]) l.get(2))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList2d() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(-1.0, "s0", "c0"); + d.addValue(null, "s1", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0, + false); + assertEquals(2, l.size()); + assertEquals(new Double(-1.0), ((Object[]) l.get(0))[1]); + assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList3a() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(0.0, "s0", "c0"); + d.addValue(1.1, "s1", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0, + false); + assertEquals(3, l.size()); + assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); + assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); + assertEquals(new Double(1.1), ((Object[]) l.get(2))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList3b() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(0.0, "s0", "c0"); + d.addValue(-1.1, "s1", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0, + false); + assertEquals(3, l.size()); + assertEquals(new Double(-1.1), ((Object[]) l.get(0))[1]); + assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); + assertEquals(new Double(0.0), ((Object[]) l.get(2))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList3c() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(0.0, "s0", "c0"); + d.addValue(0.0, "s1", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0, + false); + assertEquals(3, l.size()); + assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); + assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); + assertEquals(new Double(0.0), ((Object[]) l.get(2))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList3d() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(0.0, "s0", "c0"); + d.addValue(null, "s1", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0, 1 }, 0.0, + false); + assertEquals(2, l.size()); + assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); + assertEquals(new Double(0.0), ((Object[]) l.get(1))[1]); + } + + /** + * A test for the createStackedValueList() method. + */ + @Test + public void testCreateStackedValueList5() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(1.0, "s0", "c0"); + d.addValue(null, "s1", "c0"); + d.addValue(2.0, "s2", "c0"); + MyRenderer r = new MyRenderer(); + List l = r.createStackedValueList(d, "c0", new int[] { 0, 1, 2 }, 0.0, + false); + assertEquals(3, l.size()); + assertEquals(new Double(0.0), ((Object[]) l.get(0))[1]); + assertEquals(new Double(1.0), ((Object[]) l.get(1))[1]); + assertEquals(new Double(3.0), ((Object[]) l.get(2))[1]); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StackedBarRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StackedBarRendererTest.java new file mode 100755 index 0000000..38cc9cf --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StackedBarRendererTest.java @@ -0,0 +1,150 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * StackedBarRendererTest.java + * --------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StackedBarRenderer} class. + */ +public class StackedBarRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + StackedBarRenderer r1 = new StackedBarRenderer(); + StackedBarRenderer r2 = new StackedBarRenderer(); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + r1.setRenderAsPercentages(true); + assertFalse(r1.equals(r2)); + r2.setRenderAsPercentages(true); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + StackedBarRenderer r1 = new StackedBarRenderer(); + StackedBarRenderer r2 = new StackedBarRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StackedBarRenderer r1 = new StackedBarRenderer(); + StackedBarRenderer r2 = (StackedBarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + StackedBarRenderer r1 = new StackedBarRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StackedBarRenderer r1 = new StackedBarRenderer(); + StackedBarRenderer r2 = (StackedBarRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + StackedBarRenderer r = new StackedBarRenderer(); + assertNull(r.findRangeBounds(null)); + + // an empty dataset should return a null range + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + assertNull(r.findRangeBounds(dataset)); + + dataset.addValue(1.0, "R1", "C1"); + assertEquals(new Range(0.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(-2.0, "R1", "C2"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(null, "R1", "C3"); + assertEquals(new Range(-2.0, 1.0), r.findRangeBounds(dataset)); + + dataset.addValue(2.0, "R2", "C1"); + assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset)); + + dataset.addValue(null, "R2", "C2"); + assertEquals(new Range(-2.0, 3.0), r.findRangeBounds(dataset)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StandardBarPainterTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StandardBarPainterTest.java new file mode 100755 index 0000000..06351ef --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StandardBarPainterTest.java @@ -0,0 +1,102 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * StandardBarPainterTest.java + * --------------------------- + * (C) Copyright 2008-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Jun-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StandardBarPainter} class. + */ +public class StandardBarPainterTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + StandardBarPainter p1 = new StandardBarPainter(); + StandardBarPainter p2 = new StandardBarPainter(); + assertEquals(p1, p2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + StandardBarPainter p1 = new StandardBarPainter(); + StandardBarPainter p2 = new StandardBarPainter(); + assertTrue(p1.equals(p2)); + int h1 = p1.hashCode(); + int h2 = p2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning isn't implemented (it isn't required, because + * instances of the class are immutable). + */ + @Test + public void testCloning() { + StandardBarPainter p1 = new StandardBarPainter(); + assertFalse(p1 instanceof Cloneable); + assertFalse(p1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardBarPainter p1 = new StandardBarPainter(); + StandardBarPainter p2 = (StandardBarPainter) + TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StatisticalBarRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StatisticalBarRendererTest.java new file mode 100755 index 0000000..c7954af --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StatisticalBarRendererTest.java @@ -0,0 +1,292 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * StatisticalBarRendererTest.java + * ------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 28-Aug-2007 : Added tests for bug 1779941 (DG); + * 14-Nov-2007 : Updated testEquals() (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * 16-May-2009 : Added testFindRangeBounds (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.awt.BasicStroke; +import java.awt.Color; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.Range; +import org.jfree.data.statistics.DefaultStatisticalCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StatisticalBarRenderer} class. + */ +public class StatisticalBarRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + StatisticalBarRenderer r1 = new StatisticalBarRenderer(); + StatisticalBarRenderer r2 = new StatisticalBarRenderer(); + assertEquals(r1, r2); + + r1.setErrorIndicatorPaint(Color.red); + assertFalse(r1.equals(r2)); + r2.setErrorIndicatorPaint(Color.red); + assertTrue(r2.equals(r1)); + + r1.setErrorIndicatorStroke(new BasicStroke(1.5f)); + assertFalse(r1.equals(r2)); + r2.setErrorIndicatorStroke(new BasicStroke(1.5f)); + assertTrue(r2.equals(r1)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + StatisticalBarRenderer r1 = new StatisticalBarRenderer(); + StatisticalBarRenderer r2 = new StatisticalBarRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StatisticalBarRenderer r1 = new StatisticalBarRenderer(); + StatisticalBarRenderer r2 = (StatisticalBarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + StatisticalBarRenderer r1 = new StatisticalBarRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StatisticalBarRenderer r1 = new StatisticalBarRenderer(); + StatisticalBarRenderer r2 = (StatisticalBarRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (particularly by code in the renderer). + */ + @Test + public void testDrawWithNullInfo() { + try { + DefaultStatisticalCategoryDataset dataset + = new DefaultStatisticalCategoryDataset(); + dataset.add(1.0, 2.0, "S1", "C1"); + dataset.add(3.0, 4.0, "S1", "C2"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new StatisticalBarRenderer()); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * Draws the chart with a null mean value to make sure that + * no exceptions are thrown (particularly by code in the renderer). See + * bug report 1779941. + */ + @Test + public void testDrawWithNullMeanVertical() { + try { + DefaultStatisticalCategoryDataset dataset + = new DefaultStatisticalCategoryDataset(); + dataset.add(1.0, 2.0, "S1", "C1"); + dataset.add(null, new Double(4.0), "S1", "C2"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new StatisticalBarRenderer()); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * Draws the chart with a null mean value to make sure that + * no exceptions are thrown (particularly by code in the renderer). See + * bug report 1779941. + */ + @Test + public void testDrawWithNullMeanHorizontal() { + try { + DefaultStatisticalCategoryDataset dataset + = new DefaultStatisticalCategoryDataset(); + dataset.add(1.0, 2.0, "S1", "C1"); + dataset.add(null, new Double(4.0), "S1", "C2"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new StatisticalBarRenderer()); + plot.setOrientation(PlotOrientation.HORIZONTAL); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * Draws the chart with a null standard deviation to make sure + * that no exceptions are thrown (particularly by code in the renderer). + * See bug report 1779941. + */ + @Test + public void testDrawWithNullDeviationVertical() { + try { + DefaultStatisticalCategoryDataset dataset + = new DefaultStatisticalCategoryDataset(); + dataset.add(1.0, 2.0, "S1", "C1"); + dataset.add(new Double(4.0), null, "S1", "C2"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new StatisticalBarRenderer()); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * Draws the chart with a null standard deviation to make sure + * that no exceptions are thrown (particularly by code in the renderer). + * See bug report 1779941. + */ + @Test + public void testDrawWithNullDeviationHorizontal() { + try { + DefaultStatisticalCategoryDataset dataset + = new DefaultStatisticalCategoryDataset(); + dataset.add(1.0, 2.0, "S1", "C1"); + dataset.add(new Double(4.0), null, "S1", "C2"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new StatisticalBarRenderer()); + plot.setOrientation(PlotOrientation.HORIZONTAL); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + StatisticalBarRenderer r = new StatisticalBarRenderer(); + assertNull(r.findRangeBounds(null)); + + // an empty dataset should return a null range + DefaultStatisticalCategoryDataset dataset + = new DefaultStatisticalCategoryDataset(); + assertNull(r.findRangeBounds(dataset)); + + dataset.add(1.0, 0.5, "R1", "C1"); + assertEquals(new Range(0.0, 1.5), r.findRangeBounds(dataset)); + + r.setIncludeBaseInRange(false); + assertEquals(new Range(0.5, 1.5), r.findRangeBounds(dataset)); + r.setIncludeBaseInRange(true); + + dataset.add(-2.0, 0.2, "R1", "C2"); + assertEquals(new Range(-2.2, 1.5), r.findRangeBounds(dataset)); + + dataset.add(null, null, "R1", "C3"); + assertEquals(new Range(-2.2, 1.5), r.findRangeBounds(dataset)); + + dataset.add(5.0, 1.0, "R2", "C3"); + assertEquals(new Range(-2.2, 6.0), r.findRangeBounds(dataset)); + + // check that the series visible flag is observed + r.setSeriesVisible(1, Boolean.FALSE); + assertEquals(new Range(-2.2, 1.5), r.findRangeBounds(dataset)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StatisticalLineAndShapeRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StatisticalLineAndShapeRendererTest.java new file mode 100755 index 0000000..44af62d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/StatisticalLineAndShapeRendererTest.java @@ -0,0 +1,207 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------------- + * StatisticalLineAndShapeRendererTest.java + * ---------------------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 15-Jun-2005 : Version 1 (DG); + * 25-Sep-2006 : Added test1562759() (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * 16-May-2009 : Added testFindRangeBounds() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import java.awt.Color; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.CategoryAxis; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.CategoryPlot; +import org.jfree.data.Range; +import org.jfree.data.statistics.DefaultStatisticalCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StatisticalLineAndShapeRenderer} class. + */ +public class StatisticalLineAndShapeRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + StatisticalLineAndShapeRenderer r1 + = new StatisticalLineAndShapeRenderer(); + StatisticalLineAndShapeRenderer r2 + = new StatisticalLineAndShapeRenderer(); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + r1.setErrorIndicatorPaint(Color.red); + assertFalse(r1.equals(r2)); + r2.setErrorIndicatorPaint(Color.red); + assertTrue(r2.equals(r1)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + StatisticalLineAndShapeRenderer r1 + = new StatisticalLineAndShapeRenderer(); + StatisticalLineAndShapeRenderer r2 + = new StatisticalLineAndShapeRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StatisticalLineAndShapeRenderer r1 + = new StatisticalLineAndShapeRenderer(); + StatisticalLineAndShapeRenderer r2 = (StatisticalLineAndShapeRenderer) + r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + StatisticalLineAndShapeRenderer r1 + = new StatisticalLineAndShapeRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StatisticalLineAndShapeRenderer r1 + = new StatisticalLineAndShapeRenderer(); + StatisticalLineAndShapeRenderer r2 = (StatisticalLineAndShapeRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (particularly by code in the renderer). + */ + @Test + public void testDrawWithNullInfo() { + try { + DefaultStatisticalCategoryDataset dataset + = new DefaultStatisticalCategoryDataset(); + dataset.add(1.0, 2.0, "S1", "C1"); + dataset.add(3.0, 4.0, "S1", "C2"); + CategoryPlot plot = new CategoryPlot(dataset, + new CategoryAxis("Category"), new NumberAxis("Value"), + new StatisticalLineAndShapeRenderer()); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * A simple test for bug report 1562759. + */ + @Test + public void test1562759() { + StatisticalLineAndShapeRenderer r + = new StatisticalLineAndShapeRenderer(true, false); + assertTrue(r.getBaseLinesVisible()); + assertFalse(r.getBaseShapesVisible()); + + r = new StatisticalLineAndShapeRenderer(false, true); + assertFalse(r.getBaseLinesVisible()); + assertTrue(r.getBaseShapesVisible()); + } + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + StatisticalLineAndShapeRenderer r + = new StatisticalLineAndShapeRenderer(); + assertNull(r.findRangeBounds(null)); + + // an empty dataset should return a null range + DefaultStatisticalCategoryDataset dataset + = new DefaultStatisticalCategoryDataset(); + assertNull(r.findRangeBounds(dataset)); + + dataset.add(1.0, 0.5, "R1", "C1"); + assertEquals(new Range(0.5, 1.5), r.findRangeBounds(dataset)); + + dataset.add(-2.0, 0.2, "R1", "C2"); + assertEquals(new Range(-2.2, 1.5), r.findRangeBounds(dataset)); + + dataset.add(null, null, "R1", "C3"); + assertEquals(new Range(-2.2, 1.5), r.findRangeBounds(dataset)); + + dataset.add(5.0, 1.0, "R2", "C3"); + assertEquals(new Range(-2.2, 6.0), r.findRangeBounds(dataset)); + + // check that the series visible flag is observed + r.setSeriesVisible(1, Boolean.FALSE); + assertEquals(new Range(-2.2, 1.5), r.findRangeBounds(dataset)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/WaterfallBarRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/WaterfallBarRendererTest.java new file mode 100755 index 0000000..13d2960 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/category/WaterfallBarRendererTest.java @@ -0,0 +1,198 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * WaterfallBarRendererTest.java + * ----------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Oct-2003 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable() (DG); + * 04-Feb-2009 : Added testFindRangeBounds() (DG); + * + */ + +package org.jfree.chart.renderer.category; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + +import java.awt.Color; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link WaterfallBarRenderer} class. + */ +public class WaterfallBarRendererTest { + + /** + * Some tests for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + WaterfallBarRenderer r = new WaterfallBarRenderer(); + assertNull(r.findRangeBounds(null)); + } + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + WaterfallBarRenderer r1 = new WaterfallBarRenderer(); + WaterfallBarRenderer r2 = new WaterfallBarRenderer(); + assertEquals(r1, r2); + + // firstBarPaint; + r1.setFirstBarPaint(Color.cyan); + assertFalse(r1.equals(r2)); + r2.setFirstBarPaint(Color.cyan); + assertTrue(r1.equals(r2)); + + // lastBarPaint; + r1.setLastBarPaint(Color.cyan); + assertFalse(r1.equals(r2)); + r2.setLastBarPaint(Color.cyan); + assertTrue(r1.equals(r2)); + + // positiveBarPaint; + r1.setPositiveBarPaint(Color.cyan); + assertFalse(r1.equals(r2)); + r2.setPositiveBarPaint(Color.cyan); + assertTrue(r1.equals(r2)); + + //private Paint negativeBarPaint; + r1.setNegativeBarPaint(Color.cyan); + assertFalse(r1.equals(r2)); + r2.setNegativeBarPaint(Color.cyan); + assertTrue(r1.equals(r2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + WaterfallBarRenderer r1 = new WaterfallBarRenderer(); + WaterfallBarRenderer r2 = new WaterfallBarRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + WaterfallBarRenderer r1 = new WaterfallBarRenderer(); + WaterfallBarRenderer r2 = (WaterfallBarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // quick check for independence + r1.setFirstBarPaint(Color.yellow); + assertFalse(r1.equals(r2)); + r2.setFirstBarPaint(Color.yellow); + assertTrue(r1.equals(r2)); + + } + + /** + * Check that this class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + WaterfallBarRenderer r1 = new WaterfallBarRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + WaterfallBarRenderer r1 = new WaterfallBarRenderer(); + WaterfallBarRenderer r2 = (WaterfallBarRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + +// /** +// * Check that the paint object returned for a middle column with 0 +// * difference is the positive bar paint object +// */ +// @Test +// public void testGetSeriesPaintForDifferentValues() { +//Color firstPaint = Color.cyan; +//Color positivePaint = Color.green; +//Color negativePaint = Color.red; +//Color lastPaint = Color.blue; +//WaterfallBarRenderer waterfallBarRenderer = new WaterfallBarRenderer(firstPaint, positivePaint, negativePaint, lastPaint); +// +//// Sets of tests for making sure the correct paint object is returned +//// for different scenarios. +// +//// In the first set, the "firstPaint" object is always returned because +//// this is first column (regardless of the value of the value difference). +//assertSame(firstPaint, waterfallBarRenderer.getSeriesPaintObject(0, 1, 0d)); +//assertSame(firstPaint, waterfallBarRenderer.getSeriesPaintObject(0, 2, 1d)); +//assertSame(firstPaint, waterfallBarRenderer.getSeriesPaintObject(0, 2, -1d)); +// +//// In the second set, the "positivePaint" object is returned for middle +//// columns which are greater than or equal to 0. +//assertSame(positivePaint, waterfallBarRenderer.getSeriesPaintObject(1, 1, 1d)); +//assertSame(positivePaint, waterfallBarRenderer.getSeriesPaintObject(1, 1, 0d)); +//assertSame(positivePaint, waterfallBarRenderer.getSeriesPaintObject(1, 3, 0d)); +// +//// In the third set, the "negativePaint" object is returned for middle +//// columns which are less than zero. +//assertSame(negativePaint, waterfallBarRenderer.getSeriesPaintObject(1, 1, -0.5d)); +//assertSame(negativePaint, waterfallBarRenderer.getSeriesPaintObject(1, 3, -0.5d)); +//assertSame(negativePaint, waterfallBarRenderer.getSeriesPaintObject(1, 0, -0.5d)); +// +//// In the last set, the "lastPaint" object is returned because this is the +//// last column (regardless of the value of the value difference). +//assertSame(lastPaint, waterfallBarRenderer.getSeriesPaintObject(1, 2, 0d)); +//assertSame(lastPaint, waterfallBarRenderer.getSeriesPaintObject(1, 2, 1d)); +//assertSame(lastPaint, waterfallBarRenderer.getSeriesPaintObject(1, 2, -1d)); +//} + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/package.html new file mode 100755 index 0000000..08924b5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/package.html @@ -0,0 +1,6 @@ + + + +JUnit tests. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/AbstractXYItemRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/AbstractXYItemRendererTest.java new file mode 100755 index 0000000..1dfb474 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/AbstractXYItemRendererTest.java @@ -0,0 +1,163 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * AbstractXYItemRendererTest.java + * ------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 06-Oct-2004 : Version 1 (DG); + * 24-Nov-2006 : Added cloning tests (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.labels.StandardXYSeriesLabelGenerator; +import org.jfree.data.Range; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.junit.Test; + +/** + * Tests for the {@link AbstractXYItemRenderer} class. + */ +public class AbstractXYItemRendererTest { + + /** + * Creates a test dataset. + * + * @return A test dataset. + */ + private XYDataset createDataset1() { + XYSeries series = new XYSeries("Series"); + series.add(1.0, 1.0); + series.add(2.0, 2.0); + series.add(3.0, 3.0); + XYSeriesCollection dataset = new XYSeriesCollection(); + dataset.addSeries(series); + return dataset; + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the findDomainBounds() method. + */ + @Test + public void testFindDomainBounds() { + AbstractXYItemRenderer renderer = new StandardXYItemRenderer(); + + // check the bounds of a simple dataset + XYDataset dataset = createDataset1(); + Range r = renderer.findDomainBounds(dataset); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(3.0, r.getUpperBound(), EPSILON); + + // check that a null dataset returns null bounds + assertTrue(renderer.findDomainBounds(null) == null); + } + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + AbstractXYItemRenderer renderer = new StandardXYItemRenderer(); + // check that a null dataset returns null bounds + assertTrue(renderer.findRangeBounds(null) == null); + } + + /** + * Check that the legendItemLabelGenerator is cloned. + */ + @Test + public void testCloning_LegendItemLabelGenerator() throws CloneNotSupportedException { + StandardXYSeriesLabelGenerator generator + = new StandardXYSeriesLabelGenerator("Series {0}"); + XYBarRenderer r1 = new XYBarRenderer(); + r1.setLegendItemLabelGenerator(generator); + XYBarRenderer r2 = (XYBarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // check that the generator has been cloned + assertTrue(r1.getLegendItemLabelGenerator() + != r2.getLegendItemLabelGenerator()); + } + + /** + * Check that the legendItemToolTipGenerator is cloned. + */ + @Test + public void testCloning_LegendItemToolTipGenerator() + throws CloneNotSupportedException { + StandardXYSeriesLabelGenerator generator + = new StandardXYSeriesLabelGenerator("Series {0}"); + XYBarRenderer r1 = new XYBarRenderer(); + r1.setLegendItemToolTipGenerator(generator); + XYBarRenderer r2 = (XYBarRenderer) r1.clone(); + + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // check that the generator has been cloned + assertTrue(r1.getLegendItemToolTipGenerator() + != r2.getLegendItemToolTipGenerator()); + } + + /** + * Check that the legendItemURLGenerator is cloned. + */ + @Test + public void testCloning_LegendItemURLGenerator() + throws CloneNotSupportedException { + StandardXYSeriesLabelGenerator generator + = new StandardXYSeriesLabelGenerator("Series {0}"); + XYBarRenderer r1 = new XYBarRenderer(); + r1.setLegendItemURLGenerator(generator); + XYBarRenderer r2 = (XYBarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // check that the generator has been cloned + assertTrue(r1.getLegendItemURLGenerator() + != r2.getLegendItemURLGenerator()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/CandlestickRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/CandlestickRendererTest.java new file mode 100755 index 0000000..1e02663 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/CandlestickRendererTest.java @@ -0,0 +1,238 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * CandlestickRendererTest.java + * ---------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 22-Oct-2003 : Added hashCode test (DG); + * 17-Aug-2006 : Strengthened testEquals() and added testFindRangeBounds() + * method (DG); + * 05-Mar-2007 : Added new field to testEquals() (DG); + * 08-Oct-2007 : Added tests for new volumePaint field (DG); + * 22-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + +import java.awt.Color; +import java.awt.GradientPaint; +import java.util.Date; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.data.xy.DefaultOHLCDataset; +import org.jfree.data.xy.OHLCDataItem; +import org.jfree.data.xy.OHLCDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link CandlestickRenderer} class. + */ +public class CandlestickRendererTest { + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the constructor. + */ + @Test + public void testConstructor() { + CandlestickRenderer r1 = new CandlestickRenderer(); + + // check defaults + assertEquals(Color.green, r1.getUpPaint()); + assertEquals(Color.red, r1.getDownPaint()); + assertFalse(r1.getUseOutlinePaint()); + assertTrue(r1.getDrawVolume()); + assertEquals(Color.gray, r1.getVolumePaint()); + assertEquals(-1.0, r1.getCandleWidth(), EPSILON); + } + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + CandlestickRenderer r1 = new CandlestickRenderer(); + CandlestickRenderer r2 = new CandlestickRenderer(); + assertEquals(r1, r2); + + // upPaint + r1.setUpPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.white)); + assertFalse(r1.equals(r2)); + r2.setUpPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.white)); + assertTrue(r1.equals(r2)); + + // downPaint + r1.setDownPaint(new GradientPaint(5.0f, 6.0f, Color.green, 7.0f, 8.0f, + Color.yellow)); + assertFalse(r1.equals(r2)); + r2.setDownPaint(new GradientPaint(5.0f, 6.0f, Color.green, 7.0f, 8.0f, + Color.yellow)); + assertTrue(r1.equals(r2)); + + // drawVolume + r1.setDrawVolume(false); + assertFalse(r1.equals(r2)); + r2.setDrawVolume(false); + assertTrue(r1.equals(r2)); + + // candleWidth + r1.setCandleWidth(3.3); + assertFalse(r1.equals(r2)); + r2.setCandleWidth(3.3); + assertTrue(r1.equals(r2)); + + // maxCandleWidthInMilliseconds + r1.setMaxCandleWidthInMilliseconds(123); + assertFalse(r1.equals(r2)); + r2.setMaxCandleWidthInMilliseconds(123); + assertTrue(r1.equals(r2)); + + // autoWidthMethod + r1.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); + assertFalse(r1.equals(r2)); + r2.setAutoWidthMethod(CandlestickRenderer.WIDTHMETHOD_SMALLEST); + assertTrue(r1.equals(r2)); + + // autoWidthFactor + r1.setAutoWidthFactor(0.22); + assertFalse(r1.equals(r2)); + r2.setAutoWidthFactor(0.22); + assertTrue(r1.equals(r2)); + + // autoWidthGap + r1.setAutoWidthGap(1.1); + assertFalse(r1.equals(r2)); + r2.setAutoWidthGap(1.1); + assertTrue(r1.equals(r2)); + + r1.setUseOutlinePaint(true); + assertFalse(r1.equals(r2)); + r2.setUseOutlinePaint(true); + assertTrue(r1.equals(r2)); + + r1.setVolumePaint(Color.blue); + assertFalse(r1.equals(r2)); + r2.setVolumePaint(Color.blue); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + CandlestickRenderer r1 = new CandlestickRenderer(); + CandlestickRenderer r2 = new CandlestickRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CandlestickRenderer r1 = new CandlestickRenderer(); + CandlestickRenderer r2 = (CandlestickRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + CandlestickRenderer r1 = new CandlestickRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CandlestickRenderer r1 = new CandlestickRenderer(); + CandlestickRenderer r2 = (CandlestickRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + CandlestickRenderer renderer = new CandlestickRenderer(); + + OHLCDataItem item1 = new OHLCDataItem(new Date(1L), 2.0, 4.0, 1.0, 3.0, + 100); + OHLCDataset dataset = new DefaultOHLCDataset("S1", + new OHLCDataItem[] {item1}); + Range range = renderer.findRangeBounds(dataset); + assertEquals(new Range(1.0, 4.0), range); + + OHLCDataItem item2 = new OHLCDataItem(new Date(1L), -1.0, 3.0, -1.0, + 3.0, 100); + dataset = new DefaultOHLCDataset("S1", new OHLCDataItem[] {item1, + item2}); + range = renderer.findRangeBounds(dataset); + assertEquals(new Range(-1.0, 4.0), range); + + // try an empty dataset - should return a null range + dataset = new DefaultOHLCDataset("S1", new OHLCDataItem[] {}); + range = renderer.findRangeBounds(dataset); + assertNull(range); + + // try a null dataset - should return a null range + range = renderer.findRangeBounds(null); + assertNull(range); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/ClusteredXYBarRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/ClusteredXYBarRendererTest.java new file mode 100755 index 0000000..6c28ce8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/ClusteredXYBarRendererTest.java @@ -0,0 +1,181 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * ClusteredXYBarRendererTest.java + * ------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 22-Oct-2003 : Added hashCode test (DG); + * 10-Jul-2007 : Fixed compile errors (DG); + * 22-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.data.xy.DefaultIntervalXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link ClusteredXYBarRenderer} class. + */ +public class ClusteredXYBarRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer(); + ClusteredXYBarRenderer r2 = new ClusteredXYBarRenderer(); + assertEquals(r1, r2); + assertEquals(r2, r1); + + r1 = new ClusteredXYBarRenderer(1.2, false); + assertFalse(r1.equals(r2)); + r2 = new ClusteredXYBarRenderer(1.2, false); + assertTrue(r1.equals(r2)); + + r1 = new ClusteredXYBarRenderer(1.2, true); + assertFalse(r1.equals(r2)); + r2 = new ClusteredXYBarRenderer(1.2, true); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer(); + ClusteredXYBarRenderer r2 = new ClusteredXYBarRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer(); + ClusteredXYBarRenderer r2 = (ClusteredXYBarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ClusteredXYBarRenderer r1 = new ClusteredXYBarRenderer(); + ClusteredXYBarRenderer r2 = (ClusteredXYBarRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the findDomainBounds() method (which requires special + * handling when the centerBarAtStartValue flag is set to true). + */ + @Test + public void testFindDomainBounds() { + AbstractXYItemRenderer renderer = new ClusteredXYBarRenderer(); + XYDataset dataset = createSampleDataset1(); + Range r = renderer.findDomainBounds(dataset); + assertEquals(0.9, r.getLowerBound(), EPSILON); + assertEquals(13.1, r.getUpperBound(), EPSILON); + + renderer = new ClusteredXYBarRenderer(0.0, true); + r = renderer.findDomainBounds(dataset); + assertEquals(0.8, r.getLowerBound(), EPSILON); + assertEquals(13.0, r.getUpperBound(), EPSILON); + + // check that a null dataset returns null bounds + assertTrue(renderer.findDomainBounds(null) == null); + } + + /** + * Creates a sample dataset for testing. + * + * @return A sample dataset. + */ + public DefaultIntervalXYDataset createSampleDataset1() { + DefaultIntervalXYDataset d = new DefaultIntervalXYDataset(); + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] x1Start = new double[] {0.9, 1.9, 2.9}; + double[] x1End = new double[] {1.1, 2.1, 3.1}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] y1Start = new double[] {1.09, 2.09, 3.09}; + double[] y1End = new double[] {1.11, 2.11, 3.11}; + double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, + y1End}; + d.addSeries("S1", data1); + + double[] x2 = new double[] {11.0, 12.0, 13.0}; + double[] x2Start = new double[] {10.9, 11.9, 12.9}; + double[] x2End = new double[] {11.1, 12.1, 13.1}; + double[] y2 = new double[] {14.0, 15.0, 16.0}; + double[] y2Start = new double[] {11.09, 12.09, 13.09}; + double[] y2End = new double[] {11.11, 12.11, 13.11}; + double[][] data2 = new double[][] {x2, x2Start, x2End, y2, y2Start, + y2End}; + d.addSeries("S2", data2); + return d; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/DeviationRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/DeviationRendererTest.java new file mode 100755 index 0000000..b53cd31 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/DeviationRendererTest.java @@ -0,0 +1,119 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * DeviationRendererTest.java + * -------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Feb-2007 : Version 1 (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link DeviationRenderer} class. + */ +public class DeviationRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + // default instances + DeviationRenderer r1 = new DeviationRenderer(); + DeviationRenderer r2 = new DeviationRenderer(); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + r1.setAlpha(0.1f); + assertFalse(r1.equals(r2)); + r2.setAlpha(0.1f); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + DeviationRenderer r1 = new DeviationRenderer(); + DeviationRenderer r2 = new DeviationRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DeviationRenderer r1 = new DeviationRenderer(); + DeviationRenderer r2 = (DeviationRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + DeviationRenderer r1 = new DeviationRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DeviationRenderer r1 = new DeviationRenderer(); + DeviationRenderer r2 = (DeviationRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/GradientXYBarPainterTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/GradientXYBarPainterTest.java new file mode 100755 index 0000000..79c8045 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/GradientXYBarPainterTest.java @@ -0,0 +1,117 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * GradientXYBarPainterTest.java + * ----------------------------- + * (C) Copyright 2008-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Jun-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link GradientXYBarPainter} class. + */ +public class GradientXYBarPainterTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + GradientXYBarPainter p1 = new GradientXYBarPainter(0.1, 0.2, 0.3); + GradientXYBarPainter p2 = new GradientXYBarPainter(0.1, 0.2, 0.3); + assertEquals(p1, p2); + + p1 = new GradientXYBarPainter(0.11, 0.2, 0.3); + assertFalse(p1.equals(p2)); + p2 = new GradientXYBarPainter(0.11, 0.2, 0.3); + assertTrue(p1.equals(p2)); + + p1 = new GradientXYBarPainter(0.11, 0.22, 0.3); + assertFalse(p1.equals(p2)); + p2 = new GradientXYBarPainter(0.11, 0.22, 0.3); + assertTrue(p1.equals(p2)); + + p1 = new GradientXYBarPainter(0.11, 0.22, 0.33); + assertFalse(p1.equals(p2)); + p2 = new GradientXYBarPainter(0.11, 0.22, 0.33); + assertTrue(p1.equals(p2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + GradientXYBarPainter p1 = new GradientXYBarPainter(0.1, 0.2, 0.3); + GradientXYBarPainter p2 = new GradientXYBarPainter(0.1, 0.2, 0.3); + assertTrue(p1.equals(p2)); + int h1 = p1.hashCode(); + int h2 = p2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning isn't implemented (it isn't required, because + * instances of the class are immutable). + */ + @Test + public void testCloning() { + GradientXYBarPainter p1 = new GradientXYBarPainter(0.1, 0.2, 0.3); + assertFalse(p1 instanceof Cloneable); + assertFalse(p1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + GradientXYBarPainter p1 = new GradientXYBarPainter(0.1, 0.2, 0.3); + GradientXYBarPainter p2 = (GradientXYBarPainter) + TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/HighLowRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/HighLowRendererTest.java new file mode 100755 index 0000000..99dad7c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/HighLowRendererTest.java @@ -0,0 +1,187 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * HighLowRendererTest.java + * ------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 22-Oct-2003 : Added hashCode test (DG); + * 01-Nov-2005 : Added tests for new fields (DG); + * 17-Aug-2006 : Added testFindRangeBounds() method (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * 29-Apr-2008 : Extended testEquals() for new field (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + +import java.awt.Color; +import java.util.Date; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.data.xy.DefaultOHLCDataset; +import org.jfree.data.xy.OHLCDataItem; +import org.jfree.data.xy.OHLCDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link HighLowRenderer} class. + */ +public class HighLowRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + HighLowRenderer r1 = new HighLowRenderer(); + HighLowRenderer r2 = new HighLowRenderer(); + assertEquals(r1, r2); + + // drawOpenTicks + r1.setDrawOpenTicks(false); + assertFalse(r1.equals(r2)); + r2.setDrawOpenTicks(false); + assertTrue(r1.equals(r2)); + + // drawCloseTicks + r1.setDrawCloseTicks(false); + assertFalse(r1.equals(r2)); + r2.setDrawCloseTicks(false); + assertTrue(r1.equals(r2)); + + // openTickPaint + r1.setOpenTickPaint(Color.red); + assertFalse(r1.equals(r2)); + r2.setOpenTickPaint(Color.red); + assertTrue(r1.equals(r2)); + + // closeTickPaint + r1.setCloseTickPaint(Color.blue); + assertFalse(r1.equals(r2)); + r2.setCloseTickPaint(Color.blue); + assertTrue(r1.equals(r2)); + + // tickLength + r1.setTickLength(99.9); + assertFalse(r1.equals(r2)); + r2.setTickLength(99.9); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + HighLowRenderer r1 = new HighLowRenderer(); + HighLowRenderer r2 = new HighLowRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + HighLowRenderer r1 = new HighLowRenderer(); + r1.setCloseTickPaint(Color.green); + HighLowRenderer r2 = (HighLowRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + HighLowRenderer r1 = new HighLowRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + HighLowRenderer r1 = new HighLowRenderer(); + r1.setCloseTickPaint(Color.green); + HighLowRenderer r2 = (HighLowRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + HighLowRenderer renderer = new HighLowRenderer(); + + OHLCDataItem item1 = new OHLCDataItem(new Date(1L), 2.0, 4.0, 1.0, 3.0, + 100); + OHLCDataset dataset = new DefaultOHLCDataset("S1", + new OHLCDataItem[] {item1}); + Range range = renderer.findRangeBounds(dataset); + assertEquals(new Range(1.0, 4.0), range); + + OHLCDataItem item2 = new OHLCDataItem(new Date(1L), -1.0, 3.0, -1.0, + 3.0, 100); + dataset = new DefaultOHLCDataset("S1", new OHLCDataItem[] {item1, + item2}); + range = renderer.findRangeBounds(dataset); + assertEquals(new Range(-1.0, 4.0), range); + + // try an empty dataset - should return a null range + dataset = new DefaultOHLCDataset("S1", new OHLCDataItem[] {}); + range = renderer.findRangeBounds(dataset); + assertNull(range); + + // try a null dataset - should return a null range + range = renderer.findRangeBounds(null); + assertNull(range); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/RendererXYPackageUtils.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/RendererXYPackageUtils.java new file mode 100755 index 0000000..4de8650 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/RendererXYPackageUtils.java @@ -0,0 +1,100 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * RendererXYPackageTests.java + * --------------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 23-Aug-2004 : Restructured org.jfree.chart.renderer package (DG); + * 06-Jan-2005 : Added method to create test dataset (DG); + * 07-Jan-2005 : Added a second method to create a test dataset (DG); + * 19-Jan-2005 : Added main() method to run JUnit in text mode (DG); + * 25-Oct-2006 : Added tests for XYErrorRenderer class (DG); + * 31-Jan-2007 : Added XYBlockRendererTests (DG); + * 26-Feb-2007 : Added DeviationRendererTests (DG); + * 30-Apr-2007 : Added XYLine3DRendererTests (DG); + * 25-May-2007 : Added VectorRendererTests (DG); + * 25-Jul-2007 : Added XYSplineAndRendererTests (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import org.jfree.data.xy.DefaultTableXYDataset; +import org.jfree.data.xy.TableXYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; + +/** + * A collection of tests for the org.jfree.chart.renderer.xy package. + *

      + * These tests can be run using JUnit (http://www.junit.org). + */ +public class RendererXYPackageUtils { + + /** + * Creates and returns a sample dataset for testing purposes. + * + * @return A sample dataset. + */ + public static XYSeriesCollection createTestXYSeriesCollection() { + XYSeriesCollection result = new XYSeriesCollection(); + XYSeries series1 = new XYSeries("Series 1", false, false); + series1.add(1.0, 2.0); + series1.add(2.0, 5.0); + XYSeries series2 = new XYSeries("Series 2", false, false); + series2.add(1.0, 4.0); + series2.add(2.0, 3.0); + result.addSeries(series1); + result.addSeries(series2); + return result; + } + + /** + * Creates and returns a sample dataset for testing purposes. + * + * @return A sample dataset. + */ + public static TableXYDataset createTestTableXYDataset() { + DefaultTableXYDataset result = new DefaultTableXYDataset(); + XYSeries series1 = new XYSeries("Series 1", false, false); + series1.add(1.0, 2.0); + series1.add(2.0, 5.0); + XYSeries series2 = new XYSeries("Series 2", false, false); + series2.add(1.0, 4.0); + series2.add(2.0, 3.0); + result.addSeries(series1); + result.addSeries(series2); + return result; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2Test.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2Test.java new file mode 100755 index 0000000..bb7fafc --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StackedXYAreaRenderer2Test.java @@ -0,0 +1,184 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * StackedXYAreaRenderer2Test.java + * ------------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 06-Jan-2005 : Version 1 (DG); + * 22-Aug-2006 : Added testDrawWithEmptyDataset() method (DG); + * 30-Nov-2006 : Extended testEquals() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.Range; +import org.jfree.data.xy.DefaultTableXYDataset; +import org.jfree.data.xy.TableXYDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StackedXYAreaRenderer2} class. + */ +public class StackedXYAreaRenderer2Test { + + /** + * Test chart drawing with an empty dataset to ensure that this special + * case doesn't cause any exceptions. + */ + @Test + public void testDrawWithEmptyDataset() { + boolean success = false; + JFreeChart chart = ChartFactory.createStackedXYAreaChart("title", "x", + "y", new DefaultTableXYDataset(), PlotOrientation.VERTICAL, + true, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setRenderer(new StackedXYAreaRenderer2()); + try { + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, null); + g2.dispose(); + success = true; + } + catch (Exception e) { + success = false; + } + assertTrue(success); + } + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2(); + StackedXYAreaRenderer2 r2 = new StackedXYAreaRenderer2(); + assertEquals(r1, r2); + assertEquals(r2, r1); + + r1.setRoundXCoordinates(!r1.getRoundXCoordinates()); + assertFalse(r1.equals(r2)); + r2.setRoundXCoordinates(r1.getRoundXCoordinates()); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2(); + StackedXYAreaRenderer2 r2 = new StackedXYAreaRenderer2(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2(); + StackedXYAreaRenderer2 r2 = (StackedXYAreaRenderer2) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StackedXYAreaRenderer2 r1 = new StackedXYAreaRenderer2(); + StackedXYAreaRenderer2 r2 = (StackedXYAreaRenderer2) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Check that the renderer is calculating the range bounds correctly. + */ + @Test + public void testFindRangeBounds() { + TableXYDataset dataset + = RendererXYPackageUtils.createTestTableXYDataset(); + JFreeChart chart = ChartFactory.createStackedXYAreaChart( + "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, + false, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + StackedXYAreaRenderer2 renderer = new StackedXYAreaRenderer2(); + plot.setRenderer(renderer); + NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + Range bounds = rangeAxis.getRange(); + assertTrue(bounds.contains(6.0)); + assertTrue(bounds.contains(8.0)); + + // try null argument + assertNull(renderer.findRangeBounds(null)); + + // try empty dataset + assertNull(renderer.findRangeBounds(new DefaultTableXYDataset())); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StackedXYAreaRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StackedXYAreaRendererTest.java new file mode 100755 index 0000000..f100b7a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StackedXYAreaRendererTest.java @@ -0,0 +1,233 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * StackedXYAreaRendererTest.java + * ------------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 06-Jan-2005 : Renamed StackedAreaXYRendererTests --> + * StackedXYAreaRendererTests, improved testEquals() method, + * added check for auto range calculation (DG); + * 10-Nov-2006 : Added testBug1593156() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Stroke; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.Range; +import org.jfree.data.xy.DefaultTableXYDataset; +import org.jfree.data.xy.TableXYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StackedXYAreaRenderer} class. + */ +public class StackedXYAreaRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + StackedXYAreaRenderer r1 = new StackedXYAreaRenderer(); + StackedXYAreaRenderer r2 = new StackedXYAreaRenderer(); + assertEquals(r1, r2); + assertEquals(r2, r1); + + r1.setShapePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.green)); + assertFalse(r1.equals(r2)); + r2.setShapePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.green)); + assertTrue(r1.equals(r2)); + + Stroke s = new BasicStroke(1.23f); + r1.setShapeStroke(s); + assertFalse(r1.equals(r2)); + r2.setShapeStroke(s); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + StackedXYAreaRenderer r1 = new StackedXYAreaRenderer(); + StackedXYAreaRenderer r2 = new StackedXYAreaRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StackedXYAreaRenderer r1 = new StackedXYAreaRenderer(); + StackedXYAreaRenderer r2 = (StackedXYAreaRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + StackedXYAreaRenderer r1 = new StackedXYAreaRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StackedXYAreaRenderer r1 = new StackedXYAreaRenderer(); + r1.setShapePaint(Color.red); + r1.setShapeStroke(new BasicStroke(1.23f)); + StackedXYAreaRenderer r2 = (StackedXYAreaRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Check that the renderer is calculating the range bounds correctly. + */ + @Test + public void testFindRangeBounds() { + TableXYDataset dataset + = RendererXYPackageUtils.createTestTableXYDataset(); + JFreeChart chart = ChartFactory.createStackedXYAreaChart( + "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, + false, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + Range bounds = rangeAxis.getRange(); + assertTrue(bounds.contains(6.0)); + assertTrue(bounds.contains(8.0)); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (particularly by code in the renderer). + */ + @Test + public void testDrawWithNullInfo() { + try { + DefaultTableXYDataset dataset = new DefaultTableXYDataset(); + + XYSeries s1 = new XYSeries("Series 1", true, false); + s1.add(5.0, 5.0); + s1.add(10.0, 15.5); + s1.add(15.0, 9.5); + s1.add(20.0, 7.5); + dataset.addSeries(s1); + + XYSeries s2 = new XYSeries("Series 2", true, false); + s2.add(5.0, 5.0); + s2.add(10.0, 15.5); + s2.add(15.0, 9.5); + s2.add(20.0, 3.5); + dataset.addSeries(s2); + XYPlot plot = new XYPlot(dataset, + new NumberAxis("X"), new NumberAxis("Y"), + new StackedXYAreaRenderer()); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * A test for bug 1593156. + */ + @Test + public void testBug1593156() { + try { + DefaultTableXYDataset dataset = new DefaultTableXYDataset(); + + XYSeries s1 = new XYSeries("Series 1", true, false); + s1.add(5.0, 5.0); + s1.add(10.0, 15.5); + s1.add(15.0, 9.5); + s1.add(20.0, 7.5); + dataset.addSeries(s1); + + XYSeries s2 = new XYSeries("Series 2", true, false); + s2.add(5.0, 5.0); + s2.add(10.0, 15.5); + s2.add(15.0, 9.5); + s2.add(20.0, 3.5); + dataset.addSeries(s2); + StackedXYAreaRenderer renderer = new StackedXYAreaRenderer( + XYAreaRenderer.LINES); + XYPlot plot = new XYPlot(dataset, + new NumberAxis("X"), new NumberAxis("Y"), + renderer); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StackedXYBarRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StackedXYBarRendererTest.java new file mode 100755 index 0000000..2b410d1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StackedXYBarRendererTest.java @@ -0,0 +1,176 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * StackedXYBarRendererTest.java + * ----------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-Sep-2004 : Version 1 (DG); + * 06-Jan-2005 : Added test for auto range calculation (DG); + * 06-Dec-2006 : Confirm serialization of GradientPaint (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.Range; +import org.jfree.data.xy.TableXYDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StackedXYBarRenderer} class. + */ +public class StackedXYBarRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + StackedXYBarRenderer r1 = new StackedXYBarRenderer(); + StackedXYBarRenderer r2 = new StackedXYBarRenderer(); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + r1.setRenderAsPercentages(true); + assertFalse(r1.equals(r2)); + r2.setRenderAsPercentages(true); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + StackedXYBarRenderer r1 = new StackedXYBarRenderer(); + StackedXYBarRenderer r2 = new StackedXYBarRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + + r1.setRenderAsPercentages(true); + h1 = r1.hashCode(); + h2 = r2.hashCode(); + assertFalse(h1 == h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StackedXYBarRenderer r1 = new StackedXYBarRenderer(); + StackedXYBarRenderer r2 = (StackedXYBarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + StackedXYBarRenderer r1 = new StackedXYBarRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StackedXYBarRenderer r1 = new StackedXYBarRenderer(); + r1.setSeriesPaint(0, new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.yellow)); + StackedXYBarRenderer r2 = (StackedXYBarRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Check that the renderer is calculating the domain bounds correctly. + */ + @Test + public void testFindDomainBounds() { + TableXYDataset dataset + = RendererXYPackageUtils.createTestTableXYDataset(); + JFreeChart chart = ChartFactory.createStackedXYAreaChart( + "Test Chart", "X", "Y", dataset, + PlotOrientation.VERTICAL, false, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setRenderer(new StackedXYBarRenderer()); + NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); + domainAxis.setAutoRangeIncludesZero(false); + Range bounds = domainAxis.getRange(); + assertFalse(bounds.contains(0.3)); + assertTrue(bounds.contains(0.5)); + assertTrue(bounds.contains(2.5)); + assertFalse(bounds.contains(2.8)); + } + + /** + * Check that the renderer is calculating the range bounds correctly. + */ + @Test + public void testFindRangeBounds() { + TableXYDataset dataset + = RendererXYPackageUtils.createTestTableXYDataset(); + JFreeChart chart = ChartFactory.createStackedXYAreaChart( + "Test Chart", "X", "Y", dataset, + PlotOrientation.VERTICAL, false, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setRenderer(new StackedXYBarRenderer()); + NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + Range bounds = rangeAxis.getRange(); + assertTrue(bounds.contains(6.0)); + assertTrue(bounds.contains(8.0)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StandardXYBarPainterTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StandardXYBarPainterTest.java new file mode 100755 index 0000000..dbd256f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StandardXYBarPainterTest.java @@ -0,0 +1,102 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * StandardXYBarPainterTest.java + * ----------------------------- + * (C) Copyright 2008-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Jun-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StandardXYBarPainter} class. + */ +public class StandardXYBarPainterTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + StandardXYBarPainter p1 = new StandardXYBarPainter(); + StandardXYBarPainter p2 = new StandardXYBarPainter(); + assertEquals(p1, p2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + StandardXYBarPainter p1 = new StandardXYBarPainter(); + StandardXYBarPainter p2 = new StandardXYBarPainter(); + assertTrue(p1.equals(p2)); + int h1 = p1.hashCode(); + int h2 = p2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning isn't implemented (it isn't required, because + * instances of the class are immutable). + */ + @Test + public void testCloning() { + StandardXYBarPainter p1 = new StandardXYBarPainter(); + assertFalse(p1 instanceof Cloneable); + assertFalse(p1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardXYBarPainter p1 = new StandardXYBarPainter(); + StandardXYBarPainter p2 = (StandardXYBarPainter) + TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StandardXYItemRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StandardXYItemRendererTest.java new file mode 100755 index 0000000..a09dbd6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/StandardXYItemRendererTest.java @@ -0,0 +1,267 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * StandardXYItemRendererTest.java + * ------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 22-Oct-2003 : Added hashCode test (DG); + * 08-Oct-2004 : Strengthened test for equals() method (DG); + * 14-Mar-2007 : Added new checks in testEquals() and testCloning() (DG); + * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); + * 08-Jun-2007 : Added testNoDisplayedItem() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.Graphics2D; +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.ChartRenderingInfo; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.entity.EntityCollection; +import org.jfree.chart.entity.XYItemEntity; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.util.PublicCloneable; +import org.jfree.util.UnitType; +import org.junit.Test; + +/** + * Tests for the {@link StandardXYItemRenderer} class. + */ +public class StandardXYItemRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + StandardXYItemRenderer r1 = new StandardXYItemRenderer(); + StandardXYItemRenderer r2 = new StandardXYItemRenderer(); + assertEquals(r1, r2); + + r1.setBaseShapesVisible(true); + assertFalse(r1.equals(r2)); + r2.setBaseShapesVisible(true); + assertTrue(r1.equals(r2)); + + r1.setPlotLines(false); + assertFalse(r1.equals(r2)); + r2.setPlotLines(false); + assertTrue(r1.equals(r2)); + + r1.setPlotImages(true); + assertFalse(r1.equals(r2)); + r2.setPlotImages(true); + assertTrue(r1.equals(r2)); + + r1.setPlotDiscontinuous(true); + assertFalse(r1.equals(r2)); + r2.setPlotDiscontinuous(true); + assertTrue(r1.equals(r2)); + + r1.setGapThresholdType(UnitType.ABSOLUTE); + assertFalse(r1.equals(r2)); + r2.setGapThresholdType(UnitType.ABSOLUTE); + assertTrue(r1.equals(r2)); + + r1.setGapThreshold(1.23); + assertFalse(r1.equals(r2)); + r2.setGapThreshold(1.23); + assertTrue(r1.equals(r2)); + + r1.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); + assertFalse(r1.equals(r2)); + r2.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); + assertTrue(r1.equals(r2)); + + r1.setShapesFilled(false); + assertFalse(r1.equals(r2)); + r2.setShapesFilled(false); + assertTrue(r1.equals(r2)); + + r1.setSeriesShapesFilled(1, Boolean.TRUE); + assertFalse(r1.equals(r2)); + r2.setSeriesShapesFilled(1, Boolean.TRUE); + assertTrue(r1.equals(r2)); + + r1.setBaseShapesFilled(false); + assertFalse(r1.equals(r2)); + r2.setBaseShapesFilled(false); + assertTrue(r1.equals(r2)); + + r1.setDrawSeriesLineAsPath(true); + assertFalse(r1.equals(r2)); + r2.setDrawSeriesLineAsPath(true); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + StandardXYItemRenderer r1 = new StandardXYItemRenderer(); + StandardXYItemRenderer r2 = new StandardXYItemRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + StandardXYItemRenderer r1 = new StandardXYItemRenderer(); + Rectangle2D rect1 = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); + r1.setLegendLine(rect1); + StandardXYItemRenderer r2 = (StandardXYItemRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // check independence + rect1.setRect(4.0, 3.0, 2.0, 1.0); + assertFalse(r1.equals(r2)); + r2.setLegendLine(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertTrue(r1.equals(r2)); + + r1.setSeriesShapesFilled(1, Boolean.TRUE); + assertFalse(r1.equals(r2)); + r2.setSeriesShapesFilled(1, Boolean.TRUE); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + StandardXYItemRenderer r1 = new StandardXYItemRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardXYItemRenderer r1 = new StandardXYItemRenderer(); + StandardXYItemRenderer r2 = (StandardXYItemRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + XYSeriesCollection d1 = new XYSeriesCollection(); + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + XYSeries s2 = new XYSeries("S2"); + s2.add(1.0, 1.1); + d1.addSeries(s1); + d1.addSeries(s2); + + XYSeriesCollection d2 = new XYSeriesCollection(); + XYSeries s3 = new XYSeries("S3"); + s3.add(1.0, 1.1); + XYSeries s4 = new XYSeries("S4"); + s4.add(1.0, 1.1); + XYSeries s5 = new XYSeries("S5"); + s5.add(1.0, 1.1); + d2.addSeries(s3); + d2.addSeries(s4); + d2.addSeries(s5); + + StandardXYItemRenderer r = new StandardXYItemRenderer(); + XYPlot plot = new XYPlot(d1, new NumberAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, d2); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("S5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + + /** + * A check to ensure that an item that falls outside the plot's data area + * does NOT generate an item entity. + */ + @Test + public void testNoDisplayedItem() { + XYSeriesCollection dataset = new XYSeriesCollection(); + XYSeries s1 = new XYSeries("S1"); + s1.add(10.0, 10.0); + dataset.addSeries(s1); + JFreeChart chart = ChartFactory.createXYLineChart("Title", "X", "Y", + dataset, PlotOrientation.VERTICAL, false, true, false); + XYPlot plot = (XYPlot) chart.getPlot(); + plot.setRenderer(new StandardXYItemRenderer()); + NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); + xAxis.setRange(0.0, 5.0); + NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); + yAxis.setRange(0.0, 5.0); + BufferedImage image = new BufferedImage(200 , 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + ChartRenderingInfo info = new ChartRenderingInfo(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 200, 100), null, info); + g2.dispose(); + EntityCollection ec = info.getEntityCollection(); + assertFalse(TestUtilities.containsInstanceOf(ec.getEntities(), + XYItemEntity.class)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/VectorRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/VectorRendererTest.java new file mode 100755 index 0000000..bed81e0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/VectorRendererTest.java @@ -0,0 +1,122 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * VectorRendererTest.java + * ----------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jan-2007 : Version 1 (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.Color; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link VectorRenderer} class. + */ +public class VectorRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + // default instances + VectorRenderer r1 = new VectorRenderer(); + VectorRenderer r2 = new VectorRenderer(); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + // check that super class fields are being looked at... + r1.setSeriesFillPaint(0, Color.green); + assertFalse(r1.equals(r2)); + r2.setSeriesFillPaint(0, Color.green); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + VectorRenderer r1 = new VectorRenderer(); + VectorRenderer r2 = new VectorRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + VectorRenderer r1 = new VectorRenderer(); + VectorRenderer r2 = (VectorRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + VectorRenderer r1 = new VectorRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + VectorRenderer r1 = new VectorRenderer(); + VectorRenderer r2 = (VectorRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/WindItemRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/WindItemRendererTest.java new file mode 100755 index 0000000..a0240ea --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/WindItemRendererTest.java @@ -0,0 +1,111 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * WindItemRendererTest.java + * ------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link WindItemRenderer} class. + */ +public class WindItemRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + WindItemRenderer r1 = new WindItemRenderer(); + WindItemRenderer r2 = new WindItemRenderer(); + assertEquals(r1, r2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + WindItemRenderer r1 = new WindItemRenderer(); + WindItemRenderer r2 = new WindItemRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + WindItemRenderer r1 = new WindItemRenderer(); + WindItemRenderer r2 = (WindItemRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + WindItemRenderer r1 = new WindItemRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + WindItemRenderer r1 = new WindItemRenderer(); + WindItemRenderer r2 = (WindItemRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYAreaRenderer2Test.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYAreaRenderer2Test.java new file mode 100755 index 0000000..fe33f97 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYAreaRenderer2Test.java @@ -0,0 +1,209 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * XYAreaRenderer2Test.java + * ------------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 24-May-2005 : Version 1 (DG); + * 30-Nov-2006 : Extended testEquals() and testCloning() (DG); + * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import java.awt.Rectangle; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.xy.DefaultTableXYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYAreaRenderer2} class. + */ +public class XYAreaRenderer2Test { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + XYAreaRenderer2 r1 = new XYAreaRenderer2(); + XYAreaRenderer2 r2 = new XYAreaRenderer2(); + assertEquals(r1, r2); + + r1.setOutline(!r1.isOutline()); + assertFalse(r1.equals(r2)); + r2.setOutline(r1.isOutline()); + assertTrue(r1.equals(r2)); + + r1.setLegendArea(new Rectangle(1, 2, 3, 4)); + assertFalse(r1.equals(r2)); + r2.setLegendArea(new Rectangle(1, 2, 3, 4)); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYAreaRenderer2 r1 = new XYAreaRenderer2(); + XYAreaRenderer2 r2 = new XYAreaRenderer2(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYAreaRenderer2 r1 = new XYAreaRenderer2(); + Rectangle rect = new Rectangle(1, 2, 3, 4); + r1.setLegendArea(rect); + XYAreaRenderer2 r2 = (XYAreaRenderer2) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // check independence + rect.setBounds(99, 99, 99, 99); + assertFalse(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYAreaRenderer2 r1 = new XYAreaRenderer2(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYAreaRenderer2 r1 = new XYAreaRenderer2(); + XYAreaRenderer2 r2 = (XYAreaRenderer2) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (particularly by code in the renderer). + */ + @Test + public void testDrawWithNullInfo() { + try { + DefaultTableXYDataset dataset = new DefaultTableXYDataset(); + + XYSeries s1 = new XYSeries("Series 1", true, false); + s1.add(5.0, 5.0); + s1.add(10.0, 15.5); + s1.add(15.0, 9.5); + s1.add(20.0, 7.5); + dataset.addSeries(s1); + + XYSeries s2 = new XYSeries("Series 2", true, false); + s2.add(5.0, 5.0); + s2.add(10.0, 15.5); + s2.add(15.0, 9.5); + s2.add(20.0, 3.5); + dataset.addSeries(s2); + XYPlot plot = new XYPlot(dataset, + new NumberAxis("X"), new NumberAxis("Y"), + new XYAreaRenderer2()); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + XYSeriesCollection d1 = new XYSeriesCollection(); + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + XYSeries s2 = new XYSeries("S2"); + s2.add(1.0, 1.1); + d1.addSeries(s1); + d1.addSeries(s2); + + XYSeriesCollection d2 = new XYSeriesCollection(); + XYSeries s3 = new XYSeries("S3"); + s3.add(1.0, 1.1); + XYSeries s4 = new XYSeries("S4"); + s4.add(1.0, 1.1); + XYSeries s5 = new XYSeries("S5"); + s5.add(1.0, 1.1); + d2.addSeries(s3); + d2.addSeries(s4); + d2.addSeries(s5); + + XYAreaRenderer2 r = new XYAreaRenderer2(); + XYPlot plot = new XYPlot(d1, new NumberAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, d2); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("S5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYAreaRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYAreaRendererTest.java new file mode 100755 index 0000000..6ce3850 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYAreaRendererTest.java @@ -0,0 +1,255 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * XYAreaRendererTest.java + * ----------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 22-Oct-2003 : Added hashCode test (DG); + * 14-Feb-2007 : Updated testCloning() (DG); + * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * 10-Jun-2009 : Check new fields (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.xy.DefaultTableXYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.ui.GradientPaintTransformType; +import org.jfree.ui.StandardGradientPaintTransformer; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYAreaRenderer} class. + */ +public class XYAreaRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + XYAreaRenderer r1 = new XYAreaRenderer(); + XYAreaRenderer r2 = new XYAreaRenderer(); + assertEquals(r1, r2); + + r1 = new XYAreaRenderer(XYAreaRenderer.AREA_AND_SHAPES); + assertFalse(r1.equals(r2)); + r2 = new XYAreaRenderer(XYAreaRenderer.AREA_AND_SHAPES); + assertTrue(r1.equals(r2)); + + r1 = new XYAreaRenderer(XYAreaRenderer.AREA); + assertFalse(r1.equals(r2)); + r2 = new XYAreaRenderer(XYAreaRenderer.AREA); + assertTrue(r1.equals(r2)); + + r1 = new XYAreaRenderer(XYAreaRenderer.LINES); + assertFalse(r1.equals(r2)); + r2 = new XYAreaRenderer(XYAreaRenderer.LINES); + assertTrue(r1.equals(r2)); + + r1 = new XYAreaRenderer(XYAreaRenderer.SHAPES); + assertFalse(r1.equals(r2)); + r2 = new XYAreaRenderer(XYAreaRenderer.SHAPES); + assertTrue(r1.equals(r2)); + + r1 = new XYAreaRenderer(XYAreaRenderer.SHAPES_AND_LINES); + assertFalse(r1.equals(r2)); + r2 = new XYAreaRenderer(XYAreaRenderer.SHAPES_AND_LINES); + assertTrue(r1.equals(r2)); + + r1.setOutline(true); + assertFalse(r1.equals(r2)); + r2.setOutline(true); + assertTrue(r1.equals(r2)); + + r1.setLegendArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertFalse(r1.equals(r2)); + r2.setLegendArea(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertTrue(r1.equals(r2)); + + r1.setUseFillPaint(true); + assertFalse(r1.equals(r2)); + r2.setUseFillPaint(true); + assertTrue(r1.equals(r2)); + + r1.setGradientTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_VERTICAL)); + assertFalse(r1.equals(r2)); + r2.setGradientTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_VERTICAL)); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYAreaRenderer r1 = new XYAreaRenderer(); + XYAreaRenderer r2 = new XYAreaRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + + r2.setUseFillPaint(true); + assertFalse(r1.hashCode() == r2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYAreaRenderer r1 = new XYAreaRenderer(); + Rectangle2D rect1 = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); + r1.setLegendArea(rect1); + XYAreaRenderer r2 = (XYAreaRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // check independence + rect1.setRect(4.0, 3.0, 2.0, 1.0); + assertFalse(r1.equals(r2)); + r2.setLegendArea(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYAreaRenderer r1 = new XYAreaRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYAreaRenderer r1 = new XYAreaRenderer(); + XYAreaRenderer r2 = (XYAreaRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (particularly by code in the renderer). + */ + @Test + public void testDrawWithNullInfo() { + try { + DefaultTableXYDataset dataset = new DefaultTableXYDataset(); + + XYSeries s1 = new XYSeries("Series 1", true, false); + s1.add(5.0, 5.0); + s1.add(10.0, 15.5); + s1.add(15.0, 9.5); + s1.add(20.0, 7.5); + dataset.addSeries(s1); + + XYSeries s2 = new XYSeries("Series 2", true, false); + s2.add(5.0, 5.0); + s2.add(10.0, 15.5); + s2.add(15.0, 9.5); + s2.add(20.0, 3.5); + dataset.addSeries(s2); + XYPlot plot = new XYPlot(dataset, + new NumberAxis("X"), new NumberAxis("Y"), + new XYAreaRenderer()); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + XYSeriesCollection d1 = new XYSeriesCollection(); + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + XYSeries s2 = new XYSeries("S2"); + s2.add(1.0, 1.1); + d1.addSeries(s1); + d1.addSeries(s2); + + XYSeriesCollection d2 = new XYSeriesCollection(); + XYSeries s3 = new XYSeries("S3"); + s3.add(1.0, 1.1); + XYSeries s4 = new XYSeries("S4"); + s4.add(1.0, 1.1); + XYSeries s5 = new XYSeries("S5"); + s5.add(1.0, 1.1); + d2.addSeries(s3); + d2.addSeries(s4); + d2.addSeries(s5); + + XYAreaRenderer r = new XYAreaRenderer(); + XYPlot plot = new XYPlot(d1, new NumberAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, d2); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("S5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYBarRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYBarRendererTest.java new file mode 100755 index 0000000..66f6d95 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYBarRendererTest.java @@ -0,0 +1,370 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * XYBarRendererTest.java + * ---------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 22-Oct-2003 : Added hashCode test (DG); + * 09-Feb-2007 : Added to testCloning() (DG); + * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * 19-Jun-2008 : Added testFindRangeBounds() (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.labels.ItemLabelPosition; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.Range; +import org.jfree.data.xy.DefaultIntervalXYDataset; +import org.jfree.data.xy.XYBarDataset; +import org.jfree.data.xy.XYIntervalSeries; +import org.jfree.data.xy.XYIntervalSeriesCollection; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.ui.GradientPaintTransformType; +import org.jfree.ui.StandardGradientPaintTransformer; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYBarRenderer} class. + */ +public class XYBarRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + + // default instances + XYBarRenderer r1 = new XYBarRenderer(); + XYBarRenderer r2 = new XYBarRenderer(); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + // setBase() + r1.setBase(1.0); + assertFalse(r1.equals(r2)); + r2.setBase(1.0); + assertTrue(r1.equals(r2)); + + // setUseYInterval + r1.setUseYInterval(!r1.getUseYInterval()); + assertFalse(r1.equals(r2)); + r2.setUseYInterval(!r2.getUseYInterval()); + assertTrue(r1.equals(r2)); + + // setMargin() + r1.setMargin(0.10); + assertFalse(r1.equals(r2)); + r2.setMargin(0.10); + assertTrue(r1.equals(r2)); + + // setDrawBarOutline() + r1.setDrawBarOutline(!r1.isDrawBarOutline()); + assertFalse(r1.equals(r2)); + r2.setDrawBarOutline(!r2.isDrawBarOutline()); + assertTrue(r1.equals(r2)); + + // setGradientPaintTransformer() + r1.setGradientPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_HORIZONTAL)); + assertFalse(r1.equals(r2)); + r2.setGradientPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_HORIZONTAL)); + assertTrue(r1.equals(r2)); + + // legendBar + r1.setLegendBar(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertFalse(r1.equals(r2)); + r2.setLegendBar(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertTrue(r1.equals(r2)); + + // positiveItemLabelFallbackPosition + r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition()); + assertFalse(r1.equals(r2)); + r2.setPositiveItemLabelPositionFallback(new ItemLabelPosition()); + assertTrue(r1.equals(r2)); + + // negativeItemLabelFallbackPosition + r1.setNegativeItemLabelPositionFallback(new ItemLabelPosition()); + assertFalse(r1.equals(r2)); + r2.setNegativeItemLabelPositionFallback(new ItemLabelPosition()); + assertTrue(r1.equals(r2)); + + // barPainter + r1.setBarPainter(new GradientXYBarPainter(0.11, 0.22, 0.33)); + assertFalse(r1.equals(r2)); + r2.setBarPainter(new GradientXYBarPainter(0.11, 0.22, 0.33)); + assertTrue(r1.equals(r2)); + + // shadowsVisible + r1.setShadowVisible(false); + assertFalse(r1.equals(r2)); + r2.setShadowVisible(false); + assertTrue(r1.equals(r2)); + + // shadowXOffset + r1.setShadowXOffset(3.3); + assertFalse(r1.equals(r2)); + r2.setShadowXOffset(3.3); + assertTrue(r1.equals(r2)); + + // shadowYOffset + r1.setShadowYOffset(3.3); + assertFalse(r1.equals(r2)); + r2.setShadowYOffset(3.3); + assertTrue(r1.equals(r2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYBarRenderer r1 = new XYBarRenderer(); + XYBarRenderer r2 = new XYBarRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYBarRenderer r1 = new XYBarRenderer(); + Rectangle2D rect = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); + r1.setLegendBar(rect); + XYBarRenderer r2 = (XYBarRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // check independence + rect.setRect(4.0, 3.0, 2.0, 1.0); + assertFalse(r1.equals(r2)); + r2.setLegendBar(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYBarRenderer r1 = new XYBarRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYBarRenderer r1 = new XYBarRenderer(); + XYBarRenderer r2 = (XYBarRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization2() { + XYBarRenderer r1 = new XYBarRenderer(); + r1.setPositiveItemLabelPositionFallback(new ItemLabelPosition()); + XYBarRenderer r2 = (XYBarRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Check that the renderer is calculating the domain bounds correctly. + */ + @Test + public void testFindDomainBounds() { + XYSeriesCollection dataset + = RendererXYPackageUtils.createTestXYSeriesCollection(); + JFreeChart chart = ChartFactory.createXYBarChart("Test Chart", "X", + false, "Y", dataset, PlotOrientation.VERTICAL, false, false, + false); + XYPlot plot = (XYPlot) chart.getPlot(); + NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); + domainAxis.setAutoRangeIncludesZero(false); + Range bounds = domainAxis.getRange(); + assertFalse(bounds.contains(0.3)); + assertTrue(bounds.contains(0.5)); + assertTrue(bounds.contains(2.5)); + assertFalse(bounds.contains(2.8)); + } + + /** + * A test for the findDomainBounds method to ensure it correctly accounts + * for the series visibility. + */ + @Test + public void testFindDomainBounds2() { + XYIntervalSeries s1 = new XYIntervalSeries("S1"); + s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5); + s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3); + XYIntervalSeries s2 = new XYIntervalSeries("S2"); + s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5); + s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0); + XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection(); + dataset.addSeries(s1); + dataset.addSeries(s2); + + XYBarRenderer renderer = new XYBarRenderer(); + Range r = renderer.findDomainBounds(dataset); + assertEquals(0.5, r.getLowerBound(), EPSILON); + assertEquals(4.1, r.getUpperBound(), EPSILON); + + renderer.setSeriesVisible(1, Boolean.FALSE); + r = renderer.findDomainBounds(dataset); + assertEquals(0.5, r.getLowerBound(), EPSILON); + assertEquals(2.1, r.getUpperBound(), EPSILON); + } + + private static final double EPSILON = 0.0000000001; + + /** + * A simple test for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset(); + double[] x = {1.0, 2.0, 3.0, 4.0}; + double[] startx = {0.9, 1.8, 2.7, 3.6}; + double[] endx = {1.1, 2.2, 3.3, 4.4}; + double[] y = {1.0, 2.0, 3.0, 4.0}; + double[] starty = {0.9, 1.8, 2.7, 3.6}; + double[] endy = {1.1, 2.2, 3.3, 4.4}; + double[][] data = new double[][] {x, startx, endx, y, starty, endy}; + dataset.addSeries("Series 1", data); + XYBarRenderer renderer = new XYBarRenderer(); + renderer.setUseYInterval(true); + Range r = renderer.findRangeBounds(dataset); + assertEquals(0.9, r.getLowerBound(), EPSILON); + assertEquals(4.4, r.getUpperBound(), EPSILON); + + renderer.setUseYInterval(false); + r = renderer.findRangeBounds(dataset); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(4.0, r.getUpperBound(), EPSILON); + } + + /** + * A test for the findRangeBounds method to ensure it correctly accounts + * for the series visibility. + */ + @Test + public void testFindRangeBounds2() { + XYIntervalSeries s1 = new XYIntervalSeries("S1"); + s1.add(1.0, 0.5, 1.5, 10.0, 9.5, 10.5); + s1.add(2.0, 1.9, 2.1, 20.0, 19.8, 20.3); + XYIntervalSeries s2 = new XYIntervalSeries("S2"); + s2.add(3.0, 2.5, 3.5, 30.0, 29.5, 30.5); + s2.add(4.0, 3.9, 4.1, 9.0, 9.0, 9.0); + XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection(); + dataset.addSeries(s1); + dataset.addSeries(s2); + + XYBarRenderer renderer = new XYBarRenderer(); + renderer.setUseYInterval(false); + Range r = renderer.findRangeBounds(dataset); + assertEquals(9.0, r.getLowerBound(), EPSILON); + assertEquals(30.0, r.getUpperBound(), EPSILON); + + renderer.setSeriesVisible(1, Boolean.FALSE); + r = renderer.findRangeBounds(dataset); + assertEquals(10.0, r.getLowerBound(), EPSILON); + assertEquals(20.0, r.getUpperBound(), EPSILON); + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + XYSeriesCollection d1 = new XYSeriesCollection(); + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + XYSeries s2 = new XYSeries("S2"); + s2.add(1.0, 1.1); + d1.addSeries(s1); + d1.addSeries(s2); + + XYSeriesCollection d2 = new XYSeriesCollection(); + XYSeries s3 = new XYSeries("S3"); + s3.add(1.0, 1.1); + XYSeries s4 = new XYSeries("S4"); + s4.add(1.0, 1.1); + XYSeries s5 = new XYSeries("S5"); + s5.add(1.0, 1.1); + d2.addSeries(s3); + d2.addSeries(s4); + d2.addSeries(s5); + + XYBarRenderer r = new XYBarRenderer(); + XYPlot plot = new XYPlot(new XYBarDataset(d1, 1.0), new NumberAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, new XYBarDataset(d2, 2.0)); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("S5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYBlockRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYBlockRendererTest.java new file mode 100755 index 0000000..f743d99 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYBlockRendererTest.java @@ -0,0 +1,219 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * XYBlockRendererTest.java + * ------------------------ + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Jul-2006 : Version 1 (DG); + * 09-Mar-2007 : Added independence check to testCloning (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * 20-Oct-2011 : Added testFindDomainBounds() and testFindRangeBounds() (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + +import java.awt.Color; + +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.renderer.GrayPaintScale; +import org.jfree.chart.renderer.LookupPaintScale; +import org.jfree.data.Range; +import org.jfree.data.xy.DefaultXYZDataset; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.data.xy.XYSeries; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYBlockRenderer} class. + */ +public class XYBlockRendererTest { + + private static final double EPSILON = 0.0000000001; + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + + // default instances + XYBlockRenderer r1 = new XYBlockRenderer(); + XYBlockRenderer r2 = new XYBlockRenderer(); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + // blockHeight + r1.setBlockHeight(2.0); + assertFalse(r1.equals(r2)); + r2.setBlockHeight(2.0); + assertTrue(r1.equals(r2)); + + // blockWidth + r1.setBlockWidth(2.0); + assertFalse(r1.equals(r2)); + r2.setBlockWidth(2.0); + assertTrue(r1.equals(r2)); + + // paintScale + r1.setPaintScale(new GrayPaintScale(0.0, 1.0)); + assertFalse(r1.equals(r2)); + r2.setPaintScale(new GrayPaintScale(0.0, 1.0)); + assertTrue(r1.equals(r2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYBlockRenderer r1 = new XYBlockRenderer(); + XYBlockRenderer r2 = new XYBlockRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYBlockRenderer r1 = new XYBlockRenderer(); + LookupPaintScale scale1 = new LookupPaintScale(); + r1.setPaintScale(scale1); + XYBlockRenderer r2 = (XYBlockRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // check independence + scale1.add(0.5, Color.red); + assertFalse(r1.equals(r2)); + LookupPaintScale scale2 = (LookupPaintScale) r2.getPaintScale(); + scale2.add(0.5, Color.red); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYBlockRenderer r1 = new XYBlockRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYBlockRenderer r1 = new XYBlockRenderer(); + XYBlockRenderer r2 = (XYBlockRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * A simple test for bug 1766646. + */ + @Test + public void testBug1766646A() { + XYBlockRenderer r = new XYBlockRenderer(); + Range range = r.findDomainBounds(null); + assertTrue(range == null); + DefaultXYZDataset emptyDataset = new DefaultXYZDataset(); + range = r.findDomainBounds(emptyDataset); + assertTrue(range == null); + } + + /** + * A simple test for bug 1766646. + */ + @Test + public void testBug1766646B() { + XYBlockRenderer r = new XYBlockRenderer(); + Range range = r.findRangeBounds(null); + assertTrue(range == null); + DefaultXYZDataset emptyDataset = new DefaultXYZDataset(); + range = r.findRangeBounds(emptyDataset); + assertTrue(range == null); + } + + /** + * Some tests for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + XYBlockRenderer renderer = new XYBlockRenderer(); + assertNull(renderer.findRangeBounds(null)); + + XYSeriesCollection dataset = new XYSeriesCollection(); + XYSeries series = new XYSeries("S1"); + series.add(1.0, null); + dataset.addSeries(series); + Range r = renderer.findRangeBounds(dataset); + assertNull(r); + } + + /** + * Some tests for the findDomainBounds() method. + */ + @Test + public void testFindDomainBounds() { + XYBlockRenderer renderer = new XYBlockRenderer(); + assertNull(renderer.findRangeBounds(null)); + + XYSeriesCollection dataset = new XYSeriesCollection(); + XYSeries series = new XYSeries("S1"); + series.add(1.0, null); + dataset.addSeries(series); + Range r = renderer.findDomainBounds(dataset); + assertEquals(0.5, r.getLowerBound(), EPSILON); + assertEquals(1.5, r.getUpperBound(), EPSILON); + + dataset.removeAllSeries(); + r = renderer.findDomainBounds(dataset); + assertNull(r); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRendererTest.java new file mode 100755 index 0000000..0bd2acc --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYBoxAndWhiskerRendererTest.java @@ -0,0 +1,187 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------- + * XYBoxAndWhiskerRendererTest.java + * -------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Oct-2003 : Version 1 (DG); + * 23-Apr-2004 : Extended testEquals() method (DG); + * 27-Mar-2008 : Extended testEquals() some more (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * 08-Dec-2008 : Added test2909215() (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Graphics2D; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.util.Date; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.data.statistics.BoxAndWhiskerItem; +import org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYBoxAndWhiskerRenderer} class. + */ +public class XYBoxAndWhiskerRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer(); + XYBoxAndWhiskerRenderer r2 = new XYBoxAndWhiskerRenderer(); + assertEquals(r1, r2); + + r1.setPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.red)); + assertFalse(r1.equals(r2)); + r2.setPaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.red)); + assertEquals(r1, r2); + + r1.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.green, + 3.0f, 4.0f, Color.red)); + assertFalse(r1.equals(r2)); + r2.setArtifactPaint(new GradientPaint(1.0f, 2.0f, Color.green, + 3.0f, 4.0f, Color.red)); + assertEquals(r1, r2); + + r1.setBoxWidth(0.55); + assertFalse(r1.equals(r2)); + r2.setBoxWidth(0.55); + assertEquals(r1, r2); + + r1.setFillBox(!r1.getFillBox()); + assertFalse(r1.equals(r2)); + r2.setFillBox(!r2.getFillBox()); + assertEquals(r1, r2); + + r1.setBoxPaint(Color.yellow); + assertFalse(r1.equals(r2)); + r2.setBoxPaint(Color.yellow); + assertEquals(r1, r2); + + // check boxPaint null also + r1.setBoxPaint(null); + assertFalse(r1.equals(r2)); + r2.setBoxPaint(null); + assertEquals(r1, r2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer(); + XYBoxAndWhiskerRenderer r2 = new XYBoxAndWhiskerRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer(); + XYBoxAndWhiskerRenderer r2 = (XYBoxAndWhiskerRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYBoxAndWhiskerRenderer r1 = new XYBoxAndWhiskerRenderer(); + XYBoxAndWhiskerRenderer r2 = (XYBoxAndWhiskerRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * A test for bug report 2909215. + */ + @Test + public void test2909215() { + DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset( + "Series"); + d1.add(new Date(1L), new BoxAndWhiskerItem(new Double(1.0), + new Double(2.0), new Double(3.0), new Double(4.0), + new Double(5.0), new Double(6.0), null, null, null)); + JFreeChart chart = ChartFactory.createBoxAndWhiskerChart("Title", "X", + "Y", d1, true); + try { + BufferedImage image = new BufferedImage(400, 200, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + chart.draw(g2, new Rectangle2D.Double(0, 0, 400, 200), null, null); + g2.dispose(); + } + catch (Exception e) { + fail("No exception should be thrown."); + } + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYBubbleRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYBubbleRendererTest.java new file mode 100755 index 0000000..30b6546 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYBubbleRendererTest.java @@ -0,0 +1,169 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * XYBubbleRendererTest.java + * ------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 24-Jan-2007 : Added more checks to testEquals() (DG); + * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.xy.DefaultXYZDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYBubbleRenderer} class. + */ +public class XYBubbleRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + XYBubbleRenderer r1 = new XYBubbleRenderer(); + XYBubbleRenderer r2 = new XYBubbleRenderer(); + assertEquals(r1, r2); + + r1 = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS); + assertFalse(r1.equals(r2)); + r2 = new XYBubbleRenderer(XYBubbleRenderer.SCALE_ON_RANGE_AXIS); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYBubbleRenderer r1 = new XYBubbleRenderer(); + XYBubbleRenderer r2 = new XYBubbleRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYBubbleRenderer r1 = new XYBubbleRenderer(); + XYBubbleRenderer r2 = (XYBubbleRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYBubbleRenderer r1 = new XYBubbleRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYBubbleRenderer r1 = new XYBubbleRenderer(); + XYBubbleRenderer r2 = (XYBubbleRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + DefaultXYZDataset d1 = new DefaultXYZDataset(); + double[] x = {2.1, 2.3, 2.3, 2.2, 2.2, 1.8, 1.8, 1.9, 2.3, 3.8}; + double[] y = {14.1, 11.1, 10.0, 8.8, 8.7, 8.4, 5.4, 4.1, 4.1, 25}; + double[] z = {2.4, 2.7, 2.7, 2.2, 2.2, 2.2, 2.1, 2.2, 1.6, 4}; + double[][] s1 = new double[][] {x, y, z}; + d1.addSeries("S1", s1); + x = new double[] {2.1}; + y = new double[] {14.1}; + z = new double[] {2.4}; + double[][] s2 = new double[][] {x, y, z}; + d1.addSeries("S2", s2); + + DefaultXYZDataset d2 = new DefaultXYZDataset(); + x = new double[] {2.1}; + y = new double[] {14.1}; + z = new double[] {2.4}; + double[][] s3 = new double[][] {x, y, z}; + d2.addSeries("S3", s3); + x = new double[] {2.1}; + y = new double[] {14.1}; + z = new double[] {2.4}; + double[][] s4 = new double[][] {x, y, z}; + d2.addSeries("S4", s4); + x = new double[] {2.1}; + y = new double[] {14.1}; + z = new double[] {2.4}; + double[][] s5 = new double[][] {x, y, z}; + d2.addSeries("S5", s5); + + XYBubbleRenderer r = new XYBubbleRenderer(); + XYPlot plot = new XYPlot(d1, new NumberAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, d2); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("S5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYDifferenceRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYDifferenceRendererTest.java new file mode 100755 index 0000000..f156aa4 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYDifferenceRendererTest.java @@ -0,0 +1,213 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * XYDifferenceRendererTest.java + * ----------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Oct-2003 : Version 1 (DG); + * 04-May-2005 : Improved equals() test (DG); + * 24-Jan-2007 : Added 'roundXCoordinates' to testEquals(), and improved + * testClone() (DG); + * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.Color; +import java.awt.GradientPaint; +import java.awt.Shape; +import java.awt.geom.Line2D; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYDifferenceRenderer} class. + */ +public class XYDifferenceRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + XYDifferenceRenderer r1 = new XYDifferenceRenderer( + Color.red, Color.blue, false); + XYDifferenceRenderer r2 = new XYDifferenceRenderer( + Color.red, Color.blue, false); + assertEquals(r1, r2); + + // positive paint + r1.setPositivePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertFalse(r1.equals(r2)); + r2.setPositivePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertTrue(r1.equals(r2)); + + // negative paint + r1.setNegativePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.blue)); + assertFalse(r1.equals(r2)); + r2.setNegativePaint(new GradientPaint(1.0f, 2.0f, Color.yellow, + 3.0f, 4.0f, Color.blue)); + assertTrue(r1.equals(r2)); + + // shapesVisible + r1 = new XYDifferenceRenderer(Color.green, Color.yellow, true); + assertFalse(r1.equals(r2)); + r2 = new XYDifferenceRenderer(Color.green, Color.yellow, true); + assertTrue(r1.equals(r2)); + + // legendLine + r1.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); + assertFalse(r1.equals(r2)); + r2.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); + assertTrue(r1.equals(r2)); + + // roundXCoordinates + r1.setRoundXCoordinates(true); + assertFalse(r1.equals(r2)); + r2.setRoundXCoordinates(true); + assertTrue(r1.equals(r2)); + + assertFalse(r1.equals(null)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYDifferenceRenderer r1 + = new XYDifferenceRenderer(Color.red, Color.blue, false); + XYDifferenceRenderer r2 + = new XYDifferenceRenderer(Color.red, Color.blue, false); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYDifferenceRenderer r1 = new XYDifferenceRenderer(Color.red, + Color.blue, false); + XYDifferenceRenderer r2 = (XYDifferenceRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // check independence + Shape s = r1.getLegendLine(); + if (s instanceof Line2D) { + Line2D l = (Line2D) s; + l.setLine(1.0, 2.0, 3.0, 4.0); + assertFalse(r1.equals(r2)); + } + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYDifferenceRenderer r1 = new XYDifferenceRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYDifferenceRenderer r1 = new XYDifferenceRenderer(Color.red, + Color.blue, false); + XYDifferenceRenderer r2 = (XYDifferenceRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + XYSeriesCollection d1 = new XYSeriesCollection(); + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + XYSeries s2 = new XYSeries("S2"); + s2.add(1.0, 1.1); + d1.addSeries(s1); + d1.addSeries(s2); + + XYSeriesCollection d2 = new XYSeriesCollection(); + XYSeries s3 = new XYSeries("S3"); + s3.add(1.0, 1.1); + XYSeries s4 = new XYSeries("S4"); + s4.add(1.0, 1.1); + XYSeries s5 = new XYSeries("S5"); + s5.add(1.0, 1.1); + d2.addSeries(s3); + d2.addSeries(s4); + d2.addSeries(s5); + + XYDifferenceRenderer r = new XYDifferenceRenderer(); + XYPlot plot = new XYPlot(d1, new NumberAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, d2); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("S5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYDotRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYDotRendererTest.java new file mode 100755 index 0000000..24006d0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYDotRendererTest.java @@ -0,0 +1,179 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * XYDotRendererTest.java + * ---------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); + * 09-Nov-2007 : Updated testEquals() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYDotRenderer} class. + */ +public class XYDotRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + XYDotRenderer r1 = new XYDotRenderer(); + XYDotRenderer r2 = new XYDotRenderer(); + assertEquals(r1, r2); + + r1.setDotWidth(11); + assertFalse(r1.equals(r2)); + r2.setDotWidth(11); + assertTrue(r1.equals(r2)); + + r1.setDotHeight(12); + assertFalse(r1.equals(r2)); + r2.setDotHeight(12); + assertTrue(r1.equals(r2)); + + r1.setLegendShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertFalse(r1.equals(r2)); + r2.setLegendShape(new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0)); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYDotRenderer r1 = new XYDotRenderer(); + XYDotRenderer r2 = new XYDotRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + + r1.setDotHeight(12); + r2.setDotHeight(12); + assertTrue(r1.equals(r2)); + h1 = r1.hashCode(); + h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYDotRenderer r1 = new XYDotRenderer(); + XYDotRenderer r2 = (XYDotRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYDotRenderer r1 = new XYDotRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYDotRenderer r1 = new XYDotRenderer(); + XYDotRenderer r2 = (XYDotRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + XYSeriesCollection d1 = new XYSeriesCollection(); + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + XYSeries s2 = new XYSeries("S2"); + s2.add(1.0, 1.1); + d1.addSeries(s1); + d1.addSeries(s2); + + XYSeriesCollection d2 = new XYSeriesCollection(); + XYSeries s3 = new XYSeries("S3"); + s3.add(1.0, 1.1); + XYSeries s4 = new XYSeries("S4"); + s4.add(1.0, 1.1); + XYSeries s5 = new XYSeries("S5"); + s5.add(1.0, 1.1); + d2.addSeries(s3); + d2.addSeries(s4); + d2.addSeries(s5); + + XYDotRenderer r = new XYDotRenderer(); + XYPlot plot = new XYPlot(d1, new NumberAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, d2); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("S5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYErrorRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYErrorRendererTest.java new file mode 100755 index 0000000..62b8624 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYErrorRendererTest.java @@ -0,0 +1,197 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * XYErrorRendererTest.java + * ------------------------ + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Oct-2006 : Version 1 (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * 28-Jan-2009 : Updated tests for new errorStroke field (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYErrorRenderer} class. + */ +public class XYErrorRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + XYErrorRenderer r1 = new XYErrorRenderer(); + XYErrorRenderer r2 = new XYErrorRenderer(); + assertEquals(r1, r2); + + // drawXError + r1.setDrawXError(false); + assertFalse(r1.equals(r2)); + r2.setDrawXError(false); + assertTrue(r1.equals(r2)); + + // drawYError + r1.setDrawYError(false); + assertFalse(r1.equals(r2)); + r2.setDrawYError(false); + assertTrue(r1.equals(r2)); + + // capLength + r1.setCapLength(9.0); + assertFalse(r1.equals(r2)); + r2.setCapLength(9.0); + assertTrue(r1.equals(r2)); + + // errorPaint + r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.green)); + assertFalse(r1.equals(r2)); + r2.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.green)); + assertTrue(r1.equals(r2)); + + // errorStroke + r1.setErrorStroke(new BasicStroke(1.5f)); + assertFalse(r1.equals(r2)); + r2.setErrorStroke(new BasicStroke(1.5f)); + assertTrue(r1.equals(r2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYErrorRenderer r1 = new XYErrorRenderer(); + XYErrorRenderer r2 = new XYErrorRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYErrorRenderer r1 = new XYErrorRenderer(); + r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.white)); + XYErrorRenderer r2 = (XYErrorRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * A test for cloning. + */ + @Test + public void testCloning2() throws CloneNotSupportedException { + XYErrorRenderer r1 = new XYErrorRenderer(); + r1.setErrorStroke(new BasicStroke(1.5f)); + XYErrorRenderer r2 = (XYErrorRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYErrorRenderer r1 = new XYErrorRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYErrorRenderer r1 = new XYErrorRenderer(); + r1.setErrorPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.white)); + XYErrorRenderer r2 = (XYErrorRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization2() { + XYErrorRenderer r1 = new XYErrorRenderer(); + r1.setErrorStroke(new BasicStroke(1.5f)); + XYErrorRenderer r2 = (XYErrorRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Some checks for the findDomainBounds() method. + */ + @Test + public void testFindDomainBounds() { + XYErrorRenderer r = new XYErrorRenderer(); + assertNull(r.findDomainBounds(null)); + } + + + /** + * Some checks for the findRangeBounds() method. + */ + @Test + public void testFindRangeBounds() { + XYErrorRenderer r = new XYErrorRenderer(); + assertNull(r.findRangeBounds(null)); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYLine3DRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYLine3DRendererTest.java new file mode 100755 index 0000000..42a1181 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYLine3DRendererTest.java @@ -0,0 +1,136 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * XYLine3DRendererTest.java + * ------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Apr-2007 : Version 1 (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYLine3DRenderer} class. + */ +public class XYLine3DRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + XYLine3DRenderer r1 = new XYLine3DRenderer(); + XYLine3DRenderer r2 = new XYLine3DRenderer(); + assertEquals(r1, r2); + + r1.setXOffset(11.1); + assertFalse(r1.equals(r2)); + r2.setXOffset(11.1); + assertTrue(r1.equals(r2)); + + r1.setYOffset(11.1); + assertFalse(r1.equals(r2)); + r2.setYOffset(11.1); + assertTrue(r1.equals(r2)); + + r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.blue)); + assertFalse(r1.equals(r2)); + r2.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.blue)); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYLine3DRenderer r1 = new XYLine3DRenderer(); + XYLine3DRenderer r2 = new XYLine3DRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYLine3DRenderer r1 = new XYLine3DRenderer(); + r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue)); + XYLine3DRenderer r2 = (XYLine3DRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYLine3DRenderer r1 = new XYLine3DRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYLine3DRenderer r1 = new XYLine3DRenderer(); + r1.setWallPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, + Color.blue)); + XYLine3DRenderer r2 = (XYLine3DRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYLineAndShapeRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYLineAndShapeRendererTest.java new file mode 100755 index 0000000..58ab069 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYLineAndShapeRendererTest.java @@ -0,0 +1,316 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * XYLineAndShapeRendererTest.java + * ------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Jan-2004 : Version 1 (DG); + * 07-Jan-2005 : Added check for findRangeBounds() method (DG); + * 21-Feb-2007 : Check independence in testCloning() (DG); + * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); + * 22-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.ChartFactory; +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.urls.TimeSeriesURLGenerator; +import org.jfree.data.Range; +import org.jfree.data.xy.TableXYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYLineAndShapeRenderer} class. + */ +public class XYLineAndShapeRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + + XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); + XYLineAndShapeRenderer r2 = new XYLineAndShapeRenderer(); + assertEquals(r1, r2); + assertEquals(r2, r1); + + r1.setLinesVisible(true); + assertFalse(r1.equals(r2)); + r2.setLinesVisible(true); + assertTrue(r1.equals(r2)); + + r1.setSeriesLinesVisible(3, true); + assertFalse(r1.equals(r2)); + r2.setSeriesLinesVisible(3, true); + assertTrue(r1.equals(r2)); + + r1.setBaseLinesVisible(false); + assertFalse(r1.equals(r2)); + r2.setBaseLinesVisible(false); + assertTrue(r1.equals(r2)); + + r1.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); + assertFalse(r1.equals(r2)); + r2.setLegendLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); + assertTrue(r1.equals(r2)); + + r1.setShapesVisible(true); + assertFalse(r1.equals(r2)); + r2.setShapesVisible(true); + assertTrue(r1.equals(r2)); + + r1.setSeriesShapesVisible(3, true); + assertFalse(r1.equals(r2)); + r2.setSeriesShapesVisible(3, true); + assertTrue(r1.equals(r2)); + + r1.setBaseShapesVisible(false); + assertFalse(r1.equals(r2)); + r2.setBaseShapesVisible(false); + assertTrue(r1.equals(r2)); + + r1.setShapesFilled(true); + assertFalse(r1.equals(r2)); + r2.setShapesFilled(true); + assertTrue(r1.equals(r2)); + + r1.setSeriesShapesFilled(3, true); + assertFalse(r1.equals(r2)); + r2.setSeriesShapesFilled(3, true); + assertTrue(r1.equals(r2)); + + r1.setBaseShapesFilled(false); + assertFalse(r1.equals(r2)); + r2.setBaseShapesFilled(false); + assertTrue(r1.equals(r2)); + + r1.setDrawOutlines(!r1.getDrawOutlines()); + assertFalse(r1.equals(r2)); + r2.setDrawOutlines(r1.getDrawOutlines()); + assertTrue(r1.equals(r2)); + + r1.setUseOutlinePaint(true); + assertFalse(r1.equals(r2)); + r2.setUseOutlinePaint(true); + assertTrue(r1.equals(r2)); + + r1.setUseFillPaint(true); + assertFalse(r1.equals(r2)); + r2.setUseFillPaint(true); + assertTrue(r1.equals(r2)); + + r1.setDrawSeriesLineAsPath(true); + assertFalse(r1.equals(r2)); + r2.setDrawSeriesLineAsPath(true); + assertTrue(r1.equals(r2)); + } + + /** + * Test that the equals() method works for a TimeSeriesURLGenerator. + */ + @Test + public void testEquals2() { + XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); + XYLineAndShapeRenderer r2 = new XYLineAndShapeRenderer(); + assertEquals(r1, r2); + assertEquals(r2, r1); + + r1.setURLGenerator(new TimeSeriesURLGenerator()); + assertFalse(r1.equals(r2)); + r2.setURLGenerator(new TimeSeriesURLGenerator()); + assertTrue(r1.equals(r2)); + } + + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); + XYLineAndShapeRenderer r2 = new XYLineAndShapeRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + Rectangle2D legendShape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); + XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); + r1.setLegendLine(legendShape); + XYLineAndShapeRenderer r2 = (XYLineAndShapeRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + r1.setSeriesLinesVisible(0, false); + assertFalse(r1.equals(r2)); + r2.setSeriesLinesVisible(0, false); + assertTrue(r1.equals(r2)); + + legendShape.setRect(4.0, 3.0, 2.0, 1.0); + assertFalse(r1.equals(r2)); + r2.setLegendLine(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertTrue(r1.equals(r2)); + + r1.setSeriesShapesVisible(1, true); + assertFalse(r1.equals(r2)); + r2.setSeriesShapesVisible(1, true); + assertTrue(r1.equals(r2)); + + r1.setSeriesShapesFilled(1, true); + assertFalse(r1.equals(r2)); + r2.setSeriesShapesFilled(1, true); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYLineAndShapeRenderer r1 = new XYLineAndShapeRenderer(); + XYLineAndShapeRenderer r2 = (XYLineAndShapeRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Check that the renderer is calculating the domain bounds correctly. + */ + @Test + public void testFindDomainBounds() { + XYSeriesCollection dataset + = RendererXYPackageUtils.createTestXYSeriesCollection(); + JFreeChart chart = ChartFactory.createXYLineChart( + "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, + false, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); + domainAxis.setAutoRangeIncludesZero(false); + Range bounds = domainAxis.getRange(); + assertFalse(bounds.contains(0.9)); + assertTrue(bounds.contains(1.0)); + assertTrue(bounds.contains(2.0)); + assertFalse(bounds.contains(2.10)); + } + + /** + * Check that the renderer is calculating the range bounds correctly. + */ + @Test + public void testFindRangeBounds() { + TableXYDataset dataset + = RendererXYPackageUtils.createTestTableXYDataset(); + JFreeChart chart = ChartFactory.createXYLineChart( + "Test Chart", "X", "Y", dataset, PlotOrientation.VERTICAL, + false, false, false); + XYPlot plot = (XYPlot) chart.getPlot(); + NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); + rangeAxis.setAutoRangeIncludesZero(false); + Range bounds = rangeAxis.getRange(); + assertFalse(bounds.contains(1.0)); + assertTrue(bounds.contains(2.0)); + assertTrue(bounds.contains(5.0)); + assertFalse(bounds.contains(6.0)); + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + XYSeriesCollection d1 = new XYSeriesCollection(); + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + XYSeries s2 = new XYSeries("S2"); + s2.add(1.0, 1.1); + d1.addSeries(s1); + d1.addSeries(s2); + + XYSeriesCollection d2 = new XYSeriesCollection(); + XYSeries s3 = new XYSeries("S3"); + s3.add(1.0, 1.1); + XYSeries s4 = new XYSeries("S4"); + s4.add(1.0, 1.1); + XYSeries s5 = new XYSeries("S5"); + s5.add(1.0, 1.1); + d2.addSeries(s3); + d2.addSeries(s4); + d2.addSeries(s5); + + XYLineAndShapeRenderer r = new XYLineAndShapeRenderer(); + XYPlot plot = new XYPlot(d1, new NumberAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, d2); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("S5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYShapeRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYShapeRendererTest.java new file mode 100755 index 0000000..617dce7 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYShapeRendererTest.java @@ -0,0 +1,189 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * XYShapeRendererTest.java + * ------------------------ + * (C) Copyright 2010-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Martin Hoeller (patch 2952086); + * + * Changes + * ------- + * 17-Sep-2008 : Version 1 (DG); + * 16-Feb-2010 : Added testFindZBounds() (MH); + * 19-Oct-2011 : Added test3026341() (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; + +import java.awt.Color; + +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.renderer.LookupPaintScale; +import org.jfree.data.Range; +import org.jfree.data.xy.DefaultXYZDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.junit.Test; + +/** + * Tests for the {@link XYShapeRenderer} class. + */ +public class XYShapeRendererTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + XYShapeRenderer r1 = new XYShapeRenderer(); + XYShapeRenderer r2 = new XYShapeRenderer(); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + r1.setPaintScale(new LookupPaintScale(1.0, 2.0, Color.white)); + assertFalse(r1.equals(r2)); + r2.setPaintScale(new LookupPaintScale(1.0, 2.0, Color.white)); + assertTrue(r1.equals(r2)); + + r1.setDrawOutlines(true); + assertFalse(r1.equals(r2)); + r2.setDrawOutlines(true); + assertTrue(r1.equals(r2)); + + r1.setUseOutlinePaint(false); + assertFalse(r1.equals(r2)); + r2.setUseOutlinePaint(false); + assertTrue(r1.equals(r2)); + + r1.setUseFillPaint(true); + assertFalse(r1.equals(r2)); + r2.setUseFillPaint(true); + assertTrue(r1.equals(r2)); + + r1.setGuideLinesVisible(true); + assertFalse(r1.equals(r2)); + r2.setGuideLinesVisible(true); + assertTrue(r1.equals(r2)); + + r1.setGuideLinePaint(Color.red); + assertFalse(r1.equals(r2)); + r2.setGuideLinePaint(Color.red); + assertTrue(r1.equals(r2)); + + } + + /** + * Confirm that cloning works. + */ + public void testCloning() throws CloneNotSupportedException { + XYShapeRenderer r1 = new XYShapeRenderer(); + XYShapeRenderer r2 = (XYShapeRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + public void testSerialization() { + XYShapeRenderer r1 = new XYShapeRenderer(); + XYShapeRenderer r2 = (XYShapeRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + private static final double EPSILON = 0.0000000001; + + /** + * Check if finding the bounds in z-dimension of an XYZDataset works. + */ + public void testFindZBounds() { + XYShapeRenderer r = new XYShapeRenderer(); + assertNull(r.findZBounds(null)); + + DefaultXYZDataset dataset = new DefaultXYZDataset(); + Range range; + + double data1[][] = { {1,1,1}, {1,1,1}, {1,2,3} }; + dataset.addSeries("series1", data1); + range = r.findZBounds(dataset); + assertNotNull(range); + assertEquals(1d, range.getLowerBound(), EPSILON); + assertEquals(3d, range.getUpperBound(), EPSILON); + + double data2[][] = { {1,1,1}, {1,1,1}, {-1,-2,-3} }; + dataset.removeSeries("series1"); + dataset.addSeries("series2", data2); + range = r.findZBounds(dataset); + assertNotNull(range); + assertEquals(-3d, range.getLowerBound(), EPSILON); + assertEquals(-1d, range.getUpperBound(), EPSILON); + + double data3[][] = { {1,1,1}, {1,1,1}, {-1.2,2.9,3.8} }; + dataset.removeSeries("series2"); + dataset.addSeries("series3", data3); + range = r.findZBounds(dataset); + assertNotNull(range); + assertEquals(-1.2d, range.getLowerBound(), EPSILON); + assertEquals(3.8d, range.getUpperBound(), EPSILON); + } + + /** + * Test for bug 3026341. + */ + public void test3026341() { + XYShapeRenderer renderer = new XYShapeRenderer(); + assertNull(renderer.findRangeBounds(null)); + + XYSeriesCollection dataset = new XYSeriesCollection(); + XYSeries series = new XYSeries("S1"); + series.add(1.0, null); + dataset.addSeries(series); + Range r = renderer.findRangeBounds(dataset); + assertNull(r); + + // test findDomainBounds as well + r = renderer.findDomainBounds(dataset); + assertEquals(r.getLowerBound(), 1.0, EPSILON); + assertEquals(r.getUpperBound(), 1.0, EPSILON); + + dataset.removeAllSeries(); + r = renderer.findDomainBounds(dataset); + assertNull(r); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYSplineRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYSplineRendererTest.java new file mode 100755 index 0000000..430349a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYSplineRendererTest.java @@ -0,0 +1,142 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * XYSplineRendererTest.java + * ------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Jul-2007 : Version 1 (DG); + * 22-Apr-2008 : Added testPublicCloneable() (DG); + * 20-Nov-2013 : Add tests for new fields (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; +import org.jfree.ui.GradientPaintTransformType; +import org.jfree.ui.StandardGradientPaintTransformer; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYSplineRenderer} class. + */ +public class XYSplineRendererTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + XYSplineRenderer r1 = new XYSplineRenderer(); + XYSplineRenderer r2 = new XYSplineRenderer(); + assertEquals(r1, r2); + assertEquals(r2, r1); + + r1.setPrecision(9); + assertFalse(r1.equals(r2)); + r2.setPrecision(9); + assertTrue(r1.equals(r2)); + + r1.setFillType(XYSplineRenderer.FillType.TO_ZERO); + assertFalse(r1.equals(r2)); + r2.setFillType(XYSplineRenderer.FillType.TO_ZERO); + assertTrue(r1.equals(r2)); + + r1.setGradientPaintTransformer(null); + assertFalse(r1.equals(r2)); + r2.setGradientPaintTransformer(null); + assertTrue(r1.equals(r2)); + + r1.setGradientPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.HORIZONTAL)); + assertFalse(r1.equals(r2)); + r2.setGradientPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.HORIZONTAL)); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYSplineRenderer r1 = new XYSplineRenderer(); + XYSplineRenderer r2 = new XYSplineRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + Rectangle2D legendShape = new Rectangle2D.Double(1.0, 2.0, 3.0, 4.0); + XYSplineRenderer r1 = new XYSplineRenderer(); + r1.setLegendLine(legendShape); + XYSplineRenderer r2 = (XYSplineRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYSplineRenderer r1 = new XYSplineRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYSplineRenderer r1 = new XYSplineRenderer(); + XYSplineRenderer r2 = (XYSplineRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYStepAreaRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYStepAreaRendererTest.java new file mode 100755 index 0000000..eb379b3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYStepAreaRendererTest.java @@ -0,0 +1,180 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * XYStepAreaRendererTest.java + * --------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Matthias Rose; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 26-Sep-2003 : copied XYStepRendererTests.java and used for + * testing XYStepAreaRenderer (MR); + * 14-Feb-2007 : Extended testEquals() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.xy.DefaultTableXYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYStepAreaRenderer} class. + */ +public class XYStepAreaRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + XYStepAreaRenderer r1 = new XYStepAreaRenderer(); + XYStepAreaRenderer r2 = new XYStepAreaRenderer(); + assertEquals(r1, r2); + + r1.setOutline(true); + assertFalse(r1.equals(r2)); + r2.setOutline(true); + assertTrue(r1.equals(r2)); + + r1.setShapesVisible(true); + assertFalse(r1.equals(r2)); + r2.setShapesVisible(true); + assertTrue(r1.equals(r2)); + + r1.setShapesFilled(true); + assertFalse(r1.equals(r2)); + r2.setShapesFilled(true); + assertTrue(r1.equals(r2)); + + r1.setPlotArea(false); + assertFalse(r1.equals(r2)); + r2.setPlotArea(false); + assertTrue(r1.equals(r2)); + + r1.setRangeBase(-1.0); + assertFalse(r1.equals(r2)); + r2.setRangeBase(-1.0); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYStepAreaRenderer r1 = new XYStepAreaRenderer(); + XYStepAreaRenderer r2 = new XYStepAreaRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYStepAreaRenderer r1 = new XYStepAreaRenderer(); + XYStepAreaRenderer r2 = (XYStepAreaRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYStepAreaRenderer r1 = new XYStepAreaRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYStepAreaRenderer r1 = new XYStepAreaRenderer(); + XYStepAreaRenderer r2 = (XYStepAreaRenderer) + TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (particularly by code in the renderer). + */ + @Test + public void testDrawWithNullInfo() { + try { + DefaultTableXYDataset dataset = new DefaultTableXYDataset(); + + XYSeries s1 = new XYSeries("Series 1", true, false); + s1.add(5.0, 5.0); + s1.add(10.0, 15.5); + s1.add(15.0, 9.5); + s1.add(20.0, 7.5); + dataset.addSeries(s1); + + XYSeries s2 = new XYSeries("Series 2", true, false); + s2.add(5.0, 5.0); + s2.add(10.0, 15.5); + s2.add(15.0, 9.5); + s2.add(20.0, 3.5); + dataset.addSeries(s2); + XYPlot plot = new XYPlot(dataset, + new NumberAxis("X"), new NumberAxis("Y"), + new XYStepAreaRenderer()); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYStepRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYStepRendererTest.java new file mode 100755 index 0000000..58cbe5c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/XYStepRendererTest.java @@ -0,0 +1,200 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * XYStepRendererTest.java + * ----------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 14-Feb-2008 : Added checks for new code (DG); + * 22-Apr-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.plot.XYPlot; +import org.jfree.data.xy.DefaultTableXYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYStepRenderer} class. + */ +public class XYStepRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + XYStepRenderer r1 = new XYStepRenderer(); + XYStepRenderer r2 = new XYStepRenderer(); + assertEquals(r1, r2); + + r1.setStepPoint(0.44); + assertFalse(r1.equals(r2)); + r2.setStepPoint(0.44); + assertTrue(r1.equals(r2)); + + // try something from the base class + r1.setBaseCreateEntities(false); + assertFalse(r1.equals(r2)); + r2.setBaseCreateEntities(false); + assertTrue(r1.equals(r2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYStepRenderer r1 = new XYStepRenderer(); + r1.setStepPoint(0.123); + XYStepRenderer r2 = new XYStepRenderer(); + r2.setStepPoint(0.123); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYStepRenderer r1 = new XYStepRenderer(); + XYStepRenderer r2 = (XYStepRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYStepRenderer r1 = new XYStepRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYStepRenderer r1 = new XYStepRenderer(); + r1.setStepPoint(0.123); + XYStepRenderer r2 = (XYStepRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * Draws the chart with a null info object to make sure that + * no exceptions are thrown (particularly by code in the renderer). + */ + @Test + public void testDrawWithNullInfo() { + try { + DefaultTableXYDataset dataset = new DefaultTableXYDataset(); + + XYSeries s1 = new XYSeries("Series 1", true, false); + s1.add(5.0, 5.0); + s1.add(10.0, 15.5); + s1.add(15.0, 9.5); + s1.add(20.0, 7.5); + dataset.addSeries(s1); + + XYSeries s2 = new XYSeries("Series 2", true, false); + s2.add(5.0, 5.0); + s2.add(10.0, 15.5); + s2.add(15.0, 9.5); + s2.add(20.0, 3.5); + dataset.addSeries(s2); + XYPlot plot = new XYPlot(dataset, + new NumberAxis("X"), new NumberAxis("Y"), + new XYStepRenderer()); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + + /** + * Draws the chart with a null value in the dataset to make + * sure that no exceptions are thrown. + */ + @Test + public void testDrawWithNullValue() { + try { + DefaultTableXYDataset dataset = new DefaultTableXYDataset(); + + XYSeries s1 = new XYSeries("Series 1", true, false); + s1.add(5.0, 5.0); + s1.add(10.0, null); + s1.add(15.0, 9.5); + s1.add(20.0, 7.5); + dataset.addSeries(s1); + + XYSeries s2 = new XYSeries("Series 2", true, false); + s2.add(5.0, 5.0); + s2.add(10.0, 15.5); + s2.add(15.0, null); + s2.add(20.0, null); + dataset.addSeries(s2); + XYPlot plot = new XYPlot(dataset, + new NumberAxis("X"), new NumberAxis("Y"), + new XYStepRenderer()); + JFreeChart chart = new JFreeChart(plot); + /* BufferedImage image = */ chart.createBufferedImage(300, 200, + null); + } + catch (NullPointerException e) { + fail("No exception should be thrown."); + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/YIntervalRendererTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/YIntervalRendererTest.java new file mode 100755 index 0000000..bb16121 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/renderer/xy/YIntervalRendererTest.java @@ -0,0 +1,263 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * YIntervalRendererTest.java + * -------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2003 : Version 1 (DG); + * 20-Feb-2007 : Extended the testEquals() checks (DG); + * 17-May-2007 : Added testGetLegendItemSeriesIndex() (DG); + * 22-Apr-2008 : Added testPublicCloneable() (DG); + * 26-May-2008 : Extended testEquals() (DG); + * + */ + +package org.jfree.chart.renderer.xy; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.LegendItem; +import org.jfree.chart.TestUtilities; +import org.jfree.chart.annotations.XYTextAnnotation; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.labels.IntervalXYItemLabelGenerator; +import org.jfree.chart.labels.StandardXYItemLabelGenerator; +import org.jfree.chart.labels.StandardXYSeriesLabelGenerator; +import org.jfree.chart.labels.StandardXYToolTipGenerator; +import org.jfree.chart.plot.XYPlot; +import org.jfree.chart.urls.StandardXYURLGenerator; +import org.jfree.data.xy.YIntervalSeries; +import org.jfree.data.xy.YIntervalSeriesCollection; +import org.jfree.ui.Layer; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link YIntervalRenderer} class. + */ +public class YIntervalRendererTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + YIntervalRenderer r1 = new YIntervalRenderer(); + YIntervalRenderer r2 = new YIntervalRenderer(); + assertEquals(r1, r2); + + // the following fields are inherited from the AbstractXYItemRenderer + r1.setItemLabelGenerator(new StandardXYItemLabelGenerator()); + assertFalse(r1.equals(r2)); + r2.setItemLabelGenerator(new StandardXYItemLabelGenerator()); + assertTrue(r1.equals(r2)); + + r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); + assertFalse(r1.equals(r2)); + r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); + assertTrue(r1.equals(r2)); + + r1.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); + assertFalse(r1.equals(r2)); + r2.setBaseItemLabelGenerator(new StandardXYItemLabelGenerator()); + assertTrue(r1.equals(r2)); + + r1.setToolTipGenerator(new StandardXYToolTipGenerator()); + assertFalse(r1.equals(r2)); + r2.setToolTipGenerator(new StandardXYToolTipGenerator()); + assertTrue(r1.equals(r2)); + + r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); + assertFalse(r1.equals(r2)); + r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); + assertTrue(r1.equals(r2)); + + r1.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); + assertFalse(r1.equals(r2)); + r2.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); + assertTrue(r1.equals(r2)); + + r1.setURLGenerator(new StandardXYURLGenerator()); + assertFalse(r1.equals(r2)); + r2.setURLGenerator(new StandardXYURLGenerator()); + assertTrue(r1.equals(r2)); + + r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND); + assertFalse(r1.equals(r2)); + r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.FOREGROUND); + assertTrue(r1.equals(r2)); + + r1.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND); + assertFalse(r1.equals(r2)); + r2.addAnnotation(new XYTextAnnotation("X", 1.0, 2.0), Layer.BACKGROUND); + assertTrue(r1.equals(r2)); + + r1.setDefaultEntityRadius(99); + assertFalse(r1.equals(r2)); + r2.setDefaultEntityRadius(99); + assertTrue(r1.equals(r2)); + + r1.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator( + "{0} {1}")); + assertFalse(r1.equals(r2)); + r2.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator( + "{0} {1}")); + assertTrue(r1.equals(r2)); + + r1.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator()); + assertFalse(r1.equals(r2)); + r2.setLegendItemToolTipGenerator(new StandardXYSeriesLabelGenerator()); + assertTrue(r1.equals(r2)); + + r1.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator()); + assertFalse(r1.equals(r2)); + r2.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator()); + assertTrue(r1.equals(r2)); + + r1.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator()); + assertFalse(r1.equals(r2)); + r2.setAdditionalItemLabelGenerator(new IntervalXYItemLabelGenerator()); + assertTrue(r1.equals(r2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + YIntervalRenderer r1 = new YIntervalRenderer(); + YIntervalRenderer r2 = new YIntervalRenderer(); + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + YIntervalRenderer r1 = new YIntervalRenderer(); + YIntervalRenderer r2 = (YIntervalRenderer) r1.clone(); + assertTrue(r1 != r2); + assertTrue(r1.getClass() == r2.getClass()); + assertTrue(r1.equals(r2)); + + // check independence + r1.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); + assertFalse(r1.equals(r2)); + r2.setSeriesItemLabelGenerator(0, new StandardXYItemLabelGenerator()); + assertTrue(r1.equals(r2)); + + r1.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); + assertFalse(r1.equals(r2)); + r2.setSeriesToolTipGenerator(0, new StandardXYToolTipGenerator()); + assertTrue(r1.equals(r2)); + + r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), + Layer.FOREGROUND); + assertFalse(r1.equals(r2)); + r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), + Layer.FOREGROUND); + assertTrue(r1.equals(r2)); + + r1.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), + Layer.BACKGROUND); + assertFalse(r1.equals(r2)); + r2.addAnnotation(new XYTextAnnotation("ABC", 1.0, 2.0), + Layer.BACKGROUND); + assertTrue(r1.equals(r2)); + + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + YIntervalRenderer r1 = new YIntervalRenderer(); + assertTrue(r1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + YIntervalRenderer r1 = new YIntervalRenderer(); + YIntervalRenderer r2 = (YIntervalRenderer) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * A check for the datasetIndex and seriesIndex fields in the LegendItem + * returned by the getLegendItem() method. + */ + @Test + public void testGetLegendItemSeriesIndex() { + YIntervalSeriesCollection d1 = new YIntervalSeriesCollection(); + YIntervalSeries s1 = new YIntervalSeries("S1"); + s1.add(1.0, 1.1, 1.2, 1.3); + YIntervalSeries s2 = new YIntervalSeries("S2"); + s2.add(1.0, 1.1, 1.2, 1.3); + d1.addSeries(s1); + d1.addSeries(s2); + + YIntervalSeriesCollection d2 = new YIntervalSeriesCollection(); + YIntervalSeries s3 = new YIntervalSeries("S3"); + s3.add(1.0, 1.1, 1.2, 1.3); + YIntervalSeries s4 = new YIntervalSeries("S4"); + s4.add(1.0, 1.1, 1.2, 1.3); + YIntervalSeries s5 = new YIntervalSeries("S5"); + s5.add(1.0, 1.1, 1.2, 1.3); + d2.addSeries(s3); + d2.addSeries(s4); + d2.addSeries(s5); + + YIntervalRenderer r = new YIntervalRenderer(); + XYPlot plot = new XYPlot(d1, new NumberAxis("x"), + new NumberAxis("y"), r); + plot.setDataset(1, d2); + /*JFreeChart chart =*/ new JFreeChart(plot); + LegendItem li = r.getLegendItem(1, 2); + assertEquals("S5", li.getLabel()); + assertEquals(1, li.getDatasetIndex()); + assertEquals(2, li.getSeriesIndex()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/CompositeTitleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/CompositeTitleTest.java new file mode 100755 index 0000000..9d267a5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/CompositeTitleTest.java @@ -0,0 +1,166 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * CompositeTitleTest.java + * ----------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Feb-2005 : Version 1 (DG); + * 09-Jul-2008 : Added new field into testEquals() (DG); + * + */ + +package org.jfree.chart.title; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.fail; +import static org.junit.Assert.assertNull; + +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.block.BlockBorder; +import org.jfree.chart.block.BlockContainer; +import org.jfree.ui.RectangleInsets; +import org.junit.Test; + +/** + * Tests for the {@link CompositeTitle} class. + */ +public class CompositeTitleTest { + + /** + * Some checks for the constructor. + */ + @Test + public void testConstructor() { + CompositeTitle t = new CompositeTitle(); + assertNull(t.getBackgroundPaint()); + } + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + CompositeTitle t1 = new CompositeTitle(new BlockContainer()); + CompositeTitle t2 = new CompositeTitle(new BlockContainer()); + assertEquals(t1, t2); + assertEquals(t2, t1); + + // margin + t1.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); + assertFalse(t1.equals(t2)); + t2.setMargin(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); + assertTrue(t1.equals(t2)); + + // border + t1.setBorder(new BlockBorder(Color.red)); + assertFalse(t1.equals(t2)); + t2.setBorder(new BlockBorder(Color.red)); + assertTrue(t1.equals(t2)); + + // padding + t1.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); + assertFalse(t1.equals(t2)); + t2.setPadding(new RectangleInsets(1.0, 2.0, 3.0, 4.0)); + assertTrue(t1.equals(t2)); + + // contained titles + t1.getContainer().add(new TextTitle("T1")); + assertFalse(t1.equals(t2)); + t2.getContainer().add(new TextTitle("T1")); + assertTrue(t1.equals(t2)); + + t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertFalse(t1.equals(t2)); + t2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + assertTrue(t1.equals(t2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + CompositeTitle t1 = new CompositeTitle(new BlockContainer()); + t1.getContainer().add(new TextTitle("T1")); + CompositeTitle t2 = new CompositeTitle(new BlockContainer()); + t2.getContainer().add(new TextTitle("T1")); + assertTrue(t1.equals(t2)); + int h1 = t1.hashCode(); + int h2 = t2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() { + CompositeTitle t1 = new CompositeTitle(new BlockContainer()); + t1.getContainer().add(new TextTitle("T1")); + t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.yellow)); + CompositeTitle t2 = null; + try { + t2 = (CompositeTitle) t1.clone(); + } + catch (CloneNotSupportedException e) { + fail(e.toString()); + } + assertTrue(t1 != t2); + assertTrue(t1.getClass() == t2.getClass()); + assertTrue(t1.equals(t2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CompositeTitle t1 = new CompositeTitle(new BlockContainer()); + t1.getContainer().add(new TextTitle("T1")); + t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + CompositeTitle t2 = (CompositeTitle) TestUtilities.serialised(t1); + assertEquals(t1, t2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/DateTitleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/DateTitleTest.java new file mode 100755 index 0000000..5d36342 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/DateTitleTest.java @@ -0,0 +1,125 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * DateTitleTest.java + * ------------------ + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 17-Feb-2004 : Version 1 (DG); + * + */ + +package org.jfree.chart.title; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; +import java.awt.Font; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link DateTitle} class. + */ +public class DateTitleTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + DateTitle t1 = new DateTitle(); + DateTitle t2 = new DateTitle(); + assertEquals(t1, t2); + + t1.setText("Test 1"); + assertFalse(t1.equals(t2)); + t2.setText("Test 1"); + assertTrue(t1.equals(t2)); + + Font f = new Font("SansSerif", Font.PLAIN, 15); + t1.setFont(f); + assertFalse(t1.equals(t2)); + t2.setFont(f); + assertTrue(t1.equals(t2)); + + t1.setPaint(Color.blue); + assertFalse(t1.equals(t2)); + t2.setPaint(Color.blue); + assertTrue(t1.equals(t2)); + + t1.setBackgroundPaint(Color.blue); + assertFalse(t1.equals(t2)); + t2.setBackgroundPaint(Color.blue); + assertTrue(t1.equals(t2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + DateTitle t1 = new DateTitle(); + DateTitle t2 = new DateTitle(); + assertTrue(t1.equals(t2)); + int h1 = t1.hashCode(); + int h2 = t2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DateTitle t1 = new DateTitle(); + DateTitle t2 = (DateTitle) t1.clone(); + assertTrue(t1 != t2); + assertTrue(t1.getClass() == t2.getClass()); + assertTrue(t1.equals(t2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DateTitle t1 = new DateTitle(); + DateTitle t2 = (DateTitle) TestUtilities.serialised(t1); + assertEquals(t1, t2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/ImageTitleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/ImageTitleTest.java new file mode 100755 index 0000000..19e518d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/ImageTitleTest.java @@ -0,0 +1,145 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * ImageTitleTest.java + * ------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 17-Feb-2004 : Version 1 (DG); + * 21-Mar-2008 : Added tests for arrange method (DG); + * + */ + +package org.jfree.chart.title; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Graphics2D; +import java.awt.image.BufferedImage; + +import org.jfree.chart.JFreeChart; +import org.jfree.ui.Size2D; +import org.junit.Test; + +/** + * Tests for the {@link ImageTitle} class. + */ +public class ImageTitleTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); + ImageTitle t2 = new ImageTitle(JFreeChart.INFO.getLogo()); + assertEquals(t1, t2); + + t1.setImage(new BufferedImage(2, 1, BufferedImage.TYPE_INT_RGB)); + assertFalse(t1.equals(t2)); + t2.setImage(new BufferedImage(2, 1, BufferedImage.TYPE_INT_RGB)); + // images considered equal only if they're the SAME object + // TODO: is there a way to do a better test? + assertFalse(t1.equals(t2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); + ImageTitle t2 = new ImageTitle(JFreeChart.INFO.getLogo()); + assertTrue(t1.equals(t2)); + int h1 = t1.hashCode(); + int h2 = t2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); + ImageTitle t2 = (ImageTitle) t1.clone(); + assertTrue(t1 != t2); + assertTrue(t1.getClass() == t2.getClass()); + assertTrue(t1.equals(t2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + public void testSerialization() { + // TODO: add serialization support for images + } + + private static final double EPSILON = 0.00000001; + + /** + * Check the width and height. + */ + @Test + public void testWidthAndHeight() { + ImageTitle t1 = new ImageTitle(JFreeChart.INFO.getLogo()); + assertEquals(100, t1.getWidth(), EPSILON); + assertEquals(100, t1.getHeight(), EPSILON); + } + + /** + * Some checks for the arrange method. + */ + @Test + public void testArrangeNN() { + BufferedImage image = new BufferedImage(100, 100, + BufferedImage.TYPE_INT_RGB); + Graphics2D g2 = image.createGraphics(); + ImageTitle t = new ImageTitle(JFreeChart.INFO.getLogo()); + Size2D s = t.arrange(g2); + assertEquals(102.0, s.getWidth(), EPSILON); + assertEquals(102.0, s.getHeight(), EPSILON); + + t.setPadding(1.0, 2.0, 3.0, 4.0); + s = t.arrange(g2); + assertEquals(106.0, s.getWidth(), EPSILON); + assertEquals(104.0, s.getHeight(), EPSILON); + + t.setMargin(5.0, 6.0, 7.0, 8.0); + s = t.arrange(g2); + assertEquals(120.0, s.getWidth(), EPSILON); + assertEquals(116.0, s.getHeight(), EPSILON); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/LegendGraphicTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/LegendGraphicTest.java new file mode 100755 index 0000000..235154f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/LegendGraphicTest.java @@ -0,0 +1,231 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * LegendGraphicTest.java + * ---------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 01-Sep-2005 : Version 1 (DG); + * + */ + +package org.jfree.chart.title; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.Rectangle; +import java.awt.Stroke; +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; + +import org.jfree.ui.GradientPaintTransformType; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.StandardGradientPaintTransformer; +import org.junit.Test; + +/** + * Tests for the {@link LegendGraphic} class. + */ +public class LegendGraphicTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + LegendGraphic g1 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, + 3.0, 4.0), Color.black); + LegendGraphic g2 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, + 3.0, 4.0), Color.black); + assertEquals(g1, g2); + assertEquals(g2, g1); + + // shapeVisible + g1.setShapeVisible(!g1.isShapeVisible()); + assertFalse(g1.equals(g2)); + g2.setShapeVisible(!g2.isShapeVisible()); + assertTrue(g1.equals(g2)); + + // shape + g1.setShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertFalse(g1.equals(g2)); + g2.setShape(new Rectangle2D.Double(4.0, 3.0, 2.0, 1.0)); + assertTrue(g1.equals(g2)); + + // shapeFilled + g1.setShapeFilled(!g1.isShapeFilled()); + assertFalse(g1.equals(g2)); + g2.setShapeFilled(!g2.isShapeFilled()); + assertTrue(g1.equals(g2)); + + // fillPaint + g1.setFillPaint(Color.green); + assertFalse(g1.equals(g2)); + g2.setFillPaint(Color.green); + assertTrue(g1.equals(g2)); + + // shapeOutlineVisible + g1.setShapeOutlineVisible(!g1.isShapeOutlineVisible()); + assertFalse(g1.equals(g2)); + g2.setShapeOutlineVisible(!g2.isShapeOutlineVisible()); + assertTrue(g1.equals(g2)); + + // outlinePaint + g1.setOutlinePaint(Color.green); + assertFalse(g1.equals(g2)); + g2.setOutlinePaint(Color.green); + assertTrue(g1.equals(g2)); + + // outlineStroke + g1.setOutlineStroke(new BasicStroke(1.23f)); + assertFalse(g1.equals(g2)); + g2.setOutlineStroke(new BasicStroke(1.23f)); + assertTrue(g1.equals(g2)); + + // shapeAnchor + g1.setShapeAnchor(RectangleAnchor.BOTTOM_RIGHT); + assertFalse(g1.equals(g2)); + g2.setShapeAnchor(RectangleAnchor.BOTTOM_RIGHT); + assertTrue(g1.equals(g2)); + + // shapeLocation + g1.setShapeLocation(RectangleAnchor.BOTTOM_RIGHT); + assertFalse(g1.equals(g2)); + g2.setShapeLocation(RectangleAnchor.BOTTOM_RIGHT); + assertTrue(g1.equals(g2)); + + // lineVisible + g1.setLineVisible(!g1.isLineVisible()); + assertFalse(g1.equals(g2)); + g2.setLineVisible(!g2.isLineVisible()); + assertTrue(g1.equals(g2)); + + // line + g1.setLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); + assertFalse(g1.equals(g2)); + g2.setLine(new Line2D.Double(1.0, 2.0, 3.0, 4.0)); + assertTrue(g1.equals(g2)); + + // linePaint + g1.setLinePaint(Color.green); + assertFalse(g1.equals(g2)); + g2.setLinePaint(Color.green); + assertTrue(g1.equals(g2)); + + // lineStroke + g1.setLineStroke(new BasicStroke(1.23f)); + assertFalse(g1.equals(g2)); + g2.setLineStroke(new BasicStroke(1.23f)); + assertTrue(g1.equals(g2)); + + // fillPaintTransformer + g1.setFillPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_HORIZONTAL)); + assertFalse(g1.equals(g2)); + g2.setFillPaintTransformer(new StandardGradientPaintTransformer( + GradientPaintTransformType.CENTER_HORIZONTAL)); + assertTrue(g1.equals(g2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + LegendGraphic g1 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, + 3.0, 4.0), Color.black); + LegendGraphic g2 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, + 3.0, 4.0), Color.black); + assertTrue(g1.equals(g2)); + int h1 = g1.hashCode(); + int h2 = g2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + Rectangle r = new Rectangle(1, 2, 3, 4); + LegendGraphic g1 = new LegendGraphic(r, Color.black); + LegendGraphic g2 = (LegendGraphic) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + + // check independence + r.setBounds(4, 3, 2, 1); + assertFalse(g1.equals(g2)); + } + + /** + * A test for cloning - checks that the line shape is cloned correctly. + */ + @Test + public void testCloning2() throws CloneNotSupportedException { + Rectangle r = new Rectangle(1, 2, 3, 4); + LegendGraphic g1 = new LegendGraphic(r, Color.black); + Line2D l = new Line2D.Double(1.0, 2.0, 3.0, 4.0); + g1.setLine(l); + LegendGraphic g2 = (LegendGraphic) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + + // check independence + l.setLine(4.0, 3.0, 2.0, 1.0); + assertFalse(g1.equals(g2)); + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Stroke s = new BasicStroke(1.23f); + LegendGraphic g1 = new LegendGraphic(new Rectangle2D.Double(1.0, 2.0, + 3.0, 4.0), Color.black); + g1.setOutlineStroke(s); + LegendGraphic g2 = (LegendGraphic) TestUtilities.serialised(g1); + assertTrue(g1.equals(g2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/LegendTitleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/LegendTitleTest.java new file mode 100755 index 0000000..b8bb90e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/LegendTitleTest.java @@ -0,0 +1,159 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * LegendTitleTest.java + * -------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Feb-2005 : Version 1 (DG); + * 16-Mar-2005 : Extended testEquals() (DG); + * 11-Mar-2012 : Extended testEquals() (MH); + */ + +package org.jfree.chart.title; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; +import java.awt.geom.Rectangle2D; + +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.plot.XYPlot; +import org.jfree.ui.RectangleAnchor; +import org.jfree.ui.RectangleEdge; +import org.jfree.util.SortOrder; +import org.junit.Test; + +/** + * Some tests for the {@link LegendTitle} class. + */ +public class LegendTitleTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + XYPlot plot1 = new XYPlot(); + LegendTitle t1 = new LegendTitle(plot1); + LegendTitle t2 = new LegendTitle(plot1); + assertEquals(t1, t2); + + t1.setBackgroundPaint( + new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow) + ); + assertFalse(t1.equals(t2)); + t2.setBackgroundPaint( + new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, 4.0f, Color.yellow) + ); + assertTrue(t1.equals(t2)); + + t1.setLegendItemGraphicEdge(RectangleEdge.BOTTOM); + assertFalse(t1.equals(t2)); + t2.setLegendItemGraphicEdge(RectangleEdge.BOTTOM); + assertTrue(t1.equals(t2)); + + t1.setLegendItemGraphicAnchor(RectangleAnchor.BOTTOM_LEFT); + assertFalse(t1.equals(t2)); + t2.setLegendItemGraphicAnchor(RectangleAnchor.BOTTOM_LEFT); + assertTrue(t1.equals(t2)); + + t1.setLegendItemGraphicLocation(RectangleAnchor.TOP_LEFT); + assertFalse(t1.equals(t2)); + t2.setLegendItemGraphicLocation(RectangleAnchor.TOP_LEFT); + assertTrue(t1.equals(t2)); + + t1.setItemFont(new Font("Dialog", Font.PLAIN, 19)); + assertFalse(t1.equals(t2)); + t2.setItemFont(new Font("Dialog", Font.PLAIN, 19)); + assertTrue(t1.equals(t2)); + + t1.setSortOrder(SortOrder.DESCENDING); + assertFalse(t1.equals(t2)); + t2.setSortOrder(SortOrder.DESCENDING); + assertTrue(t1.equals(t2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYPlot plot1 = new XYPlot(); + LegendTitle t1 = new LegendTitle(plot1); + LegendTitle t2 = new LegendTitle(plot1); + assertTrue(t1.equals(t2)); + int h1 = t1.hashCode(); + int h2 = t2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYPlot plot = new XYPlot(); + Rectangle2D bounds1 = new Rectangle2D.Double(10.0, 20.0, 30.0, 40.0); + LegendTitle t1 = new LegendTitle(plot); + t1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, 3.0f, + 4.0f, Color.yellow)); + t1.setBounds(bounds1); + LegendTitle t2 = (LegendTitle) t1.clone(); + assertTrue(t1 != t2); + assertTrue(t1.getClass() == t2.getClass()); + assertTrue(t1.equals(t2)); + + // check independence + bounds1.setFrame(40.0, 30.0, 20.0, 10.0); + assertFalse(t1.equals(t2)); + t2.setBounds(new Rectangle2D.Double(40.0, 30.0, 20.0, 10.0)); + assertTrue(t1.equals(t2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYPlot plot = new XYPlot(); + LegendTitle t1 = new LegendTitle(plot); + LegendTitle t2 = (LegendTitle) TestUtilities.serialised(t1); + assertTrue(t1.equals(t2)); + assertTrue(t2.getSources()[0].equals(plot)); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/PaintScaleLegendTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/PaintScaleLegendTest.java new file mode 100755 index 0000000..45453d5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/PaintScaleLegendTest.java @@ -0,0 +1,183 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * PaintScaleLegendTest.java + * ------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 22-Jan-2007 : Version 1 (DG); + * 18-Jun-2008 : Extended testEquals() for new field (DG); + * + */ + +package org.jfree.chart.title; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.BasicStroke; +import java.awt.Color; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.chart.axis.AxisLocation; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.renderer.GrayPaintScale; +import org.jfree.chart.renderer.LookupPaintScale; +import org.junit.Test; + +/** + * Tests for the {@link PaintScaleLegend} class. + */ +public class PaintScaleLegendTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + + // default instances + PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(), + new NumberAxis("X")); + PaintScaleLegend l2 = new PaintScaleLegend(new GrayPaintScale(), + new NumberAxis("X")); + assertTrue(l1.equals(l2)); + assertTrue(l2.equals(l1)); + + // paintScale + l1.setScale(new LookupPaintScale()); + assertFalse(l1.equals(l2)); + l2.setScale(new LookupPaintScale()); + assertTrue(l1.equals(l2)); + + // axis + l1.setAxis(new NumberAxis("Axis 2")); + assertFalse(l1.equals(l2)); + l2.setAxis(new NumberAxis("Axis 2")); + assertTrue(l1.equals(l2)); + + // axisLocation + l1.setAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); + assertFalse(l1.equals(l2)); + l2.setAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); + assertTrue(l1.equals(l2)); + + // axisOffset + l1.setAxisOffset(99.0); + assertFalse(l1.equals(l2)); + l2.setAxisOffset(99.0); + assertTrue(l1.equals(l2)); + + // stripWidth + l1.setStripWidth(99.0); + assertFalse(l1.equals(l2)); + l2.setStripWidth(99.0); + assertTrue(l1.equals(l2)); + + // stripOutlineVisible + l1.setStripOutlineVisible(!l1.isStripOutlineVisible()); + assertFalse(l1.equals(l2)); + l2.setStripOutlineVisible(l1.isStripOutlineVisible()); + assertTrue(l1.equals(l2)); + + // stripOutlinePaint + l1.setStripOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertFalse(l1.equals(l2)); + l2.setStripOutlinePaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertTrue(l1.equals(l2)); + + // stripOutlineStroke + l1.setStripOutlineStroke(new BasicStroke(1.1f)); + assertFalse(l1.equals(l2)); + l2.setStripOutlineStroke(new BasicStroke(1.1f)); + assertTrue(l1.equals(l2)); + + // backgroundPaint + l1.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertFalse(l1.equals(l2)); + l2.setBackgroundPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertTrue(l1.equals(l2)); + + l1.setSubdivisionCount(99); + assertFalse(l1.equals(l2)); + l2.setSubdivisionCount(99); + assertTrue(l1.equals(l2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(), + new NumberAxis("X")); + PaintScaleLegend l2 = new PaintScaleLegend(new GrayPaintScale(), + new NumberAxis("X")); + assertTrue(l1.equals(l2)); + int h1 = l1.hashCode(); + int h2 = l2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(), + new NumberAxis("X")); + PaintScaleLegend l2 = (PaintScaleLegend) l1.clone(); + assertTrue(l1 != l2); + assertTrue(l1.getClass() == l2.getClass()); + assertTrue(l1.equals(l2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PaintScaleLegend l1 = new PaintScaleLegend(new GrayPaintScale(), + new NumberAxis("X")); + PaintScaleLegend l2 = (PaintScaleLegend) TestUtilities.serialised(l1); + assertEquals(l1, l2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/ShortTextTitleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/ShortTextTitleTest.java new file mode 100755 index 0000000..c895b22 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/ShortTextTitleTest.java @@ -0,0 +1,105 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * ShortTextTitleTest.java + * ----------------------- + * (C) Copyright 2008-2013, 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.chart.title; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link ShortTextTitle} class. + */ +public class ShortTextTitleTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + ShortTextTitle t1 = new ShortTextTitle("ABC"); + ShortTextTitle t2 = new ShortTextTitle("ABC"); + assertEquals(t1, t2); + + t1.setText("Test 1"); + assertFalse(t1.equals(t2)); + t2.setText("Test 1"); + assertTrue(t1.equals(t2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + ShortTextTitle t1 = new ShortTextTitle("ABC"); + ShortTextTitle t2 = new ShortTextTitle("ABC"); + assertTrue(t1.equals(t2)); + int h1 = t1.hashCode(); + int h2 = t2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ShortTextTitle t1 = new ShortTextTitle("ABC"); + ShortTextTitle t2 = (ShortTextTitle) t1.clone(); + assertTrue(t1 != t2); + assertTrue(t1.getClass() == t2.getClass()); + assertTrue(t1.equals(t2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ShortTextTitle t1 = new ShortTextTitle("ABC"); + ShortTextTitle t2 = (ShortTextTitle) TestUtilities.serialised(t1); + assertEquals(t1, t2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/TextTitleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/TextTitleTest.java new file mode 100755 index 0000000..4f38a97 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/TextTitleTest.java @@ -0,0 +1,166 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * TextTitleTest.java + * ------------------ + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 17-Feb-2004 : Version 1 (DG); + * 06-Jun-2005 : Use GradientPaint in equals() test (DG); + * 07-Oct-2005 : Updated testEquals() (DG); + * 28-Apr-2008 : Extended testEquals() (DG); + * + */ + +package org.jfree.chart.title; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.awt.Color; +import java.awt.Font; +import java.awt.GradientPaint; + +import org.jfree.chart.TestUtilities; + +import org.jfree.ui.HorizontalAlignment; +import org.junit.Test; + +/** + * Tests for the {@link TextTitle} class. + */ +public class TextTitleTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + TextTitle t1 = new TextTitle(); + TextTitle t2 = new TextTitle(); + assertEquals(t1, t2); + + t1.setText("Test 1"); + assertFalse(t1.equals(t2)); + t2.setText("Test 1"); + assertTrue(t1.equals(t2)); + + Font f = new Font("SansSerif", Font.PLAIN, 15); + t1.setFont(f); + assertFalse(t1.equals(t2)); + t2.setFont(f); + assertTrue(t1.equals(t2)); + + t1.setTextAlignment(HorizontalAlignment.RIGHT); + assertFalse(t1.equals(t2)); + t2.setTextAlignment(HorizontalAlignment.RIGHT); + assertTrue(t1.equals(t2)); + + // paint + t1.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertFalse(t1.equals(t2)); + t2.setPaint(new GradientPaint(1.0f, 2.0f, Color.red, + 3.0f, 4.0f, Color.blue)); + assertTrue(t1.equals(t2)); + + // backgroundPaint + t1.setBackgroundPaint(new GradientPaint(4.0f, 3.0f, Color.red, + 2.0f, 1.0f, Color.blue)); + assertFalse(t1.equals(t2)); + t2.setBackgroundPaint(new GradientPaint(4.0f, 3.0f, Color.red, + 2.0f, 1.0f, Color.blue)); + assertTrue(t1.equals(t2)); + + // maximumLinesToDisplay + t1.setMaximumLinesToDisplay(3); + assertFalse(t1.equals(t2)); + t2.setMaximumLinesToDisplay(3); + assertTrue(t1.equals(t2)); + + // toolTipText + t1.setToolTipText("TTT"); + assertFalse(t1.equals(t2)); + t2.setToolTipText("TTT"); + assertTrue(t1.equals(t2)); + + // urlText + t1.setURLText(("URL")); + assertFalse(t1.equals(t2)); + t2.setURLText(("URL")); + assertTrue(t1.equals(t2)); + + // expandToFitSpace + t1.setExpandToFitSpace(!t1.getExpandToFitSpace()); + assertFalse(t1.equals(t2)); + t2.setExpandToFitSpace(!t2.getExpandToFitSpace()); + assertTrue(t1.equals(t2)); + + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + TextTitle t1 = new TextTitle(); + TextTitle t2 = new TextTitle(); + assertTrue(t1.equals(t2)); + int h1 = t1.hashCode(); + int h2 = t2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + TextTitle t1 = new TextTitle(); + TextTitle t2 = (TextTitle) t1.clone(); + assertTrue(t1 != t2); + assertTrue(t1.getClass() == t2.getClass()); + assertTrue(t1.equals(t2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TextTitle t1 = new TextTitle("Test"); + TextTitle t2 = (TextTitle) TestUtilities.serialised(t1); + assertEquals(t1, t2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/TitleTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/TitleTest.java new file mode 100755 index 0000000..c1bd8ff --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/title/TitleTest.java @@ -0,0 +1,102 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * TitleTest.java + * -------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 17-Feb-2004 : Version 1 (DG); + * 18-Sep-2008 : Updated testEquals() (DG); + * + */ + +package org.jfree.chart.title; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import org.jfree.ui.HorizontalAlignment; +import org.jfree.ui.RectangleEdge; +import org.jfree.ui.VerticalAlignment; +import org.junit.Test; + +/** + * Tests for the abstract {@link Title} class. + */ +public class TitleTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + // use the TextTitle class because it is a concrete subclass + Title t1 = new TextTitle(); + Title t2 = new TextTitle(); + assertEquals(t1, t2); + + t1.setPosition(RectangleEdge.LEFT); + assertFalse(t1.equals(t2)); + t2.setPosition(RectangleEdge.LEFT); + assertTrue(t1.equals(t2)); + + t1.setHorizontalAlignment(HorizontalAlignment.RIGHT); + assertFalse(t1.equals(t2)); + t2.setHorizontalAlignment(HorizontalAlignment.RIGHT); + assertTrue(t1.equals(t2)); + + t1.setVerticalAlignment(VerticalAlignment.BOTTOM); + assertFalse(t1.equals(t2)); + t2.setVerticalAlignment(VerticalAlignment.BOTTOM); + assertTrue(t1.equals(t2)); + + t1.setVisible(false); + assertFalse(t1.equals(t2)); + t2.setVisible(false); + assertTrue(t1.equals(t2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + TextTitle t1 = new TextTitle(); + TextTitle t2 = new TextTitle(); + assertTrue(t1.equals(t2)); + int h1 = t1.hashCode(); + int h2 = t2.hashCode(); + assertEquals(h1, h2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/CustomCategoryURLGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/CustomCategoryURLGeneratorTest.java new file mode 100755 index 0000000..ab9dc58 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/CustomCategoryURLGeneratorTest.java @@ -0,0 +1,165 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------- + * CustomCategoryURLGeneratorTest.java + * ----------------------------------- + * (C) Copyright 2008-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Apr-2008 : Version 1, based on CustomXYURLGeneratorTests.java (DG); + * + */ + +package org.jfree.chart.urls; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.util.List; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link CustomCategoryURLGenerator} class. + */ +public class CustomCategoryURLGeneratorTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator(); + CustomCategoryURLGenerator g2 = new CustomCategoryURLGenerator(); + assertTrue(g1.equals(g2)); + List u1 = new java.util.ArrayList(); + u1.add("URL A1"); + u1.add("URL A2"); + u1.add("URL A3"); + g1.addURLSeries(u1); + assertFalse(g1.equals(g2)); + List u2 = new java.util.ArrayList(); + u2.add("URL A1"); + u2.add("URL A2"); + u2.add("URL A3"); + g2.addURLSeries(u2); + assertTrue(g1.equals(g2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator(); + List u1 = new java.util.ArrayList(); + u1.add("URL A1"); + u1.add("URL A2"); + u1.add("URL A3"); + g1.addURLSeries(u1); + CustomCategoryURLGenerator g2 = (CustomCategoryURLGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + + // check independence + List u2 = new java.util.ArrayList(); + u2.add("URL XXX"); + g1.addURLSeries(u2); + assertFalse(g1.equals(g2)); + g2.addURLSeries(new java.util.ArrayList(u2)); + assertTrue(g1.equals(g2)); + } + + /** + * Checks that the class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + + List u1 = new java.util.ArrayList(); + u1.add("URL A1"); + u1.add("URL A2"); + u1.add("URL A3"); + + List u2 = new java.util.ArrayList(); + u2.add("URL B1"); + u2.add("URL B2"); + u2.add("URL B3"); + + CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator(); + g1.addURLSeries(u1); + g1.addURLSeries(u2); + CustomCategoryURLGenerator g2 = (CustomCategoryURLGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + + /** + * Some checks for the addURLSeries() method. + */ + @Test + public void testAddURLSeries() { + CustomCategoryURLGenerator g1 = new CustomCategoryURLGenerator(); + // you can add a null list - it would have been better if this + // required EMPTY_LIST + g1.addURLSeries(null); + assertEquals(1, g1.getListCount()); + assertEquals(0, g1.getURLCount(0)); + + List list1 = new java.util.ArrayList(); + list1.add("URL1"); + g1.addURLSeries(list1); + assertEquals(2, g1.getListCount()); + assertEquals(0, g1.getURLCount(0)); + assertEquals(1, g1.getURLCount(1)); + assertEquals("URL1", g1.getURL(1, 0)); + + // if we modify the original list, it's best if the URL generator is + // not affected + list1.clear(); + assertEquals("URL1", g1.getURL(1, 0)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/CustomPieURLGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/CustomPieURLGeneratorTest.java new file mode 100755 index 0000000..a076cb9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/CustomPieURLGeneratorTest.java @@ -0,0 +1,122 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * CustomPieURLGeneratorTest.java + * ------------------------------ + * (C) Copyright 2008-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-Apr-2008 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.urls; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.util.HashMap; +import java.util.Map; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link CustomPieURLGenerator} class. + */ +public class CustomPieURLGeneratorTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + CustomPieURLGenerator g1 = new CustomPieURLGenerator(); + CustomPieURLGenerator g2 = new CustomPieURLGenerator(); + assertTrue(g1.equals(g2)); + + Map m1 = new HashMap(); + m1.put("A", "http://www.jfree.org/"); + g1.addURLs(m1); + assertFalse(g1.equals(g2)); + g2.addURLs(m1); + assertTrue(g1.equals(g2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CustomPieURLGenerator g1 = new CustomPieURLGenerator(); + Map m1 = new HashMap(); + m1.put("A", "http://www.jfree.org/"); + g1.addURLs(m1); + CustomPieURLGenerator g2 = (CustomPieURLGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + + // check independence + Map m2 = new HashMap(); + m2.put("B", "XYZ"); + g1.addURLs(m2); + assertFalse(g1.equals(g2)); + } + + /** + * Checks that the class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + CustomPieURLGenerator g1 = new CustomPieURLGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CustomPieURLGenerator g1 = new CustomPieURLGenerator(); + Map m1 = new HashMap(); + m1.put("A", "http://www.jfree.org/"); + g1.addURLs(m1); + CustomPieURLGenerator g2 = (CustomPieURLGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/CustomXYURLGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/CustomXYURLGeneratorTest.java new file mode 100755 index 0000000..1dce8ff --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/CustomXYURLGeneratorTest.java @@ -0,0 +1,167 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * CustomXYURLGeneratorTest.java + * ----------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Mar-2003 : Version 1 (DG); + * 11-Apr-2008 : Added testCloning() and testEquals() (DG); + * 21-Apr-2008 : Enhanced testCloning() (DG); + * 23-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.urls; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.util.List; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link CustomXYURLGenerator} class. + */ +public class CustomXYURLGeneratorTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + CustomXYURLGenerator g1 = new CustomXYURLGenerator(); + CustomXYURLGenerator g2 = new CustomXYURLGenerator(); + assertTrue(g1.equals(g2)); + List u1 = new java.util.ArrayList(); + u1.add("URL A1"); + u1.add("URL A2"); + u1.add("URL A3"); + g1.addURLSeries(u1); + assertFalse(g1.equals(g2)); + List u2 = new java.util.ArrayList(); + u2.add("URL A1"); + u2.add("URL A2"); + u2.add("URL A3"); + g2.addURLSeries(u2); + assertTrue(g1.equals(g2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CustomXYURLGenerator g1 = new CustomXYURLGenerator(); + List u1 = new java.util.ArrayList(); + u1.add("URL A1"); + u1.add("URL A2"); + u1.add("URL A3"); + g1.addURLSeries(u1); + CustomXYURLGenerator g2 = (CustomXYURLGenerator) g1.clone(); + assertTrue(g1 != g2); + assertTrue(g1.getClass() == g2.getClass()); + assertTrue(g1.equals(g2)); + + // check independence + List u2 = new java.util.ArrayList(); + u2.add("URL XXX"); + g1.addURLSeries(u2); + assertFalse(g1.equals(g2)); + g2.addURLSeries(new java.util.ArrayList(u2)); + assertTrue(g1.equals(g2)); + } + + /** + * Checks that the class implements PublicCloneable. + */ + @Test + public void testPublicCloneable() { + CustomXYURLGenerator g1 = new CustomXYURLGenerator(); + assertTrue(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + List u1 = new java.util.ArrayList(); + u1.add("URL A1"); + u1.add("URL A2"); + u1.add("URL A3"); + + List u2 = new java.util.ArrayList(); + u2.add("URL B1"); + u2.add("URL B2"); + u2.add("URL B3"); + + CustomXYURLGenerator g1 = new CustomXYURLGenerator(); + g1.addURLSeries(u1); + g1.addURLSeries(u2); + CustomXYURLGenerator g2 = (CustomXYURLGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + + /** + * Some checks for the addURLSeries() method. + */ + @Test + public void testAddURLSeries() { + CustomXYURLGenerator g1 = new CustomXYURLGenerator(); + // you can add a null list - it would have been better if this + // required EMPTY_LIST + g1.addURLSeries(null); + assertEquals(1, g1.getListCount()); + assertEquals(0, g1.getURLCount(0)); + + List list1 = new java.util.ArrayList(); + list1.add("URL1"); + g1.addURLSeries(list1); + assertEquals(2, g1.getListCount()); + assertEquals(0, g1.getURLCount(0)); + assertEquals(1, g1.getURLCount(1)); + assertEquals("URL1", g1.getURL(1, 0)); + + // if we modify the original list, it's best if the URL generator is + // not affected + list1.clear(); + assertEquals("URL1", g1.getURL(1, 0)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/StandardCategoryURLGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/StandardCategoryURLGeneratorTest.java new file mode 100755 index 0000000..203ad8b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/StandardCategoryURLGeneratorTest.java @@ -0,0 +1,127 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------- + * StandardCategoryURLGeneratorTest.java + * ------------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Aug-2003 : Version 1 (DG); + * 13-Dec-2007 : Added testGenerateURL() and testEquals() (DG); + * 23-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.urls; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StandardCategoryURLGenerator} class. + */ +public class StandardCategoryURLGeneratorTest { + + /** + * Some tests for the generateURL() method. + */ + @Test + public void testGenerateURL() { + StandardCategoryURLGenerator g1 = new StandardCategoryURLGenerator(); + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(1.0, "R1", "C1"); + dataset.addValue(2.0, "R2", "C2"); + dataset.addValue(3.0, "R&", "C&"); + assertEquals("index.html?series=R1&category=C1", + g1.generateURL(dataset, 0, 0)); + assertEquals("index.html?series=R1&category=C2", + g1.generateURL(dataset, 0, 1)); + assertEquals("index.html?series=R2&category=C2", + g1.generateURL(dataset, 1, 1)); + assertEquals("index.html?series=R%26&category=C%26", + g1.generateURL(dataset, 2, 2)); + } + + /** + * Checks that the class does not implement PublicCloneable (the generator + * is immutable, so cloning is not necessary). + */ + @Test + public void testPublicCloneable() { + StandardCategoryURLGenerator g1 = new StandardCategoryURLGenerator(); + assertFalse(g1 instanceof PublicCloneable); + } + + /** + * Some tests for the equals() method. + */ + @Test + public void testEquals() { + StandardCategoryURLGenerator g1 = new StandardCategoryURLGenerator(); + StandardCategoryURLGenerator g2 = new StandardCategoryURLGenerator(); + assertTrue(g1.equals(g2)); + + g1 = new StandardCategoryURLGenerator("index2.html?"); + assertFalse(g1.equals(g2)); + g2 = new StandardCategoryURLGenerator("index2.html?"); + assertTrue(g1.equals(g2)); + + g1 = new StandardCategoryURLGenerator("index2.html?", "A", "B"); + assertFalse(g1.equals(g2)); + g2 = new StandardCategoryURLGenerator("index2.html?", "A", "B"); + assertTrue(g1.equals(g2)); + + g1 = new StandardCategoryURLGenerator("index2.html?", "A", "C"); + assertFalse(g1.equals(g2)); + g2 = new StandardCategoryURLGenerator("index2.html?", "A", "C"); + assertTrue(g1.equals(g2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardCategoryURLGenerator g1 = new StandardCategoryURLGenerator( + "index.html?"); + StandardCategoryURLGenerator g2 = (StandardCategoryURLGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/StandardPieURLGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/StandardPieURLGeneratorTest.java new file mode 100755 index 0000000..d58bdd9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/StandardPieURLGeneratorTest.java @@ -0,0 +1,136 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------- + * StandardPieURLGeneratorTest.java + * -------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Mar-2003 : Version 1 (DG); + * 06-Jan-2003 : Added a test for URL generation (DG); + * 24-Nov-2006 : New equals() test (DG); + * 17-Apr-2007 : Added additional check to testURL() (DG); + * 23-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.urls; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.DefaultPieDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StandardPieURLGenerator} class. + */ +public class StandardPieURLGeneratorTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + StandardPieURLGenerator g1 = new StandardPieURLGenerator(); + StandardPieURLGenerator g2 = new StandardPieURLGenerator(); + assertTrue(g1.equals(g2)); + + g1 = new StandardPieURLGenerator("prefix", "category", "index"); + assertFalse(g1.equals(g2)); + g2 = new StandardPieURLGenerator("prefix", "category", "index"); + assertTrue(g1.equals(g2)); + + g1 = new StandardPieURLGenerator("prefix2", "category", "index"); + assertFalse(g1.equals(g2)); + g2 = new StandardPieURLGenerator("prefix2", "category", "index"); + assertTrue(g1.equals(g2)); + + g1 = new StandardPieURLGenerator("prefix2", "category2", "index"); + assertFalse(g1.equals(g2)); + g2 = new StandardPieURLGenerator("prefix2", "category2", "index"); + assertTrue(g1.equals(g2)); + + g1 = new StandardPieURLGenerator("prefix2", "category2", "index2"); + assertFalse(g1.equals(g2)); + g2 = new StandardPieURLGenerator("prefix2", "category2", "index2"); + assertTrue(g1.equals(g2)); + + g1 = new StandardPieURLGenerator("prefix2", "category2", null); + assertFalse(g1.equals(g2)); + g2 = new StandardPieURLGenerator("prefix2", "category2", null); + assertTrue(g1.equals(g2)); + } + + /** + * Checks that the class does not implement PublicCloneable (the generator + * is immutable). + */ + @Test + public void testPublicCloneable() { + StandardPieURLGenerator g1 = new StandardPieURLGenerator( + "index.html?", "cat"); + assertFalse(g1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardPieURLGenerator g1 = new StandardPieURLGenerator( + "index.html?", "cat"); + StandardPieURLGenerator g2 = (StandardPieURLGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + + /** + * Test that the generated URL is as expected. + */ + @Test + public void testURL() { + DefaultPieDataset dataset = new DefaultPieDataset(); + dataset.setValue("Alpha '1'", new Double(5.0)); + dataset.setValue("Beta", new Double(5.5)); + StandardPieURLGenerator g1 = new StandardPieURLGenerator( + "chart.jsp", "category"); + String url = g1.generateURL(dataset, "Beta", 0); + assertEquals("chart.jsp?category=Beta&pieIndex=0", url); + url = g1.generateURL(dataset, "Alpha '1'", 0); + assertEquals("chart.jsp?category=Alpha+%271%27&pieIndex=0", url); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/StandardXYURLGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/StandardXYURLGeneratorTest.java new file mode 100755 index 0000000..6c9e69b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/StandardXYURLGeneratorTest.java @@ -0,0 +1,78 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * StandardXYURLGeneratorTest.java + * ------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 01-Mar-2004 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.urls; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link StandardXYURLGenerator} class. + */ +public class StandardXYURLGeneratorTest { + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + StandardXYURLGenerator g1 = new StandardXYURLGenerator("index.html?"); + StandardXYURLGenerator g2 = (StandardXYURLGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + + /** + * Checks that the class does not implement PublicCloneable (the generator + * is immutable). + */ + @Test + public void testPublicCloneable() { + StandardXYURLGenerator g1 = new StandardXYURLGenerator("index.html?"); + assertFalse(g1 instanceof PublicCloneable); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/TimeSeriesURLGeneratorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/TimeSeriesURLGeneratorTest.java new file mode 100755 index 0000000..7e7d0b0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/TimeSeriesURLGeneratorTest.java @@ -0,0 +1,140 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * TimeSeriesURLGeneratorTest.java + * ------------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 17-Apr-2007 : Version 1 (DG); + * 23-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.chart.urls; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.text.SimpleDateFormat; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.xy.DefaultXYDataset; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link TimeSeriesURLGenerator} class. + */ +public class TimeSeriesURLGeneratorTest { + + /** + * A basic check for the generateURL() method. + */ + @Test + public void testGenerateURL() { + TimeSeriesURLGenerator g = new TimeSeriesURLGenerator(); + DefaultXYDataset dataset = new DefaultXYDataset(); + dataset.addSeries("Series '1'", new double[][] {{1.0, 2.0}, + {3.0, 4.0}}); + String s = g.generateURL(dataset, 0, 0); + assertTrue(s.startsWith("index.html?series=Series+%271%27&item=")); + } + + /** + * Check that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + TimeSeriesURLGenerator g1 = new TimeSeriesURLGenerator(); + TimeSeriesURLGenerator g2 = new TimeSeriesURLGenerator(); + assertTrue(g1.equals(g2)); + + g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yyyy"), "prefix", + "series", "item"); + assertFalse(g1.equals(g2)); + g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yyyy"), "prefix", + "series", "item"); + assertTrue(g1.equals(g2)); + + g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix", + "series", "item"); + assertFalse(g1.equals(g2)); + g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix", + "series", "item"); + assertTrue(g1.equals(g2)); + + g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1", + "series", "item"); + assertFalse(g1.equals(g2)); + g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1", + "series", "item"); + assertTrue(g1.equals(g2)); + + g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1", + "series1", "item"); + assertFalse(g1.equals(g2)); + g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1", + "series1", "item"); + assertTrue(g1.equals(g2)); + + g1 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1", + "series1", "item1"); + assertFalse(g1.equals(g2)); + g2 = new TimeSeriesURLGenerator(new SimpleDateFormat("yy"), "prefix1", + "series1", "item1"); + assertTrue(g1.equals(g2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TimeSeriesURLGenerator g1 = new TimeSeriesURLGenerator(); + TimeSeriesURLGenerator g2 = (TimeSeriesURLGenerator) + TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + + /** + * Checks that the class does not implement PublicCloneable (the generator + * is immutable). + */ + @Test + public void testPublicCloneable() { + TimeSeriesURLGenerator g1 = new TimeSeriesURLGenerator(); + assertFalse(g1 instanceof PublicCloneable); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/package.html new file mode 100755 index 0000000..08924b5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/urls/package.html @@ -0,0 +1,6 @@ + + + +JUnit tests. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/util/HMSNumberFormatTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/util/HMSNumberFormatTest.java new file mode 100755 index 0000000..d58bce3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/util/HMSNumberFormatTest.java @@ -0,0 +1,61 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * HMSNumberFormatTest.java + * ------------------------ + * (C) Copyright 2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Nov-2013 : Version 1 (DG); + * + */ + +package org.jfree.chart.util; + +import static org.junit.Assert.assertEquals; +import org.junit.Test; + +/** + * Tests for the {@link HMSNumberFormat} class. + */ +public class HMSNumberFormatTest { + + @Test + public void testGeneral() { + HMSNumberFormat formatter = new HMSNumberFormat(); + assertEquals("00:00:00", formatter.format(0)); + assertEquals("00:00:59", formatter.format(59)); + assertEquals("00:01:01", formatter.format(61)); + assertEquals("00:59:59", formatter.format(3599)); + assertEquals("01:00:00", formatter.format(3600)); + assertEquals("01:00:01", formatter.format(3601)); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/util/LineUtilitiesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/util/LineUtilitiesTest.java new file mode 100755 index 0000000..3316f34 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/util/LineUtilitiesTest.java @@ -0,0 +1,122 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * LineUtilitiesTest.java + * ---------------------- + * (C) Copyright 2008-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Nov-2008 : Version 1 (DG); + * + */ + +package org.jfree.chart.util; + +import java.awt.geom.Line2D; +import java.awt.geom.Rectangle2D; +import org.junit.Test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +/** + * Tests for the {@link LineUtilities} class. + */ +public class LineUtilitiesTest { + + private boolean lineEquals(Line2D line, double x1, double y1, double x2, + double y2) { + boolean result = true; + double epsilon = 0.0000000001; + if (Math.abs(line.getX1() - x1) > epsilon) { result = false; } + if (Math.abs(line.getY1() - y1) > epsilon) { result = false; } + if (Math.abs(line.getX2() - x2) > epsilon) { result = false; } + if (Math.abs(line.getY2() - y2) > epsilon) { result = false; } + return result; + } + + @Test + public void testClipLine() { + Rectangle2D rect = new Rectangle2D.Double(1.0, 1.0, 1.0, 1.0); + Line2D line = new Line2D.Double(); + + assertFalse(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 0.0, 0.0, 0.0, 0.0)); + + line.setLine(0.5, 0.5, 0.6, 0.6); + assertFalse(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 0.5, 0.5, 0.6, 0.6)); + + line.setLine(0.5, 0.5, 1.6, 0.6); + assertFalse(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 0.5, 0.5, 1.6, 0.6)); + + line.setLine(0.5, 0.5, 2.6, 0.6); + assertFalse(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 0.5, 0.5, 2.6, 0.6)); + + line.setLine(0.5, 0.5, 0.6, 1.6); + assertFalse(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 0.5, 0.5, 0.6, 1.6)); + + line.setLine(0.5, 0.5, 1.6, 1.6); + assertTrue(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 1.0, 1.0, 1.6, 1.6)); + + line.setLine(0.5, 0.5, 2.6, 1.6); + assertTrue(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 1.4545454545454546, 1.0, 2.0, + 1.2857142857142858)); + + line.setLine(0.5, 0.5, 0.5, 2.6); + assertFalse(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 0.5, 0.5, 0.5, 2.6)); + + line.setLine(0.5, 0.5, 1.5, 2.6); + assertTrue(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 1.0, 1.55, 1.2142857142857142, 2.0)); + + line.setLine(0.5, 0.5, 2.5, 2.6); + assertTrue(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 1.0, 1.025, 1.9285714285714284, 2.0)); + + line.setLine(0.5, 0.5, 1.5, 1.5); + assertTrue(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 1.0, 1.0, 1.5, 1.5)); + + line.setLine(2.5, 1.0, 1.5, 1.5); + assertTrue(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 2.0, 1.25, 1.5, 1.5)); + + line.setLine(1.5, 1.5, 2.5, 1.0); + assertTrue(LineUtilities.clipLine(line, rect)); + assertTrue(lineEquals(line, 1.5, 1.5, 2.0, 1.25)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/util/LogFormatTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/util/LogFormatTest.java new file mode 100755 index 0000000..688c0c5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/util/LogFormatTest.java @@ -0,0 +1,119 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * LogFormatTest.java + * ------------------ + * (C) Copyright 2008-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Feb-2008 : Version 1 (DG); + * 14-Jan-2009 : Updated testEquals() for new field (DG); + * + */ + +package org.jfree.chart.util; + +import java.text.DecimalFormat; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +/** + * Tests for the {@link LogFormat} class. + */ +public class LogFormatTest { + + /** + * Check that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + LogFormat f1 = new LogFormat(10.0, "10", true); + LogFormat f2 = new LogFormat(10.0, "10", true); + assertEquals(f1, f2); + + f1 = new LogFormat(11.0, "10", true); + assertFalse(f1.equals(f2)); + f2 = new LogFormat(11.0, "10", true); + assertTrue(f1.equals(f2)); + + f1 = new LogFormat(11.0, "11", true); + assertFalse(f1.equals(f2)); + f2 = new LogFormat(11.0, "11", true); + assertTrue(f1.equals(f2)); + + f1 = new LogFormat(11.0, "11", false); + assertFalse(f1.equals(f2)); + f2 = new LogFormat(11.0, "11", false); + assertTrue(f1.equals(f2)); + + f1.setExponentFormat(new DecimalFormat("0.000")); + assertFalse(f1.equals(f2)); + f2.setExponentFormat(new DecimalFormat("0.000")); + assertTrue(f1.equals(f2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + public void testHashcode() { + LogFormat f1 = new LogFormat(10.0, "10", true); + LogFormat f2 = new LogFormat(10.0, "10", true); + assertTrue(f1.equals(f2)); + int h1 = f1.hashCode(); + int h2 = f2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + public void testCloning() { + LogFormat f1 = new LogFormat(10.0, "10", true); + LogFormat f2 = (LogFormat) f1.clone(); + assertTrue(f1 != f2); + assertTrue(f1.getClass() == f2.getClass()); + assertTrue(f1.equals(f2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + public void testSerialization() { + LogFormat f1 = new LogFormat(10.0, "10", true); + LogFormat f2 = (LogFormat) TestUtilities.serialised(f1); + assertEquals(f1, f2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/util/RelativeDateFormatTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/util/RelativeDateFormatTest.java new file mode 100755 index 0000000..446c504 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/chart/util/RelativeDateFormatTest.java @@ -0,0 +1,220 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * RelativeDateFormatTest.java + * --------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Nov-2006 : Version 1 (DG); + * 15-Feb-2008 : Added tests for negative dates (DG); + * 01-Sep-2008 : Added a test for hours and minutes with leading zeroes (DG); + * 06-Oct-2011 : Fixed bug 3418287 (DG); + * + */ + +package org.jfree.chart.util; + +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.Date; +import java.util.Locale; +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +/** + * Tests for the {@link RelativeDateFormat} class. + */ +public class RelativeDateFormatTest { + + private Locale savedLocale; + + /** + * Set a known locale for the tests. + */ + @Before + public void setUp() throws Exception { + this.savedLocale = Locale.getDefault(); + Locale.setDefault(Locale.UK); + } + + /** + * Restore the default locale after the tests complete. + */ + @After + public void tearDown() throws Exception { + Locale.setDefault(this.savedLocale); + } + + /** + * Some checks for the formatting. + */ + @Test + public void testFormat() { + RelativeDateFormat rdf = new RelativeDateFormat(); + String s = rdf.format(new Date(2 * 60L * 60L * 1000L + 122500L)); + assertEquals("2h2m2.500s", s); + } + + /** + * Test that we can configure the RelativeDateFormat to show + * hh:mm:ss. + */ + public void test2033092() { + RelativeDateFormat rdf = new RelativeDateFormat(); + rdf.setShowZeroDays(false); + rdf.setShowZeroHours(false); + rdf.setMinuteSuffix(":"); + rdf.setHourSuffix(":"); + rdf.setSecondSuffix(""); + DecimalFormat hoursFormatter = new DecimalFormat(); + hoursFormatter.setMaximumFractionDigits(0); + hoursFormatter.setMaximumIntegerDigits(2); + hoursFormatter.setMinimumIntegerDigits(2); + rdf.setHourFormatter(hoursFormatter); + DecimalFormat minsFormatter = new DecimalFormat(); + minsFormatter.setMaximumFractionDigits(0); + minsFormatter.setMaximumIntegerDigits(2); + minsFormatter.setMinimumIntegerDigits(2); + rdf.setMinuteFormatter(minsFormatter); + DecimalFormat secondsFormatter = new DecimalFormat(); + secondsFormatter.setMaximumFractionDigits(0); + secondsFormatter.setMaximumIntegerDigits(2); + secondsFormatter.setMinimumIntegerDigits(2); + rdf.setSecondFormatter(secondsFormatter); + String s = rdf.format(new Date(2 * 60L * 60L * 1000L + 122500L)); + assertEquals("02:02:02", s); + } + + /** + * Check that the equals() method can distinguish all fields. + */ + public void testEquals() { + RelativeDateFormat df1 = new RelativeDateFormat(); + RelativeDateFormat df2 = new RelativeDateFormat(); + assertEquals(df1, df2); + + df1.setBaseMillis(123L); + assertFalse(df1.equals(df2)); + df2.setBaseMillis(123L); + assertTrue(df1.equals(df2)); + + df1.setDayFormatter(new DecimalFormat("0%")); + assertFalse(df1.equals(df2)); + df2.setDayFormatter(new DecimalFormat("0%")); + assertTrue(df1.equals(df2)); + + df1.setDaySuffix("D"); + assertFalse(df1.equals(df2)); + df2.setDaySuffix("D"); + assertTrue(df1.equals(df2)); + + df1.setHourFormatter(new DecimalFormat("0%")); + assertFalse(df1.equals(df2)); + df2.setHourFormatter(new DecimalFormat("0%")); + assertTrue(df1.equals(df2)); + + df1.setHourSuffix("H"); + assertFalse(df1.equals(df2)); + df2.setHourSuffix("H"); + assertTrue(df1.equals(df2)); + + df1.setMinuteFormatter(new DecimalFormat("0%")); + assertFalse(df1.equals(df2)); + df2.setMinuteFormatter(new DecimalFormat("0%")); + assertTrue(df1.equals(df2)); + + df1.setMinuteSuffix("M"); + assertFalse(df1.equals(df2)); + df2.setMinuteSuffix("M"); + assertTrue(df1.equals(df2)); + + df1.setSecondSuffix("S"); + assertFalse(df1.equals(df2)); + df2.setSecondSuffix("S"); + assertTrue(df1.equals(df2)); + + df1.setShowZeroDays(!df1.getShowZeroDays()); + assertFalse(df1.equals(df2)); + df2.setShowZeroDays(!df2.getShowZeroDays()); + assertTrue(df1.equals(df2)); + + df1.setSecondFormatter(new DecimalFormat("0.0")); + assertFalse(df1.equals(df2)); + df2.setSecondFormatter(new DecimalFormat("0.0")); + assertTrue(df1.equals(df2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + public void testHashCode() { + RelativeDateFormat df1 = new RelativeDateFormat(123L); + RelativeDateFormat df2 = new RelativeDateFormat(123L); + assertTrue(df1.equals(df2)); + int h1 = df1.hashCode(); + int h2 = df2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + public void testCloning() { + NumberFormat nf = new DecimalFormat("0"); + RelativeDateFormat df1 = new RelativeDateFormat(); + df1.setSecondFormatter(nf); + RelativeDateFormat df2 = null; + df2 = (RelativeDateFormat) df1.clone(); + assertTrue(df1 != df2); + assertTrue(df1.getClass() == df2.getClass()); + assertTrue(df1.equals(df2)); + + // is the clone independent + nf.setMinimumFractionDigits(2); + assertFalse(df1.equals(df2)); + } + + /** + * Some tests for negative dates. + */ + public void testNegative() { + NumberFormat nf = new DecimalFormat("0"); + RelativeDateFormat df1 = new RelativeDateFormat(); + df1.setSecondFormatter(nf); + assertEquals("-0h0m1s", df1.format(new Date(-1000L))); + } +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/ComparableObjectItemTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/ComparableObjectItemTest.java new file mode 100755 index 0000000..c9ddc0a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/ComparableObjectItemTest.java @@ -0,0 +1,139 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * ComparableObjectItemTest.java + * ----------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * + */ + +package org.jfree.data; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.fail; + +/** + * Tests for the {@link ComparableObjectItem} class. + */ +public class ComparableObjectItemTest { + + /** + * Some checks for the constructor. + */ + @Test + public void testConstructor() { + // check null argument 1 + try { + /* ComparableObjectItem item1 = */ new ComparableObjectItem(null, + "XYZ"); + fail("There should be an exception."); + } + catch (IllegalArgumentException e) { + // expected + } + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1), + "XYZ"); + ComparableObjectItem item2 = new ComparableObjectItem(new Integer(1), + "XYZ"); + assertEquals(item1, item2); + + item1 = new ComparableObjectItem(new Integer(2), "XYZ"); + assertNotEquals(item1, item2); + item2 = new ComparableObjectItem(new Integer(2), "XYZ"); + assertEquals(item1, item2); + + item1 = new ComparableObjectItem(new Integer(2), null); + assertNotEquals(item1, item2); + item2 = new ComparableObjectItem(new Integer(2), null); + assertEquals(item1, item2); + } + + /** + * Some checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1), + "XYZ"); + ComparableObjectItem item2 = (ComparableObjectItem) item1.clone(); + assertNotSame(item1, item2); + assertSame(item1.getClass(), item2.getClass()); + assertEquals(item1, item2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1), + "XYZ"); + ComparableObjectItem item2 = (ComparableObjectItem) + TestUtilities.serialised(item1); + assertEquals(item1, item2); + } + + /** + * Some checks for the compareTo() method. + */ + @Test + public void testCompareTo() { + ComparableObjectItem item1 = new ComparableObjectItem(new Integer(1), + "XYZ"); + ComparableObjectItem item2 = new ComparableObjectItem(new Integer(2), + "XYZ"); + ComparableObjectItem item3 = new ComparableObjectItem(new Integer(3), + "XYZ"); + ComparableObjectItem item4 = new ComparableObjectItem(new Integer(1), + "XYZ"); + assertTrue(item2.compareTo(item1) > 0); + assertTrue(item3.compareTo(item1) > 0); + assertTrue(item4.compareTo(item1) == 0); + assertTrue(item1.compareTo(item2) < 0); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/ComparableObjectSeriesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/ComparableObjectSeriesTest.java new file mode 100755 index 0000000..5e5dbdf --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/ComparableObjectSeriesTest.java @@ -0,0 +1,214 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * ComparableObjectSeriesTest.java + * ------------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * 31-Oct-2007 : New hashCode() test (DG); + * + */ + +package org.jfree.data; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; + +/** + * Tests for the {@link ComparableObjectSeries} class. + */ +public class ComparableObjectSeriesTest { + + static class MyComparableObjectSeries extends ComparableObjectSeries { + /** + * Creates a new instance. + * + * @param key the series key. + */ + public MyComparableObjectSeries(Comparable key) { + super(key); + } + /** + * Creates a new instance. + * + * @param key the series key. + * @param autoSort automatically sort by x-value? + * @param allowDuplicateXValues allow duplicate values? + */ + public MyComparableObjectSeries(Comparable key, boolean autoSort, + boolean allowDuplicateXValues) { + super(key, autoSort, allowDuplicateXValues); + } + @Override + public void add(Comparable x, Object y) { + super.add(x, y); + } + + @Override + public ComparableObjectItem remove(Comparable x) { + return super.remove(x); + } + } + + /** + * Some checks for the constructor. + */ + @Test + public void testConstructor1() { + ComparableObjectSeries s1 = new ComparableObjectSeries("s1"); + assertEquals("s1", s1.getKey()); + assertNull(s1.getDescription()); + assertTrue(s1.getAllowDuplicateXValues()); + assertTrue(s1.getAutoSort()); + assertEquals(0, s1.getItemCount()); + assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); + + // try null key + boolean pass = false; + try { + /*s1 = */new ComparableObjectSeries(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + MyComparableObjectSeries s1 = new MyComparableObjectSeries("A"); + MyComparableObjectSeries s2 = new MyComparableObjectSeries("A"); + assertTrue(s1.equals(s2)); + assertTrue(s2.equals(s1)); + + // key + s1 = new MyComparableObjectSeries("B"); + assertNotEquals(s1, s2); + s2 = new MyComparableObjectSeries("B"); + assertTrue(s1.equals(s2)); + + // autoSort + s1 = new MyComparableObjectSeries("B", false, true); + assertNotEquals(s1, s2); + s2 = new MyComparableObjectSeries("B", false, true); + assertTrue(s1.equals(s2)); + + // allowDuplicateXValues + s1 = new MyComparableObjectSeries("B", false, false); + assertNotEquals(s1, s2); + s2 = new MyComparableObjectSeries("B", false, false); + assertTrue(s1.equals(s2)); + + // add a value + s1.add(new Integer(1), "ABC"); + assertNotEquals(s1, s2); + s2.add(new Integer(1), "ABC"); + assertTrue(s1.equals(s2)); + + // add another value + s1.add(new Integer(0), "DEF"); + assertNotEquals(s1, s2); + s2.add(new Integer(0), "DEF"); + assertTrue(s1.equals(s2)); + + // remove an item + s1.remove(new Integer(1)); + assertNotEquals(s1, s2); + s2.remove(new Integer(1)); + assertTrue(s1.equals(s2)); + } + + /** + * Some checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + MyComparableObjectSeries s1 = new MyComparableObjectSeries("A"); + s1.add(new Integer(1), "ABC"); + MyComparableObjectSeries s2 = (MyComparableObjectSeries) s1.clone(); + assertTrue(s1 != s2); + assertTrue(s1.getClass() == s2.getClass()); + assertTrue(s1.equals(s2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + MyComparableObjectSeries s1 = new MyComparableObjectSeries("A"); + s1.add(new Integer(1), "ABC"); + MyComparableObjectSeries s2 = (MyComparableObjectSeries) + TestUtilities.serialised(s1); + assertEquals(s1, s2); + } + + /** + * Some simple checks for the hashCode() method. + */ + @Test + public void testHashCode() { + MyComparableObjectSeries s1 = new MyComparableObjectSeries("Test"); + MyComparableObjectSeries s2 = new MyComparableObjectSeries("Test"); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + + s1.add("A", "1"); + s2.add("A", "1"); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + + s1.add("B", null); + s2.add("B", null); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + + s1.add("C", "3"); + s2.add("C", "3"); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + + s1.add("D", "4"); + s2.add("D", "4"); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DataUtilitiesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DataUtilitiesTest.java new file mode 100755 index 0000000..3c2d97e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DataUtilitiesTest.java @@ -0,0 +1,245 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * DataUtilitiesTest.java + * ---------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 03-Mar-2005 : Version 1 (DG); + * 28-Jan-2009 : Added tests for equal(double[][], double[][]) method (DG); + * 28-Jan-2009 : Added tests for clone(double[][]) (DG); + * 04-Feb-2009 : Added tests for new calculateColumnTotal/RowTotal methods (DG); + * + */ + +package org.jfree.data; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import org.junit.Test; + +/** + * Some tests for the {@link DataUtilities} class. + */ +public class DataUtilitiesTest { + + /** + * Tests the createNumberArray2D() method. + */ + @Test + public void testCreateNumberArray2D() { + double[][] d = new double[2][]; + d[0] = new double[] {1.1, 2.2, 3.3, 4.4}; + d[1] = new double[] {1.1, 2.2, 3.3, 4.4, 5.5}; + Number[][] n = DataUtilities.createNumberArray2D(d); + assertEquals(2, n.length); + assertEquals(4, n[0].length); + assertEquals(5, n[1].length); + } + + private static final double EPSILON = 0.000000001; + + /** + * Some checks for the calculateColumnTotal() method. + */ + @Test + public void testCalculateColumnTotal() { + DefaultKeyedValues2D table = new DefaultKeyedValues2D(); + table.addValue(new Double(1.0), "R0", "C0"); + table.addValue(new Double(2.0), "R0", "C1"); + table.addValue(new Double(3.0), "R1", "C0"); + table.addValue(new Double(4.0), "R1", "C1"); + assertEquals(4.0, DataUtilities.calculateColumnTotal(table, 0), EPSILON); + assertEquals(6.0, DataUtilities.calculateColumnTotal(table, 1), EPSILON); + table.setValue(null, "R1", "C1"); + assertEquals(2.0, DataUtilities.calculateColumnTotal(table, 1), EPSILON); + } + + /** + * Some checks for the calculateColumnTotal() method. + */ + @Test + public void testCalculateColumnTotal2() { + DefaultKeyedValues2D table = new DefaultKeyedValues2D(); + table.addValue(new Double(1.0), "R0", "C0"); + table.addValue(new Double(2.0), "R0", "C1"); + table.addValue(new Double(3.0), "R1", "C0"); + table.addValue(new Double(4.0), "R1", "C1"); + assertEquals(4.0, DataUtilities.calculateColumnTotal(table, 0, + new int[] {0, 1}), EPSILON); + assertEquals(1.0, DataUtilities.calculateColumnTotal(table, 0, + new int[] {0}), EPSILON); + assertEquals(3.0, DataUtilities.calculateColumnTotal(table, 0, + new int[] {1}), EPSILON); + assertEquals(0.0, DataUtilities.calculateColumnTotal(table, 0, + new int[] {}), EPSILON); + + assertEquals(6.0, DataUtilities.calculateColumnTotal(table, 1, + new int[] {0, 1}), EPSILON); + assertEquals(2.0, DataUtilities.calculateColumnTotal(table, 1, + new int[] {0}), EPSILON); + assertEquals(4.0, DataUtilities.calculateColumnTotal(table, 1, + new int[] {1}), EPSILON); + + table.setValue(null, "R1", "C1"); + assertEquals(2.0, DataUtilities.calculateColumnTotal(table, 1, + new int[] {0, 1}), EPSILON); + assertEquals(0.0, DataUtilities.calculateColumnTotal(table, 1, + new int[] {1}), EPSILON); + } + + /** + * Some checks for the calculateRowTotal() method. + */ + @Test + public void testCalculateRowTotal() { + DefaultKeyedValues2D table = new DefaultKeyedValues2D(); + table.addValue(new Double(1.0), "R0", "C0"); + table.addValue(new Double(2.0), "R0", "C1"); + table.addValue(new Double(3.0), "R1", "C0"); + table.addValue(new Double(4.0), "R1", "C1"); + assertEquals(3.0, DataUtilities.calculateRowTotal(table, 0), EPSILON); + assertEquals(7.0, DataUtilities.calculateRowTotal(table, 1), EPSILON); + table.setValue(null, "R1", "C1"); + assertEquals(3.0, DataUtilities.calculateRowTotal(table, 1), EPSILON); + } + + /** + * Some checks for the calculateRowTotal() method. + */ + @Test + public void testCalculateRowTotal2() { + DefaultKeyedValues2D table = new DefaultKeyedValues2D(); + table.addValue(new Double(1.0), "R0", "C0"); + table.addValue(new Double(2.0), "R0", "C1"); + table.addValue(new Double(3.0), "R1", "C0"); + table.addValue(new Double(4.0), "R1", "C1"); + assertEquals(3.0, DataUtilities.calculateRowTotal(table, 0, + new int[] {0, 1}), EPSILON); + assertEquals(1.0, DataUtilities.calculateRowTotal(table, 0, + new int[] {0}), EPSILON); + assertEquals(2.0, DataUtilities.calculateRowTotal(table, 0, + new int[] {1}), EPSILON); + assertEquals(0.0, DataUtilities.calculateRowTotal(table, 0, + new int[] {}), EPSILON); + + assertEquals(7.0, DataUtilities.calculateRowTotal(table, 1, + new int[] {0, 1}), EPSILON); + assertEquals(3.0, DataUtilities.calculateRowTotal(table, 1, + new int[] {0}), EPSILON); + assertEquals(4.0, DataUtilities.calculateRowTotal(table, 1, + new int[] {1}), EPSILON); + assertEquals(0.0, DataUtilities.calculateRowTotal(table, 1, + new int[] {}), EPSILON); + table.setValue(null, "R1", "C1"); + assertEquals(3.0, DataUtilities.calculateRowTotal(table, 1, + new int[] {0, 1}), EPSILON); + assertEquals(0.0, DataUtilities.calculateRowTotal(table, 1, + new int[] {1}), EPSILON); + } + + /** + * Some tests for the equal(double[][], double[][]) method. + */ + @Test + public void testEqual() { + assertTrue(DataUtilities.equal(null, null)); + + double[][] a = new double[5][]; + double[][] b = new double[5][]; + assertTrue(DataUtilities.equal(a, b)); + + a = new double[4][]; + assertFalse(DataUtilities.equal(a, b)); + b = new double[4][]; + assertTrue(DataUtilities.equal(a, b)); + + a[0] = new double[6]; + assertFalse(DataUtilities.equal(a, b)); + b[0] = new double[6]; + assertTrue(DataUtilities.equal(a, b)); + + a[0][0] = 1.0; + assertFalse(DataUtilities.equal(a, b)); + b[0][0] = 1.0; + assertTrue(DataUtilities.equal(a, b)); + + a[0][1] = Double.NaN; + assertFalse(DataUtilities.equal(a, b)); + b[0][1] = Double.NaN; + assertTrue(DataUtilities.equal(a, b)); + + a[0][2] = Double.NEGATIVE_INFINITY; + assertFalse(DataUtilities.equal(a, b)); + b[0][2] = Double.NEGATIVE_INFINITY; + assertTrue(DataUtilities.equal(a, b)); + + a[0][3] = Double.POSITIVE_INFINITY; + assertFalse(DataUtilities.equal(a, b)); + b[0][3] = Double.POSITIVE_INFINITY; + assertTrue(DataUtilities.equal(a, b)); + + a[0][4] = Double.POSITIVE_INFINITY; + assertFalse(DataUtilities.equal(a, b)); + b[0][4] = Double.NEGATIVE_INFINITY; + assertFalse(DataUtilities.equal(a, b)); + b[0][4] = Double.POSITIVE_INFINITY; + assertTrue(DataUtilities.equal(a, b)); + } + + /** + * Some tests for the clone() method. + */ + @Test + public void testClone() { + double[][] a = new double[1][]; + double[][] b = DataUtilities.clone(a); + assertTrue(DataUtilities.equal(a, b)); + a[0] = new double[] { 3.0, 4.0 }; + assertFalse(DataUtilities.equal(a, b)); + b[0] = new double[] { 3.0, 4.0 }; + assertTrue(DataUtilities.equal(a, b)); + + a = new double[2][3]; + a[0][0] = 1.23; + a[1][1] = Double.NaN; + b = DataUtilities.clone(a); + assertTrue(DataUtilities.equal(a, b)); + + a[0][0] = 99.9; + assertFalse(DataUtilities.equal(a, b)); + b[0][0] = 99.9; + assertTrue(DataUtilities.equal(a, b)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DefaultKeyedValueTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DefaultKeyedValueTest.java new file mode 100755 index 0000000..c47d308 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DefaultKeyedValueTest.java @@ -0,0 +1,126 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * DefaultKeyedValueTests.java + * --------------------------- + * (C) Copyright 2003-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Mar-2003 : Version 1 (DG); + * + */ + +package org.jfree.data; + +import org.jfree.chart.TestUtilities; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import org.junit.Test; + +/** + * Tests for the {@link DefaultKeyedValue} class. + */ +public class DefaultKeyedValueTest { + + /** + * Simple checks for the constructor. + */ + @Test + public void testConstructor() { + DefaultKeyedValue v = new DefaultKeyedValue("A", new Integer(1)); + assertEquals("A", v.getKey()); + assertEquals(new Integer(1), v.getValue()); + + // try null key + boolean pass = false; + try { + /*v =*/ new DefaultKeyedValue(null, new Integer(1)); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + // try a null value + v = new DefaultKeyedValue("A", null); + assertNull(v.getValue()); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5)); + DefaultKeyedValue v2 = new DefaultKeyedValue("Test", new Double(45.5)); + assertTrue(v1.equals(v2)); + assertTrue(v2.equals(v1)); + + v1 = new DefaultKeyedValue("Test 1", new Double(45.5)); + v2 = new DefaultKeyedValue("Test 2", new Double(45.5)); + assertFalse(v1.equals(v2)); + + v1 = new DefaultKeyedValue("Test", new Double(45.5)); + v2 = new DefaultKeyedValue("Test", new Double(45.6)); + assertFalse(v1.equals(v2)); + + } + + /** + * Some checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(45.5)); + DefaultKeyedValue v2 = (DefaultKeyedValue) v1.clone(); + assertTrue(v1 != v2); + assertTrue(v1.getClass() == v2.getClass()); + assertTrue(v1.equals(v2)); + + // confirm that the clone is independent of the original + v2.setValue(new Double(12.3)); + assertFalse(v1.equals(v2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultKeyedValue v1 = new DefaultKeyedValue("Test", new Double(25.3)); + DefaultKeyedValue v2 = (DefaultKeyedValue) TestUtilities.serialised(v1); + assertEquals(v1, v2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DefaultKeyedValues2DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DefaultKeyedValues2DTest.java new file mode 100755 index 0000000..224490d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DefaultKeyedValues2DTest.java @@ -0,0 +1,335 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * DefaultKeyedValues2DTest.java + * ----------------------------- + * (C) Copyright 2003-2013 by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Mar-2003 : Version 1 (DG); + * 15-Sep-2004 : Updated cloning test (DG); + * 06-Oct-2005 : Added testEquals() (DG); + * 18-Jan-2007 : Added testSparsePopulation() (DG); + * 26-Feb-2007 : Added some basic tests (DG); + * 30-Mar-2007 : Added a test for bug 1690654 (DG); + * 21-Nov-2007 : Added testRemoveColumnByKey() method (DG); + * + */ + +package org.jfree.data; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link DefaultKeyedValues2D} class. + */ +public class DefaultKeyedValues2DTest { + + /** + * Some checks for the getValue() method. + */ + @Test + public void testGetValue() { + DefaultKeyedValues2D d = new DefaultKeyedValues2D(); + d.addValue(new Double(1.0), "R1", "C1"); + assertEquals(new Double(1.0), d.getValue("R1", "C1")); + boolean pass = false; + try { + d.getValue("XX", "C1"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + d.getValue("R1", "XX"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultKeyedValues2D v1 = new DefaultKeyedValues2D(); + v1.setValue(new Integer(1), "V1", "C1"); + v1.setValue(null, "V2", "C1"); + v1.setValue(new Integer(3), "V3", "C2"); + DefaultKeyedValues2D v2 = (DefaultKeyedValues2D) v1.clone(); + assertTrue(v1 != v2); + assertTrue(v1.getClass() == v2.getClass()); + assertTrue(v1.equals(v2)); + + // check that clone is independent of the original + v2.setValue(new Integer(2), "V2", "C1"); + assertFalse(v1.equals(v2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultKeyedValues2D kv2D1 = new DefaultKeyedValues2D(); + kv2D1.addValue(new Double(234.2), "Row1", "Col1"); + kv2D1.addValue(null, "Row1", "Col2"); + kv2D1.addValue(new Double(345.9), "Row2", "Col1"); + kv2D1.addValue(new Double(452.7), "Row2", "Col2"); + + DefaultKeyedValues2D kv2D2 = (DefaultKeyedValues2D) + TestUtilities.serialised(kv2D1); + assertEquals(kv2D1, kv2D2); + } + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + DefaultKeyedValues2D d1 = new DefaultKeyedValues2D(); + DefaultKeyedValues2D d2 = new DefaultKeyedValues2D(); + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + d1.addValue(new Double(1.0), new Double(2.0), "S1"); + assertFalse(d1.equals(d2)); + d2.addValue(new Double(1.0), new Double(2.0), "S1"); + assertTrue(d1.equals(d2)); + } + + /** + * Populates a data structure with sparse entries, then checks that + * the unspecified entries return null. + */ + @Test + public void testSparsePopulation() { + DefaultKeyedValues2D d = new DefaultKeyedValues2D(); + d.addValue(new Integer(11), "R1", "C1"); + d.addValue(new Integer(22), "R2", "C2"); + + assertEquals(new Integer(11), d.getValue("R1", "C1")); + assertNull(d.getValue("R1", "C2")); + assertEquals(new Integer(22), d.getValue("R2", "C2")); + assertNull(d.getValue("R2", "C1")); + } + + /** + * Some basic checks for the getRowCount() method. + */ + @Test + public void testRowCount() { + DefaultKeyedValues2D d = new DefaultKeyedValues2D(); + assertEquals(0, d.getRowCount()); + d.addValue(new Double(1.0), "R1", "C1"); + assertEquals(1, d.getRowCount()); + d.addValue(new Double(2.0), "R2", "C1"); + assertEquals(2, d.getRowCount()); + } + + /** + * Some basic checks for the getColumnCount() method. + */ + @Test + public void testColumnCount() { + DefaultKeyedValues2D d = new DefaultKeyedValues2D(); + assertEquals(0, d.getColumnCount()); + d.addValue(new Double(1.0), "R1", "C1"); + assertEquals(1, d.getColumnCount()); + d.addValue(new Double(2.0), "R1", "C2"); + assertEquals(2, d.getColumnCount()); + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some basic checks for the getValue(int, int) method. + */ + @Test + public void testGetValue2() { + DefaultKeyedValues2D d = new DefaultKeyedValues2D(); + boolean pass = false; + try { + d.getValue(0, 0); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + d.addValue(new Double(1.0), "R1", "C1"); + assertEquals(1.0, d.getValue(0, 0).doubleValue(), EPSILON); + d.addValue(new Double(2.0), "R2", "C2"); + assertEquals(2.0, d.getValue(1, 1).doubleValue(), EPSILON); + assertNull(d.getValue(1, 0)); + assertNull(d.getValue(0, 1)); + + pass = false; + try { + d.getValue(2, 0); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some basic checks for the getRowKey() method. + */ + @Test + public void testGetRowKey() { + DefaultKeyedValues2D d = new DefaultKeyedValues2D(); + boolean pass = false; + try { + d.getRowKey(0); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + d.addValue(new Double(1.0), "R1", "C1"); + d.addValue(new Double(1.0), "R2", "C1"); + assertEquals("R1", d.getRowKey(0)); + assertEquals("R2", d.getRowKey(1)); + + // check sorted rows + d = new DefaultKeyedValues2D(true); + d.addValue(new Double(1.0), "R1", "C1"); + assertEquals("R1", d.getRowKey(0)); + d.addValue(new Double(0.0), "R0", "C1"); + assertEquals("R0", d.getRowKey(0)); + assertEquals("R1", d.getRowKey(1)); + } + + /** + * Some basic checks for the getColumnKey() method. + */ + @Test + public void testGetColumnKey() { + DefaultKeyedValues2D d = new DefaultKeyedValues2D(); + boolean pass = false; + try { + d.getColumnKey(0); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + d.addValue(new Double(1.0), "R1", "C1"); + d.addValue(new Double(1.0), "R1", "C2"); + assertEquals("C1", d.getColumnKey(0)); + assertEquals("C2", d.getColumnKey(1)); + } + + /** + * Some basic checks for the removeValue() method. + */ + @Test + public void testRemoveValue() { + DefaultKeyedValues2D d = new DefaultKeyedValues2D(); + d.removeValue("R1", "C1"); + d.addValue(new Double(1.0), "R1", "C1"); + d.removeValue("R1", "C1"); + assertEquals(0, d.getRowCount()); + assertEquals(0, d.getColumnCount()); + + d.addValue(new Double(1.0), "R1", "C1"); + d.addValue(new Double(2.0), "R2", "C1"); + d.removeValue("R1", "C1"); + assertEquals(new Double(2.0), d.getValue(0, 0)); + } + + /** + * A test for bug 1690654. + */ + @Test + public void testRemoveValueBug1690654() { + DefaultKeyedValues2D d = new DefaultKeyedValues2D(); + d.addValue(new Double(1.0), "R1", "C1"); + d.addValue(new Double(2.0), "R2", "C2"); + assertEquals(2, d.getColumnCount()); + assertEquals(2, d.getRowCount()); + d.removeValue("R2", "C2"); + assertEquals(1, d.getColumnCount()); + assertEquals(1, d.getRowCount()); + assertEquals(new Double(1.0), d.getValue(0, 0)); + } + + /** + * Some basic checks for the removeRow() method. + */ + @Test + public void testRemoveRow() { + DefaultKeyedValues2D d = new DefaultKeyedValues2D(); + boolean pass = false; + try { + d.removeRow(0); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some basic checks for the removeColumn(Comparable) method. + */ + @Test + public void testRemoveColumnByKey() { + DefaultKeyedValues2D d = new DefaultKeyedValues2D(); + d.addValue(new Double(1.0), "R1", "C1"); + d.addValue(new Double(2.0), "R2", "C2"); + d.removeColumn("C2"); + d.addValue(new Double(3.0), "R2", "C2"); + assertEquals(3.0, d.getValue("R2", "C2").doubleValue(), EPSILON); + + // check for unknown column + boolean pass = false; + try { + d.removeColumn("XXX"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DefaultKeyedValuesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DefaultKeyedValuesTest.java new file mode 100755 index 0000000..bc35acd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DefaultKeyedValuesTest.java @@ -0,0 +1,500 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * DefaultKeyedValuesTest.java + * --------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Mar-2003 : Version 1 (DG); + * 27-Aug-2003 : Moved SortOrder from org.jfree.data --> org.jfree.util (DG); + * 31-Jul-2006 : Added test for new clear() method (DG); + * 01-Aug-2006 : Extended testGetIndex() method (DG); + * 30-Apr-2007 : Added some new tests (DG); + * 03-Oct-2007 : Updated testRemoveValue() (DG); + * 21-Nov-2007 : Added testGetIndex2() method (DG); + * + */ + +package org.jfree.data; + +import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import org.jfree.chart.TestUtilities; +import org.jfree.util.SortOrder; +import org.junit.Test; + +/** + * Tests for the {@link DefaultKeyedValues} class. + */ +public class DefaultKeyedValuesTest { + + /** + * Checks that a new instance is empty. + */ + @Test + public void testConstructor() { + DefaultKeyedValues d = new DefaultKeyedValues(); + assertEquals(0, d.getItemCount()); + } + + /** + * Some checks for the getItemCount() method. + */ + @Test + public void testGetItemCount() { + DefaultKeyedValues d = new DefaultKeyedValues(); + assertEquals(0, d.getItemCount()); + d.addValue("A", 1.0); + assertEquals(1, d.getItemCount()); + d.addValue("B", 2.0); + assertEquals(2, d.getItemCount()); + d.clear(); + assertEquals(0, d.getItemCount()); + } + + /** + * Some checks for the getKeys() method. + */ + @Test + public void testGetKeys() { + DefaultKeyedValues d = new DefaultKeyedValues(); + List keys = d.getKeys(); + assertTrue(keys.isEmpty()); + d.addValue("A", 1.0); + keys = d.getKeys(); + assertEquals(1, keys.size()); + assertTrue(keys.contains("A")); + d.addValue("B", 2.0); + keys = d.getKeys(); + assertEquals(2, keys.size()); + assertTrue(keys.contains("A")); + assertTrue(keys.contains("B")); + d.clear(); + keys = d.getKeys(); + assertEquals(0, keys.size()); + } + + /** + * A simple test for the clear() method. + */ + @Test + public void testClear() { + DefaultKeyedValues v1 = new DefaultKeyedValues(); + v1.addValue("A", 1.0); + v1.addValue("B", 2.0); + assertEquals(2, v1.getItemCount()); + v1.clear(); + assertEquals(0, v1.getItemCount()); + } + + /** + * Some checks for the getValue() methods. + */ + @Test + public void testGetValue() { + DefaultKeyedValues v1 = new DefaultKeyedValues(); + try { + /* Number n = */ v1.getValue(-1); + assertTrue(false); + } + catch (IndexOutOfBoundsException e) { + // expected + } + try { + /* Number n = */ v1.getValue(0); + assertTrue(false); + } + catch (IndexOutOfBoundsException e) { + // expected + } + DefaultKeyedValues v2 = new DefaultKeyedValues(); + v2.addValue("K1", new Integer(1)); + v2.addValue("K2", new Integer(2)); + v2.addValue("K3", new Integer(3)); + assertEquals(new Integer(3), v2.getValue(2)); + + boolean pass = false; + try { + /* Number n = */ v2.getValue("KK"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getKey() methods. + */ + @Test + public void testGetKey() { + DefaultKeyedValues v1 = new DefaultKeyedValues(); + try { + /* Comparable k = */ v1.getKey(-1); + assertTrue(false); + } + catch (IndexOutOfBoundsException e) { + // expected + } + try { + /* Comparable k = */ v1.getKey(0); + assertTrue(false); + } + catch (IndexOutOfBoundsException e) { + // expected + } + DefaultKeyedValues v2 = new DefaultKeyedValues(); + v2.addValue("K1", new Integer(1)); + v2.addValue("K2", new Integer(2)); + v2.addValue("K3", new Integer(3)); + assertEquals("K2", v2.getKey(1)); + } + + /** + * Some checks for the getIndex() methods. + */ + @Test + public void testGetIndex() { + DefaultKeyedValues v1 = new DefaultKeyedValues(); + assertEquals(-1, v1.getIndex("K1")); + + DefaultKeyedValues v2 = new DefaultKeyedValues(); + v2.addValue("K1", new Integer(1)); + v2.addValue("K2", new Integer(2)); + v2.addValue("K3", new Integer(3)); + assertEquals(2, v2.getIndex("K3")); + + // try null + boolean pass = false; + try { + v2.getIndex(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Another check for the getIndex(Comparable) method. + */ + @Test + public void testGetIndex2() { + DefaultKeyedValues v = new DefaultKeyedValues(); + assertEquals(-1, v.getIndex("K1")); + v.addValue("K1", 1.0); + assertEquals(0, v.getIndex("K1")); + v.removeValue("K1"); + assertEquals(-1, v.getIndex("K1")); + } + /** + * Some checks for the addValue() method. + */ + @Test + public void testAddValue() { + DefaultKeyedValues v1 = new DefaultKeyedValues(); + v1.addValue("A", 1.0); + assertEquals(new Double(1.0), v1.getValue("A")); + v1.addValue("B", 2.0); + assertEquals(new Double(2.0), v1.getValue("B")); + v1.addValue("B", 3.0); + assertEquals(new Double(3.0), v1.getValue("B")); + assertEquals(2, v1.getItemCount()); + v1.addValue("A", null); + assertNull(v1.getValue("A")); + assertEquals(2, v1.getItemCount()); + + boolean pass = false; + try { + v1.addValue(null, 99.9); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the insertValue() method. + */ + @Test + public void testInsertValue() { + DefaultKeyedValues v1 = new DefaultKeyedValues(); + v1.insertValue(0, "A", 1.0); + assertEquals(new Double(1.0), v1.getValue(0)); + v1.insertValue(0, "B", 2.0); + assertEquals(new Double(2.0), v1.getValue(0)); + assertEquals(new Double(1.0), v1.getValue(1)); + + // it's OK to use an index equal to the size of the list + v1.insertValue(2, "C", 3.0); + assertEquals(new Double(2.0), v1.getValue(0)); + assertEquals(new Double(1.0), v1.getValue(1)); + assertEquals(new Double(3.0), v1.getValue(2)); + + // try replacing an existing value + v1.insertValue(2, "B", 4.0); + assertEquals(new Double(1.0), v1.getValue(0)); + assertEquals(new Double(3.0), v1.getValue(1)); + assertEquals(new Double(4.0), v1.getValue(2)); + } + + /** + * Some checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultKeyedValues v1 = new DefaultKeyedValues(); + v1.addValue("V1", new Integer(1)); + v1.addValue("V2", null); + v1.addValue("V3", new Integer(3)); + DefaultKeyedValues v2 = (DefaultKeyedValues) v1.clone(); + assertTrue(v1 != v2); + assertTrue(v1.getClass() == v2.getClass()); + assertTrue(v1.equals(v2)); + + // confirm that the clone is independent of the original + v2.setValue("V1", new Integer(44)); + assertFalse(v1.equals(v2)); + } + + /** + * Check that inserting and retrieving values works as expected. + */ + @Test + public void testInsertAndRetrieve() { + + DefaultKeyedValues data = new DefaultKeyedValues(); + data.addValue("A", new Double(1.0)); + data.addValue("B", new Double(2.0)); + data.addValue("C", new Double(3.0)); + data.addValue("D", null); + + // check key order + assertEquals(data.getKey(0), "A"); + assertEquals(data.getKey(1), "B"); + assertEquals(data.getKey(2), "C"); + assertEquals(data.getKey(3), "D"); + + // check retrieve value by key + assertEquals(data.getValue("A"), new Double(1.0)); + assertEquals(data.getValue("B"), new Double(2.0)); + assertEquals(data.getValue("C"), new Double(3.0)); + assertEquals(data.getValue("D"), null); + + // check retrieve value by index + assertEquals(data.getValue(0), new Double(1.0)); + assertEquals(data.getValue(1), new Double(2.0)); + assertEquals(data.getValue(2), new Double(3.0)); + assertEquals(data.getValue(3), null); + + } + + /** + * Some tests for the removeValue() method. + */ + @Test + public void testRemoveValue() { + DefaultKeyedValues data = new DefaultKeyedValues(); + data.addValue("A", new Double(1.0)); + data.addValue("B", null); + data.addValue("C", new Double(3.0)); + data.addValue("D", new Double(2.0)); + assertEquals(1, data.getIndex("B")); + data.removeValue("B"); + assertEquals(-1, data.getIndex("B")); + + boolean pass = false; + try { + data.removeValue("XXX"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Tests sorting of data by key (ascending). + */ + @Test + public void testSortByKeyAscending() { + + DefaultKeyedValues data = new DefaultKeyedValues(); + data.addValue("C", new Double(1.0)); + data.addValue("B", null); + data.addValue("D", new Double(3.0)); + data.addValue("A", new Double(2.0)); + + data.sortByKeys(SortOrder.ASCENDING); + + // check key order + assertEquals(data.getKey(0), "A"); + assertEquals(data.getKey(1), "B"); + assertEquals(data.getKey(2), "C"); + assertEquals(data.getKey(3), "D"); + + // check retrieve value by key + assertEquals(data.getValue("A"), new Double(2.0)); + assertEquals(data.getValue("B"), null); + assertEquals(data.getValue("C"), new Double(1.0)); + assertEquals(data.getValue("D"), new Double(3.0)); + + // check retrieve value by index + assertEquals(data.getValue(0), new Double(2.0)); + assertEquals(data.getValue(1), null); + assertEquals(data.getValue(2), new Double(1.0)); + assertEquals(data.getValue(3), new Double(3.0)); + + } + + /** + * Tests sorting of data by key (descending). + */ + @Test + public void testSortByKeyDescending() { + + DefaultKeyedValues data = new DefaultKeyedValues(); + data.addValue("C", new Double(1.0)); + data.addValue("B", null); + data.addValue("D", new Double(3.0)); + data.addValue("A", new Double(2.0)); + + data.sortByKeys(SortOrder.DESCENDING); + + // check key order + assertEquals(data.getKey(0), "D"); + assertEquals(data.getKey(1), "C"); + assertEquals(data.getKey(2), "B"); + assertEquals(data.getKey(3), "A"); + + // check retrieve value by key + assertEquals(data.getValue("A"), new Double(2.0)); + assertEquals(data.getValue("B"), null); + assertEquals(data.getValue("C"), new Double(1.0)); + assertEquals(data.getValue("D"), new Double(3.0)); + + // check retrieve value by index + assertEquals(data.getValue(0), new Double(3.0)); + assertEquals(data.getValue(1), new Double(1.0)); + assertEquals(data.getValue(2), null); + assertEquals(data.getValue(3), new Double(2.0)); + + } + + /** + * Tests sorting of data by value (ascending). + */ + @Test + public void testSortByValueAscending() { + + DefaultKeyedValues data = new DefaultKeyedValues(); + data.addValue("C", new Double(1.0)); + data.addValue("B", null); + data.addValue("D", new Double(3.0)); + data.addValue("A", new Double(2.0)); + + data.sortByValues(SortOrder.ASCENDING); + + // check key order + assertEquals(data.getKey(0), "C"); + assertEquals(data.getKey(1), "A"); + assertEquals(data.getKey(2), "D"); + assertEquals(data.getKey(3), "B"); + + // check retrieve value by key + assertEquals(data.getValue("A"), new Double(2.0)); + assertEquals(data.getValue("B"), null); + assertEquals(data.getValue("C"), new Double(1.0)); + assertEquals(data.getValue("D"), new Double(3.0)); + + // check retrieve value by index + assertEquals(data.getValue(0), new Double(1.0)); + assertEquals(data.getValue(1), new Double(2.0)); + assertEquals(data.getValue(2), new Double(3.0)); + assertEquals(data.getValue(3), null); + + } + + /** + * Tests sorting of data by key (descending). + */ + @Test + public void testSortByValueDescending() { + + DefaultKeyedValues data = new DefaultKeyedValues(); + data.addValue("C", new Double(1.0)); + data.addValue("B", null); + data.addValue("D", new Double(3.0)); + data.addValue("A", new Double(2.0)); + + data.sortByValues(SortOrder.DESCENDING); + + // check key order + assertEquals(data.getKey(0), "D"); + assertEquals(data.getKey(1), "A"); + assertEquals(data.getKey(2), "C"); + assertEquals(data.getKey(3), "B"); + + // check retrieve value by key + assertEquals(data.getValue("A"), new Double(2.0)); + assertEquals(data.getValue("B"), null); + assertEquals(data.getValue("C"), new Double(1.0)); + assertEquals(data.getValue("D"), new Double(3.0)); + + // check retrieve value by index + assertEquals(data.getValue(0), new Double(3.0)); + assertEquals(data.getValue(1), new Double(2.0)); + assertEquals(data.getValue(2), new Double(1.0)); + assertEquals(data.getValue(3), null); + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultKeyedValues v1 = new DefaultKeyedValues(); + v1.addValue("Key 1", new Double(23)); + v1.addValue("Key 2", null); + v1.addValue("Key 3", new Double(42)); + + DefaultKeyedValues v2 = (DefaultKeyedValues) + TestUtilities.serialised(v1); + assertEquals(v1, v2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DomainOrderTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DomainOrderTest.java new file mode 100755 index 0000000..1043e82 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/DomainOrderTest.java @@ -0,0 +1,97 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * DomainOrderTest.java + * -------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-May-2005 : Version 1 (DG); + * + */ + +package org.jfree.data; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertSame; + +/** + * Tests for the {@link DomainOrder} class. + */ +public class DomainOrderTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + assertEquals(DomainOrder.NONE, DomainOrder.NONE); + assertEquals(DomainOrder.ASCENDING, DomainOrder.ASCENDING); + assertEquals(DomainOrder.DESCENDING, DomainOrder.DESCENDING); + assertFalse(DomainOrder.NONE.equals(DomainOrder.ASCENDING)); + assertFalse(DomainOrder.NONE.equals(DomainOrder.DESCENDING)); + assertFalse(DomainOrder.NONE.equals(null)); + assertFalse(DomainOrder.ASCENDING.equals(DomainOrder.NONE)); + assertFalse(DomainOrder.ASCENDING.equals(DomainOrder.DESCENDING)); + assertFalse(DomainOrder.ASCENDING.equals(null)); + assertFalse(DomainOrder.DESCENDING.equals(DomainOrder.NONE)); + assertFalse(DomainOrder.DESCENDING.equals(DomainOrder.ASCENDING)); + assertFalse(DomainOrder.DESCENDING.equals(null)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + DomainOrder d1 = DomainOrder.ASCENDING; + DomainOrder d2 = DomainOrder.ASCENDING; + assertTrue(d1.equals(d2)); + int h1 = d1.hashCode(); + int h2 = d2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DomainOrder d1 = DomainOrder.ASCENDING; + DomainOrder d2 = (DomainOrder) TestUtilities.serialised(d1); + assertSame(d1, d2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/KeyToGroupMapTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/KeyToGroupMapTest.java new file mode 100755 index 0000000..0f40882 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/KeyToGroupMapTest.java @@ -0,0 +1,250 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * KeyToGroupMapTests.java + * ----------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Apr-2004 : Version 1 (DG); + * + */ + +package org.jfree.data; + +import org.jfree.chart.TestUtilities; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import org.junit.Test; + +/** + * Tests for the {@link KeyToGroupMap} class. + */ +public class KeyToGroupMapTest { + + /** + * Tests the mapKeyToGroup() method. + */ + @Test + public void testMapKeyToGroup() { + KeyToGroupMap m1 = new KeyToGroupMap("G1"); + + // map a key to the default group + m1.mapKeyToGroup("K1", "G1"); + assertEquals("G1", m1.getGroup("K1")); + + // map a key to a new group + m1.mapKeyToGroup("K2", "G2"); + assertEquals("G2", m1.getGroup("K2")); + + // clear a mapping + m1.mapKeyToGroup("K2", null); + assertEquals("G1", m1.getGroup("K2")); // after clearing, reverts to + // default group + + // check handling of null key + boolean pass = false; + try { + m1.mapKeyToGroup(null, "G1"); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Tests that the getGroupCount() method returns the correct values under + * various circumstances. + */ + @Test + public void testGroupCount() { + KeyToGroupMap m1 = new KeyToGroupMap("Default Group"); + + // a new map always has 1 group (the default group) + assertEquals(1, m1.getGroupCount()); + + // if the default group is not mapped to, it should still count towards + // the group count... + m1.mapKeyToGroup("C1", "G1"); + assertEquals(2, m1.getGroupCount()); + + // now when the default group is mapped to, it shouldn't increase the + // group count... + m1.mapKeyToGroup("C2", "Default Group"); + assertEquals(2, m1.getGroupCount()); + + // complicate things a little... + m1.mapKeyToGroup("C3", "Default Group"); + m1.mapKeyToGroup("C4", "G2"); + m1.mapKeyToGroup("C5", "G2"); + m1.mapKeyToGroup("C6", "Default Group"); + assertEquals(3, m1.getGroupCount()); + + // now overwrite group "G2"... + m1.mapKeyToGroup("C4", "G1"); + m1.mapKeyToGroup("C5", "G1"); + assertEquals(2, m1.getGroupCount()); + } + + /** + * Tests that the getKeyCount() method returns the correct values under + * various circumstances. + */ + @Test + public void testKeyCount() { + KeyToGroupMap m1 = new KeyToGroupMap("Default Group"); + + // a new map always has 1 group (the default group) + assertEquals(0, m1.getKeyCount("Default Group")); + + // simple case + m1.mapKeyToGroup("K1", "G1"); + assertEquals(1, m1.getKeyCount("G1")); + m1.mapKeyToGroup("K1", null); + assertEquals(0, m1.getKeyCount("G1")); + + // if there is an explicit mapping to the default group, it is counted + m1.mapKeyToGroup("K2", "Default Group"); + assertEquals(1, m1.getKeyCount("Default Group")); + + // complicate things a little... + m1.mapKeyToGroup("K3", "Default Group"); + m1.mapKeyToGroup("K4", "G2"); + m1.mapKeyToGroup("K5", "G2"); + m1.mapKeyToGroup("K6", "Default Group"); + assertEquals(3, m1.getKeyCount("Default Group")); + assertEquals(2, m1.getKeyCount("G2")); + + // now overwrite group "G2"... + m1.mapKeyToGroup("K4", "G1"); + m1.mapKeyToGroup("K5", "G1"); + assertEquals(2, m1.getKeyCount("G1")); + assertEquals(0, m1.getKeyCount("G2")); + } + + /** + * Tests the getGroupIndex() method. + */ + @Test + public void testGetGroupIndex() { + KeyToGroupMap m1 = new KeyToGroupMap("Default Group"); + + // the default group is always at index 0 + assertEquals(0, m1.getGroupIndex("Default Group")); + + // a non-existent group should return -1 + assertEquals(-1, m1.getGroupIndex("G3")); + + // indices are assigned in the order that groups are originally mapped + m1.mapKeyToGroup("K3", "G3"); + m1.mapKeyToGroup("K1", "G1"); + m1.mapKeyToGroup("K2", "G2"); + assertEquals(1, m1.getGroupIndex("G3")); + assertEquals(2, m1.getGroupIndex("G1")); + assertEquals(3, m1.getGroupIndex("G2")); + } + + /** + * Tests the getGroup() method. + */ + @Test + public void testGetGroup() { + KeyToGroupMap m1 = new KeyToGroupMap("Default Group"); + + // a key that hasn't been mapped should return the default group + assertEquals("Default Group", m1.getGroup("K1")); + + m1.mapKeyToGroup("K1", "G1"); + assertEquals("G1", m1.getGroup("K1")); + m1.mapKeyToGroup("K1", "G2"); + assertEquals("G2", m1.getGroup("K1")); + m1.mapKeyToGroup("K1", null); + assertEquals("Default Group", m1.getGroup("K1")); + + // a null argument should throw an exception + boolean pass = false; + try { + Comparable g = m1.getGroup(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + KeyToGroupMap m1 = new KeyToGroupMap("Default Group"); + KeyToGroupMap m2 = new KeyToGroupMap("Default Group"); + assertTrue(m1.equals(m2)); + assertTrue(m2.equals(m1)); + + m1.mapKeyToGroup("K1", "G1"); + assertFalse(m1.equals(m2)); + m2.mapKeyToGroup("K1", "G1"); + assertTrue(m1.equals(m2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + KeyToGroupMap m1 = new KeyToGroupMap("Test"); + m1.mapKeyToGroup("K1", "G1"); + KeyToGroupMap m2 = (KeyToGroupMap) m1.clone(); + assertTrue(m1 != m2); + assertTrue(m1.getClass() == m2.getClass()); + assertTrue(m1.equals(m2)); + + // a small check for independence + m1.mapKeyToGroup("K1", "G2"); + assertFalse(m1.equals(m2)); + m2.mapKeyToGroup("K1", "G2"); + assertTrue(m1.equals(m2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + KeyToGroupMap m1 = new KeyToGroupMap("Test"); + KeyToGroupMap m2 = (KeyToGroupMap) TestUtilities.serialised(m1); + assertEquals(m1, m2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/KeyedObjectTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/KeyedObjectTest.java new file mode 100755 index 0000000..6e4cf34 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/KeyedObjectTest.java @@ -0,0 +1,131 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * KeyedObjectTest.java + * -------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Jan-2004 : Version 1 (DG); + * 28-Sep-2007 : Added testCloning2() (DG); + * + */ + +package org.jfree.data; + +import java.util.ArrayList; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.DefaultPieDataset; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import org.junit.Test; + +/** + * Tests for the {@link KeyedObject} class. + */ +public class KeyedObjectTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + KeyedObject ko1 = new KeyedObject("Test", "Object"); + KeyedObject ko2 = new KeyedObject("Test", "Object"); + assertTrue(ko1.equals(ko2)); + assertTrue(ko2.equals(ko1)); + + ko1 = new KeyedObject("Test 1", "Object"); + ko2 = new KeyedObject("Test 2", "Object"); + assertFalse(ko1.equals(ko2)); + + ko1 = new KeyedObject("Test", "Object 1"); + ko2 = new KeyedObject("Test", "Object 2"); + assertFalse(ko1.equals(ko2)); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + KeyedObject ko1 = new KeyedObject("Test", "Object"); + KeyedObject ko2 = (KeyedObject) ko1.clone(); + assertTrue(ko1 != ko2); + assertTrue(ko1.getClass() == ko2.getClass()); + assertTrue(ko1.equals(ko2)); + } + + /** + * Confirm special features of cloning. + */ + @Test + public void testCloning2() throws CloneNotSupportedException { + // case 1 - object is mutable but not PublicCloneable + Object obj1 = new ArrayList(); + KeyedObject ko1 = new KeyedObject("Test", obj1); + KeyedObject ko2 = (KeyedObject) ko1.clone(); + assertTrue(ko1 != ko2); + assertTrue(ko1.getClass() == ko2.getClass()); + assertTrue(ko1.equals(ko2)); + + // the clone contains a reference to the original object + assertTrue(ko2.getObject() == obj1); + + // CASE 2 - object is mutable AND PublicCloneable + obj1 = new DefaultPieDataset(); + ko1 = new KeyedObject("Test", obj1); + ko2 = (KeyedObject) ko1.clone(); + assertTrue(ko1 != ko2); + assertTrue(ko1.getClass() == ko2.getClass()); + assertTrue(ko1.equals(ko2)); + + // the clone contains a reference to a CLONE of the original object + assertTrue(ko2.getObject() != obj1); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + KeyedObject ko1 = new KeyedObject("Test", "Object"); + KeyedObject ko2 = (KeyedObject) TestUtilities.serialised(ko1); + assertEquals(ko1, ko2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/KeyedObjects2DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/KeyedObjects2DTest.java new file mode 100755 index 0000000..0057393 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/KeyedObjects2DTest.java @@ -0,0 +1,392 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * KeyedObjects2DTest.java + * ----------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 01-Mar-2004 : Version 1 (DG); + * 28-Sep-2007 : Added testEquals() and enhanced testClone() (DG); + * 03-Oct-2007 : Added new tests (DG); + * + */ + +package org.jfree.data; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; + +/** + * Tests for the {@link KeyedObjects2D} class. + */ +public class KeyedObjects2DTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + KeyedObjects2D k1 = new KeyedObjects2D(); + KeyedObjects2D k2 = new KeyedObjects2D(); + assertTrue(k1.equals(k2)); + assertTrue(k2.equals(k1)); + + k1.addObject(new Integer(99), "R1", "C1"); + assertFalse(k1.equals(k2)); + k2.addObject(new Integer(99), "R1", "C1"); + assertTrue(k1.equals(k2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + KeyedObjects2D o1 = new KeyedObjects2D(); + o1.setObject(new Integer(1), "V1", "C1"); + o1.setObject(null, "V2", "C1"); + o1.setObject(new Integer(3), "V3", "C2"); + KeyedObjects2D o2 = (KeyedObjects2D) o1.clone(); + assertTrue(o1 != o2); + assertTrue(o1.getClass() == o2.getClass()); + assertTrue(o1.equals(o2)); + + // check independence + o1.addObject("XX", "R1", "C1"); + assertFalse(o1.equals(o2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + KeyedObjects2D ko2D1 = new KeyedObjects2D(); + ko2D1.addObject(new Double(234.2), "Row1", "Col1"); + ko2D1.addObject(null, "Row1", "Col2"); + ko2D1.addObject(new Double(345.9), "Row2", "Col1"); + ko2D1.addObject(new Double(452.7), "Row2", "Col2"); + + KeyedObjects2D ko2D2 = (KeyedObjects2D) TestUtilities.serialised(ko2D1); + assertEquals(ko2D1, ko2D2); + } + + /** + * Some checks for the getValue(int, int) method. + */ + @Test + public void testGetValueByIndex() { + KeyedObjects2D data = new KeyedObjects2D(); + data.addObject("Obj1", "R1", "C1"); + data.addObject("Obj2", "R2", "C2"); + assertEquals("Obj1", data.getObject(0, 0)); + assertEquals("Obj2", data.getObject(1, 1)); + assertNull(data.getObject(0, 1)); + assertNull(data.getObject(1, 0)); + + // check invalid indices + boolean pass = false; + try { + data.getObject(-1, 0); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + data.getObject(0, -1); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + data.getObject(2, 0); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + data.getObject(0, 2); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getValue(Comparable, Comparable) method. + */ + @Test + public void testGetValueByKey() { + KeyedObjects2D data = new KeyedObjects2D(); + data.addObject("Obj1", "R1", "C1"); + data.addObject("Obj2", "R2", "C2"); + assertEquals("Obj1", data.getObject("R1", "C1")); + assertEquals("Obj2", data.getObject("R2", "C2")); + assertNull(data.getObject("R1", "C2")); + assertNull(data.getObject("R2", "C1")); + + // check invalid indices + boolean pass = false; + try { + data.getObject("XX", "C1"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + data.getObject("R1", "XX"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + data.getObject("XX", "C1"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + data.getObject("R1", "XX"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the setObject(Object, Comparable, Comparable) method. + */ + @Test + public void testSetObject() { + KeyedObjects2D data = new KeyedObjects2D(); + data.setObject("Obj1", "R1", "C1"); + data.setObject("Obj2", "R2", "C2"); + assertEquals("Obj1", data.getObject("R1", "C1")); + assertEquals("Obj2", data.getObject("R2", "C2")); + assertNull(data.getObject("R1", "C2")); + assertNull(data.getObject("R2", "C1")); + + // confirm overwriting an existing value + data.setObject("ABC", "R2", "C2"); + assertEquals("ABC", data.getObject("R2", "C2")); + + // try null keys + boolean pass = false; + try { + data.setObject("X", null, "C1"); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + data.setObject("X", "R1", null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the removeRow(int) method. + */ + @Test + public void testRemoveRowByIndex() { + KeyedObjects2D data = new KeyedObjects2D(); + data.setObject("Obj1", "R1", "C1"); + data.setObject("Obj2", "R2", "C2"); + data.removeRow(0); + assertEquals(1, data.getRowCount()); + assertEquals("Obj2", data.getObject(0, 1)); + + // try negative row index + boolean pass = false; + try { + data.removeRow(-1); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + + // try row index too high + pass = false; + try { + data.removeRow(data.getRowCount()); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the removeColumn(int) method. + */ + @Test + public void testRemoveColumnByIndex() { + KeyedObjects2D data = new KeyedObjects2D(); + data.setObject("Obj1", "R1", "C1"); + data.setObject("Obj2", "R2", "C2"); + data.removeColumn(0); + assertEquals(1, data.getColumnCount()); + assertEquals("Obj2", data.getObject(1, 0)); + + // try negative column index + boolean pass = false; + try { + data.removeColumn(-1); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + + // try column index too high + pass = false; + try { + data.removeColumn(data.getColumnCount()); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the removeRow(Comparable) method. + */ + @Test + public void testRemoveRowByKey() { + KeyedObjects2D data = new KeyedObjects2D(); + data.setObject("Obj1", "R1", "C1"); + data.setObject("Obj2", "R2", "C2"); + data.removeRow("R2"); + assertEquals(1, data.getRowCount()); + assertEquals("Obj1", data.getObject(0, 0)); + + // try unknown row key + boolean pass = false; + try { + data.removeRow("XXX"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + // try null row key + pass = false; + try { + data.removeRow(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the removeColumn(Comparable) method. + */ + @Test + public void testRemoveColumnByKey() { + KeyedObjects2D data = new KeyedObjects2D(); + data.setObject("Obj1", "R1", "C1"); + data.setObject("Obj2", "R2", "C2"); + data.removeColumn("C2"); + assertEquals(1, data.getColumnCount()); + assertEquals("Obj1", data.getObject(0, 0)); + + // try unknown column key + boolean pass = false; + try { + data.removeColumn("XXX"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + // try null column key + pass = false; + try { + data.removeColumn(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * A simple check for the removeValue() method. + */ + @Test + public void testRemoveValue() { + KeyedObjects2D data = new KeyedObjects2D(); + data.setObject("Obj1", "R1", "C1"); + data.setObject("Obj2", "R2", "C2"); + data.removeObject("R2", "C2"); + assertEquals(1, data.getRowCount()); + assertEquals(1, data.getColumnCount()); + assertEquals("Obj1", data.getObject(0, 0)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/KeyedObjectsTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/KeyedObjectsTest.java new file mode 100755 index 0000000..bfa4ba1 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/KeyedObjectsTest.java @@ -0,0 +1,359 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * KeyedObjectsTest.java + * --------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Jan-2004 : Version 1 (DG); + * 28-Sep-2007 : Added testCloning2() (DG); + * 03-Oct-2007 : New tests (DG); + * + */ + +package org.jfree.data; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; +import java.util.ArrayList; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.DefaultPieDataset; +import org.junit.Test; + +/** + * Tests for the {@link KeyedObjects} class. + */ +public class KeyedObjectsTest { + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + KeyedObjects ko1 = new KeyedObjects(); + ko1.addObject("V1", new Integer(1)); + ko1.addObject("V2", null); + ko1.addObject("V3", new Integer(3)); + KeyedObjects ko2 = (KeyedObjects) ko1.clone(); + assertTrue(ko1 != ko2); + assertTrue(ko1.getClass() == ko2.getClass()); + assertTrue(ko1.equals(ko2)); + } + + /** + * Confirm special features of cloning. + */ + @Test + public void testCloning2() throws CloneNotSupportedException { + // case 1 - object is mutable but not PublicCloneable + Object obj1 = new ArrayList(); + KeyedObjects ko1 = new KeyedObjects(); + ko1.addObject("K1", obj1); + KeyedObjects ko2 = (KeyedObjects) ko1.clone(); + assertTrue(ko1 != ko2); + assertTrue(ko1.getClass() == ko2.getClass()); + assertTrue(ko1.equals(ko2)); + + // the clone contains a reference to the original object + assertTrue(ko2.getObject("K1") == obj1); + + // CASE 2 - object is mutable AND PublicCloneable + obj1 = new DefaultPieDataset(); + ko1 = new KeyedObjects(); + ko1.addObject("K1", obj1); + ko2 = (KeyedObjects) ko1.clone(); + assertTrue(ko1 != ko2); + assertTrue(ko1.getClass() == ko2.getClass()); + assertTrue(ko1.equals(ko2)); + + // the clone contains a reference to a CLONE of the original object + assertTrue(ko2.getObject("K1") != obj1); + } + + /** + * Check that inserting and retrieving values works as expected. + */ + @Test + public void testInsertAndRetrieve() { + + KeyedObjects data = new KeyedObjects(); + data.addObject("A", new Double(1.0)); + data.addObject("B", new Double(2.0)); + data.addObject("C", new Double(3.0)); + data.addObject("D", null); + + // check key order + assertEquals(data.getKey(0), "A"); + assertEquals(data.getKey(1), "B"); + assertEquals(data.getKey(2), "C"); + assertEquals(data.getKey(3), "D"); + + // check retrieve value by key + assertEquals(data.getObject("A"), new Double(1.0)); + assertEquals(data.getObject("B"), new Double(2.0)); + assertEquals(data.getObject("C"), new Double(3.0)); + assertEquals(data.getObject("D"), null); + + boolean pass = false; + try { + data.getObject("Not a key"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + // check retrieve value by index + assertEquals(data.getObject(0), new Double(1.0)); + assertEquals(data.getObject(1), new Double(2.0)); + assertEquals(data.getObject(2), new Double(3.0)); + assertEquals(data.getObject(3), null); + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + KeyedObjects ko1 = new KeyedObjects(); + ko1.addObject("Key 1", "Object 1"); + ko1.addObject("Key 2", null); + ko1.addObject("Key 3", "Object 2"); + KeyedObjects ko2 = (KeyedObjects) TestUtilities.serialised(ko1); + assertEquals(ko1, ko2); + } + + /** + * Simple checks for the getObject(int) method. + */ + @Test + public void testGetObject() { + // retrieve an item + KeyedObjects ko1 = new KeyedObjects(); + ko1.addObject("Key 1", "Object 1"); + ko1.addObject("Key 2", null); + ko1.addObject("Key 3", "Object 2"); + assertEquals("Object 1", ko1.getObject(0)); + assertNull(ko1.getObject(1)); + assertEquals("Object 2", ko1.getObject(2)); + + // request with a negative index + boolean pass = false; + try { + ko1.getObject(-1); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + + // request width index == itemCount + pass = false; + try { + ko1.getObject(3); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Simple checks for the getKey(int) method. + */ + @Test + public void testGetKey() { + // retrieve an item + KeyedObjects ko1 = new KeyedObjects(); + ko1.addObject("Key 1", "Object 1"); + ko1.addObject("Key 2", null); + ko1.addObject("Key 3", "Object 2"); + assertEquals("Key 1", ko1.getKey(0)); + assertEquals("Key 2", ko1.getKey(1)); + assertEquals("Key 3", ko1.getKey(2)); + + // request with a negative index + boolean pass = false; + try { + ko1.getKey(-1); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + + // request width index == itemCount + pass = false; + try { + ko1.getKey(3); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Simple checks for the getIndex(Comparable) method. + */ + @Test + public void testGetIndex() { + KeyedObjects ko1 = new KeyedObjects(); + ko1.addObject("Key 1", "Object 1"); + ko1.addObject("Key 2", null); + ko1.addObject("Key 3", "Object 2"); + assertEquals(0, ko1.getIndex("Key 1")); + assertEquals(1, ko1.getIndex("Key 2")); + assertEquals(2, ko1.getIndex("Key 3")); + + // check null argument + boolean pass = false; + try { + ko1.getIndex(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the setObject(Comparable, Object) method. + */ + @Test + public void testSetObject() { + KeyedObjects ko1 = new KeyedObjects(); + ko1.setObject("Key 1", "Object 1"); + ko1.setObject("Key 2", null); + ko1.setObject("Key 3", "Object 2"); + + assertEquals("Object 1", ko1.getObject("Key 1")); + assertEquals(null, ko1.getObject("Key 2")); + assertEquals("Object 2", ko1.getObject("Key 3")); + + // replace an existing value + ko1.setObject("Key 2", "AAA"); + ko1.setObject("Key 3", "BBB"); + assertEquals("AAA", ko1.getObject("Key 2")); + assertEquals("BBB", ko1.getObject("Key 3")); + + // try a null key - should throw an exception + boolean pass = false; + try { + ko1.setObject(null, "XX"); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the removeValue() methods. + */ + @Test + public void testRemoveValue() { + KeyedObjects ko1 = new KeyedObjects(); + ko1.setObject("Key 1", "Object 1"); + ko1.setObject("Key 2", null); + ko1.setObject("Key 3", "Object 2"); + + ko1.removeValue(1); + assertEquals(2, ko1.getItemCount()); + assertEquals(1, ko1.getIndex("Key 3")); + + ko1.removeValue("Key 1"); + assertEquals(1, ko1.getItemCount()); + assertEquals(0, ko1.getIndex("Key 3")); + + // try unknown key + boolean pass = false; + try { + ko1.removeValue("UNKNOWN"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + // try null argument + pass = false; + try { + ko1.removeValue(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the removeValue(int) method. + */ + @Test + public void testRemoveValueInt() { + KeyedObjects ko1 = new KeyedObjects(); + ko1.setObject("Key 1", "Object 1"); + ko1.setObject("Key 2", null); + ko1.setObject("Key 3", "Object 2"); + + ko1.removeValue(1); + assertEquals(2, ko1.getItemCount()); + assertEquals(1, ko1.getIndex("Key 3")); + + + // try negative key index + boolean pass = false; + try { + ko1.removeValue(-1); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + + // try key index == itemCount + pass = false; + try { + ko1.removeValue(2); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/RangeTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/RangeTest.java new file mode 100755 index 0000000..542b610 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/RangeTest.java @@ -0,0 +1,349 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * RangeTest.java + * -------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Sergei Ivanov; + * + * Changes + * ------- + * 14-Aug-2003 : Version 1 (DG); + * 18-Dec-2007 : Additional tests from Sergei Ivanov (DG); + * 08-Jan-2012 : Added test for combine() method (DG); + * + */ + +package org.jfree.data; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link Range} class. + */ +public class RangeTest { + + /** + * Confirm that the constructor initializes all the required fields. + */ + @Test + public void testConstructor() { + Range r1 = new Range(0.1, 1000.0); + assertEquals(r1.getLowerBound(), 0.1, 0.0d); + assertEquals(r1.getUpperBound(), 1000.0, 0.0d); + + try { + /*Range r2 =*/ new Range(10.0, 0.0); + fail("Lower bound cannot be greater than the upper"); + } + catch (Exception e) { + // expected + } + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + Range r1 = new Range(0.0, 1.0); + Range r2 = new Range(0.0, 1.0); + assertEquals(r1, r2); + assertEquals(r2, r1); + + r1 = new Range(0.0, 1.0); + r2 = new Range(0.5, 1.0); + assertFalse(r1.equals(r2)); + + r1 = new Range(0.0, 1.0); + r2 = new Range(0.0, 2.0); + assertFalse(r1.equals(r2)); + + // a Range object cannot be equal to a different object type + assertFalse(r1.equals(new Double(0.0))); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + Range a1 = new Range(1.0, 100.0); + Range a2 = new Range(1.0, 100.0); + assertEquals(a1.hashCode(), a2.hashCode()); + + a1 = new Range(-100.0, 2.0); + a2 = new Range(-100.0, 2.0); + assertEquals(a1.hashCode(), a2.hashCode()); + } + + /** + * Simple tests for the contains() method. + */ + @Test + public void testContains() { + Range r1 = new Range(0.0, 1.0); + assertFalse(r1.contains(Double.NaN)); + assertFalse(r1.contains(Double.NEGATIVE_INFINITY)); + assertFalse(r1.contains(-1.0)); + assertTrue(r1.contains(0.0)); + assertTrue(r1.contains(0.5)); + assertTrue(r1.contains(1.0)); + assertFalse(r1.contains(2.0)); + assertFalse(r1.contains(Double.POSITIVE_INFINITY)); + } + + /** + * Tests the constrain() method for various values. + */ + @Test + public void testConstrain() { + Range r1 = new Range(0.0, 1.0); + + double d = r1.constrain(0.5); + assertEquals(0.5, d, 0.0000001); + + d = r1.constrain(0.0); + assertEquals(0.0, d, 0.0000001); + + d = r1.constrain(1.0); + assertEquals(1.0, d, 0.0000001); + + d = r1.constrain(-1.0); + assertEquals(0.0, d, 0.0000001); + + d = r1.constrain(2.0); + assertEquals(1.0, d, 0.0000001); + + d = r1.constrain(Double.POSITIVE_INFINITY); + assertEquals(1.0, d, 0.0000001); + + d = r1.constrain(Double.NEGATIVE_INFINITY); + assertEquals(0.0, d, 0.0000001); + + d = r1.constrain(Double.NaN); + assertTrue(Double.isNaN(d)); + } + + /** + * Simple tests for the intersects() method. + */ + @Test + public void testIntersects() { + Range r1 = new Range(0.0, 1.0); + assertFalse(r1.intersects(-2.0, -1.0)); + assertFalse(r1.intersects(-2.0, 0.0)); + assertTrue(r1.intersects(-2.0, 0.5)); + assertTrue(r1.intersects(-2.0, 1.0)); + assertTrue(r1.intersects(-2.0, 1.5)); + assertTrue(r1.intersects(0.0, 0.5)); + assertTrue(r1.intersects(0.0, 1.0)); + assertTrue(r1.intersects(0.0, 1.5)); + assertTrue(r1.intersects(0.5, 0.6)); + assertTrue(r1.intersects(0.5, 1.0)); + assertTrue(r1.intersects(0.5, 1.5)); + assertFalse(r1.intersects(1.0, 1.1)); + assertFalse(r1.intersects(1.5, 2.0)); + } + + /** + * A simple test for the expand() method. + */ + @Test + public void testExpand() { + Range r1 = new Range(0.0, 100.0); + Range r2 = Range.expand(r1, 0.10, 0.10); + assertEquals(-10.0, r2.getLowerBound(), 0.001); + assertEquals(110.0, r2.getUpperBound(), 0.001); + + // Expand by 0% does not change the range + r2 = Range.expand(r1, 0.0, 0.0); + assertEquals(r1, r2); + + try { + Range.expand(null, 0.1, 0.1); + fail("Null value is accepted"); + } + catch (Exception e) { + } + + // Lower > upper: mid point is used + r2 = Range.expand(r1, -0.8, -0.5); + assertEquals(65.0, r2.getLowerBound(), 0.001); + assertEquals(65.0, r2.getUpperBound(), 0.001); + } + + /** + * A simple test for the scale() method. + */ + @Test + public void testShift() { + Range r1 = new Range(10.0, 20.0); + Range r2 = Range.shift(r1, 20.0); + assertEquals(30.0, r2.getLowerBound(), 0.001); + assertEquals(40.0, r2.getUpperBound(), 0.001); + + r1 = new Range(0.0, 100.0); + r2 = Range.shift(r1, -50.0, true); + assertEquals(-50.0, r2.getLowerBound(), 0.001); + assertEquals(50.0, r2.getUpperBound(), 0.001); + + r1 = new Range(-10.0, 20.0); + r2 = Range.shift(r1, 20.0, true); + assertEquals(10.0, r2.getLowerBound(), 0.001); + assertEquals(40.0, r2.getUpperBound(), 0.001); + + r1 = new Range(-10.0, 20.0); + r2 = Range.shift(r1, -30.0, true); + assertEquals(-40.0, r2.getLowerBound(), 0.001); + assertEquals(-10.0, r2.getUpperBound(), 0.001); + + r1 = new Range(-10.0, 20.0); + r2 = Range.shift(r1, 20.0, false); + assertEquals(0.0, r2.getLowerBound(), 0.001); + assertEquals(40.0, r2.getUpperBound(), 0.001); + + r1 = new Range(-10.0, 20.0); + r2 = Range.shift(r1, -30.0, false); + assertEquals(-40.0, r2.getLowerBound(), 0.001); + assertEquals(0.0, r2.getUpperBound(), 0.001); + + // Shifting with a delta of 0 does not change the range + r2 = Range.shift(r1, 0.0); + assertEquals(r1, r2); + + try { + Range.shift(null, 0.1); + fail("Null value is accepted"); + } + catch (Exception e) { + } + } + + /** + * A simple test for the scale() method. + */ + @Test + public void testScale() { + Range r1 = new Range(0.0, 100.0); + Range r2 = Range.scale(r1, 0.10); + assertEquals(0.0, r2.getLowerBound(), 0.001); + assertEquals(10.0, r2.getUpperBound(), 0.001); + + r1 = new Range(-10.0, 100.0); + r2 = Range.scale(r1, 2.0); + assertEquals(-20.0, r2.getLowerBound(), 0.001); + assertEquals(200.0, r2.getUpperBound(), 0.001); + + // Scaling with a factor of 1 does not change the range + r2 = Range.scale(r1, 1.0); + assertEquals(r1, r2); + + try { + Range.scale(null, 0.1); + fail("Null value is accepted"); + } + catch (Exception e) { + } + + try { + Range.scale(r1, -0.5); + fail("Negative factor accepted"); + } + catch (Exception e) { + } + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Range r1 = new Range(25.0, 133.42); + Range r2 = (Range) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the combine method. + */ + @Test + public void testCombine() { + Range r1 = new Range(1.0, 2.0); + Range r2 = new Range(1.5, 2.5); + + assertNull(Range.combine(null, null)); + assertEquals(r1, Range.combine(r1, null)); + assertEquals(r2, Range.combine(null, r2)); + assertEquals(new Range(1.0, 2.5), Range.combine(r1, r2)); + + Range r3 = new Range(Double.NaN, 1.3); + Range rr = Range.combine(r1, r3); + assertTrue(Double.isNaN(rr.getLowerBound())); + assertEquals(2.0, rr.getUpperBound(), EPSILON); + + Range r4 = new Range(1.7, Double.NaN); + rr = Range.combine(r4, r1); + assertEquals(1.0, rr.getLowerBound(), EPSILON); + assertTrue(Double.isNaN(rr.getUpperBound())); + } + + /** + * Some checks for the combineIgnoringNaN() method. + */ + @Test + public void testCombineIgnoringNaN() { + Range r1 = new Range(1.0, 2.0); + Range r2 = new Range(1.5, 2.5); + + assertNull(Range.combineIgnoringNaN(null, null)); + assertEquals(r1, Range.combineIgnoringNaN(r1, null)); + assertEquals(r2, Range.combineIgnoringNaN(null, r2)); + assertEquals(new Range(1.0, 2.5), Range.combineIgnoringNaN(r1, r2)); + + Range r3 = new Range(Double.NaN, 1.3); + Range rr = Range.combineIgnoringNaN(r1, r3); + assertEquals(1.0, rr.getLowerBound(), EPSILON); + assertEquals(2.0, rr.getUpperBound(), EPSILON); + + Range r4 = new Range(1.7, Double.NaN); + rr = Range.combineIgnoringNaN(r4, r1); + assertEquals(1.0, rr.getLowerBound(), EPSILON); + assertEquals(2.0, rr.getUpperBound(), EPSILON); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/RangeTypeTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/RangeTypeTest.java new file mode 100755 index 0000000..6698780 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/RangeTypeTest.java @@ -0,0 +1,97 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * RangeTypeTest.java + * ------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 19-May-2005 : Version 1 (DG); + * + */ + +package org.jfree.data; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertSame; +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link RangeType} class. + */ +public class RangeTypeTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + assertEquals(RangeType.FULL, RangeType.FULL); + assertEquals(RangeType.NEGATIVE, RangeType.NEGATIVE); + assertEquals(RangeType.POSITIVE, RangeType.POSITIVE); + assertFalse(RangeType.FULL.equals(RangeType.NEGATIVE)); + assertFalse(RangeType.FULL.equals(RangeType.POSITIVE)); + assertFalse(RangeType.FULL.equals(null)); + assertFalse(RangeType.NEGATIVE.equals(RangeType.FULL)); + assertFalse(RangeType.NEGATIVE.equals(RangeType.POSITIVE)); + assertFalse(RangeType.NEGATIVE.equals(null)); + assertFalse(RangeType.POSITIVE.equals(RangeType.NEGATIVE)); + assertFalse(RangeType.POSITIVE.equals(RangeType.FULL)); + assertFalse(RangeType.POSITIVE.equals(null)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashCode() { + RangeType r1 = RangeType.FULL; + RangeType r2 = RangeType.FULL; + assertTrue(r1.equals(r2)); + int h1 = r1.hashCode(); + int h2 = r2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + RangeType r1 = RangeType.FULL; + RangeType r2 = (RangeType) TestUtilities.serialised(r1); + assertSame(r1, r2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/category/CategoryToPieDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/category/CategoryToPieDatasetTest.java new file mode 100755 index 0000000..d1c0cd3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/category/CategoryToPieDatasetTest.java @@ -0,0 +1,220 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * CategoryToPieDatasetTests.java + * ------------------------------ + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 26-Jul-2006 : Version 1 (DG); + * 01-Aug-2006 : Added testGetIndex() method (DG); + * + */ + +package org.jfree.data.category; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.DefaultPieDataset; +import org.jfree.util.TableOrder; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +/** + * Tests for the {@link CategoryToPieDataset} class. + */ +public class CategoryToPieDatasetTest { + + /** + * Some tests for the constructor. + */ + @Test + public void testConstructor() { + // try a null source + CategoryToPieDataset p1 = new CategoryToPieDataset(null, + TableOrder.BY_COLUMN, 0); + assertNull(p1.getUnderlyingDataset()); + assertEquals(p1.getItemCount(), 0); + assertTrue(p1.getKeys().isEmpty()); + assertNull(p1.getValue("R1")); + } + + /** + * Some checks for the getValue() method. + */ + @Test + public void testGetValue() { + DefaultCategoryDataset underlying = new DefaultCategoryDataset(); + underlying.addValue(1.1, "R1", "C1"); + underlying.addValue(2.2, "R1", "C2"); + CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, + TableOrder.BY_ROW, 0); + assertEquals(d1.getValue("C1"), new Double(1.1)); + assertEquals(d1.getValue("C2"), new Double(2.2)); + + // check negative index throws exception + try { + /* Number n = */ d1.getValue(-1); + fail("Expected IndexOutOfBoundsException."); + } + catch (IndexOutOfBoundsException e) { + // this is expected + } + + // check index == getItemCount() throws exception + try { + /* Number n = */ d1.getValue(d1.getItemCount()); + fail("Expected IndexOutOfBoundsException."); + } + catch (IndexOutOfBoundsException e) { + // this is expected + } + + // test null source + CategoryToPieDataset p1 = new CategoryToPieDataset(null, + TableOrder.BY_COLUMN, 0); + try { + /* Number n = */ p1.getValue(0); + fail("Expected IndexOutOfBoundsException."); + } + catch (IndexOutOfBoundsException e) { + // this is expected + } + } + + /** + * Some checks for the getKey(int) method. + */ + @Test + public void testGetKey() { + DefaultCategoryDataset underlying = new DefaultCategoryDataset(); + underlying.addValue(1.1, "R1", "C1"); + underlying.addValue(2.2, "R1", "C2"); + CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, + TableOrder.BY_ROW, 0); + assertEquals(d1.getKey(0), "C1"); + assertEquals(d1.getKey(1), "C2"); + + // check negative index throws exception + try { + /* Number n = */ d1.getKey(-1); + fail("Expected IndexOutOfBoundsException."); + } + catch (IndexOutOfBoundsException e) { + // this is expected + } + + // check index == getItemCount() throws exception + try { + /* Number n = */ d1.getKey(d1.getItemCount()); + fail("Expected IndexOutOfBoundsException."); + } + catch (IndexOutOfBoundsException e) { + // this is expected + } + + // test null source + CategoryToPieDataset p1 = new CategoryToPieDataset(null, + TableOrder.BY_COLUMN, 0); + try { + /* Number n = */ p1.getKey(0); + fail("Expected IndexOutOfBoundsException."); + } + catch (IndexOutOfBoundsException e) { + // this is expected + } + } + + /** + * Some checks for the getIndex() method. + */ + @Test + public void testGetIndex() { + DefaultCategoryDataset underlying = new DefaultCategoryDataset(); + underlying.addValue(1.1, "R1", "C1"); + underlying.addValue(2.2, "R1", "C2"); + CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, + TableOrder.BY_ROW, 0); + assertEquals(0, d1.getIndex("C1")); + assertEquals(1, d1.getIndex("C2")); + assertEquals(-1, d1.getIndex("XX")); + + // try null + boolean pass = false; + try { + d1.getIndex(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * For datasets, the equals() method just checks keys and values. + */ + @Test + public void testEquals() { + DefaultCategoryDataset underlying = new DefaultCategoryDataset(); + underlying.addValue(1.1, "R1", "C1"); + underlying.addValue(2.2, "R1", "C2"); + CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, + TableOrder.BY_COLUMN, 1); + DefaultPieDataset d2 = new DefaultPieDataset(); + d2.setValue("R1", 2.2); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultCategoryDataset underlying = new DefaultCategoryDataset(); + underlying.addValue(1.1, "R1", "C1"); + underlying.addValue(2.2, "R1", "C2"); + CategoryToPieDataset d1 = new CategoryToPieDataset(underlying, + TableOrder.BY_COLUMN, 1); + CategoryToPieDataset d2 = (CategoryToPieDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + + // regular equality for the datasets doesn't check the fields, just + // the data values...so let's check some more things... + assertEquals(d1.getUnderlyingDataset(), d2.getUnderlyingDataset()); + assertEquals(d1.getExtractType(), d2.getExtractType()); + assertEquals(d1.getExtractIndex(), d2.getExtractIndex()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/category/DefaultCategoryDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/category/DefaultCategoryDatasetTest.java new file mode 100755 index 0000000..44b274a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/category/DefaultCategoryDatasetTest.java @@ -0,0 +1,377 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------- + * DefaultCategoryDatasetTests.java + * -------------------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Mar-2004 : Version 1 (DG); + * 08-Mar-2007 : Added testCloning() (DG); + * 21-Nov-2007 : Added testBug1835955() method (DG); + * 09-May-2008 : Added testPublicCloneable() (DG); + * + */ + +package org.jfree.data.category; + +import org.jfree.chart.TestUtilities; +import org.jfree.data.UnknownKeyException; +import org.jfree.util.PublicCloneable; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertFalse; +import org.junit.Test; + +/** + * Tests for the {@link DefaultCategoryDataset} class. + */ +public class DefaultCategoryDatasetTest { + + /** + * Some checks for the getValue() method. + */ + @Test + public void testGetValue() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(1.0, "R1", "C1"); + assertEquals(new Double(1.0), d.getValue("R1", "C1")); + boolean pass = false; + try { + d.getValue("XX", "C1"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + d.getValue("R1", "XX"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * A simple check for the getValue(int, int) method. + */ + public void testGetValue2() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + boolean pass = false; + try { + /* Number n =*/ d.getValue(0, 0); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the incrementValue() method. + */ + public void testIncrementValue() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(1.0, "R1", "C1"); + d.incrementValue(2.0, "R1", "C1"); + assertEquals(new Double(3.0), d.getValue("R1", "C1")); + + // increment a null value + d.addValue(null, "R2", "C1"); + d.incrementValue(2.0, "R2", "C1"); + assertEquals(new Double(2.0), d.getValue("R2", "C1")); + + // increment an unknown row + boolean pass = false; + try { + d.incrementValue(1.0, "XX", "C1"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + // increment an unknown column + pass = false; + try { + d.incrementValue(1.0, "R1", "XX"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some tests for the getRowCount() method. + */ + public void testGetRowCount() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + assertTrue(d.getRowCount() == 0); + + d.addValue(1.0, "R1", "C1"); + assertTrue(d.getRowCount() == 1); + + d.addValue(1.0, "R2", "C1"); + assertTrue(d.getRowCount() == 2); + + d.addValue(2.0, "R2", "C1"); + assertTrue(d.getRowCount() == 2); + + // a row of all null values is still counted... + d.setValue(null, "R2", "C1"); + assertTrue(d.getRowCount() == 2); + } + + /** + * Some tests for the getColumnCount() method. + */ + public void testGetColumnCount() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + assertTrue(d.getColumnCount() == 0); + + d.addValue(1.0, "R1", "C1"); + assertTrue(d.getColumnCount() == 1); + + d.addValue(1.0, "R1", "C2"); + assertTrue(d.getColumnCount() == 2); + + d.addValue(2.0, "R1", "C2"); + assertTrue(d.getColumnCount() == 2); + + // a column of all null values is still counted... + d.setValue(null, "R1", "C2"); + assertTrue(d.getColumnCount() == 2); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + public void testEquals() { + DefaultCategoryDataset d1 = new DefaultCategoryDataset(); + d1.setValue(23.4, "R1", "C1"); + DefaultCategoryDataset d2 = new DefaultCategoryDataset(); + d2.setValue(23.4, "R1", "C1"); + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + d1.setValue(36.5, "R1", "C2"); + assertFalse(d1.equals(d2)); + d2.setValue(36.5, "R1", "C2"); + assertTrue(d1.equals(d2)); + + d1.setValue(null, "R1", "C1"); + assertFalse(d1.equals(d2)); + d2.setValue(null, "R1", "C1"); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + public void testSerialization() { + DefaultCategoryDataset d1 = new DefaultCategoryDataset(); + d1.setValue(23.4, "R1", "C1"); + DefaultCategoryDataset d2 = (DefaultCategoryDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + /** + * Some checks for the addValue() method. + */ + public void testAddValue() { + DefaultCategoryDataset d1 = new DefaultCategoryDataset(); + d1.addValue(null, "R1", "C1"); + assertNull(d1.getValue("R1", "C1")); + d1.addValue(new Double(1.0), "R2", "C1"); + assertEquals(new Double(1.0), d1.getValue("R2", "C1")); + + boolean pass = false; + try { + d1.addValue(new Double(1.1), null, "C2"); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some basic checks for the removeValue() method. + */ + public void testRemoveValue() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.removeValue("R1", "C1"); + d.addValue(new Double(1.0), "R1", "C1"); + d.removeValue("R1", "C1"); + assertEquals(0, d.getRowCount()); + assertEquals(0, d.getColumnCount()); + + d.addValue(new Double(1.0), "R1", "C1"); + d.addValue(new Double(2.0), "R2", "C1"); + d.removeValue("R1", "C1"); + assertEquals(new Double(2.0), d.getValue(0, 0)); + + boolean pass = false; + try { + d.removeValue(null, "C1"); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + d.removeValue("R1", null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Confirm that cloning works. + */ + public void testCloning() throws CloneNotSupportedException { + DefaultCategoryDataset d1 = new DefaultCategoryDataset(); + DefaultCategoryDataset d2 = (DefaultCategoryDataset) d1.clone(); + + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // try a dataset with some content... + d1.addValue(1.0, "R1", "C1"); + d1.addValue(2.0, "R1", "C2"); + d2 = (DefaultCategoryDataset) d1.clone(); + + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // check that the clone doesn't share the same underlying arrays. + d1.addValue(3.0, "R1", "C1"); + assertFalse(d1.equals(d2)); + d2.addValue(3.0, "R1", "C1"); + assertTrue(d1.equals(d2)); + } + + /** + * Check that this class implements PublicCloneable. + */ + public void testPublicCloneable() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + assertTrue(d instanceof PublicCloneable); + } + + private static final double EPSILON = 0.0000000001; + + /** + * A test for bug 1835955. + */ + public void testBug1835955() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(1.0, "R1", "C1"); + d.addValue(2.0, "R2", "C2"); + d.removeColumn("C2"); + d.addValue(3.0, "R2", "C2"); + assertEquals(3.0, d.getValue("R2", "C2").doubleValue(), EPSILON); + } + + /** + * Some checks for the removeColumn(Comparable) method. + */ + public void testRemoveColumn() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(1.0, "R1", "C1"); + d.addValue(2.0, "R2", "C2"); + assertEquals(2, d.getColumnCount()); + d.removeColumn("C2"); + assertEquals(1, d.getColumnCount()); + + boolean pass = false; + try { + d.removeColumn("XXX"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + d.removeColumn(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the removeRow(Comparable) method. + */ + public void testRemoveRow() { + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(1.0, "R1", "C1"); + d.addValue(2.0, "R2", "C2"); + assertEquals(2, d.getRowCount()); + d.removeRow("R2"); + assertEquals(1, d.getRowCount()); + + boolean pass = false; + try { + d.removeRow("XXX"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + d.removeRow(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/category/DefaultIntervalCategoryDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/category/DefaultIntervalCategoryDatasetTest.java new file mode 100755 index 0000000..6bf8fa8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/category/DefaultIntervalCategoryDatasetTest.java @@ -0,0 +1,478 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------------- + * DefaultIntervalCategoryDatasetTest.java + * --------------------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-Mar-2007 : Version 1 (DG); + * 25-Feb-2008 : Added new tests to check behaviour of an empty dataset (DG); + * 11-Feb-2009 : Fixed locale-sensitive failures (DG); + * + */ + +package org.jfree.data.category; + +import java.util.List; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.DataUtilities; +import org.jfree.data.UnknownKeyException; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +/** + * Tests for the {@link DefaultIntervalCategoryDataset} class. + */ +public class DefaultIntervalCategoryDatasetTest { + + /** + * Some checks for the getValue() method. + */ + @Test + public void testGetValue() { + double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; + double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; + double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; + double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; + double[][] starts = new double[][] {starts_S1, starts_S2}; + double[][] ends = new double[][] {ends_S1, ends_S2}; + DefaultIntervalCategoryDataset d = new DefaultIntervalCategoryDataset( + new Comparable[] {"Series 1", "Series 2"}, + new Comparable[] {"Category 1", "Category 2", "Category 3"}, + DataUtilities.createNumberArray2D(starts), + DataUtilities.createNumberArray2D(ends)); + + assertEquals(new Double(0.1), d.getStartValue("Series 1", + "Category 1")); + assertEquals(new Double(0.2), d.getStartValue("Series 1", + "Category 2")); + assertEquals(new Double(0.3), d.getStartValue("Series 1", + "Category 3")); + assertEquals(new Double(0.3), d.getStartValue("Series 2", + "Category 1")); + assertEquals(new Double(0.4), d.getStartValue("Series 2", + "Category 2")); + assertEquals(new Double(0.5), d.getStartValue("Series 2", + "Category 3")); + + assertEquals(new Double(0.5), d.getEndValue("Series 1", + "Category 1")); + assertEquals(new Double(0.6), d.getEndValue("Series 1", + "Category 2")); + assertEquals(new Double(0.7), d.getEndValue("Series 1", + "Category 3")); + assertEquals(new Double(0.7), d.getEndValue("Series 2", + "Category 1")); + assertEquals(new Double(0.8), d.getEndValue("Series 2", + "Category 2")); + assertEquals(new Double(0.9), d.getEndValue("Series 2", + "Category 3")); + + boolean pass = false; + try { + d.getValue("XX", "Category 1"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + d.getValue("Series 1", "XX"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + } + + + /** + * Some tests for the getRowCount() method. + */ + @Test + public void testGetRowAndColumnCount() { + double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; + double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; + double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; + double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; + double[][] starts = new double[][] {starts_S1, starts_S2}; + double[][] ends = new double[][] {ends_S1, ends_S2}; + DefaultIntervalCategoryDataset d + = new DefaultIntervalCategoryDataset(starts, ends); + + assertEquals(2, d.getRowCount()); + assertEquals(3, d.getColumnCount()); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + double[] starts_S1A = new double[] {0.1, 0.2, 0.3}; + double[] starts_S2A = new double[] {0.3, 0.4, 0.5}; + double[] ends_S1A = new double[] {0.5, 0.6, 0.7}; + double[] ends_S2A = new double[] {0.7, 0.8, 0.9}; + double[][] startsA = new double[][] {starts_S1A, starts_S2A}; + double[][] endsA = new double[][] {ends_S1A, ends_S2A}; + DefaultIntervalCategoryDataset dA + = new DefaultIntervalCategoryDataset(startsA, endsA); + + double[] starts_S1B = new double[] {0.1, 0.2, 0.3}; + double[] starts_S2B = new double[] {0.3, 0.4, 0.5}; + double[] ends_S1B = new double[] {0.5, 0.6, 0.7}; + double[] ends_S2B = new double[] {0.7, 0.8, 0.9}; + double[][] startsB = new double[][] {starts_S1B, starts_S2B}; + double[][] endsB = new double[][] {ends_S1B, ends_S2B}; + DefaultIntervalCategoryDataset dB + = new DefaultIntervalCategoryDataset(startsB, endsB); + + assertTrue(dA.equals(dB)); + assertTrue(dB.equals(dA)); + + // check that two empty datasets are equal + DefaultIntervalCategoryDataset empty1 + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + DefaultIntervalCategoryDataset empty2 + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + assertTrue(empty1.equals(empty2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; + double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; + double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; + double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; + double[][] starts = new double[][] {starts_S1, starts_S2}; + double[][] ends = new double[][] {ends_S1, ends_S2}; + DefaultIntervalCategoryDataset d1 + = new DefaultIntervalCategoryDataset(starts, ends); + DefaultIntervalCategoryDataset d2 = (DefaultIntervalCategoryDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; + double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; + double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; + double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; + double[][] starts = new double[][] {starts_S1, starts_S2}; + double[][] ends = new double[][] {ends_S1, ends_S2}; + DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset( + new Comparable[] {"Series 1", "Series 2"}, + new Comparable[] {"Category 1", "Category 2", "Category 3"}, + DataUtilities.createNumberArray2D(starts), + DataUtilities.createNumberArray2D(ends)); + DefaultIntervalCategoryDataset d2 = null; + d2 = (DefaultIntervalCategoryDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // check that the clone doesn't share the same underlying arrays. + d1.setStartValue(0, "Category 1", new Double(0.99)); + assertFalse(d1.equals(d2)); + d2.setStartValue(0, "Category 1", new Double(0.99)); + assertTrue(d1.equals(d2)); + } + + /** + * A check to ensure that an empty dataset can be cloned. + */ + @Test + public void testCloning2() throws CloneNotSupportedException { + DefaultIntervalCategoryDataset d1 + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + DefaultIntervalCategoryDataset d2 = null; + d2 = (DefaultIntervalCategoryDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + } + + /** + * Some basic checks for the setStartValue() method. + */ + @Test + public void testSetStartValue() { + double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; + double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; + double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; + double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; + double[][] starts = new double[][] {starts_S1, starts_S2}; + double[][] ends = new double[][] {ends_S1, ends_S2}; + DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset( + new Comparable[] {"Series 1", "Series 2"}, + new Comparable[] {"Category 1", "Category 2", "Category 3"}, + DataUtilities.createNumberArray2D(starts), + DataUtilities.createNumberArray2D(ends)); + d1.setStartValue(0, "Category 2", new Double(99.9)); + assertEquals(new Double(99.9), d1.getStartValue("Series 1", + "Category 2")); + + boolean pass = false; + try { + d1.setStartValue(-1, "Category 2", new Double(99.9)); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + d1.setStartValue(2, "Category 2", new Double(99.9)); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some basic checks for the setEndValue() method. + */ + @Test + public void testSetEndValue() { + double[] starts_S1 = new double[] {0.1, 0.2, 0.3}; + double[] starts_S2 = new double[] {0.3, 0.4, 0.5}; + double[] ends_S1 = new double[] {0.5, 0.6, 0.7}; + double[] ends_S2 = new double[] {0.7, 0.8, 0.9}; + double[][] starts = new double[][] {starts_S1, starts_S2}; + double[][] ends = new double[][] {ends_S1, ends_S2}; + DefaultIntervalCategoryDataset d1 = new DefaultIntervalCategoryDataset( + new Comparable[] {"Series 1", "Series 2"}, + new Comparable[] {"Category 1", "Category 2", "Category 3"}, + DataUtilities.createNumberArray2D(starts), + DataUtilities.createNumberArray2D(ends)); + d1.setEndValue(0, "Category 2", new Double(99.9)); + assertEquals(new Double(99.9), d1.getEndValue("Series 1", + "Category 2")); + + boolean pass = false; + try { + d1.setEndValue(-1, "Category 2", new Double(99.9)); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + d1.setEndValue(2, "Category 2", new Double(99.9)); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getSeriesCount() method. + */ + @Test + public void testGetSeriesCount() { + // check an empty dataset + DefaultIntervalCategoryDataset empty + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + assertEquals(0, empty.getSeriesCount()); + } + + /** + * Some checks for the getCategoryCount() method. + */ + @Test + public void testGetCategoryCount() { + // check an empty dataset + DefaultIntervalCategoryDataset empty + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + assertEquals(0, empty.getCategoryCount()); + } + + /** + * Some checks for the getSeriesIndex() method. + */ + @Test + public void testGetSeriesIndex() { + // check an empty dataset + DefaultIntervalCategoryDataset empty + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + assertEquals(-1, empty.getSeriesIndex("ABC")); + } + + /** + * Some checks for the getRowIndex() method. + */ + @Test + public void testGetRowIndex() { + // check an empty dataset + DefaultIntervalCategoryDataset empty + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + assertEquals(-1, empty.getRowIndex("ABC")); + } + + /** + * Some checks for the setSeriesKeys() method. + */ + @Test + public void testSetSeriesKeys() { + // check an empty dataset + DefaultIntervalCategoryDataset empty + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + boolean pass = true; + try { + empty.setSeriesKeys(new String[0]); + } + catch (RuntimeException e) { + pass = false; + } + assertTrue(pass); + } + + /** + * Some checks for the getCategoryIndex() method. + */ + @Test + public void testGetCategoryIndex() { + // check an empty dataset + DefaultIntervalCategoryDataset empty + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + assertEquals(-1, empty.getCategoryIndex("ABC")); + } + + /** + * Some checks for the getColumnIndex() method. + */ + @Test + public void testGetColumnIndex() { + // check an empty dataset + DefaultIntervalCategoryDataset empty + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + assertEquals(-1, empty.getColumnIndex("ABC")); + } + + /** + * Some checks for the setCategoryKeys() method. + */ + @Test + public void testSetCategoryKeys() { + // check an empty dataset + DefaultIntervalCategoryDataset empty + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + boolean pass = true; + try { + empty.setCategoryKeys(new String[0]); + } + catch (RuntimeException e) { + pass = false; + } + assertTrue(pass); + } + + /** + * Some checks for the getColumnKeys() method. + */ + @Test + public void testGetColumnKeys() { + // check an empty dataset + DefaultIntervalCategoryDataset empty + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + List keys = empty.getColumnKeys(); + assertEquals(0, keys.size()); + } + + /** + * Some checks for the getRowKeys() method. + */ + @Test + public void testGetRowKeys() { + // check an empty dataset + DefaultIntervalCategoryDataset empty + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + List keys = empty.getRowKeys(); + assertEquals(0, keys.size()); + } + + /** + * Some checks for the getColumnCount() method. + */ + @Test + public void testGetColumnCount() { + // check an empty dataset + DefaultIntervalCategoryDataset empty + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + assertEquals(0, empty.getColumnCount()); + } + + /** + * Some checks for the getRowCount() method. + */ + @Test + public void testGetRowCount() { + // check an empty dataset + DefaultIntervalCategoryDataset empty + = new DefaultIntervalCategoryDataset(new double[0][0], + new double[0][0]); + assertEquals(0, empty.getColumnCount()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/category/SlidingCategoryDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/category/SlidingCategoryDatasetTest.java new file mode 100755 index 0000000..d1b926e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/category/SlidingCategoryDatasetTest.java @@ -0,0 +1,267 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * SlidingCategoryDatasetTest.java + * ------------------------------- + * (C) Copyright 2008-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-May-2008 : Version 1 (DG); + * 15-Mar-2009 : Added testGetColumnKeys() (DG); + * + */ + +package org.jfree.data.category; + +import java.util.List; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.UnknownKeyException; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +/** + * Tests for the {@link SlidingCategoryDataset} class. + */ +public class SlidingCategoryDatasetTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + DefaultCategoryDataset u1 = new DefaultCategoryDataset(); + u1.addValue(1.0, "R1", "C1"); + u1.addValue(2.0, "R1", "C2"); + SlidingCategoryDataset d1 = new SlidingCategoryDataset(u1, 0, 5); + DefaultCategoryDataset u2 = new DefaultCategoryDataset(); + u2.addValue(1.0, "R1", "C1"); + u2.addValue(2.0, "R1", "C2"); + SlidingCategoryDataset d2 = new SlidingCategoryDataset(u2, 0, 5); + assertTrue(d1.equals(d2)); + + d1.setFirstCategoryIndex(1); + assertFalse(d1.equals(d2)); + d2.setFirstCategoryIndex(1); + assertTrue(d1.equals(d2)); + + d1.setMaximumCategoryCount(99); + assertFalse(d1.equals(d2)); + d2.setMaximumCategoryCount(99); + assertTrue(d1.equals(d2)); + + u1.addValue(3.0, "R1", "C3"); + assertFalse(d1.equals(d2)); + u2.addValue(3.0, "R1", "C3"); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultCategoryDataset u1 = new DefaultCategoryDataset(); + u1.addValue(1.0, "R1", "C1"); + u1.addValue(2.0, "R1", "C2"); + SlidingCategoryDataset d1 = new SlidingCategoryDataset(u1, 0, 5); + SlidingCategoryDataset d2; + d2 = (SlidingCategoryDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // basic check for independence + u1.addValue(3.0, "R1", "C3"); + assertFalse(d1.equals(d2)); + DefaultCategoryDataset u2 + = (DefaultCategoryDataset) d2.getUnderlyingDataset(); + u2.addValue(3.0, "R1", "C3"); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultCategoryDataset u1 = new DefaultCategoryDataset(); + u1.addValue(1.0, "R1", "C1"); + u1.addValue(2.0, "R1", "C2"); + SlidingCategoryDataset d1 = new SlidingCategoryDataset(u1, 0, 5); + SlidingCategoryDataset d2 = (SlidingCategoryDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + + // basic check for independence + u1.addValue(3.0, "R1", "C3"); + assertFalse(d1.equals(d2)); + DefaultCategoryDataset u2 + = (DefaultCategoryDataset) d2.getUnderlyingDataset(); + u2.addValue(3.0, "R1", "C3"); + assertTrue(d1.equals(d2)); + } + + /** + * Some checks for the getColumnCount() method. + */ + @Test + public void testGetColumnCount() { + DefaultCategoryDataset underlying = new DefaultCategoryDataset(); + SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, + 10, 2); + assertEquals(0, dataset.getColumnCount()); + underlying.addValue(1.0, "R1", "C1"); + assertEquals(0, dataset.getColumnCount()); + underlying.addValue(1.0, "R1", "C2"); + assertEquals(0, dataset.getColumnCount()); + dataset.setFirstCategoryIndex(0); + assertEquals(2, dataset.getColumnCount()); + underlying.addValue(1.0, "R1", "C3"); + assertEquals(2, dataset.getColumnCount()); + dataset.setFirstCategoryIndex(2); + assertEquals(1, dataset.getColumnCount()); + underlying.clear(); + assertEquals(0, dataset.getColumnCount()); + } + + /** + * Some checks for the getRowCount() method. + */ + @Test + public void testGetRowCount() { + DefaultCategoryDataset underlying = new DefaultCategoryDataset(); + SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, + 10, 5); + assertEquals(0, dataset.getRowCount()); + underlying.addValue(1.0, "R1", "C1"); + assertEquals(1, dataset.getRowCount()); + + underlying.clear(); + assertEquals(0, dataset.getRowCount()); + } + + /** + * Some checks for the getColumnIndex() method. + */ + @Test + public void testGetColumnIndex() { + DefaultCategoryDataset underlying = new DefaultCategoryDataset(); + underlying.addValue(1.0, "R1", "C1"); + underlying.addValue(2.0, "R1", "C2"); + underlying.addValue(3.0, "R1", "C3"); + underlying.addValue(4.0, "R1", "C4"); + SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, + 1, 2); + assertEquals(-1, dataset.getColumnIndex("C1")); + assertEquals(0, dataset.getColumnIndex("C2")); + assertEquals(1, dataset.getColumnIndex("C3")); + assertEquals(-1, dataset.getColumnIndex("C4")); + } + + /** + * Some checks for the getRowIndex() method. + */ + @Test + public void testGetRowIndex() { + DefaultCategoryDataset underlying = new DefaultCategoryDataset(); + underlying.addValue(1.0, "R1", "C1"); + underlying.addValue(2.0, "R2", "C1"); + underlying.addValue(3.0, "R3", "C1"); + underlying.addValue(4.0, "R4", "C1"); + SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, + 1, 2); + assertEquals(0, dataset.getRowIndex("R1")); + assertEquals(1, dataset.getRowIndex("R2")); + assertEquals(2, dataset.getRowIndex("R3")); + assertEquals(3, dataset.getRowIndex("R4")); + } + + /** + * Some checks for the getValue() method. + */ + @Test + public void testGetValue() { + DefaultCategoryDataset underlying = new DefaultCategoryDataset(); + underlying.addValue(1.0, "R1", "C1"); + underlying.addValue(2.0, "R1", "C2"); + underlying.addValue(3.0, "R1", "C3"); + underlying.addValue(4.0, "R1", "C4"); + SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, + 1, 2); + assertEquals(new Double(2.0), dataset.getValue("R1", "C2")); + assertEquals(new Double(3.0), dataset.getValue("R1", "C3")); + boolean pass = false; + try { + dataset.getValue("R1", "C1"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + dataset.getValue("R1", "C4"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getColumnKeys() method. + */ + @Test + public void testGetColumnKeys() { + DefaultCategoryDataset underlying = new DefaultCategoryDataset(); + underlying.addValue(1.0, "R1", "C1"); + underlying.addValue(2.0, "R1", "C2"); + underlying.addValue(3.0, "R1", "C3"); + underlying.addValue(4.0, "R1", "C4"); + SlidingCategoryDataset dataset = new SlidingCategoryDataset(underlying, + 1, 2); + List keys = dataset.getColumnKeys(); + assertTrue(keys.contains("C2")); + assertTrue(keys.contains("C3")); + assertEquals(2, keys.size()); + + dataset.setFirstCategoryIndex(3); + keys = dataset.getColumnKeys(); + assertTrue(keys.contains("C4")); + assertEquals(1, keys.size()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/function/LineFunction2DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/function/LineFunction2DTest.java new file mode 100755 index 0000000..7beaaaf --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/function/LineFunction2DTest.java @@ -0,0 +1,103 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * LineFunction2DTest.java + * ----------------------- + * (C) Copyright 2009-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 28-May-2009 : Version 1 (DG); + * + */ + +package org.jfree.data.function; + +import org.jfree.chart.TestUtilities; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; +import org.junit.Test; +/** + * Tests for the {@link LineFunction2D} class. + */ +public class LineFunction2DTest { + + private static final double EPSILON = 0.000000001; + + /** + * Some tests for the constructor. + */ + @Test + public void testConstructor() { + LineFunction2D f = new LineFunction2D(1.0, 2.0); + assertEquals(1.0, f.getIntercept(), EPSILON); + assertEquals(2.0, f.getSlope(), EPSILON); + } + + + + /** + * For datasets, the equals() method just checks keys and values. + */ + @Test + public void testEquals() { + LineFunction2D f1 = new LineFunction2D(1.0, 2.0); + LineFunction2D f2 = new LineFunction2D(1.0, 2.0); + assertEquals(f1, f2); + f1 = new LineFunction2D(2.0, 3.0); + assertNotEquals(f1, f2); + f2 = new LineFunction2D(2.0, 3.0); + assertEquals(f1, f2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + LineFunction2D f1 = new LineFunction2D(1.0, 2.0); + LineFunction2D f2 = (LineFunction2D) TestUtilities.serialised(f1); + assertEquals(f1, f2); + } + + /** + * Objects that are equal should have the same hash code otherwise FindBugs + * will tell on us... + */ + @Test + public void testHashCode() { + LineFunction2D f1 = new LineFunction2D(1.0, 2.0); + LineFunction2D f2 = new LineFunction2D(1.0, 2.0); + assertEquals(f1.hashCode(), f2.hashCode()); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/function/NormalDistributionFunction2DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/function/NormalDistributionFunction2DTest.java new file mode 100755 index 0000000..b77eaa3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/function/NormalDistributionFunction2DTest.java @@ -0,0 +1,109 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------- + * NormalDistributionFunction2DTest.java + * ------------------------------------- + * (C) Copyright 2009-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 28-May-2009 : Version 1 (DG); + * + */ + +package org.jfree.data.function; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotEquals; + +/** + * Tests for the {@link NormalDistributionFunction2D} class. + */ +public class NormalDistributionFunction2DTest { + + private static final double EPSILON = 0.000000001; + + /** + * Some tests for the constructor. + */ + @Test + public void testConstructor() { + NormalDistributionFunction2D f = new NormalDistributionFunction2D(1.0, + 2.0); + assertEquals(1.0, f.getMean(), EPSILON); + assertEquals(2.0, f.getStandardDeviation(), EPSILON); + } + + /** + * For datasets, the equals() method just checks keys and values. + */ + @Test + public void testEquals() { + NormalDistributionFunction2D f1 = new NormalDistributionFunction2D(1.0, + 2.0); + NormalDistributionFunction2D f2 = new NormalDistributionFunction2D(1.0, + 2.0); + assertEquals(f1, f2); + f1 = new NormalDistributionFunction2D(2.0, 3.0); + assertNotEquals(f1, f2); + f2 = new NormalDistributionFunction2D(2.0, 3.0); + assertEquals(f1, f2); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + NormalDistributionFunction2D f1 = new NormalDistributionFunction2D(1.0, + 2.0); + NormalDistributionFunction2D f2 = (NormalDistributionFunction2D) + TestUtilities.serialised(f1); + assertEquals(f1, f2); + } + + /** + * Objects that are equal should have the same hash code otherwise FindBugs + * will tell on us... + */ + @Test + public void testHashCode() { + NormalDistributionFunction2D f1 = new NormalDistributionFunction2D(1.0, + 2.0); + NormalDistributionFunction2D f2 = new NormalDistributionFunction2D(1.0, + 2.0); + assertEquals(f1.hashCode(), f2.hashCode()); + } + +} + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/function/PolynomialFunction2DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/function/PolynomialFunction2DTest.java new file mode 100755 index 0000000..8747f4b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/function/PolynomialFunction2DTest.java @@ -0,0 +1,143 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * PolynomialFunction2DTests.java + * ------------------------------ + * (C) Copyright 2009, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 28-May-2009 : Version 1 (DG); + * + */ + +package org.jfree.data.function; + +import java.util.Arrays; +import org.jfree.chart.TestUtilities; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * Tests for the {@link PolynomialFunction2D} class. + */ +public class PolynomialFunction2DTest { + + /** + * Some tests for the constructor. + */ + @Test + public void testConstructor() { + PolynomialFunction2D f = new PolynomialFunction2D(new double[] {1.0, + 2.0}); + assertTrue(Arrays.equals(new double[] {1.0, 2.0}, f.getCoefficients())); + + boolean pass = false; + try { + f = new PolynomialFunction2D(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getCoefficients() method. + */ + @Test + public void testGetCoefficients() { + PolynomialFunction2D f = new PolynomialFunction2D(new double[] {1.0, + 2.0}); + double[] c = f.getCoefficients(); + assertTrue(Arrays.equals(new double[] {1.0, 2.0}, c)); + + // make sure that modifying the returned array doesn't change the + // function + c[0] = 99.9; + assertTrue(Arrays.equals(new double[] {1.0, 2.0}, f.getCoefficients())); + } + + /** + * Some checks for the getOrder() method. + */ + @Test + public void testGetOrder() { + PolynomialFunction2D f = new PolynomialFunction2D(new double[] {1.0, + 2.0}); + assertEquals(1, f.getOrder()); + } + + /** + * For datasets, the equals() method just checks keys and values. + */ + @Test + public void testEquals() { + PolynomialFunction2D f1 = new PolynomialFunction2D(new double[] {1.0, + 2.0}); + PolynomialFunction2D f2 = new PolynomialFunction2D(new double[] {1.0, + 2.0}); + assertTrue(f1.equals(f2)); + f1 = new PolynomialFunction2D(new double[] {2.0, 3.0}); + assertFalse(f1.equals(f2)); + f2 = new PolynomialFunction2D(new double[] {2.0, 3.0}); + assertTrue(f1.equals(f2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PolynomialFunction2D f1 = new PolynomialFunction2D(new double[] {1.0, + 2.0}); + PolynomialFunction2D f2 = (PolynomialFunction2D) + TestUtilities.serialised(f1); + assertEquals(f1, f2); + } + + /** + * Objects that are equal should have the same hash code otherwise FindBugs + * will tell on us... + */ + @Test + public void testHashCode() { + PolynomialFunction2D f1 = new PolynomialFunction2D(new double[] {1.0, + 2.0}); + PolynomialFunction2D f2 = new PolynomialFunction2D(new double[] {1.0, + 2.0}); + assertEquals(f1.hashCode(), f2.hashCode()); + + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/function/PowerFunction2DTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/function/PowerFunction2DTest.java new file mode 100755 index 0000000..2c321bf --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/function/PowerFunction2DTest.java @@ -0,0 +1,103 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * PowerFunction2DTest.java + * ------------------------ + * (C) Copyright 2009-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 28-May-2009 : Version 1 (DG); + * + */ + +package org.jfree.data.function; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * Tests for the {@link PowerFunction2D} class. + */ +public class PowerFunction2DTest { + + private static final double EPSILON = 0.000000001; + + /** + * Some tests for the constructor. + */ + @Test + public void testConstructor() { + PowerFunction2D f = new PowerFunction2D(1.0, 2.0); + assertEquals(1.0, f.getA(), EPSILON); + assertEquals(2.0, f.getB(), EPSILON); + } + + /** + * For datasets, the equals() method just checks keys and values. + */ + @Test + public void testEquals() { + PowerFunction2D f1 = new PowerFunction2D(1.0, 2.0); + PowerFunction2D f2 = new PowerFunction2D(1.0, 2.0); + assertTrue(f1.equals(f2)); + f1 = new PowerFunction2D(2.0, 3.0); + assertFalse(f1.equals(f2)); + f2 = new PowerFunction2D(2.0, 3.0); + assertTrue(f1.equals(f2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + PowerFunction2D f1 = new PowerFunction2D(1.0, 2.0); + PowerFunction2D f2 = (PowerFunction2D) TestUtilities.serialised(f1); + assertEquals(f1, f2); + } + + /** + * Objects that are equal should have the same hash code otherwise FindBugs + * will tell on us... + */ + @Test + public void testHashCode() { + PowerFunction2D f1 = new PowerFunction2D(1.0, 2.0); + PowerFunction2D f2 = new PowerFunction2D(1.0, 2.0); + assertEquals(f1.hashCode(), f2.hashCode()); + } + +} + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/SlidingGanttCategoryDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/SlidingGanttCategoryDatasetTest.java new file mode 100755 index 0000000..1d1b68f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/SlidingGanttCategoryDatasetTest.java @@ -0,0 +1,147 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------ + * SlidingGanttCategoryDatasetTest.java + * ------------------------------------ + * (C) Copyright 2008-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 08-May-2008 : Version 1 (DG); + * + */ + +package org.jfree.data.gantt; + +import java.util.Date; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * Tests for the {@link SlidingGanttCategoryDataset} class. + */ +public class SlidingGanttCategoryDatasetTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + TaskSeries s1 = new TaskSeries("Series"); + s1.add(new Task("Task 1", new Date(0L), new Date(1L))); + s1.add(new Task("Task 2", new Date(10L), new Date(11L))); + s1.add(new Task("Task 3", new Date(20L), new Date(21L))); + TaskSeriesCollection u1 = new TaskSeriesCollection(); + u1.add(s1); + SlidingGanttCategoryDataset d1 = new SlidingGanttCategoryDataset( + u1, 0, 5); + TaskSeries s2 = new TaskSeries("Series"); + s2.add(new Task("Task 1", new Date(0L), new Date(1L))); + s2.add(new Task("Task 2", new Date(10L), new Date(11L))); + s2.add(new Task("Task 3", new Date(20L), new Date(21L))); + TaskSeriesCollection u2 = new TaskSeriesCollection(); + u2.add(s2); + SlidingGanttCategoryDataset d2 = new SlidingGanttCategoryDataset( + u2, 0, 5); + assertTrue(d1.equals(d2)); + + d1.setFirstCategoryIndex(1); + assertFalse(d1.equals(d2)); + d2.setFirstCategoryIndex(1); + assertTrue(d1.equals(d2)); + + d1.setMaximumCategoryCount(99); + assertFalse(d1.equals(d2)); + d2.setMaximumCategoryCount(99); + assertTrue(d1.equals(d2)); + + s1.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertFalse(d1.equals(d2)); + s2.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + TaskSeries s1 = new TaskSeries("Series"); + s1.add(new Task("Task 1", new Date(0L), new Date(1L))); + TaskSeriesCollection u1 = new TaskSeriesCollection(); + u1.add(s1); + SlidingGanttCategoryDataset d1 = new SlidingGanttCategoryDataset( + u1, 0, 5); + SlidingGanttCategoryDataset d2 = (SlidingGanttCategoryDataset) + d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // basic check for independence + s1.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertFalse(d1.equals(d2)); + TaskSeriesCollection u2 + = (TaskSeriesCollection) d2.getUnderlyingDataset(); + TaskSeries s2 = u2.getSeries("Series"); + s2.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TaskSeries s1 = new TaskSeries("Series"); + s1.add(new Task("Task 1", new Date(0L), new Date(1L))); + TaskSeriesCollection u1 = new TaskSeriesCollection(); + u1.add(s1); + SlidingGanttCategoryDataset d1 = new SlidingGanttCategoryDataset( + u1, 0, 5); + SlidingGanttCategoryDataset d2 = (SlidingGanttCategoryDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + + // basic check for independence + s1.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertFalse(d1.equals(d2)); + TaskSeriesCollection u2 + = (TaskSeriesCollection) d2.getUnderlyingDataset(); + TaskSeries s2 = u2.getSeries("Series"); + s2.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertTrue(d1.equals(d2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/TaskSeriesCollectionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/TaskSeriesCollectionTest.java new file mode 100755 index 0000000..6763d51 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/TaskSeriesCollectionTest.java @@ -0,0 +1,653 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * TaskSeriesCollectionTest.java + * ----------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jul-2004 : Version 1 (DG); + * 12-Jan-2005 : Added tests from TaskSeriesCollectionTests2.java (DG); + * 08-Mar-2007 : Added testRemove() (DG); + * + */ + +package org.jfree.data.gantt; + +import java.util.Date; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.time.SimpleTimePeriod; +import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * Tests for the {@link TaskSeriesCollection} class. + */ +public class TaskSeriesCollectionTest { + + /** + * Creates a sample collection for testing purposes. + * + * @return A sample collection. + */ + private TaskSeriesCollection createCollection1() { + TaskSeriesCollection result = new TaskSeriesCollection(); + TaskSeries s1 = new TaskSeries("S1"); + s1.add(new Task("Task 1", new Date(1), new Date(2))); + s1.add(new Task("Task 2", new Date(3), new Date(4))); + result.add(s1); + TaskSeries s2 = new TaskSeries("S2"); + s2.add(new Task("Task 3", new Date(5), new Date(6))); + result.add(s2); + return result; + } + + /** + * Creates a sample collection for testing purposes. + * + * @return A sample collection. + */ + private TaskSeriesCollection createCollection2() { + TaskSeriesCollection result = new TaskSeriesCollection(); + TaskSeries s1 = new TaskSeries("S1"); + Task t1 = new Task("Task 1", new Date(10), new Date(20)); + t1.addSubtask(new Task("Task 1A", new Date(10), new Date(15))); + t1.addSubtask(new Task("Task 1B", new Date(16), new Date(20))); + t1.setPercentComplete(0.10); + s1.add(t1); + Task t2 = new Task("Task 2", new Date(30), new Date(40)); + t2.addSubtask(new Task("Task 2A", new Date(30), new Date(35))); + t2.addSubtask(new Task("Task 2B", new Date(36), new Date(40))); + t2.setPercentComplete(0.20); + s1.add(t2); + result.add(s1); + TaskSeries s2 = new TaskSeries("S2"); + Task t3 = new Task("Task 3", new Date(50), new Date(60)); + t3.addSubtask(new Task("Task 3A", new Date(50), new Date(55))); + t3.addSubtask(new Task("Task 3B", new Date(56), new Date(60))); + t3.setPercentComplete(0.30); + s2.add(t3); + result.add(s2); + return result; + } + + /** + * Creates a sample collection for testing purposes. + * + * @return A sample collection. + */ + private TaskSeriesCollection createCollection3() { + + // define subtasks + Task sub1 = new Task("Sub1", new Date(11), new Date(111)); + Task sub2 = new Task("Sub2", new Date(22), new Date(222)); + Task sub3 = new Task("Sub3", new Date(33), new Date(333)); + Task sub4 = new Task("Sub4", new Date(44), new Date(444)); + Task sub5 = new Task("Sub5", new Date(55), new Date(555)); + Task sub6 = new Task("Sub6", new Date(66), new Date(666)); + sub1.setPercentComplete(0.111); + sub2.setPercentComplete(0.222); + sub3.setPercentComplete(0.333); + sub4.setPercentComplete(0.444); + sub5.setPercentComplete(0.555); + sub6.setPercentComplete(0.666); + + TaskSeries seriesA = new TaskSeries("Series A"); + Task taskA1 = new Task("Task 1", new SimpleTimePeriod(new Date(100), + new Date(200))); + taskA1.setPercentComplete(0.1); + taskA1.addSubtask(sub1); + Task taskA2 = new Task("Task 2", new SimpleTimePeriod(new Date(220), + new Date(350))); + taskA2.setPercentComplete(0.2); + taskA2.addSubtask(sub2); + taskA2.addSubtask(sub3); + seriesA.add(taskA1); + seriesA.add(taskA2); + + TaskSeries seriesB = new TaskSeries("Series B"); + // note that we don't define taskB1 + Task taskB2 = new Task("Task 2", new SimpleTimePeriod(new Date(2220), + new Date(3350))); + taskB2.setPercentComplete(0.3); + taskB2.addSubtask(sub4); + taskB2.addSubtask(sub5); + taskB2.addSubtask(sub6); + seriesB.add(taskB2); + + TaskSeriesCollection tsc = new TaskSeriesCollection(); + tsc.add(seriesA); + tsc.add(seriesB); + + return tsc; + } + + /** + * A test for the getSeriesCount() method. + */ + @Test + public void testGetSeriesCount() { + TaskSeriesCollection c = createCollection1(); + assertEquals(2, c.getSeriesCount()); + } + + /** + * Some tests for the getSeriesKey() method. + */ + @Test + public void testGetSeriesKey() { + TaskSeriesCollection c = createCollection1(); + assertEquals("S1", c.getSeriesKey(0)); + assertEquals("S2", c.getSeriesKey(1)); + } + + /** + * A test for the getRowCount() method. + */ + @Test + public void testGetRowCount() { + TaskSeriesCollection c = createCollection1(); + assertEquals(2, c.getRowCount()); + } + + /** + * Some tests for the getRowKey() method. + */ + @Test + public void testGetRowKey() { + TaskSeriesCollection c = createCollection1(); + assertEquals("S1", c.getRowKey(0)); + assertEquals("S2", c.getRowKey(1)); + } + + /** + * Some tests for the getRowIndex() method. + */ + @Test + public void testGetRowIndex() { + TaskSeriesCollection c = createCollection1(); + assertEquals(0, c.getRowIndex("S1")); + assertEquals(1, c.getRowIndex("S2")); + } + + /** + * Some tests for the getValue() method. + */ + @Test + public void testGetValue() { + TaskSeriesCollection c = createCollection1(); + assertEquals(new Long(1L), c.getValue("S1", "Task 1")); + assertEquals(new Long(3L), c.getValue("S1", "Task 2")); + assertEquals(new Long(5L), c.getValue("S2", "Task 3")); + + assertEquals(new Long(1L), c.getValue(0, 0)); + assertEquals(new Long(3L), c.getValue(0, 1)); + assertEquals(null, c.getValue(0, 2)); + assertEquals(null, c.getValue(1, 0)); + assertEquals(null, c.getValue(1, 1)); + assertEquals(new Long(5L), c.getValue(1, 2)); + } + + /** + * Some tests for the getStartValue() method. + */ + @Test + public void testGetStartValue() { + TaskSeriesCollection c = createCollection1(); + assertEquals(new Long(1L), c.getStartValue("S1", "Task 1")); + assertEquals(new Long(3L), c.getStartValue("S1", "Task 2")); + assertEquals(new Long(5L), c.getStartValue("S2", "Task 3")); + + assertEquals(new Long(1L), c.getStartValue(0, 0)); + assertEquals(new Long(3L), c.getStartValue(0, 1)); + assertEquals(null, c.getStartValue(0, 2)); + assertEquals(null, c.getStartValue(1, 0)); + assertEquals(null, c.getStartValue(1, 1)); + assertEquals(new Long(5L), c.getStartValue(1, 2)); + + // test collection 3, which doesn't define all tasks in all series + TaskSeriesCollection c3 = createCollection3(); + assertEquals(new Long(100), c3.getStartValue(0, 0)); + assertEquals(new Long(220), c3.getStartValue(0, 1)); + assertTrue(c3.getStartValue(1, 0) == null); + assertEquals(new Long(2220), c3.getStartValue(1, 1)); + } + + /** + * Some tests for the getStartValue() method for sub-intervals. + */ + @Test + public void testGetStartValue2() { + TaskSeriesCollection c = createCollection2(); + assertEquals(new Long(10L), c.getStartValue("S1", "Task 1", 0)); + assertEquals(new Long(16L), c.getStartValue("S1", "Task 1", 1)); + assertEquals(new Long(30L), c.getStartValue("S1", "Task 2", 0)); + assertEquals(new Long(36L), c.getStartValue("S1", "Task 2", 1)); + assertEquals(new Long(50L), c.getStartValue("S2", "Task 3", 0)); + assertEquals(new Long(56L), c.getStartValue("S2", "Task 3", 1)); + + assertEquals(new Long(10L), c.getStartValue(0, 0, 0)); + assertEquals(new Long(16L), c.getStartValue(0, 0, 1)); + assertEquals(new Long(30L), c.getStartValue(0, 1, 0)); + assertEquals(new Long(36L), c.getStartValue(0, 1, 1)); + assertEquals(new Long(50L), c.getStartValue(1, 2, 0)); + assertEquals(new Long(56L), c.getStartValue(1, 2, 1)); + + TaskSeriesCollection c3 = createCollection3(); + assertEquals(new Long(11), c3.getStartValue(0, 0, 0)); + assertEquals(new Long(22), c3.getStartValue(0, 1, 0)); + assertEquals(new Long(33), c3.getStartValue(0, 1, 1)); + assertTrue(c3.getStartValue(1, 0, 0) == null); + assertEquals(new Long(44), c3.getStartValue(1, 1, 0)); + assertEquals(new Long(55), c3.getStartValue(1, 1, 1)); + assertEquals(new Long(66), c3.getStartValue(1, 1, 2)); + } + + /** + * A check for a null task duration. + */ + @Test + public void testGetStartValue3() { + TaskSeriesCollection c = new TaskSeriesCollection(); + TaskSeries s = new TaskSeries("Series 1"); + s.add(new Task("Task with null duration", null)); + c.add(s); + Number millis = c.getStartValue("Series 1", "Task with null duration"); + assertTrue(millis == null); + } + + /** + * Some tests for the getEndValue() method. + */ + @Test + public void testGetEndValue() { + TaskSeriesCollection c = createCollection1(); + assertEquals(new Long(2L), c.getEndValue("S1", "Task 1")); + assertEquals(new Long(4L), c.getEndValue("S1", "Task 2")); + assertEquals(new Long(6L), c.getEndValue("S2", "Task 3")); + + assertEquals(new Long(2L), c.getEndValue(0, 0)); + assertEquals(new Long(4L), c.getEndValue(0, 1)); + assertEquals(null, c.getEndValue(0, 2)); + assertEquals(null, c.getEndValue(1, 0)); + assertEquals(null, c.getEndValue(1, 1)); + assertEquals(new Long(6L), c.getEndValue(1, 2)); + + // test collection 3, which doesn't define all tasks in all series + TaskSeriesCollection c3 = createCollection3(); + assertEquals(new Long(200), c3.getEndValue(0, 0)); + assertEquals(new Long(350), c3.getEndValue(0, 1)); + assertTrue(c3.getEndValue(1, 0) == null); + assertEquals(new Long(3350), c3.getEndValue(1, 1)); + } + + /** + * Some tests for the getEndValue() method for sub-intervals. + */ + @Test + public void testGetEndValue2() { + TaskSeriesCollection c = createCollection2(); + assertEquals(new Long(15L), c.getEndValue("S1", "Task 1", 0)); + assertEquals(new Long(20L), c.getEndValue("S1", "Task 1", 1)); + assertEquals(new Long(35L), c.getEndValue("S1", "Task 2", 0)); + assertEquals(new Long(40L), c.getEndValue("S1", "Task 2", 1)); + assertEquals(new Long(55L), c.getEndValue("S2", "Task 3", 0)); + assertEquals(new Long(60L), c.getEndValue("S2", "Task 3", 1)); + + assertEquals(new Long(15L), c.getEndValue(0, 0, 0)); + assertEquals(new Long(20L), c.getEndValue(0, 0, 1)); + assertEquals(new Long(35L), c.getEndValue(0, 1, 0)); + assertEquals(new Long(40L), c.getEndValue(0, 1, 1)); + assertEquals(new Long(55L), c.getEndValue(1, 2, 0)); + assertEquals(new Long(60L), c.getEndValue(1, 2, 1)); + + TaskSeriesCollection c3 = createCollection3(); + assertEquals(new Long(111), c3.getEndValue(0, 0, 0)); + assertEquals(new Long(222), c3.getEndValue(0, 1, 0)); + assertEquals(new Long(333), c3.getEndValue(0, 1, 1)); + assertTrue(c3.getEndValue(1, 0, 0) == null); + assertEquals(new Long(444), c3.getEndValue(1, 1, 0)); + assertEquals(new Long(555), c3.getEndValue(1, 1, 1)); + assertEquals(new Long(666), c3.getEndValue(1, 1, 2)); + } + + /** + * A check for a null task duration. + */ + @Test + public void testGetEndValue3() { + TaskSeriesCollection c = new TaskSeriesCollection(); + TaskSeries s = new TaskSeries("Series 1"); + s.add(new Task("Task with null duration", null)); + c.add(s); + Number millis = c.getEndValue("Series 1", "Task with null duration"); + assertTrue(millis == null); + } + + /** + * Some tests for the getPercentComplete() method. + */ + @Test + public void testGetPercentComplete() { + TaskSeriesCollection c = createCollection2(); + assertEquals(new Double(0.10), c.getPercentComplete("S1", "Task 1")); + assertEquals(new Double(0.20), c.getPercentComplete("S1", "Task 2")); + assertEquals(new Double(0.30), c.getPercentComplete("S2", "Task 3")); + + assertEquals(new Double(0.10), c.getPercentComplete(0, 0)); + assertEquals(new Double(0.20), c.getPercentComplete(0, 1)); + assertEquals(null, c.getPercentComplete(0, 2)); + assertEquals(null, c.getPercentComplete(1, 0)); + assertEquals(null, c.getPercentComplete(1, 1)); + assertEquals(new Double(0.30), c.getPercentComplete(1, 2)); + + // test collection 3, which doesn't define all tasks in all series + TaskSeriesCollection c3 = createCollection3(); + assertEquals(new Double(0.1), c3.getPercentComplete(0, 0)); + assertEquals(new Double(0.2), c3.getPercentComplete(0, 1)); + assertTrue(c3.getPercentComplete(1, 0) == null); + assertEquals(new Double(0.3), c3.getPercentComplete(1, 1)); + + assertEquals(new Double(0.111), c3.getPercentComplete(0, 0, 0)); + + assertEquals(new Double(0.222), c3.getPercentComplete(0, 1, 0)); + assertEquals(new Double(0.333), c3.getPercentComplete(0, 1, 1)); + + assertEquals(new Double(0.444), c3.getPercentComplete(1, 1, 0)); + assertEquals(new Double(0.555), c3.getPercentComplete(1, 1, 1)); + assertEquals(new Double(0.666), c3.getPercentComplete(1, 1, 2)); + } + + /** + * A test for the getColumnCount() method. + */ + @Test + public void testGetColumnCount() { + TaskSeriesCollection c = createCollection1(); + assertEquals(3, c.getColumnCount()); + } + + /** + * Some tests for the getColumnKey() method. + */ + public void testGetColumnKey() { + TaskSeriesCollection c = createCollection1(); + assertEquals("Task 1", c.getColumnKey(0)); + assertEquals("Task 2", c.getColumnKey(1)); + assertEquals("Task 3", c.getColumnKey(2)); + } + + /** + * Some tests for the getColumnIndex() method. + */ + @Test + public void testGetColumnIndex() { + TaskSeriesCollection c = createCollection1(); + assertEquals(0, c.getColumnIndex("Task 1")); + assertEquals(1, c.getColumnIndex("Task 2")); + assertEquals(2, c.getColumnIndex("Task 3")); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + TaskSeries s1 = new TaskSeries("S"); + s1.add(new Task("T1", new Date(1), new Date(2))); + s1.add(new Task("T2", new Date(11), new Date(22))); + TaskSeries s2 = new TaskSeries("S"); + s2.add(new Task("T1", new Date(1), new Date(2))); + s2.add(new Task("T2", new Date(11), new Date(22))); + TaskSeriesCollection c1 = new TaskSeriesCollection(); + c1.add(s1); + c1.add(s2); + + TaskSeries s1b = new TaskSeries("S"); + s1b.add(new Task("T1", new Date(1), new Date(2))); + s1b.add(new Task("T2", new Date(11), new Date(22))); + TaskSeries s2b = new TaskSeries("S"); + s2b.add(new Task("T1", new Date(1), new Date(2))); + s2b.add(new Task("T2", new Date(11), new Date(22))); + TaskSeriesCollection c2 = new TaskSeriesCollection(); + c2.add(s1b); + c2.add(s2b); + + assertTrue(c1.equals(c2)); + assertTrue(c2.equals(c1)); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + TaskSeries s1 = new TaskSeries("S1"); + s1.add(new Task("T1", new Date(1), new Date(2))); + s1.add(new Task("T2", new Date(11), new Date(22))); + TaskSeries s2 = new TaskSeries("S2"); + s2.add(new Task("T1", new Date(33), new Date(44))); + s2.add(new Task("T2", new Date(55), new Date(66))); + TaskSeriesCollection c1 = new TaskSeriesCollection(); + c1.add(s1); + c1.add(s2); + + TaskSeriesCollection c2 = (TaskSeriesCollection) c1.clone(); + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + + // basic check for independence + s1.add(new Task("T3", new Date(21), new Date(33))); + assertFalse(c1.equals(c2)); + TaskSeries series = c2.getSeries("S1"); + series.add(new Task("T3", new Date(21), new Date(33))); + assertTrue(c1.equals(c2)); + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TaskSeries s1 = new TaskSeries("S"); + s1.add(new Task("T1", new Date(1), new Date(2))); + s1.add(new Task("T2", new Date(11), new Date(22))); + TaskSeries s2 = new TaskSeries("S"); + s2.add(new Task("T1", new Date(1), new Date(2))); + s2.add(new Task("T2", new Date(11), new Date(22))); + TaskSeriesCollection c1 = new TaskSeriesCollection(); + c1.add(s1); + c1.add(s2); + TaskSeriesCollection c2 = (TaskSeriesCollection) + TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + + /** + * A test for bug report 697153. + */ + @Test + public void test697153() { + + TaskSeries s1 = new TaskSeries("S1"); + s1.add(new Task("Task 1", new SimpleTimePeriod(new Date(), + new Date()))); + s1.add(new Task("Task 2", new SimpleTimePeriod(new Date(), + new Date()))); + s1.add(new Task("Task 3", new SimpleTimePeriod(new Date(), + new Date()))); + + TaskSeries s2 = new TaskSeries("S2"); + s2.add(new Task("Task 2", new SimpleTimePeriod(new Date(), + new Date()))); + s2.add(new Task("Task 3", new SimpleTimePeriod(new Date(), + new Date()))); + s2.add(new Task("Task 4", new SimpleTimePeriod(new Date(), + new Date()))); + + TaskSeriesCollection tsc = new TaskSeriesCollection(); + tsc.add(s1); + tsc.add(s2); + + s1.removeAll(); + + int taskCount = tsc.getColumnCount(); + + assertEquals(3, taskCount); + + } + + /** + * A test for bug report 800324. + */ + @Test + public void test800324() { + TaskSeries s1 = new TaskSeries("S1"); + s1.add(new Task("Task 1", new SimpleTimePeriod(new Date(), + new Date()))); + s1.add(new Task("Task 2", new SimpleTimePeriod(new Date(), + new Date()))); + s1.add(new Task("Task 3", new SimpleTimePeriod(new Date(), + new Date()))); + + TaskSeriesCollection tsc = new TaskSeriesCollection(); + tsc.add(s1); + + // these methods should throw an IndexOutOfBoundsException since the + // column is too high... + try { + /* Number start = */ tsc.getStartValue(0, 3); + assertTrue(false); + } + catch (IndexOutOfBoundsException e) { + // expected + } + try { + /* Number end = */ tsc.getEndValue(0, 3); + assertTrue(false); + } + catch (IndexOutOfBoundsException e) { + // expected + } + try { + /* int count = */ tsc.getSubIntervalCount(0, 3); + assertTrue(false); + } + catch (IndexOutOfBoundsException e) { + // expected + } + } + + /** + * Some tests for the bug report 1099331. We create a TaskSeriesCollection + * with two series - the first series has two tasks, but the second has + * only one. The key is to ensure that the methods in TaskSeriesCollection + * translate the index values to key values *before* accessing the tasks + * in the series. + */ + @Test + public void testGetSubIntervalCount() { + TaskSeriesCollection tsc = createCollection3(); + assertEquals(1, tsc.getSubIntervalCount(0, 0)); + assertEquals(2, tsc.getSubIntervalCount(0, 1)); + assertEquals(0, tsc.getSubIntervalCount(1, 0)); + assertEquals(3, tsc.getSubIntervalCount(1, 1)); + } + + /** + * Some basic tests for the getSeries() methods. + */ + @Test + public void testGetSeries() { + TaskSeries s1 = new TaskSeries("S1"); + TaskSeries s2 = new TaskSeries("S2"); + TaskSeriesCollection c = new TaskSeriesCollection(); + c.add(s1); + + assertEquals(c.getSeries(0), s1); + assertEquals(c.getSeries("S1"), s1); + assertEquals(c.getSeries("XX"), null); + + c.add(s2); + assertEquals(c.getSeries(1), s2); + assertEquals(c.getSeries("S2"), s2); + + boolean pass = false; + try { + c.getSeries(null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some basic checks for the remove() method. + */ + @Test + public void testRemove() { + TaskSeriesCollection c = new TaskSeriesCollection(); + TaskSeries s1 = new TaskSeries("S1"); + c.add(s1); + assertEquals("S1", c.getSeries(0).getKey()); + c.remove(0); + assertEquals(0, c.getSeriesCount()); + c.add(s1); + + boolean pass = false; + try { + c.remove(-1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + c.remove(1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/TaskSeriesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/TaskSeriesTest.java new file mode 100755 index 0000000..55663fd --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/TaskSeriesTest.java @@ -0,0 +1,125 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * TaskSeriesTests.java + * -------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jul-2004 : Version 1 (DG); + * 09-May-2008 : Added independence check in testCloning() (DG); + * + */ + +package org.jfree.data.gantt; + +import java.util.Date; + +import org.jfree.chart.TestUtilities; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import org.junit.Test; + +/** + * Tests for the {@link TaskSeries} class. + */ +public class TaskSeriesTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + TaskSeries s1 = new TaskSeries("S"); + s1.add(new Task("T1", new Date(1), new Date(2))); + s1.add(new Task("T2", new Date(11), new Date(22))); + TaskSeries s2 = new TaskSeries("S"); + s2.add(new Task("T1", new Date(1), new Date(2))); + s2.add(new Task("T2", new Date(11), new Date(22))); + assertTrue(s1.equals(s2)); + assertTrue(s2.equals(s1)); + + s1.add(new Task("T3", new Date(22), new Date(33))); + assertFalse(s1.equals(s2)); + s2.add(new Task("T3", new Date(22), new Date(33))); + assertTrue(s1.equals(s2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + TaskSeries s1 = new TaskSeries("S"); + s1.add(new Task("T1", new Date(1), new Date(2))); + s1.add(new Task("T2", new Date(11), new Date(22))); + TaskSeries s2 = (TaskSeries) s1.clone(); + assertTrue(s1 != s2); + assertTrue(s1.getClass() == s2.getClass()); + assertTrue(s1.equals(s2)); + + // basic check for independence + s1.add(new Task("T3", new Date(22), new Date(33))); + assertFalse(s1.equals(s2)); + s2.add(new Task("T3", new Date(22), new Date(33))); + assertTrue(s1.equals(s2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TaskSeries s1 = new TaskSeries("S"); + s1.add(new Task("T1", new Date(1), new Date(2))); + s1.add(new Task("T2", new Date(11), new Date(22))); + TaskSeries s2 = (TaskSeries) TestUtilities.serialised(s1); + assertEquals(s1, s2); + } + + /** + * Some checks for the getTask() method. + */ + @Test + public void testGetTask() { + TaskSeries s1 = new TaskSeries("S"); + s1.add(new Task("T1", new Date(1), new Date(2))); + s1.add(new Task("T2", new Date(11), new Date(22))); + Task t1 = s1.get("T1"); + assertTrue(t1.equals(new Task("T1", new Date(1), new Date(2)))); + Task t2 = s1.get("T2"); + assertTrue(t2.equals(new Task("T2", new Date(11), new Date(22)))); + Task t3 = s1.get("T3"); + assertTrue(t3 == null); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/TaskTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/TaskTest.java new file mode 100755 index 0000000..3b1e0c9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/TaskTest.java @@ -0,0 +1,131 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * TaskTest.java + * ------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jul-2004 : Version 1 (DG); + * + */ + +package org.jfree.data.gantt; + +import java.util.Date; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.time.SimpleTimePeriod; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import org.junit.Test; + +/** + * Tests for the {@link Task} class. + */ +public class TaskTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + Task t1 = new Task("T", new Date(1), new Date(2)); + Task t2 = new Task("T", new Date(1), new Date(2)); + assertTrue(t1.equals(t2)); + assertTrue(t2.equals(t1)); + + t1.setDescription("X"); + assertFalse(t1.equals(t2)); + t2.setDescription("X"); + assertTrue(t1.equals(t2)); + + t1.setDuration(new SimpleTimePeriod(new Date(2), new Date(3))); + assertFalse(t1.equals(t2)); + t2.setDuration(new SimpleTimePeriod(new Date(2), new Date(3))); + assertTrue(t1.equals(t2)); + + t1.setPercentComplete(0.5); + assertFalse(t1.equals(t2)); + t2.setPercentComplete(0.5); + assertTrue(t1.equals(t2)); + + t1.addSubtask(new Task("T", new Date(22), new Date(33))); + assertFalse(t1.equals(t2)); + t2.addSubtask(new Task("T", new Date(22), new Date(33))); + assertTrue(t1.equals(t2)); + + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + Task t1 = new Task("T", new Date(1), new Date(2)); + Task t2 = (Task) t1.clone(); + assertTrue(t1 != t2); + assertTrue(t1.getClass() == t2.getClass()); + assertTrue(t1.equals(t2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Task t1 = new Task("T", new Date(1), new Date(2)); + Task t2 = (Task) TestUtilities.serialised(t1); + assertEquals(t1, t2); + } + + /** + * Check the getSubTaskCount() method. + */ + @Test + public void testGetSubTaskCount() { + Task t1 = new Task("T", new Date(100), new Date(200)); + assertEquals(0, t1.getSubtaskCount()); + t1.addSubtask(new Task("S1", new Date(100), new Date(110))); + assertEquals(1, t1.getSubtaskCount()); + Task s2 = new Task("S2", new Date(111), new Date(120)); + t1.addSubtask(s2); + assertEquals(2, t1.getSubtaskCount()); + t1.addSubtask(new Task("S3", new Date(121), new Date(130))); + assertEquals(3, t1.getSubtaskCount()); + t1.removeSubtask(s2); + assertEquals(2, t1.getSubtaskCount()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/XYTaskDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/XYTaskDatasetTest.java new file mode 100755 index 0000000..54e4476 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/gantt/XYTaskDatasetTest.java @@ -0,0 +1,139 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * XYTaskDatasetTest.java + * ---------------------- + * (C) Copyright 2008-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Sep-2008 : Version 1 (DG); + * + */ + +package org.jfree.data.gantt; + +import java.util.Date; + +import org.jfree.chart.TestUtilities; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import org.junit.Test; + +/** + * Tests for the {@link XYTaskDataset} class. + */ +public class XYTaskDatasetTest { + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + TaskSeries s1 = new TaskSeries("Series"); + s1.add(new Task("Task 1", new Date(0L), new Date(1L))); + s1.add(new Task("Task 2", new Date(10L), new Date(11L))); + s1.add(new Task("Task 3", new Date(20L), new Date(21L))); + TaskSeriesCollection u1 = new TaskSeriesCollection(); + u1.add(s1); + XYTaskDataset d1 = new XYTaskDataset(u1); + TaskSeries s2 = new TaskSeries("Series"); + s2.add(new Task("Task 1", new Date(0L), new Date(1L))); + s2.add(new Task("Task 2", new Date(10L), new Date(11L))); + s2.add(new Task("Task 3", new Date(20L), new Date(21L))); + TaskSeriesCollection u2 = new TaskSeriesCollection(); + u2.add(s2); + XYTaskDataset d2 = new XYTaskDataset(u2); + assertTrue(d1.equals(d2)); + + d1.setSeriesWidth(0.123); + assertFalse(d1.equals(d2)); + d2.setSeriesWidth(0.123); + assertTrue(d1.equals(d2)); + + d1.setTransposed(true); + assertFalse(d1.equals(d2)); + d2.setTransposed(true); + assertTrue(d1.equals(d2)); + + s1.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertFalse(d1.equals(d2)); + s2.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + TaskSeries s1 = new TaskSeries("Series"); + s1.add(new Task("Task 1", new Date(0L), new Date(1L))); + TaskSeriesCollection u1 = new TaskSeriesCollection(); + u1.add(s1); + XYTaskDataset d1 = new XYTaskDataset(u1); + XYTaskDataset d2 = (XYTaskDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // basic check for independence + s1.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertFalse(d1.equals(d2)); + TaskSeriesCollection u2 = d2.getTasks(); + TaskSeries s2 = u2.getSeries("Series"); + s2.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TaskSeries s1 = new TaskSeries("Series"); + s1.add(new Task("Task 1", new Date(0L), new Date(1L))); + TaskSeriesCollection u1 = new TaskSeriesCollection(); + u1.add(s1); + XYTaskDataset d1 = new XYTaskDataset(u1); + XYTaskDataset d2 = (XYTaskDataset) TestUtilities.serialised(d1); + assertEquals(d1, d2); + + // basic check for independence + s1.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertFalse(d1.equals(d2)); + TaskSeriesCollection u2 = d2.getTasks(); + TaskSeries s2 = u2.getSeries("Series"); + s2.add(new Task("Task 2", new Date(10L), new Date(11L))); + assertTrue(d1.equals(d2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DatasetGroupTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DatasetGroupTest.java new file mode 100755 index 0000000..4829d4c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DatasetGroupTest.java @@ -0,0 +1,62 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * DatasetGroupTest.java + * --------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 14-Jan-2005 : Version 1 (DG); + * + */ + +package org.jfree.data.general; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; +import static org.junit.Assert.assertEquals; + +/** + * Tests for the {@link DatasetGroup} class. + */ +public class DatasetGroupTest { + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DatasetGroup g1 = new DatasetGroup(); + DatasetGroup g2 = (DatasetGroup) TestUtilities.serialised(g1); + assertEquals(g1, g2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DatasetUtilitiesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DatasetUtilitiesTest.java new file mode 100755 index 0000000..7cd029c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DatasetUtilitiesTest.java @@ -0,0 +1,1421 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * DatasetUtilitiesTest.java + * ------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Sep-2003 : Version 1 (DG); + * 23-Mar-2004 : Added test for maximumStackedRangeValue() method (DG); + * 04-Oct-2004 : Eliminated NumberUtils usage (DG); + * 07-Jan-2005 : Updated for method name changes (DG); + * 03-Feb-2005 : Added testFindStackedRangeBounds2() method (DG); + * 26-Sep-2007 : Added testIsEmptyOrNullXYDataset() method (DG); + * 28-Mar-2008 : Added and renamed various tests (DG); + * 08-Oct-2008 : New tests to support patch 2131001 and related + * changes (DG); + * 25-Mar-2009 : Added tests for new iterateToFindRangeBounds() method (DG); + * 16-May-2009 : Added + * testIterateToFindRangeBounds_MultiValueCategoryDataset() (DG); + * 10-Sep-2009 : Added tests for bug 2849731 (DG); + * + */ + +package org.jfree.data.general; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.List; + +import org.jfree.data.KeyToGroupMap; +import org.jfree.data.Range; +import org.jfree.data.category.CategoryDataset; +import org.jfree.data.category.DefaultCategoryDataset; +import org.jfree.data.category.DefaultIntervalCategoryDataset; +import org.jfree.data.function.Function2D; +import org.jfree.data.function.LineFunction2D; +import org.jfree.data.statistics.BoxAndWhiskerItem; +import org.jfree.data.statistics.DefaultBoxAndWhiskerXYDataset; +import org.jfree.data.statistics.DefaultMultiValueCategoryDataset; +import org.jfree.data.statistics.DefaultStatisticalCategoryDataset; +import org.jfree.data.statistics.MultiValueCategoryDataset; +import org.jfree.data.xy.DefaultIntervalXYDataset; +import org.jfree.data.xy.DefaultTableXYDataset; +import org.jfree.data.xy.DefaultXYDataset; +import org.jfree.data.xy.IntervalXYDataset; +import org.jfree.data.xy.TableXYDataset; +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYIntervalSeries; +import org.jfree.data.xy.XYIntervalSeriesCollection; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.jfree.data.xy.YIntervalSeries; +import org.jfree.data.xy.YIntervalSeriesCollection; +import org.junit.Test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +/** + * Tests for the {@link DatasetUtilities} class. + */ +public class DatasetUtilitiesTest { + + private static final double EPSILON = 0.0000000001; + + /** + * Some tests to verify that Java does what I think it does! + */ + @Test + public void testJava() { + assertTrue(Double.isNaN(Math.min(1.0, Double.NaN))); + assertTrue(Double.isNaN(Math.max(1.0, Double.NaN))); + } + + /** + * Some tests for the calculatePieDatasetTotal() method. + */ + @Test + public void testCalculatePieDatasetTotal() { + DefaultPieDataset d = new DefaultPieDataset(); + assertEquals(0.0, DatasetUtilities.calculatePieDatasetTotal(d), + EPSILON); + d.setValue("A", 1.0); + assertEquals(1.0, DatasetUtilities.calculatePieDatasetTotal(d), + EPSILON); + d.setValue("B", 3.0); + assertEquals(4.0, DatasetUtilities.calculatePieDatasetTotal(d), + EPSILON); + } + + /** + * Some tests for the findDomainBounds() method. + */ + @Test + public void testFindDomainBounds() { + XYDataset dataset = createXYDataset1(); + Range r = DatasetUtilities.findDomainBounds(dataset); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(3.0, r.getUpperBound(), EPSILON); + } + + /** + * This test checks that the standard method has 'includeInterval' + * defaulting to true. + */ + @Test + public void testFindDomainBounds2() { + DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset(); + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] x1Start = new double[] {0.9, 1.9, 2.9}; + double[] x1End = new double[] {1.1, 2.1, 3.1}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] y1Start = new double[] {1.09, 2.09, 3.09}; + double[] y1End = new double[] {1.11, 2.11, 3.11}; + double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, + y1End}; + dataset.addSeries("S1", data1); + Range r = DatasetUtilities.findDomainBounds(dataset); + assertEquals(0.9, r.getLowerBound(), EPSILON); + assertEquals(3.1, r.getUpperBound(), EPSILON); + } + + /** + * This test checks that when the 'includeInterval' flag is false, the + * bounds come from the regular x-values. + */ + @Test + public void testFindDomainBounds3() { + DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset(); + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] x1Start = new double[] {0.9, 1.9, 2.9}; + double[] x1End = new double[] {1.1, 2.1, 3.1}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] y1Start = new double[] {1.09, 2.09, 3.09}; + double[] y1End = new double[] {1.11, 2.11, 3.11}; + double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, + y1End}; + dataset.addSeries("S1", data1); + Range r = DatasetUtilities.findDomainBounds(dataset, false); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(3.0, r.getUpperBound(), EPSILON); + } + + /** + * This test checks that NaN values are ignored. + */ + @Test + public void testFindDomainBounds_NaN() { + DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset(); + double[] x1 = new double[] {1.0, 2.0, Double.NaN}; + double[] x1Start = new double[] {0.9, 1.9, Double.NaN}; + double[] x1End = new double[] {1.1, 2.1, Double.NaN}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] y1Start = new double[] {1.09, 2.09, 3.09}; + double[] y1End = new double[] {1.11, 2.11, 3.11}; + double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, + y1End}; + dataset.addSeries("S1", data1); + Range r = DatasetUtilities.findDomainBounds(dataset); + assertEquals(0.9, r.getLowerBound(), EPSILON); + assertEquals(2.1, r.getUpperBound(), EPSILON); + + r = DatasetUtilities.findDomainBounds(dataset, false); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(2.0, r.getUpperBound(), EPSILON); + } + + /** + * Some tests for the iterateDomainBounds() method. + */ + @Test + public void testIterateDomainBounds() { + XYDataset dataset = createXYDataset1(); + Range r = DatasetUtilities.iterateDomainBounds(dataset); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(3.0, r.getUpperBound(), EPSILON); + } + + /** + * Check that NaN values in the dataset are ignored. + */ + @Test + public void testIterateDomainBounds_NaN() { + DefaultXYDataset dataset = new DefaultXYDataset(); + double[] x = new double[] {1.0, 2.0, Double.NaN, 3.0}; + double[] y = new double[] {9.0, 8.0, 7.0, 6.0}; + dataset.addSeries("S1", new double[][] {x, y}); + Range r = DatasetUtilities.iterateDomainBounds(dataset); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(3.0, r.getUpperBound(), EPSILON); + } + + /** + * Check that NaN values in the IntervalXYDataset are ignored. + */ + @Test + public void testIterateDomainBounds_NaN2() { + DefaultIntervalXYDataset dataset = new DefaultIntervalXYDataset(); + double[] x1 = new double[] {Double.NaN, 2.0, 3.0}; + double[] x1Start = new double[] {0.9, Double.NaN, 2.9}; + double[] x1End = new double[] {1.1, Double.NaN, 3.1}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] y1Start = new double[] {1.09, 2.09, 3.09}; + double[] y1End = new double[] {1.11, 2.11, 3.11}; + double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, + y1End}; + dataset.addSeries("S1", data1); + Range r = DatasetUtilities.iterateDomainBounds(dataset, false); + assertEquals(2.0, r.getLowerBound(), EPSILON); + assertEquals(3.0, r.getUpperBound(), EPSILON); + r = DatasetUtilities.iterateDomainBounds(dataset, true); + assertEquals(0.9, r.getLowerBound(), EPSILON); + assertEquals(3.1, r.getUpperBound(), EPSILON); + } + + /** + * Some tests for the findRangeBounds() for a CategoryDataset method. + */ + @Test + public void testFindRangeBounds_CategoryDataset() { + CategoryDataset dataset = createCategoryDataset1(); + Range r = DatasetUtilities.findRangeBounds(dataset); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(6.0, r.getUpperBound(), EPSILON); + } + + /** + * Some tests for the findRangeBounds() method on an XYDataset. + */ + @Test + public void testFindRangeBounds() { + XYDataset dataset = createXYDataset1(); + Range r = DatasetUtilities.findRangeBounds(dataset); + assertEquals(100.0, r.getLowerBound(), EPSILON); + assertEquals(105.0, r.getUpperBound(), EPSILON); + } + + /** + * A test for the findRangeBounds(XYDataset) method using + * an IntervalXYDataset. + */ + @Test + public void testFindRangeBounds2() { + YIntervalSeriesCollection dataset = new YIntervalSeriesCollection(); + Range r = DatasetUtilities.findRangeBounds(dataset); + assertNull(r); + YIntervalSeries s1 = new YIntervalSeries("S1"); + dataset.addSeries(s1); + r = DatasetUtilities.findRangeBounds(dataset); + assertNull(r); + + // try a single item + s1.add(1.0, 2.0, 1.5, 2.5); + r = DatasetUtilities.findRangeBounds(dataset); + assertEquals(1.5, r.getLowerBound(), EPSILON); + assertEquals(2.5, r.getUpperBound(), EPSILON); + + r = DatasetUtilities.findRangeBounds(dataset, false); + assertEquals(2.0, r.getLowerBound(), EPSILON); + assertEquals(2.0, r.getUpperBound(), EPSILON); + + // another item + s1.add(2.0, 2.0, 1.4, 2.1); + r = DatasetUtilities.findRangeBounds(dataset); + assertEquals(1.4, r.getLowerBound(), EPSILON); + assertEquals(2.5, r.getUpperBound(), EPSILON); + + // another empty series + YIntervalSeries s2 = new YIntervalSeries("S2"); + dataset.addSeries(s2); + r = DatasetUtilities.findRangeBounds(dataset); + assertEquals(1.4, r.getLowerBound(), EPSILON); + assertEquals(2.5, r.getUpperBound(), EPSILON); + + // an item in series 2 + s2.add(1.0, 2.0, 1.9, 2.6); + r = DatasetUtilities.findRangeBounds(dataset); + assertEquals(1.4, r.getLowerBound(), EPSILON); + assertEquals(2.6, r.getUpperBound(), EPSILON); + + // what if we don't want the interval? + r = DatasetUtilities.findRangeBounds(dataset, false); + assertEquals(2.0, r.getLowerBound(), EPSILON); + assertEquals(2.0, r.getUpperBound(), EPSILON); + } + + /** + * Some tests for the iterateRangeBounds() method. + */ + @Test + public void testIterateRangeBounds_CategoryDataset() { + CategoryDataset dataset = createCategoryDataset1(); + Range r = DatasetUtilities.iterateRangeBounds(dataset, false); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(6.0, r.getUpperBound(), EPSILON); + } + + /** + * Some checks for the iterateRangeBounds() method. + */ + @Test + public void testIterateRangeBounds2_CategoryDataset() { + // an empty dataset should return a null range + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + Range r = DatasetUtilities.iterateRangeBounds(dataset, false); + assertNull(r); + + // a dataset with a single value + dataset.addValue(1.23, "R1", "C1"); + r = DatasetUtilities.iterateRangeBounds(dataset, false); + assertEquals(1.23, r.getLowerBound(), EPSILON); + assertEquals(1.23, r.getUpperBound(), EPSILON); + + // null is ignored + dataset.addValue(null, "R2", "C1"); + r = DatasetUtilities.iterateRangeBounds(dataset, false); + assertEquals(1.23, r.getLowerBound(), EPSILON); + assertEquals(1.23, r.getUpperBound(), EPSILON); + + // a Double.NaN should be ignored + dataset.addValue(Double.NaN, "R2", "C1"); + r = DatasetUtilities.iterateRangeBounds(dataset, false); + assertEquals(1.23, r.getLowerBound(), EPSILON); + assertEquals(1.23, r.getUpperBound(), EPSILON); + } + + /** + * Some checks for the iterateRangeBounds() method using an + * IntervalCategoryDataset. + */ + @Test + public void testIterateRangeBounds3_CategoryDataset() { + Number[][] starts = new Double[2][3]; + Number[][] ends = new Double[2][3]; + starts[0][0] = new Double(1.0); + starts[0][1] = new Double(2.0); + starts[0][2] = new Double(3.0); + starts[1][0] = new Double(11.0); + starts[1][1] = new Double(12.0); + starts[1][2] = new Double(13.0); + ends[0][0] = new Double(4.0); + ends[0][1] = new Double(5.0); + ends[0][2] = new Double(6.0); + ends[1][0] = new Double(16.0); + ends[1][1] = new Double(15.0); + ends[1][2] = new Double(14.0); + + DefaultIntervalCategoryDataset d = new DefaultIntervalCategoryDataset( + starts, ends); + Range r = DatasetUtilities.iterateRangeBounds(d, false); + assertEquals(4.0, r.getLowerBound(), EPSILON); + assertEquals(16.0, r.getUpperBound(), EPSILON); + r = DatasetUtilities.iterateRangeBounds(d, true); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(16.0, r.getUpperBound(), EPSILON); + } + + /** + * Some tests for the iterateRangeBounds() method. + */ + @Test + public void testIterateRangeBounds() { + XYDataset dataset = createXYDataset1(); + Range r = DatasetUtilities.iterateRangeBounds(dataset); + assertEquals(100.0, r.getLowerBound(), EPSILON); + assertEquals(105.0, r.getUpperBound(), EPSILON); + } + + /** + * Check the range returned when a series contains a null value. + */ + @Test + public void testIterateRangeBounds2() { + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + s1.add(2.0, null); + s1.add(3.0, 3.3); + XYSeriesCollection dataset = new XYSeriesCollection(s1); + Range r = DatasetUtilities.iterateRangeBounds(dataset); + assertEquals(1.1, r.getLowerBound(), EPSILON); + assertEquals(3.3, r.getUpperBound(), EPSILON); + } + + /** + * Some checks for the iterateRangeBounds() method. + */ + @Test + public void testIterateRangeBounds3() { + // an empty dataset should return a null range + XYSeriesCollection dataset = new XYSeriesCollection(); + Range r = DatasetUtilities.iterateRangeBounds(dataset); + assertNull(r); + XYSeries s1 = new XYSeries("S1"); + dataset.addSeries(s1); + r = DatasetUtilities.iterateRangeBounds(dataset); + assertNull(r); + + // a dataset with a single value + s1.add(1.0, 1.23); + r = DatasetUtilities.iterateRangeBounds(dataset); + assertEquals(1.23, r.getLowerBound(), EPSILON); + assertEquals(1.23, r.getUpperBound(), EPSILON); + + // null is ignored + s1.add(2.0, null); + r = DatasetUtilities.iterateRangeBounds(dataset); + assertEquals(1.23, r.getLowerBound(), EPSILON); + assertEquals(1.23, r.getUpperBound(), EPSILON); + + // Double.NaN DOESN'T mess things up + s1.add(3.0, Double.NaN); + r = DatasetUtilities.iterateRangeBounds(dataset); + assertEquals(1.23, r.getLowerBound(), EPSILON); + assertEquals(1.23, r.getUpperBound(), EPSILON); + } + + /** + * Some checks for the range bounds of a dataset that implements the + * {@link IntervalXYDataset} interface. + */ + @Test + public void testIterateRangeBounds4() { + YIntervalSeriesCollection dataset = new YIntervalSeriesCollection(); + Range r = DatasetUtilities.iterateRangeBounds(dataset); + assertNull(r); + YIntervalSeries s1 = new YIntervalSeries("S1"); + dataset.addSeries(s1); + r = DatasetUtilities.iterateRangeBounds(dataset); + assertNull(r); + + // try a single item + s1.add(1.0, 2.0, 1.5, 2.5); + r = DatasetUtilities.iterateRangeBounds(dataset); + assertEquals(1.5, r.getLowerBound(), EPSILON); + assertEquals(2.5, r.getUpperBound(), EPSILON); + + // another item + s1.add(2.0, 2.0, 1.4, 2.1); + r = DatasetUtilities.iterateRangeBounds(dataset); + assertEquals(1.4, r.getLowerBound(), EPSILON); + assertEquals(2.5, r.getUpperBound(), EPSILON); + + // another empty series + YIntervalSeries s2 = new YIntervalSeries("S2"); + dataset.addSeries(s2); + r = DatasetUtilities.iterateRangeBounds(dataset); + assertEquals(1.4, r.getLowerBound(), EPSILON); + assertEquals(2.5, r.getUpperBound(), EPSILON); + + // an item in series 2 + s2.add(1.0, 2.0, 1.9, 2.6); + r = DatasetUtilities.iterateRangeBounds(dataset); + assertEquals(1.4, r.getLowerBound(), EPSILON); + assertEquals(2.6, r.getUpperBound(), EPSILON); + } + + /** + * Some tests for the findMinimumDomainValue() method. + */ + @Test + public void testFindMinimumDomainValue() { + XYDataset dataset = createXYDataset1(); + Number minimum = DatasetUtilities.findMinimumDomainValue(dataset); + assertEquals(new Double(1.0), minimum); + } + + /** + * Some tests for the findMaximumDomainValue() method. + */ + @Test + public void testFindMaximumDomainValue() { + XYDataset dataset = createXYDataset1(); + Number maximum = DatasetUtilities.findMaximumDomainValue(dataset); + assertEquals(new Double(3.0), maximum); + } + + /** + * Some tests for the findMinimumRangeValue() method. + */ + @Test + public void testFindMinimumRangeValue() { + CategoryDataset d1 = createCategoryDataset1(); + Number min1 = DatasetUtilities.findMinimumRangeValue(d1); + assertEquals(new Double(1.0), min1); + + XYDataset d2 = createXYDataset1(); + Number min2 = DatasetUtilities.findMinimumRangeValue(d2); + assertEquals(new Double(100.0), min2); + } + + /** + * Some tests for the findMaximumRangeValue() method. + */ + @Test + public void testFindMaximumRangeValue() { + CategoryDataset d1 = createCategoryDataset1(); + Number max1 = DatasetUtilities.findMaximumRangeValue(d1); + assertEquals(new Double(6.0), max1); + + XYDataset dataset = createXYDataset1(); + Number maximum = DatasetUtilities.findMaximumRangeValue(dataset); + assertEquals(new Double(105.0), maximum); + } + + /** + * A quick test of the min and max range value methods. + */ + @Test + public void testMinMaxRange() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(100.0, "Series 1", "Type 1"); + dataset.addValue(101.1, "Series 1", "Type 2"); + Number min = DatasetUtilities.findMinimumRangeValue(dataset); + assertTrue(min.doubleValue() < 100.1); + Number max = DatasetUtilities.findMaximumRangeValue(dataset); + assertTrue(max.doubleValue() > 101.0); + } + + /** + * A test to reproduce bug report 803660. + */ + @Test + public void test803660() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(100.0, "Series 1", "Type 1"); + dataset.addValue(101.1, "Series 1", "Type 2"); + Number n = DatasetUtilities.findMaximumRangeValue(dataset); + assertTrue(n.doubleValue() > 101.0); + } + + /** + * A simple test for the cumulative range calculation. The sequence of + * "cumulative" values are considered to be { 0.0, 10.0, 25.0, 18.0 } so + * the range should be 0.0 -> 25.0. + */ + @Test + public void testCumulativeRange1() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(10.0, "Series 1", "Start"); + dataset.addValue(15.0, "Series 1", "Delta 1"); + dataset.addValue(-7.0, "Series 1", "Delta 2"); + Range range = DatasetUtilities.findCumulativeRangeBounds(dataset); + assertEquals(0.0, range.getLowerBound(), 0.00000001); + assertEquals(25.0, range.getUpperBound(), 0.00000001); + } + + /** + * A further test for the cumulative range calculation. + */ + @Test + public void testCumulativeRange2() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(-21.4, "Series 1", "Start Value"); + dataset.addValue(11.57, "Series 1", "Delta 1"); + dataset.addValue(3.51, "Series 1", "Delta 2"); + dataset.addValue(-12.36, "Series 1", "Delta 3"); + dataset.addValue(3.39, "Series 1", "Delta 4"); + dataset.addValue(38.68, "Series 1", "Delta 5"); + dataset.addValue(-43.31, "Series 1", "Delta 6"); + dataset.addValue(-29.59, "Series 1", "Delta 7"); + dataset.addValue(35.30, "Series 1", "Delta 8"); + dataset.addValue(5.0, "Series 1", "Delta 9"); + Range range = DatasetUtilities.findCumulativeRangeBounds(dataset); + assertEquals(-49.51, range.getLowerBound(), 0.00000001); + assertEquals(23.39, range.getUpperBound(), 0.00000001); + } + + /** + * A further test for the cumulative range calculation. + */ + @Test + public void testCumulativeRange3() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(15.76, "Product 1", "Labour"); + dataset.addValue(8.66, "Product 1", "Administration"); + dataset.addValue(4.71, "Product 1", "Marketing"); + dataset.addValue(3.51, "Product 1", "Distribution"); + dataset.addValue(32.64, "Product 1", "Total Expense"); + Range range = DatasetUtilities.findCumulativeRangeBounds(dataset); + assertEquals(0.0, range.getLowerBound(), EPSILON); + assertEquals(65.28, range.getUpperBound(), EPSILON); + } + + /** + * Check that the findCumulativeRangeBounds() method ignores Double.NaN + * values. + */ + @Test + public void testCumulativeRange_NaN() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(10.0, "Series 1", "Start"); + dataset.addValue(15.0, "Series 1", "Delta 1"); + dataset.addValue(Double.NaN, "Series 1", "Delta 2"); + Range range = DatasetUtilities.findCumulativeRangeBounds(dataset); + assertEquals(0.0, range.getLowerBound(), EPSILON); + assertEquals(25.0, range.getUpperBound(), EPSILON); + } + + /** + * Test the creation of a dataset from an array. + */ + @Test + public void testCreateCategoryDataset1() { + String[] rowKeys = {"R1", "R2", "R3"}; + String[] columnKeys = {"C1", "C2"}; + double[][] data = new double[3][]; + data[0] = new double[] {1.1, 1.2}; + data[1] = new double[] {2.1, 2.2}; + data[2] = new double[] {3.1, 3.2}; + CategoryDataset dataset = DatasetUtilities.createCategoryDataset( + rowKeys, columnKeys, data); + assertTrue(dataset.getRowCount() == 3); + assertTrue(dataset.getColumnCount() == 2); + } + + /** + * Test the creation of a dataset from an array. This time is should fail + * because the array dimensions are around the wrong way. + */ + @Test + public void testCreateCategoryDataset2() { + boolean pass = false; + String[] rowKeys = {"R1", "R2", "R3"}; + String[] columnKeys = {"C1", "C2"}; + double[][] data = new double[2][]; + data[0] = new double[] {1.1, 1.2, 1.3}; + data[1] = new double[] {2.1, 2.2, 2.3}; + CategoryDataset dataset = null; + try { + dataset = DatasetUtilities.createCategoryDataset(rowKeys, + columnKeys, data); + } + catch (IllegalArgumentException e) { + pass = true; // got it! + } + assertTrue(pass); + assertTrue(dataset == null); + } + + /** + * Test for a bug reported in the forum: + * + * http://www.jfree.org/phpBB2/viewtopic.php?t=7903 + */ + @Test + public void testMaximumStackedRangeValue() { + double v1 = 24.3; + double v2 = 14.2; + double v3 = 33.2; + double v4 = 32.4; + double v5 = 26.3; + double v6 = 22.6; + Number answer = new Double(Math.max(v1 + v2 + v3, v4 + v5 + v6)); + DefaultCategoryDataset d = new DefaultCategoryDataset(); + d.addValue(v1, "Row 0", "Column 0"); + d.addValue(v2, "Row 1", "Column 0"); + d.addValue(v3, "Row 2", "Column 0"); + d.addValue(v4, "Row 0", "Column 1"); + d.addValue(v5, "Row 1", "Column 1"); + d.addValue(v6, "Row 2", "Column 1"); + Number max = DatasetUtilities.findMaximumStackedRangeValue(d); + assertTrue(max.equals(answer)); + } + + /** + * Some checks for the findStackedRangeBounds() method. + */ + @Test + public void testFindStackedRangeBounds_CategoryDataset1() { + CategoryDataset d1 = createCategoryDataset1(); + Range r = DatasetUtilities.findStackedRangeBounds(d1); + assertEquals(0.0, r.getLowerBound(), EPSILON); + assertEquals(15.0, r.getUpperBound(), EPSILON); + + d1 = createCategoryDataset2(); + r = DatasetUtilities.findStackedRangeBounds(d1); + assertEquals(-2.0, r.getLowerBound(), EPSILON); + assertEquals(2.0, r.getUpperBound(), EPSILON); + } + + /** + * Some checks for the findStackedRangeBounds() method. + */ + @Test + public void testFindStackedRangeBounds_CategoryDataset2() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + Range r = DatasetUtilities.findStackedRangeBounds(dataset); + assertTrue(r == null); + + dataset.addValue(5.0, "R1", "C1"); + r = DatasetUtilities.findStackedRangeBounds(dataset, 3.0); + assertEquals(3.0, r.getLowerBound(), EPSILON); + assertEquals(8.0, r.getUpperBound(), EPSILON); + + dataset.addValue(-1.0, "R2", "C1"); + r = DatasetUtilities.findStackedRangeBounds(dataset, 3.0); + assertEquals(2.0, r.getLowerBound(), EPSILON); + assertEquals(8.0, r.getUpperBound(), EPSILON); + + dataset.addValue(null, "R3", "C1"); + r = DatasetUtilities.findStackedRangeBounds(dataset, 3.0); + assertEquals(2.0, r.getLowerBound(), EPSILON); + assertEquals(8.0, r.getUpperBound(), EPSILON); + + dataset.addValue(Double.NaN, "R4", "C1"); + r = DatasetUtilities.findStackedRangeBounds(dataset, 3.0); + assertEquals(2.0, r.getLowerBound(), EPSILON); + assertEquals(8.0, r.getUpperBound(), EPSILON); + } + + /** + * Some checks for the findStackedRangeBounds(CategoryDataset, + * KeyToGroupMap) method. + */ + @Test + public void testFindStackedRangeBounds_CategoryDataset3() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + KeyToGroupMap map = new KeyToGroupMap("Group A"); + Range r = DatasetUtilities.findStackedRangeBounds(dataset, map); + assertTrue(r == null); + + dataset.addValue(1.0, "R1", "C1"); + dataset.addValue(2.0, "R2", "C1"); + dataset.addValue(3.0, "R3", "C1"); + dataset.addValue(4.0, "R4", "C1"); + + map.mapKeyToGroup("R1", "Group A"); + map.mapKeyToGroup("R2", "Group A"); + map.mapKeyToGroup("R3", "Group B"); + map.mapKeyToGroup("R4", "Group B"); + + r = DatasetUtilities.findStackedRangeBounds(dataset, map); + assertEquals(0.0, r.getLowerBound(), EPSILON); + assertEquals(7.0, r.getUpperBound(), EPSILON); + + dataset.addValue(null, "R5", "C1"); + r = DatasetUtilities.findStackedRangeBounds(dataset, map); + assertEquals(0.0, r.getLowerBound(), EPSILON); + assertEquals(7.0, r.getUpperBound(), EPSILON); + + dataset.addValue(Double.NaN, "R6", "C1"); + r = DatasetUtilities.findStackedRangeBounds(dataset, map); + assertEquals(0.0, r.getLowerBound(), EPSILON); + assertEquals(7.0, r.getUpperBound(), EPSILON); + } + + /** + * Some checks for the findStackedRangeBounds() method. + */ + @Test + public void testFindStackedRangeBoundsForTableXYDataset1() { + TableXYDataset d2 = createTableXYDataset1(); + Range r = DatasetUtilities.findStackedRangeBounds(d2); + assertEquals(-2.0, r.getLowerBound(), EPSILON); + assertEquals(2.0, r.getUpperBound(), EPSILON); + } + + /** + * Some checks for the findStackedRangeBounds() method. + */ + @Test + public void testFindStackedRangeBoundsForTableXYDataset2() { + DefaultTableXYDataset d = new DefaultTableXYDataset(); + Range r = DatasetUtilities.findStackedRangeBounds(d); + assertEquals(r, new Range(0.0, 0.0)); + } + + /** + * Tests the stacked range extent calculation. + */ + @Test + public void testStackedRangeWithMap() { + CategoryDataset d = createCategoryDataset1(); + KeyToGroupMap map = new KeyToGroupMap("G0"); + map.mapKeyToGroup("R2", "G1"); + Range r = DatasetUtilities.findStackedRangeBounds(d, map); + assertEquals(0.0, r.getLowerBound(), EPSILON); + assertEquals(9.0, r.getUpperBound(), EPSILON); + } + + /** + * Some checks for the isEmptyOrNull(XYDataset) method. + */ + @Test + public void testIsEmptyOrNullXYDataset() { + XYSeriesCollection dataset = null; + assertTrue(DatasetUtilities.isEmptyOrNull(dataset)); + dataset = new XYSeriesCollection(); + assertTrue(DatasetUtilities.isEmptyOrNull(dataset)); + XYSeries s1 = new XYSeries("S1"); + dataset.addSeries(s1); + assertTrue(DatasetUtilities.isEmptyOrNull(dataset)); + s1.add(1.0, 2.0); + assertFalse(DatasetUtilities.isEmptyOrNull(dataset)); + s1.clear(); + assertTrue(DatasetUtilities.isEmptyOrNull(dataset)); + } + + /** + * Some checks for the limitPieDataset() methods. + */ + @Test + public void testLimitPieDataset() { + + // check that empty dataset is handled OK + DefaultPieDataset d1 = new DefaultPieDataset(); + PieDataset d2 = DatasetUtilities.createConsolidatedPieDataset(d1, + "Other", 0.05); + assertEquals(0, d2.getItemCount()); + + // check that minItem limit is observed + d1.setValue("Item 1", 1.0); + d1.setValue("Item 2", 49.50); + d1.setValue("Item 3", 49.50); + d2 = DatasetUtilities.createConsolidatedPieDataset(d1, "Other", 0.05); + assertEquals(3, d2.getItemCount()); + assertEquals("Item 1", d2.getKey(0)); + assertEquals("Item 2", d2.getKey(1)); + assertEquals("Item 3", d2.getKey(2)); + + // check that minItem limit is observed + d1.setValue("Item 4", 1.0); + d2 = DatasetUtilities.createConsolidatedPieDataset(d1, "Other", 0.05, + 2); + + // and that simple aggregation works + assertEquals(3, d2.getItemCount()); + assertEquals("Item 2", d2.getKey(0)); + assertEquals("Item 3", d2.getKey(1)); + assertEquals("Other", d2.getKey(2)); + assertEquals(new Double(2.0), d2.getValue("Other")); + + } + + /** + * Some checks for the sampleFunction2D() method. + */ + @Test + public void testSampleFunction2D() { + Function2D f = new LineFunction2D(0, 1); + XYDataset dataset = DatasetUtilities.sampleFunction2D(f, 0.0, 1.0, 2, + "S1"); + assertEquals(1, dataset.getSeriesCount()); + assertEquals("S1", dataset.getSeriesKey(0)); + assertEquals(2, dataset.getItemCount(0)); + assertEquals(0.0, dataset.getXValue(0, 0), EPSILON); + assertEquals(0.0, dataset.getYValue(0, 0), EPSILON); + assertEquals(1.0, dataset.getXValue(0, 1), EPSILON); + assertEquals(1.0, dataset.getYValue(0, 1), EPSILON); + } + + /** + * A simple check for the findMinimumStackedRangeValue() method. + */ + @Test + public void testFindMinimumStackedRangeValue() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + + // an empty dataset should return a null max + Number min = DatasetUtilities.findMinimumStackedRangeValue(dataset); + assertNull(min); + + dataset.addValue(1.0, "R1", "C1"); + min = DatasetUtilities.findMinimumStackedRangeValue(dataset); + assertEquals(0.0, min.doubleValue(), EPSILON); + + dataset.addValue(2.0, "R2", "C1"); + min = DatasetUtilities.findMinimumStackedRangeValue(dataset); + assertEquals(0.0, min.doubleValue(), EPSILON); + + dataset.addValue(-3.0, "R3", "C1"); + min = DatasetUtilities.findMinimumStackedRangeValue(dataset); + assertEquals(-3.0, min.doubleValue(), EPSILON); + + dataset.addValue(Double.NaN, "R4", "C1"); + min = DatasetUtilities.findMinimumStackedRangeValue(dataset); + assertEquals(-3.0, min.doubleValue(), EPSILON); + } + + /** + * A simple check for the findMaximumStackedRangeValue() method. + */ + @Test + public void testFindMinimumStackedRangeValue2() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(-1.0, "R1", "C1"); + Number min = DatasetUtilities.findMinimumStackedRangeValue(dataset); + assertEquals(-1.0, min.doubleValue(), EPSILON); + + dataset.addValue(-2.0, "R2", "C1"); + min = DatasetUtilities.findMinimumStackedRangeValue(dataset); + assertEquals(-3.0, min.doubleValue(), EPSILON); + } + + /** + * A simple check for the findMaximumStackedRangeValue() method. + */ + @Test + public void testFindMaximumStackedRangeValue() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + + // an empty dataset should return a null max + Number max = DatasetUtilities.findMaximumStackedRangeValue(dataset); + assertNull(max); + + dataset.addValue(1.0, "R1", "C1"); + max = DatasetUtilities.findMaximumStackedRangeValue(dataset); + assertEquals(1.0, max.doubleValue(), EPSILON); + + dataset.addValue(2.0, "R2", "C1"); + max = DatasetUtilities.findMaximumStackedRangeValue(dataset); + assertEquals(3.0, max.doubleValue(), EPSILON); + + dataset.addValue(-3.0, "R3", "C1"); + max = DatasetUtilities.findMaximumStackedRangeValue(dataset); + assertEquals(3.0, max.doubleValue(), EPSILON); + + dataset.addValue(Double.NaN, "R4", "C1"); + max = DatasetUtilities.findMaximumStackedRangeValue(dataset); + assertEquals(3.0, max.doubleValue(), EPSILON); + } + + /** + * A simple check for the findMaximumStackedRangeValue() method. + */ + @Test + public void testFindMaximumStackedRangeValue2() { + DefaultCategoryDataset dataset = new DefaultCategoryDataset(); + dataset.addValue(-1.0, "R1", "C1"); + Number max = DatasetUtilities.findMaximumStackedRangeValue(dataset); + assertEquals(0.0, max.doubleValue(), EPSILON); + + dataset.addValue(-2.0, "R2", "C1"); + max = DatasetUtilities.findMaximumStackedRangeValue(dataset); + assertEquals(0.0, max.doubleValue(), EPSILON); + } + + /** + * Creates a dataset for testing. + * + * @return A dataset. + */ + private CategoryDataset createCategoryDataset1() { + DefaultCategoryDataset result = new DefaultCategoryDataset(); + result.addValue(1.0, "R0", "C0"); + result.addValue(1.0, "R1", "C0"); + result.addValue(1.0, "R2", "C0"); + result.addValue(4.0, "R0", "C1"); + result.addValue(5.0, "R1", "C1"); + result.addValue(6.0, "R2", "C1"); + return result; + } + + /** + * Creates a dataset for testing. + * + * @return A dataset. + */ + private CategoryDataset createCategoryDataset2() { + DefaultCategoryDataset result = new DefaultCategoryDataset(); + result.addValue(1.0, "R0", "C0"); + result.addValue(-2.0, "R1", "C0"); + result.addValue(2.0, "R0", "C1"); + result.addValue(-1.0, "R1", "C1"); + return result; + } + + + /** + * Creates a dataset for testing. + * + * @return A dataset. + */ + private XYDataset createXYDataset1() { + XYSeries series1 = new XYSeries("S1"); + series1.add(1.0, 100.0); + series1.add(2.0, 101.0); + series1.add(3.0, 102.0); + XYSeries series2 = new XYSeries("S2"); + series2.add(1.0, 103.0); + series2.add(2.0, null); + series2.add(3.0, 105.0); + XYSeriesCollection result = new XYSeriesCollection(); + result.addSeries(series1); + result.addSeries(series2); + result.setIntervalWidth(0.0); + return result; + } + + /** + * Creates a sample dataset for testing purposes. + * + * @return A sample dataset. + */ + private TableXYDataset createTableXYDataset1() { + DefaultTableXYDataset dataset = new DefaultTableXYDataset(); + + XYSeries s1 = new XYSeries("Series 1", true, false); + s1.add(1.0, 1.0); + s1.add(2.0, 2.0); + dataset.addSeries(s1); + + XYSeries s2 = new XYSeries("Series 2", true, false); + s2.add(1.0, -2.0); + s2.add(2.0, -1.0); + dataset.addSeries(s2); + + return dataset; + } + + /** + * Some checks for the iteratorToFindRangeBounds(XYDataset...) method. + */ + @Test + public void testIterateToFindRangeBounds1_XYDataset() { + // null dataset throws IllegalArgumentException + boolean pass = false; + try { + DatasetUtilities.iterateToFindRangeBounds(null, new ArrayList(), + new Range(0.0, 1.0), true); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + // null list throws IllegalArgumentException + pass = false; + try { + DatasetUtilities.iterateToFindRangeBounds(new XYSeriesCollection(), + null, new Range(0.0, 1.0), true); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + // null range throws IllegalArgumentException + pass = false; + try { + DatasetUtilities.iterateToFindRangeBounds(new XYSeriesCollection(), + new ArrayList(), null, true); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some tests for the iterateToFindRangeBounds() method. + */ + @Test + public void testIterateToFindRangeBounds2_XYDataset() { + List visibleSeriesKeys = new ArrayList(); + Range xRange = new Range(0.0, 10.0); + + // empty dataset returns null + XYSeriesCollection dataset = new XYSeriesCollection(); + Range r = DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, xRange, false); + assertNull(r); + + // add an empty series + XYSeries s1 = new XYSeries("A"); + dataset.addSeries(s1); + visibleSeriesKeys.add("A"); + r = DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, xRange, false); + assertNull(r); + + // check a null value + s1.add(1.0, null); + r = DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, xRange, false); + assertNull(r); + + // check a NaN + s1.add(2.0, Double.NaN); + r = DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, xRange, false); + assertNull(r); + + // check a regular value + s1.add(3.0, 5.0); + r = DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, xRange, false); + assertEquals(new Range(5.0, 5.0), r); + + // check another regular value + s1.add(4.0, 6.0); + r = DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, xRange, false); + assertEquals(new Range(5.0, 6.0), r); + + // add a second series + XYSeries s2 = new XYSeries("B"); + dataset.addSeries(s2); + r = DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, xRange, false); + assertEquals(new Range(5.0, 6.0), r); + visibleSeriesKeys.add("B"); + r = DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, xRange, false); + assertEquals(new Range(5.0, 6.0), r); + + // add a value to the second series + s2.add(5.0, 15.0); + r = DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, xRange, false); + assertEquals(new Range(5.0, 15.0), r); + + // add a value that isn't in the xRange + s2.add(15.0, 150.0); + r = DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, xRange, false); + assertEquals(new Range(5.0, 15.0), r); + + r = DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, new Range(0.0, 20.0), false); + assertEquals(new Range(5.0, 150.0), r); + } + + /** + * Some checks for the iterateToFindRangeBounds() method when applied to + * a BoxAndWhiskerXYDataset. + */ + @Test + public void testIterateToFindRangeBounds_BoxAndWhiskerXYDataset() { + DefaultBoxAndWhiskerXYDataset dataset + = new DefaultBoxAndWhiskerXYDataset("Series 1"); + List visibleSeriesKeys = new ArrayList(); + visibleSeriesKeys.add("Series 1"); + Range xRange = new Range(Double.NEGATIVE_INFINITY, + Double.POSITIVE_INFINITY); + assertNull(DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, xRange, false)); + + dataset.add(new Date(50L), new BoxAndWhiskerItem(5.0, 4.9, 2.0, 8.0, + 1.0, 9.0, 0.0, 10.0, new ArrayList())); + assertEquals(new Range(5.0, 5.0), + DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, xRange, false)); + assertEquals(new Range(1.0, 9.0), + DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, xRange, true)); + } + + /** + * Some checks for the iterateToFindRangeBounds(CategoryDataset...) + * method. + */ + @Test + public void testIterateToFindRangeBounds_StatisticalCategoryDataset() { + DefaultStatisticalCategoryDataset dataset + = new DefaultStatisticalCategoryDataset(); + List visibleSeriesKeys = new ArrayList(); + assertNull(DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, false)); + dataset.add(1.0, 0.5, "R1", "C1"); + visibleSeriesKeys.add("R1"); + assertEquals(new Range(1.0, 1.0), + DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, false)); + assertEquals(new Range(0.5, 1.5), + DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, true)); + } + + /** + * Some checks for the iterateToFindRangeBounds(CategoryDataset...) method + * with a {@link MultiValueCategoryDataset}. + */ + @Test + public void testIterateToFindRangeBounds_MultiValueCategoryDataset() { + DefaultMultiValueCategoryDataset dataset + = new DefaultMultiValueCategoryDataset(); + List visibleSeriesKeys = new ArrayList(); + assertNull(DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, true)); + List values = Arrays.asList(new Double[] {new Double(1.0)}); + dataset.add(values, "R1", "C1"); + visibleSeriesKeys.add("R1"); + assertEquals(new Range(1.0, 1.0), + DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, true)); + + values = Arrays.asList(new Double[] {new Double(2.0), new Double(3.0)}); + dataset.add(values, "R1", "C2"); + assertEquals(new Range(1.0, 3.0), + DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, true)); + + values = Arrays.asList(new Double[] {new Double(-1.0), + new Double(-2.0)}); + dataset.add(values, "R2", "C1"); + assertEquals(new Range(1.0, 3.0), + DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, true)); + visibleSeriesKeys.add("R2"); + assertEquals(new Range(-2.0, 3.0), + DatasetUtilities.iterateToFindRangeBounds(dataset, + visibleSeriesKeys, true)); + } + + /** + * Some checks for the iterateRangeBounds() method when passed an + * IntervalCategoryDataset. + */ + @Test + public void testIterateRangeBounds_IntervalCategoryDataset() { + TestIntervalCategoryDataset d = new TestIntervalCategoryDataset(); + d.addItem(1.0, 2.0, 3.0, "R1", "C1"); + assertEquals(new Range(1.0, 3.0), + DatasetUtilities.iterateRangeBounds(d)); + + d = new TestIntervalCategoryDataset(); + d.addItem(2.5, 2.0, 3.0, "R1", "C1"); + assertEquals(new Range(2.0, 3.0), + DatasetUtilities.iterateRangeBounds(d)); + + d = new TestIntervalCategoryDataset(); + d.addItem(4.0, 2.0, 3.0, "R1", "C1"); + assertEquals(new Range(2.0, 4.0), + DatasetUtilities.iterateRangeBounds(d)); + + d = new TestIntervalCategoryDataset(); + d.addItem(null, new Double(2.0), new Double(3.0), "R1", "C1"); + assertEquals(new Range(2.0, 3.0), + DatasetUtilities.iterateRangeBounds(d)); + + // try some nulls + d = new TestIntervalCategoryDataset(); + d.addItem(null, null, null, "R1", "C1"); + assertNull(DatasetUtilities.iterateRangeBounds(d)); + + d = new TestIntervalCategoryDataset(); + d.addItem(new Double(1.0), null, null, "R1", "C1"); + assertEquals(new Range(1.0, 1.0), + DatasetUtilities.iterateRangeBounds(d)); + + d = new TestIntervalCategoryDataset(); + d.addItem(null, new Double(1.0), null, "R1", "C1"); + assertEquals(new Range(1.0, 1.0), + DatasetUtilities.iterateRangeBounds(d)); + + d = new TestIntervalCategoryDataset(); + d.addItem(null, null, new Double(1.0), "R1", "C1"); + assertEquals(new Range(1.0, 1.0), + DatasetUtilities.iterateRangeBounds(d)); + } + + /** + * A test for bug 2849731. + */ + @Test + public void testBug2849731() { + TestIntervalCategoryDataset d = new TestIntervalCategoryDataset(); + d.addItem(2.5, 2.0, 3.0, "R1", "C1"); + d.addItem(new Double(4.0), null, null, "R2", "C1"); + assertEquals(new Range(2.0, 4.0), + DatasetUtilities.iterateRangeBounds(d)); + } + + /** + * Another test for bug 2849731. + */ + @Test + public void testBug2849731_2() { + XYIntervalSeriesCollection d = new XYIntervalSeriesCollection(); + XYIntervalSeries s = new XYIntervalSeries("S1"); + s.add(1.0, Double.NaN, Double.NaN, Double.NaN, 1.5, Double.NaN); + d.addSeries(s); + Range r = DatasetUtilities.iterateDomainBounds(d); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(1.0, r.getUpperBound(), EPSILON); + + s.add(1.0, 1.5, Double.NaN, Double.NaN, 1.5, Double.NaN); + r = DatasetUtilities.iterateDomainBounds(d); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(1.5, r.getUpperBound(), EPSILON); + + s.add(1.0, Double.NaN, 0.5, Double.NaN, 1.5, Double.NaN); + r = DatasetUtilities.iterateDomainBounds(d); + assertEquals(0.5, r.getLowerBound(), EPSILON); + assertEquals(1.5, r.getUpperBound(), EPSILON); + } + /** + * Yet another test for bug 2849731. + */ + @Test + public void testBug2849731_3() { + XYIntervalSeriesCollection d = new XYIntervalSeriesCollection(); + XYIntervalSeries s = new XYIntervalSeries("S1"); + s.add(1.0, Double.NaN, Double.NaN, 1.5, Double.NaN, Double.NaN); + d.addSeries(s); + Range r = DatasetUtilities.iterateRangeBounds(d); + assertEquals(1.5, r.getLowerBound(), EPSILON); + assertEquals(1.5, r.getUpperBound(), EPSILON); + + s.add(1.0, 1.5, Double.NaN, Double.NaN, Double.NaN, 2.5); + r = DatasetUtilities.iterateRangeBounds(d); + assertEquals(1.5, r.getLowerBound(), EPSILON); + assertEquals(2.5, r.getUpperBound(), EPSILON); + + s.add(1.0, Double.NaN, 0.5, Double.NaN, 3.5, Double.NaN); + r = DatasetUtilities.iterateRangeBounds(d); + assertEquals(1.5, r.getLowerBound(), EPSILON); + assertEquals(3.5, r.getUpperBound(), EPSILON); + } + + /** + * Check the findYValue() method with a dataset that is in ascending order + * of x-values. + */ + @Test + public void testFindYValue() { + XYSeries series = new XYSeries("S1"); + XYSeriesCollection dataset = new XYSeriesCollection(series); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 100.0))); + + series.add(1.0, 5.0); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 0.0))); + assertEquals(5.0, DatasetUtilities.findYValue(dataset, 0, 1.0), EPSILON); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 2.0))); + + series.add(2.0, 10.0); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 0.0))); + assertEquals(5.0, DatasetUtilities.findYValue(dataset, 0, 1.0), EPSILON); + assertEquals(6.25, DatasetUtilities.findYValue(dataset, 0, 1.25), EPSILON); + assertEquals(7.5, DatasetUtilities.findYValue(dataset, 0, 1.5), EPSILON); + assertEquals(10.0, DatasetUtilities.findYValue(dataset, 0, 2.0), EPSILON); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 3.0))); + } + + /** + * Check the findYValue() method with a dataset that is not sorted. + */ + @Test + public void testFindYValueNonSorted() { + XYSeries series = new XYSeries("S1", false); + XYSeriesCollection dataset = new XYSeriesCollection(series); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 100.0))); + + series.add(1.0, 5.0); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 0.0))); + assertEquals(5.0, DatasetUtilities.findYValue(dataset, 0, 1.0), EPSILON); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 2.0))); + + series.add(0.0, 10.0); + series.add(4.0, 20.0); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, -0.5))); + assertEquals(10.0, DatasetUtilities.findYValue(dataset, 0, 0.0), EPSILON); + assertEquals(5.0, DatasetUtilities.findYValue(dataset, 0, 1.0), EPSILON); + assertEquals(15.0, DatasetUtilities.findYValue(dataset, 0, 2.0), EPSILON); + assertEquals(20.0, DatasetUtilities.findYValue(dataset, 0, 4.0), EPSILON); + assertEquals(17.5, DatasetUtilities.findYValue(dataset, 0, 3.0), EPSILON); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 5.0))); + } + + /** + * Check the findYValue() method with a dataset that allows duplicate + * values. + */ + @Test + public void testFindYValueWithDuplicates() { + XYSeries series = new XYSeries("S1", true, true); + XYSeriesCollection dataset = new XYSeriesCollection(series); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 100.0))); + + series.add(1.0, 5.0); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 0.0))); + assertEquals(5.0, DatasetUtilities.findYValue(dataset, 0, 1.0), EPSILON); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 2.0))); + + series.add(1.0, 10.0); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 0.0))); + assertEquals(5.0, DatasetUtilities.findYValue(dataset, 0, 1.0), EPSILON); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 2.0))); + + series.add(2.0, 10.0); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 0.0))); + assertEquals(5.0, DatasetUtilities.findYValue(dataset, 0, 1.0), EPSILON); + assertEquals(10.0, DatasetUtilities.findYValue(dataset, 0, 1.25), EPSILON); + assertEquals(10.0, DatasetUtilities.findYValue(dataset, 0, 1.5), EPSILON); + assertEquals(10.0, DatasetUtilities.findYValue(dataset, 0, 2.0), EPSILON); + assertTrue(Double.isNaN(DatasetUtilities.findYValue(dataset, 0, 3.0))); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultHeatMapDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultHeatMapDatasetTest.java new file mode 100755 index 0000000..5f550cb --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultHeatMapDatasetTest.java @@ -0,0 +1,197 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * DefaultHeatMapDatasetTest.java + * ------------------------------ + * (C) Copyright 2009-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes: + * -------- + * 28-Jan-2009 : Version 1 (DG); + * + */ + +package org.jfree.data.general; + +import org.jfree.chart.TestUtilities; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; +import org.junit.Test; + +/** + * Somes tests for the {@link DefaultHeatMapDataset} class. + * + * @since 1.0.13 + */ +public class DefaultHeatMapDatasetTest implements DatasetChangeListener { + + /** The last event received. */ + private DatasetChangeEvent lastEvent; + + /** + * Records the last event. + * + * @param event the last event. + */ + @Override + public void datasetChanged(DatasetChangeEvent event) { + this.lastEvent = event; + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some general tests. + */ + @Test + public void testGeneral() { + DefaultHeatMapDataset d = new DefaultHeatMapDataset(10, 5, 0.0, 9.0, + 0.0, 5.0); + assertEquals(10, d.getXSampleCount()); + assertEquals(5, d.getYSampleCount()); + assertEquals(0.0, d.getMinimumXValue(), EPSILON); + assertEquals(9.0, d.getMaximumXValue(), EPSILON); + assertEquals(0.0, d.getMinimumYValue(), EPSILON); + assertEquals(5.0, d.getMaximumYValue(), EPSILON); + assertEquals(0.0, d.getZValue(0, 0), EPSILON); + d.addChangeListener(this); + d.setZValue(0, 0, 1.0, false); + assertEquals(1.0, d.getZValue(0, 0), EPSILON); + assertNull(this.lastEvent); + d.setZValue(1, 2, 2.0); + assertEquals(2.0, d.getZValue(1, 2), EPSILON); + assertNotNull(this.lastEvent); + } + + /** + * Some tests for the equals() method. + */ + @Test + public void testEquals() { + DefaultHeatMapDataset d1 = new DefaultHeatMapDataset(5, 10, 1.0, 2.0, + 3.0, 4.0); + DefaultHeatMapDataset d2 = new DefaultHeatMapDataset(5, 10, 1.0, 2.0, + 3.0, 4.0); + assertEquals(d1, d2); + + d1 = new DefaultHeatMapDataset(6, 10, 1.0, 2.0, 3.0, 4.0); + assertFalse(d1.equals(d2)); + d2 = new DefaultHeatMapDataset(6, 10, 1.0, 2.0, 3.0, 4.0); + assertTrue(d1.equals(d2)); + + d1 = new DefaultHeatMapDataset(6, 11, 1.0, 2.0, 3.0, 4.0); + assertFalse(d1.equals(d2)); + d2 = new DefaultHeatMapDataset(6, 11, 1.0, 2.0, 3.0, 4.0); + assertTrue(d1.equals(d2)); + + d1 = new DefaultHeatMapDataset(6, 11, 2.0, 2.0, 3.0, 4.0); + assertFalse(d1.equals(d2)); + d2 = new DefaultHeatMapDataset(6, 11, 2.0, 2.0, 3.0, 4.0); + assertTrue(d1.equals(d2)); + + d1 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 3.0, 4.0); + assertFalse(d1.equals(d2)); + d2 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 3.0, 4.0); + assertTrue(d1.equals(d2)); + + d1 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 4.0); + assertFalse(d1.equals(d2)); + d2 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 4.0); + assertTrue(d1.equals(d2)); + + d1 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 5.0); + assertFalse(d1.equals(d2)); + d2 = new DefaultHeatMapDataset(6, 11, 2.0, 3.0, 4.0, 5.0); + assertTrue(d1.equals(d2)); + + d1.setZValue(1, 2, 3.0); + assertFalse(d1.equals(d2)); + d2.setZValue(1, 2, 3.0); + assertTrue(d1.equals(d2)); + + d1.setZValue(0, 0, Double.NEGATIVE_INFINITY); + assertFalse(d1.equals(d2)); + d2.setZValue(0, 0, Double.NEGATIVE_INFINITY); + assertTrue(d1.equals(d2)); + + d1.setZValue(0, 1, Double.POSITIVE_INFINITY); + assertFalse(d1.equals(d2)); + d2.setZValue(0, 1, Double.POSITIVE_INFINITY); + assertTrue(d1.equals(d2)); + + d1.setZValue(0, 2, Double.NaN); + assertFalse(d1.equals(d2)); + d2.setZValue(0, 2, Double.NaN); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultHeatMapDataset d1 = new DefaultHeatMapDataset(2, 3, -1.0, 4.0, + -2.0, 5.0); + d1.setZValue(0, 0, 10.0); + d1.setZValue(0, 1, Double.NEGATIVE_INFINITY); + d1.setZValue(0, 2, Double.POSITIVE_INFINITY); + d1.setZValue(1, 0, Double.NaN); + DefaultHeatMapDataset d2 = (DefaultHeatMapDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // simple check for independence + d1.setZValue(0, 0, 11.0); + assertFalse(d1.equals(d2)); + d2.setZValue(0, 0, 11.0); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultHeatMapDataset d1 = new DefaultHeatMapDataset(2, 3, -1.0, 4.0, + -2.0, 5.0); + d1.setZValue(0, 0, 10.0); + d1.setZValue(0, 1, Double.NEGATIVE_INFINITY); + d1.setZValue(0, 2, Double.POSITIVE_INFINITY); + d1.setZValue(1, 0, Double.NaN); + DefaultHeatMapDataset d2 = (DefaultHeatMapDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultKeyedValueDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultKeyedValueDatasetTest.java new file mode 100755 index 0000000..a253330 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultKeyedValueDatasetTest.java @@ -0,0 +1,119 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * DefaultKeyedValueDatasetTest.java + * --------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Aug-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.general; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.junit.Test; + +/** + * Tests for the {@link DefaultKeyedValueDataset} class. + */ +public class DefaultKeyedValueDatasetTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + DefaultKeyedValueDataset d1 + = new DefaultKeyedValueDataset("Test", new Double(45.5)); + DefaultKeyedValueDataset d2 + = new DefaultKeyedValueDataset("Test", new Double(45.5)); + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + d1 = new DefaultKeyedValueDataset("Test 1", new Double(45.5)); + d2 = new DefaultKeyedValueDataset("Test 2", new Double(45.5)); + assertFalse(d1.equals(d2)); + + d1 = new DefaultKeyedValueDataset("Test", new Double(45.5)); + d2 = new DefaultKeyedValueDataset("Test", new Double(45.6)); + assertFalse(d1.equals(d2)); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultKeyedValueDataset d1 + = new DefaultKeyedValueDataset("Test", new Double(45.5)); + DefaultKeyedValueDataset d2 = (DefaultKeyedValueDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that the clone is independent of the original. + */ + @Test + public void testCloneIndependence() throws CloneNotSupportedException { + DefaultKeyedValueDataset d1 + = new DefaultKeyedValueDataset("Key", new Double(10.0)); + DefaultKeyedValueDataset d2 = (DefaultKeyedValueDataset) d1.clone(); + assertTrue(d1.equals(d2)); + d2.updateValue(new Double(99.9)); + assertFalse(d1.equals(d2)); + d2.updateValue(new Double(10.0)); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultKeyedValueDataset d1 + = new DefaultKeyedValueDataset("Test", new Double(25.3)); + DefaultKeyedValueDataset d2 = (DefaultKeyedValueDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultKeyedValues2DDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultKeyedValues2DDatasetTest.java new file mode 100755 index 0000000..938f3e0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultKeyedValues2DDatasetTest.java @@ -0,0 +1,84 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------ + * DefaultKeyedValues2DDatasetTest.java + * ------------------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Mar-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.general; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +/** + * Tests for the {@link DefaultKeyedValues2DDataset} class. + */ +public class DefaultKeyedValues2DDatasetTest { + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset(); + d1.setValue(new Integer(1), "V1", "C1"); + d1.setValue(null, "V2", "C1"); + d1.setValue(new Integer(3), "V3", "C2"); + DefaultKeyedValues2DDataset d2 = (DefaultKeyedValues2DDataset) + d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + public void testSerialization() { + DefaultKeyedValues2DDataset d1 = new DefaultKeyedValues2DDataset(); + d1.addValue(new Double(234.2), "Row1", "Col1"); + d1.addValue(null, "Row1", "Col2"); + d1.addValue(new Double(345.9), "Row2", "Col1"); + d1.addValue(new Double(452.7), "Row2", "Col2"); + + DefaultKeyedValues2DDataset d2 = (DefaultKeyedValues2DDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultKeyedValuesDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultKeyedValuesDatasetTest.java new file mode 100755 index 0000000..7e64e48 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultKeyedValuesDatasetTest.java @@ -0,0 +1,83 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------- + * DefaultKeyedValuesDatasetTest.java + * ---------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Mar-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.general; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +/** + * Tests for the {@link DefaultKeyedValuesDataset} class. + */ +public class DefaultKeyedValuesDatasetTest { + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset(); + d1.setValue("V1", new Integer(1)); + d1.setValue("V2", null); + d1.setValue("V3", new Integer(3)); + DefaultKeyedValuesDataset d2 = (DefaultKeyedValuesDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + public void testSerialization() { + DefaultKeyedValuesDataset d1 = new DefaultKeyedValuesDataset(); + d1.setValue("C1", new Double(234.2)); + d1.setValue("C2", null); + d1.setValue("C3", new Double(345.9)); + d1.setValue("C4", new Double(452.7)); + + KeyedValuesDataset d2 = (KeyedValuesDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultPieDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultPieDatasetTest.java new file mode 100755 index 0000000..866e9c8 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/DefaultPieDatasetTest.java @@ -0,0 +1,166 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * PieDatasetTest.java + * ------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-Aug-2003 : Version 1 (DG); + * 31-Jul-2006 : Added test for new clear() method (DG); + * 01-Aug-2006 : Added testGetKey() and testGetIndex() methods (DG); + * + */ + +package org.jfree.data.general; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; + +/** + * Tests for the {@link org.jfree.data.general.PieDataset} class. + */ +public class DefaultPieDatasetTest implements DatasetChangeListener { + + private DatasetChangeEvent lastEvent; + + /** + * Records the last event. + * + * @param event the last event. + */ + @Override + public void datasetChanged(DatasetChangeEvent event) { + this.lastEvent = event; + } + + /** + * Some tests for the clear() method. + */ + @Test + public void testClear() { + DefaultPieDataset d = new DefaultPieDataset(); + d.addChangeListener(this); + // no event is generated if the dataset is already empty + d.clear(); + assertNull(this.lastEvent); + d.setValue("A", 1.0); + assertEquals(1, d.getItemCount()); + this.lastEvent = null; + d.clear(); + assertNotNull(this.lastEvent); + assertEquals(0, d.getItemCount()); + } + + /** + * Some checks for the getKey(int) method. + */ + public void testGetKey() { + DefaultPieDataset d = new DefaultPieDataset(); + d.setValue("A", 1.0); + d.setValue("B", 2.0); + assertEquals("A", d.getKey(0)); + assertEquals("B", d.getKey(1)); + + boolean pass = false; + try { + d.getKey(-1); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + d.getKey(2); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getIndex() method. + */ + public void testGetIndex() { + DefaultPieDataset d = new DefaultPieDataset(); + d.setValue("A", 1.0); + d.setValue("B", 2.0); + assertEquals(0, d.getIndex("A")); + assertEquals(1, d.getIndex("B")); + assertEquals(-1, d.getIndex("XX")); + + boolean pass = false; + try { + d.getIndex(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Confirm that cloning works. + */ + public void testCloning() throws CloneNotSupportedException { + DefaultPieDataset d1 = new DefaultPieDataset(); + d1.setValue("V1", new Integer(1)); + d1.setValue("V2", null); + d1.setValue("V3", new Integer(3)); + DefaultPieDataset d2 = (DefaultPieDataset) d1.clone(); + + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + public void testSerialization() { + DefaultPieDataset d1 = new DefaultPieDataset(); + d1.setValue("C1", new Double(234.2)); + d1.setValue("C2", null); + d1.setValue("C3", new Double(345.9)); + d1.setValue("C4", new Double(452.7)); + + DefaultPieDataset d2 = (DefaultPieDataset) TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/IntervalDataItem.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/IntervalDataItem.java new file mode 100755 index 0000000..18eb54c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/IntervalDataItem.java @@ -0,0 +1,73 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * IntervalDataItem.java + * --------------------- + * (C) Copyright 2009, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-Sep-2009 : Version 1, based on DefaultCategoryDataset (DG); + * + */ + +package org.jfree.data.general; + +/** + * A data holder for a value and an associated range or interval. Used by + * the TestIntervalCategoryDataset class. + */ +public class IntervalDataItem { + + private Number value; + + private Number lowerBound; + + private Number upperBound; + + public IntervalDataItem(Number value, Number lowerBound, Number upperBound) { + this.value = value; + this.lowerBound = lowerBound; + this.upperBound = upperBound; + } + + public Number getLowerBound() { + return lowerBound; + } + + public Number getUpperBound() { + return upperBound; + } + + public Number getValue() { + return value; + } +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/TestIntervalCategoryDataset.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/TestIntervalCategoryDataset.java new file mode 100755 index 0000000..b8c18a6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/general/TestIntervalCategoryDataset.java @@ -0,0 +1,471 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------- + * TestIntervalCategoryDataset.java + * -------------------------------- + * (C) Copyright 2009-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-Sep-2009 : Version 1, based on DefaultCategoryDataset (DG); + * + */ + +package org.jfree.data.general; + +import java.io.Serializable; +import java.util.List; + +import org.jfree.data.KeyedObjects2D; +import org.jfree.data.UnknownKeyException; +import org.jfree.data.category.IntervalCategoryDataset; +import org.jfree.util.PublicCloneable; +/** + * A test implementation of the {@link IntervalCategoryDataset} interface. + */ +public class TestIntervalCategoryDataset extends AbstractDataset + implements IntervalCategoryDataset, PublicCloneable, Serializable { + + /** For serialization. */ + private static final long serialVersionUID = -8168173757291644622L; + + /** A storage structure for the data. */ + private KeyedObjects2D data; + + /** + * Creates a new (empty) dataset. + */ + public TestIntervalCategoryDataset() { + this.data = new KeyedObjects2D(); + } + + /** + * Returns the number of rows in the table. + * + * @return The row count. + * + * @see #getColumnCount() + */ + @Override + public int getRowCount() { + return this.data.getRowCount(); + } + + /** + * Returns the number of columns in the table. + * + * @return The column count. + * + * @see #getRowCount() + */ + @Override + public int getColumnCount() { + return this.data.getColumnCount(); + } + + /** + * Returns a value from the table. + * + * @param row the row index (zero-based). + * @param column the column index (zero-based). + * + * @return The value (possibly null). + * + * @see #addValue(Number, Comparable, Comparable) + * @see #removeValue(Comparable, Comparable) + */ + @Override + public Number getValue(int row, int column) { + IntervalDataItem item = (IntervalDataItem) this.data.getObject(row, + column); + if (item == null) { + return null; + } + return item.getValue(); + } + + /** + * Returns the key for the specified row. + * + * @param row the row index (zero-based). + * + * @return The row key. + * + * @see #getRowIndex(Comparable) + * @see #getRowKeys() + * @see #getColumnKey(int) + */ + @Override + public Comparable getRowKey(int row) { + return this.data.getRowKey(row); + } + + /** + * Returns the row index for a given key. + * + * @param key the row key (null not permitted). + * + * @return The row index. + * + * @see #getRowKey(int) + */ + @Override + public int getRowIndex(Comparable key) { + // defer null argument check + return this.data.getRowIndex(key); + } + + /** + * Returns the row keys. + * + * @return The keys. + * + * @see #getRowKey(int) + */ + @Override + public List getRowKeys() { + return this.data.getRowKeys(); + } + + /** + * Returns a column key. + * + * @param column the column index (zero-based). + * + * @return The column key. + * + * @see #getColumnIndex(Comparable) + */ + @Override + public Comparable getColumnKey(int column) { + return this.data.getColumnKey(column); + } + + /** + * Returns the column index for a given key. + * + * @param key the column key (null not permitted). + * + * @return The column index. + * + * @see #getColumnKey(int) + */ + @Override + public int getColumnIndex(Comparable key) { + // defer null argument check + return this.data.getColumnIndex(key); + } + + /** + * Returns the column keys. + * + * @return The keys. + * + * @see #getColumnKey(int) + */ + @Override + public List getColumnKeys() { + return this.data.getColumnKeys(); + } + + /** + * Returns the value for a pair of keys. + * + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @return The value (possibly null). + * + * @throws UnknownKeyException if either key is not defined in the dataset. + * + * @see #addValue(Number, Comparable, Comparable) + */ + @Override + public Number getValue(Comparable rowKey, Comparable columnKey) { + IntervalDataItem item = (IntervalDataItem) this.data.getObject(rowKey, + columnKey); + if (item == null) { + return null; + } + return item.getValue(); + } + + /** + * Adds a value to the table. Performs the same function as setValue(). + * + * @param value the value. + * @param rowKey the row key. + * @param columnKey the column key. + * + * @see #getValue(Comparable, Comparable) + * @see #removeValue(Comparable, Comparable) + */ + public void addItem(Number value, Number lower, Number upper, + Comparable rowKey, Comparable columnKey) { + IntervalDataItem item = new IntervalDataItem(value, lower, upper); + this.data.addObject(item, rowKey, columnKey); + fireDatasetChanged(); + } + + /** + * Adds a value to the table. + * + * @param value the value. + * @param rowKey the row key. + * @param columnKey the column key. + * + * @see #getValue(Comparable, Comparable) + */ + public void addItem(double value, double lower, double upper, + Comparable rowKey, Comparable columnKey) { + addItem(new Double(value), new Double(lower), new Double(upper), + rowKey, columnKey); + } + + /** + * Adds or updates a value in the table and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param value the value (null permitted). + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @see #getValue(Comparable, Comparable) + */ + public void setItem(Number value, Number lower, Number upper, + Comparable rowKey, Comparable columnKey) { + IntervalDataItem item = new IntervalDataItem(value, lower, upper); + this.data.addObject(item, rowKey, columnKey); + fireDatasetChanged(); + } + + /** + * Adds or updates a value in the table and sends a + * {@link DatasetChangeEvent} to all registered listeners. + * + * @param value the value. + * @param rowKey the row key (null not permitted). + * @param columnKey the column key (null not permitted). + * + * @see #getValue(Comparable, Comparable) + */ + public void setItem(double value, double lower, double upper, + Comparable rowKey, Comparable columnKey) { + setItem(new Double(value), new Double(lower), new Double(upper), + rowKey, columnKey); + } + + /** + * Removes a value from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param rowKey the row key. + * @param columnKey the column key. + * + * @see #addValue(Number, Comparable, Comparable) + */ + public void removeItem(Comparable rowKey, Comparable columnKey) { + this.data.removeObject(rowKey, columnKey); + fireDatasetChanged(); + } + + /** + * Removes a row from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param rowIndex the row index. + * + * @see #removeColumn(int) + */ + public void removeRow(int rowIndex) { + this.data.removeRow(rowIndex); + fireDatasetChanged(); + } + + /** + * Removes a row from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param rowKey the row key. + * + * @see #removeColumn(Comparable) + */ + public void removeRow(Comparable rowKey) { + this.data.removeRow(rowKey); + fireDatasetChanged(); + } + + /** + * Removes a column from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param columnIndex the column index. + * + * @see #removeRow(int) + */ + public void removeColumn(int columnIndex) { + this.data.removeColumn(columnIndex); + fireDatasetChanged(); + } + + /** + * Removes a column from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + * + * @param columnKey the column key (null not permitted). + * + * @see #removeRow(Comparable) + * + * @throws UnknownKeyException if columnKey is not defined + * in the dataset. + */ + public void removeColumn(Comparable columnKey) { + this.data.removeColumn(columnKey); + fireDatasetChanged(); + } + + /** + * Clears all data from the dataset and sends a {@link DatasetChangeEvent} + * to all registered listeners. + */ + public void clear() { + this.data.clear(); + fireDatasetChanged(); + } + + /** + * Tests this dataset for equality with an arbitrary object. + * + * @param obj the object (null permitted). + * + * @return A boolean. + */ + @Override + public boolean equals(Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof TestIntervalCategoryDataset)) { + return false; + } + TestIntervalCategoryDataset that = (TestIntervalCategoryDataset) obj; + if (!getRowKeys().equals(that.getRowKeys())) { + return false; + } + if (!getColumnKeys().equals(that.getColumnKeys())) { + return false; + } + int rowCount = getRowCount(); + int colCount = getColumnCount(); + for (int r = 0; r < rowCount; r++) { + for (int c = 0; c < colCount; c++) { + Number v1 = getValue(r, c); + Number v2 = that.getValue(r, c); + if (v1 == null) { + if (v2 != null) { + return false; + } + } + else if (!v1.equals(v2)) { + return false; + } + } + } + return true; + } + + /** + * Returns a hash code for the dataset. + * + * @return A hash code. + */ + @Override + public int hashCode() { + return this.data.hashCode(); + } + + /** + * Returns a clone of the dataset. + * + * @return A clone. + * + * @throws CloneNotSupportedException if there is a problem cloning the + * dataset. + */ + @Override + public Object clone() throws CloneNotSupportedException { + TestIntervalCategoryDataset clone = (TestIntervalCategoryDataset) + super.clone(); + clone.data = (KeyedObjects2D) this.data.clone(); + return clone; + } + + @Override + public Number getStartValue(int series, int category) { + IntervalDataItem item = (IntervalDataItem) this.data.getObject(series, + category); + if (item == null) { + return null; + } + return item.getLowerBound(); + } + + @Override + public Number getStartValue(Comparable series, Comparable category) { + IntervalDataItem item = (IntervalDataItem) this.data.getObject(series, + category); + if (item == null) { + return null; + } + return item.getLowerBound(); + } + + @Override + public Number getEndValue(int series, int category) { + IntervalDataItem item = (IntervalDataItem) this.data.getObject(series, + category); + if (item == null) { + return null; + } + return item.getUpperBound(); + } + + @Override + public Number getEndValue(Comparable series, Comparable category) { + IntervalDataItem item = (IntervalDataItem) this.data.getObject(series, + category); + if (item == null) { + return null; + } + return item.getUpperBound(); + } + +} + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/package.html new file mode 100755 index 0000000..2e7485a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/package.html @@ -0,0 +1,6 @@ + + + +Test cases for the classes in com.jrefinery.data.*. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/BoxAndWhiskerCalculatorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/BoxAndWhiskerCalculatorTest.java new file mode 100755 index 0000000..5454011 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/BoxAndWhiskerCalculatorTest.java @@ -0,0 +1,165 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------- + * BoxAndWhiskerCalculatorTest.java + * -------------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 28-Aug-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.statistics; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; +import java.util.List; +import org.junit.Test; + +/** + * Tests for the {@link BoxAndWhiskerCalculator} class. + */ +public class BoxAndWhiskerCalculatorTest { + + /** + * Some checks for the calculateBoxAndWhiskerStatistics() method. + */ + @Test + public void testCalculateBoxAndWhiskerStatistics() { + + // try null list + boolean pass = false; + try { + BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + // try a list containing a single value + List values = new ArrayList(); + values.add(new Double(1.1)); + BoxAndWhiskerItem item + = BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(values); + assertEquals(1.1, item.getMean().doubleValue(), EPSILON); + assertEquals(1.1, item.getMedian().doubleValue(), EPSILON); + assertEquals(1.1, item.getQ1().doubleValue(), EPSILON); + assertEquals(1.1, item.getQ3().doubleValue(), EPSILON); + } + + private static final double EPSILON = 0.000000001; + + /** + * Tests the Q1 calculation. + */ + @Test + public void testCalculateQ1() { + + // try null argument + boolean pass = false; + try { + BoxAndWhiskerCalculator.calculateQ1(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + List values = new ArrayList(); + double q1 = BoxAndWhiskerCalculator.calculateQ1(values); + assertTrue(Double.isNaN(q1)); + values.add(new Double(1.0)); + q1 = BoxAndWhiskerCalculator.calculateQ1(values); + assertEquals(q1, 1.0, EPSILON); + values.add(new Double(2.0)); + q1 = BoxAndWhiskerCalculator.calculateQ1(values); + assertEquals(q1, 1.0, EPSILON); + values.add(new Double(3.0)); + q1 = BoxAndWhiskerCalculator.calculateQ1(values); + assertEquals(q1, 1.5, EPSILON); + values.add(new Double(4.0)); + q1 = BoxAndWhiskerCalculator.calculateQ1(values); + assertEquals(q1, 1.5, EPSILON); + } + + /** + * Tests the Q3 calculation. + */ + @Test + public void testCalculateQ3() { + // try null argument + boolean pass = false; + try { + BoxAndWhiskerCalculator.calculateQ3(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + List values = new ArrayList(); + double q3 = BoxAndWhiskerCalculator.calculateQ3(values); + assertTrue(Double.isNaN(q3)); + values.add(new Double(1.0)); + q3 = BoxAndWhiskerCalculator.calculateQ3(values); + assertEquals(q3, 1.0, EPSILON); + values.add(new Double(2.0)); + q3 = BoxAndWhiskerCalculator.calculateQ3(values); + assertEquals(q3, 2.0, EPSILON); + values.add(new Double(3.0)); + q3 = BoxAndWhiskerCalculator.calculateQ3(values); + assertEquals(q3, 2.5, EPSILON); + values.add(new Double(4.0)); + q3 = BoxAndWhiskerCalculator.calculateQ3(values); + assertEquals(q3, 3.5, EPSILON); + } + + /** + * The test case included in bug report 1593149. + */ + @Test + public void test1593149() { + ArrayList theList = new ArrayList(5); + theList.add(0, new Double(1.0)); + theList.add(1, new Double(2.0)); + theList.add(2, new Double(Double.NaN)); + theList.add(3, new Double(3.0)); + theList.add(4, new Double(4.0)); + BoxAndWhiskerItem theItem = + BoxAndWhiskerCalculator.calculateBoxAndWhiskerStatistics(theList); + assertEquals(1.0, theItem.getMinRegularValue().doubleValue(), EPSILON); + assertEquals(4.0, theItem.getMaxRegularValue().doubleValue(), EPSILON); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/BoxAndWhiskerItemTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/BoxAndWhiskerItemTest.java new file mode 100755 index 0000000..5d55313 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/BoxAndWhiskerItemTest.java @@ -0,0 +1,87 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * BoxAndWhiskerItemTest.java + * -------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 01-Mar-2004 : Version 1 (DG); + * + */ + +package org.jfree.data.statistics; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import java.util.ArrayList; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link BoxAndWhiskerItem} class. + */ +public class BoxAndWhiskerItemTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + BoxAndWhiskerItem i1 = new BoxAndWhiskerItem(new Double(1.0), + new Double(2.0), new Double(3.0), new Double(4.0), + new Double(5.0), new Double(6.0), new Double(7.0), + new Double(8.0), new ArrayList()); + BoxAndWhiskerItem i2 = new BoxAndWhiskerItem(new Double(1.0), + new Double(2.0), new Double(3.0), new Double(4.0), + new Double(5.0), new Double(6.0), new Double(7.0), + new Double(8.0), new ArrayList()); + assertTrue(i1.equals(i2)); + assertTrue(i2.equals(i1)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + BoxAndWhiskerItem i1 = new BoxAndWhiskerItem(new Double(1.0), + new Double(2.0), new Double(3.0), new Double(4.0), + new Double(5.0), new Double(6.0), new Double(7.0), + new Double(8.0), new ArrayList()); + BoxAndWhiskerItem i2 = (BoxAndWhiskerItem) TestUtilities.serialised(i1); + assertEquals(i1, i2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDatasetTest.java new file mode 100755 index 0000000..38c2f5b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/DefaultBoxAndWhiskerCategoryDatasetTest.java @@ -0,0 +1,292 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------------------- + * DefaultBoxAndWhiskerCategoryDatasetTest.java + * -------------------------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 01-Mar-2004 : Version 1 (DG); + * 17-Apr-2007 : Added a test for bug 1701822 (DG); + * 28-Sep-2007 : Enhanced testClone() (DG); + * 02-Oct-2007 : Added new tests (DG); + * 03-Oct-2007 : Added getTestRangeBounds() and testRemove() (DG); + * + */ + +package org.jfree.data.statistics; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.util.ArrayList; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.data.UnknownKeyException; +import org.junit.Test; + +/** + * Tests for the {@link DefaultBoxAndWhiskerCategoryDataset} class. + */ +public class DefaultBoxAndWhiskerCategoryDatasetTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DefaultBoxAndWhiskerCategoryDataset d1 + = new DefaultBoxAndWhiskerCategoryDataset(); + d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), + new Double(3.0), new Double(4.0), new Double(5.0), + new Double(6.0), new Double(7.0), new Double(8.0), + new ArrayList()), "ROW1", "COLUMN1"); + DefaultBoxAndWhiskerCategoryDataset d2 + = new DefaultBoxAndWhiskerCategoryDataset(); + d2.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), + new Double(3.0), new Double(4.0), new Double(5.0), + new Double(6.0), new Double(7.0), new Double(8.0), + new ArrayList()), "ROW1", "COLUMN1"); + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultBoxAndWhiskerCategoryDataset d1 + = new DefaultBoxAndWhiskerCategoryDataset(); + d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), + new Double(3.0), new Double(4.0), new Double(5.0), + new Double(6.0), new Double(7.0), new Double(8.0), + new ArrayList()), "ROW1", "COLUMN1"); + DefaultBoxAndWhiskerCategoryDataset d2 = + (DefaultBoxAndWhiskerCategoryDataset) TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultBoxAndWhiskerCategoryDataset d1 + = new DefaultBoxAndWhiskerCategoryDataset(); + d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), + new Double(3.0), new Double(4.0), new Double(5.0), + new Double(6.0), new Double(7.0), new Double(8.0), + new ArrayList()), "ROW1", "COLUMN1"); + DefaultBoxAndWhiskerCategoryDataset d2 + = (DefaultBoxAndWhiskerCategoryDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // test independence + d1.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), + new Double(3.0), new Double(4.0), new Double(5.0), + new Double(6.0), new Double(7.0), new Double(8.0), + new ArrayList()), "ROW2", "COLUMN1"); + assertFalse(d1.equals(d2)); + } + + /** + * A simple test for bug report 1701822. + */ + @Test + public void test1701822() { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset(); + try { + dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), + new Double(3.0), new Double(4.0), new Double(5.0), + new Double(6.0), null, new Double(8.0), + new ArrayList()), "ROW1", "COLUMN1"); + dataset.add(new BoxAndWhiskerItem(new Double(1.0), new Double(2.0), + new Double(3.0), new Double(4.0), new Double(5.0), + new Double(6.0), new Double(7.0), null, + new ArrayList()), "ROW1", "COLUMN2"); + } + catch (NullPointerException e) { + assertTrue(false); + } + + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the add() method. + */ + @Test + public void testAdd() { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset(); + BoxAndWhiskerItem item1 = new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, + 5.0, 6.0, 7.0, 8.0, new ArrayList()); + dataset.add(item1, "R1", "C1"); + + assertEquals(2.0, dataset.getValue("R1", "C1").doubleValue(), EPSILON); + assertEquals(1.0, dataset.getMeanValue("R1", "C1").doubleValue(), + EPSILON); + assertEquals(2.0, dataset.getMedianValue("R1", "C1").doubleValue(), + EPSILON); + assertEquals(3.0, dataset.getQ1Value("R1", "C1").doubleValue(), + EPSILON); + assertEquals(4.0, dataset.getQ3Value("R1", "C1").doubleValue(), + EPSILON); + assertEquals(5.0, dataset.getMinRegularValue("R1", "C1").doubleValue(), + EPSILON); + assertEquals(6.0, dataset.getMaxRegularValue("R1", "C1").doubleValue(), + EPSILON); + assertEquals(7.0, dataset.getMinOutlier("R1", "C1").doubleValue(), + EPSILON); + assertEquals(8.0, dataset.getMaxOutlier("R1", "C1").doubleValue(), + EPSILON); + assertEquals(new Range(7.0, 8.0), dataset.getRangeBounds(false)); + } + + /** + * Some checks for the add() method. + */ + @Test + public void testAddUpdatesCachedRange() { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset(); + BoxAndWhiskerItem item1 = new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, + 5.0, 6.0, 7.0, 8.0, new ArrayList()); + dataset.add(item1, "R1", "C1"); + + // now overwrite this item with another + BoxAndWhiskerItem item2 = new BoxAndWhiskerItem(1.5, 2.5, 3.5, 4.5, + 5.5, 6.5, 7.5, 8.5, new ArrayList()); + dataset.add(item2, "R1", "C1"); + + assertEquals(2.5, dataset.getValue("R1", "C1").doubleValue(), EPSILON); + assertEquals(1.5, dataset.getMeanValue("R1", "C1").doubleValue(), + EPSILON); + assertEquals(2.5, dataset.getMedianValue("R1", "C1").doubleValue(), + EPSILON); + assertEquals(3.5, dataset.getQ1Value("R1", "C1").doubleValue(), + EPSILON); + assertEquals(4.5, dataset.getQ3Value("R1", "C1").doubleValue(), + EPSILON); + assertEquals(5.5, dataset.getMinRegularValue("R1", "C1").doubleValue(), + EPSILON); + assertEquals(6.5, dataset.getMaxRegularValue("R1", "C1").doubleValue(), + EPSILON); + assertEquals(7.5, dataset.getMinOutlier("R1", "C1").doubleValue(), + EPSILON); + assertEquals(8.5, dataset.getMaxOutlier("R1", "C1").doubleValue(), + EPSILON); + assertEquals(new Range(7.5, 8.5), dataset.getRangeBounds(false)); + } + + /** + * Some basic checks for the constructor. + */ + @Test + public void testConstructor() { + DefaultBoxAndWhiskerCategoryDataset dataset + = new DefaultBoxAndWhiskerCategoryDataset(); + assertEquals(0, dataset.getColumnCount()); + assertEquals(0, dataset.getRowCount()); + assertTrue(Double.isNaN(dataset.getRangeLowerBound(false))); + assertTrue(Double.isNaN(dataset.getRangeUpperBound(false))); + } + + /** + * Some checks for the getRangeBounds() method. + */ + @Test + public void testGetRangeBounds() { + DefaultBoxAndWhiskerCategoryDataset d1 + = new DefaultBoxAndWhiskerCategoryDataset(); + d1.add(new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, + new ArrayList()), "R1", "C1"); + assertEquals(new Range(7.0, 8.0), d1.getRangeBounds(false)); + assertEquals(new Range(7.0, 8.0), d1.getRangeBounds(true)); + + d1.add(new BoxAndWhiskerItem(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, + new ArrayList()), "R1", "C1"); + assertEquals(new Range(7.5, 8.5), d1.getRangeBounds(false)); + assertEquals(new Range(7.5, 8.5), d1.getRangeBounds(true)); + + d1.add(new BoxAndWhiskerItem(2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, + new ArrayList()), "R2", "C1"); + assertEquals(new Range(7.5, 9.5), d1.getRangeBounds(false)); + assertEquals(new Range(7.5, 9.5), d1.getRangeBounds(true)); + + // this replaces the entry with the current minimum value, but the new + // minimum value is now in a different item + d1.add(new BoxAndWhiskerItem(1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 8.6, 9.6, + new ArrayList()), "R1", "C1"); + assertEquals(new Range(8.5, 9.6), d1.getRangeBounds(false)); + assertEquals(new Range(8.5, 9.6), d1.getRangeBounds(true)); + } + + /** + * Some checks for the remove method. + */ + @Test + public void testRemove() { + DefaultBoxAndWhiskerCategoryDataset data + = new DefaultBoxAndWhiskerCategoryDataset(); + + boolean pass = false; + try { + data.remove("R1", "R2"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + data.add(new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, + new ArrayList()), "R1", "C1"); + assertEquals(new Range(7.0, 8.0), data.getRangeBounds(false)); + assertEquals(new Range(7.0, 8.0), data.getRangeBounds(true)); + + data.add(new BoxAndWhiskerItem(2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, + new ArrayList()), "R2", "C1"); + assertEquals(new Range(7.0, 9.5), data.getRangeBounds(false)); + assertEquals(new Range(7.0, 9.5), data.getRangeBounds(true)); + + data.remove("R1", "C1"); + assertEquals(new Range(8.5, 9.5), data.getRangeBounds(false)); + assertEquals(new Range(8.5, 9.5), data.getRangeBounds(true)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/DefaultBoxAndWhiskerXYDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/DefaultBoxAndWhiskerXYDatasetTest.java new file mode 100755 index 0000000..a40a02c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/DefaultBoxAndWhiskerXYDatasetTest.java @@ -0,0 +1,183 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------------------- + * DefaultBoxAndWhiskerXYDatasetTest.java + * -------------------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 12-Nov-2007 : Version 1 (DG); + * + */ + +package org.jfree.data.statistics; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.util.ArrayList; +import java.util.Date; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.junit.Test; + +/** + * Tests for the {@link DefaultBoxAndWhiskerXYDataset} class. + */ +public class DefaultBoxAndWhiskerXYDatasetTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset( + "Series"); + DefaultBoxAndWhiskerXYDataset d2 = new DefaultBoxAndWhiskerXYDataset( + "Series"); + assertTrue(d1.equals(d2)); + + d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, + 6.0, 7.0, 8.0, new ArrayList())); + assertFalse(d1.equals(d2)); + d2.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, + 6.0, 7.0, 8.0, new ArrayList())); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset( + "Series"); + d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, + 6.0, 7.0, 8.0, new ArrayList())); + DefaultBoxAndWhiskerXYDataset d2 = (DefaultBoxAndWhiskerXYDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + + // test independence + d1.add(new Date(2L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, + 6.0, 7.0, 8.0, new ArrayList())); + assertFalse(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultBoxAndWhiskerXYDataset d1 = new DefaultBoxAndWhiskerXYDataset( + "Series"); + d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, + 6.0, 7.0, 8.0, new ArrayList())); + DefaultBoxAndWhiskerXYDataset d2 = (DefaultBoxAndWhiskerXYDataset) + d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // test independence + d1.add(new Date(2L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, + 6.0, 7.0, 8.0, new ArrayList())); + assertFalse(d1.equals(d2)); + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the add() method. + */ + @Test + public void testAdd() { + DefaultBoxAndWhiskerXYDataset dataset + = new DefaultBoxAndWhiskerXYDataset("S1"); + BoxAndWhiskerItem item1 = new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, + 5.0, 6.0, 7.0, 8.0, new ArrayList()); + dataset.add(new Date(33L), item1); + + assertEquals(1.0, dataset.getY(0, 0).doubleValue(), EPSILON); + assertEquals(1.0, dataset.getMeanValue(0, 0).doubleValue(), EPSILON); + assertEquals(2.0, dataset.getMedianValue(0, 0).doubleValue(), EPSILON); + assertEquals(3.0, dataset.getQ1Value(0, 0).doubleValue(), EPSILON); + assertEquals(4.0, dataset.getQ3Value(0, 0).doubleValue(), EPSILON); + assertEquals(5.0, dataset.getMinRegularValue(0, 0).doubleValue(), + EPSILON); + assertEquals(6.0, dataset.getMaxRegularValue(0, 0).doubleValue(), + EPSILON); + assertEquals(7.0, dataset.getMinOutlier(0, 0).doubleValue(), EPSILON); + assertEquals(8.0, dataset.getMaxOutlier(0, 0).doubleValue(), EPSILON); + assertEquals(new Range(5.0, 6.0), dataset.getRangeBounds(false)); + } + + /** + * Some basic checks for the constructor. + */ + @Test + public void testConstructor() { + DefaultBoxAndWhiskerXYDataset dataset + = new DefaultBoxAndWhiskerXYDataset("S1"); + assertEquals(1, dataset.getSeriesCount()); + assertEquals(0, dataset.getItemCount(0)); + assertTrue(Double.isNaN(dataset.getRangeLowerBound(false))); + assertTrue(Double.isNaN(dataset.getRangeUpperBound(false))); + } + + /** + * Some checks for the getRangeBounds() method. + */ + @Test + public void testGetRangeBounds() { + DefaultBoxAndWhiskerXYDataset d1 + = new DefaultBoxAndWhiskerXYDataset("S"); + d1.add(new Date(1L), new BoxAndWhiskerItem(1.0, 2.0, 3.0, 4.0, 5.0, + 6.0, 7.0, 8.0, new ArrayList())); + assertEquals(new Range(5.0, 6.0), d1.getRangeBounds(false)); + assertEquals(new Range(5.0, 6.0), d1.getRangeBounds(true)); + + d1.add(new Date(1L), new BoxAndWhiskerItem(1.5, 2.5, 3.5, 4.5, 5.5, + 6.5, 7.5, 8.5, new ArrayList())); + assertEquals(new Range(5.0, 6.5), d1.getRangeBounds(false)); + assertEquals(new Range(5.0, 6.5), d1.getRangeBounds(true)); + + d1.add(new Date(2L), new BoxAndWhiskerItem(2.5, 3.5, 4.5, 5.5, 6.5, + 7.5, 8.5, 9.5, new ArrayList())); + assertEquals(new Range(5.0, 7.5), d1.getRangeBounds(false)); + assertEquals(new Range(5.0, 7.5), d1.getRangeBounds(true)); + } + + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/DefaultMultiValueCategoryDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/DefaultMultiValueCategoryDatasetTest.java new file mode 100755 index 0000000..1e9c0e6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/DefaultMultiValueCategoryDatasetTest.java @@ -0,0 +1,253 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------------- + * DefaultMultiValueCategoryDatasetTest.java + * ----------------------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 28-Sep-2007 : Version 1 (DG); + * + */ + +package org.jfree.data.statistics; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import java.util.ArrayList; +import java.util.List; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.UnknownKeyException; +import org.junit.Test; + +/** + * Tests for the {@link DefaultMultiValueCategoryDataset} class. + */ +public class DefaultMultiValueCategoryDatasetTest { + + /** + * Some checks for the getValue() method. + */ + @Test + public void testGetValue() { + DefaultMultiValueCategoryDataset d + = new DefaultMultiValueCategoryDataset(); + List values = new ArrayList(); + values.add(new Integer(1)); + values.add(new Integer(2)); + d.add(values, "R1", "C1"); + assertEquals(new Double(1.5), d.getValue("R1", "C1")); + boolean pass = false; + try { + d.getValue("XX", "C1"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + d.getValue("R1", "XX"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * A simple check for the getValue(int, int) method. + */ + @Test + public void testGetValue2() { + DefaultMultiValueCategoryDataset d + = new DefaultMultiValueCategoryDataset(); + boolean pass = false; + try { + /* Number n =*/ d.getValue(0, 0); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some tests for the getRowCount() method. + */ + @Test + public void testGetRowCount() { + DefaultMultiValueCategoryDataset d + = new DefaultMultiValueCategoryDataset(); + assertTrue(d.getRowCount() == 0); + List values = new ArrayList(); + d.add(values, "R1", "C1"); + assertTrue(d.getRowCount() == 1); + + d.add(values, "R2", "C1"); + assertTrue(d.getRowCount() == 2); + + d.add(values, "R2", "C1"); + assertTrue(d.getRowCount() == 2); + } + + /** + * Some tests for the getColumnCount() method. + */ + @Test + public void testGetColumnCount() { + DefaultMultiValueCategoryDataset d + = new DefaultMultiValueCategoryDataset(); + assertTrue(d.getColumnCount() == 0); + + List values = new ArrayList(); + d.add(values, "R1", "C1"); + assertTrue(d.getColumnCount() == 1); + + d.add(values, "R1", "C2"); + assertTrue(d.getColumnCount() == 2); + + d.add(values, "R1", "C2"); + assertTrue(d.getColumnCount() == 2); + + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DefaultMultiValueCategoryDataset d1 + = new DefaultMultiValueCategoryDataset(); + DefaultMultiValueCategoryDataset d2 + = new DefaultMultiValueCategoryDataset(); + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + List values = new ArrayList(); + d1.add(values, "R1", "C1"); + assertFalse(d1.equals(d2)); + d2.add(values, "R1", "C1"); + assertTrue(d1.equals(d2)); + + values.add(new Integer(99)); + d1.add(values, "R1", "C1"); + assertFalse(d1.equals(d2)); + d2.add(values, "R1", "C1"); + assertTrue(d1.equals(d2)); + + values.add(new Integer(99)); + d1.add(values, "R1", "C2"); + assertFalse(d1.equals(d2)); + d2.add(values, "R1", "C2"); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultMultiValueCategoryDataset d1 + = new DefaultMultiValueCategoryDataset(); + DefaultMultiValueCategoryDataset d2 = (DefaultMultiValueCategoryDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + /** + * Some checks for the add() method. + */ + @Test + public void testAddValue() { + DefaultMultiValueCategoryDataset d1 + = new DefaultMultiValueCategoryDataset(); + + boolean pass = false; + try { + d1.add(null, "R1", "C1"); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + List values = new ArrayList(); + d1.add(values, "R2", "C1"); + assertEquals(values, d1.getValues("R2", "C1")); + + pass = false; + try { + d1.add(values, null, "C2"); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultMultiValueCategoryDataset d1 + = new DefaultMultiValueCategoryDataset(); + DefaultMultiValueCategoryDataset d2 + = (DefaultMultiValueCategoryDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // try a dataset with some content... + List values = new ArrayList(); + values.add(new Integer(99)); + d1.add(values, "R1", "C1"); + d2 = (DefaultMultiValueCategoryDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // check that the clone doesn't share the same underlying arrays. + List values2 = new ArrayList(); + values2.add(new Integer(111)); + d1.add(values2, "R2", "C2"); + assertFalse(d1.equals(d2)); + d2.add(values2, "R2", "C2"); + assertTrue(d1.equals(d2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/DefaultStatisticalCategoryDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/DefaultStatisticalCategoryDatasetTest.java new file mode 100755 index 0000000..3b5f931 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/DefaultStatisticalCategoryDatasetTest.java @@ -0,0 +1,285 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------------ + * DefaultStatisticalCategoryDatasetTest.java + * ------------------------------------------ + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Feb-2005 : Version 1 (DG); + * 03-Aug-2006 : Added testGetRangeBounds() method (DG); + * 28-Sep-2007 : Enhanced testCloning() method (DG); + * 02-Oct-2007 : Added new bounds tests (DG); + * 03-Oct-2007 : Added testRemove() method (DG); + * + */ + +package org.jfree.data.statistics; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.data.UnknownKeyException; +import org.junit.Test; + +/** + * Tests for the {@link DefaultStatisticalCategoryDataset} class. + */ +public class DefaultStatisticalCategoryDatasetTest { + + /** + * Some checks for the getRangeBounds() method. + */ + @Test + public void testGetRangeBounds() { + DefaultStatisticalCategoryDataset d + = new DefaultStatisticalCategoryDataset(); + + // an empty dataset should return null for bounds + assertNull(d.getRangeBounds(true)); + + // try a dataset with a single value + d.add(4.5, 1.0, "R1", "C1"); + assertEquals(new Range(4.5, 4.5), d.getRangeBounds(false)); + assertEquals(new Range(3.5, 5.5), d.getRangeBounds(true)); + + // try a dataset with two values + d.add(0.5, 2.0, "R1", "C2"); + assertEquals(new Range(0.5, 4.5), d.getRangeBounds(false)); + assertEquals(new Range(-1.5, 5.5), d.getRangeBounds(true)); + + // try a Double.NaN + d.add(Double.NaN, 0.0, "R1", "C3"); + assertEquals(new Range(0.5, 4.5), d.getRangeBounds(false)); + assertEquals(new Range(-1.5, 5.5), d.getRangeBounds(true)); + + // try a Double.NEGATIVE_INFINITY + d.add(Double.NEGATIVE_INFINITY, 0.0, "R1", "C3"); + assertEquals(new Range(Double.NEGATIVE_INFINITY, 4.5), + d.getRangeBounds(false)); + assertEquals(new Range(Double.NEGATIVE_INFINITY, 5.5), + d.getRangeBounds(true)); + + // try a Double.POSITIVE_INFINITY + d.add(Double.POSITIVE_INFINITY, 0.0, "R1", "C3"); + assertEquals(new Range(0.5, Double.POSITIVE_INFINITY), + d.getRangeBounds(false)); + assertEquals(new Range(-1.5, Double.POSITIVE_INFINITY), + d.getRangeBounds(true)); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DefaultStatisticalCategoryDataset d1 + = new DefaultStatisticalCategoryDataset(); + DefaultStatisticalCategoryDataset d2 + = new DefaultStatisticalCategoryDataset(); + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + } + + /** + * Some checks for cloning. + */ + @Test + public void testCloning() { + DefaultStatisticalCategoryDataset d1 + = new DefaultStatisticalCategoryDataset(); + d1.add(1.1, 2.2, "R1", "C1"); + d1.add(3.3, 4.4, "R1", "C2"); + d1.add(null, new Double(5.5), "R1", "C3"); + d1.add(new Double(6.6), null, "R2", "C3"); + DefaultStatisticalCategoryDataset d2 = null; + try { + d2 = (DefaultStatisticalCategoryDataset) d1.clone(); + } + catch (CloneNotSupportedException e) { + fail(e.toString()); + } + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // check independence + d1.add(1.1, 2.2, "R3", "C1"); + assertFalse(d1.equals(d2)); + } + + /** + * Check serialization of a default instance. + */ + @Test + public void testSerialization1() { + DefaultStatisticalCategoryDataset d1 + = new DefaultStatisticalCategoryDataset(); + d1.add(1.1, 2.2, "R1", "C1"); + d1.add(3.3, 4.4, "R1", "C2"); + d1.add(null, new Double(5.5), "R1", "C3"); + d1.add(new Double(6.6), null, "R2", "C3"); + DefaultStatisticalCategoryDataset d2 = + (DefaultStatisticalCategoryDataset) TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + /** + * Check serialization of a more complex instance. + */ + @Test + public void testSerialization2() { + DefaultStatisticalCategoryDataset d1 + = new DefaultStatisticalCategoryDataset(); + d1.add(1.2, 3.4, "Row 1", "Column 1"); + DefaultStatisticalCategoryDataset d2 = + (DefaultStatisticalCategoryDataset) TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the add() method. + */ + @Test + public void testAdd() { + DefaultStatisticalCategoryDataset d1 + = new DefaultStatisticalCategoryDataset(); + d1.add(1.0, 2.0, "R1", "C1"); + assertEquals(1.0, d1.getValue("R1", "C1").doubleValue(), EPSILON); + assertEquals(2.0, d1.getStdDevValue("R1", "C1").doubleValue(), EPSILON); + + // overwrite the value + d1.add(10.0, 20.0, "R1", "C1"); + assertEquals(10.0, d1.getValue("R1", "C1").doubleValue(), EPSILON); + assertEquals(20.0, d1.getStdDevValue("R1", "C1").doubleValue(), EPSILON); + } + + /** + * Some checks for the getRangeLowerBound() method. + */ + @Test + public void testGetRangeLowerBound() { + DefaultStatisticalCategoryDataset d1 + = new DefaultStatisticalCategoryDataset(); + d1.add(1.0, 2.0, "R1", "C1"); + assertEquals(1.0, d1.getRangeLowerBound(false), EPSILON); + assertEquals(-1.0, d1.getRangeLowerBound(true), EPSILON); + } + + /** + * Some checks for the getRangeUpperBound() method. + */ + @Test + public void testGetRangeUpperBound() { + DefaultStatisticalCategoryDataset d1 + = new DefaultStatisticalCategoryDataset(); + d1.add(1.0, 2.0, "R1", "C1"); + assertEquals(1.0, d1.getRangeUpperBound(false), EPSILON); + assertEquals(3.0, d1.getRangeUpperBound(true), EPSILON); + } + + /** + * Some checks for the getRangeBounds() method. + */ + @Test + public void testGetRangeBounds2() { + DefaultStatisticalCategoryDataset d1 + = new DefaultStatisticalCategoryDataset(); + d1.add(1.0, 2.0, "R1", "C1"); + assertEquals(new Range(1.0, 1.0), d1.getRangeBounds(false)); + assertEquals(new Range(-1.0, 3.0), d1.getRangeBounds(true)); + + d1.add(10.0, 20.0, "R1", "C1"); + assertEquals(new Range(10.0, 10.0), d1.getRangeBounds(false)); + assertEquals(new Range(-10.0, 30.0), d1.getRangeBounds(true)); + } + + /** + * Some checks for the remove method. + */ + @Test + public void testRemove() { + DefaultStatisticalCategoryDataset data + = new DefaultStatisticalCategoryDataset(); + + boolean pass = false; + try { + data.remove("R1", "R2"); + } + catch (UnknownKeyException e) { + pass = true; + } + assertTrue(pass); + data.add(1.0, 0.5, "R1", "C1"); + assertEquals(new Range(1.0, 1.0), data.getRangeBounds(false)); + assertEquals(new Range(0.5, 1.5), data.getRangeBounds(true)); + + data.add(1.4, 0.2, "R2", "C1"); + + assertEquals(1.0, data.getRangeLowerBound(false), EPSILON); + assertEquals(1.4, data.getRangeUpperBound(false), EPSILON); + assertEquals(0.5, data.getRangeLowerBound(true), EPSILON); + assertEquals(1.6, data.getRangeUpperBound(true), EPSILON); + + data.remove("R1", "C1"); + + assertEquals(1.4, data.getRangeLowerBound(false), EPSILON); + assertEquals(1.4, data.getRangeUpperBound(false), EPSILON); + assertEquals(1.2, data.getRangeLowerBound(true), EPSILON); + assertEquals(1.6, data.getRangeUpperBound(true), EPSILON); + } + + /** + * A test for bug 3072674. + */ + @Test + public void test3072674() { + DefaultStatisticalCategoryDataset dataset + = new DefaultStatisticalCategoryDataset(); + dataset.add(1.0, Double.NaN, "R1", "C1"); + assertEquals(1.0, dataset.getRangeLowerBound(true), EPSILON); + assertEquals(1.0, dataset.getRangeUpperBound(true), EPSILON); + + Range r = dataset.getRangeBounds(true); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(1.0, r.getUpperBound(), EPSILON); + } + + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/HistogramBinTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/HistogramBinTest.java new file mode 100755 index 0000000..d8f1ee3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/HistogramBinTest.java @@ -0,0 +1,92 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * HistogramBinTest.java + * --------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 01-Mar-2004 : Version 1 (DG); + * + */ + +package org.jfree.data.statistics; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link HistogramBin} class. + */ +public class HistogramBinTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + double start = 10.0; + double end = 20.0; + HistogramBin b1 = new HistogramBin(start, end); + HistogramBin b2 = new HistogramBin(start, end); + assertEquals(b1, b2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + double start = 10.0; + double end = 20.0; + HistogramBin b1 = new HistogramBin(start, end); + HistogramBin b2 = (HistogramBin) b1.clone(); + assertTrue(b1 != b2); + assertTrue(b1.getClass() == b2.getClass()); + assertTrue(b1.equals(b2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + double start = 10.0; + double end = 20.0; + HistogramBin b1 = new HistogramBin(start, end); + HistogramBin b2 = (HistogramBin) TestUtilities.serialised(b1); + assertEquals(b1, b2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/HistogramDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/HistogramDatasetTest.java new file mode 100755 index 0000000..766d018 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/HistogramDatasetTest.java @@ -0,0 +1,256 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * HistogramDatasetTest.java + * ------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 01-Mar-2004 : Version 1 (DG); + * 08-Jun-2005 : Added test for getSeriesKey(int) bug (DG); + * 03-Aug-2006 : Added testAddSeries() and testBinBoundaries() method (DG); + * 22-May-2008 : Added testAddSeries2() and enhanced testCloning() (DG); + * 08-Dec-2009 : Added test2902842() for patch at SourceForge (DG); + * + */ + +package org.jfree.data.statistics; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetChangeListener; +import org.junit.Test; + +/** + * Tests for the {@link HistogramDataset} class. + */ +public class HistogramDatasetTest implements DatasetChangeListener { + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks that the correct values are assigned to bins. + */ + @Test + public void testBins() { + double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5}; + HistogramDataset hd = new HistogramDataset(); + hd.addSeries("Series 1", values, 5); + assertEquals(hd.getYValue(0, 0), 3.0, EPSILON); + assertEquals(hd.getYValue(0, 1), 3.0, EPSILON); + assertEquals(hd.getYValue(0, 2), 2.0, EPSILON); + assertEquals(hd.getYValue(0, 3), 0.0, EPSILON); + assertEquals(hd.getYValue(0, 4), 1.0, EPSILON); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5}; + HistogramDataset d1 = new HistogramDataset(); + d1.addSeries("Series 1", values, 5); + HistogramDataset d2 = new HistogramDataset(); + d2.addSeries("Series 1", values, 5); + + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + d1.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2); + assertFalse(d1.equals(d2)); + d2.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5}; + HistogramDataset d1 = new HistogramDataset(); + d1.addSeries("Series 1", values, 5); + HistogramDataset d2 = (HistogramDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // simple check for independence + d1.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2); + assertFalse(d1.equals(d2)); + d2.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5}; + HistogramDataset d1 = new HistogramDataset(); + d1.addSeries("Series 1", values, 5); + HistogramDataset d2 = (HistogramDataset) TestUtilities.serialised(d1); + assertEquals(d1, d2); + + // simple check for independence + d1.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2); + assertFalse(d1.equals(d2)); + d2.addSeries("Series 2", new double[] {1.0, 2.0, 3.0}, 2); + assertTrue(d1.equals(d2)); + } + + /** + * A test for a bug reported in the forum where the series name isn't being + * returned correctly. + */ + @Test + public void testGetSeriesKey() { + double[] values = {1.0, 2.0, 3.0, 4.0, 6.0, 12.0, 5.0, 6.3, 4.5}; + HistogramDataset d1 = new HistogramDataset(); + d1.addSeries("Series 1", values, 5); + assertEquals("Series 1", d1.getSeriesKey(0)); + } + + /** + * Some checks for the addSeries() method. + */ + @Test + public void testAddSeries() { + double[] values = {-1.0, 0.0, 0.1, 0.9, 1.0, 1.1, 1.9, 2.0, 3.0}; + HistogramDataset d = new HistogramDataset(); + d.addSeries("S1", values, 2, 0.0, 2.0); + assertEquals(0.0, d.getStartXValue(0, 0), EPSILON); + assertEquals(1.0, d.getEndXValue(0, 0), EPSILON); + assertEquals(4.0, d.getYValue(0, 0), EPSILON); + + assertEquals(1.0, d.getStartXValue(0, 1), EPSILON); + assertEquals(2.0, d.getEndXValue(0, 1), EPSILON); + assertEquals(5.0, d.getYValue(0, 1), EPSILON); + } + + /** + * Another check for the addSeries() method. + */ + @Test + public void testAddSeries2() { + double[] values = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + HistogramDataset hd = new HistogramDataset(); + hd.addSeries("S1", values, 5); + assertEquals(0.0, hd.getStartXValue(0, 0), EPSILON); + assertEquals(1.0, hd.getEndXValue(0, 0), EPSILON); + assertEquals(1.0, hd.getYValue(0, 0), EPSILON); + assertEquals(1.0, hd.getStartXValue(0, 1), EPSILON); + assertEquals(2.0, hd.getEndXValue(0, 1), EPSILON); + assertEquals(1.0, hd.getYValue(0, 1), EPSILON); + assertEquals(2.0, hd.getStartXValue(0, 2), EPSILON); + assertEquals(3.0, hd.getEndXValue(0, 2), EPSILON); + assertEquals(1.0, hd.getYValue(0, 2), EPSILON); + assertEquals(3.0, hd.getStartXValue(0, 3), EPSILON); + assertEquals(4.0, hd.getEndXValue(0, 3), EPSILON); + assertEquals(1.0, hd.getYValue(0, 3), EPSILON); + assertEquals(4.0, hd.getStartXValue(0, 4), EPSILON); + assertEquals(5.0, hd.getEndXValue(0, 4), EPSILON); + assertEquals(2.0, hd.getYValue(0, 4), EPSILON); + } + + /** + * This test is derived from a reported bug. + */ + @Test + public void testBinBoundaries() { + double[] values = {-5.000000000000286E-5}; + int bins = 1260; + double minimum = -0.06307522528160199; + double maximum = 0.06297522528160199; + HistogramDataset d = new HistogramDataset(); + d.addSeries("S1", values, bins, minimum, maximum); + assertEquals(0.0, d.getYValue(0, 629), EPSILON); + assertEquals(1.0, d.getYValue(0, 630), EPSILON); + assertEquals(0.0, d.getYValue(0, 631), EPSILON); + assertTrue(values[0] > d.getStartXValue(0, 630)); + assertTrue(values[0] < d.getEndXValue(0, 630)); + } + + /** + * Some checks for bug 1553088. An IndexOutOfBoundsException is thrown + * when a data value is *very* close to the upper limit of the last bin. + */ + @Test + public void test1553088() { + double[] values = {-1.0, 0.0, -Double.MIN_VALUE, 3.0}; + HistogramDataset d = new HistogramDataset(); + d.addSeries("S1", values, 2, -1.0, 0.0); + assertEquals(-1.0, d.getStartXValue(0, 0), EPSILON); + assertEquals(-0.5, d.getEndXValue(0, 0), EPSILON); + assertEquals(1.0, d.getYValue(0, 0), EPSILON); + + assertEquals(-0.5, d.getStartXValue(0, 1), EPSILON); + assertEquals(0.0, d.getEndXValue(0, 1), EPSILON); + assertEquals(3.0, d.getYValue(0, 1), EPSILON); + } + + /** + * A test to show the limitation addressed by patch 2902842. + */ + @Test + public void test2902842() { + this.lastEvent = null; + double[] values = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0}; + HistogramDataset hd = new HistogramDataset(); + hd.addChangeListener(this); + hd.addSeries("S1", values, 5); + assertNotNull(this.lastEvent); + } + + /** + * A reference to the last event received by the datasetChanged() method. + */ + private DatasetChangeEvent lastEvent; + + /** + * Receives event notification. + * + * @param event the event. + */ + @Override + public void datasetChanged(DatasetChangeEvent event) { + this.lastEvent = event; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/MeanAndStandardDeviationTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/MeanAndStandardDeviationTest.java new file mode 100755 index 0000000..8a6032e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/MeanAndStandardDeviationTest.java @@ -0,0 +1,95 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * MeanAndStandardDeviationTest.java + * --------------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Feb-2005 : Version 1 (DG); + * + */ + +package org.jfree.data.statistics; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link MeanAndStandardDeviation} class. + */ +public class MeanAndStandardDeviationTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + MeanAndStandardDeviation m1 = new MeanAndStandardDeviation(1.2, 3.4); + MeanAndStandardDeviation m2 = new MeanAndStandardDeviation(1.2, 3.4); + assertTrue(m1.equals(m2)); + assertTrue(m2.equals(m1)); + + m1 = new MeanAndStandardDeviation(1.0, 3.4); + assertFalse(m1.equals(m2)); + m2 = new MeanAndStandardDeviation(1.0, 3.4); + assertTrue(m1.equals(m2)); + + m1 = new MeanAndStandardDeviation(1.0, 3.0); + assertFalse(m1.equals(m2)); + m2 = new MeanAndStandardDeviation(1.0, 3.0); + assertTrue(m1.equals(m2)); + } + + /** + * Immutable class - should not be cloneable. + */ + @Test + public void testCloning() { + MeanAndStandardDeviation m1 = new MeanAndStandardDeviation(1.2, 3.4); + assertFalse(m1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + MeanAndStandardDeviation m1 = new MeanAndStandardDeviation(1.2, 3.4); + MeanAndStandardDeviation m2 = (MeanAndStandardDeviation) + TestUtilities.serialised(m1); + assertEquals(m1, m2); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/RegressionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/RegressionTest.java new file mode 100755 index 0000000..634f33a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/RegressionTest.java @@ -0,0 +1,261 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * RegressionTest.java + * ------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Sep-2002 : Version 1 (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * + */ + +package org.jfree.data.statistics; + +import static org.junit.Assert.assertEquals; + +import org.jfree.data.xy.XYDataset; +import org.jfree.data.xy.XYSeries; +import org.jfree.data.xy.XYSeriesCollection; +import org.junit.Test; + +/** + * Tests for the {@link Regression} class. + */ +public class RegressionTest { + + /** + * Checks the results of an OLS regression on sample dataset 1. + */ + @Test + public void testOLSRegression1a() { + double[][] data = createSampleData1(); + double[] result1 = Regression.getOLSRegression(data); + assertEquals(.25680930, result1[0], 0.0000001); + assertEquals(0.72792106, result1[1], 0.0000001); + } + + /** + * Checks the results of an OLS regression on sample dataset 1 AFTER + * converting it to an XYSeries. + */ + @Test + public void testOLSRegression1b() { + + double[][] data = createSampleData1(); + + XYSeries series = new XYSeries("Test"); + for (int i = 0; i < 11; i++) { + series.add(data[i][0], data[i][1]); + } + XYDataset ds = new XYSeriesCollection(series); + double[] result2 = Regression.getOLSRegression(ds, 0); + + assertEquals(.25680930, result2[0], 0.0000001); + assertEquals(0.72792106, result2[1], 0.0000001); + + } + + /** + * Checks the results of a power regression on sample dataset 1. + */ + @Test + public void testPowerRegression1a() { + + double[][] data = createSampleData1(); + double[] result = Regression.getPowerRegression(data); + assertEquals(0.91045813, result[0], 0.0000001); + assertEquals(0.88918346, result[1], 0.0000001); + + } + + /** + * Checks the results of a power regression on sample dataset 1 AFTER + * converting it to an XYSeries. + */ + @Test + public void testPowerRegression1b() { + + double[][] data = createSampleData1(); + + XYSeries series = new XYSeries("Test"); + for (int i = 0; i < 11; i++) { + series.add(data[i][0], data[i][1]); + } + XYDataset ds = new XYSeriesCollection(series); + double[] result = Regression.getPowerRegression(ds, 0); + + assertEquals(0.91045813, result[0], 0.0000001); + assertEquals(0.88918346, result[1], 0.0000001); + + } + + /** + * Checks the results of an OLS regression on sample dataset 2. + */ + @Test + public void testOLSRegression2a() { + + double[][] data = createSampleData2(); + double[] result = Regression.getOLSRegression(data); + assertEquals(53.9729697, result[0], 0.0000001); + assertEquals(-4.1823030, result[1], 0.0000001); + + } + + /** + * Checks the results of an OLS regression on sample dataset 2 AFTER + * converting it to an XYSeries. + */ + @Test + public void testOLSRegression2b() { + + double[][] data = createSampleData2(); + + XYSeries series = new XYSeries("Test"); + for (int i = 0; i < 10; i++) { + series.add(data[i][0], data[i][1]); + } + XYDataset ds = new XYSeriesCollection(series); + double[] result = Regression.getOLSRegression(ds, 0); + + assertEquals(53.9729697, result[0], 0.0000001); + assertEquals(-4.1823030, result[1], 0.0000001); + + } + + /** + * Checks the results of a power regression on sample dataset 2. + */ + @Test + public void testPowerRegression2a() { + double[][] data = createSampleData2(); + double[] result = Regression.getPowerRegression(data); + assertEquals(106.1241681, result[0], 0.0000001); + assertEquals(-0.8466615, result[1], 0.0000001); + } + + /** + * Checks the results of a power regression on sample dataset 2 AFTER + * converting it to an XYSeries. + */ + @Test + public void testPowerRegression2b() { + + double[][] data = createSampleData2(); + + XYSeries series = new XYSeries("Test"); + for (int i = 0; i < 10; i++) { + series.add(data[i][0], data[i][1]); + } + XYDataset ds = new XYSeriesCollection(series); + double[] result = Regression.getPowerRegression(ds, 0); + + assertEquals(106.1241681, result[0], 0.0000001); + assertEquals(-0.8466615, result[1], 0.0000001); + + } + + /** + * Creates and returns a sample dataset. + *

      + * The data is taken from Table 11.2, page 313 of "Understanding Statistics" + * by Ott and Mendenhall (Duxbury Press). + * + * @return The sample data. + */ + private double[][] createSampleData1() { + + double[][] result = new double[11][2]; + + result[0][0] = 2.00; + result[0][1] = 1.60; + result[1][0] = 2.25; + result[1][1] = 2.00; + result[2][0] = 2.60; + result[2][1] = 1.80; + result[3][0] = 2.65; + result[3][1] = 2.80; + result[4][0] = 2.80; + result[4][1] = 2.10; + result[5][0] = 3.10; + result[5][1] = 2.00; + result[6][0] = 2.90; + result[6][1] = 2.65; + result[7][0] = 3.25; + result[7][1] = 2.25; + result[8][0] = 3.30; + result[8][1] = 2.60; + result[9][0] = 3.60; + result[9][1] = 3.00; + result[10][0] = 3.25; + result[10][1] = 3.10; + + return result; + + } + + /** + * Creates a sample data set. + * + * @return The sample data. + */ + private double[][] createSampleData2() { + + double[][] result = new double[10][2]; + + result[0][0] = 2; + result[0][1] = 56.27; + result[1][0] = 3; + result[1][1] = 41.32; + result[2][0] = 4; + result[2][1] = 31.45; + result[3][0] = 5; + result[3][1] = 30.05; + result[4][0] = 6; + result[4][1] = 24.69; + result[5][0] = 7; + result[5][1] = 19.78; + result[6][0] = 8; + result[6][1] = 20.94; + result[7][0] = 9; + result[7][1] = 16.73; + result[8][0] = 10; + result[8][1] = 14.21; + result[9][0] = 11; + result[9][1] = 12.44; + + return result; + + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/SimpleHistogramBinTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/SimpleHistogramBinTest.java new file mode 100755 index 0000000..f92bea0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/SimpleHistogramBinTest.java @@ -0,0 +1,165 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * SimpleHistogramBinTest.java + * --------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-Jan-2005 : Version 1 (DG); + * + */ + +package org.jfree.data.statistics; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link SimpleHistogramBin} class. + */ +public class SimpleHistogramBinTest { + + /** + * Some checks for the accepts() method. + */ + @Test + public void testAccepts() { + SimpleHistogramBin bin1 = new SimpleHistogramBin(1.0, 2.0); + assertFalse(bin1.accepts(0.0)); + assertTrue(bin1.accepts(1.0)); + assertTrue(bin1.accepts(1.5)); + assertTrue(bin1.accepts(2.0)); + assertFalse(bin1.accepts(2.1)); + assertFalse(bin1.accepts(Double.NaN)); + + SimpleHistogramBin bin2 + = new SimpleHistogramBin(1.0, 2.0, false, false); + assertFalse(bin2.accepts(0.0)); + assertFalse(bin2.accepts(1.0)); + assertTrue(bin2.accepts(1.5)); + assertFalse(bin2.accepts(2.0)); + assertFalse(bin2.accepts(2.1)); + assertFalse(bin2.accepts(Double.NaN)); + } + + /** + * Some checks for the overlapsWith() method. + */ + @Test + public void testOverlapsWidth() { + SimpleHistogramBin b1 = new SimpleHistogramBin(1.0, 2.0); + SimpleHistogramBin b2 = new SimpleHistogramBin(2.0, 3.0); + SimpleHistogramBin b3 = new SimpleHistogramBin(3.0, 4.0); + SimpleHistogramBin b4 = new SimpleHistogramBin(0.0, 5.0); + SimpleHistogramBin b5 = new SimpleHistogramBin(2.0, 3.0, false, true); + SimpleHistogramBin b6 = new SimpleHistogramBin(2.0, 3.0, true, false); + assertTrue(b1.overlapsWith(b2)); + assertTrue(b2.overlapsWith(b1)); + assertFalse(b1.overlapsWith(b3)); + assertFalse(b3.overlapsWith(b1)); + assertTrue(b1.overlapsWith(b4)); + assertTrue(b4.overlapsWith(b1)); + assertFalse(b1.overlapsWith(b5)); + assertFalse(b5.overlapsWith(b1)); + assertTrue(b1.overlapsWith(b6)); + assertTrue(b6.overlapsWith(b1)); + } + + /** + * Ensure that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + SimpleHistogramBin b1 = new SimpleHistogramBin(1.0, 2.0); + SimpleHistogramBin b2 = new SimpleHistogramBin(1.0, 2.0); + assertTrue(b1.equals(b2)); + assertTrue(b2.equals(b1)); + + b1 = new SimpleHistogramBin(1.1, 2.0, true, true); + assertFalse(b1.equals(b2)); + b2 = new SimpleHistogramBin(1.1, 2.0, true, true); + assertTrue(b1.equals(b2)); + + b1 = new SimpleHistogramBin(1.1, 2.2, true, true); + assertFalse(b1.equals(b2)); + b2 = new SimpleHistogramBin(1.1, 2.2, true, true); + assertTrue(b1.equals(b2)); + + b1 = new SimpleHistogramBin(1.1, 2.2, false, true); + assertFalse(b1.equals(b2)); + b2 = new SimpleHistogramBin(1.1, 2.2, false, true); + assertTrue(b1.equals(b2)); + + b1 = new SimpleHistogramBin(1.1, 2.2, false, false); + assertFalse(b1.equals(b2)); + b2 = new SimpleHistogramBin(1.1, 2.2, false, false); + assertTrue(b1.equals(b2)); + + b1.setItemCount(99); + assertFalse(b1.equals(b2)); + b2.setItemCount(99); + assertTrue(b1.equals(b2)); + } + + /** + * Some checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + SimpleHistogramBin b1 = new SimpleHistogramBin(1.1, 2.2, false, true); + b1.setItemCount(99); + SimpleHistogramBin b2 = (SimpleHistogramBin) b1.clone(); + assertTrue(b1 != b2); + assertTrue(b1.getClass() == b2.getClass()); + assertTrue(b1.equals(b2)); + + // check that clone is independent of the original + b2.setItemCount(111); + assertFalse(b1.equals(b2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + SimpleHistogramBin b1 = new SimpleHistogramBin(1.0, 2.0, false, true); + b1.setItemCount(123); + SimpleHistogramBin b2 = (SimpleHistogramBin) TestUtilities.serialised(b1); + assertEquals(b1, b2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/SimpleHistogramDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/SimpleHistogramDatasetTest.java new file mode 100755 index 0000000..b3b5d72 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/SimpleHistogramDatasetTest.java @@ -0,0 +1,128 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * SimpleHistogramDatasetTest.java + * ------------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 10-Jan-2005 : Version 1 (DG); + * 21-May-2007 : Added testClearObservations (DG); + * + */ + +package org.jfree.data.statistics; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link SimpleHistogramDataset} class. + */ +public class SimpleHistogramDatasetTest { + + /** + * Ensure that the equals() method can distinguish all fields. + */ + @Test + public void testEquals() { + SimpleHistogramDataset d1 = new SimpleHistogramDataset("Dataset 1"); + SimpleHistogramDataset d2 = new SimpleHistogramDataset("Dataset 1"); + assertTrue(d1.equals(d2)); + + d1.addBin(new SimpleHistogramBin(1.0, 2.0)); + assertFalse(d1.equals(d2)); + d2.addBin(new SimpleHistogramBin(1.0, 2.0)); + assertTrue(d1.equals(d2)); + } + + /** + * Some checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + SimpleHistogramDataset d1 = new SimpleHistogramDataset("Dataset 1"); + SimpleHistogramDataset d2 = (SimpleHistogramDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // check that clone is independent of the original + d2.addBin(new SimpleHistogramBin(2.0, 3.0)); + d2.addObservation(2.3); + assertFalse(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + SimpleHistogramDataset d1 = new SimpleHistogramDataset("D1"); + SimpleHistogramDataset d2 = (SimpleHistogramDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the clearObservations() method. + */ + @Test + public void testClearObservations() { + SimpleHistogramDataset d1 = new SimpleHistogramDataset("D1"); + d1.clearObservations(); + assertEquals(0, d1.getItemCount(0)); + d1.addBin(new SimpleHistogramBin(0.0, 1.0)); + d1.addObservation(0.5); + assertEquals(1.0, d1.getYValue(0, 0), EPSILON); + } + + /** + * Some checks for the removeAllBins() method. + */ + @Test + public void testRemoveAllBins() { + SimpleHistogramDataset d1 = new SimpleHistogramDataset("D1"); + d1.addBin(new SimpleHistogramBin(0.0, 1.0)); + d1.addObservation(0.5); + d1.addBin(new SimpleHistogramBin(2.0, 3.0)); + assertEquals(2, d1.getItemCount(0)); + d1.removeAllBins(); + assertEquals(0, d1.getItemCount(0)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/StatisticsTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/StatisticsTest.java new file mode 100755 index 0000000..580fbcc --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/StatisticsTest.java @@ -0,0 +1,465 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * StatisticsTest.java + * ------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Mar-2004 : Version 1 (DG); + * 04-Oct-2004 : Eliminated NumberUtils usage (DG); + * + */ + +package org.jfree.data.statistics; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import org.junit.Test; + +/** + * Tests for the {@link Statistics} class. + */ +public class StatisticsTest { + + /** + * Some checks for the calculateMean(Number[]) and + * calculateMean(Number[], boolean) methods. + */ + @Test + public void testCalculateMean_Array() { + + // try null array + boolean pass = false; + try { + Statistics.calculateMean((Number[]) null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + Statistics.calculateMean((Number[]) null, false); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + // try an array containing no items + assertTrue(Double.isNaN(Statistics.calculateMean(new Number[0]))); + assertTrue(Double.isNaN(Statistics.calculateMean(new Number[0], + false))); + + // try an array containing a single Number + Number[] values = new Number[] {new Double(1.0)}; + assertEquals(1.0, Statistics.calculateMean(values), EPSILON); + assertEquals(1.0, Statistics.calculateMean(values, true), EPSILON); + assertEquals(1.0, Statistics.calculateMean(values, false), EPSILON); + + // try an array containing a single Number and a null + values = new Number[] {new Double(1.0), null}; + assertTrue(Double.isNaN(Statistics.calculateMean(values))); + assertTrue(Double.isNaN(Statistics.calculateMean(values, true))); + assertEquals(1.0, Statistics.calculateMean(values, false), EPSILON); + + // try an array containing a single Number and a NaN + values = new Number[] {new Double(1.0), new Double(Double.NaN)}; + assertTrue(Double.isNaN(Statistics.calculateMean(values))); + assertTrue(Double.isNaN(Statistics.calculateMean(values, true))); + assertEquals(1.0, Statistics.calculateMean(values, false), EPSILON); + } + + /** + * Some checks for the calculateMean(Collection) and + * calculateMean(Collection, boolean) methods. + */ + @Test + public void testCalculateMean_Collection() { + + // try a null collection + boolean pass = false; + try { + Statistics.calculateMean((Collection) null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + Statistics.calculateMean((Collection) null, false); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + // try an empty collection + List values = new ArrayList(); + assertTrue(Double.isNaN(Statistics.calculateMean(values))); + assertTrue(Double.isNaN(Statistics.calculateMean(values, true))); + assertTrue(Double.isNaN(Statistics.calculateMean(values, false))); + + // try a collection with a single number + values.add(new Double(9.0)); + assertEquals(9.0, Statistics.calculateMean(values), EPSILON); + assertEquals(9.0, Statistics.calculateMean(values, true), EPSILON); + assertEquals(9.0, Statistics.calculateMean(values, false), EPSILON); + + // try a collection with a single number plus a null + values.add(null); + assertTrue(Double.isNaN(Statistics.calculateMean(values))); + assertTrue(Double.isNaN(Statistics.calculateMean(values, true))); + assertEquals(9.0, Statistics.calculateMean(values, false), EPSILON); + + // try a collection with a single number plus a NaN + values.clear(); + values.add(new Double(9.0)); + values.add(new Double(Double.NaN)); + assertTrue(Double.isNaN(Statistics.calculateMean(values))); + assertTrue(Double.isNaN(Statistics.calculateMean(values, true))); + assertEquals(9.0, Statistics.calculateMean(values, false), EPSILON); + + // try a collection with several numbers + values = new ArrayList(); + values.add(new Double(9.0)); + values.add(new Double(3.0)); + values.add(new Double(2.0)); + values.add(new Double(2.0)); + double mean = Statistics.calculateMean(values); + assertEquals(4.0, mean, EPSILON); + + // a Collection containing a NaN will return Double.NaN for the result + values.add(new Double(Double.NaN)); + assertTrue(Double.isNaN(Statistics.calculateMean(values))); + } + + static final double EPSILON = 0.0000000001; + + /** + * Some checks for the calculateMedian(List, boolean) method. + */ + @Test + public void testCalculateMedian() { + + // check null list + assertTrue(Double.isNaN(Statistics.calculateMedian(null, false))); + assertTrue(Double.isNaN(Statistics.calculateMedian(null, true))); + + // check empty list + List list = new ArrayList(); + assertTrue(Double.isNaN(Statistics.calculateMedian(list, false))); + assertTrue(Double.isNaN(Statistics.calculateMedian(list, true))); + + // check list containing null + list.add(null); + boolean pass = false; + try { + Statistics.calculateMedian(list, false); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + Statistics.calculateMedian(list, true); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + + // check a list containing a non-Number object + list.clear(); + list.add("Not a number"); + pass = false; + try { + Statistics.calculateMedian(list, false); + } + catch (ClassCastException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + Statistics.calculateMedian(list, true); + } + catch (ClassCastException e) { + pass = true; + } + assertTrue(pass); + + } + + /** + * A test for the calculateMedian() method. + */ + @Test + public void testCalculateMedian1() { + List values = new ArrayList(); + values.add(new Double(1.0)); + double median = Statistics.calculateMedian(values); + assertEquals(1.0, median, 0.0000001); + } + + /** + * A test for the calculateMedian() method. + */ + @Test + public void testCalculateMedian2() { + List values = new ArrayList(); + values.add(new Double(2.0)); + values.add(new Double(1.0)); + double median = Statistics.calculateMedian(values); + assertEquals(1.5, median, 0.0000001); + } + + /** + * A test for the calculateMedian() method. + */ + @Test + public void testCalculateMedian3() { + List values = new ArrayList(); + values.add(new Double(1.0)); + values.add(new Double(2.0)); + values.add(new Double(3.0)); + values.add(new Double(6.0)); + values.add(new Double(5.0)); + values.add(new Double(4.0)); + double median = Statistics.calculateMedian(values); + assertEquals(3.5, median, 0.0000001); + } + + /** + * A test for the calculateMedian() method. + */ + @Test + public void testCalculateMedian4() { + List values = new ArrayList(); + values.add(new Double(7.0)); + values.add(new Double(2.0)); + values.add(new Double(3.0)); + values.add(new Double(5.0)); + values.add(new Double(4.0)); + values.add(new Double(6.0)); + values.add(new Double(1.0)); + double median = Statistics.calculateMedian(values); + assertEquals(4.0, median, 0.0000001); + } + + /** + * A test using some real data that caused a problem at one point. + */ + @Test + public void testCalculateMedian5() { + List values = new ArrayList(); + values.add(new Double(11.228692993861783)); + values.add(new Double(11.30823353859889)); + values.add(new Double(11.75312904769314)); + values.add(new Double(11.825102897465314)); + values.add(new Double(10.184252778401783)); + values.add(new Double(12.207951828057766)); + values.add(new Double(10.68841994040566)); + values.add(new Double(12.099522004479438)); + values.add(new Double(11.508874945056881)); + values.add(new Double(12.052517729558513)); + values.add(new Double(12.401481645578734)); + values.add(new Double(12.185377793028543)); + values.add(new Double(10.666372951930315)); + values.add(new Double(11.680978041499548)); + values.add(new Double(11.06528277406718)); + values.add(new Double(11.36876492904596)); + values.add(new Double(11.927565516175939)); + values.add(new Double(11.39307785978655)); + values.add(new Double(11.989603679523857)); + values.add(new Double(12.009834360354864)); + values.add(new Double(10.653351822461559)); + values.add(new Double(11.851776254376754)); + values.add(new Double(11.045441544755946)); + values.add(new Double(11.993674040560624)); + values.add(new Double(12.898219965238944)); + values.add(new Double(11.97095782819647)); + values.add(new Double(11.73234406745488)); + values.add(new Double(11.649006017243991)); + values.add(new Double(12.20549704915365)); + values.add(new Double(11.799723639384919)); + values.add(new Double(11.896208658005628)); + values.add(new Double(12.164149111823424)); + values.add(new Double(12.042795103513766)); + values.add(new Double(12.114839532596426)); + values.add(new Double(12.166609097075824)); + values.add(new Double(12.183017546225935)); + values.add(new Double(11.622009125845342)); + values.add(new Double(11.289365786738633)); + values.add(new Double(12.462984323671568)); + values.add(new Double(11.573494921030598)); + values.add(new Double(10.862867940485804)); + values.add(new Double(12.018186939664872)); + values.add(new Double(10.418046849313018)); + values.add(new Double(11.326344465881341)); + double median = Statistics.calculateMedian(values, true); + assertEquals(11.812413268425116, median, 0.000001); + Collections.sort(values); + double median2 = Statistics.calculateMedian(values, false); + assertEquals(11.812413268425116, median2, 0.000001); + } + + /** + * A test for the calculateMedian() method. + */ + @Test + public void testCalculateMedian6() { + List values = new ArrayList(); + values.add(new Double(7.0)); + values.add(new Double(2.0)); + values.add(new Double(3.0)); + values.add(new Double(5.0)); + values.add(new Double(4.0)); + values.add(new Double(6.0)); + values.add(new Double(1.0)); + double median = Statistics.calculateMedian(values, 0, 2); + assertEquals(3.0, median, 0.0000001); + } + + /** + * A simple test for the correlation calculation. + */ + @Test + public void testCorrelation1() { + Number[] data1 = new Number[3]; + data1[0] = new Double(1); + data1[1] = new Double(2); + data1[2] = new Double(3); + Number[] data2 = new Number[3]; + data2[0] = new Double(1); + data2[1] = new Double(2); + data2[2] = new Double(3); + double r = Statistics.getCorrelation(data1, data2); + assertEquals(1.0, r, 0.00000001); + } + + /** + * A simple test for the correlation calculation. + * + * http://trochim.human.cornell.edu/kb/statcorr.htm + */ + @Test + public void testCorrelation2() { + Number[] data1 = new Number[20]; + data1[0] = new Double(68); + data1[1] = new Double(71); + data1[2] = new Double(62); + data1[3] = new Double(75); + data1[4] = new Double(58); + data1[5] = new Double(60); + data1[6] = new Double(67); + data1[7] = new Double(68); + data1[8] = new Double(71); + data1[9] = new Double(69); + data1[10] = new Double(68); + data1[11] = new Double(67); + data1[12] = new Double(63); + data1[13] = new Double(62); + data1[14] = new Double(60); + data1[15] = new Double(63); + data1[16] = new Double(65); + data1[17] = new Double(67); + data1[18] = new Double(63); + data1[19] = new Double(61); + Number[] data2 = new Number[20]; + data2[0] = new Double(4.1); + data2[1] = new Double(4.6); + data2[2] = new Double(3.8); + data2[3] = new Double(4.4); + data2[4] = new Double(3.2); + data2[5] = new Double(3.1); + data2[6] = new Double(3.8); + data2[7] = new Double(4.1); + data2[8] = new Double(4.3); + data2[9] = new Double(3.7); + data2[10] = new Double(3.5); + data2[11] = new Double(3.2); + data2[12] = new Double(3.7); + data2[13] = new Double(3.3); + data2[14] = new Double(3.4); + data2[15] = new Double(4.0); + data2[16] = new Double(4.1); + data2[17] = new Double(3.8); + data2[18] = new Double(3.4); + data2[19] = new Double(3.6); + double r = Statistics.getCorrelation(data1, data2); + assertEquals(0.7306356862792885, r, 0.000000000001); + } + + /** + * Some checks for the getStdDev() method. + */ + @Test + public void testGetStdDev() { + + // try null argument + boolean pass = false; + try { + Statistics.getStdDev(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + // try zero length array + pass = false; + try { + Statistics.getStdDev(new Double[0]); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + // try single value + assertTrue(Double.isNaN(Statistics.getStdDev(new Double[] + {new Double(1.0)}))); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/package.html new file mode 100755 index 0000000..d971432 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/statistics/package.html @@ -0,0 +1,6 @@ + + + +Tests for the classes in the org.jfree.data.statistics package. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/DateRangeTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/DateRangeTest.java new file mode 100755 index 0000000..3da852c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/DateRangeTest.java @@ -0,0 +1,113 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * DateRangeTest.java + * ------------------ + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Mar-2004 : Version 1 (DG); + * 11-Jan-2005 : Added test to ensure Cloneable is not implemented (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import java.util.Date; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Some tests for the {@link DateRange} class. + */ +public class DateRangeTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DateRange r1 = new DateRange(new Date(1000L), new Date(2000L)); + DateRange r2 = new DateRange(new Date(1000L), new Date(2000L)); + assertTrue(r1.equals(r2)); + assertTrue(r2.equals(r1)); + + r1 = new DateRange(new Date(1111L), new Date(2000L)); + assertFalse(r1.equals(r2)); + r2 = new DateRange(new Date(1111L), new Date(2000L)); + assertTrue(r1.equals(r2)); + + r1 = new DateRange(new Date(1111L), new Date(2222L)); + assertFalse(r1.equals(r2)); + r2 = new DateRange(new Date(1111L), new Date(2222L)); + assertTrue(r1.equals(r2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DateRange r1 = new DateRange(new Date(1000L), new Date(2000L)); + DateRange r2 = (DateRange) TestUtilities.serialised(r1); + assertEquals(r1, r2); + } + + /** + * The {@link DateRange} class is immutable, so it doesn't need to + * be cloneable. + */ + @Test + public void testClone() { + DateRange r1 = new DateRange(new Date(1000L), new Date(2000L)); + assertFalse(r1 instanceof Cloneable); + } + + /** + * Confirm that a DateRange is immutable. + */ + @Test + public void testImmutable() { + Date d1 = new Date(10L); + Date d2 = new Date(20L); + DateRange r = new DateRange(d1, d2); + d1.setTime(11L); + assertEquals(new Date(10L), r.getLowerDate()); + r.getUpperDate().setTime(22L); + assertEquals(new Date(20L), r.getUpperDate()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/DayTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/DayTest.java new file mode 100755 index 0000000..9cc1509 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/DayTest.java @@ -0,0 +1,402 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------ + * DayTest.java + * ------------ + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 15-Nov-2001 : Version 1 (DG); + * 20-Mar-2002 : Added new tests for Day constructor and getStart() and + * getEnd() in different time zones (DG); + * 26-Jun-2002 : Removed unnecessary imports (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 13-Mar-2003 : Added serialization test (DG); + * 21-Oct-2003 : Added hashCode test (DG); + * 11-Jan-2005 : Added test for non-clonability (DG); + * 03-Oct-2006 : Added testGetSerialIndex() (DG); + * 11-Jul-2007 : Fixed bad time zone assumption (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; + +import org.jfree.date.MonthConstants; +import org.junit.Test; + +/** + * Tests for the {@link Day} class. + */ +public class DayTest { + + /** + * Check that a Day instance is equal to itself. + * + * SourceForge Bug ID: 558850. + */ + @Test + public void testEqualsSelf() { + Day day = new Day(); + assertTrue(day.equals(day)); + } + + /** + * Tests the equals method. + */ + @Test + public void testEquals() { + Day day1 = new Day(29, MonthConstants.MARCH, 2002); + Day day2 = new Day(29, MonthConstants.MARCH, 2002); + assertTrue(day1.equals(day2)); + } + + /** + * In GMT, the end of 29 Feb 2004 is java.util.Date(1,078,099,199,999L). + * Use this to check the day constructor. + */ + @Test + public void testDateConstructor1() { + TimeZone zone = TimeZone.getTimeZone("GMT"); + Locale locale = Locale.UK; + Day d1 = new Day(new Date(1078099199999L), zone, locale); + Day d2 = new Day(new Date(1078099200000L), zone, locale); + + assertEquals(MonthConstants.FEBRUARY, d1.getMonth()); + assertEquals(1078099199999L, d1.getLastMillisecond(zone)); + + assertEquals(MonthConstants.MARCH, d2.getMonth()); + assertEquals(1078099200000L, d2.getFirstMillisecond(zone)); + } + + /** + * In Helsinki, the end of 29 Feb 2004 is + * java.util.Date(1,078,091,999,999L). Use this to check the Day + * constructor. + */ + @Test + public void testDateConstructor2() { + TimeZone zone = TimeZone.getTimeZone("Europe/Helsinki"); + Locale locale = Locale.getDefault(); // locale shouldn't matter here + Day d1 = new Day(new Date(1078091999999L), zone, locale); + Day d2 = new Day(new Date(1078092000000L), zone, locale); + + assertEquals(MonthConstants.FEBRUARY, d1.getMonth()); + assertEquals(1078091999999L, d1.getLastMillisecond(zone)); + + assertEquals(MonthConstants.MARCH, d2.getMonth()); + assertEquals(1078092000000L, d2.getFirstMillisecond(zone)); + } + + /** + * Set up a day equal to 1 January 1900. Request the previous day, it + * should be null. + */ + @Test + public void test1Jan1900Previous() { + Day jan1st1900 = new Day(1, MonthConstants.JANUARY, 1900); + Day previous = (Day) jan1st1900.previous(); + assertNull(previous); + } + + /** + * Set up a day equal to 1 January 1900. Request the next day, it should + * be 2 January 1900. + */ + @Test + public void test1Jan1900Next() { + Day jan1st1900 = new Day(1, MonthConstants.JANUARY, 1900); + Day next = (Day) jan1st1900.next(); + assertEquals(2, next.getDayOfMonth()); + } + + /** + * Set up a day equal to 31 December 9999. Request the previous day, it + * should be 30 December 9999. + */ + @Test + public void test31Dec9999Previous() { + Day dec31st9999 = new Day(31, MonthConstants.DECEMBER, 9999); + Day previous = (Day) dec31st9999.previous(); + assertEquals(30, previous.getDayOfMonth()); + } + + /** + * Set up a day equal to 31 December 9999. Request the next day, it should + * be null. + */ + @Test + public void test31Dec9999Next() { + Day dec31st9999 = new Day(31, MonthConstants.DECEMBER, 9999); + Day next = (Day) dec31st9999.next(); + assertNull(next); + } + + /** + * Problem for date parsing. + *

      + * This test works only correct if the short pattern of the date + * format is "dd/MM/yyyy". If not, this test will result in a + * false negative. + * + * @throws ParseException on parsing errors. + */ + @Test + public void testParseDay() throws ParseException { + GregorianCalendar gc = new GregorianCalendar(2001, 12, 31); + SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy"); + Date reference = format.parse("31/12/2001"); + if (reference.equals(gc.getTime())) { + // test 1... + Day d = Day.parseDay("31/12/2001"); + assertEquals(37256, d.getSerialDate().toSerial()); + } + + // test 2... + Day d = Day.parseDay("2001-12-31"); + assertEquals(37256, d.getSerialDate().toSerial()); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Day d1 = new Day(15, 4, 2000); + Day d2 = (Day) TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + Day d1 = new Day(1, 2, 2003); + Day d2 = new Day(1, 2, 2003); + assertTrue(d1.equals(d2)); + int h1 = d1.hashCode(); + int h2 = d2.hashCode(); + assertEquals(h1, h2); + } + + /** + * The {@link Day} class is immutable, so should not be {@link Cloneable}. + */ + @Test + public void testNotCloneable() { + Day d = new Day(1, 2, 2003); + assertFalse(d instanceof Cloneable); + } + + /** + * Some checks for the getSerialIndex() method. + */ + @Test + public void testGetSerialIndex() { + Day d = new Day(1, 1, 1900); + assertEquals(2, d.getSerialIndex()); + d = new Day(15, 4, 2000); + assertEquals(36631, d.getSerialIndex()); + } + + /** + * Some checks for the getFirstMillisecond() method. + */ + @Test + public void testGetFirstMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Day d = new Day(1, 3, 1970); + assertEquals(5094000000L, d.getFirstMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithTimeZone() { + Day d = new Day(26, 4, 1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-621187200000L, d.getFirstMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + d.getFirstMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithCalendar() { + Day d = new Day(1, 12, 2001); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(1007164800000L, d.getFirstMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + d.getFirstMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond() method. + */ + @Test + public void testGetLastMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Day d = new Day(1, 1, 1970); + assertEquals(82799999L, d.getLastMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithTimeZone() { + Day d = new Day(1, 2, 1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-628358400001L, d.getLastMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + d.getLastMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithCalendar() { + + Day d = new Day(4, 5, 2001); + Calendar calendar = Calendar.getInstance( + TimeZone.getTimeZone("Europe/London"), Locale.UK); + assertEquals(989017199999L, d.getLastMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + d.getLastMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the testNext() method. + */ + @Test + public void testNext() { + Day d = new Day(25, 12, 2000); + d = (Day) d.next(); + assertEquals(2000, d.getYear()); + assertEquals(12, d.getMonth()); + assertEquals(26, d.getDayOfMonth()); + d = new Day(31, 12, 9999); + assertNull(d.next()); + } + + /** + * Some checks for the getStart() method. + */ + @Test + public void testGetStart() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.NOVEMBER, 3, 0, 0, 0); + cal.set(Calendar.MILLISECOND, 0); + Day d = new Day(3, 11, 2006); + assertEquals(cal.getTime(), d.getStart()); + Locale.setDefault(saved); + } + + /** + * Some checks for the getEnd() method. + */ + @Test + public void testGetEnd() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(1900, Calendar.JANUARY, 1, 23, 59, 59); + cal.set(Calendar.MILLISECOND, 999); + Day d = new Day(1, 1, 1900); + assertEquals(cal.getTime(), d.getEnd()); + Locale.setDefault(saved); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/FixedMillisecondTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/FixedMillisecondTest.java new file mode 100755 index 0000000..c589be6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/FixedMillisecondTest.java @@ -0,0 +1,103 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * FixedMillisecondTest.java + * ------------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Jan-2002 : Version 1 (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 21-Oct-2003 : Added hashCode test (DG); + * 28-May-2008 : Added test for immutability (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import java.util.Date; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link FixedMillisecond} class. + */ +public class FixedMillisecondTest { + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + FixedMillisecond m1 = new FixedMillisecond(); + FixedMillisecond m2 = (FixedMillisecond) TestUtilities.serialised(m1); + assertEquals(m1, m2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + FixedMillisecond m1 = new FixedMillisecond(500000L); + FixedMillisecond m2 = new FixedMillisecond(500000L); + assertTrue(m1.equals(m2)); + int h1 = m1.hashCode(); + int h2 = m2.hashCode(); + assertEquals(h1, h2); + } + + /** + * The {@link FixedMillisecond} class is immutable, so should not be + * {@link Cloneable}. + */ + @Test + public void testNotCloneable() { + FixedMillisecond m = new FixedMillisecond(500000L); + assertFalse(m instanceof Cloneable); + } + + /** + * A check for immutability. + */ + @Test + public void testImmutability() { + Date d = new Date(20L); + FixedMillisecond fm = new FixedMillisecond(d); + d.setTime(22L); + assertEquals(20L, fm.getFirstMillisecond()); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/HourTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/HourTest.java new file mode 100755 index 0000000..86d6f42 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/HourTest.java @@ -0,0 +1,383 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * HourTest.java + * ------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Jan-2002 : Version 1 (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 13-Mar-2003 : Added serialization test (DG); + * 21-Oct-2003 : Added hashCode test (DG); + * 11-Jan-2005 : Added test for non-clonability (DG); + * 05-Oct-2006 : Added new tests (DG); + * 11-Jul-2007 : Fixed bad time zone assumption (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; + +import org.jfree.date.MonthConstants; +import org.junit.Test; + +/** + * Tests for the {@link Hour} class. + */ +public class HourTest { + + /** + * Check that an Hour instance is equal to itself. + * + * SourceForge Bug ID: 558850. + */ + @Test + public void testEqualsSelf() { + Hour hour = new Hour(); + assertTrue(hour.equals(hour)); + } + + /** + * Tests the equals method. + */ + @Test + public void testEquals() { + Hour hour1 = new Hour(15, new Day(29, MonthConstants.MARCH, 2002)); + Hour hour2 = new Hour(15, new Day(29, MonthConstants.MARCH, 2002)); + assertTrue(hour1.equals(hour2)); + } + + /** + * In GMT, the 4pm on 21 Mar 2002 is java.util.Date(1,014,307,200,000L). + * Use this to check the hour constructor. + */ + @Test + public void testDateConstructor1() { + TimeZone zone = TimeZone.getTimeZone("GMT"); + Locale locale = Locale.getDefault(); // locale should not matter here + Hour h1 = new Hour(new Date(1014307199999L), zone, locale); + Hour h2 = new Hour(new Date(1014307200000L), zone, locale); + + assertEquals(15, h1.getHour()); + assertEquals(1014307199999L, h1.getLastMillisecond(zone)); + + assertEquals(16, h2.getHour()); + assertEquals(1014307200000L, h2.getFirstMillisecond(zone)); + } + + /** + * In Sydney, the 4pm on 21 Mar 2002 is java.util.Date(1,014,267,600,000L). + * Use this to check the hour constructor. + */ + @Test + public void testDateConstructor2() { + TimeZone zone = TimeZone.getTimeZone("Australia/Sydney"); + Locale locale = Locale.getDefault(); // locale should not matter here + Hour h1 = new Hour(new Date(1014267599999L), zone, locale); + Hour h2 = new Hour (new Date(1014267600000L), zone, locale); + + assertEquals(15, h1.getHour()); + assertEquals(1014267599999L, h1.getLastMillisecond(zone)); + + assertEquals(16, h2.getHour()); + assertEquals(1014267600000L, h2.getFirstMillisecond(zone)); + } + + /** + * Set up an hour equal to hour zero, 1 January 1900. Request the + * previous hour, it should be null. + */ + @Test + public void testFirstHourPrevious() { + Hour first = new Hour(0, new Day(1, MonthConstants.JANUARY, 1900)); + Hour previous = (Hour) first.previous(); + assertNull(previous); + } + + /** + * Set up an hour equal to hour zero, 1 January 1900. Request the next + * hour, it should be null. + */ + @Test + public void testFirstHourNext() { + Hour first = new Hour(0, new Day(1, MonthConstants.JANUARY, 1900)); + Hour next = (Hour) first.next(); + assertEquals(1, next.getHour()); + assertEquals(1900, next.getYear()); + } + + /** + * Set up an hour equal to hour zero, 1 January 1900. Request the previous + * hour, it should be null. + */ + @Test + public void testLastHourPrevious() { + Hour last = new Hour(23, new Day(31, MonthConstants.DECEMBER, 9999)); + Hour previous = (Hour) last.previous(); + assertEquals(22, previous.getHour()); + assertEquals(9999, previous.getYear()); + } + + /** + * Set up an hour equal to hour zero, 1 January 1900. Request the next + * hour, it should be null. + */ + @Test + public void testLastHourNext() { + Hour last = new Hour(23, new Day(31, MonthConstants.DECEMBER, 9999)); + Hour next = (Hour) last.next(); + assertNull(next); + } + + /** + * Problem for date parsing. + */ + @Test + public void testParseHour() { + // test 1... + Hour h = Hour.parseHour("2002-01-29 13"); + assertEquals(13, h.getHour()); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Hour h1 = new Hour(); + Hour h2 = (Hour) TestUtilities.serialised(h1); + assertEquals(h1, h2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + Hour h1 = new Hour(7, 9, 10, 1999); + Hour h2 = new Hour(7, 9, 10, 1999); + assertTrue(h1.equals(h2)); + int hash1 = h1.hashCode(); + int hash2 = h2.hashCode(); + assertEquals(hash1, hash2); + } + + /** + * The {@link Hour} class is immutable, so should not be {@link Cloneable}. + */ + @Test + public void testNotCloneable() { + Hour h = new Hour(7, 9, 10, 1999); + assertFalse(h instanceof Cloneable); + } + + /** + * Some checks for the getFirstMillisecond() method. + */ + @Test + public void testGetFirstMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Hour h = new Hour(15, 1, 4, 2006); + assertEquals(1143900000000L, h.getFirstMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithTimeZone() { + Hour h = new Hour(15, 1, 4, 1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-623293200000L, h.getFirstMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + h.getFirstMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithCalendar() { + Hour h = new Hour(2, 15, 4, 2000); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(955764000000L, h.getFirstMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + h.getFirstMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond() method. + */ + @Test + public void testGetLastMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Hour h = new Hour(1, 1, 1, 1970); + assertEquals(3599999L, h.getLastMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithTimeZone() { + Hour h = new Hour(2, 7, 7, 1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-614959200001L, h.getLastMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + h.getLastMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithCalendar() { + Hour h = new Hour(21, 21, 4, 2001); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(987890399999L, h.getLastMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + h.getLastMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getSerialIndex() method. + */ + @Test + public void testGetSerialIndex() { + Hour h = new Hour(1, 1, 1, 2000); + assertEquals(876625L, h.getSerialIndex()); + h = new Hour(1, 1, 1, 1900); + assertEquals(49L, h.getSerialIndex()); + } + + /** + * Some checks for the testNext() method. + */ + @Test + public void testNext() { + Hour h = new Hour(1, 12, 12, 2000); + h = (Hour) h.next(); + assertEquals(2000, h.getYear()); + assertEquals(12, h.getMonth()); + assertEquals(12, h.getDayOfMonth()); + assertEquals(2, h.getHour()); + h = new Hour(23, 31, 12, 9999); + assertNull(h.next()); + } + + /** + * Some checks for the getStart() method. + */ + @Test + public void testGetStart() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.JANUARY, 16, 3, 0, 0); + cal.set(Calendar.MILLISECOND, 0); + Hour h = new Hour(3, 16, 1, 2006); + assertEquals(cal.getTime(), h.getStart()); + Locale.setDefault(saved); + } + + /** + * Some checks for the getEnd() method. + */ + @Test + public void testGetEnd() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.JANUARY, 8, 1, 59, 59); + cal.set(Calendar.MILLISECOND, 999); + Hour h = new Hour(1, 8, 1, 2006); + assertEquals(cal.getTime(), h.getEnd()); + Locale.setDefault(saved); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/MillisecondTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/MillisecondTest.java new file mode 100755 index 0000000..a0caf75 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/MillisecondTest.java @@ -0,0 +1,360 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------- + * MillisecondTest.java + * -------------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Jan-2002 : Version 1 (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 21-Oct-2003 : Added hashCode tests (DG); + * 29-Apr-2004 : Added test for getMiddleMillisecond() method (DG); + * 11-Jan-2005 : Added test for non-clonability (DG); + * 05-Oct-2006 : Added some tests (DG); + * 11-Jul-2007 : Fixed bad time zone assumption (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; + +import org.jfree.date.MonthConstants; +import org.junit.Test; + +/** + * Tests for the {@link Millisecond} class. + */ +public class MillisecondTest { + + /** + * Check that a {@link Millisecond} instance is equal to itself. + * + * SourceForge Bug ID: 558850. + */ + @Test + public void testEqualsSelf() { + Millisecond millisecond = new Millisecond(); + assertTrue(millisecond.equals(millisecond)); + } + + /** + * Tests the equals method. + */ + @Test + public void testEquals() { + Day day1 = new Day(29, MonthConstants.MARCH, 2002); + Hour hour1 = new Hour(15, day1); + Minute minute1 = new Minute(15, hour1); + Second second1 = new Second(34, minute1); + Millisecond milli1 = new Millisecond(999, second1); + Day day2 = new Day(29, MonthConstants.MARCH, 2002); + Hour hour2 = new Hour(15, day2); + Minute minute2 = new Minute(15, hour2); + Second second2 = new Second(34, minute2); + Millisecond milli2 = new Millisecond(999, second2); + assertTrue(milli1.equals(milli2)); + } + + /** + * In GMT, the 4.55:59.123pm on 21 Mar 2002 is + * java.util.Date(1016729759123L). Use this to check the Millisecond + * constructor. + */ + @Test + public void testDateConstructor1() { + TimeZone zone = TimeZone.getTimeZone("GMT"); + Locale locale = Locale.getDefault(); // locale should not matter here + Millisecond m1 = new Millisecond(new Date(1016729759122L), zone, + locale); + Millisecond m2 = new Millisecond(new Date(1016729759123L), zone, + locale); + + assertEquals(122, m1.getMillisecond()); + assertEquals(1016729759122L, m1.getLastMillisecond(zone)); + + assertEquals(123, m2.getMillisecond()); + assertEquals(1016729759123L, m2.getFirstMillisecond(zone)); + } + + /** + * In Tallinn, the 4.55:59.123pm on 21 Mar 2002 is + * java.util.Date(1016722559123L). Use this to check the Millisecond + * constructor. + */ + @Test + public void testDateConstructor2() { + TimeZone zone = TimeZone.getTimeZone("Europe/Tallinn"); + Locale locale = Locale.getDefault(); // locale should not matter here + Millisecond m1 = new Millisecond(new Date(1016722559122L), zone, + locale); + Millisecond m2 = new Millisecond(new Date(1016722559123L), zone, + locale); + + assertEquals(122, m1.getMillisecond()); + assertEquals(1016722559122L, m1.getLastMillisecond(zone)); + + assertEquals(123, m2.getMillisecond()); + assertEquals(1016722559123L, m2.getFirstMillisecond(zone)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Millisecond m1 = new Millisecond(); + Millisecond m2 = (Millisecond) TestUtilities.serialised(m1); + assertEquals(m1, m2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + Millisecond m1 = new Millisecond(599, 23, 45, 7, 9, 10, 2007); + Millisecond m2 = new Millisecond(599, 23, 45, 7, 9, 10, 2007); + assertTrue(m1.equals(m2)); + int hash1 = m1.hashCode(); + int hash2 = m2.hashCode(); + assertEquals(hash1, hash2); + } + + /** + * A test for bug report 943985 - the calculation for the middle + * millisecond is incorrect for odd milliseconds. + */ + @Test + public void test943985() { + Millisecond ms = new Millisecond(new java.util.Date(4)); + assertEquals(ms.getFirstMillisecond(), ms.getMiddleMillisecond()); + assertEquals(ms.getMiddleMillisecond(), ms.getLastMillisecond()); + ms = new Millisecond(new java.util.Date(5)); + assertEquals(ms.getFirstMillisecond(), ms.getMiddleMillisecond()); + assertEquals(ms.getMiddleMillisecond(), ms.getLastMillisecond()); + } + + /** + * The {@link Millisecond} class is immutable, so should not be + * {@link Cloneable}. + */ + @Test + public void testNotCloneable() { + Millisecond m = new Millisecond(599, 23, 45, 7, 9, 10, 2007); + assertFalse(m instanceof Cloneable); + } + + /** + * Some checks for the getFirstMillisecond() method. + */ + @Test + public void testGetFirstMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Millisecond m = new Millisecond(500, 15, 43, 15, 1, 4, 2006); + assertEquals(1143902595500L, m.getFirstMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithTimeZone() { + Millisecond m = new Millisecond(500, 50, 59, 15, 1, 4, 1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-623289609500L, m.getFirstMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + m.getFirstMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithCalendar() { + Millisecond m = new Millisecond(500, 55, 40, 2, 15, 4, 2000); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(955766455500L, m.getFirstMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + m.getFirstMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond() method. + */ + @Test + public void testGetLastMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Millisecond m = new Millisecond(750, 1, 1, 1, 1, 1, 1970); + assertEquals(61750L, m.getLastMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithTimeZone() { + Millisecond m = new Millisecond(750, 55, 1, 2, 7, 7, 1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-614962684250L, m.getLastMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + m.getLastMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithCalendar() { + Millisecond m = new Millisecond(250, 50, 45, 21, 21, 4, 2001); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(987889550250L, m.getLastMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + m.getLastMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getSerialIndex() method. + */ + @Test + public void testGetSerialIndex() { + Millisecond m = new Millisecond(500, 1, 1, 1, 1, 1, 2000); + assertEquals(3155850061500L, m.getSerialIndex()); + m = new Millisecond(500, 1, 1, 1, 1, 1, 1900); + // TODO: this must be wrong... + assertEquals(176461500L, m.getSerialIndex()); + } + + /** + * Some checks for the testNext() method. + */ + @Test + public void testNext() { + Millisecond m = new Millisecond(555, 55, 30, 1, 12, 12, 2000); + m = (Millisecond) m.next(); + assertEquals(2000, m.getSecond().getMinute().getHour().getYear()); + assertEquals(12, m.getSecond().getMinute().getHour().getMonth()); + assertEquals(12, m.getSecond().getMinute().getHour().getDayOfMonth()); + assertEquals(1, m.getSecond().getMinute().getHour().getHour()); + assertEquals(30, m.getSecond().getMinute().getMinute()); + assertEquals(55, m.getSecond().getSecond()); + assertEquals(556, m.getMillisecond()); + m = new Millisecond(999, 59, 59, 23, 31, 12, 9999); + assertNull(m.next()); + } + + /** + * Some checks for the getStart() method. + */ + @Test + public void testGetStart() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55); + cal.set(Calendar.MILLISECOND, 555); + Millisecond m = new Millisecond(555, 55, 47, 3, 16, 1, 2006); + assertEquals(cal.getTime(), m.getStart()); + Locale.setDefault(saved); + } + + /** + * Some checks for the getEnd() method. + */ + @Test + public void testGetEnd() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55); + cal.set(Calendar.MILLISECOND, 555); + Millisecond m = new Millisecond(555, 55, 47, 3, 16, 1, 2006); + assertEquals(cal.getTime(), m.getEnd()); + Locale.setDefault(saved); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/MinuteTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/MinuteTest.java new file mode 100755 index 0000000..d151f94 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/MinuteTest.java @@ -0,0 +1,351 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------- + * MinuteTest.java + * --------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Jan-2002 : Version 1 (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 13-Mar-2003 : Added serialization test (DG); + * 21-Oct-2003 : Added hashCode test (DG); + * 11-Jan-2005 : Added test for non-clonability (DG); + * 05-Oct-2006 : Added new tests (DG); + * 11-Dec-2006 : Added test1611872() (DG); + * 11-Jul-2007 : Fixed bad time zone assumption (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; + +import org.jfree.date.MonthConstants; +import org.junit.Test; + +/** + * Tests for the {@link Minute} class. + */ +public class MinuteTest { + + /** + * Check that a Minute instance is equal to itself. + * + * SourceForge Bug ID: 558850. + */ + @Test + public void testEqualsSelf() { + Minute minute = new Minute(); + assertTrue(minute.equals(minute)); + } + + /** + * Tests the equals method. + */ + @Test + public void testEquals() { + Day day1 = new Day(29, MonthConstants.MARCH, 2002); + Hour hour1 = new Hour(15, day1); + Minute minute1 = new Minute(15, hour1); + Day day2 = new Day(29, MonthConstants.MARCH, 2002); + Hour hour2 = new Hour(15, day2); + Minute minute2 = new Minute(15, hour2); + assertTrue(minute1.equals(minute2)); + } + + /** + * In GMT, the 4.55pm on 21 Mar 2002 is java.util.Date(1016729700000L). + * Use this to check the Minute constructor. + */ + @Test + public void testDateConstructor1() { + TimeZone zone = TimeZone.getTimeZone("GMT"); + Locale locale = Locale.getDefault(); // locale should not matter here + Minute m1 = new Minute(new Date(1016729699999L), zone, locale); + Minute m2 = new Minute(new Date(1016729700000L), zone, locale); + + assertEquals(54, m1.getMinute()); + assertEquals(1016729699999L, m1.getLastMillisecond(zone)); + + assertEquals(55, m2.getMinute()); + assertEquals(1016729700000L, m2.getFirstMillisecond(zone)); + } + + /** + * In Singapore, the 4.55pm on 21 Mar 2002 is + * java.util.Date(1,014,281,700,000L). Use this to check the Minute + * constructor. + */ + @Test + public void testDateConstructor2() { + TimeZone zone = TimeZone.getTimeZone("Asia/Singapore"); + Locale locale = Locale.getDefault(); // locale should not matter here + Minute m1 = new Minute(new Date(1016700899999L), zone, locale); + Minute m2 = new Minute(new Date(1016700900000L), zone, locale); + + assertEquals(54, m1.getMinute()); + assertEquals(1016700899999L, m1.getLastMillisecond(zone)); + + assertEquals(55, m2.getMinute()); + assertEquals(1016700900000L, m2.getFirstMillisecond(zone)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Minute m1 = new Minute(); + Minute m2 = (Minute) TestUtilities.serialised(m1); + assertEquals(m1, m2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + Minute m1 = new Minute(45, 5, 1, 2, 2003); + Minute m2 = new Minute(45, 5, 1, 2, 2003); + assertTrue(m1.equals(m2)); + int h1 = m1.hashCode(); + int h2 = m2.hashCode(); + assertEquals(h1, h2); + } + + /** + * The {@link Minute} class is immutable, so should not be + * {@link Cloneable}. + */ + @Test + public void testNotCloneable() { + Minute m = new Minute(45, 5, 1, 2, 2003); + assertFalse(m instanceof Cloneable); + } + + /** + * Some checks for the getFirstMillisecond() method. + */ + @Test + public void testGetFirstMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Minute m = new Minute(43, 15, 1, 4, 2006); + assertEquals(1143902580000L, m.getFirstMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithTimeZone() { + Minute m = new Minute(59, 15, 1, 4, 1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-623289660000L, m.getFirstMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + m.getFirstMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithCalendar() { + Minute m = new Minute(40, 2, 15, 4, 2000); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(955766400000L, m.getFirstMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + m.getFirstMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond() method. + */ + @Test + public void testGetLastMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Minute m = new Minute(1, 1, 1, 1, 1970); + assertEquals(119999L, m.getLastMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithTimeZone() { + Minute m = new Minute(1, 2, 7, 7, 1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-614962680001L, m.getLastMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + m.getLastMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithCalendar() { + Minute m = new Minute(45, 21, 21, 4, 2001); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(987889559999L, m.getLastMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + m.getLastMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getSerialIndex() method. + */ + @Test + public void testGetSerialIndex() { + Minute m = new Minute(1, 1, 1, 1, 2000); + assertEquals(52597501L, m.getSerialIndex()); + m = new Minute(1, 1, 1, 1, 1900); + assertEquals(2941L, m.getSerialIndex()); + } + + /** + * Some checks for the testNext() method. + */ + @Test + public void testNext() { + Minute m = new Minute(30, 1, 12, 12, 2000); + m = (Minute) m.next(); + assertEquals(2000, m.getHour().getYear()); + assertEquals(12, m.getHour().getMonth()); + assertEquals(12, m.getHour().getDayOfMonth()); + assertEquals(1, m.getHour().getHour()); + assertEquals(31, m.getMinute()); + m = new Minute(59, 23, 31, 12, 9999); + assertNull(m.next()); + } + + /** + * Some checks for the getStart() method. + */ + @Test + public void testGetStart() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/Rome")); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.JANUARY, 16, 3, 47, 0); + cal.set(Calendar.MILLISECOND, 0); + Minute m = new Minute(47, 3, 16, 1, 2006); + assertEquals(cal.getTime(), m.getStart()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getEnd() method. + */ + @Test + public void testGetEnd() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/Rome")); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.JANUARY, 16, 3, 47, 59); + cal.set(Calendar.MILLISECOND, 999); + Minute m = new Minute(47, 3, 16, 1, 2006); + assertEquals(cal.getTime(), m.getEnd()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Test for bug 1611872 - previous() fails for first minute in hour. + */ + @Test + public void test1611872() { + Minute m1 = new Minute(0, 10, 15, 4, 2000); + Minute m2 = (Minute) m1.previous(); + assertEquals(m2, new Minute(59, 9, 15, 4, 2000)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/MonthTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/MonthTest.java new file mode 100755 index 0000000..4d858ec --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/MonthTest.java @@ -0,0 +1,434 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------- + * MonthTest.java + * -------------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Nov-2001 : Version 1 (DG); + * 14-Feb-2002 : Order of parameters in Month(int, int) constructor + * changed (DG); + * 26-Jun-2002 : Removed unnecessary import (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 13-Mar-2003 : Added serialization test (DG); + * 21-Oct-2003 : Added hashCode test (DG); + * 11-Jan-2005 : Added non-clonability test (DG); + * 05-Oct-2006 : Added some new tests (DG); + * 11-Jul-2007 : Fixed bad time zone assumption (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; + +import org.jfree.date.MonthConstants; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests for the {@link Month} class. + */ +public class MonthTest { + + /** A month. */ + private Month jan1900; + + /** A month. */ + private Month feb1900; + + /** A month. */ + private Month nov9999; + + /** A month. */ + private Month dec9999; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.jan1900 = new Month(MonthConstants.JANUARY, 1900); + this.feb1900 = new Month(MonthConstants.FEBRUARY, 1900); + this.nov9999 = new Month(MonthConstants.NOVEMBER, 9999); + this.dec9999 = new Month(MonthConstants.DECEMBER, 9999); + } + + /** + * Check that a Month instance is equal to itself. + * + * SourceForge Bug ID: 558850. + */ + @Test + public void testEqualsSelf() { + Month month = new Month(); + assertTrue(month.equals(month)); + } + + /** + * Tests the equals method. + */ + @Test + public void testEquals() { + Month m1 = new Month(MonthConstants.MAY, 2002); + Month m2 = new Month(MonthConstants.MAY, 2002); + assertTrue(m1.equals(m2)); + } + + /** + * In GMT, the end of Feb 2000 is java.util.Date(951,868,799,999L). Use + * this to check the Month constructor. + */ + @Test + public void testDateConstructor1() { + + TimeZone zone = TimeZone.getTimeZone("GMT"); + Month m1 = new Month(new Date(951868799999L), zone); + Month m2 = new Month(new Date(951868800000L), zone); + + assertEquals(MonthConstants.FEBRUARY, m1.getMonth()); + assertEquals(951868799999L, m1.getLastMillisecond(zone)); + + assertEquals(MonthConstants.MARCH, m2.getMonth()); + assertEquals(951868800000L, m2.getFirstMillisecond(zone)); + + } + + /** + * In Auckland, the end of Feb 2000 is java.util.Date(951,821,999,999L). + * Use this to check the Month constructor. + */ + @Test + public void testDateConstructor2() { + + TimeZone zone = TimeZone.getTimeZone("Pacific/Auckland"); + Month m1 = new Month(new Date(951821999999L), zone); + Month m2 = new Month(new Date(951822000000L), zone); + + assertEquals(MonthConstants.FEBRUARY, m1.getMonth()); + assertEquals(951821999999L, m1.getLastMillisecond(zone)); + + assertEquals(MonthConstants.MARCH, m2.getMonth()); + assertEquals(951822000000L, m2.getFirstMillisecond(zone)); + + } + + /** + * Set up a month equal to Jan 1900. Request the previous month, it should + * be null. + */ + @Test + public void testJan1900Previous() { + Month previous = (Month) this.jan1900.previous(); + assertNull(previous); + } + + /** + * Set up a month equal to Jan 1900. Request the next month, it should be + * Feb 1900. + */ + @Test + public void testJan1900Next() { + Month next = (Month) this.jan1900.next(); + assertEquals(this.feb1900, next); + } + + /** + * Set up a month equal to Dec 9999. Request the previous month, it should + * be Nov 9999. + */ + @Test + public void testDec9999Previous() { + Month previous = (Month) this.dec9999.previous(); + assertEquals(this.nov9999, previous); + } + + /** + * Set up a month equal to Dec 9999. Request the next month, it should be + * null. + */ + @Test + public void testDec9999Next() { + Month next = (Month) this.dec9999.next(); + assertNull(next); + } + + /** + * Tests the string parsing code... + */ + @Test + public void testParseMonth() { + + Month month = null; + + // test 1... + try { + month = Month.parseMonth("1990-01"); + } + catch (TimePeriodFormatException e) { + month = new Month(1, 1900); + } + assertEquals(1, month.getMonth()); + assertEquals(1990, month.getYear().getYear()); + + // test 2... + try { + month = Month.parseMonth("02-1991"); + } + catch (TimePeriodFormatException e) { + month = new Month(1, 1900); + } + assertEquals(2, month.getMonth()); + assertEquals(1991, month.getYear().getYear()); + + // test 3... + try { + month = Month.parseMonth("March 1993"); + } + catch (TimePeriodFormatException e) { + month = new Month(1, 1900); + } + assertEquals(3, month.getMonth()); + assertEquals(1993, month.getYear().getYear()); + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Month m1 = new Month(12, 1999); + Month m2 = (Month) TestUtilities.serialised(m1); + assertEquals(m1, m2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + Month m1 = new Month(2, 2003); + Month m2 = new Month(2, 2003); + assertTrue(m1.equals(m2)); + int h1 = m1.hashCode(); + int h2 = m2.hashCode(); + assertEquals(h1, h2); + } + + /** + * The {@link Month} class is immutable, so should not be {@link Cloneable}. + */ + @Test + public void testNotCloneable() { + Month m = new Month(2, 2003); + assertFalse(m instanceof Cloneable); + } + + /** + * Some checks for the getFirstMillisecond() method. + */ + @Test + public void testGetFirstMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Month m = new Month(3, 1970); + assertEquals(5094000000L, m.getFirstMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithTimeZone() { + Month m = new Month(2, 1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-628444800000L, m.getFirstMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + m.getFirstMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithCalendar() { + Month m = new Month(1, 2001); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(978307200000L, m.getFirstMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + m.getFirstMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond() method. + */ + @Test + public void testGetLastMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Month m = new Month(3, 1970); + assertEquals(7772399999L, m.getLastMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithTimeZone() { + Month m = new Month(2, 1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-626025600001L, m.getLastMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + m.getLastMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithCalendar() { + Month m = new Month(3, 2001); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(986083199999L, m.getLastMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + m.getLastMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getSerialIndex() method. + */ + @Test + public void testGetSerialIndex() { + Month m = new Month(1, 2000); + assertEquals(24001L, m.getSerialIndex()); + m = new Month(1, 1900); + assertEquals(22801L, m.getSerialIndex()); + } + + /** + * Some checks for the testNext() method. + */ + @Test + public void testNext() { + Month m = new Month(12, 2000); + m = (Month) m.next(); + assertEquals(new Year(2001), m.getYear()); + assertEquals(1, m.getMonth()); + m = new Month(12, 9999); + assertNull(m.next()); + } + + /** + * Some checks for the getStart() method. + */ + @Test + public void testGetStart() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.MARCH, 1, 0, 0, 0); + cal.set(Calendar.MILLISECOND, 0); + Month m = new Month(3, 2006); + assertEquals(cal.getTime(), m.getStart()); + Locale.setDefault(saved); + } + + /** + * Some checks for the getEnd() method. + */ + @Test + public void testGetEnd() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.JANUARY, 31, 23, 59, 59); + cal.set(Calendar.MILLISECOND, 999); + Month m = new Month(1, 2006); + assertEquals(cal.getTime(), m.getEnd()); + Locale.setDefault(saved); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/MovingAverageTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/MovingAverageTest.java new file mode 100755 index 0000000..4716b45 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/MovingAverageTest.java @@ -0,0 +1,103 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------- + * MovingAverageTest.java + * ---------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 14-Aug-2003 : Version 1 (DG); + * 04-Oct-2004 : Eliminated NumberUtils usage (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertEquals; + +import org.jfree.date.MonthConstants; +import org.junit.Test; + +/** + * Tests for the {@link MovingAverage} class. + */ +public class MovingAverageTest { + + private static final double EPSILON = 0.0000000001; + + /** + * A test for the values calculated from a time series. + */ + @Test + public void test1() { + TimeSeries source = createDailyTimeSeries1(); + TimeSeries maverage = MovingAverage.createMovingAverage(source, + "Moving Average", 3, 3); + + // the moving average series has 7 items, the first three + // days (11, 12, 13 August are skipped) + assertEquals(7, maverage.getItemCount()); + double value = maverage.getValue(0).doubleValue(); + assertEquals(14.1, value, EPSILON); + value = maverage.getValue(1).doubleValue(); + assertEquals(13.4, value, EPSILON); + value = maverage.getValue(2).doubleValue(); + assertEquals(14.433333333333, value, EPSILON); + value = maverage.getValue(3).doubleValue(); + assertEquals(14.933333333333, value, EPSILON); + value = maverage.getValue(4).doubleValue(); + assertEquals(19.8, value, EPSILON); + value = maverage.getValue(5).doubleValue(); + assertEquals(15.25, value, EPSILON); + value = maverage.getValue(6).doubleValue(); + assertEquals(12.5, value, EPSILON); + } + + /** + * Creates a sample series. + * + * @return A sample series. + */ + private TimeSeries createDailyTimeSeries1() { + TimeSeries series = new TimeSeries("Series 1", Day.class); + series.add(new Day(11, MonthConstants.AUGUST, 2003), 11.2); + series.add(new Day(13, MonthConstants.AUGUST, 2003), 13.8); + series.add(new Day(17, MonthConstants.AUGUST, 2003), 14.1); + series.add(new Day(18, MonthConstants.AUGUST, 2003), 12.7); + series.add(new Day(19, MonthConstants.AUGUST, 2003), 16.5); + series.add(new Day(20, MonthConstants.AUGUST, 2003), 15.6); + series.add(new Day(25, MonthConstants.AUGUST, 2003), 19.8); + series.add(new Day(27, MonthConstants.AUGUST, 2003), 10.7); + series.add(new Day(28, MonthConstants.AUGUST, 2003), 14.3); + return series; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/QuarterTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/QuarterTest.java new file mode 100755 index 0000000..f7a7cad --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/QuarterTest.java @@ -0,0 +1,453 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * QuarterTest.java + * ---------------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Nov-2001 : Version 1 (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 13-Mar-2003 : Added serialization test (DG); + * 11-Jan-2005 : Added check for non-clonability (DG); + * 05-Oct-2006 : Added some new tests (DG); + * 11-Jul-2007 : Fixed bad time zone assumption (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests for the {link Quarter} class. + */ +public class QuarterTest { + + /** A quarter. */ + private Quarter q1Y1900; + + /** A quarter. */ + private Quarter q2Y1900; + + /** A quarter. */ + private Quarter q3Y9999; + + /** A quarter. */ + private Quarter q4Y9999; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.q1Y1900 = new Quarter(1, 1900); + this.q2Y1900 = new Quarter(2, 1900); + this.q3Y9999 = new Quarter(3, 9999); + this.q4Y9999 = new Quarter(4, 9999); + } + + /** + * Check that a Quarter instance is equal to itself. + * + * SourceForge Bug ID: 558850. + */ + @Test + public void testEqualsSelf() { + Quarter quarter = new Quarter(); + assertTrue(quarter.equals(quarter)); + } + + /** + * Tests the equals method. + */ + @Test + public void testEquals() { + Quarter q1 = new Quarter(2, 2002); + Quarter q2 = new Quarter(2, 2002); + assertTrue(q1.equals(q2)); + } + + /** + * In GMT, the end of Q1 2002 is java.util.Date(1017619199999L). Use this + * to check the quarter constructor. + */ + @Test + public void testDateConstructor1() { + + TimeZone zone = TimeZone.getTimeZone("GMT"); + Quarter q1 = new Quarter(new Date(1017619199999L), zone); + Quarter q2 = new Quarter(new Date(1017619200000L), zone); + + assertEquals(1, q1.getQuarter()); + assertEquals(1017619199999L, q1.getLastMillisecond(zone)); + + assertEquals(2, q2.getQuarter()); + assertEquals(1017619200000L, q2.getFirstMillisecond(zone)); + + } + + /** + * In Istanbul, the end of Q1 2002 is java.util.Date(1017608399999L). Use + * this to check the quarter constructor. + */ + @Test + public void testDateConstructor2() { + + TimeZone zone = TimeZone.getTimeZone("Europe/Istanbul"); + Quarter q1 = new Quarter(new Date(1017608399999L), zone); + Quarter q2 = new Quarter(new Date(1017608400000L), zone); + + assertEquals(1, q1.getQuarter()); + assertEquals(1017608399999L, q1.getLastMillisecond(zone)); + + assertEquals(2, q2.getQuarter()); + assertEquals(1017608400000L, q2.getFirstMillisecond(zone)); + + } + + /** + * Set up a quarter equal to Q1 1900. Request the previous quarter, it + * should be null. + */ + @Test + public void testQ1Y1900Previous() { + Quarter previous = (Quarter) this.q1Y1900.previous(); + assertNull(previous); + } + + /** + * Set up a quarter equal to Q1 1900. Request the next quarter, it should + * be Q2 1900. + */ + @Test + public void testQ1Y1900Next() { + Quarter next = (Quarter) this.q1Y1900.next(); + assertEquals(this.q2Y1900, next); + } + + /** + * Set up a quarter equal to Q4 9999. Request the previous quarter, it + * should be Q3 9999. + */ + @Test + public void testQ4Y9999Previous() { + Quarter previous = (Quarter) this.q4Y9999.previous(); + assertEquals(this.q3Y9999, previous); + } + + /** + * Set up a quarter equal to Q4 9999. Request the next quarter, it should + * be null. + */ + @Test + public void testQ4Y9999Next() { + Quarter next = (Quarter) this.q4Y9999.next(); + assertNull(next); + } + + /** + * Test the string parsing code... + */ + @Test + public void testParseQuarter() { + + Quarter quarter = null; + + // test 1... + try { + quarter = Quarter.parseQuarter("Q1-2000"); + } + catch (TimePeriodFormatException e) { + quarter = new Quarter(1, 1900); + } + assertEquals(1, quarter.getQuarter()); + assertEquals(2000, quarter.getYear().getYear()); + + // test 2... + try { + quarter = Quarter.parseQuarter("2001-Q2"); + } + catch (TimePeriodFormatException e) { + quarter = new Quarter(1, 1900); + } + assertEquals(2, quarter.getQuarter()); + assertEquals(2001, quarter.getYear().getYear()); + + // test 3... + try { + quarter = Quarter.parseQuarter("Q3, 2002"); + } + catch (TimePeriodFormatException e) { + quarter = new Quarter(1, 1900); + } + assertEquals(3, quarter.getQuarter()); + assertEquals(2002, quarter.getYear().getYear()); + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Quarter q1 = new Quarter(4, 1999); + Quarter q2 = (Quarter) TestUtilities.serialised(q1); + assertEquals(q1, q2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + Quarter q1 = new Quarter(2, 2003); + Quarter q2 = new Quarter(2, 2003); + assertTrue(q1.equals(q2)); + int h1 = q1.hashCode(); + int h2 = q2.hashCode(); + assertEquals(h1, h2); + } + + /** + * The {@link Quarter} class is immutable, so should not be + * {@link Cloneable}. + */ + @Test + public void testNotCloneable() { + Quarter q = new Quarter(2, 2003); + assertFalse(q instanceof Cloneable); + } + + /** + * Some tests for the constructor with (int, int) arguments. Covers bug + * report 1377239. + */ + @Test + public void testConstructor() { + boolean pass = false; + try { + /*Quarter q =*/ new Quarter(0, 2005); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + /*Quarter q =*/ new Quarter(5, 2005); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getFirstMillisecond() method. + */ + @Test + public void testGetFirstMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Quarter q = new Quarter(3, 1970); + assertEquals(15634800000L, q.getFirstMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithTimeZone() { + Quarter q = new Quarter(2, 1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-623347200000L, q.getFirstMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + q.getFirstMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithCalendar() { + Quarter q = new Quarter(1, 2001); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(978307200000L, q.getFirstMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + q.getFirstMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond() method. + */ + @Test + public void testGetLastMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Quarter q = new Quarter(3, 1970); + assertEquals(23583599999L, q.getLastMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithTimeZone() { + Quarter q = new Quarter(2, 1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-615488400001L, q.getLastMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + q.getLastMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithCalendar() { + Quarter q = new Quarter(3, 2001); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(1001894399999L, q.getLastMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + q.getLastMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getSerialIndex() method. + */ + @Test + public void testGetSerialIndex() { + Quarter q = new Quarter(1, 2000); + assertEquals(8001L, q.getSerialIndex()); + q = new Quarter(1, 1900); + assertEquals(7601L, q.getSerialIndex()); + } + + /** + * Some checks for the testNext() method. + */ + @Test + public void testNext() { + Quarter q = new Quarter(1, 2000); + q = (Quarter) q.next(); + assertEquals(new Year(2000), q.getYear()); + assertEquals(2, q.getQuarter()); + q = new Quarter(4, 9999); + assertNull(q.next()); + } + + /** + * Some checks for the getStart() method. + */ + @Test + public void testGetStart() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.JULY, 1, 0, 0, 0); + cal.set(Calendar.MILLISECOND, 0); + Quarter q = new Quarter(3, 2006); + assertEquals(cal.getTime(), q.getStart()); + Locale.setDefault(saved); + } + + /** + * Some checks for the getEnd() method. + */ + @Test + public void testGetEnd() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.MARCH, 31, 23, 59, 59); + cal.set(Calendar.MILLISECOND, 999); + Quarter q = new Quarter(1, 2006); + assertEquals(cal.getTime(), q.getEnd()); + Locale.setDefault(saved); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/SecondTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/SecondTest.java new file mode 100755 index 0000000..259d566 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/SecondTest.java @@ -0,0 +1,335 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * SecondTest.java + * ---------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Jan-2002 : Version 1 (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 13-Oct-2003 : Added serialization test (DG); + * 11-Jan-2005 : Added test for non-clonability (DG); + * 06-Oct-2006 : Added some new tests (DG); + * 11-Jul-2007 : Fixed bad time zone assumption (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; + +import org.jfree.date.MonthConstants; +import org.junit.Test; + +/** + * Tests for the {@link Second} class. + */ +public class SecondTest { + + /** + * Test that a Second instance is equal to itself. + * + * SourceForge Bug ID: 558850. + */ + @Test + public void testEqualsSelf() { + Second second = new Second(); + assertTrue(second.equals(second)); + } + + /** + * Tests the equals method. + */ + @Test + public void testEquals() { + Day day1 = new Day(29, MonthConstants.MARCH, 2002); + Hour hour1 = new Hour(15, day1); + Minute minute1 = new Minute(15, hour1); + Second second1 = new Second(34, minute1); + Day day2 = new Day(29, MonthConstants.MARCH, 2002); + Hour hour2 = new Hour(15, day2); + Minute minute2 = new Minute(15, hour2); + Second second2 = new Second(34, minute2); + assertTrue(second1.equals(second2)); + } + + /** + * In GMT, the 4.55:59pm on 21 Mar 2002 is java.util.Date(1016729759000L). + * Use this to check the Second constructor. + */ + @Test + public void testDateConstructor1() { + TimeZone zone = TimeZone.getTimeZone("GMT"); + Locale locale = Locale.getDefault(); // locale shouldn't matter here + Second s1 = new Second(new Date(1016729758999L), zone, locale); + Second s2 = new Second(new Date(1016729759000L), zone, locale); + + assertEquals(58, s1.getSecond()); + assertEquals(1016729758999L, s1.getLastMillisecond(zone)); + + assertEquals(59, s2.getSecond()); + assertEquals(1016729759000L, s2.getFirstMillisecond(zone)); + } + + /** + * In Chicago, the 4.55:59pm on 21 Mar 2002 is + * java.util.Date(1016751359000L). Use this to check the Second constructor. + */ + @Test + public void testDateConstructor2() { + TimeZone zone = TimeZone.getTimeZone("America/Chicago"); + Locale locale = Locale.getDefault(); // locale shouldn't matter here + Second s1 = new Second(new Date(1016751358999L), zone, locale); + Second s2 = new Second(new Date(1016751359000L), zone, locale); + + assertEquals(58, s1.getSecond()); + assertEquals(1016751358999L, s1.getLastMillisecond(zone)); + + assertEquals(59, s2.getSecond()); + assertEquals(1016751359000L, s2.getFirstMillisecond(zone)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Second s1 = new Second(); + Second s2 = (Second) TestUtilities.serialised(s1); + assertEquals(s1, s2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + Second s1 = new Second(13, 45, 5, 1, 2, 2003); + Second s2 = new Second(13, 45, 5, 1, 2, 2003); + assertTrue(s1.equals(s2)); + int h1 = s1.hashCode(); + int h2 = s2.hashCode(); + assertEquals(h1, h2); + } + + /** + * The {@link Second} class is immutable, so should not be + * {@link Cloneable}. + */ + @Test + public void testNotCloneable() { + Second s = new Second(13, 45, 5, 1, 2, 2003); + assertFalse(s instanceof Cloneable); + } + + /** + * Some checks for the getFirstMillisecond() method. + */ + @Test + public void testGetFirstMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Second s = new Second(15, 43, 15, 1, 4, 2006); + assertEquals(1143902595000L, s.getFirstMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithTimeZone() { + Second s = new Second(50, 59, 15, 1, 4, 1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-623289610000L, s.getFirstMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + s.getFirstMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithCalendar() { + Second s = new Second(55, 40, 2, 15, 4, 2000); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(955766455000L, s.getFirstMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + s.getFirstMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond() method. + */ + @Test + public void testGetLastMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Second s = new Second(1, 1, 1, 1, 1, 1970); + assertEquals(61999L, s.getLastMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithTimeZone() { + Second s = new Second(55, 1, 2, 7, 7, 1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-614962684001L, s.getLastMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + s.getLastMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithCalendar() { + Second s = new Second(50, 45, 21, 21, 4, 2001); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(987889550999L, s.getLastMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + s.getLastMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getSerialIndex() method. + */ + @Test + public void testGetSerialIndex() { + Second s = new Second(1, 1, 1, 1, 1, 2000); + assertEquals(3155850061L, s.getSerialIndex()); + s = new Second(1, 1, 1, 1, 1, 1900); + assertEquals(176461L, s.getSerialIndex()); + } + + /** + * Some checks for the testNext() method. + */ + @Test + public void testNext() { + Second s = new Second(55, 30, 1, 12, 12, 2000); + s = (Second) s.next(); + assertEquals(2000, s.getMinute().getHour().getYear()); + assertEquals(12, s.getMinute().getHour().getMonth()); + assertEquals(12, s.getMinute().getHour().getDayOfMonth()); + assertEquals(1, s.getMinute().getHour().getHour()); + assertEquals(30, s.getMinute().getMinute()); + assertEquals(56, s.getSecond()); + s = new Second(59, 59, 23, 31, 12, 9999); + assertNull(s.next()); + } + + /** + * Some checks for the getStart() method. + */ + @Test + public void testGetStart() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55); + cal.set(Calendar.MILLISECOND, 0); + Second s = new Second(55, 47, 3, 16, 1, 2006); + assertEquals(cal.getTime(), s.getStart()); + Locale.setDefault(saved); + } + + /** + * Some checks for the getEnd() method. + */ + @Test + public void testGetEnd() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.JANUARY, 16, 3, 47, 55); + cal.set(Calendar.MILLISECOND, 999); + Second s = new Second(55, 47, 3, 16, 1, 2006); + assertEquals(cal.getTime(), s.getEnd()); + Locale.setDefault(saved); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/SimpleTimePeriodTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/SimpleTimePeriodTest.java new file mode 100755 index 0000000..e07ae82 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/SimpleTimePeriodTest.java @@ -0,0 +1,186 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * SimpleTimePeriodTest.java + * ------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Mar-2003 : Version 1 (DG); + * 21-Oct-2003 : Added hashCode() test (DG); + * 02-Jun-2008 : Added a test for immutability (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import java.util.Date; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link SimpleTimePeriod} class. + */ +public class SimpleTimePeriodTest { + + /** + * Check that an instance is equal to itself. + * + * SourceForge Bug ID: 558850. + */ + @Test + public void testEqualsSelf() { + SimpleTimePeriod p = new SimpleTimePeriod(new Date(1000L), + new Date(1001L)); + assertTrue(p.equals(p)); + } + + /** + * Test the equals() method. + */ + @Test + public void testEquals() { + SimpleTimePeriod p1 = new SimpleTimePeriod(new Date(1000L), + new Date(1004L)); + SimpleTimePeriod p2 = new SimpleTimePeriod(new Date(1000L), + new Date(1004L)); + assertTrue(p1.equals(p2)); + assertTrue(p2.equals(p1)); + + p1 = new SimpleTimePeriod(new Date(1002L), new Date(1004L)); + assertFalse(p1.equals(p2)); + p2 = new SimpleTimePeriod(new Date(1002L), new Date(1004L)); + assertTrue(p1.equals(p2)); + + p1 = new SimpleTimePeriod(new Date(1002L), new Date(1003L)); + assertFalse(p1.equals(p2)); + p2 = new SimpleTimePeriod(new Date(1002L), new Date(1003L)); + assertTrue(p1.equals(p2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + SimpleTimePeriod p1 = new SimpleTimePeriod(new Date(1000L), + new Date(1001L)); + SimpleTimePeriod p2 = (SimpleTimePeriod) TestUtilities.serialised(p1); + assertEquals(p1, p2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + SimpleTimePeriod s1 = new SimpleTimePeriod(new Date(10L), + new Date(20L)); + SimpleTimePeriod s2 = new SimpleTimePeriod(new Date(10L), + new Date(20L)); + assertTrue(s1.equals(s2)); + int h1 = s1.hashCode(); + int h2 = s2.hashCode(); + assertEquals(h1, h2); + } + + /** + * This class is immutable, so it should not implement Cloneable. + */ + @Test + public void testClone() { + SimpleTimePeriod s1 = new SimpleTimePeriod(new Date(10L), + new Date(20)); + assertFalse(s1 instanceof Cloneable); + } + + /** + * Some simple checks for immutability. + */ + @Test + public void testImmutable() { + SimpleTimePeriod p1 = new SimpleTimePeriod(new Date(10L), + new Date(20L)); + SimpleTimePeriod p2 = new SimpleTimePeriod(new Date(10L), + new Date(20L)); + assertEquals(p1, p2); + p1.getStart().setTime(11L); + assertEquals(p1, p2); + + Date d1 = new Date(10L); + Date d2 = new Date(20L); + p1 = new SimpleTimePeriod(d1, d2); + d1.setTime(11L); + assertEquals(new Date(10L), p1.getStart()); + } + + /** + * Some checks for the compareTo() method. + */ + @Test + public void testCompareTo() { + SimpleTimePeriod s1 = new SimpleTimePeriod(new Date(10L), + new Date(20L)); + SimpleTimePeriod s2 = new SimpleTimePeriod(new Date(10L), + new Date(20L)); + assertEquals(0, s1.compareTo(s2)); + + s1 = new SimpleTimePeriod(new Date(9L), new Date(21L)); + s2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); + assertEquals(-1, s1.compareTo(s2)); + + s1 = new SimpleTimePeriod(new Date(11L), new Date(19L)); + s2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); + assertEquals(1, s1.compareTo(s2)); + + s1 = new SimpleTimePeriod(new Date(9L), new Date(19L)); + s2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); + assertEquals(-1, s1.compareTo(s2)); + + s1 = new SimpleTimePeriod(new Date(11L), new Date(21)); + s2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); + assertEquals(1, s1.compareTo(s2)); + + s1 = new SimpleTimePeriod(new Date(10L), new Date(18)); + s2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); + assertEquals(-1, s1.compareTo(s2)); + + s1 = new SimpleTimePeriod(new Date(10L), new Date(22)); + s2 = new SimpleTimePeriod(new Date(10L), new Date(20L)); + assertEquals(1, s1.compareTo(s2)); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimePeriodAnchorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimePeriodAnchorTest.java new file mode 100755 index 0000000..80e96c2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimePeriodAnchorTest.java @@ -0,0 +1,73 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * TimePeriodAnchorTest.java + * ------------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 01-Mar-2004 : Version 1 (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link TimePeriodAnchor} class. + */ +public class TimePeriodAnchorTest { + + /** + * Test the equals() method. + */ + @Test + public void testEquals() { + assertTrue(TimePeriodAnchor.START.equals(TimePeriodAnchor.START)); + assertTrue(TimePeriodAnchor.MIDDLE.equals(TimePeriodAnchor.MIDDLE)); + assertTrue(TimePeriodAnchor.END.equals(TimePeriodAnchor.END)); + } + + /** + * Serialize an instance, restore it, and check for identity. + */ + @Test + public void testSerialization() { + TimePeriodAnchor a1 = TimePeriodAnchor.START; + TimePeriodAnchor a2 = (TimePeriodAnchor) TestUtilities.serialised(a1); + assertTrue(a1 == a2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimePeriodValueTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimePeriodValueTest.java new file mode 100755 index 0000000..f9522d2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimePeriodValueTest.java @@ -0,0 +1,84 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * TimePeriodValueTest.java + * ------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jul-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link TimePeriodValue} class. + */ +public class TimePeriodValueTest { + + /** + * Test that an instance is equal to itself. + */ + @Test + public void testEqualsSelf() { + TimePeriodValue tpv = new TimePeriodValue(new Day(), 55.75); + assertTrue(tpv.equals(tpv)); + } + + /** + * Tests the equals() method. + */ + @Test + public void testEquals() { + TimePeriodValue tpv1 = new TimePeriodValue(new Day(30, 7, 2003), 55.75); + TimePeriodValue tpv2 = new TimePeriodValue(new Day(30, 7, 2003), 55.75); + assertTrue(tpv1.equals(tpv2)); + assertTrue(tpv2.equals(tpv1)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TimePeriodValue tpv1 = new TimePeriodValue(new Day(30, 7, 2003), 55.75); + TimePeriodValue tpv2 = (TimePeriodValue) TestUtilities.serialised(tpv1); + assertEquals(tpv1, tpv2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimePeriodValuesCollectionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimePeriodValuesCollectionTest.java new file mode 100755 index 0000000..aa96c09 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimePeriodValuesCollectionTest.java @@ -0,0 +1,220 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------------ + * TimePeriodValuesCollectionTests.java + * ------------------------------------ + * (C) Copyright 2005-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 11-Mar-2005 : Version 1 (DG); + * 08-Mar-2007 : Added testGetSeries() (DG); + * 11-Jun-2007 : Added tests for getDomainBounds() (DG); + * 10-Jul-2007 : Fixed compile errors (DG); + * 07-Apr-2008 : Added more checks to + * testGetDomainBoundsWithInterval() (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.junit.Test; + +/** + * Some tests for the {@link TimePeriodValuesCollection} class. + */ +public class TimePeriodValuesCollectionTest { + + /** + * A test for bug report 1161340. I wasn't able to reproduce the problem + * with this test. + */ + @Test + public void test1161340() { + TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); + TimePeriodValues v1 = new TimePeriodValues("V1"); + v1.add(new Day(11, 3, 2005), 1.2); + v1.add(new Day(12, 3, 2005), 3.4); + dataset.addSeries(v1); + assertEquals(1, dataset.getSeriesCount()); + dataset.removeSeries(v1); + assertEquals(0, dataset.getSeriesCount()); + + TimePeriodValues v2 = new TimePeriodValues("V2"); + v1.add(new Day(5, 3, 2005), 1.2); + v1.add(new Day(6, 3, 2005), 3.4); + dataset.addSeries(v2); + assertEquals(1, dataset.getSeriesCount()); + } + + /** + * Tests the equals() method. + */ + @Test + public void testEquals() { + + TimePeriodValuesCollection c1 = new TimePeriodValuesCollection(); + TimePeriodValuesCollection c2 = new TimePeriodValuesCollection(); + assertTrue(c1.equals(c2)); + + c1.setDomainIsPointsInTime(!c1.getDomainIsPointsInTime()); + assertFalse(c1.equals(c2)); + c2.setDomainIsPointsInTime(c1.getDomainIsPointsInTime()); + assertTrue(c1.equals(c2)); + + c1.setXPosition(TimePeriodAnchor.END); + assertFalse(c1.equals(c2)); + c2.setXPosition(TimePeriodAnchor.END); + assertTrue(c1.equals(c2)); + + TimePeriodValues v1 = new TimePeriodValues("Test"); + TimePeriodValues v2 = new TimePeriodValues("Test"); + + c1.addSeries(v1); + assertFalse(c1.equals(c2)); + c2.addSeries(v2); + assertTrue(c1.equals(c2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TimePeriodValuesCollection c1 = new TimePeriodValuesCollection(); + TimePeriodValuesCollection c2 = (TimePeriodValuesCollection) + TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + + /** + * Some basic checks for the getSeries() method. + */ + @Test + public void testGetSeries() { + TimePeriodValuesCollection c1 = new TimePeriodValuesCollection(); + TimePeriodValues s1 = new TimePeriodValues("Series 1"); + c1.addSeries(s1); + assertEquals("Series 1", c1.getSeries(0).getKey()); + + boolean pass = false; + try { + c1.getSeries(-1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + c1.getSeries(1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the getDomainBounds() method. + */ + @Test + public void testGetDomainBoundsWithoutInterval() { + // check empty dataset + TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); + dataset.setDomainIsPointsInTime(false); + Range r = dataset.getDomainBounds(false); + assertNull(r); + + // check dataset with one time period + TimePeriodValues s1 = new TimePeriodValues("S1"); + s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0); + dataset.addSeries(s1); + r = dataset.getDomainBounds(false); + assertEquals(1500.0, r.getLowerBound(), EPSILON); + assertEquals(1500.0, r.getUpperBound(), EPSILON); + + // check dataset with two time periods + s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0); + r = dataset.getDomainBounds(false); + assertEquals(1500.0, r.getLowerBound(), EPSILON); + assertEquals(2250.0, r.getUpperBound(), EPSILON); + } + + /** + * Some more checks for the getDomainBounds() method. + * + * @see #testGetDomainBoundsWithoutInterval() + */ + @Test + public void testGetDomainBoundsWithInterval() { + // check empty dataset + TimePeriodValuesCollection dataset = new TimePeriodValuesCollection(); + Range r = dataset.getDomainBounds(true); + assertNull(r); + + // check dataset with one time period + TimePeriodValues s1 = new TimePeriodValues("S1"); + s1.add(new SimpleTimePeriod(1000L, 2000L), 1.0); + dataset.addSeries(s1); + r = dataset.getDomainBounds(true); + assertEquals(1000.0, r.getLowerBound(), EPSILON); + assertEquals(2000.0, r.getUpperBound(), EPSILON); + + // check dataset with two time periods + s1.add(new SimpleTimePeriod(1500L, 3000L), 2.0); + r = dataset.getDomainBounds(true); + assertEquals(1000.0, r.getLowerBound(), EPSILON); + assertEquals(3000.0, r.getUpperBound(), EPSILON); + + // add a third time period + s1.add(new SimpleTimePeriod(6000L, 7000L), 1.5); + r = dataset.getDomainBounds(true); + assertEquals(1000.0, r.getLowerBound(), EPSILON); + assertEquals(7000.0, r.getUpperBound(), EPSILON); + + // add a fourth time period + s1.add(new SimpleTimePeriod(4000L, 5000L), 1.4); + r = dataset.getDomainBounds(true); + assertEquals(1000.0, r.getLowerBound(), EPSILON); + assertEquals(7000.0, r.getUpperBound(), EPSILON); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimePeriodValuesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimePeriodValuesTest.java new file mode 100755 index 0000000..9b84de6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimePeriodValuesTest.java @@ -0,0 +1,373 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * TimePeriodValueTest.java + * ------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jul-2003 : Version 1 (DG); + * 07-Apr-2008 : Added new tests for min/max-start/middle/end + * index updates (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.util.Date; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.data.general.SeriesChangeListener; +import org.jfree.date.MonthConstants; +import org.junit.Before; +import org.junit.Test; + +/** + * A collection of test cases for the {@link TimePeriodValues} class. + */ +public class TimePeriodValuesTest { + + /** Series A. */ + private TimePeriodValues seriesA; + + /** Series B. */ + private TimePeriodValues seriesB; + + /** Series C. */ + private TimePeriodValues seriesC; + + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.seriesA = new TimePeriodValues("Series A"); + this.seriesA.add(new Year(2000), new Integer(102000)); + this.seriesA.add(new Year(2001), new Integer(102001)); + this.seriesA.add(new Year(2002), new Integer(102002)); + this.seriesA.add(new Year(2003), new Integer(102003)); + this.seriesA.add(new Year(2004), new Integer(102004)); + this.seriesA.add(new Year(2005), new Integer(102005)); + + this.seriesB = new TimePeriodValues("Series B"); + this.seriesB.add(new Year(2006), new Integer(202006)); + this.seriesB.add(new Year(2007), new Integer(202007)); + this.seriesB.add(new Year(2008), new Integer(202008)); + + this.seriesC = new TimePeriodValues("Series C"); + this.seriesC.add(new Year(1999), new Integer(301999)); + this.seriesC.add(new Year(2000), new Integer(302000)); + this.seriesC.add(new Year(2002), new Integer(302002)); + } + + /** + * Set up a quarter equal to Q1 1900. Request the previous quarter, it + * should be null. + */ + @Test + public void testClone() throws CloneNotSupportedException { + TimePeriodValues series = new TimePeriodValues("Test Series"); + RegularTimePeriod jan1st2002 = new Day(1, MonthConstants.JANUARY, 2002); + series.add(jan1st2002, new Integer(42)); + TimePeriodValues clone = (TimePeriodValues) series.clone(); + clone.setKey("Clone Series"); + clone.update(0, new Integer(10)); + + int seriesValue = series.getValue(0).intValue(); + int cloneValue = clone.getValue(0).intValue(); + + assertEquals(42, seriesValue); + assertEquals(10, cloneValue); + assertEquals("Test Series", series.getKey()); + assertEquals("Clone Series", clone.getKey()); + } + + /** + * Add a value to series A for 1999. It should be added at index 0. + */ + @Test + public void testAddValue() { + TimePeriodValues tpvs = new TimePeriodValues("Test"); + tpvs.add(new Year(1999), new Integer(1)); + int value = tpvs.getValue(0).intValue(); + assertEquals(1, value); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TimePeriodValues s1 = new TimePeriodValues("A test"); + s1.add(new Year(2000), 13.75); + s1.add(new Year(2001), 11.90); + s1.add(new Year(2002), null); + s1.add(new Year(2005), 19.32); + s1.add(new Year(2007), 16.89); + TimePeriodValues s2 = (TimePeriodValues) TestUtilities.serialised(s1); + assertTrue(s1.equals(s2)); + } + + /** + * Tests the equals method. + */ + @Test + public void testEquals() { + TimePeriodValues s1 = new TimePeriodValues("Time Series 1"); + TimePeriodValues s2 = new TimePeriodValues("Time Series 2"); + boolean b1 = s1.equals(s2); + assertFalse("b1", b1); + + s2.setKey("Time Series 1"); + boolean b2 = s1.equals(s2); + assertTrue("b2", b2); + + // domain description + s1.setDomainDescription("XYZ"); + assertFalse(s1.equals(s2)); + s2.setDomainDescription("XYZ"); + assertTrue(s1.equals(s2)); + + // domain description - null + s1.setDomainDescription(null); + assertFalse(s1.equals(s2)); + s2.setDomainDescription(null); + assertTrue(s1.equals(s2)); + + // range description + s1.setRangeDescription("XYZ"); + assertFalse(s1.equals(s2)); + s2.setRangeDescription("XYZ"); + assertTrue(s1.equals(s2)); + + // range description - null + s1.setRangeDescription(null); + assertFalse(s1.equals(s2)); + s2.setRangeDescription(null); + assertTrue(s1.equals(s2)); + + RegularTimePeriod p1 = new Day(); + RegularTimePeriod p2 = p1.next(); + s1.add(p1, 100.0); + s1.add(p2, 200.0); + boolean b3 = s1.equals(s2); + assertFalse("b3", b3); + + s2.add(p1, 100.0); + s2.add(p2, 200.0); + boolean b4 = s1.equals(s2); + assertTrue("b4", b4); + + } + + /** + * A test for bug report 1161329. + */ + @Test + public void test1161329() { + TimePeriodValues tpv = new TimePeriodValues("Test"); + RegularTimePeriod t = new Day(); + tpv.add(t, 1.0); + t = t.next(); + tpv.add(t, 2.0); + tpv.delete(0, 1); + assertEquals(0, tpv.getItemCount()); + tpv.add(t, 2.0); + assertEquals(1, tpv.getItemCount()); + } + + static final double EPSILON = 0.0000000001; + + /** + * Some checks for the add() methods. + */ + @Test + public void testAdd() { + TimePeriodValues tpv = new TimePeriodValues("Test"); + MySeriesChangeListener listener = new MySeriesChangeListener(); + tpv.addChangeListener(listener); + tpv.add(new TimePeriodValue(new SimpleTimePeriod(new Date(1L), + new Date(3L)), 99.0)); + assertEquals(99.0, tpv.getValue(0).doubleValue(), EPSILON); + assertEquals(tpv, listener.getLastEvent().getSource()); + + // a null item should throw an IllegalArgumentException + boolean pass = false; + try { + tpv.add((TimePeriodValue) null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some tests for the getMinStartIndex() method. + */ + @Test + public void testGetMinStartIndex() { + TimePeriodValues s = new TimePeriodValues("Test"); + assertEquals(-1, s.getMinStartIndex()); + s.add(new SimpleTimePeriod(100L, 200L), 1.0); + assertEquals(0, s.getMinStartIndex()); + s.add(new SimpleTimePeriod(300L, 400L), 2.0); + assertEquals(0, s.getMinStartIndex()); + s.add(new SimpleTimePeriod(0L, 50L), 3.0); + assertEquals(2, s.getMinStartIndex()); + } + + /** + * Some tests for the getMaxStartIndex() method. + */ + @Test + public void testGetMaxStartIndex() { + TimePeriodValues s = new TimePeriodValues("Test"); + assertEquals(-1, s.getMaxStartIndex()); + s.add(new SimpleTimePeriod(100L, 200L), 1.0); + assertEquals(0, s.getMaxStartIndex()); + s.add(new SimpleTimePeriod(300L, 400L), 2.0); + assertEquals(1, s.getMaxStartIndex()); + s.add(new SimpleTimePeriod(0L, 50L), 3.0); + assertEquals(1, s.getMaxStartIndex()); + } + + /** + * Some tests for the getMinMiddleIndex() method. + */ + @Test + public void testGetMinMiddleIndex() { + TimePeriodValues s = new TimePeriodValues("Test"); + assertEquals(-1, s.getMinMiddleIndex()); + s.add(new SimpleTimePeriod(100L, 200L), 1.0); + assertEquals(0, s.getMinMiddleIndex()); + s.add(new SimpleTimePeriod(300L, 400L), 2.0); + assertEquals(0, s.getMinMiddleIndex()); + s.add(new SimpleTimePeriod(0L, 50L), 3.0); + assertEquals(2, s.getMinMiddleIndex()); + } + + /** + * Some tests for the getMaxMiddleIndex() method. + */ + @Test + public void testGetMaxMiddleIndex() { + TimePeriodValues s = new TimePeriodValues("Test"); + assertEquals(-1, s.getMaxMiddleIndex()); + s.add(new SimpleTimePeriod(100L, 200L), 1.0); + assertEquals(0, s.getMaxMiddleIndex()); + s.add(new SimpleTimePeriod(300L, 400L), 2.0); + assertEquals(1, s.getMaxMiddleIndex()); + s.add(new SimpleTimePeriod(0L, 50L), 3.0); + assertEquals(1, s.getMaxMiddleIndex()); + s.add(new SimpleTimePeriod(150L, 200L), 4.0); + assertEquals(1, s.getMaxMiddleIndex()); + } + + /** + * Some tests for the getMinEndIndex() method. + */ + @Test + public void getMinEndIndex() { + TimePeriodValues s = new TimePeriodValues("Test"); + assertEquals(-1, s.getMinEndIndex()); + s.add(new SimpleTimePeriod(100L, 200L), 1.0); + assertEquals(0, s.getMinEndIndex()); + s.add(new SimpleTimePeriod(300L, 400L), 2.0); + assertEquals(0, s.getMinEndIndex()); + s.add(new SimpleTimePeriod(0L, 50L), 3.0); + assertEquals(2, s.getMinEndIndex()); + } + + /** + * Some tests for the getMaxEndIndex() method. + */ + @Test + public void getMaxEndIndex() { + TimePeriodValues s = new TimePeriodValues("Test"); + assertEquals(-1, s.getMaxEndIndex()); + s.add(new SimpleTimePeriod(100L, 200L), 1.0); + assertEquals(0, s.getMaxEndIndex()); + s.add(new SimpleTimePeriod(300L, 400L), 2.0); + assertEquals(1, s.getMaxEndIndex()); + s.add(new SimpleTimePeriod(0L, 50L), 3.0); + assertEquals(1, s.getMaxEndIndex()); + } + + /** + * A listener used for detecting series change events. + */ + static class MySeriesChangeListener implements SeriesChangeListener { + + SeriesChangeEvent lastEvent; + + /** + * Creates a new listener. + */ + public MySeriesChangeListener() { + this.lastEvent = null; + } + + /** + * Returns the last event. + * + * @return The last event (possibly null). + */ + public SeriesChangeEvent getLastEvent() { + return this.lastEvent; + } + + /** + * Clears the last event (sets it to null). + */ + public void clearLastEvent() { + this.lastEvent = null; + } + + /** + * Callback method for series change events. + * + * @param event the event. + */ + @Override + public void seriesChanged(SeriesChangeEvent event) { + this.lastEvent = event; + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimeSeriesCollectionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimeSeriesCollectionTest.java new file mode 100755 index 0000000..0a3d563 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimeSeriesCollectionTest.java @@ -0,0 +1,419 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * TimeSeriesCollectionTest.java + * ----------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 01-May-2003 : Version 1 (DG); + * 04-Dec-2003 : Added a test for the getSurroundingItems() method (DG); + * 08-May-2007 : Added testIndexOf() method (DG); + * 18-May-2009 : Added testFindDomainBounds() (DG); + * 08-Jan-2012 : Added testBug3445507() (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; + +import java.util.ArrayList; +import java.util.List; +import java.util.TimeZone; +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.data.general.DatasetUtilities; +import org.junit.Test; + +/** + * A collection of test cases for the {@link TimeSeriesCollection} class. + */ +public class TimeSeriesCollectionTest { + + /** + * Some tests for the equals() method. + */ + @Test + public void testEquals() { + TimeSeriesCollection c1 = new TimeSeriesCollection(); + TimeSeriesCollection c2 = new TimeSeriesCollection(); + + TimeSeries s1 = new TimeSeries("Series 1"); + TimeSeries s2 = new TimeSeries("Series 2"); + + // newly created collections should be equal + boolean b1 = c1.equals(c2); + assertTrue("b1", b1); + + // add series to collection 1, should be not equal + c1.addSeries(s1); + c1.addSeries(s2); + boolean b2 = c1.equals(c2); + assertFalse("b2", b2); + + // now add the same series to collection 2 to make them equal again... + c2.addSeries(s1); + c2.addSeries(s2); + boolean b3 = c1.equals(c2); + assertTrue("b3", b3); + + // now remove series 2 from collection 2 + c2.removeSeries(s2); + boolean b4 = c1.equals(c2); + assertFalse("b4", b4); + + // now remove series 2 from collection 1 to make them equal again + c1.removeSeries(s2); + boolean b5 = c1.equals(c2); + assertTrue("b5", b5); + } + + /** + * Tests the remove series method. + */ + @Test + public void testRemoveSeries() { + TimeSeriesCollection c1 = new TimeSeriesCollection(); + + TimeSeries s1 = new TimeSeries("Series 1"); + TimeSeries s2 = new TimeSeries("Series 2"); + TimeSeries s3 = new TimeSeries("Series 3"); + TimeSeries s4 = new TimeSeries("Series 4"); + + c1.addSeries(s1); + c1.addSeries(s2); + c1.addSeries(s3); + c1.addSeries(s4); + + c1.removeSeries(s3); + + TimeSeries s = c1.getSeries(2); + boolean b1 = s.equals(s4); + assertTrue(b1); + } + + /** + * Some checks for the {@link TimeSeriesCollection#removeSeries(int)} + * method. + */ + @Test + public void testRemoveSeries_int() { + TimeSeriesCollection c1 = new TimeSeriesCollection(); + TimeSeries s1 = new TimeSeries("Series 1"); + TimeSeries s2 = new TimeSeries("Series 2"); + TimeSeries s3 = new TimeSeries("Series 3"); + TimeSeries s4 = new TimeSeries("Series 4"); + c1.addSeries(s1); + c1.addSeries(s2); + c1.addSeries(s3); + c1.addSeries(s4); + c1.removeSeries(2); + assertTrue(c1.getSeries(2).equals(s4)); + c1.removeSeries(0); + assertTrue(c1.getSeries(0).equals(s2)); + assertEquals(2, c1.getSeriesCount()); + } + + /** + * Test the getSurroundingItems() method to ensure it is returning the + * values we expect. + */ + @Test + public void testGetSurroundingItems() { + TimeSeries series = new TimeSeries("Series 1"); + TimeSeriesCollection collection = new TimeSeriesCollection(series); + collection.setXPosition(TimePeriodAnchor.MIDDLE); + + // for a series with no data, we expect {-1, -1}... + int[] result = collection.getSurroundingItems(0, 1000L); + assertTrue(result[0] == -1); + assertTrue(result[1] == -1); + + // now test with a single value in the series... + Day today = new Day(); + long start1 = today.getFirstMillisecond(); + long middle1 = today.getMiddleMillisecond(); + long end1 = today.getLastMillisecond(); + + series.add(today, 99.9); + result = collection.getSurroundingItems(0, start1); + assertTrue(result[0] == -1); + assertTrue(result[1] == 0); + + result = collection.getSurroundingItems(0, middle1); + assertTrue(result[0] == 0); + assertTrue(result[1] == 0); + + result = collection.getSurroundingItems(0, end1); + assertTrue(result[0] == 0); + assertTrue(result[1] == -1); + + // now add a second value to the series... + Day tomorrow = (Day) today.next(); + long start2 = tomorrow.getFirstMillisecond(); + long middle2 = tomorrow.getMiddleMillisecond(); + long end2 = tomorrow.getLastMillisecond(); + + series.add(tomorrow, 199.9); + result = collection.getSurroundingItems(0, start2); + assertTrue(result[0] == 0); + assertTrue(result[1] == 1); + + result = collection.getSurroundingItems(0, middle2); + assertTrue(result[0] == 1); + assertTrue(result[1] == 1); + + result = collection.getSurroundingItems(0, end2); + assertTrue(result[0] == 1); + assertTrue(result[1] == -1); + + // now add a third value to the series... + Day yesterday = (Day) today.previous(); + long start3 = yesterday.getFirstMillisecond(); + long middle3 = yesterday.getMiddleMillisecond(); + long end3 = yesterday.getLastMillisecond(); + + series.add(yesterday, 1.23); + result = collection.getSurroundingItems(0, start3); + assertTrue(result[0] == -1); + assertTrue(result[1] == 0); + + result = collection.getSurroundingItems(0, middle3); + assertTrue(result[0] == 0); + assertTrue(result[1] == 0); + + result = collection.getSurroundingItems(0, end3); + assertTrue(result[0] == 0); + assertTrue(result[1] == 1); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TimeSeriesCollection c1 = new TimeSeriesCollection(createSeries()); + TimeSeriesCollection c2 = (TimeSeriesCollection) + TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + + /** + * Creates a time series for testing. + * + * @return A time series. + */ + private TimeSeries createSeries() { + RegularTimePeriod t = new Day(); + TimeSeries series = new TimeSeries("Test"); + series.add(t, 1.0); + t = t.next(); + series.add(t, 2.0); + t = t.next(); + series.add(t, null); + t = t.next(); + series.add(t, 4.0); + return series; + } + + /** + * A test for bug report 1170825. + */ + @Test + public void test1170825() { + TimeSeries s1 = new TimeSeries("Series1"); + TimeSeriesCollection dataset = new TimeSeriesCollection(); + dataset.addSeries(s1); + try { + /* TimeSeries s = */ dataset.getSeries(1); + } + catch (IllegalArgumentException e) { + // correct outcome + } + catch (IndexOutOfBoundsException e) { + assertTrue(false); // wrong outcome + } + } + + /** + * Some tests for the indexOf() method. + */ + @Test + public void testIndexOf() { + TimeSeries s1 = new TimeSeries("S1"); + TimeSeries s2 = new TimeSeries("S2"); + TimeSeriesCollection dataset = new TimeSeriesCollection(); + assertEquals(-1, dataset.indexOf(s1)); + assertEquals(-1, dataset.indexOf(s2)); + + dataset.addSeries(s1); + assertEquals(0, dataset.indexOf(s1)); + assertEquals(-1, dataset.indexOf(s2)); + + dataset.addSeries(s2); + assertEquals(0, dataset.indexOf(s1)); + assertEquals(1, dataset.indexOf(s2)); + + dataset.removeSeries(s1); + assertEquals(-1, dataset.indexOf(s1)); + assertEquals(0, dataset.indexOf(s2)); + + TimeSeries s2b = new TimeSeries("S2"); + assertEquals(0, dataset.indexOf(s2b)); + } + + private static final double EPSILON = 0.0000000001; + + /** + * This method provides a check for the bounds calculated using the + * {@link DatasetUtilities#findDomainBounds(org.jfree.data.xy.XYDataset, + * java.util.List, boolean)} method. + */ + @Test + public void testFindDomainBounds() { + TimeSeriesCollection dataset = new TimeSeriesCollection(); + List visibleSeriesKeys = new java.util.ArrayList(); + Range r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, + true); + assertNull(r); + + TimeSeries s1 = new TimeSeries("S1"); + dataset.addSeries(s1); + visibleSeriesKeys.add("S1"); + r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true); + assertNull(r); + + // store the current time zone + TimeZone saved = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/Paris")); + + s1.add(new Year(2008), 8.0); + r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true); + assertEquals(1199142000000.0, r.getLowerBound(), EPSILON); + assertEquals(1230764399999.0, r.getUpperBound(), EPSILON); + + TimeSeries s2 = new TimeSeries("S2"); + dataset.addSeries(s2); + s2.add(new Year(2009), 9.0); + s2.add(new Year(2010), 10.0); + r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true); + assertEquals(1199142000000.0, r.getLowerBound(), EPSILON); + assertEquals(1230764399999.0, r.getUpperBound(), EPSILON); + + visibleSeriesKeys.add("S2"); + r = DatasetUtilities.findDomainBounds(dataset, visibleSeriesKeys, true); + assertEquals(1199142000000.0, r.getLowerBound(), EPSILON); + assertEquals(1293836399999.0, r.getUpperBound(), EPSILON); + + // restore the default time zone + TimeZone.setDefault(saved); + } + + /** + * Basic checks for cloning. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + TimeSeries s1 = new TimeSeries("Series"); + s1.add(new Year(2009), 1.1); + TimeSeriesCollection c1 = new TimeSeriesCollection(); + c1.addSeries(s1); + TimeSeriesCollection c2 = (TimeSeriesCollection) c1.clone(); + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + + // check independence + s1.setDescription("XYZ"); + assertFalse(c1.equals(c2)); + c2.getSeries(0).setDescription("XYZ"); + assertTrue(c1.equals(c2)); + } + + /** + * A test to cover bug 3445507. + */ + @Test + public void testBug3445507() { + TimeSeries s1 = new TimeSeries("S1"); + s1.add(new Year(2011), null); + s1.add(new Year(2012), null); + + TimeSeries s2 = new TimeSeries("S2"); + s2.add(new Year(2011), 5.0); + s2.add(new Year(2012), 6.0); + + TimeSeriesCollection dataset = new TimeSeriesCollection(); + dataset.addSeries(s1); + dataset.addSeries(s2); + + List keys = new ArrayList(); + keys.add("S1"); + keys.add("S2"); + Range r = dataset.getRangeBounds(keys, new Range( + Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY), false); + assertEquals(5.0, r.getLowerBound(), EPSILON); + assertEquals(6.0, r.getUpperBound(), EPSILON); + } + + /** + * Some checks for the getRangeBounds() method. + */ + @Test + public void testGetRangeBounds() { + TimeSeriesCollection dataset = new TimeSeriesCollection(); + Range r = dataset.getRangeBounds(false); + assertNull(r); + + TimeSeries s1 = new TimeSeries("S1"); + dataset.addSeries(s1); + r = dataset.getRangeBounds(false); + assertTrue(Double.isNaN(r.getLowerBound())); + assertTrue(Double.isNaN(r.getUpperBound())); + + s1.add(new Year(2012), 1.0); + r = dataset.getRangeBounds(false); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(1.0, r.getUpperBound(), EPSILON); + + TimeSeries s2 = new TimeSeries("S2"); + dataset.addSeries(s2); + r = dataset.getRangeBounds(false); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(1.0, r.getUpperBound(), EPSILON); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimeSeriesDataItemTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimeSeriesDataItemTest.java new file mode 100755 index 0000000..1702c1e --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimeSeriesDataItemTest.java @@ -0,0 +1,97 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * TimeSeriesDataItemTest.java + * --------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 13-Mar-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link TimeSeriesDataItem} class. + */ +public class TimeSeriesDataItemTest { + + /** + * Test that an instance is equal to itself. + * + * SourceForge Bug ID: 558850. + */ + @Test + public void testEqualsSelf() { + TimeSeriesDataItem item = new TimeSeriesDataItem(new Day(23, 9, 2001), + 99.7); + assertTrue(item.equals(item)); + } + + /** + * Test the equals() method. + */ + @Test + public void testEquals() { + TimeSeriesDataItem item1 = new TimeSeriesDataItem(new Day(23, 9, 2001), + 99.7); + TimeSeriesDataItem item2 = new TimeSeriesDataItem(new Day(23, 9, 2001), + 99.7); + assertTrue(item1.equals(item2)); + assertTrue(item2.equals(item1)); + + item1.setValue(new Integer(5)); + assertFalse(item1.equals(item2)); + item2.setValue(new Integer(5)); + assertTrue(item1.equals(item2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TimeSeriesDataItem item1 = new TimeSeriesDataItem(new Day(23, 9, 2001), + 99.7); + TimeSeriesDataItem item2 = (TimeSeriesDataItem) + TestUtilities.serialised(item1); + assertEquals(item1, item2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimeSeriesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimeSeriesTest.java new file mode 100755 index 0000000..acccbd5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimeSeriesTest.java @@ -0,0 +1,1108 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * TimeSeriesTest.java + * ------------------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Nov-2001 : Version 1 (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 13-Mar-2003 : Added serialization test (DG); + * 15-Oct-2003 : Added test for setMaximumItemCount method (DG); + * 23-Aug-2004 : Added test that highlights a bug where the addOrUpdate() + * method can lead to more than maximumItemCount items in the + * dataset (DG); + * 24-May-2006 : Added new tests (DG); + * 31-Oct-2007 : New hashCode() test (DG); + * 21-Nov-2007 : Added testBug1832432() and testClone2() (DG); + * 10-Jan-2008 : Added testBug1864222() (DG); + * 13-Jan-2009 : Added testEquals3() and testRemoveAgedItems3() (DG); + * 26-May-2009 : Added various tests for min/maxY values (DG); + * 09-Jun-2009 : Added testAdd_TimeSeriesDataItem (DG); + * 31-Aug-2009 : Added new test for createCopy() method (DG); + * 03-Dec-2011 : Added testBug3446965() (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.data.general.SeriesChangeListener; +import org.jfree.data.general.SeriesException; +import org.jfree.date.MonthConstants; +import org.junit.Before; +import org.junit.Test; + +/** + * A collection of test cases for the {@link TimeSeries} class. + */ +public class TimeSeriesTest implements SeriesChangeListener { + + /** A time series. */ + private TimeSeries seriesA; + + /** A time series. */ + private TimeSeries seriesB; + + /** A time series. */ + private TimeSeries seriesC; + + /** A flag that indicates whether or not a change event was fired. */ + private boolean gotSeriesChangeEvent = false; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.seriesA = new TimeSeries("Series A"); + this.seriesA.add(new Year(2000), new Integer(102000)); + this.seriesA.add(new Year(2001), new Integer(102001)); + this.seriesA.add(new Year(2002), new Integer(102002)); + this.seriesA.add(new Year(2003), new Integer(102003)); + this.seriesA.add(new Year(2004), new Integer(102004)); + this.seriesA.add(new Year(2005), new Integer(102005)); + + this.seriesB = new TimeSeries("Series B"); + this.seriesB.add(new Year(2006), new Integer(202006)); + this.seriesB.add(new Year(2007), new Integer(202007)); + this.seriesB.add(new Year(2008), new Integer(202008)); + + this.seriesC = new TimeSeries("Series C"); + this.seriesC.add(new Year(1999), new Integer(301999)); + this.seriesC.add(new Year(2000), new Integer(302000)); + this.seriesC.add(new Year(2002), new Integer(302002)); + } + + /** + * Sets the flag to indicate that a {@link SeriesChangeEvent} has been + * received. + * + * @param event the event. + */ + @Override + public void seriesChanged(SeriesChangeEvent event) { + this.gotSeriesChangeEvent = true; + } + + /** + * Check that cloning works. + */ + @Test + public void testClone() throws CloneNotSupportedException { + + TimeSeries series = new TimeSeries("Test Series"); + RegularTimePeriod jan1st2002 = new Day(1, MonthConstants.JANUARY, 2002); + series.add(jan1st2002, new Integer(42)); + + TimeSeries clone; + clone = (TimeSeries) series.clone(); + clone.setKey("Clone Series"); + clone.update(jan1st2002, new Integer(10)); + + int seriesValue = series.getValue(jan1st2002).intValue(); + int cloneValue = clone.getValue(jan1st2002).intValue(); + + assertEquals(42, seriesValue); + assertEquals(10, cloneValue); + assertEquals("Test Series", series.getKey()); + assertEquals("Clone Series", clone.getKey()); + } + + /** + * Another test of the clone() method. + */ + @Test + public void testClone2() throws CloneNotSupportedException { + TimeSeries s1 = new TimeSeries("S1", Year.class); + s1.add(new Year(2007), 100.0); + s1.add(new Year(2008), null); + s1.add(new Year(2009), 200.0); + TimeSeries s2 = (TimeSeries) s1.clone(); + assertTrue(s1.equals(s2)); + + // check independence + s2.addOrUpdate(new Year(2009), 300.0); + assertFalse(s1.equals(s2)); + s1.addOrUpdate(new Year(2009), 300.0); + assertTrue(s1.equals(s2)); + } + + /** + * Add a value to series A for 1999. It should be added at index 0. + */ + @Test + public void testAddValue() { + this.seriesA.add(new Year(1999), new Integer(1)); + int value = this.seriesA.getValue(0).intValue(); + assertEquals(1, value); + } + + /** + * Tests the retrieval of values. + */ + @Test + public void testGetValue() { + Number value1 = this.seriesA.getValue(new Year(1999)); + assertNull(value1); + int value2 = this.seriesA.getValue(new Year(2000)).intValue(); + assertEquals(102000, value2); + } + + /** + * Tests the deletion of values. + */ + @Test + public void testDelete() { + this.seriesA.delete(0, 0); + assertEquals(5, this.seriesA.getItemCount()); + Number value = this.seriesA.getValue(new Year(2000)); + assertNull(value); + } + + /** + * Basic tests for the delete() method. + */ + @Test + public void testDelete2() { + TimeSeries s1 = new TimeSeries("Series", Year.class); + s1.add(new Year(2000), 13.75); + s1.add(new Year(2001), 11.90); + s1.add(new Year(2002), null); + s1.addChangeListener(this); + this.gotSeriesChangeEvent = false; + s1.delete(new Year(2001)); + assertTrue(this.gotSeriesChangeEvent); + assertEquals(2, s1.getItemCount()); + assertEquals(null, s1.getValue(new Year(2001))); + + // try deleting a time period that doesn't exist... + this.gotSeriesChangeEvent = false; + s1.delete(new Year(2006)); + assertFalse(this.gotSeriesChangeEvent); + + // try deleting null + try { + s1.delete(null); + fail("Expected IllegalArgumentException."); + } + catch (IllegalArgumentException e) { + // expected + } + } + + /** + * Some checks for the delete(int, int) method. + */ + @Test + public void testDelete3() { + TimeSeries s1 = new TimeSeries("S1"); + s1.add(new Year(2011), 1.1); + s1.add(new Year(2012), 2.2); + s1.add(new Year(2013), 3.3); + s1.add(new Year(2014), 4.4); + s1.add(new Year(2015), 5.5); + s1.add(new Year(2016), 6.6); + s1.delete(2, 5); + assertEquals(2, s1.getItemCount()); + assertEquals(new Year(2011), s1.getTimePeriod(0)); + assertEquals(new Year(2012), s1.getTimePeriod(1)); + assertEquals(1.1, s1.getMinY(), EPSILON); + assertEquals(2.2, s1.getMaxY(), EPSILON); + } + + /** + * Check that the item bounds are determined correctly when there is a + * maximum item count and a new value is added. + */ + @Test + public void testDelete_RegularTimePeriod() { + TimeSeries s1 = new TimeSeries("S1"); + s1.add(new Year(2010), 1.1); + s1.add(new Year(2011), 2.2); + s1.add(new Year(2012), 3.3); + s1.add(new Year(2013), 4.4); + s1.delete(new Year(2010)); + s1.delete(new Year(2013)); + assertEquals(2.2, s1.getMinY(), EPSILON); + assertEquals(3.3, s1.getMaxY(), EPSILON); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TimeSeries s1 = new TimeSeries("A test"); + s1.add(new Year(2000), 13.75); + s1.add(new Year(2001), 11.90); + s1.add(new Year(2002), null); + s1.add(new Year(2005), 19.32); + s1.add(new Year(2007), 16.89); + TimeSeries s2 = (TimeSeries) TestUtilities.serialised(s1); + assertTrue(s1.equals(s2)); + } + + /** + * Tests the equals method. + */ + @Test + public void testEquals() { + TimeSeries s1 = new TimeSeries("Time Series 1"); + TimeSeries s2 = new TimeSeries("Time Series 2"); + boolean b1 = s1.equals(s2); + assertFalse("b1", b1); + + s2.setKey("Time Series 1"); + boolean b2 = s1.equals(s2); + assertTrue("b2", b2); + + RegularTimePeriod p1 = new Day(); + RegularTimePeriod p2 = p1.next(); + s1.add(p1, 100.0); + s1.add(p2, 200.0); + boolean b3 = s1.equals(s2); + assertFalse("b3", b3); + + s2.add(p1, 100.0); + s2.add(p2, 200.0); + boolean b4 = s1.equals(s2); + assertTrue("b4", b4); + + s1.setMaximumItemCount(100); + boolean b5 = s1.equals(s2); + assertFalse("b5", b5); + + s2.setMaximumItemCount(100); + boolean b6 = s1.equals(s2); + assertTrue("b6", b6); + + s1.setMaximumItemAge(100); + boolean b7 = s1.equals(s2); + assertFalse("b7", b7); + + s2.setMaximumItemAge(100); + boolean b8 = s1.equals(s2); + assertTrue("b8", b8); + } + + /** + * Tests a specific bug report where null arguments in the constructor + * cause the equals() method to fail. Fixed for 0.9.21. + */ + @Test + public void testEquals2() { + TimeSeries s1 = new TimeSeries("Series", null, null, Day.class); + TimeSeries s2 = new TimeSeries("Series", null, null, Day.class); + assertTrue(s1.equals(s2)); + } + + /** + * Two classes with different period classes are NOT the same. + */ + @Test + public void testEquals3() { + TimeSeries s1 = new TimeSeries("Series", Day.class); + TimeSeries s2 = new TimeSeries("Series", Month.class); + assertFalse(s1.equals(s2)); + } + + /** + * Some tests to ensure that the createCopy(RegularTimePeriod, + * RegularTimePeriod) method is functioning correctly. + */ + @Test + public void testCreateCopy1() { + + TimeSeries series = new TimeSeries("Series", Month.class); + series.add(new Month(MonthConstants.JANUARY, 2003), 45.0); + series.add(new Month(MonthConstants.FEBRUARY, 2003), 55.0); + series.add(new Month(MonthConstants.JUNE, 2003), 35.0); + series.add(new Month(MonthConstants.NOVEMBER, 2003), 85.0); + series.add(new Month(MonthConstants.DECEMBER, 2003), 75.0); + + try { + // copy a range before the start of the series data... + TimeSeries result1 = series.createCopy( + new Month(MonthConstants.NOVEMBER, 2002), + new Month(MonthConstants.DECEMBER, 2002)); + assertEquals(0, result1.getItemCount()); + + // copy a range that includes only the first item in the series... + TimeSeries result2 = series.createCopy( + new Month(MonthConstants.NOVEMBER, 2002), + new Month(MonthConstants.JANUARY, 2003)); + assertEquals(1, result2.getItemCount()); + + // copy a range that begins before and ends in the middle of the + // series... + TimeSeries result3 = series.createCopy( + new Month(MonthConstants.NOVEMBER, 2002), + new Month(MonthConstants.APRIL, 2003)); + assertEquals(2, result3.getItemCount()); + + TimeSeries result4 = series.createCopy( + new Month(MonthConstants.NOVEMBER, 2002), + new Month(MonthConstants.DECEMBER, 2003)); + assertEquals(5, result4.getItemCount()); + + TimeSeries result5 = series.createCopy( + new Month(MonthConstants.NOVEMBER, 2002), + new Month(MonthConstants.MARCH, 2004)); + assertEquals(5, result5.getItemCount()); + + TimeSeries result6 = series.createCopy( + new Month(MonthConstants.JANUARY, 2003), + new Month(MonthConstants.JANUARY, 2003)); + assertEquals(1, result6.getItemCount()); + + TimeSeries result7 = series.createCopy( + new Month(MonthConstants.JANUARY, 2003), + new Month(MonthConstants.APRIL, 2003)); + assertEquals(2, result7.getItemCount()); + + TimeSeries result8 = series.createCopy( + new Month(MonthConstants.JANUARY, 2003), + new Month(MonthConstants.DECEMBER, 2003)); + assertEquals(5, result8.getItemCount()); + + TimeSeries result9 = series.createCopy( + new Month(MonthConstants.JANUARY, 2003), + new Month(MonthConstants.MARCH, 2004)); + assertEquals(5, result9.getItemCount()); + + TimeSeries result10 = series.createCopy( + new Month(MonthConstants.MAY, 2003), + new Month(MonthConstants.DECEMBER, 2003)); + assertEquals(3, result10.getItemCount()); + + TimeSeries result11 = series.createCopy( + new Month(MonthConstants.MAY, 2003), + new Month(MonthConstants.MARCH, 2004)); + assertEquals(3, result11.getItemCount()); + + TimeSeries result12 = series.createCopy( + new Month(MonthConstants.DECEMBER, 2003), + new Month(MonthConstants.DECEMBER, 2003)); + assertEquals(1, result12.getItemCount()); + + TimeSeries result13 = series.createCopy( + new Month(MonthConstants.DECEMBER, 2003), + new Month(MonthConstants.MARCH, 2004)); + assertEquals(1, result13.getItemCount()); + + TimeSeries result14 = series.createCopy( + new Month(MonthConstants.JANUARY, 2004), + new Month(MonthConstants.MARCH, 2004)); + assertEquals(0, result14.getItemCount()); + } + catch (CloneNotSupportedException e) { + assertTrue(false); + } + + } + + /** + * Some tests to ensure that the createCopy(int, int) method is + * functioning correctly. + */ + @Test + public void testCreateCopy2() { + + TimeSeries series = new TimeSeries("Series", Month.class); + series.add(new Month(MonthConstants.JANUARY, 2003), 45.0); + series.add(new Month(MonthConstants.FEBRUARY, 2003), 55.0); + series.add(new Month(MonthConstants.JUNE, 2003), 35.0); + series.add(new Month(MonthConstants.NOVEMBER, 2003), 85.0); + series.add(new Month(MonthConstants.DECEMBER, 2003), 75.0); + + try { + // copy just the first item... + TimeSeries result1 = series.createCopy(0, 0); + assertEquals(new Month(1, 2003), result1.getTimePeriod(0)); + + // copy the first two items... + result1 = series.createCopy(0, 1); + assertEquals(new Month(2, 2003), result1.getTimePeriod(1)); + + // copy the middle three items... + result1 = series.createCopy(1, 3); + assertEquals(new Month(2, 2003), result1.getTimePeriod(0)); + assertEquals(new Month(11, 2003), result1.getTimePeriod(2)); + + // copy the last two items... + result1 = series.createCopy(3, 4); + assertEquals(new Month(11, 2003), result1.getTimePeriod(0)); + assertEquals(new Month(12, 2003), result1.getTimePeriod(1)); + + // copy the last item... + result1 = series.createCopy(4, 4); + assertEquals(new Month(12, 2003), result1.getTimePeriod(0)); + } + catch (CloneNotSupportedException e) { + assertTrue(false); + } + + // check negative first argument + boolean pass = false; + try { + /* TimeSeries result = */ series.createCopy(-1, 1); + } + catch (IllegalArgumentException e) { + pass = true; + } + catch (CloneNotSupportedException e) { + pass = false; + } + assertTrue(pass); + + // check second argument less than first argument + pass = false; + try { + /* TimeSeries result = */ series.createCopy(1, 0); + } + catch (IllegalArgumentException e) { + pass = true; + } + catch (CloneNotSupportedException e) { + pass = false; + } + assertTrue(pass); + + TimeSeries series2 = new TimeSeries("Series 2"); + try { + TimeSeries series3 = series2.createCopy(99, 999); + assertEquals(0, series3.getItemCount()); + } + catch (CloneNotSupportedException e) { + assertTrue(false); + } + } + + /** + * Checks that the min and max y values are updated correctly when copying + * a subset. + * + * @throws java.lang.CloneNotSupportedException + */ + @Test + public void testCreateCopy3() throws CloneNotSupportedException { + TimeSeries s1 = new TimeSeries("S1"); + s1.add(new Year(2009), 100.0); + s1.add(new Year(2010), 101.0); + s1.add(new Year(2011), 102.0); + assertEquals(100.0, s1.getMinY(), EPSILON); + assertEquals(102.0, s1.getMaxY(), EPSILON); + + TimeSeries s2 = s1.createCopy(0, 1); + assertEquals(100.0, s2.getMinY(), EPSILON); + assertEquals(101.0, s2.getMaxY(), EPSILON); + + TimeSeries s3 = s1.createCopy(1, 2); + assertEquals(101.0, s3.getMinY(), EPSILON); + assertEquals(102.0, s3.getMaxY(), EPSILON); + } + + /** + * Test the setMaximumItemCount() method to ensure that it removes items + * from the series if necessary. + */ + @Test + public void testSetMaximumItemCount() { + TimeSeries s1 = new TimeSeries("S1", Year.class); + s1.add(new Year(2000), 13.75); + s1.add(new Year(2001), 11.90); + s1.add(new Year(2002), null); + s1.add(new Year(2005), 19.32); + s1.add(new Year(2007), 16.89); + assertTrue(s1.getItemCount() == 5); + + s1.setMaximumItemCount(3); + assertTrue(s1.getItemCount() == 3); + TimeSeriesDataItem item = s1.getDataItem(0); + assertTrue(item.getPeriod().equals(new Year(2002))); + assertEquals(16.89, s1.getMinY(), EPSILON); + assertEquals(19.32, s1.getMaxY(), EPSILON); + } + + /** + * Some checks for the addOrUpdate() method. + */ + @Test + public void testAddOrUpdate() { + TimeSeries s1 = new TimeSeries("S1", Year.class); + s1.setMaximumItemCount(2); + s1.addOrUpdate(new Year(2000), 100.0); + assertEquals(1, s1.getItemCount()); + s1.addOrUpdate(new Year(2001), 101.0); + assertEquals(2, s1.getItemCount()); + s1.addOrUpdate(new Year(2001), 102.0); + assertEquals(2, s1.getItemCount()); + s1.addOrUpdate(new Year(2002), 103.0); + assertEquals(2, s1.getItemCount()); + } + + /** + * Test the add branch of the addOrUpdate() method. + */ + @Test + public void testAddOrUpdate2() { + TimeSeries s1 = new TimeSeries("S1"); + s1.setMaximumItemCount(2); + s1.addOrUpdate(new Year(2010), 1.1); + s1.addOrUpdate(new Year(2011), 2.2); + s1.addOrUpdate(new Year(2012), 3.3); + assertEquals(2, s1.getItemCount()); + assertEquals(2.2, s1.getMinY(), EPSILON); + assertEquals(3.3, s1.getMaxY(), EPSILON); + } + + /** + * Test that the addOrUpdate() method won't allow multiple time period + * classes. + */ + @Test + public void testAddOrUpdate3() { + TimeSeries s1 = new TimeSeries("S1"); + s1.addOrUpdate(new Year(2010), 1.1); + assertEquals(Year.class, s1.getTimePeriodClass()); + + boolean pass = false; + try { + s1.addOrUpdate(new Month(1, 2009), 0.0); + } + catch (SeriesException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some more checks for the addOrUpdate() method. + */ + @Test + public void testAddOrUpdate4() { + TimeSeries ts = new TimeSeries("S"); + TimeSeriesDataItem overwritten = ts.addOrUpdate(new Year(2009), 20.09); + assertNull(overwritten); + overwritten = ts.addOrUpdate(new Year(2009), 1.0); + assertEquals(new Double(20.09), overwritten.getValue()); + assertEquals(new Double(1.0), ts.getValue(new Year(2009))); + + // changing the overwritten record shouldn't affect the series + overwritten.setValue(null); + assertEquals(new Double(1.0), ts.getValue(new Year(2009))); + + TimeSeriesDataItem item = new TimeSeriesDataItem(new Year(2010), 20.10); + overwritten = ts.addOrUpdate(item); + assertNull(overwritten); + assertEquals(new Double(20.10), ts.getValue(new Year(2010))); + // changing the item that was added should not change the series + item.setValue(null); + assertEquals(new Double(20.10), ts.getValue(new Year(2010))); + } + + /** + * A test for the bug report 1075255. + */ + @Test + public void testBug1075255() { + TimeSeries ts = new TimeSeries("dummy"); + ts.add(new FixedMillisecond(0L), 0.0); + TimeSeries ts2 = new TimeSeries("dummy2"); + ts2.add(new FixedMillisecond(0L), 1.0); + try { + ts.addAndOrUpdate(ts2); + } + catch (Exception e) { + fail("No exceptions should be thrown."); + } + assertEquals(1, ts.getItemCount()); + } + + /** + * A test for bug 1832432. + */ + @Test + public void testBug1832432() throws CloneNotSupportedException { + TimeSeries s1 = new TimeSeries("Series"); + TimeSeries s2 = (TimeSeries) s1.clone(); + assertTrue(s1 != s2); + assertTrue(s1.getClass() == s2.getClass()); + assertTrue(s1.equals(s2)); + + // test independence + s1.add(new Day(1, 1, 2007), 100.0); + assertFalse(s1.equals(s2)); + } + + /** + * Some checks for the getIndex() method. + */ + @Test + public void testGetIndex() { + TimeSeries series = new TimeSeries("Series", Month.class); + assertEquals(-1, series.getIndex(new Month(1, 2003))); + + series.add(new Month(1, 2003), 45.0); + assertEquals(0, series.getIndex(new Month(1, 2003))); + assertEquals(-1, series.getIndex(new Month(12, 2002))); + assertEquals(-2, series.getIndex(new Month(2, 2003))); + + series.add(new Month(3, 2003), 55.0); + assertEquals(-1, series.getIndex(new Month(12, 2002))); + assertEquals(0, series.getIndex(new Month(1, 2003))); + assertEquals(-2, series.getIndex(new Month(2, 2003))); + assertEquals(1, series.getIndex(new Month(3, 2003))); + assertEquals(-3, series.getIndex(new Month(4, 2003))); + } + + /** + * Some checks for the getDataItem(int) method. + */ + @Test + public void testGetDataItem1() { + TimeSeries series = new TimeSeries("S", Year.class); + + // can't get anything yet...just an exception + boolean pass = false; + try { + /*TimeSeriesDataItem item =*/ series.getDataItem(0); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + + series.add(new Year(2006), 100.0); + TimeSeriesDataItem item = series.getDataItem(0); + assertEquals(new Year(2006), item.getPeriod()); + pass = false; + try { + /*item = */series.getDataItem(-1); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + /*item = */series.getDataItem(1); + } + catch (IndexOutOfBoundsException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getDataItem(RegularTimePeriod) method. + */ + @Test + public void testGetDataItem2() { + TimeSeries series = new TimeSeries("S", Year.class); + assertNull(series.getDataItem(new Year(2006))); + + // try a null argument + boolean pass = false; + try { + /* TimeSeriesDataItem item = */ series.getDataItem(null); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the removeAgedItems() method. + */ + @Test + public void testRemoveAgedItems() { + TimeSeries series = new TimeSeries("Test Series", Year.class); + series.addChangeListener(this); + assertEquals(Long.MAX_VALUE, series.getMaximumItemAge()); + assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount()); + this.gotSeriesChangeEvent = false; + + // test empty series + series.removeAgedItems(true); + assertEquals(0, series.getItemCount()); + assertFalse(this.gotSeriesChangeEvent); + + // test series with one item + series.add(new Year(1999), 1.0); + series.setMaximumItemAge(0); + this.gotSeriesChangeEvent = false; + series.removeAgedItems(true); + assertEquals(1, series.getItemCount()); + assertFalse(this.gotSeriesChangeEvent); + + // test series with two items + series.setMaximumItemAge(10); + series.add(new Year(2001), 2.0); + this.gotSeriesChangeEvent = false; + series.setMaximumItemAge(2); + assertEquals(2, series.getItemCount()); + assertEquals(0, series.getIndex(new Year(1999))); + assertFalse(this.gotSeriesChangeEvent); + series.setMaximumItemAge(1); + assertEquals(1, series.getItemCount()); + assertEquals(0, series.getIndex(new Year(2001))); + assertTrue(this.gotSeriesChangeEvent); + } + + /** + * Some checks for the removeAgedItems(long, boolean) method. + */ + @Test + public void testRemoveAgedItems2() { + long y2006 = 1157087372534L; // milliseconds somewhere in 2006 + TimeSeries series = new TimeSeries("Test Series", Year.class); + series.addChangeListener(this); + assertEquals(Long.MAX_VALUE, series.getMaximumItemAge()); + assertEquals(Integer.MAX_VALUE, series.getMaximumItemCount()); + this.gotSeriesChangeEvent = false; + + // test empty series + series.removeAgedItems(y2006, true); + assertEquals(0, series.getItemCount()); + assertFalse(this.gotSeriesChangeEvent); + + // test a series with 1 item + series.add(new Year(2004), 1.0); + series.setMaximumItemAge(1); + this.gotSeriesChangeEvent = false; + series.removeAgedItems(new Year(2005).getMiddleMillisecond(), true); + assertEquals(1, series.getItemCount()); + assertFalse(this.gotSeriesChangeEvent); + series.removeAgedItems(y2006, true); + assertEquals(0, series.getItemCount()); + assertTrue(this.gotSeriesChangeEvent); + + // test a series with two items + series.setMaximumItemAge(2); + series.add(new Year(2003), 1.0); + series.add(new Year(2005), 2.0); + assertEquals(2, series.getItemCount()); + this.gotSeriesChangeEvent = false; + assertEquals(2, series.getItemCount()); + + series.removeAgedItems(new Year(2005).getMiddleMillisecond(), true); + assertEquals(2, series.getItemCount()); + assertFalse(this.gotSeriesChangeEvent); + series.removeAgedItems(y2006, true); + assertEquals(1, series.getItemCount()); + assertTrue(this.gotSeriesChangeEvent); + } + + /** + * Calling removeAgedItems() on an empty series should not throw any + * exception. + */ + @Test + public void testRemoveAgedItems3() { + TimeSeries s = new TimeSeries("Test"); + boolean pass = true; + try { + s.removeAgedItems(0L, true); + } + catch (Exception e) { + pass = false; + } + assertTrue(pass); + } + + /** + * Check that the item bounds are determined correctly when there is a + * maximum item count. + */ + @Test + public void testRemoveAgedItems4() { + TimeSeries s1 = new TimeSeries("S1"); + s1.setMaximumItemAge(2); + s1.add(new Year(2010), 1.1); + s1.add(new Year(2011), 2.2); + s1.add(new Year(2012), 3.3); + s1.add(new Year(2013), 2.5); + assertEquals(3, s1.getItemCount()); + assertEquals(2.2, s1.getMinY(), EPSILON); + assertEquals(3.3, s1.getMaxY(), EPSILON); + } + + /** + * Check that the item bounds are determined correctly after a call to + * removeAgedItems(). + */ + @Test + public void testRemoveAgedItems5() { + TimeSeries s1 = new TimeSeries("S1"); + s1.setMaximumItemAge(4); + s1.add(new Year(2010), 1.1); + s1.add(new Year(2011), 2.2); + s1.add(new Year(2012), 3.3); + s1.add(new Year(2013), 2.5); + s1.removeAgedItems(new Year(2015).getMiddleMillisecond(), true); + assertEquals(3, s1.getItemCount()); + assertEquals(2.2, s1.getMinY(), EPSILON); + assertEquals(3.3, s1.getMaxY(), EPSILON); + } + + /** + * Some simple checks for the hashCode() method. + */ + @Test + public void testHashCode() { + TimeSeries s1 = new TimeSeries("Test"); + TimeSeries s2 = new TimeSeries("Test"); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + + s1.add(new Day(1, 1, 2007), 500.0); + s2.add(new Day(1, 1, 2007), 500.0); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + + s1.add(new Day(2, 1, 2007), null); + s2.add(new Day(2, 1, 2007), null); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + + s1.add(new Day(5, 1, 2007), 111.0); + s2.add(new Day(5, 1, 2007), 111.0); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + + s1.add(new Day(9, 1, 2007), 1.0); + s2.add(new Day(9, 1, 2007), 1.0); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + } + + /** + * Test for bug report 1864222. + */ + @Test + public void testBug1864222() { + TimeSeries s = new TimeSeries("S"); + s.add(new Day(19, 8, 2005), 1); + s.add(new Day(31, 1, 2006), 1); + boolean pass = true; + try { + s.createCopy(new Day(1, 12, 2005), new Day(18, 1, 2006)); + } + catch (CloneNotSupportedException e) { + pass = false; + } + assertTrue(pass); + } + + /** + * Test for bug report 3446965. + */ + @Test + public void testBug3446965() { + TimeSeries s = new TimeSeries("s"); + s.addOrUpdate(new Year(2011), 100.0); + s.addOrUpdate(new Year(2012), 150.0); + s.addOrUpdate(new Year(2013), 200.0); + s.addOrUpdate(new Year(2012), 250.0); // this line triggers the defect + assertEquals(100.0, s.getMinY(), EPSILON); + assertEquals(250.0, s.getMaxY(), EPSILON); + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the getMinY() method. + */ + @Test + public void testGetMinY() { + TimeSeries s1 = new TimeSeries("S1"); + assertTrue(Double.isNaN(s1.getMinY())); + + s1.add(new Year(2008), 1.1); + assertEquals(1.1, s1.getMinY(), EPSILON); + + s1.add(new Year(2009), 2.2); + assertEquals(1.1, s1.getMinY(), EPSILON); + + s1.add(new Year(2000), 99.9); + assertEquals(1.1, s1.getMinY(), EPSILON); + + s1.add(new Year(2002), -1.1); + assertEquals(-1.1, s1.getMinY(), EPSILON); + + s1.add(new Year(2003), null); + assertEquals(-1.1, s1.getMinY(), EPSILON); + + s1.addOrUpdate(new Year(2002), null); + assertEquals(1.1, s1.getMinY(), EPSILON); + } + + /** + * Some checks for the getMaxY() method. + */ + @Test + public void testGetMaxY() { + TimeSeries s1 = new TimeSeries("S1"); + assertTrue(Double.isNaN(s1.getMaxY())); + + s1.add(new Year(2008), 1.1); + assertEquals(1.1, s1.getMaxY(), EPSILON); + + s1.add(new Year(2009), 2.2); + assertEquals(2.2, s1.getMaxY(), EPSILON); + + s1.add(new Year(2000), 99.9); + assertEquals(99.9, s1.getMaxY(), EPSILON); + + s1.add(new Year(2002), -1.1); + assertEquals(99.9, s1.getMaxY(), EPSILON); + + s1.add(new Year(2003), null); + assertEquals(99.9, s1.getMaxY(), EPSILON); + + s1.addOrUpdate(new Year(2000), null); + assertEquals(2.2, s1.getMaxY(), EPSILON); + } + + /** + * A test for the clear method. + */ + @Test + public void testClear() { + TimeSeries s1 = new TimeSeries("S1"); + s1.add(new Year(2009), 1.1); + s1.add(new Year(2010), 2.2); + + assertEquals(2, s1.getItemCount()); + + s1.clear(); + assertEquals(0, s1.getItemCount()); + assertTrue(Double.isNaN(s1.getMinY())); + assertTrue(Double.isNaN(s1.getMaxY())); + } + + /** + * Check that the item bounds are determined correctly when there is a + * maximum item count and a new value is added. + */ + @Test + public void testAdd() { + TimeSeries s1 = new TimeSeries("S1"); + s1.setMaximumItemCount(2); + s1.add(new Year(2010), 1.1); + s1.add(new Year(2011), 2.2); + s1.add(new Year(2012), 3.3); + assertEquals(2, s1.getItemCount()); + assertEquals(2.2, s1.getMinY(), EPSILON); + assertEquals(3.3, s1.getMaxY(), EPSILON); + } + + /** + * Some checks for the update(RegularTimePeriod...method). + */ + @Test + public void testUpdate_RegularTimePeriod() { + TimeSeries s1 = new TimeSeries("S1"); + s1.add(new Year(2010), 1.1); + s1.add(new Year(2011), 2.2); + s1.add(new Year(2012), 3.3); + s1.update(new Year(2012), 4.4); + assertEquals(4.4, s1.getMaxY(), EPSILON); + s1.update(new Year(2010), 0.5); + assertEquals(0.5, s1.getMinY(), EPSILON); + s1.update(new Year(2012), null); + assertEquals(2.2, s1.getMaxY(), EPSILON); + s1.update(new Year(2010), null); + assertEquals(2.2, s1.getMinY(), EPSILON); + } + + /** + * Create a TimeSeriesDataItem, add it to a TimeSeries. Now, modifying + * the original TimeSeriesDataItem should NOT affect the TimeSeries. + */ + @Test + public void testAdd_TimeSeriesDataItem() { + TimeSeriesDataItem item = new TimeSeriesDataItem(new Year(2009), 1.0); + TimeSeries series = new TimeSeries("S1"); + series.add(item); + assertTrue(item.equals(series.getDataItem(0))); + item.setValue(new Double(99.9)); + assertFalse(item.equals(series.getDataItem(0))); + } + + @Test + public void testSetKey() { + TimeSeries s1 = new TimeSeries("S"); + s1.setKey("S1"); + assertEquals("S1", s1.getKey()); + + TimeSeriesCollection c = new TimeSeriesCollection(); + c.addSeries(s1); + TimeSeries s2 = new TimeSeries("S2"); + c.addSeries(s2); + + // now we should be allowed to change s1's key to anything but "S2" + s1.setKey("OK"); + assertEquals("OK", s1.getKey()); + + try { + s1.setKey("S2"); + fail("Expect an exception here."); + } catch (IllegalArgumentException e) { + // OK + } + + // after s1 is removed from the collection, we should be able to set + // the key to anything we want... + c.removeSeries(s1); + s1.setKey("S2"); + + // check that removing by index also works + s1.setKey("S1"); + c.addSeries(s1); + c.removeSeries(1); + s1.setKey("S2"); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimeTableXYDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimeTableXYDatasetTest.java new file mode 100755 index 0000000..6a274fa --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/TimeTableXYDatasetTest.java @@ -0,0 +1,170 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------- + * TimeTableXYDatasetTests.java + * ---------------------------- + * (C) Copyright 2004-2008, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): Rob Eden; + * + * Changes + * ------- + * 15-Sep-2004 : Version 1 (DG); + * 25-Jul-2007 : Added test for clear() method, by Rob Eden (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * A collection of test cases for the {@link TimeTableXYDataset} class. + */ +public class TimeTableXYDatasetTest { + + private static final double DELTA = 0.0000000001; + + /** + * Some checks for a simple dataset. + */ + @Test + public void testStandard() { + TimeTableXYDataset d = new TimeTableXYDataset(); + d.add(new Year(1999), 1.0, "Series 1"); + assertEquals(d.getItemCount(), 1); + assertEquals(d.getSeriesCount(), 1); + d.add(new Year(2000), 2.0, "Series 2"); + assertEquals(d.getItemCount(), 2); + assertEquals(d.getSeriesCount(), 2); + assertEquals(d.getYValue(0, 0), 1.0, DELTA); + assertTrue(Double.isNaN(d.getYValue(0, 1))); + assertTrue(Double.isNaN(d.getYValue(1, 0))); + assertEquals(d.getYValue(1, 1), 2.0, DELTA); + } + + /** + * Some checks for the getTimePeriod() method. + */ + @Test + public void testGetTimePeriod() { + TimeTableXYDataset d = new TimeTableXYDataset(); + d.add(new Year(1999), 1.0, "Series 1"); + d.add(new Year(1998), 2.0, "Series 1"); + d.add(new Year(1996), 3.0, "Series 1"); + assertEquals(d.getTimePeriod(0), new Year(1996)); + assertEquals(d.getTimePeriod(1), new Year(1998)); + assertEquals(d.getTimePeriod(2), new Year(1999)); + } + + /** + * Some checks for the equals() method. + */ + @Test + public void testEquals() { + TimeTableXYDataset d1 = new TimeTableXYDataset(); + TimeTableXYDataset d2 = new TimeTableXYDataset(); + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + d1.add(new Year(1999), 123.4, "S1"); + assertFalse(d1.equals(d2)); + d2.add(new Year(1999), 123.4, "S1"); + assertTrue(d1.equals(d2)); + + d1.setDomainIsPointsInTime(!d1.getDomainIsPointsInTime()); + assertFalse(d1.equals(d2)); + d2.setDomainIsPointsInTime(!d2.getDomainIsPointsInTime()); + assertTrue(d1.equals(d2)); + + d1 = new TimeTableXYDataset(TimeZone.getTimeZone("GMT")); + d2 = new TimeTableXYDataset(TimeZone.getTimeZone( + "America/Los_Angeles")); + assertFalse(d1.equals(d2)); + } + + /** + * Some checks for cloning. + */ + @Test + public void testClone() { + + TimeTableXYDataset d = new TimeTableXYDataset(); + d.add(new Year(1999), 25.0, "Series"); + + TimeTableXYDataset clone = null; + try { + clone = (TimeTableXYDataset) d.clone(); + } + catch (CloneNotSupportedException e) { + assertTrue(false); + } + assertTrue(clone.equals(d)); + + // now test that the clone is independent of the original + clone.add(new Year(2004), 1.2, "SS"); + assertFalse(clone.equals(d)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + TimeTableXYDataset d1 = new TimeTableXYDataset(); + d1.add(new Year(1999), 123.4, "S1"); + TimeTableXYDataset d2 = (TimeTableXYDataset) + TestUtilities.serialised(d1); + assertTrue(d1.equals(d2)); + } + + /** + * Test clearing data. + */ + @Test + public void testClear() { + TimeTableXYDataset d = new TimeTableXYDataset(); + d.add(new Year(1999), 1.0, "Series 1"); + assertEquals(d.getItemCount(), 1); + assertEquals(d.getSeriesCount(), 1); + d.add(new Year(2000), 2.0, "Series 2"); + + d.clear(); + // Make sure there's nothing left + assertEquals(0, d.getItemCount()); + assertEquals(0, d.getSeriesCount()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/WeekTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/WeekTest.java new file mode 100755 index 0000000..4f43d0c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/WeekTest.java @@ -0,0 +1,518 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * WeekTest.java + * ------------- + * (C) Copyright 2002-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 05-Apr-2002 : Version 1 (DG); + * 26-Jun-2002 : Removed unnecessary imports (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 13-Mar-2003 : Added serialization test (DG); + * 21-Oct-2003 : Added hashCode test (DG); + * 06-Apr-2006 : Added testBug1448828() method (DG); + * 01-Jun-2006 : Added testBug1498805() method (DG); + * 11-Jul-2007 : Fixed bad time zone assumption (DG); + * 28-Aug-2007 : Added test for constructor problem (DG); + * 19-Dec-2007 : Set default locale for tests that are sensitive + * to the locale (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; +import org.junit.Before; +import org.junit.Test; + +/** + * Tests for the {@link Week} class. + */ +public class WeekTest { + + /** A week. */ + private Week w1Y1900; + + /** A week. */ + private Week w2Y1900; + + /** A week. */ + private Week w51Y9999; + + /** A week. */ + private Week w52Y9999; + + /** + * Common test setup. + */ + @Before + public void setUp() { + this.w1Y1900 = new Week(1, 1900); + this.w2Y1900 = new Week(2, 1900); + this.w51Y9999 = new Week(51, 9999); + this.w52Y9999 = new Week(52, 9999); + } + + /** + * Tests the equals method. + */ + @Test + public void testEquals() { + Week w1 = new Week(1, 2002); + Week w2 = new Week(1, 2002); + assertTrue(w1.equals(w2)); + assertTrue(w2.equals(w1)); + + w1 = new Week(2, 2002); + assertFalse(w1.equals(w2)); + w2 = new Week(2, 2002); + assertTrue(w1.equals(w2)); + + w1 = new Week(2, 2003); + assertFalse(w1.equals(w2)); + w2 = new Week(2, 2003); + assertTrue(w1.equals(w2)); + } + + /** + * Request the week before week 1, 1900: it should be null. + */ + @Test + public void testW1Y1900Previous() { + Week previous = (Week) this.w1Y1900.previous(); + assertNull(previous); + } + + /** + * Request the week after week 1, 1900: it should be week 2, 1900. + */ + @Test + public void testW1Y1900Next() { + Week next = (Week) this.w1Y1900.next(); + assertEquals(this.w2Y1900, next); + } + + /** + * Request the week before w52, 9999: it should be week 51, 9999. + */ + @Test + public void testW52Y9999Previous() { + Week previous = (Week) this.w52Y9999.previous(); + assertEquals(this.w51Y9999, previous); + } + + /** + * Request the week after w52, 9999: it should be null. + */ + @Test + public void testW52Y9999Next() { + Week next = (Week) this.w52Y9999.next(); + assertNull(next); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Week w1 = new Week(24, 1999); + Week w2 = (Week) TestUtilities.serialised(w1); + assertEquals(w1, w2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + Week w1 = new Week(2, 2003); + Week w2 = new Week(2, 2003); + assertTrue(w1.equals(w2)); + int h1 = w1.hashCode(); + int h2 = w2.hashCode(); + assertEquals(h1, h2); + } + + /** + * The {@link Week} class is immutable, so should not be {@link Cloneable}. + */ + @Test + public void testNotCloneable() { + Week w = new Week(1, 1999); + assertFalse(w instanceof Cloneable); + } + + /** + * The first week in 2005 should span the range: + * + * TimeZone | Start Millis | End Millis | Start Date | End Date + * -----------------+---------------+---------------+-------------+------------ + * Europe/London | 1104710400000 | 1105315199999 | 3-Jan-2005 | 9-Jan-2005 + * Europe/Paris | 1104706800000 | 1105311599999 | 3-Jan-2005 | 2-Jan-2005 + * America/New_York | 1104037200000 | 1104641999999 | 26-Dec-2004 | 1-Jan-2005 + * + * In London and Paris, Monday is the first day of the week, while in the + * US it is Sunday. + * + * Previously, we were using these values, but see Java Bug ID 4960215: + * + * TimeZone | Start Millis | End Millis | Start Date | End Date + * -----------------+---------------+---------------+-------------+------------ + * Europe/London | 1104105600000 | 1104710399999 | 27-Dec-2004 | 2-Jan-2005 + * Europe/Paris | 1104102000000 | 1104706799999 | 27-Dec-2004 | 2-Jan-2005 + * America/New_York | 1104037200000 | 1104641999999 | 26-Dec-2004 | 1-Jan-2005 + */ + @Test + public void testWeek12005() { + Week w1 = new Week(1, 2005); + Calendar c1 = Calendar.getInstance( + TimeZone.getTimeZone("Europe/London"), Locale.UK); + c1.setMinimalDaysInFirstWeek(4); // see Java Bug ID 4960215 + assertEquals(1104710400000L, w1.getFirstMillisecond(c1)); + assertEquals(1105315199999L, w1.getLastMillisecond(c1)); + Calendar c2 = Calendar.getInstance( + TimeZone.getTimeZone("Europe/Paris"), Locale.FRANCE); + c2.setMinimalDaysInFirstWeek(4); // see Java Bug ID 4960215 + assertEquals(1104706800000L, w1.getFirstMillisecond(c2)); + assertEquals(1105311599999L, w1.getLastMillisecond(c2)); + Calendar c3 = Calendar.getInstance( + TimeZone.getTimeZone("America/New_York"), Locale.US); + assertEquals(1104037200000L, w1.getFirstMillisecond(c3)); + assertEquals(1104641999999L, w1.getLastMillisecond(c3)); + } + + /** + * The 53rd week in 2004 in London and Paris should span the range: + * + * TimeZone | Start Millis | End Millis | Start Date | End Date + * -----------------+---------------+---------------+-------------+------------ + * Europe/London | 1104105600000 | 1104710399999 | 27-Dec-2004 | 02-Jan-2005 + * Europe/Paris | 1104102000000 | 1104706799999 | 27-Dec-2004 | 02-Jan-2005 + * + * The 53rd week in 2005 in New York should span the range: + * + * TimeZone | Start Millis | End Millis | Start Date | End Date + * -----------------+---------------+---------------+-------------+------------ + * America/New_York | 1135486800000 | 1136091599999 | 25-Dec-2005 | 31-Dec-2005 + * + * In London and Paris, Monday is the first day of the week, while in the + * US it is Sunday. + */ + @Test + public void testWeek532005() { + Week w1 = new Week(53, 2004); + Calendar c1 = Calendar.getInstance( + TimeZone.getTimeZone("Europe/London"), Locale.UK); + c1.setMinimalDaysInFirstWeek(4); // see Java Bug ID 4960215 + assertEquals(1104105600000L, w1.getFirstMillisecond(c1)); + assertEquals(1104710399999L, w1.getLastMillisecond(c1)); + Calendar c2 = Calendar.getInstance( + TimeZone.getTimeZone("Europe/Paris"), Locale.FRANCE); + c2.setMinimalDaysInFirstWeek(4); // see Java Bug ID 4960215 + assertEquals(1104102000000L, w1.getFirstMillisecond(c2)); + assertEquals(1104706799999L, w1.getLastMillisecond(c2)); + w1 = new Week(53, 2005); + Calendar c3 = Calendar.getInstance( + TimeZone.getTimeZone("America/New_York"), Locale.US); + assertEquals(1135486800000L, w1.getFirstMillisecond(c3)); + assertEquals(1136091599999L, w1.getLastMillisecond(c3)); + } + + /** + * A test case for bug 1448828. + */ + @Test + public void testBug1448828() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + try { + Week w = new Week(new Date(1136109830000l), + TimeZone.getTimeZone("GMT")); + assertEquals(2005, w.getYearValue()); + assertEquals(52, w.getWeek()); + } + finally { + Locale.setDefault(saved); + } + } + + /** + * A test case for bug 1498805. + */ + @Test + public void testBug1498805() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + try { + TimeZone zone = TimeZone.getTimeZone("GMT"); + GregorianCalendar gc = new GregorianCalendar(zone); + gc.set(2005, Calendar.JANUARY, 1, 12, 0, 0); + Week w = new Week(gc.getTime(), zone); + assertEquals(53, w.getWeek()); + assertEquals(new Year(2004), w.getYear()); + } + finally { + Locale.setDefault(saved); + } + } + + /** + * Some checks for the getFirstMillisecond() method. + */ + @Test + public void testGetFirstMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Week w = new Week(3, 1970); + assertEquals(946800000L, w.getFirstMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithTimeZone() { + Week w = new Week(47, 1950); + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.US); + try { + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-603302400000L, w.getFirstMillisecond(zone)); + } + finally { + Locale.setDefault(saved); + } + + // try null calendar + boolean pass = false; + try { + w.getFirstMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithCalendar() { + Week w = new Week(1, 2001); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(978307200000L, w.getFirstMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + w.getFirstMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond() method. + */ + @Test + public void testGetLastMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Week w = new Week(31, 1970); + assertEquals(18485999999L, w.getLastMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithTimeZone() { + Week w = new Week(2, 1950); + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.US); + try { + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-629913600001L, w.getLastMillisecond(zone)); + } + finally { + Locale.setDefault(saved); + } + + // try null zone + boolean pass = false; + try { + w.getLastMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithCalendar() { + Week w = new Week(52, 2001); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(1009756799999L, w.getLastMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + w.getLastMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getSerialIndex() method. + */ + @Test + public void testGetSerialIndex() { + Week w = new Week(1, 2000); + assertEquals(106001L, w.getSerialIndex()); + w = new Week(1, 1900); + assertEquals(100701L, w.getSerialIndex()); + } + + /** + * Some checks for the testNext() method. + */ + @Test + public void testNext() { + Week w = new Week(12, 2000); + w = (Week) w.next(); + assertEquals(new Year(2000), w.getYear()); + assertEquals(13, w.getWeek()); + w = new Week(53, 9999); + assertNull(w.next()); + } + + /** + * Some checks for the getStart() method. + */ + @Test + public void testGetStart() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.JANUARY, 16, 0, 0, 0); + cal.set(Calendar.MILLISECOND, 0); + Week w = new Week(3, 2006); + assertEquals(cal.getTime(), w.getStart()); + Locale.setDefault(saved); + } + + /** + * Some checks for the getEnd() method. + */ + @Test + public void testGetEnd() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.JANUARY, 8, 23, 59, 59); + cal.set(Calendar.MILLISECOND, 999); + Week w = new Week(1, 2006); + assertEquals(cal.getTime(), w.getEnd()); + Locale.setDefault(saved); + } + + /** + * A test for a problem in constructing a new Week instance. + */ + @Test + public void testConstructor() { + Locale savedLocale = Locale.getDefault(); + TimeZone savedZone = TimeZone.getDefault(); + Locale.setDefault(new Locale("da", "DK")); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/Copenhagen")); + GregorianCalendar cal = (GregorianCalendar) Calendar.getInstance( + TimeZone.getDefault(), Locale.getDefault()); + + // first day of week is monday + assertEquals(Calendar.MONDAY, cal.getFirstDayOfWeek()); + cal.set(2007, Calendar.AUGUST, 26, 1, 0, 0); + cal.set(Calendar.MILLISECOND, 0); + Date t = cal.getTime(); + Week w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen")); + assertEquals(34, w.getWeek()); + + Locale.setDefault(Locale.US); + TimeZone.setDefault(TimeZone.getTimeZone("US/Detroit")); + cal = (GregorianCalendar) Calendar.getInstance(TimeZone.getDefault()); + // first day of week is Sunday + assertEquals(Calendar.SUNDAY, cal.getFirstDayOfWeek()); + cal.set(2007, Calendar.AUGUST, 26, 1, 0, 0); + cal.set(Calendar.MILLISECOND, 0); + + t = cal.getTime(); + w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen")); + assertEquals(35, w.getWeek()); + w = new Week(t, TimeZone.getTimeZone("Europe/Copenhagen"), + new Locale("da", "DK")); + assertEquals(34, w.getWeek()); + + Locale.setDefault(savedLocale); + TimeZone.setDefault(savedZone); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/YearTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/YearTest.java new file mode 100755 index 0000000..75a05a0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/YearTest.java @@ -0,0 +1,411 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * YearTest.java + * ------------- + * (C) Copyright 2001-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 16-Nov-2001 : Version 1 (DG); + * 19-Mar-2002 : Added tests for constructor that uses java.util.Date to ensure + * it is consistent with the getStart() and getEnd() methods (DG); + * 17-Oct-2002 : Fixed errors reported by Checkstyle (DG); + * 13-Mar-2003 : Added serialization test (DG); + * 11-Jan-2005 : Added test for non-clonability (DG); + * 05-Oct-2006 : Added some new tests (DG); + * 11-Jul-2007 : Fixed bad time zone assumption (DG); + * + */ + +package org.jfree.data.time; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + +import java.util.Calendar; +import java.util.Date; +import java.util.GregorianCalendar; +import java.util.Locale; +import java.util.TimeZone; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link Year} class. + */ +public class YearTest { + + /** + * Check that a Year instance is equal to itself. + * + * SourceForge Bug ID: 558850. + */ + @Test + public void testEqualsSelf() { + Year year = new Year(); + assertTrue(year.equals(year)); + } + + /** + * Tests the equals method. + */ + @Test + public void testEquals() { + Year year1 = new Year(2002); + Year year2 = new Year(2002); + assertTrue(year1.equals(year2)); + + year1 = new Year(1999); + assertFalse(year1.equals(year2)); + year2 = new Year(1999); + assertTrue(year1.equals(year2)); + } + + /** + * In GMT, the end of 2001 is java.util.Date(1009843199999L). Use this to + * check the year constructor. + */ + @Test + public void testDateConstructor1() { + + TimeZone zone = TimeZone.getTimeZone("GMT"); + Date d1 = new Date(1009843199999L); + Date d2 = new Date(1009843200000L); + Year y1 = new Year(d1, zone); + Year y2 = new Year(d2, zone); + + assertEquals(2001, y1.getYear()); + assertEquals(1009843199999L, y1.getLastMillisecond(zone)); + + assertEquals(2002, y2.getYear()); + assertEquals(1009843200000L, y2.getFirstMillisecond(zone)); + + } + + /** + * In Los Angeles, the end of 2001 is java.util.Date(1009871999999L). Use + * this to check the year constructor. + */ + @Test + public void testDateConstructor2() { + + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + Year y1 = new Year(new Date(1009871999999L), zone); + Year y2 = new Year(new Date(1009872000000L), zone); + + assertEquals(2001, y1.getYear()); + assertEquals(1009871999999L, y1.getLastMillisecond(zone)); + + assertEquals(2002, y2.getYear()); + assertEquals(1009872000000L, y2.getFirstMillisecond(zone)); + + } + + /** + * Set up a year equal to 1900. Request the previous year, it should be + * null. + */ + @Test + public void testMinuss9999Previous() { + Year current = new Year(-9999); + Year previous = (Year) current.previous(); + assertNull(previous); + } + + /** + * Set up a year equal to 1900. Request the next year, it should be 1901. + */ + @Test + public void test1900Next() { + Year current = new Year(1900); + Year next = (Year) current.next(); + assertEquals(1901, next.getYear()); + } + + /** + * Set up a year equal to 9999. Request the previous year, it should be + * 9998. + */ + @Test + public void test9999Previous() { + Year current = new Year(9999); + Year previous = (Year) current.previous(); + assertEquals(9998, previous.getYear()); + } + + /** + * Set up a year equal to 9999. Request the next year, it should be null. + */ + @Test + public void test9999Next() { + Year current = new Year(9999); + Year next = (Year) current.next(); + assertNull(next); + } + + /** + * Tests the year string parser. + */ + @Test + public void testParseYear() { + + Year year = null; + + // test 1... + try { + year = Year.parseYear("2000"); + } + catch (TimePeriodFormatException e) { + year = new Year(1900); + } + assertEquals(2000, year.getYear()); + + // test 2... + try { + year = Year.parseYear(" 2001 "); + } + catch (TimePeriodFormatException e) { + year = new Year(1900); + } + assertEquals(2001, year.getYear()); + + // test 3... + try { + year = Year.parseYear("99"); + } + catch (TimePeriodFormatException e) { + year = new Year(1900); + } + assertEquals(99, year.getYear()); + + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Year y1 = new Year(1999); + Year y2 = (Year) TestUtilities.serialised(y1); + assertEquals(y1, y2); + } + + /** + * The {@link Year} class is immutable, so should not be {@link Cloneable}. + */ + @Test + public void testNotCloneable() { + Year y = new Year(1999); + assertFalse(y instanceof Cloneable); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + Year y1 = new Year(1988); + Year y2 = new Year(1988); + assertTrue(y1.equals(y2)); + int h1 = y1.hashCode(); + int h2 = y2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Some checks for the getFirstMillisecond() method. + */ + @Test + public void testGetFirstMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Year y = new Year(1970); + // TODO: Check this result... + assertEquals(-3600000L, y.getFirstMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithTimeZone() { + Year y = new Year(1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-631123200000L, y.getFirstMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + y.getFirstMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getFirstMillisecond(TimeZone) method. + */ + @Test + public void testGetFirstMillisecondWithCalendar() { + Year y = new Year(2001); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(978307200000L, y.getFirstMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + y.getFirstMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond() method. + */ + @Test + public void testGetLastMillisecond() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.UK); + TimeZone savedZone = TimeZone.getDefault(); + TimeZone.setDefault(TimeZone.getTimeZone("Europe/London")); + Year y = new Year(1970); + // TODO: Check this result... + assertEquals(31532399999L, y.getLastMillisecond()); + Locale.setDefault(saved); + TimeZone.setDefault(savedZone); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithTimeZone() { + Year y = new Year(1950); + TimeZone zone = TimeZone.getTimeZone("America/Los_Angeles"); + assertEquals(-599587200001L, y.getLastMillisecond(zone)); + + // try null calendar + boolean pass = false; + try { + y.getLastMillisecond((TimeZone) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getLastMillisecond(TimeZone) method. + */ + @Test + public void testGetLastMillisecondWithCalendar() { + Year y = new Year(2001); + GregorianCalendar calendar = new GregorianCalendar(Locale.GERMANY); + calendar.setTimeZone(TimeZone.getTimeZone("Europe/Frankfurt")); + assertEquals(1009843199999L, y.getLastMillisecond(calendar)); + + // try null calendar + boolean pass = false; + try { + y.getLastMillisecond((Calendar) null); + } + catch (NullPointerException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getSerialIndex() method. + */ + @Test + public void testGetSerialIndex() { + Year y = new Year(2000); + assertEquals(2000L, y.getSerialIndex()); + } + + /** + * Some checks for the testNext() method. + */ + @Test + public void testNext() { + Year y = new Year(2000); + y = (Year) y.next(); + assertEquals(2001, y.getYear()); + y = new Year(9999); + assertNull(y.next()); + } + + /** + * Some checks for the getStart() method. + */ + @Test + public void testGetStart() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.JANUARY, 1, 0, 0, 0); + cal.set(Calendar.MILLISECOND, 0); + Year y = new Year(2006); + assertEquals(cal.getTime(), y.getStart()); + Locale.setDefault(saved); + } + + /** + * Some checks for the getEnd() method. + */ + @Test + public void testGetEnd() { + Locale saved = Locale.getDefault(); + Locale.setDefault(Locale.ITALY); + Calendar cal = Calendar.getInstance(Locale.ITALY); + cal.set(2006, Calendar.DECEMBER, 31, 23, 59, 59); + cal.set(Calendar.MILLISECOND, 999); + Year y = new Year(2006); + assertEquals(cal.getTime(), y.getEnd()); + Locale.setDefault(saved); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/ohlc/OHLCItemTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/ohlc/OHLCItemTest.java new file mode 100755 index 0000000..4e3fba3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/ohlc/OHLCItemTest.java @@ -0,0 +1,149 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * OHLCItemTest.java + * ----------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Dec-2006 : Version 1 (DG); + * 23-May-2009 : Added testHashCode() (DG); + * + */ + +package org.jfree.data.time.ohlc; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.time.Year; +import org.junit.Test; + +/** + * Tests for the {@link OHLCItem} class. + */ +public class OHLCItemTest { + + private static final double EPSILON = 0.00000000001; + + /** + * Some checks for the constructor. + */ + @Test + public void testConstructor1() { + OHLCItem item1 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0); + assertEquals(new Year(2006), item1.getPeriod()); + assertEquals(2.0, item1.getOpenValue(), EPSILON); + assertEquals(4.0, item1.getHighValue(), EPSILON); + assertEquals(1.0, item1.getLowValue(), EPSILON); + assertEquals(3.0, item1.getCloseValue(), EPSILON); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + OHLCItem item1 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0); + OHLCItem item2 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0); + assertTrue(item1.equals(item2)); + assertTrue(item2.equals(item1)); + + // period + item1 = new OHLCItem(new Year(2007), 2.0, 4.0, 1.0, 3.0); + assertFalse(item1.equals(item2)); + item2 = new OHLCItem(new Year(2007), 2.0, 4.0, 1.0, 3.0); + assertTrue(item1.equals(item2)); + + // open + item1 = new OHLCItem(new Year(2007), 2.2, 4.0, 1.0, 3.0); + assertFalse(item1.equals(item2)); + item2 = new OHLCItem(new Year(2007), 2.2, 4.0, 1.0, 3.0); + assertTrue(item1.equals(item2)); + + // high + item1 = new OHLCItem(new Year(2007), 2.2, 4.4, 1.0, 3.0); + assertFalse(item1.equals(item2)); + item2 = new OHLCItem(new Year(2007), 2.2, 4.4, 1.0, 3.0); + assertTrue(item1.equals(item2)); + + // low + item1 = new OHLCItem(new Year(2007), 2.2, 4.4, 1.1, 3.0); + assertFalse(item1.equals(item2)); + item2 = new OHLCItem(new Year(2007), 2.2, 4.4, 1.1, 3.0); + assertTrue(item1.equals(item2)); + + // close + item1 = new OHLCItem(new Year(2007), 2.2, 4.4, 1.1, 3.3); + assertFalse(item1.equals(item2)); + item2 = new OHLCItem(new Year(2007), 2.2, 4.4, 1.1, 3.3); + assertTrue(item1.equals(item2)); + } + + /** + * Some checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + OHLCItem item1 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0); + OHLCItem item2 = (OHLCItem) item1.clone(); + assertTrue(item1 != item2); + assertTrue(item1.getClass() == item2.getClass()); + assertTrue(item1.equals(item2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + OHLCItem item1 = new OHLCItem(new Year(2006), 2.0, 4.0, 1.0, 3.0); + OHLCItem item2 = (OHLCItem) TestUtilities.serialised(item1); + assertEquals(item1, item2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + OHLCItem i1 = new OHLCItem(new Year(2009), 2.0, 4.0, 1.0, 3.0); + OHLCItem i2 = new OHLCItem(new Year(2009), 2.0, 4.0, 1.0, 3.0); + assertTrue(i1.equals(i2)); + int h1 = i1.hashCode(); + int h2 = i2.hashCode(); + assertEquals(h1, h2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/ohlc/OHLCSeriesCollectionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/ohlc/OHLCSeriesCollectionTest.java new file mode 100755 index 0000000..9173eb6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/ohlc/OHLCSeriesCollectionTest.java @@ -0,0 +1,248 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------- + * OHLCSeriesCollectionTest.java + * ----------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Dec-2006 : Version 1 (DG); + * 10-Jul-2008 : Updated testEquals() method (DG); + * 26-Jun-2009 : Added tests for removeSeries() methods (DG); + * + */ + +package org.jfree.data.time.ohlc; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.DatasetChangeEvent; +import org.jfree.data.general.DatasetChangeListener; +import org.jfree.data.time.TimePeriodAnchor; +import org.jfree.data.time.Year; +import org.junit.Test; + +/** + * Tests for the {@link OHLCSeriesCollectionTests} class. + */ +public class OHLCSeriesCollectionTest implements DatasetChangeListener { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + OHLCSeriesCollection c1 = new OHLCSeriesCollection(); + OHLCSeriesCollection c2 = new OHLCSeriesCollection(); + assertEquals(c1, c2); + + // add a series + OHLCSeries s1 = new OHLCSeries("Series"); + s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3); + c1.addSeries(s1); + assertFalse(c1.equals(c2)); + OHLCSeries s2 = new OHLCSeries("Series"); + s2.add(new Year(2006), 1.0, 1.1, 1.2, 1.3); + c2.addSeries(s2); + assertTrue(c1.equals(c2)); + + // add an empty series + c1.addSeries(new OHLCSeries("Empty Series")); + assertFalse(c1.equals(c2)); + c2.addSeries(new OHLCSeries("Empty Series")); + assertTrue(c1.equals(c2)); + + c1.setXPosition(TimePeriodAnchor.END); + assertFalse(c1.equals(c2)); + c2.setXPosition(TimePeriodAnchor.END); + assertTrue(c1.equals(c2)); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + OHLCSeriesCollection c1 = new OHLCSeriesCollection(); + OHLCSeries s1 = new OHLCSeries("Series"); + s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3); + c1.addSeries(s1); + OHLCSeriesCollection c2 = (OHLCSeriesCollection) c1.clone(); + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + + // check independence + s1.setDescription("XYZ"); + assertFalse(c1.equals(c2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + OHLCSeriesCollection c1 = new OHLCSeriesCollection(); + OHLCSeries s1 = new OHLCSeries("Series"); + s1.add(new Year(2006), 1.0, 1.1, 1.2, 1.3); + c1.addSeries(s1); + OHLCSeriesCollection c2 = (OHLCSeriesCollection) + TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + + /** + * A test for bug report 1170825 (originally affected XYSeriesCollection, + * this test is just copied over). + */ + @Test + public void test1170825() { + OHLCSeries s1 = new OHLCSeries("Series1"); + OHLCSeriesCollection dataset = new OHLCSeriesCollection(); + dataset.addSeries(s1); + try { + /* XYSeries s = */ dataset.getSeries(1); + } + catch (IllegalArgumentException e) { + // correct outcome + } + catch (IndexOutOfBoundsException e) { + assertTrue(false); // wrong outcome + } + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + OHLCSeriesCollection c1 = new OHLCSeriesCollection(); + OHLCSeries s1 = new OHLCSeries("S"); + s1.add(new Year(2009), 1.0, 4.0, 0.5, 2.0); + c1.addSeries(s1); + OHLCSeriesCollection c2 = new OHLCSeriesCollection(); + OHLCSeries s2 = new OHLCSeries("S"); + s2.add(new Year(2009), 1.0, 4.0, 0.5, 2.0); + c2.addSeries(s2); + assertTrue(c1.equals(c2)); + int h1 = c1.hashCode(); + int h2 = c2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Some checks for the {@link OHLCSeriesCollection#removeSeries(int)} + * method. + */ + @Test + public void testRemoveSeries_int() { + OHLCSeriesCollection c1 = new OHLCSeriesCollection(); + OHLCSeries s1 = new OHLCSeries("Series 1"); + OHLCSeries s2 = new OHLCSeries("Series 2"); + OHLCSeries s3 = new OHLCSeries("Series 3"); + OHLCSeries s4 = new OHLCSeries("Series 4"); + c1.addSeries(s1); + c1.addSeries(s2); + c1.addSeries(s3); + c1.addSeries(s4); + c1.removeSeries(2); + assertTrue(c1.getSeries(2).equals(s4)); + c1.removeSeries(0); + assertTrue(c1.getSeries(0).equals(s2)); + assertEquals(2, c1.getSeriesCount()); + } + + /** + * Some checks for the + * {@link OHLCSeriesCollection#removeSeries(OHLCSeries)} method. + */ + @Test + public void testRemoveSeries() { + OHLCSeriesCollection c1 = new OHLCSeriesCollection(); + OHLCSeries s1 = new OHLCSeries("Series 1"); + OHLCSeries s2 = new OHLCSeries("Series 2"); + OHLCSeries s3 = new OHLCSeries("Series 3"); + OHLCSeries s4 = new OHLCSeries("Series 4"); + c1.addSeries(s1); + c1.addSeries(s2); + c1.addSeries(s3); + c1.addSeries(s4); + c1.removeSeries(s3); + assertTrue(c1.getSeries(2).equals(s4)); + c1.removeSeries(s1); + assertTrue(c1.getSeries(0).equals(s2)); + assertEquals(2, c1.getSeriesCount()); + } + + /** + * A simple check for the removeAllSeries() method. + */ + @Test + public void testRemoveAllSeries() { + OHLCSeriesCollection c1 = new OHLCSeriesCollection(); + c1.addChangeListener(this); + + // there should be no change event when clearing an empty series + this.lastEvent = null; + c1.removeAllSeries(); + assertNull(this.lastEvent); + + OHLCSeries s1 = new OHLCSeries("Series 1"); + OHLCSeries s2 = new OHLCSeries("Series 2"); + c1.addSeries(s1); + c1.addSeries(s2); + c1.removeAllSeries(); + assertEquals(0, c1.getSeriesCount()); + assertNotNull(this.lastEvent); + this.lastEvent = null; // clean up + } + + /** The last received event. */ + private DatasetChangeEvent lastEvent; + + /** + * Receives dataset change events. + * + * @param event the event. + */ + @Override + public void datasetChanged(DatasetChangeEvent event) { + this.lastEvent = event; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/ohlc/OHLCSeriesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/ohlc/OHLCSeriesTest.java new file mode 100755 index 0000000..770e533 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/ohlc/OHLCSeriesTest.java @@ -0,0 +1,262 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * OHLCSeriesTest.java + * ------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Dec-2006 : Version 1, based on XYSeriesTests (DG); + * 27-Nov-2007 : Added testClear() method (DG); + * 23-May-2009 : Added testHashCode() (DG); + * 17-Jun-2009 : Added testRemove_int() (DG); + * + */ + +package org.jfree.data.time.ohlc; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.data.general.SeriesChangeListener; +import org.jfree.data.general.SeriesException; +import org.jfree.data.time.Year; +import org.junit.Test; + +/** + * Tests for the {@link OHLCSeries} class. + */ +public class OHLCSeriesTest implements SeriesChangeListener { + + SeriesChangeEvent lastEvent; + + /** + * Records a change event. + * + * @param event the event. + */ + @Override + public void seriesChanged(SeriesChangeEvent event) { + this.lastEvent = event; + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + OHLCSeries s1 = new OHLCSeries("s1"); + OHLCSeries s2 = new OHLCSeries("s1"); + assertTrue(s1.equals(s2)); + + // seriesKey + s1 = new OHLCSeries("s2"); + assertFalse(s1.equals(s2)); + s2 = new OHLCSeries("s2"); + assertTrue(s1.equals(s2)); + + // add a value + s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0); + assertFalse(s1.equals(s2)); + s2.add(new Year(2006), 2.0, 4.0, 1.0, 3.0); + assertTrue(s2.equals(s1)); + + // add another value + s1.add(new Year(2008), 2.0, 4.0, 1.0, 3.0); + assertFalse(s1.equals(s2)); + s2.add(new Year(2008), 2.0, 4.0, 1.0, 3.0); + assertTrue(s2.equals(s1)); + + // remove a value + s1.remove(new Year(2008)); + assertFalse(s1.equals(s2)); + s2.remove(new Year(2008)); + assertTrue(s2.equals(s1)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + OHLCSeries s1 = new OHLCSeries("Test"); + s1.add(new Year(2009), 1.0, 3.0, 2.0, 1.4); + OHLCSeries s2 = new OHLCSeries("Test"); + s2.add(new Year(2009), 1.0, 3.0, 2.0, 1.4); + assertTrue(s1.equals(s2)); + int h1 = s1.hashCode(); + int h2 = s2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + OHLCSeries s1 = new OHLCSeries("s1"); + s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0); + OHLCSeries s2 = (OHLCSeries) s1.clone(); + assertTrue(s1 != s2); + assertTrue(s1.getClass() == s2.getClass()); + assertTrue(s1.equals(s2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + OHLCSeries s1 = new OHLCSeries("s1"); + s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0); + OHLCSeries s2 = (OHLCSeries) TestUtilities.serialised(s1); + assertEquals(s1, s2); + } + + /** + * Simple test for the indexOf() method. + */ + @Test + public void testIndexOf() { + OHLCSeries s1 = new OHLCSeries("s1"); + s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0); + s1.add(new Year(2011), 2.0, 4.0, 1.0, 3.0); + s1.add(new Year(2010), 2.0, 4.0, 1.0, 3.0); + assertEquals(0, s1.indexOf(new Year(2006))); + assertEquals(1, s1.indexOf(new Year(2010))); + assertEquals(2, s1.indexOf(new Year(2011))); + } + + /** + * Simple test for the remove() method. + */ + @Test + public void testRemove() { + OHLCSeries s1 = new OHLCSeries("s1"); + s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0); + s1.add(new Year(2011), 2.1, 4.1, 1.1, 3.1); + s1.add(new Year(2010), 2.2, 4.2, 1.2, 3.2); + assertEquals(3, s1.getItemCount()); + + s1.remove(new Year(2010)); + assertEquals(new Year(2011), s1.getPeriod(1)); + + s1.remove(new Year(2006)); + assertEquals(new Year(2011), s1.getPeriod(0)); + } + + /** + * A check for the remove(int) method. + */ + @Test + public void testRemove_int() { + OHLCSeries s1 = new OHLCSeries("s1"); + s1.add(new Year(2006), 2.0, 4.0, 1.0, 3.0); + s1.add(new Year(2011), 2.1, 4.1, 1.1, 3.1); + s1.add(new Year(2010), 2.2, 4.2, 1.2, 3.2); + assertEquals(3, s1.getItemCount()); + + s1.remove(s1.getItemCount() - 1); + assertEquals(2, s1.getItemCount()); + assertEquals(new Year(2010), s1.getPeriod(1)); + } + + /** + * If you add a duplicate period, an exception should be thrown. + */ + @Test + public void testAdditionOfDuplicatePeriod() { + OHLCSeries s1 = new OHLCSeries("s1"); + s1.add(new Year(2006), 1.0, 1.0, 1.0, 1.0); + boolean pass = false; + try { + s1.add(new Year(2006), 1.0, 1.0, 1.0, 1.0); + } + catch (SeriesException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * A simple check that the maximumItemCount attribute is working. + */ + @Test + public void testSetMaximumItemCount() { + OHLCSeries s1 = new OHLCSeries("s1"); + assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); + s1.setMaximumItemCount(2); + assertEquals(2, s1.getMaximumItemCount()); + s1.add(new Year(2006), 1.0, 1.1, 1.1, 1.1); + s1.add(new Year(2007), 2.0, 2.2, 2.2, 2.2); + s1.add(new Year(2008), 3.0, 3.3, 3.3, 3.3); + assertEquals(new Year(2007), s1.getPeriod(0)); + assertEquals(new Year(2008), s1.getPeriod(1)); + } + + /** + * Check that the maximum item count can be applied retrospectively. + */ + @Test + public void testSetMaximumItemCount2() { + OHLCSeries s1 = new OHLCSeries("s1"); + s1.add(new Year(2006), 1.0, 1.1, 1.1, 1.1); + s1.add(new Year(2007), 2.0, 2.2, 2.2, 2.2); + s1.add(new Year(2008), 3.0, 3.3, 3.3, 3.3); + s1.setMaximumItemCount(2); + assertEquals(new Year(2007), s1.getPeriod(0)); + assertEquals(new Year(2008), s1.getPeriod(1)); + } + + /** + * Some checks for the clear() method. + */ + @Test + public void testClear() { + OHLCSeries s1 = new OHLCSeries("S1"); + s1.addChangeListener(this); + s1.clear(); + assertNull(this.lastEvent); + assertTrue(s1.isEmpty()); + s1.add(new Year(2006), 1.0, 1.1, 1.1, 1.1); + assertFalse(s1.isEmpty()); + s1.clear(); + assertNotNull(this.lastEvent); + assertTrue(s1.isEmpty()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/ohlc/OHLCTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/ohlc/OHLCTest.java new file mode 100755 index 0000000..b10499b --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/ohlc/OHLCTest.java @@ -0,0 +1,118 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------- + * OHLCTest.java + * ------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 04-Dec-2006 : Version 1 (DG); + * 23-May-2009 : Added testHashCode() (DG); + * + */ + +package org.jfree.data.time.ohlc; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link OHLC} class. + */ +public class OHLCTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + OHLC i1 = new OHLC(2.0, 4.0, 1.0, 3.0); + OHLC i2 = new OHLC(2.0, 4.0, 1.0, 3.0); + assertEquals(i1, i2); + + i1 = new OHLC(2.2, 4.0, 1.0, 3.0); + assertFalse(i1.equals(i2)); + i2 = new OHLC(2.2, 4.0, 1.0, 3.0); + assertTrue(i1.equals(i2)); + + i1 = new OHLC(2.2, 4.4, 1.0, 3.0); + assertFalse(i1.equals(i2)); + i2 = new OHLC(2.2, 4.4, 1.0, 3.0); + assertTrue(i1.equals(i2)); + + i1 = new OHLC(2.2, 4.4, 1.1, 3.0); + assertFalse(i1.equals(i2)); + i2 = new OHLC(2.2, 4.4, 1.1, 3.0); + assertTrue(i1.equals(i2)); + + i1 = new OHLC(2.2, 4.4, 1.1, 3.3); + assertFalse(i1.equals(i2)); + i2 = new OHLC(2.2, 4.4, 1.1, 3.3); + assertTrue(i1.equals(i2)); + } + + /** + * This class is immutable. + */ + @Test + public void testCloning() { + OHLC i1 = new OHLC(2.0, 4.0, 1.0, 3.0); + assertFalse(i1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + OHLC i1 = new OHLC(2.0, 4.0, 1.0, 3.0); + OHLC i2 = (OHLC) TestUtilities.serialised(i1); + assertEquals(i1, i2); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + OHLC i1 = new OHLC(2.0, 4.0, 1.0, 3.0); + OHLC i2 = new OHLC(2.0, 4.0, 1.0, 3.0); + assertTrue(i1.equals(i2)); + int h1 = i1.hashCode(); + int h2 = i2.hashCode(); + assertEquals(h1, h2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/package.html b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/package.html new file mode 100755 index 0000000..08924b5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/time/package.html @@ -0,0 +1,6 @@ + + + +JUnit tests. + + diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/CategoryTableXYDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/CategoryTableXYDatasetTest.java new file mode 100755 index 0000000..0cffd79 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/CategoryTableXYDatasetTest.java @@ -0,0 +1,195 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * CategoryTableXYDatasetTest.java + * ------------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 06-Oct-2005 : Version 1 (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link CategoryTableXYDataset} class. + */ +public class CategoryTableXYDatasetTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + CategoryTableXYDataset d1 = new CategoryTableXYDataset(); + d1.add(1.0, 1.1, "Series 1"); + d1.add(2.0, 2.2, "Series 1"); + + CategoryTableXYDataset d2 = new CategoryTableXYDataset(); + d2.add(1.0, 1.1, "Series 1"); + d2.add(2.0, 2.2, "Series 1"); + + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + d1.add(3.0, 3.3, "Series 1"); + assertFalse(d1.equals(d2)); + + d2.add(3.0, 3.3, "Series 1"); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + CategoryTableXYDataset d1 = new CategoryTableXYDataset(); + d1.add(1.0, 1.1, "Series 1"); + d1.add(2.0, 2.2, "Series 1"); + + CategoryTableXYDataset d2 = (CategoryTableXYDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + d1.add(3.0, 3.3, "Series 1"); + assertFalse(d1.equals(d2)); + d2.add(3.0, 3.3, "Series 1"); + assertTrue(d1.equals(d2)); + + d1.setIntervalPositionFactor(0.33); + assertFalse(d1.equals(d2)); + d2.setIntervalPositionFactor(0.33); + assertTrue(d1.equals(d2)); + } + + /** + * Another check for cloning - making sure it works for a customised + * interval delegate. + */ + @Test + public void testCloning2() throws CloneNotSupportedException { + CategoryTableXYDataset d1 = new CategoryTableXYDataset(); + d1.add(1.0, 1.1, "Series 1"); + d1.add(2.0, 2.2, "Series 1"); + d1.setIntervalWidth(1.23); + + CategoryTableXYDataset d2 = (CategoryTableXYDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + d1.add(3.0, 3.3, "Series 1"); + assertFalse(d1.equals(d2)); + d2.add(3.0, 3.3, "Series 1"); + assertTrue(d1.equals(d2)); + + d1.setIntervalPositionFactor(0.33); + assertFalse(d1.equals(d2)); + d2.setIntervalPositionFactor(0.33); + assertTrue(d1.equals(d2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + CategoryTableXYDataset d1 = new CategoryTableXYDataset(); + assertTrue(d1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + CategoryTableXYDataset d1 = new CategoryTableXYDataset(); + d1.add(1.0, 1.1, "Series 1"); + d1.add(2.0, 2.2, "Series 1"); + CategoryTableXYDataset d2 = (CategoryTableXYDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + private static final double EPSILON = 0.0000000001; + + /** + * This is a test for bug 1312066 - adding a new series should trigger a + * recalculation of the interval width, if it is being automatically + * calculated. + */ + @Test + public void testAddSeries() { + CategoryTableXYDataset d1 = new CategoryTableXYDataset(); + d1.setAutoWidth(true); + d1.add(3.0, 1.1, "Series 1"); + d1.add(7.0, 2.2, "Series 1"); + assertEquals(3.0, d1.getXValue(0, 0), EPSILON); + assertEquals(7.0, d1.getXValue(0, 1), EPSILON); + assertEquals(1.0, d1.getStartXValue(0, 0), EPSILON); + assertEquals(5.0, d1.getStartXValue(0, 1), EPSILON); + assertEquals(5.0, d1.getEndXValue(0, 0), EPSILON); + assertEquals(9.0, d1.getEndXValue(0, 1), EPSILON); + + // now add some more data + d1.add(7.5, 1.1, "Series 2"); + d1.add(9.0, 2.2, "Series 2"); + + assertEquals(3.0, d1.getXValue(1, 0), EPSILON); + assertEquals(7.0, d1.getXValue(1, 1), EPSILON); + assertEquals(7.5, d1.getXValue(1, 2), EPSILON); + assertEquals(9.0, d1.getXValue(1, 3), EPSILON); + + assertEquals(7.25, d1.getStartXValue(1, 2), EPSILON); + assertEquals(8.75, d1.getStartXValue(1, 3), EPSILON); + assertEquals(7.75, d1.getEndXValue(1, 2), EPSILON); + assertEquals(9.25, d1.getEndXValue(1, 3), EPSILON); + + // and check the first series too... + assertEquals(2.75, d1.getStartXValue(0, 0), EPSILON); + assertEquals(6.75, d1.getStartXValue(0, 1), EPSILON); + assertEquals(3.25, d1.getEndXValue(0, 0), EPSILON); + assertEquals(7.25, d1.getEndXValue(0, 1), EPSILON); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultHighLowDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultHighLowDatasetTest.java new file mode 100755 index 0000000..1b594b6 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultHighLowDatasetTest.java @@ -0,0 +1,187 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * DefaultHighLowDatasetTest.java + * ------------------------------ + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 28-Nov-2006 : Version 1 (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import java.util.Date; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link DefaultHighLowDataset} class. + */ +public class DefaultHighLowDatasetTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1", + new Date[0], new double[0], new double[0], new double[0], + new double[0], new double[0]); + DefaultHighLowDataset d2 = new DefaultHighLowDataset("Series 1", + new Date[0], new double[0], new double[0], new double[0], + new double[0], new double[0]); + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + d1 = new DefaultHighLowDataset("Series 2", + new Date[0], new double[0], new double[0], new double[0], + new double[0], new double[0]); + assertFalse(d1.equals(d2)); + d2 = new DefaultHighLowDataset("Series 2", + new Date[0], new double[0], new double[0], new double[0], + new double[0], new double[0]); + assertTrue(d1.equals(d2)); + + d1 = new DefaultHighLowDataset("Series 2", + new Date[] {new Date(123L)}, new double[1], new double[1], + new double[1], new double[1], new double[1]); + assertFalse(d1.equals(d2)); + d2 = new DefaultHighLowDataset("Series 2", + new Date[] {new Date(123L)}, new double[1], new double[1], + new double[1], new double[1], new double[1]); + assertTrue(d1.equals(d2)); + + d1 = new DefaultHighLowDataset("Series 2", + new Date[] {new Date(123L)}, new double[] {1.2}, new double[1], + new double[1], new double[1], new double[1]); + assertFalse(d1.equals(d2)); + d2 = new DefaultHighLowDataset("Series 2", + new Date[] {new Date(123L)}, new double[] {1.2}, new double[1], + new double[1], new double[1], new double[1]); + assertTrue(d1.equals(d2)); + + d1 = new DefaultHighLowDataset("Series 2", + new Date[] {new Date(123L)}, new double[] {1.2}, + new double[] {3.4}, new double[1], new double[1], + new double[1]); + assertFalse(d1.equals(d2)); + d2 = new DefaultHighLowDataset("Series 2", + new Date[] {new Date(123L)}, new double[] {1.2}, + new double[] {3.4}, new double[1], new double[1], + new double[1]); + assertTrue(d1.equals(d2)); + + d1 = new DefaultHighLowDataset("Series 2", + new Date[] {new Date(123L)}, new double[] {1.2}, + new double[] {3.4}, new double[] {5.6}, new double[1], + new double[1]); + assertFalse(d1.equals(d2)); + d2 = new DefaultHighLowDataset("Series 2", + new Date[] {new Date(123L)}, new double[] {1.2}, + new double[] {3.4}, new double[] {5.6}, new double[1], + new double[1]); + assertTrue(d1.equals(d2)); + + d1 = new DefaultHighLowDataset("Series 2", + new Date[] {new Date(123L)}, new double[] {1.2}, + new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, + new double[1]); + assertFalse(d1.equals(d2)); + d2 = new DefaultHighLowDataset("Series 2", + new Date[] {new Date(123L)}, new double[] {1.2}, + new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, + new double[1]); + assertTrue(d1.equals(d2)); + + d1 = new DefaultHighLowDataset("Series 2", + new Date[] {new Date(123L)}, new double[] {1.2}, + new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, + new double[] {99.9}); + assertFalse(d1.equals(d2)); + d2 = new DefaultHighLowDataset("Series 2", + new Date[] {new Date(123L)}, new double[] {1.2}, + new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, + new double[] {99.9}); + assertTrue(d1.equals(d2)); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1", + new Date[] {new Date(123L)}, new double[] {1.2}, + new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, + new double[] {99.9}); + DefaultHighLowDataset d2 = (DefaultHighLowDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1", + new Date[0], new double[0], new double[0], new double[0], + new double[0], new double[0]); + assertTrue(d1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultHighLowDataset d1 = new DefaultHighLowDataset("Series 1", + new Date[] {new Date(123L)}, new double[] {1.2}, + new double[] {3.4}, new double[] {5.6}, new double[] {7.8}, + new double[] {99.9}); + DefaultHighLowDataset d2 = (DefaultHighLowDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultIntervalXYDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultIntervalXYDatasetTest.java new file mode 100755 index 0000000..b0d9629 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultIntervalXYDatasetTest.java @@ -0,0 +1,362 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------------- + * DefaultIntervalXYDatasetTest.java + * --------------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Oct-2006 : Version 1 (DG); + * 02-Nov-2006 : Added testAddSeries() method (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Some tests for the {@link DefaultIntervalXYDataset} class. + */ +public class DefaultIntervalXYDatasetTest { + + /** + * Some checks for the getSeriesCount() method. + */ + @Test + public void testGetSeriesCount() { + DefaultIntervalXYDataset d = new DefaultIntervalXYDataset(); + assertEquals(0, d.getSeriesCount()); + d = createSampleDataset1(); + assertEquals(2, d.getSeriesCount()); + } + + /** + * Some checks for the getSeriesKey(int) method. + */ + @Test + public void testGetSeriesKey() { + DefaultIntervalXYDataset d = createSampleDataset1(); + assertEquals("S1", d.getSeriesKey(0)); + assertEquals("S2", d.getSeriesKey(1)); + + // check for series key out of bounds + boolean pass = false; + try { + /*Comparable k =*/ d.getSeriesKey(-1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + /*Comparable k =*/ d.getSeriesKey(2); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the getItemCount() method. + */ + @Test + public void testGetItemCount() { + DefaultIntervalXYDataset d = createSampleDataset1(); + assertEquals(3, d.getItemCount(0)); + assertEquals(3, d.getItemCount(1)); + + // try an index out of bounds + boolean pass = false; + try { + d.getItemCount(2); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the getXValue() method. + */ + @Test + public void testGetXValue() { + DefaultIntervalXYDataset d = createSampleDataset1(); + assertEquals(1.0, d.getXValue(0, 0), EPSILON); + assertEquals(2.0, d.getXValue(0, 1), EPSILON); + assertEquals(3.0, d.getXValue(0, 2), EPSILON); + assertEquals(11.0, d.getXValue(1, 0), EPSILON); + assertEquals(12.0, d.getXValue(1, 1), EPSILON); + assertEquals(13.0, d.getXValue(1, 2), EPSILON); + } + + /** + * Some checks for the getYValue() method. + */ + @Test + public void testGetYValue() { + DefaultIntervalXYDataset d = createSampleDataset1(); + assertEquals(4.0, d.getYValue(0, 0), EPSILON); + assertEquals(5.0, d.getYValue(0, 1), EPSILON); + assertEquals(6.0, d.getYValue(0, 2), EPSILON); + assertEquals(14.0, d.getYValue(1, 0), EPSILON); + assertEquals(15.0, d.getYValue(1, 1), EPSILON); + assertEquals(16.0, d.getYValue(1, 2), EPSILON); + } + + /** + * Some checks for the getStartXValue() method. + */ + @Test + public void testGetStartXValue() { + DefaultIntervalXYDataset d = createSampleDataset1(); + assertEquals(0.9, d.getStartXValue(0, 0), EPSILON); + assertEquals(1.9, d.getStartXValue(0, 1), EPSILON); + assertEquals(2.9, d.getStartXValue(0, 2), EPSILON); + assertEquals(10.9, d.getStartXValue(1, 0), EPSILON); + assertEquals(11.9, d.getStartXValue(1, 1), EPSILON); + assertEquals(12.9, d.getStartXValue(1, 2), EPSILON); + } + + /** + * Some checks for the getEndXValue() method. + */ + @Test + public void testGetEndXValue() { + DefaultIntervalXYDataset d = createSampleDataset1(); + assertEquals(1.1, d.getEndXValue(0, 0), EPSILON); + assertEquals(2.1, d.getEndXValue(0, 1), EPSILON); + assertEquals(3.1, d.getEndXValue(0, 2), EPSILON); + assertEquals(11.1, d.getEndXValue(1, 0), EPSILON); + assertEquals(12.1, d.getEndXValue(1, 1), EPSILON); + assertEquals(13.1, d.getEndXValue(1, 2), EPSILON); + } + + /** + * Some checks for the getStartYValue() method. + */ + @Test + public void testGetStartYValue() { + DefaultIntervalXYDataset d = createSampleDataset1(); + assertEquals(1.09, d.getStartYValue(0, 0), EPSILON); + assertEquals(2.09, d.getStartYValue(0, 1), EPSILON); + assertEquals(3.09, d.getStartYValue(0, 2), EPSILON); + assertEquals(11.09, d.getStartYValue(1, 0), EPSILON); + assertEquals(12.09, d.getStartYValue(1, 1), EPSILON); + assertEquals(13.09, d.getStartYValue(1, 2), EPSILON); + } + + /** + * Some checks for the getEndYValue() method. + */ + @Test + public void testGetEndYValue() { + DefaultIntervalXYDataset d = createSampleDataset1(); + assertEquals(1.11, d.getEndYValue(0, 0), EPSILON); + assertEquals(2.11, d.getEndYValue(0, 1), EPSILON); + assertEquals(3.11, d.getEndYValue(0, 2), EPSILON); + assertEquals(11.11, d.getEndYValue(1, 0), EPSILON); + assertEquals(12.11, d.getEndYValue(1, 1), EPSILON); + assertEquals(13.11, d.getEndYValue(1, 2), EPSILON); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DefaultIntervalXYDataset d1 = new DefaultIntervalXYDataset(); + DefaultIntervalXYDataset d2 = new DefaultIntervalXYDataset(); + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + d1 = createSampleDataset1(); + assertFalse(d1.equals(d2)); + d2 = createSampleDataset1(); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultIntervalXYDataset d1 = new DefaultIntervalXYDataset(); + DefaultIntervalXYDataset d2 = (DefaultIntervalXYDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // try a dataset with some content... + d1 = createSampleDataset1(); + d2 = (DefaultIntervalXYDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + } + + /** + * Another test for cloning. + */ + @Test + public void testCloning2() throws CloneNotSupportedException { + DefaultIntervalXYDataset d1 = new DefaultIntervalXYDataset(); + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] x1Start = new double[] {0.9, 1.9, 2.9}; + double[] x1End = new double[] {1.1, 2.1, 3.1}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] y1Start = new double[] {1.09, 2.09, 3.09}; + double[] y1End = new double[] {1.11, 2.11, 3.11}; + double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, + y1End}; + d1.addSeries("S1", data1); + DefaultIntervalXYDataset d2 = (DefaultIntervalXYDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // check independence + x1[0] = 111.1; + assertFalse(d1.equals(d2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + DefaultIntervalXYDataset d1 = new DefaultIntervalXYDataset(); + assertTrue(d1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultIntervalXYDataset d1 = new DefaultIntervalXYDataset(); + DefaultIntervalXYDataset d2 = (DefaultIntervalXYDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + + // try a dataset with some content... + d1 = createSampleDataset1(); + d2 = (DefaultIntervalXYDataset) TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + /** + * Some checks for the indexOf(Comparable) method. + */ + @Test + public void testIndexOf() { + DefaultIntervalXYDataset d = createSampleDataset1(); + assertEquals(0, d.indexOf("S1")); + assertEquals(1, d.indexOf("S2")); + assertEquals(-1, d.indexOf("Green Eggs and Ham")); + assertEquals(-1, d.indexOf(null)); + } + + /** + * Some tests for the addSeries() method. + */ + @Test + public void testAddSeries() { + DefaultIntervalXYDataset d = new DefaultIntervalXYDataset(); + d.addSeries("S1", new double[][] {{1.0}, {0.5}, {1.5}, {2.0}, {2.5}, + {1.5}}); + assertEquals(1, d.getSeriesCount()); + assertEquals("S1", d.getSeriesKey(0)); + + // check that adding a series will overwrite the old series + d.addSeries("S1", new double[][] {{1.1}, {0.6}, {1.6}, {2.1}, {2.6}, + {1.6}}); + assertEquals(1, d.getSeriesCount()); + assertEquals(2.1, d.getYValue(0, 0), EPSILON); + + // check null key + boolean pass = false; + try + { + d.addSeries(null, new double[][] {{1.1}, {0.6}, {1.6}, {2.1}, {2.6}, + {1.6}}); + } + catch (IllegalArgumentException e) + { + pass = true; + } + assertTrue(pass); + } + + /** + * Creates a sample dataset for testing. + * + * @return A sample dataset. + */ + public DefaultIntervalXYDataset createSampleDataset1() { + DefaultIntervalXYDataset d = new DefaultIntervalXYDataset(); + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] x1Start = new double[] {0.9, 1.9, 2.9}; + double[] x1End = new double[] {1.1, 2.1, 3.1}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] y1Start = new double[] {1.09, 2.09, 3.09}; + double[] y1End = new double[] {1.11, 2.11, 3.11}; + double[][] data1 = new double[][] {x1, x1Start, x1End, y1, y1Start, + y1End}; + d.addSeries("S1", data1); + + double[] x2 = new double[] {11.0, 12.0, 13.0}; + double[] x2Start = new double[] {10.9, 11.9, 12.9}; + double[] x2End = new double[] {11.1, 12.1, 13.1}; + double[] y2 = new double[] {14.0, 15.0, 16.0}; + double[] y2Start = new double[] {11.09, 12.09, 13.09}; + double[] y2End = new double[] {11.11, 12.11, 13.11}; + double[][] data2 = new double[][] {x2, x2Start, x2End, y2, y2Start, + y2End}; + d.addSeries("S2", data2); + return d; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultOHLCDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultOHLCDatasetTest.java new file mode 100755 index 0000000..93b1776 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultOHLCDatasetTest.java @@ -0,0 +1,161 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * DefaultOHLCDatasetTest.java + * --------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Apr-2005 : Version 1 (DG); + * 28-Nov-2006 : Extended equals() test (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import java.util.Date; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.data.general.DatasetUtilities; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link DefaultOHLCDataset} class. + */ +public class DefaultOHLCDatasetTest { + + private static final double EPSILON = 0.0000000001; + + /** + * A small test for the data range calculated on this dataset. + */ + @Test + public void testDataRange() { + OHLCDataItem[] data = new OHLCDataItem[3]; + data[0] = new OHLCDataItem(new Date(11L), 2.0, 4.0, 1.0, 3.0, 100.0); + data[1] = new OHLCDataItem(new Date(22L), 4.0, 9.0, 2.0, 5.0, 120.0); + data[2] = new OHLCDataItem(new Date(33L), 3.0, 7.0, 3.0, 6.0, 140.0); + DefaultOHLCDataset d = new DefaultOHLCDataset("S1", data); + Range r = DatasetUtilities.findRangeBounds(d, true); + assertEquals(1.0, r.getLowerBound(), EPSILON); + assertEquals(9.0, r.getUpperBound(), EPSILON); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", + new OHLCDataItem[0]); + DefaultOHLCDataset d2 = new DefaultOHLCDataset("Series 1", + new OHLCDataItem[0]); + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + d1 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[0]); + assertFalse(d1.equals(d2)); + d2 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[0]); + assertTrue(d1.equals(d2)); + + d1 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[] { + new OHLCDataItem(new Date(123L), 1.2, 3.4, 5.6, 7.8, 99.9)}); + assertFalse(d1.equals(d2)); + d2 = new DefaultOHLCDataset("Series 2", new OHLCDataItem[] { + new OHLCDataItem(new Date(123L), 1.2, 3.4, 5.6, 7.8, 99.9)}); + assertTrue(d1.equals(d2)); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", + new OHLCDataItem[0]); + DefaultOHLCDataset d2 = (DefaultOHLCDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning2() throws CloneNotSupportedException { + OHLCDataItem item1 = new OHLCDataItem(new Date(1L), 1.0, 2.0, 3.0, 4.0, + 5.0); + OHLCDataItem item2 = new OHLCDataItem(new Date(2L), 6.0, 7.0, 8.0, 9.0, + 10.0); + // create an array of items in reverse order + OHLCDataItem[] items = new OHLCDataItem[] {item2, item1}; + DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", items); + DefaultOHLCDataset d2 = (DefaultOHLCDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + d1.sortDataByDate(); + assertFalse(d1.equals(d2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", + new OHLCDataItem[0]); + assertTrue(d1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultOHLCDataset d1 = new DefaultOHLCDataset("Series 1", + new OHLCDataItem[0]); + DefaultOHLCDataset d2 = (DefaultOHLCDataset) TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultTableXYDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultTableXYDatasetTest.java new file mode 100755 index 0000000..45a8295 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultTableXYDatasetTest.java @@ -0,0 +1,207 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------ + * DefaultTableXYDatasetTest.java + * ------------------------------ + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Dec-2003 : Version 1 (DG); + * 06-Oct-2005 : Added test for new data updating interval width (DG); + * 08-Mar-2007 : Added testGetSeries() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link DefaultTableXYDataset} class. + */ +public class DefaultTableXYDatasetTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DefaultTableXYDataset d1 = new DefaultTableXYDataset(); + XYSeries s1 = new XYSeries("Series 1", true, false); + s1.add(1.0, 1.1); + s1.add(2.0, 2.2); + d1.addSeries(s1); + + DefaultTableXYDataset d2 = new DefaultTableXYDataset(); + XYSeries s2 = new XYSeries("Series 1", true, false); + s2.add(1.0, 1.1); + s2.add(2.0, 2.2); + d2.addSeries(s2); + + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + s1.add(3.0, 3.3); + assertFalse(d1.equals(d2)); + + s2.add(3.0, 3.3); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultTableXYDataset d1 = new DefaultTableXYDataset(); + XYSeries s1 = new XYSeries("Series 1", true, false); + s1.add(1.0, 1.1); + s1.add(2.0, 2.2); + d1.addSeries(s1); + + DefaultTableXYDataset d2 = (DefaultTableXYDataset) d1.clone(); + + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + s1.add(3.0, 3.3); + assertFalse(d1.equals(d2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + DefaultTableXYDataset d1 = new DefaultTableXYDataset(); + assertTrue(d1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultTableXYDataset d1 = new DefaultTableXYDataset(); + XYSeries s1 = new XYSeries("Series 1", true, false); + s1.add(1.0, 1.1); + s1.add(2.0, 2.2); + d1.addSeries(s1); + + DefaultTableXYDataset d2 = (DefaultTableXYDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + private static final double EPSILON = 0.0000000001; + + /** + * This is a test for bug 1312066 - adding a new series should trigger a + * recalculation of the interval width, if it is being automatically + * calculated. + */ + @Test + public void testAddSeries() { + DefaultTableXYDataset d1 = new DefaultTableXYDataset(); + d1.setAutoWidth(true); + XYSeries s1 = new XYSeries("Series 1", true, false); + s1.add(3.0, 1.1); + s1.add(7.0, 2.2); + d1.addSeries(s1); + assertEquals(3.0, d1.getXValue(0, 0), EPSILON); + assertEquals(7.0, d1.getXValue(0, 1), EPSILON); + assertEquals(1.0, d1.getStartXValue(0, 0), EPSILON); + assertEquals(5.0, d1.getStartXValue(0, 1), EPSILON); + assertEquals(5.0, d1.getEndXValue(0, 0), EPSILON); + assertEquals(9.0, d1.getEndXValue(0, 1), EPSILON); + + // now add another series + XYSeries s2 = new XYSeries("Series 2", true, false); + s2.add(7.5, 1.1); + s2.add(9.0, 2.2); + d1.addSeries(s2); + + assertEquals(3.0, d1.getXValue(1, 0), EPSILON); + assertEquals(7.0, d1.getXValue(1, 1), EPSILON); + assertEquals(7.5, d1.getXValue(1, 2), EPSILON); + assertEquals(9.0, d1.getXValue(1, 3), EPSILON); + + assertEquals(7.25, d1.getStartXValue(1, 2), EPSILON); + assertEquals(8.75, d1.getStartXValue(1, 3), EPSILON); + assertEquals(7.75, d1.getEndXValue(1, 2), EPSILON); + assertEquals(9.25, d1.getEndXValue(1, 3), EPSILON); + + // and check the first series too... + assertEquals(2.75, d1.getStartXValue(0, 0), EPSILON); + assertEquals(6.75, d1.getStartXValue(0, 1), EPSILON); + assertEquals(3.25, d1.getEndXValue(0, 0), EPSILON); + assertEquals(7.25, d1.getEndXValue(0, 1), EPSILON); + } + + /** + * Some basic checks for the getSeries() method. + */ + @Test + public void testGetSeries() { + DefaultTableXYDataset d1 = new DefaultTableXYDataset(); + XYSeries s1 = new XYSeries("Series 1", true, false); + d1.addSeries(s1); + assertEquals("Series 1", d1.getSeries(0).getKey()); + + boolean pass = false; + try { + d1.getSeries(-1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + d1.getSeries(1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultWindDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultWindDatasetTest.java new file mode 100755 index 0000000..147c541 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultWindDatasetTest.java @@ -0,0 +1,192 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * DefaultWindDatasetTest.java + * --------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 12-Jul-2006 : Version 1 (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.time.Day; +import org.jfree.data.time.RegularTimePeriod; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for {@link DefaultWindDataset}. + */ +public class DefaultWindDatasetTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DefaultWindDataset d1 = new DefaultWindDataset(); + DefaultWindDataset d2 = new DefaultWindDataset(); + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + d1 = createSampleDataset1(); + assertFalse(d1.equals(d2)); + d2 = createSampleDataset1(); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultWindDataset d1 = new DefaultWindDataset(); + DefaultWindDataset d2 = (DefaultWindDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // try a dataset with some content... + d1 = createSampleDataset1(); + d2 = (DefaultWindDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + DefaultWindDataset d1 = new DefaultWindDataset(); + assertTrue(d1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultWindDataset d1 = new DefaultWindDataset(); + DefaultWindDataset d2 = (DefaultWindDataset) TestUtilities.serialised(d1); + assertEquals(d1, d2); + + // try a dataset with some content... + d1 = createSampleDataset1(); + d2 = (DefaultWindDataset) TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + /** + * Some checks for the getSeriesKey(int) method. + */ + @Test + public void testGetSeriesKey() { + DefaultWindDataset d = createSampleDataset1(); + assertEquals("Series 1", d.getSeriesKey(0)); + assertEquals("Series 2", d.getSeriesKey(1)); + + // check for series key out of bounds + boolean pass = false; + try { + /*Comparable k =*/ d.getSeriesKey(-1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + /*Comparable k =*/ d.getSeriesKey(2); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the indexOf(Comparable) method. + */ + @Test + public void testIndexOf() { + DefaultWindDataset d = createSampleDataset1(); + assertEquals(0, d.indexOf("Series 1")); + assertEquals(1, d.indexOf("Series 2")); + assertEquals(-1, d.indexOf("Green Eggs and Ham")); + assertEquals(-1, d.indexOf(null)); + } + + /** + * Creates a sample dataset for testing. + * + * @return A sample dataset. + */ + public DefaultWindDataset createSampleDataset1() { + Day t = new Day(1, 4, 2006); + Object[] item1 = createItem(t, 3, 7); + Object[] item2 = createItem(t.next(), 4, 8); + Object[] item3 = createItem(t.next(), 5, 9); + Object[][] series1 = new Object[][] {item1, item2, item3}; + Object[] item1b = createItem(t, 6, 10); + Object[] item2b = createItem(t.next(), 7, 11); + Object[] item3b = createItem(t.next(), 8, 12); + Object[][] series2 = new Object[][] {item1b, item2b, item3b}; + Object[][][] data = new Object[][][] {series1, series2}; + return new DefaultWindDataset(data); + } + + /** + * Creates an array representing one item in a series. + * + * @param t the time period. + * @param dir the wind direction. + * @param force the wind force. + * + * @return An array containing the specified items. + */ + private Object[] createItem(RegularTimePeriod t, int dir, int force) { + return new Object[] {new Long(t.getMiddleMillisecond()), + new Integer(dir), new Integer(force)}; + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultXYDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultXYDatasetTest.java new file mode 100755 index 0000000..1aa9416 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultXYDatasetTest.java @@ -0,0 +1,228 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * DefaultXYDatasetTests.java + * -------------------------- + * (C) Copyright 2006-2008, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 06-Jul-2006 : Version 1 (DG); + * 02-Nov-2006 : Added testAddSeries() method (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for {@link DefaultXYDataset}. + */ +public class DefaultXYDatasetTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + DefaultXYDataset d1 = new DefaultXYDataset(); + DefaultXYDataset d2 = new DefaultXYDataset(); + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[][] data1 = new double[][] {x1, y1}; + double[] x2 = new double[] {1.0, 2.0, 3.0}; + double[] y2 = new double[] {4.0, 5.0, 6.0}; + double[][] data2 = new double[][] {x2, y2}; + d1.addSeries("S1", data1); + assertFalse(d1.equals(d2)); + d2.addSeries("S1", data2); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultXYDataset d1 = new DefaultXYDataset(); + DefaultXYDataset d2 = (DefaultXYDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // try a dataset with some content... + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[][] data1 = new double[][] {x1, y1}; + d1.addSeries("S1", data1); + d2 = (DefaultXYDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // check that the clone doesn't share the same underlying arrays. + x1[1] = 2.2; + assertFalse(d1.equals(d2)); + x1[1] = 2.0; + assertTrue(d1.equals(d2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + DefaultXYDataset d1 = new DefaultXYDataset(); + assertTrue(d1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + + DefaultXYDataset d1 = new DefaultXYDataset(); + DefaultXYDataset d2 = (DefaultXYDataset) TestUtilities.serialised(d1); + assertEquals(d1, d2); + + // try a dataset with some content... + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[][] data1 = new double[][] {x1, y1}; + d1.addSeries("S1", data1); + d2 = (DefaultXYDataset) TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + /** + * Some checks for the getSeriesKey(int) method. + */ + @Test + public void testGetSeriesKey() { + DefaultXYDataset d = createSampleDataset1(); + assertEquals("S1", d.getSeriesKey(0)); + assertEquals("S2", d.getSeriesKey(1)); + + // check for series key out of bounds + boolean pass = false; + try { + /*Comparable k =*/ d.getSeriesKey(-1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + /*Comparable k =*/ d.getSeriesKey(2); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the indexOf(Comparable) method. + */ + @Test + public void testIndexOf() { + DefaultXYDataset d = createSampleDataset1(); + assertEquals(0, d.indexOf("S1")); + assertEquals(1, d.indexOf("S2")); + assertEquals(-1, d.indexOf("Green Eggs and Ham")); + assertEquals(-1, d.indexOf(null)); + } + + static final double EPSILON = 0.0000000001; + + /** + * Some tests for the addSeries() method. + */ + @Test + public void testAddSeries() { + DefaultXYDataset d = new DefaultXYDataset(); + d.addSeries("S1", new double[][] {{1.0}, {2.0}}); + assertEquals(1, d.getSeriesCount()); + assertEquals("S1", d.getSeriesKey(0)); + + // check that adding a series will overwrite the old series + d.addSeries("S1", new double[][] {{11.0}, {12.0}}); + assertEquals(1, d.getSeriesCount()); + assertEquals(12.0, d.getYValue(0, 0), EPSILON); + + // check null key + boolean pass = false; + try + { + d.addSeries(null, new double[][] {{1.0}, {2.0}}); + } + catch (IllegalArgumentException e) + { + pass = true; + } + assertTrue(pass); + } + + /** + * Creates a sample dataset for testing. + * + * @return A sample dataset. + */ + public DefaultXYDataset createSampleDataset1() { + DefaultXYDataset d = new DefaultXYDataset(); + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[][] data1 = new double[][] {x1, y1}; + d.addSeries("S1", data1); + + double[] x2 = new double[] {1.0, 2.0, 3.0}; + double[] y2 = new double[] {4.0, 5.0, 6.0}; + double[][] data2 = new double[][] {x2, y2}; + d.addSeries("S2", data2); + return d; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultXYZDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultXYZDatasetTest.java new file mode 100755 index 0000000..957856d --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/DefaultXYZDatasetTest.java @@ -0,0 +1,233 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * DefaultXYZDatasetTest.java + * -------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 12-Jul-2006 : Version 1 (DG); + * 02-Nov-2006 : Added testAddSeries() method (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for {@link DefaultXYZDataset}. + */ +public class DefaultXYZDatasetTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + DefaultXYZDataset d1 = new DefaultXYZDataset(); + DefaultXYZDataset d2 = new DefaultXYZDataset(); + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] z1 = new double[] {7.0, 8.0, 9.0}; + double[][] data1 = new double[][] {x1, y1, z1}; + double[] x2 = new double[] {1.0, 2.0, 3.0}; + double[] y2 = new double[] {4.0, 5.0, 6.0}; + double[] z2 = new double[] {7.0, 8.0, 9.0}; + double[][] data2 = new double[][] {x2, y2, z2}; + d1.addSeries("S1", data1); + assertFalse(d1.equals(d2)); + d2.addSeries("S1", data2); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultXYZDataset d1 = new DefaultXYZDataset(); + DefaultXYZDataset d2 = (DefaultXYZDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // try a dataset with some content... + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] z1 = new double[] {7.0, 8.0, 9.0}; + double[][] data1 = new double[][] {x1, y1, z1}; + d1.addSeries("S1", data1); + d2 = (DefaultXYZDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + + // check that the clone doesn't share the same underlying arrays. + x1[1] = 2.2; + assertFalse(d1.equals(d2)); + x1[1] = 2.0; + assertTrue(d1.equals(d2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + DefaultXYZDataset d1 = new DefaultXYZDataset(); + assertTrue(d1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultXYZDataset d1 = new DefaultXYZDataset(); + DefaultXYZDataset d2 = (DefaultXYZDataset) TestUtilities.serialised(d1); + assertEquals(d1, d2); + + // try a dataset with some content... + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] z1 = new double[] {7.0, 8.0, 9.0}; + double[][] data1 = new double[][] {x1, y1, z1}; + d1.addSeries("S1", data1); + d2 = (DefaultXYZDataset) TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + /** + * Some checks for the getSeriesKey(int) method. + */ + @Test + public void testGetSeriesKey() { + DefaultXYZDataset d = createSampleDataset1(); + assertEquals("S1", d.getSeriesKey(0)); + assertEquals("S2", d.getSeriesKey(1)); + + // check for series key out of bounds + boolean pass = false; + try { + /*Comparable k =*/ d.getSeriesKey(-1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + /*Comparable k =*/ d.getSeriesKey(2); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * Some checks for the indexOf(Comparable) method. + */ + @Test + public void testIndexOf() { + DefaultXYZDataset d = createSampleDataset1(); + assertEquals(0, d.indexOf("S1")); + assertEquals(1, d.indexOf("S2")); + assertEquals(-1, d.indexOf("Green Eggs and Ham")); + assertEquals(-1, d.indexOf(null)); + } + + static final double EPSILON = 0.0000000001; + + /** + * Some tests for the addSeries() method. + */ + @Test + public void testAddSeries() { + DefaultXYZDataset d = new DefaultXYZDataset(); + d.addSeries("S1", new double[][] {{1.0}, {2.0}, {3.0}}); + assertEquals(1, d.getSeriesCount()); + assertEquals("S1", d.getSeriesKey(0)); + + // check that adding a series will overwrite the old series + d.addSeries("S1", new double[][] {{11.0}, {12.0}, {13.0}}); + assertEquals(1, d.getSeriesCount()); + assertEquals(12.0, d.getYValue(0, 0), EPSILON); + + // check null key + boolean pass = false; + try + { + d.addSeries(null, new double[][] {{1.0}, {2.0}, {3.0}}); + } + catch (IllegalArgumentException e) + { + pass = true; + } + assertTrue(pass); + } + + /** + * Creates a sample dataset for testing. + * + * @return A sample dataset. + */ + public DefaultXYZDataset createSampleDataset1() { + DefaultXYZDataset d = new DefaultXYZDataset(); + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[] z1 = new double[] {7.0, 8.0, 9.0}; + double[][] data1 = new double[][] {x1, y1, z1}; + d.addSeries("S1", data1); + + double[] x2 = new double[] {1.0, 2.0, 3.0}; + double[] y2 = new double[] {4.0, 5.0, 6.0}; + double[] z2 = new double[] {7.0, 8.0, 9.0}; + double[][] data2 = new double[][] {x2, y2, z2}; + d.addSeries("S2", data2); + return d; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/IntervalXYDelegateTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/IntervalXYDelegateTest.java new file mode 100755 index 0000000..2815fd2 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/IntervalXYDelegateTest.java @@ -0,0 +1,122 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * IntervalXYDelegateTest.java + * --------------------------- + * (C) Copyright 2005-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-Feb-2005 : Version 1 (DG); + * 06-Oct-2005 : Updated for testEquals() for method name change (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Some checks for the {@link IntervalXYDelegate} class. + */ +public class IntervalXYDelegateTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XYSeries s1 = new XYSeries("Series"); + s1.add(1.2, 3.4); + XYSeriesCollection c1 = new XYSeriesCollection(); + c1.addSeries(s1); + IntervalXYDelegate d1 = new IntervalXYDelegate(c1); + + XYSeries s2 = new XYSeries("Series"); + XYSeriesCollection c2 = new XYSeriesCollection(); + s2.add(1.2, 3.4); + c2.addSeries(s2); + IntervalXYDelegate d2 = new IntervalXYDelegate(c2); + + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + d1.setAutoWidth(false); + assertFalse(d1.equals(d2)); + d2.setAutoWidth(false); + assertTrue(d1.equals(d2)); + + d1.setIntervalPositionFactor(0.123); + assertFalse(d1.equals(d2)); + d2.setIntervalPositionFactor(0.123); + assertTrue(d1.equals(d2)); + + d1.setFixedIntervalWidth(1.23); + assertFalse(d1.equals(d2)); + d2.setFixedIntervalWidth(1.23); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYSeries s1 = new XYSeries("Series"); + s1.add(1.2, 3.4); + XYSeriesCollection c1 = new XYSeriesCollection(); + c1.addSeries(s1); + IntervalXYDelegate d1 = new IntervalXYDelegate(c1); + IntervalXYDelegate d2 = (IntervalXYDelegate) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYSeries s1 = new XYSeries("Series"); + s1.add(1.2, 3.4); + XYSeriesCollection c1 = new XYSeriesCollection(); + c1.addSeries(s1); + IntervalXYDelegate d1 = new IntervalXYDelegate(c1); + IntervalXYDelegate d2 = (IntervalXYDelegate) TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/MatrixSeriesCollectionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/MatrixSeriesCollectionTest.java new file mode 100755 index 0000000..2533363 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/MatrixSeriesCollectionTest.java @@ -0,0 +1,124 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * MatrixSeriesCollectionTest.java + * ------------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 27-Nov-2006 : Version 1 (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link MatrixSeriesCollection} class. + */ +public class MatrixSeriesCollectionTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + MatrixSeries s1 = new MatrixSeries("Series", 2, 3); + s1.update(0, 0, 1.1); + MatrixSeriesCollection c1 = new MatrixSeriesCollection(); + c1.addSeries(s1); + MatrixSeries s2 = new MatrixSeries("Series", 2, 3); + s2.update(0, 0, 1.1); + MatrixSeriesCollection c2 = new MatrixSeriesCollection(); + c2.addSeries(s2); + assertTrue(c1.equals(c2)); + assertTrue(c2.equals(c1)); + + c1.addSeries(new MatrixSeries("Empty Series", 1, 1)); + assertFalse(c1.equals(c2)); + + c2.addSeries(new MatrixSeries("Empty Series", 1, 1)); + assertTrue(c1.equals(c2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + MatrixSeries s1 = new MatrixSeries("Series", 2, 3); + s1.update(0, 0, 1.1); + MatrixSeriesCollection c1 = new MatrixSeriesCollection(); + c1.addSeries(s1); + MatrixSeriesCollection c2 = (MatrixSeriesCollection) c1.clone(); + + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + + // check independence + s1.setDescription("XYZ"); + assertFalse(c1.equals(c2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + MatrixSeriesCollection c1 = new MatrixSeriesCollection(); + assertTrue(c1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + MatrixSeries s1 = new MatrixSeries("Series", 2, 3); + s1.update(0, 0, 1.1); + MatrixSeriesCollection c1 = new MatrixSeriesCollection(); + c1.addSeries(s1); + MatrixSeriesCollection c2 = (MatrixSeriesCollection) + TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/MatrixSeriesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/MatrixSeriesTest.java new file mode 100755 index 0000000..419aa42 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/MatrixSeriesTest.java @@ -0,0 +1,164 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * MatrixSeriesTest.java + * --------------------- + * (C) Copyright 2004-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 21-May-2004 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + + +/** + * Tests for the {@link MatrixSeries} class. + */ +public class MatrixSeriesTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + MatrixSeries m1 = new MatrixSeries("Test", 8, 3); + m1.update(0, 0, 11.0); + m1.update(7, 2, 22.0); + MatrixSeries m2 = new MatrixSeries("Test", 8, 3); + m2.update(0, 0, 11.0); + m2.update(7, 2, 22.0); + assertTrue(m1.equals(m2)); + assertTrue(m2.equals(m1)); + + m1 = new MatrixSeries("Test 2", 8, 3); + assertFalse(m1.equals(m2)); + m2 = new MatrixSeries("Test 2", 8, 3); + assertTrue(m1.equals(m2)); + + m1 = new MatrixSeries("Test 2", 10, 3); + assertFalse(m1.equals(m2)); + m2 = new MatrixSeries("Test 2", 10, 3); + assertTrue(m1.equals(m2)); + + m1 = new MatrixSeries("Test 2", 10, 5); + assertFalse(m1.equals(m2)); + m2 = new MatrixSeries("Test 2", 10, 5); + assertTrue(m1.equals(m2)); + + m1.update(0, 0, 99); + assertFalse(m1.equals(m2)); + m2.update(0, 0, 99); + assertTrue(m1.equals(m2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + MatrixSeries m1 = new MatrixSeries("Test", 8, 3); + m1.update(0, 0, 11.0); + m1.update(7, 2, 22.0); + MatrixSeries m2 = (MatrixSeries) m1.clone(); + assertTrue(m1 != m2); + assertTrue(m1.getClass() == m2.getClass()); + assertTrue(m1.equals(m2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + MatrixSeries m1 = new MatrixSeries("Test", 8, 3); + m1.update(0, 0, 11.0); + m1.update(7, 2, 22.0); + MatrixSeries m2 = (MatrixSeries) TestUtilities.serialised(m1); + assertEquals(m1, m2); + } + + /** + * Tests the getItemColumn() method. + */ + @Test + public void testGetItemColumn() { + MatrixSeries m = new MatrixSeries("Test", 3, 2); + assertEquals(0, m.getItemColumn(0)); + assertEquals(1, m.getItemColumn(1)); + assertEquals(0, m.getItemColumn(2)); + assertEquals(1, m.getItemColumn(3)); + assertEquals(0, m.getItemColumn(4)); + assertEquals(1, m.getItemColumn(5)); + } + + /** + * Tests the getItemRow() method. + */ + @Test + public void testGetItemRow() { + MatrixSeries m = new MatrixSeries("Test", 3, 2); + assertEquals(0, m.getItemRow(0)); + assertEquals(0, m.getItemRow(1)); + assertEquals(1, m.getItemRow(2)); + assertEquals(1, m.getItemRow(3)); + assertEquals(2, m.getItemRow(4)); + assertEquals(2, m.getItemRow(5)); + } + + /** + * Tests the getItem() method. + */ + @Test + public void testGetItem() { + MatrixSeries m = new MatrixSeries("Test", 3, 2); + m.update(0, 0, 0.0); + m.update(0, 1, 1.0); + m.update(1, 0, 2.0); + m.update(1, 1, 3.0); + m.update(2, 0, 4.0); + m.update(2, 1, 5.0); + assertEquals(0.0, m.getItem(0).doubleValue(), 0.001); + assertEquals(1.0, m.getItem(1).doubleValue(), 0.001); + assertEquals(2.0, m.getItem(2).doubleValue(), 0.001); + assertEquals(3.0, m.getItem(3).doubleValue(), 0.001); + assertEquals(4.0, m.getItem(4).doubleValue(), 0.001); + assertEquals(5.0, m.getItem(5).doubleValue(), 0.001); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/OHLCDataItemTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/OHLCDataItemTest.java new file mode 100755 index 0000000..74a5d94 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/OHLCDataItemTest.java @@ -0,0 +1,92 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * OHLCDataItemTest.java + * --------------------- + * (C) Copyright 2005-2013 by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 29-Apr-2005 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import java.util.Date; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link OHLCDataItem} class. + */ +public class OHLCDataItemTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + OHLCDataItem i1 = new OHLCDataItem(new Date(1L), 1.0, 2.0, 3.0, 4.0, + 5.0); + OHLCDataItem i2 = new OHLCDataItem(new Date(1L), 1.0, 2.0, 3.0, 4.0, + 5.0); + assertTrue(i1.equals(i2)); + assertTrue(i2.equals(i1)); + } + + /** + * Instances of this class are immutable - cloning not required. + */ + @Test + public void testCloning() { + OHLCDataItem i1 = new OHLCDataItem( + new Date(1L), 1.0, 2.0, 3.0, 4.0, 5.0 + ); + assertFalse(i1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + OHLCDataItem i1 = new OHLCDataItem(new Date(1L), 1.0, 2.0, 3.0, 4.0, + 5.0); + OHLCDataItem i2 = (OHLCDataItem) TestUtilities.serialised(i1); + assertEquals(i1, i2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/TableXYDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/TableXYDatasetTest.java new file mode 100755 index 0000000..7567a58 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/TableXYDatasetTest.java @@ -0,0 +1,278 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * TableXYDatasetTest.java + * ----------------------- + * (C) Copyright 2003-2013, by Richard Atkinson and Contributors. + * + * Original Author: Richard Atkinson; + * Contributor(s): David Gilbert (for Object Refinery Limited); + * + * Changes + * ------- + * 11-Aug-2003 : Version 1 (RA); + * 18-Aug-2003 : Added tests for event notification when removing and updating + * series (RA); + * 22-Sep-2003 : Changed to recognise that empty values are now null rather + * than zero (RA); + * 16-Feb-2004 : Added some additional tests (DG); + * 15-Jul-2004 : Switched getX() with getXValue() and getY() with + * getYValue() (DG); + * 02-Feb-2007 : Removed author tags all over JFreeChart sources (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for {@link DefaultTableXYDataset}. + */ +public class TableXYDatasetTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DefaultTableXYDataset d1 = new DefaultTableXYDataset(); + DefaultTableXYDataset d2 = new DefaultTableXYDataset(); + assertTrue(d1.equals(d2)); + assertTrue(d2.equals(d1)); + + d1.addSeries(createSeries1()); + assertFalse(d1.equals(d2)); + + d2.addSeries(createSeries1()); + assertTrue(d1.equals(d2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultTableXYDataset d1 = new DefaultTableXYDataset(); + d1.addSeries(createSeries1()); + DefaultTableXYDataset d2 = (DefaultTableXYDataset) d1.clone(); + assertTrue(d1 != d2); + assertTrue(d1.getClass() == d2.getClass()); + assertTrue(d1.equals(d2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + DefaultTableXYDataset d1 = new DefaultTableXYDataset(); + assertTrue(d1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultTableXYDataset d1 = new DefaultTableXYDataset(); + d1.addSeries(createSeries2()); + DefaultTableXYDataset d2 = (DefaultTableXYDataset) + TestUtilities.serialised(d1); + assertEquals(d1, d2); + } + + /** + * Assorted tests. + */ + @Test + public void testTableXYDataset() { + XYSeries series1 = createSeries1(); + XYSeries series2 = createSeries2(); + + DefaultTableXYDataset dataset = new DefaultTableXYDataset(); + dataset.addSeries(series1); + dataset.addSeries(series2); + + // Test that there are 6 X points and some specific values + assertEquals(6, dataset.getItemCount()); + assertEquals(6, dataset.getX(0, 5).intValue()); + assertEquals(null, dataset.getY(0, 5)); + assertEquals(6, dataset.getX(1, 5).intValue()); + assertEquals(2, dataset.getY(1, 5).intValue()); + + // after adding a point to a series, check that there are now 7 + // items in each series + series2.add(7, 2); + assertEquals(7, dataset.getItemCount()); + assertEquals(null, dataset.getY(0, 6)); + assertEquals(2, dataset.getY(1, 6).intValue()); + + // Remove series 1 + dataset.removeSeries(series1); + // Test that there are still 7 X points + assertEquals(7, dataset.getItemCount()); + + // Remove series 2 and add new series + dataset.removeSeries(series2); + series1 = createSeries1(); + dataset.addSeries(series1); + + // Test that there are now 4 X points + assertEquals(4, dataset.getItemCount()); + } + + /** + * A test for bug report 788597. + */ + @Test + public void test788597() { + DefaultTableXYDataset dataset = new DefaultTableXYDataset(); + dataset.addSeries(createSeries1()); + assertEquals(4, dataset.getItemCount()); + dataset.removeAllSeries(); + assertEquals(0, dataset.getItemCount()); + } + + /** + * Test that removing all values for a given x works. + */ + @Test + public void testRemoveAllValuesForX() { + DefaultTableXYDataset dataset = new DefaultTableXYDataset(); + dataset.addSeries(createSeries1()); + dataset.addSeries(createSeries2()); + dataset.removeAllValuesForX(new Double(2.0)); + assertEquals(5, dataset.getItemCount()); + assertEquals(new Double(1.0), dataset.getX(0, 0)); + assertEquals(new Double(3.0), dataset.getX(0, 1)); + assertEquals(new Double(4.0), dataset.getX(0, 2)); + assertEquals(new Double(5.0), dataset.getX(0, 3)); + assertEquals(new Double(6.0), dataset.getX(0, 4)); + } + + /** + * Tests to see that pruning removes unwanted x values. + */ + @Test + public void testPrune() { + DefaultTableXYDataset dataset = new DefaultTableXYDataset(); + dataset.addSeries(createSeries1()); + dataset.addSeries(createSeries2()); + dataset.removeSeries(1); + dataset.prune(); + assertEquals(4, dataset.getItemCount()); + } + + /** + * Tests the auto-pruning feature. + */ + @Test + public void testAutoPrune() { + + // WITH AUTOPRUNING + DefaultTableXYDataset dataset = new DefaultTableXYDataset(true); + dataset.addSeries(createSeriesA()); + assertEquals(2, dataset.getItemCount()); // should be 2 items + dataset.addSeries(createSeriesB()); + assertEquals(2, dataset.getItemCount()); // still 2 + dataset.removeSeries(1); + assertEquals(1, dataset.getItemCount()); // 1 value pruned. + + // WITHOUT AUTOPRUNING + DefaultTableXYDataset dataset2 = new DefaultTableXYDataset(true); + dataset2.addSeries(createSeriesA()); + assertEquals(2, dataset2.getItemCount()); // should be 2 items + dataset2.addSeries(createSeriesB()); + assertEquals(2, dataset2.getItemCount()); // still 2 + dataset2.removeSeries(1); + assertEquals(1, dataset2.getItemCount()); // still 2. + + } + + /** + * Creates a series for testing. + * + * @return A series. + */ + private XYSeries createSeriesA() { + XYSeries s = new XYSeries("A", true, false); + s.add(1.0, 1.1); + s.add(2.0, null); + return s; + } + + /** + * Creates a series for testing. + * + * @return A series. + */ + private XYSeries createSeriesB() { + XYSeries s = new XYSeries("B", true, false); + s.add(1.0, null); + s.add(2.0, 2.2); + return s; + } + + /** + * Creates a series for testing. + * + * @return A series. + */ + private XYSeries createSeries1() { + XYSeries series1 = new XYSeries("Series 1", true, false); + series1.add(1.0, 1.0); + series1.add(2.0, 1.0); + series1.add(4.0, 1.0); + series1.add(5.0, 1.0); + return series1; + } + + /** + * Creates a series for testing. + * + * @return A series. + */ + private XYSeries createSeries2() { + XYSeries series2 = new XYSeries("Series 2", true, false); + series2.add(2.0, 2.0); + series2.add(3.0, 2.0); + series2.add(4.0, 2.0); + series2.add(5.0, 2.0); + series2.add(6.0, 2.0); + return series2; + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/VectorDataItemTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/VectorDataItemTest.java new file mode 100755 index 0000000..f4d9242 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/VectorDataItemTest.java @@ -0,0 +1,122 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * VectorDataItemTest.java + * ----------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jan-2007 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link VectorDataItem} class. + */ +public class VectorDataItemTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + // default instances + VectorDataItem v1 = new VectorDataItem(1.0, 2.0, 3.0, 4.0); + VectorDataItem v2 = new VectorDataItem(1.0, 2.0, 3.0, 4.0); + assertTrue(v1.equals(v2)); + assertTrue(v2.equals(v1)); + + v1 = new VectorDataItem(1.1, 2.0, 3.0, 4.0); + assertFalse(v1.equals(v2)); + v2 = new VectorDataItem(1.1, 2.0, 3.0, 4.0); + assertTrue(v1.equals(v2)); + + v1 = new VectorDataItem(1.1, 2.2, 3.0, 4.0); + assertFalse(v1.equals(v2)); + v2 = new VectorDataItem(1.1, 2.2, 3.0, 4.0); + assertTrue(v1.equals(v2)); + + v1 = new VectorDataItem(1.1, 2.2, 3.3, 4.0); + assertFalse(v1.equals(v2)); + v2 = new VectorDataItem(1.1, 2.2, 3.3, 4.0); + assertTrue(v1.equals(v2)); + + v1 = new VectorDataItem(1.1, 2.2, 3.3, 4.4); + assertFalse(v1.equals(v2)); + v2 = new VectorDataItem(1.1, 2.2, 3.3, 4.4); + assertTrue(v1.equals(v2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + VectorDataItem v1 = new VectorDataItem(1.0, 2.0, 3.0, 4.0); + VectorDataItem v2 = new VectorDataItem(1.0, 2.0, 3.0, 4.0); + assertTrue(v1.equals(v2)); + int h1 = v1.hashCode(); + int h2 = v2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Check cloning. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + VectorDataItem v1 = new VectorDataItem(1.0, 2.0, 3.0, 4.0); + VectorDataItem v2 = (VectorDataItem) v1.clone(); + assertTrue(v1 != v2); + assertTrue(v1.getClass() == v2.getClass()); + assertTrue(v1.equals(v2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + VectorDataItem v1 = new VectorDataItem(1.0, 2.0, 3.0, 4.0); + VectorDataItem v2 = (VectorDataItem) TestUtilities.serialised(v1); + assertEquals(v1, v2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/VectorSeriesCollectionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/VectorSeriesCollectionTest.java new file mode 100755 index 0000000..16c6a77 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/VectorSeriesCollectionTest.java @@ -0,0 +1,147 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------------- + * VectorSeriesCollectionTest.java + * ------------------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jan-2007 : Version 1 (DG); + * 24-May-2007 : Added testRemoveSeries() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link VectorSeriesCollection} class. + */ +public class VectorSeriesCollectionTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + VectorSeries s1 = new VectorSeries("Series"); + s1.add(1.0, 1.1, 1.2, 1.3); + VectorSeriesCollection c1 = new VectorSeriesCollection(); + c1.addSeries(s1); + VectorSeries s2 = new VectorSeries("Series"); + s2.add(1.0, 1.1, 1.2, 1.3); + VectorSeriesCollection c2 = new VectorSeriesCollection(); + c2.addSeries(s2); + assertTrue(c1.equals(c2)); + assertTrue(c2.equals(c1)); + + c1.addSeries(new VectorSeries("Empty Series")); + assertFalse(c1.equals(c2)); + + c2.addSeries(new VectorSeries("Empty Series")); + assertTrue(c1.equals(c2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + VectorSeries s1 = new VectorSeries("Series"); + s1.add(1.0, 1.1, 1.2, 1.3); + VectorSeriesCollection c1 = new VectorSeriesCollection(); + c1.addSeries(s1); + VectorSeriesCollection c2 = (VectorSeriesCollection) c1.clone(); + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + + // check independence + s1.setDescription("XYZ"); + assertFalse(c1.equals(c2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + VectorSeriesCollection d1 = new VectorSeriesCollection(); + assertTrue(d1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + VectorSeries s1 = new VectorSeries("Series"); + s1.add(1.0, 1.1, 1.2, 1.3); + VectorSeriesCollection c1 = new VectorSeriesCollection(); + c1.addSeries(s1); + VectorSeriesCollection c2 = (VectorSeriesCollection) + TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + + /** + * Some checks for the removeSeries() method. + */ + @Test + public void testRemoveSeries() { + VectorSeries s1 = new VectorSeries("S1"); + VectorSeries s2 = new VectorSeries("S2"); + VectorSeriesCollection vsc = new VectorSeriesCollection(); + vsc.addSeries(s1); + vsc.addSeries(s2); + assertEquals(2, vsc.getSeriesCount()); + boolean b = vsc.removeSeries(s1); + assertTrue(b); + assertEquals(1, vsc.getSeriesCount()); + assertEquals("S2", vsc.getSeriesKey(0)); + b = vsc.removeSeries(new VectorSeries("NotInDataset")); + assertFalse(b); + assertEquals(1, vsc.getSeriesCount()); + b = vsc.removeSeries(s2); + assertTrue(b); + assertEquals(0, vsc.getSeriesCount()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/VectorSeriesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/VectorSeriesTest.java new file mode 100755 index 0000000..2241b94 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/VectorSeriesTest.java @@ -0,0 +1,279 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * VectorSeriesTest.java + * --------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jan-2007 : Version 1, based on XYSeriesTests (DG); + * 24-May-2007 : Updated for modified method names (DG); + * 27-Nov-2007 : Added testClear() method (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.data.general.SeriesChangeListener; +import org.junit.Test; + +/** + * Tests for the {@link VectorSeries} class. + */ +public class VectorSeriesTest implements SeriesChangeListener { + + SeriesChangeEvent lastEvent; + + /** + * Records the last event. + * + * @param event the event. + */ + public void seriesChanged(SeriesChangeEvent event) { + this.lastEvent = event; + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + VectorSeries s1 = new VectorSeries("s1"); + VectorSeries s2 = new VectorSeries("s1"); + assertTrue(s1.equals(s2)); + + // seriesKey + s1 = new VectorSeries("s2"); + assertFalse(s1.equals(s2)); + s2 = new VectorSeries("s2"); + assertTrue(s1.equals(s2)); + + // autoSort + s1 = new VectorSeries("s2", true, true); + assertFalse(s1.equals(s2)); + s2 = new VectorSeries("s2", true, true); + assertTrue(s1.equals(s2)); + + // allowDuplicateValues + s1 = new VectorSeries("s2", false, false); + assertFalse(s1.equals(s2)); + s2 = new VectorSeries("s2", false, false); + assertTrue(s1.equals(s2)); + + // add a value + s1.add(1.0, 0.5, 1.5, 2.0); + assertFalse(s1.equals(s2)); + s2.add(1.0, 0.5, 1.5, 2.0); + assertTrue(s2.equals(s1)); + + // add another value + s1.add(2.0, 0.5, 1.5, 2.0); + assertFalse(s1.equals(s2)); + s2.add(2.0, 0.5, 1.5, 2.0); + assertTrue(s2.equals(s1)); + + // remove a value + s1.remove(new XYCoordinate(1.0, 0.5)); + assertFalse(s1.equals(s2)); + s2.remove(new XYCoordinate(1.0, 0.5)); + assertTrue(s2.equals(s1)); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + VectorSeries s1 = new VectorSeries("s1"); + s1.add(1.0, 0.5, 1.5, 2.0); + VectorSeries s2 = (VectorSeries) s1.clone(); + assertTrue(s1 != s2); + assertTrue(s1.getClass() == s2.getClass()); + assertTrue(s1.equals(s2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + VectorSeries s1 = new VectorSeries("s1"); + s1.add(1.0, 0.5, 1.5, 2.0); + VectorSeries s2 = (VectorSeries) TestUtilities.serialised(s1); + assertEquals(s1, s2); + } + + /** + * Simple test for the indexOf() method. + */ + @Test + public void testIndexOf() { + VectorSeries s1 = new VectorSeries("Series 1"); + s1.add(1.0, 1.0, 1.0, 2.0); + s1.add(2.0, 2.0, 2.0, 3.0); + s1.add(3.0, 3.0, 3.0, 4.0); + assertEquals(0, s1.indexOf(new XYCoordinate(1.0, 1.0))); + } + + /** + * A check for the indexOf() method for an unsorted series. + */ + @Test + public void testIndexOf2() { + VectorSeries s1 = new VectorSeries("Series 1"); + s1.add(1.0, 1.0, 1.0, 2.0); + s1.add(3.0, 3.0, 3.0, 3.0); + s1.add(2.0, 2.0, 2.0, 2.0); + assertEquals(0, s1.indexOf(new XYCoordinate(1.0, 1.0))); + assertEquals(1, s1.indexOf(new XYCoordinate(3.0, 3.0))); + assertEquals(2, s1.indexOf(new XYCoordinate(2.0, 2.0))); + } + + /** + * Simple test for the remove() method. + */ + @Test + public void testRemove() { + VectorSeries s1 = new VectorSeries("Series 1"); + s1.add(1.0, 1.0, 1.0, 2.0); + s1.add(3.0, 3.0, 3.0, 3.0); + s1.add(2.0, 2.0, 2.0, 2.0); + assertEquals(3, s1.getItemCount()); + + s1.remove(new XYCoordinate(2.0, 2.0)); + assertEquals(3.0, s1.getXValue(1), EPSILON); + + s1.remove(new XYCoordinate(1.0, 1.0)); + assertEquals(3.0, s1.getXValue(0), EPSILON); + } + + private static final double EPSILON = 0.0000000001; + + /** + * When items are added with duplicate x-values, we expect them to remain + * in the order they were added. + */ + @Test + public void testAdditionOfDuplicateXValues() { + VectorSeries s1 = new VectorSeries("Series 1"); + s1.add(1.0, 1.0, 1.0, 1.0); + s1.add(2.0, 2.0, 2.0, 2.0); + s1.add(2.0, 2.0, 3.0, 3.0); + s1.add(2.0, 3.0, 4.0, 4.0); + s1.add(3.0, 5.0, 5.0, 5.0); + assertEquals(1.0, s1.getVectorXValue(0), EPSILON); + assertEquals(2.0, s1.getVectorXValue(1), EPSILON); + assertEquals(3.0, s1.getVectorXValue(2), EPSILON); + assertEquals(4.0, s1.getVectorXValue(3), EPSILON); + assertEquals(5.0, s1.getVectorXValue(4), EPSILON); + } + + /** + * Some checks for the add() method for an UNSORTED series. + */ + @Test + public void testAdd() { + VectorSeries series = new VectorSeries("Series", false, true); + series.add(5.0, 5.50, 5.50, 5.50); + series.add(5.1, 5.51, 5.51, 5.51); + series.add(6.0, 6.6, 6.6, 6.6); + series.add(3.0, 3.3, 3.3, 3.3); + series.add(4.0, 4.4, 4.4, 4.4); + series.add(2.0, 2.2, 2.2, 2.2); + series.add(1.0, 1.1, 1.1, 1.1); + assertEquals(5.5, series.getVectorXValue(0), EPSILON); + assertEquals(5.51, series.getVectorXValue(1), EPSILON); + assertEquals(6.6, series.getVectorXValue(2), EPSILON); + assertEquals(3.3, series.getVectorXValue(3), EPSILON); + assertEquals(4.4, series.getVectorXValue(4), EPSILON); + assertEquals(2.2, series.getVectorXValue(5), EPSILON); + assertEquals(1.1, series.getVectorXValue(6), EPSILON); + } + + /** + * A simple check that the maximumItemCount attribute is working. + */ + @Test + public void testSetMaximumItemCount() { + VectorSeries s1 = new VectorSeries("S1"); + assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); + s1.setMaximumItemCount(2); + assertEquals(2, s1.getMaximumItemCount()); + s1.add(1.0, 1.1, 1.1, 1.1); + s1.add(2.0, 2.2, 2.2, 2.2); + s1.add(3.0, 3.3, 3.3, 3.3); + assertEquals(2.0, s1.getXValue(0), EPSILON); + assertEquals(3.0, s1.getXValue(1), EPSILON); + } + + /** + * Check that the maximum item count can be applied retrospectively. + */ + @Test + public void testSetMaximumItemCount2() { + VectorSeries s1 = new VectorSeries("S1"); + s1.add(1.0, 1.1, 1.1, 1.1); + s1.add(2.0, 2.2, 2.2, 2.2); + s1.add(3.0, 3.3, 3.3, 3.3); + s1.setMaximumItemCount(2); + assertEquals(2.0, s1.getXValue(0), EPSILON); + assertEquals(3.0, s1.getXValue(1), EPSILON); + } + + /** + * Some checks for the clear() method. + */ + @Test + public void testClear() { + VectorSeries s1 = new VectorSeries("S1"); + s1.addChangeListener(this); + s1.clear(); + assertNull(this.lastEvent); + assertTrue(s1.isEmpty()); + s1.add(1.0, 2.0, 3.0, 4.0); + assertFalse(s1.isEmpty()); + s1.clear(); + assertNotNull(this.lastEvent); + assertTrue(s1.isEmpty()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/VectorTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/VectorTest.java new file mode 100755 index 0000000..329e921 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/VectorTest.java @@ -0,0 +1,109 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------- + * VectorTests.java + * ---------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jan-2007 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link Vector} class. + */ +public class VectorTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + // default instances + Vector v1 = new Vector(1.0, 2.0); + Vector v2 = new Vector(1.0, 2.0); + assertTrue(v1.equals(v2)); + assertTrue(v2.equals(v1)); + + v1 = new Vector(1.1, 2.0); + assertFalse(v1.equals(v2)); + v2 = new Vector(1.1, 2.0); + assertTrue(v1.equals(v2)); + + v1 = new Vector(1.1, 2.2); + assertFalse(v1.equals(v2)); + v2 = new Vector(1.1, 2.2); + assertTrue(v1.equals(v2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + Vector v1 = new Vector(1.0, 2.0); + Vector v2 = new Vector(1.0, 2.0); + assertTrue(v1.equals(v2)); + int h1 = v1.hashCode(); + int h2 = v2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Immutable class is not cloneable. + */ + @Test + public void testCloning() { + Vector v1 = new Vector(1.0, 2.0); + assertFalse(v1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + Vector v1 = new Vector(1.0, 2.0); + Vector v2 = (Vector) TestUtilities.serialised(v1); + assertEquals(v1, v2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XIntervalDataItemTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XIntervalDataItemTest.java new file mode 100755 index 0000000..b32252a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XIntervalDataItemTest.java @@ -0,0 +1,127 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * XIntervalDataItemTest.java + * -------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link XIntervalDataItem} class. + */ +public class XIntervalDataItemTest { + + private static final double EPSILON = 0.00000000001; + + /** + * Some checks for the constructor. + */ + @Test + public void testConstructor1() { + XIntervalDataItem item1 = new XIntervalDataItem(1.0, 2.0, 3.0, 4.0); + assertEquals(new Double(1.0), item1.getX()); + assertEquals(2.0, item1.getXLowValue(), EPSILON); + assertEquals(3.0, item1.getXHighValue(), EPSILON); + assertEquals(4.0, item1.getYValue(), EPSILON); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XIntervalDataItem item1 = new XIntervalDataItem(1.0, 2.0, 3.0, 4.0); + XIntervalDataItem item2 = new XIntervalDataItem(1.0, 2.0, 3.0, 4.0); + assertTrue(item1.equals(item2)); + assertTrue(item2.equals(item1)); + + // x + item1 = new XIntervalDataItem(1.1, 2.0, 3.0, 4.0); + assertFalse(item1.equals(item2)); + item2 = new XIntervalDataItem(1.1, 2.0, 3.0, 4.0); + assertTrue(item1.equals(item2)); + + // xLow + item1 = new XIntervalDataItem(1.1, 2.2, 3.0, 4.0); + assertFalse(item1.equals(item2)); + item2 = new XIntervalDataItem(1.1, 2.2, 3.0, 4.0); + assertTrue(item1.equals(item2)); + + // xHigh + item1 = new XIntervalDataItem(1.1, 2.2, 3.3, 4.0); + assertFalse(item1.equals(item2)); + item2 = new XIntervalDataItem(1.1, 2.2, 3.3, 4.0); + assertTrue(item1.equals(item2)); + + // y + item1 = new XIntervalDataItem(1.1, 2.2, 3.3, 4.4); + assertFalse(item1.equals(item2)); + item2 = new XIntervalDataItem(1.1, 2.2, 3.3, 4.4); + assertTrue(item1.equals(item2)); + + } + + /** + * Some checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XIntervalDataItem item1 = new XIntervalDataItem(1.0, 2.0, 3.0, 4.0); + XIntervalDataItem item2 = (XIntervalDataItem) item1.clone(); + assertTrue(item1 != item2); + assertTrue(item1.getClass() == item2.getClass()); + assertTrue(item1.equals(item2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XIntervalDataItem item1 = new XIntervalDataItem(1.0, 2.0, 3.0, 4.0); + XIntervalDataItem item2 = (XIntervalDataItem) TestUtilities.serialised(item1); + assertEquals(item1, item2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XIntervalSeriesCollectionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XIntervalSeriesCollectionTest.java new file mode 100755 index 0000000..4d2bf91 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XIntervalSeriesCollectionTest.java @@ -0,0 +1,177 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------- + * XIntervalSeriesCollectionTest.java + * ---------------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * 18-Jan-2008 : Added testRemoveSeries() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XIntervalSeriesCollection} class. + */ +public class XIntervalSeriesCollectionTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XIntervalSeriesCollection c1 = new XIntervalSeriesCollection(); + XIntervalSeriesCollection c2 = new XIntervalSeriesCollection(); + assertEquals(c1, c2); + + // add a series + XIntervalSeries s1 = new XIntervalSeries("Series"); + s1.add(1.0, 1.1, 1.2, 1.3); + c1.addSeries(s1); + assertFalse(c1.equals(c2)); + XIntervalSeries s2 = new XIntervalSeries("Series"); + s2.add(1.0, 1.1, 1.2, 1.3); + c2.addSeries(s2); + assertTrue(c1.equals(c2)); + + // add an empty series + c1.addSeries(new XIntervalSeries("Empty Series")); + assertFalse(c1.equals(c2)); + c2.addSeries(new XIntervalSeries("Empty Series")); + assertTrue(c1.equals(c2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XIntervalSeriesCollection c1 = new XIntervalSeriesCollection(); + XIntervalSeries s1 = new XIntervalSeries("Series"); + s1.add(1.0, 1.1, 1.2, 1.3); + c1.addSeries(s1); + XIntervalSeriesCollection c2 = (XIntervalSeriesCollection) c1.clone(); + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + + // check independence + s1.setDescription("XYZ"); + assertFalse(c1.equals(c2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XIntervalSeriesCollection c1 = new XIntervalSeriesCollection(); + assertTrue(c1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XIntervalSeriesCollection c1 = new XIntervalSeriesCollection(); + XIntervalSeries s1 = new XIntervalSeries("Series"); + s1.add(1.0, 1.1, 1.2, 1.3); + XIntervalSeriesCollection c2 = (XIntervalSeriesCollection) + TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + + /** + * Some basic checks for the removeSeries() method. + */ + @Test + public void testRemoveSeries() { + XIntervalSeriesCollection c = new XIntervalSeriesCollection(); + XIntervalSeries s1 = new XIntervalSeries("s1"); + c.addSeries(s1); + c.removeSeries(0); + assertEquals(0, c.getSeriesCount()); + c.addSeries(s1); + + boolean pass = false; + try { + c.removeSeries(-1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + c.removeSeries(1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * A test for bug report 1170825 (originally affected XYSeriesCollection, + * this test is just copied over). + */ + @Test + public void test1170825() { + XIntervalSeries s1 = new XIntervalSeries("Series1"); + XIntervalSeriesCollection dataset = new XIntervalSeriesCollection(); + dataset.addSeries(s1); + try { + /* XYSeries s = */ dataset.getSeries(1); + } + catch (IllegalArgumentException e) { + // correct outcome + } + catch (IndexOutOfBoundsException e) { + assertTrue(false); // wrong outcome + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XIntervalSeriesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XIntervalSeriesTest.java new file mode 100755 index 0000000..afd5551 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XIntervalSeriesTest.java @@ -0,0 +1,301 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * XIntervalSeriesTest.java + * ------------------------ + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1, based on XYSeriesTests (DG); + * 27-Nov-2007 : Added testClear() method (DG); + * 10-Apr-2008 : Added testGetXLowValue() and testGetXHighValue() (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.data.general.SeriesChangeListener; +import org.junit.Test; + +/** + * Tests for the {@link XIntervalSeries} class. + */ +public class XIntervalSeriesTest implements SeriesChangeListener { + + SeriesChangeEvent lastEvent; + + /** + * Records the last event. + * + * @param event the event. + */ + public void seriesChanged(SeriesChangeEvent event) { + this.lastEvent = event; + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XIntervalSeries s1 = new XIntervalSeries("s1"); + XIntervalSeries s2 = new XIntervalSeries("s1"); + assertTrue(s1.equals(s2)); + + // seriesKey + s1 = new XIntervalSeries("s2"); + assertFalse(s1.equals(s2)); + s2 = new XIntervalSeries("s2"); + assertTrue(s1.equals(s2)); + + // autoSort + s1 = new XIntervalSeries("s2", false, true); + assertFalse(s1.equals(s2)); + s2 = new XIntervalSeries("s2", false, true); + assertTrue(s1.equals(s2)); + + // allowDuplicateValues + s1 = new XIntervalSeries("s2", false, false); + assertFalse(s1.equals(s2)); + s2 = new XIntervalSeries("s2", false, false); + assertTrue(s1.equals(s2)); + + // add a value + s1.add(1.0, 0.5, 1.5, 2.0); + assertFalse(s1.equals(s2)); + s2.add(1.0, 0.5, 1.5, 2.0); + assertTrue(s2.equals(s1)); + + // add another value + s1.add(2.0, 0.5, 1.5, 2.0); + assertFalse(s1.equals(s2)); + s2.add(2.0, 0.5, 1.5, 2.0); + assertTrue(s2.equals(s1)); + + // remove a value + s1.remove(new Double(1.0)); + assertFalse(s1.equals(s2)); + s2.remove(new Double(1.0)); + assertTrue(s2.equals(s1)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XIntervalSeries s1 = new XIntervalSeries("s1"); + s1.add(1.0, 0.5, 1.5, 2.0); + XIntervalSeries s2 = (XIntervalSeries) s1.clone(); + assertTrue(s1 != s2); + assertTrue(s1.getClass() == s2.getClass()); + assertTrue(s1.equals(s2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XIntervalSeries s1 = new XIntervalSeries("s1"); + s1.add(1.0, 0.5, 1.5, 2.0); + XIntervalSeries s2 = (XIntervalSeries) TestUtilities.serialised(s1); + assertEquals(s1, s2); + } + + /** + * Simple test for the indexOf() method. + */ + @Test + public void testIndexOf() { + XIntervalSeries s1 = new XIntervalSeries("Series 1"); + s1.add(1.0, 1.0, 1.0, 2.0); + s1.add(2.0, 2.0, 2.0, 3.0); + s1.add(3.0, 3.0, 3.0, 4.0); + assertEquals(0, s1.indexOf(new Double(1.0))); + } + + /** + * A check for the indexOf() method for an unsorted series. + */ + @Test + public void testIndexOf2() { + XIntervalSeries s1 = new XIntervalSeries("Series 1", false, true); + s1.add(1.0, 1.0, 1.0, 2.0); + s1.add(3.0, 3.0, 3.0, 3.0); + s1.add(2.0, 2.0, 2.0, 2.0); + assertEquals(0, s1.indexOf(new Double(1.0))); + assertEquals(1, s1.indexOf(new Double(3.0))); + assertEquals(2, s1.indexOf(new Double(2.0))); + } + + /** + * Simple test for the remove() method. + */ + @Test + public void testRemove() { + XIntervalSeries s1 = new XIntervalSeries("Series 1"); + s1.add(1.0, 1.0, 1.0, 2.0); + s1.add(2.0, 2.0, 2.0, 2.0); + s1.add(3.0, 3.0, 3.0, 3.0); + assertEquals(3, s1.getItemCount()); + + s1.remove(new Double(2.0)); + assertEquals(new Double(3.0), s1.getX(1)); + + s1.remove(new Double(1.0)); + assertEquals(new Double(3.0), s1.getX(0)); + } + + private static final double EPSILON = 0.0000000001; + + /** + * When items are added with duplicate x-values, we expect them to remain + * in the order they were added. + */ + @Test + public void testAdditionOfDuplicateXValues() { + XIntervalSeries s1 = new XIntervalSeries("Series 1"); + s1.add(1.0, 1.0, 1.0, 1.0); + s1.add(2.0, 2.0, 2.0, 2.0); + s1.add(2.0, 3.0, 3.0, 3.0); + s1.add(2.0, 4.0, 4.0, 4.0); + s1.add(3.0, 5.0, 5.0, 5.0); + assertEquals(1.0, s1.getYValue(0), EPSILON); + assertEquals(2.0, s1.getYValue(1), EPSILON); + assertEquals(3.0, s1.getYValue(2), EPSILON); + assertEquals(4.0, s1.getYValue(3), EPSILON); + assertEquals(5.0, s1.getYValue(4), EPSILON); + } + + /** + * Some checks for the add() method for an UNSORTED series. + */ + @Test + public void testAdd() { + XIntervalSeries series = new XIntervalSeries("Series", false, true); + series.add(5.0, 5.50, 5.50, 5.50); + series.add(5.1, 5.51, 5.51, 5.51); + series.add(6.0, 6.6, 6.6, 6.6); + series.add(3.0, 3.3, 3.3, 3.3); + series.add(4.0, 4.4, 4.4, 4.4); + series.add(2.0, 2.2, 2.2, 2.2); + series.add(1.0, 1.1, 1.1, 1.1); + assertEquals(5.5, series.getYValue(0), EPSILON); + assertEquals(5.51, series.getYValue(1), EPSILON); + assertEquals(6.6, series.getYValue(2), EPSILON); + assertEquals(3.3, series.getYValue(3), EPSILON); + assertEquals(4.4, series.getYValue(4), EPSILON); + assertEquals(2.2, series.getYValue(5), EPSILON); + assertEquals(1.1, series.getYValue(6), EPSILON); + } + + /** + * A simple check that the maximumItemCount attribute is working. + */ + @Test + public void testSetMaximumItemCount() { + XIntervalSeries s1 = new XIntervalSeries("S1"); + assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); + s1.setMaximumItemCount(2); + assertEquals(2, s1.getMaximumItemCount()); + s1.add(1.0, 1.1, 1.1, 1.1); + s1.add(2.0, 2.2, 2.2, 2.2); + s1.add(3.0, 3.3, 3.3, 3.3); + assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); + assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); + } + + /** + * Check that the maximum item count can be applied retrospectively. + */ + @Test + public void testSetMaximumItemCount2() { + XIntervalSeries s1 = new XIntervalSeries("S1"); + s1.add(1.0, 1.1, 1.1, 1.1); + s1.add(2.0, 2.2, 2.2, 2.2); + s1.add(3.0, 3.3, 3.3, 3.3); + s1.setMaximumItemCount(2); + assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); + assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); + } + + /** + * Some checks for the clear() method. + */ + @Test + public void testClear() { + XIntervalSeries s1 = new XIntervalSeries("S1"); + s1.addChangeListener(this); + s1.clear(); + assertNull(this.lastEvent); + assertTrue(s1.isEmpty()); + s1.add(1.0, 2.0, 3.0, 4.0); + assertFalse(s1.isEmpty()); + s1.clear(); + assertNotNull(this.lastEvent); + assertTrue(s1.isEmpty()); + } + + /** + * A simple check for getXLowValue(). + */ + @Test + public void testGetXLowValue() { + XIntervalSeries s1 = new XIntervalSeries("S1"); + s1.add(1.0, 2.0, 3.0, 4.0); + assertEquals(2.0, s1.getXLowValue(0), EPSILON); + s1.add(2.0, 1.0, 4.0, 2.5); + assertEquals(1.0, s1.getXLowValue(1), EPSILON); + } + + /** + * A simple check for getXHighValue(). + */ + @Test + public void testGetXHighValue() { + XIntervalSeries s1 = new XIntervalSeries("S1"); + s1.add(1.0, 2.0, 3.0, 4.0); + assertEquals(3.0, s1.getXHighValue(0), EPSILON); + s1.add(2.0, 1.0, 4.0, 2.5); + assertEquals(4.0, s1.getXHighValue(1), EPSILON); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYBarDatasetTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYBarDatasetTest.java new file mode 100755 index 0000000..44a2cee --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYBarDatasetTest.java @@ -0,0 +1,134 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * XYBarDatasetTest.java + * --------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 25-Jan-2007 : Version 1 (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Some tests for the {@link XYBarDataset} class. + */ +public class XYBarDatasetTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + DefaultXYDataset d1 = new DefaultXYDataset(); + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[][] data1 = new double[][] {x1, y1}; + d1.addSeries("S1", data1); + DefaultXYDataset d2 = new DefaultXYDataset(); + double[] x2 = new double[] {1.0, 2.0, 3.0}; + double[] y2 = new double[] {4.0, 5.0, 6.0}; + double[][] data2 = new double[][] {x2, y2}; + d2.addSeries("S1", data2); + + XYBarDataset bd1 = new XYBarDataset(d1, 5.0); + XYBarDataset bd2 = new XYBarDataset(d2, 5.0); + assertTrue(bd1.equals(bd2)); + assertTrue(bd2.equals(bd1)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + DefaultXYDataset d1 = new DefaultXYDataset(); + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[][] data1 = new double[][] {x1, y1}; + d1.addSeries("S1", data1); + XYBarDataset bd1 = new XYBarDataset(d1, 5.0); + XYBarDataset bd2 = (XYBarDataset) bd1.clone(); + assertTrue(bd1 != bd2); + assertTrue(bd1.getClass() == bd2.getClass()); + assertTrue(bd1.equals(bd2)); + + // check independence + d1 = (DefaultXYDataset) bd1.getUnderlyingDataset(); + d1.addSeries("S2", new double[][] {{1.0}, {2.0}}); + assertFalse(bd1.equals(bd2)); + DefaultXYDataset d2 = (DefaultXYDataset) bd2.getUnderlyingDataset(); + d2.addSeries("S2", new double[][] {{1.0}, {2.0}}); + assertTrue(bd1.equals(bd2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + DefaultXYDataset d1 = new DefaultXYDataset(); + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[][] data1 = new double[][] {x1, y1}; + d1.addSeries("S1", data1); + XYBarDataset bd1 = new XYBarDataset(d1, 5.0); + assertTrue(bd1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + DefaultXYDataset d1 = new DefaultXYDataset(); + double[] x1 = new double[] {1.0, 2.0, 3.0}; + double[] y1 = new double[] {4.0, 5.0, 6.0}; + double[][] data1 = new double[][] {x1, y1}; + d1.addSeries("S1", data1); + XYBarDataset bd1 = new XYBarDataset(d1, 5.0); + XYBarDataset bd2 = (XYBarDataset) TestUtilities.serialised(bd1); + assertEquals(bd1, bd2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYCoordinateTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYCoordinateTest.java new file mode 100755 index 0000000..d5bb5c3 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYCoordinateTest.java @@ -0,0 +1,109 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------- + * XYCoordinateTest.java + * --------------------- + * (C) Copyright 2007-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 30-Jan-2007 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link XYCoordinate} class. + */ +public class XYCoordinateTest { + + /** + * Test that the equals() method distinguishes all fields. + */ + @Test + public void testEquals() { + // default instances + XYCoordinate v1 = new XYCoordinate(1.0, 2.0); + XYCoordinate v2 = new XYCoordinate(1.0, 2.0); + assertTrue(v1.equals(v2)); + assertTrue(v2.equals(v1)); + + v1 = new XYCoordinate(1.1, 2.0); + assertFalse(v1.equals(v2)); + v2 = new XYCoordinate(1.1, 2.0); + assertTrue(v1.equals(v2)); + + v1 = new XYCoordinate(1.1, 2.2); + assertFalse(v1.equals(v2)); + v2 = new XYCoordinate(1.1, 2.2); + assertTrue(v1.equals(v2)); + } + + /** + * Two objects that are equal are required to return the same hashCode. + */ + @Test + public void testHashcode() { + XYCoordinate v1 = new XYCoordinate(1.0, 2.0); + XYCoordinate v2 = new XYCoordinate(1.0, 2.0); + assertTrue(v1.equals(v2)); + int h1 = v1.hashCode(); + int h2 = v2.hashCode(); + assertEquals(h1, h2); + } + + /** + * Immutable class is not cloneable. + */ + @Test + public void testCloning() { + XYCoordinate v1 = new XYCoordinate(1.0, 2.0); + assertFalse(v1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYCoordinate v1 = new XYCoordinate(1.0, 2.0); + XYCoordinate v2 = (XYCoordinate) TestUtilities.serialised(v1); + assertEquals(v1, v2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYDataItemTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYDataItemTest.java new file mode 100755 index 0000000..79dd6e5 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYDataItemTest.java @@ -0,0 +1,94 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * XYDataItemTest.java + * ------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Dec-2003 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link XYDataItem} class. + */ +public class XYDataItemTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XYDataItem i1 = new XYDataItem(1.0, 1.1); + XYDataItem i2 = new XYDataItem(1.0, 1.1); + assertTrue(i1.equals(i2)); + assertTrue(i2.equals(i1)); + + i1.setY(new Double(9.9)); + assertFalse(i1.equals(i2)); + + i2.setY(new Double(9.9)); + assertTrue(i1.equals(i2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() { + XYDataItem i1 = new XYDataItem(1.0, 1.1); + XYDataItem i2 = (XYDataItem) i1.clone(); + assertTrue(i1 != i2); + assertTrue(i1.getClass() == i2.getClass()); + assertTrue(i1.equals(i2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYDataItem i1 = new XYDataItem(1.0, 1.1); + XYDataItem i2 = (XYDataItem) TestUtilities.serialised(i1); + assertEquals(i1, i2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYIntervalDataItemTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYIntervalDataItemTest.java new file mode 100755 index 0000000..b8464b0 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYIntervalDataItemTest.java @@ -0,0 +1,145 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * XYIntervalDataItemTest.java + * --------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link XYIntervalDataItem} class. + */ +public class XYIntervalDataItemTest { + + private static final double EPSILON = 0.000000001; + /** + * Some checks for the constructor. + */ + @Test + public void testConstructor1() { + XYIntervalDataItem item1 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, + 1.9, 2.1); + assertEquals(new Double(1.0), item1.getX()); + assertEquals(0.5, item1.getXLowValue(), EPSILON); + assertEquals(1.5, item1.getXHighValue(), EPSILON); + assertEquals(2.0, item1.getYValue(), EPSILON); + assertEquals(1.9, item1.getYLowValue(), EPSILON); + assertEquals(2.1, item1.getYHighValue(), EPSILON); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XYIntervalDataItem item1 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, + 1.9, 2.1); + XYIntervalDataItem item2 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, + 1.9, 2.1); + assertTrue(item1.equals(item2)); + assertTrue(item2.equals(item1)); + + // x + item1 = new XYIntervalDataItem(1.1, 0.5, 1.5, 2.0, 1.9, 2.1); + assertFalse(item1.equals(item2)); + item2 = new XYIntervalDataItem(1.1, 0.5, 1.5, 2.0, 1.9, 2.1); + assertTrue(item1.equals(item2)); + + // xLow + item1 = new XYIntervalDataItem(1.1, 0.55, 1.5, 2.0, 1.9, 2.1); + assertFalse(item1.equals(item2)); + item2 = new XYIntervalDataItem(1.1, 0.55, 1.5, 2.0, 1.9, 2.1); + assertTrue(item1.equals(item2)); + + // xHigh + item1 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.0, 1.9, 2.1); + assertFalse(item1.equals(item2)); + item2 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.0, 1.9, 2.1); + assertTrue(item1.equals(item2)); + + // y + item1 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.9, 2.1); + assertFalse(item1.equals(item2)); + item2 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.9, 2.1); + assertTrue(item1.equals(item2)); + + // yLow + item1 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.99, 2.1); + assertFalse(item1.equals(item2)); + item2 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.99, 2.1); + assertTrue(item1.equals(item2)); + + // yHigh + item1 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.99, 2.11); + assertFalse(item1.equals(item2)); + item2 = new XYIntervalDataItem(1.1, 0.55, 1.55, 2.2, 1.99, 2.11); + assertTrue(item1.equals(item2)); + } + + /** + * Some checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYIntervalDataItem item1 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, + 1.9, 2.1); + XYIntervalDataItem item2 = (XYIntervalDataItem) item1.clone(); + assertTrue(item1 != item2); + assertTrue(item1.getClass() == item2.getClass()); + assertTrue(item1.equals(item2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYIntervalDataItem item1 = new XYIntervalDataItem(1.0, 0.5, 1.5, 2.0, + 1.9, 2.1); + XYIntervalDataItem item2 = (XYIntervalDataItem) + TestUtilities.serialised(item1); + assertEquals(item1, item2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYIntervalSeriesCollectionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYIntervalSeriesCollectionTest.java new file mode 100755 index 0000000..9d1873a --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYIntervalSeriesCollectionTest.java @@ -0,0 +1,185 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------------------- + * XYIntervalSeriesCollectionTest.java + * ----------------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * 13-Feb-2007 : Check for independence in testCloning() (DG); + * 18-Jan-2008 : Added testRemoveSeries() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYIntervalSeriesCollection} class. + */ +public class XYIntervalSeriesCollectionTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection(); + XYIntervalSeriesCollection c2 = new XYIntervalSeriesCollection(); + assertEquals(c1, c2); + + // add a series + XYIntervalSeries s1 = new XYIntervalSeries("Series"); + s1.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5); + c1.addSeries(s1); + assertFalse(c1.equals(c2)); + XYIntervalSeries s2 = new XYIntervalSeries("Series"); + s2.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5); + c2.addSeries(s2); + assertTrue(c1.equals(c2)); + + // add an empty series + c1.addSeries(new XYIntervalSeries("Empty Series")); + assertFalse(c1.equals(c2)); + c2.addSeries(new XYIntervalSeries("Empty Series")); + assertTrue(c1.equals(c2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection(); + XYIntervalSeries s1 = new XYIntervalSeries("Series"); + s1.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5); + XYIntervalSeriesCollection c2 = (XYIntervalSeriesCollection) c1.clone(); + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + + // check independence + c1.addSeries(new XYIntervalSeries("Empty")); + assertFalse(c1.equals(c2)); + c2.addSeries(new XYIntervalSeries("Empty")); + assertTrue(c1.equals(c2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection(); + assertTrue(c1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYIntervalSeriesCollection c1 = new XYIntervalSeriesCollection(); + XYIntervalSeries s1 = new XYIntervalSeries("Series"); + s1.add(1.0, 1.1, 1.2, 1.3, 1.4, 1.5); + XYIntervalSeriesCollection c2 = (XYIntervalSeriesCollection) + TestUtilities.serialised(c1); + assertEquals(c1, c2); + + // check independence + c1.addSeries(new XYIntervalSeries("Empty")); + assertFalse(c1.equals(c2)); + c2.addSeries(new XYIntervalSeries("Empty")); + assertTrue(c1.equals(c2)); + } + + /** + * Some basic checks for the removeSeries() method. + */ + @Test + public void testRemoveSeries() { + XYIntervalSeriesCollection c = new XYIntervalSeriesCollection(); + XYIntervalSeries s1 = new XYIntervalSeries("s1"); + c.addSeries(s1); + c.removeSeries(0); + assertEquals(0, c.getSeriesCount()); + c.addSeries(s1); + + boolean pass = false; + try { + c.removeSeries(-1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + c.removeSeries(1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * A test for bug report 1170825 (originally affected XYSeriesCollection, + * this test is just copied over). + */ + @Test + public void test1170825() { + XYIntervalSeries s1 = new XYIntervalSeries("Series1"); + XYIntervalSeriesCollection dataset = new XYIntervalSeriesCollection(); + dataset.addSeries(s1); + try { + /* XYSeries s = */ dataset.getSeries(1); + } + catch (IllegalArgumentException e) { + // correct outcome + } + catch (IndexOutOfBoundsException e) { + assertTrue(false); // wrong outcome + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYIntervalSeriesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYIntervalSeriesTest.java new file mode 100755 index 0000000..3243bba --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYIntervalSeriesTest.java @@ -0,0 +1,292 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------- + * XYIntervalSeriesTest.java + * ------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1, based on XYSeriesTests (DG); + * 13-Feb-2007 : Added testValues() (DG); + * 27-Nov-2007 : Added testClear() method (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.data.general.SeriesChangeListener; +import org.junit.Test; + +/** + * Tests for the {@link XYIntervalSeries} class. + */ +public class XYIntervalSeriesTest implements SeriesChangeListener { + + SeriesChangeEvent lastEvent; + + /** + * Records the last event. + * + * @param event the event. + */ + public void seriesChanged(SeriesChangeEvent event) { + this.lastEvent = event; + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XYIntervalSeries s1 = new XYIntervalSeries("s1"); + XYIntervalSeries s2 = new XYIntervalSeries("s1"); + assertTrue(s1.equals(s2)); + + // seriesKey + s1 = new XYIntervalSeries("s2"); + assertFalse(s1.equals(s2)); + s2 = new XYIntervalSeries("s2"); + assertTrue(s1.equals(s2)); + + // autoSort + s1 = new XYIntervalSeries("s2", false, true); + assertFalse(s1.equals(s2)); + s2 = new XYIntervalSeries("s2", false, true); + assertTrue(s1.equals(s2)); + + // allowDuplicateValues + s1 = new XYIntervalSeries("s2", false, false); + assertFalse(s1.equals(s2)); + s2 = new XYIntervalSeries("s2", false, false); + assertTrue(s1.equals(s2)); + + // add a value + s1.add(1.0, 0.5, 1.5, 2.0, 1.9, 2.1); + assertFalse(s1.equals(s2)); + s2.add(1.0, 0.5, 1.5, 2.0, 1.9, 2.1); + assertTrue(s2.equals(s1)); + + // add another value + s1.add(2.0, 0.5, 1.5, 2.0, 1.9, 2.1); + assertFalse(s1.equals(s2)); + s2.add(2.0, 0.5, 1.5, 2.0, 1.9, 2.1); + assertTrue(s2.equals(s1)); + + // remove a value + s1.remove(new Double(1.0)); + assertFalse(s1.equals(s2)); + s2.remove(new Double(1.0)); + assertTrue(s2.equals(s1)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYIntervalSeries s1 = new XYIntervalSeries("s1"); + s1.add(1.0, 0.5, 1.5, 2.0, 1.9, 2.01); + XYIntervalSeries s2 = (XYIntervalSeries) s1.clone(); + assertTrue(s1 != s2); + assertTrue(s1.getClass() == s2.getClass()); + assertTrue(s1.equals(s2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYIntervalSeries s1 = new XYIntervalSeries("s1"); + s1.add(1.0, 0.5, 1.5, 2.0, 1.9, 2.1); + XYIntervalSeries s2 = (XYIntervalSeries) TestUtilities.serialised(s1); + assertEquals(s1, s2); + } + + /** + * Simple test for the indexOf() method. + */ + @Test + public void testIndexOf() { + XYIntervalSeries s1 = new XYIntervalSeries("Series 1"); + s1.add(1.0, 1.0, 1.0, 2.0, 1.9, 2.1); + s1.add(2.0, 2.0, 2.0, 3.0, 2.9, 3.1); + s1.add(3.0, 3.0, 3.0, 4.0, 3.9, 4.1); + assertEquals(0, s1.indexOf(new Double(1.0))); + } + + /** + * A check for the indexOf() method for an unsorted series. + */ + @Test + public void testIndexOf2() { + XYIntervalSeries s1 = new XYIntervalSeries("Series 1", false, true); + s1.add(1.0, 1.0, 1.0, 2.0, 1.9, 2.1); + s1.add(3.0, 3.0, 3.0, 3.0, 2.9, 3.1); + s1.add(2.0, 2.0, 2.0, 2.0, 1.9, 2.1); + assertEquals(0, s1.indexOf(new Double(1.0))); + assertEquals(1, s1.indexOf(new Double(3.0))); + assertEquals(2, s1.indexOf(new Double(2.0))); + } + + /** + * Simple test for the remove() method. + */ + @Test + public void testRemove() { + XYIntervalSeries s1 = new XYIntervalSeries("Series 1"); + s1.add(1.0, 1.0, 1.0, 2.0, 1.9, 2.1); + s1.add(2.0, 2.0, 2.0, 2.0, 1.9, 2.1); + s1.add(3.0, 3.0, 3.0, 3.0, 2.9, 3.1); + assertEquals(3, s1.getItemCount()); + + s1.remove(new Double(2.0)); + assertEquals(new Double(3.0), s1.getX(1)); + + s1.remove(new Double(1.0)); + assertEquals(new Double(3.0), s1.getX(0)); + } + + private static final double EPSILON = 0.0000000001; + + /** + * When items are added with duplicate x-values, we expect them to remain + * in the order they were added. + */ + @Test + public void testAdditionOfDuplicateXValues() { + XYIntervalSeries s1 = new XYIntervalSeries("Series 1"); + s1.add(1.0, 1.0, 1.0, 1.0, 1.0, 1.0); + s1.add(2.0, 2.0, 2.0, 2.0, 2.0, 2.0); + s1.add(2.0, 3.0, 3.0, 3.0, 3.0, 3.0); + s1.add(2.0, 4.0, 4.0, 4.0, 4.0, 4.0); + s1.add(3.0, 5.0, 5.0, 5.0, 5.0, 5.0); + assertEquals(1.0, s1.getYValue(0), EPSILON); + assertEquals(2.0, s1.getYValue(1), EPSILON); + assertEquals(3.0, s1.getYValue(2), EPSILON); + assertEquals(4.0, s1.getYValue(3), EPSILON); + assertEquals(5.0, s1.getYValue(4), EPSILON); + } + + /** + * Some checks for the add() method for an UNSORTED series. + */ + @Test + public void testAdd() { + XYIntervalSeries series = new XYIntervalSeries("Series", false, true); + series.add(5.0, 5.50, 5.50, 5.50, 5.50, 5.50); + series.add(5.1, 5.51, 5.51, 5.51, 5.51, 5.51); + series.add(6.0, 6.6, 6.6, 6.6, 6.6, 6.6); + series.add(3.0, 3.3, 3.3, 3.3, 3.3, 3.3); + series.add(4.0, 4.4, 4.4, 4.4, 4.4, 4.4); + series.add(2.0, 2.2, 2.2, 2.2, 2.2, 2.2); + series.add(1.0, 1.1, 1.1, 1.1, 1.1, 1.1); + assertEquals(5.5, series.getYValue(0), EPSILON); + assertEquals(5.51, series.getYValue(1), EPSILON); + assertEquals(6.6, series.getYValue(2), EPSILON); + assertEquals(3.3, series.getYValue(3), EPSILON); + assertEquals(4.4, series.getYValue(4), EPSILON); + assertEquals(2.2, series.getYValue(5), EPSILON); + assertEquals(1.1, series.getYValue(6), EPSILON); + } + + /** + * A simple check that the maximumItemCount attribute is working. + */ + @Test + public void testSetMaximumItemCount() { + XYIntervalSeries s1 = new XYIntervalSeries("S1"); + assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); + s1.setMaximumItemCount(2); + assertEquals(2, s1.getMaximumItemCount()); + s1.add(1.0, 1.1, 1.1, 1.1, 1.1, 1.1); + s1.add(2.0, 2.2, 2.2, 2.2, 2.2, 2.2); + s1.add(3.0, 3.3, 3.3, 3.3, 3.3, 3.3); + assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); + assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); + } + + /** + * Check that the maximum item count can be applied retrospectively. + */ + @Test + public void testSetMaximumItemCount2() { + XYIntervalSeries s1 = new XYIntervalSeries("S1"); + s1.add(1.0, 1.1, 1.1, 1.1, 1.1, 1.1); + s1.add(2.0, 2.2, 2.2, 2.2, 2.2, 2.2); + s1.add(3.0, 3.3, 3.3, 3.3, 2.2, 2.2); + s1.setMaximumItemCount(2); + assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); + assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); + } + + /** + * Some checks for the new accessor methods added in 1.0.5. + */ + @Test + public void testValues() { + XYIntervalSeries s1 = new XYIntervalSeries("S1"); + s1.add(2.0, 1.0, 3.0, 5.0, 4.0, 6.0); + assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); + assertEquals(1.0, s1.getXLowValue(0), EPSILON); + assertEquals(3.0, s1.getXHighValue(0), EPSILON); + assertEquals(5.0, s1.getYValue(0), EPSILON); + assertEquals(4.0, s1.getYLowValue(0), EPSILON); + assertEquals(6.0, s1.getYHighValue(0), EPSILON); + } + + /** + * Some checks for the clear() method. + */ + @Test + public void testClear() { + XYIntervalSeries s1 = new XYIntervalSeries("S1"); + s1.addChangeListener(this); + s1.clear(); + assertNull(this.lastEvent); + assertTrue(s1.isEmpty()); + s1.add(1.0, 2.0, 3.0, 4.0, 5.0, 6.0); + assertFalse(s1.isEmpty()); + s1.clear(); + assertNotNull(this.lastEvent); + assertTrue(s1.isEmpty()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYIntervalTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYIntervalTest.java new file mode 100755 index 0000000..20fbdff --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYIntervalTest.java @@ -0,0 +1,109 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------- + * XYIntervalTest.java + * ------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link XYInterval} class. + */ +public class XYIntervalTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XYInterval i1 = new XYInterval(1.0, 2.0, 3.0, 2.5, 3.5); + XYInterval i2 = new XYInterval(1.0, 2.0, 3.0, 2.5, 3.5); + assertEquals(i1, i2); + + i1 = new XYInterval(1.1, 2.0, 3.0, 2.5, 3.5); + assertFalse(i1.equals(i2)); + i2 = new XYInterval(1.1, 2.0, 3.0, 2.5, 3.5); + assertTrue(i1.equals(i2)); + + i1 = new XYInterval(1.1, 2.2, 3.0, 2.5, 3.5); + assertFalse(i1.equals(i2)); + i2 = new XYInterval(1.1, 2.2, 3.0, 2.5, 3.5); + assertTrue(i1.equals(i2)); + + i1 = new XYInterval(1.1, 2.2, 3.3, 2.5, 3.5); + assertFalse(i1.equals(i2)); + i2 = new XYInterval(1.1, 2.2, 3.3, 2.5, 3.5); + assertTrue(i1.equals(i2)); + + i1 = new XYInterval(1.1, 2.2, 3.3, 2.6, 3.5); + assertFalse(i1.equals(i2)); + i2 = new XYInterval(1.1, 2.2, 3.3, 2.6, 3.5); + assertTrue(i1.equals(i2)); + + i1 = new XYInterval(1.1, 2.2, 3.3, 2.6, 3.6); + assertFalse(i1.equals(i2)); + i2 = new XYInterval(1.1, 2.2, 3.3, 2.6, 3.6); + assertTrue(i1.equals(i2)); + } + + /** + * This class is immutable. + */ + @Test + public void testCloning() { + XYInterval i1 = new XYInterval(1.0, 2.0, 3.0, 2.5, 3.5); + assertFalse(i1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYInterval i1 = new XYInterval(1.0, 2.0, 3.0, 2.5, 3.5); + XYInterval i2 = (XYInterval) TestUtilities.serialised(i1); + assertEquals(i1, i2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYSeriesCollectionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYSeriesCollectionTest.java new file mode 100755 index 0000000..852af44 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYSeriesCollectionTest.java @@ -0,0 +1,448 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * --------------------------- + * XYSeriesCollectionTest.java + * --------------------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 18-May-2003 : Version 1 (DG); + * 27-Nov-2006 : Updated testCloning() (DG); + * 08-Mar-2007 : Added testGetSeries() and testRemoveSeries() (DG); + * 08-May-2007 : Added testIndexOf() (DG); + * 03-Dec-2007 : Added testGetSeriesByKey() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * 06-Mar-2009 : Added testGetDomainBounds (DG); + * 17-May-2010 : Added checks for duplicate series names (DG); + * 08-Jan-2012 : Added testBug3445507() (DG); + * 28-Jul-2012 : Added testSeriesRename() (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertNotSame; +import static org.junit.Assert.fail + ; +import org.jfree.chart.TestUtilities; + +import org.jfree.data.Range; +import org.jfree.data.UnknownKeyException; +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link XYSeriesCollection} class. + */ +public class XYSeriesCollectionTest { + + private static final double EPSILON = 0.0000000001; + + /** + * Some checks for the constructor. + */ + @Test + public void testConstructor() { + XYSeriesCollection xysc = new XYSeriesCollection(); + assertEquals(0, xysc.getSeriesCount()); + assertEquals(1.0, xysc.getIntervalWidth(), EPSILON); + assertEquals(0.5, xysc.getIntervalPositionFactor(), EPSILON); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XYSeries s1 = new XYSeries("Series"); + s1.add(1.0, 1.1); + XYSeriesCollection c1 = new XYSeriesCollection(); + c1.addSeries(s1); + XYSeries s2 = new XYSeries("Series"); + s2.add(1.0, 1.1); + XYSeriesCollection c2 = new XYSeriesCollection(); + c2.addSeries(s2); + assertEquals(c1, c2); + assertEquals(c2, c1); + + c1.addSeries(new XYSeries("Empty Series")); + assertFalse(c1.equals(c2)); + c2.addSeries(new XYSeries("Empty Series")); + assertEquals(c1, c2); + + c1.setIntervalWidth(5.0); + assertFalse(c1.equals(c2)); + c2.setIntervalWidth(5.0); + assertEquals(c1, c2); + + c1.setIntervalPositionFactor(0.75); + assertFalse(c1.equals(c2)); + c2.setIntervalPositionFactor(0.75); + assertEquals(c1, c2); + + c1.setAutoWidth(true); + assertFalse(c1.equals(c2)); + c2.setAutoWidth(true); + assertEquals(c1, c2); + + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYSeries s1 = new XYSeries("Series"); + s1.add(1.0, 1.1); + XYSeriesCollection c1 = new XYSeriesCollection(); + c1.addSeries(s1); + XYSeriesCollection c2 = (XYSeriesCollection) c1.clone(); + assertNotSame(c1, c2); + assertSame(c1.getClass(), c2.getClass()); + assertEquals(c1, c2); + + // check independence + s1.setDescription("XYZ"); + assertFalse(c1.equals(c2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + Object c1 = new XYSeriesCollection(); + assertTrue(c1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYSeries s1 = new XYSeries("Series"); + s1.add(1.0, 1.1); + XYSeriesCollection c1 = new XYSeriesCollection(); + c1.addSeries(s1); + XYSeriesCollection c2 = (XYSeriesCollection) + TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + + /** + * A test for bug report 1170825. + */ + @Test + public void test1170825() { + XYSeries s1 = new XYSeries("Series1"); + XYSeriesCollection dataset = new XYSeriesCollection(); + dataset.addSeries(s1); + try { + /* XYSeries s = */ dataset.getSeries(1); + } + catch (IllegalArgumentException e) { + // correct outcome + } + catch (IndexOutOfBoundsException e) { + assertTrue(false); // wrong outcome + } + } + + /** + * Some basic checks for the getSeries() method. + */ + @Test + public void testGetSeries() { + XYSeriesCollection c = new XYSeriesCollection(); + XYSeries s1 = new XYSeries("s1"); + c.addSeries(s1); + assertEquals("s1", c.getSeries(0).getKey()); + + try { + c.getSeries(-1); + fail("Should have thrown IndexOutOfBoundsException on negative key"); + } + catch (IllegalArgumentException e) { + assertEquals("Series index out of bounds", e.getMessage()); + } + + try { + c.getSeries(1); + fail("Should have thrown IndexOutOfBoundsException on key out of range"); + } + catch (IllegalArgumentException e) { + assertEquals("Series index out of bounds", e.getMessage()); + } + } + + /** + * Some checks for the getSeries(Comparable) method. + */ + @Test + public void testGetSeriesByKey() { + XYSeriesCollection c = new XYSeriesCollection(); + XYSeries s1 = new XYSeries("s1"); + c.addSeries(s1); + assertEquals("s1", c.getSeries("s1").getKey()); + + try { + c.getSeries("s2"); + fail("Should have thrown UnknownKeyException on unknown key"); + } + catch (UnknownKeyException e) { + assertEquals("Key not found: s2", e.getMessage()); + } + + try { + c.getSeries(null); + fail("Should have thrown IndexOutOfBoundsException on null key"); + } + catch (IllegalArgumentException e) { + assertEquals("Null 'key' argument.", e.getMessage()); + } + } + + /** + * Some basic checks for the addSeries() method. + */ + @Test + public void testAddSeries() { + XYSeriesCollection c = new XYSeriesCollection(); + XYSeries s1 = new XYSeries("s1"); + c.addSeries(s1); + + // the dataset should prevent the addition of a series with the + // same name as an existing series in the dataset + XYSeries s2 = new XYSeries("s1"); + try { + c.addSeries(s2); + fail("Should have thrown IllegalArgumentException on duplicate key"); + } catch (IllegalArgumentException e) { + assertEquals("This dataset already contains a series with the key s1", e.getMessage()); + } + assertEquals(1, c.getSeriesCount()); + } + + /** + * Some basic checks for the removeSeries() method. + */ + @Test + public void testRemoveSeries() { + XYSeriesCollection c = new XYSeriesCollection(); + XYSeries s1 = new XYSeries("s1"); + c.addSeries(s1); + c.removeSeries(0); + assertEquals(0, c.getSeriesCount()); + c.addSeries(s1); + + try { + c.removeSeries(-1); + fail("Should have thrown IndexOutOfBoundsException on negative key"); + } + catch (IllegalArgumentException e) { + assertEquals("Series index out of bounds.", e.getMessage()); + } + + try { + c.removeSeries(1); + fail("Should have thrown IndexOutOfBoundsException on key out of range"); + } + catch (IllegalArgumentException e) { + assertEquals("Series index out of bounds.", e.getMessage()); + } + } + + /** + * Some tests for the indexOf() method. + */ + @Test + public void testIndexOf() { + XYSeries s1 = new XYSeries("S1"); + XYSeries s2 = new XYSeries("S2"); + XYSeriesCollection dataset = new XYSeriesCollection(); + assertEquals(-1, dataset.indexOf(s1)); + assertEquals(-1, dataset.indexOf(s2)); + + dataset.addSeries(s1); + assertEquals(0, dataset.indexOf(s1)); + assertEquals(-1, dataset.indexOf(s2)); + + dataset.addSeries(s2); + assertEquals(0, dataset.indexOf(s1)); + assertEquals(1, dataset.indexOf(s2)); + + dataset.removeSeries(s1); + assertEquals(-1, dataset.indexOf(s1)); + assertEquals(0, dataset.indexOf(s2)); + + XYSeries s2b = new XYSeries("S2"); + assertEquals(0, dataset.indexOf(s2b)); + } + + /** + * Some checks for the getDomainBounds() method. + */ + @Test + public void testGetDomainBounds() { + XYSeriesCollection dataset = new XYSeriesCollection(); + Range r = dataset.getDomainBounds(false); + assertNull(r); + r = dataset.getDomainBounds(true); + assertNull(r); + + XYSeries series = new XYSeries("S1"); + dataset.addSeries(series); + r = dataset.getDomainBounds(false); + assertNull(r); + r = dataset.getDomainBounds(true); + assertNull(r); + + series.add(1.0, 1.1); + r = dataset.getDomainBounds(false); + assertEquals(new Range(1.0, 1.0), r); + r = dataset.getDomainBounds(true); + assertEquals(new Range(0.5, 1.5), r); + + series.add(-1.0, -1.1); + r = dataset.getDomainBounds(false); + assertEquals(new Range(-1.0, 1.0), r); + r = dataset.getDomainBounds(true); + assertEquals(new Range(-1.5, 1.5), r); + } + + /** + * Some checks for the getRangeBounds() method. + */ + @Test + public void testGetRangeBounds() { + XYSeriesCollection dataset = new XYSeriesCollection(); + Range r = dataset.getRangeBounds(false); + assertNull(r); + r = dataset.getRangeBounds(true); + assertNull(r); + + XYSeries series = new XYSeries("S1"); + dataset.addSeries(series); + r = dataset.getRangeBounds(false); + assertNull(r); + r = dataset.getRangeBounds(true); + assertNull(r); + + series.add(1.0, 1.1); + r = dataset.getRangeBounds(false); + assertEquals(new Range(1.1, 1.1), r); + r = dataset.getRangeBounds(true); + assertEquals(new Range(1.1, 1.1), r); + + series.add(-1.0, -1.1); + r = dataset.getRangeBounds(false); + assertEquals(new Range(-1.1, 1.1), r); + r = dataset.getRangeBounds(true); + assertEquals(new Range(-1.1, 1.1), r); + } + + /** + * A check that the dataset prevents renaming a series to the name of an + * existing series in the dataset. + */ + @Test + public void testRenameSeries() { + XYSeries s1 = new XYSeries("S1"); + XYSeries s2 = new XYSeries("S2"); + XYSeriesCollection dataset = new XYSeriesCollection(); + dataset.addSeries(s1); + dataset.addSeries(s2); + + try { + s2.setKey("S1"); + fail("Should have thrown IllegalArgumentException on negative key"); + } + catch (IllegalArgumentException e) { + assertEquals("Duplicate key2", e.getMessage()); + } + } + + /** + * A test to cover bug 3445507. The issue does not affect + * XYSeriesCollection. + */ + @Test + public void testBug3445507() { + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, null); + s1.add(2.0, null); + + XYSeries s2 = new XYSeries("S2"); + s1.add(1.0, 5.0); + s1.add(2.0, 6.0); + + XYSeriesCollection dataset = new XYSeriesCollection(); + dataset.addSeries(s1); + dataset.addSeries(s2); + + Range r = dataset.getRangeBounds(false); + assertEquals(5.0, r.getLowerBound(), EPSILON); + assertEquals(6.0, r.getUpperBound(), EPSILON); + } + + /** + * Test that a series belonging to a collection can be renamed (in fact, + * because of a bug this was not possible in JFreeChart 1.0.14). + */ + @Test + public void testSeriesRename() { + // first check that a valid renaming works + XYSeries series1 = new XYSeries("A"); + XYSeries series2 = new XYSeries("B"); + XYSeriesCollection collection = new XYSeriesCollection(); + collection.addSeries(series1); + collection.addSeries(series2); + series1.setKey("C"); + assertEquals("C", collection.getSeries(0).getKey()); + + // next, check that setting a duplicate key fails + try { + series2.setKey("C"); + fail("Expected an IllegalArgumentException."); + } + catch (IllegalArgumentException e) { + // expected + } + assertEquals("B", series2.getKey()); // the series name should not + // change because "C" is already the key for the other series in the + // collection + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYSeriesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYSeriesTest.java new file mode 100755 index 0000000..1968dad --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/XYSeriesTest.java @@ -0,0 +1,809 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------- + * XYSeriesTest.java + * ----------------- + * (C) Copyright 2003-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 23-Dec-2003 : Version 1 (DG); + * 15-Jan-2007 : Added tests for new toArray() method (DG); + * 30-Jan-2007 : Fixed some code that won't compile with Java 1.4 (DG); + * 31-Oct-2007 : New hashCode() test (DG); + * 01-May-2008 : Added testAddOrUpdate3() (DG); + * 24-Nov-2008 : Added testBug1955483() (DG); + * 06-Mar-2009 : Added tests for cached bounds values (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.SeriesException; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.fail; +import org.junit.Test; + +/** + * Tests for the {@link XYSeries} class. + */ +public class XYSeriesTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + XYSeries s1 = new XYSeries("Series"); + s1.add(1.0, 1.1); + XYSeries s2 = new XYSeries("Series"); + s2.add(1.0, 1.1); + assertTrue(s1.equals(s2)); + assertTrue(s2.equals(s1)); + + s1.setKey("Series X"); + assertFalse(s1.equals(s2)); + s2.setKey("Series X"); + assertTrue(s1.equals(s2)); + + s1.add(2.0, 2.2); + assertFalse(s1.equals(s2)); + s2.add(2.0, 2.2); + assertTrue(s1.equals(s2)); + } + + /** + * Some simple checks for the hashCode() method. + */ + @Test + public void testHashCode() { + XYSeries s1 = new XYSeries("Test"); + XYSeries s2 = new XYSeries("Test"); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + + s1.add(1.0, 500.0); + s2.add(1.0, 500.0); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + + s1.add(2.0, null); + s2.add(2.0, null); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + + s1.add(5.0, 111.0); + s2.add(5.0, 111.0); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + + s1.add(9.0, 1.0); + s2.add(9.0, 1.0); + assertEquals(s1, s2); + assertEquals(s1.hashCode(), s2.hashCode()); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + XYSeries s1 = new XYSeries("Series"); + s1.add(1.0, 1.1); + XYSeries s2 = (XYSeries) s1.clone(); + assertTrue(s1 != s2); + assertTrue(s1.getClass() == s2.getClass()); + assertTrue(s1.equals(s2)); + } + + /** + * Another test of the clone() method. + */ + @Test + public void testCloning2() throws CloneNotSupportedException { + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 100.0); + s1.add(2.0, null); + s1.add(3.0, 200.0); + XYSeries s2 = (XYSeries) s1.clone(); + assertTrue(s1.equals(s2)); + + // check independence + s2.add(4.0, 300.0); + assertFalse(s1.equals(s2)); + s1.add(4.0, 300.0); + assertTrue(s1.equals(s2)); + } + + /** + * Another test of the clone() method. + */ + @Test + public void testCloning3() throws CloneNotSupportedException { + XYSeries s1 = new XYSeries("S1"); + XYSeries s2 = (XYSeries) s1.clone(); + assertTrue(s1.equals(s2)); + + // check independence + s2.add(4.0, 300.0); + assertFalse(s1.equals(s2)); + s1.add(4.0, 300.0); + assertTrue(s1.equals(s2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + XYSeries s1 = new XYSeries("Series"); + s1.add(1.0, 1.1); + XYSeries s2 = (XYSeries) TestUtilities.serialised(s1); + assertEquals(s1, s2); + } + + /** + * Simple test for the indexOf() method. + */ + @Test + public void testIndexOf() { + XYSeries s1 = new XYSeries("Series 1"); + s1.add(1.0, 1.0); + s1.add(2.0, 2.0); + s1.add(3.0, 3.0); + assertEquals(0, s1.indexOf(new Double(1.0))); + assertEquals(1, s1.indexOf(new Double(2.0))); + assertEquals(2, s1.indexOf(new Double(3.0))); + assertEquals(-4, s1.indexOf(new Double(99.9))); + } + + /** + * A check for the indexOf() method for an unsorted series. + */ + @Test + public void testIndexOf2() { + XYSeries s1 = new XYSeries("Series 1", false, true); + s1.add(1.0, 1.0); + s1.add(3.0, 3.0); + s1.add(2.0, 2.0); + assertEquals(0, s1.indexOf(new Double(1.0))); + assertEquals(1, s1.indexOf(new Double(3.0))); + assertEquals(2, s1.indexOf(new Double(2.0))); + } + + /** + * A check for the indexOf(Number) method when the series has duplicate + * x-values. + */ + @Test + public void testIndexOf3() { + XYSeries s1 = new XYSeries("Series 1"); + s1.add(1.0, 1.0); + s1.add(2.0, 2.0); + s1.add(2.0, 3.0); + assertEquals(0, s1.indexOf(new Double(1.0))); + assertEquals(1, s1.indexOf(new Double(2.0))); + } + + /** + * Simple test for the remove() method. + */ + @Test + public void testRemove() { + XYSeries s1 = new XYSeries("Series 1"); + s1.add(1.0, 1.0); + s1.add(2.0, 2.0); + s1.add(3.0, 3.0); + assertEquals(3, s1.getItemCount()); + + s1.remove(new Double(2.0)); + assertEquals(new Double(3.0), s1.getX(1)); + + s1.remove(0); + assertEquals(new Double(3.0), s1.getX(0)); + } + + /** + * Some checks for the remove(int) method. + */ + @Test + public void testRemove2() { + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + s1.add(2.0, 2.2); + s1.add(3.0, 3.3); + s1.add(4.0, 4.4); + s1.add(5.0, 5.5); + s1.add(6.0, 6.6); + assertEquals(6, s1.getItemCount()); + assertEquals(1.0, s1.getMinX(), EPSILON); + assertEquals(6.0, s1.getMaxX(), EPSILON); + assertEquals(1.1, s1.getMinY(), EPSILON); + assertEquals(6.6, s1.getMaxY(), EPSILON); + + s1.remove(5); + assertEquals(5, s1.getItemCount()); + assertEquals(1.0, s1.getMinX(), EPSILON); + assertEquals(5.0, s1.getMaxX(), EPSILON); + assertEquals(1.1, s1.getMinY(), EPSILON); + assertEquals(5.5, s1.getMaxY(), EPSILON); + } + + private static final double EPSILON = 0.0000000001; + + /** + * When items are added with duplicate x-values, we expect them to remain + * in the order they were added. + */ + @Test + public void testAdditionOfDuplicateXValues() { + XYSeries s1 = new XYSeries("Series 1"); + s1.add(1.0, 1.0); + s1.add(2.0, 2.0); + s1.add(2.0, 3.0); + s1.add(2.0, 4.0); + s1.add(3.0, 5.0); + assertEquals(1.0, s1.getY(0).doubleValue(), EPSILON); + assertEquals(2.0, s1.getY(1).doubleValue(), EPSILON); + assertEquals(3.0, s1.getY(2).doubleValue(), EPSILON); + assertEquals(4.0, s1.getY(3).doubleValue(), EPSILON); + assertEquals(5.0, s1.getY(4).doubleValue(), EPSILON); + } + + /** + * Some checks for the update(Number, Number) method. + */ + @Test + public void testUpdate() { + XYSeries series = new XYSeries("S1"); + series.add(new Integer(1), new Integer(2)); + assertEquals(new Integer(2), series.getY(0)); + series.update(new Integer(1), new Integer(3)); + assertEquals(new Integer(3), series.getY(0)); + try { + series.update(new Integer(2), new Integer(99)); + assertTrue(false); + } + catch (SeriesException e) { + // got the required exception + } + } + + /** + * Some checks for the update() method for an unsorted series. + */ + @Test + public void testUpdate2() { + XYSeries series = new XYSeries("Series", false, true); + series.add(5.0, 55.0); + series.add(4.0, 44.0); + series.add(6.0, 66.0); + series.update(new Double(4.0), new Double(99.0)); + assertEquals(new Double(99.0), series.getY(1)); + } + + /** + * Some checks for the addOrUpdate() method. + */ + @Test + public void testAddOrUpdate() { + XYSeries series = new XYSeries("S1", true, false); + XYDataItem old = series.addOrUpdate(new Long(1), new Long(2)); + assertTrue(old == null); + assertEquals(1, series.getItemCount()); + assertEquals(new Long(2), series.getY(0)); + + old = series.addOrUpdate(new Long(2), new Long(3)); + assertTrue(old == null); + assertEquals(2, series.getItemCount()); + assertEquals(new Long(3), series.getY(1)); + + old = series.addOrUpdate(new Long(1), new Long(99)); + assertEquals(new XYDataItem(new Long(1), new Long(2)), old); + assertEquals(2, series.getItemCount()); + assertEquals(new Long(99), series.getY(0)); + assertEquals(new Long(3), series.getY(1)); + } + + /** + * Some checks for the addOrUpdate() method for an UNSORTED series. + */ + @Test + public void testAddOrUpdate2() { + XYSeries series = new XYSeries("Series", false, false); + series.add(5.0, 5.5); + series.add(6.0, 6.6); + series.add(3.0, 3.3); + series.add(4.0, 4.4); + series.add(2.0, 2.2); + series.add(1.0, 1.1); + series.addOrUpdate(new Double(3.0), new Double(33.3)); + series.addOrUpdate(new Double(2.0), new Double(22.2)); + assertEquals(33.3, series.getY(2).doubleValue(), EPSILON); + assertEquals(22.2, series.getY(4).doubleValue(), EPSILON); + } + + /** + * Another test for the addOrUpdate() method. + */ + @Test + public void testAddOrUpdate3() { + XYSeries series = new XYSeries("Series", false, true); + series.addOrUpdate(1.0, 1.0); + series.addOrUpdate(1.0, 2.0); + series.addOrUpdate(1.0, 3.0); + assertEquals(new Double(1.0), series.getY(0)); + assertEquals(new Double(2.0), series.getY(1)); + assertEquals(new Double(3.0), series.getY(2)); + assertEquals(3, series.getItemCount()); + } + + /** + * Some checks for the add() method for an UNSORTED series. + */ + @Test + public void testAdd() { + XYSeries series = new XYSeries("Series", false, true); + series.add(5.0, 5.50); + series.add(5.1, 5.51); + series.add(6.0, 6.6); + series.add(3.0, 3.3); + series.add(4.0, 4.4); + series.add(2.0, 2.2); + series.add(1.0, 1.1); + assertEquals(5.5, series.getY(0).doubleValue(), EPSILON); + assertEquals(5.51, series.getY(1).doubleValue(), EPSILON); + assertEquals(6.6, series.getY(2).doubleValue(), EPSILON); + assertEquals(3.3, series.getY(3).doubleValue(), EPSILON); + assertEquals(4.4, series.getY(4).doubleValue(), EPSILON); + assertEquals(2.2, series.getY(5).doubleValue(), EPSILON); + assertEquals(1.1, series.getY(6).doubleValue(), EPSILON); + } + + /** + * A simple check that the maximumItemCount attribute is working. + */ + @Test + public void testSetMaximumItemCount() { + XYSeries s1 = new XYSeries("S1"); + assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); + s1.setMaximumItemCount(2); + assertEquals(2, s1.getMaximumItemCount()); + s1.add(1.0, 1.1); + s1.add(2.0, 2.2); + s1.add(3.0, 3.3); + assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); + assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); + } + + /** + * Check that the maximum item count can be applied retrospectively. + */ + @Test + public void testSetMaximumItemCount2() { + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + s1.add(2.0, 2.2); + s1.add(3.0, 3.3); + s1.setMaximumItemCount(2); + assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); + assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); + } + + /** + * Check that the item bounds are determined correctly when there is a + * maximum item count. + */ + @Test + public void testSetMaximumItemCount3() { + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + s1.add(2.0, 2.2); + s1.add(3.0, 3.3); + s1.add(4.0, 4.4); + s1.add(5.0, 5.5); + s1.add(6.0, 6.6); + s1.setMaximumItemCount(2); + assertEquals(5.0, s1.getX(0).doubleValue(), EPSILON); + assertEquals(6.0, s1.getX(1).doubleValue(), EPSILON); + assertEquals(5.0, s1.getMinX(), EPSILON); + assertEquals(6.0, s1.getMaxX(), EPSILON); + assertEquals(5.5, s1.getMinY(), EPSILON); + assertEquals(6.6, s1.getMaxY(), EPSILON); + } + + /** + * Check that the item bounds are determined correctly when there is a + * maximum item count. + */ + @Test + public void testSetMaximumItemCount4() { + XYSeries s1 = new XYSeries("S1"); + s1.setMaximumItemCount(2); + s1.add(1.0, 1.1); + s1.add(2.0, 2.2); + s1.add(3.0, 3.3); + assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); + assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); + assertEquals(2.0, s1.getMinX(), EPSILON); + assertEquals(3.0, s1.getMaxX(), EPSILON); + assertEquals(2.2, s1.getMinY(), EPSILON); + assertEquals(3.3, s1.getMaxY(), EPSILON); + } + + /** + * Some checks for the toArray() method. + */ + @Test + public void testToArray() { + XYSeries s = new XYSeries("S1"); + double[][] array = s.toArray(); + assertEquals(2, array.length); + assertEquals(0, array[0].length); + assertEquals(0, array[1].length); + + s.add(1.0, 2.0); + array = s.toArray(); + assertEquals(1, array[0].length); + assertEquals(1, array[1].length); + assertEquals(2, array.length); + assertEquals(1.0, array[0][0], EPSILON); + assertEquals(2.0, array[1][0], EPSILON); + + s.add(2.0, null); + array = s.toArray(); + assertEquals(2, array.length); + assertEquals(2, array[0].length); + assertEquals(2, array[1].length); + assertEquals(2.0, array[0][1], EPSILON); + assertTrue(Double.isNaN(array[1][1])); + } + + /** + * Some checks for an example using the toArray() method. + */ + @Test + public void testToArrayExample() { + XYSeries s = new XYSeries("S"); + s.add(1.0, 11.0); + s.add(2.0, 22.0); + s.add(3.5, 35.0); + s.add(5.0, null); + DefaultXYDataset dataset = new DefaultXYDataset(); + dataset.addSeries("S", s.toArray()); + assertEquals(1, dataset.getSeriesCount()); + assertEquals(4, dataset.getItemCount(0)); + assertEquals("S", dataset.getSeriesKey(0)); + assertEquals(1.0, dataset.getXValue(0, 0), EPSILON); + assertEquals(2.0, dataset.getXValue(0, 1), EPSILON); + assertEquals(3.5, dataset.getXValue(0, 2), EPSILON); + assertEquals(5.0, dataset.getXValue(0, 3), EPSILON); + assertEquals(11.0, dataset.getYValue(0, 0), EPSILON); + assertEquals(22.0, dataset.getYValue(0, 1), EPSILON); + assertEquals(35.0, dataset.getYValue(0, 2), EPSILON); + assertTrue(Double.isNaN(dataset.getYValue(0, 3))); + } + + /** + * Another test for the addOrUpdate() method. + */ + @Test + public void testBug1955483() { + XYSeries series = new XYSeries("Series", true, true); + series.addOrUpdate(1.0, 1.0); + series.addOrUpdate(1.0, 2.0); + assertEquals(new Double(1.0), series.getY(0)); + assertEquals(new Double(2.0), series.getY(1)); + assertEquals(2, series.getItemCount()); + } + + /** + * Some checks for the delete(int, int) method. + */ + @Test + public void testDelete() { + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + s1.add(2.0, 2.2); + s1.add(3.0, 3.3); + s1.add(4.0, 4.4); + s1.add(5.0, 5.5); + s1.add(6.0, 6.6); + s1.delete(2, 5); + assertEquals(2, s1.getItemCount()); + assertEquals(1.0, s1.getX(0).doubleValue(), EPSILON); + assertEquals(2.0, s1.getX(1).doubleValue(), EPSILON); + assertEquals(1.0, s1.getMinX(), EPSILON); + assertEquals(2.0, s1.getMaxX(), EPSILON); + assertEquals(1.1, s1.getMinY(), EPSILON); + assertEquals(2.2, s1.getMaxY(), EPSILON); + } + + /** + * Some checks for the getMinX() method. + */ + @Test + public void testGetMinX() { + XYSeries s1 = new XYSeries("S1"); + assertTrue(Double.isNaN(s1.getMinX())); + + s1.add(1.0, 1.1); + assertEquals(1.0, s1.getMinX(), EPSILON); + + s1.add(2.0, 2.2); + assertEquals(1.0, s1.getMinX(), EPSILON); + + s1.add(Double.NaN, 99.9); + assertEquals(1.0, s1.getMinX(), EPSILON); + + s1.add(-1.0, -1.1); + assertEquals(-1.0, s1.getMinX(), EPSILON); + + s1.add(0.0, null); + assertEquals(-1.0, s1.getMinX(), EPSILON); + } + + /** + * Some checks for the getMaxX() method. + */ + @Test + public void testGetMaxX() { + XYSeries s1 = new XYSeries("S1"); + assertTrue(Double.isNaN(s1.getMaxX())); + + s1.add(1.0, 1.1); + assertEquals(1.0, s1.getMaxX(), EPSILON); + + s1.add(2.0, 2.2); + assertEquals(2.0, s1.getMaxX(), EPSILON); + + s1.add(Double.NaN, 99.9); + assertEquals(2.0, s1.getMaxX(), EPSILON); + + s1.add(-1.0, -1.1); + assertEquals(2.0, s1.getMaxX(), EPSILON); + + s1.add(0.0, null); + assertEquals(2.0, s1.getMaxX(), EPSILON); + } + + /** + * Some checks for the getMinY() method. + */ + @Test + public void testGetMinY() { + XYSeries s1 = new XYSeries("S1"); + assertTrue(Double.isNaN(s1.getMinY())); + + s1.add(1.0, 1.1); + assertEquals(1.1, s1.getMinY(), EPSILON); + + s1.add(2.0, 2.2); + assertEquals(1.1, s1.getMinY(), EPSILON); + + s1.add(Double.NaN, 99.9); + assertEquals(1.1, s1.getMinY(), EPSILON); + + s1.add(-1.0, -1.1); + assertEquals(-1.1, s1.getMinY(), EPSILON); + + s1.add(0.0, null); + assertEquals(-1.1, s1.getMinY(), EPSILON); + } + + /** + * Some checks for the getMaxY() method. + */ + @Test + public void testGetMaxY() { + XYSeries s1 = new XYSeries("S1"); + assertTrue(Double.isNaN(s1.getMaxY())); + + s1.add(1.0, 1.1); + assertEquals(1.1, s1.getMaxY(), EPSILON); + + s1.add(2.0, 2.2); + assertEquals(2.2, s1.getMaxY(), EPSILON); + + s1.add(Double.NaN, 99.9); + assertEquals(99.9, s1.getMaxY(), EPSILON); + + s1.add(-1.0, -1.1); + assertEquals(99.9, s1.getMaxY(), EPSILON); + + s1.add(0.0, null); + assertEquals(99.9, s1.getMaxY(), EPSILON); + } + + /** + * A test for a bug reported in the forum: + * + * http://www.jfree.org/forum/viewtopic.php?f=3&t=116601 + */ + @Test + public void testGetMaxY2() { + XYSeries series = new XYSeries(1, true, false); + series.addOrUpdate(1, 20); + series.addOrUpdate(2, 30); + series.addOrUpdate(3, 40); + assertEquals(40.0, series.getMaxY(), EPSILON); + series.addOrUpdate(2, 22); + assertEquals(40.0, series.getMaxY(), EPSILON); + } + + /** + * A test for the clear method. + */ + @Test + public void testClear() { + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + s1.add(2.0, 2.2); + s1.add(3.0, 3.3); + + assertEquals(3, s1.getItemCount()); + + s1.clear(); + assertEquals(0, s1.getItemCount()); + assertTrue(Double.isNaN(s1.getMinX())); + assertTrue(Double.isNaN(s1.getMaxX())); + assertTrue(Double.isNaN(s1.getMinY())); + assertTrue(Double.isNaN(s1.getMaxY())); + } + + /** + * Some checks for the updateByIndex() method. + */ + @Test + public void testUpdateByIndex() { + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + s1.add(2.0, 2.2); + s1.add(3.0, 3.3); + + assertEquals(1.1, s1.getMinY(), EPSILON); + assertEquals(3.3, s1.getMaxY(), EPSILON); + + s1.updateByIndex(0, new Double(-5.0)); + assertEquals(-5.0, s1.getMinY(), EPSILON); + assertEquals(3.3, s1.getMaxY(), EPSILON); + + s1.updateByIndex(0, null); + assertEquals(2.2, s1.getMinY(), EPSILON); + assertEquals(3.3, s1.getMaxY(), EPSILON); + + s1.updateByIndex(2, null); + assertEquals(2.2, s1.getMinY(), EPSILON); + assertEquals(2.2, s1.getMaxY(), EPSILON); + + s1.updateByIndex(1, null); + assertTrue(Double.isNaN(s1.getMinY())); + assertTrue(Double.isNaN(s1.getMaxY())); + } + + /** + * Some checks for the updateByIndex() method. + */ + @Test + public void testUpdateByIndex2() { + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, Double.NaN); + + assertTrue(Double.isNaN(s1.getMinY())); + assertTrue(Double.isNaN(s1.getMaxY())); + + s1.updateByIndex(0, new Double(1.0)); + assertEquals(1.0, s1.getMinY(), EPSILON); + assertEquals(1.0, s1.getMaxY(), EPSILON); + + s1.updateByIndex(0, new Double(2.0)); + assertEquals(2.0, s1.getMinY(), EPSILON); + assertEquals(2.0, s1.getMaxY(), EPSILON); + + s1.add(-1.0, -1.0); + s1.updateByIndex(0, new Double(0.0)); + assertEquals(0.0, s1.getMinY(), EPSILON); + assertEquals(2.0, s1.getMaxY(), EPSILON); + } + + /** + * Some checks for the updateByIndex() method. + */ + @Test + public void testUpdateByIndex3() { + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, 1.1); + s1.add(2.0, 2.2); + s1.add(3.0, 3.3); + + s1.updateByIndex(1, new Double(2.05)); + assertEquals(1.1, s1.getMinY(), EPSILON); + assertEquals(3.3, s1.getMaxY(), EPSILON); + } + + /** + * Some checks for the update(Number, Number) method. + */ + @Test + public void testUpdateXY() { + XYSeries s1 = new XYSeries("S1"); + s1.add(1.0, Double.NaN); + + assertTrue(Double.isNaN(s1.getMinY())); + assertTrue(Double.isNaN(s1.getMaxY())); + + s1.update(new Double(1.0), new Double(1.0)); + assertEquals(1.0, s1.getMinY(), EPSILON); + assertEquals(1.0, s1.getMaxY(), EPSILON); + + s1.update(new Double(1.0), new Double(2.0)); + assertEquals(2.0, s1.getMinY(), EPSILON); + assertEquals(2.0, s1.getMaxY(), EPSILON); + } + + @Test + public void testSetKey() { + XYSeries s1 = new XYSeries("S"); + s1.setKey("S1"); + assertEquals("S1", s1.getKey()); + + XYSeriesCollection c = new XYSeriesCollection(); + c.addSeries(s1); + XYSeries s2 = new XYSeries("S2"); + c.addSeries(s2); + + // now we should be allowed to change s1's key to anything but "S2" + s1.setKey("OK"); + assertEquals("OK", s1.getKey()); + + try { + s1.setKey("S2"); + fail("Expect an exception here."); + } catch (IllegalArgumentException e) { + // OK + } + + // after s1 is removed from the collection, we should be able to set + // the key to anything we want... + c.removeSeries(s1); + s1.setKey("S2"); + + // check that removing by index also works + s1.setKey("S1"); + c.addSeries(s1); + c.removeSeries(1); + s1.setKey("S2"); + } +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YIntervalDataItemTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YIntervalDataItemTest.java new file mode 100755 index 0000000..6da288c --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YIntervalDataItemTest.java @@ -0,0 +1,126 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * -------------------------- + * YIntervalDataItemTest.java + * -------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link YIntervalDataItem} class. + */ +public class YIntervalDataItemTest { + + private static final double EPSILON = 0.00000000001; + + /** + * Some checks for the constructor. + */ + @Test + public void testConstructor1() { + YIntervalDataItem item1 = new YIntervalDataItem(1.0, 2.0, 3.0, 4.0); + assertEquals(new Double(1.0), item1.getX()); + assertEquals(2.0, item1.getYValue(), EPSILON); + assertEquals(3.0, item1.getYLowValue(), EPSILON); + assertEquals(4.0, item1.getYHighValue(), EPSILON); + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + YIntervalDataItem item1 = new YIntervalDataItem(1.0, 2.0, 1.5, 2.5); + YIntervalDataItem item2 = new YIntervalDataItem(1.0, 2.0, 1.5, 2.5); + assertTrue(item1.equals(item2)); + assertTrue(item2.equals(item1)); + + // x + item1 = new YIntervalDataItem(1.1, 2.0, 1.5, 2.5); + assertFalse(item1.equals(item2)); + item2 = new YIntervalDataItem(1.1, 2.0, 1.5, 2.5); + assertTrue(item1.equals(item2)); + + // y + item1 = new YIntervalDataItem(1.1, 2.2, 1.5, 2.5); + assertFalse(item1.equals(item2)); + item2 = new YIntervalDataItem(1.1, 2.2, 1.5, 2.5); + assertTrue(item1.equals(item2)); + + // yLow + item1 = new YIntervalDataItem(1.1, 2.2, 1.55, 2.5); + assertFalse(item1.equals(item2)); + item2 = new YIntervalDataItem(1.1, 2.2, 1.55, 2.5); + assertTrue(item1.equals(item2)); + + // yHigh + item1 = new YIntervalDataItem(1.1, 2.2, 1.55, 2.55); + assertFalse(item1.equals(item2)); + item2 = new YIntervalDataItem(1.1, 2.2, 1.55, 2.55); + assertTrue(item1.equals(item2)); + } + + /** + * Some checks for the clone() method. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + YIntervalDataItem item1 = new YIntervalDataItem(1.0, 2.0, 1.5, 2.5); + YIntervalDataItem item2 = (YIntervalDataItem) item1.clone(); + assertTrue(item1 != item2); + assertTrue(item1.getClass() == item2.getClass()); + assertTrue(item1.equals(item2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + YIntervalDataItem item1 = new YIntervalDataItem(1.0, 2.0, 1.5, 2.5); + YIntervalDataItem item2 = (YIntervalDataItem) + TestUtilities.serialised(item1); + assertEquals(item1, item2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YIntervalSeriesCollectionTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YIntervalSeriesCollectionTest.java new file mode 100755 index 0000000..6a3b224 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YIntervalSeriesCollectionTest.java @@ -0,0 +1,177 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ---------------------------------- + * YIntervalSeriesCollectionTest.java + * ---------------------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * 18-Jan-2008 : Added testRemoveSeries() (DG); + * 22-Apr-2008 : Added testPublicCloneable (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; + +import org.jfree.util.PublicCloneable; +import org.junit.Test; + +/** + * Tests for the {@link YIntervalSeriesCollection} class. + */ +public class YIntervalSeriesCollectionTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + YIntervalSeriesCollection c1 = new YIntervalSeriesCollection(); + YIntervalSeriesCollection c2 = new YIntervalSeriesCollection(); + assertEquals(c1, c2); + + // add a series + YIntervalSeries s1 = new YIntervalSeries("Series"); + s1.add(1.0, 1.1, 1.2, 1.3); + c1.addSeries(s1); + assertFalse(c1.equals(c2)); + YIntervalSeries s2 = new YIntervalSeries("Series"); + s2.add(1.0, 1.1, 1.2, 1.3); + c2.addSeries(s2); + assertTrue(c1.equals(c2)); + + // add an empty series + c1.addSeries(new YIntervalSeries("Empty Series")); + assertFalse(c1.equals(c2)); + c2.addSeries(new YIntervalSeries("Empty Series")); + assertTrue(c1.equals(c2)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + YIntervalSeriesCollection c1 = new YIntervalSeriesCollection(); + YIntervalSeries s1 = new YIntervalSeries("Series"); + s1.add(1.0, 1.1, 1.2, 1.3); + c1.addSeries(s1); + YIntervalSeriesCollection c2 = (YIntervalSeriesCollection) c1.clone(); + assertTrue(c1 != c2); + assertTrue(c1.getClass() == c2.getClass()); + assertTrue(c1.equals(c2)); + + // check independence + s1.setDescription("XYZ"); + assertFalse(c1.equals(c2)); + } + + /** + * Verify that this class implements {@link PublicCloneable}. + */ + @Test + public void testPublicCloneable() { + YIntervalSeriesCollection c1 = new YIntervalSeriesCollection(); + assertTrue(c1 instanceof PublicCloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + YIntervalSeriesCollection c1 = new YIntervalSeriesCollection(); + YIntervalSeries s1 = new YIntervalSeries("Series"); + s1.add(1.0, 1.1, 1.2, 1.3); + YIntervalSeriesCollection c2 = (YIntervalSeriesCollection) + TestUtilities.serialised(c1); + assertEquals(c1, c2); + } + + /** + * Some basic checks for the removeSeries() method. + */ + @Test + public void testRemoveSeries() { + YIntervalSeriesCollection c = new YIntervalSeriesCollection(); + YIntervalSeries s1 = new YIntervalSeries("s1"); + c.addSeries(s1); + c.removeSeries(0); + assertEquals(0, c.getSeriesCount()); + c.addSeries(s1); + + boolean pass = false; + try { + c.removeSeries(-1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + + pass = false; + try { + c.removeSeries(1); + } + catch (IllegalArgumentException e) { + pass = true; + } + assertTrue(pass); + } + + /** + * A test for bug report 1170825 (originally affected XYSeriesCollection, + * this test is just copied over). + */ + @Test + public void test1170825() { + YIntervalSeries s1 = new YIntervalSeries("Series1"); + YIntervalSeriesCollection dataset = new YIntervalSeriesCollection(); + dataset.addSeries(s1); + try { + /* XYSeries s = */ dataset.getSeries(1); + } + catch (IllegalArgumentException e) { + // correct outcome + } + catch (IndexOutOfBoundsException e) { + assertTrue(false); // wrong outcome + } + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YIntervalSeriesTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YIntervalSeriesTest.java new file mode 100755 index 0000000..937c7a9 --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YIntervalSeriesTest.java @@ -0,0 +1,277 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------------ + * YIntervalSeriesTest.java + * ------------------------ + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1, based on XYSeriesTests (DG); + * 27-Nov-2007 : Added testClear() method (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertNotNull; + +import org.jfree.chart.TestUtilities; + +import org.jfree.data.general.SeriesChangeEvent; +import org.jfree.data.general.SeriesChangeListener; +import org.junit.Test; + +/** + * Tests for the {@link YIntervalSeries} class. + */ +public class YIntervalSeriesTest implements SeriesChangeListener { + + SeriesChangeEvent lastEvent; + + /** + * Records the last event. + * + * @param event the event. + */ + public void seriesChanged(SeriesChangeEvent event) { + this.lastEvent = event; + } + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + + YIntervalSeries s1 = new YIntervalSeries("s1"); + YIntervalSeries s2 = new YIntervalSeries("s1"); + assertTrue(s1.equals(s2)); + + // seriesKey + s1 = new YIntervalSeries("s2"); + assertFalse(s1.equals(s2)); + s2 = new YIntervalSeries("s2"); + assertTrue(s1.equals(s2)); + + // autoSort + s1 = new YIntervalSeries("s2", false, true); + assertFalse(s1.equals(s2)); + s2 = new YIntervalSeries("s2", false, true); + assertTrue(s1.equals(s2)); + + // allowDuplicateValues + s1 = new YIntervalSeries("s2", false, false); + assertFalse(s1.equals(s2)); + s2 = new YIntervalSeries("s2", false, false); + assertTrue(s1.equals(s2)); + + // add a value + s1.add(1.0, 0.5, 1.5, 2.0); + assertFalse(s1.equals(s2)); + s2.add(1.0, 0.5, 1.5, 2.0); + assertTrue(s2.equals(s1)); + + // add another value + s1.add(2.0, 0.5, 1.5, 2.0); + assertFalse(s1.equals(s2)); + s2.add(2.0, 0.5, 1.5, 2.0); + assertTrue(s2.equals(s1)); + + // remove a value + s1.remove(new Double(1.0)); + assertFalse(s1.equals(s2)); + s2.remove(new Double(1.0)); + assertTrue(s2.equals(s1)); + } + + /** + * Confirm that cloning works. + */ + @Test + public void testCloning() throws CloneNotSupportedException { + YIntervalSeries s1 = new YIntervalSeries("s1"); + s1.add(1.0, 0.5, 1.5, 2.0); + YIntervalSeries s2 = (YIntervalSeries) s1.clone(); + assertTrue(s1 != s2); + assertTrue(s1.getClass() == s2.getClass()); + assertTrue(s1.equals(s2)); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + YIntervalSeries s1 = new YIntervalSeries("s1"); + s1.add(1.0, 0.5, 1.5, 2.0); + YIntervalSeries s2 = (YIntervalSeries) TestUtilities.serialised(s1); + assertEquals(s1, s2); + } + + /** + * Simple test for the indexOf() method. + */ + @Test + public void testIndexOf() { + YIntervalSeries s1 = new YIntervalSeries("Series 1"); + s1.add(1.0, 1.0, 1.0, 2.0); + s1.add(2.0, 2.0, 2.0, 3.0); + s1.add(3.0, 3.0, 3.0, 4.0); + assertEquals(0, s1.indexOf(new Double(1.0))); + } + + /** + * A check for the indexOf() method for an unsorted series. + */ + @Test + public void testIndexOf2() { + YIntervalSeries s1 = new YIntervalSeries("Series 1", false, true); + s1.add(1.0, 1.0, 1.0, 2.0); + s1.add(3.0, 3.0, 3.0, 3.0); + s1.add(2.0, 2.0, 2.0, 2.0); + assertEquals(0, s1.indexOf(new Double(1.0))); + assertEquals(1, s1.indexOf(new Double(3.0))); + assertEquals(2, s1.indexOf(new Double(2.0))); + } + + /** + * Simple test for the remove() method. + */ + @Test + public void testRemove() { + YIntervalSeries s1 = new YIntervalSeries("Series 1"); + s1.add(1.0, 1.0, 1.0, 2.0); + s1.add(2.0, 2.0, 2.0, 2.0); + s1.add(3.0, 3.0, 3.0, 3.0); + assertEquals(3, s1.getItemCount()); + + s1.remove(new Double(2.0)); + assertEquals(new Double(3.0), s1.getX(1)); + + s1.remove(new Double(1.0)); + assertEquals(new Double(3.0), s1.getX(0)); + } + + private static final double EPSILON = 0.0000000001; + + /** + * When items are added with duplicate x-values, we expect them to remain + * in the order they were added. + */ + @Test + public void testAdditionOfDuplicateXValues() { + YIntervalSeries s1 = new YIntervalSeries("Series 1"); + s1.add(1.0, 1.0, 1.0, 1.0); + s1.add(2.0, 2.0, 2.0, 2.0); + s1.add(2.0, 3.0, 3.0, 3.0); + s1.add(2.0, 4.0, 4.0, 4.0); + s1.add(3.0, 5.0, 5.0, 5.0); + assertEquals(1.0, s1.getYValue(0), EPSILON); + assertEquals(2.0, s1.getYValue(1), EPSILON); + assertEquals(3.0, s1.getYValue(2), EPSILON); + assertEquals(4.0, s1.getYValue(3), EPSILON); + assertEquals(5.0, s1.getYValue(4), EPSILON); + } + + /** + * Some checks for the add() method for an UNSORTED series. + */ + @Test + public void testAdd() { + YIntervalSeries series = new YIntervalSeries("Series", false, true); + series.add(5.0, 5.50, 5.50, 5.50); + series.add(5.1, 5.51, 5.51, 5.51); + series.add(6.0, 6.6, 6.6, 6.6); + series.add(3.0, 3.3, 3.3, 3.3); + series.add(4.0, 4.4, 4.4, 4.4); + series.add(2.0, 2.2, 2.2, 2.2); + series.add(1.0, 1.1, 1.1, 1.1); + assertEquals(5.5, series.getYValue(0), EPSILON); + assertEquals(5.51, series.getYValue(1), EPSILON); + assertEquals(6.6, series.getYValue(2), EPSILON); + assertEquals(3.3, series.getYValue(3), EPSILON); + assertEquals(4.4, series.getYValue(4), EPSILON); + assertEquals(2.2, series.getYValue(5), EPSILON); + assertEquals(1.1, series.getYValue(6), EPSILON); + } + + /** + * A simple check that the maximumItemCount attribute is working. + */ + @Test + public void testSetMaximumItemCount() { + YIntervalSeries s1 = new YIntervalSeries("S1"); + assertEquals(Integer.MAX_VALUE, s1.getMaximumItemCount()); + s1.setMaximumItemCount(2); + assertEquals(2, s1.getMaximumItemCount()); + s1.add(1.0, 1.1, 1.1, 1.1); + s1.add(2.0, 2.2, 2.2, 2.2); + s1.add(3.0, 3.3, 3.3, 3.3); + assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); + assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); + } + + /** + * Check that the maximum item count can be applied retrospectively. + */ + @Test + public void testSetMaximumItemCount2() { + YIntervalSeries s1 = new YIntervalSeries("S1"); + s1.add(1.0, 1.1, 1.1, 1.1); + s1.add(2.0, 2.2, 2.2, 2.2); + s1.add(3.0, 3.3, 3.3, 3.3); + s1.setMaximumItemCount(2); + assertEquals(2.0, s1.getX(0).doubleValue(), EPSILON); + assertEquals(3.0, s1.getX(1).doubleValue(), EPSILON); + } + + /** + * Some checks for the clear() method. + */ + @Test + public void testClear() { + YIntervalSeries s1 = new YIntervalSeries("S1"); + s1.addChangeListener(this); + s1.clear(); + assertNull(this.lastEvent); + assertTrue(s1.isEmpty()); + s1.add(1.0, 2.0, 3.0, 4.0); + assertFalse(s1.isEmpty()); + s1.clear(); + assertNotNull(this.lastEvent); + assertTrue(s1.isEmpty()); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YIntervalTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YIntervalTest.java new file mode 100755 index 0000000..27195ef --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YIntervalTest.java @@ -0,0 +1,99 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ------------------ + * YIntervalTest.java + * ------------------ + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link YInterval} class. + */ +public class YIntervalTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + YInterval i1 = new YInterval(1.0, 0.5, 1.5); + YInterval i2 = new YInterval(1.0, 0.5, 1.5); + assertEquals(i1, i2); + + i1 = new YInterval(1.1, 0.5, 1.5); + assertFalse(i1.equals(i2)); + i2 = new YInterval(1.1, 0.5, 1.5); + assertTrue(i1.equals(i2)); + + i1 = new YInterval(1.1, 0.55, 1.5); + assertFalse(i1.equals(i2)); + i2 = new YInterval(1.1, 0.55, 1.5); + assertTrue(i1.equals(i2)); + + i1 = new YInterval(1.1, 0.55, 1.55); + assertFalse(i1.equals(i2)); + i2 = new YInterval(1.1, 0.55, 1.55); + assertTrue(i1.equals(i2)); + } + + /** + * This class is immutable. + */ + @Test + public void testCloning() { + YInterval i1 = new YInterval(1.0, 0.5, 1.5); + assertFalse(i1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + YInterval i1 = new YInterval(1.0, 0.5, 1.5); + YInterval i2 = (YInterval) TestUtilities.serialised(i1); + assertEquals(i1, i2); + } + +} diff --git a/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YWithXIntervalTest.java b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YWithXIntervalTest.java new file mode 100755 index 0000000..773864f --- /dev/null +++ b/WFRperfTool.editor/libs/jfreechart-1.0.17/tests/org/jfree/data/xy/YWithXIntervalTest.java @@ -0,0 +1,99 @@ +/* =========================================================== + * JFreeChart : a free chart library for the Java(tm) platform + * =========================================================== + * + * (C) Copyright 2000-2013, 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. + * + * [Oracle and Java are registered trademarks of Oracle and/or its affiliates. + * Other names may be trademarks of their respective owners.] + * + * ----------------------- + * YWithXIntervalTest.java + * ----------------------- + * (C) Copyright 2006-2013, by Object Refinery Limited and Contributors. + * + * Original Author: David Gilbert (for Object Refinery Limited); + * Contributor(s): -; + * + * Changes + * ------- + * 20-Oct-2006 : Version 1 (DG); + * + */ + +package org.jfree.data.xy; + +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertEquals; + +import org.jfree.chart.TestUtilities; +import org.junit.Test; + +/** + * Tests for the {@link YWithXInterval} class. + */ +public class YWithXIntervalTest { + + /** + * Confirm that the equals method can distinguish all the required fields. + */ + @Test + public void testEquals() { + YWithXInterval i1 = new YWithXInterval(1.0, 0.5, 1.5); + YWithXInterval i2 = new YWithXInterval(1.0, 0.5, 1.5); + assertEquals(i1, i2); + + i1 = new YWithXInterval(1.1, 0.5, 1.5); + assertFalse(i1.equals(i2)); + i2 = new YWithXInterval(1.1, 0.5, 1.5); + assertTrue(i1.equals(i2)); + + i1 = new YWithXInterval(1.1, 0.55, 1.5); + assertFalse(i1.equals(i2)); + i2 = new YWithXInterval(1.1, 0.55, 1.5); + assertTrue(i1.equals(i2)); + + i1 = new YWithXInterval(1.1, 0.55, 1.55); + assertFalse(i1.equals(i2)); + i2 = new YWithXInterval(1.1, 0.55, 1.55); + assertTrue(i1.equals(i2)); + } + + /** + * This class is immutable. + */ + @Test + public void testCloning() { + YWithXInterval i1 = new YWithXInterval(1.0, 0.5, 1.5); + assertFalse(i1 instanceof Cloneable); + } + + /** + * Serialize an instance, restore it, and check for equality. + */ + @Test + public void testSerialization() { + YWithXInterval i1 = new YWithXInterval(1.0, 0.5, 1.5); + YWithXInterval i2 = (YWithXInterval) TestUtilities.serialised(i1); + assertEquals(i1, i2); + } + +} diff --git a/WFRperfTool.editor/libs/sqlite-jdbc-3.7.2.jar b/WFRperfTool.editor/libs/sqlite-jdbc-3.7.2.jar new file mode 100755 index 0000000..b0bec7b Binary files /dev/null and b/WFRperfTool.editor/libs/sqlite-jdbc-3.7.2.jar differ diff --git a/WFRperfTool.editor/plugin.properties b/WFRperfTool.editor/plugin.properties new file mode 100755 index 0000000..95d37b9 --- /dev/null +++ b/WFRperfTool.editor/plugin.properties @@ -0,0 +1,79 @@ +# + +pluginName = WFRperfToolModel Editor +providerName = www.example.org + +_UI_PerftoolEditor_menu = &Perftool Editor + +_UI_CreateChild_menu_item = &New Child +_UI_CreateSibling_menu_item = N&ew Sibling + +_UI_ShowPropertiesView_menu_item = Show &Properties View +_UI_RefreshViewer_menu_item = &Refresh + +_UI_SelectionPage_label = Selection +_UI_ParentPage_label = Parent +_UI_ListPage_label = List +_UI_TreePage_label = Tree +_UI_TablePage_label = Table +_UI_TreeWithColumnsPage_label = Tree with Columns +_UI_ObjectColumn_label = Object +_UI_SelfColumn_label = Self + +_UI_NoObjectSelected = Selected Nothing +_UI_SingleObjectSelected = Selected Object: {0} +_UI_MultiObjectSelected = Selected {0} Objects + +_UI_OpenEditorError_label = Open Editor + +_UI_Wizard_category = Example EMF Model Creation Wizards + +_UI_CreateModelError_message = Problems encountered in file "{0}" + +_UI_PerftoolModelWizard_label = Perftool Model +_UI_PerftoolModelWizard_description = Create a new Perftool model + +_UI_PerftoolEditor_label = Perftool Model Editor + +_UI_PerftoolEditorFilenameDefaultBase = My +_UI_PerftoolEditorFilenameExtensions = perftool + +_UI_Wizard_label = New + +_WARN_FilenameExtension = The file name must end in ''.{0}'' +_WARN_FilenameExtensions = The file name must have one of the following extensions: {0} + +_UI_ModelObject = &Model Object +_UI_XMLEncoding = &XML Encoding +_UI_XMLEncodingChoices = UTF-8 ASCII UTF-16 UTF-16BE UTF-16LE ISO-8859-1 +_UI_Wizard_initial_object_description = Specify a file name and select a model object to create + +_UI_FileConflict_label = File Conflict +_WARN_FileConflict = There are unsaved changes that conflict with changes made outside the editor. Do you wish to discard this editor's changes? + +_UI_WFRperfToolModelEditorAdvisor_ActionSet_label = WFRperfToolModel Action Set +_UI_Perspective_label = WFRperfToolModel + +_UI_Browse_label = &Browse... +_UI_File_label = &File +_UI_Question_title = Question +_WARN_FileConflict = The file "{0}" already exists. Do you want to replace the existing file? +_UI_Error_title = Error +_WARN_No_Editor = There is no editor registered for the file "{0}". + +_UI_Application_title = WFRperfToolModel Application +_UI_Menu_File_label = &File +_UI_Menu_New_label = &New +_UI_Menu_Open_label = &Open... +_UI_Menu_Open_description = Opens a model object file +_UI_Menu_OpenURI_label = &Open URI... +_UI_Menu_OpenURI_description = Opens a model object loading it from a URI +_UI_Menu_Edit_label = &Edit +_UI_Menu_Window_label = &Window +_UI_Menu_Help_label = &Help +_UI_Menu_About_label = WFRperfToolModel &About... +_UI_About_title = WFRperfToolModel Application +_UI_About_text = WFRperfToolModel Application about box goes here. + +_UI_PerftoolModelWizard_ActionSet_label = Perftool Model Action Set + diff --git a/WFRperfTool.editor/plugin.xml b/WFRperfTool.editor/plugin.xml new file mode 100755 index 0000000..de4d988 --- /dev/null +++ b/WFRperfTool.editor/plugin.xml @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/deviceeventstimeline/BirtChartCanvas.java b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/deviceeventstimeline/BirtChartCanvas.java new file mode 100755 index 0000000..1b8d6fa --- /dev/null +++ b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/deviceeventstimeline/BirtChartCanvas.java @@ -0,0 +1,264 @@ +package at.ac.uibk.wfr.perftool.deviceeventstimeline; + +import org.eclipse.birt.chart.computation.DataPointHints; +import org.eclipse.birt.chart.device.ICallBackNotifier; +import org.eclipse.birt.chart.device.IDeviceRenderer; +import org.eclipse.birt.chart.event.WrappedStructureSource; +import org.eclipse.birt.chart.factory.GeneratedChartState; +import org.eclipse.birt.chart.factory.Generator; +import org.eclipse.birt.chart.model.Chart; +import org.eclipse.birt.chart.model.attribute.Bounds; +import org.eclipse.birt.chart.model.attribute.CallBackValue; +import org.eclipse.birt.chart.model.attribute.impl.BoundsImpl; +import org.eclipse.birt.chart.util.PluginSettings; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.PaintEvent; +import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.ToolTip; + +public class BirtChartCanvas extends Canvas implements Listener, ICallBackNotifier, PaintListener { + + + private IDeviceRenderer render; + private GeneratedChartState state; + private Image image = null; + + private GC gcImage; + + private Bounds bo; + + private Chart chart; + + private boolean regenerateFlag = true; + + private BirtChartCanvasController controller; + + public BirtChartCanvas(BirtChartCanvasController controller, Chart chart, Composite parent, int style) { + super(parent, style); + this.controller = controller; + try { + PluginSettings ps = PluginSettings.instance(); + render = ps.getDevice("dv.SWT"); + } catch (Exception e) { + e.printStackTrace(); + } + + this.chart = chart; + + addPaintListener(this); + + this.addListener(SWT.MouseDown, this); + this.addListener(SWT.MouseUp, this); + this.addListener(SWT.MouseMove, this); + this.addListener(SWT.Paint, this); + this.addListener(SWT.Resize, this); + } + + Rectangle rect; + + @Override + public void paintControl(PaintEvent e) { + + if (BirtChartCanvas.this.chart != null) { + + if (regenerateFlag) { + Composite co = (Composite) e.getSource(); + rect = co.getClientArea(); + //System.out.println("Width: " + rect.width + " - Height: " + rect.height); + + image = new Image( Display.getCurrent(), rect); + gcImage = new GC(image); + render.setProperty(IDeviceRenderer.GRAPHICS_CONTEXT, gcImage); + render.setProperty( IDeviceRenderer.UPDATE_NOTIFIER, BirtChartCanvas.this ); + + bo = BoundsImpl.create(0, 0, rect.width, rect.height); + bo.scale(72d / render.getDisplayServer().getDpiResolution()); + + regenerateFlag = false; + } + + Generator gr = Generator.instance(); + + try { + state = gr.build(render.getDisplayServer(), BirtChartCanvas.this.chart, bo, null, null, null); + gr.render(render, state); + GC gc = e.gc; + gc.drawImage(image, rect.x, rect.y); + + if (isDrag) { + gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK)); + gc.setAlpha(128); + + int minX = Math.min(mouseDownX, mouseUpX); + //int minY = Math.min(mouseDownY, mouseUpY); + int minY = 0; + + int maxX = Math.max(mouseDownX, mouseUpX); + //int maxY = Math.max(mouseDownY, mouseUpY); + int maxY = rect.height; + + int width = maxX - minX; + int height = maxY - minY; + + gc.fillRectangle(minX, minY, width, height); + } + } catch (Exception ex) { + ex.printStackTrace(); + } + + // For Live Updates + /*Display.getDefault().timerExec( 500, new Runnable() { + public void run() { + chartRefresh( ); + } + } );*/ + } + } + + public void setChart(Chart chart) { + this.chart = chart; + regenerateFlag = true; + } + + + public void chartRefresh() { + if ( !isDisposed() ) { + final Generator gr = Generator.instance( ); + try { + gr.refresh( state ); + } catch ( Exception ex ) { + ex.printStackTrace( ); + } + redraw( ); + } + } + + private boolean isDrag = false; + private int mouseDownX = 0; + private int mouseDownY = 0; + private int mouseUpX = 0; + private int mouseUpY = 0; + + @Override + public void handleEvent(Event event) { + switch (event.type) { + case SWT.MouseDown: + mouseDownX = event.x; + mouseDownY = event.y; + mouseUpX = event.x; + mouseUpY = event.y; + isDrag = true; + chartRefresh(); + break; + case SWT.MouseUp: + if (isDrag) { + mouseUpX = event.x; + mouseUpY = event.y; + isDrag = false; + controller.zoomRequested(state, rect, mouseDownX, mouseDownY, mouseUpX, mouseUpY); + chartRefresh(); + } + break; + case SWT.MouseMove: + if (isDrag) { + mouseUpX = event.x; + mouseUpY = event.y; + chartRefresh(); + } + break; + case SWT.Paint: + break; + case SWT.Resize: + regenerateFlag = true; + regenerateChart(); + break; + default: + break; + } + + } + + @Override + public void regenerateChart() { + chartRefresh(); + } + + @Override + public void repaintChart() { + chartRefresh(); + } + + @Override + public Object peerInstance() { + return this; + } + + @Override + public Chart getDesignTimeModel() { + return chart; + } + + @Override + public Chart getRunTimeModel() { + return state.getChartModel(); + } + + private boolean tooltipIsShown = false; + + private ToolTip toolTip = null; + + CallBackValue toolTipValue = null; + + @Override + public void callback(Object event, Object source, CallBackValue value) { + //System.out.println(event); + + if (event instanceof MouseEvent) { + MouseEvent mevent = (MouseEvent) event; + if (source instanceof WrappedStructureSource && value.getIdentifier() != null) { + if (!tooltipIsShown) { + toolTipValue = value; + toolTip = new ToolTip(getShell(), SWT.BALLOON); + toolTip.setMessage(toolTipValue.getIdentifier()); + Point cursorLoc = Display.getCurrent().getCursorLocation(); + toolTip.setLocation(cursorLoc); + toolTip.setVisible(true); + tooltipIsShown = true; + } else if (value != toolTipValue) { + toolTip.setVisible(false); + tooltipIsShown = false; + toolTip = null; + toolTipValue = null; + } + } + } + + /*if (source instanceof WrappedStructureSource ) + { + DataPointHints hint = (DataPointHints)((WrappedStructureSource)source).getSource(); + System.out.println("getBaseDisplayValue " + hint.getBaseDisplayValue()); + System.out.println("getOrthogonalDisplayValue " + hint.getOrthogonalDisplayValue()); + System.out.println("getLocationX " + hint.getLocation().getX()); + System.out.println("getLocationY " + hint.getLocation().getY()); + + ToolTip tip = new ToolTip(getShell(), SWT.BALLOON); + tip.setMessage("Testing"); + tip.setLocation((int)hint.getLocation().getX(), (int)hint.getLocation().getY()); + tip.setVisible(true); + } */ + chartRefresh(); + } + + +} + diff --git a/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/deviceeventstimeline/BirtChartCanvasController.java b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/deviceeventstimeline/BirtChartCanvasController.java new file mode 100755 index 0000000..398dab2 --- /dev/null +++ b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/deviceeventstimeline/BirtChartCanvasController.java @@ -0,0 +1,10 @@ +package at.ac.uibk.wfr.perftool.deviceeventstimeline; + +import org.eclipse.birt.chart.factory.GeneratedChartState; +import org.eclipse.swt.graphics.Rectangle; + +public interface BirtChartCanvasController { + + public int zoomRequested(GeneratedChartState state, Rectangle rec, int mouseDownX, int mouseDownY, int mouseUpX, int mouseUpY); + +} diff --git a/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/deviceeventstimeline/DeviceEventsTimelineEditorPart.java b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/deviceeventstimeline/DeviceEventsTimelineEditorPart.java new file mode 100755 index 0000000..44f24d4 --- /dev/null +++ b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/deviceeventstimeline/DeviceEventsTimelineEditorPart.java @@ -0,0 +1,447 @@ +package at.ac.uibk.wfr.perftool.deviceeventstimeline; + +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Vector; + +import org.eclipse.birt.chart.computation.PlotComputation; +import org.eclipse.birt.chart.extension.datafeed.GanttEntry; +import org.eclipse.birt.chart.factory.GeneratedChartState; +import org.eclipse.birt.chart.model.Chart; +import org.eclipse.birt.chart.model.ChartWithAxes; +import org.eclipse.birt.chart.model.ChartWithoutAxes; +import org.eclipse.birt.chart.model.attribute.ActionType; +import org.eclipse.birt.chart.model.attribute.Anchor; +import org.eclipse.birt.chart.model.attribute.AxisType; +import org.eclipse.birt.chart.model.attribute.Bounds; +import org.eclipse.birt.chart.model.attribute.ChartDimension; +import org.eclipse.birt.chart.model.attribute.IntersectionType; +import org.eclipse.birt.chart.model.attribute.LegendItemType; +import org.eclipse.birt.chart.model.attribute.LineAttributes; +import org.eclipse.birt.chart.model.attribute.LineStyle; +import org.eclipse.birt.chart.model.attribute.Position; +import org.eclipse.birt.chart.model.attribute.TickStyle; +import org.eclipse.birt.chart.model.attribute.TriggerCondition; +import org.eclipse.birt.chart.model.attribute.impl.CallBackValueImpl; +import org.eclipse.birt.chart.model.attribute.impl.ColorDefinitionImpl; +import org.eclipse.birt.chart.model.attribute.impl.JavaDateFormatSpecifierImpl; +import org.eclipse.birt.chart.model.attribute.impl.SeriesValueImpl; +import org.eclipse.birt.chart.model.attribute.impl.URLValueImpl; +import org.eclipse.birt.chart.model.component.Axis; +import org.eclipse.birt.chart.model.component.Series; +import org.eclipse.birt.chart.model.component.impl.AxisImpl; +import org.eclipse.birt.chart.model.component.impl.SeriesImpl; +import org.eclipse.birt.chart.model.data.BaseSampleData; +import org.eclipse.birt.chart.model.data.DataFactory; +import org.eclipse.birt.chart.model.data.GanttDataSet; +import org.eclipse.birt.chart.model.data.NumberDataSet; +import org.eclipse.birt.chart.model.data.OrthogonalSampleData; +import org.eclipse.birt.chart.model.data.SampleData; +import org.eclipse.birt.chart.model.data.SeriesDefinition; +import org.eclipse.birt.chart.model.data.SeriesGrouping; +import org.eclipse.birt.chart.model.data.TextDataSet; +import org.eclipse.birt.chart.model.data.impl.ActionImpl; +import org.eclipse.birt.chart.model.data.impl.DateTimeDataElementImpl; +import org.eclipse.birt.chart.model.data.impl.GanttDataSetImpl; +import org.eclipse.birt.chart.model.data.impl.NumberDataSetImpl; +import org.eclipse.birt.chart.model.data.impl.SeriesDefinitionImpl; +import org.eclipse.birt.chart.model.data.impl.SeriesGroupingImpl; +import org.eclipse.birt.chart.model.data.impl.TextDataSetImpl; +import org.eclipse.birt.chart.model.data.impl.TriggerImpl; +import org.eclipse.birt.chart.model.impl.ChartWithAxesImpl; +import org.eclipse.birt.chart.model.impl.ChartWithoutAxesImpl; +import org.eclipse.birt.chart.model.layout.Legend; +import org.eclipse.birt.chart.model.type.BarSeries; +import org.eclipse.birt.chart.model.type.GanttSeries; +import org.eclipse.birt.chart.model.type.PieSeries; +import org.eclipse.birt.chart.model.type.impl.BarSeriesImpl; +import org.eclipse.birt.chart.model.type.impl.GanttSeriesImpl; +import org.eclipse.birt.chart.model.type.impl.PieSeriesImpl; +import org.eclipse.birt.chart.util.CDateTime; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.emf.teneo.hibernate.HbDataStore; +import org.eclipse.emf.teneo.hibernate.resource.HibernateResource; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.TreeSelection; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Rectangle; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.part.EditorPart; +import org.hibernate.Query; +import org.hibernate.Session; + +import at.ac.uibk.wfr.perftool.Activity; +import at.ac.uibk.wfr.perftool.ActivityInstance; +import at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent; +import at.ac.uibk.wfr.perftool.ComponentStatusEvent; +import at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent; +import at.ac.uibk.wfr.perftool.Workflow; +import at.ac.uibk.wfr.perftool.WorkflowStatusEvent; +import at.ac.uibk.wfr.perftool.presentation.PerftoolEditor; + +public class DeviceEventsTimelineEditorPart extends EditorPart implements ISelectionChangedListener, BirtChartCanvasController { + + public static final String ID = "at.ac.uibk.wfr.perftool.perftooleditor.DeviceEventsTimelineEditorPart"; //$NON-NLS-1$ + + private PerftoolEditor mainEditor; + + private HibernateResource hResource; + + private Workflow selectedWorkflow = null; + + private BirtChartCanvas canvas; + + private Axis mainAxis = null; + + private long mainAxisCurrentMin = 0; + private long mainAxisCurrentMax = 0; + + public DeviceEventsTimelineEditorPart(PerftoolEditor mainEditor) { + this.mainEditor = mainEditor; + this.mainEditor.addSelectionChangedListener(this); + hResource = mainEditor.getHibernateResource(); + } + + + @Override + public void init(IEditorSite site, IEditorInput input) throws PartInitException { + setSite(site); + setInput(input); + } + + + /** + * Create contents of the editor part. + * @param parent + */ + @Override + public void createPartControl(Composite parent) { + canvas = new BirtChartCanvas(this, null, parent, SWT.NONE); + } + + + @Override + public void setFocus() { + + } + + + long wfstarttime = -1; + long wfendtime = -1; + + public Chart createChart() { + + class DeviceInstanceEntry { + public long deviceID; + public Vector events = new Vector(); + } + int totalDeviceInstanceCount = 0; + HashMap> deviceMap = new HashMap>(); + List componentEvents = null; + if (selectedWorkflow != null) { + HbDataStore hds = hResource.getEMFDataStore(); + Session session = hds.getSessionFactory().openSession(); + Query query = session.createQuery("from WorkflowStatusEvent where parentWorkflow = :wf order by timestamp"); + query.setParameter("wf", selectedWorkflow); + List rs = query.list(); + if (rs.size() > 0) { + wfstarttime = ((WorkflowStatusEvent)rs.get(0)).getTimestamp(); + wfendtime = ((WorkflowStatusEvent)rs.get(rs.size()-1)).getTimestamp(); + } else { + return null; + } + query = session.createQuery("from DeviceInstanceStatusEvent " + + "where (parentWorkflow = :wf or parentWorkflow is null) and timestamp >= :st and timestamp <= :et" + + " order by timestamp"); + query.setParameter("wf", selectedWorkflow); + query.setParameter("st", wfstarttime); + query.setParameter("et", wfendtime); + rs = query.list(); + for (int t = 0; t < rs.size(); t++) { + DeviceInstanceStatusEvent e = (DeviceInstanceStatusEvent) rs.get(t); + String type = e.getDeviceType(); + long deviceID = e.getDeviceID(); + HashMap dm = deviceMap.get(type); + if (dm == null) { + dm = new HashMap(); + DeviceInstanceEntry de = new DeviceInstanceEntry(); + de.deviceID = e.getDeviceID(); + de.events.add(e); + dm.put(de.deviceID, de); + deviceMap.put(type, dm); + totalDeviceInstanceCount++; + } else { + DeviceInstanceEntry de = dm.get(e.getDeviceID()); + if (de == null) { + de = new DeviceInstanceEntry(); + de.deviceID = e.getDeviceID(); + dm.put(de.deviceID, de); + totalDeviceInstanceCount++; + } + de.events.add(e); + } + } + query = session.createQuery("from ComponentStatusEvent " + + "where workflow = :wf and componentType = :type"); + query.setParameter("wf", selectedWorkflow); + query.setParameter("type", "Enactment"); + componentEvents = query.list(); + + } else { + return null; + } + + + + ChartWithAxes chart = ChartWithAxesImpl.create(); + + chart.setDimension(ChartDimension.TWO_DIMENSIONAL_LITERAL); + chart.setType("Gantt Chart"); + chart.setSubType("Standard Gantt Chart"); + + chart.getBlock().setBackground(ColorDefinitionImpl.WHITE()); + chart.getPlot().setBackground(ColorDefinitionImpl.GREY()); + + chart.setTransposed(true); + + // Title + + chart.getTitle().getLabel().getCaption().setValue("Device Events");//$NON-NLS-1$ + + // Legend + Legend lg = chart.getLegend(); + LineAttributes lia = lg.getOutline(); + lg.getText().getFont().setSize(16); + lia.setStyle(LineStyle.SOLID_LITERAL); + lg.getInsets().set(10, 5, 0, 0); + lg.getOutline().setVisible(true); + lg.setAnchor(Anchor.NORTH_LITERAL); + lg.setItemType(LegendItemType.CATEGORIES_LITERAL); + lg.setVisible(false); + + // X-Axis + Axis xAxisPrimary = chart.getPrimaryBaseAxes()[0]; + xAxisPrimary.setType(AxisType.TEXT_LITERAL); + xAxisPrimary.getMajorGrid().setTickStyle(TickStyle.BELOW_LITERAL); + xAxisPrimary.getOrigin().setType(IntersectionType.MIN_LITERAL); + + // Y-Axis + + Axis yAxisPrimary = chart.getPrimaryOrthogonalAxis(xAxisPrimary); + yAxisPrimary.setType(AxisType.DATE_TIME_LITERAL); + yAxisPrimary.getMajorGrid().setTickStyle(TickStyle.LEFT_LITERAL); + mainAxisCurrentMin = 0; + mainAxisCurrentMax = (wfendtime - wfstarttime)/1000000; + yAxisPrimary.getScale().setMin(DateTimeDataElementImpl.create(mainAxisCurrentMin)); + yAxisPrimary.getScale().setMax(DateTimeDataElementImpl.create(mainAxisCurrentMax)); + //yAxisPrimary.setFormatSpecifier( JavaDateFormatSpecifierImpl.create( "H:m:s::S" ) ); + mainAxis = yAxisPrimary; + + // Data Set + String[] deviceStringArray = new String[totalDeviceInstanceCount + 1]; + int i = 0; + for (String s : deviceMap.keySet()) { + for (Long l : deviceMap.get(s).keySet()) { + deviceStringArray[i] = s + "[" + l + "]"; + i++; + } + } + deviceStringArray[totalDeviceInstanceCount] = "Enactment Thread"; + TextDataSet categoryValues = TextDataSetImpl.create(deviceStringArray); + + // X-Series + Series seCategory = SeriesImpl.create(); + seCategory.setDataSet(categoryValues); + SeriesDefinition sdX = SeriesDefinitionImpl.create(); + xAxisPrimary.getSeriesDefinitions().add(sdX); + sdX.getSeries().add(seCategory); + sdX.getSeriesPalette().shift(0); + + SeriesDefinition sdY1 = SeriesDefinitionImpl.create(); + //sdY1.getSeriesPalette().shift(0); + yAxisPrimary.getSeriesDefinitions().add(sdY1); + + i = 0; + for (String s : deviceMap.keySet()) { + HashMap dm = deviceMap.get(s); + for (Long l : deviceMap.get(s).keySet()) { + DeviceInstanceEntry de = dm.get(l); + DeviceInstanceStatusEvent lastEvent = null; + for (DeviceInstanceStatusEvent e : de.events) { + if (e.getNewStatus().equalsIgnoreCase("FinishedTask")) { + if (!lastEvent.getNewStatus().equalsIgnoreCase("ExecutingTask")) { + throw new Error("ERROR"); + } + GanttEntry[] ges = new GanttEntry[totalDeviceInstanceCount + 1]; + for (int t = 0; t < totalDeviceInstanceCount + 1; t++) { + if (t == i) { + long lastTimeStamp = lastEvent.getTimestamp(); + long startms = (lastTimeStamp - wfstarttime)/1000000; // timestamps are in nanoseconds + long endms = (e.getTimestamp() - wfstarttime)/1000000; + ges[t] = new GanttEntry( new CDateTime(startms), + new CDateTime(endms), + ""); + } else { + //ges[t] = new GanttEntry(new CDateTime(0), new CDateTime(0), ""); + ges[t] = new GanttEntry((CDateTime)null, (CDateTime)null, ""); + } + } + GanttDataSet gds = GanttDataSetImpl.create( ges ); + GanttSeries gs = (GanttSeries) GanttSeriesImpl.create( ); + gs.setDataSet( gds ); + gs.getLabel( ).setVisible( false ); + sdY1.getSeries().add(gs); + ActivityInstance ei = e.getExecutedInstance(); + if (ei != null) { + long startTime = -1; + long stopTime = -1; + long readyTime = -1; + for (ActivityInstanceStatusEvent se : ei.getStatusEvents()) { + if (se.getNewStatus().equalsIgnoreCase("Running")) { + startTime = se.getTimestamp(); + } else if (se.getNewStatus().equalsIgnoreCase("Finished")) { + stopTime = se.getTimestamp(); + } else if (se.getNewStatus().equalsIgnoreCase("ReadyForExecution")) { + readyTime = se.getTimestamp(); + } + } + String text = ei.getBaseActivity().getName() + " (InstanceID " + ei.getInstid() + ", ImplementationID " + e.getExecutedImplID(); + if (readyTime >= 0 && startTime >= readyTime) { + text += ", Waittime " + ((double)(startTime - readyTime)/1000000000.0) + " s"; + } + if (startTime >= 0 && stopTime >= readyTime) { + text += ", Runtime " + ((double)(stopTime - startTime)/1000000000.0) + " s"; + } + text += ")"; + gs.getTriggers( ).add( TriggerImpl.create( TriggerCondition.ONMOUSEOVER_LITERAL, + ActionImpl.create( ActionType.CALL_BACK_LITERAL, + CallBackValueImpl.create( text ) ) ) ); + gs.getTriggers( ).add( TriggerImpl.create( TriggerCondition.ONMOUSEOUT_LITERAL, + ActionImpl.create( ActionType.CALL_BACK_LITERAL, + CallBackValueImpl.create( null ) ) ) ); + } + + } + lastEvent = e; + } + i++; + } + } + ComponentStatusEvent lastEvent = null; + for (Object o : componentEvents) { + ComponentStatusEvent e = (ComponentStatusEvent)o; + if (e.getNewStatus().equalsIgnoreCase("Idle") || e.getNewStatus().equalsIgnoreCase("Finished") ) { + if (lastEvent != null) { + GanttEntry[] ges = new GanttEntry[totalDeviceInstanceCount + 1]; + for (int t = 0; t < totalDeviceInstanceCount; t++) { + ges[t] = new GanttEntry((CDateTime)null, (CDateTime)null, ""); + } + long lastTimeStamp = lastEvent.getTimestamp(); + long startms = (lastTimeStamp - wfstarttime)/1000000; // timestamps are in nanoseconds + long endms = (e.getTimestamp() - wfstarttime)/1000000; + ges[totalDeviceInstanceCount] = new GanttEntry( new CDateTime(startms), + new CDateTime(endms), + ""); + GanttDataSet gds = GanttDataSetImpl.create( ges ); + GanttSeries gs = (GanttSeries) GanttSeriesImpl.create( ); + gs.setDataSet( gds ); + gs.getLabel( ).setVisible( false ); + sdY1.getSeries().add(gs); + } else { + throw new Error("Error"); + } + } else { + lastEvent = e; + } + } + + return chart; + } + + + + + @Override + public boolean isDirty() { + return false; + } + @Override + public boolean isSaveAsAllowed() { + return false; + } + @Override + public void doSave(IProgressMonitor monitor) { + } + @Override + public void doSaveAs() { + } + + + @Override + public void selectionChanged(SelectionChangedEvent event) { + if (event.getSelection() instanceof TreeSelection) { + TreeSelection sel = (TreeSelection) event.getSelection(); + Object o = sel.getFirstElement(); + Workflow wf = null; + if (o instanceof Workflow) { + wf = (Workflow) o; + } else if (o instanceof Activity) { + wf = ((Activity) o).getParentWorkflow(); + } else if (o instanceof ActivityInstance) { + wf = ((ActivityInstance) o).getParentWorkflow(); + } + if (wf != null && wf != selectedWorkflow) { + selectedWorkflow = wf; + canvas.setChart(createChart()); + } + } + + } + + + @Override + public int zoomRequested(GeneratedChartState state, Rectangle rec, int mouseDownX, int mouseDownY, int mouseUpX, int mouseUpY) { + if (mainAxis != null) { + if (mouseDownX > mouseUpX) { + mainAxisCurrentMin = 0; + mainAxisCurrentMax = (wfendtime - wfstarttime)/1000000; + mainAxis.getScale().setMin(DateTimeDataElementImpl.create(mainAxisCurrentMin)); + mainAxis.getScale().setMax(DateTimeDataElementImpl.create(mainAxisCurrentMax)); + } else { + PlotComputation comp = state.getComputations(); + Bounds pbo = comp.getPlotBounds(); + if (mouseDownX > pbo.getLeft() && mouseDownX <= pbo.getLeft() + pbo.getWidth() ) { + mouseDownX -= pbo.getLeft(); + } else if (mouseDownX <= pbo.getLeft()) { + mouseDownX = 0; + } else { + mouseDownX = (int) pbo.getWidth(); + } + if (mouseUpX > pbo.getLeft() && mouseUpX <= pbo.getWidth() + pbo.getLeft()) { + mouseUpX -= pbo.getLeft(); + } else if (mouseUpX <= pbo.getLeft()) { + mouseUpX = 0; + } else { + mouseUpX = (int) pbo.getWidth(); + } + if (mouseDownX < mouseUpX) { + long tmpMin = mainAxisCurrentMin + (long)(((double)(mainAxisCurrentMax-mainAxisCurrentMin)*mouseDownX)/((double)rec.width)); + long tmpMax = mainAxisCurrentMin + (long)(((double)(mainAxisCurrentMax-mainAxisCurrentMin)*mouseUpX)/((double)rec.width)); + if (tmpMin < tmpMax) { + mainAxisCurrentMin = tmpMin; + mainAxisCurrentMax = tmpMax; + mainAxis.getScale().setMin(DateTimeDataElementImpl.create(mainAxisCurrentMin)); + mainAxis.getScale().setMax(DateTimeDataElementImpl.create(mainAxisCurrentMax)); + } + } + } + } + return 0; + } + +} diff --git a/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/perftooleditor/OverviewTreeComparator.java b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/perftooleditor/OverviewTreeComparator.java new file mode 100755 index 0000000..fb94729 --- /dev/null +++ b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/perftooleditor/OverviewTreeComparator.java @@ -0,0 +1,57 @@ +package at.ac.uibk.wfr.perftool.perftooleditor; + +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerComparator; + +import at.ac.uibk.wfr.perftool.Activity; +import at.ac.uibk.wfr.perftool.ActivityInstance; +import at.ac.uibk.wfr.perftool.Workflow; + +public class OverviewTreeComparator extends ViewerComparator { + + @Override + public int compare(Viewer viewer, Object e1, Object e2) { + int e1type = getObjectType(e1); + int e2type = getObjectType(e2); + if (e1type < 0 && e1type < 0) { + return super.compare(viewer, e1, e2); + } else if (e1type < 0) { + return -1; + } else if (e2type < 0) { + return 1; + } else if (e1type != e2type) { + return e1type - e2type; + } else { + switch (e1type) { + case 0: + Workflow w1 = (Workflow)e1; + Workflow w2 = (Workflow)e2; + return w1.getOid() - w2.getOid(); + case 1: + Activity a1 = (Activity)e1; + Activity a2 = (Activity)e2; + return (int) (a1.getActid() - a2.getActid()); + case 2: + ActivityInstance i1 = (ActivityInstance)e1; + ActivityInstance i2 = (ActivityInstance)e2; + return (int) (i1.getInstid() - i2.getInstid()); + default: + return 0; + } + } + } + + private int getObjectType(Object o) { + int otype = -1; + if (o instanceof Workflow) { + otype = 0; + } else if (o instanceof Activity) { + otype = 1; + } else if (o instanceof ActivityInstance) { + otype = 2; + } + return otype; + } + + +} diff --git a/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor.java b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor.java new file mode 100755 index 0000000..eb19d4e --- /dev/null +++ b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/PerftoolActionBarContributor.java @@ -0,0 +1,449 @@ +/** + */ +package at.ac.uibk.wfr.perftool.presentation; + +import java.util.ArrayList; +import java.util.Collection; + +import org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate; + +import org.eclipse.emf.common.ui.viewer.IViewerProvider; + +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; + +import org.eclipse.emf.edit.ui.action.ControlAction; +import org.eclipse.emf.edit.ui.action.CreateChildAction; +import org.eclipse.emf.edit.ui.action.CreateSiblingAction; +import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; +import org.eclipse.emf.edit.ui.action.LoadResourceAction; +import org.eclipse.emf.edit.ui.action.ValidateAction; + +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.ActionContributionItem; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IContributionItem; +import org.eclipse.jface.action.IContributionManager; +import org.eclipse.jface.action.IMenuListener; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.action.SubContributionItem; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.Viewer; + +import org.eclipse.jface.wizard.WizardDialog; + +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.PartInitException; + +/** + * This is the action bar contributor for the Perftool model editor. + * + * + * @generated + */ +public class PerftoolActionBarContributor + extends EditingDomainActionBarContributor + implements ISelectionChangedListener { + /** + * Action to create objects from the Perftool model. + * + * + * @generated + */ + public static class NewAction extends WorkbenchWindowActionDelegate { + /** + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + * + * + * @generated + */ + public void run(IAction action) { + PerftoolModelWizard wizard = new PerftoolModelWizard(); + wizard.init(getWindow().getWorkbench(), StructuredSelection.EMPTY); + WizardDialog wizardDialog = new WizardDialog(getWindow().getShell(), wizard); + wizardDialog.open(); + } + } + + /** + * This keeps track of the active editor. + * + * + * @generated + */ + protected IEditorPart activeEditorPart; + + /** + * This keeps track of the current selection provider. + * + * + * @generated + */ + protected ISelectionProvider selectionProvider; + + /** + * This action opens the Properties view. + * + * + * @generated + */ + protected IAction showPropertiesViewAction = + new Action(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_ShowPropertiesView_menu_item")) { + @Override + public void run() { + try { + getPage().showView("org.eclipse.ui.views.PropertySheet"); + } + catch (PartInitException exception) { + WFRperfToolModelEditorPlugin.INSTANCE.log(exception); + } + } + }; + + /** + * This action refreshes the viewer of the current editor if the editor + * implements {@link org.eclipse.emf.common.ui.viewer.IViewerProvider}. + * + * + * @generated + */ + protected IAction refreshViewerAction = + new Action(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_RefreshViewer_menu_item")) { + @Override + public boolean isEnabled() { + return activeEditorPart instanceof IViewerProvider; + } + + @Override + public void run() { + if (activeEditorPart instanceof IViewerProvider) { + Viewer viewer = ((IViewerProvider)activeEditorPart).getViewer(); + if (viewer != null) { + viewer.refresh(); + } + } + } + }; + + /** + * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateChildAction} corresponding to each descriptor + * generated for the current selection by the item provider. + * + * + * @generated + */ + protected Collection createChildActions; + + /** + * This is the menu manager into which menu contribution items should be added for CreateChild actions. + * + * + * @generated + */ + protected IMenuManager createChildMenuManager; + + /** + * This will contain one {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} corresponding to each descriptor + * generated for the current selection by the item provider. + * + * + * @generated + */ + protected Collection createSiblingActions; + + /** + * This is the menu manager into which menu contribution items should be added for CreateSibling actions. + * + * + * @generated + */ + protected IMenuManager createSiblingMenuManager; + + /** + * This creates an instance of the contributor. + * + * + * @generated + */ + public PerftoolActionBarContributor() { + super(ADDITIONS_LAST_STYLE); + loadResourceAction = new LoadResourceAction(); + validateAction = new ValidateAction(); + controlAction = new ControlAction(); + } + + /** + * This adds Separators for editor additions to the tool bar. + * + * + * @generated + */ + @Override + public void contributeToToolBar(IToolBarManager toolBarManager) { + toolBarManager.add(new Separator("perftool-settings")); + toolBarManager.add(new Separator("perftool-additions")); + } + + /** + * This adds to the menu bar a menu and some separators for editor additions, + * as well as the sub-menus for object creation items. + * + * + * @generated + */ + @Override + public void contributeToMenu(IMenuManager menuManager) { + super.contributeToMenu(menuManager); + + IMenuManager submenuManager = new MenuManager(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_PerftoolEditor_menu"), "at.ac.uibk.wfr.perftoolMenuID"); + menuManager.insertAfter("additions", submenuManager); + submenuManager.add(new Separator("settings")); + submenuManager.add(new Separator("actions")); + submenuManager.add(new Separator("additions")); + submenuManager.add(new Separator("additions-end")); + + // Prepare for CreateChild item addition or removal. + // + createChildMenuManager = new MenuManager(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); + submenuManager.insertBefore("additions", createChildMenuManager); + + // Prepare for CreateSibling item addition or removal. + // + createSiblingMenuManager = new MenuManager(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); + submenuManager.insertBefore("additions", createSiblingMenuManager); + + // Force an update because Eclipse hides empty menus now. + // + submenuManager.addMenuListener + (new IMenuListener() { + public void menuAboutToShow(IMenuManager menuManager) { + menuManager.updateAll(true); + } + }); + + addGlobalActions(submenuManager); + } + + /** + * When the active editor changes, this remembers the change and registers with it as a selection provider. + * + * + * @generated + */ + @Override + public void setActiveEditor(IEditorPart part) { + super.setActiveEditor(part); + activeEditorPart = part; + + // Switch to the new selection provider. + // + if (selectionProvider != null) { + selectionProvider.removeSelectionChangedListener(this); + } + if (part == null) { + selectionProvider = null; + } + else { + selectionProvider = part.getSite().getSelectionProvider(); + selectionProvider.addSelectionChangedListener(this); + + // Fake a selection changed event to update the menus. + // + if (selectionProvider.getSelection() != null) { + selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection())); + } + } + } + + /** + * This implements {@link org.eclipse.jface.viewers.ISelectionChangedListener}, + * handling {@link org.eclipse.jface.viewers.SelectionChangedEvent}s by querying for the children and siblings + * that can be added to the selected object and updating the menus accordingly. + * + * + * @generated + */ + public void selectionChanged(SelectionChangedEvent event) { + // Remove any menu items for old selection. + // + if (createChildMenuManager != null) { + depopulateManager(createChildMenuManager, createChildActions); + } + if (createSiblingMenuManager != null) { + depopulateManager(createSiblingMenuManager, createSiblingActions); + } + + // Query the new selection for appropriate new child/sibling descriptors + // + Collection newChildDescriptors = null; + Collection newSiblingDescriptors = null; + + ISelection selection = event.getSelection(); + if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) { + Object object = ((IStructuredSelection)selection).getFirstElement(); + + EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain(); + + newChildDescriptors = domain.getNewChildDescriptors(object, null); + newSiblingDescriptors = domain.getNewChildDescriptors(null, object); + } + + // Generate actions for selection; populate and redraw the menus. + // + createChildActions = generateCreateChildActions(newChildDescriptors, selection); + createSiblingActions = generateCreateSiblingActions(newSiblingDescriptors, selection); + + if (createChildMenuManager != null) { + populateManager(createChildMenuManager, createChildActions, null); + createChildMenuManager.update(true); + } + if (createSiblingMenuManager != null) { + populateManager(createSiblingMenuManager, createSiblingActions, null); + createSiblingMenuManager.update(true); + } + } + + /** + * This generates a {@link org.eclipse.emf.edit.ui.action.CreateChildAction} for each object in descriptors, + * and returns the collection of these actions. + * + * + * @generated + */ + protected Collection generateCreateChildActions(Collection descriptors, ISelection selection) { + Collection actions = new ArrayList(); + if (descriptors != null) { + for (Object descriptor : descriptors) { + actions.add(new CreateChildAction(activeEditorPart, selection, descriptor)); + } + } + return actions; + } + + /** + * This generates a {@link org.eclipse.emf.edit.ui.action.CreateSiblingAction} for each object in descriptors, + * and returns the collection of these actions. + * + * + * @generated + */ + protected Collection generateCreateSiblingActions(Collection descriptors, ISelection selection) { + Collection actions = new ArrayList(); + if (descriptors != null) { + for (Object descriptor : descriptors) { + actions.add(new CreateSiblingAction(activeEditorPart, selection, descriptor)); + } + } + return actions; + } + + /** + * This populates the specified manager with {@link org.eclipse.jface.action.ActionContributionItem}s + * based on the {@link org.eclipse.jface.action.IAction}s contained in the actions collection, + * by inserting them before the specified contribution item contributionID. + * If contributionID is null, they are simply added. + * + * + * @generated + */ + protected void populateManager(IContributionManager manager, Collection actions, String contributionID) { + if (actions != null) { + for (IAction action : actions) { + if (contributionID != null) { + manager.insertBefore(contributionID, action); + } + else { + manager.add(action); + } + } + } + } + + /** + * This removes from the specified manager all {@link org.eclipse.jface.action.ActionContributionItem}s + * based on the {@link org.eclipse.jface.action.IAction}s contained in the actions collection. + * + * + * @generated + */ + protected void depopulateManager(IContributionManager manager, Collection actions) { + if (actions != null) { + IContributionItem[] items = manager.getItems(); + for (int i = 0; i < items.length; i++) { + // Look into SubContributionItems + // + IContributionItem contributionItem = items[i]; + while (contributionItem instanceof SubContributionItem) { + contributionItem = ((SubContributionItem)contributionItem).getInnerItem(); + } + + // Delete the ActionContributionItems with matching action. + // + if (contributionItem instanceof ActionContributionItem) { + IAction action = ((ActionContributionItem)contributionItem).getAction(); + if (actions.contains(action)) { + manager.remove(contributionItem); + } + } + } + } + } + + /** + * This populates the pop-up menu before it appears. + * + * + * @generated + */ + @Override + public void menuAboutToShow(IMenuManager menuManager) { + super.menuAboutToShow(menuManager); + MenuManager submenuManager = null; + + submenuManager = new MenuManager(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_CreateChild_menu_item")); + populateManager(submenuManager, createChildActions, null); + menuManager.insertBefore("edit", submenuManager); + + submenuManager = new MenuManager(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_CreateSibling_menu_item")); + populateManager(submenuManager, createSiblingActions, null); + menuManager.insertBefore("edit", submenuManager); + } + + /** + * This inserts global actions before the "additions-end" separator. + * + * + * @generated + */ + @Override + protected void addGlobalActions(IMenuManager menuManager) { + menuManager.insertAfter("additions-end", new Separator("ui-actions")); + menuManager.insertAfter("ui-actions", showPropertiesViewAction); + + refreshViewerAction.setEnabled(refreshViewerAction.isEnabled()); + menuManager.insertAfter("ui-actions", refreshViewerAction); + + super.addGlobalActions(menuManager); + } + + /** + * This ensures that a delete action will clean up all references to deleted objects. + * + * + * @generated + */ + @Override + protected boolean removeAllReferencesOnDelete() { + return true; + } + +} diff --git a/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor.java b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor.java new file mode 100755 index 0000000..b438d07 --- /dev/null +++ b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/PerftoolEditor.java @@ -0,0 +1,1593 @@ +/** + */ +package at.ac.uibk.wfr.perftool.presentation; + + +import java.io.IOException; +import java.io.InputStream; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.EventObject; +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.Properties; +import java.util.UUID; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.NullProgressMonitor; + +import org.eclipse.jface.action.IMenuListener; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IStatusLineManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; + +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.dialogs.ProgressMonitorDialog; + +import org.eclipse.jface.util.LocalSelectionTransfer; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ListViewer; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.jface.viewers.Viewer; + +import org.eclipse.swt.SWT; + +import org.eclipse.swt.custom.CTabFolder; + +import org.eclipse.swt.dnd.DND; +import org.eclipse.swt.dnd.FileTransfer; +import org.eclipse.swt.dnd.Transfer; + +import org.eclipse.swt.events.ControlAdapter; +import org.eclipse.swt.events.ControlEvent; + +import org.eclipse.swt.graphics.Point; + +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.Tree; + +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.IEditorInput; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IEditorSite; +import org.eclipse.ui.IPartListener; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.PartInitException; + +import org.eclipse.ui.part.MultiPageEditorPart; +import org.eclipse.ui.part.ViewPart; + +import org.eclipse.ui.views.contentoutline.ContentOutline; +import org.eclipse.ui.views.contentoutline.ContentOutlinePage; +import org.eclipse.ui.views.contentoutline.IContentOutlinePage; + +import org.eclipse.ui.views.properties.IPropertySheetPage; +import org.eclipse.ui.views.properties.PropertySheet; +import org.eclipse.ui.views.properties.PropertySheetPage; + +import org.eclipse.emf.common.command.BasicCommandStack; +import org.eclipse.emf.common.command.Command; +import org.eclipse.emf.common.command.CommandStack; +import org.eclipse.emf.common.command.CommandStackListener; + +import org.eclipse.emf.common.notify.AdapterFactory; +import org.eclipse.emf.common.notify.Notification; + +import org.eclipse.emf.common.ui.ViewerPane; + +import org.eclipse.emf.common.ui.editor.ProblemEditorPart; + +import org.eclipse.emf.common.ui.viewer.IViewerProvider; + +import org.eclipse.emf.common.util.BasicDiagnostic; +import org.eclipse.emf.common.util.Diagnostic; +import org.eclipse.emf.common.util.URI; + + +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.resource.Resource; + +import org.eclipse.emf.ecore.util.EContentAdapter; +import org.eclipse.emf.ecore.util.EcoreUtil; + +import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain; +import org.eclipse.emf.edit.domain.EditingDomain; +import org.eclipse.emf.edit.domain.IEditingDomainProvider; + +import org.eclipse.emf.edit.provider.AdapterFactoryItemDelegator; +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; + +import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory; + +import org.eclipse.emf.edit.ui.action.EditingDomainActionBarContributor; + +import org.eclipse.emf.edit.ui.celleditor.AdapterFactoryTreeEditor; + +import org.eclipse.emf.edit.ui.dnd.EditingDomainViewerDropAdapter; +import org.eclipse.emf.edit.ui.dnd.LocalTransfer; +import org.eclipse.emf.edit.ui.dnd.ViewerDragAdapter; + +import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; +import org.eclipse.emf.edit.ui.provider.UnwrappingSelectionProvider; +import org.eclipse.emf.edit.ui.util.EditUIUtil; + +import org.eclipse.emf.edit.ui.view.ExtendedPropertySheetPage; +import org.eclipse.emf.teneo.hibernate.HbDataStore; +import org.eclipse.emf.teneo.hibernate.HbHelper; +import org.eclipse.emf.teneo.hibernate.resource.HibernateResource; + +import at.ac.uibk.wfr.perftool.PerftoolPackage; +import at.ac.uibk.wfr.perftool.deviceeventstimeline.DeviceEventsTimelineEditorPart; +import at.ac.uibk.wfr.perftool.perftooleditor.OverviewTreeComparator; +import at.ac.uibk.wfr.perftool.provider.PerftoolItemProviderAdapterFactory; + +import org.eclipse.emf.common.ui.URIEditorInput; + +import org.eclipse.jface.operation.IRunnableWithProgress; + + +/** + * This is an example of a Perftool model editor. + * + * + * @generated + */ +public class PerftoolEditor + extends MultiPageEditorPart + implements IEditingDomainProvider, ISelectionProvider, IMenuListener, IViewerProvider { + /** + * The filters for file extensions supported by the editor. + * + * + * @generated + */ + public static final List FILE_EXTENSION_FILTERS = prefixExtensions(PerftoolModelWizard.FILE_EXTENSIONS, "*."); + + /** + * Returns a new unmodifiable list containing prefixed versions of the extensions in the given list. + * + * + * @generated + */ + private static List prefixExtensions(List extensions, String prefix) { + List result = new ArrayList(); + for (String extension : extensions) { + result.add(prefix + extension); + } + return Collections.unmodifiableList(result); + } + + /** + * This keeps track of the editing domain that is used to track all changes to the model. + * + * + * @generated + */ + protected AdapterFactoryEditingDomain editingDomain; + + /** + * This is the one adapter factory used for providing views of the model. + * + * + * @generated + */ + protected ComposedAdapterFactory adapterFactory; + + /** + * This is the content outline page. + * + * + * @generated + */ + protected IContentOutlinePage contentOutlinePage; + + /** + * This is a kludge... + * + * + * @generated + */ + protected IStatusLineManager contentOutlineStatusLineManager; + + /** + * This is the content outline page's viewer. + * + * + * @generated + */ + protected TreeViewer contentOutlineViewer; + + /** + * This is the property sheet page. + * + * + * @generated + */ + protected List propertySheetPages = new ArrayList(); + + /** + * This is the viewer that shadows the selection in the content outline. + * The parent relation must be correctly defined for this to work. + * + * + * @generated + */ + protected TreeViewer selectionViewer; + + /** + * This inverts the roll of parent and child in the content provider and show parents as a tree. + * + * + * @generated + */ + protected TreeViewer parentViewer; + + /** + * This shows how a tree view works. + * + * + * @generated + */ + protected TreeViewer treeViewer; + + /** + * This shows how a list view works. + * A list viewer doesn't support icons. + * + * + * @generated + */ + protected ListViewer listViewer; + + /** + * This shows how a table view works. + * A table can be used as a list with icons. + * + * + * @generated + */ + protected TableViewer tableViewer; + + /** + * This shows how a tree view with columns works. + * + * + * @generated + */ + protected TreeViewer treeViewerWithColumns; + + /** + * This keeps track of the active viewer pane, in the book. + * + * + * @generated + */ + protected ViewerPane currentViewerPane; + + /** + * This keeps track of the active content viewer, which may be either one of the viewers in the pages or the content outline viewer. + * + * + * @generated + */ + protected Viewer currentViewer; + + /** + * This listens to which ever viewer is active. + * + * + * @generated + */ + protected ISelectionChangedListener selectionChangedListener; + + /** + * This keeps track of all the {@link org.eclipse.jface.viewers.ISelectionChangedListener}s that are listening to this editor. + * + * + * @generated + */ + protected Collection selectionChangedListeners = new ArrayList(); + + /** + * This keeps track of the selection of the editor as a whole. + * + * + * @generated + */ + protected ISelection editorSelection = StructuredSelection.EMPTY; + + /** + * This listens for when the outline becomes active + * + * + * @generated + */ + protected IPartListener partListener = + new IPartListener() { + public void partActivated(IWorkbenchPart p) { + if (p instanceof ContentOutline) { + if (((ContentOutline)p).getCurrentPage() == contentOutlinePage) { + getActionBarContributor().setActiveEditor(PerftoolEditor.this); + + setCurrentViewer(contentOutlineViewer); + } + } + else if (p instanceof PropertySheet) { + if (propertySheetPages.contains(((PropertySheet)p).getCurrentPage())) { + getActionBarContributor().setActiveEditor(PerftoolEditor.this); + handleActivate(); + } + } + else if (p == PerftoolEditor.this) { + handleActivate(); + } + } + public void partBroughtToTop(IWorkbenchPart p) { + // Ignore. + } + public void partClosed(IWorkbenchPart p) { + // Ignore. + } + public void partDeactivated(IWorkbenchPart p) { + // Ignore. + } + public void partOpened(IWorkbenchPart p) { + // Ignore. + } + }; + + /** + * Resources that have been removed since last activation. + * + * + * @generated + */ + protected Collection removedResources = new ArrayList(); + + /** + * Resources that have been changed since last activation. + * + * + * @generated + */ + protected Collection changedResources = new ArrayList(); + + /** + * Resources that have been saved. + * + * + * @generated + */ + protected Collection savedResources = new ArrayList(); + + /** + * Map to store the diagnostic associated with a resource. + * + * + * @generated + */ + protected Map resourceToDiagnosticMap = new LinkedHashMap(); + + /** + * Controls whether the problem indication should be updated. + * + * + * @generated + */ + protected boolean updateProblemIndication = true; + + /** + * Adapter used to update the problem indication when resources are demanded loaded. + * + * + * @generated + */ + protected EContentAdapter problemIndicationAdapter = + new EContentAdapter() { + @Override + public void notifyChanged(Notification notification) { + if (notification.getNotifier() instanceof Resource) { + switch (notification.getFeatureID(Resource.class)) { + case Resource.RESOURCE__IS_LOADED: + case Resource.RESOURCE__ERRORS: + case Resource.RESOURCE__WARNINGS: { + Resource resource = (Resource)notification.getNotifier(); + Diagnostic diagnostic = analyzeResourceProblems(resource, null); + if (diagnostic.getSeverity() != Diagnostic.OK) { + resourceToDiagnosticMap.put(resource, diagnostic); + } + else { + resourceToDiagnosticMap.remove(resource); + } + + if (updateProblemIndication) { + getSite().getShell().getDisplay().asyncExec + (new Runnable() { + public void run() { + updateProblemIndication(); + } + }); + } + break; + } + } + } + else { + super.notifyChanged(notification); + } + } + + @Override + protected void setTarget(Resource target) { + basicSetTarget(target); + } + + @Override + protected void unsetTarget(Resource target) { + basicUnsetTarget(target); + resourceToDiagnosticMap.remove(target); + if (updateProblemIndication) { + getSite().getShell().getDisplay().asyncExec + (new Runnable() { + public void run() { + updateProblemIndication(); + } + }); + } + } + }; + + /** + * Handles activation of the editor or it's associated views. + * + * + * @generated + */ + protected void handleActivate() { + // Recompute the read only state. + // + if (editingDomain.getResourceToReadOnlyMap() != null) { + editingDomain.getResourceToReadOnlyMap().clear(); + + // Refresh any actions that may become enabled or disabled. + // + setSelection(getSelection()); + } + + if (!removedResources.isEmpty()) { + if (handleDirtyConflict()) { + getSite().getPage().closeEditor(PerftoolEditor.this, false); + } + else { + removedResources.clear(); + changedResources.clear(); + savedResources.clear(); + } + } + else if (!changedResources.isEmpty()) { + changedResources.removeAll(savedResources); + handleChangedResources(); + changedResources.clear(); + savedResources.clear(); + } + } + + /** + * Handles what to do with changed resources on activation. + * + * + * @generated + */ + protected void handleChangedResources() { + if (!changedResources.isEmpty() && (!isDirty() || handleDirtyConflict())) { + if (isDirty()) { + changedResources.addAll(editingDomain.getResourceSet().getResources()); + } + editingDomain.getCommandStack().flush(); + + updateProblemIndication = false; + for (Resource resource : changedResources) { + if (resource.isLoaded()) { + resource.unload(); + try { + resource.load(Collections.EMPTY_MAP); + } + catch (IOException exception) { + if (!resourceToDiagnosticMap.containsKey(resource)) { + resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); + } + } + } + } + + if (AdapterFactoryEditingDomain.isStale(editorSelection)) { + setSelection(StructuredSelection.EMPTY); + } + + updateProblemIndication = true; + updateProblemIndication(); + } + } + + /** + * Updates the problems indication with the information described in the specified diagnostic. + * + * + * @generated + */ + protected void updateProblemIndication() { + if (updateProblemIndication) { + BasicDiagnostic diagnostic = + new BasicDiagnostic + (Diagnostic.OK, + "WFRperfTool.editor", + 0, + null, + new Object [] { editingDomain.getResourceSet() }); + for (Diagnostic childDiagnostic : resourceToDiagnosticMap.values()) { + if (childDiagnostic.getSeverity() != Diagnostic.OK) { + diagnostic.add(childDiagnostic); + } + } + + int lastEditorPage = getPageCount() - 1; + if (lastEditorPage >= 0 && getEditor(lastEditorPage) instanceof ProblemEditorPart) { + ((ProblemEditorPart)getEditor(lastEditorPage)).setDiagnostic(diagnostic); + if (diagnostic.getSeverity() != Diagnostic.OK) { + setActivePage(lastEditorPage); + } + } + else if (diagnostic.getSeverity() != Diagnostic.OK) { + ProblemEditorPart problemEditorPart = new ProblemEditorPart(); + problemEditorPart.setDiagnostic(diagnostic); + try { + addPage(++lastEditorPage, problemEditorPart, getEditorInput()); + setPageText(lastEditorPage, problemEditorPart.getPartName()); + setActivePage(lastEditorPage); + showTabs(); + } + catch (PartInitException exception) { + WFRperfToolModelEditorPlugin.INSTANCE.log(exception); + } + } + } + } + + /** + * Shows a dialog that asks if conflicting changes should be discarded. + * + * + * @generated + */ + protected boolean handleDirtyConflict() { + return + MessageDialog.openQuestion + (getSite().getShell(), + getString("_UI_FileConflict_label"), + getString("_WARN_FileConflict")); + } + + /** + * This creates a model editor. + * + * + * @generated + */ + public PerftoolEditor() { + super(); + initializeEditingDomain(); + } + + /** + * This sets up the editing domain for the model editor. + * + * + * @generated + */ + protected void initializeEditingDomain() { + // Create an adapter factory that yields item providers. + // + adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE); + + adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory()); + adapterFactory.addAdapterFactory(new PerftoolItemProviderAdapterFactory()); + adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); + + // Create the command stack that will notify this editor as commands are executed. + // + BasicCommandStack commandStack = new BasicCommandStack(); + + // Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus. + // + commandStack.addCommandStackListener + (new CommandStackListener() { + public void commandStackChanged(final EventObject event) { + getContainer().getDisplay().asyncExec + (new Runnable() { + public void run() { + firePropertyChange(IEditorPart.PROP_DIRTY); + + // Try to select the affected objects. + // + Command mostRecentCommand = ((CommandStack)event.getSource()).getMostRecentCommand(); + if (mostRecentCommand != null) { + setSelectionToViewer(mostRecentCommand.getAffectedObjects()); + } + for (Iterator i = propertySheetPages.iterator(); i.hasNext(); ) { + PropertySheetPage propertySheetPage = i.next(); + if (propertySheetPage.getControl().isDisposed()) { + i.remove(); + } + else { + propertySheetPage.refresh(); + } + } + } + }); + } + }); + + // Create the editing domain with a special command stack. + // + editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap()); + } + + /** + * This is here for the listener to be able to call it. + * + * + * @generated + */ + @Override + protected void firePropertyChange(int action) { + super.firePropertyChange(action); + } + + /** + * This sets the selection into whichever viewer is active. + * + * + * @generated + */ + public void setSelectionToViewer(Collection collection) { + final Collection theSelection = collection; + // Make sure it's okay. + // + if (theSelection != null && !theSelection.isEmpty()) { + Runnable runnable = + new Runnable() { + public void run() { + // Try to select the items in the current content viewer of the editor. + // + if (currentViewer != null) { + currentViewer.setSelection(new StructuredSelection(theSelection.toArray()), true); + } + } + }; + getSite().getShell().getDisplay().asyncExec(runnable); + } + } + + /** + * This returns the editing domain as required by the {@link IEditingDomainProvider} interface. + * This is important for implementing the static methods of {@link AdapterFactoryEditingDomain} + * and for supporting {@link org.eclipse.emf.edit.ui.action.CommandAction}. + * + * + * @generated + */ + public EditingDomain getEditingDomain() { + return editingDomain; + } + + /** + * + * + * @generated + */ + public class ReverseAdapterFactoryContentProvider extends AdapterFactoryContentProvider { + /** + * + * + * @generated + */ + public ReverseAdapterFactoryContentProvider(AdapterFactory adapterFactory) { + super(adapterFactory); + } + + /** + * + * + * @generated + */ + @Override + public Object [] getElements(Object object) { + Object parent = super.getParent(object); + return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); + } + + /** + * + * + * @generated + */ + @Override + public Object [] getChildren(Object object) { + Object parent = super.getParent(object); + return (parent == null ? Collections.EMPTY_SET : Collections.singleton(parent)).toArray(); + } + + /** + * + * + * @generated + */ + @Override + public boolean hasChildren(Object object) { + Object parent = super.getParent(object); + return parent != null; + } + + /** + * + * + * @generated + */ + @Override + public Object getParent(Object object) { + return null; + } + } + + /** + * + * + * @generated + */ + public void setCurrentViewerPane(ViewerPane viewerPane) { + if (currentViewerPane != viewerPane) { + if (currentViewerPane != null) { + currentViewerPane.showFocus(false); + } + currentViewerPane = viewerPane; + } + setCurrentViewer(currentViewerPane.getViewer()); + } + + /** + * This makes sure that one content viewer, either for the current page or the outline view, if it has focus, + * is the current one. + * + * + * @generated + */ + public void setCurrentViewer(Viewer viewer) { + // If it is changing... + // + if (currentViewer != viewer) { + if (selectionChangedListener == null) { + // Create the listener on demand. + // + selectionChangedListener = + new ISelectionChangedListener() { + // This just notifies those things that are affected by the section. + // + public void selectionChanged(SelectionChangedEvent selectionChangedEvent) { + setSelection(selectionChangedEvent.getSelection()); + } + }; + } + + // Stop listening to the old one. + // + if (currentViewer != null) { + currentViewer.removeSelectionChangedListener(selectionChangedListener); + } + + // Start listening to the new one. + // + if (viewer != null) { + viewer.addSelectionChangedListener(selectionChangedListener); + } + + // Remember it. + // + currentViewer = viewer; + + // Set the editors selection based on the current viewer's selection. + // + setSelection(currentViewer == null ? StructuredSelection.EMPTY : currentViewer.getSelection()); + } + } + + /** + * This returns the viewer as required by the {@link IViewerProvider} interface. + * + * + * @generated + */ + public Viewer getViewer() { + return currentViewer; + } + + /** + * This creates a context menu for the viewer and adds a listener as well registering the menu for extension. + * + * + * @generated + */ + protected void createContextMenuFor(StructuredViewer viewer) { + MenuManager contextMenu = new MenuManager("#PopUp"); + contextMenu.add(new Separator("additions")); + contextMenu.setRemoveAllWhenShown(true); + contextMenu.addMenuListener(this); + Menu menu= contextMenu.createContextMenu(viewer.getControl()); + viewer.getControl().setMenu(menu); + getSite().registerContextMenu(contextMenu, new UnwrappingSelectionProvider(viewer)); + + int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK; + Transfer[] transfers = new Transfer[] { LocalTransfer.getInstance(), LocalSelectionTransfer.getTransfer(), FileTransfer.getInstance() }; + viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer)); + viewer.addDropSupport(dndOperations, transfers, new EditingDomainViewerDropAdapter(editingDomain, viewer)); + } + + + HibernateResource hResource = null; + HbDataStore teneoDatastore = null; + + public HibernateResource getHibernateResource() { + return hResource; + } + + /** + * This is the method called to load a resource into the editing domain's resource set based on the editor's input. + * + * + * @generated + */ + public void createModel() { + + URI resourceURI = EditUIUtil.getURI(getEditorInput()); + + InputStream propsIn = PerftoolEditor.class.getResourceAsStream("teneo.properties"); + Properties props = new Properties(); + try { + props.load(propsIn); + } catch (IOException e) { + e.printStackTrace(); + } + //*************** Initialize Teneo Hibernate DataStore ************************************* + UUID dataStoreID = UUID.randomUUID(); + HbDataStore hbds = (HbDataStore) HbHelper.INSTANCE.createRegisterDataStore(dataStoreID.toString()); + + String conurl = "jdbc:sqlite:" + resourceURI.toFileString(); + System.out.println("Connection URL: " + conurl); + props.put("hibernate.connection.url", conurl); + + hbds.setDataStoreProperties(props); + hbds.setEPackages(new EPackage[] { PerftoolPackage.eINSTANCE }); //Register EMF package + hbds.initialize(); + + Exception exception = null; + Resource resource = null; + try { + // Load the resource through the editing domain. + + String uriStr = "hibernate://?" + HibernateResource.DS_NAME_PARAM + "=" + dataStoreID.toString(); + final URI uri = URI.createURI(uriStr); + + resource = editingDomain.getResourceSet().getResource(uri, true); + + teneoDatastore = hbds; + } + catch (Exception e) { + exception = e; + resource = editingDomain.getResourceSet().getResource(resourceURI, false); + } + + Diagnostic diagnostic = analyzeResourceProblems(resource, exception); + if (diagnostic.getSeverity() != Diagnostic.OK) { + resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); + } + editingDomain.getResourceSet().eAdapters().add(problemIndicationAdapter); + hResource = (HibernateResource) resource; + teneoDatastore = hbds; + } + + /** + * Returns a diagnostic describing the errors and warnings listed in the resource + * and the specified exception (if any). + * + * + * @generated + */ + public Diagnostic analyzeResourceProblems(Resource resource, Exception exception) { + if (!resource.getErrors().isEmpty() || !resource.getWarnings().isEmpty()) { + BasicDiagnostic basicDiagnostic = + new BasicDiagnostic + (Diagnostic.ERROR, + "WFRperfTool.editor", + 0, + getString("_UI_CreateModelError_message", resource.getURI()), + new Object [] { exception == null ? (Object)resource : exception }); + basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true)); + return basicDiagnostic; + } + else if (exception != null) { + return + new BasicDiagnostic + (Diagnostic.ERROR, + "WFRperfTool.editor", + 0, + getString("_UI_CreateModelError_message", resource.getURI()), + new Object[] { exception }); + } + else { + return Diagnostic.OK_INSTANCE; + } + } + + /** + * This is the method used by the framework to install your own controls. + * + * + * @generated + */ + @Override + public void createPages() { + // Creates the model from the editor input + // + createModel(); + + // Only creates the other pages if there is something that can be edited + // + if (!getEditingDomain().getResourceSet().getResources().isEmpty()) { + // Create a page for the selection tree view. + // + { + ViewerPane viewerPane = + new ViewerPane(getSite().getPage(), PerftoolEditor.this) { + @Override + public Viewer createViewer(Composite composite) { + Tree tree = new Tree(composite, SWT.MULTI); + TreeViewer newTreeViewer = new TreeViewer(tree); + return newTreeViewer; + } + @Override + public void requestActivation() { + super.requestActivation(); + setCurrentViewerPane(this); + } + }; + viewerPane.createControl(getContainer()); + + selectionViewer = (TreeViewer)viewerPane.getViewer(); + selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); + + selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); + selectionViewer.setInput(editingDomain.getResourceSet()); + selectionViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); + selectionViewer.setComparator(new OverviewTreeComparator()); + viewerPane.setTitle("Structure Overview"); + + new AdapterFactoryTreeEditor(selectionViewer.getTree(), adapterFactory); + + createContextMenuFor(selectionViewer); + int pageIndex = addPage(viewerPane.getControl()); + setPageText(pageIndex, "Overview"); + } + + // Create a page for Device Event Timeline + // + { + + DeviceEventsTimelineEditorPart viewPart = new DeviceEventsTimelineEditorPart(this); + viewPart.createPartControl(getContainer()); + + int pageIndex = -1; + try { + pageIndex = addPage(viewPart, partInput); + setPageText(pageIndex, "Device Events Timeline"); + } catch (PartInitException e) { + e.printStackTrace(); + } + } + + getSite().getShell().getDisplay().asyncExec + (new Runnable() { + public void run() { + setActivePage(0); + } + }); + } + + // Ensures that this editor will only display the page's tab + // area if there are more than one page + // + getContainer().addControlListener + (new ControlAdapter() { + boolean guard = false; + @Override + public void controlResized(ControlEvent event) { + if (!guard) { + guard = true; + hideTabs(); + guard = false; + } + } + }); + + getSite().getShell().getDisplay().asyncExec + (new Runnable() { + public void run() { + updateProblemIndication(); + } + }); + } + + /** + * If there is just one page in the multi-page editor part, + * this hides the single tab at the bottom. + * + * + * @generated + */ + protected void hideTabs() { + if (getPageCount() <= 1) { + setPageText(0, ""); + if (getContainer() instanceof CTabFolder) { + ((CTabFolder)getContainer()).setTabHeight(1); + Point point = getContainer().getSize(); + getContainer().setSize(point.x, point.y + 6); + } + } + } + + /** + * If there is more than one page in the multi-page editor part, + * this shows the tabs at the bottom. + * + * + * @generated + */ + protected void showTabs() { + if (getPageCount() > 1) { + setPageText(0, getString("_UI_SelectionPage_label")); + if (getContainer() instanceof CTabFolder) { + ((CTabFolder)getContainer()).setTabHeight(SWT.DEFAULT); + Point point = getContainer().getSize(); + getContainer().setSize(point.x, point.y - 6); + } + } + } + + /** + * This is used to track the active viewer. + * + * + * @generated + */ + @Override + protected void pageChange(int pageIndex) { + super.pageChange(pageIndex); + + if (contentOutlinePage != null) { + handleContentOutlineSelection(contentOutlinePage.getSelection()); + } + } + + /** + * This is how the framework determines which interfaces we implement. + * + * + * @generated + */ + @SuppressWarnings("rawtypes") + @Override + public Object getAdapter(Class key) { + if (key.equals(IContentOutlinePage.class)) { + return showOutlineView() ? getContentOutlinePage() : null; + } + else if (key.equals(IPropertySheetPage.class)) { + return getPropertySheetPage(); + } + else { + return super.getAdapter(key); + } + } + + /** + * This accesses a cached version of the content outliner. + * + * + * @generated + */ + public IContentOutlinePage getContentOutlinePage() { + if (contentOutlinePage == null) { + // The content outline is just a tree. + // + class MyContentOutlinePage extends ContentOutlinePage { + @Override + public void createControl(Composite parent) { + super.createControl(parent); + contentOutlineViewer = getTreeViewer(); + contentOutlineViewer.addSelectionChangedListener(this); + + // Set up the tree viewer. + // + contentOutlineViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); + contentOutlineViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); + contentOutlineViewer.setInput(editingDomain.getResourceSet()); + + // Make sure our popups work. + // + createContextMenuFor(contentOutlineViewer); + + if (!editingDomain.getResourceSet().getResources().isEmpty()) { + // Select the root object in the view. + // + contentOutlineViewer.setSelection(new StructuredSelection(editingDomain.getResourceSet().getResources().get(0)), true); + } + } + + @Override + public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) { + super.makeContributions(menuManager, toolBarManager, statusLineManager); + contentOutlineStatusLineManager = statusLineManager; + } + + @Override + public void setActionBars(IActionBars actionBars) { + super.setActionBars(actionBars); + getActionBarContributor().shareGlobalActions(this, actionBars); + } + } + + contentOutlinePage = new MyContentOutlinePage(); + + // Listen to selection so that we can handle it is a special way. + // + contentOutlinePage.addSelectionChangedListener + (new ISelectionChangedListener() { + // This ensures that we handle selections correctly. + // + public void selectionChanged(SelectionChangedEvent event) { + handleContentOutlineSelection(event.getSelection()); + } + }); + } + + return contentOutlinePage; + } + + /** + * This accesses a cached version of the property sheet. + * + * + * @generated + */ + public IPropertySheetPage getPropertySheetPage() { + PropertySheetPage propertySheetPage = + new ExtendedPropertySheetPage(editingDomain) { + @Override + public void setSelectionToViewer(List selection) { + PerftoolEditor.this.setSelectionToViewer(selection); + PerftoolEditor.this.setFocus(); + } + + @Override + public void setActionBars(IActionBars actionBars) { + super.setActionBars(actionBars); + getActionBarContributor().shareGlobalActions(this, actionBars); + } + }; + propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory)); + propertySheetPages.add(propertySheetPage); + + return propertySheetPage; + } + + /** + * This deals with how we want selection in the outliner to affect the other views. + * + * + * @generated + */ + public void handleContentOutlineSelection(ISelection selection) { + if (currentViewerPane != null && !selection.isEmpty() && selection instanceof IStructuredSelection) { + Iterator selectedElements = ((IStructuredSelection)selection).iterator(); + if (selectedElements.hasNext()) { + // Get the first selected element. + // + Object selectedElement = selectedElements.next(); + + // If it's the selection viewer, then we want it to select the same selection as this selection. + // + if (currentViewerPane.getViewer() == selectionViewer) { + ArrayList selectionList = new ArrayList(); + selectionList.add(selectedElement); + while (selectedElements.hasNext()) { + selectionList.add(selectedElements.next()); + } + + // Set the selection to the widget. + // + selectionViewer.setSelection(new StructuredSelection(selectionList)); + } + else { + // Set the input to the widget. + // + if (currentViewerPane.getViewer().getInput() != selectedElement) { + currentViewerPane.getViewer().setInput(selectedElement); + currentViewerPane.setTitle(selectedElement); + } + } + } + } + } + + /** + * This is for implementing {@link IEditorPart} and simply tests the command stack. + * + * + * @generated + */ + @Override + public boolean isDirty() { + return ((BasicCommandStack)editingDomain.getCommandStack()).isSaveNeeded(); + } + + /** + * This is for implementing {@link IEditorPart} and simply saves the model file. + * + * + * @generated + */ + @Override + public void doSave(IProgressMonitor progressMonitor) { + // Save only resources that have actually changed. + // + final Map saveOptions = new HashMap(); + saveOptions.put(Resource.OPTION_SAVE_ONLY_IF_CHANGED, Resource.OPTION_SAVE_ONLY_IF_CHANGED_MEMORY_BUFFER); + saveOptions.put(Resource.OPTION_LINE_DELIMITER, Resource.OPTION_LINE_DELIMITER_UNSPECIFIED); + + // Do the work within an operation because this is a long running activity that modifies the workbench. + // + IRunnableWithProgress operation = + new IRunnableWithProgress() { + // This is the method that gets invoked when the operation runs. + // + public void run(IProgressMonitor monitor) { + // Save the resources to the file system. + // + boolean first = true; + for (Resource resource : editingDomain.getResourceSet().getResources()) { + if ((first || !resource.getContents().isEmpty() || isPersisted(resource)) && !editingDomain.isReadOnly(resource)) { + try { + long timeStamp = resource.getTimeStamp(); + resource.save(saveOptions); + if (resource.getTimeStamp() != timeStamp) { + savedResources.add(resource); + } + } + catch (Exception exception) { + resourceToDiagnosticMap.put(resource, analyzeResourceProblems(resource, exception)); + } + first = false; + } + } + } + }; + + updateProblemIndication = false; + try { + // This runs the options, and shows progress. + // + new ProgressMonitorDialog(getSite().getShell()).run(true, false, operation); + + // Refresh the necessary state. + // + ((BasicCommandStack)editingDomain.getCommandStack()).saveIsDone(); + firePropertyChange(IEditorPart.PROP_DIRTY); + } + catch (Exception exception) { + // Something went wrong that shouldn't. + // + WFRperfToolModelEditorPlugin.INSTANCE.log(exception); + } + updateProblemIndication = true; + updateProblemIndication(); + } + + /** + * This returns whether something has been persisted to the URI of the specified resource. + * The implementation uses the URI converter from the editor's resource set to try to open an input stream. + * + * + * @generated + */ + protected boolean isPersisted(Resource resource) { + boolean result = false; + try { + InputStream stream = editingDomain.getResourceSet().getURIConverter().createInputStream(resource.getURI()); + if (stream != null) { + result = true; + stream.close(); + } + } + catch (IOException e) { + // Ignore + } + return result; + } + + /** + * This always returns true because it is not currently supported. + * + * + * @generated + */ + @Override + public boolean isSaveAsAllowed() { + return true; + } + + /** + * This also changes the editor's input. + * + * + * @generated + */ + @Override + public void doSaveAs() { + String[] filters = FILE_EXTENSION_FILTERS.toArray(new String[FILE_EXTENSION_FILTERS.size()]); + String[] files = WFRperfToolModelEditorAdvisor.openFilePathDialog(getSite().getShell(), SWT.SAVE, filters); + if (files.length > 0) { + URI uri = URI.createFileURI(files[0]); + doSaveAs(uri, new URIEditorInput(uri)); + } + } + + /** + * + * + * @generated + */ + protected void doSaveAs(URI uri, IEditorInput editorInput) { + (editingDomain.getResourceSet().getResources().get(0)).setURI(uri); + setInputWithNotify(editorInput); + setPartName(editorInput.getName()); + IProgressMonitor progressMonitor = + getActionBars().getStatusLineManager() != null ? + getActionBars().getStatusLineManager().getProgressMonitor() : + new NullProgressMonitor(); + doSave(progressMonitor); + } + + + IEditorInput partInput = null; + + /** + * This is called during startup. + * + * + * @generated + */ + @Override + public void init(IEditorSite site, IEditorInput editorInput) { + partInput = editorInput; + setSite(site); + setInputWithNotify(editorInput); + setPartName(editorInput.getName()); + site.setSelectionProvider(this); + site.getPage().addPartListener(partListener); + } + + /** + * + * + * @generated + */ + @Override + public void setFocus() { + if (currentViewerPane != null) { + currentViewerPane.setFocus(); + } + else { + getControl(getActivePage()).setFocus(); + } + } + + /** + * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. + * + * + * @generated + */ + public void addSelectionChangedListener(ISelectionChangedListener listener) { + selectionChangedListeners.add(listener); + } + + /** + * This implements {@link org.eclipse.jface.viewers.ISelectionProvider}. + * + * + * @generated + */ + public void removeSelectionChangedListener(ISelectionChangedListener listener) { + selectionChangedListeners.remove(listener); + } + + /** + * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to return this editor's overall selection. + * + * + * @generated + */ + public ISelection getSelection() { + return editorSelection; + } + + /** + * This implements {@link org.eclipse.jface.viewers.ISelectionProvider} to set this editor's overall selection. + * Calling this result will notify the listeners. + * + * + * @generated + */ + public void setSelection(ISelection selection) { + editorSelection = selection; + + for (ISelectionChangedListener listener : selectionChangedListeners) { + listener.selectionChanged(new SelectionChangedEvent(this, selection)); + } + setStatusLineManager(selection); + } + + /** + * + * + * @generated + */ + public void setStatusLineManager(ISelection selection) { + IStatusLineManager statusLineManager = currentViewer != null && currentViewer == contentOutlineViewer ? + contentOutlineStatusLineManager : getActionBars().getStatusLineManager(); + + if (statusLineManager != null) { + if (selection instanceof IStructuredSelection) { + Collection collection = ((IStructuredSelection)selection).toList(); + switch (collection.size()) { + case 0: { + statusLineManager.setMessage(getString("_UI_NoObjectSelected")); + break; + } + case 1: { + String text = new AdapterFactoryItemDelegator(adapterFactory).getText(collection.iterator().next()); + statusLineManager.setMessage(getString("_UI_SingleObjectSelected", text)); + break; + } + default: { + statusLineManager.setMessage(getString("_UI_MultiObjectSelected", Integer.toString(collection.size()))); + break; + } + } + } + else { + statusLineManager.setMessage(""); + } + } + } + + /** + * This looks up a string in the plugin's plugin.properties file. + * + * + * @generated + */ + private static String getString(String key) { + return WFRperfToolModelEditorPlugin.INSTANCE.getString(key); + } + + /** + * This looks up a string in plugin.properties, making a substitution. + * + * + * @generated + */ + private static String getString(String key, Object s1) { + return WFRperfToolModelEditorPlugin.INSTANCE.getString(key, new Object [] { s1 }); + } + + /** + * This implements {@link org.eclipse.jface.action.IMenuListener} to help fill the context menus with contributions from the Edit menu. + * + * + * @generated + */ + public void menuAboutToShow(IMenuManager menuManager) { + ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager); + } + + /** + * + * + * @generated + */ + public EditingDomainActionBarContributor getActionBarContributor() { + return (EditingDomainActionBarContributor)getEditorSite().getActionBarContributor(); + } + + /** + * + * + * @generated + */ + public IActionBars getActionBars() { + return getActionBarContributor().getActionBars(); + } + + /** + * + * + * @generated + */ + public AdapterFactory getAdapterFactory() { + return adapterFactory; + } + + /** + * + * + * @generated + */ + @Override + public void dispose() { + updateProblemIndication = false; + + getSite().getPage().removePartListener(partListener); + + adapterFactory.dispose(); + + if (getActionBarContributor().getActiveEditor() == this) { + getActionBarContributor().setActiveEditor(null); + } + + for (PropertySheetPage propertySheetPage : propertySheetPages) { + propertySheetPage.dispose(); + } + + if (contentOutlinePage != null) { + contentOutlinePage.dispose(); + } + + super.dispose(); + } + + /** + * Returns whether the outline view should be presented to the user. + * + * + * @generated + */ + protected boolean showOutlineView() { + return true; + } +} diff --git a/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard.java b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard.java new file mode 100755 index 0000000..56831d6 --- /dev/null +++ b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/PerftoolModelWizard.java @@ -0,0 +1,583 @@ +/** + */ +package at.ac.uibk.wfr.perftool.presentation; + + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.MissingResourceException; +import java.util.StringTokenizer; + +import org.eclipse.emf.common.util.URI; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EClassifier; + +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.emf.ecore.resource.ResourceSet; + +import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl; + +import org.eclipse.emf.ecore.EObject; + +import org.eclipse.emf.ecore.xmi.XMLResource; + +import org.eclipse.emf.edit.ui.provider.ExtendedImageRegistry; + +import org.eclipse.core.runtime.IProgressMonitor; + +import org.eclipse.jface.dialogs.MessageDialog; + +import org.eclipse.jface.viewers.IStructuredSelection; + +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.jface.wizard.WizardPage; + +import org.eclipse.swt.SWT; + +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.ModifyEvent; + +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; + +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; + +import at.ac.uibk.wfr.perftool.PerftoolFactory; +import at.ac.uibk.wfr.perftool.PerftoolPackage; +import at.ac.uibk.wfr.perftool.provider.WFRperfToolModelEditPlugin; + + +import java.io.File; + +import org.eclipse.jface.operation.IRunnableWithProgress; + +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; + +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Text; + + +/** + * This is a simple wizard for creating a new model file. + * + * + * @generated + */ +public class PerftoolModelWizard extends Wizard implements INewWizard { + /** + * The supported extensions for created files. + * + * + * @generated + */ + public static final List FILE_EXTENSIONS = + Collections.unmodifiableList(Arrays.asList(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_PerftoolEditorFilenameExtensions").split("\\s*,\\s*"))); + + /** + * A formatted list of supported file extensions, suitable for display. + * + * + * @generated + */ + public static final String FORMATTED_FILE_EXTENSIONS = + WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_PerftoolEditorFilenameExtensions").replaceAll("\\s*,\\s*", ", "); + + /** + * This caches an instance of the model package. + * + * + * @generated + */ + protected PerftoolPackage perftoolPackage = PerftoolPackage.eINSTANCE; + + /** + * This caches an instance of the model factory. + * + * + * @generated + */ + protected PerftoolFactory perftoolFactory = perftoolPackage.getPerftoolFactory(); + + /** + * This is the initial object creation page. + * + * + * @generated + */ + protected PerftoolModelWizardInitialObjectCreationPage initialObjectCreationPage; + + /** + * Remember the selection during initialization for populating the default container. + * + * + * @generated + */ + protected IStructuredSelection selection; + + /** + * Remember the workbench during initialization. + * + * + * @generated + */ + protected IWorkbench workbench; + + /** + * Caches the names of the types that can be created as the root object. + * + * + * @generated + */ + protected List initialObjectNames; + + /** + * This just records the information. + * + * + * @generated + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + this.workbench = workbench; + this.selection = selection; + setWindowTitle(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_Wizard_label")); + setDefaultPageImageDescriptor(ExtendedImageRegistry.INSTANCE.getImageDescriptor(WFRperfToolModelEditorPlugin.INSTANCE.getImage("full/wizban/NewPerftool"))); + } + + /** + * Returns the names of the types that can be created as the root object. + * + * + * @generated + */ + protected Collection getInitialObjectNames() { + if (initialObjectNames == null) { + initialObjectNames = new ArrayList(); + for (EClassifier eClassifier : perftoolPackage.getEClassifiers()) { + if (eClassifier instanceof EClass) { + EClass eClass = (EClass)eClassifier; + if (!eClass.isAbstract()) { + initialObjectNames.add(eClass.getName()); + } + } + } + Collections.sort(initialObjectNames, java.text.Collator.getInstance()); + } + return initialObjectNames; + } + + /** + * Create a new model. + * + * + * @generated + */ + protected EObject createInitialModel() { + EClass eClass = (EClass)perftoolPackage.getEClassifier(initialObjectCreationPage.getInitialObjectName()); + EObject rootObject = perftoolFactory.create(eClass); + return rootObject; + } + + /** + * Do the work after everything is specified. + * + * + * @generated + */ + @Override + public boolean performFinish() { + try { + // Get the URI of the model file. + // + final URI fileURI = getModelURI(); + if (new File(fileURI.toFileString()).exists()) { + if (!MessageDialog.openQuestion + (getShell(), + WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_Question_title"), + WFRperfToolModelEditorPlugin.INSTANCE.getString("_WARN_FileConflict", new String []{ fileURI.toFileString() }))) { + initialObjectCreationPage.selectFileField(); + return false; + } + } + + // Do the work within an operation. + // + IRunnableWithProgress operation = new IRunnableWithProgress() { + public void run(IProgressMonitor progressMonitor) { + try { + // Create a resource set + // + ResourceSet resourceSet = new ResourceSetImpl(); + + // Create a resource for this file. + // + Resource resource = resourceSet.createResource(fileURI); + + // Add the initial model object to the contents. + // + EObject rootObject = createInitialModel(); + if (rootObject != null) { + resource.getContents().add(rootObject); + } + + // Save the contents of the resource to the file system. + // + Map options = new HashMap(); + options.put(XMLResource.OPTION_ENCODING, initialObjectCreationPage.getEncoding()); + resource.save(options); + } + catch (Exception exception) { + WFRperfToolModelEditorPlugin.INSTANCE.log(exception); + } + finally { + progressMonitor.done(); + } + } + }; + + getContainer().run(false, false, operation); + + return WFRperfToolModelEditorAdvisor.openEditor(workbench, fileURI); + } + catch (Exception exception) { + WFRperfToolModelEditorPlugin.INSTANCE.log(exception); + return false; + } + } + + /** + * This is the page where the type of object to create is selected. + * + * + * @generated + */ + public class PerftoolModelWizardInitialObjectCreationPage extends WizardPage { + /** + * + * + * @generated + */ + protected Text fileField; + + /** + * + * + * @generated + */ + protected Combo initialObjectField; + + /** + * @generated + * + * + */ + protected List encodings; + + /** + * + * + * @generated + */ + protected Combo encodingField; + + /** + * Pass in the selection. + * + * + * @generated + */ + public PerftoolModelWizardInitialObjectCreationPage(String pageId) { + super(pageId); + } + + /** + * + * + * @generated + */ + public void createControl(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + { + GridLayout layout = new GridLayout(); + layout.numColumns = 1; + layout.verticalSpacing = 12; + composite.setLayout(layout); + + GridData data = new GridData(); + data.verticalAlignment = GridData.FILL; + data.grabExcessVerticalSpace = true; + data.horizontalAlignment = GridData.FILL; + composite.setLayoutData(data); + } + + Label resourceURILabel = new Label(composite, SWT.LEFT); + { + resourceURILabel.setText(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_File_label")); + + GridData data = new GridData(); + data.horizontalAlignment = GridData.FILL; + resourceURILabel.setLayoutData(data); + } + + Composite fileComposite = new Composite(composite, SWT.NONE); + { + GridData data = new GridData(); + data.horizontalAlignment = GridData.END; + fileComposite.setLayoutData(data); + + GridLayout layout = new GridLayout(); + data.horizontalAlignment = GridData.FILL; + layout.marginHeight = 0; + layout.marginWidth = 0; + layout.numColumns = 2; + fileComposite.setLayout(layout); + } + + fileField = new Text(fileComposite, SWT.BORDER); + { + GridData data = new GridData(); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + data.horizontalSpan = 1; + fileField.setLayoutData(data); + } + + fileField.addModifyListener(validator); + + Button resourceURIBrowseFileSystemButton = new Button(fileComposite, SWT.PUSH); + resourceURIBrowseFileSystemButton.setText(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_Browse_label")); + + resourceURIBrowseFileSystemButton.addSelectionListener + (new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent event) { + String[] filters = PerftoolEditor.FILE_EXTENSION_FILTERS.toArray(new String[PerftoolEditor.FILE_EXTENSION_FILTERS.size()]); + String[] files = WFRperfToolModelEditorAdvisor.openFilePathDialog(getShell(), SWT.SAVE, filters); + if (files.length > 0) { + fileField.setText(files[0]); + } + } + }); + Label containerLabel = new Label(composite, SWT.LEFT); + { + containerLabel.setText(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_ModelObject")); + + GridData data = new GridData(); + data.horizontalAlignment = GridData.FILL; + containerLabel.setLayoutData(data); + } + + initialObjectField = new Combo(composite, SWT.BORDER); + { + GridData data = new GridData(); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + initialObjectField.setLayoutData(data); + } + + for (String objectName : getInitialObjectNames()) { + initialObjectField.add(getLabel(objectName)); + } + + if (initialObjectField.getItemCount() == 1) { + initialObjectField.select(0); + } + initialObjectField.addModifyListener(validator); + + Label encodingLabel = new Label(composite, SWT.LEFT); + { + encodingLabel.setText(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_XMLEncoding")); + + GridData data = new GridData(); + data.horizontalAlignment = GridData.FILL; + encodingLabel.setLayoutData(data); + } + encodingField = new Combo(composite, SWT.BORDER); + { + GridData data = new GridData(); + data.horizontalAlignment = GridData.FILL; + data.grabExcessHorizontalSpace = true; + encodingField.setLayoutData(data); + } + + for (String encoding : getEncodings()) { + encodingField.add(encoding); + } + + encodingField.select(0); + encodingField.addModifyListener(validator); + + setPageComplete(validatePage()); + setControl(composite); + } + + /** + * + * + * @generated + */ + protected ModifyListener validator = + new ModifyListener() { + public void modifyText(ModifyEvent e) { + setPageComplete(validatePage()); + } + }; + + /** + * + * + * @generated + */ + protected boolean validatePage() { + URI fileURI = getFileURI(); + if (fileURI == null || fileURI.isEmpty()) { + setErrorMessage(null); + return false; + } + + String extension = fileURI.fileExtension(); + if (extension == null || !FILE_EXTENSIONS.contains(extension)) { + String key = FILE_EXTENSIONS.size() > 1 ? "_WARN_FilenameExtensions" : "_WARN_FilenameExtension"; + setErrorMessage(WFRperfToolModelEditorPlugin.INSTANCE.getString(key, new Object [] { FORMATTED_FILE_EXTENSIONS })); + return false; + } + + setErrorMessage(null); + return getInitialObjectName() != null && getEncodings().contains(encodingField.getText()); + } + + /** + * + * + * @generated + */ + @Override + public void setVisible(boolean visible) { + super.setVisible(visible); + if (visible) { + initialObjectField.clearSelection(); + encodingField.clearSelection(); + fileField.setFocus(); + } + } + + /** + * + * + * @generated + */ + public String getInitialObjectName() { + String label = initialObjectField.getText(); + + for (String name : getInitialObjectNames()) { + if (getLabel(name).equals(label)) { + return name; + } + } + return null; + } + + /** + * + * + * @generated + */ + public String getEncoding() { + return encodingField.getText(); + } + + /** + * + * + * @generated + */ + public URI getFileURI() { + try { + return URI.createFileURI(fileField.getText()); + } + catch (Exception exception) { + // Ignore + } + return null; + } + + /** + * + * + * @generated + */ + public void selectFileField() { + initialObjectField.clearSelection(); + encodingField.clearSelection(); + fileField.selectAll(); + fileField.setFocus(); + } + + /** + * Returns the label for the specified type name. + * + * + * @generated + */ + protected String getLabel(String typeName) { + try { + return WFRperfToolModelEditPlugin.INSTANCE.getString("_UI_" + typeName + "_type"); + } + catch(MissingResourceException mre) { + WFRperfToolModelEditorPlugin.INSTANCE.log(mre); + } + return typeName; + } + + /** + * + * + * @generated + */ + protected Collection getEncodings() { + if (encodings == null) { + encodings = new ArrayList(); + for (StringTokenizer stringTokenizer = new StringTokenizer(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_XMLEncodingChoices")); stringTokenizer.hasMoreTokens(); ) { + encodings.add(stringTokenizer.nextToken()); + } + } + return encodings; + } + } + + /** + * The framework calls this to create the contents of the wizard. + * + * + * @generated + */ + @Override + public void addPages() { + initialObjectCreationPage = new PerftoolModelWizardInitialObjectCreationPage("Whatever2"); + initialObjectCreationPage.setTitle(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_PerftoolModelWizard_label")); + initialObjectCreationPage.setDescription(WFRperfToolModelEditorPlugin.INSTANCE.getString("_UI_Wizard_initial_object_description")); + addPage(initialObjectCreationPage); + } + + /** + * Get the URI from the page. + * + * + * @generated + */ + public URI getModelURI() { + return initialObjectCreationPage.getFileURI(); + } + +} diff --git a/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor.java b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor.java new file mode 100755 index 0000000..2ae879b --- /dev/null +++ b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorAdvisor.java @@ -0,0 +1,567 @@ +/** + */ +package at.ac.uibk.wfr.perftool.presentation; + +import java.io.File; +import java.util.Arrays; + +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; + +import org.eclipse.jface.action.GroupMarker; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.action.Separator; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.IEditorDescriptor; +import org.eclipse.ui.IFolderLayout; +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PartInitException; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.actions.ContributionItemFactory; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; +import org.eclipse.ui.application.IWorkbenchConfigurer; +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchAdvisor; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +import org.eclipse.emf.common.ui.URIEditorInput; +import org.eclipse.emf.common.ui.action.WorkbenchWindowActionDelegate; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.edit.ui.action.LoadResourceAction; +import org.eclipse.emf.edit.ui.util.EditUIUtil; + +import at.ac.uibk.wfr.perftool.presentation.WFRperfToolModelEditorPlugin; +import at.ac.uibk.wfr.perftool.view.WFREventView; + + +/** + * Customized {@link WorkbenchAdvisor} for the RCP application. + * + * + * @generated + */ +public final class WFRperfToolModelEditorAdvisor extends WorkbenchAdvisor { + /** + * The default file extension filters for use in dialogs. + * + * + * @generated + */ + private static final String[] FILE_EXTENSION_FILTERS = PerftoolEditor.FILE_EXTENSION_FILTERS.toArray(new String[0]); + + /** + * This looks up a string in the plugin's plugin.properties file. + * + * + * @generated + */ + private static String getString(String key) { + return WFRperfToolModelEditorPlugin.INSTANCE.getString(key); + } + + /** + * This looks up a string in plugin.properties, making a substitution. + * + * + * @generated + */ + private static String getString(String key, Object s1) { + return at.ac.uibk.wfr.perftool.presentation.WFRperfToolModelEditorPlugin.INSTANCE.getString(key, new Object [] { s1 }); + } + + /** + * RCP's application + * + * + * @generated + */ + public static class Application implements IApplication { + /** + * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) + * + * + * @generated + */ + public Object start(IApplicationContext context) throws Exception { + WorkbenchAdvisor workbenchAdvisor = new WFRperfToolModelEditorAdvisor(); + Display display = PlatformUI.createDisplay(); + try { + int returnCode = PlatformUI.createAndRunWorkbench(display, workbenchAdvisor); + if (returnCode == PlatformUI.RETURN_RESTART) { + return IApplication.EXIT_RESTART; + } + else { + return IApplication.EXIT_OK; + } + } + finally { + display.dispose(); + } + } + + /** + * @see org.eclipse.equinox.app.IApplication#stop() + * + * + * @generated + */ + public void stop() { + // Do nothing. + } + } + + /** + * RCP's perspective + * + * + * @generated + */ + public static class Perspective implements IPerspectiveFactory { + /** + * Perspective ID + * + * + * @generated + */ + public static final String ID_PERSPECTIVE = "at.ac.uibk.wfr.perftool.presentation.WFRperfToolModelEditorAdvisorPerspective"; + + /** + * @see org.eclipse.ui.IPerspectiveFactory#createInitialLayout(org.eclipse.ui.IPageLayout) + * + * + * @generated + */ + public void createInitialLayout(IPageLayout layout) { + layout.setEditorAreaVisible(true); + layout.addPerspectiveShortcut(ID_PERSPECTIVE); + + IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT, (float)0.66, layout.getEditorArea()); + //right.addView(IPageLayout.ID_OUTLINE); + right.addView(WFREventView.ID); + + IFolderLayout bottonRight = layout.createFolder("bottonRight", IPageLayout.BOTTOM, (float)0.60, "right"); + bottonRight.addView(IPageLayout.ID_PROP_SHEET); + } + } + + /** + * RCP's window advisor + * + * + * @generated + */ + public static class WindowAdvisor extends WorkbenchWindowAdvisor { + /** + * @see WorkbenchWindowAdvisor#WorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer) + * + * + * @generated + */ + public WindowAdvisor(IWorkbenchWindowConfigurer configurer) { + super(configurer); + } + + /** + * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#preWindowOpen() + * + * + * @generated + */ + @Override + public void preWindowOpen() { + IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); + configurer.setInitialSize(new Point(600, 450)); + configurer.setShowCoolBar(false); + configurer.setShowStatusLine(true); + configurer.setTitle(getString("_UI_Application_title")); + } + + /** + * @see org.eclipse.ui.application.WorkbenchWindowAdvisor#createActionBarAdvisor(org.eclipse.ui.application.IActionBarConfigurer) + * + * + * @generated + */ + @Override + public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { + return new WindowActionBarAdvisor(configurer); + } + } + + /** + * RCP's action bar advisor + * + * + * @generated + */ + public static class WindowActionBarAdvisor extends ActionBarAdvisor { + /** + * @see ActionBarAdvisor#ActionBarAdvisor(org.eclipse.ui.application.IActionBarConfigurer) + * + * + * @generated + */ + public WindowActionBarAdvisor(IActionBarConfigurer configurer) { + super(configurer); + } + + /** + * @see org.eclipse.ui.application.ActionBarAdvisor#fillMenuBar(org.eclipse.jface.action.IMenuManager) + * + * + * @generated + */ + @Override + protected void fillMenuBar(IMenuManager menuBar) { + IWorkbenchWindow window = getActionBarConfigurer().getWindowConfigurer().getWindow(); + menuBar.add(createFileMenu(window)); + menuBar.add(createEditMenu(window)); + menuBar.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + menuBar.add(createWindowMenu(window)); + menuBar.add(createHelpMenu(window)); + } + + /** + * Creates the 'File' menu. + * + * + * @generated + */ + protected IMenuManager createFileMenu(IWorkbenchWindow window) { + IMenuManager menu = new MenuManager(getString("_UI_Menu_File_label"), + IWorkbenchActionConstants.M_FILE); + menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_START)); + + IMenuManager newMenu = new MenuManager(getString("_UI_Menu_New_label"), "new"); + newMenu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + + menu.add(newMenu); + menu.add(new Separator()); + menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + menu.add(new Separator()); + addToMenuAndRegister(menu, ActionFactory.CLOSE.create(window)); + addToMenuAndRegister(menu, ActionFactory.CLOSE_ALL.create(window)); + menu.add(new Separator()); + addToMenuAndRegister(menu, ActionFactory.SAVE.create(window)); + addToMenuAndRegister(menu, ActionFactory.SAVE_AS.create(window)); + addToMenuAndRegister(menu, ActionFactory.SAVE_ALL.create(window)); + menu.add(new Separator()); + addToMenuAndRegister(menu, ActionFactory.QUIT.create(window)); + menu.add(new GroupMarker(IWorkbenchActionConstants.FILE_END)); + return menu; + } + + /** + * Creates the 'Edit' menu. + * + * + * @generated + */ + protected IMenuManager createEditMenu(IWorkbenchWindow window) { + IMenuManager menu = new MenuManager(getString("_UI_Menu_Edit_label"), + IWorkbenchActionConstants.M_EDIT); + menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_START)); + + addToMenuAndRegister(menu, ActionFactory.UNDO.create(window)); + addToMenuAndRegister(menu, ActionFactory.REDO.create(window)); + menu.add(new GroupMarker(IWorkbenchActionConstants.UNDO_EXT)); + menu.add(new Separator()); + + addToMenuAndRegister(menu, ActionFactory.CUT.create(window)); + addToMenuAndRegister(menu, ActionFactory.COPY.create(window)); + addToMenuAndRegister(menu, ActionFactory.PASTE.create(window)); + menu.add(new GroupMarker(IWorkbenchActionConstants.CUT_EXT)); + menu.add(new Separator()); + + addToMenuAndRegister(menu, ActionFactory.DELETE.create(window)); + addToMenuAndRegister(menu, ActionFactory.SELECT_ALL.create(window)); + menu.add(new Separator()); + + menu.add(new GroupMarker(IWorkbenchActionConstants.ADD_EXT)); + + menu.add(new GroupMarker(IWorkbenchActionConstants.EDIT_END)); + menu.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS)); + return menu; + } + + /** + * Creates the 'Window' menu. + * + * + * @generated + */ + protected IMenuManager createWindowMenu(IWorkbenchWindow window) { + IMenuManager menu = new MenuManager(getString("_UI_Menu_Window_label"), + IWorkbenchActionConstants.M_WINDOW); + + addToMenuAndRegister(menu, ActionFactory.OPEN_NEW_WINDOW.create(window)); + menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + menu.add(ContributionItemFactory.OPEN_WINDOWS.create(window)); + + return menu; + } + + /** + * Creates the 'Help' menu. + * + * + * @generated + */ + protected IMenuManager createHelpMenu(IWorkbenchWindow window) { + IMenuManager menu = new MenuManager(getString("_UI_Menu_Help_label"), IWorkbenchActionConstants.M_HELP); + // Welcome or intro page would go here + // Help contents would go here + // Tips and tricks page would go here + menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_START)); + menu.add(new GroupMarker(IWorkbenchActionConstants.HELP_END)); + menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS)); + return menu; + } + + /** + * Adds the specified action to the given menu and also registers the action with the + * action bar configurer, in order to activate its key binding. + * + * + * @generated + */ + protected void addToMenuAndRegister(IMenuManager menuManager, IAction action) { + menuManager.add(action); + getActionBarConfigurer().registerGlobalAction(action); + } + } + + /** + * About action for the RCP application. + * + * + * @generated + */ + public static class AboutAction extends WorkbenchWindowActionDelegate { + /** + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + * + * + * @generated + */ + public void run(IAction action) { + MessageDialog.openInformation(getWindow().getShell(), getString("_UI_About_title"), + getString("_UI_About_text")); + } + } + + /** + * Open action for the objects from the WFRperfToolModel model. + * + * + * @generated + */ + public static class OpenAction extends WorkbenchWindowActionDelegate { + /** + * Opens the editors for the files selected using the file dialog. + * + * + * @generated + */ + public void run(IAction action) { + String[] filePaths = openFilePathDialog(getWindow().getShell(), SWT.OPEN, null); + if (filePaths.length > 0) { + openEditor(getWindow().getWorkbench(), URI.createFileURI(filePaths[0])); + } + } + } + + /** + * Open URI action for the objects from the WFRperfToolModel model. + * + * + * @generated + */ + public static class OpenURIAction extends WorkbenchWindowActionDelegate { + /** + * Opens the editors for the files selected using the LoadResourceDialog. + * + * + * @generated + */ + public void run(IAction action) { + LoadResourceAction.LoadResourceDialog loadResourceDialog = new LoadResourceAction.LoadResourceDialog(getWindow().getShell()); + if (Window.OK == loadResourceDialog.open()) { + for (URI uri : loadResourceDialog.getURIs()) { + openEditor(getWindow().getWorkbench(), uri); + } + } + } + } + + /** + * + * + * @generated + */ + public static String[] openFilePathDialog(Shell shell, int style, String[] fileExtensionFilters) { + return openFilePathDialog(shell, style, fileExtensionFilters, (style & SWT.OPEN) != 0, (style & SWT.OPEN) != 0, (style & SWT.SAVE) != 0); + } + + /** + * + * + * @generated + */ + public static String[] openFilePathDialog(Shell shell, int style, String[] fileExtensionFilters, boolean includeGroupFilter, boolean includeAllFilter, boolean addExtension) { + FileDialog fileDialog = new FileDialog(shell, style); + if (fileExtensionFilters == null) { + fileExtensionFilters = FILE_EXTENSION_FILTERS; + } + + // If requested, augment the file extension filters by adding a group of all the other filters (*.ext1;*.ext2;...) + // at the beginning and/or an all files wildcard (*.*) at the end. + // + includeGroupFilter &= fileExtensionFilters.length > 1; + int offset = includeGroupFilter ? 1 : 0; + + if (includeGroupFilter || includeAllFilter) { + int size = fileExtensionFilters.length + offset + (includeAllFilter ? 1 : 0); + String[] allFilters = new String[size]; + StringBuilder group = includeGroupFilter ? new StringBuilder() : null; + + for (int i = 0; i < fileExtensionFilters.length; i++) { + if (includeGroupFilter) { + if (i != 0) { + group.append(';'); + } + group.append(fileExtensionFilters[i]); + } + allFilters[i + offset] = fileExtensionFilters[i]; + } + + if (includeGroupFilter) { + allFilters[0] = group.toString(); + } + if (includeAllFilter) { + allFilters[allFilters.length - 1] = "*.*"; + } + + fileDialog.setFilterExtensions(allFilters); + } + else { + fileDialog.setFilterExtensions(fileExtensionFilters); + } + fileDialog.open(); + + String[] filenames = fileDialog.getFileNames(); + String[] result = new String[filenames.length]; + String path = fileDialog.getFilterPath() + File.separator; + String extension = null; + + // If extension adding requested, get the dotted extension corresponding to the selected filter. + // + if (addExtension) { + int i = fileDialog.getFilterIndex(); + if (i != -1 && (!includeAllFilter || i != fileExtensionFilters.length)) { + i = includeGroupFilter && i == 0 ? 0 : i - offset; + String filter = fileExtensionFilters[i]; + int dot = filter.lastIndexOf('.'); + if (dot == 1 && filter.charAt(0) == '*') { + extension = filter.substring(dot); + } + } + } + + // Build the result by adding the selected path and, if needed, auto-appending the extension. + // + for (int i = 0; i < filenames.length; i++) { + String filename = path + filenames[i]; + if (extension != null) { + int dot = filename.lastIndexOf('.'); + if (dot == -1 || !Arrays.asList(fileExtensionFilters).contains("*" + filename.substring(dot))) { + filename += extension; + } + } + result[i] = filename; + } + return result; + } + + /** + * + * + * @generated + */ + public static boolean openEditor(IWorkbench workbench, URI uri) { + IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); + IWorkbenchPage page = workbenchWindow.getActivePage(); + + IEditorDescriptor editorDescriptor = EditUIUtil.getDefaultEditor(uri, null); + if (editorDescriptor == null) { + MessageDialog.openError( + workbenchWindow.getShell(), + getString("_UI_Error_title"), + getString("_WARN_No_Editor", uri.lastSegment())); + return false; + } + else { + try { + page.openEditor(new URIEditorInput(uri), editorDescriptor.getId()); + } + catch (PartInitException exception) { + MessageDialog.openError( + workbenchWindow.getShell(), + getString("_UI_OpenEditorError_label"), + exception.getMessage()); + return false; + } + } + return true; + } + + /** + * @see org.eclipse.ui.application.WorkbenchAdvisor#getInitialWindowPerspectiveId() + * + * + * @generated + */ + @Override + public String getInitialWindowPerspectiveId() { + return Perspective.ID_PERSPECTIVE; + } + + /** + * @see org.eclipse.ui.application.WorkbenchAdvisor#initialize(org.eclipse.ui.application.IWorkbenchConfigurer) + * + * + * @generated + */ + @Override + public void initialize(IWorkbenchConfigurer configurer) { + super.initialize(configurer); + configurer.setSaveAndRestore(true); + } + + /** + * @see org.eclipse.ui.application.WorkbenchAdvisor#createWorkbenchWindowAdvisor(org.eclipse.ui.application.IWorkbenchWindowConfigurer) + * + * + * @generated + * @wbp.parser.entryPoint + */ + @Override + public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + return new WindowAdvisor(configurer); + } +} diff --git a/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorPlugin.java b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorPlugin.java new file mode 100755 index 0000000..e30aad8 --- /dev/null +++ b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/WFRperfToolModelEditorPlugin.java @@ -0,0 +1,91 @@ +/** + */ +package at.ac.uibk.wfr.perftool.presentation; + +import org.eclipse.emf.common.EMFPlugin; + +import org.eclipse.emf.common.ui.EclipseUIPlugin; + +import org.eclipse.emf.common.util.ResourceLocator; + +/** + * This is the central singleton for the WFRperfToolModel editor plugin. + * + * + * @generated + */ +public final class WFRperfToolModelEditorPlugin extends EMFPlugin { + /** + * Keep track of the singleton. + * + * + * @generated + */ + public static final WFRperfToolModelEditorPlugin INSTANCE = new WFRperfToolModelEditorPlugin(); + + /** + * Keep track of the singleton. + * + * + * @generated + */ + private static Implementation plugin; + + /** + * Create the instance. + * + * + * @generated + */ + public WFRperfToolModelEditorPlugin() { + super + (new ResourceLocator [] { + }); + } + + /** + * Returns the singleton instance of the Eclipse plugin. + * + * + * @return the singleton instance. + * @generated + */ + @Override + public ResourceLocator getPluginResourceLocator() { + return plugin; + } + + /** + * Returns the singleton instance of the Eclipse plugin. + * + * + * @return the singleton instance. + * @generated + */ + public static Implementation getPlugin() { + return plugin; + } + + /** + * The actual implementation of the Eclipse Plugin. + * + * + * @generated + */ + public static class Implementation extends EclipseUIPlugin { + /** + * Creates an instance. + * + * + * @generated + */ + public Implementation() { + super(); + + // Remember the static instance. + // + plugin = this; + } + } + +} diff --git a/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/teneo.properties b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/teneo.properties new file mode 100755 index 0000000..ddfb453 --- /dev/null +++ b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/presentation/teneo.properties @@ -0,0 +1,29 @@ + ## Debug Settings +#hibernate.show_sql=true +#hibernate.format_sql=true +#hibernate.use_sql_comments=true + +hibernate.connection.driver_class=org.sqlite.JDBC + +#hibernate.connection.url=jdbc\:sqlite\:default.sqlite + +## Database Creation Mode (validate | update | create | create-drop) +hibernate.hbm2ddl.auto=validate + +hibernate.dialect=perftoolutils.SQLiteDialect + +teneo.naming.join_column_naming_strategy=simple + +## Teneo Settings +teneo.mapping.disable_econtainer=true +teneo.mapping.always_version=false +teneo.mapping.inheritance=JOINED +teneo.naming.sql_fk_name_prefix=fk_ +teneo.naming.set_foreign_key_name=true +hibernate.jdbc.batch_size=30 + +## Teneo Cache Settings +#hibernate.cache.use_second_level_cache=false +#hibernate.cache.use_query_cache=false +#teneo.mapping.default_cache_strategy=NONE +#hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory \ No newline at end of file diff --git a/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/view/WFREventView.java b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/view/WFREventView.java new file mode 100755 index 0000000..06e708b --- /dev/null +++ b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/view/WFREventView.java @@ -0,0 +1,182 @@ +package at.ac.uibk.wfr.perftool.view; + +import org.eclipse.emf.edit.provider.ComposedAdapterFactory; +import org.eclipse.emf.edit.provider.ReflectiveItemProviderAdapterFactory; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider; +import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.ITreeSelection; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.ui.IActionBars; +import org.eclipse.ui.ISelectionListener; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.part.ViewPart; +import org.eclipse.ui.views.properties.IPropertySheetPage; +import org.eclipse.ui.views.properties.PropertySheetPage; + +import at.ac.uibk.wfr.perftool.provider.PerftoolItemProviderAdapterFactory; +import at.ac.uibk.wfr.perftool.wfreventview.WFREventViewResource; + +public class WFREventView extends ViewPart implements ISelectionListener, ISelectionChangedListener, ISelectionProvider { + + public static final String ID = "at.ac.uibk.wfr.perftool.view.WFREventView"; //$NON-NLS-1$ + + protected TreeViewer treeViewer; + + WFREventViewResource resource = new WFREventViewResource(); + + ComposedAdapterFactory adapterFactory = null; + PerftoolItemProviderAdapterFactory wfrAdapterFactory = null; + + protected ISelection editorSelection = StructuredSelection.EMPTY; + protected PropertySheetPage propertySheetPage; + + public WFREventView() { + super(); + adapterFactory = new ComposedAdapterFactory(); + wfrAdapterFactory = new PerftoolItemProviderAdapterFactory(); + adapterFactory.addAdapterFactory(wfrAdapterFactory); + //adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory()); + } + + /** + * Create contents of the view part. + * @param parent + */ + @Override + public void createPartControl(Composite parent) { + + treeViewer = new TreeViewer(parent); + Tree tree = treeViewer.getTree(); + tree.setHeaderVisible(true); + tree.setLinesVisible(true); + + + createActions(); + initializeToolBar(); + initializeMenu(); + + getSite().getPage().addSelectionListener(this); + + createActions(); + initializeToolBar(); + initializeMenu(); + + treeViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory)); + treeViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)); + treeViewer.setInput(resource); + treeViewer.addSelectionChangedListener(this); + getSite().setSelectionProvider(treeViewer); + } + + /** + * Create the actions. + */ + private void createActions() { + // Create the actions + } + + /** + * Initialize the toolbar. + */ + private void initializeToolBar() { + IToolBarManager toolbarManager = getViewSite().getActionBars() + .getToolBarManager(); + } + + /** + * Initialize the menu. + */ + private void initializeMenu() { + IMenuManager menuManager = getViewSite().getActionBars() + .getMenuManager(); + } + + @Override + public void setFocus() { + // Set the focus + } + + @Override + public void selectionChanged(IWorkbenchPart part, ISelection selection) { + if (part == this) { + + } else { + if (selection instanceof ITreeSelection) { + ITreeSelection ts = (ITreeSelection) selection; + Object o = ts.getFirstElement(); + resource.setRootObject(o); + treeViewer.refresh(); + } + } + } + + + + /** + * This is how the framework determines which interfaces we implement. + * + * + * @generated + */ + @SuppressWarnings("rawtypes") + @Override + public Object getAdapter(Class key) { + if (key.equals(IPropertySheetPage.class)) { + return getPropertySheetPage(); + } + else { + return super.getAdapter(key); + } + } + + public IPropertySheetPage getPropertySheetPage() { + if (propertySheetPage == null) { + propertySheetPage = new PropertySheetPage() { + @Override + public void setActionBars(IActionBars actionBars) { + super.setActionBars(actionBars); + } + }; + propertySheetPage.setPropertySourceProvider(new AdapterFactoryContentProvider(adapterFactory)); + } + return propertySheetPage; + } + + @Override + public void addSelectionChangedListener(ISelectionChangedListener listener) { + // TODO Auto-generated method stub + + } + + @Override + public ISelection getSelection() { + return editorSelection; + } + + @Override + public void removeSelectionChangedListener( + ISelectionChangedListener listener) { + // TODO Auto-generated method stub + + } + + @Override + public void setSelection(ISelection selection) { + editorSelection = selection; + } + + @Override + public void selectionChanged(SelectionChangedEvent event) { + setSelection(event.getSelection()); + } + +} diff --git a/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/wfreventview/WFREventViewResource.java b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/wfreventview/WFREventViewResource.java new file mode 100755 index 0000000..a5fad61 --- /dev/null +++ b/WFRperfTool.editor/src/at/ac/uibk/wfr/perftool/wfreventview/WFREventViewResource.java @@ -0,0 +1,82 @@ +package at.ac.uibk.wfr.perftool.wfreventview; + +import java.util.Collection; +import java.util.Vector; + +import org.eclipse.emf.edit.provider.IStructuredItemContentProvider; +import org.eclipse.emf.edit.provider.ITreeItemContentProvider; +import org.eclipse.jface.viewers.ITreeContentProvider; +import org.eclipse.jface.viewers.Viewer; + +import at.ac.uibk.wfr.perftool.Activity; +import at.ac.uibk.wfr.perftool.ActivityInstance; +import at.ac.uibk.wfr.perftool.Workflow; + +public class WFREventViewResource implements ITreeItemContentProvider, IStructuredItemContentProvider { + + private int rootObjectType; // 0 .. nothing, 1 .. Workflow, 2 .. Activity, 3 .. ActivityInstance + + private Workflow workflow = null; + private Activity activity = null; + private ActivityInstance instance = null; + + public void setRootObject(Object o) { + if (o instanceof Workflow) { + workflow = (Workflow)o; + rootObjectType = 1; + } else if (o instanceof Activity) { + activity = (Activity)o; + rootObjectType = 2; + } else if (o instanceof ActivityInstance) { + instance = (ActivityInstance)o; + rootObjectType = 3; + } else { + rootObjectType = 0; + } + } + + @Override + public Object getParent(Object element) { + return null; + } + + @Override + public boolean hasChildren(Object element) { + return true; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public Collection getElements(Object arg0) { + return getChildren(arg0); + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + @Override + public Collection getChildren(Object arg0) { + Vector retval = new Vector(); + switch (rootObjectType) { + case 1: + if (arg0 == null || arg0 == workflow || arg0 == this) { + retval.addAll(workflow.getStatusEvents()); + retval.addAll(workflow.getDeviceEvents()); + retval.addAll(workflow.getComponentEvents()); + } + break; + case 2: + if (arg0 == null || arg0 == activity || arg0 == this) { + retval.addAll(activity.getStatusEvents()); + } + break; + case 3: + if (arg0 == null || arg0 == instance || arg0 == this) { + retval.addAll(instance.getStatusEvents()); + } + break; + default: + break; + } + return retval; + } + +} diff --git a/WFRperfTool/.classpath b/WFRperfTool/.classpath new file mode 100755 index 0000000..d131682 --- /dev/null +++ b/WFRperfTool/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/WFRperfTool/.project b/WFRperfTool/.project new file mode 100755 index 0000000..878d849 --- /dev/null +++ b/WFRperfTool/.project @@ -0,0 +1,28 @@ + + + WFRperfTool + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/WFRperfTool/.settings/org.eclipse.core.resources.prefs b/WFRperfTool/.settings/org.eclipse.core.resources.prefs new file mode 100755 index 0000000..a85a27a --- /dev/null +++ b/WFRperfTool/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,3 @@ +eclipse.preferences.version=1 +encoding//dbmodel/WFRperfToolModel.ecore=UTF-8 +encoding//dbmodel/WFRperfToolModel.ecorediag=UTF-8 diff --git a/WFRperfTool/.settings/org.eclipse.jdt.core.prefs b/WFRperfTool/.settings/org.eclipse.jdt.core.prefs new file mode 100755 index 0000000..c537b63 --- /dev/null +++ b/WFRperfTool/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/WFRperfTool/META-INF/MANIFEST.MF b/WFRperfTool/META-INF/MANIFEST.MF new file mode 100755 index 0000000..ba8b263 --- /dev/null +++ b/WFRperfTool/META-INF/MANIFEST.MF @@ -0,0 +1,21 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: %pluginName +Bundle-SymbolicName: WFRperfTool;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-ClassPath: ., + libs/sqlite-jdbc-3.7.2.jar +Bundle-Vendor: %providerName +Bundle-Localization: plugin +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.emf.ecore;visibility:=reexport, + org.eclipse.emf.teneo;bundle-version="2.0.1", + org.eclipse.emf.teneo.hibernate;bundle-version="2.0.1", + org.hibernate;bundle-version="4.1.1", + org.apache.commons.logging;bundle-version="1.1.1", + javax.persistence;bundle-version="2.0.1" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Export-Package: at.ac.uibk.wfr.perftool, + at.ac.uibk.wfr.perftool.impl, + at.ac.uibk.wfr.perftool.util diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/Activity.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/Activity.class new file mode 100755 index 0000000..c51725a Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/Activity.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/ActivityInstance.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/ActivityInstance.class new file mode 100755 index 0000000..1726877 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/ActivityInstance.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/ActivityInstanceStatusEvent.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/ActivityInstanceStatusEvent.class new file mode 100755 index 0000000..28adb07 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/ActivityInstanceStatusEvent.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/ActivityStatusEvent.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/ActivityStatusEvent.class new file mode 100755 index 0000000..9ed47bf Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/ActivityStatusEvent.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/ComponentStatusEvent.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/ComponentStatusEvent.class new file mode 100755 index 0000000..583b9a8 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/ComponentStatusEvent.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/DeviceInstanceStatusEvent.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/DeviceInstanceStatusEvent.class new file mode 100755 index 0000000..1fd7353 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/DeviceInstanceStatusEvent.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/PerftoolFactory.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/PerftoolFactory.class new file mode 100755 index 0000000..b21b40d Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/PerftoolFactory.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/PerftoolPackage$Literals.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/PerftoolPackage$Literals.class new file mode 100755 index 0000000..467969e Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/PerftoolPackage$Literals.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/PerftoolPackage.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/PerftoolPackage.class new file mode 100755 index 0000000..cf07ca2 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/PerftoolPackage.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/Workflow.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/Workflow.class new file mode 100755 index 0000000..e974329 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/Workflow.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/WorkflowStatusEvent.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/WorkflowStatusEvent.class new file mode 100755 index 0000000..1dbdc36 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/WorkflowStatusEvent.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ActivityImpl.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ActivityImpl.class new file mode 100755 index 0000000..6c1add5 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ActivityImpl.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ActivityInstanceImpl.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ActivityInstanceImpl.class new file mode 100755 index 0000000..beafec2 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ActivityInstanceImpl.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ActivityInstanceStatusEventImpl.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ActivityInstanceStatusEventImpl.class new file mode 100755 index 0000000..e406e13 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ActivityInstanceStatusEventImpl.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ActivityStatusEventImpl.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ActivityStatusEventImpl.class new file mode 100755 index 0000000..e1c1b69 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ActivityStatusEventImpl.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ComponentStatusEventImpl.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ComponentStatusEventImpl.class new file mode 100755 index 0000000..997b33d Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/ComponentStatusEventImpl.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/DeviceInstanceStatusEventImpl.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/DeviceInstanceStatusEventImpl.class new file mode 100755 index 0000000..c73e921 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/DeviceInstanceStatusEventImpl.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/PerftoolFactoryImpl.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/PerftoolFactoryImpl.class new file mode 100755 index 0000000..b9fa0fd Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/PerftoolFactoryImpl.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/PerftoolPackageImpl.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/PerftoolPackageImpl.class new file mode 100755 index 0000000..aacd4f5 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/PerftoolPackageImpl.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/WorkflowImpl.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/WorkflowImpl.class new file mode 100755 index 0000000..06f1d77 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/WorkflowImpl.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/WorkflowStatusEventImpl.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/WorkflowStatusEventImpl.class new file mode 100755 index 0000000..034758e Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/impl/WorkflowStatusEventImpl.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/util/PerftoolAdapterFactory$1.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/util/PerftoolAdapterFactory$1.class new file mode 100755 index 0000000..c6b9d68 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/util/PerftoolAdapterFactory$1.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/util/PerftoolAdapterFactory.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/util/PerftoolAdapterFactory.class new file mode 100755 index 0000000..53caa8a Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/util/PerftoolAdapterFactory.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/util/PerftoolSwitch.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/util/PerftoolSwitch.class new file mode 100755 index 0000000..c9da624 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/util/PerftoolSwitch.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ActivityInstanceStatusEventValidator.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ActivityInstanceStatusEventValidator.class new file mode 100755 index 0000000..b3d9d92 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ActivityInstanceStatusEventValidator.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ActivityInstanceValidator.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ActivityInstanceValidator.class new file mode 100755 index 0000000..34b3b97 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ActivityInstanceValidator.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ActivityStatusEventValidator.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ActivityStatusEventValidator.class new file mode 100755 index 0000000..a29f11e Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ActivityStatusEventValidator.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ActivityValidator.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ActivityValidator.class new file mode 100755 index 0000000..8954030 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ActivityValidator.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ComponentStatusEventValidator.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ComponentStatusEventValidator.class new file mode 100755 index 0000000..c09841c Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/ComponentStatusEventValidator.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/DeviceInstanceStatusEventValidator.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/DeviceInstanceStatusEventValidator.class new file mode 100755 index 0000000..2d52675 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/DeviceInstanceStatusEventValidator.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/WorkflowStatusEventValidator.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/WorkflowStatusEventValidator.class new file mode 100755 index 0000000..842fdbf Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/WorkflowStatusEventValidator.class differ diff --git a/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/WorkflowValidator.class b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/WorkflowValidator.class new file mode 100755 index 0000000..e004c93 Binary files /dev/null and b/WFRperfTool/bin/at/ac/uibk/wfr/perftool/validation/WorkflowValidator.class differ diff --git a/WFRperfTool/bin/perftoolutils/DBCreator.class b/WFRperfTool/bin/perftoolutils/DBCreator.class new file mode 100755 index 0000000..e47a783 Binary files /dev/null and b/WFRperfTool/bin/perftoolutils/DBCreator.class differ diff --git a/WFRperfTool/bin/perftoolutils/MySQLNameStrategy.class b/WFRperfTool/bin/perftoolutils/MySQLNameStrategy.class new file mode 100755 index 0000000..b034d5b Binary files /dev/null and b/WFRperfTool/bin/perftoolutils/MySQLNameStrategy.class differ diff --git a/WFRperfTool/bin/perftoolutils/SQLiteDialect$1.class b/WFRperfTool/bin/perftoolutils/SQLiteDialect$1.class new file mode 100755 index 0000000..f95ba3e Binary files /dev/null and b/WFRperfTool/bin/perftoolutils/SQLiteDialect$1.class differ diff --git a/WFRperfTool/bin/perftoolutils/SQLiteDialect.class b/WFRperfTool/bin/perftoolutils/SQLiteDialect.class new file mode 100755 index 0000000..1b8bcd2 Binary files /dev/null and b/WFRperfTool/bin/perftoolutils/SQLiteDialect.class differ diff --git a/WFRperfTool/bin/perftoolutils/teneo.properties b/WFRperfTool/bin/perftoolutils/teneo.properties new file mode 100755 index 0000000..a254519 --- /dev/null +++ b/WFRperfTool/bin/perftoolutils/teneo.properties @@ -0,0 +1,29 @@ + ## Debug Settings +hibernate.show_sql=true +hibernate.format_sql=true +hibernate.use_sql_comments=true + +hibernate.connection.driver_class=org.sqlite.JDBC + +hibernate.connection.url=jdbc\:sqlite\:default.sqlite + +## Database Creation Mode (validate | update | create | create-drop) +hibernate.hbm2ddl.auto=validate + +hibernate.dialect=perftoolutils.SQLiteDialect + +teneo.naming.join_column_naming_strategy=simple + +## Teneo Settings +teneo.mapping.disable_econtainer=true +teneo.mapping.always_version=false +teneo.mapping.inheritance=JOINED +teneo.naming.sql_fk_name_prefix=fk_ +teneo.naming.set_foreign_key_name=true +hibernate.jdbc.batch_size=30 + +## Teneo Cache Settings +#hibernate.cache.use_second_level_cache=false +#hibernate.cache.use_query_cache=false +#teneo.mapping.default_cache_strategy=NONE +#hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory \ No newline at end of file diff --git a/WFRperfTool/build.properties b/WFRperfTool/build.properties new file mode 100755 index 0000000..ea0a364 --- /dev/null +++ b/WFRperfTool/build.properties @@ -0,0 +1,11 @@ +# + +bin.includes = .,\ + model/,\ + META-INF/,\ + plugin.xml,\ + plugin.properties,\ + libs/sqlite-jdbc-3.7.2.jar +jars.compile.order = . +source.. = src/ +output.. = bin/ diff --git a/WFRperfTool/dbmodel/WFRperfToolModel.ecore b/WFRperfTool/dbmodel/WFRperfToolModel.ecore new file mode 100755 index 0000000..b5430c9 --- /dev/null +++ b/WFRperfTool/dbmodel/WFRperfToolModel.ecore @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WFRperfTool/dbmodel/WFRperfToolModel.ecorediag b/WFRperfTool/dbmodel/WFRperfToolModel.ecorediag new file mode 100755 index 0000000..2fe5cd4 --- /dev/null +++ b/WFRperfTool/dbmodel/WFRperfToolModel.ecorediag @@ -0,0 +1,528 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WFRperfTool/dbmodel/WFRperfToolModel.genmodel b/WFRperfTool/dbmodel/WFRperfToolModel.genmodel new file mode 100755 index 0000000..f6c869d --- /dev/null +++ b/WFRperfTool/dbmodel/WFRperfToolModel.genmodel @@ -0,0 +1,84 @@ + + + WFRperfToolModel.ecore + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/WFRperfTool/default.sqlite b/WFRperfTool/default.sqlite new file mode 100755 index 0000000..0730b1c Binary files /dev/null and b/WFRperfTool/default.sqlite differ diff --git a/WFRperfTool/libs/sqlite-jdbc-3.7.2.jar b/WFRperfTool/libs/sqlite-jdbc-3.7.2.jar new file mode 100755 index 0000000..b0bec7b Binary files /dev/null and b/WFRperfTool/libs/sqlite-jdbc-3.7.2.jar differ diff --git a/WFRperfTool/plugin.properties b/WFRperfTool/plugin.properties new file mode 100755 index 0000000..29db60c --- /dev/null +++ b/WFRperfTool/plugin.properties @@ -0,0 +1,4 @@ +# + +pluginName = WFRperfToolModel Model +providerName = www.example.org diff --git a/WFRperfTool/plugin.xml b/WFRperfTool/plugin.xml new file mode 100755 index 0000000..fd972f3 --- /dev/null +++ b/WFRperfTool/plugin.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/Activity.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/Activity.java new file mode 100755 index 0000000..715c0ff --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/Activity.java @@ -0,0 +1,272 @@ +/** + */ +package at.ac.uibk.wfr.perftool; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Activity'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.Activity#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Activity#getActid Actid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Activity#getName Name}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Activity#getType Type}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Activity#getBranchID Branch ID}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Activity#getParentWorkflow Parent Workflow}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Activity#getInstances Instances}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Activity#getStatusEvents Status Events}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Activity#getParent Parent}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Activity#getChildren Children}
      • + *
      + *

      + * + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivity() + * @model + * @generated + */ +public interface Activity extends EObject { + /** + * Returns the value of the 'Oid' attribute. + * + *

      + * If the meaning of the 'Oid' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Oid' attribute. + * @see #setOid(int) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivity_Oid() + * @model id="true" required="true" + * @generated + */ + int getOid(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.Activity#getOid Oid}' attribute. + * + * + * @param value the new value of the 'Oid' attribute. + * @see #getOid() + * @generated + */ + void setOid(int value); + + /** + * Returns the value of the 'Actid' attribute. + * + *

      + * If the meaning of the 'Actid' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Actid' attribute. + * @see #setActid(long) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivity_Actid() + * @model required="true" + * @generated + */ + long getActid(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.Activity#getActid Actid}' attribute. + * + * + * @param value the new value of the 'Actid' attribute. + * @see #getActid() + * @generated + */ + void setActid(long value); + + /** + * Returns the value of the 'Name' attribute. + * + *

      + * If the meaning of the 'Name' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Name' attribute. + * @see #setName(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivity_Name() + * @model required="true" + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.Activity#getName Name}' attribute. + * + * + * @param value the new value of the 'Name' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Returns the value of the 'Type' attribute. + * + *

      + * If the meaning of the 'Type' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Type' attribute. + * @see #setType(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivity_Type() + * @model required="true" + * @generated + */ + String getType(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.Activity#getType Type}' attribute. + * + * + * @param value the new value of the 'Type' attribute. + * @see #getType() + * @generated + */ + void setType(String value); + + /** + * Returns the value of the 'Branch ID' attribute. + * + *

      + * If the meaning of the 'Branch ID' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Branch ID' attribute. + * @see #setBranchID(long) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivity_BranchID() + * @model required="true" + * @generated + */ + long getBranchID(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.Activity#getBranchID Branch ID}' attribute. + * + * + * @param value the new value of the 'Branch ID' attribute. + * @see #getBranchID() + * @generated + */ + void setBranchID(long value); + + /** + * Returns the value of the 'Parent Workflow' reference. + * + *

      + * If the meaning of the 'Parent Workflow' container reference isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Parent Workflow' reference. + * @see #setParentWorkflow(Workflow) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivity_ParentWorkflow() + * @model required="true" ordered="false" + * @generated + */ + Workflow getParentWorkflow(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.Activity#getParentWorkflow Parent Workflow}' reference. + * + * + * @param value the new value of the 'Parent Workflow' reference. + * @see #getParentWorkflow() + * @generated + */ + void setParentWorkflow(Workflow value); + + /** + * Returns the value of the 'Instances' containment reference list. + * The list contents are of type {@link at.ac.uibk.wfr.perftool.ActivityInstance}. + * It is bidirectional and its opposite is '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getBaseActivity Base Activity}'. + * + *

      + * If the meaning of the 'Instances' containment reference list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Instances' containment reference list. + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivity_Instances() + * @see at.ac.uibk.wfr.perftool.ActivityInstance#getBaseActivity + * @model opposite="baseActivity" containment="true" ordered="false" + * @generated + */ + EList getInstances(); + + /** + * Returns the value of the 'Status Events' containment reference list. + * The list contents are of type {@link at.ac.uibk.wfr.perftool.ActivityStatusEvent}. + * It is bidirectional and its opposite is '{@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getParentActivity Parent Activity}'. + * + *

      + * If the meaning of the 'Status Events' containment reference list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Status Events' containment reference list. + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivity_StatusEvents() + * @see at.ac.uibk.wfr.perftool.ActivityStatusEvent#getParentActivity + * @model opposite="parentActivity" containment="true" ordered="false" + * @generated + */ + EList getStatusEvents(); + + /** + * Returns the value of the 'Parent' container reference. + * It is bidirectional and its opposite is '{@link at.ac.uibk.wfr.perftool.Activity#getChildren Children}'. + * + *

      + * If the meaning of the 'Parent' container reference isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Parent' container reference. + * @see #setParent(Activity) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivity_Parent() + * @see at.ac.uibk.wfr.perftool.Activity#getChildren + * @model opposite="children" transient="false" + * @generated + */ + Activity getParent(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.Activity#getParent Parent}' container reference. + * + * + * @param value the new value of the 'Parent' container reference. + * @see #getParent() + * @generated + */ + void setParent(Activity value); + + /** + * Returns the value of the 'Children' containment reference list. + * The list contents are of type {@link at.ac.uibk.wfr.perftool.Activity}. + * It is bidirectional and its opposite is '{@link at.ac.uibk.wfr.perftool.Activity#getParent Parent}'. + * + *

      + * If the meaning of the 'Children' containment reference list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Children' containment reference list. + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivity_Children() + * @see at.ac.uibk.wfr.perftool.Activity#getParent + * @model opposite="parent" containment="true" ordered="false" + * @generated + */ + EList getChildren(); + +} // Activity diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/ActivityInstance.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/ActivityInstance.java new file mode 100755 index 0000000..0e0fff6 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/ActivityInstance.java @@ -0,0 +1,207 @@ +/** + */ +package at.ac.uibk.wfr.perftool; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Activity Instance'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.ActivityInstance#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ActivityInstance#getInstid Instid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ActivityInstance#getIterationID Iteration ID}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ActivityInstance#getBaseActivity Base Activity}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ActivityInstance#getParentWorkflow Parent Workflow}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ActivityInstance#getParentInstance Parent Instance}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ActivityInstance#getStatusEvents Status Events}
      • + *
      + *

      + * + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityInstance() + * @model + * @generated + */ +public interface ActivityInstance extends EObject { + /** + * Returns the value of the 'Oid' attribute. + * + *

      + * If the meaning of the 'Oid' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Oid' attribute. + * @see #setOid(int) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityInstance_Oid() + * @model id="true" required="true" + * @generated + */ + int getOid(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getOid Oid}' attribute. + * + * + * @param value the new value of the 'Oid' attribute. + * @see #getOid() + * @generated + */ + void setOid(int value); + + /** + * Returns the value of the 'Instid' attribute. + * + *

      + * If the meaning of the 'Instid' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Instid' attribute. + * @see #setInstid(long) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityInstance_Instid() + * @model required="true" + * @generated + */ + long getInstid(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getInstid Instid}' attribute. + * + * + * @param value the new value of the 'Instid' attribute. + * @see #getInstid() + * @generated + */ + void setInstid(long value); + + /** + * Returns the value of the 'Iteration ID' attribute. + * + *

      + * If the meaning of the 'Iteration ID' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Iteration ID' attribute. + * @see #setIterationID(long) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityInstance_IterationID() + * @model required="true" + * @generated + */ + long getIterationID(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getIterationID Iteration ID}' attribute. + * + * + * @param value the new value of the 'Iteration ID' attribute. + * @see #getIterationID() + * @generated + */ + void setIterationID(long value); + + /** + * Returns the value of the 'Base Activity' container reference. + * It is bidirectional and its opposite is '{@link at.ac.uibk.wfr.perftool.Activity#getInstances Instances}'. + * + *

      + * If the meaning of the 'Base Activity' container reference isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Base Activity' container reference. + * @see #setBaseActivity(Activity) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityInstance_BaseActivity() + * @see at.ac.uibk.wfr.perftool.Activity#getInstances + * @model opposite="instances" required="true" transient="false" + * @generated + */ + Activity getBaseActivity(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getBaseActivity Base Activity}' container reference. + * + * + * @param value the new value of the 'Base Activity' container reference. + * @see #getBaseActivity() + * @generated + */ + void setBaseActivity(Activity value); + + /** + * Returns the value of the 'Parent Workflow' reference. + * + *

      + * If the meaning of the 'Parent Workflow' reference isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Parent Workflow' reference. + * @see #setParentWorkflow(Workflow) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityInstance_ParentWorkflow() + * @model + * @generated + */ + Workflow getParentWorkflow(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getParentWorkflow Parent Workflow}' reference. + * + * + * @param value the new value of the 'Parent Workflow' reference. + * @see #getParentWorkflow() + * @generated + */ + void setParentWorkflow(Workflow value); + + /** + * Returns the value of the 'Parent Instance' reference. + * + *

      + * If the meaning of the 'Parent Instance' reference isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Parent Instance' reference. + * @see #setParentInstance(ActivityInstance) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityInstance_ParentInstance() + * @model + * @generated + */ + ActivityInstance getParentInstance(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getParentInstance Parent Instance}' reference. + * + * + * @param value the new value of the 'Parent Instance' reference. + * @see #getParentInstance() + * @generated + */ + void setParentInstance(ActivityInstance value); + + /** + * Returns the value of the 'Status Events' containment reference list. + * The list contents are of type {@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent}. + * It is bidirectional and its opposite is '{@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getParentInstance Parent Instance}'. + * + *

      + * If the meaning of the 'Status Events' containment reference list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Status Events' containment reference list. + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityInstance_StatusEvents() + * @see at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getParentInstance + * @model opposite="parentInstance" containment="true" ordered="false" + * @generated + */ + EList getStatusEvents(); + +} // ActivityInstance diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/ActivityInstanceStatusEvent.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/ActivityInstanceStatusEvent.java new file mode 100755 index 0000000..0d4df00 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/ActivityInstanceStatusEvent.java @@ -0,0 +1,160 @@ +/** + */ +package at.ac.uibk.wfr.perftool; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Activity Instance Status Event'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getNewStatus New Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getOldStatus Old Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getTimestamp Timestamp}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getParentInstance Parent Instance}
      • + *
      + *

      + * + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityInstanceStatusEvent() + * @model + * @generated + */ +public interface ActivityInstanceStatusEvent extends EObject { + /** + * Returns the value of the 'Oid' attribute. + * + *

      + * If the meaning of the 'Oid' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Oid' attribute. + * @see #setOid(int) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityInstanceStatusEvent_Oid() + * @model id="true" required="true" + * @generated + */ + int getOid(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getOid Oid}' attribute. + * + * + * @param value the new value of the 'Oid' attribute. + * @see #getOid() + * @generated + */ + void setOid(int value); + + /** + * Returns the value of the 'New Status' attribute. + * + *

      + * If the meaning of the 'New Status' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'New Status' attribute. + * @see #setNewStatus(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityInstanceStatusEvent_NewStatus() + * @model required="true" + * @generated + */ + String getNewStatus(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getNewStatus New Status}' attribute. + * + * + * @param value the new value of the 'New Status' attribute. + * @see #getNewStatus() + * @generated + */ + void setNewStatus(String value); + + /** + * Returns the value of the 'Old Status' attribute. + * + *

      + * If the meaning of the 'Old Status' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Old Status' attribute. + * @see #setOldStatus(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityInstanceStatusEvent_OldStatus() + * @model required="true" + * @generated + */ + String getOldStatus(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getOldStatus Old Status}' attribute. + * + * + * @param value the new value of the 'Old Status' attribute. + * @see #getOldStatus() + * @generated + */ + void setOldStatus(String value); + + /** + * Returns the value of the 'Timestamp' attribute. + * + *

      + * If the meaning of the 'Timestamp' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Timestamp' attribute. + * @see #setTimestamp(long) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityInstanceStatusEvent_Timestamp() + * @model required="true" + * @generated + */ + long getTimestamp(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getTimestamp Timestamp}' attribute. + * + * + * @param value the new value of the 'Timestamp' attribute. + * @see #getTimestamp() + * @generated + */ + void setTimestamp(long value); + + /** + * Returns the value of the 'Parent Instance' container reference. + * It is bidirectional and its opposite is '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getStatusEvents Status Events}'. + * + *

      + * If the meaning of the 'Parent Instance' container reference isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Parent Instance' container reference. + * @see #setParentInstance(ActivityInstance) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityInstanceStatusEvent_ParentInstance() + * @see at.ac.uibk.wfr.perftool.ActivityInstance#getStatusEvents + * @model opposite="statusEvents" required="true" transient="false" + * @generated + */ + ActivityInstance getParentInstance(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getParentInstance Parent Instance}' container reference. + * + * + * @param value the new value of the 'Parent Instance' container reference. + * @see #getParentInstance() + * @generated + */ + void setParentInstance(ActivityInstance value); + +} // ActivityInstanceStatusEvent diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/ActivityStatusEvent.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/ActivityStatusEvent.java new file mode 100755 index 0000000..1559aab --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/ActivityStatusEvent.java @@ -0,0 +1,160 @@ +/** + */ +package at.ac.uibk.wfr.perftool; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Activity Status Event'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getNewStatus New Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getOldStatus Old Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getTimestamp Timestamp}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getParentActivity Parent Activity}
      • + *
      + *

      + * + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityStatusEvent() + * @model + * @generated + */ +public interface ActivityStatusEvent extends EObject { + /** + * Returns the value of the 'Oid' attribute. + * + *

      + * If the meaning of the 'Oid' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Oid' attribute. + * @see #setOid(int) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityStatusEvent_Oid() + * @model id="true" required="true" + * @generated + */ + int getOid(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getOid Oid}' attribute. + * + * + * @param value the new value of the 'Oid' attribute. + * @see #getOid() + * @generated + */ + void setOid(int value); + + /** + * Returns the value of the 'New Status' attribute. + * + *

      + * If the meaning of the 'New Status' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'New Status' attribute. + * @see #setNewStatus(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityStatusEvent_NewStatus() + * @model required="true" + * @generated + */ + String getNewStatus(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getNewStatus New Status}' attribute. + * + * + * @param value the new value of the 'New Status' attribute. + * @see #getNewStatus() + * @generated + */ + void setNewStatus(String value); + + /** + * Returns the value of the 'Old Status' attribute. + * + *

      + * If the meaning of the 'Old Status' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Old Status' attribute. + * @see #setOldStatus(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityStatusEvent_OldStatus() + * @model required="true" + * @generated + */ + String getOldStatus(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getOldStatus Old Status}' attribute. + * + * + * @param value the new value of the 'Old Status' attribute. + * @see #getOldStatus() + * @generated + */ + void setOldStatus(String value); + + /** + * Returns the value of the 'Timestamp' attribute. + * + *

      + * If the meaning of the 'Timestamp' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Timestamp' attribute. + * @see #setTimestamp(long) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityStatusEvent_Timestamp() + * @model required="true" + * @generated + */ + long getTimestamp(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getTimestamp Timestamp}' attribute. + * + * + * @param value the new value of the 'Timestamp' attribute. + * @see #getTimestamp() + * @generated + */ + void setTimestamp(long value); + + /** + * Returns the value of the 'Parent Activity' container reference. + * It is bidirectional and its opposite is '{@link at.ac.uibk.wfr.perftool.Activity#getStatusEvents Status Events}'. + * + *

      + * If the meaning of the 'Parent Activity' container reference isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Parent Activity' container reference. + * @see #setParentActivity(Activity) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getActivityStatusEvent_ParentActivity() + * @see at.ac.uibk.wfr.perftool.Activity#getStatusEvents + * @model opposite="statusEvents" required="true" transient="false" + * @generated + */ + Activity getParentActivity(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getParentActivity Parent Activity}' container reference. + * + * + * @param value the new value of the 'Parent Activity' container reference. + * @see #getParentActivity() + * @generated + */ + void setParentActivity(Activity value); + +} // ActivityStatusEvent diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/ComponentStatusEvent.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/ComponentStatusEvent.java new file mode 100755 index 0000000..0bf96d5 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/ComponentStatusEvent.java @@ -0,0 +1,187 @@ +/** + */ +package at.ac.uibk.wfr.perftool; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Component Status Event'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getComponentType Component Type}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getNewStatus New Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getOldStatus Old Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getTimestamp Timestamp}
      • + *
      • {@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getWorkflow Workflow}
      • + *
      + *

      + * + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getComponentStatusEvent() + * @model + * @generated + */ +public interface ComponentStatusEvent extends EObject { + /** + * Returns the value of the 'Oid' attribute. + * + *

      + * If the meaning of the 'Oid' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Oid' attribute. + * @see #setOid(int) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getComponentStatusEvent_Oid() + * @model id="true" required="true" + * @generated + */ + int getOid(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getOid Oid}' attribute. + * + * + * @param value the new value of the 'Oid' attribute. + * @see #getOid() + * @generated + */ + void setOid(int value); + + /** + * Returns the value of the 'Component Type' attribute. + * + *

      + * If the meaning of the 'Component Type' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Component Type' attribute. + * @see #setComponentType(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getComponentStatusEvent_ComponentType() + * @model required="true" + * @generated + */ + String getComponentType(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getComponentType Component Type}' attribute. + * + * + * @param value the new value of the 'Component Type' attribute. + * @see #getComponentType() + * @generated + */ + void setComponentType(String value); + + /** + * Returns the value of the 'New Status' attribute. + * + *

      + * If the meaning of the 'New Status' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'New Status' attribute. + * @see #setNewStatus(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getComponentStatusEvent_NewStatus() + * @model required="true" + * @generated + */ + String getNewStatus(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getNewStatus New Status}' attribute. + * + * + * @param value the new value of the 'New Status' attribute. + * @see #getNewStatus() + * @generated + */ + void setNewStatus(String value); + + /** + * Returns the value of the 'Old Status' attribute. + * + *

      + * If the meaning of the 'Old Status' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Old Status' attribute. + * @see #setOldStatus(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getComponentStatusEvent_OldStatus() + * @model required="true" + * @generated + */ + String getOldStatus(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getOldStatus Old Status}' attribute. + * + * + * @param value the new value of the 'Old Status' attribute. + * @see #getOldStatus() + * @generated + */ + void setOldStatus(String value); + + /** + * Returns the value of the 'Timestamp' attribute. + * + *

      + * If the meaning of the 'Timestamp' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Timestamp' attribute. + * @see #setTimestamp(long) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getComponentStatusEvent_Timestamp() + * @model required="true" + * @generated + */ + long getTimestamp(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getTimestamp Timestamp}' attribute. + * + * + * @param value the new value of the 'Timestamp' attribute. + * @see #getTimestamp() + * @generated + */ + void setTimestamp(long value); + + /** + * Returns the value of the 'Workflow' container reference. + * It is bidirectional and its opposite is '{@link at.ac.uibk.wfr.perftool.Workflow#getComponentEvents Component Events}'. + * + *

      + * If the meaning of the 'Workflow' container reference isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Workflow' container reference. + * @see #setWorkflow(Workflow) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getComponentStatusEvent_Workflow() + * @see at.ac.uibk.wfr.perftool.Workflow#getComponentEvents + * @model opposite="componentEvents" transient="false" + * @generated + */ + Workflow getWorkflow(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getWorkflow Workflow}' container reference. + * + * + * @param value the new value of the 'Workflow' container reference. + * @see #getWorkflow() + * @generated + */ + void setWorkflow(Workflow value); + +} // ComponentStatusEvent diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/DeviceInstanceStatusEvent.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/DeviceInstanceStatusEvent.java new file mode 100755 index 0000000..37ce49a --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/DeviceInstanceStatusEvent.java @@ -0,0 +1,295 @@ +/** + */ +package at.ac.uibk.wfr.perftool; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Device Instance Status Event'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getDeviceType Device Type}
      • + *
      • {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getDeviceID Device ID}
      • + *
      • {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getNewStatus New Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getOldStatus Old Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getTimestamp Timestamp}
      • + *
      • {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getExecutedImplID Executed Impl ID}
      • + *
      • {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getDeviceSlotCount Device Slot Count}
      • + *
      • {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getParentWorkflow Parent Workflow}
      • + *
      • {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getExecutedInstance Executed Instance}
      • + *
      + *

      + * + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getDeviceInstanceStatusEvent() + * @model + * @generated + */ +public interface DeviceInstanceStatusEvent extends EObject { + /** + * Returns the value of the 'Oid' attribute. + * + *

      + * If the meaning of the 'Oid' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Oid' attribute. + * @see #setOid(int) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getDeviceInstanceStatusEvent_Oid() + * @model id="true" required="true" + * @generated + */ + int getOid(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getOid Oid}' attribute. + * + * + * @param value the new value of the 'Oid' attribute. + * @see #getOid() + * @generated + */ + void setOid(int value); + + /** + * Returns the value of the 'Device Type' attribute. + * + *

      + * If the meaning of the 'Device Type' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Device Type' attribute. + * @see #setDeviceType(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getDeviceInstanceStatusEvent_DeviceType() + * @model required="true" + * @generated + */ + String getDeviceType(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getDeviceType Device Type}' attribute. + * + * + * @param value the new value of the 'Device Type' attribute. + * @see #getDeviceType() + * @generated + */ + void setDeviceType(String value); + + /** + * Returns the value of the 'Device ID' attribute. + * + *

      + * If the meaning of the 'Device ID' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Device ID' attribute. + * @see #setDeviceID(long) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getDeviceInstanceStatusEvent_DeviceID() + * @model required="true" + * @generated + */ + long getDeviceID(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getDeviceID Device ID}' attribute. + * + * + * @param value the new value of the 'Device ID' attribute. + * @see #getDeviceID() + * @generated + */ + void setDeviceID(long value); + + /** + * Returns the value of the 'New Status' attribute. + * + *

      + * If the meaning of the 'New Status' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'New Status' attribute. + * @see #setNewStatus(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getDeviceInstanceStatusEvent_NewStatus() + * @model required="true" + * @generated + */ + String getNewStatus(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getNewStatus New Status}' attribute. + * + * + * @param value the new value of the 'New Status' attribute. + * @see #getNewStatus() + * @generated + */ + void setNewStatus(String value); + + /** + * Returns the value of the 'Old Status' attribute. + * + *

      + * If the meaning of the 'Old Status' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Old Status' attribute. + * @see #setOldStatus(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getDeviceInstanceStatusEvent_OldStatus() + * @model required="true" + * @generated + */ + String getOldStatus(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getOldStatus Old Status}' attribute. + * + * + * @param value the new value of the 'Old Status' attribute. + * @see #getOldStatus() + * @generated + */ + void setOldStatus(String value); + + /** + * Returns the value of the 'Timestamp' attribute. + * + *

      + * If the meaning of the 'Timestamp' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Timestamp' attribute. + * @see #setTimestamp(long) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getDeviceInstanceStatusEvent_Timestamp() + * @model required="true" + * @generated + */ + long getTimestamp(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getTimestamp Timestamp}' attribute. + * + * + * @param value the new value of the 'Timestamp' attribute. + * @see #getTimestamp() + * @generated + */ + void setTimestamp(long value); + + /** + * Returns the value of the 'Executed Impl ID' attribute. + * + *

      + * If the meaning of the 'Executed Impl ID' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Executed Impl ID' attribute. + * @see #setExecutedImplID(long) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getDeviceInstanceStatusEvent_ExecutedImplID() + * @model required="true" + * @generated + */ + long getExecutedImplID(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getExecutedImplID Executed Impl ID}' attribute. + * + * + * @param value the new value of the 'Executed Impl ID' attribute. + * @see #getExecutedImplID() + * @generated + */ + void setExecutedImplID(long value); + + /** + * Returns the value of the 'Device Slot Count' attribute. + * + *

      + * If the meaning of the 'Device Slot Count' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Device Slot Count' attribute. + * @see #setDeviceSlotCount(long) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getDeviceInstanceStatusEvent_DeviceSlotCount() + * @model required="true" + * @generated + */ + long getDeviceSlotCount(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getDeviceSlotCount Device Slot Count}' attribute. + * + * + * @param value the new value of the 'Device Slot Count' attribute. + * @see #getDeviceSlotCount() + * @generated + */ + void setDeviceSlotCount(long value); + + /** + * Returns the value of the 'Parent Workflow' container reference. + * It is bidirectional and its opposite is '{@link at.ac.uibk.wfr.perftool.Workflow#getDeviceEvents Device Events}'. + * + *

      + * If the meaning of the 'Parent Workflow' container reference isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Parent Workflow' container reference. + * @see #setParentWorkflow(Workflow) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getDeviceInstanceStatusEvent_ParentWorkflow() + * @see at.ac.uibk.wfr.perftool.Workflow#getDeviceEvents + * @model opposite="deviceEvents" transient="false" + * @generated + */ + Workflow getParentWorkflow(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getParentWorkflow Parent Workflow}' container reference. + * + * + * @param value the new value of the 'Parent Workflow' container reference. + * @see #getParentWorkflow() + * @generated + */ + void setParentWorkflow(Workflow value); + + /** + * Returns the value of the 'Executed Instance' reference. + * + *

      + * If the meaning of the 'Executed Instance' reference isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Executed Instance' reference. + * @see #setExecutedInstance(ActivityInstance) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getDeviceInstanceStatusEvent_ExecutedInstance() + * @model + * @generated + */ + ActivityInstance getExecutedInstance(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getExecutedInstance Executed Instance}' reference. + * + * + * @param value the new value of the 'Executed Instance' reference. + * @see #getExecutedInstance() + * @generated + */ + void setExecutedInstance(ActivityInstance value); + +} // DeviceInstanceStatusEvent diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/PerftoolFactory.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/PerftoolFactory.java new file mode 100755 index 0000000..ceabb68 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/PerftoolFactory.java @@ -0,0 +1,105 @@ +/** + */ +package at.ac.uibk.wfr.perftool; + +import org.eclipse.emf.ecore.EFactory; + +/** + * + * The Factory for the model. + * It provides a create method for each non-abstract class of the model. + * + * @see at.ac.uibk.wfr.perftool.PerftoolPackage + * @generated + */ +public interface PerftoolFactory extends EFactory { + /** + * The singleton instance of the factory. + * + * + * @generated + */ + PerftoolFactory eINSTANCE = at.ac.uibk.wfr.perftool.impl.PerftoolFactoryImpl.init(); + + /** + * Returns a new object of class 'Workflow'. + * + * + * @return a new object of class 'Workflow'. + * @generated + */ + Workflow createWorkflow(); + + /** + * Returns a new object of class 'Activity'. + * + * + * @return a new object of class 'Activity'. + * @generated + */ + Activity createActivity(); + + /** + * Returns a new object of class 'Activity Instance'. + * + * + * @return a new object of class 'Activity Instance'. + * @generated + */ + ActivityInstance createActivityInstance(); + + /** + * Returns a new object of class 'Workflow Status Event'. + * + * + * @return a new object of class 'Workflow Status Event'. + * @generated + */ + WorkflowStatusEvent createWorkflowStatusEvent(); + + /** + * Returns a new object of class 'Activity Status Event'. + * + * + * @return a new object of class 'Activity Status Event'. + * @generated + */ + ActivityStatusEvent createActivityStatusEvent(); + + /** + * Returns a new object of class 'Activity Instance Status Event'. + * + * + * @return a new object of class 'Activity Instance Status Event'. + * @generated + */ + ActivityInstanceStatusEvent createActivityInstanceStatusEvent(); + + /** + * Returns a new object of class 'Device Instance Status Event'. + * + * + * @return a new object of class 'Device Instance Status Event'. + * @generated + */ + DeviceInstanceStatusEvent createDeviceInstanceStatusEvent(); + + /** + * Returns a new object of class 'Component Status Event'. + * + * + * @return a new object of class 'Component Status Event'. + * @generated + */ + ComponentStatusEvent createComponentStatusEvent(); + + /** + * Returns the package supported by this factory. + * + * + * @return the package supported by this factory. + * @generated + */ + PerftoolPackage getPerftoolPackage(); + +} //PerftoolFactory diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/PerftoolPackage.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/PerftoolPackage.java new file mode 100755 index 0000000..744d710 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/PerftoolPackage.java @@ -0,0 +1,2041 @@ +/** + */ +package at.ac.uibk.wfr.perftool; + +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +/** + * + * The Package for the model. + * It contains accessors for the meta objects to represent + *
        + *
      • each class,
      • + *
      • each feature of each class,
      • + *
      • each operation of each class,
      • + *
      • each enum,
      • + *
      • and each data type
      • + *
      + * + * @see at.ac.uibk.wfr.perftool.PerftoolFactory + * @model kind="package" + * @generated + */ +public interface PerftoolPackage extends EPackage { + /** + * The package name. + * + * + * @generated + */ + String eNAME = "perftool"; + + /** + * The package namespace URI. + * + * + * @generated + */ + String eNS_URI = "http://at.ac.uibk.wfr.perftool/1.0"; + + /** + * The package namespace name. + * + * + * @generated + */ + String eNS_PREFIX = "perftool"; + + /** + * The singleton instance of the package. + * + * + * @generated + */ + PerftoolPackage eINSTANCE = at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl.init(); + + /** + * The meta object id for the '{@link at.ac.uibk.wfr.perftool.impl.WorkflowImpl Workflow}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.WorkflowImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getWorkflow() + * @generated + */ + int WORKFLOW = 0; + + /** + * The feature id for the 'Oid' attribute. + * + * + * @generated + * @ordered + */ + int WORKFLOW__OID = 0; + + /** + * The feature id for the 'Wfid' attribute. + * + * + * @generated + * @ordered + */ + int WORKFLOW__WFID = 1; + + /** + * The feature id for the 'Uuid' attribute. + * + * + * @generated + * @ordered + */ + int WORKFLOW__UUID = 2; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int WORKFLOW__NAME = 3; + + /** + * The feature id for the 'Toplevel Activity' containment reference. + * + * + * @generated + * @ordered + */ + int WORKFLOW__TOPLEVEL_ACTIVITY = 4; + + /** + * The feature id for the 'Status Events' containment reference list. + * + * + * @generated + * @ordered + */ + int WORKFLOW__STATUS_EVENTS = 5; + + /** + * The feature id for the 'Device Events' containment reference list. + * + * + * @generated + * @ordered + */ + int WORKFLOW__DEVICE_EVENTS = 6; + + /** + * The feature id for the 'Component Events' containment reference list. + * + * + * @generated + * @ordered + */ + int WORKFLOW__COMPONENT_EVENTS = 7; + + /** + * The number of structural features of the 'Workflow' class. + * + * + * @generated + * @ordered + */ + int WORKFLOW_FEATURE_COUNT = 8; + + /** + * The number of operations of the 'Workflow' class. + * + * + * @generated + * @ordered + */ + int WORKFLOW_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link at.ac.uibk.wfr.perftool.impl.ActivityImpl Activity}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.ActivityImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getActivity() + * @generated + */ + int ACTIVITY = 1; + + /** + * The feature id for the 'Oid' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY__OID = 0; + + /** + * The feature id for the 'Actid' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY__ACTID = 1; + + /** + * The feature id for the 'Name' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY__NAME = 2; + + /** + * The feature id for the 'Type' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY__TYPE = 3; + + /** + * The feature id for the 'Branch ID' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY__BRANCH_ID = 4; + + /** + * The feature id for the 'Parent Workflow' reference. + * + * + * @generated + * @ordered + */ + int ACTIVITY__PARENT_WORKFLOW = 5; + + /** + * The feature id for the 'Instances' containment reference list. + * + * + * @generated + * @ordered + */ + int ACTIVITY__INSTANCES = 6; + + /** + * The feature id for the 'Status Events' containment reference list. + * + * + * @generated + * @ordered + */ + int ACTIVITY__STATUS_EVENTS = 7; + + /** + * The feature id for the 'Parent' container reference. + * + * + * @generated + * @ordered + */ + int ACTIVITY__PARENT = 8; + + /** + * The feature id for the 'Children' containment reference list. + * + * + * @generated + * @ordered + */ + int ACTIVITY__CHILDREN = 9; + + /** + * The number of structural features of the 'Activity' class. + * + * + * @generated + * @ordered + */ + int ACTIVITY_FEATURE_COUNT = 10; + + /** + * The number of operations of the 'Activity' class. + * + * + * @generated + * @ordered + */ + int ACTIVITY_OPERATION_COUNT = 0; + + + /** + * The meta object id for the '{@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceImpl Activity Instance}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.ActivityInstanceImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getActivityInstance() + * @generated + */ + int ACTIVITY_INSTANCE = 2; + + /** + * The feature id for the 'Oid' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE__OID = 0; + + /** + * The feature id for the 'Instid' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE__INSTID = 1; + + /** + * The feature id for the 'Iteration ID' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE__ITERATION_ID = 2; + + /** + * The feature id for the 'Base Activity' container reference. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE__BASE_ACTIVITY = 3; + + /** + * The feature id for the 'Parent Workflow' reference. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE__PARENT_WORKFLOW = 4; + + /** + * The feature id for the 'Parent Instance' reference. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE__PARENT_INSTANCE = 5; + + /** + * The feature id for the 'Status Events' containment reference list. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE__STATUS_EVENTS = 6; + + /** + * The number of structural features of the 'Activity Instance' class. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE_FEATURE_COUNT = 7; + + /** + * The number of operations of the 'Activity Instance' class. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE_OPERATION_COUNT = 0; + + + /** + * The meta object id for the '{@link at.ac.uibk.wfr.perftool.impl.WorkflowStatusEventImpl Workflow Status Event}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.WorkflowStatusEventImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getWorkflowStatusEvent() + * @generated + */ + int WORKFLOW_STATUS_EVENT = 3; + + /** + * The feature id for the 'Oid' attribute. + * + * + * @generated + * @ordered + */ + int WORKFLOW_STATUS_EVENT__OID = 0; + + /** + * The feature id for the 'New Status' attribute. + * + * + * @generated + * @ordered + */ + int WORKFLOW_STATUS_EVENT__NEW_STATUS = 1; + + /** + * The feature id for the 'Old Status' attribute. + * + * + * @generated + * @ordered + */ + int WORKFLOW_STATUS_EVENT__OLD_STATUS = 2; + + /** + * The feature id for the 'Timestamp' attribute. + * + * + * @generated + * @ordered + */ + int WORKFLOW_STATUS_EVENT__TIMESTAMP = 3; + + /** + * The feature id for the 'Parent Workflow' container reference. + * + * + * @generated + * @ordered + */ + int WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW = 4; + + /** + * The number of structural features of the 'Workflow Status Event' class. + * + * + * @generated + * @ordered + */ + int WORKFLOW_STATUS_EVENT_FEATURE_COUNT = 5; + + /** + * The number of operations of the 'Workflow Status Event' class. + * + * + * @generated + * @ordered + */ + int WORKFLOW_STATUS_EVENT_OPERATION_COUNT = 0; + + + /** + * The meta object id for the '{@link at.ac.uibk.wfr.perftool.impl.ActivityStatusEventImpl Activity Status Event}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.ActivityStatusEventImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getActivityStatusEvent() + * @generated + */ + int ACTIVITY_STATUS_EVENT = 4; + + /** + * The feature id for the 'Oid' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY_STATUS_EVENT__OID = 0; + + /** + * The feature id for the 'New Status' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY_STATUS_EVENT__NEW_STATUS = 1; + + /** + * The feature id for the 'Old Status' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY_STATUS_EVENT__OLD_STATUS = 2; + + /** + * The feature id for the 'Timestamp' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY_STATUS_EVENT__TIMESTAMP = 3; + + /** + * The feature id for the 'Parent Activity' container reference. + * + * + * @generated + * @ordered + */ + int ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY = 4; + + /** + * The number of structural features of the 'Activity Status Event' class. + * + * + * @generated + * @ordered + */ + int ACTIVITY_STATUS_EVENT_FEATURE_COUNT = 5; + + /** + * The number of operations of the 'Activity Status Event' class. + * + * + * @generated + * @ordered + */ + int ACTIVITY_STATUS_EVENT_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceStatusEventImpl Activity Instance Status Event}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.ActivityInstanceStatusEventImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getActivityInstanceStatusEvent() + * @generated + */ + int ACTIVITY_INSTANCE_STATUS_EVENT = 5; + + /** + * The feature id for the 'Oid' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE_STATUS_EVENT__OID = 0; + + /** + * The feature id for the 'New Status' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE_STATUS_EVENT__NEW_STATUS = 1; + + /** + * The feature id for the 'Old Status' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE_STATUS_EVENT__OLD_STATUS = 2; + + /** + * The feature id for the 'Timestamp' attribute. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE_STATUS_EVENT__TIMESTAMP = 3; + + /** + * The feature id for the 'Parent Instance' container reference. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE = 4; + + /** + * The number of structural features of the 'Activity Instance Status Event' class. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE_STATUS_EVENT_FEATURE_COUNT = 5; + + /** + * The number of operations of the 'Activity Instance Status Event' class. + * + * + * @generated + * @ordered + */ + int ACTIVITY_INSTANCE_STATUS_EVENT_OPERATION_COUNT = 0; + + /** + * The meta object id for the '{@link at.ac.uibk.wfr.perftool.impl.DeviceInstanceStatusEventImpl Device Instance Status Event}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.DeviceInstanceStatusEventImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getDeviceInstanceStatusEvent() + * @generated + */ + int DEVICE_INSTANCE_STATUS_EVENT = 6; + + /** + * The feature id for the 'Oid' attribute. + * + * + * @generated + * @ordered + */ + int DEVICE_INSTANCE_STATUS_EVENT__OID = 0; + + /** + * The feature id for the 'Device Type' attribute. + * + * + * @generated + * @ordered + */ + int DEVICE_INSTANCE_STATUS_EVENT__DEVICE_TYPE = 1; + + /** + * The feature id for the 'Device ID' attribute. + * + * + * @generated + * @ordered + */ + int DEVICE_INSTANCE_STATUS_EVENT__DEVICE_ID = 2; + + /** + * The feature id for the 'New Status' attribute. + * + * + * @generated + * @ordered + */ + int DEVICE_INSTANCE_STATUS_EVENT__NEW_STATUS = 3; + + /** + * The feature id for the 'Old Status' attribute. + * + * + * @generated + * @ordered + */ + int DEVICE_INSTANCE_STATUS_EVENT__OLD_STATUS = 4; + + /** + * The feature id for the 'Timestamp' attribute. + * + * + * @generated + * @ordered + */ + int DEVICE_INSTANCE_STATUS_EVENT__TIMESTAMP = 5; + + /** + * The feature id for the 'Executed Impl ID' attribute. + * + * + * @generated + * @ordered + */ + int DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_IMPL_ID = 6; + + /** + * The feature id for the 'Device Slot Count' attribute. + * + * + * @generated + * @ordered + */ + int DEVICE_INSTANCE_STATUS_EVENT__DEVICE_SLOT_COUNT = 7; + + /** + * The feature id for the 'Parent Workflow' container reference. + * + * + * @generated + * @ordered + */ + int DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW = 8; + + /** + * The feature id for the 'Executed Instance' reference. + * + * + * @generated + * @ordered + */ + int DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_INSTANCE = 9; + + /** + * The number of structural features of the 'Device Instance Status Event' class. + * + * + * @generated + * @ordered + */ + int DEVICE_INSTANCE_STATUS_EVENT_FEATURE_COUNT = 10; + + /** + * The number of operations of the 'Device Instance Status Event' class. + * + * + * @generated + * @ordered + */ + int DEVICE_INSTANCE_STATUS_EVENT_OPERATION_COUNT = 0; + + + /** + * The meta object id for the '{@link at.ac.uibk.wfr.perftool.impl.ComponentStatusEventImpl Component Status Event}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.ComponentStatusEventImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getComponentStatusEvent() + * @generated + */ + int COMPONENT_STATUS_EVENT = 7; + + /** + * The feature id for the 'Oid' attribute. + * + * + * @generated + * @ordered + */ + int COMPONENT_STATUS_EVENT__OID = 0; + + /** + * The feature id for the 'Component Type' attribute. + * + * + * @generated + * @ordered + */ + int COMPONENT_STATUS_EVENT__COMPONENT_TYPE = 1; + + /** + * The feature id for the 'New Status' attribute. + * + * + * @generated + * @ordered + */ + int COMPONENT_STATUS_EVENT__NEW_STATUS = 2; + + /** + * The feature id for the 'Old Status' attribute. + * + * + * @generated + * @ordered + */ + int COMPONENT_STATUS_EVENT__OLD_STATUS = 3; + + /** + * The feature id for the 'Timestamp' attribute. + * + * + * @generated + * @ordered + */ + int COMPONENT_STATUS_EVENT__TIMESTAMP = 4; + + /** + * The feature id for the 'Workflow' container reference. + * + * + * @generated + * @ordered + */ + int COMPONENT_STATUS_EVENT__WORKFLOW = 5; + + /** + * The number of structural features of the 'Component Status Event' class. + * + * + * @generated + * @ordered + */ + int COMPONENT_STATUS_EVENT_FEATURE_COUNT = 6; + + /** + * The number of operations of the 'Component Status Event' class. + * + * + * @generated + * @ordered + */ + int COMPONENT_STATUS_EVENT_OPERATION_COUNT = 0; + + + /** + * Returns the meta object for class '{@link at.ac.uibk.wfr.perftool.Workflow Workflow}'. + * + * + * @return the meta object for class 'Workflow'. + * @see at.ac.uibk.wfr.perftool.Workflow + * @generated + */ + EClass getWorkflow(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.Workflow#getOid Oid}'. + * + * + * @return the meta object for the attribute 'Oid'. + * @see at.ac.uibk.wfr.perftool.Workflow#getOid() + * @see #getWorkflow() + * @generated + */ + EAttribute getWorkflow_Oid(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.Workflow#getWfid Wfid}'. + * + * + * @return the meta object for the attribute 'Wfid'. + * @see at.ac.uibk.wfr.perftool.Workflow#getWfid() + * @see #getWorkflow() + * @generated + */ + EAttribute getWorkflow_Wfid(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.Workflow#getUuid Uuid}'. + * + * + * @return the meta object for the attribute 'Uuid'. + * @see at.ac.uibk.wfr.perftool.Workflow#getUuid() + * @see #getWorkflow() + * @generated + */ + EAttribute getWorkflow_Uuid(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.Workflow#getName Name}'. + * + * + * @return the meta object for the attribute 'Name'. + * @see at.ac.uibk.wfr.perftool.Workflow#getName() + * @see #getWorkflow() + * @generated + */ + EAttribute getWorkflow_Name(); + + /** + * Returns the meta object for the containment reference '{@link at.ac.uibk.wfr.perftool.Workflow#getToplevelActivity Toplevel Activity}'. + * + * + * @return the meta object for the containment reference 'Toplevel Activity'. + * @see at.ac.uibk.wfr.perftool.Workflow#getToplevelActivity() + * @see #getWorkflow() + * @generated + */ + EReference getWorkflow_ToplevelActivity(); + + /** + * Returns the meta object for the containment reference list '{@link at.ac.uibk.wfr.perftool.Workflow#getStatusEvents Status Events}'. + * + * + * @return the meta object for the containment reference list 'Status Events'. + * @see at.ac.uibk.wfr.perftool.Workflow#getStatusEvents() + * @see #getWorkflow() + * @generated + */ + EReference getWorkflow_StatusEvents(); + + /** + * Returns the meta object for the containment reference list '{@link at.ac.uibk.wfr.perftool.Workflow#getDeviceEvents Device Events}'. + * + * + * @return the meta object for the containment reference list 'Device Events'. + * @see at.ac.uibk.wfr.perftool.Workflow#getDeviceEvents() + * @see #getWorkflow() + * @generated + */ + EReference getWorkflow_DeviceEvents(); + + /** + * Returns the meta object for the containment reference list '{@link at.ac.uibk.wfr.perftool.Workflow#getComponentEvents Component Events}'. + * + * + * @return the meta object for the containment reference list 'Component Events'. + * @see at.ac.uibk.wfr.perftool.Workflow#getComponentEvents() + * @see #getWorkflow() + * @generated + */ + EReference getWorkflow_ComponentEvents(); + + /** + * Returns the meta object for class '{@link at.ac.uibk.wfr.perftool.Activity Activity}'. + * + * + * @return the meta object for class 'Activity'. + * @see at.ac.uibk.wfr.perftool.Activity + * @generated + */ + EClass getActivity(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.Activity#getOid Oid}'. + * + * + * @return the meta object for the attribute 'Oid'. + * @see at.ac.uibk.wfr.perftool.Activity#getOid() + * @see #getActivity() + * @generated + */ + EAttribute getActivity_Oid(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.Activity#getActid Actid}'. + * + * + * @return the meta object for the attribute 'Actid'. + * @see at.ac.uibk.wfr.perftool.Activity#getActid() + * @see #getActivity() + * @generated + */ + EAttribute getActivity_Actid(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.Activity#getName Name}'. + * + * + * @return the meta object for the attribute 'Name'. + * @see at.ac.uibk.wfr.perftool.Activity#getName() + * @see #getActivity() + * @generated + */ + EAttribute getActivity_Name(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.Activity#getType Type}'. + * + * + * @return the meta object for the attribute 'Type'. + * @see at.ac.uibk.wfr.perftool.Activity#getType() + * @see #getActivity() + * @generated + */ + EAttribute getActivity_Type(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.Activity#getBranchID Branch ID}'. + * + * + * @return the meta object for the attribute 'Branch ID'. + * @see at.ac.uibk.wfr.perftool.Activity#getBranchID() + * @see #getActivity() + * @generated + */ + EAttribute getActivity_BranchID(); + + /** + * Returns the meta object for the reference '{@link at.ac.uibk.wfr.perftool.Activity#getParentWorkflow Parent Workflow}'. + * + * + * @return the meta object for the reference 'Parent Workflow'. + * @see at.ac.uibk.wfr.perftool.Activity#getParentWorkflow() + * @see #getActivity() + * @generated + */ + EReference getActivity_ParentWorkflow(); + + /** + * Returns the meta object for the containment reference list '{@link at.ac.uibk.wfr.perftool.Activity#getInstances Instances}'. + * + * + * @return the meta object for the containment reference list 'Instances'. + * @see at.ac.uibk.wfr.perftool.Activity#getInstances() + * @see #getActivity() + * @generated + */ + EReference getActivity_Instances(); + + /** + * Returns the meta object for the containment reference list '{@link at.ac.uibk.wfr.perftool.Activity#getStatusEvents Status Events}'. + * + * + * @return the meta object for the containment reference list 'Status Events'. + * @see at.ac.uibk.wfr.perftool.Activity#getStatusEvents() + * @see #getActivity() + * @generated + */ + EReference getActivity_StatusEvents(); + + /** + * Returns the meta object for the container reference '{@link at.ac.uibk.wfr.perftool.Activity#getParent Parent}'. + * + * + * @return the meta object for the container reference 'Parent'. + * @see at.ac.uibk.wfr.perftool.Activity#getParent() + * @see #getActivity() + * @generated + */ + EReference getActivity_Parent(); + + /** + * Returns the meta object for the containment reference list '{@link at.ac.uibk.wfr.perftool.Activity#getChildren Children}'. + * + * + * @return the meta object for the containment reference list 'Children'. + * @see at.ac.uibk.wfr.perftool.Activity#getChildren() + * @see #getActivity() + * @generated + */ + EReference getActivity_Children(); + + /** + * Returns the meta object for class '{@link at.ac.uibk.wfr.perftool.ActivityInstance Activity Instance}'. + * + * + * @return the meta object for class 'Activity Instance'. + * @see at.ac.uibk.wfr.perftool.ActivityInstance + * @generated + */ + EClass getActivityInstance(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getOid Oid}'. + * + * + * @return the meta object for the attribute 'Oid'. + * @see at.ac.uibk.wfr.perftool.ActivityInstance#getOid() + * @see #getActivityInstance() + * @generated + */ + EAttribute getActivityInstance_Oid(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getInstid Instid}'. + * + * + * @return the meta object for the attribute 'Instid'. + * @see at.ac.uibk.wfr.perftool.ActivityInstance#getInstid() + * @see #getActivityInstance() + * @generated + */ + EAttribute getActivityInstance_Instid(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getIterationID Iteration ID}'. + * + * + * @return the meta object for the attribute 'Iteration ID'. + * @see at.ac.uibk.wfr.perftool.ActivityInstance#getIterationID() + * @see #getActivityInstance() + * @generated + */ + EAttribute getActivityInstance_IterationID(); + + /** + * Returns the meta object for the container reference '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getBaseActivity Base Activity}'. + * + * + * @return the meta object for the container reference 'Base Activity'. + * @see at.ac.uibk.wfr.perftool.ActivityInstance#getBaseActivity() + * @see #getActivityInstance() + * @generated + */ + EReference getActivityInstance_BaseActivity(); + + /** + * Returns the meta object for the reference '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getParentWorkflow Parent Workflow}'. + * + * + * @return the meta object for the reference 'Parent Workflow'. + * @see at.ac.uibk.wfr.perftool.ActivityInstance#getParentWorkflow() + * @see #getActivityInstance() + * @generated + */ + EReference getActivityInstance_ParentWorkflow(); + + /** + * Returns the meta object for the reference '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getParentInstance Parent Instance}'. + * + * + * @return the meta object for the reference 'Parent Instance'. + * @see at.ac.uibk.wfr.perftool.ActivityInstance#getParentInstance() + * @see #getActivityInstance() + * @generated + */ + EReference getActivityInstance_ParentInstance(); + + /** + * Returns the meta object for the containment reference list '{@link at.ac.uibk.wfr.perftool.ActivityInstance#getStatusEvents Status Events}'. + * + * + * @return the meta object for the containment reference list 'Status Events'. + * @see at.ac.uibk.wfr.perftool.ActivityInstance#getStatusEvents() + * @see #getActivityInstance() + * @generated + */ + EReference getActivityInstance_StatusEvents(); + + /** + * Returns the meta object for class '{@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent Workflow Status Event}'. + * + * + * @return the meta object for class 'Workflow Status Event'. + * @see at.ac.uibk.wfr.perftool.WorkflowStatusEvent + * @generated + */ + EClass getWorkflowStatusEvent(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getOid Oid}'. + * + * + * @return the meta object for the attribute 'Oid'. + * @see at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getOid() + * @see #getWorkflowStatusEvent() + * @generated + */ + EAttribute getWorkflowStatusEvent_Oid(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getNewStatus New Status}'. + * + * + * @return the meta object for the attribute 'New Status'. + * @see at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getNewStatus() + * @see #getWorkflowStatusEvent() + * @generated + */ + EAttribute getWorkflowStatusEvent_NewStatus(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getOldStatus Old Status}'. + * + * + * @return the meta object for the attribute 'Old Status'. + * @see at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getOldStatus() + * @see #getWorkflowStatusEvent() + * @generated + */ + EAttribute getWorkflowStatusEvent_OldStatus(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getTimestamp Timestamp}'. + * + * + * @return the meta object for the attribute 'Timestamp'. + * @see at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getTimestamp() + * @see #getWorkflowStatusEvent() + * @generated + */ + EAttribute getWorkflowStatusEvent_Timestamp(); + + /** + * Returns the meta object for the container reference '{@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getParentWorkflow Parent Workflow}'. + * + * + * @return the meta object for the container reference 'Parent Workflow'. + * @see at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getParentWorkflow() + * @see #getWorkflowStatusEvent() + * @generated + */ + EReference getWorkflowStatusEvent_ParentWorkflow(); + + /** + * Returns the meta object for class '{@link at.ac.uibk.wfr.perftool.ActivityStatusEvent Activity Status Event}'. + * + * + * @return the meta object for class 'Activity Status Event'. + * @see at.ac.uibk.wfr.perftool.ActivityStatusEvent + * @generated + */ + EClass getActivityStatusEvent(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getOid Oid}'. + * + * + * @return the meta object for the attribute 'Oid'. + * @see at.ac.uibk.wfr.perftool.ActivityStatusEvent#getOid() + * @see #getActivityStatusEvent() + * @generated + */ + EAttribute getActivityStatusEvent_Oid(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getNewStatus New Status}'. + * + * + * @return the meta object for the attribute 'New Status'. + * @see at.ac.uibk.wfr.perftool.ActivityStatusEvent#getNewStatus() + * @see #getActivityStatusEvent() + * @generated + */ + EAttribute getActivityStatusEvent_NewStatus(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getOldStatus Old Status}'. + * + * + * @return the meta object for the attribute 'Old Status'. + * @see at.ac.uibk.wfr.perftool.ActivityStatusEvent#getOldStatus() + * @see #getActivityStatusEvent() + * @generated + */ + EAttribute getActivityStatusEvent_OldStatus(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getTimestamp Timestamp}'. + * + * + * @return the meta object for the attribute 'Timestamp'. + * @see at.ac.uibk.wfr.perftool.ActivityStatusEvent#getTimestamp() + * @see #getActivityStatusEvent() + * @generated + */ + EAttribute getActivityStatusEvent_Timestamp(); + + /** + * Returns the meta object for the container reference '{@link at.ac.uibk.wfr.perftool.ActivityStatusEvent#getParentActivity Parent Activity}'. + * + * + * @return the meta object for the container reference 'Parent Activity'. + * @see at.ac.uibk.wfr.perftool.ActivityStatusEvent#getParentActivity() + * @see #getActivityStatusEvent() + * @generated + */ + EReference getActivityStatusEvent_ParentActivity(); + + /** + * Returns the meta object for class '{@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent Activity Instance Status Event}'. + * + * + * @return the meta object for class 'Activity Instance Status Event'. + * @see at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent + * @generated + */ + EClass getActivityInstanceStatusEvent(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getOid Oid}'. + * + * + * @return the meta object for the attribute 'Oid'. + * @see at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getOid() + * @see #getActivityInstanceStatusEvent() + * @generated + */ + EAttribute getActivityInstanceStatusEvent_Oid(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getNewStatus New Status}'. + * + * + * @return the meta object for the attribute 'New Status'. + * @see at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getNewStatus() + * @see #getActivityInstanceStatusEvent() + * @generated + */ + EAttribute getActivityInstanceStatusEvent_NewStatus(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getOldStatus Old Status}'. + * + * + * @return the meta object for the attribute 'Old Status'. + * @see at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getOldStatus() + * @see #getActivityInstanceStatusEvent() + * @generated + */ + EAttribute getActivityInstanceStatusEvent_OldStatus(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getTimestamp Timestamp}'. + * + * + * @return the meta object for the attribute 'Timestamp'. + * @see at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getTimestamp() + * @see #getActivityInstanceStatusEvent() + * @generated + */ + EAttribute getActivityInstanceStatusEvent_Timestamp(); + + /** + * Returns the meta object for the container reference '{@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getParentInstance Parent Instance}'. + * + * + * @return the meta object for the container reference 'Parent Instance'. + * @see at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent#getParentInstance() + * @see #getActivityInstanceStatusEvent() + * @generated + */ + EReference getActivityInstanceStatusEvent_ParentInstance(); + + /** + * Returns the meta object for class '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent Device Instance Status Event}'. + * + * + * @return the meta object for class 'Device Instance Status Event'. + * @see at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent + * @generated + */ + EClass getDeviceInstanceStatusEvent(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getOid Oid}'. + * + * + * @return the meta object for the attribute 'Oid'. + * @see at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getOid() + * @see #getDeviceInstanceStatusEvent() + * @generated + */ + EAttribute getDeviceInstanceStatusEvent_Oid(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getDeviceType Device Type}'. + * + * + * @return the meta object for the attribute 'Device Type'. + * @see at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getDeviceType() + * @see #getDeviceInstanceStatusEvent() + * @generated + */ + EAttribute getDeviceInstanceStatusEvent_DeviceType(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getDeviceID Device ID}'. + * + * + * @return the meta object for the attribute 'Device ID'. + * @see at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getDeviceID() + * @see #getDeviceInstanceStatusEvent() + * @generated + */ + EAttribute getDeviceInstanceStatusEvent_DeviceID(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getNewStatus New Status}'. + * + * + * @return the meta object for the attribute 'New Status'. + * @see at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getNewStatus() + * @see #getDeviceInstanceStatusEvent() + * @generated + */ + EAttribute getDeviceInstanceStatusEvent_NewStatus(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getOldStatus Old Status}'. + * + * + * @return the meta object for the attribute 'Old Status'. + * @see at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getOldStatus() + * @see #getDeviceInstanceStatusEvent() + * @generated + */ + EAttribute getDeviceInstanceStatusEvent_OldStatus(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getTimestamp Timestamp}'. + * + * + * @return the meta object for the attribute 'Timestamp'. + * @see at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getTimestamp() + * @see #getDeviceInstanceStatusEvent() + * @generated + */ + EAttribute getDeviceInstanceStatusEvent_Timestamp(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getExecutedImplID Executed Impl ID}'. + * + * + * @return the meta object for the attribute 'Executed Impl ID'. + * @see at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getExecutedImplID() + * @see #getDeviceInstanceStatusEvent() + * @generated + */ + EAttribute getDeviceInstanceStatusEvent_ExecutedImplID(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getDeviceSlotCount Device Slot Count}'. + * + * + * @return the meta object for the attribute 'Device Slot Count'. + * @see at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getDeviceSlotCount() + * @see #getDeviceInstanceStatusEvent() + * @generated + */ + EAttribute getDeviceInstanceStatusEvent_DeviceSlotCount(); + + /** + * Returns the meta object for the container reference '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getParentWorkflow Parent Workflow}'. + * + * + * @return the meta object for the container reference 'Parent Workflow'. + * @see at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getParentWorkflow() + * @see #getDeviceInstanceStatusEvent() + * @generated + */ + EReference getDeviceInstanceStatusEvent_ParentWorkflow(); + + /** + * Returns the meta object for the reference '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getExecutedInstance Executed Instance}'. + * + * + * @return the meta object for the reference 'Executed Instance'. + * @see at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getExecutedInstance() + * @see #getDeviceInstanceStatusEvent() + * @generated + */ + EReference getDeviceInstanceStatusEvent_ExecutedInstance(); + + /** + * Returns the meta object for class '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent Component Status Event}'. + * + * + * @return the meta object for class 'Component Status Event'. + * @see at.ac.uibk.wfr.perftool.ComponentStatusEvent + * @generated + */ + EClass getComponentStatusEvent(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getOid Oid}'. + * + * + * @return the meta object for the attribute 'Oid'. + * @see at.ac.uibk.wfr.perftool.ComponentStatusEvent#getOid() + * @see #getComponentStatusEvent() + * @generated + */ + EAttribute getComponentStatusEvent_Oid(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getComponentType Component Type}'. + * + * + * @return the meta object for the attribute 'Component Type'. + * @see at.ac.uibk.wfr.perftool.ComponentStatusEvent#getComponentType() + * @see #getComponentStatusEvent() + * @generated + */ + EAttribute getComponentStatusEvent_ComponentType(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getNewStatus New Status}'. + * + * + * @return the meta object for the attribute 'New Status'. + * @see at.ac.uibk.wfr.perftool.ComponentStatusEvent#getNewStatus() + * @see #getComponentStatusEvent() + * @generated + */ + EAttribute getComponentStatusEvent_NewStatus(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getOldStatus Old Status}'. + * + * + * @return the meta object for the attribute 'Old Status'. + * @see at.ac.uibk.wfr.perftool.ComponentStatusEvent#getOldStatus() + * @see #getComponentStatusEvent() + * @generated + */ + EAttribute getComponentStatusEvent_OldStatus(); + + /** + * Returns the meta object for the attribute '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getTimestamp Timestamp}'. + * + * + * @return the meta object for the attribute 'Timestamp'. + * @see at.ac.uibk.wfr.perftool.ComponentStatusEvent#getTimestamp() + * @see #getComponentStatusEvent() + * @generated + */ + EAttribute getComponentStatusEvent_Timestamp(); + + /** + * Returns the meta object for the container reference '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getWorkflow Workflow}'. + * + * + * @return the meta object for the container reference 'Workflow'. + * @see at.ac.uibk.wfr.perftool.ComponentStatusEvent#getWorkflow() + * @see #getComponentStatusEvent() + * @generated + */ + EReference getComponentStatusEvent_Workflow(); + + /** + * Returns the factory that creates the instances of the model. + * + * + * @return the factory that creates the instances of the model. + * @generated + */ + PerftoolFactory getPerftoolFactory(); + + /** + * + * Defines literals for the meta objects that represent + *
        + *
      • each class,
      • + *
      • each feature of each class,
      • + *
      • each operation of each class,
      • + *
      • each enum,
      • + *
      • and each data type
      • + *
      + * + * @generated + */ + interface Literals { + /** + * The meta object literal for the '{@link at.ac.uibk.wfr.perftool.impl.WorkflowImpl Workflow}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.WorkflowImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getWorkflow() + * @generated + */ + EClass WORKFLOW = eINSTANCE.getWorkflow(); + + /** + * The meta object literal for the 'Oid' attribute feature. + * + * + * @generated + */ + EAttribute WORKFLOW__OID = eINSTANCE.getWorkflow_Oid(); + + /** + * The meta object literal for the 'Wfid' attribute feature. + * + * + * @generated + */ + EAttribute WORKFLOW__WFID = eINSTANCE.getWorkflow_Wfid(); + + /** + * The meta object literal for the 'Uuid' attribute feature. + * + * + * @generated + */ + EAttribute WORKFLOW__UUID = eINSTANCE.getWorkflow_Uuid(); + + /** + * The meta object literal for the 'Name' attribute feature. + * + * + * @generated + */ + EAttribute WORKFLOW__NAME = eINSTANCE.getWorkflow_Name(); + + /** + * The meta object literal for the 'Toplevel Activity' containment reference feature. + * + * + * @generated + */ + EReference WORKFLOW__TOPLEVEL_ACTIVITY = eINSTANCE.getWorkflow_ToplevelActivity(); + + /** + * The meta object literal for the 'Status Events' containment reference list feature. + * + * + * @generated + */ + EReference WORKFLOW__STATUS_EVENTS = eINSTANCE.getWorkflow_StatusEvents(); + + /** + * The meta object literal for the 'Device Events' containment reference list feature. + * + * + * @generated + */ + EReference WORKFLOW__DEVICE_EVENTS = eINSTANCE.getWorkflow_DeviceEvents(); + + /** + * The meta object literal for the 'Component Events' containment reference list feature. + * + * + * @generated + */ + EReference WORKFLOW__COMPONENT_EVENTS = eINSTANCE.getWorkflow_ComponentEvents(); + + /** + * The meta object literal for the '{@link at.ac.uibk.wfr.perftool.impl.ActivityImpl Activity}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.ActivityImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getActivity() + * @generated + */ + EClass ACTIVITY = eINSTANCE.getActivity(); + + /** + * The meta object literal for the 'Oid' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY__OID = eINSTANCE.getActivity_Oid(); + + /** + * The meta object literal for the 'Actid' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY__ACTID = eINSTANCE.getActivity_Actid(); + + /** + * The meta object literal for the 'Name' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY__NAME = eINSTANCE.getActivity_Name(); + + /** + * The meta object literal for the 'Type' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY__TYPE = eINSTANCE.getActivity_Type(); + + /** + * The meta object literal for the 'Branch ID' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY__BRANCH_ID = eINSTANCE.getActivity_BranchID(); + + /** + * The meta object literal for the 'Parent Workflow' reference feature. + * + * + * @generated + */ + EReference ACTIVITY__PARENT_WORKFLOW = eINSTANCE.getActivity_ParentWorkflow(); + + /** + * The meta object literal for the 'Instances' containment reference list feature. + * + * + * @generated + */ + EReference ACTIVITY__INSTANCES = eINSTANCE.getActivity_Instances(); + + /** + * The meta object literal for the 'Status Events' containment reference list feature. + * + * + * @generated + */ + EReference ACTIVITY__STATUS_EVENTS = eINSTANCE.getActivity_StatusEvents(); + + /** + * The meta object literal for the 'Parent' container reference feature. + * + * + * @generated + */ + EReference ACTIVITY__PARENT = eINSTANCE.getActivity_Parent(); + + /** + * The meta object literal for the 'Children' containment reference list feature. + * + * + * @generated + */ + EReference ACTIVITY__CHILDREN = eINSTANCE.getActivity_Children(); + + /** + * The meta object literal for the '{@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceImpl Activity Instance}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.ActivityInstanceImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getActivityInstance() + * @generated + */ + EClass ACTIVITY_INSTANCE = eINSTANCE.getActivityInstance(); + + /** + * The meta object literal for the 'Oid' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY_INSTANCE__OID = eINSTANCE.getActivityInstance_Oid(); + + /** + * The meta object literal for the 'Instid' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY_INSTANCE__INSTID = eINSTANCE.getActivityInstance_Instid(); + + /** + * The meta object literal for the 'Iteration ID' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY_INSTANCE__ITERATION_ID = eINSTANCE.getActivityInstance_IterationID(); + + /** + * The meta object literal for the 'Base Activity' container reference feature. + * + * + * @generated + */ + EReference ACTIVITY_INSTANCE__BASE_ACTIVITY = eINSTANCE.getActivityInstance_BaseActivity(); + + /** + * The meta object literal for the 'Parent Workflow' reference feature. + * + * + * @generated + */ + EReference ACTIVITY_INSTANCE__PARENT_WORKFLOW = eINSTANCE.getActivityInstance_ParentWorkflow(); + + /** + * The meta object literal for the 'Parent Instance' reference feature. + * + * + * @generated + */ + EReference ACTIVITY_INSTANCE__PARENT_INSTANCE = eINSTANCE.getActivityInstance_ParentInstance(); + + /** + * The meta object literal for the 'Status Events' containment reference list feature. + * + * + * @generated + */ + EReference ACTIVITY_INSTANCE__STATUS_EVENTS = eINSTANCE.getActivityInstance_StatusEvents(); + + /** + * The meta object literal for the '{@link at.ac.uibk.wfr.perftool.impl.WorkflowStatusEventImpl Workflow Status Event}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.WorkflowStatusEventImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getWorkflowStatusEvent() + * @generated + */ + EClass WORKFLOW_STATUS_EVENT = eINSTANCE.getWorkflowStatusEvent(); + + /** + * The meta object literal for the 'Oid' attribute feature. + * + * + * @generated + */ + EAttribute WORKFLOW_STATUS_EVENT__OID = eINSTANCE.getWorkflowStatusEvent_Oid(); + + /** + * The meta object literal for the 'New Status' attribute feature. + * + * + * @generated + */ + EAttribute WORKFLOW_STATUS_EVENT__NEW_STATUS = eINSTANCE.getWorkflowStatusEvent_NewStatus(); + + /** + * The meta object literal for the 'Old Status' attribute feature. + * + * + * @generated + */ + EAttribute WORKFLOW_STATUS_EVENT__OLD_STATUS = eINSTANCE.getWorkflowStatusEvent_OldStatus(); + + /** + * The meta object literal for the 'Timestamp' attribute feature. + * + * + * @generated + */ + EAttribute WORKFLOW_STATUS_EVENT__TIMESTAMP = eINSTANCE.getWorkflowStatusEvent_Timestamp(); + + /** + * The meta object literal for the 'Parent Workflow' container reference feature. + * + * + * @generated + */ + EReference WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW = eINSTANCE.getWorkflowStatusEvent_ParentWorkflow(); + + /** + * The meta object literal for the '{@link at.ac.uibk.wfr.perftool.impl.ActivityStatusEventImpl Activity Status Event}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.ActivityStatusEventImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getActivityStatusEvent() + * @generated + */ + EClass ACTIVITY_STATUS_EVENT = eINSTANCE.getActivityStatusEvent(); + + /** + * The meta object literal for the 'Oid' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY_STATUS_EVENT__OID = eINSTANCE.getActivityStatusEvent_Oid(); + + /** + * The meta object literal for the 'New Status' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY_STATUS_EVENT__NEW_STATUS = eINSTANCE.getActivityStatusEvent_NewStatus(); + + /** + * The meta object literal for the 'Old Status' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY_STATUS_EVENT__OLD_STATUS = eINSTANCE.getActivityStatusEvent_OldStatus(); + + /** + * The meta object literal for the 'Timestamp' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY_STATUS_EVENT__TIMESTAMP = eINSTANCE.getActivityStatusEvent_Timestamp(); + + /** + * The meta object literal for the 'Parent Activity' container reference feature. + * + * + * @generated + */ + EReference ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY = eINSTANCE.getActivityStatusEvent_ParentActivity(); + + /** + * The meta object literal for the '{@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceStatusEventImpl Activity Instance Status Event}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.ActivityInstanceStatusEventImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getActivityInstanceStatusEvent() + * @generated + */ + EClass ACTIVITY_INSTANCE_STATUS_EVENT = eINSTANCE.getActivityInstanceStatusEvent(); + + /** + * The meta object literal for the 'Oid' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY_INSTANCE_STATUS_EVENT__OID = eINSTANCE.getActivityInstanceStatusEvent_Oid(); + + /** + * The meta object literal for the 'New Status' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY_INSTANCE_STATUS_EVENT__NEW_STATUS = eINSTANCE.getActivityInstanceStatusEvent_NewStatus(); + + /** + * The meta object literal for the 'Old Status' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY_INSTANCE_STATUS_EVENT__OLD_STATUS = eINSTANCE.getActivityInstanceStatusEvent_OldStatus(); + + /** + * The meta object literal for the 'Timestamp' attribute feature. + * + * + * @generated + */ + EAttribute ACTIVITY_INSTANCE_STATUS_EVENT__TIMESTAMP = eINSTANCE.getActivityInstanceStatusEvent_Timestamp(); + + /** + * The meta object literal for the 'Parent Instance' container reference feature. + * + * + * @generated + */ + EReference ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE = eINSTANCE.getActivityInstanceStatusEvent_ParentInstance(); + + /** + * The meta object literal for the '{@link at.ac.uibk.wfr.perftool.impl.DeviceInstanceStatusEventImpl Device Instance Status Event}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.DeviceInstanceStatusEventImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getDeviceInstanceStatusEvent() + * @generated + */ + EClass DEVICE_INSTANCE_STATUS_EVENT = eINSTANCE.getDeviceInstanceStatusEvent(); + + /** + * The meta object literal for the 'Oid' attribute feature. + * + * + * @generated + */ + EAttribute DEVICE_INSTANCE_STATUS_EVENT__OID = eINSTANCE.getDeviceInstanceStatusEvent_Oid(); + + /** + * The meta object literal for the 'Device Type' attribute feature. + * + * + * @generated + */ + EAttribute DEVICE_INSTANCE_STATUS_EVENT__DEVICE_TYPE = eINSTANCE.getDeviceInstanceStatusEvent_DeviceType(); + + /** + * The meta object literal for the 'Device ID' attribute feature. + * + * + * @generated + */ + EAttribute DEVICE_INSTANCE_STATUS_EVENT__DEVICE_ID = eINSTANCE.getDeviceInstanceStatusEvent_DeviceID(); + + /** + * The meta object literal for the 'New Status' attribute feature. + * + * + * @generated + */ + EAttribute DEVICE_INSTANCE_STATUS_EVENT__NEW_STATUS = eINSTANCE.getDeviceInstanceStatusEvent_NewStatus(); + + /** + * The meta object literal for the 'Old Status' attribute feature. + * + * + * @generated + */ + EAttribute DEVICE_INSTANCE_STATUS_EVENT__OLD_STATUS = eINSTANCE.getDeviceInstanceStatusEvent_OldStatus(); + + /** + * The meta object literal for the 'Timestamp' attribute feature. + * + * + * @generated + */ + EAttribute DEVICE_INSTANCE_STATUS_EVENT__TIMESTAMP = eINSTANCE.getDeviceInstanceStatusEvent_Timestamp(); + + /** + * The meta object literal for the 'Executed Impl ID' attribute feature. + * + * + * @generated + */ + EAttribute DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_IMPL_ID = eINSTANCE.getDeviceInstanceStatusEvent_ExecutedImplID(); + + /** + * The meta object literal for the 'Device Slot Count' attribute feature. + * + * + * @generated + */ + EAttribute DEVICE_INSTANCE_STATUS_EVENT__DEVICE_SLOT_COUNT = eINSTANCE.getDeviceInstanceStatusEvent_DeviceSlotCount(); + + /** + * The meta object literal for the 'Parent Workflow' container reference feature. + * + * + * @generated + */ + EReference DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW = eINSTANCE.getDeviceInstanceStatusEvent_ParentWorkflow(); + + /** + * The meta object literal for the 'Executed Instance' reference feature. + * + * + * @generated + */ + EReference DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_INSTANCE = eINSTANCE.getDeviceInstanceStatusEvent_ExecutedInstance(); + + /** + * The meta object literal for the '{@link at.ac.uibk.wfr.perftool.impl.ComponentStatusEventImpl Component Status Event}' class. + * + * + * @see at.ac.uibk.wfr.perftool.impl.ComponentStatusEventImpl + * @see at.ac.uibk.wfr.perftool.impl.PerftoolPackageImpl#getComponentStatusEvent() + * @generated + */ + EClass COMPONENT_STATUS_EVENT = eINSTANCE.getComponentStatusEvent(); + + /** + * The meta object literal for the 'Oid' attribute feature. + * + * + * @generated + */ + EAttribute COMPONENT_STATUS_EVENT__OID = eINSTANCE.getComponentStatusEvent_Oid(); + + /** + * The meta object literal for the 'Component Type' attribute feature. + * + * + * @generated + */ + EAttribute COMPONENT_STATUS_EVENT__COMPONENT_TYPE = eINSTANCE.getComponentStatusEvent_ComponentType(); + + /** + * The meta object literal for the 'New Status' attribute feature. + * + * + * @generated + */ + EAttribute COMPONENT_STATUS_EVENT__NEW_STATUS = eINSTANCE.getComponentStatusEvent_NewStatus(); + + /** + * The meta object literal for the 'Old Status' attribute feature. + * + * + * @generated + */ + EAttribute COMPONENT_STATUS_EVENT__OLD_STATUS = eINSTANCE.getComponentStatusEvent_OldStatus(); + + /** + * The meta object literal for the 'Timestamp' attribute feature. + * + * + * @generated + */ + EAttribute COMPONENT_STATUS_EVENT__TIMESTAMP = eINSTANCE.getComponentStatusEvent_Timestamp(); + + /** + * The meta object literal for the 'Workflow' container reference feature. + * + * + * @generated + */ + EReference COMPONENT_STATUS_EVENT__WORKFLOW = eINSTANCE.getComponentStatusEvent_Workflow(); + + } + +} //PerftoolPackage diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/Workflow.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/Workflow.java new file mode 100755 index 0000000..0d09501 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/Workflow.java @@ -0,0 +1,217 @@ +/** + */ +package at.ac.uibk.wfr.perftool; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Workflow'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.Workflow#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Workflow#getWfid Wfid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Workflow#getUuid Uuid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Workflow#getName Name}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Workflow#getToplevelActivity Toplevel Activity}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Workflow#getStatusEvents Status Events}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Workflow#getDeviceEvents Device Events}
      • + *
      • {@link at.ac.uibk.wfr.perftool.Workflow#getComponentEvents Component Events}
      • + *
      + *

      + * + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflow() + * @model + * @generated + */ +public interface Workflow extends EObject { + /** + * Returns the value of the 'Oid' attribute. + * + *

      + * If the meaning of the 'Oid' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Oid' attribute. + * @see #setOid(int) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflow_Oid() + * @model id="true" required="true" + * @generated + */ + int getOid(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.Workflow#getOid Oid}' attribute. + * + * + * @param value the new value of the 'Oid' attribute. + * @see #getOid() + * @generated + */ + void setOid(int value); + + /** + * Returns the value of the 'Wfid' attribute. + * + *

      + * If the meaning of the 'Wfid' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Wfid' attribute. + * @see #setWfid(long) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflow_Wfid() + * @model required="true" + * @generated + */ + long getWfid(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.Workflow#getWfid Wfid}' attribute. + * + * + * @param value the new value of the 'Wfid' attribute. + * @see #getWfid() + * @generated + */ + void setWfid(long value); + + /** + * Returns the value of the 'Uuid' attribute. + * + *

      + * If the meaning of the 'Uuid' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Uuid' attribute. + * @see #setUuid(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflow_Uuid() + * @model required="true" + * @generated + */ + String getUuid(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.Workflow#getUuid Uuid}' attribute. + * + * + * @param value the new value of the 'Uuid' attribute. + * @see #getUuid() + * @generated + */ + void setUuid(String value); + + /** + * Returns the value of the 'Name' attribute. + * + *

      + * If the meaning of the 'Name' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Name' attribute. + * @see #setName(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflow_Name() + * @model required="true" + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.Workflow#getName Name}' attribute. + * + * + * @param value the new value of the 'Name' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Returns the value of the 'Toplevel Activity' containment reference. + * + *

      + * If the meaning of the 'Toplevel Activity' reference isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Toplevel Activity' containment reference. + * @see #setToplevelActivity(Activity) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflow_ToplevelActivity() + * @model containment="true" + * @generated + */ + Activity getToplevelActivity(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.Workflow#getToplevelActivity Toplevel Activity}' containment reference. + * + * + * @param value the new value of the 'Toplevel Activity' containment reference. + * @see #getToplevelActivity() + * @generated + */ + void setToplevelActivity(Activity value); + + /** + * Returns the value of the 'Status Events' containment reference list. + * The list contents are of type {@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent}. + * It is bidirectional and its opposite is '{@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getParentWorkflow Parent Workflow}'. + * + *

      + * If the meaning of the 'Status Events' containment reference list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Status Events' containment reference list. + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflow_StatusEvents() + * @see at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getParentWorkflow + * @model opposite="parentWorkflow" containment="true" ordered="false" + * @generated + */ + EList getStatusEvents(); + + /** + * Returns the value of the 'Device Events' containment reference list. + * The list contents are of type {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent}. + * It is bidirectional and its opposite is '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getParentWorkflow Parent Workflow}'. + * + *

      + * If the meaning of the 'Device Events' containment reference list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Device Events' containment reference list. + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflow_DeviceEvents() + * @see at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent#getParentWorkflow + * @model opposite="parentWorkflow" containment="true" ordered="false" + * @generated + */ + EList getDeviceEvents(); + + /** + * Returns the value of the 'Component Events' containment reference list. + * The list contents are of type {@link at.ac.uibk.wfr.perftool.ComponentStatusEvent}. + * It is bidirectional and its opposite is '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent#getWorkflow Workflow}'. + * + *

      + * If the meaning of the 'Component Events' containment reference list isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Component Events' containment reference list. + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflow_ComponentEvents() + * @see at.ac.uibk.wfr.perftool.ComponentStatusEvent#getWorkflow + * @model opposite="workflow" containment="true" ordered="false" + * @generated + */ + EList getComponentEvents(); + +} // Workflow diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/WorkflowStatusEvent.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/WorkflowStatusEvent.java new file mode 100755 index 0000000..9eb42a9 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/WorkflowStatusEvent.java @@ -0,0 +1,160 @@ +/** + */ +package at.ac.uibk.wfr.perftool; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * A representation of the model object 'Workflow Status Event'. + * + * + *

      + * The following features are supported: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getNewStatus New Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getOldStatus Old Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getTimestamp Timestamp}
      • + *
      • {@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getParentWorkflow Parent Workflow}
      • + *
      + *

      + * + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflowStatusEvent() + * @model + * @generated + */ +public interface WorkflowStatusEvent extends EObject { + /** + * Returns the value of the 'Oid' attribute. + * + *

      + * If the meaning of the 'Oid' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Oid' attribute. + * @see #setOid(int) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflowStatusEvent_Oid() + * @model id="true" required="true" + * @generated + */ + int getOid(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getOid Oid}' attribute. + * + * + * @param value the new value of the 'Oid' attribute. + * @see #getOid() + * @generated + */ + void setOid(int value); + + /** + * Returns the value of the 'New Status' attribute. + * + *

      + * If the meaning of the 'New Status' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'New Status' attribute. + * @see #setNewStatus(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflowStatusEvent_NewStatus() + * @model required="true" + * @generated + */ + String getNewStatus(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getNewStatus New Status}' attribute. + * + * + * @param value the new value of the 'New Status' attribute. + * @see #getNewStatus() + * @generated + */ + void setNewStatus(String value); + + /** + * Returns the value of the 'Old Status' attribute. + * + *

      + * If the meaning of the 'Old Status' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Old Status' attribute. + * @see #setOldStatus(String) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflowStatusEvent_OldStatus() + * @model required="true" + * @generated + */ + String getOldStatus(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getOldStatus Old Status}' attribute. + * + * + * @param value the new value of the 'Old Status' attribute. + * @see #getOldStatus() + * @generated + */ + void setOldStatus(String value); + + /** + * Returns the value of the 'Timestamp' attribute. + * + *

      + * If the meaning of the 'Timestamp' attribute isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Timestamp' attribute. + * @see #setTimestamp(long) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflowStatusEvent_Timestamp() + * @model required="true" + * @generated + */ + long getTimestamp(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getTimestamp Timestamp}' attribute. + * + * + * @param value the new value of the 'Timestamp' attribute. + * @see #getTimestamp() + * @generated + */ + void setTimestamp(long value); + + /** + * Returns the value of the 'Parent Workflow' container reference. + * It is bidirectional and its opposite is '{@link at.ac.uibk.wfr.perftool.Workflow#getStatusEvents Status Events}'. + * + *

      + * If the meaning of the 'Parent Workflow' container reference isn't clear, + * there really should be more of a description here... + *

      + * + * @return the value of the 'Parent Workflow' container reference. + * @see #setParentWorkflow(Workflow) + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#getWorkflowStatusEvent_ParentWorkflow() + * @see at.ac.uibk.wfr.perftool.Workflow#getStatusEvents + * @model opposite="statusEvents" required="true" transient="false" + * @generated + */ + Workflow getParentWorkflow(); + + /** + * Sets the value of the '{@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent#getParentWorkflow Parent Workflow}' container reference. + * + * + * @param value the new value of the 'Parent Workflow' container reference. + * @see #getParentWorkflow() + * @generated + */ + void setParentWorkflow(Workflow value); + +} // WorkflowStatusEvent diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ActivityImpl.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ActivityImpl.java new file mode 100755 index 0000000..b12e649 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ActivityImpl.java @@ -0,0 +1,662 @@ +/** + */ +package at.ac.uibk.wfr.perftool.impl; + +import at.ac.uibk.wfr.perftool.Activity; +import at.ac.uibk.wfr.perftool.ActivityInstance; +import at.ac.uibk.wfr.perftool.ActivityStatusEvent; +import at.ac.uibk.wfr.perftool.PerftoolPackage; +import at.ac.uibk.wfr.perftool.Workflow; + +import java.util.Collection; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Activity'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityImpl#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityImpl#getActid Actid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityImpl#getName Name}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityImpl#getType Type}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityImpl#getBranchID Branch ID}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityImpl#getParentWorkflow Parent Workflow}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityImpl#getInstances Instances}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityImpl#getStatusEvents Status Events}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityImpl#getParent Parent}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityImpl#getChildren Children}
      • + *
      + *

      + * + * @generated + */ +public class ActivityImpl extends MinimalEObjectImpl.Container implements Activity { + /** + * The default value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected static final int OID_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected int oid = OID_EDEFAULT; + + /** + * The default value of the '{@link #getActid() Actid}' attribute. + * + * + * @see #getActid() + * @generated + * @ordered + */ + protected static final long ACTID_EDEFAULT = 0L; + + /** + * The cached value of the '{@link #getActid() Actid}' attribute. + * + * + * @see #getActid() + * @generated + * @ordered + */ + protected long actid = ACTID_EDEFAULT; + + /** + * The default value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * The default value of the '{@link #getType() Type}' attribute. + * + * + * @see #getType() + * @generated + * @ordered + */ + protected static final String TYPE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getType() Type}' attribute. + * + * + * @see #getType() + * @generated + * @ordered + */ + protected String type = TYPE_EDEFAULT; + + /** + * The default value of the '{@link #getBranchID() Branch ID}' attribute. + * + * + * @see #getBranchID() + * @generated + * @ordered + */ + protected static final long BRANCH_ID_EDEFAULT = 0L; + + /** + * The cached value of the '{@link #getBranchID() Branch ID}' attribute. + * + * + * @see #getBranchID() + * @generated + * @ordered + */ + protected long branchID = BRANCH_ID_EDEFAULT; + + /** + * The cached value of the '{@link #getParentWorkflow() Parent Workflow}' reference. + * + * + * @see #getParentWorkflow() + * @generated + * @ordered + */ + protected Workflow parentWorkflow; + + /** + * The cached value of the '{@link #getInstances() Instances}' containment reference list. + * + * + * @see #getInstances() + * @generated + * @ordered + */ + protected EList instances; + + /** + * The cached value of the '{@link #getStatusEvents() Status Events}' containment reference list. + * + * + * @see #getStatusEvents() + * @generated + * @ordered + */ + protected EList statusEvents; + + /** + * The cached value of the '{@link #getChildren() Children}' containment reference list. + * + * + * @see #getChildren() + * @generated + * @ordered + */ + protected EList children; + + /** + * + * + * @generated + */ + protected ActivityImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return PerftoolPackage.Literals.ACTIVITY; + } + + /** + * + * + * @generated + */ + public int getOid() { + return oid; + } + + /** + * + * + * @generated + */ + public void setOid(int newOid) { + int oldOid = oid; + oid = newOid; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY__OID, oldOid, oid)); + } + + /** + * + * + * @generated + */ + public long getActid() { + return actid; + } + + /** + * + * + * @generated + */ + public void setActid(long newActid) { + long oldActid = actid; + actid = newActid; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY__ACTID, oldActid, actid)); + } + + /** + * + * + * @generated + */ + public String getName() { + return name; + } + + /** + * + * + * @generated + */ + public void setName(String newName) { + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY__NAME, oldName, name)); + } + + /** + * + * + * @generated + */ + public String getType() { + return type; + } + + /** + * + * + * @generated + */ + public void setType(String newType) { + String oldType = type; + type = newType; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY__TYPE, oldType, type)); + } + + /** + * + * + * @generated + */ + public long getBranchID() { + return branchID; + } + + /** + * + * + * @generated + */ + public void setBranchID(long newBranchID) { + long oldBranchID = branchID; + branchID = newBranchID; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY__BRANCH_ID, oldBranchID, branchID)); + } + + /** + * + * + * @generated + */ + public Workflow getParentWorkflow() { + if (parentWorkflow != null && parentWorkflow.eIsProxy()) { + InternalEObject oldParentWorkflow = (InternalEObject)parentWorkflow; + parentWorkflow = (Workflow)eResolveProxy(oldParentWorkflow); + if (parentWorkflow != oldParentWorkflow) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, PerftoolPackage.ACTIVITY__PARENT_WORKFLOW, oldParentWorkflow, parentWorkflow)); + } + } + return parentWorkflow; + } + + /** + * + * + * @generated + */ + public Workflow basicGetParentWorkflow() { + return parentWorkflow; + } + + /** + * + * + * @generated + */ + public void setParentWorkflow(Workflow newParentWorkflow) { + Workflow oldParentWorkflow = parentWorkflow; + parentWorkflow = newParentWorkflow; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY__PARENT_WORKFLOW, oldParentWorkflow, parentWorkflow)); + } + + /** + * + * + * @generated + */ + public EList getInstances() { + if (instances == null) { + instances = new EObjectContainmentWithInverseEList(ActivityInstance.class, this, PerftoolPackage.ACTIVITY__INSTANCES, PerftoolPackage.ACTIVITY_INSTANCE__BASE_ACTIVITY); + } + return instances; + } + + /** + * + * + * @generated + */ + public EList getStatusEvents() { + if (statusEvents == null) { + statusEvents = new EObjectContainmentWithInverseEList(ActivityStatusEvent.class, this, PerftoolPackage.ACTIVITY__STATUS_EVENTS, PerftoolPackage.ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY); + } + return statusEvents; + } + + /** + * + * + * @generated + */ + public Activity getParent() { + if (eContainerFeatureID() != PerftoolPackage.ACTIVITY__PARENT) return null; + return (Activity)eInternalContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetParent(Activity newParent, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject)newParent, PerftoolPackage.ACTIVITY__PARENT, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + public void setParent(Activity newParent) { + if (newParent != eInternalContainer() || (eContainerFeatureID() != PerftoolPackage.ACTIVITY__PARENT && newParent != null)) { + if (EcoreUtil.isAncestor(this, newParent)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newParent != null) + msgs = ((InternalEObject)newParent).eInverseAdd(this, PerftoolPackage.ACTIVITY__CHILDREN, Activity.class, msgs); + msgs = basicSetParent(newParent, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY__PARENT, newParent, newParent)); + } + + /** + * + * + * @generated + */ + public EList getChildren() { + if (children == null) { + children = new EObjectContainmentWithInverseEList(Activity.class, this, PerftoolPackage.ACTIVITY__CHILDREN, PerftoolPackage.ACTIVITY__PARENT); + } + return children; + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.ACTIVITY__INSTANCES: + return ((InternalEList)(InternalEList)getInstances()).basicAdd(otherEnd, msgs); + case PerftoolPackage.ACTIVITY__STATUS_EVENTS: + return ((InternalEList)(InternalEList)getStatusEvents()).basicAdd(otherEnd, msgs); + case PerftoolPackage.ACTIVITY__PARENT: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetParent((Activity)otherEnd, msgs); + case PerftoolPackage.ACTIVITY__CHILDREN: + return ((InternalEList)(InternalEList)getChildren()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.ACTIVITY__INSTANCES: + return ((InternalEList)getInstances()).basicRemove(otherEnd, msgs); + case PerftoolPackage.ACTIVITY__STATUS_EVENTS: + return ((InternalEList)getStatusEvents()).basicRemove(otherEnd, msgs); + case PerftoolPackage.ACTIVITY__PARENT: + return basicSetParent(null, msgs); + case PerftoolPackage.ACTIVITY__CHILDREN: + return ((InternalEList)getChildren()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch (eContainerFeatureID()) { + case PerftoolPackage.ACTIVITY__PARENT: + return eInternalContainer().eInverseRemove(this, PerftoolPackage.ACTIVITY__CHILDREN, Activity.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PerftoolPackage.ACTIVITY__OID: + return getOid(); + case PerftoolPackage.ACTIVITY__ACTID: + return getActid(); + case PerftoolPackage.ACTIVITY__NAME: + return getName(); + case PerftoolPackage.ACTIVITY__TYPE: + return getType(); + case PerftoolPackage.ACTIVITY__BRANCH_ID: + return getBranchID(); + case PerftoolPackage.ACTIVITY__PARENT_WORKFLOW: + if (resolve) return getParentWorkflow(); + return basicGetParentWorkflow(); + case PerftoolPackage.ACTIVITY__INSTANCES: + return getInstances(); + case PerftoolPackage.ACTIVITY__STATUS_EVENTS: + return getStatusEvents(); + case PerftoolPackage.ACTIVITY__PARENT: + return getParent(); + case PerftoolPackage.ACTIVITY__CHILDREN: + return getChildren(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case PerftoolPackage.ACTIVITY__OID: + setOid((Integer)newValue); + return; + case PerftoolPackage.ACTIVITY__ACTID: + setActid((Long)newValue); + return; + case PerftoolPackage.ACTIVITY__NAME: + setName((String)newValue); + return; + case PerftoolPackage.ACTIVITY__TYPE: + setType((String)newValue); + return; + case PerftoolPackage.ACTIVITY__BRANCH_ID: + setBranchID((Long)newValue); + return; + case PerftoolPackage.ACTIVITY__PARENT_WORKFLOW: + setParentWorkflow((Workflow)newValue); + return; + case PerftoolPackage.ACTIVITY__INSTANCES: + getInstances().clear(); + getInstances().addAll((Collection)newValue); + return; + case PerftoolPackage.ACTIVITY__STATUS_EVENTS: + getStatusEvents().clear(); + getStatusEvents().addAll((Collection)newValue); + return; + case PerftoolPackage.ACTIVITY__PARENT: + setParent((Activity)newValue); + return; + case PerftoolPackage.ACTIVITY__CHILDREN: + getChildren().clear(); + getChildren().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PerftoolPackage.ACTIVITY__OID: + setOid(OID_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY__ACTID: + setActid(ACTID_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY__NAME: + setName(NAME_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY__TYPE: + setType(TYPE_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY__BRANCH_ID: + setBranchID(BRANCH_ID_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY__PARENT_WORKFLOW: + setParentWorkflow((Workflow)null); + return; + case PerftoolPackage.ACTIVITY__INSTANCES: + getInstances().clear(); + return; + case PerftoolPackage.ACTIVITY__STATUS_EVENTS: + getStatusEvents().clear(); + return; + case PerftoolPackage.ACTIVITY__PARENT: + setParent((Activity)null); + return; + case PerftoolPackage.ACTIVITY__CHILDREN: + getChildren().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PerftoolPackage.ACTIVITY__OID: + return oid != OID_EDEFAULT; + case PerftoolPackage.ACTIVITY__ACTID: + return actid != ACTID_EDEFAULT; + case PerftoolPackage.ACTIVITY__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + case PerftoolPackage.ACTIVITY__TYPE: + return TYPE_EDEFAULT == null ? type != null : !TYPE_EDEFAULT.equals(type); + case PerftoolPackage.ACTIVITY__BRANCH_ID: + return branchID != BRANCH_ID_EDEFAULT; + case PerftoolPackage.ACTIVITY__PARENT_WORKFLOW: + return parentWorkflow != null; + case PerftoolPackage.ACTIVITY__INSTANCES: + return instances != null && !instances.isEmpty(); + case PerftoolPackage.ACTIVITY__STATUS_EVENTS: + return statusEvents != null && !statusEvents.isEmpty(); + case PerftoolPackage.ACTIVITY__PARENT: + return getParent() != null; + case PerftoolPackage.ACTIVITY__CHILDREN: + return children != null && !children.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (oid: "); + result.append(oid); + result.append(", actid: "); + result.append(actid); + result.append(", name: "); + result.append(name); + result.append(", type: "); + result.append(type); + result.append(", branchID: "); + result.append(branchID); + result.append(')'); + return result.toString(); + } + +} //ActivityImpl diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ActivityInstanceImpl.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ActivityInstanceImpl.java new file mode 100755 index 0000000..86fd259 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ActivityInstanceImpl.java @@ -0,0 +1,538 @@ +/** + */ +package at.ac.uibk.wfr.perftool.impl; + +import at.ac.uibk.wfr.perftool.Activity; +import at.ac.uibk.wfr.perftool.ActivityInstance; +import at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent; +import at.ac.uibk.wfr.perftool.PerftoolPackage; +import at.ac.uibk.wfr.perftool.Workflow; + +import java.util.Collection; +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.EcoreUtil; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Activity Instance'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceImpl#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceImpl#getInstid Instid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceImpl#getIterationID Iteration ID}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceImpl#getBaseActivity Base Activity}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceImpl#getParentWorkflow Parent Workflow}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceImpl#getParentInstance Parent Instance}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceImpl#getStatusEvents Status Events}
      • + *
      + *

      + * + * @generated + */ +public class ActivityInstanceImpl extends MinimalEObjectImpl.Container implements ActivityInstance { + /** + * The default value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected static final int OID_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected int oid = OID_EDEFAULT; + + /** + * The default value of the '{@link #getInstid() Instid}' attribute. + * + * + * @see #getInstid() + * @generated + * @ordered + */ + protected static final long INSTID_EDEFAULT = 0L; + + /** + * The cached value of the '{@link #getInstid() Instid}' attribute. + * + * + * @see #getInstid() + * @generated + * @ordered + */ + protected long instid = INSTID_EDEFAULT; + + /** + * The default value of the '{@link #getIterationID() Iteration ID}' attribute. + * + * + * @see #getIterationID() + * @generated + * @ordered + */ + protected static final long ITERATION_ID_EDEFAULT = 0L; + + /** + * The cached value of the '{@link #getIterationID() Iteration ID}' attribute. + * + * + * @see #getIterationID() + * @generated + * @ordered + */ + protected long iterationID = ITERATION_ID_EDEFAULT; + + /** + * The cached value of the '{@link #getParentWorkflow() Parent Workflow}' reference. + * + * + * @see #getParentWorkflow() + * @generated + * @ordered + */ + protected Workflow parentWorkflow; + + /** + * The cached value of the '{@link #getParentInstance() Parent Instance}' reference. + * + * + * @see #getParentInstance() + * @generated + * @ordered + */ + protected ActivityInstance parentInstance; + + /** + * The cached value of the '{@link #getStatusEvents() Status Events}' containment reference list. + * + * + * @see #getStatusEvents() + * @generated + * @ordered + */ + protected EList statusEvents; + + /** + * + * + * @generated + */ + protected ActivityInstanceImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return PerftoolPackage.Literals.ACTIVITY_INSTANCE; + } + + /** + * + * + * @generated + */ + public int getOid() { + return oid; + } + + /** + * + * + * @generated + */ + public void setOid(int newOid) { + int oldOid = oid; + oid = newOid; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_INSTANCE__OID, oldOid, oid)); + } + + /** + * + * + * @generated + */ + public long getInstid() { + return instid; + } + + /** + * + * + * @generated + */ + public void setInstid(long newInstid) { + long oldInstid = instid; + instid = newInstid; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_INSTANCE__INSTID, oldInstid, instid)); + } + + /** + * + * + * @generated + */ + public long getIterationID() { + return iterationID; + } + + /** + * + * + * @generated + */ + public void setIterationID(long newIterationID) { + long oldIterationID = iterationID; + iterationID = newIterationID; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_INSTANCE__ITERATION_ID, oldIterationID, iterationID)); + } + + /** + * + * + * @generated + */ + public Activity getBaseActivity() { + if (eContainerFeatureID() != PerftoolPackage.ACTIVITY_INSTANCE__BASE_ACTIVITY) return null; + return (Activity)eInternalContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetBaseActivity(Activity newBaseActivity, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject)newBaseActivity, PerftoolPackage.ACTIVITY_INSTANCE__BASE_ACTIVITY, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + public void setBaseActivity(Activity newBaseActivity) { + if (newBaseActivity != eInternalContainer() || (eContainerFeatureID() != PerftoolPackage.ACTIVITY_INSTANCE__BASE_ACTIVITY && newBaseActivity != null)) { + if (EcoreUtil.isAncestor(this, newBaseActivity)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newBaseActivity != null) + msgs = ((InternalEObject)newBaseActivity).eInverseAdd(this, PerftoolPackage.ACTIVITY__INSTANCES, Activity.class, msgs); + msgs = basicSetBaseActivity(newBaseActivity, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_INSTANCE__BASE_ACTIVITY, newBaseActivity, newBaseActivity)); + } + + /** + * + * + * @generated + */ + public Workflow getParentWorkflow() { + if (parentWorkflow != null && parentWorkflow.eIsProxy()) { + InternalEObject oldParentWorkflow = (InternalEObject)parentWorkflow; + parentWorkflow = (Workflow)eResolveProxy(oldParentWorkflow); + if (parentWorkflow != oldParentWorkflow) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, PerftoolPackage.ACTIVITY_INSTANCE__PARENT_WORKFLOW, oldParentWorkflow, parentWorkflow)); + } + } + return parentWorkflow; + } + + /** + * + * + * @generated + */ + public Workflow basicGetParentWorkflow() { + return parentWorkflow; + } + + /** + * + * + * @generated + */ + public void setParentWorkflow(Workflow newParentWorkflow) { + Workflow oldParentWorkflow = parentWorkflow; + parentWorkflow = newParentWorkflow; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_INSTANCE__PARENT_WORKFLOW, oldParentWorkflow, parentWorkflow)); + } + + /** + * + * + * @generated + */ + public ActivityInstance getParentInstance() { + if (parentInstance != null && parentInstance.eIsProxy()) { + InternalEObject oldParentInstance = (InternalEObject)parentInstance; + parentInstance = (ActivityInstance)eResolveProxy(oldParentInstance); + if (parentInstance != oldParentInstance) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, PerftoolPackage.ACTIVITY_INSTANCE__PARENT_INSTANCE, oldParentInstance, parentInstance)); + } + } + return parentInstance; + } + + /** + * + * + * @generated + */ + public ActivityInstance basicGetParentInstance() { + return parentInstance; + } + + /** + * + * + * @generated + */ + public void setParentInstance(ActivityInstance newParentInstance) { + ActivityInstance oldParentInstance = parentInstance; + parentInstance = newParentInstance; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_INSTANCE__PARENT_INSTANCE, oldParentInstance, parentInstance)); + } + + /** + * + * + * @generated + */ + public EList getStatusEvents() { + if (statusEvents == null) { + statusEvents = new EObjectContainmentWithInverseEList(ActivityInstanceStatusEvent.class, this, PerftoolPackage.ACTIVITY_INSTANCE__STATUS_EVENTS, PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE); + } + return statusEvents; + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_INSTANCE__BASE_ACTIVITY: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetBaseActivity((Activity)otherEnd, msgs); + case PerftoolPackage.ACTIVITY_INSTANCE__STATUS_EVENTS: + return ((InternalEList)(InternalEList)getStatusEvents()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_INSTANCE__BASE_ACTIVITY: + return basicSetBaseActivity(null, msgs); + case PerftoolPackage.ACTIVITY_INSTANCE__STATUS_EVENTS: + return ((InternalEList)getStatusEvents()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch (eContainerFeatureID()) { + case PerftoolPackage.ACTIVITY_INSTANCE__BASE_ACTIVITY: + return eInternalContainer().eInverseRemove(this, PerftoolPackage.ACTIVITY__INSTANCES, Activity.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_INSTANCE__OID: + return getOid(); + case PerftoolPackage.ACTIVITY_INSTANCE__INSTID: + return getInstid(); + case PerftoolPackage.ACTIVITY_INSTANCE__ITERATION_ID: + return getIterationID(); + case PerftoolPackage.ACTIVITY_INSTANCE__BASE_ACTIVITY: + return getBaseActivity(); + case PerftoolPackage.ACTIVITY_INSTANCE__PARENT_WORKFLOW: + if (resolve) return getParentWorkflow(); + return basicGetParentWorkflow(); + case PerftoolPackage.ACTIVITY_INSTANCE__PARENT_INSTANCE: + if (resolve) return getParentInstance(); + return basicGetParentInstance(); + case PerftoolPackage.ACTIVITY_INSTANCE__STATUS_EVENTS: + return getStatusEvents(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_INSTANCE__OID: + setOid((Integer)newValue); + return; + case PerftoolPackage.ACTIVITY_INSTANCE__INSTID: + setInstid((Long)newValue); + return; + case PerftoolPackage.ACTIVITY_INSTANCE__ITERATION_ID: + setIterationID((Long)newValue); + return; + case PerftoolPackage.ACTIVITY_INSTANCE__BASE_ACTIVITY: + setBaseActivity((Activity)newValue); + return; + case PerftoolPackage.ACTIVITY_INSTANCE__PARENT_WORKFLOW: + setParentWorkflow((Workflow)newValue); + return; + case PerftoolPackage.ACTIVITY_INSTANCE__PARENT_INSTANCE: + setParentInstance((ActivityInstance)newValue); + return; + case PerftoolPackage.ACTIVITY_INSTANCE__STATUS_EVENTS: + getStatusEvents().clear(); + getStatusEvents().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_INSTANCE__OID: + setOid(OID_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY_INSTANCE__INSTID: + setInstid(INSTID_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY_INSTANCE__ITERATION_ID: + setIterationID(ITERATION_ID_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY_INSTANCE__BASE_ACTIVITY: + setBaseActivity((Activity)null); + return; + case PerftoolPackage.ACTIVITY_INSTANCE__PARENT_WORKFLOW: + setParentWorkflow((Workflow)null); + return; + case PerftoolPackage.ACTIVITY_INSTANCE__PARENT_INSTANCE: + setParentInstance((ActivityInstance)null); + return; + case PerftoolPackage.ACTIVITY_INSTANCE__STATUS_EVENTS: + getStatusEvents().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_INSTANCE__OID: + return oid != OID_EDEFAULT; + case PerftoolPackage.ACTIVITY_INSTANCE__INSTID: + return instid != INSTID_EDEFAULT; + case PerftoolPackage.ACTIVITY_INSTANCE__ITERATION_ID: + return iterationID != ITERATION_ID_EDEFAULT; + case PerftoolPackage.ACTIVITY_INSTANCE__BASE_ACTIVITY: + return getBaseActivity() != null; + case PerftoolPackage.ACTIVITY_INSTANCE__PARENT_WORKFLOW: + return parentWorkflow != null; + case PerftoolPackage.ACTIVITY_INSTANCE__PARENT_INSTANCE: + return parentInstance != null; + case PerftoolPackage.ACTIVITY_INSTANCE__STATUS_EVENTS: + return statusEvents != null && !statusEvents.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (oid: "); + result.append(oid); + result.append(", instid: "); + result.append(instid); + result.append(", iterationID: "); + result.append(iterationID); + result.append(')'); + return result.toString(); + } + +} //ActivityInstanceImpl diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ActivityInstanceStatusEventImpl.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ActivityInstanceStatusEventImpl.java new file mode 100755 index 0000000..1b6a3b1 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ActivityInstanceStatusEventImpl.java @@ -0,0 +1,426 @@ +/** + */ +package at.ac.uibk.wfr.perftool.impl; + +import at.ac.uibk.wfr.perftool.ActivityInstance; +import at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent; +import at.ac.uibk.wfr.perftool.PerftoolPackage; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EcoreUtil; + +/** + * + * An implementation of the model object 'Activity Instance Status Event'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceStatusEventImpl#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceStatusEventImpl#getNewStatus New Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceStatusEventImpl#getOldStatus Old Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceStatusEventImpl#getTimestamp Timestamp}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityInstanceStatusEventImpl#getParentInstance Parent Instance}
      • + *
      + *

      + * + * @generated + */ +public class ActivityInstanceStatusEventImpl extends MinimalEObjectImpl.Container implements ActivityInstanceStatusEvent { + /** + * The default value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected static final int OID_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected int oid = OID_EDEFAULT; + + /** + * The default value of the '{@link #getNewStatus() New Status}' attribute. + * + * + * @see #getNewStatus() + * @generated + * @ordered + */ + protected static final String NEW_STATUS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getNewStatus() New Status}' attribute. + * + * + * @see #getNewStatus() + * @generated + * @ordered + */ + protected String newStatus = NEW_STATUS_EDEFAULT; + + /** + * The default value of the '{@link #getOldStatus() Old Status}' attribute. + * + * + * @see #getOldStatus() + * @generated + * @ordered + */ + protected static final String OLD_STATUS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getOldStatus() Old Status}' attribute. + * + * + * @see #getOldStatus() + * @generated + * @ordered + */ + protected String oldStatus = OLD_STATUS_EDEFAULT; + + /** + * The default value of the '{@link #getTimestamp() Timestamp}' attribute. + * + * + * @see #getTimestamp() + * @generated + * @ordered + */ + protected static final long TIMESTAMP_EDEFAULT = 0L; + + /** + * The cached value of the '{@link #getTimestamp() Timestamp}' attribute. + * + * + * @see #getTimestamp() + * @generated + * @ordered + */ + protected long timestamp = TIMESTAMP_EDEFAULT; + + /** + * + * + * @generated + */ + protected ActivityInstanceStatusEventImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return PerftoolPackage.Literals.ACTIVITY_INSTANCE_STATUS_EVENT; + } + + /** + * + * + * @generated + */ + public int getOid() { + return oid; + } + + /** + * + * + * @generated + */ + public void setOid(int newOid) { + int oldOid = oid; + oid = newOid; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__OID, oldOid, oid)); + } + + /** + * + * + * @generated + */ + public String getNewStatus() { + return newStatus; + } + + /** + * + * + * @generated + */ + public void setNewStatus(String newNewStatus) { + String oldNewStatus = newStatus; + newStatus = newNewStatus; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__NEW_STATUS, oldNewStatus, newStatus)); + } + + /** + * + * + * @generated + */ + public String getOldStatus() { + return oldStatus; + } + + /** + * + * + * @generated + */ + public void setOldStatus(String newOldStatus) { + String oldOldStatus = oldStatus; + oldStatus = newOldStatus; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__OLD_STATUS, oldOldStatus, oldStatus)); + } + + /** + * + * + * @generated + */ + public long getTimestamp() { + return timestamp; + } + + /** + * + * + * @generated + */ + public void setTimestamp(long newTimestamp) { + long oldTimestamp = timestamp; + timestamp = newTimestamp; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__TIMESTAMP, oldTimestamp, timestamp)); + } + + /** + * + * + * @generated + */ + public ActivityInstance getParentInstance() { + if (eContainerFeatureID() != PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE) return null; + return (ActivityInstance)eInternalContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetParentInstance(ActivityInstance newParentInstance, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject)newParentInstance, PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + public void setParentInstance(ActivityInstance newParentInstance) { + if (newParentInstance != eInternalContainer() || (eContainerFeatureID() != PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE && newParentInstance != null)) { + if (EcoreUtil.isAncestor(this, newParentInstance)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newParentInstance != null) + msgs = ((InternalEObject)newParentInstance).eInverseAdd(this, PerftoolPackage.ACTIVITY_INSTANCE__STATUS_EVENTS, ActivityInstance.class, msgs); + msgs = basicSetParentInstance(newParentInstance, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE, newParentInstance, newParentInstance)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetParentInstance((ActivityInstance)otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE: + return basicSetParentInstance(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch (eContainerFeatureID()) { + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE: + return eInternalContainer().eInverseRemove(this, PerftoolPackage.ACTIVITY_INSTANCE__STATUS_EVENTS, ActivityInstance.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__OID: + return getOid(); + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__NEW_STATUS: + return getNewStatus(); + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__OLD_STATUS: + return getOldStatus(); + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__TIMESTAMP: + return getTimestamp(); + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE: + return getParentInstance(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__OID: + setOid((Integer)newValue); + return; + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__NEW_STATUS: + setNewStatus((String)newValue); + return; + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__OLD_STATUS: + setOldStatus((String)newValue); + return; + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__TIMESTAMP: + setTimestamp((Long)newValue); + return; + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE: + setParentInstance((ActivityInstance)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__OID: + setOid(OID_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__NEW_STATUS: + setNewStatus(NEW_STATUS_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__OLD_STATUS: + setOldStatus(OLD_STATUS_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__TIMESTAMP: + setTimestamp(TIMESTAMP_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE: + setParentInstance((ActivityInstance)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__OID: + return oid != OID_EDEFAULT; + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__NEW_STATUS: + return NEW_STATUS_EDEFAULT == null ? newStatus != null : !NEW_STATUS_EDEFAULT.equals(newStatus); + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__OLD_STATUS: + return OLD_STATUS_EDEFAULT == null ? oldStatus != null : !OLD_STATUS_EDEFAULT.equals(oldStatus); + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__TIMESTAMP: + return timestamp != TIMESTAMP_EDEFAULT; + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE: + return getParentInstance() != null; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (oid: "); + result.append(oid); + result.append(", newStatus: "); + result.append(newStatus); + result.append(", oldStatus: "); + result.append(oldStatus); + result.append(", timestamp: "); + result.append(timestamp); + result.append(')'); + return result.toString(); + } + +} //ActivityInstanceStatusEventImpl diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ActivityStatusEventImpl.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ActivityStatusEventImpl.java new file mode 100755 index 0000000..f63cd31 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ActivityStatusEventImpl.java @@ -0,0 +1,426 @@ +/** + */ +package at.ac.uibk.wfr.perftool.impl; + +import at.ac.uibk.wfr.perftool.Activity; +import at.ac.uibk.wfr.perftool.ActivityStatusEvent; +import at.ac.uibk.wfr.perftool.PerftoolPackage; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EcoreUtil; + +/** + * + * An implementation of the model object 'Activity Status Event'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityStatusEventImpl#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityStatusEventImpl#getNewStatus New Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityStatusEventImpl#getOldStatus Old Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityStatusEventImpl#getTimestamp Timestamp}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ActivityStatusEventImpl#getParentActivity Parent Activity}
      • + *
      + *

      + * + * @generated + */ +public class ActivityStatusEventImpl extends MinimalEObjectImpl.Container implements ActivityStatusEvent { + /** + * The default value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected static final int OID_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected int oid = OID_EDEFAULT; + + /** + * The default value of the '{@link #getNewStatus() New Status}' attribute. + * + * + * @see #getNewStatus() + * @generated + * @ordered + */ + protected static final String NEW_STATUS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getNewStatus() New Status}' attribute. + * + * + * @see #getNewStatus() + * @generated + * @ordered + */ + protected String newStatus = NEW_STATUS_EDEFAULT; + + /** + * The default value of the '{@link #getOldStatus() Old Status}' attribute. + * + * + * @see #getOldStatus() + * @generated + * @ordered + */ + protected static final String OLD_STATUS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getOldStatus() Old Status}' attribute. + * + * + * @see #getOldStatus() + * @generated + * @ordered + */ + protected String oldStatus = OLD_STATUS_EDEFAULT; + + /** + * The default value of the '{@link #getTimestamp() Timestamp}' attribute. + * + * + * @see #getTimestamp() + * @generated + * @ordered + */ + protected static final long TIMESTAMP_EDEFAULT = 0L; + + /** + * The cached value of the '{@link #getTimestamp() Timestamp}' attribute. + * + * + * @see #getTimestamp() + * @generated + * @ordered + */ + protected long timestamp = TIMESTAMP_EDEFAULT; + + /** + * + * + * @generated + */ + protected ActivityStatusEventImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return PerftoolPackage.Literals.ACTIVITY_STATUS_EVENT; + } + + /** + * + * + * @generated + */ + public int getOid() { + return oid; + } + + /** + * + * + * @generated + */ + public void setOid(int newOid) { + int oldOid = oid; + oid = newOid; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_STATUS_EVENT__OID, oldOid, oid)); + } + + /** + * + * + * @generated + */ + public String getNewStatus() { + return newStatus; + } + + /** + * + * + * @generated + */ + public void setNewStatus(String newNewStatus) { + String oldNewStatus = newStatus; + newStatus = newNewStatus; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_STATUS_EVENT__NEW_STATUS, oldNewStatus, newStatus)); + } + + /** + * + * + * @generated + */ + public String getOldStatus() { + return oldStatus; + } + + /** + * + * + * @generated + */ + public void setOldStatus(String newOldStatus) { + String oldOldStatus = oldStatus; + oldStatus = newOldStatus; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_STATUS_EVENT__OLD_STATUS, oldOldStatus, oldStatus)); + } + + /** + * + * + * @generated + */ + public long getTimestamp() { + return timestamp; + } + + /** + * + * + * @generated + */ + public void setTimestamp(long newTimestamp) { + long oldTimestamp = timestamp; + timestamp = newTimestamp; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_STATUS_EVENT__TIMESTAMP, oldTimestamp, timestamp)); + } + + /** + * + * + * @generated + */ + public Activity getParentActivity() { + if (eContainerFeatureID() != PerftoolPackage.ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY) return null; + return (Activity)eInternalContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetParentActivity(Activity newParentActivity, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject)newParentActivity, PerftoolPackage.ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + public void setParentActivity(Activity newParentActivity) { + if (newParentActivity != eInternalContainer() || (eContainerFeatureID() != PerftoolPackage.ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY && newParentActivity != null)) { + if (EcoreUtil.isAncestor(this, newParentActivity)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newParentActivity != null) + msgs = ((InternalEObject)newParentActivity).eInverseAdd(this, PerftoolPackage.ACTIVITY__STATUS_EVENTS, Activity.class, msgs); + msgs = basicSetParentActivity(newParentActivity, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY, newParentActivity, newParentActivity)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetParentActivity((Activity)otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY: + return basicSetParentActivity(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch (eContainerFeatureID()) { + case PerftoolPackage.ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY: + return eInternalContainer().eInverseRemove(this, PerftoolPackage.ACTIVITY__STATUS_EVENTS, Activity.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_STATUS_EVENT__OID: + return getOid(); + case PerftoolPackage.ACTIVITY_STATUS_EVENT__NEW_STATUS: + return getNewStatus(); + case PerftoolPackage.ACTIVITY_STATUS_EVENT__OLD_STATUS: + return getOldStatus(); + case PerftoolPackage.ACTIVITY_STATUS_EVENT__TIMESTAMP: + return getTimestamp(); + case PerftoolPackage.ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY: + return getParentActivity(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_STATUS_EVENT__OID: + setOid((Integer)newValue); + return; + case PerftoolPackage.ACTIVITY_STATUS_EVENT__NEW_STATUS: + setNewStatus((String)newValue); + return; + case PerftoolPackage.ACTIVITY_STATUS_EVENT__OLD_STATUS: + setOldStatus((String)newValue); + return; + case PerftoolPackage.ACTIVITY_STATUS_EVENT__TIMESTAMP: + setTimestamp((Long)newValue); + return; + case PerftoolPackage.ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY: + setParentActivity((Activity)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_STATUS_EVENT__OID: + setOid(OID_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY_STATUS_EVENT__NEW_STATUS: + setNewStatus(NEW_STATUS_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY_STATUS_EVENT__OLD_STATUS: + setOldStatus(OLD_STATUS_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY_STATUS_EVENT__TIMESTAMP: + setTimestamp(TIMESTAMP_EDEFAULT); + return; + case PerftoolPackage.ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY: + setParentActivity((Activity)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PerftoolPackage.ACTIVITY_STATUS_EVENT__OID: + return oid != OID_EDEFAULT; + case PerftoolPackage.ACTIVITY_STATUS_EVENT__NEW_STATUS: + return NEW_STATUS_EDEFAULT == null ? newStatus != null : !NEW_STATUS_EDEFAULT.equals(newStatus); + case PerftoolPackage.ACTIVITY_STATUS_EVENT__OLD_STATUS: + return OLD_STATUS_EDEFAULT == null ? oldStatus != null : !OLD_STATUS_EDEFAULT.equals(oldStatus); + case PerftoolPackage.ACTIVITY_STATUS_EVENT__TIMESTAMP: + return timestamp != TIMESTAMP_EDEFAULT; + case PerftoolPackage.ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY: + return getParentActivity() != null; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (oid: "); + result.append(oid); + result.append(", newStatus: "); + result.append(newStatus); + result.append(", oldStatus: "); + result.append(oldStatus); + result.append(", timestamp: "); + result.append(timestamp); + result.append(')'); + return result.toString(); + } + +} //ActivityStatusEventImpl diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ComponentStatusEventImpl.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ComponentStatusEventImpl.java new file mode 100755 index 0000000..555328c --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/ComponentStatusEventImpl.java @@ -0,0 +1,480 @@ +/** + */ +package at.ac.uibk.wfr.perftool.impl; + +import at.ac.uibk.wfr.perftool.ComponentStatusEvent; +import at.ac.uibk.wfr.perftool.PerftoolPackage; +import at.ac.uibk.wfr.perftool.Workflow; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EcoreUtil; + +/** + * + * An implementation of the model object 'Component Status Event'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.impl.ComponentStatusEventImpl#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ComponentStatusEventImpl#getComponentType Component Type}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ComponentStatusEventImpl#getNewStatus New Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ComponentStatusEventImpl#getOldStatus Old Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ComponentStatusEventImpl#getTimestamp Timestamp}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.ComponentStatusEventImpl#getWorkflow Workflow}
      • + *
      + *

      + * + * @generated + */ +public class ComponentStatusEventImpl extends MinimalEObjectImpl.Container implements ComponentStatusEvent { + /** + * The default value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected static final int OID_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected int oid = OID_EDEFAULT; + + /** + * The default value of the '{@link #getComponentType() Component Type}' attribute. + * + * + * @see #getComponentType() + * @generated + * @ordered + */ + protected static final String COMPONENT_TYPE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getComponentType() Component Type}' attribute. + * + * + * @see #getComponentType() + * @generated + * @ordered + */ + protected String componentType = COMPONENT_TYPE_EDEFAULT; + + /** + * The default value of the '{@link #getNewStatus() New Status}' attribute. + * + * + * @see #getNewStatus() + * @generated + * @ordered + */ + protected static final String NEW_STATUS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getNewStatus() New Status}' attribute. + * + * + * @see #getNewStatus() + * @generated + * @ordered + */ + protected String newStatus = NEW_STATUS_EDEFAULT; + + /** + * The default value of the '{@link #getOldStatus() Old Status}' attribute. + * + * + * @see #getOldStatus() + * @generated + * @ordered + */ + protected static final String OLD_STATUS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getOldStatus() Old Status}' attribute. + * + * + * @see #getOldStatus() + * @generated + * @ordered + */ + protected String oldStatus = OLD_STATUS_EDEFAULT; + + /** + * The default value of the '{@link #getTimestamp() Timestamp}' attribute. + * + * + * @see #getTimestamp() + * @generated + * @ordered + */ + protected static final long TIMESTAMP_EDEFAULT = 0L; + + /** + * The cached value of the '{@link #getTimestamp() Timestamp}' attribute. + * + * + * @see #getTimestamp() + * @generated + * @ordered + */ + protected long timestamp = TIMESTAMP_EDEFAULT; + + /** + * + * + * @generated + */ + protected ComponentStatusEventImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return PerftoolPackage.Literals.COMPONENT_STATUS_EVENT; + } + + /** + * + * + * @generated + */ + public int getOid() { + return oid; + } + + /** + * + * + * @generated + */ + public void setOid(int newOid) { + int oldOid = oid; + oid = newOid; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.COMPONENT_STATUS_EVENT__OID, oldOid, oid)); + } + + /** + * + * + * @generated + */ + public String getComponentType() { + return componentType; + } + + /** + * + * + * @generated + */ + public void setComponentType(String newComponentType) { + String oldComponentType = componentType; + componentType = newComponentType; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.COMPONENT_STATUS_EVENT__COMPONENT_TYPE, oldComponentType, componentType)); + } + + /** + * + * + * @generated + */ + public String getNewStatus() { + return newStatus; + } + + /** + * + * + * @generated + */ + public void setNewStatus(String newNewStatus) { + String oldNewStatus = newStatus; + newStatus = newNewStatus; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.COMPONENT_STATUS_EVENT__NEW_STATUS, oldNewStatus, newStatus)); + } + + /** + * + * + * @generated + */ + public String getOldStatus() { + return oldStatus; + } + + /** + * + * + * @generated + */ + public void setOldStatus(String newOldStatus) { + String oldOldStatus = oldStatus; + oldStatus = newOldStatus; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.COMPONENT_STATUS_EVENT__OLD_STATUS, oldOldStatus, oldStatus)); + } + + /** + * + * + * @generated + */ + public long getTimestamp() { + return timestamp; + } + + /** + * + * + * @generated + */ + public void setTimestamp(long newTimestamp) { + long oldTimestamp = timestamp; + timestamp = newTimestamp; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.COMPONENT_STATUS_EVENT__TIMESTAMP, oldTimestamp, timestamp)); + } + + /** + * + * + * @generated + */ + public Workflow getWorkflow() { + if (eContainerFeatureID() != PerftoolPackage.COMPONENT_STATUS_EVENT__WORKFLOW) return null; + return (Workflow)eInternalContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetWorkflow(Workflow newWorkflow, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject)newWorkflow, PerftoolPackage.COMPONENT_STATUS_EVENT__WORKFLOW, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + public void setWorkflow(Workflow newWorkflow) { + if (newWorkflow != eInternalContainer() || (eContainerFeatureID() != PerftoolPackage.COMPONENT_STATUS_EVENT__WORKFLOW && newWorkflow != null)) { + if (EcoreUtil.isAncestor(this, newWorkflow)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newWorkflow != null) + msgs = ((InternalEObject)newWorkflow).eInverseAdd(this, PerftoolPackage.WORKFLOW__COMPONENT_EVENTS, Workflow.class, msgs); + msgs = basicSetWorkflow(newWorkflow, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.COMPONENT_STATUS_EVENT__WORKFLOW, newWorkflow, newWorkflow)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.COMPONENT_STATUS_EVENT__WORKFLOW: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetWorkflow((Workflow)otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.COMPONENT_STATUS_EVENT__WORKFLOW: + return basicSetWorkflow(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch (eContainerFeatureID()) { + case PerftoolPackage.COMPONENT_STATUS_EVENT__WORKFLOW: + return eInternalContainer().eInverseRemove(this, PerftoolPackage.WORKFLOW__COMPONENT_EVENTS, Workflow.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PerftoolPackage.COMPONENT_STATUS_EVENT__OID: + return getOid(); + case PerftoolPackage.COMPONENT_STATUS_EVENT__COMPONENT_TYPE: + return getComponentType(); + case PerftoolPackage.COMPONENT_STATUS_EVENT__NEW_STATUS: + return getNewStatus(); + case PerftoolPackage.COMPONENT_STATUS_EVENT__OLD_STATUS: + return getOldStatus(); + case PerftoolPackage.COMPONENT_STATUS_EVENT__TIMESTAMP: + return getTimestamp(); + case PerftoolPackage.COMPONENT_STATUS_EVENT__WORKFLOW: + return getWorkflow(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case PerftoolPackage.COMPONENT_STATUS_EVENT__OID: + setOid((Integer)newValue); + return; + case PerftoolPackage.COMPONENT_STATUS_EVENT__COMPONENT_TYPE: + setComponentType((String)newValue); + return; + case PerftoolPackage.COMPONENT_STATUS_EVENT__NEW_STATUS: + setNewStatus((String)newValue); + return; + case PerftoolPackage.COMPONENT_STATUS_EVENT__OLD_STATUS: + setOldStatus((String)newValue); + return; + case PerftoolPackage.COMPONENT_STATUS_EVENT__TIMESTAMP: + setTimestamp((Long)newValue); + return; + case PerftoolPackage.COMPONENT_STATUS_EVENT__WORKFLOW: + setWorkflow((Workflow)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PerftoolPackage.COMPONENT_STATUS_EVENT__OID: + setOid(OID_EDEFAULT); + return; + case PerftoolPackage.COMPONENT_STATUS_EVENT__COMPONENT_TYPE: + setComponentType(COMPONENT_TYPE_EDEFAULT); + return; + case PerftoolPackage.COMPONENT_STATUS_EVENT__NEW_STATUS: + setNewStatus(NEW_STATUS_EDEFAULT); + return; + case PerftoolPackage.COMPONENT_STATUS_EVENT__OLD_STATUS: + setOldStatus(OLD_STATUS_EDEFAULT); + return; + case PerftoolPackage.COMPONENT_STATUS_EVENT__TIMESTAMP: + setTimestamp(TIMESTAMP_EDEFAULT); + return; + case PerftoolPackage.COMPONENT_STATUS_EVENT__WORKFLOW: + setWorkflow((Workflow)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PerftoolPackage.COMPONENT_STATUS_EVENT__OID: + return oid != OID_EDEFAULT; + case PerftoolPackage.COMPONENT_STATUS_EVENT__COMPONENT_TYPE: + return COMPONENT_TYPE_EDEFAULT == null ? componentType != null : !COMPONENT_TYPE_EDEFAULT.equals(componentType); + case PerftoolPackage.COMPONENT_STATUS_EVENT__NEW_STATUS: + return NEW_STATUS_EDEFAULT == null ? newStatus != null : !NEW_STATUS_EDEFAULT.equals(newStatus); + case PerftoolPackage.COMPONENT_STATUS_EVENT__OLD_STATUS: + return OLD_STATUS_EDEFAULT == null ? oldStatus != null : !OLD_STATUS_EDEFAULT.equals(oldStatus); + case PerftoolPackage.COMPONENT_STATUS_EVENT__TIMESTAMP: + return timestamp != TIMESTAMP_EDEFAULT; + case PerftoolPackage.COMPONENT_STATUS_EVENT__WORKFLOW: + return getWorkflow() != null; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (oid: "); + result.append(oid); + result.append(", componentType: "); + result.append(componentType); + result.append(", newStatus: "); + result.append(newStatus); + result.append(", oldStatus: "); + result.append(oldStatus); + result.append(", timestamp: "); + result.append(timestamp); + result.append(')'); + return result.toString(); + } + +} //ComponentStatusEventImpl diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/DeviceInstanceStatusEventImpl.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/DeviceInstanceStatusEventImpl.java new file mode 100755 index 0000000..6bbd7a4 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/DeviceInstanceStatusEventImpl.java @@ -0,0 +1,703 @@ +/** + */ +package at.ac.uibk.wfr.perftool.impl; + +import at.ac.uibk.wfr.perftool.ActivityInstance; +import at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent; +import at.ac.uibk.wfr.perftool.PerftoolPackage; +import at.ac.uibk.wfr.perftool.Workflow; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EcoreUtil; + +/** + * + * An implementation of the model object 'Device Instance Status Event'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.impl.DeviceInstanceStatusEventImpl#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.DeviceInstanceStatusEventImpl#getDeviceType Device Type}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.DeviceInstanceStatusEventImpl#getDeviceID Device ID}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.DeviceInstanceStatusEventImpl#getNewStatus New Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.DeviceInstanceStatusEventImpl#getOldStatus Old Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.DeviceInstanceStatusEventImpl#getTimestamp Timestamp}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.DeviceInstanceStatusEventImpl#getExecutedImplID Executed Impl ID}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.DeviceInstanceStatusEventImpl#getDeviceSlotCount Device Slot Count}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.DeviceInstanceStatusEventImpl#getParentWorkflow Parent Workflow}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.DeviceInstanceStatusEventImpl#getExecutedInstance Executed Instance}
      • + *
      + *

      + * + * @generated + */ +public class DeviceInstanceStatusEventImpl extends MinimalEObjectImpl.Container implements DeviceInstanceStatusEvent { + /** + * The default value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected static final int OID_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected int oid = OID_EDEFAULT; + + /** + * The default value of the '{@link #getDeviceType() Device Type}' attribute. + * + * + * @see #getDeviceType() + * @generated + * @ordered + */ + protected static final String DEVICE_TYPE_EDEFAULT = null; + + /** + * The cached value of the '{@link #getDeviceType() Device Type}' attribute. + * + * + * @see #getDeviceType() + * @generated + * @ordered + */ + protected String deviceType = DEVICE_TYPE_EDEFAULT; + + /** + * The default value of the '{@link #getDeviceID() Device ID}' attribute. + * + * + * @see #getDeviceID() + * @generated + * @ordered + */ + protected static final long DEVICE_ID_EDEFAULT = 0L; + + /** + * The cached value of the '{@link #getDeviceID() Device ID}' attribute. + * + * + * @see #getDeviceID() + * @generated + * @ordered + */ + protected long deviceID = DEVICE_ID_EDEFAULT; + + /** + * The default value of the '{@link #getNewStatus() New Status}' attribute. + * + * + * @see #getNewStatus() + * @generated + * @ordered + */ + protected static final String NEW_STATUS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getNewStatus() New Status}' attribute. + * + * + * @see #getNewStatus() + * @generated + * @ordered + */ + protected String newStatus = NEW_STATUS_EDEFAULT; + + /** + * The default value of the '{@link #getOldStatus() Old Status}' attribute. + * + * + * @see #getOldStatus() + * @generated + * @ordered + */ + protected static final String OLD_STATUS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getOldStatus() Old Status}' attribute. + * + * + * @see #getOldStatus() + * @generated + * @ordered + */ + protected String oldStatus = OLD_STATUS_EDEFAULT; + + /** + * The default value of the '{@link #getTimestamp() Timestamp}' attribute. + * + * + * @see #getTimestamp() + * @generated + * @ordered + */ + protected static final long TIMESTAMP_EDEFAULT = 0L; + + /** + * The cached value of the '{@link #getTimestamp() Timestamp}' attribute. + * + * + * @see #getTimestamp() + * @generated + * @ordered + */ + protected long timestamp = TIMESTAMP_EDEFAULT; + + /** + * The default value of the '{@link #getExecutedImplID() Executed Impl ID}' attribute. + * + * + * @see #getExecutedImplID() + * @generated + * @ordered + */ + protected static final long EXECUTED_IMPL_ID_EDEFAULT = 0L; + + /** + * The cached value of the '{@link #getExecutedImplID() Executed Impl ID}' attribute. + * + * + * @see #getExecutedImplID() + * @generated + * @ordered + */ + protected long executedImplID = EXECUTED_IMPL_ID_EDEFAULT; + + /** + * The default value of the '{@link #getDeviceSlotCount() Device Slot Count}' attribute. + * + * + * @see #getDeviceSlotCount() + * @generated + * @ordered + */ + protected static final long DEVICE_SLOT_COUNT_EDEFAULT = 0L; + + /** + * The cached value of the '{@link #getDeviceSlotCount() Device Slot Count}' attribute. + * + * + * @see #getDeviceSlotCount() + * @generated + * @ordered + */ + protected long deviceSlotCount = DEVICE_SLOT_COUNT_EDEFAULT; + + /** + * The cached value of the '{@link #getExecutedInstance() Executed Instance}' reference. + * + * + * @see #getExecutedInstance() + * @generated + * @ordered + */ + protected ActivityInstance executedInstance; + + /** + * + * + * @generated + */ + protected DeviceInstanceStatusEventImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return PerftoolPackage.Literals.DEVICE_INSTANCE_STATUS_EVENT; + } + + /** + * + * + * @generated + */ + public int getOid() { + return oid; + } + + /** + * + * + * @generated + */ + public void setOid(int newOid) { + int oldOid = oid; + oid = newOid; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__OID, oldOid, oid)); + } + + /** + * + * + * @generated + */ + public String getDeviceType() { + return deviceType; + } + + /** + * + * + * @generated + */ + public void setDeviceType(String newDeviceType) { + String oldDeviceType = deviceType; + deviceType = newDeviceType; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_TYPE, oldDeviceType, deviceType)); + } + + /** + * + * + * @generated + */ + public long getDeviceID() { + return deviceID; + } + + /** + * + * + * @generated + */ + public void setDeviceID(long newDeviceID) { + long oldDeviceID = deviceID; + deviceID = newDeviceID; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_ID, oldDeviceID, deviceID)); + } + + /** + * + * + * @generated + */ + public String getNewStatus() { + return newStatus; + } + + /** + * + * + * @generated + */ + public void setNewStatus(String newNewStatus) { + String oldNewStatus = newStatus; + newStatus = newNewStatus; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__NEW_STATUS, oldNewStatus, newStatus)); + } + + /** + * + * + * @generated + */ + public String getOldStatus() { + return oldStatus; + } + + /** + * + * + * @generated + */ + public void setOldStatus(String newOldStatus) { + String oldOldStatus = oldStatus; + oldStatus = newOldStatus; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__OLD_STATUS, oldOldStatus, oldStatus)); + } + + /** + * + * + * @generated + */ + public long getTimestamp() { + return timestamp; + } + + /** + * + * + * @generated + */ + public void setTimestamp(long newTimestamp) { + long oldTimestamp = timestamp; + timestamp = newTimestamp; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__TIMESTAMP, oldTimestamp, timestamp)); + } + + /** + * + * + * @generated + */ + public long getExecutedImplID() { + return executedImplID; + } + + /** + * + * + * @generated + */ + public void setExecutedImplID(long newExecutedImplID) { + long oldExecutedImplID = executedImplID; + executedImplID = newExecutedImplID; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_IMPL_ID, oldExecutedImplID, executedImplID)); + } + + /** + * + * + * @generated + */ + public long getDeviceSlotCount() { + return deviceSlotCount; + } + + /** + * + * + * @generated + */ + public void setDeviceSlotCount(long newDeviceSlotCount) { + long oldDeviceSlotCount = deviceSlotCount; + deviceSlotCount = newDeviceSlotCount; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_SLOT_COUNT, oldDeviceSlotCount, deviceSlotCount)); + } + + /** + * + * + * @generated + */ + public Workflow getParentWorkflow() { + if (eContainerFeatureID() != PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW) return null; + return (Workflow)eInternalContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetParentWorkflow(Workflow newParentWorkflow, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject)newParentWorkflow, PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + public void setParentWorkflow(Workflow newParentWorkflow) { + if (newParentWorkflow != eInternalContainer() || (eContainerFeatureID() != PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW && newParentWorkflow != null)) { + if (EcoreUtil.isAncestor(this, newParentWorkflow)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newParentWorkflow != null) + msgs = ((InternalEObject)newParentWorkflow).eInverseAdd(this, PerftoolPackage.WORKFLOW__DEVICE_EVENTS, Workflow.class, msgs); + msgs = basicSetParentWorkflow(newParentWorkflow, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW, newParentWorkflow, newParentWorkflow)); + } + + /** + * + * + * @generated + */ + public ActivityInstance getExecutedInstance() { + if (executedInstance != null && executedInstance.eIsProxy()) { + InternalEObject oldExecutedInstance = (InternalEObject)executedInstance; + executedInstance = (ActivityInstance)eResolveProxy(oldExecutedInstance); + if (executedInstance != oldExecutedInstance) { + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.RESOLVE, PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_INSTANCE, oldExecutedInstance, executedInstance)); + } + } + return executedInstance; + } + + /** + * + * + * @generated + */ + public ActivityInstance basicGetExecutedInstance() { + return executedInstance; + } + + /** + * + * + * @generated + */ + public void setExecutedInstance(ActivityInstance newExecutedInstance) { + ActivityInstance oldExecutedInstance = executedInstance; + executedInstance = newExecutedInstance; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_INSTANCE, oldExecutedInstance, executedInstance)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetParentWorkflow((Workflow)otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW: + return basicSetParentWorkflow(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch (eContainerFeatureID()) { + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW: + return eInternalContainer().eInverseRemove(this, PerftoolPackage.WORKFLOW__DEVICE_EVENTS, Workflow.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__OID: + return getOid(); + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_TYPE: + return getDeviceType(); + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_ID: + return getDeviceID(); + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__NEW_STATUS: + return getNewStatus(); + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__OLD_STATUS: + return getOldStatus(); + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__TIMESTAMP: + return getTimestamp(); + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_IMPL_ID: + return getExecutedImplID(); + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_SLOT_COUNT: + return getDeviceSlotCount(); + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW: + return getParentWorkflow(); + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_INSTANCE: + if (resolve) return getExecutedInstance(); + return basicGetExecutedInstance(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__OID: + setOid((Integer)newValue); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_TYPE: + setDeviceType((String)newValue); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_ID: + setDeviceID((Long)newValue); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__NEW_STATUS: + setNewStatus((String)newValue); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__OLD_STATUS: + setOldStatus((String)newValue); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__TIMESTAMP: + setTimestamp((Long)newValue); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_IMPL_ID: + setExecutedImplID((Long)newValue); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_SLOT_COUNT: + setDeviceSlotCount((Long)newValue); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW: + setParentWorkflow((Workflow)newValue); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_INSTANCE: + setExecutedInstance((ActivityInstance)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__OID: + setOid(OID_EDEFAULT); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_TYPE: + setDeviceType(DEVICE_TYPE_EDEFAULT); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_ID: + setDeviceID(DEVICE_ID_EDEFAULT); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__NEW_STATUS: + setNewStatus(NEW_STATUS_EDEFAULT); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__OLD_STATUS: + setOldStatus(OLD_STATUS_EDEFAULT); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__TIMESTAMP: + setTimestamp(TIMESTAMP_EDEFAULT); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_IMPL_ID: + setExecutedImplID(EXECUTED_IMPL_ID_EDEFAULT); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_SLOT_COUNT: + setDeviceSlotCount(DEVICE_SLOT_COUNT_EDEFAULT); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW: + setParentWorkflow((Workflow)null); + return; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_INSTANCE: + setExecutedInstance((ActivityInstance)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__OID: + return oid != OID_EDEFAULT; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_TYPE: + return DEVICE_TYPE_EDEFAULT == null ? deviceType != null : !DEVICE_TYPE_EDEFAULT.equals(deviceType); + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_ID: + return deviceID != DEVICE_ID_EDEFAULT; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__NEW_STATUS: + return NEW_STATUS_EDEFAULT == null ? newStatus != null : !NEW_STATUS_EDEFAULT.equals(newStatus); + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__OLD_STATUS: + return OLD_STATUS_EDEFAULT == null ? oldStatus != null : !OLD_STATUS_EDEFAULT.equals(oldStatus); + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__TIMESTAMP: + return timestamp != TIMESTAMP_EDEFAULT; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_IMPL_ID: + return executedImplID != EXECUTED_IMPL_ID_EDEFAULT; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__DEVICE_SLOT_COUNT: + return deviceSlotCount != DEVICE_SLOT_COUNT_EDEFAULT; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW: + return getParentWorkflow() != null; + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_INSTANCE: + return executedInstance != null; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (oid: "); + result.append(oid); + result.append(", deviceType: "); + result.append(deviceType); + result.append(", deviceID: "); + result.append(deviceID); + result.append(", newStatus: "); + result.append(newStatus); + result.append(", oldStatus: "); + result.append(oldStatus); + result.append(", timestamp: "); + result.append(timestamp); + result.append(", executedImplID: "); + result.append(executedImplID); + result.append(", deviceSlotCount: "); + result.append(deviceSlotCount); + result.append(')'); + return result.toString(); + } + +} //DeviceInstanceStatusEventImpl diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/PerftoolFactoryImpl.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/PerftoolFactoryImpl.java new file mode 100755 index 0000000..7d6b016 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/PerftoolFactoryImpl.java @@ -0,0 +1,172 @@ +/** + */ +package at.ac.uibk.wfr.perftool.impl; + +import at.ac.uibk.wfr.perftool.*; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.impl.EFactoryImpl; + +import org.eclipse.emf.ecore.plugin.EcorePlugin; + +/** + * + * An implementation of the model Factory. + * + * @generated + */ +public class PerftoolFactoryImpl extends EFactoryImpl implements PerftoolFactory { + /** + * Creates the default factory implementation. + * + * + * @generated + */ + public static PerftoolFactory init() { + try { + PerftoolFactory thePerftoolFactory = (PerftoolFactory)EPackage.Registry.INSTANCE.getEFactory(PerftoolPackage.eNS_URI); + if (thePerftoolFactory != null) { + return thePerftoolFactory; + } + } + catch (Exception exception) { + EcorePlugin.INSTANCE.log(exception); + } + return new PerftoolFactoryImpl(); + } + + /** + * Creates an instance of the factory. + * + * + * @generated + */ + public PerftoolFactoryImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + public EObject create(EClass eClass) { + switch (eClass.getClassifierID()) { + case PerftoolPackage.WORKFLOW: return createWorkflow(); + case PerftoolPackage.ACTIVITY: return createActivity(); + case PerftoolPackage.ACTIVITY_INSTANCE: return createActivityInstance(); + case PerftoolPackage.WORKFLOW_STATUS_EVENT: return createWorkflowStatusEvent(); + case PerftoolPackage.ACTIVITY_STATUS_EVENT: return createActivityStatusEvent(); + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT: return createActivityInstanceStatusEvent(); + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT: return createDeviceInstanceStatusEvent(); + case PerftoolPackage.COMPONENT_STATUS_EVENT: return createComponentStatusEvent(); + default: + throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); + } + } + + /** + * + * + * @generated + */ + public Workflow createWorkflow() { + WorkflowImpl workflow = new WorkflowImpl(); + return workflow; + } + + /** + * + * + * @generated + */ + public Activity createActivity() { + ActivityImpl activity = new ActivityImpl(); + return activity; + } + + /** + * + * + * @generated + */ + public ActivityInstance createActivityInstance() { + ActivityInstanceImpl activityInstance = new ActivityInstanceImpl(); + return activityInstance; + } + + /** + * + * + * @generated + */ + public WorkflowStatusEvent createWorkflowStatusEvent() { + WorkflowStatusEventImpl workflowStatusEvent = new WorkflowStatusEventImpl(); + return workflowStatusEvent; + } + + /** + * + * + * @generated + */ + public ActivityStatusEvent createActivityStatusEvent() { + ActivityStatusEventImpl activityStatusEvent = new ActivityStatusEventImpl(); + return activityStatusEvent; + } + + /** + * + * + * @generated + */ + public ActivityInstanceStatusEvent createActivityInstanceStatusEvent() { + ActivityInstanceStatusEventImpl activityInstanceStatusEvent = new ActivityInstanceStatusEventImpl(); + return activityInstanceStatusEvent; + } + + /** + * + * + * @generated + */ + public DeviceInstanceStatusEvent createDeviceInstanceStatusEvent() { + DeviceInstanceStatusEventImpl deviceInstanceStatusEvent = new DeviceInstanceStatusEventImpl(); + return deviceInstanceStatusEvent; + } + + /** + * + * + * @generated + */ + public ComponentStatusEvent createComponentStatusEvent() { + ComponentStatusEventImpl componentStatusEvent = new ComponentStatusEventImpl(); + return componentStatusEvent; + } + + /** + * + * + * @generated + */ + public PerftoolPackage getPerftoolPackage() { + return (PerftoolPackage)getEPackage(); + } + + /** + * + * + * @deprecated + * @generated + */ + @Deprecated + public static PerftoolPackage getPackage() { + return PerftoolPackage.eINSTANCE; + } + +} //PerftoolFactoryImpl diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/PerftoolPackageImpl.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/PerftoolPackageImpl.java new file mode 100755 index 0000000..af53204 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/PerftoolPackageImpl.java @@ -0,0 +1,930 @@ +/** + */ +package at.ac.uibk.wfr.perftool.impl; + +import at.ac.uibk.wfr.perftool.Activity; +import at.ac.uibk.wfr.perftool.ActivityInstance; +import at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent; +import at.ac.uibk.wfr.perftool.ActivityStatusEvent; +import at.ac.uibk.wfr.perftool.ComponentStatusEvent; +import at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent; +import at.ac.uibk.wfr.perftool.PerftoolFactory; +import at.ac.uibk.wfr.perftool.PerftoolPackage; +import at.ac.uibk.wfr.perftool.Workflow; + +import at.ac.uibk.wfr.perftool.WorkflowStatusEvent; +import org.eclipse.emf.ecore.EAttribute; +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.ecore.EReference; + +import org.eclipse.emf.ecore.impl.EPackageImpl; + +/** + * + * An implementation of the model Package. + * + * @generated + */ +public class PerftoolPackageImpl extends EPackageImpl implements PerftoolPackage { + /** + * + * + * @generated + */ + private EClass workflowEClass = null; + + /** + * + * + * @generated + */ + private EClass activityEClass = null; + + /** + * + * + * @generated + */ + private EClass activityInstanceEClass = null; + + /** + * + * + * @generated + */ + private EClass workflowStatusEventEClass = null; + + /** + * + * + * @generated + */ + private EClass activityStatusEventEClass = null; + + /** + * + * + * @generated + */ + private EClass activityInstanceStatusEventEClass = null; + + /** + * + * + * @generated + */ + private EClass deviceInstanceStatusEventEClass = null; + + /** + * + * + * @generated + */ + private EClass componentStatusEventEClass = null; + + /** + * Creates an instance of the model Package, registered with + * {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package + * package URI value. + *

      Note: the correct way to create the package is via the static + * factory method {@link #init init()}, which also performs + * initialization of the package, or returns the registered package, + * if one already exists. + * + * + * @see org.eclipse.emf.ecore.EPackage.Registry + * @see at.ac.uibk.wfr.perftool.PerftoolPackage#eNS_URI + * @see #init() + * @generated + */ + private PerftoolPackageImpl() { + super(eNS_URI, PerftoolFactory.eINSTANCE); + } + + /** + * + * + * @generated + */ + private static boolean isInited = false; + + /** + * Creates, registers, and initializes the Package for this model, and for any others upon which it depends. + * + *

      This method is used to initialize {@link PerftoolPackage#eINSTANCE} when that field is accessed. + * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package. + * + * + * @see #eNS_URI + * @see #createPackageContents() + * @see #initializePackageContents() + * @generated + */ + public static PerftoolPackage init() { + if (isInited) return (PerftoolPackage)EPackage.Registry.INSTANCE.getEPackage(PerftoolPackage.eNS_URI); + + // Obtain or create and register package + PerftoolPackageImpl thePerftoolPackage = (PerftoolPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof PerftoolPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new PerftoolPackageImpl()); + + isInited = true; + + // Create package meta-data objects + thePerftoolPackage.createPackageContents(); + + // Initialize created meta-data + thePerftoolPackage.initializePackageContents(); + + // Mark meta-data to indicate it can't be changed + thePerftoolPackage.freeze(); + + + // Update the registry and return the package + EPackage.Registry.INSTANCE.put(PerftoolPackage.eNS_URI, thePerftoolPackage); + return thePerftoolPackage; + } + + /** + * + * + * @generated + */ + public EClass getWorkflow() { + return workflowEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getWorkflow_Oid() { + return (EAttribute)workflowEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getWorkflow_Wfid() { + return (EAttribute)workflowEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EAttribute getWorkflow_Uuid() { + return (EAttribute)workflowEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EAttribute getWorkflow_Name() { + return (EAttribute)workflowEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + public EReference getWorkflow_ToplevelActivity() { + return (EReference)workflowEClass.getEStructuralFeatures().get(4); + } + + /** + * + * + * @generated + */ + public EReference getWorkflow_StatusEvents() { + return (EReference)workflowEClass.getEStructuralFeatures().get(5); + } + + /** + * + * + * @generated + */ + public EReference getWorkflow_DeviceEvents() { + return (EReference)workflowEClass.getEStructuralFeatures().get(6); + } + + /** + * + * + * @generated + */ + public EReference getWorkflow_ComponentEvents() { + return (EReference)workflowEClass.getEStructuralFeatures().get(7); + } + + /** + * + * + * @generated + */ + public EClass getActivity() { + return activityEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getActivity_Oid() { + return (EAttribute)activityEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getActivity_Actid() { + return (EAttribute)activityEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EAttribute getActivity_Name() { + return (EAttribute)activityEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EAttribute getActivity_Type() { + return (EAttribute)activityEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + public EAttribute getActivity_BranchID() { + return (EAttribute)activityEClass.getEStructuralFeatures().get(4); + } + + /** + * + * + * @generated + */ + public EReference getActivity_ParentWorkflow() { + return (EReference)activityEClass.getEStructuralFeatures().get(5); + } + + /** + * + * + * @generated + */ + public EReference getActivity_Instances() { + return (EReference)activityEClass.getEStructuralFeatures().get(6); + } + + /** + * + * + * @generated + */ + public EReference getActivity_StatusEvents() { + return (EReference)activityEClass.getEStructuralFeatures().get(7); + } + + /** + * + * + * @generated + */ + public EReference getActivity_Parent() { + return (EReference)activityEClass.getEStructuralFeatures().get(8); + } + + /** + * + * + * @generated + */ + public EReference getActivity_Children() { + return (EReference)activityEClass.getEStructuralFeatures().get(9); + } + + /** + * + * + * @generated + */ + public EClass getActivityInstance() { + return activityInstanceEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getActivityInstance_Oid() { + return (EAttribute)activityInstanceEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getActivityInstance_Instid() { + return (EAttribute)activityInstanceEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EAttribute getActivityInstance_IterationID() { + return (EAttribute)activityInstanceEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EReference getActivityInstance_BaseActivity() { + return (EReference)activityInstanceEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + public EReference getActivityInstance_ParentWorkflow() { + return (EReference)activityInstanceEClass.getEStructuralFeatures().get(4); + } + + /** + * + * + * @generated + */ + public EReference getActivityInstance_ParentInstance() { + return (EReference)activityInstanceEClass.getEStructuralFeatures().get(5); + } + + /** + * + * + * @generated + */ + public EReference getActivityInstance_StatusEvents() { + return (EReference)activityInstanceEClass.getEStructuralFeatures().get(6); + } + + /** + * + * + * @generated + */ + public EClass getWorkflowStatusEvent() { + return workflowStatusEventEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getWorkflowStatusEvent_Oid() { + return (EAttribute)workflowStatusEventEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getWorkflowStatusEvent_NewStatus() { + return (EAttribute)workflowStatusEventEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EAttribute getWorkflowStatusEvent_OldStatus() { + return (EAttribute)workflowStatusEventEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EAttribute getWorkflowStatusEvent_Timestamp() { + return (EAttribute)workflowStatusEventEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + public EReference getWorkflowStatusEvent_ParentWorkflow() { + return (EReference)workflowStatusEventEClass.getEStructuralFeatures().get(4); + } + + /** + * + * + * @generated + */ + public EClass getActivityStatusEvent() { + return activityStatusEventEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getActivityStatusEvent_Oid() { + return (EAttribute)activityStatusEventEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getActivityStatusEvent_NewStatus() { + return (EAttribute)activityStatusEventEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EAttribute getActivityStatusEvent_OldStatus() { + return (EAttribute)activityStatusEventEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EAttribute getActivityStatusEvent_Timestamp() { + return (EAttribute)activityStatusEventEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + public EReference getActivityStatusEvent_ParentActivity() { + return (EReference)activityStatusEventEClass.getEStructuralFeatures().get(4); + } + + /** + * + * + * @generated + */ + public EClass getActivityInstanceStatusEvent() { + return activityInstanceStatusEventEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getActivityInstanceStatusEvent_Oid() { + return (EAttribute)activityInstanceStatusEventEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getActivityInstanceStatusEvent_NewStatus() { + return (EAttribute)activityInstanceStatusEventEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EAttribute getActivityInstanceStatusEvent_OldStatus() { + return (EAttribute)activityInstanceStatusEventEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EAttribute getActivityInstanceStatusEvent_Timestamp() { + return (EAttribute)activityInstanceStatusEventEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + public EReference getActivityInstanceStatusEvent_ParentInstance() { + return (EReference)activityInstanceStatusEventEClass.getEStructuralFeatures().get(4); + } + + /** + * + * + * @generated + */ + public EClass getDeviceInstanceStatusEvent() { + return deviceInstanceStatusEventEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getDeviceInstanceStatusEvent_Oid() { + return (EAttribute)deviceInstanceStatusEventEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getDeviceInstanceStatusEvent_DeviceType() { + return (EAttribute)deviceInstanceStatusEventEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EAttribute getDeviceInstanceStatusEvent_DeviceID() { + return (EAttribute)deviceInstanceStatusEventEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EAttribute getDeviceInstanceStatusEvent_NewStatus() { + return (EAttribute)deviceInstanceStatusEventEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + public EAttribute getDeviceInstanceStatusEvent_OldStatus() { + return (EAttribute)deviceInstanceStatusEventEClass.getEStructuralFeatures().get(4); + } + + /** + * + * + * @generated + */ + public EAttribute getDeviceInstanceStatusEvent_Timestamp() { + return (EAttribute)deviceInstanceStatusEventEClass.getEStructuralFeatures().get(5); + } + + /** + * + * + * @generated + */ + public EAttribute getDeviceInstanceStatusEvent_ExecutedImplID() { + return (EAttribute)deviceInstanceStatusEventEClass.getEStructuralFeatures().get(6); + } + + /** + * + * + * @generated + */ + public EAttribute getDeviceInstanceStatusEvent_DeviceSlotCount() { + return (EAttribute)deviceInstanceStatusEventEClass.getEStructuralFeatures().get(7); + } + + /** + * + * + * @generated + */ + public EReference getDeviceInstanceStatusEvent_ParentWorkflow() { + return (EReference)deviceInstanceStatusEventEClass.getEStructuralFeatures().get(8); + } + + /** + * + * + * @generated + */ + public EReference getDeviceInstanceStatusEvent_ExecutedInstance() { + return (EReference)deviceInstanceStatusEventEClass.getEStructuralFeatures().get(9); + } + + /** + * + * + * @generated + */ + public EClass getComponentStatusEvent() { + return componentStatusEventEClass; + } + + /** + * + * + * @generated + */ + public EAttribute getComponentStatusEvent_Oid() { + return (EAttribute)componentStatusEventEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * @generated + */ + public EAttribute getComponentStatusEvent_ComponentType() { + return (EAttribute)componentStatusEventEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * @generated + */ + public EAttribute getComponentStatusEvent_NewStatus() { + return (EAttribute)componentStatusEventEClass.getEStructuralFeatures().get(2); + } + + /** + * + * + * @generated + */ + public EAttribute getComponentStatusEvent_OldStatus() { + return (EAttribute)componentStatusEventEClass.getEStructuralFeatures().get(3); + } + + /** + * + * + * @generated + */ + public EAttribute getComponentStatusEvent_Timestamp() { + return (EAttribute)componentStatusEventEClass.getEStructuralFeatures().get(4); + } + + /** + * + * + * @generated + */ + public EReference getComponentStatusEvent_Workflow() { + return (EReference)componentStatusEventEClass.getEStructuralFeatures().get(5); + } + + /** + * + * + * @generated + */ + public PerftoolFactory getPerftoolFactory() { + return (PerftoolFactory)getEFactoryInstance(); + } + + /** + * + * + * @generated + */ + private boolean isCreated = false; + + /** + * Creates the meta-model objects for the package. This method is + * guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void createPackageContents() { + if (isCreated) return; + isCreated = true; + + // Create classes and their features + workflowEClass = createEClass(WORKFLOW); + createEAttribute(workflowEClass, WORKFLOW__OID); + createEAttribute(workflowEClass, WORKFLOW__WFID); + createEAttribute(workflowEClass, WORKFLOW__UUID); + createEAttribute(workflowEClass, WORKFLOW__NAME); + createEReference(workflowEClass, WORKFLOW__TOPLEVEL_ACTIVITY); + createEReference(workflowEClass, WORKFLOW__STATUS_EVENTS); + createEReference(workflowEClass, WORKFLOW__DEVICE_EVENTS); + createEReference(workflowEClass, WORKFLOW__COMPONENT_EVENTS); + + activityEClass = createEClass(ACTIVITY); + createEAttribute(activityEClass, ACTIVITY__OID); + createEAttribute(activityEClass, ACTIVITY__ACTID); + createEAttribute(activityEClass, ACTIVITY__NAME); + createEAttribute(activityEClass, ACTIVITY__TYPE); + createEAttribute(activityEClass, ACTIVITY__BRANCH_ID); + createEReference(activityEClass, ACTIVITY__PARENT_WORKFLOW); + createEReference(activityEClass, ACTIVITY__INSTANCES); + createEReference(activityEClass, ACTIVITY__STATUS_EVENTS); + createEReference(activityEClass, ACTIVITY__PARENT); + createEReference(activityEClass, ACTIVITY__CHILDREN); + + activityInstanceEClass = createEClass(ACTIVITY_INSTANCE); + createEAttribute(activityInstanceEClass, ACTIVITY_INSTANCE__OID); + createEAttribute(activityInstanceEClass, ACTIVITY_INSTANCE__INSTID); + createEAttribute(activityInstanceEClass, ACTIVITY_INSTANCE__ITERATION_ID); + createEReference(activityInstanceEClass, ACTIVITY_INSTANCE__BASE_ACTIVITY); + createEReference(activityInstanceEClass, ACTIVITY_INSTANCE__PARENT_WORKFLOW); + createEReference(activityInstanceEClass, ACTIVITY_INSTANCE__PARENT_INSTANCE); + createEReference(activityInstanceEClass, ACTIVITY_INSTANCE__STATUS_EVENTS); + + workflowStatusEventEClass = createEClass(WORKFLOW_STATUS_EVENT); + createEAttribute(workflowStatusEventEClass, WORKFLOW_STATUS_EVENT__OID); + createEAttribute(workflowStatusEventEClass, WORKFLOW_STATUS_EVENT__NEW_STATUS); + createEAttribute(workflowStatusEventEClass, WORKFLOW_STATUS_EVENT__OLD_STATUS); + createEAttribute(workflowStatusEventEClass, WORKFLOW_STATUS_EVENT__TIMESTAMP); + createEReference(workflowStatusEventEClass, WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW); + + activityStatusEventEClass = createEClass(ACTIVITY_STATUS_EVENT); + createEAttribute(activityStatusEventEClass, ACTIVITY_STATUS_EVENT__OID); + createEAttribute(activityStatusEventEClass, ACTIVITY_STATUS_EVENT__NEW_STATUS); + createEAttribute(activityStatusEventEClass, ACTIVITY_STATUS_EVENT__OLD_STATUS); + createEAttribute(activityStatusEventEClass, ACTIVITY_STATUS_EVENT__TIMESTAMP); + createEReference(activityStatusEventEClass, ACTIVITY_STATUS_EVENT__PARENT_ACTIVITY); + + activityInstanceStatusEventEClass = createEClass(ACTIVITY_INSTANCE_STATUS_EVENT); + createEAttribute(activityInstanceStatusEventEClass, ACTIVITY_INSTANCE_STATUS_EVENT__OID); + createEAttribute(activityInstanceStatusEventEClass, ACTIVITY_INSTANCE_STATUS_EVENT__NEW_STATUS); + createEAttribute(activityInstanceStatusEventEClass, ACTIVITY_INSTANCE_STATUS_EVENT__OLD_STATUS); + createEAttribute(activityInstanceStatusEventEClass, ACTIVITY_INSTANCE_STATUS_EVENT__TIMESTAMP); + createEReference(activityInstanceStatusEventEClass, ACTIVITY_INSTANCE_STATUS_EVENT__PARENT_INSTANCE); + + deviceInstanceStatusEventEClass = createEClass(DEVICE_INSTANCE_STATUS_EVENT); + createEAttribute(deviceInstanceStatusEventEClass, DEVICE_INSTANCE_STATUS_EVENT__OID); + createEAttribute(deviceInstanceStatusEventEClass, DEVICE_INSTANCE_STATUS_EVENT__DEVICE_TYPE); + createEAttribute(deviceInstanceStatusEventEClass, DEVICE_INSTANCE_STATUS_EVENT__DEVICE_ID); + createEAttribute(deviceInstanceStatusEventEClass, DEVICE_INSTANCE_STATUS_EVENT__NEW_STATUS); + createEAttribute(deviceInstanceStatusEventEClass, DEVICE_INSTANCE_STATUS_EVENT__OLD_STATUS); + createEAttribute(deviceInstanceStatusEventEClass, DEVICE_INSTANCE_STATUS_EVENT__TIMESTAMP); + createEAttribute(deviceInstanceStatusEventEClass, DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_IMPL_ID); + createEAttribute(deviceInstanceStatusEventEClass, DEVICE_INSTANCE_STATUS_EVENT__DEVICE_SLOT_COUNT); + createEReference(deviceInstanceStatusEventEClass, DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW); + createEReference(deviceInstanceStatusEventEClass, DEVICE_INSTANCE_STATUS_EVENT__EXECUTED_INSTANCE); + + componentStatusEventEClass = createEClass(COMPONENT_STATUS_EVENT); + createEAttribute(componentStatusEventEClass, COMPONENT_STATUS_EVENT__OID); + createEAttribute(componentStatusEventEClass, COMPONENT_STATUS_EVENT__COMPONENT_TYPE); + createEAttribute(componentStatusEventEClass, COMPONENT_STATUS_EVENT__NEW_STATUS); + createEAttribute(componentStatusEventEClass, COMPONENT_STATUS_EVENT__OLD_STATUS); + createEAttribute(componentStatusEventEClass, COMPONENT_STATUS_EVENT__TIMESTAMP); + createEReference(componentStatusEventEClass, COMPONENT_STATUS_EVENT__WORKFLOW); + } + + /** + * + * + * @generated + */ + private boolean isInitialized = false; + + /** + * Complete the initialization of the package and its meta-model. This + * method is guarded to have no affect on any invocation but its first. + * + * + * @generated + */ + public void initializePackageContents() { + if (isInitialized) return; + isInitialized = true; + + // Initialize package + setName(eNAME); + setNsPrefix(eNS_PREFIX); + setNsURI(eNS_URI); + + // Create type parameters + + // Set bounds for type parameters + + // Add supertypes to classes + + // Initialize classes, features, and operations; add parameters + initEClass(workflowEClass, Workflow.class, "Workflow", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getWorkflow_Oid(), ecorePackage.getEInt(), "oid", null, 1, 1, Workflow.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getWorkflow_Wfid(), ecorePackage.getELong(), "wfid", null, 1, 1, Workflow.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getWorkflow_Uuid(), ecorePackage.getEString(), "uuid", null, 1, 1, Workflow.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getWorkflow_Name(), ecorePackage.getEString(), "name", null, 1, 1, Workflow.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getWorkflow_ToplevelActivity(), this.getActivity(), null, "toplevelActivity", null, 0, 1, Workflow.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getWorkflow_StatusEvents(), this.getWorkflowStatusEvent(), this.getWorkflowStatusEvent_ParentWorkflow(), "statusEvents", null, 0, -1, Workflow.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + initEReference(getWorkflow_DeviceEvents(), this.getDeviceInstanceStatusEvent(), this.getDeviceInstanceStatusEvent_ParentWorkflow(), "deviceEvents", null, 0, -1, Workflow.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + initEReference(getWorkflow_ComponentEvents(), this.getComponentStatusEvent(), this.getComponentStatusEvent_Workflow(), "componentEvents", null, 0, -1, Workflow.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + + initEClass(activityEClass, Activity.class, "Activity", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getActivity_Oid(), ecorePackage.getEInt(), "oid", null, 1, 1, Activity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getActivity_Actid(), ecorePackage.getELong(), "actid", null, 1, 1, Activity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getActivity_Name(), ecorePackage.getEString(), "name", null, 1, 1, Activity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getActivity_Type(), ecorePackage.getEString(), "type", null, 1, 1, Activity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getActivity_BranchID(), ecorePackage.getELong(), "branchID", null, 1, 1, Activity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getActivity_ParentWorkflow(), this.getWorkflow(), null, "parentWorkflow", null, 1, 1, Activity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + initEReference(getActivity_Instances(), this.getActivityInstance(), this.getActivityInstance_BaseActivity(), "instances", null, 0, -1, Activity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + initEReference(getActivity_StatusEvents(), this.getActivityStatusEvent(), this.getActivityStatusEvent_ParentActivity(), "statusEvents", null, 0, -1, Activity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + initEReference(getActivity_Parent(), this.getActivity(), this.getActivity_Children(), "parent", null, 0, 1, Activity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getActivity_Children(), this.getActivity(), this.getActivity_Parent(), "children", null, 0, -1, Activity.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + + initEClass(activityInstanceEClass, ActivityInstance.class, "ActivityInstance", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getActivityInstance_Oid(), ecorePackage.getEInt(), "oid", null, 1, 1, ActivityInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getActivityInstance_Instid(), ecorePackage.getELong(), "instid", null, 1, 1, ActivityInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getActivityInstance_IterationID(), ecorePackage.getELong(), "iterationID", null, 1, 1, ActivityInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getActivityInstance_BaseActivity(), this.getActivity(), this.getActivity_Instances(), "baseActivity", null, 1, 1, ActivityInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getActivityInstance_ParentWorkflow(), this.getWorkflow(), null, "parentWorkflow", null, 0, 1, ActivityInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getActivityInstance_ParentInstance(), this.getActivityInstance(), null, "parentInstance", null, 0, 1, ActivityInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getActivityInstance_StatusEvents(), this.getActivityInstanceStatusEvent(), this.getActivityInstanceStatusEvent_ParentInstance(), "statusEvents", null, 0, -1, ActivityInstance.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, !IS_ORDERED); + + initEClass(workflowStatusEventEClass, WorkflowStatusEvent.class, "WorkflowStatusEvent", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getWorkflowStatusEvent_Oid(), ecorePackage.getEInt(), "oid", null, 1, 1, WorkflowStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getWorkflowStatusEvent_NewStatus(), ecorePackage.getEString(), "newStatus", null, 1, 1, WorkflowStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getWorkflowStatusEvent_OldStatus(), ecorePackage.getEString(), "oldStatus", null, 1, 1, WorkflowStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getWorkflowStatusEvent_Timestamp(), ecorePackage.getELong(), "timestamp", null, 1, 1, WorkflowStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getWorkflowStatusEvent_ParentWorkflow(), this.getWorkflow(), this.getWorkflow_StatusEvents(), "parentWorkflow", null, 1, 1, WorkflowStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(activityStatusEventEClass, ActivityStatusEvent.class, "ActivityStatusEvent", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getActivityStatusEvent_Oid(), ecorePackage.getEInt(), "oid", null, 1, 1, ActivityStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getActivityStatusEvent_NewStatus(), ecorePackage.getEString(), "newStatus", null, 1, 1, ActivityStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getActivityStatusEvent_OldStatus(), ecorePackage.getEString(), "oldStatus", null, 1, 1, ActivityStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getActivityStatusEvent_Timestamp(), ecorePackage.getELong(), "timestamp", null, 1, 1, ActivityStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getActivityStatusEvent_ParentActivity(), this.getActivity(), this.getActivity_StatusEvents(), "parentActivity", null, 1, 1, ActivityStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(activityInstanceStatusEventEClass, ActivityInstanceStatusEvent.class, "ActivityInstanceStatusEvent", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getActivityInstanceStatusEvent_Oid(), ecorePackage.getEInt(), "oid", null, 1, 1, ActivityInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getActivityInstanceStatusEvent_NewStatus(), ecorePackage.getEString(), "newStatus", null, 1, 1, ActivityInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getActivityInstanceStatusEvent_OldStatus(), ecorePackage.getEString(), "oldStatus", null, 1, 1, ActivityInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getActivityInstanceStatusEvent_Timestamp(), ecorePackage.getELong(), "timestamp", null, 1, 1, ActivityInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getActivityInstanceStatusEvent_ParentInstance(), this.getActivityInstance(), this.getActivityInstance_StatusEvents(), "parentInstance", null, 1, 1, ActivityInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(deviceInstanceStatusEventEClass, DeviceInstanceStatusEvent.class, "DeviceInstanceStatusEvent", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getDeviceInstanceStatusEvent_Oid(), ecorePackage.getEInt(), "oid", null, 1, 1, DeviceInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDeviceInstanceStatusEvent_DeviceType(), ecorePackage.getEString(), "deviceType", null, 1, 1, DeviceInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDeviceInstanceStatusEvent_DeviceID(), ecorePackage.getELong(), "deviceID", null, 1, 1, DeviceInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDeviceInstanceStatusEvent_NewStatus(), ecorePackage.getEString(), "newStatus", null, 1, 1, DeviceInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDeviceInstanceStatusEvent_OldStatus(), ecorePackage.getEString(), "oldStatus", null, 1, 1, DeviceInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDeviceInstanceStatusEvent_Timestamp(), ecorePackage.getELong(), "timestamp", null, 1, 1, DeviceInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDeviceInstanceStatusEvent_ExecutedImplID(), ecorePackage.getELong(), "executedImplID", null, 1, 1, DeviceInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getDeviceInstanceStatusEvent_DeviceSlotCount(), ecorePackage.getELong(), "deviceSlotCount", null, 1, 1, DeviceInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDeviceInstanceStatusEvent_ParentWorkflow(), this.getWorkflow(), this.getWorkflow_DeviceEvents(), "parentWorkflow", null, 0, 1, DeviceInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getDeviceInstanceStatusEvent_ExecutedInstance(), this.getActivityInstance(), null, "executedInstance", null, 0, 1, DeviceInstanceStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + initEClass(componentStatusEventEClass, ComponentStatusEvent.class, "ComponentStatusEvent", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEAttribute(getComponentStatusEvent_Oid(), ecorePackage.getEInt(), "oid", null, 1, 1, ComponentStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getComponentStatusEvent_ComponentType(), ecorePackage.getEString(), "componentType", null, 1, 1, ComponentStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getComponentStatusEvent_NewStatus(), ecorePackage.getEString(), "newStatus", null, 1, 1, ComponentStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getComponentStatusEvent_OldStatus(), ecorePackage.getEString(), "oldStatus", null, 1, 1, ComponentStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getComponentStatusEvent_Timestamp(), ecorePackage.getELong(), "timestamp", null, 1, 1, ComponentStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEReference(getComponentStatusEvent_Workflow(), this.getWorkflow(), this.getWorkflow_ComponentEvents(), "workflow", null, 0, 1, ComponentStatusEvent.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + + // Create resource + createResource(eNS_URI); + } + +} //PerftoolPackageImpl diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/WorkflowImpl.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/WorkflowImpl.java new file mode 100755 index 0000000..4d220a4 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/WorkflowImpl.java @@ -0,0 +1,544 @@ +/** + */ +package at.ac.uibk.wfr.perftool.impl; + +import at.ac.uibk.wfr.perftool.Activity; +import at.ac.uibk.wfr.perftool.ComponentStatusEvent; +import at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent; +import at.ac.uibk.wfr.perftool.PerftoolPackage; +import at.ac.uibk.wfr.perftool.Workflow; + +import at.ac.uibk.wfr.perftool.WorkflowStatusEvent; +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList; +import org.eclipse.emf.ecore.util.InternalEList; + +/** + * + * An implementation of the model object 'Workflow'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.impl.WorkflowImpl#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.WorkflowImpl#getWfid Wfid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.WorkflowImpl#getUuid Uuid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.WorkflowImpl#getName Name}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.WorkflowImpl#getToplevelActivity Toplevel Activity}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.WorkflowImpl#getStatusEvents Status Events}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.WorkflowImpl#getDeviceEvents Device Events}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.WorkflowImpl#getComponentEvents Component Events}
      • + *
      + *

      + * + * @generated + */ +public class WorkflowImpl extends MinimalEObjectImpl.Container implements Workflow { + /** + * The default value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected static final int OID_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected int oid = OID_EDEFAULT; + + /** + * The default value of the '{@link #getWfid() Wfid}' attribute. + * + * + * @see #getWfid() + * @generated + * @ordered + */ + protected static final long WFID_EDEFAULT = 0L; + + /** + * The cached value of the '{@link #getWfid() Wfid}' attribute. + * + * + * @see #getWfid() + * @generated + * @ordered + */ + protected long wfid = WFID_EDEFAULT; + + /** + * The default value of the '{@link #getUuid() Uuid}' attribute. + * + * + * @see #getUuid() + * @generated + * @ordered + */ + protected static final String UUID_EDEFAULT = null; + + /** + * The cached value of the '{@link #getUuid() Uuid}' attribute. + * + * + * @see #getUuid() + * @generated + * @ordered + */ + protected String uuid = UUID_EDEFAULT; + + /** + * The default value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() Name}' attribute. + * + * + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * The cached value of the '{@link #getToplevelActivity() Toplevel Activity}' containment reference. + * + * + * @see #getToplevelActivity() + * @generated + * @ordered + */ + protected Activity toplevelActivity; + + /** + * The cached value of the '{@link #getStatusEvents() Status Events}' containment reference list. + * + * + * @see #getStatusEvents() + * @generated + * @ordered + */ + protected EList statusEvents; + + /** + * The cached value of the '{@link #getDeviceEvents() Device Events}' containment reference list. + * + * + * @see #getDeviceEvents() + * @generated + * @ordered + */ + protected EList deviceEvents; + + /** + * The cached value of the '{@link #getComponentEvents() Component Events}' containment reference list. + * + * + * @see #getComponentEvents() + * @generated + * @ordered + */ + protected EList componentEvents; + + /** + * + * + * @generated + */ + protected WorkflowImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return PerftoolPackage.Literals.WORKFLOW; + } + + /** + * + * + * @generated + */ + public int getOid() { + return oid; + } + + /** + * + * + * @generated + */ + public void setOid(int newOid) { + int oldOid = oid; + oid = newOid; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.WORKFLOW__OID, oldOid, oid)); + } + + /** + * + * + * @generated + */ + public long getWfid() { + return wfid; + } + + /** + * + * + * @generated + */ + public void setWfid(long newWfid) { + long oldWfid = wfid; + wfid = newWfid; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.WORKFLOW__WFID, oldWfid, wfid)); + } + + /** + * + * + * @generated + */ + public String getUuid() { + return uuid; + } + + /** + * + * + * @generated + */ + public void setUuid(String newUuid) { + String oldUuid = uuid; + uuid = newUuid; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.WORKFLOW__UUID, oldUuid, uuid)); + } + + /** + * + * + * @generated + */ + public String getName() { + return name; + } + + /** + * + * + * @generated + */ + public void setName(String newName) { + String oldName = name; + name = newName; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.WORKFLOW__NAME, oldName, name)); + } + + /** + * + * + * @generated + */ + public Activity getToplevelActivity() { + return toplevelActivity; + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetToplevelActivity(Activity newToplevelActivity, NotificationChain msgs) { + Activity oldToplevelActivity = toplevelActivity; + toplevelActivity = newToplevelActivity; + if (eNotificationRequired()) { + ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, PerftoolPackage.WORKFLOW__TOPLEVEL_ACTIVITY, oldToplevelActivity, newToplevelActivity); + if (msgs == null) msgs = notification; else msgs.add(notification); + } + return msgs; + } + + /** + * + * + * @generated + */ + public void setToplevelActivity(Activity newToplevelActivity) { + if (newToplevelActivity != toplevelActivity) { + NotificationChain msgs = null; + if (toplevelActivity != null) + msgs = ((InternalEObject)toplevelActivity).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - PerftoolPackage.WORKFLOW__TOPLEVEL_ACTIVITY, null, msgs); + if (newToplevelActivity != null) + msgs = ((InternalEObject)newToplevelActivity).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - PerftoolPackage.WORKFLOW__TOPLEVEL_ACTIVITY, null, msgs); + msgs = basicSetToplevelActivity(newToplevelActivity, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.WORKFLOW__TOPLEVEL_ACTIVITY, newToplevelActivity, newToplevelActivity)); + } + + /** + * + * + * @generated + */ + public EList getStatusEvents() { + if (statusEvents == null) { + statusEvents = new EObjectContainmentWithInverseEList(WorkflowStatusEvent.class, this, PerftoolPackage.WORKFLOW__STATUS_EVENTS, PerftoolPackage.WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW); + } + return statusEvents; + } + + /** + * + * + * @generated + */ + public EList getDeviceEvents() { + if (deviceEvents == null) { + deviceEvents = new EObjectContainmentWithInverseEList(DeviceInstanceStatusEvent.class, this, PerftoolPackage.WORKFLOW__DEVICE_EVENTS, PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT__PARENT_WORKFLOW); + } + return deviceEvents; + } + + /** + * + * + * @generated + */ + public EList getComponentEvents() { + if (componentEvents == null) { + componentEvents = new EObjectContainmentWithInverseEList(ComponentStatusEvent.class, this, PerftoolPackage.WORKFLOW__COMPONENT_EVENTS, PerftoolPackage.COMPONENT_STATUS_EVENT__WORKFLOW); + } + return componentEvents; + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.WORKFLOW__STATUS_EVENTS: + return ((InternalEList)(InternalEList)getStatusEvents()).basicAdd(otherEnd, msgs); + case PerftoolPackage.WORKFLOW__DEVICE_EVENTS: + return ((InternalEList)(InternalEList)getDeviceEvents()).basicAdd(otherEnd, msgs); + case PerftoolPackage.WORKFLOW__COMPONENT_EVENTS: + return ((InternalEList)(InternalEList)getComponentEvents()).basicAdd(otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.WORKFLOW__TOPLEVEL_ACTIVITY: + return basicSetToplevelActivity(null, msgs); + case PerftoolPackage.WORKFLOW__STATUS_EVENTS: + return ((InternalEList)getStatusEvents()).basicRemove(otherEnd, msgs); + case PerftoolPackage.WORKFLOW__DEVICE_EVENTS: + return ((InternalEList)getDeviceEvents()).basicRemove(otherEnd, msgs); + case PerftoolPackage.WORKFLOW__COMPONENT_EVENTS: + return ((InternalEList)getComponentEvents()).basicRemove(otherEnd, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PerftoolPackage.WORKFLOW__OID: + return getOid(); + case PerftoolPackage.WORKFLOW__WFID: + return getWfid(); + case PerftoolPackage.WORKFLOW__UUID: + return getUuid(); + case PerftoolPackage.WORKFLOW__NAME: + return getName(); + case PerftoolPackage.WORKFLOW__TOPLEVEL_ACTIVITY: + return getToplevelActivity(); + case PerftoolPackage.WORKFLOW__STATUS_EVENTS: + return getStatusEvents(); + case PerftoolPackage.WORKFLOW__DEVICE_EVENTS: + return getDeviceEvents(); + case PerftoolPackage.WORKFLOW__COMPONENT_EVENTS: + return getComponentEvents(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case PerftoolPackage.WORKFLOW__OID: + setOid((Integer)newValue); + return; + case PerftoolPackage.WORKFLOW__WFID: + setWfid((Long)newValue); + return; + case PerftoolPackage.WORKFLOW__UUID: + setUuid((String)newValue); + return; + case PerftoolPackage.WORKFLOW__NAME: + setName((String)newValue); + return; + case PerftoolPackage.WORKFLOW__TOPLEVEL_ACTIVITY: + setToplevelActivity((Activity)newValue); + return; + case PerftoolPackage.WORKFLOW__STATUS_EVENTS: + getStatusEvents().clear(); + getStatusEvents().addAll((Collection)newValue); + return; + case PerftoolPackage.WORKFLOW__DEVICE_EVENTS: + getDeviceEvents().clear(); + getDeviceEvents().addAll((Collection)newValue); + return; + case PerftoolPackage.WORKFLOW__COMPONENT_EVENTS: + getComponentEvents().clear(); + getComponentEvents().addAll((Collection)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PerftoolPackage.WORKFLOW__OID: + setOid(OID_EDEFAULT); + return; + case PerftoolPackage.WORKFLOW__WFID: + setWfid(WFID_EDEFAULT); + return; + case PerftoolPackage.WORKFLOW__UUID: + setUuid(UUID_EDEFAULT); + return; + case PerftoolPackage.WORKFLOW__NAME: + setName(NAME_EDEFAULT); + return; + case PerftoolPackage.WORKFLOW__TOPLEVEL_ACTIVITY: + setToplevelActivity((Activity)null); + return; + case PerftoolPackage.WORKFLOW__STATUS_EVENTS: + getStatusEvents().clear(); + return; + case PerftoolPackage.WORKFLOW__DEVICE_EVENTS: + getDeviceEvents().clear(); + return; + case PerftoolPackage.WORKFLOW__COMPONENT_EVENTS: + getComponentEvents().clear(); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PerftoolPackage.WORKFLOW__OID: + return oid != OID_EDEFAULT; + case PerftoolPackage.WORKFLOW__WFID: + return wfid != WFID_EDEFAULT; + case PerftoolPackage.WORKFLOW__UUID: + return UUID_EDEFAULT == null ? uuid != null : !UUID_EDEFAULT.equals(uuid); + case PerftoolPackage.WORKFLOW__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + case PerftoolPackage.WORKFLOW__TOPLEVEL_ACTIVITY: + return toplevelActivity != null; + case PerftoolPackage.WORKFLOW__STATUS_EVENTS: + return statusEvents != null && !statusEvents.isEmpty(); + case PerftoolPackage.WORKFLOW__DEVICE_EVENTS: + return deviceEvents != null && !deviceEvents.isEmpty(); + case PerftoolPackage.WORKFLOW__COMPONENT_EVENTS: + return componentEvents != null && !componentEvents.isEmpty(); + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (oid: "); + result.append(oid); + result.append(", wfid: "); + result.append(wfid); + result.append(", uuid: "); + result.append(uuid); + result.append(", name: "); + result.append(name); + result.append(')'); + return result.toString(); + } + +} //WorkflowImpl diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/WorkflowStatusEventImpl.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/WorkflowStatusEventImpl.java new file mode 100755 index 0000000..c76e746 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/impl/WorkflowStatusEventImpl.java @@ -0,0 +1,426 @@ +/** + */ +package at.ac.uibk.wfr.perftool.impl; + +import at.ac.uibk.wfr.perftool.PerftoolPackage; +import at.ac.uibk.wfr.perftool.Workflow; +import at.ac.uibk.wfr.perftool.WorkflowStatusEvent; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.notify.NotificationChain; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.InternalEObject; + +import org.eclipse.emf.ecore.impl.ENotificationImpl; +import org.eclipse.emf.ecore.impl.MinimalEObjectImpl; + +import org.eclipse.emf.ecore.util.EcoreUtil; + +/** + * + * An implementation of the model object 'Workflow Status Event'. + * + *

      + * The following features are implemented: + *

        + *
      • {@link at.ac.uibk.wfr.perftool.impl.WorkflowStatusEventImpl#getOid Oid}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.WorkflowStatusEventImpl#getNewStatus New Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.WorkflowStatusEventImpl#getOldStatus Old Status}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.WorkflowStatusEventImpl#getTimestamp Timestamp}
      • + *
      • {@link at.ac.uibk.wfr.perftool.impl.WorkflowStatusEventImpl#getParentWorkflow Parent Workflow}
      • + *
      + *

      + * + * @generated + */ +public class WorkflowStatusEventImpl extends MinimalEObjectImpl.Container implements WorkflowStatusEvent { + /** + * The default value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected static final int OID_EDEFAULT = 0; + + /** + * The cached value of the '{@link #getOid() Oid}' attribute. + * + * + * @see #getOid() + * @generated + * @ordered + */ + protected int oid = OID_EDEFAULT; + + /** + * The default value of the '{@link #getNewStatus() New Status}' attribute. + * + * + * @see #getNewStatus() + * @generated + * @ordered + */ + protected static final String NEW_STATUS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getNewStatus() New Status}' attribute. + * + * + * @see #getNewStatus() + * @generated + * @ordered + */ + protected String newStatus = NEW_STATUS_EDEFAULT; + + /** + * The default value of the '{@link #getOldStatus() Old Status}' attribute. + * + * + * @see #getOldStatus() + * @generated + * @ordered + */ + protected static final String OLD_STATUS_EDEFAULT = null; + + /** + * The cached value of the '{@link #getOldStatus() Old Status}' attribute. + * + * + * @see #getOldStatus() + * @generated + * @ordered + */ + protected String oldStatus = OLD_STATUS_EDEFAULT; + + /** + * The default value of the '{@link #getTimestamp() Timestamp}' attribute. + * + * + * @see #getTimestamp() + * @generated + * @ordered + */ + protected static final long TIMESTAMP_EDEFAULT = 0L; + + /** + * The cached value of the '{@link #getTimestamp() Timestamp}' attribute. + * + * + * @see #getTimestamp() + * @generated + * @ordered + */ + protected long timestamp = TIMESTAMP_EDEFAULT; + + /** + * + * + * @generated + */ + protected WorkflowStatusEventImpl() { + super(); + } + + /** + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return PerftoolPackage.Literals.WORKFLOW_STATUS_EVENT; + } + + /** + * + * + * @generated + */ + public int getOid() { + return oid; + } + + /** + * + * + * @generated + */ + public void setOid(int newOid) { + int oldOid = oid; + oid = newOid; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.WORKFLOW_STATUS_EVENT__OID, oldOid, oid)); + } + + /** + * + * + * @generated + */ + public String getNewStatus() { + return newStatus; + } + + /** + * + * + * @generated + */ + public void setNewStatus(String newNewStatus) { + String oldNewStatus = newStatus; + newStatus = newNewStatus; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.WORKFLOW_STATUS_EVENT__NEW_STATUS, oldNewStatus, newStatus)); + } + + /** + * + * + * @generated + */ + public String getOldStatus() { + return oldStatus; + } + + /** + * + * + * @generated + */ + public void setOldStatus(String newOldStatus) { + String oldOldStatus = oldStatus; + oldStatus = newOldStatus; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.WORKFLOW_STATUS_EVENT__OLD_STATUS, oldOldStatus, oldStatus)); + } + + /** + * + * + * @generated + */ + public long getTimestamp() { + return timestamp; + } + + /** + * + * + * @generated + */ + public void setTimestamp(long newTimestamp) { + long oldTimestamp = timestamp; + timestamp = newTimestamp; + if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.WORKFLOW_STATUS_EVENT__TIMESTAMP, oldTimestamp, timestamp)); + } + + /** + * + * + * @generated + */ + public Workflow getParentWorkflow() { + if (eContainerFeatureID() != PerftoolPackage.WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW) return null; + return (Workflow)eInternalContainer(); + } + + /** + * + * + * @generated + */ + public NotificationChain basicSetParentWorkflow(Workflow newParentWorkflow, NotificationChain msgs) { + msgs = eBasicSetContainer((InternalEObject)newParentWorkflow, PerftoolPackage.WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW, msgs); + return msgs; + } + + /** + * + * + * @generated + */ + public void setParentWorkflow(Workflow newParentWorkflow) { + if (newParentWorkflow != eInternalContainer() || (eContainerFeatureID() != PerftoolPackage.WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW && newParentWorkflow != null)) { + if (EcoreUtil.isAncestor(this, newParentWorkflow)) + throw new IllegalArgumentException("Recursive containment not allowed for " + toString()); + NotificationChain msgs = null; + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + if (newParentWorkflow != null) + msgs = ((InternalEObject)newParentWorkflow).eInverseAdd(this, PerftoolPackage.WORKFLOW__STATUS_EVENTS, Workflow.class, msgs); + msgs = basicSetParentWorkflow(newParentWorkflow, msgs); + if (msgs != null) msgs.dispatch(); + } + else if (eNotificationRequired()) + eNotify(new ENotificationImpl(this, Notification.SET, PerftoolPackage.WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW, newParentWorkflow, newParentWorkflow)); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseAdd(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW: + if (eInternalContainer() != null) + msgs = eBasicRemoveFromContainer(msgs); + return basicSetParentWorkflow((Workflow)otherEnd, msgs); + } + return super.eInverseAdd(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) { + switch (featureID) { + case PerftoolPackage.WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW: + return basicSetParentWorkflow(null, msgs); + } + return super.eInverseRemove(otherEnd, featureID, msgs); + } + + /** + * + * + * @generated + */ + @Override + public NotificationChain eBasicRemoveFromContainerFeature(NotificationChain msgs) { + switch (eContainerFeatureID()) { + case PerftoolPackage.WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW: + return eInternalContainer().eInverseRemove(this, PerftoolPackage.WORKFLOW__STATUS_EVENTS, Workflow.class, msgs); + } + return super.eBasicRemoveFromContainerFeature(msgs); + } + + /** + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PerftoolPackage.WORKFLOW_STATUS_EVENT__OID: + return getOid(); + case PerftoolPackage.WORKFLOW_STATUS_EVENT__NEW_STATUS: + return getNewStatus(); + case PerftoolPackage.WORKFLOW_STATUS_EVENT__OLD_STATUS: + return getOldStatus(); + case PerftoolPackage.WORKFLOW_STATUS_EVENT__TIMESTAMP: + return getTimestamp(); + case PerftoolPackage.WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW: + return getParentWorkflow(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * @generated + */ + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case PerftoolPackage.WORKFLOW_STATUS_EVENT__OID: + setOid((Integer)newValue); + return; + case PerftoolPackage.WORKFLOW_STATUS_EVENT__NEW_STATUS: + setNewStatus((String)newValue); + return; + case PerftoolPackage.WORKFLOW_STATUS_EVENT__OLD_STATUS: + setOldStatus((String)newValue); + return; + case PerftoolPackage.WORKFLOW_STATUS_EVENT__TIMESTAMP: + setTimestamp((Long)newValue); + return; + case PerftoolPackage.WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW: + setParentWorkflow((Workflow)newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PerftoolPackage.WORKFLOW_STATUS_EVENT__OID: + setOid(OID_EDEFAULT); + return; + case PerftoolPackage.WORKFLOW_STATUS_EVENT__NEW_STATUS: + setNewStatus(NEW_STATUS_EDEFAULT); + return; + case PerftoolPackage.WORKFLOW_STATUS_EVENT__OLD_STATUS: + setOldStatus(OLD_STATUS_EDEFAULT); + return; + case PerftoolPackage.WORKFLOW_STATUS_EVENT__TIMESTAMP: + setTimestamp(TIMESTAMP_EDEFAULT); + return; + case PerftoolPackage.WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW: + setParentWorkflow((Workflow)null); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PerftoolPackage.WORKFLOW_STATUS_EVENT__OID: + return oid != OID_EDEFAULT; + case PerftoolPackage.WORKFLOW_STATUS_EVENT__NEW_STATUS: + return NEW_STATUS_EDEFAULT == null ? newStatus != null : !NEW_STATUS_EDEFAULT.equals(newStatus); + case PerftoolPackage.WORKFLOW_STATUS_EVENT__OLD_STATUS: + return OLD_STATUS_EDEFAULT == null ? oldStatus != null : !OLD_STATUS_EDEFAULT.equals(oldStatus); + case PerftoolPackage.WORKFLOW_STATUS_EVENT__TIMESTAMP: + return timestamp != TIMESTAMP_EDEFAULT; + case PerftoolPackage.WORKFLOW_STATUS_EVENT__PARENT_WORKFLOW: + return getParentWorkflow() != null; + } + return super.eIsSet(featureID); + } + + /** + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) return super.toString(); + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (oid: "); + result.append(oid); + result.append(", newStatus: "); + result.append(newStatus); + result.append(", oldStatus: "); + result.append(oldStatus); + result.append(", timestamp: "); + result.append(timestamp); + result.append(')'); + return result.toString(); + } + +} //WorkflowStatusEventImpl diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/util/PerftoolAdapterFactory.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/util/PerftoolAdapterFactory.java new file mode 100755 index 0000000..5306c3c --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/util/PerftoolAdapterFactory.java @@ -0,0 +1,246 @@ +/** + */ +package at.ac.uibk.wfr.perftool.util; + +import at.ac.uibk.wfr.perftool.*; + +import org.eclipse.emf.common.notify.Adapter; +import org.eclipse.emf.common.notify.Notifier; + +import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl; + +import org.eclipse.emf.ecore.EObject; + +/** + * + * The Adapter Factory for the model. + * It provides an adapter createXXX method for each class of the model. + * + * @see at.ac.uibk.wfr.perftool.PerftoolPackage + * @generated + */ +public class PerftoolAdapterFactory extends AdapterFactoryImpl { + /** + * The cached model package. + * + * + * @generated + */ + protected static PerftoolPackage modelPackage; + + /** + * Creates an instance of the adapter factory. + * + * + * @generated + */ + public PerftoolAdapterFactory() { + if (modelPackage == null) { + modelPackage = PerftoolPackage.eINSTANCE; + } + } + + /** + * Returns whether this factory is applicable for the type of the object. + * + * This implementation returns true if the object is either the model's package or is an instance object of the model. + * + * @return whether this factory is applicable for the type of the object. + * @generated + */ + @Override + public boolean isFactoryForType(Object object) { + if (object == modelPackage) { + return true; + } + if (object instanceof EObject) { + return ((EObject)object).eClass().getEPackage() == modelPackage; + } + return false; + } + + /** + * The switch that delegates to the createXXX methods. + * + * + * @generated + */ + protected PerftoolSwitch modelSwitch = + new PerftoolSwitch() { + @Override + public Adapter caseWorkflow(Workflow object) { + return createWorkflowAdapter(); + } + @Override + public Adapter caseActivity(Activity object) { + return createActivityAdapter(); + } + @Override + public Adapter caseActivityInstance(ActivityInstance object) { + return createActivityInstanceAdapter(); + } + @Override + public Adapter caseWorkflowStatusEvent(WorkflowStatusEvent object) { + return createWorkflowStatusEventAdapter(); + } + @Override + public Adapter caseActivityStatusEvent(ActivityStatusEvent object) { + return createActivityStatusEventAdapter(); + } + @Override + public Adapter caseActivityInstanceStatusEvent(ActivityInstanceStatusEvent object) { + return createActivityInstanceStatusEventAdapter(); + } + @Override + public Adapter caseDeviceInstanceStatusEvent(DeviceInstanceStatusEvent object) { + return createDeviceInstanceStatusEventAdapter(); + } + @Override + public Adapter caseComponentStatusEvent(ComponentStatusEvent object) { + return createComponentStatusEventAdapter(); + } + @Override + public Adapter defaultCase(EObject object) { + return createEObjectAdapter(); + } + }; + + /** + * Creates an adapter for the target. + * + * + * @param target the object to adapt. + * @return the adapter for the target. + * @generated + */ + @Override + public Adapter createAdapter(Notifier target) { + return modelSwitch.doSwitch((EObject)target); + } + + + /** + * Creates a new adapter for an object of class '{@link at.ac.uibk.wfr.perftool.Workflow Workflow}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see at.ac.uibk.wfr.perftool.Workflow + * @generated + */ + public Adapter createWorkflowAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link at.ac.uibk.wfr.perftool.Activity Activity}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see at.ac.uibk.wfr.perftool.Activity + * @generated + */ + public Adapter createActivityAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link at.ac.uibk.wfr.perftool.ActivityInstance Activity Instance}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see at.ac.uibk.wfr.perftool.ActivityInstance + * @generated + */ + public Adapter createActivityInstanceAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent Workflow Status Event}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see at.ac.uibk.wfr.perftool.WorkflowStatusEvent + * @generated + */ + public Adapter createWorkflowStatusEventAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link at.ac.uibk.wfr.perftool.ActivityStatusEvent Activity Status Event}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see at.ac.uibk.wfr.perftool.ActivityStatusEvent + * @generated + */ + public Adapter createActivityStatusEventAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent Activity Instance Status Event}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent + * @generated + */ + public Adapter createActivityInstanceStatusEventAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent Device Instance Status Event}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent + * @generated + */ + public Adapter createDeviceInstanceStatusEventAdapter() { + return null; + } + + /** + * Creates a new adapter for an object of class '{@link at.ac.uibk.wfr.perftool.ComponentStatusEvent Component Status Event}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * @return the new adapter. + * @see at.ac.uibk.wfr.perftool.ComponentStatusEvent + * @generated + */ + public Adapter createComponentStatusEventAdapter() { + return null; + } + + /** + * Creates a new adapter for the default case. + * + * This default implementation returns null. + * + * @return the new adapter. + * @generated + */ + public Adapter createEObjectAdapter() { + return null; + } + +} //PerftoolAdapterFactory diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/util/PerftoolSwitch.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/util/PerftoolSwitch.java new file mode 100755 index 0000000..43b6c12 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/util/PerftoolSwitch.java @@ -0,0 +1,257 @@ +/** + */ +package at.ac.uibk.wfr.perftool.util; + +import at.ac.uibk.wfr.perftool.*; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.EPackage; + +import org.eclipse.emf.ecore.util.Switch; + +/** + * + * The Switch for the model's inheritance hierarchy. + * It supports the call {@link #doSwitch(EObject) doSwitch(object)} + * to invoke the caseXXX method for each class of the model, + * starting with the actual class of the object + * and proceeding up the inheritance hierarchy + * until a non-null result is returned, + * which is the result of the switch. + * + * @see at.ac.uibk.wfr.perftool.PerftoolPackage + * @generated + */ +public class PerftoolSwitch extends Switch { + /** + * The cached model package + * + * + * @generated + */ + protected static PerftoolPackage modelPackage; + + /** + * Creates an instance of the switch. + * + * + * @generated + */ + public PerftoolSwitch() { + if (modelPackage == null) { + modelPackage = PerftoolPackage.eINSTANCE; + } + } + + /** + * Checks whether this is a switch for the given package. + * + * + * @parameter ePackage the package in question. + * @return whether this is a switch for the given package. + * @generated + */ + @Override + protected boolean isSwitchFor(EPackage ePackage) { + return ePackage == modelPackage; + } + + /** + * Calls caseXXX for each class of the model until one returns a non null result; it yields that result. + * + * + * @return the first non-null result returned by a caseXXX call. + * @generated + */ + @Override + protected T doSwitch(int classifierID, EObject theEObject) { + switch (classifierID) { + case PerftoolPackage.WORKFLOW: { + Workflow workflow = (Workflow)theEObject; + T result = caseWorkflow(workflow); + if (result == null) result = defaultCase(theEObject); + return result; + } + case PerftoolPackage.ACTIVITY: { + Activity activity = (Activity)theEObject; + T result = caseActivity(activity); + if (result == null) result = defaultCase(theEObject); + return result; + } + case PerftoolPackage.ACTIVITY_INSTANCE: { + ActivityInstance activityInstance = (ActivityInstance)theEObject; + T result = caseActivityInstance(activityInstance); + if (result == null) result = defaultCase(theEObject); + return result; + } + case PerftoolPackage.WORKFLOW_STATUS_EVENT: { + WorkflowStatusEvent workflowStatusEvent = (WorkflowStatusEvent)theEObject; + T result = caseWorkflowStatusEvent(workflowStatusEvent); + if (result == null) result = defaultCase(theEObject); + return result; + } + case PerftoolPackage.ACTIVITY_STATUS_EVENT: { + ActivityStatusEvent activityStatusEvent = (ActivityStatusEvent)theEObject; + T result = caseActivityStatusEvent(activityStatusEvent); + if (result == null) result = defaultCase(theEObject); + return result; + } + case PerftoolPackage.ACTIVITY_INSTANCE_STATUS_EVENT: { + ActivityInstanceStatusEvent activityInstanceStatusEvent = (ActivityInstanceStatusEvent)theEObject; + T result = caseActivityInstanceStatusEvent(activityInstanceStatusEvent); + if (result == null) result = defaultCase(theEObject); + return result; + } + case PerftoolPackage.DEVICE_INSTANCE_STATUS_EVENT: { + DeviceInstanceStatusEvent deviceInstanceStatusEvent = (DeviceInstanceStatusEvent)theEObject; + T result = caseDeviceInstanceStatusEvent(deviceInstanceStatusEvent); + if (result == null) result = defaultCase(theEObject); + return result; + } + case PerftoolPackage.COMPONENT_STATUS_EVENT: { + ComponentStatusEvent componentStatusEvent = (ComponentStatusEvent)theEObject; + T result = caseComponentStatusEvent(componentStatusEvent); + if (result == null) result = defaultCase(theEObject); + return result; + } + default: return defaultCase(theEObject); + } + } + + /** + * Returns the result of interpreting the object as an instance of 'Workflow'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Workflow'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseWorkflow(Workflow object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Activity'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Activity'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseActivity(Activity object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Activity Instance'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Activity Instance'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseActivityInstance(ActivityInstance object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Workflow Status Event'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Workflow Status Event'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseWorkflowStatusEvent(WorkflowStatusEvent object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Activity Status Event'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Activity Status Event'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseActivityStatusEvent(ActivityStatusEvent object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Activity Instance Status Event'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Activity Instance Status Event'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseActivityInstanceStatusEvent(ActivityInstanceStatusEvent object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Device Instance Status Event'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Device Instance Status Event'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseDeviceInstanceStatusEvent(DeviceInstanceStatusEvent object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'Component Status Event'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'Component Status Event'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseComponentStatusEvent(ComponentStatusEvent object) { + return null; + } + + /** + * Returns the result of interpreting the object as an instance of 'EObject'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch, but this is the last case anyway. + * + * @param object the target of the switch. + * @return the result of interpreting the object as an instance of 'EObject'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) + * @generated + */ + @Override + public T defaultCase(EObject object) { + return null; + } + +} //PerftoolSwitch diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ActivityInstanceStatusEventValidator.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ActivityInstanceStatusEventValidator.java new file mode 100755 index 0000000..f9e38de --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ActivityInstanceStatusEventValidator.java @@ -0,0 +1,25 @@ +/** + * + * $Id$ + */ +package at.ac.uibk.wfr.perftool.validation; + +import at.ac.uibk.wfr.perftool.ActivityInstance; + +/** + * A sample validator interface for {@link at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent}. + * This doesn't really do anything, and it's not a real EMF artifact. + * It was generated by the org.eclipse.emf.examples.generator.validator plug-in to illustrate how EMF's code generator can be extended. + * This can be disabled with -vmargs -Dorg.eclipse.emf.examples.generator.validator=false. + */ +public interface ActivityInstanceStatusEventValidator { + boolean validate(); + + boolean validateOid(int value); + boolean validateNewStatus(String value); + boolean validateOldStatus(String value); + boolean validateTimestamp(long value); + + boolean validateTimestamp(int value); + boolean validateParentInstance(ActivityInstance value); +} diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ActivityInstanceValidator.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ActivityInstanceValidator.java new file mode 100755 index 0000000..29058e6 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ActivityInstanceValidator.java @@ -0,0 +1,34 @@ +/** + * + * $Id$ + */ +package at.ac.uibk.wfr.perftool.validation; + +import at.ac.uibk.wfr.perftool.Activity; +import at.ac.uibk.wfr.perftool.ActivityInstance; +import at.ac.uibk.wfr.perftool.ActivityInstanceStatusEvent; +import at.ac.uibk.wfr.perftool.Workflow; +import org.eclipse.emf.common.util.EList; + +/** + * A sample validator interface for {@link at.ac.uibk.wfr.perftool.ActivityInstance}. + * This doesn't really do anything, and it's not a real EMF artifact. + * It was generated by the org.eclipse.emf.examples.generator.validator plug-in to illustrate how EMF's code generator can be extended. + * This can be disabled with -vmargs -Dorg.eclipse.emf.examples.generator.validator=false. + */ +public interface ActivityInstanceValidator { + boolean validate(); + + boolean validateOid(int value); + boolean validateInstid(long value); + + boolean validateIterationID(long value); + + boolean validateInstid(int value); + boolean validateIterationID(int value); + boolean validateBaseActivity(Activity value); + boolean validateParentWorkflow(Workflow value); + boolean validateParentInstance(ActivityInstance value); + + boolean validateStatusEvents(EList value); +} diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ActivityStatusEventValidator.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ActivityStatusEventValidator.java new file mode 100755 index 0000000..1f4c70a --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ActivityStatusEventValidator.java @@ -0,0 +1,25 @@ +/** + * + * $Id$ + */ +package at.ac.uibk.wfr.perftool.validation; + +import at.ac.uibk.wfr.perftool.Activity; + +/** + * A sample validator interface for {@link at.ac.uibk.wfr.perftool.ActivityStatusEvent}. + * This doesn't really do anything, and it's not a real EMF artifact. + * It was generated by the org.eclipse.emf.examples.generator.validator plug-in to illustrate how EMF's code generator can be extended. + * This can be disabled with -vmargs -Dorg.eclipse.emf.examples.generator.validator=false. + */ +public interface ActivityStatusEventValidator { + boolean validate(); + + boolean validateOid(int value); + boolean validateNewStatus(String value); + boolean validateOldStatus(String value); + boolean validateTimestamp(long value); + + boolean validateTimestamp(int value); + boolean validateParentActivity(Activity value); +} diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ActivityValidator.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ActivityValidator.java new file mode 100755 index 0000000..694e924 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ActivityValidator.java @@ -0,0 +1,40 @@ +/** + * + * $Id$ + */ +package at.ac.uibk.wfr.perftool.validation; + +import at.ac.uibk.wfr.perftool.Activity; +import at.ac.uibk.wfr.perftool.ActivityInstance; +import at.ac.uibk.wfr.perftool.ActivityStatusEvent; +import at.ac.uibk.wfr.perftool.Workflow; +import org.eclipse.emf.common.util.EList; + +/** + * A sample validator interface for {@link at.ac.uibk.wfr.perftool.Activity}. + * This doesn't really do anything, and it's not a real EMF artifact. + * It was generated by the org.eclipse.emf.examples.generator.validator plug-in to illustrate how EMF's code generator can be extended. + * This can be disabled with -vmargs -Dorg.eclipse.emf.examples.generator.validator=false. + */ +public interface ActivityValidator { + boolean validate(); + + boolean validateOid(int value); + boolean validateActid(long value); + + boolean validateActid(int value); + boolean validateName(String value); + boolean validateType(String value); + boolean validateBranchID(long value); + + boolean validateBranchID(int value); + boolean validateParentWorkflow(Workflow value); + + boolean validateInstances(EList value); + + boolean validateStatusEvents(EList value); + + boolean validateParent(Activity value); + + boolean validateChildren(EList value); +} diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ComponentStatusEventValidator.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ComponentStatusEventValidator.java new file mode 100755 index 0000000..0fb400a --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/ComponentStatusEventValidator.java @@ -0,0 +1,26 @@ +/** + * + * $Id$ + */ +package at.ac.uibk.wfr.perftool.validation; + +import at.ac.uibk.wfr.perftool.Workflow; + +/** + * A sample validator interface for {@link at.ac.uibk.wfr.perftool.ComponentStatusEvent}. + * This doesn't really do anything, and it's not a real EMF artifact. + * It was generated by the org.eclipse.emf.examples.generator.validator plug-in to illustrate how EMF's code generator can be extended. + * This can be disabled with -vmargs -Dorg.eclipse.emf.examples.generator.validator=false. + */ +public interface ComponentStatusEventValidator { + boolean validate(); + + boolean validateOid(int value); + boolean validateComponentType(String value); + boolean validateNewStatus(String value); + boolean validateOldStatus(String value); + boolean validateTimestamp(long value); + + boolean validateTimestamp(int value); + boolean validateWorkflow(Workflow value); +} diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/DeviceInstanceStatusEventValidator.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/DeviceInstanceStatusEventValidator.java new file mode 100755 index 0000000..5d3e7dc --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/DeviceInstanceStatusEventValidator.java @@ -0,0 +1,40 @@ +/** + * + * $Id$ + */ +package at.ac.uibk.wfr.perftool.validation; + +import at.ac.uibk.wfr.perftool.ActivityInstance; +import at.ac.uibk.wfr.perftool.Workflow; + +/** + * A sample validator interface for {@link at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent}. + * This doesn't really do anything, and it's not a real EMF artifact. + * It was generated by the org.eclipse.emf.examples.generator.validator plug-in to illustrate how EMF's code generator can be extended. + * This can be disabled with -vmargs -Dorg.eclipse.emf.examples.generator.validator=false. + */ +public interface DeviceInstanceStatusEventValidator { + boolean validate(); + + boolean validateOid(int value); + boolean validateDeviceType(String value); + boolean validateDeviceID(long value); + + boolean validateDeviceID(int value); + boolean validateNewStatus(String value); + boolean validateOldStatus(String value); + boolean validateTimestamp(long value); + + boolean validateExecutedImplID(long value); + + boolean validateDeviceSlotCount(long value); + + boolean validateTimestamp(int value); + boolean validateExecutedImplID(int value); + boolean validateDeviceSlotCount(int value); + + boolean validateDevicesSlotCount(int value); + boolean validateParentWorkflow(Workflow value); + + boolean validateExecutedInstance(ActivityInstance value); +} diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/WorkflowStatusEventValidator.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/WorkflowStatusEventValidator.java new file mode 100755 index 0000000..7181923 --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/WorkflowStatusEventValidator.java @@ -0,0 +1,25 @@ +/** + * + * $Id$ + */ +package at.ac.uibk.wfr.perftool.validation; + +import at.ac.uibk.wfr.perftool.Workflow; + +/** + * A sample validator interface for {@link at.ac.uibk.wfr.perftool.WorkflowStatusEvent}. + * This doesn't really do anything, and it's not a real EMF artifact. + * It was generated by the org.eclipse.emf.examples.generator.validator plug-in to illustrate how EMF's code generator can be extended. + * This can be disabled with -vmargs -Dorg.eclipse.emf.examples.generator.validator=false. + */ +public interface WorkflowStatusEventValidator { + boolean validate(); + + boolean validateOid(int value); + boolean validateNewStatus(String value); + boolean validateOldStatus(String value); + boolean validateTimestamp(int value); + + boolean validateTimestamp(long value); + boolean validateParentWorkflow(Workflow value); +} diff --git a/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/WorkflowValidator.java b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/WorkflowValidator.java new file mode 100755 index 0000000..fa8e20a --- /dev/null +++ b/WFRperfTool/src/at/ac/uibk/wfr/perftool/validation/WorkflowValidator.java @@ -0,0 +1,37 @@ +/** + * + * $Id$ + */ +package at.ac.uibk.wfr.perftool.validation; + +import at.ac.uibk.wfr.perftool.Activity; + +import at.ac.uibk.wfr.perftool.ComponentStatusEvent; +import at.ac.uibk.wfr.perftool.DeviceInstanceStatusEvent; +import at.ac.uibk.wfr.perftool.WorkflowStatusEvent; +import org.eclipse.emf.common.util.EList; + +/** + * A sample validator interface for {@link at.ac.uibk.wfr.perftool.Workflow}. + * This doesn't really do anything, and it's not a real EMF artifact. + * It was generated by the org.eclipse.emf.examples.generator.validator plug-in to illustrate how EMF's code generator can be extended. + * This can be disabled with -vmargs -Dorg.eclipse.emf.examples.generator.validator=false. + */ +public interface WorkflowValidator { + boolean validate(); + + boolean validateOid(int value); + boolean validateWfid(long value); + + boolean validateWfid(int value); + boolean validateUuid(String value); + boolean validateName(String value); + boolean validateActivities(EList value); + boolean validateToplevelActivity(Activity value); + + boolean validateStatusEvents(EList value); + + boolean validateDeviceEvents(EList value); + + boolean validateComponentEvents(EList value); +} diff --git a/WFRperfTool/src/perftoolutils/DBCreator.java b/WFRperfTool/src/perftoolutils/DBCreator.java new file mode 100755 index 0000000..e84c342 --- /dev/null +++ b/WFRperfTool/src/perftoolutils/DBCreator.java @@ -0,0 +1,52 @@ +package perftoolutils; + +import java.io.IOException; +import java.io.InputStream; +import java.util.Properties; + +import org.eclipse.emf.ecore.EPackage; +import org.eclipse.emf.teneo.extension.ExtensionManager; +import org.eclipse.emf.teneo.hibernate.HbDataStore; +import org.eclipse.emf.teneo.hibernate.HbHelper; +import org.eclipse.emf.teneo.mapping.strategy.SQLNameStrategy; +import org.hibernate.cfg.Configuration; + +import at.ac.uibk.wfr.perftool.PerftoolPackage; + +public class DBCreator { + + /** + * @param args + */ + public static void main(String[] args) { + + InputStream propsIn = DBCreator.class.getResourceAsStream("teneo.properties"); + Properties props = new Properties(); + try { + props.load(propsIn); + } catch (IOException e) { + e.printStackTrace(); + } + + //*************** Initialize Teneo Hibernate DataStore ************************************* + HbDataStore hbds = (HbDataStore) HbHelper.INSTANCE.createRegisterDataStore("perfdb"); + final ExtensionManager extensionManager = hbds.getExtensionManager(); + extensionManager.registerExtension(SQLNameStrategy.class.getName(), MySQLNameStrategy.class.getName()); + hbds.setDataStoreProperties(props); + hbds.setEPackages(new EPackage[] { PerftoolPackage.eINSTANCE }); //Register EMF package + hbds.initialize(); + + System.out.println("\nHibernate Mapping XML:\n============================"); + Configuration hconf = hbds.getHibernateConfiguration(); + System.out.println(hbds.getMappingXML()); + System.out.println("============================"); + + System.out.println("\nDatabase Create Script:\n============================"); + for (String s : hconf.generateSchemaCreationScript(org.hibernate.dialect.Dialect.getDialect(props))) { + System.out.println(s); + } + System.out.println("============================"); + + } + +} diff --git a/WFRperfTool/src/perftoolutils/MySQLNameStrategy.java b/WFRperfTool/src/perftoolutils/MySQLNameStrategy.java new file mode 100755 index 0000000..3586bfa --- /dev/null +++ b/WFRperfTool/src/perftoolutils/MySQLNameStrategy.java @@ -0,0 +1,9 @@ +package perftoolutils; + +import org.eclipse.emf.teneo.mapping.strategy.impl.TeneoSQLNameStrategy; + +public class MySQLNameStrategy extends TeneoSQLNameStrategy { + + + +} diff --git a/WFRperfTool/src/perftoolutils/SQLiteDialect.java b/WFRperfTool/src/perftoolutils/SQLiteDialect.java new file mode 100755 index 0000000..2083c52 --- /dev/null +++ b/WFRperfTool/src/perftoolutils/SQLiteDialect.java @@ -0,0 +1,223 @@ +package perftoolutils; + +/* + * The author disclaims copyright to this source code. In place of + * a legal notice, here is a blessing: + * + * May you do good and not evil. + * May you find forgiveness for yourself and forgive others. + * May you share freely, never taking more than you give. + * + */ + +import java.sql.Types; +import org.hibernate.dialect.Dialect; + +import org.hibernate.dialect.function.AbstractAnsiTrimEmulationFunction; +import org.hibernate.dialect.function.NoArgSQLFunction; +import org.hibernate.dialect.function.SQLFunction; +import org.hibernate.dialect.function.SQLFunctionTemplate; +import org.hibernate.dialect.function.StandardSQLFunction; +import org.hibernate.dialect.function.VarArgsSQLFunction; +import org.hibernate.type.StandardBasicTypes; + +public class SQLiteDialect extends Dialect { + public SQLiteDialect() { + registerColumnType(Types.BIT, "boolean"); + registerColumnType(Types.TINYINT, "tinyint"); + registerColumnType(Types.SMALLINT, "smallint"); + registerColumnType(Types.INTEGER, "integer"); + registerColumnType(Types.BIGINT, "bigint"); + registerColumnType(Types.FLOAT, "float"); + registerColumnType(Types.REAL, "real"); + registerColumnType(Types.DOUBLE, "double"); + registerColumnType(Types.NUMERIC, "numeric($p, $s)"); + registerColumnType(Types.DECIMAL, "decimal"); + registerColumnType(Types.CHAR, "char"); + registerColumnType(Types.VARCHAR, "varchar($l)"); + registerColumnType(Types.LONGVARCHAR, "longvarchar"); + registerColumnType(Types.DATE, "date"); + registerColumnType(Types.TIME, "time"); + registerColumnType(Types.TIMESTAMP, "datetime"); + registerColumnType(Types.BINARY, "blob"); + registerColumnType(Types.VARBINARY, "blob"); + registerColumnType(Types.LONGVARBINARY, "blob"); + registerColumnType(Types.BLOB, "blob"); + registerColumnType(Types.CLOB, "clob"); + registerColumnType(Types.BOOLEAN, "boolean"); + + //registerFunction( "abs", new StandardSQLFunction("abs") ); + registerFunction( "concat", new VarArgsSQLFunction(StandardBasicTypes.STRING, "", "||", "") ); + //registerFunction( "length", new StandardSQLFunction("length", StandardBasicTypes.LONG) ); + //registerFunction( "lower", new StandardSQLFunction("lower") ); + registerFunction( "mod", new SQLFunctionTemplate(StandardBasicTypes.INTEGER, "?1 % ?2" ) ); + registerFunction( "quote", new StandardSQLFunction("quote", StandardBasicTypes.STRING) ); + registerFunction( "random", new NoArgSQLFunction("random", StandardBasicTypes.INTEGER) ); + registerFunction( "round", new StandardSQLFunction("round") ); + registerFunction( "substr", new StandardSQLFunction("substr", StandardBasicTypes.STRING) ); + registerFunction( "substring", new SQLFunctionTemplate( StandardBasicTypes.STRING, "substr(?1, ?2, ?3)" ) ); + registerFunction( "trim", new AbstractAnsiTrimEmulationFunction() { + protected SQLFunction resolveBothSpaceTrimFunction() { + return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1)"); + } + + protected SQLFunction resolveBothSpaceTrimFromFunction() { + return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?2)"); + } + + protected SQLFunction resolveLeadingSpaceTrimFunction() { + return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1)"); + } + + protected SQLFunction resolveTrailingSpaceTrimFunction() { + return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1)"); + } + + protected SQLFunction resolveBothTrimFunction() { + return new SQLFunctionTemplate(StandardBasicTypes.STRING, "trim(?1, ?2)"); + } + + protected SQLFunction resolveLeadingTrimFunction() { + return new SQLFunctionTemplate(StandardBasicTypes.STRING, "ltrim(?1, ?2)"); + } + + protected SQLFunction resolveTrailingTrimFunction() { + return new SQLFunctionTemplate(StandardBasicTypes.STRING, "rtrim(?1, ?2)"); + } + } ); + //registerFunction( "upper", new StandardSQLFunction("upper") ); + } + + public boolean supportsIdentityColumns() { + return true; + } + + /* + public boolean supportsInsertSelectIdentity() { + return true; // As specify in NHibernate dialect + } + */ + + public boolean hasDataTypeInIdentityColumn() { + return false; // As specify in NHibernate dialect + } + + /* + public String appendIdentitySelectToInsert(String insertString) { + return new StringBuffer(insertString.length()+30). // As specify in NHibernate dialect + append(insertString). + append("; ").append(getIdentitySelectString()). + toString(); + } + */ + + public String getIdentityColumnString() { + // return "integer primary key autoincrement"; + return "integer"; + } + + public String getIdentitySelectString() { + return "select last_insert_rowid()"; + } + + public boolean supportsLimit() { + return true; + } + + public boolean bindLimitParametersInReverseOrder() { + return true; + } + + protected String getLimitString(String query, boolean hasOffset) { + return new StringBuffer(query.length()+20). + append(query). + append(hasOffset ? " limit ? offset ?" : " limit ?"). + toString(); + } + + public boolean supportsTemporaryTables() { + return true; + } + + public String getCreateTemporaryTableString() { + return "create temporary table if not exists"; + } + + public boolean dropTemporaryTableAfterUse() { + return true; // TODO Validate + } + + public boolean supportsCurrentTimestampSelection() { + return true; + } + + public boolean isCurrentTimestampSelectStringCallable() { + return false; + } + + public String getCurrentTimestampSelectString() { + return "select current_timestamp"; + } + + public boolean supportsUnionAll() { + return true; + } + + public boolean hasAlterTable() { + return false; // As specify in NHibernate dialect + } + + public boolean dropConstraints() { + return false; + } + + /* + public String getAddColumnString() { + return "add column"; + } + */ + + public String getForUpdateString() { + return ""; + } + + public boolean supportsOuterJoinForUpdate() { + return false; + } + + public String getDropForeignKeyString() { + throw new UnsupportedOperationException("No drop foreign key syntax supported by SQLiteDialect"); + } + + public String getAddForeignKeyConstraintString(String constraintName, + String[] foreignKey, String referencedTable, String[] primaryKey, + boolean referencesPrimaryKey) { + throw new UnsupportedOperationException("No add foreign key syntax supported by SQLiteDialect"); + } + + public String getAddPrimaryKeyConstraintString(String constraintName) { + throw new UnsupportedOperationException("No add primary key syntax supported by SQLiteDialect"); + } + + public boolean supportsIfExistsBeforeTableName() { + return true; + } + + public boolean supportsCascadeDelete() { + return true; + } + + /* not case insensitive for unicode characters by default (ICU extension needed) + public boolean supportsCaseInsensitiveLike() { + return true; + } + */ + + public boolean supportsTupleDistinctCounts() { + return false; + } + + public String getSelectGUIDString() { + return "select hex(randomblob(16))"; + } +} \ No newline at end of file diff --git a/WFRperfTool/src/perftoolutils/teneo.properties b/WFRperfTool/src/perftoolutils/teneo.properties new file mode 100755 index 0000000..a254519 --- /dev/null +++ b/WFRperfTool/src/perftoolutils/teneo.properties @@ -0,0 +1,29 @@ + ## Debug Settings +hibernate.show_sql=true +hibernate.format_sql=true +hibernate.use_sql_comments=true + +hibernate.connection.driver_class=org.sqlite.JDBC + +hibernate.connection.url=jdbc\:sqlite\:default.sqlite + +## Database Creation Mode (validate | update | create | create-drop) +hibernate.hbm2ddl.auto=validate + +hibernate.dialect=perftoolutils.SQLiteDialect + +teneo.naming.join_column_naming_strategy=simple + +## Teneo Settings +teneo.mapping.disable_econtainer=true +teneo.mapping.always_version=false +teneo.mapping.inheritance=JOINED +teneo.naming.sql_fk_name_prefix=fk_ +teneo.naming.set_foreign_key_name=true +hibernate.jdbc.batch_size=30 + +## Teneo Cache Settings +#hibernate.cache.use_second_level_cache=false +#hibernate.cache.use_query_cache=false +#teneo.mapping.default_cache_strategy=NONE +#hibernate.cache.region.factory_class=org.hibernate.cache.ehcache.EhCacheRegionFactory \ No newline at end of file diff --git a/WFRperfTool/text/description.txt b/WFRperfTool/text/description.txt new file mode 100755 index 0000000..c6e5699 --- /dev/null +++ b/WFRperfTool/text/description.txt @@ -0,0 +1,80 @@ +Model WFRperfToolModel + +This model description is not a real EMF artifact. It was generated by the +org.eclipse.emf.examples.generator.validator plug-in to illustrate how EMF's +code generator can be extended. +This can be disabled with -vmargs -Dorg.eclipse.emf.examples.generator.validator=false. + +Package perftool + + Class Workflow + Attribute oid : EInt<<1..1>> + Attribute wfid : ELong<<1..1>> + Attribute uuid : EString<<1..1>> + Attribute name : EString<<1..1>> + Reference toplevelActivity : Activity + Reference statusEvents : WorkflowStatusEvent<<0..*>> + Reference deviceEvents : DeviceInstanceStatusEvent<<0..*>> + Reference componentEvents : ComponentStatusEvent<<0..*>> + + Class Activity + Attribute oid : EInt<<1..1>> + Attribute actid : ELong<<1..1>> + Attribute name : EString<<1..1>> + Attribute type : EString<<1..1>> + Attribute branchID : ELong<<1..1>> + Reference parentWorkflow : Workflow<<1..1>> + Reference instances : ActivityInstance<<0..*>> + Reference statusEvents : ActivityStatusEvent<<0..*>> + Reference parent : Activity + Reference children : Activity<<0..*>> + + Class ActivityInstance + Attribute oid : EInt<<1..1>> + Attribute instid : ELong<<1..1>> + Attribute iterationID : ELong<<1..1>> + Reference baseActivity : Activity<<1..1>> + Reference parentWorkflow : Workflow + Reference parentInstance : ActivityInstance + Reference statusEvents : ActivityInstanceStatusEvent<<0..*>> + + Class WorkflowStatusEvent + Attribute oid : EInt<<1..1>> + Attribute newStatus : EString<<1..1>> + Attribute oldStatus : EString<<1..1>> + Attribute timestamp : ELong<<1..1>> + Reference parentWorkflow : Workflow<<1..1>> + + Class ActivityStatusEvent + Attribute oid : EInt<<1..1>> + Attribute newStatus : EString<<1..1>> + Attribute oldStatus : EString<<1..1>> + Attribute timestamp : ELong<<1..1>> + Reference parentActivity : Activity<<1..1>> + + Class ActivityInstanceStatusEvent + Attribute oid : EInt<<1..1>> + Attribute newStatus : EString<<1..1>> + Attribute oldStatus : EString<<1..1>> + Attribute timestamp : ELong<<1..1>> + Reference parentInstance : ActivityInstance<<1..1>> + + Class DeviceInstanceStatusEvent + Attribute oid : EInt<<1..1>> + Attribute deviceType : EString<<1..1>> + Attribute deviceID : ELong<<1..1>> + Attribute newStatus : EString<<1..1>> + Attribute oldStatus : EString<<1..1>> + Attribute timestamp : ELong<<1..1>> + Attribute executedImplID : ELong<<1..1>> + Attribute deviceSlotCount : ELong<<1..1>> + Reference parentWorkflow : Workflow + Reference executedInstance : ActivityInstance + + Class ComponentStatusEvent + Attribute oid : EInt<<1..1>> + Attribute componentType : EString<<1..1>> + Attribute newStatus : EString<<1..1>> + Attribute oldStatus : EString<<1..1>> + Attribute timestamp : ELong<<1..1>> + Reference workflow : Workflow